Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

typal

Package Overview
Dependencies
Maintainers
1
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typal - npm Package Compare versions

Comparing version 1.27.1 to 2.0.0

161

CHANGELOG.md

@@ -0,1 +1,8 @@

## 16 April 2020
### [2.0.0](https://gitlab.com/artdeco/typal/compare/v1.27.1...v2.0.0)
- [feature] Generate interfaces for templates.
- [package] Publish compiled code only with source under `typal@src` branch.
## 12 April 2020

@@ -18,7 +25,7 @@

### [1.26.2](https://github.com/artdecocode/typal/compare/v1.26.1...v1.26.2)
### [1.26.2](https://gitlab.com/artdeco/typal/compare/v1.26.1...v1.26.2)
- [fix] Try to fix EOLs.
### [1.26.1](https://github.com/artdecocode/typal/compare/v1.26.0...v1.26.1)
### [1.26.1](https://gitlab.com/artdeco/typal/compare/v1.26.0...v1.26.1)

@@ -29,7 +36,7 @@ - [fix] Upgrade `makePromise`.

### [1.26.0](https://github.com/artdecocode/typal/compare/v1.25.1...v1.26.0)
### [1.26.0](https://gitlab.com/artdeco/typal/compare/v1.25.1...v1.26.0)
- [license] Change to AGPL.
### [1.25.1](https://github.com/artdecocode/typal/compare/v1.25.0...v1.25.1)
### [1.25.1](https://gitlab.com/artdeco/typal/compare/v1.25.0...v1.25.1)

@@ -40,3 +47,3 @@ - [feature] Support `no-embed` attribute and inherit attributes for embedding.

### [1.25.0](https://github.com/artdecocode/typal/compare/v1.24.20...v1.25.0)
### [1.25.0](https://gitlab.com/artdeco/typal/compare/v1.24.20...v1.25.0)

@@ -47,3 +54,3 @@ - [feature] Add `<embed>` element to the schema.

### [1.24.20](https://github.com/artdecocode/typal/compare/v1.24.19...v1.24.20)
### [1.24.20](https://gitlab.com/artdeco/typal/compare/v1.24.19...v1.24.20)

@@ -54,7 +61,7 @@ - [fix] Fix the typedef order of extended types (nominal comes first).

### [1.24.19](https://github.com/artdecocode/typal/compare/v1.24.18...v1.24.19)
### [1.24.19](https://gitlab.com/artdeco/typal/compare/v1.24.18...v1.24.19)
- [fix] Fix how constructors are parsed and serialised.
### [1.24.18](https://github.com/artdecocode/typal/compare/v1.24.17...v1.24.18)
### [1.24.18](https://gitlab.com/artdeco/typal/compare/v1.24.17...v1.24.18)

@@ -65,3 +72,3 @@ - [fix] Fix the order when flattening.

### [1.24.17](https://github.com/artdecocode/typal/compare/v1.24.16...v1.24.17)
### [1.24.17](https://gitlab.com/artdeco/typal/compare/v1.24.16...v1.24.17)

@@ -71,3 +78,3 @@ - [feature] Read `<record>` tags.

### [1.24.16](https://github.com/artdecocode/typal/compare/v1.24.15...v1.24.16)
### [1.24.16](https://gitlab.com/artdeco/typal/compare/v1.24.15...v1.24.16)

@@ -79,3 +86,3 @@ - [fix] Run `nameProcess` on the extends type.

### [1.24.15](https://github.com/artdecocode/typal/compare/v1.24.14...v1.24.15)
### [1.24.15](https://gitlab.com/artdeco/typal/compare/v1.24.14...v1.24.15)

@@ -87,39 +94,39 @@ - [feature] Add the `return` property to the _Property_.

### [1.24.14](https://github.com/artdecocode/typal/compare/v1.24.13...v1.24.14)
### [1.24.14](https://gitlab.com/artdeco/typal/compare/v1.24.13...v1.24.14)
- [feature] Arguments for interfaces/constructors in externs.
### [1.24.13](https://github.com/artdecocode/typal/compare/v1.24.12...v1.24.13)
### [1.24.13](https://gitlab.com/artdeco/typal/compare/v1.24.12...v1.24.13)
- [feature] Template no return.
### [1.24.12](https://github.com/artdecocode/typal/compare/v1.24.11...v1.24.12)
### [1.24.12](https://gitlab.com/artdeco/typal/compare/v1.24.11...v1.24.12)
- [fix] Add constructor property on constructors/interfaces even without args.
### [1.24.11](https://github.com/artdecocode/typal/compare/v1.24.10...v1.24.11)
### [1.24.11](https://gitlab.com/artdeco/typal/compare/v1.24.10...v1.24.11)
- [fix] Add location to the template.
### [1.24.10](https://github.com/artdecocode/typal/compare/v1.24.9...v1.24.10)
### [1.24.10](https://gitlab.com/artdeco/typal/compare/v1.24.9...v1.24.10)
- [fix] Fix reading examples for `fns`.
### [1.24.9](https://github.com/artdecocode/typal/compare/v1.24.8...v1.24.9)
### [1.24.9](https://gitlab.com/artdeco/typal/compare/v1.24.8...v1.24.9)
- [fix] Read relative properties' examples.
### [1.24.8](https://github.com/artdecocode/typal/compare/v1.24.7...v1.24.8)
### [1.24.8](https://gitlab.com/artdeco/typal/compare/v1.24.7...v1.24.8)
- [feature] Relative example paths.
### [1.24.7](https://github.com/artdecocode/typal/compare/v1.24.6...v1.24.7)
### [1.24.7](https://gitlab.com/artdeco/typal/compare/v1.24.6...v1.24.7)
- [fix] Fix ordering.
### [1.24.6](https://github.com/artdecocode/typal/compare/v1.24.5...v1.24.6)
### [1.24.6](https://gitlab.com/artdeco/typal/compare/v1.24.5...v1.24.6)
- [fix] Fix examples' indentation.
### [1.24.5](https://github.com/artdecocode/typal/compare/v1.24.4...v1.24.5)
### [1.24.5](https://gitlab.com/artdeco/typal/compare/v1.24.4...v1.24.5)

@@ -130,3 +137,3 @@ - [fix] Add examples to `prop`.

### [1.24.4](https://github.com/artdecocode/typal/compare/v1.24.3...v1.24.4)
### [1.24.4](https://gitlab.com/artdeco/typal/compare/v1.24.3...v1.24.4)

@@ -136,7 +143,7 @@ - [fix] Fix variable arg param names in externs.

### [1.24.3](https://github.com/artdecocode/typal/compare/v1.24.2...v1.24.3)
### [1.24.3](https://gitlab.com/artdeco/typal/compare/v1.24.2...v1.24.3)
- [fix] Variable args names in template.
### [1.24.2](https://github.com/artdecocode/typal/compare/v1.24.1...v1.24.2)
### [1.24.2](https://gitlab.com/artdeco/typal/compare/v1.24.1...v1.24.2)

@@ -147,11 +154,11 @@ - [fix] Fix examples parsing.

### [1.24.1](https://github.com/artdecocode/typal/compare/v1.24.0...v1.24.1)
### [1.24.1](https://gitlab.com/artdeco/typal/compare/v1.24.0...v1.24.1)
- [fix] Pass `examples` to constructor prop.
### [1.24.0](https://github.com/artdecocode/typal/compare/v1.23.2...v1.24.0)
### [1.24.0](https://gitlab.com/artdeco/typal/compare/v1.23.2...v1.24.0)
- [feature] Generate classes in templates.
### [1.23.2](https://github.com/artdecocode/typal/compare/v1.23.1...v1.23.2)
### [1.23.2](https://gitlab.com/artdeco/typal/compare/v1.23.1...v1.23.2)

@@ -162,7 +169,7 @@ - [fix] Add `examples` to Type's externs.

### [1.23.1](https://github.com/artdecocode/typal/compare/v1.23.0...v1.23.1)
### [1.23.1](https://gitlab.com/artdeco/typal/compare/v1.23.0...v1.23.1)
- [fix] Indent templates with multiple lines in descriptions.
### [1.23.0](https://github.com/artdecocode/typal/compare/v1.22.9...v1.23.0)
### [1.23.0](https://gitlab.com/artdeco/typal/compare/v1.22.9...v1.23.0)

@@ -173,3 +180,3 @@ - [feature] Read and embed examples into templates.

### [1.22.9](https://github.com/artdecocode/typal/compare/v1.22.8...v1.22.9)
### [1.22.9](https://gitlab.com/artdeco/typal/compare/v1.22.8...v1.22.9)

@@ -180,3 +187,3 @@ - [feature] Allow to extend multiple supers.

### [1.22.8](https://github.com/artdecocode/typal/compare/v1.22.7...v1.22.8)
### [1.22.8](https://gitlab.com/artdeco/typal/compare/v1.22.7...v1.22.8)

@@ -187,3 +194,3 @@ - [fix] Print methods in externs as typedefs.c

### [1.22.7](https://github.com/artdecocode/typal/compare/v1.22.6...v1.22.7)
### [1.22.7](https://gitlab.com/artdeco/typal/compare/v1.22.6...v1.22.7)

@@ -194,11 +201,11 @@ - [feature] Allows to pass a directory via `-t` for source JSDoc generation.

### [1.22.6](https://github.com/artdecocode/typal/compare/v1.22.5...v1.22.6)
### [1.22.6](https://gitlab.com/artdeco/typal/compare/v1.22.5...v1.22.6)
- [fix] Fix arguments names in function assignment in externs.
### [1.22.5](https://github.com/artdecocode/typal/compare/v1.22.4...v1.22.5)
### [1.22.5](https://gitlab.com/artdeco/typal/compare/v1.22.4...v1.22.5)
- [fix] Fix _JSDoc_ regex to pickup descriptions over multiple lines.
### [1.22.4](https://github.com/artdecocode/typal/compare/v1.22.3...v1.22.4)
### [1.22.4](https://gitlab.com/artdeco/typal/compare/v1.22.3...v1.22.4)

@@ -209,7 +216,7 @@ - [fix] Print `*` in descriptions with new lines in _JSDoc_ rule.

### [1.22.3](https://github.com/artdecocode/typal/compare/v1.22.2...v1.22.3)
### [1.22.3](https://gitlab.com/artdeco/typal/compare/v1.22.2...v1.22.3)
- [fix] Correct `this` args count and allow to print `...custom` var args in typescript types.
### [1.22.2](https://github.com/artdecocode/typal/compare/v1.22.1...v1.22.2)
### [1.22.2](https://gitlab.com/artdeco/typal/compare/v1.22.1...v1.22.2)

@@ -220,3 +227,3 @@ - [fix] Pass `this` and `...args` arguments in _`<fn><arg>`_ correctly.

### [1.22.1](https://github.com/artdecocode/typal/compare/v1.22.0...v1.22.1)
### [1.22.1](https://gitlab.com/artdeco/typal/compare/v1.22.0...v1.22.1)

@@ -227,3 +234,3 @@ - [fix] Pass `useNamespace` via arguments for source (non-closure) _JSDoc_.

### [1.22.0](https://github.com/artdecocode/typal/compare/v1.21.1...v1.22.0)
### [1.22.0](https://gitlab.com/artdeco/typal/compare/v1.21.1...v1.22.0)

@@ -242,7 +249,7 @@ - [refactor] Create a separate class for _Method_ which together with the _Interface_ now extend the _Type_.

### [1.21.1](https://github.com/artdecocode/typal/compare/v1.21.0...v1.21.1)
### [1.21.1](https://gitlab.com/artdeco/typal/compare/v1.21.0...v1.21.1)
- [fix] Fix parsing the _null_ return of functions.
### [1.21.0](https://github.com/artdecocode/typal/compare/v1.20.2...v1.21.0)
### [1.21.0](https://gitlab.com/artdeco/typal/compare/v1.20.2...v1.21.0)

@@ -255,7 +262,7 @@ - [feature] Display VSCode-style types in _README_ documentation.

### [1.20.2](https://github.com/artdecocode/typal/compare/v1.20.1...v1.20.2)
### [1.20.2](https://gitlab.com/artdeco/typal/compare/v1.20.1...v1.20.2)
- [fix] Don't print static methods and properties in typedef.
### [1.20.1](https://github.com/artdecocode/typal/compare/v1.20.0...v1.20.1)
### [1.20.1](https://gitlab.com/artdeco/typal/compare/v1.20.0...v1.20.1)

@@ -266,3 +273,3 @@ - [fix] Don't specify _void_ return in externs.

### [1.20.0](https://github.com/artdecocode/typal/compare/v1.19.2...v1.20.0)
### [1.20.0](https://gitlab.com/artdeco/typal/compare/v1.19.2...v1.20.0)

@@ -280,3 +287,3 @@ - [fix] Respect root namespace in arguments.

### [1.19.2](https://github.com/artdecocode/typal/compare/v1.19.1...v1.19.2)
### [1.19.2](https://gitlab.com/artdeco/typal/compare/v1.19.1...v1.19.2)

@@ -287,7 +294,7 @@ - [deps] Install missing `@wrote/read`.

### [1.19.1](https://github.com/artdecocode/typal/compare/v1.19.0...v1.19.1)
### [1.19.1](https://gitlab.com/artdeco/typal/compare/v1.19.0...v1.19.1)
- [fix] Allow to template constructor methods and properties.
### [1.19.0](https://github.com/artdecocode/typal/compare/v1.18.0...v1.19.0)
### [1.19.0](https://gitlab.com/artdeco/typal/compare/v1.18.0...v1.19.0)

@@ -298,3 +305,3 @@ - [feature] Static methods and interfaces in schema.

### [1.18.0](https://github.com/artdecocode/typal/compare/v1.17.0...v1.18.0)
### [1.18.0](https://gitlab.com/artdeco/typal/compare/v1.17.0...v1.18.0)

@@ -317,3 +324,3 @@ - [feature] Generate source code from template

### [1.17.0](https://github.com/artdecocode/typal/compare/v1.16.0...v1.17.0)
### [1.17.0](https://gitlab.com/artdeco/typal/compare/v1.16.0...v1.17.0)

@@ -324,3 +331,3 @@ - [feature] Allow to write properties as functions.

### [1.16.0](https://github.com/artdecocode/typal/compare/v1.15.3...v1.16.0)
### [1.16.0](https://gitlab.com/artdeco/typal/compare/v1.15.3...v1.16.0)

@@ -337,3 +344,3 @@ - [fix] Indent new lines in JSDoc descriptions with `*`.

### [1.15.3](https://github.com/artdecocode/typal/compare/v1.15.2...v1.15.3)
### [1.15.3](https://gitlab.com/artdeco/typal/compare/v1.15.2...v1.15.3)

@@ -346,3 +353,3 @@ - [feature] Better trimming of info from XML files.

### [1.15.2](https://github.com/artdecocode/typal/compare/v1.15.1...v1.15.2)
### [1.15.2](https://gitlab.com/artdeco/typal/compare/v1.15.1...v1.15.2)

@@ -353,7 +360,7 @@ - [fix] Use the `<strong>` tag in props.

### [1.15.1](https://github.com/artdecocode/typal/compare/v1.15.0...v1.15.1)
### [1.15.1](https://gitlab.com/artdeco/typal/compare/v1.15.0...v1.15.1)
- [fix] Call flatten callback.
### [1.15.0](https://github.com/artdecocode/typal/compare/v1.14.0...v1.15.0)
### [1.15.0](https://gitlab.com/artdeco/typal/compare/v1.14.0...v1.15.0)

@@ -366,3 +373,3 @@ - [feature] Write `extends` information and link to external source if present.

### [1.14.0](https://github.com/artdecocode/typal/compare/v1.13.1...v1.14.0)
### [1.14.0](https://gitlab.com/artdeco/typal/compare/v1.13.1...v1.14.0)

@@ -374,3 +381,3 @@ - [deps] Upgrade `rexml` to 2.0.0 (major).

### [1.13.1](https://github.com/artdecocode/typal/compare/v1.13.0...v1.13.1)
### [1.13.1](https://gitlab.com/artdeco/typal/compare/v1.13.0...v1.13.1)

@@ -381,3 +388,3 @@ - [fix] Fix escaping `null` in property table.

### [1.13.0](https://github.com/artdecocode/typal/compare/v1.12.0...v1.13.0)
### [1.13.0](https://gitlab.com/artdeco/typal/compare/v1.12.0...v1.13.0)

@@ -388,7 +395,7 @@ - [feature] Add the `skipNsDecl` tag to prevent adding of the namespace declaration.

### [1.12.0](https://github.com/artdecocode/typal/compare/v1.11.1...v1.12.0)
### [1.12.0](https://gitlab.com/artdeco/typal/compare/v1.11.1...v1.12.0)
- [feature] Add tags (`@constructor/record/interface`) to JSDoc typedefs' description.
### [1.11.1](https://github.com/artdecocode/typal/compare/v1.11.0...v1.11.1)
### [1.11.1](https://gitlab.com/artdeco/typal/compare/v1.11.0...v1.11.1)

@@ -399,3 +406,3 @@ - [fix] Print nullability in linking.

### [1.11.0](https://github.com/artdecocode/typal/compare/v1.10.0...v1.11.0)
### [1.11.0](https://gitlab.com/artdeco/typal/compare/v1.10.0...v1.11.0)

@@ -406,23 +413,23 @@ - [fix] Group types when optional is given to prevent merging with `undefined`.

### [1.10.0](https://github.com/artdecocode/typal/compare/v1.9.2...v1.10.0)
### [1.10.0](https://gitlab.com/artdeco/typal/compare/v1.9.2...v1.10.0)
- [feature] Ignore types from the marker.
### [1.9.2](https://github.com/artdecocode/typal/compare/v1.9.1...v1.9.2)
### [1.9.2](https://gitlab.com/artdeco/typal/compare/v1.9.1...v1.9.2)
- [package] Publish again as registry does not find `v1.9.1`.
### [1.9.1](https://github.com/artdecocode/typal/compare/v1.9.0...v1.9.1)
### [1.9.1](https://gitlab.com/artdeco/typal/compare/v1.9.0...v1.9.1)
- [fix] Correct the imports with namespace printing and linking (including for the `rootNamespace`); return `Imports` in from the _parse_ method.
### [1.9.0](https://github.com/artdecocode/typal/compare/v1.8.0...v1.9.0)
### [1.9.0](https://gitlab.com/artdeco/typal/compare/v1.8.0...v1.9.0)
- [feature] Pass multiple source files.
### [1.8.0](https://github.com/artdecocode/typal/compare/v1.7.0...v1.8.0)
### [1.8.0](https://gitlab.com/artdeco/typal/compare/v1.7.0...v1.8.0)
- [feature] Pass arguments via the marker; allow to disable suppress annotations with `@suppress`.
### [1.7.0](https://github.com/artdecocode/typal/compare/v1.6.3...v1.7.0)
### [1.7.0](https://gitlab.com/artdeco/typal/compare/v1.6.3...v1.7.0)

@@ -434,19 +441,19 @@ - [feature] Pass `-t` flag to fetch types' info from a given file.

### [1.6.3](https://github.com/artdecocode/typal/compare/v1.6.2...v1.6.3)
### [1.6.3](https://gitlab.com/artdeco/typal/compare/v1.6.2...v1.6.3)
- [fix] Fix disabling the root namespace for multiple properties of a type.
### [1.6.2](https://github.com/artdecocode/typal/compare/v1.6.1...v1.6.2)
### [1.6.2](https://gitlab.com/artdeco/typal/compare/v1.6.1...v1.6.2)
- [fix] Fix multiple escapes in types' names.
### [1.6.1](https://github.com/artdecocode/typal/compare/v1.6.0...v1.6.1)
### [1.6.1](https://gitlab.com/artdeco/typal/compare/v1.6.0...v1.6.1)
- [fix] Fix order of joining function's linked args.
### [1.6.0](https://github.com/artdecocode/typal/compare/v1.5.0...v1.6.0)
### [1.6.0](https://gitlab.com/artdeco/typal/compare/v1.5.0...v1.6.0)
- [feature] Support variable arguments linking.
### [1.5.0](https://github.com/artdecocode/typal/compare/v1.4.0...v1.5.0)
### [1.5.0](https://gitlab.com/artdeco/typal/compare/v1.4.0...v1.5.0)

@@ -457,3 +464,3 @@ - [feature] Use `@typedefs/parser` for better types linking and source code warnings.

### [1.4.0](https://github.com/artdecocode/typal/compare/v1.3.2...v1.4.0)
### [1.4.0](https://gitlab.com/artdeco/typal/compare/v1.3.2...v1.4.0)

@@ -465,3 +472,3 @@ - [doc] Document schema.

### [1.3.2](https://github.com/artdecocode/typal/compare/v1.3.1...v1.3.2)
### [1.3.2](https://gitlab.com/artdeco/typal/compare/v1.3.1...v1.3.2)

@@ -472,7 +479,7 @@ - [feature] Basic parsing of the types in a function type, to link.

### [1.3.1](https://github.com/artdecocode/typal/compare/v1.3.0...v1.3.1)
### [1.3.1](https://gitlab.com/artdeco/typal/compare/v1.3.0...v1.3.1)
- [fix] Fix the `bin` location.
### [1.3.0](https://github.com/artdecocode/typal/compare/v1.2.3...v1.3.0)
### [1.3.0](https://gitlab.com/artdeco/typal/compare/v1.2.3...v1.3.0)

