-
Notifications
You must be signed in to change notification settings - Fork 22
/
src_app_custom-elements_api_api-list_module_ts-es5.d9c36aa3d5321c3f76ac.js.map
1 lines (1 loc) · 15.1 KB
/
src_app_custom-elements_api_api-list_module_ts-es5.d9c36aa3d5321c3f76ac.js.map
1
{"version":3,"sources":["webpack:///src/app/custom-elements/api/api.service.ts","webpack:///src/app/custom-elements/api/api-list.component.html","webpack:///src/app/custom-elements/api/api-list.module.ts","webpack:///src/app/custom-elements/api/api-list.component.ts"],"names":["ApiService","http","logger","apiBase","apiListJsonDefault","firstTime","onDestroy","Subject","sectionsSubject","ReplaySubject","_sections","this","pipe","takeUntil","fetchSections","subscribe","sections","log","length","tap","forEach","section","deprecated","items","every","item","stability","next","src","url","get","err","error","ApiListModule","SearchCriteria","query","status","type","ApiListComponent","apiService","locationService","showStatusMenu","showTypeMenu","criteriaSubject","searchCriteria","types","value","title","statuses","filteredSections","combineLatest","map","results","criteria","filterSection","initializeSearchCriteria","setSearchCriteria","toLowerCase","trim","toggleStatusMenu","toggleTypeMenu","sectionNameMatches","name","indexOf","filter","docType","securityRisk","search","q","queryEl","nativeElement","find","x","setSearch","Object","assign","setLocationSearch","setType","setStatus","setQuery","customElementComponent"],"mappings":"kpBA2BO,iBAAMA,EAAN,WA+BL,WAAoBC,EAA0BC,aAA1B,KAAAD,OAA0B,KAAAC,SA7BtC,KAAAC,QAAU,KAAyB,OACnC,KAAAC,mBAAqB,gBACrB,KAAAC,aACA,KAAAC,UAAY,IAAIC,EAAA,GAChB,KAAAC,gBAAkB,IAAIC,EAAA,EAA4B,GAClD,KAAAC,UAAYC,KAAKH,gBAAgBI,MAAK,EAAAC,EAAA,GAAUF,KAAKL,YAPxD,gCAaL,WAAc,WAUZ,OARIK,KAAKN,YACPM,KAAKN,aACLM,KAAKG,gBAGLH,KAAKD,UAAUK,UAAUC,YAAQ,OAAIL,EAAKT,OAAOe,IAAZN,6BAAsCK,EAASE,OAA/CP,mBAGhCA,KAAKD,UAAUE,MAAK,E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C,eAAgBS,IAC7D1C,KAAKiE,wBAxIF,K,6CAAMtC,GAAgB,sB,wBAAhBA,EAAgB,qD,OAAA,K,giBF5B7B,iBAEE,wBAAY,kCAAU,EAAAuC,QAAA,YAKtB,QAEA,wBAAY,kCAAU,EAAAC,UAAA,YAKtB,QAEA,iBACE,qBAAgC,iCAAS,EAAAC,SAAA,kBAAzC,QACA,eAA0B,kBAAM,QAClC,QACF,QAEA,qBACE,uB,kBAaF,S,MAjCc,kCAAiB,kBAAjB,CAAiB,iBAOjB,qCAAoB,oBAApB,CAAoB,qCAaP,2D,4DEKpB,GDdA,IAAM9C,EANb,uBAOE,KAAA+C,uBAAoC1C,I,oCADzBL,I,wBAAAA,I,6BAFA,CAAEjC,GAAY,SAHhB,CAAE,KAAc,IAAc,S","file":"x","sourcesContent":["import { Injectable, OnDestroy } from '@angular/core';\nimport { HttpClient, HttpErrorResponse } from '@angular/common/http';\n\nimport { ReplaySubject, Subject } from 'rxjs';\nimport { takeUntil, tap } from 'rxjs/operators';\n\nimport { Logger } from 'app/shared/logger.service';\nimport { DOC_CONTENT_URL_PREFIX } from 'app/documents/document.service';\n\nexport interface ApiItem {\n name: string;\n title: string;\n path: string;\n docType: string;\n stability: string;\n securityRisk: boolean;\n}\n\nexport interface ApiSection {\n path: string;\n name: string;\n title: string;\n deprecated: boolean;\n items: ApiItem[]|null;\n}\n\n@Injectable()\nexport class ApiService implements OnDestroy {\n\n private apiBase = DOC_CONTENT_URL_PREFIX + 'api/';\n private apiListJsonDefault = 'api-list.json';\n private firstTime = true;\n private onDestroy = new Subject();\n private sectionsSubject = new ReplaySubject<ApiSection[]>(1);\n private _sections = this.sectionsSubject.pipe(takeUntil(this.onDestroy));\n\n /**\n * Return a cached observable of API sections from a JSON file.\n * API sections is an array of Angular top modules and metadata about their API documents (items).\n */\n get sections() {\n\n if (this.firstTime) {\n this.firstTime = false;\n this.fetchSections(); // TODO: get URL for fetchSections by configuration?\n\n // makes sectionsSubject hot; subscribe ensures stays alive (always refCount > 0);\n this._sections.subscribe(sections => this.logger.log(`ApiService got API ${sections.length} section(s)`));\n }\n\n return this._sections.pipe(tap(sections => {\n sections.forEach(section => {\n section.deprecated = !!section.items &&\n section.items.every(item => item.stability === 'deprecated');\n });\n }));\n }\n\n constructor(private http: HttpClient, private logger: Logger) { }\n\n ngOnDestroy() {\n this.onDestroy.next();\n }\n\n /**\n * Fetch API sections from a JSON file.\n * API sections is an array of Angular top modules and metadata about their API documents (items).\n * Updates `sections` observable\n *\n * @param [src] - Name of the api list JSON file\n */\n fetchSections(src?: string) {\n // TODO: get URL by configuration?\n const url = this.apiBase + (src || this.apiListJsonDefault);\n this.http.get<ApiSection[]>(url)\n .pipe(\n takeUntil(this.onDestroy),\n tap(() => this.logger.log(`Got API sections from ${url}`)),\n )\n .subscribe(\n sections => this.sectionsSubject.next(sections),\n (err: HttpErrorResponse) => {\n // TODO: handle error\n this.logger.error(err);\n throw err; // rethrow for now.\n }\n );\n }\n}\n","<div class=\"l-flex-wrap api-filter\">\n\n <aio-select (change)=\"setType($event.option)\"\n [options]=\"types\"\n [selected]=\"type\"\n [showSymbol]=\"true\"\n label=\"类型:\">\n </aio-select>\n\n <aio-select (change)=\"setStatus($event.option)\"\n [options]=\"statuses\"\n [selected]=\"status\"\n [disabled]=\"type.value === 'package'\"\n label=\"状态:\">\n </aio-select>\n\n <div class=\"form-search\">\n <input #filter placeholder=\"过滤\" (input)=\"setQuery($any($event.target).value)\" aria-label=\"Filter Search\">\n <i class=\"material-icons\">search</i>\n </div>\n</div>\n\n<article class=\"api-list-container\">\n <div *ngFor=\"let section of filteredSections | async\" >\n <h2 *ngIf=\"section.items\"><a [href]=\"section.path\" [class.deprecated-api-item]=\"section.deprecated\">{{section.title}}</a></h2>\n <ul class=\"api-list\" *ngIf=\"section.items && section.items.length\">\n <ng-container *ngFor=\"let item of section.items\">\n <li class=\"api-item\">\n <a [href]=\"item.path\" [class.deprecated-api-item]=\"item.stability === 'deprecated'\">\n <span class=\"symbol {{item.docType}}\"></span>\n {{item.title}}\n </a>\n </li>\n </ng-container>\n </ul>\n </div>\n</article>\n","import { NgModule, Type } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { HttpClientModule } from '@angular/common/http';\nimport { SharedModule } from '../../shared/shared.module';\nimport { ApiListComponent } from './api-list.component';\nimport { ApiService } from './api.service';\nimport { WithCustomElementComponent } from '../element-registry';\n\n@NgModule({\n imports: [ CommonModule, SharedModule, HttpClientModule ],\n declarations: [ ApiListComponent ],\n entryComponents: [ ApiListComponent ],\n providers: [ ApiService ]\n})\nexport class ApiListModule implements WithCustomElementComponent {\n customElementComponent: Type<any> = ApiListComponent;\n}\n","/*\n* API List & Filter Component\n*\n* A page that displays a formatted list of the public Angular API entities.\n* Clicking on a list item triggers navigation to the corresponding API entity document.\n* Can add/remove API entity links based on filter settings.\n*/\n\nimport { Component, ElementRef, OnInit, ViewChild } from '@angular/core';\n\nimport { combineLatest, Observable, ReplaySubject } from 'rxjs';\n\nimport { LocationService } from 'app/shared/location.service';\nimport { ApiItem, ApiSection, ApiService } from './api.service';\n\nimport { Option } from 'app/shared/select/select.component';\nimport { map } from 'rxjs/operators';\n\nclass SearchCriteria {\n query = '';\n status = 'all';\n type = 'all';\n}\n\n@Component({\n selector: 'aio-api-list',\n templateUrl: './api-list.component.html',\n})\nexport class ApiListComponent implements OnInit {\n\n filteredSections: Observable<ApiSection[]>;\n\n showStatusMenu = false;\n showTypeMenu = false;\n\n private criteriaSubject = new ReplaySubject<SearchCriteria>(1);\n private searchCriteria = new SearchCriteria();\n\n status: Option;\n type: Option;\n\n // API types\n types: Option[] = [\n { value: 'all', title: '全部' },\n { value: 'class', title: '类' },\n { value: 'const', title: '常量'},\n { value: 'decorator', title: '装饰器' },\n { value: 'directive', title: '指令' },\n { value: 'enum', title: '枚举' },\n { value: 'function', title: '函数' },\n { value: 'interface', title: '接口' },\n { value: 'pipe', title: '管道'},\n { value: 'ngmodule', title: 'NgModule'},\n { value: 'type-alias', title: '类型别名' },\n { value: 'package', title: '包'}\n ];\n\n statuses: Option[] = [\n { value: 'all', title: '全部' },\n { value: 'stable', title: '稳定'},\n { value: 'deprecated', title: '弃用' },\n { value: 'security-risk', title: '安全风险' }\n ];\n\n @ViewChild('filter', { static: true }) queryEl: ElementRef;\n\n constructor(\n private apiService: ApiService,\n private locationService: LocationService) { }\n\n ngOnInit() {\n this.filteredSections =\n combineLatest([\n this.apiService.sections,\n this.criteriaSubject,\n ]).pipe(\n map( results => ({ sections: results[0], criteria: results[1]})),\n map( results => (\n results.sections\n .map(section => ({ ...section, items: this.filterSection(section, results.criteria) }))\n ))\n );\n\n this.initializeSearchCriteria();\n }\n\n // TODO: may need to debounce as the original did\n // although there shouldn't be any perf consequences if we don't\n setQuery(query: string) {\n this.setSearchCriteria({query: (query || '').toLowerCase().trim() });\n }\n\n setStatus(status: Option) {\n this.toggleStatusMenu();\n this.status = status;\n this.setSearchCriteria({status: status.value});\n }\n\n setType(type: Option) {\n this.toggleTypeMenu();\n this.type = type;\n this.setSearchCriteria({type: type.value});\n }\n\n toggleStatusMenu() {\n this.showStatusMenu = !this.showStatusMenu;\n }\n\n toggleTypeMenu() {\n this.showTypeMenu = !this.showTypeMenu;\n }\n\n //////// Private //////////\n\n private filterSection(section: ApiSection, { query, status, type }: SearchCriteria) {\n const sectionNameMatches = !query || section.name.indexOf(query) !== -1;\n\n const matchesQuery = (item: ApiItem) =>\n sectionNameMatches || item.name.indexOf(query) !== -1;\n const matchesStatus = (item: ApiItem) =>\n status === 'all' || status === item.stability || (status === 'security-risk' && item.securityRisk);\n const matchesType = (item: ApiItem) =>\n type === 'all' || type === item.docType;\n\n const items: ApiItem[] = (section.items || []).filter(item =>\n matchesType(item) && matchesStatus(item) && matchesQuery(item));\n\n // If there are no items we still return an empty array if the section name matches and the type is 'package'\n return items.length ? items : (sectionNameMatches && type === 'package') ? [] : null;\n }\n\n // Get initial search criteria from URL search params\n private initializeSearchCriteria() {\n const {query, status, type} = this.locationService.search();\n\n const q = (query || '').toLowerCase();\n // Hack: can't bind to query because input cursor always forced to end-of-line.\n this.queryEl.nativeElement.value = q;\n\n this.status = this.statuses.find(x => x.value === status) || this.statuses[0];\n this.type = this.types.find(x => x.value === type) || this.types[0];\n\n this.searchCriteria = {\n query: q,\n status: this.status.value,\n type: this.type.value\n };\n\n this.criteriaSubject.next(this.searchCriteria);\n }\n\n private setLocationSearch() {\n const {query, status, type} = this.searchCriteria;\n const params = {\n query: query ? query : undefined,\n status: status !== 'all' ? status : undefined,\n type: type !== 'all' ? type : undefined\n };\n\n this.locationService.setSearch('API 搜索', params);\n }\n\n private setSearchCriteria(criteria: Partial<SearchCriteria>) {\n this.criteriaSubject.next(Object.assign(this.searchCriteria, criteria));\n this.setLocationSearch();\n }\n}\n"]}