@ng-doc/keywords-loaders 18.0.9 → 18.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/angular/helpers/fetch-docs.d.ts +1 -2
- package/angular/interfaces/index.d.ts +0 -1
- package/angular/types/index.d.ts +1 -0
- package/angular/types/ng-response.d.ts +5 -0
- package/index.cjs.js +64 -8
- package/index.d.ts +1 -0
- package/package.json +2 -2
- package/rxjs/helpers/fetch-docs.d.ts +5 -0
- package/rxjs/helpers/get-api-url.d.ts +6 -0
- package/rxjs/helpers/get-rxjs-host.d.ts +5 -0
- package/rxjs/helpers/index.d.ts +2 -0
- package/rxjs/helpers/rxjs-to-keyword.d.ts +9 -0
- package/rxjs/index.d.ts +2 -0
- package/rxjs/interfaces/index.d.ts +1 -0
- package/rxjs/interfaces/rxjs-page.d.ts +4 -0
- package/rxjs/rxjs-keywords-loader.d.ts +6 -0
- package/rxjs/types/index.d.ts +2 -0
- package/rxjs/types/rxjs-response.d.ts +6 -0
- package/rxjs/types/rxjs-version.d.ts +1 -0
- package/angular/interfaces/ng-response.d.ts +0 -4
package/angular/types/index.d.ts
CHANGED
package/index.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var fetch = require('node-fetch');
|
|
3
|
+
var fetch$1 = require('node-fetch');
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
*
|
|
@@ -15,9 +15,9 @@ function getNgHost(version) {
|
|
|
15
15
|
*
|
|
16
16
|
* @param version
|
|
17
17
|
*/
|
|
18
|
-
async function fetchDocs(version) {
|
|
18
|
+
async function fetchDocs$1(version) {
|
|
19
19
|
const manifestUrl = `${getNgHost(version)}/assets/api/manifest.json`;
|
|
20
|
-
return fetch(manifestUrl).then(response => response.json());
|
|
20
|
+
return fetch$1(manifestUrl).then(response => response.json());
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -26,7 +26,7 @@ async function fetchDocs(version) {
|
|
|
26
26
|
* @param pageName
|
|
27
27
|
* @param version
|
|
28
28
|
*/
|
|
29
|
-
function getApiUrl(packageName, pageName, version) {
|
|
29
|
+
function getApiUrl$1(packageName, pageName, version) {
|
|
30
30
|
const packageNameWithoutPrefix = packageName.replace('@angular/', '');
|
|
31
31
|
return `${getNgHost(version)}/api/${packageNameWithoutPrefix}/${pageName}`;
|
|
32
32
|
}
|
|
@@ -38,7 +38,7 @@ function getApiUrl(packageName, pageName, version) {
|
|
|
38
38
|
* @param version
|
|
39
39
|
*/
|
|
40
40
|
function ngPageToKeyword(packageName, page, version) {
|
|
41
|
-
const url = getApiUrl(packageName, page.name, version);
|
|
41
|
+
const url = getApiUrl$1(packageName, page.name, version);
|
|
42
42
|
const description = `External link the Angular documentation.`;
|
|
43
43
|
const keywords = [[page.name, {
|
|
44
44
|
title: page.name,
|
|
@@ -65,8 +65,11 @@ function ngPageToKeyword(packageName, page, version) {
|
|
|
65
65
|
function ngKeywordsLoader(options) {
|
|
66
66
|
return async () => {
|
|
67
67
|
try {
|
|
68
|
-
const packages = await fetchDocs(options?.version);
|
|
69
|
-
const keywords =
|
|
68
|
+
const packages = await fetchDocs$1(options?.version);
|
|
69
|
+
const keywords = packages.flatMap(({
|
|
70
|
+
moduleName,
|
|
71
|
+
entries
|
|
72
|
+
}) => entries.flatMap(page => ngPageToKeyword(moduleName, page, options?.version)));
|
|
70
73
|
return Object.fromEntries(keywords);
|
|
71
74
|
} catch (error) {
|
|
72
75
|
console.error(`Failed to load Angular keywords: ${error}`);
|
|
@@ -80,7 +83,7 @@ function ngKeywordsLoader(options) {
|
|
|
80
83
|
* @param endpoint
|
|
81
84
|
*/
|
|
82
85
|
async function fetchKeywords(endpoint) {
|
|
83
|
-
return await fetch(`${endpoint}/keywords.json`).then(response => response.json());
|
|
86
|
+
return await fetch$1(`${endpoint}/keywords.json`).then(response => response.json());
|
|
84
87
|
}
|
|
85
88
|
|
|
86
89
|
/**
|
|
@@ -124,5 +127,58 @@ function ngDocKeywordsLoader(options) {
|
|
|
124
127
|
};
|
|
125
128
|
}
|
|
126
129
|
|
|
130
|
+
/**
|
|
131
|
+
* @param version rxjs version
|
|
132
|
+
*/
|
|
133
|
+
function getRxjsHost(version) {
|
|
134
|
+
return `https://${version ? `${version}.` : ''}rxjs.dev`;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* @param path type api path from rxjs api manifest
|
|
139
|
+
* @param version version of rxjs
|
|
140
|
+
*/
|
|
141
|
+
function getApiUrl(path, version) {
|
|
142
|
+
return `${getRxjsHost(version)}/${path}`;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* @param version rxjs version
|
|
147
|
+
*/
|
|
148
|
+
async function fetchDocs(version) {
|
|
149
|
+
const manifestUrl = getApiUrl('generated/docs/api/api-list.json', version);
|
|
150
|
+
return fetch(manifestUrl).then(response => response.json());
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
*
|
|
155
|
+
* @param page
|
|
156
|
+
* @param version
|
|
157
|
+
*/
|
|
158
|
+
function rxjsPageToKeyword(page, version) {
|
|
159
|
+
return [page.title, {
|
|
160
|
+
title: page.title,
|
|
161
|
+
url: getApiUrl(page.path, version),
|
|
162
|
+
description: `External link the RxJS documentation.`
|
|
163
|
+
}];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* @param version rxjs version
|
|
168
|
+
*/
|
|
169
|
+
function rxjsKeywordsLoader(version) {
|
|
170
|
+
return async () => {
|
|
171
|
+
try {
|
|
172
|
+
const apiReference = await fetchDocs(version);
|
|
173
|
+
const keywords = apiReference.flatMap(ref => ref.items.map(item => rxjsPageToKeyword(item, version)));
|
|
174
|
+
return Object.fromEntries(keywords);
|
|
175
|
+
} catch (error) {
|
|
176
|
+
console.error(`Failed to load RxJS keywords:`, error);
|
|
177
|
+
return {};
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
127
182
|
exports.ngDocKeywordsLoader = ngDocKeywordsLoader;
|
|
128
183
|
exports.ngKeywordsLoader = ngKeywordsLoader;
|
|
184
|
+
exports.rxjsKeywordsLoader = rxjsKeywordsLoader;
|
package/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { NgDocGlobalKeyword } from '@ng-doc/core';
|
|
2
|
+
import { RxjsPage } from '../interfaces';
|
|
3
|
+
import { RxjsVersion } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param page
|
|
7
|
+
* @param version
|
|
8
|
+
*/
|
|
9
|
+
export declare function rxjsPageToKeyword(page: RxjsPage, version?: RxjsVersion): [string, NgDocGlobalKeyword];
|
package/rxjs/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './rxjs-page';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type RxjsVersion = string;
|