@@ -485,3 +492,3 @@ - [feature] Compile binary with _Google Closure Compiler_ via [_Depack_](https://artdecocode.com/depack/).

### [1.2.3](https://github.com/artdecocode/typal/compare/v1.2.2...v1.2.3)
### [1.2.3](https://gitlab.com/artdeco/typal/compare/v1.2.2...v1.2.3)

@@ -493,3 +500,3 @@ - [fix] Fix escape bug in property with no description.

### [1.2.2](https://github.com/artdecocode/typal/compare/v1.2.1...v1.2.2)
### [1.2.2](https://gitlab.com/artdeco/typal/compare/v1.2.1...v1.2.2)

@@ -496,0 +503,0 @@ - [fix] Implement the `whitespace` argument, e.g., when used inside of classes.

@@ -6,1893 +6,78 @@ #!/usr/bin/env node

const stream = require('stream');
const path = require('path');
var aa = "function" == typeof Object.defineProperties ? Object.defineProperty : function(a, b, c) {
a != Array.prototype && a != Object.prototype && (a[b] = c.value);
};
function ba(a) {
a = ["object" == typeof window && window, "object" == typeof self && self, "object" == typeof global && global, a];
for (var b = 0; b < a.length; ++b) {
var c = a[b];
if (c && c.Math == Math) {
return c;
}
}
throw Error("Cannot find global object");
}
var ca = ba(this);
function da(a, b) {
if (b) {
var c = ca;
a = a.split(".");
for (var d = 0; d < a.length - 1; d++) {
var e = a[d];
e in c || (c[e] = {});
c = c[e];
}
a = a[a.length - 1];
d = c[a];
b = b(d);
b != d && null != b && aa(c, a, {configurable:!0, writable:!0, value:b});
}
}
da("String.prototype.trimRight", function(a) {
function b() {
return this.replace(/[\s\xa0]+$/, "");
}
return a || b;
});
const ea = (a, b, c, d = !1, e = !1) => {
const f = c ? new RegExp(`^-(${c}|-${b})$`) : new RegExp(`^--${b}$`);
b = a.findIndex(g => f.test(g));
if (-1 == b) {
return {argv:a};
}
if (d) {
return {value:!0, index:b, length:1};
}
d = a[b + 1];
if (!d || "string" == typeof d && d.startsWith("--")) {
return {argv:a};
}
e && (d = parseInt(d, 10));
return {value:d, index:b, length:2};
}, fa = a => {
const b = [];
for (let c = 0; c < a.length; c++) {
const d = a[c];
if (d.startsWith("-")) {
break;
}
b.push(d);
}
return b;
}, ia = () => {
var a = ha;
return Object.keys(a).reduce((b, c) => {
const d = a[c];
if ("string" == typeof d) {
return b[`-${d}`] = "", b;
}
c = d.command ? c : `--${c}`;
d.short && (c = `${c}, -${d.short}`);
let e = d.description;
d.default && (e = `${e}\nDefault: ${d.default}.`);
b[c] = e;
return b;
}, {});
};
const ha = {source:{description:"The path to the source file or directory with files to embed types into. Can specify multiple values, e.g., `typal types/index.js types/vendor.js`.", command:!0, multiple:!0}, output:{description:"The destination where to save output.\nIf not passed, the file will be overwritten.\nIf `-` is passed, prints to stdout.", short:"o"}, closure:{description:"Whether to generate types in _Closure_ mode.", boolean:!0, short:"c"}, useNamespace:{description:"Generate JSDoc for functions using namespaces.",
boolean:!0, short:"u"}, externs:{description:"Whether to generate externs for _GCC_.", boolean:!0, short:"e"}, types:{description:"Comma-separated location of files to read types from.", short:"t"}, template:{description:"Scans the input file for `@type` comment in functions' JSDoc, and inserts the annotations from types' files.", short:"T"}, migrate:{description:"Extracts types from JavaScript source code and saves them\ninto the types.xml file specified in the output option.", boolean:!0, short:"m"},
help:{description:"Print the help information and exit.", boolean:!0, short:"h"}, version:{description:"Show the version's number and exit.", boolean:!0, short:"v"}}, q = function(a = {}, b = process.argv) {
let [, , ...c] = b;
const d = fa(c);
c = c.slice(d.length);
a = Object.entries(a).reduce((g, [h, l]) => {
g[h] = "string" == typeof l ? {short:l} : l;
return g;
}, {});
const e = [];
a = Object.entries(a).reduce((g, [h, l]) => {
let k;
try {
const m = l.short, n = l.boolean, p = l.number, t = l.command, r = l.multiple;
if (t && r && d.length) {
k = d;
} else {
if (t && d.length) {
k = d[0];
} else {
const u = ea(c, h, m, n, p);
({value:k} = u);
const v = u.index, w = u.length;
void 0 !== v && w && e.push({index:v, length:w});
}
}
} catch (m) {
return g;
}
return void 0 === k ? g : {...g, [h]:k};
}, {});
let f = c;
e.forEach(({index:g, length:h}) => {
Array.from({length:h}).forEach((l, k) => {
f[g + k] = null;
});
});
f = f.filter(g => null !== g);
Object.assign(a, {Z:f});
return a;
}(ha), x = q.source, z = q.output, ja = q.closure, ka = q.useNamespace, la = q.externs, ma = q.types, na = q.template, oa = q.migrate, pa = q.version;
function qa(a = {usage:{}}) {
const {usage:b = {}, description:c, line:d, example:e} = a;
a = Object.keys(b);
const f = Object.values(b), [g] = a.reduce(([k = 0, m = 0], n) => {
const p = b[n].split("\n").reduce((t, r) => r.length > t ? r.length : t, 0);
p > m && (m = p);
n.length > k && (k = n.length);
return [k, m];
}, []), h = (k, m) => {
m = " ".repeat(m - k.length);
return `${k}${m}`;
};
a = a.reduce((k, m, n) => {
n = f[n].split("\n");
m = h(m, g);
const [p, ...t] = n;
m = `${m}\t${p}`;
const r = h("", g);
n = t.map(u => `${r}\t${u}`);
return [...k, m, ...n];
}, []).map(k => `\t${k}`);
const l = [c, ` ${d || ""}`].filter(k => k ? k.trim() : k).join("\n\n");
a = `${l ? `${l}\n` : ""}
const path = require('path'); var aa="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){a!=Array.prototype&&a!=Object.prototype&&(a[b]=c.value)};function ba(a){a=["object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global,a];for(var b=0;b<a.length;++b){var c=a[b];if(c&&c.Math==Math)return c}throw Error("Cannot find global object");}var ca=ba(this);
function da(a,b){if(b){var c=ca;a=a.split(".");for(var d=0;d<a.length-1;d++){var e=a[d];e in c||(c[e]={});c=c[e]}a=a[a.length-1];d=c[a];b=b(d);b!=d&&null!=b&&aa(c,a,{configurable:!0,writable:!0,value:b})}}da("String.prototype.trimRight",function(a){function b(){return this.replace(/[\s\xa0]+$/,"")}return a||b});const ea=(a,b,c,d=!1,e=!1)=>{const g=c?new RegExp(`^-(${c}|-${b})$`):new RegExp(`^--${b}$`);b=a.findIndex(f=>g.test(f));if(-1==b)return{argv:a};if(d)return{value:!0,index:b,length:1};d=a[b+1];if(!d||"string"==typeof d&&d.startsWith("--"))return{argv:a};e&&(d=parseInt(d,10));return{value:d,index:b,length:2}},fa=a=>{const b=[];for(let c=0;c<a.length;c++){const d=a[c];if(d.startsWith("-"))break;b.push(d)}return b},ia=()=>{var a=ha;return Object.keys(a).reduce((b,c)=>{const d=a[c];if("string"==typeof d)return b[`-${d}`]=
"",b;c=d.command?c:`--${c}`;d.short&&(c=`${c}, -${d.short}`);let e=d.description;d.default&&(e=`${e}\nDefault: ${d.default}.`);b[c]=e;return b},{})};const ha={source:{description:"The path to the source file or directory with files to embed types into. Can specify multiple values, e.g., `typal types/index.js types/vendor.js`.",command:!0,multiple:!0},output:{description:"The destination where to save output.\nIf not passed, the file will be overwritten.\nIf `-` is passed, prints to stdout.",short:"o"},closure:{description:"Whether to generate types in _Closure_ mode.",boolean:!0,short:"c"},useNamespace:{description:"Generate JSDoc for functions using namespaces.",
boolean:!0,short:"u"},externs:{description:"Whether to generate externs for _GCC_.",boolean:!0,short:"e"},types:{description:"Comma-separated location of files to read types from.",short:"t"},template:{description:"Scans the input file for `@type` comment in functions' JSDoc, and inserts the annotations from types' files.",short:"T"},migrate:{description:"Extracts types from JavaScript source code and saves them\ninto the types.xml file specified in the output option.",boolean:!0,short:"m"},help:{description:"Print the help information and exit.",
boolean:!0,short:"h"},version:{description:"Show the version's number and exit.",boolean:!0,short:"v"}},p=function(a={},b=process.argv){let [,,...c]=b;const d=fa(c);c=c.slice(d.length);a=Object.entries(a).reduce((f,[h,k])=>{f[h]="string"==typeof k?{short:k}:k;return f},{});const e=[];a=Object.entries(a).reduce((f,[h,k])=>{let l;try{const m=k.short,n=k.boolean,q=k.number,r=k.command,t=k.multiple;if(r&&t&&d.length)l=d;else if(r&&d.length)l=d[0];else{const u=ea(c,h,m,n,q);({value:l}=u);const v=u.index,
w=u.length;void 0!==v&&w&&e.push({index:v,length:w})}}catch(m){return f}return void 0===l?f:{...f,[h]:l}},{});let g=c;e.forEach(({index:f,length:h})=>{Array.from({length:h}).forEach((k,l)=>{g[f+l]=null})});g=g.filter(f=>null!==f);Object.assign(a,{$:g});return a}(ha),x=p.source,ja=p.output,ka=p.closure,la=p.useNamespace,ma=p.externs,na=p.types,oa=p.template,pa=p.migrate,qa=p.version;function ra(a={usage:{}}){const {usage:b={},description:c,line:d,example:e}=a;a=Object.keys(b);const g=Object.values(b),[f]=a.reduce(([l=0,m=0],n)=>{const q=b[n].split("\n").reduce((r,t)=>t.length>r?t.length:r,0);q>m&&(m=q);n.length>l&&(l=n.length);return[l,m]},[]),h=(l,m)=>{m=" ".repeat(m-l.length);return`${l}${m}`};a=a.reduce((l,m,n)=>{n=g[n].split("\n");m=h(m,f);const [q,...r]=n;m=`${m}\t${q}`;const t=h("",f);n=r.map(u=>`${t}\t${u}`);return[...l,m,...n]},[]).map(l=>`\t${l}`);const k=[c,` ${d||
""}`].filter(l=>l?l.trim():l).join("\n\n");a=`${k?`${k}\n`:""}
${a.join("\n")}
`;
return e ? `${a}
`;return e?`${a}
Example:
${e}
` : a;
}
;const ra = fs.createReadStream, sa = fs.createWriteStream, A = fs.lstat, ta = fs.readFileSync, ua = fs.readdir;
var va = stream;
const B = stream.Transform, wa = stream.Writable;
const xa = (a, b = 0, c = !1) => {
if (0 === b && !c) {
return a;
}
a = a.split("\n", c ? b + 1 : void 0);
return c ? a[a.length - 1] : a.slice(b).join("\n");
}, ya = (a, b = !1) => xa(a, 2 + (b ? 1 : 0)), za = a => {
({callee:{caller:a}} = a);
return a;
};
const C = os.EOL, Aa = os.homedir;
const Ba = /\s+at.*(?:\(|\s)(.*)\)?/, Ca = /^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:IGNORED_MODULES)\/.*)?\w+)\.js:\d+:\d+)|native)/, E = a => {
const {pretty:b = !1, ignoredModules:c = ["pirates", "@artdeco/pirates"]} = {}, d = c.join("|"), e = new RegExp(Ca.source.replace("IGNORED_MODULES", d));
return a.replace(/\\/g, "/").split("\n").filter(f => {
f = f.match(Ba);
if (null === f || !f[1]) {
return !0;
}
f = f[1];
return f.includes(".app/Contents/Resources/electron.asar") || f.includes(".app/Contents/Resources/default_app.asar") ? !1 : !e.test(f);
}).filter(f => f.trim()).map(f => {
if (b) {
const g = Aa().replace(/\\/g, "/");
return f.replace(/\s+at.*(?:\(|\s)(.*)\)?/, (h, l) => h.replace(l, l.replace(g, "~")));
}
return f;
}).join("\n");
};
function Da(a, b, c = !1) {
return function(d) {
var e = za(arguments), {stack:f} = Error();
const g = xa(f, 2, !0), h = (f = d instanceof Error) ? d.message : d;
e = [`Error: ${h}`, ...null !== e && a === e || c ? [b] : [g, b]].join("\n");
e = E(e);
return Object.assign(f ? d : Error(), {message:h, stack:e});
};
}
;function F(a) {
var {stack:b} = Error();
const c = za(arguments);
b = ya(b, a);
return Da(c, b, a);
}
;const Ea = (a, b) => {
b.once("error", c => {
a.emit("error", c);
});
return b;
};
class Fa extends wa {
constructor(a) {
const {binary:b = !1, rs:c = null, ...d} = a || {}, {S:e = F(!0), proxyError:f} = a || {}, g = (h, l) => e(l);
super(d);
this.b = [];
this.O = new Promise((h, l) => {
this.on("finish", () => {
let k;
b ? k = Buffer.concat(this.b) : k = this.b.join("");
h(k);
this.b = [];
});
this.once("error", k => {
if (-1 == k.stack.indexOf("\n")) {
g`${k}`;
} else {
const m = E(k.stack);
k.stack = m;
f && g`${k}`;
}
l(k);
});
c && Ea(this, c).pipe(this);
});
}
_write(a, b, c) {
this.b.push(a);
c();
}
get f() {
return this.O;
}
}
const G = async a => {
({f:a} = new Fa({rs:a, S:F(!0)}));
return await a;
};
async function H(a) {
a = ra(a);
return await G(a);
}
;async function I(a, b) {
if (!a) {
throw Error("No path is given.");
}
const c = F(!0), d = sa(a);
await new Promise((e, f) => {
d.on("error", g => {
g = c(g);
f(g);
}).on("close", e).end(b);
});
}
;async function J(a, b, c) {
const d = F(!0);
if ("function" != typeof a) {
throw Error("Function must be passed.");
}
if (!a.length) {
throw Error(`Function${a.name ? ` ${a.name}` : ""} does not accept any arguments.`);
}
return await new Promise((e, f) => {
const g = (l, k) => l ? (l = d(l), f(l)) : e(c || k);
let h = [g];
Array.isArray(b) ? h = [...b, g] : 1 < Array.from(arguments).length && (h = [b, g]);
a(...h);
});
}
;const Ga = path.dirname, Ha = path.join, Ia = path.relative, Ja = path.resolve;
async function Ka(a, b) {
b = b.map(async c => {
const d = Ha(a, c);
return {lstat:await J(A, d), path:d, relativePath:c};
});
return await Promise.all(b);
}
const La = a => a.lstat.isDirectory(), Ma = a => !a.lstat.isDirectory();
async function K(a) {
if (!a) {
throw Error("Please specify a path to the directory");
}
const {ignore:b = []} = {};
if (!(await J(A, a)).isDirectory()) {
var c = Error("Path is not a directory");
c.code = "ENOTDIR";
throw c;
}
c = await J(ua, a);
var d = await Ka(a, c);
c = d.filter(La);
d = d.filter(Ma).reduce((e, f) => {
var g = f.lstat.isDirectory() ? "Directory" : f.lstat.isFile() ? "File" : f.lstat.isSymbolicLink() ? "SymbolicLink" : void 0;
return {...e, [f.relativePath]:{type:g}};
}, {});
c = await c.reduce(async(e, {path:f, relativePath:g}) => {
const h = Ia(a, f);
if (b.includes(h)) {
return e;
}
e = await e;
f = await K(f);
return {...e, [g]:f};
}, {});
return {content:{...d, ...c}, type:"Directory"};
}
const L = (a, b) => {
let c = [], d = [];
Object.keys(a).forEach(f => {
const {type:g} = a[f];
"File" == g ? c.push(Ha(b, f)) : "Directory" == g && d.push(f);
});
const e = d.reduce((f, g) => {
const {content:h} = a[g];
g = L(h, Ha(b, g));
return [...f, ...g];
}, []);
return [...c, ...e];
};
function Na(a) {
if ("object" != typeof a) {
return !1;
}
const b = a.re instanceof RegExp;
a = -1 != ["string", "function"].indexOf(typeof a.replacement);
return b && a;
}
const Oa = (a, b) => {
if (!(b instanceof Error)) {
throw b;
}
[, , a] = a.stack.split("\n", 3);
a = b.stack.indexOf(a);
if (-1 == a) {
throw b;
}
a = b.stack.substr(0, a - 1);
const c = a.lastIndexOf("\n");
b.stack = a.substr(0, c);
throw b;
};
function Pa(a, b) {
function c() {
return b.filter(Na).reduce((d, {re:e, replacement:f}) => {
if (this.j) {
return d;
}
if ("string" == typeof f) {
return d = d.replace(e, f);
}
{
let g;
return d.replace(e, (h, ...l) => {
g = Error();
try {
return this.j ? h : f.call(this, h, ...l);
} catch (k) {
Oa(g, k);
}
});
}
}, `${a}`);
}
c.b = () => {
c.j = !0;
};
return c.call(c);
}
;const Qa = a => new RegExp(`%%_RESTREAM_${a.toUpperCase()}_REPLACEMENT_(\\d+)_%%`, "g"), Ra = (a, b) => `%%_RESTREAM_${a.toUpperCase()}_REPLACEMENT_${b}_%%`, Sa = () => {
var a = {T:/^\/\*\*? (documentary|typal) (.+?) externs (.*?)\*\/\r?\n(?:([^\r\n][\s\S]+?\r?\n))?$/mg};
return Object.keys(a).reduce((b, c) => {
{
var d = a[c];
const {getReplacement:e = Ra, getRegex:f = Qa} = {}, g = f(c);
d = {name:c, re:d, regExp:g, getReplacement:e, map:{}, lastIndex:0};
}
return {...b, [c]:d};
}, {});
}, Ta = a => {
var b = [];
const c = a.map;
return {re:a.regExp, replacement(d, e) {
d = c[e];
delete c[e];
return Pa(d, Array.isArray(b) ? b : [b]);
}};
}, Ua = a => {
const b = a.map, c = a.getReplacement, d = a.name;
return {re:a.re, replacement(e) {
const f = a.lastIndex;
b[f] = e;
a.lastIndex += 1;
return c(d, f);
}};
};
async function Va(a, b) {
return Wa(a, b);
}
class Xa extends B {
constructor(a, b) {
super(b);
this.g = (Array.isArray(a) ? a : [a]).filter(Na);
this.j = !1;
this.h = b;
}
async replace(a, b) {
const c = new Xa(this.g, this.h);
b && Object.assign(c, b);
a = await Va(c, a);
c.j && (this.j = !0);
b && Object.keys(b).forEach(d => {
b[d] = c[d];
});
return a;
}
async reduce(a) {
return await this.g.reduce(async(b, {re:c, replacement:d}) => {
b = await b;
if (this.j) {
return b;
}
if ("string" == typeof d) {
b = b.replace(c, d);
} else {
const e = [];
let f;
const g = b.replace(c, (h, ...l) => {
f = Error();
try {
if (this.j) {
return e.length ? e.push(Promise.resolve(h)) : h;
}
const k = d.call(this, h, ...l);
k instanceof Promise && e.push(k);
return k;
} catch (k) {
Oa(f, k);
}
});
if (e.length) {
try {
const h = await Promise.all(e);
b = b.replace(c, () => h.shift());
} catch (h) {
Oa(f, h);
}
} else {
b = g;
}
}
return b;
}, `${a}`);
}
async _transform(a, b, c) {
try {
const d = await this.reduce(a);
this.push(d);
c();
} catch (d) {
a = E(d.stack), d.stack = a, c(d);
}
}
}
async function Wa(a, b) {
b instanceof va ? b.pipe(a) : a.end(b);
return await G(a);
}
;function Ya() {
var a = Za;
let b = "";
const c = new B({transform(d, e, f) {
let g;
for (b += d.toString(); (d = a.exec(b)) && (c.push(d), g = d, a.global);) {
}
g && (b = b.slice(g.index + g[0].length));
f();
}, objectMode:!0});
return c;
}
;const $a = (a, b, c, d) => {
if (!a) {
throw Error("The name of the property is not given");
}
a = `${d ? `${d}.` : ""}${a}`;
if (null === b) {
return a;
}
b = Number.isInteger(b) || [!0, !1, "null"].includes(b) || ["number", "boolean"].includes(c) ? b : `"${b}"`;
return `${a}=${b}`;
}, ab = ({number:a, M:b, boolean:c, type:d}) => b ? "string" : a ? "number" : c ? "boolean" : d ? d : "*", bb = a => `${/[^\w\d._]/.test(a) ? `(${a})` : a}|undefined`, M = a => a ? `/**${C}${a}${C} */${C}` : `/**${C} */${C}`, N = a => ` * @suppress {nonStandardJsDocs}${C}${a}`, cb = (a, b, c) => {
let d = a ? `${a}.` : "";
a = a ? "" : "var ";
b.includes("-") && (b = `['${b}']`, d = d.replace(/\.$/, ""));
b = `${a}${d}${b}`;
c && (b += ` = ${c}`);
return b;
}, db = a => {
const b = a.split(/\r?\n/).map(c => {
let d = Infinity;
c.replace(/\S/, (e, f) => {
d = f;
});
return d;
}).reduce((c, d) => d < c ? d : c, Infinity);
return a.replace(new RegExp(`^ {${b}}`, "gm"), "");
}, Q = a => {
a = a.trimRight();
a = a.replace(/^\s*\r?\n( *\S)/, "$1");
return db(a);
}, eb = (a, b, c = null) => {
const {async:d, "void":e, "return":f = e ? "void" : "", ...g} = a;
({args:a = ""} = a);
a || (a = b.map(({I:h, name:l}) => "this" == l ? `${l}: ${h}` : l.startsWith("...") ? `...${h}` : h).join(","));
b = f.replace(/\r?\n\s*/g, " ");
d && b ? b = `!Promise<${b}>` : d && (b = "!Promise");
c = `function(${"constructor" == g.name ? `new: ${c}, ` : ""}${a})`;
b && (c += `: ${b}`);
return {W:{...g, async:d, return:b}, H:c};
};
function R(a, b) {
const c = a.example;
c && c.startsWith(".") && b && (a.example = Ja(Ga(b), c));
}
const fb = (...a) => a.join(C);
function gb(a, b, c) {
const d = [];
b.replace(a, (e, ...f) => {
e = f.slice(0, f.length - 2).reduce((g, h, l) => {
l = c[l];
if (!l || void 0 === h) {
return g;
}
g[l] = h;
return g;
}, {});
d.push(e);
});
return d;
}
;const hb = new RegExp(`${/([^\s>=/]+)/.source}(?:\\s*=\\s*${/(?:"([\s\S]*?)"|'([\s\S]*?)')/.source})?`, "g"), ib = new RegExp(`(?:\\s+((?:${hb.source}\\s*)*))`);
const S = (a, b) => {
a = (Array.isArray(a) ? a : [a]).join("|");
return gb(new RegExp(`<(${a})${ib.source}?(?:${/\s*\/>/.source}|${/>([\s\S]+?)?<\/\1>/.source})`, "g"), b, "t a v v1 v2 c".split(" ")).map(({t:c, a:d = "", c:e = ""}) => {
d = d.replace(/\/$/, "").trim();
d = jb(d);
return {content:e, props:d, tag:c};
});
}, jb = a => gb(hb, a, ["key", "val", "def", "f"]).reduce((b, {key:c, val:d}) => {
if (void 0 === d) {
return b[c] = !0, b;
}
b[c] = "true" == d ? !0 : "false" == d ? !1 : /^\d+$/.test(d) ? parseInt(d, 10) : d;
return b;
}, {});
const kb = a => a.split(/([!?=*(),:.<>{}|\s+])/g).filter(b => /\S/.test(b)).map(b => {
switch(b) {
case "function":
return "function";
case "Function":
return "Function";
case "!":
return "nonNullable";
case "?":
return "nullable";
case "=":
return "=";
case "*":
return "any";
}
return b;
});
function lb(a) {
let b = 0;
const c = (e = 1) => a[b + e], d = (e = !0, f = []) => {
var g = {};
let h = a[b];
if (["nullable", "nonNullable"].includes(h)) {
if (!e) {
throw Error(`${h} not allowed after .`);
}
g.nullable = "nullable" === h;
b++;
}
h = a[b];
if ("(" == h) {
b++;
g = {...d(!0, []), ...g};
if (")" != a[b]) {
throw Error("Expecting closing )");
}
b++;
if ("|" != a[b]) {
return g;
}
} else {
if ("{" == h) {
b++;
f = g;
for (e = {}; "}" != a[b];) {
var l = a[b];
b++;
e[l] = null;
if (":" == a[b]) {
b++;
try {
var k = d();
e[l] = k;
} catch (n) {
throw n.message += `(when parsing ${l} property)`, n;
}
}
if ("}" == a[b]) {
b++;
break;
}
if ("," != a[b]) {
throw Error(`Expecting , for record after ${l}`);
}
b++;
}
f.record = e;
return g;
}
}
if (["nonNullable", "nullable"].includes(h)) {
throw Error("Nullability already defined.");
}
if (/[=),:.<>}|]/.test(h)) {
throw Error(`Unexpected token ${h}.`);
}
"|" != a[b] && (g.name = a[b], b++);
if ("function" == h) {
k = g;
l = {return:null, args:[]};
if ("(" != a[b]) {
throw Error("Expecting opening (");
}
b++;
for (var m; ")" != a[b];) {
if (m && "this" == a[b]) {
throw Error("this must come first in function arguments");
}
if (m && "new" == a[b]) {
throw Error("new must come first in function arguments");
}
if ("this" == a[b]) {
b++;
if (":" != a[b]) {
throw Error("Expecting :");
}
b++;
l.this = d();
} else {
if ("new" == a[b]) {
b++;
if (":" != a[b]) {
throw Error("Expecting :");
}
b++;
l.new = d();
} else {
if ("." == a[b] && "." == c() && "." == c(2)) {
b++;
b++;
b++;
m = d();
if (")" != a[b]) {
throw Error("Variable args must come last");
}
l.variableArgs = m;
} else {
m = d(), l.args.push(m), "=" == a[b] && (m.optional = !0, b++);
}
}
}
m = !0;
if (")" == a[b]) {
break;
}
if ("," == a[b]) {
b++;
} else {
throw Error("Expecting , between arguments");
}
}
b++;
":" == a[b] && (b++, m = d(), void 0 == m.name && m.nullable && (m.name = ""), l.return = m);
k.function = l;
} else {
if ("<" == a[b] || (l = "." == a[b] && "<" == c())) {
b++;
l && b++;
k = g;
for (l = []; ">" != a[b];) {
m = d();
l.push(m);
if (">" == a[b]) {
break;
}
if ("," == a[b]) {
b++;
} else {
throw Error("Expecting , between applications");
}
}
b++;
k.application = l;
}
}
for (; "." == a[b];) {
g.name += ".";
b++;
({name:k} = d(!1));
if (!k) {
throw Error("Expected to see the name after .");
}
g.name += k;
}
if ("|" != a[b] || !e) {
return g;
}
for (f.push(g); "|" == a[b];) {
b++, g = d(!0, f), g.union !== f && f.push(g);
}
return {union:f};
};
return d();
}
;function mb(a) {
a = kb(a);
return lb(a);
}
;function nb(a, b, {name:c, string:d, "boolean":e, opt:f, number:g, type:h}, l) {
if (!c) {
throw Error("Argument does not have a name.");
}
a.name = c;
b && (a.description = Q(b));
b = ab({number:g, M:d, boolean:e, type:h});
l && (b = b.replace(new RegExp(`([!?])?${l}\\.`, "g"), "$1"));
b.endsWith("=") && (b = b.replace(/=$/, ""), f = !0);
a.type = b;
f && (a.optional = !0);
}
class ob {
constructor() {
this.name = null;
this.type = "";
this.optional = !1;
this.description = "";
}
get I() {
return this.optional ? `${this.type}=` : this.type;
}
}
const pb = (a, b) => {
let c = a.lastIndexOf("</arg>"), d = a;
var e = [];
-1 != c && (c += 6, e = a.slice(0, c), d = a.slice(c), e = S("arg", e), e = e.map(({content:f, props:g}) => {
const h = new ob;
nb(h, f, g, b);
return h;
}));
return {J:d, F:e};
};
function T(a) {
if ("" == a.name && a.nullable) {
return "?";
}
var b = "";
a.nullable ? b = "?" : !1 === a.nullable && (b = "!");
if (a.function) {
b += a.name + "(";
const d = [];
if (a.function.this) {
var c = "this: " + T(a.function.this);
d.push(c);
}
a.function.new && (c = "new: " + T(a.function.new), d.push(c));
a.function.args.forEach(e => {
let f = T(e);
e.optional && (f += "=");
d.push(f);
});
a.function.variableArgs && (c = "..." + T(a.function.variableArgs), d.push(c));
c = d.join(", ");
b += c + ")";
a.function.return && (b += ": " + T(a.function.return));
} else {
if (a.record) {
b += "{ ", c = Object.keys(a.record).map(d => {
var e = a.record[d];
if (!e) {
return d;
}
e = T(e);
return `${d}: ${e}`;
}), b += c.join(", "), b += " }";
} else {
if (a.application) {
if ("Promise" == a.name && !a.application.some(d => "void" != d.name)) {
return b + "Promise";
}
b += a.name + "<";
c = a.application.map(d => T(d));
b += c.join(", ");
b += ">";
} else {
a.union ? (b += "(", c = a.union.map(d => T(d)), b += c.join("|"), b += ")") : b += "any" == a.name ? "*" : a.name;
}
}
}
return b;
}
;const U = (a, b = !1) => a.split("\n").map((c, d) => {
if (b && !d) {
return c;
}
d = " *";
c.length && "\r" != c && (d += " ");
return d + c;
}).join("\n"), qb = a => {
const b = a.replace(/^\s*\r?\n/gm, "").split(C).reduce((c, d) => {
[{length:d = 0} = {}] = /^\s*/.exec(d) || [];
return d < c ? d : c;
}, Infinity);
return a.replace(new RegExp(`^ {${b}}`, "gm"), "");
};
function rb(a, b = "") {
const c = b.split(/\s*,\s*/);
return a.split(/\s*,\s*/).map(d => {
let e = d = ta(d, "utf8");
if (d = /\/\* start example \*\/\r?\n([\s\S]+?)\r?\n\s*\/\* end example \*\//.exec(d)) {
[, d] = d, e = qb(d);
}
c.forEach(f => {
const [g, h] = f.split(/\s*=>\s*/);
e = e.replace(`'${g}'`, `'${h}'`);
e = e.replace(`"${g}"`, `"${h}"`);
});
return e = e.replace(/@/g, "\uff20");
});
}
function sb(a, {P:b = !0, U:c = !0} = {}) {
const d = [];
b && d.push(" * @example");
a.forEach(e => {
let f = [], g = [], h = "", l;
e = e.split(C).reduce((k, m) => {
m.startsWith("///") ? (l = "comment", f.push(m)) : (l = "block", g.push(m));
h || (h = l);
l != h && ("block" == l ? (k.push(f.join(C)), f = []) : (k.push(g.join(C)), g = []), h = l);
return k;
}, []);
f.length ? e.push(f.join(C)) : g.length && e.push(g.join(C));
e = e.reduce((k, m) => {
m.startsWith("///") ? (m = m.replace(/^\/\/\/\s+/gm, ""), k.push(...m.split(/\r?\n/))) : (k.push("```js"), k.push(...m.split(/\r?\n/)), k.push("```"));
return k;
}, []);
c && (e = e.map(k => U(k)));
d.push(...e);
});
return d;
}
function tb(a, b, c = new RegExp(`([!?])?${b}\\.`, "g")) {
b && (a.f && (a.f = a.f.replace(c, "$1")), a.type = a.type.replace(c, "$1"));
}
function ub(a, b = !1) {
return b ? a.closureType : a.isParsedFunction ? a.toTypeScriptFunction(T) : a.type;
}
function vb(a, b = null, c = !1, d = !1) {
if (!a.name) {
throw Error("Property does not have a name. Has it been constructed using fromXML?");
}
b = $a(a.name, a.optional ? a.default : null, a.type, b);
b = a.optional ? `[${b}]` : b;
var e = a.m;
e = e ? ` ${e}` : "";
c = `{${ub(a, c)}} ${b}${e}`;
d && (a = sb(a.examples, {P:!1, U:!1}).join(C).replace(/\*/g, "\uff0a")) && (c += `${C}${a}`);
return c;
}
function wb(a, b = !1) {
a = vb(a, null, b, !0);
return ` * @prop ${U(a, !0)}`;
}
function xb(a, b) {
const c = [], {function:{args:d, return:e, variableArgs:f, this:g}} = a.parsed;
d.map(h => T(h)).forEach((h, l) => {
const {optional:k} = d[l], {name:m = `arg${l}`, description:n} = a.args[l] || {};
c.push(` * @param {${h}${k ? "=" : ""}} ${k ? `[${m}]` : m}${n ? ` ${n}` : ""}`);
});
if (f) {
const {N:h, Y:l} = yb(a.args || []), k = [h, l].filter(Boolean).join(" ");
c.push(` * @param {...${T(f)}} ${k}`);
}
g && c.push(` * @this {${T(g)}}`);
if (e && "void" != e.name) {
if (b && a.u) {
return c;
}
b = T(e);
c.push(` * @return {${b}}`);
}
return c;
}
function zb(a) {
if (a.isParsedFunction) {
const {function:{args:b, variableArgs:c}} = a.parsed, d = b.map((e, f) => {
({name:e = `arg${f}`} = a.l[f] || {});
return e;
});
if (c) {
const {N:e} = yb(a.args || []);
d.push(`...${e}`);
}
return ` = function(${d.join(", ")}) {}`;
}
return a.type.startsWith("function(") ? " = function() {}" : "";
}
function V(a, b = "", c = !1) {
let d = [];
var e = a.m;
e && (e = U(e), d.push(...e.split(C)));
!a.optional && a.isParsedFunction ? (e = xb(a, c), d.push(...e)) : d.push(` * @type {${a.optional ? bb(a.closureType) : a.closureType}}`);
c && a.examples.length && (a = sb(a.examples), d.push(...a));
b && (d = d.map(f => `${b}${f}`));
return d.join(C);
}
function Ab(a, b) {
const c = Object.assign(Object.create(Object.getPrototypeOf(a)), a);
c.description = `An alias for \`${a.name}\`.`;
c.name = b;
return c;
}
class Bb {
constructor(a = null) {
this.h = this.description = this.name = null;
this.closureType = "";
this.default = this.f = null;
this.optional = !1;
this.aliases = [];
this.s = !1;
this.parsed = null;
this.args = a;
this.g = !1;
this.examples = [];
this.u = !1;
}
toTypeScriptFunction(a) {
if (!this.parsed) {
throw Error("The property was not parsed.");
}
let {function:{new:b, args:c, return:d, this:e, variableArgs:f}} = this.parsed;
b && (d = b);
var g = c.map(l => a(l)).map((l, k) => {
const {optional:m} = c[k];
let {name:n = `arg${k}`, optional:p = m} = this.l[k] || {};
return `${`${n}${p ? "?" : ""}`}: ${l}`;
});
if (e) {
var h = a(e);
g.unshift(`this: ${h}`);
}
if (f) {
h = a(f);
let l = "...args";
try {
l = `${this.args[this.args.length - 1].name}`;
} catch (k) {
}
g.push(`${l}: ${h}[]`);
}
g = g.join(", ");
h = d ? a(d) : "?";
g = `(${g}) => ${h}`;
b && (g = "new " + g);
return g;
}
get static() {
return this.g;
}
get hasDefault() {
return null !== this.default;
}
b(a, {name:b, string:c, "boolean":d, opt:e, number:f, type:g, "default":h, closure:l, alias:k, aliases:m, example:n, "example-override":p = "", noParams:t, "static":r, initial:u, "template-no-return":v}) {
if (!b) {
throw Error("Property does not have a name.");
}
this.name = b;
a && (this.description = Q(a));
a = ab({number:f, M:c, boolean:d, type:g});
t && (this.s = t);
l && (this.f = l);
this.type = a;
void 0 !== h ? this.default = h : void 0 !== u && (this.default = u);
if (e || void 0 !== h) {
this.optional = !0;
}
k && (this.aliases = [k]);
m && (this.aliases = m.split(/\s*,\s*/));
r && (this.g = !0);
n && (this.examples = rb(n, p));
v && (this.u = !0);
}
get type() {
return this.h || "*";
}
set type(a) {
this.h = a || null;
this.closureType = this.f || this.h || "";
if (!this.s) {
try {
this.parsed = mb(this.closureType), this.isParsedFunction && !this.args && (this.args = []);
} catch (b) {
this.parsed = null;
}
}
}
get m() {
let a = this.description || "";
return `${a}${this.hasDefault ? `${/``` */.test(this.description) ? C : a ? " " : ""}Default \`${this.default}\`.` : ""}`;
}
get l() {
var a = this.args;
this.args && this.args[0] && "this" == this.args[0].name && ([, ...a] = this.args);
return a;
}
get isParsedFunction() {
return !!this.parsed && "function" == this.parsed.name;
}
C(a, b = "", c = !1) {
a = vb(this, a, c);
const [d, ...e] = a.split(C);
return [`@param ${d}`, ...e].map(f => `${b} * ${f}`).join(C);
}
}
const yb = a => {
let b = "args";
const {name:c = "", description:d} = a[a.length - 1] || {};
c.startsWith("...") && (b = c.replace("...", ""));
return {N:b, Y:d};
};
class W extends Bb {
constructor(...a) {
super(...a);
this.isConstructor = this.async = !1;
this.return = "";
}
b(a, b) {
super.b(a, b);
"constructor" == b.name && (this.isConstructor = !0);
this.async = b.async;
this.return = b.return;
}
}
;function Cb(a, b, c, d) {
var e = S("prop", a).map(({content:l, props:k}) => {
const m = new Bb;
R(k, c);
m.b(l, k);
return m;
});
a = S(["function", "fn", "static"], a).map(({content:l, props:k, tag:m}) => {
m = "static" == m;
const {J:n, F:p} = pb(l, b);
l = new W(p);
const {W:t, H:r} = eb(k, p, d);
t.type = r;
R(t, c);
l.b(n, t);
m && (l.g = !0);
return l;
});
e = [...e, ...a];
const {G:f, L:g, n:h} = e.reduce((l, k) => {
k.isConstructor ? l.G.push(k) : k.static ? l.L.push(k) : l.n.push(k);
return l;
}, {G:[], L:[], n:[]});
return {constructor:f[0] || null, properties:[...f, ...g, ...h]};
}
;const Db = (a, b, c = {}) => {
let d;
if ("object" == typeof b) {
d = b;
} else {
try {
(d = mb(b)) || console.log("Could not parse %s", b);
} catch (e) {
console.log("Could not parse %s", b), console.error(e.message);
}
}
return d ? X(d, a, c) : b;
}, X = (a, b, c = {}) => {
if ("" == a.name && a.nullable) {
return "?";
}
var {escapePipe:d = !0} = c;
let e = "";
var f = "";
a.nullable ? f = "?" : !1 === a.nullable && (f = "!");
if (a.function) {
e = e + f + (a.name + "(");
const g = [];
a.function.this && (d = "this: " + X(a.function.this, b, c), g.push(d));
a.function.new && (d = "new: " + X(a.function.new, b, c), g.push(d));
a.function.args.forEach(h => {
let l = X(h, b, c);
h.optional && (l += "=");
g.push(l);
});
a.function.variableArgs && (d = "..." + X(a.function.variableArgs, b, c), g.push(d));
d = g.join(", ");
e += d + ")";
a.function.return && (e += ": " + X(a.function.return, b, c));
} else {
a.record ? (e += "{ ", d = Object.keys(a.record).map(g => {
var h = a.record[g];
if (!h) {
return g;
}
h = X(h, b, c);
return `${g}: ${h}`;
}), e += d.join(", "), e += " }") : a.application ? (e += Eb(a.name, b, f, c) + "&lt;", d = a.application.map(g => X(g, b, c)), e += d.join(", "), e += "&gt;") : a.union ? (e = e + f + "(", f = a.union.map(g => X(g, b, c)), e += f.join(d ? " \\| " : " | "), e += ")") : e += Eb("any" == a.name ? "*" : a.name, b, f, c);
}
return e;
}, Eb = (a, b, c = "", d = {}) => {
const {flatten:e = !1, nameProcess:f, link:g = ({link:k}) => `#${k}`} = d;
d = Fb(b, a);
c = `${c}${a}`;
if (!d) {
return c;
}
let {link:h, type:{description:l}} = d;
e && ((b = b.find(({fullName:k}) => k == a)) && b.link && (h = b.link), !l && b.description && (l = b.description), "function" == typeof e && e(a));
d.link == h && (h = g(d));
b = f ? f(c) : c;
return l ? `<a href="${h}" title="${l.replace(/"/g, "&quot;")}">${b}</a>` : `[${b}](${h})`;
}, Fb = (a, b) => {
a = a.filter(({fullName:d}) => d == b);
if (a.length) {
var c = a.find(({import:d}) => d || !1);
a = a.find(({import:d}) => !d) || c;
return {link:`${"type"}-${a.fullName.replace(/<\/?code>/g, "").replace(/<\/?strong>/g, "").replace(/<br\/>/g, "").replace(/&nbsp;/g, "").replace(/[^\w-\d ]/g, "").toLowerCase().replace(/[, ]/g, "-")}`, type:a};
}
};
function Gb(a, b = [], c = [], d = {}) {
const {narrow:e = !1, preprocessDesc:f} = d;
if (!b.length) {
return "";
}
const g = a.isConstructor || a.isInterface, h = b.some(({hasDefault:n}) => n), l = {escapePipe:!e, ...d};
let k;
const m = n => Db(c, n, {...l, nameProcess:d.nameProcess ? p => d.nameProcess(p, k) : void 0});
a = b.map((n, p) => {
k = 0 < (p + 1) % 2;
p = n.args && n.isParsedFunction ? n.toTypeScriptFunction(m) : m(n.parsed || n.type);
const t = g || n.optional ? n.name : `${n.name}*`, r = n.hasDefault ? `\`${n.default}\`` : "-", u = f ? f(n.description) : n.description;
return {prop:n, typeName:p, name:t, de:Hb(u, !e), d:r, $:k};
});
if (e) {
return {props:a, anyHaveDefault:h, constr:g};
}
a = a.map(({name:n, typeName:p, de:t, d:r, prop:u}) => [u.optional ? n : `__${n}__`, `<em>${p}</em>`, t, ...h ? [r] : []]);
b = ["Name", ...e ? ["Type & Description"] : ["Type", "Description"], ...h ? [g ? "Initial" : "Default"] : []];
return ["", "", "```table", JSON.stringify([b, ...a], null, 2).replace(/\n/g, C), "```"].join(C);
}
const Hb = (a = "", b = !0) => {
null === a && (a = "");
b && (a = a.replace(/\|/g, "\\|"));
return a.replace(/</g, "&lt;").replace(/>/g, "&gt;");
};
const Ib = (a, b, c = {}) => {
function d(e) {
e.replace(/^!?/, "");
return `\`${e}\``;
}
return a.split(/,\s*/).map(e => Db(b, e, {flatten:!0, ...c, nameProcess:c.nameProcess ? f => {
f = c.nameProcess(f);
return /[_*~>]/.test(f) ? `<code>${f}</code>` : d(f);
} : d})).join(", ");
};
function Jb(a) {
var b = a.h();
b = M(b.join(C));
b += cb(a.namespace, a.name, Kb(a));
const c = a.properties.reduce((d, e) => {
d.push(e);
const f = e.aliases.map(g => Ab(e, g));
d.push(...f);
return d;
}, []).filter(d => d instanceof W && d.isConstructor ? !1 : !0).map(d => {
let e = V(d);
e = M(e);
e += cb(`${a.fullName}${d.static ? "" : ".prototype"}`, d.name);
return e += zb(d);
});
return [b, ...c].join(C);
}
function Lb(a, b = !1) {
const c = `${a.extends ? "$" : ""}${a.name}`;
return b ? `${a.ns}${c}` : c;
}
function Mb(a, b = !1, c = !1, d = b) {
d = ` * @typedef {${(b ? a.closureType : a.type) || a.s()}}${` ${Lb(a, d)}${a.l}`}`;
a = (a.properties ? a.properties.reduce((e, f) => {
if (f.g) {
return e;
}
e.push(f);
const g = f.aliases.map(h => Ab(f, h));
e.push(...g);
return e;
}, []) : []).filter(e => e instanceof W ? !e.isConstructor : !0).map(e => wb(e, b));
a = [d, ...a].join(C);
b && !c && (a = N(a));
return a = M(a);
}
function Kb(a) {
return a.args ? `function(${a.args.filter(({name:b}) => "this" != b).map(({name:b}) => b).join(", ")}) {}` : null;
}
class Y {
constructor() {
this.name = "";
this.description = this.closureType = this.type = null;
this.noExpand = this.spread = this.noToc = !1;
this.link = null;
this.properties = [];
this.namespace = null;
this.isRecord = this.isInterface = this.isConstructor = !1;
this.args = this.extends = null;
this.examples = [];
this.file = null;
}
get import() {
return !1;
}
b(a, {name:b, type:c, desc:d, noToc:e, spread:f, noExpand:g, link:h, closure:l, constructor:k, "extends":m, "interface":n, record:p, example:t, "example-override":r}, u, v = null) {
if (!b) {
throw Error("Type does not have a name.");
}
this.name = b;
c && (this.type = c);
l ? this.closureType = l : this.closureType = this.type;
d && (this.description = Q(d));
this.noToc = !!e;
this.spread = !!f;
this.noExpand = !!g;
h && (this.link = h);
!0 === k && (this.isConstructor = k);
!0 === n && (this.isInterface = n);
!0 === p && (this.isRecord = p);
m && (this.extends = m);
u && (this.namespace = u);
if (a) {
const {properties:w, constructor:y} = Cb(a, v, this.file, this.fullName);
y && (this.args = y.args);
this.properties = w;
}
t && (a = {example:t}, R(a, this.file), this.examples = rb(a.example, r));
}
get K() {
return this.isConstructor || this.isInterface || this.isRecord;
}
s() {
return "Object";
}
m(a, b = new RegExp(`([!?])?${a}\\.`, "g")) {
this.type && (this.type = this.type.replace(b, "$1"));
this.extends && (this.extends = this.extends.replace(b, "$1"));
return b;
}
get l() {
return `${this.tag ? ` \`\uff20${this.tag}\`` : ""}${this.description ? ` ${this.description}` : ""}`;
}
g(a = !1, b = !1, c = a) {
const d = !!this.extends, e = Mb(this, a, b, c), f = [];
if (this.namespace && a) {
var g = ` * @typedef {${this.fullName}} ${this.name}${this.l}`;
a && !b && (g = N(g));
g = M(g);
f.push(g);
} else {
this.namespace && c && (g = ` * @typedef {${this.fullName}} ${this.name}${this.l}`, g = M(g), f.push(g));
}
d && (c = ` * @typedef {${Lb(this, c)} & ${this.extends.split(/,\s*/).join(" & ")}} ${c ? this.fullName : this.name}${this.l}`, a && !b && (c = N(c)), c = M(c), f.push(c));
f.push(e);
return f.join("");
}
get X() {
const a = this.tag;
if (!a) {
throw Error("Unknown prototype type (not constructor or interface).");
}
return a;
}
get tag() {
return this.isConstructor ? "constructor" : this.isInterface ? "interface" : this.isRecord ? "record" : "";
}
h(a = "", b = !0, c = !1) {
let d = [];
this.description && d.push(` * ${this.description}`);
const e = this.properties[0];
e instanceof W && e.isConstructor && e.description && d.push(U(e.description));
this.extends && this.extends.split(/,\s*/).forEach(f => {
d.push(` * @extends {${f}}`);
});
this.args && this.args.forEach(f => {
let {name:g, description:h, optional:l, type:k} = f;
f = h ? ` ${h}` : "";
if (g.startsWith("...")) {
g = g.slice(3), k = `...${k}`;
} else {
if ("this" == g) {
d.push(` * @this {${k}}${f}`);
return;
}
}
d.push(` * @param {${k}${l ? "=" : ""}} ${l ? `[${g}]` : g}${f}`);
});
b && d.push(` * @${this.X}`);
c && this.examples.length && (b = sb(this.examples), d.push(...b));
a && (d = d.map(f => `${a}${f}`));
return d;
}
get ns() {
return this.namespace ? `${this.namespace}.` : "";
}
get fullName() {
return `${this.ns}${this.name}`;
}
C(a, b, c, d, e = !1, f = !1) {
var g = "";
!0 === d ? g = "?" : !1 === d && (g = "!");
d = this.description ? ` ${this.description}` : "";
const h = this.spread ? Nb(this.properties) : e || f ? this.fullName : this.name;
b = `${c || ""} * @param {${g}${h}} ${b ? `[${a}]` : a}${d}`;
g = this.properties && !this.noExpand ? this.properties.map(l => l.C(a, c, e, f)) : [];
return [b, ...g].join(C);
}
toMarkdown(a = [], b = {}) {
const {flatten:c, details:d = []} = b, e = d.includes(this.name);
var f = this.type ? `\`${this.type}\`` : "", g = f;
this.link ? g = `[${f}](${this.link})` : !this.import && this.type && (g = Db(a, this.type, b), f = g != this.type, g = Ob(g, f));
f = Ob(this.fullName);
f = this.import ? `[${f}](l-type)` : this.noToc ? `[${f}](l-type)` : `[${f}](t-type)`;
const h = this.description ? `: ${this.description}` : "";
g = g ? `${g} ` : "";
let l = /_/.test(f);
if (this.extends) {
const k = Ib(this.extends, a, b), m = ` extends ${k}`;
l = l || /_/.test(k);
g = (l ? g + "<strong>" : g + "__") + (f + m);
"function" == typeof c && c(this.extends);
} else {
g = (l ? g + "<strong>" : g + "__") + f;
}
g = (l ? g + "</strong>" : g + "__") + h;
a = Gb(this, this.properties, a, b);
return {LINE:g, table:a, displayInDetails:e};
}
}
const Ob = (a, b = !1) => `${b ? "<code>" : "`"}${a}${b ? "</code>" : "`"}`, Nb = (a = [], b = !1) => {
a = a.reduce((c, d) => {
c.push(d);
const e = d.aliases.map(f => ({...d, name:f}));
c.push(...e);
return c;
}, []);
return `{ ${a.map(c => {
const d = b ? c.closureType : c.type;
let e = c.name, f = d;
c.optional && !b ? e = `${c.name}?` : c.optional && b && (f = `(${bb(d)})`);
return `${e}: ${f}`;
}).join(", ")} }`;
};
class Pb extends Y {
constructor() {
super();
this.from = "";
}
get import() {
return !0;
}
b(a, {from:b, name:c, ...d}, e, f) {
if (!b) {
throw Error("From attribute of import is not given.");
}
this.from = b;
this.description = Q(a);
super.b("", {...d, noToc:!0, name:c, type:`import('${b}').${c}`}, e != f ? e : null);
}
g(a = !0) {
return ` * @typedef {import('${this.from}').${this.name}} ${a ? this.fullName : this.name}`;
}
}
;function Qb(a, b) {
b = b.reduce((c, d) => ({...c, [d.fullName]:d}), {});
a.A = {...a.A, ...b};
}
class Rb extends Xa {
constructor(a, b = {}) {
super(a);
this.A = {};
this.on("types", c => {
Qb(this, c);
});
this.on("namespace", c => {
this.b.includes(c) || this.b.push(c);
});
this.f = b;
this.b = [];
this.i = console.log;
this.file = null;
this.lines = [];
}
static get Type() {
return Y;
}
static get Import() {
return Pb;
}
get types() {
return this.A;
}
}
;class Sb extends Y {
constructor() {
super();
this.f = null;
this.async = !1;
}
get K() {
return !1;
}
get isMethod() {
return !0;
}
b(a, {async:b, "return":c, "void":d, ...e}, ...f) {
this.description = Q(a);
super.b("", e, ...f);
c && (this.f = c.replace(/\r?\n\s*/g, " "));
d && (this.f = "void");
b && (this.async = !0);
}
get return() {
return this.f || "void";
}
h(a = "") {
const b = super.h(a, !1), c = this.u;
c && b.push(`${a} * @return {${c}}`);
return b;
}
get u() {
let a = "";
this.f && (a = this.return);
this.async && a ? a = `Promise<${a}>` : this.async && (a = "Promise");
return a;
}
s() {
return `(${this.args.map(({name:a, type:b, optional:c}) => `${a}${c ? "?" : ""}: ${b}`).join(", ")}) => ${this.u}`;
}
m(a) {
a = super.m(a);
this.f && (this.f = this.f.replace(a, "$1"));
}
}
;const Tb = (a, b) => {
const c = new RegExp(`([!?])?${a}\\.`, "g");
b.properties.forEach(d => {
tb(d, a, c);
});
b.m(a);
}, Ub = (a, b) => {
var {args:c = []} = a, d = c.map(({I:f}) => f).join(", ");
let e = `new: ${a.fullName}`;
d.length && (e = `${e}, `);
d = `function(${e}${d})`;
c = new W(c);
c.isConstructor = !0;
c.b("Constructor method.", {type:d, name:"constructor"});
c.examples = a.examples;
tb(c, b);
a.properties.unshift(c);
}, Wb = (a, b, c = null) => {
a = S("types", a);
if (!a.length) {
throw Error("XML file should contain root types element.");
}
const [{content:d, props:{namespace:e, ns:f = e}}] = a, g = b == f ? void 0 : f;
a = S(["embed"], d).map(({props:k}) => k);
const h = [], l = S("type interface constructor method import record".split(" "), d).reduce((k, {content:m, props:n, tag:p}) => {
"record" == p && (p = "type", n.record = !0);
const {alias:t, aliases:r, ...u} = n;
c && R(u, c);
var v = t ? [t] : r ? r.split(/, */) : [];
switch(p) {
case "type":
p = new Y;
c && (p.file = c);
p.b(m, n, g, b);
k.push(p);
v.forEach(w => {
const y = new Y;
c && (y.file = c);
y.b(m, {...u, name:w}, g, b);
k.push(y);
});
break;
case "interface":
n = Vb({content:m, props:n, ns:g, B:b, location:c});
n.forEach(w => {
w.properties.some(({isConstructor:y}) => y) || Ub(w, b);
w.isInterface = !0;
});
k.push(...n);
break;
case "constructor":
n = Vb({content:m, props:n, ns:g, B:b, location:c});
n.forEach(w => {
w.properties.some(({isConstructor:y}) => y) || Ub(w, b);
w.isConstructor = !0;
});
k.push(...n);
break;
case "method":
n = Vb({content:m, props:n, ns:g, B:b, isMethod:!0, location:c});
k.push(...n);
break;
case "import":
v = new Pb, v.b(m, n, n.ns || n.from, b), h.push(v);
}
return k;
}, []);
b && l.forEach(k => Tb(b, k));
return {namespace:f, types:l, imports:h, embeds:a};
}, Xb = (a, b, c, d, e = !1, f = null) => {
const g = e ? new Sb : new Y;
g.file = f;
f = a.search(/<(prop|function|fn|static) /);
let h = "", l = a;
1 != f && (h = a.slice(0, f), l = a.slice(f));
const {F:k, J:m} = pb(h, d);
g.b(e ? m : l, b, c, d);
({H:a} = eb(b, k));
e && (g.closureType = a);
g.args || (g.args = k);
return g;
}, Vb = ({content:a, props:b, ns:c, B:d, isMethod:e = !1, location:f = null}) => {
const g = [], {alias:h, aliases:l, ...k} = b;
b = Xb(a, b, c, d, e, f);
g.push(b);
(h ? [h] : l ? l.split(/, */) : []).forEach(m => {
m = Xb(a, {...k, name:m}, c, d, e, f);
m.description = `${m.description}${m.description ? " " : ""}Alias of \`${k.name}\`.`;
g.push(m);
});
return g;
}, Yb = async(a, b = []) => {
const c = await H(a);
let d, e, f, g;
try {
({namespace:d = null, types:e, imports:f, embeds:g} = Wb(c, void 0, a));
} catch (h) {
throw h.message = `Error while reading ${a}${C}${h.message}`, h;
}
e = e.filter(({fullName:h}) => b.includes(h) ? !1 : !0);
f = f.filter(({fullName:h}) => b.includes(h) ? !1 : !0);
return {types:e, imports:f, namespace:d, embeds:g};
};
const Zb = (a, b, c) => {
b = b.map(d => d.g(!0, c));
a = a.map(d => {
d = d.g();
return M(c ? d : N(d));
});
return [...b, ...a].join("");
}, $b = (a, b, c, d = !1) => {
a = a.map(e => {
{
let f;
e.closureType ? f = ` * @typedef {${e.closureType}}` : e.K || (f = ` * @typedef {${Nb(e.properties, !0)}}`);
f ? (e.description && (f = ` * ${e.description}${C}${f}`), f = M(f), e = f += cb(e.namespace, e.name)) : e = Jb(e);
}
return e;
});
a = fb(...a, ...[]);
return `${!b || d || c.includes(b) ? "" : ["/** @const */", `var ${b} = {}`, ""].join(C)}${a}`;
};
async function ac(a, b, c) {
const [d, ...e] = c.split(/\s+/);
var f = e.includes("closure");
const g = e.includes("externs"), h = e.includes("noSuppress"), l = e.includes("skipNsDecl"), k = e.includes("namespace"), m = e.includes("noEmbed") || e.includes("no-embed");
let n = e.find(r => r.startsWith("ignore:"));
n = n ? n.replace("ignore:", "").split(",") : [];
let {o:p, w:t} = this.f;
f && (p = !0);
g && (t = !0);
try {
this.i("Detected type marker: %s", c);
const {types:r, imports:u, namespace:v, embeds:w} = await Yb(d, n);
this.emit("types", r);
this.emit("types", u);
f = [];
m || (f = await Promise.all(w.map(async({src:D, path:hc = D, ignore:O = n.join(","), namespace:ic = k, o:jc = p, w:kc = t, "no-suppress":lc = h}) => {
D = [hc];
O && D.push(`ignore:${O}`);
ic && D.push("namespace");
jc && D.push("closure");
kc && D.push("ext");
lc && D.push("noSuppress");
O = D.join(" ");
return await ac.call(this, `${C} /* typal-embed ${O} */${C}`, "typal-embed", O);
})));
let y = f.join(""), P;
p ? P = Zb(u, r, h) : t ? (P = $b(r, v, this.b, l) + C, v && this.emit("namespace", v)) : k ? (v && this.emit("namespace", v), P = bc(u, r, !0)) : P = bc(u, r);
return `/* ${b} ${c} */${C}${P}${y}`;
} catch (r) {
return this.i("(%s) Could not process typedef-js: %s", c, r.message), process.env.b && console.error(r.stack), a;
}
}
const cc = {re:/^\/\*\*? (documentary|typal) (.+?) \*\/\r?\n(?:((?!\r?\n)[\s\S]+?\r?\n))?$/mg, replacement:ac}, bc = (a, b, c = !1) => {
b = b.map(d => d.g(!1, !1, c));
a = a.map(d => d.g(c)).map(M).join("");
b = b.join("");
return `${a}${b}`.replace(dc, " * @typedef");
}, dc = / \*\/\r?\n\/\*\*\r?\n \* @typedef/g;
const fc = {re:/( *) \* @param {(.+?)} (\[)?([^\s\]]+)\]?(?: .+)?((?:\r?\n(?: +)\* @param {(?:.+?)} \[?\4\]?(?:(?!\r?\n\s*\*(?:\/|\s*@))[\s\S])*)*)/gm, replacement:ec};
function ec(a, b, c, d, e, f, g) {
const h = this.f.o, l = this.f.D;
let k;
f = () => {
if (this.lines && this.file) {
var n;
{
let r = n = 0;
for (; r < g;) {
r += this.lines[n].length, n++;
}
n = {line:n, R:b.length + 11};
}
const {line:p, R:t} = n;
this.i("%s:%s:%s", this.file, p, t);
}
};
try {
k = mb(c);
} catch (n) {
return this.i("Error while parsing the type %s", c), this.i(process.env.DEBUG ? n.stack : n.message), f(), a;
}
if (!k) {
return this.i("Could not parse the type %s", c), f(), a;
}
const m = Object.values(this.types).map(({name:n, fullName:p}) => h || l ? p : n);
if (!Z(k, m, this.i, c, f)) {
return a;
}
c = Object.values(this.types).find(({name:n, fullName:p}) => h || l ? p == k.name : n == k.name);
return !c || c instanceof Rb.Import ? a : c.C(e, d, b, k.nullable, h, l);
}
const Z = (a, b, c, d, e) => {
if (a) {
var f = a.name;
if (!f || !"string number boolean null undefined symbol any".split(" ").includes(f)) {
if (f && !a.application && !a.function) {
let h = b.includes(f);
h || (h = gc.includes(f));
if (h) {
return !0;
}
c("Type %s%s was not found.", f, d != f ? ` in ${d}` : "");
e();
}
var g = [b, c, d, e];
a.application ? a.application.forEach(h => {
Z(h, ...g);
}) : a.record ? Object.keys(a.record).forEach(h => {
Z(a.record[h], ...g);
}) : a.union ? a.union.forEach(h => {
Z(h, ...g);
}) : a.function && (Z(a.function.this, ...g), Z(a.function.new, ...g), a.function.args.forEach(h => {
Z(h, ...g);
}), Z(a.function.variableArgs, ...g), Z(a.function.return, ...g));
}
}
}, gc = "String Boolean Object Date Number Symbol Buffer Function RegExp".split(" ");
var mc = (a, b = !1) => {
var {T:c} = Sa();
const d = Ua(c);
c = Ta(c);
return new Rb(b ? [cc] : [cc, d, fc, c], a);
};
const nc = /( *) \* @(fnType|methodType) {(.+?)}/gm, oc = (a, b, c, d, e, f, g = d) => ["/**", a, " */", `${b ? "static " : ""}${c ? "async " : ""}${d}(${e}) {`, ` return ${`${b ? f : "super"}.${g}`}(${e})`, "}"].join(C);
class pc extends Xa {
constructor(a, b) {
super([{re:/\/\*\*(?:\s+( *) \*)? @constructor {(.+?)}[\s\S]+?(class\s+.+?\s+extends\s+(.+?)\s*){\s*}/gm, replacement(c, d, e, f, g) {
d = a.find(({fullName:k}) => k == e);
if (!d) {
return console.error("Type %s in %s not found", e, b), c;
}
c = d.properties.filter(k => k instanceof W && !k.isConstructor).map(k => {
const m = k.name;
var n = k.aliases;
const p = k.static, t = k.async;
let r = V(k, "", !0);
r = qc(r, e);
const u = k.args.map(({name:v}) => v).join(", ");
k = oc(r, p, t, m, u, g);
n = n.map(v => oc(r + `${C} * @alias ${m} An alias for **${m}**.`, p, t, v, u, g, m));
return [k, ...n].join(C);
});
const h = d.properties.find(k => k instanceof W && k.isConstructor), l = h.args.map(({name:k}) => k).join(", ");
c = fb("/**", qc(V(h, "", !0), e), " */", `constructor(${l}) {`, ` super(${l})`, "}", ...c).replace(/(^|(?:\r?\n))/g, "$1 ");
return fb(...d.description ? ["/**", U(d.description), " */"] : [], `${f}{`, c, "}");
}}, {re:nc, async replacement(c, d, e, f) {
const g = f.split(".");
let h, l;
if ("methodType" == e) {
h = f;
} else {
if (2 == g.length) {
[h, l] = g;
} else {
if (3 == g.length) {
h = `${g[0]}.${g[1]}`, l = g[2];
} else {
throw Error("The @fnType should consist of _namespace.Type.propName or Type.propName");
}
}
}
f = a.find(({fullName:k}) => k == h);
if (!f) {
return console.error("Type %s in %s not found", h, b), c;
}
if ("constructor" == l || "methodType" == e) {
return f.h(d, !1, !0).join(C);
}
e = f.properties.find(({name:k}) => k == l);
return e ? e.parsed ? V(e, d, !0) : (console.error("Property %s of type %s in %s wasn't parsed, possibly parser bug.", l, h, b), c) : (console.error("Property %s of type %s in %s not found", l, h, b), c);
}}]);
}
}
const qc = (a, b) => a.replace(`${C} * @return {${b}}`, "").replace(`${C} * @return {!${b}}`, "").replace(`${C} * @return {?${b}}`, "");
const rc = async a => a ? (await Promise.all(a.split(",").map(async b => {
var c = [];
const d = await J(A, b);
d.isFile() ? c = [b] : d.isDirectory() && (c = await K(b), c = L(c.content, b), c = c.filter(e => e.endsWith(".xml")));
return c;
}))).reduce((b, c) => [...b, ...c], []) : [], sc = async a => (await Promise.all(a.map(async b => ({...await Yb(b), location:b})))).reduce((b, {imports:c, types:d}) => {
b.push(...c);
b.push(...d);
return b;
}, []);
async function tc() {
const a = await rc(ma), b = await sc(a);
await Promise.all(x.map(async c => {
var d = await J(A, c);
let e;
d.isFile() ? e = [c] : d.isDirectory() && (d = await K(c), e = L(d.content, c));
await uc(e, b, na);
}));
}
const uc = async(a, b = [], c = null) => {
await Promise.all(a.map(async d => {
var e = await H(d);
const f = new pc(b, d);
f.end(e);
e = await G(f);
"-" == c ? console.log(e) : c ? await I(c, e) : await I(d, e);
}));
};
var wc = async() => {
const {o:a = !1, D:b = !1, w:c = !1, V:d, types:e} = {o:ja, w:la, V:z, types:ma, D:ka}, f = await rc(e);
await Promise.all(x.map(async g => {
var h = await J(A, g);
let l;
h.isFile() ? l = [g] : h.isDirectory() && (h = await K(g), l = L(h.content, g));
await vc(l, a, c, d, f, b);
}));
};
const vc = async(a, b = !1, c = !1, d = "", e = [], f = !1) => {
const g = [];
await Promise.all(e.map(async h => {
h = await H(h);
const {types:l, imports:k} = Wb(h);
g.push(l, k);
}));
await Promise.all(a.map(async h => {
var l = await H(h);
const k = mc({o:b, w:c, D:f}, c);
g.forEach(m => k.emit("types", m));
k.file = h;
k.i = console.error;
k.lines = l.split(C);
k.end(l);
l = await G(k);
"-" == d ? console.log(l) : d ? await I(d, l) : await I(h, l);
}));
};
const xc = a => {
let b;
"true" == a ? b = !0 : "false" == a ? b = !1 : /^\d+$/.test(a) && (b = parseInt(a, 10));
return void 0 !== b ? b : a;
}, yc = /^ \* @prop {(.+?)} (\[)?(.+?)(?:=(["'])?(.+?)\4)?(?:])?(?: (.+?))?(?: Default `(.+?)`.)?$/gm, zc = "type opt name quote defaultValue description Default".split(" "), Za = new RegExp(`^ \\* @typedef {(.+?)} (.+?)(?: (.+))?\\r?\\n((?:${/ \* @prop(?:erty)? .+\r?\n/.source})*)`, "gm"), Ac = (a, b, c, d) => {
d = d.length;
a = a && "Object" != a ? ` type="${a}"` : "";
c = c ? ` desc="${c}"` : "";
return `${" ".repeat(2)}<type name="${b}"${a}${c}${d ? "" : " /"}>${C}`;
};
class Bc extends B {
constructor() {
super({writableObjectMode:!0});
}
_transform({type:a, name:b, description:c, properties:d}, e, f) {
a = a && a.startsWith("import") ? Cc(a, b) : Ac(a, b, c, d);
this.push(a);
d.forEach(({type:g, name:h, default:l, description:k, optional:m}) => {
{
g = ["string", "number", "boolean"].includes(g) ? ` ${g}` : ` type="${g}"`;
var n = void 0 !== l;
l = n ? ` default="${l}"` : "";
m = m && !n ? " opt" : "";
n = " ".repeat(4);
const p = " ".repeat(6);
h = `${n}<prop${m}${g} name="${h}"${l}${k ? `>${C}${p}${k}${C}${n}</prop>` : "/>"}${C}`;
}
this.push(h);
});
d.length && this.push(` </type>${C}`);
f();
}
}
const Cc = (a, b) => {
const c = /import\((['"])(.+?)\1\)/.exec(a);
if (!c) {
throw Error(`Could not extract package from "${a}"`);
}
[, , a] = c;
return `${" ".repeat(2)}<import name="${b}" from="${a}" />${C}`;
};
class Dc extends B {
constructor() {
super({objectMode:!0});
}
_transform([, a, b, c, d], e, f) {
d = gb(yc, d, zc).map(g => {
const {defaultValue:h, Default:l, opt:k, name:m, type:n, ...p} = g;
g = {...p, name:m, type:n, ...h ? {defaultValue:xc(h)} : {}, ...l ? {v:xc(l)} : {}, ...k ? {optional:!0} : {}};
if (h || l) {
if (h) {
h !== l && void 0 !== g.v && (t = $a(m, l, n), console.error("%s[%s] does not match Default `%s`.", b, t, g.v));
} else {
var t = $a(m, l, n);
console.error("%s[%s] got from Default.", b, t);
}
g.default = "defaultValue" in g ? g.defaultValue : g.v;
delete g.defaultValue;
delete g.v;
}
return g;
});
this.push({type:a, name:b, description:c, properties:d});
f();
}
}
async function Ec(a) {
const b = Ya(), c = new Dc, d = new Bc;
b.pipe(c).pipe(d);
b.end(a);
b.on("error", e => {
console.error("Error in Transform");
d.emit("error", e);
});
c.on("error", e => {
console.error("Error in RegexTransform");
d.emit("error", e);
});
d.on("error", e => {
console.error("Error in XML");
d.emit("error", e);
});
return ["<types>", ` ${(await G(d)).trim()}`, "</types>"].join(C);
}
;var Fc = async() => {
await Promise.all(x.map(async a => {
a = await H(a);
a = await Ec(a);
z ? await I(z, a) : console.log(a);
}));
};
/*
`:a};const sa=fs.createReadStream,ta=fs.createWriteStream,z=fs.lstat,ua=fs.readFileSync,va=fs.readdir;var wa=stream;const A=stream.Transform,xa=stream.Writable;const ya=(a,b=0,c=!1)=>{if(0===b&&!c)return a;a=a.split("\n",c?b+1:void 0);return c?a[a.length-1]:a.slice(b).join("\n")},za=(a,b=!1)=>ya(a,2+(b?1:0)),Aa=a=>{({callee:{caller:a}}=a);return a};const B=os.EOL,Ba=os.homedir;const Ca=/\s+at.*(?:\(|\s)(.*)\)?/,Da=/^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:IGNORED_MODULES)\/.*)?\w+)\.js:\d+:\d+)|native)/,Ea=a=>{const {pretty:b=!1,ignoredModules:c=["pirates","@artdeco/pirates"]}={},d=c.join("|"),e=new RegExp(Da.source.replace("IGNORED_MODULES",d));return a.replace(/\\/g,"/").split("\n").filter(g=>{g=g.match(Ca);if(null===g||!g[1])return!0;g=g[1];return g.includes(".app/Contents/Resources/electron.asar")||g.includes(".app/Contents/Resources/default_app.asar")?
!1:!e.test(g)}).filter(g=>g.trim()).map(g=>{if(b){const f=Ba().replace(/\\/g,"/");return g.replace(/\s+at.*(?:\(|\s)(.*)\)?/,(h,k)=>h.replace(k,k.replace(f,"~")))}return g}).join("\n")};function Fa(a,b,c=!1){return function(d){var e=Aa(arguments),{stack:g}=Error();const f=ya(g,2,!0),h=(g=d instanceof Error)?d.message:d;e=[`Error: ${h}`,...null!==e&&a===e||c?[b]:[f,b]].join("\n");e=Ea(e);return Object.assign(g?d:Error(),{message:h,stack:e})}};function C(a){var {stack:b}=Error();const c=Aa(arguments);b=za(b,a);return Fa(c,b,a)};const Ga=(a,b)=>{b.once("error",c=>{a.emit("error",c)});return b};class Ha extends xa{constructor(a){const {binary:b=!1,rs:c=null,...d}=a||{},{T:e=C(!0),proxyError:g}=a||{},f=(h,k)=>e(k);super(d);this.b=[];this.P=new Promise((h,k)=>{this.on("finish",()=>{let l;b?l=Buffer.concat(this.b):l=this.b.join("");h(l);this.b=[]});this.once("error",l=>{if(-1==l.stack.indexOf("\n"))f`${l}`;else{const m=Ea(l.stack);l.stack=m;g&&f`${l}`}k(l)});c&&Ga(this,c).pipe(this)})}_write(a,b,c){this.b.push(a);c()}get f(){return this.P}}const D=async a=>{({f:a}=new Ha({rs:a,T:C(!0)}));return await a};async function F(a){a=sa(a);return await D(a)};async function G(a,b){if(!a)throw Error("No path is given.");const c=C(!0),d=ta(a);await new Promise((e,g)=>{d.on("error",f=>{f=c(f);g(f)}).on("close",e).end(b)})};async function H(a,b,c){const d=C(!0);if("function"!=typeof a)throw Error("Function must be passed.");if(!a.length)throw Error(`Function${a.name?` ${a.name}`:""} does not accept any arguments.`);return await new Promise((e,g)=>{const f=(k,l)=>k?(k=d(k),g(k)):e(c||l);let h=[f];Array.isArray(b)?h=[...b,f]:1<Array.from(arguments).length&&(h=[b,f]);a(...h)})};const Ia=path.dirname,Ja=path.join,Ka=path.relative,La=path.resolve;async function Ma(a,b){b=b.map(async c=>{const d=Ja(a,c);return{lstat:await H(z,d),path:d,relativePath:c}});return await Promise.all(b)}const Na=a=>a.lstat.isDirectory(),Oa=a=>!a.lstat.isDirectory();
async function I(a){if(!a)throw Error("Please specify a path to the directory");const {ignore:b=[]}={};if(!(await H(z,a)).isDirectory()){var c=Error("Path is not a directory");c.code="ENOTDIR";throw c;}c=await H(va,a);var d=await Ma(a,c);c=d.filter(Na);d=d.filter(Oa).reduce((e,g)=>{var f=g.lstat.isDirectory()?"Directory":g.lstat.isFile()?"File":g.lstat.isSymbolicLink()?"SymbolicLink":void 0;return{...e,[g.relativePath]:{type:f}}},{});c=await c.reduce(async(e,{path:g,relativePath:f})=>{const h=Ka(a,
g);if(b.includes(h))return e;e=await e;g=await I(g);return{...e,[f]:g}},{});return{content:{...d,...c},type:"Directory"}}const J=(a,b)=>{let c=[],d=[];Object.keys(a).forEach(g=>{const {type:f}=a[g];"File"==f?c.push(Ja(b,g)):"Directory"==f&&d.push(g)});const e=d.reduce((g,f)=>{const {content:h}=a[f];f=J(h,Ja(b,f));return[...g,...f]},[]);return[...c,...e]};function Pa(a){if("object"!=typeof a)return!1;const b=a.re instanceof RegExp;a=-1!=["string","function"].indexOf(typeof a.replacement);return b&&a}const Qa=(a,b)=>{if(!(b instanceof Error))throw b;[,,a]=a.stack.split("\n",3);a=b.stack.indexOf(a);if(-1==a)throw b;a=b.stack.substr(0,a-1);const c=a.lastIndexOf("\n");b.stack=a.substr(0,c);throw b;};function Ra(a,b){function c(){return b.filter(Pa).reduce((d,{re:e,replacement:g})=>{if(this.j)return d;if("string"==typeof g)return d=d.replace(e,g);{let f;return d.replace(e,(h,...k)=>{f=Error();try{return this.j?h:g.call(this,h,...k)}catch(l){Qa(f,l)}})}},`${a}`)}c.b=()=>{c.j=!0};return c.call(c)};const Sa=a=>new RegExp(`%%_RESTREAM_${a.toUpperCase()}_REPLACEMENT_(\\d+)_%%`,"g"),Ta=(a,b)=>`%%_RESTREAM_${a.toUpperCase()}_REPLACEMENT_${b}_%%`,Ua=()=>{var a={U:/^\/\*\*? (documentary|typal) (.+?) externs (.*?)\*\/\r?\n(?:([^\r\n][\s\S]+?\r?\n))?$/mg};return Object.keys(a).reduce((b,c)=>{{var d=a[c];const {getReplacement:e=Ta,getRegex:g=Sa}={},f=g(c);d={name:c,re:d,regExp:f,getReplacement:e,map:{},lastIndex:0}}return{...b,[c]:d}},{})},Va=a=>{var b=[];const c=a.map;return{re:a.regExp,replacement(d,
e){d=c[e];delete c[e];return Ra(d,Array.isArray(b)?b:[b])}}},Wa=a=>{const b=a.map,c=a.getReplacement,d=a.name;return{re:a.re,replacement(e){const g=a.lastIndex;b[g]=e;a.lastIndex+=1;return c(d,g)}}};async function Xa(a,b){return Ya(a,b)}
class Za extends A{constructor(a,b){super(b);this.g=(Array.isArray(a)?a:[a]).filter(Pa);this.j=!1;this.h=b}async replace(a,b){const c=new Za(this.g,this.h);b&&Object.assign(c,b);a=await Xa(c,a);c.j&&(this.j=!0);b&&Object.keys(b).forEach(d=>{b[d]=c[d]});return a}async reduce(a){return await this.g.reduce(async(b,{re:c,replacement:d})=>{b=await b;if(this.j)return b;if("string"==typeof d)b=b.replace(c,d);else{const e=[];let g;const f=b.replace(c,(h,...k)=>{g=Error();try{if(this.j)return e.length?e.push(Promise.resolve(h)):
h;const l=d.call(this,h,...k);l instanceof Promise&&e.push(l);return l}catch(l){Qa(g,l)}});if(e.length)try{const h=await Promise.all(e);b=b.replace(c,()=>h.shift())}catch(h){Qa(g,h)}else b=f}return b},`${a}`)}async _transform(a,b,c){try{const d=await this.reduce(a);this.push(d);c()}catch(d){a=Ea(d.stack),d.stack=a,c(d)}}}async function Ya(a,b){b instanceof wa?b.pipe(a):a.end(b);return await D(a)};function $a(){var a=ab;let b="";const c=new A({transform(d,e,g){let f;for(b+=d.toString();(d=a.exec(b))&&(c.push(d),f=d,a.global););f&&(b=b.slice(f.index+f[0].length));g()},objectMode:!0});return c};const bb=(a,b,c,d)=>{if(!a)throw Error("The name of the property is not given");a=`${d?`${d}.`:""}${a}`;if(null===b)return a;b=Number.isInteger(b)||[!0,!1,"null"].includes(b)||["number","boolean"].includes(c)?b:`"${b}"`;return`${a}=${b}`},cb=({number:a,N:b,boolean:c,type:d})=>b?"string":a?"number":c?"boolean":d?d:"*",db=a=>`${/[^\w\d._]/.test(a)?`(${a})`:a}|undefined`,K=a=>a?`/**${B}${a}${B} */${B}`:`/**${B} */${B}`,L=a=>` * @suppress {nonStandardJsDocs}${B}${a}`,eb=(a,b,c)=>{let d=a?`${a}.`:"";a=
a?"":"var ";b.includes("-")&&(b=`['${b}']`,d=d.replace(/\.$/,""));b=`${a}${d}${b}`;c&&(b+=` = ${c}`);return b},fb=a=>{const b=a.split(/\r?\n/).map(c=>{let d=Infinity;c.replace(/\S/,(e,g)=>{d=g});return d}).reduce((c,d)=>d<c?d:c,Infinity);return a.replace(new RegExp(`^ {${b}}`,"gm"),"")},M=a=>{a=a.trimRight();a=a.replace(/^\s*\r?\n( *\S)/,"$1");return fb(a)},gb=(a,b,c=null)=>{const {async:d,"void":e,"return":g=e?"void":"",...f}=a;({args:a=""}=a);a||(a=b.map(({J:h,name:k})=>"this"==k?`${k}: ${h}`:k.startsWith("...")?
`...${h}`:h).join(","));b=g.replace(/\r?\n\s*/g," ");d&&b?b=`!Promise<${b}>`:d&&(b="!Promise");c=`function(${"constructor"==f.name?`new: ${c}, `:""}${a})`;b&&(c+=`: ${b}`);return{X:{...f,async:d,return:b},I:c}};function N(a,b){const c=a.example;c&&c.startsWith(".")&&b&&(a.example=La(Ia(b),c))}const O=(...a)=>a.join(B);function hb(a,b,c){const d=[];b.replace(a,(e,...g)=>{e=g.slice(0,g.length-2).reduce((f,h,k)=>{k=c[k];if(!k||void 0===h)return f;f[k]=h;return f},{});d.push(e)});return d};const ib=new RegExp(`${/([^\s>=/]+)/.source}(?:\\s*=\\s*${/(?:"([\s\S]*?)"|'([\s\S]*?)')/.source})?`,"g"),jb=new RegExp(`(?:\\s+((?:${ib.source}\\s*)*))`);const P=(a,b)=>{a=(Array.isArray(a)?a:[a]).join("|");return hb(new RegExp(`<(${a})${jb.source}?(?:${/\s*\/>/.source}|${/>([\s\S]+?)?<\/\1>/.source})`,"g"),b,"t a v v1 v2 c".split(" ")).map(({t:c,a:d="",c:e=""})=>{d=d.replace(/\/$/,"").trim();d=kb(d);return{content:e,props:d,tag:c}})},kb=a=>hb(ib,a,["key","val","def","f"]).reduce((b,{key:c,val:d})=>{if(void 0===d)return b[c]=!0,b;b[c]="true"==d?!0:"false"==d?!1:/^\d+$/.test(d)?parseInt(d,10):d;return b},{});const lb=a=>a.split(/([!?=*(),:.<>{}|\s+])/g).filter(b=>/\S/.test(b)).map(b=>{switch(b){case "function":return"function";case "Function":return"Function";case "!":return"nonNullable";case "?":return"nullable";case "=":return"=";case "*":return"any"}return b});
function mb(a){let b=0;const c=(e=1)=>a[b+e],d=(e=!0,g=[])=>{var f={};let h=a[b];if(["nullable","nonNullable"].includes(h)){if(!e)throw Error(`${h} not allowed after .`);f.nullable="nullable"===h;b++}h=a[b];if("("==h){b++;f={...d(!0,[]),...f};if(")"!=a[b])throw Error("Expecting closing )");b++;if("|"!=a[b])return f}else if("{"==h){b++;g=f;for(e={};"}"!=a[b];){var k=a[b];b++;e[k]=null;if(":"==a[b]){b++;try{var l=d();e[k]=l}catch(n){throw n.message+=`(when parsing ${k} property)`,n;}}if("}"==a[b]){b++;
break}if(","!=a[b])throw Error(`Expecting , for record after ${k}`);b++}g.record=e;return f}if(["nonNullable","nullable"].includes(h))throw Error("Nullability already defined.");if(/[=),:.<>}|]/.test(h))throw Error(`Unexpected token ${h}.`);"|"!=a[b]&&(f.name=a[b],b++);if("function"==h){l=f;k={return:null,args:[]};if("("!=a[b])throw Error("Expecting opening (");b++;for(var m;")"!=a[b];){if(m&&"this"==a[b])throw Error("this must come first in function arguments");if(m&&"new"==a[b])throw Error("new must come first in function arguments");
if("this"==a[b]){b++;if(":"!=a[b])throw Error("Expecting :");b++;k.this=d()}else if("new"==a[b]){b++;if(":"!=a[b])throw Error("Expecting :");b++;k.new=d()}else if("."==a[b]&&"."==c()&&"."==c(2)){b++;b++;b++;m=d();if(")"!=a[b])throw Error("Variable args must come last");k.variableArgs=m}else m=d(),k.args.push(m),"="==a[b]&&(m.optional=!0,b++);m=!0;if(")"==a[b])break;if(","==a[b])b++;else throw Error("Expecting , between arguments");}b++;":"==a[b]&&(b++,m=d(),void 0==m.name&&m.nullable&&(m.name=""),
k.return=m);l.function=k}else if("<"==a[b]||(k="."==a[b]&&"<"==c())){b++;k&&b++;l=f;for(k=[];">"!=a[b];){m=d();k.push(m);if(">"==a[b])break;if(","==a[b])b++;else throw Error("Expecting , between applications");}b++;l.application=k}for(;"."==a[b];){f.name+=".";b++;({name:l}=d(!1));if(!l)throw Error("Expected to see the name after .");f.name+=l}if("|"!=a[b]||!e)return f;for(g.push(f);"|"==a[b];)b++,f=d(!0,g),f.union!==g&&g.push(f);return{union:g}};return d()};function nb(a){a=lb(a);return mb(a)};function ob(a,b,{name:c,string:d,"boolean":e,opt:g,number:f,type:h},k){if(!c)throw Error("Argument does not have a name.");a.name=c;b&&(a.description=M(b));b=cb({number:f,N:d,boolean:e,type:h});k&&(b=b.replace(new RegExp(`([!?])?${k}\\.`,"g"),"$1"));b.endsWith("=")&&(b=b.replace(/=$/,""),g=!0);a.type=b;g&&(a.optional=!0)}class pb{constructor(){this.name=null;this.type="";this.optional=!1;this.description=""}get J(){return this.optional?`${this.type}=`:this.type}}
const qb=(a,b)=>{let c=a.lastIndexOf("</arg>"),d=a;var e=[];-1!=c&&(c+=6,e=a.slice(0,c),d=a.slice(c),e=P("arg",e),e=e.map(({content:g,props:f})=>{const h=new pb;ob(h,g,f,b);return h}));return{K:d,G:e}};function S(a){if(""==a.name&&a.nullable)return"?";var b="";a.nullable?b="?":!1===a.nullable&&(b="!");if(a.function){b+=a.name+"(";const d=[];if(a.function.this){var c="this: "+S(a.function.this);d.push(c)}a.function.new&&(c="new: "+S(a.function.new),d.push(c));a.function.args.forEach(e=>{let g=S(e);e.optional&&(g+="=");d.push(g)});a.function.variableArgs&&(c="..."+S(a.function.variableArgs),d.push(c));c=d.join(", ");b+=c+")";a.function.return&&(b+=": "+S(a.function.return))}else if(a.record)b+="{ ",
c=Object.keys(a.record).map(d=>{var e=a.record[d];if(!e)return d;e=S(e);return`${d}: ${e}`}),b+=c.join(", "),b+=" }";else if(a.application){if("Promise"==a.name&&!a.application.some(d=>"void"!=d.name))return b+"Promise";b+=a.name+"<";c=a.application.map(d=>S(d));b+=c.join(", ");b+=">"}else a.union?(b+="(",c=a.union.map(d=>S(d)),b+=c.join("|"),b+=")"):b+="any"==a.name?"*":a.name;return b};const T=(a,b=!1)=>a.split("\n").map((c,d)=>{if(b&&!d)return c;d=" *";c.length&&"\r"!=c&&(d+=" ");return d+c}).join("\n"),rb=a=>{const b=a.replace(/^\s*\r?\n/gm,"").split(B).reduce((c,d)=>{[{length:d=0}={}]=/^\s*/.exec(d)||[];return d<c?d:c},Infinity);return a.replace(new RegExp(`^ {${b}}`,"gm"),"")};
function sb(a,b=""){const c=b.split(/\s*,\s*/);return a.split(/\s*,\s*/).map(d=>{let e=d=ua(d,"utf8");if(d=/\/\* start example \*\/\r?\n([\s\S]+?)\r?\n\s*\/\* end example \*\//.exec(d))[,d]=d,e=rb(d);c.forEach(g=>{const [f,h]=g.split(/\s*=>\s*/);e=e.replace(`'${f}'`,`'${h}'`);e=e.replace(`"${f}"`,`"${h}"`)});return e=e.replace(/@/g,"\uff20")})}
function tb(a,{R:b=!0,V:c=!0}={}){const d=[];b&&d.push(" * @example");a.forEach(e=>{let g=[],f=[],h="",k;e=e.split(B).reduce((l,m)=>{m.startsWith("///")?(k="comment",g.push(m)):(k="block",f.push(m));h||(h=k);k!=h&&("block"==k?(l.push(g.join(B)),g=[]):(l.push(f.join(B)),f=[]),h=k);return l},[]);g.length?e.push(g.join(B)):f.length&&e.push(f.join(B));e=e.reduce((l,m)=>{m.startsWith("///")?(m=m.replace(/^\/\/\/\s+/gm,""),l.push(...m.split(/\r?\n/))):(l.push("```js"),l.push(...m.split(/\r?\n/)),l.push("```"));
return l},[]);c&&(e=e.map(l=>T(l)));d.push(...e)});return d}function ub(a,b,c=new RegExp(`([!?])?${b}\\.`,"g")){b&&(a.f&&(a.f=a.f.replace(c,"$1")),a.type=a.type.replace(c,"$1"))}function vb(a,b=!1){return b?a.closureType:a.isParsedFunction?a.toTypeScriptFunction(S):a.type}
function wb(a,b=null,c=!1,d=!1){if(!a.name)throw Error("Property does not have a name. Has it been constructed using fromXML?");b=bb(a.name,a.optional?a.default:null,a.type,b);b=a.optional?`[${b}]`:b;var e=a.o;e=e?` ${e}`:"";c=`{${vb(a,c)}} ${b}${e}`;d&&(a=tb(a.examples,{R:!1,V:!1}).join(B).replace(/\*/g,"\uff0a"))&&(c+=`${B}${a}`);return c}function xb(a,b=!1){a=wb(a,null,b,!0);return` * @prop ${T(a,!0)}`}
function yb(a,b){const c=[],{function:{args:d,return:e,variableArgs:g,this:f}}=a.parsed;d.map(h=>S(h)).forEach((h,k)=>{const {optional:l}=d[k],{name:m=`arg${k}`,description:n}=a.args[k]||{};c.push(` * @param {${h}${l?"=":""}} ${l?`[${m}]`:m}${n?` ${n}`:""}`)});if(g){const {O:h,Z:k}=zb(a.args||[]),l=[h,k].filter(Boolean).join(" ");c.push(` * @param {...${S(g)}} ${l}`)}f&&c.push(` * @this {${S(f)}}`);if(e&&"void"!=e.name){if(b&&a.v)return c;b=S(e);c.push(` * @return {${b}}`)}return c}
function Ab(a){if(a.isParsedFunction){const {function:{args:b,variableArgs:c}}=a.parsed,d=b.map((e,g)=>{({name:e=`arg${g}`}=a.l[g]||{});return e});if(c){const {O:e}=zb(a.args||[]);d.push(`...${e}`)}return` = function(${d.join(", ")}) {}`}return a.type.startsWith("function(")?" = function() {}":""}function Bb(a,b){const c=Object.assign(Object.create(Object.getPrototypeOf(a)),a);c.description=`An alias for \`${a.name}\`.`;c.name=b;return c}
class Cb{constructor(a=null){this.h=this.description=this.name=null;this.closureType="";this.default=this.f=null;this.optional=!1;this.aliases=[];this.u=!1;this.parsed=null;this.args=a;this.g=!1;this.examples=[];this.v=!1}toTypeScriptFunction(a){if(!this.parsed)throw Error("The property was not parsed.");let {function:{new:b,args:c,return:d,this:e,variableArgs:g}}=this.parsed;b&&(d=b);var f=c.map(k=>a(k)).map((k,l)=>{const {optional:m}=c[l];let {name:n=`arg${l}`,optional:q=m}=this.l[l]||{};return`${`${n}${q?
"?":""}`}: ${k}`});if(e){var h=a(e);f.unshift(`this: ${h}`)}if(g){h=a(g);let k="...args";try{k=`${this.args[this.args.length-1].name}`}catch(l){}f.push(`${k}: ${h}[]`)}f=f.join(", ");h=d?a(d):"?";f=`(${f}) => ${h}`;b&&(f="new "+f);return f}get static(){return this.g}get hasDefault(){return null!==this.default}b(a,{name:b,string:c,"boolean":d,opt:e,number:g,type:f,"default":h,closure:k,alias:l,aliases:m,example:n,"example-override":q="",noParams:r,"static":t,initial:u,"template-no-return":v}){if(!b)throw Error("Property does not have a name.");
this.name=b;a&&(this.description=M(a));a=cb({number:g,N:c,boolean:d,type:f});r&&(this.u=r);k&&(this.f=k);this.type=a;void 0!==h?this.default=h:void 0!==u&&(this.default=u);if(e||void 0!==h)this.optional=!0;l&&(this.aliases=[l]);m&&(this.aliases=m.split(/\s*,\s*/));t&&(this.g=!0);n&&(this.examples=sb(n,q));v&&(this.v=!0)}get type(){return this.h||"*"}set type(a){this.h=a||null;this.closureType=this.f||this.h||"";if(!this.u)try{this.parsed=nb(this.closureType),this.isParsedFunction&&!this.args&&(this.args=
[])}catch(b){this.parsed=null}}get o(){let a=this.description||"";return`${a}${this.hasDefault?`${/``` */.test(this.description)?B:a?" ":""}Default \`${this.default}\`.`:""}`}get l(){var a=this.args;this.args&&this.args[0]&&"this"==this.args[0].name&&([,...a]=this.args);return a}get isParsedFunction(){return!!this.parsed&&"function"==this.parsed.name}m(a="",b=!1){let c=[];var d=this.o;d&&(d=T(d),c.push(...d.split(B)));!this.optional&&this.isParsedFunction?(d=yb(this,b),c.push(...d)):c.push(` * @type {${this.optional?
db(this.closureType):this.closureType}}`);b&&this.examples.length&&(b=tb(this.examples),c.push(...b));a&&(c=c.map(e=>`${a}${e}`));return c.join(B)}D(a,b="",c=!1){a=wb(this,a,c);const [d,...e]=a.split(B);return[`@param ${d}`,...e].map(g=>`${b} * ${g}`).join(B)}}const zb=a=>{let b="args";const {name:c="",description:d}=a[a.length-1]||{};c.startsWith("...")&&(b=c.replace("...",""));return{O:b,Z:d}};class U extends Cb{constructor(...a){super(...a);this.isConstructor=this.async=!1;this.return=""}b(a,b){super.b(a,b);"constructor"==b.name&&(this.isConstructor=!0);this.async=b.async;this.return=b.return}};function Db(a,b,c,d){var e=P("prop",a).map(({content:k,props:l})=>{const m=new Cb;N(l,c);m.b(k,l);return m});a=P(["function","fn","static"],a).map(({content:k,props:l,tag:m})=>{m="static"==m;const {K:n,G:q}=qb(k,b);k=new U(q);const {X:r,I:t}=gb(l,q,d);r.type=t;N(r,c);k.b(n,r);m&&(k.g=!0);return k});e=[...e,...a];const {H:g,M:f,n:h}=e.reduce((k,l)=>{l.isConstructor?k.H.push(l):l.static?k.M.push(l):k.n.push(l);return k},{H:[],M:[],n:[]});return{constructor:g[0]||null,properties:[...g,...f,...h]}};const Eb=(a,b,c={})=>{let d;if("object"==typeof b)d=b;else try{(d=nb(b))||console.log("Could not parse %s",b)}catch(e){console.log("Could not parse %s",b),console.error(e.message)}return d?V(d,a,c):b},V=(a,b,c={})=>{if(""==a.name&&a.nullable)return"?";var {escapePipe:d=!0}=c;let e="";var g="";a.nullable?g="?":!1===a.nullable&&(g="!");if(a.function){e=e+g+(a.name+"(");const f=[];a.function.this&&(d="this: "+V(a.function.this,b,c),f.push(d));a.function.new&&(d="new: "+V(a.function.new,b,c),f.push(d));
a.function.args.forEach(h=>{let k=V(h,b,c);h.optional&&(k+="=");f.push(k)});a.function.variableArgs&&(d="..."+V(a.function.variableArgs,b,c),f.push(d));d=f.join(", ");e+=d+")";a.function.return&&(e+=": "+V(a.function.return,b,c))}else a.record?(e+="{ ",d=Object.keys(a.record).map(f=>{var h=a.record[f];if(!h)return f;h=V(h,b,c);return`${f}: ${h}`}),e+=d.join(", "),e+=" }"):a.application?(e+=Fb(a.name,b,g,c)+"&lt;",d=a.application.map(f=>V(f,b,c)),e+=d.join(", "),e+="&gt;"):a.union?(e=e+g+"(",g=a.union.map(f=>
V(f,b,c)),e+=g.join(d?" \\| ":" | "),e+=")"):e+=Fb("any"==a.name?"*":a.name,b,g,c);return e},Fb=(a,b,c="",d={})=>{const {flatten:e=!1,nameProcess:g,link:f=({link:l})=>`#${l}`}=d;d=Gb(b,a);c=`${c}${a}`;if(!d)return c;let {link:h,type:{description:k}}=d;e&&((b=b.find(({fullName:l})=>l==a))&&b.link&&(h=b.link),!k&&b.description&&(k=b.description),"function"==typeof e&&e(a));d.link==h&&(h=f(d));b=g?g(c):c;return k?`<a href="${h}" title="${k.replace(/"/g,"&quot;")}">${b}</a>`:`[${b}](${h})`},Gb=(a,b)=>
{a=a.filter(({fullName:d})=>d==b);if(a.length){var c=a.find(({import:d})=>d||!1);a=a.find(({import:d})=>!d)||c;return{link:`${"type"}-${a.fullName.replace(/<\/?code>/g,"").replace(/<\/?strong>/g,"").replace(/<br\/>/g,"").replace(/&nbsp;/g,"").replace(/[^\w-\d ]/g,"").toLowerCase().replace(/[, ]/g,"-")}`,type:a}}};function Hb(a,b=[],c=[],d={}){const {narrow:e=!1,preprocessDesc:g}=d;if(!b.length)return"";const f=a.isConstructor||a.isInterface,h=b.some(({hasDefault:n})=>n),k={escapePipe:!e,...d};let l;const m=n=>Eb(c,n,{...k,nameProcess:d.nameProcess?q=>d.nameProcess(q,l):void 0});a=b.map((n,q)=>{l=0<(q+1)%2;q=n.args&&n.isParsedFunction?n.toTypeScriptFunction(m):m(n.parsed||n.type);const r=f||n.optional?n.name:`${n.name}*`,t=n.hasDefault?`\`${n.default}\``:"-",u=g?g(n.description):n.description;return{prop:n,
typeName:q,name:r,de:Ib(u,!e),d:t,aa:l}});if(e)return{props:a,anyHaveDefault:h,constr:f};a=a.map(({name:n,typeName:q,de:r,d:t,prop:u})=>[u.optional?n:`__${n}__`,`<em>${q}</em>`,r,...h?[t]:[]]);b=["Name",...e?["Type & Description"]:["Type","Description"],...h?[f?"Initial":"Default"]:[]];return["","","```table",JSON.stringify([b,...a],null,2).replace(/\n/g,B),"```"].join(B)}const Ib=(a="",b=!0)=>{null===a&&(a="");b&&(a=a.replace(/\|/g,"\\|"));return a.replace(/</g,"&lt;").replace(/>/g,"&gt;")};const Jb=(a,b,c={})=>{function d(e){e.replace(/^!?/,"");return`\`${e}\``}return a.split(/,\s*/).map(e=>Eb(b,e,{flatten:!0,...c,nameProcess:c.nameProcess?g=>{g=c.nameProcess(g);return/[_*~>]/.test(g)?`<code>${g}</code>`:d(g)}:d})).join(", ")};function Kb(a){var b=a.h();b=K(b.join(B));b+=eb(a.namespace,a.name,Lb(a));const c=a.properties.reduce((d,e)=>{d.push(e);const g=e.aliases.map(f=>Bb(e,f));d.push(...g);return d},[]).filter(d=>d instanceof U&&d.isConstructor?!1:!0).map(d=>{let e=d.m();e=K(e);e+=eb(`${a.fullName}${d.static?"":".prototype"}`,d.name);return e+=Ab(d)});return[b,...c].join(B)}function Mb(a,b=!1){const c=`${a.extends?"$":""}${a.name}`;return b?`${a.ns}${c}`:c}
function Nb(a,b=!1,c=!1,d=b){d=` * @typedef {${(b?a.closureType:a.type)||a.u()}}${` ${Mb(a,d)}${a.l}`}`;a=(a.properties?a.properties.reduce((e,g)=>{if(g.g)return e;e.push(g);const f=g.aliases.map(h=>Bb(g,h));e.push(...f);return e},[]):[]).filter(e=>e instanceof U?!e.isConstructor:!0).map(e=>xb(e,b));a=[d,...a].join(B);b&&!c&&(a=L(a));return a=K(a)}function Lb(a){return a.args?`function(${a.args.filter(({name:b})=>"this"!=b).map(({name:b})=>b).join(", ")}) {}`:null}
class W{constructor(){this.name="";this.description=this.closureType=this.type=null;this.noExpand=this.spread=this.noToc=!1;this.link=null;this.properties=[];this.namespace=null;this.isRecord=this.isInterface=this.isConstructor=!1;this.args=this.extends=null;this.examples=[];this.file=null}get import(){return!1}b(a,{name:b,type:c,desc:d,noToc:e,spread:g,noExpand:f,link:h,closure:k,constructor:l,"extends":m,"interface":n,record:q,example:r,"example-override":t},u,v=null){if(!b)throw Error("Type does not have a name.");
this.name=b;c&&(this.type=c);k?this.closureType=k:this.closureType=this.type;d&&(this.description=M(d));this.noToc=!!e;this.spread=!!g;this.noExpand=!!f;h&&(this.link=h);!0===l&&(this.isConstructor=l);!0===n&&(this.isInterface=n);!0===q&&(this.isRecord=q);m&&(this.extends=m);u&&(this.namespace=u);if(a){const {properties:w,constructor:y}=Db(a,v,this.file,this.fullName);y&&(this.args=y.args);this.properties=w}r&&(a={example:r},N(a,this.file),this.examples=sb(a.example,t))}get L(){return this.isConstructor||
this.isInterface||this.isRecord}m(){let a;this.closureType?a=` * @typedef {${this.closureType}}`:this.L||(a=` * @typedef {${Ob(this.properties,!0)}}`);return a?(this.description&&(a=` * ${this.description}${B}${a}`),a=K(a),a+=eb(this.namespace,this.name)):Kb(this)}u(){return"Object"}o(a,b=new RegExp(`([!?])?${a}\\.`,"g")){this.type&&(this.type=this.type.replace(b,"$1"));this.extends&&(this.extends=this.extends.replace(b,"$1"));return b}get l(){return`${this.tag?` \`\uff20${this.tag}\``:""}${this.description?
` ${this.description}`:""}`}g(a=!1,b=!1,c=a){const d=!!this.extends,e=Nb(this,a,b,c),g=[];if(this.namespace&&a){var f=` * @typedef {${this.fullName}} ${this.name}${this.l}`;a&&!b&&(f=L(f));f=K(f);g.push(f)}else this.namespace&&c&&(f=` * @typedef {${this.fullName}} ${this.name}${this.l}`,f=K(f),g.push(f));d&&(c=` * @typedef {${Mb(this,c)} & ${this.extends.split(/,\s*/).join(" & ")}} ${c?this.fullName:this.name}${this.l}`,a&&!b&&(c=L(c)),c=K(c),g.push(c));g.push(e);return g.join("")}get Y(){const a=
this.tag;if(!a)throw Error("Unknown prototype type (not constructor or interface).");return a}get tag(){return this.isConstructor?"constructor":this.isInterface?"interface":this.isRecord?"record":""}h(a="",b=!0,c=!1){let d=[];this.description&&d.push(` * ${this.description}`);const e=this.properties[0];e instanceof U&&e.isConstructor&&e.description&&d.push(T(e.description));this.extends&&this.extends.split(/,\s*/).forEach(g=>{d.push(` * @extends {${g}}`)});this.args&&this.args.forEach(g=>{let {name:f,
description:h,optional:k,type:l}=g;g=h?` ${h}`:"";if(f.startsWith("..."))f=f.slice(3),l=`...${l}`;else if("this"==f){d.push(` * @this {${l}}${g}`);return}d.push(` * @param {${l}${k?"=":""}} ${k?`[${f}]`:f}${g}`)});b&&d.push(` * @${this.Y}`);c&&this.examples.length&&(b=tb(this.examples),d.push(...b));a&&(d=d.map(g=>`${a}${g}`));return d}get ns(){return this.namespace?`${this.namespace}.`:""}get fullName(){return`${this.ns}${this.name}`}D(a,b,c,d,e=!1,g=!1){var f="";!0===d?f="?":!1===d&&(f="!");d=this.description?
` ${this.description}`:"";const h=this.spread?Ob(this.properties):e||g?this.fullName:this.name;b=`${c||""} * @param {${f}${h}} ${b?`[${a}]`:a}${d}`;f=this.properties&&!this.noExpand?this.properties.map(k=>k.D(a,c,e,g)):[];return[b,...f].join(B)}toMarkdown(a=[],b={}){const {flatten:c,details:d=[]}=b,e=d.includes(this.name);var g=this.type?`\`${this.type}\``:"",f=g;this.link?f=`[${g}](${this.link})`:!this.import&&this.type&&(f=Eb(a,this.type,b),g=f!=this.type,f=Pb(f,g));g=Pb(this.fullName);g=this.import?
`[${g}](l-type)`:this.noToc?`[${g}](l-type)`:`[${g}](t-type)`;const h=this.description?`: ${this.description}`:"";f=f?`${f} `:"";let k=/_/.test(g);if(this.extends){const l=Jb(this.extends,a,b),m=` extends ${l}`;k=k||/_/.test(l);f=(k?f+"<strong>":f+"__")+(g+m);"function"==typeof c&&c(this.extends)}else f=(k?f+"<strong>":f+"__")+g;f=(k?f+"</strong>":f+"__")+h;a=Hb(this,this.properties,a,b);return{LINE:f,table:a,displayInDetails:e}}}
const Pb=(a,b=!1)=>`${b?"<code>":"`"}${a}${b?"</code>":"`"}`,Ob=(a=[],b=!1)=>{a=a.reduce((c,d)=>{c.push(d);const e=d.aliases.map(g=>({...d,name:g}));c.push(...e);return c},[]);return`{ ${a.map(c=>{const d=b?c.closureType:c.type;let e=c.name,g=d;c.optional&&!b?e=`${c.name}?`:c.optional&&b&&(g=`(${db(d)})`);return`${e}: ${g}`}).join(", ")} }`};class Qb extends W{constructor(){super();this.from=""}get import(){return!0}b(a,{from:b,name:c,...d},e,g){if(!b)throw Error("From attribute of import is not given.");this.from=b;this.description=M(a);super.b("",{...d,noToc:!0,name:c,type:`import('${b}').${c}`},e!=g?e:null)}g(a=!0){return` * @typedef {import('${this.from}').${this.name}} ${a?this.fullName:this.name}`}};function Rb(a,b){b=b.reduce((c,d)=>({...c,[d.fullName]:d}),{});a.B={...a.B,...b}}class Sb extends Za{constructor(a,b={}){super(a);this.B={};this.on("types",c=>{Rb(this,c)});this.on("namespace",c=>{this.b.includes(c)||this.b.push(c)});this.f=b;this.b=[];this.i=console.log;this.file=null;this.lines=[]}static get Type(){return W}static get Import(){return Qb}get types(){return this.B}};class Tb extends W{constructor(){super();this.f=null;this.async=!1}get L(){return!1}get isMethod(){return!0}b(a,{async:b,"return":c,"void":d,...e},...g){this.description=M(a);super.b("",e,...g);c&&(this.f=c.replace(/\r?\n\s*/g," "));d&&(this.f="void");b&&(this.async=!0)}get return(){return this.f||"void"}h(a=""){const b=super.h(a,!1),c=this.v;c&&b.push(`${a} * @return {${c}}`);return b}get v(){let a="";this.f&&(a=this.return);this.async&&a?a=`Promise<${a}>`:this.async&&(a="Promise");return a}u(){return`(${this.args.map(({name:a,
type:b,optional:c})=>`${a}${c?"?":""}: ${b}`).join(", ")}) => ${this.v}`}o(a){a=super.o(a);this.f&&(this.f=this.f.replace(a,"$1"))}};const Ub=(a,b)=>{const c=new RegExp(`([!?])?${a}\\.`,"g");b.properties.forEach(d=>{ub(d,a,c)});b.o(a)},Vb=(a,b)=>{var {args:c=[]}=a,d=c.map(({J:g})=>g).join(", ");let e=`new: ${a.fullName}`;d.length&&(e=`${e}, `);d=`function(${e}${d})`;c=new U(c);c.isConstructor=!0;c.b("Constructor method.",{type:d,name:"constructor"});c.examples=a.examples;ub(c,b);a.properties.unshift(c)},Xb=(a,b,c=null)=>{a=P("types",a);if(!a.length)throw Error("XML file should contain root types element.");const [{content:d,props:{namespace:e,
ns:g=e}}]=a,f=b==g?void 0:g;a=P(["embed"],d).map(({props:l})=>l);const h=[],k=P("type interface constructor method import record".split(" "),d).reduce((l,{content:m,props:n,tag:q})=>{"record"==q&&(q="type",n.record=!0);const {alias:r,aliases:t,...u}=n;c&&N(u,c);var v=r?[r]:t?t.split(/, */):[];switch(q){case "type":q=new W;c&&(q.file=c);q.b(m,n,f,b);l.push(q);v.forEach(w=>{const y=new W;c&&(y.file=c);y.b(m,{...u,name:w},f,b);l.push(y)});break;case "interface":n=Wb({content:m,props:n,ns:f,C:b,location:c});
n.forEach(w=>{w.properties.some(({isConstructor:y})=>y)||Vb(w,b);w.isInterface=!0});l.push(...n);break;case "constructor":n=Wb({content:m,props:n,ns:f,C:b,location:c});n.forEach(w=>{w.properties.some(({isConstructor:y})=>y)||Vb(w,b);w.isConstructor=!0});l.push(...n);break;case "method":n=Wb({content:m,props:n,ns:f,C:b,isMethod:!0,location:c});l.push(...n);break;case "import":v=new Qb,v.b(m,n,n.ns||n.from,b),h.push(v)}return l},[]);b&&k.forEach(l=>Ub(b,l));return{namespace:g,types:k,imports:h,embeds:a}},
Yb=(a,b,c,d,e=!1,g=null)=>{const f=e?new Tb:new W;f.file=g;g=a.search(/<(prop|function|fn|static) /);let h="",k=a;1!=g&&(h=a.slice(0,g),k=a.slice(g));const {G:l,K:m}=qb(h,d);f.b(e?m:k,b,c,d);({I:a}=gb(b,l));e&&(f.closureType=a);f.args||(f.args=l);return f},Wb=({content:a,props:b,ns:c,C:d,isMethod:e=!1,location:g=null})=>{const f=[],{alias:h,aliases:k,...l}=b;b=Yb(a,b,c,d,e,g);f.push(b);(h?[h]:k?k.split(/, */):[]).forEach(m=>{m=Yb(a,{...l,name:m},c,d,e,g);m.description=`${m.description}${m.description?
" ":""}Alias of \`${l.name}\`.`;f.push(m)});return f},Zb=()=>{Object.keys(X).forEach(a=>{delete X[a]});Object.keys(Y).forEach(a=>{delete Y[a]})},X={},Y={},ac=async a=>{var b=Y[a];b?b=await b:(b=F(a),Y[a]=b,b=await b);return $b(b,a,[])},bc=(a,b=[])=>{a in X||(X[a]=ua(a,"utf8"));return $b(X[a],a,b)},$b=(a,b,c)=>{let d,e,g,f;try{({namespace:d=null,types:e,imports:g,embeds:f}=Xb(a,void 0,b))}catch(h){throw h.message=`Error while reading ${b}${B}${h.message}`,h;}e=e.filter(({fullName:h})=>c.includes(h)?
!1:!0);g=g.filter(({fullName:h})=>c.includes(h)?!1:!0);return{types:e,imports:g,namespace:d,embeds:f}};const cc=(a,b,c)=>{b=b.map(d=>d.g(!0,c));a=a.map(d=>{d=d.g();return K(c?d:L(d))});return[...b,...a].join("")},dc=(a,b,c,d=!1)=>{a=a.map(e=>e.m());a=O(...a,...[]);return`${!b||d||c.includes(b)?"":["/** @const */",`var ${b} = {}`,""].join(B)}${a}`};function ec(a,b,c){const [d,...e]=c.split(/\s+/);var g=e.includes("closure");const f=e.includes("externs"),h=e.includes("noSuppress"),k=e.includes("skipNsDecl"),l=e.includes("namespace"),m=e.includes("noEmbed")||e.includes("no-embed");let n=e.find(t=>t.startsWith("ignore:"));n=n?n.replace("ignore:","").split(","):[];let {s:q,A:r}=this.f;g&&(q=!0);f&&(r=!0);try{this.i("Detected type marker: %s",c);const {types:t,imports:u,namespace:v,embeds:w}=bc(d,n);this.emit("types",t);this.emit("types",u);g=[];
!m&&w.length&&(g=w.map(({src:E,path:mc=E,ignore:Q=n.join(","),namespace:nc=l,s:oc=q,A:pc=r,"no-suppress":qc=h})=>{E=[mc];Q&&E.push(`ignore:${Q}`);nc&&E.push("namespace");oc&&E.push("closure");pc&&E.push("ext");qc&&E.push("noSuppress");Q=E.join(" ");return ec.call(this,`${B} /* typal-embed ${Q} */${B}`,"typal-embed",Q)}));let y=g.join(""),R;q?R=cc(u,t,h):r?(R=dc(t,v,this.b,k)+B,v&&this.emit("namespace",v)):l?(v&&this.emit("namespace",v),R=fc(u,t,!0)):R=fc(u,t);return`/* ${b} ${c} */${B}${R}${y}`}catch(t){return this.i("(%s) Could not process typedef-js: %s",
c,t.message),process.env.b&&console.error(t.stack),a}}const gc={re:/^\/\*\*? (documentary|typal) (.+?) \*\/\r?\n(?:((?!\r?\n)[\s\S]+?\r?\n))?$/mg,replacement:ec},fc=(a,b,c=!1)=>{b=b.map(d=>d.g(!1,!1,c));a=a.map(d=>d.g(c)).map(K).join("");b=b.join("");return`${a}${b}`.replace(hc," * @typedef")},hc=/ \*\/\r?\n\/\*\*\r?\n \* @typedef/g;const jc={re:/( *) \* @param {(.+?)} (\[)?([^\s\]]+)\]?(?: .+)?((?:\r?\n(?: +)\* @param {(?:.+?)} \[?\4\]?(?:(?!\r?\n\s*\*(?:\/|\s*@))[\s\S])*)*)/gm,replacement:ic};
function ic(a,b,c,d,e,g,f){const h=this.f.s,k=this.f.F;let l;g=()=>{if(this.lines&&this.file){var n;{let t=n=0;for(;t<f;)t+=this.lines[n].length,n++;n={line:n,S:b.length+11}}const {line:q,S:r}=n;this.i("%s:%s:%s",this.file,q,r)}};try{l=nb(c)}catch(n){return this.i("Error while parsing the type %s",c),this.i(process.env.DEBUG?n.stack:n.message),g(),a}if(!l)return this.i("Could not parse the type %s",c),g(),a;const m=Object.values(this.types).map(({name:n,fullName:q})=>h||k?q:n);if(!Z(l,m,this.i,c,
g))return a;c=Object.values(this.types).find(({name:n,fullName:q})=>h||k?q==l.name:n==l.name);return!c||c instanceof Sb.Import?a:c.D(e,d,b,l.nullable,h,k)}
const Z=(a,b,c,d,e)=>{if(a){var g=a.name;if(!g||!"string number boolean null undefined symbol any".split(" ").includes(g)){if(g&&!a.application&&!a.function){let h=b.includes(g);h||(h=kc.includes(g));if(h)return!0;c("Type %s%s was not found.",g,d!=g?` in ${d}`:"");e()}var f=[b,c,d,e];a.application?a.application.forEach(h=>{Z(h,...f)}):a.record?Object.keys(a.record).forEach(h=>{Z(a.record[h],...f)}):a.union?a.union.forEach(h=>{Z(h,...f)}):a.function&&(Z(a.function.this,...f),Z(a.function.new,...f),
a.function.args.forEach(h=>{Z(h,...f)}),Z(a.function.variableArgs,...f),Z(a.function.return,...f))}}},kc="String Boolean Object Date Number Symbol Buffer Function RegExp".split(" ");var lc=(a,b=!1)=>{Zb();var {U:c}=Ua();const d=Wa(c);c=Va(c);return new Sb(b?[gc]:[gc,d,jc,c],a)};const rc=/( *) \* @(fnType|methodType) {(.+?)}/gm,sc=(a,b,c,d,e,g,f=d)=>{c=`${b?"static ":""}${c?"async ":""}${d}(${e}) {`;return O("/**",a," */",...null===g?[`${c} }`]:[c,` return ${`${b?g:"super"}.${f}`}(${e})`,"}"])};
function tc(a,b,c){return a.map(d=>{const e=d.name;var g=d.aliases;const f=d.static,h=d.async;let k=d.m("",!0);k=uc(k,c);const l=d.args.map(({name:m})=>m).join(", ");d=sc(k,f,h,e,l,b);g=g.map(m=>sc(k+`${B} * @alias ${e} An alias for **${e}**.`,f,h,m,l,b,e));return[d,...g].join(B)})}
class vc extends Za{constructor(a,b){super([{re:/\/\*\*(?:\s+( *) \*)? @constructor {(.+?)}[\s\S]+?(class\s+.+?\s+extends\s+(.+?)\s*){\s*}/gm,replacement(c,d,e,g,f){d=a.find(({fullName:k})=>k==e);if(!d)return console.error("Type %s in %s not found",e,b),c;c=d.properties.filter(k=>k instanceof U&&!k.isConstructor);f=tc(c,f,e);c=d.properties.find(k=>k instanceof U&&k.isConstructor);const h=c.args.map(({name:k})=>k).join(", ");f=O("/**",uc(c.m("",!0),e)," */",`constructor(${h}) {`,` super(${h})`,"}",
...f).replace(/(^|(?:\r?\n))/g,"$1 ");return O(...d.description?["/**",T(d.description)," */"]:[],`${g}{`,f,"}")}},{re:/(\/\*\*[\s\S]+?)( *\* *@implements {(.+?)})[\s\S]+?((?:export\s+(?:default\s+)?)?class\s+.+?){\s*}/gm,replacement(c,d,e,g,f){const h=a.find(({fullName:m})=>m==g);if(!h)return console.error("Type %s in %s not found",g,b),c;c=h.properties.filter(m=>m instanceof U&&!m.isConstructor);c=tc(c,null,g);const k=h.properties.find(m=>m instanceof U&&m.isConstructor),l=k.args.map(({name:m})=>
m).join(", ");c=O("/**",uc(k.m("",!0),g)," */",`constructor(${l}) { }`,...c).replace(/(^|(?:\r?\n))/g,"$1 ");return O(d.trimRight(),...h.description?[T(h.description)]:[],e," */",`${f}{`,c,"}")}},{re:rc,async replacement(c,d,e,g){const f=g.split(".");let h,k;if("methodType"==e)h=g;else if(2==f.length)[h,k]=f;else if(3==f.length)h=`${f[0]}.${f[1]}`,k=f[2];else throw Error("The @fnType should consist of _namespace.Type.propName or Type.propName");g=a.find(({fullName:l})=>l==h);if(!g)return console.error("Type %s in %s not found",
h,b),c;if("constructor"==k||"methodType"==e)return g.h(d,!1,!0).join(B);e=g.properties.find(({name:l})=>l==k);return e?e.parsed?e.m(d,!0):(console.error("Property %s of type %s in %s wasn't parsed, possibly parser bug.",k,h,b),c):(console.error("Property %s of type %s in %s not found",k,h,b),c)}}])}}const uc=(a,b)=>a.replace(`${B} * @return {${b}}`,"").replace(`${B} * @return {!${b}}`,"").replace(`${B} * @return {?${b}}`,"");const wc=async a=>a?(await Promise.all(a.split(",").map(async b=>{var c=[];const d=await H(z,b);d.isFile()?c=[b]:d.isDirectory()&&(c=await I(b),c=J(c.content,b),c=c.filter(e=>e.endsWith(".xml")));return c}))).reduce((b,c)=>[...b,...c],[]):[],xc=async a=>(await Promise.all(a.map(async b=>({...await ac(b),location:b})))).reduce((b,{imports:c,types:d})=>{b.push(...c);b.push(...d);return b},[]);
async function yc(){Zb();const a=await wc(na),b=await xc(a);await Promise.all(x.map(async c=>{var d=await H(z,c);let e;d.isFile()?e=[c]:d.isDirectory()&&(d=await I(c),e=J(d.content,c));await zc(e,b,oa)}))}const zc=async(a,b=[],c=null)=>{await Promise.all(a.map(async d=>{var e=await F(d);const g=new vc(b,d);g.end(e);e=await D(g);"-"==c?console.log(e):c?await G(c,e):await G(d,e)}))};var Bc=async()=>{const {s:a=!1,F:b=!1,A:c=!1,W:d,types:e}={s:ka,A:ma,W:ja,types:na,F:la},g=await wc(e);await Promise.all(x.map(async f=>{var h=await H(z,f);let k;h.isFile()?k=[f]:h.isDirectory()&&(h=await I(f),k=J(h.content,f));await Ac(k,a,c,d,g,b)}))};
const Ac=async(a,b=!1,c=!1,d="",e=[],g=!1)=>{const f=[];await Promise.all(e.map(async h=>{h=await F(h);const {types:k,imports:l}=Xb(h);f.push(k,l)}));await Promise.all(a.map(async h=>{var k=await F(h);const l=lc({s:b,A:c,F:g},c);f.forEach(m=>l.emit("types",m));l.file=h;l.i=console.error;l.lines=k.split(B);l.end(k);k=await D(l);"-"==d?console.log(k):d?await G(d,k):await G(h,k)}))};const Cc=a=>{let b;"true"==a?b=!0:"false"==a?b=!1:/^\d+$/.test(a)&&(b=parseInt(a,10));return void 0!==b?b:a},Dc=/^ \* @prop {(.+?)} (\[)?(.+?)(?:=(["'])?(.+?)\4)?(?:])?(?: (.+?))?(?: Default `(.+?)`.)?$/gm,Ec="type opt name quote defaultValue description Default".split(" "),ab=new RegExp(`^ \\* @typedef {(.+?)} (.+?)(?: (.+))?\\r?\\n((?:${/ \* @prop(?:erty)? .+\r?\n/.source})*)`,"gm"),Fc=(a,b,c,d)=>{d=d.length;a=a&&"Object"!=a?` type="${a}"`:"";c=c?` desc="${c}"`:"";return`${" ".repeat(2)}<type name="${b}"${a}${c}${d?
"":" /"}>${B}`};
class Gc extends A{constructor(){super({writableObjectMode:!0})}_transform({type:a,name:b,description:c,properties:d},e,g){a=a&&a.startsWith("import")?Hc(a,b):Fc(a,b,c,d);this.push(a);d.forEach(({type:f,name:h,default:k,description:l,optional:m})=>{{f=["string","number","boolean"].includes(f)?` ${f}`:` type="${f}"`;var n=void 0!==k;k=n?` default="${k}"`:"";m=m&&!n?" opt":"";n=" ".repeat(4);const q=" ".repeat(6);h=`${n}<prop${m}${f} name="${h}"${k}${l?`>${B}${q}${l}${B}${n}</prop>`:"/>"}${B}`}this.push(h)});
d.length&&this.push(` </type>${B}`);g()}}const Hc=(a,b)=>{const c=/import\((['"])(.+?)\1\)/.exec(a);if(!c)throw Error(`Could not extract package from "${a}"`);[,,a]=c;return`${" ".repeat(2)}<import name="${b}" from="${a}" />${B}`};
class Ic extends A{constructor(){super({objectMode:!0})}_transform([,a,b,c,d],e,g){d=hb(Dc,d,Ec).map(f=>{const {defaultValue:h,Default:k,opt:l,name:m,type:n,...q}=f;f={...q,name:m,type:n,...h?{defaultValue:Cc(h)}:{},...k?{w:Cc(k)}:{},...l?{optional:!0}:{}};if(h||k){if(h)h!==k&&void 0!==f.w&&(r=bb(m,k,n),console.error("%s[%s] does not match Default `%s`.",b,r,f.w));else{var r=bb(m,k,n);console.error("%s[%s] got from Default.",b,r)}f.default="defaultValue"in f?f.defaultValue:f.w;delete f.defaultValue;
delete f.w}return f});this.push({type:a,name:b,description:c,properties:d});g()}}async function Jc(a){const b=$a(),c=new Ic,d=new Gc;b.pipe(c).pipe(d);b.end(a);b.on("error",e=>{console.error("Error in Transform");d.emit("error",e)});c.on("error",e=>{console.error("Error in RegexTransform");d.emit("error",e)});d.on("error",e=>{console.error("Error in XML");d.emit("error",e)});return["<types>",` ${(await D(d)).trim()}`,"</types>"].join(B)};var Kc=async()=>{await Promise.all(x.map(async a=>{a=await F(a);a=await Jc(a);ja?await G(ja,a):console.log(a)}))};/*

@@ -1917,18 +102,2 @@ Typal: keep types information in XML files to embed as typedefs,

*/
if (q.help) {
const a = ia();
console.log(qa({usage:a, description:"Embeds and maintains Closure-compatible types JSDoc in\nJavaScript source code from an external types.xml file.", line:"typal source [--closure|externs] [--migrate] [-o output] [-hv]", example:"typal src/index.js -c"}));
process.exit();
} else {
pa && (console.log(require("../../package.json").version), process.exit());
}
(async() => {
try {
return oa ? await Fc() : na ? await tc() : await wc();
} catch (a) {
process.env.DEBUG ? console.log(a.stack) : console.log(a.message);
}
})();
//# sourceMappingURL=typal.js.map
if(p.help){const a=ia();console.log(ra({usage:a,description:"Embeds and maintains Closure-compatible types JSDoc in\nJavaScript source code from an external types.xml file.",line:"typal source [--closure|externs] [--migrate] [-o output] [-hv]",example:"typal src/index.js -c"}));process.exit()}else qa&&(console.log(require("../../package.json").version),process.exit());(async()=>{try{return pa?await Kc():oa?await yc():await Bc()}catch(a){process.env.DEBUG?console.log(a.stack):console.log(a.message)}})();

@@ -18,3 +18,7 @@ const { _parseFile, _getLinks } = require('./typal')

* @param {string|!_typedefsParser.Type} type The type or parsed type that should be serialised.
* @param {!_typal.LinkingOptions=} [opts] Options for linking.
* @param {!_typal.LinkingOptions} [opts] Options for linking.
* @param {boolean} [opts.escapePipe=true] Escapes the `|` in unions so it becomes `\|`. Default `true`.
* @param {boolean|function(string): void} [opts.flatten=false] Whether to follow links of referenced types. This will exclude them from printing in imports when compiling _README_ documentation. If function is passed, it will be called with the name of flattened type. Default `false`.
* @param {(info: { link: string, type: !_typal.Type }) => string} [opts.link] The function to get a link to the type. By default, prepends `#` to the generated link, but in case of _Wiki_ generation, _Documentary_ will make sure that types can be linked across pages.
* @param {(name: string, odd?: boolean) => string} [opts.nameProcess] Preprocessor for the name of the type. Can be used to include icons.
* @return {string}

@@ -31,10 +35,113 @@ */

/* typal types/Type.xml namespace */
/**
* @typedef {import('../types').Type} _typal.Type
* @typedef {_typal.Type} Type `@interface` A representation of a type.
* @typedef {Object} _typal.Type `@interface` A representation of a type.
* @prop {string} name The name of the type.
* @prop {?string} type The type of the type. Default `null`.
* @prop {?string} closureType An overriding type for closure to generate externs, e.g., `function(string): boolean` instead of `(s:string) => boolean`. Default `null`.
* @prop {?string} description The description of the type. Default `null`.
* @prop {boolean} noToc Whether the type should not be included in the table of contents (for _Documentary_). Default `false`.
* @prop {boolean} spread When generating JSDoc, print all properties of the type, but loose individual property description. Default `false`.
* @prop {boolean} noExpand Don't print each property description. Default `false`.
* @prop {boolean} import Whether the type as an import. Default `false`.
* @prop {?string} link The link to the documentation page. Default `null`.
* @prop {!Array<!(_typal.Property|_typal.Fn)>} properties The properties of the type. Default `[]`.
* @prop {?string} namespace The type's namespace, e.g., `_typal`. Default `null`.
* @prop {string} ns The namespace or an empty string.
* @prop {string} fullName The type name with the namespace if it has with one.
* @prop {boolean} isConstructor Whether the externs should have the form of
* ```js
* /** @constructor */
* _ns.Type
* /** @boolean */
* _ns.Type.prototype.isConstructor
* ```
* Default `false`.
* @prop {boolean} isInterface Same as `constructor`, but with `@interface` annotation.
* ```js
* /** @interface */
* _ns.Type
* /** @boolean */
* _ns.Type.prototype.isInterface
* ```
* Default `false`.
* @prop {boolean} isRecord Same as `constructor`, but with `@record` annotation.
* ```js
* /** @record */
* _ns.Type
* /** @boolean */
* _ns.Type.prototype.isRecord
* ```
* Default `false`.
* @prop {?string} extends Types `@constructor`, `@interface` and `@record` can inherit properties from other types using `@extends`. [Closure Wiki](https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler#extends-type). Default `null`.
* @prop {Array<!_typal.Arg>} args Constructors and interfaces can have arguments defined in _types.xml_, which will be parsed and stored in this property. Default `null`.
* @prop {!Array<string>} examples Examples that have been read. Default `[]`.
* @prop {(allTypes: !Array<!_typal.Type>, opts: !_typal.ToMarkdownOptions) => { LINE: string, table: (string|{ props: !Array<{ prop: !_typal.Property, typeName: (string|!_typedefsParser.Type), name: string, de: string, d: string }>, anyHaveDefault: boolean, constr: boolean }), displayInDetails: boolean }} toMarkdown Converts a type to a markdown string. This function is closely integrated with the _Documentary_ package, however can also be used to get a standard markdown string with properties in a table.
*/
/* typal types/Property.xml namespace */
/**
* @typedef {import('../types').Import} _typal.Import
* @typedef {import('@typedefs/parser').Type} _typedefsParser.Type
* @typedef {_typal.Property} Property `@interface` A property of a type.
* @typedef {Object} _typal.Property `@interface` A property of a type.
* @prop {string} name The name of the property.
* @prop {?string} description The description of the property. Default `null`.
* @prop {string} type The type of the property. Default `*`.
* @prop {boolean} hasDefault Whether the property has the default value. Default `false`.
* @prop {?(string|boolean|number)} default The default value of the property. Default `null`.
* @prop {boolean} optional If the property is optional. Default `false`.
* @prop {Array<!_typal.Arg>} args Function properties can have arguments specified inside of their tags. Default `null`.
* @prop {boolean} isParsedFunction Whether the property is a function which was parsed. Default `false`.
* @prop {!Array<string>} aliases What aliases the property has. Default `[]`.
* @prop {boolean} static When writing externs, this will prevent adding `.prototype`, e.g., `Type.static` instead of `Type.prototype.static`. Default `false`.
* @prop {!Array<string>} examples Examples that have been read. Default `[]`.
* @prop {_typedefsParser.Type} parsed Whether the property is a function which was parsed. Default `null`.
* @prop {(getLinks: function(!_typedefsParser.Type): string) => string} toTypeScriptFunction If the function was a parsed function, returns _TypeScript_ type.
*/
/* typal types/Arg.xml namespace */
/**
* @typedef {import('../types').LinkingOptions} _typal.LinkingOptions
* @typedef {_typal.Arg} Arg `@interface` An argument of a constructor or method.
* @typedef {Object} _typal.Arg `@interface` An argument of a constructor or method.
* @prop {?string} name The name of the argument. Default `null`.
* @prop {string} type The type of the argument. Default ``.
* @prop {boolean} optional Whether the argument is optional. Default `false`.
* @prop {string} description Description of the argument. Default ``.
*/
/* typal types/Method.xml namespace */
/**
* @typedef {_typal.Method} Method `@interface` A representation of a type.
* @typedef {_typal.$Method & _typal.Type} _typal.Method `@interface` A representation of a type.
* @typedef {Object} _typal.$Method `@interface` A representation of a type.
* @prop {string} return The return type of the method. Returns void if no return was specified. Default `void`.
* @prop {boolean} isMethod Can be used to disambiguate methods from other types. Default `true`.
* @prop {boolean} async If the method is async. Default `false`.
*/
/* typal types/Import.xml namespace */
/**
* @typedef {_typal.Import} Import `@interface` A representation of an import.
* @typedef {_typal.$Import & _typal.Type} _typal.Import `@interface` A representation of an import.
* @typedef {Object} _typal.$Import `@interface` A representation of an import.
* @prop {boolean} import Can be used to disambiguate import from other types. Default `true`.
* @prop {string} from Which package (or internal module) to import the type from.
* @prop {string} ns The namespace, which can be set different to "from", e.g., `from` can be set to `@typedefs/parser` and `ns` to `_typedefs`.
*/
/* typal types/markdown.xml namespace */
/**
* @typedef {_typal.ToMarkdownOptions} ToMarkdownOptions `@record` These options are there for _Documentary_ integration as these 2 packages work together.
* @typedef {_typal.$ToMarkdownOptions & _typal.LinkingOptions} _typal.ToMarkdownOptions `@record` These options are there for _Documentary_ integration as these 2 packages work together.
* @typedef {Object} _typal.$ToMarkdownOptions `@record` These options are there for _Documentary_ integration as these 2 packages work together.
* @prop {boolean} [narrow=false] If specified, this will return an object `{ props: ps, anyHaveDefault, constr }` for _Documentary_. Otherwise, returns a string. Semi-private API. Default `false`.
* @prop {!Array<string>} [details] The list of types that should be displayed in a `<details>` element, with the name and description as summary, and the properties table inside.
* @prop {(description: string) => string} [preprocessDesc] How to process description. _Documentary_ will strip the triple-backtick code blocks and insert them manually at the end to avoid any transforms in them.
* @typedef {_typal.LinkingOptions} LinkingOptions `@record` Options for linking.
* @typedef {Object} _typal.LinkingOptions `@record` Options for linking.
* @prop {boolean} [escapePipe=true] Escapes the `|` in unions so it becomes `\|`. Default `true`.
* @prop {boolean|function(string): void} [flatten=false] Whether to follow links of referenced types. This will exclude them from printing in imports when compiling _README_ documentation. If function is passed, it will be called with the name of flattened type. Default `false`.
* @prop {(info: { link: string, type: !_typal.Type }) => string} [link] The function to get a link to the type. By default, prepends `#` to the generated link, but in case of _Wiki_ generation, _Documentary_ will make sure that types can be linked across pages.
* @prop {(name: string, odd?: boolean) => string} [nameProcess] Preprocessor for the name of the type. Can be used to include icons.
*/

@@ -22,10 +22,12 @@ const { _parseFile, _getLinks } = require('./typal')

/**
* @typedef {import('../types').Type} _typal.Type
*/
/**
* @typedef {import('../types').Import} _typal.Import
*/
/**
* @typedef {import('../types').LinkingOptions} _typal.LinkingOptions
*/
/* typal types/Type.xml namespace */
/* typal types/Property.xml namespace */
/* typal types/Arg.xml namespace */
/* typal types/Method.xml namespace */
/* typal types/Import.xml namespace */
/* typal types/markdown.xml namespace */

@@ -6,723 +6,24 @@ #!/usr/bin/env node

const path = require('path');
const stream = require('stream');
var w = "function" == typeof Object.defineProperties ? Object.defineProperty : function(a, b, d) {
a != Array.prototype && a != Object.prototype && (a[b] = d.value);
};
function x(a) {
a = ["object" == typeof window && window, "object" == typeof self && self, "object" == typeof global && global, a];
for (var b = 0; b < a.length; ++b) {
var d = a[b];
if (d && d.Math == Math) {
return d;
}
}
throw Error("Cannot find global object");
}
var y = x(this);
function A(a, b) {
if (b) {
var d = y;
a = a.split(".");
for (var c = 0; c < a.length - 1; c++) {
var f = a[c];
f in d || (d[f] = {});
d = d[f];
}
a = a[a.length - 1];
c = d[a];
b = b(c);
b != c && null != b && w(d, a, {configurable:!0, writable:!0, value:b});
}
}
A("String.prototype.trimRight", function(a) {
function b() {
return this.replace(/[\s\xa0]+$/, "");
}
return a || b;
});
const B = os.EOL;
function C(a, b, d) {
const c = [];
b.replace(a, (f, ...g) => {
f = g.slice(0, g.length - 2).reduce((e, k, h) => {
h = d[h];
if (!h || void 0 === k) {
return e;
}
e[h] = k;
return e;
}, {});
c.push(f);
});
return c;
}
;const D = new RegExp(`${/([^\s>=/]+)/.source}(?:\\s*=\\s*${/(?:"([\s\S]*?)"|'([\s\S]*?)')/.source})?`, "g"), E = new RegExp(`(?:\\s+((?:${D.source}\\s*)*))`);
const G = (a, b) => {
a = (Array.isArray(a) ? a : [a]).join("|");
return C(new RegExp(`<(${a})${E.source}?(?:${/\s*\/>/.source}|${/>([\s\S]+?)?<\/\1>/.source})`, "g"), b, "t a v v1 v2 c".split(" ")).map(({t:d, a:c = "", c:f = ""}) => {
c = c.replace(/\/$/, "").trim();
c = F(c);
return {content:f, props:c, tag:d};
});
}, F = a => C(D, a, ["key", "val", "def", "f"]).reduce((b, {key:d, val:c}) => {
if (void 0 === c) {
return b[d] = !0, b;
}
b[d] = "true" == c ? !0 : "false" == c ? !1 : /^\d+$/.test(c) ? parseInt(c, 10) : c;
return b;
}, {});
const aa = a => a.split(/([!?=*(),:.<>{}|\s+])/g).filter(b => /\S/.test(b)).map(b => {
switch(b) {
case "function":
return "function";
case "Function":
return "Function";
case "!":
return "nonNullable";
case "?":
return "nullable";
case "=":
return "=";
case "*":
return "any";
}
return b;
});
function ba(a) {
let b = 0;
const d = (f = 1) => a[b + f], c = (f = !0, g = []) => {
var e = {};
let k = a[b];
if (["nullable", "nonNullable"].includes(k)) {
if (!f) {
throw Error(`${k} not allowed after .`);
}
e.nullable = "nullable" === k;
b++;
}
k = a[b];
if ("(" == k) {
b++;
e = {...c(!0, []), ...e};
if (")" != a[b]) {
throw Error("Expecting closing )");
}
b++;
if ("|" != a[b]) {
return e;
}
} else {
if ("{" == k) {
b++;
g = e;
for (f = {}; "}" != a[b];) {
var h = a[b];
b++;
f[h] = null;
if (":" == a[b]) {
b++;
try {
var l = c();
f[h] = l;
} catch (m) {
throw m.message += `(when parsing ${h} property)`, m;
}
}
if ("}" == a[b]) {
b++;
break;
}
if ("," != a[b]) {
throw Error(`Expecting , for record after ${h}`);
}
b++;
}
g.record = f;
return e;
}
}
if (["nonNullable", "nullable"].includes(k)) {
throw Error("Nullability already defined.");
}
if (/[=),:.<>}|]/.test(k)) {
throw Error(`Unexpected token ${k}.`);
}
"|" != a[b] && (e.name = a[b], b++);
if ("function" == k) {
l = e;
h = {return:null, args:[]};
if ("(" != a[b]) {
throw Error("Expecting opening (");
}
b++;
for (var n; ")" != a[b];) {
if (n && "this" == a[b]) {
throw Error("this must come first in function arguments");
}
if (n && "new" == a[b]) {
throw Error("new must come first in function arguments");
}
if ("this" == a[b]) {
b++;
if (":" != a[b]) {
throw Error("Expecting :");
}
b++;
h.this = c();
} else {
if ("new" == a[b]) {
b++;
if (":" != a[b]) {
throw Error("Expecting :");
}
b++;
h.new = c();
} else {
if ("." == a[b] && "." == d() && "." == d(2)) {
b++;
b++;
b++;
n = c();
if (")" != a[b]) {
throw Error("Variable args must come last");
}
h.variableArgs = n;
} else {
n = c(), h.args.push(n), "=" == a[b] && (n.optional = !0, b++);
}
}
}
n = !0;
if (")" == a[b]) {
break;
}
if ("," == a[b]) {
b++;
} else {
throw Error("Expecting , between arguments");
}
}
b++;
":" == a[b] && (b++, n = c(), void 0 == n.name && n.nullable && (n.name = ""), h.return = n);
l.function = h;
} else {
if ("<" == a[b] || (h = "." == a[b] && "<" == d())) {
b++;
h && b++;
l = e;
for (h = []; ">" != a[b];) {
n = c();
h.push(n);
if (">" == a[b]) {
break;
}
if ("," == a[b]) {
b++;
} else {
throw Error("Expecting , between applications");
}
}
b++;
l.application = h;
}
}
for (; "." == a[b];) {
e.name += ".";
b++;
({name:l} = c(!1));
if (!l) {
throw Error("Expected to see the name after .");
}
e.name += l;
}
if ("|" != a[b] || !f) {
return e;
}
for (g.push(e); "|" == a[b];) {
b++, e = c(!0, g), e.union !== g && g.push(e);
}
return {union:g};
};
return c();
}
;function H(a) {
a = aa(a);
return ba(a);
}
;const ca = path.dirname, da = path.resolve;
const I = ({A:a, C:b, l:d, type:c}) => b ? "string" : a ? "number" : d ? "boolean" : c ? c : "*", ea = a => {
const b = a.split(/\r?\n/).map(d => {
let c = Infinity;
d.replace(/\S/, (f, g) => {
c = g;
});
return c;
}).reduce((d, c) => c < d ? c : d, Infinity);
return a.replace(new RegExp(`^ {${b}}`, "gm"), "");
}, J = a => {
a = a.trimRight();
a = a.replace(/^\s*\r?\n( *\S)/, "$1");
return ea(a);
}, K = (a, b, d = null) => {
const {async:c, "void":f, "return":g = f ? "void" : "", ...e} = a;
({args:a = ""} = a);
a || (a = b.map(({s:k, name:h}) => "this" == h ? `${h}: ${k}` : h.startsWith("...") ? `...${k}` : k).join(","));
b = g.replace(/\r?\n\s*/g, " ");
c && b ? b = `!Promise<${b}>` : c && (b = "!Promise");
d = `function(${"constructor" == e.name ? `new: ${d}, ` : ""}${a})`;
b && (d += `: ${b}`);
return {F:{...e, async:c, return:b}, o:d};
};
function L(a, b) {
const d = a.example;
d && d.startsWith(".") && b && (a.example = da(ca(b), d));
}
;function fa(a, b, {name:d, string:c, "boolean":f, opt:g, number:e, type:k}, h) {
if (!d) {
throw Error("Argument does not have a name.");
}
a.name = d;
b && (a.description = J(b));
b = I({A:e, C:c, l:f, type:k});
h && (b = b.replace(new RegExp(`([!?])?${h}\\.`, "g"), "$1"));
b.endsWith("=") && (b = b.replace(/=$/, ""), g = !0);
a.type = b;
g && (a.optional = !0);
}
class ha {
constructor() {
this.name = null;
this.type = "";
this.optional = !1;
this.description = "";
}
get s() {
return this.optional ? `${this.type}=` : this.type;
}
}
const M = (a, b) => {
let d = a.lastIndexOf("</arg>"), c = a;
var f = [];
-1 != d && (d += 6, f = a.slice(0, d), c = a.slice(d), f = G("arg", f), f = f.map(({content:g, props:e}) => {
const k = new ha;
fa(k, g, e, b);
return k;
}));
return {w:c, j:f};
};
const ia = fs.readFileSync;
const ja = a => {
const b = a.replace(/^\s*\r?\n/gm, "").split(B).reduce((d, c) => {
[{length:c = 0} = {}] = /^\s*/.exec(c) || [];
return c < d ? c : d;
}, Infinity);
return a.replace(new RegExp(`^ {${b}}`, "gm"), "");
};
function N(a, b = "") {
const d = b.split(/\s*,\s*/);
return a.split(/\s*,\s*/).map(c => {
let f = c = ia(c, "utf8");
if (c = /\/\* start example \*\/\r?\n([\s\S]+?)\r?\n\s*\/\* end example \*\//.exec(c)) {
[, c] = c, f = ja(c);
}
d.forEach(g => {
const [e, k] = g.split(/\s*=>\s*/);
f = f.replace(`'${e}'`, `'${k}'`);
f = f.replace(`"${e}"`, `"${k}"`);
});
return f = f.replace(/@/g, "\uff20");
});
}
function O(a, b, d = new RegExp(`([!?])?${b}\\.`, "g")) {
b && (a.f && (a.f = a.f.replace(d, "$1")), a.type = a.type.replace(d, "$1"));
}
class P {
constructor(a = null) {
this.h = this.description = this.name = null;
this.u = "";
this.default = this.f = null;
this.optional = !1;
this.aliases = [];
this.v = !1;
this.parsed = null;
this.args = a;
this.g = !1;
this.examples = [];
}
toTypeScriptFunction(a) {
if (!this.parsed) {
throw Error("The property was not parsed.");
}
let {function:{new:b, args:d, return:c, this:f, variableArgs:g}} = this.parsed;
b && (c = b);
var e = d.map(h => a(h)).map((h, l) => {
const {optional:n} = d[l];
let {name:m = `arg${l}`, optional:p = n} = this.D[l] || {};
return `${`${m}${p ? "?" : ""}`}: ${h}`;
});
if (f) {
var k = a(f);
e.unshift(`this: ${k}`);
}
if (g) {
k = a(g);
let h = "...args";
try {
h = `${this.args[this.args.length - 1].name}`;
} catch (l) {
}
e.push(`${h}: ${k}[]`);
}
e = e.join(", ");
k = c ? a(c) : "?";
e = `(${e}) => ${k}`;
b && (e = "new " + e);
return e;
}
get static() {
return this.g;
}
get hasDefault() {
return null !== this.default;
}
b(a, {name:b, string:d, "boolean":c, opt:f, number:g, type:e, "default":k, closure:h, alias:l, aliases:n, example:m, "example-override":p = "", noParams:q, "static":r, initial:t}) {
if (!b) {
throw Error("Property does not have a name.");
}
this.name = b;
a && (this.description = J(a));
a = I({A:g, C:d, l:c, type:e});
q && (this.v = q);
h && (this.f = h);
this.type = a;
void 0 !== k ? this.default = k : void 0 !== t && (this.default = t);
if (f || void 0 !== k) {
this.optional = !0;
}
l && (this.aliases = [l]);
n && (this.aliases = n.split(/\s*,\s*/));
r && (this.g = !0);
m && (this.examples = N(m, p));
}
get type() {
return this.h || "*";
}
set type(a) {
this.h = a || null;
this.u = this.f || this.h || "";
if (!this.v) {
try {
this.parsed = H(this.u), this.isParsedFunction && !this.args && (this.args = []);
} catch (b) {
this.parsed = null;
}
}
}
get D() {
var a = this.args;
this.args && this.args[0] && "this" == this.args[0].name && ([, ...a] = this.args);
return a;
}
get isParsedFunction() {
return !!this.parsed && "function" == this.parsed.name;
}
}
;class Q extends P {
constructor(...a) {
super(...a);
this.isConstructor = this.async = !1;
this.return = "";
}
b(a, b) {
super.b(a, b);
"constructor" == b.name && (this.isConstructor = !0);
this.async = b.async;
this.return = b.return;
}
}
;function ka(a, b, d, c) {
var f = G("prop", a).map(({content:h, props:l}) => {
const n = new P;
L(l, d);
n.b(h, l);
return n;
});
a = G(["function", "fn", "static"], a).map(({content:h, props:l, tag:n}) => {
n = "static" == n;
const {w:m, j:p} = M(h, b);
h = new Q(p);
const {F:q, o:r} = K(l, p, c);
q.type = r;
L(q, d);
h.b(m, q);
n && (h.g = !0);
return h;
});
f = [...f, ...a];
const {m:g, B:e, n:k} = f.reduce((h, l) => {
l.isConstructor ? h.m.push(l) : l.static ? h.B.push(l) : h.n.push(l);
return h;
}, {m:[], B:[], n:[]});
return {constructor:g[0] || null, properties:[...g, ...e, ...k]};
}
;const S = (a, b, d = {}) => {
let c;
if ("object" == typeof b) {
c = b;
} else {
try {
(c = H(b)) || console.log("Could not parse %s", b);
} catch (f) {
console.log("Could not parse %s", b), console.error(f.message);
}
}
return c ? R(c, a, d) : b;
}, R = (a, b, d = {}) => {
if ("" == a.name && a.nullable) {
return "?";
}
var {escapePipe:c = !0} = d;
let f = "";
var g = "";
a.nullable ? g = "?" : !1 === a.nullable && (g = "!");
if (a.function) {
f = f + g + (a.name + "(");
const e = [];
a.function.this && (c = "this: " + R(a.function.this, b, d), e.push(c));
a.function.new && (c = "new: " + R(a.function.new, b, d), e.push(c));
a.function.args.forEach(k => {
let h = R(k, b, d);
k.optional && (h += "=");
e.push(h);
});
a.function.variableArgs && (c = "..." + R(a.function.variableArgs, b, d), e.push(c));
c = e.join(", ");
f += c + ")";
a.function.return && (f += ": " + R(a.function.return, b, d));
} else {
a.record ? (f += "{ ", c = Object.keys(a.record).map(e => {
var k = a.record[e];
if (!k) {
return e;
}
k = R(k, b, d);
return `${e}: ${k}`;
}), f += c.join(", "), f += " }") : a.application ? (f += T(a.name, b, g, d) + "&lt;", c = a.application.map(e => R(e, b, d)), f += c.join(", "), f += "&gt;") : a.union ? (f = f + g + "(", g = a.union.map(e => R(e, b, d)), f += g.join(c ? " \\| " : " | "), f += ")") : f += T("any" == a.name ? "*" : a.name, b, g, d);
}
return f;
}, T = (a, b, d = "", c = {}) => {
const {flatten:f = !1, nameProcess:g, link:e = ({link:l}) => `#${l}`} = c;
c = la(b, a);
d = `${d}${a}`;
if (!c) {
return d;
}
let {link:k, type:{description:h}} = c;
f && ((b = b.find(({fullName:l}) => l == a)) && b.link && (k = b.link), !h && b.description && (h = b.description), "function" == typeof f && f(a));
c.link == k && (k = e(c));
b = g ? g(d) : d;
return h ? `<a href="${k}" title="${h.replace(/"/g, "&quot;")}">${b}</a>` : `[${b}](${k})`;
}, la = (a, b) => {
a = a.filter(({fullName:c}) => c == b);
if (a.length) {
var d = a.find(({import:c}) => c || !1);
a = a.find(({import:c}) => !c) || d;
return {link:`${"type"}-${a.fullName.replace(/<\/?code>/g, "").replace(/<\/?strong>/g, "").replace(/<br\/>/g, "").replace(/&nbsp;/g, "").replace(/[^\w-\d ]/g, "").toLowerCase().replace(/[, ]/g, "-")}`, type:a};
}
};
function ma(a, b = [], d = [], c = {}) {
const {narrow:f = !1, preprocessDesc:g} = c;
if (!b.length) {
return "";
}
const e = a.isConstructor || a.isInterface, k = b.some(({hasDefault:m}) => m), h = {escapePipe:!f, ...c};
let l;
const n = m => S(d, m, {...h, nameProcess:c.nameProcess ? p => c.nameProcess(p, l) : void 0});
a = b.map((m, p) => {
l = 0 < (p + 1) % 2;
p = m.args && m.isParsedFunction ? m.toTypeScriptFunction(n) : n(m.parsed || m.type);
const q = e || m.optional ? m.name : `${m.name}*`, r = m.hasDefault ? `\`${m.default}\`` : "-", t = g ? g(m.description) : m.description;
return {prop:m, typeName:p, name:q, de:na(t, !f), d:r, G:l};
});
if (f) {
return {props:a, anyHaveDefault:k, constr:e};
}
a = a.map(({name:m, typeName:p, de:q, d:r, prop:t}) => [t.optional ? m : `__${m}__`, `<em>${p}</em>`, q, ...k ? [r] : []]);
b = ["Name", ...f ? ["Type & Description"] : ["Type", "Description"], ...k ? [e ? "Initial" : "Default"] : []];
return ["", "", "```table", JSON.stringify([b, ...a], null, 2).replace(/\n/g, B), "```"].join(B);
}
const na = (a = "", b = !0) => {
null === a && (a = "");
b && (a = a.replace(/\|/g, "\\|"));
return a.replace(/</g, "&lt;").replace(/>/g, "&gt;");
};
const oa = (a, b, d = {}) => {
function c(f) {
f.replace(/^!?/, "");
return `\`${f}\``;
}
return a.split(/,\s*/).map(f => S(b, f, {flatten:!0, ...d, nameProcess:d.nameProcess ? g => {
g = d.nameProcess(g);
return /[_*~>]/.test(g) ? `<code>${g}</code>` : c(g);
} : c})).join(", ");
};
class U {
constructor() {
this.name = "";
this.description = this.closureType = this.type = null;
this.noExpand = this.spread = this.noToc = !1;
this.link = null;
this.properties = [];
this.namespace = null;
this.isRecord = this.isInterface = this.isConstructor = !1;
this.args = this.extends = null;
this.examples = [];
this.g = null;
}
get import() {
return !1;
}
b(a, {name:b, type:d, desc:c, noToc:f, spread:g, noExpand:e, link:k, closure:h, constructor:l, "extends":n, "interface":m, record:p, example:q, "example-override":r}, t, z = null) {
if (!b) {
throw Error("Type does not have a name.");
}
this.name = b;
d && (this.type = d);
h ? this.closureType = h : this.closureType = this.type;
c && (this.description = J(c));
this.noToc = !!f;
this.spread = !!g;
this.noExpand = !!e;
k && (this.link = k);
!0 === l && (this.isConstructor = l);
!0 === m && (this.isInterface = m);
!0 === p && (this.isRecord = p);
n && (this.extends = n);
t && (this.namespace = t);
if (a) {
const {properties:u, constructor:v} = ka(a, z, this.g, this.fullName);
v && (this.args = v.args);
this.properties = u;
}
q && (a = {example:q}, L(a, this.g), this.examples = N(a.example, r));
}
h(a, b = new RegExp(`([!?])?${a}\\.`, "g")) {
this.type && (this.type = this.type.replace(b, "$1"));
this.extends && (this.extends = this.extends.replace(b, "$1"));
return b;
}
get tag() {
return this.isConstructor ? "constructor" : this.isInterface ? "interface" : this.isRecord ? "record" : "";
}
get ns() {
return this.namespace ? `${this.namespace}.` : "";
}
get fullName() {
return `${this.ns}${this.name}`;
}
toMarkdown(a = [], b = {}) {
const {flatten:d, details:c = []} = b, f = c.includes(this.name);
var g = this.type ? `\`${this.type}\`` : "", e = g;
this.link ? e = `[${g}](${this.link})` : !this.import && this.type && (e = S(a, this.type, b), g = e != this.type, e = V(e, g));
g = V(this.fullName);
g = this.import ? `[${g}](l-type)` : this.noToc ? `[${g}](l-type)` : `[${g}](t-type)`;
const k = this.description ? `: ${this.description}` : "";
e = e ? `${e} ` : "";
let h = /_/.test(g);
if (this.extends) {
const l = oa(this.extends, a, b), n = ` extends ${l}`;
h = h || /_/.test(l);
e = (h ? e + "<strong>" : e + "__") + (g + n);
"function" == typeof d && d(this.extends);
} else {
e = (h ? e + "<strong>" : e + "__") + g;
}
e = (h ? e + "</strong>" : e + "__") + k;
a = ma(this, this.properties, a, b);
return {LINE:e, table:a, displayInDetails:f};
}
}
const V = (a, b = !1) => `${b ? "<code>" : "`"}${a}${b ? "</code>" : "`"}`;
class W extends U {
constructor() {
super();
this.f = null;
this.async = !1;
}
get isMethod() {
return !0;
}
b(a, {async:b, "return":d, "void":c, ...f}, ...g) {
this.description = J(a);
super.b("", f, ...g);
d && (this.f = d.replace(/\r?\n\s*/g, " "));
c && (this.f = "void");
b && (this.async = !0);
}
get return() {
return this.f || "void";
}
h(a) {
a = super.h(a);
this.f && (this.f = this.f.replace(a, "$1"));
}
}
;class pa extends U {
constructor() {
super();
this.from = "";
}
get import() {
return !0;
}
b(a, {from:b, name:d, ...c}, f, g) {
if (!b) {
throw Error("From attribute of import is not given.");
}
this.from = b;
this.description = J(a);
super.b("", {...c, noToc:!0, name:d, type:`import('${b}').${d}`}, f != g ? f : null);
}
}
;const qa = (a, b) => {
const d = new RegExp(`([!?])?${a}\\.`, "g");
b.properties.forEach(c => {
O(c, a, d);
});
b.h(a);
}, X = (a, b) => {
var {args:d = []} = a, c = d.map(({s:g}) => g).join(", ");
let f = `new: ${a.fullName}`;
c.length && (f = `${f}, `);
c = `function(${f}${c})`;
d = new Q(d);
d.isConstructor = !0;
d.b("Constructor method.", {type:c, name:"constructor"});
d.examples = a.examples;
O(d, b);
a.properties.unshift(d);
}, Y = (a, b, d, c, f = !1, g = null) => {
const e = f ? new W : new U;
e.g = g;
g = a.search(/<(prop|function|fn|static) /);
let k = "", h = a;
1 != g && (k = a.slice(0, g), h = a.slice(g));
const {j:l, w:n} = M(k, c);
e.b(f ? n : h, b, d, c);
({o:a} = K(b, l));
f && (e.closureType = a);
e.args || (e.args = l);
return e;
}, Z = ({content:a, props:b, ns:d, i:c, isMethod:f = !1, location:g = null}) => {
const e = [], {alias:k, aliases:h, ...l} = b;
b = Y(a, b, d, c, f, g);
e.push(b);
(k ? [k] : h ? h.split(/, */) : []).forEach(n => {
n = Y(a, {...l, name:n}, d, c, f, g);
n.description = `${n.description}${n.description ? " " : ""}Alias of \`${l.name}\`.`;
e.push(n);
});
return e;
};
/*
const stream = require('stream'); var w="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,d){a!=Array.prototype&&a!=Object.prototype&&(a[b]=d.value)};function x(a){a=["object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global,a];for(var b=0;b<a.length;++b){var d=a[b];if(d&&d.Math==Math)return d}throw Error("Cannot find global object");}var y=x(this);
function A(a,b){if(b){var d=y;a=a.split(".");for(var c=0;c<a.length-1;c++){var f=a[c];f in d||(d[f]={});d=d[f]}a=a[a.length-1];c=d[a];b=b(c);b!=c&&null!=b&&w(d,a,{configurable:!0,writable:!0,value:b})}}A("String.prototype.trimRight",function(a){function b(){return this.replace(/[\s\xa0]+$/,"")}return a||b});const B=os.EOL;function C(a,b,d){const c=[];b.replace(a,(f,...g)=>{f=g.slice(0,g.length-2).reduce((e,k,h)=>{h=d[h];if(!h||void 0===k)return e;e[h]=k;return e},{});c.push(f)});return c};const D=new RegExp(`${/([^\s>=/]+)/.source}(?:\\s*=\\s*${/(?:"([\s\S]*?)"|'([\s\S]*?)')/.source})?`,"g"),E=new RegExp(`(?:\\s+((?:${D.source}\\s*)*))`);const G=(a,b)=>{a=(Array.isArray(a)?a:[a]).join("|");return C(new RegExp(`<(${a})${E.source}?(?:${/\s*\/>/.source}|${/>([\s\S]+?)?<\/\1>/.source})`,"g"),b,"t a v v1 v2 c".split(" ")).map(({t:d,a:c="",c:f=""})=>{c=c.replace(/\/$/,"").trim();c=F(c);return{content:f,props:c,tag:d}})},F=a=>C(D,a,["key","val","def","f"]).reduce((b,{key:d,val:c})=>{if(void 0===c)return b[d]=!0,b;b[d]="true"==c?!0:"false"==c?!1:/^\d+$/.test(c)?parseInt(c,10):c;return b},{});const aa=a=>a.split(/([!?=*(),:.<>{}|\s+])/g).filter(b=>/\S/.test(b)).map(b=>{switch(b){case "function":return"function";case "Function":return"Function";case "!":return"nonNullable";case "?":return"nullable";case "=":return"=";case "*":return"any"}return b});
function ba(a){let b=0;const d=(f=1)=>a[b+f],c=(f=!0,g=[])=>{var e={};let k=a[b];if(["nullable","nonNullable"].includes(k)){if(!f)throw Error(`${k} not allowed after .`);e.nullable="nullable"===k;b++}k=a[b];if("("==k){b++;e={...c(!0,[]),...e};if(")"!=a[b])throw Error("Expecting closing )");b++;if("|"!=a[b])return e}else if("{"==k){b++;g=e;for(f={};"}"!=a[b];){var h=a[b];b++;f[h]=null;if(":"==a[b]){b++;try{var l=c();f[h]=l}catch(m){throw m.message+=`(when parsing ${h} property)`,m;}}if("}"==a[b]){b++;
break}if(","!=a[b])throw Error(`Expecting , for record after ${h}`);b++}g.record=f;return e}if(["nonNullable","nullable"].includes(k))throw Error("Nullability already defined.");if(/[=),:.<>}|]/.test(k))throw Error(`Unexpected token ${k}.`);"|"!=a[b]&&(e.name=a[b],b++);if("function"==k){l=e;h={return:null,args:[]};if("("!=a[b])throw Error("Expecting opening (");b++;for(var n;")"!=a[b];){if(n&&"this"==a[b])throw Error("this must come first in function arguments");if(n&&"new"==a[b])throw Error("new must come first in function arguments");
if("this"==a[b]){b++;if(":"!=a[b])throw Error("Expecting :");b++;h.this=c()}else if("new"==a[b]){b++;if(":"!=a[b])throw Error("Expecting :");b++;h.new=c()}else if("."==a[b]&&"."==d()&&"."==d(2)){b++;b++;b++;n=c();if(")"!=a[b])throw Error("Variable args must come last");h.variableArgs=n}else n=c(),h.args.push(n),"="==a[b]&&(n.optional=!0,b++);n=!0;if(")"==a[b])break;if(","==a[b])b++;else throw Error("Expecting , between arguments");}b++;":"==a[b]&&(b++,n=c(),void 0==n.name&&n.nullable&&(n.name=""),
h.return=n);l.function=h}else if("<"==a[b]||(h="."==a[b]&&"<"==d())){b++;h&&b++;l=e;for(h=[];">"!=a[b];){n=c();h.push(n);if(">"==a[b])break;if(","==a[b])b++;else throw Error("Expecting , between applications");}b++;l.application=h}for(;"."==a[b];){e.name+=".";b++;({name:l}=c(!1));if(!l)throw Error("Expected to see the name after .");e.name+=l}if("|"!=a[b]||!f)return e;for(g.push(e);"|"==a[b];)b++,e=c(!0,g),e.union!==g&&g.push(e);return{union:g}};return c()};function H(a){a=aa(a);return ba(a)};const ca=path.dirname,da=path.resolve;const I=({A:a,C:b,l:d,type:c})=>b?"string":a?"number":d?"boolean":c?c:"*",ea=a=>{const b=a.split(/\r?\n/).map(d=>{let c=Infinity;d.replace(/\S/,(f,g)=>{c=g});return c}).reduce((d,c)=>c<d?c:d,Infinity);return a.replace(new RegExp(`^ {${b}}`,"gm"),"")},J=a=>{a=a.trimRight();a=a.replace(/^\s*\r?\n( *\S)/,"$1");return ea(a)},K=(a,b,d=null)=>{const {async:c,"void":f,"return":g=f?"void":"",...e}=a;({args:a=""}=a);a||(a=b.map(({s:k,name:h})=>"this"==h?`${h}: ${k}`:h.startsWith("...")?`...${k}`:k).join(","));
b=g.replace(/\r?\n\s*/g," ");c&&b?b=`!Promise<${b}>`:c&&(b="!Promise");d=`function(${"constructor"==e.name?`new: ${d}, `:""}${a})`;b&&(d+=`: ${b}`);return{F:{...e,async:c,return:b},o:d}};function L(a,b){const d=a.example;d&&d.startsWith(".")&&b&&(a.example=da(ca(b),d))};function fa(a,b,{name:d,string:c,"boolean":f,opt:g,number:e,type:k},h){if(!d)throw Error("Argument does not have a name.");a.name=d;b&&(a.description=J(b));b=I({A:e,C:c,l:f,type:k});h&&(b=b.replace(new RegExp(`([!?])?${h}\\.`,"g"),"$1"));b.endsWith("=")&&(b=b.replace(/=$/,""),g=!0);a.type=b;g&&(a.optional=!0)}class ha{constructor(){this.name=null;this.type="";this.optional=!1;this.description=""}get s(){return this.optional?`${this.type}=`:this.type}}
const M=(a,b)=>{let d=a.lastIndexOf("</arg>"),c=a;var f=[];-1!=d&&(d+=6,f=a.slice(0,d),c=a.slice(d),f=G("arg",f),f=f.map(({content:g,props:e})=>{const k=new ha;fa(k,g,e,b);return k}));return{w:c,j:f}};const ia=fs.readFileSync;const ja=a=>{const b=a.replace(/^\s*\r?\n/gm,"").split(B).reduce((d,c)=>{[{length:c=0}={}]=/^\s*/.exec(c)||[];return c<d?c:d},Infinity);return a.replace(new RegExp(`^ {${b}}`,"gm"),"")};
function N(a,b=""){const d=b.split(/\s*,\s*/);return a.split(/\s*,\s*/).map(c=>{let f=c=ia(c,"utf8");if(c=/\/\* start example \*\/\r?\n([\s\S]+?)\r?\n\s*\/\* end example \*\//.exec(c))[,c]=c,f=ja(c);d.forEach(g=>{const [e,k]=g.split(/\s*=>\s*/);f=f.replace(`'${e}'`,`'${k}'`);f=f.replace(`"${e}"`,`"${k}"`)});return f=f.replace(/@/g,"\uff20")})}function O(a,b,d=new RegExp(`([!?])?${b}\\.`,"g")){b&&(a.f&&(a.f=a.f.replace(d,"$1")),a.type=a.type.replace(d,"$1"))}
class P{constructor(a=null){this.h=this.description=this.name=null;this.u="";this.default=this.f=null;this.optional=!1;this.aliases=[];this.v=!1;this.parsed=null;this.args=a;this.g=!1;this.examples=[]}toTypeScriptFunction(a){if(!this.parsed)throw Error("The property was not parsed.");let {function:{new:b,args:d,return:c,this:f,variableArgs:g}}=this.parsed;b&&(c=b);var e=d.map(h=>a(h)).map((h,l)=>{const {optional:n}=d[l];let {name:m=`arg${l}`,optional:p=n}=this.D[l]||{};return`${`${m}${p?"?":""}`}: ${h}`});
if(f){var k=a(f);e.unshift(`this: ${k}`)}if(g){k=a(g);let h="...args";try{h=`${this.args[this.args.length-1].name}`}catch(l){}e.push(`${h}: ${k}[]`)}e=e.join(", ");k=c?a(c):"?";e=`(${e}) => ${k}`;b&&(e="new "+e);return e}get static(){return this.g}get hasDefault(){return null!==this.default}b(a,{name:b,string:d,"boolean":c,opt:f,number:g,type:e,"default":k,closure:h,alias:l,aliases:n,example:m,"example-override":p="",noParams:q,"static":r,initial:t}){if(!b)throw Error("Property does not have a name.");
this.name=b;a&&(this.description=J(a));a=I({A:g,C:d,l:c,type:e});q&&(this.v=q);h&&(this.f=h);this.type=a;void 0!==k?this.default=k:void 0!==t&&(this.default=t);if(f||void 0!==k)this.optional=!0;l&&(this.aliases=[l]);n&&(this.aliases=n.split(/\s*,\s*/));r&&(this.g=!0);m&&(this.examples=N(m,p))}get type(){return this.h||"*"}set type(a){this.h=a||null;this.u=this.f||this.h||"";if(!this.v)try{this.parsed=H(this.u),this.isParsedFunction&&!this.args&&(this.args=[])}catch(b){this.parsed=null}}get D(){var a=
this.args;this.args&&this.args[0]&&"this"==this.args[0].name&&([,...a]=this.args);return a}get isParsedFunction(){return!!this.parsed&&"function"==this.parsed.name}};class Q extends P{constructor(...a){super(...a);this.isConstructor=this.async=!1;this.return=""}b(a,b){super.b(a,b);"constructor"==b.name&&(this.isConstructor=!0);this.async=b.async;this.return=b.return}};function ka(a,b,d,c){var f=G("prop",a).map(({content:h,props:l})=>{const n=new P;L(l,d);n.b(h,l);return n});a=G(["function","fn","static"],a).map(({content:h,props:l,tag:n})=>{n="static"==n;const {w:m,j:p}=M(h,b);h=new Q(p);const {F:q,o:r}=K(l,p,c);q.type=r;L(q,d);h.b(m,q);n&&(h.g=!0);return h});f=[...f,...a];const {m:g,B:e,n:k}=f.reduce((h,l)=>{l.isConstructor?h.m.push(l):l.static?h.B.push(l):h.n.push(l);return h},{m:[],B:[],n:[]});return{constructor:g[0]||null,properties:[...g,...e,...k]}};const S=(a,b,d={})=>{let c;if("object"==typeof b)c=b;else try{(c=H(b))||console.log("Could not parse %s",b)}catch(f){console.log("Could not parse %s",b),console.error(f.message)}return c?R(c,a,d):b},R=(a,b,d={})=>{if(""==a.name&&a.nullable)return"?";var {escapePipe:c=!0}=d;let f="";var g="";a.nullable?g="?":!1===a.nullable&&(g="!");if(a.function){f=f+g+(a.name+"(");const e=[];a.function.this&&(c="this: "+R(a.function.this,b,d),e.push(c));a.function.new&&(c="new: "+R(a.function.new,b,d),e.push(c));
a.function.args.forEach(k=>{let h=R(k,b,d);k.optional&&(h+="=");e.push(h)});a.function.variableArgs&&(c="..."+R(a.function.variableArgs,b,d),e.push(c));c=e.join(", ");f+=c+")";a.function.return&&(f+=": "+R(a.function.return,b,d))}else a.record?(f+="{ ",c=Object.keys(a.record).map(e=>{var k=a.record[e];if(!k)return e;k=R(k,b,d);return`${e}: ${k}`}),f+=c.join(", "),f+=" }"):a.application?(f+=T(a.name,b,g,d)+"&lt;",c=a.application.map(e=>R(e,b,d)),f+=c.join(", "),f+="&gt;"):a.union?(f=f+g+"(",g=a.union.map(e=>
R(e,b,d)),f+=g.join(c?" \\| ":" | "),f+=")"):f+=T("any"==a.name?"*":a.name,b,g,d);return f},T=(a,b,d="",c={})=>{const {flatten:f=!1,nameProcess:g,link:e=({link:l})=>`#${l}`}=c;c=la(b,a);d=`${d}${a}`;if(!c)return d;let {link:k,type:{description:h}}=c;f&&((b=b.find(({fullName:l})=>l==a))&&b.link&&(k=b.link),!h&&b.description&&(h=b.description),"function"==typeof f&&f(a));c.link==k&&(k=e(c));b=g?g(d):d;return h?`<a href="${k}" title="${h.replace(/"/g,"&quot;")}">${b}</a>`:`[${b}](${k})`},la=(a,b)=>{a=
a.filter(({fullName:c})=>c==b);if(a.length){var d=a.find(({import:c})=>c||!1);a=a.find(({import:c})=>!c)||d;return{link:`${"type"}-${a.fullName.replace(/<\/?code>/g,"").replace(/<\/?strong>/g,"").replace(/<br\/>/g,"").replace(/&nbsp;/g,"").replace(/[^\w-\d ]/g,"").toLowerCase().replace(/[, ]/g,"-")}`,type:a}}};function ma(a,b=[],d=[],c={}){const {narrow:f=!1,preprocessDesc:g}=c;if(!b.length)return"";const e=a.isConstructor||a.isInterface,k=b.some(({hasDefault:m})=>m),h={escapePipe:!f,...c};let l;const n=m=>S(d,m,{...h,nameProcess:c.nameProcess?p=>c.nameProcess(p,l):void 0});a=b.map((m,p)=>{l=0<(p+1)%2;p=m.args&&m.isParsedFunction?m.toTypeScriptFunction(n):n(m.parsed||m.type);const q=e||m.optional?m.name:`${m.name}*`,r=m.hasDefault?`\`${m.default}\``:"-",t=g?g(m.description):m.description;return{prop:m,
typeName:p,name:q,de:na(t,!f),d:r,G:l}});if(f)return{props:a,anyHaveDefault:k,constr:e};a=a.map(({name:m,typeName:p,de:q,d:r,prop:t})=>[t.optional?m:`__${m}__`,`<em>${p}</em>`,q,...k?[r]:[]]);b=["Name",...f?["Type & Description"]:["Type","Description"],...k?[e?"Initial":"Default"]:[]];return["","","```table",JSON.stringify([b,...a],null,2).replace(/\n/g,B),"```"].join(B)}const na=(a="",b=!0)=>{null===a&&(a="");b&&(a=a.replace(/\|/g,"\\|"));return a.replace(/</g,"&lt;").replace(/>/g,"&gt;")};const oa=(a,b,d={})=>{function c(f){f.replace(/^!?/,"");return`\`${f}\``}return a.split(/,\s*/).map(f=>S(b,f,{flatten:!0,...d,nameProcess:d.nameProcess?g=>{g=d.nameProcess(g);return/[_*~>]/.test(g)?`<code>${g}</code>`:c(g)}:c})).join(", ")};class U{constructor(){this.name="";this.description=this.closureType=this.type=null;this.noExpand=this.spread=this.noToc=!1;this.link=null;this.properties=[];this.namespace=null;this.isRecord=this.isInterface=this.isConstructor=!1;this.args=this.extends=null;this.examples=[];this.g=null}get import(){return!1}b(a,{name:b,type:d,desc:c,noToc:f,spread:g,noExpand:e,link:k,closure:h,constructor:l,"extends":n,"interface":m,record:p,example:q,"example-override":r},t,z=null){if(!b)throw Error("Type does not have a name.");
this.name=b;d&&(this.type=d);h?this.closureType=h:this.closureType=this.type;c&&(this.description=J(c));this.noToc=!!f;this.spread=!!g;this.noExpand=!!e;k&&(this.link=k);!0===l&&(this.isConstructor=l);!0===m&&(this.isInterface=m);!0===p&&(this.isRecord=p);n&&(this.extends=n);t&&(this.namespace=t);if(a){const {properties:u,constructor:v}=ka(a,z,this.g,this.fullName);v&&(this.args=v.args);this.properties=u}q&&(a={example:q},L(a,this.g),this.examples=N(a.example,r))}h(a,b=new RegExp(`([!?])?${a}\\.`,
"g")){this.type&&(this.type=this.type.replace(b,"$1"));this.extends&&(this.extends=this.extends.replace(b,"$1"));return b}get tag(){return this.isConstructor?"constructor":this.isInterface?"interface":this.isRecord?"record":""}get ns(){return this.namespace?`${this.namespace}.`:""}get fullName(){return`${this.ns}${this.name}`}toMarkdown(a=[],b={}){const {flatten:d,details:c=[]}=b,f=c.includes(this.name);var g=this.type?`\`${this.type}\``:"",e=g;this.link?e=`[${g}](${this.link})`:!this.import&&this.type&&
(e=S(a,this.type,b),g=e!=this.type,e=V(e,g));g=V(this.fullName);g=this.import?`[${g}](l-type)`:this.noToc?`[${g}](l-type)`:`[${g}](t-type)`;const k=this.description?`: ${this.description}`:"";e=e?`${e} `:"";let h=/_/.test(g);if(this.extends){const l=oa(this.extends,a,b),n=` extends ${l}`;h=h||/_/.test(l);e=(h?e+"<strong>":e+"__")+(g+n);"function"==typeof d&&d(this.extends)}else e=(h?e+"<strong>":e+"__")+g;e=(h?e+"</strong>":e+"__")+k;a=ma(this,this.properties,a,b);return{LINE:e,table:a,displayInDetails:f}}}
const V=(a,b=!1)=>`${b?"<code>":"`"}${a}${b?"</code>":"`"}`;class W extends U{constructor(){super();this.f=null;this.async=!1}get isMethod(){return!0}b(a,{async:b,"return":d,"void":c,...f},...g){this.description=J(a);super.b("",f,...g);d&&(this.f=d.replace(/\r?\n\s*/g," "));c&&(this.f="void");b&&(this.async=!0)}get return(){return this.f||"void"}h(a){a=super.h(a);this.f&&(this.f=this.f.replace(a,"$1"))}};class pa extends U{constructor(){super();this.from=""}get import(){return!0}b(a,{from:b,name:d,...c},f,g){if(!b)throw Error("From attribute of import is not given.");this.from=b;this.description=J(a);super.b("",{...c,noToc:!0,name:d,type:`import('${b}').${d}`},f!=g?f:null)}};const qa=(a,b)=>{const d=new RegExp(`([!?])?${a}\\.`,"g");b.properties.forEach(c=>{O(c,a,d)});b.h(a)},X=(a,b)=>{var {args:d=[]}=a,c=d.map(({s:g})=>g).join(", ");let f=`new: ${a.fullName}`;c.length&&(f=`${f}, `);c=`function(${f}${c})`;d=new Q(d);d.isConstructor=!0;d.b("Constructor method.",{type:c,name:"constructor"});d.examples=a.examples;O(d,b);a.properties.unshift(d)},Y=(a,b,d,c,f=!1,g=null)=>{const e=f?new W:new U;e.g=g;g=a.search(/<(prop|function|fn|static) /);let k="",h=a;1!=g&&(k=a.slice(0,
g),h=a.slice(g));const {j:l,w:n}=M(k,c);e.b(f?n:h,b,d,c);({o:a}=K(b,l));f&&(e.closureType=a);e.args||(e.args=l);return e},Z=({content:a,props:b,ns:d,i:c,isMethod:f=!1,location:g=null})=>{const e=[],{alias:k,aliases:h,...l}=b;b=Y(a,b,d,c,f,g);e.push(b);(k?[k]:h?h.split(/, */):[]).forEach(n=>{n=Y(a,{...l,name:n},d,c,f,g);n.description=`${n.description}${n.description?" ":""}Alias of \`${l.name}\`.`;e.push(n)});return e};/*

@@ -747,57 +48,4 @@ Typal: keep types information in XML files to embed as typedefs,

*/
module.exports = {_Type:U, _Property:P, _Method:W, _parseFile:(a, b, d = null) => {
a = G("types", a);
if (!a.length) {
throw Error("XML file should contain root types element.");
}
const [{content:c, props:{namespace:f, ns:g = f}}] = a, e = b == g ? void 0 : g;
a = G(["embed"], c).map(({props:l}) => l);
const k = [], h = G("type interface constructor method import record".split(" "), c).reduce((l, {content:n, props:m, tag:p}) => {
"record" == p && (p = "type", m.record = !0);
const {alias:q, aliases:r, ...t} = m;
d && L(t, d);
var z = q ? [q] : r ? r.split(/, */) : [];
switch(p) {
case "type":
p = new U;
d && (p.g = d);
p.b(n, m, e, b);
l.push(p);
z.forEach(u => {
const v = new U;
d && (v.g = d);
v.b(n, {...t, name:u}, e, b);
l.push(v);
});
break;
case "interface":
m = Z({content:n, props:m, ns:e, i:b, location:d});
m.forEach(u => {
u.properties.some(({isConstructor:v}) => v) || X(u, b);
u.isInterface = !0;
});
l.push(...m);
break;
case "constructor":
m = Z({content:n, props:m, ns:e, i:b, location:d});
m.forEach(u => {
u.properties.some(({isConstructor:v}) => v) || X(u, b);
u.isConstructor = !0;
});
l.push(...m);
break;
case "method":
m = Z({content:n, props:m, ns:e, i:b, isMethod:!0, location:d});
l.push(...m);
break;
case "import":
z = new pa, z.b(n, m, m.ns || m.from, b), k.push(z);
}
return l;
}, []);
b && h.forEach(l => qa(b, l));
return {namespace:g, types:h, imports:k, embeds:a};
}, _getLinks:S};
//# sourceMappingURL=typal.js.map
module.exports={_Type:U,_Property:P,_Method:W,_parseFile:(a,b,d=null)=>{a=G("types",a);if(!a.length)throw Error("XML file should contain root types element.");const [{content:c,props:{namespace:f,ns:g=f}}]=a,e=b==g?void 0:g;a=G(["embed"],c).map(({props:l})=>l);const k=[],h=G("type interface constructor method import record".split(" "),c).reduce((l,{content:n,props:m,tag:p})=>{"record"==p&&(p="type",m.record=!0);const {alias:q,aliases:r,...t}=m;d&&L(t,d);var z=q?[q]:r?r.split(/, */):[];switch(p){case "type":p=
new U;d&&(p.g=d);p.b(n,m,e,b);l.push(p);z.forEach(u=>{const v=new U;d&&(v.g=d);v.b(n,{...t,name:u},e,b);l.push(v)});break;case "interface":m=Z({content:n,props:m,ns:e,i:b,location:d});m.forEach(u=>{u.properties.some(({isConstructor:v})=>v)||X(u,b);u.isInterface=!0});l.push(...m);break;case "constructor":m=Z({content:n,props:m,ns:e,i:b,location:d});m.forEach(u=>{u.properties.some(({isConstructor:v})=>v)||X(u,b);u.isConstructor=!0});l.push(...m);break;case "method":m=Z({content:n,props:m,ns:e,i:b,isMethod:!0,
location:d});l.push(...m);break;case "import":z=new pa,z.b(n,m,m.ns||m.from,b),k.push(z)}return l},[]);b&&h.forEach(l=>qa(b,l));return{namespace:g,types:h,imports:k,embeds:a}},_getLinks:S};
{
"name": "typal",
"version": "1.27.1",
"version": "2.0.0",
"description": "Organises TypeDefs By Placing Them Into Types.Xml File To Be Embedded Into Source Code Compatible With VSCode And Google Closure Compiler, Generates Externs And Allows To Place Documentation In README Markdown.",
"main": "compile/index.js",
"module": "src/index.js",
"scripts": {
"scripts": "scripts"
},
"bin": {
"typal": "compile/bin/typal.js",
"typal-dev": "src/bin/index.js"
"typal": "compile/bin/typal.js"
},
"files": [
"src",
"compile",
"types/externs.js",
"types/index.js"
"compile"
],
"externs": "types/externs.js",
"repository": "gitlab:artdeco/typal",

@@ -32,2 +23,3 @@ "keywords": [

"closure",
"compiler",
"google closure compiler",

@@ -40,39 +32,5 @@ "externs"

"url": "https://gitlab.com/artdeco/issues/-/issues/",
"email": "incoming+artdeco-issues-17934443-issue-@incoming.gitlab.com"
"email": "issues+typal@adc.sh"
},
"homepage": "https://www.artd.eco",
"devDependencies": {
"@artdeco/clean-stack": "^1.2.1",
"@artdeco/scripts.json": "^1.0.1",
"@typedefs/parser": "^1.3.4",
"@wrote/read": "^1.0.4",
"@wrote/read-dir-structure": "^1.3.1",
"@wrote/write": "^1.0.4",
"@zoroaster/mask": "^2.7.2",
"alamode": "^3.7.1",
"argufy": "^1.7.5",
"catchment": "^3.3.0",
"depack": "^1.1.2",
"documentary": "^1.38.4",
"erotic": "^2.1.1",
"erte": "^1.3.0",
"eslint-config-artdeco": "1.0.1",
"makepromise": "^3.2.0",
"mismatch": "^1.2.0",
"restream": "^3.7.4",
"rexml": "^2.2.2",
"temp-context": "^2.2.0",
"usually": "^1.2.0",
"yarn-s": "1.2.3",
"zoroaster": "^4.4.0"
},
"srcDependencies": {
"@typedefs/parser": "^1.3.4",
"@wrote/read": "^1.0.4",
"mismatch": "^1.2.0",
"rexml": "^2.2.2"
},
"publishConfig": {
"registry": "https://registry.npmjs.com"
}
"homepage": "https://www.artd.eco"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc