-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsrc_app_custom-elements_live-example_live-example_module_ts.7376432dfb1c9b57.js.map
1 lines (1 loc) · 12.7 KB
/
src_app_custom-elements_live-example_live-example_module_ts.7376432dfb1c9b57.js.map
1
{"version":3,"file":"src_app_custom-elements_live-example_live-example_module_ts.7376432dfb1c9b57.js","mappings":"+NA2BM,WAAuBA,EAAgBC,GAC3C,MAAMC,EAAuB,iBAATD,EACdA,EACAA,EAAKE,KAAKC,GAAKJ,EAAMK,eAAeD,EAAEE,gBAE5C,YAAgBC,IAARL,OAAqBK,EAAYP,EAAME,EAAII,eAS/C,WAAwBE,EAA+BC,GAAe,GAC1E,YAAqBF,IAAdC,EAA0BC,EAA2B,UAArBD,EAAUE,oDClC/CC,aACEA,sCAAKA,eAAsCA,gDAAMA,QAAIA,mBACvDA,+BADUA,6DALZA,gBAAiC,WAE7BA,qCACFA,QACAA,qBAGFA,8BANOA,gCACsBA,mCAEvBA,kEAINA,gBAAqC,SACQA,SAASA,gCAA3BA,gCAAtBA,0BAAwCA,kDAI3CA,gBACEA,eAAEA,eAAsCA,oCAAIA,iCAAvCA,6DAHTA,gBAAuB,UACoCA,SAASA,QAClEA,wBAGFA,8BAJyCA,gCAApCA,iCAAsDA,wBAClDA,oECVLC,EAAoBC,KAAqB,iBACzCC,EAAWD,KAAqB,QAgD/B,IAAME,EAAb,MAAM,MAAOA,EAWXC,YAAYC,EAAwBC,GAClC,MAAMlB,EFvDJ,WAAmBmB,GACvB,MAAMnB,EAAsBmB,aAAcC,MAAaD,EAAGE,cAAcC,WAAaH,EAAGG,WAClFC,EAAmB,GACzB,UAAWtB,KAAQD,EACjBuB,EAAQtB,EAAKuB,KAAKlB,eAAiBL,EAAKwB,MAE1C,OAAOF,EEiDSG,CAAST,GACjBU,EAAaC,KAAKC,cAAc7B,EAAOkB,EAASY,MAAK,IACrDC,EAAiBH,KAAKI,kBAAkBhC,GAE9C4B,KAAKK,KAAOL,KAAKM,QAAQ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,kBAIM5B,KAAK6B,SAGP7B,KAAK6B,OAAOpC,cAAcqC,IAAM9B,KAAK8B,mDAZ9BJ,8BAA2BD,4QAH3B1C,4JAGA2C,GAAb,GCpIaK,EAAb,MAAM,MAAOA,EAJb3C,cAKEY,4BAAoCb,gDADzB4C,4DAHAC,QAGAD,GAAb","names":["attrs","attr","key","find","a","hasOwnProperty","toLowerCase","undefined","attrValue","def","trim","i0","LIVE_EXAMPLE_BASE","CONTENT_URL_PREFIX","ZIP_BASE","LiveExampleComponent","constructor","elementRef","location","el","ElementRef","nativeElement","attributes","attrMap","name","value","getAttrs","exampleDir","this","getExampleDir","path","stackblitzName","getStackblitzName","mode","getMode","enableDownload","getEnableDownload","stackblitz","getStackblitz","zip","getZip","title","getTitle","ngAfterContentInit","textContent","content","boolFromValue","getAttrValue","match","downloadOnly","isEmbedded","zipName","split","selectors","EmbeddedStackblitzComponent","encapsulation","ngAfterViewInit","iframe","src","LiveExampleModule","CommonModule"],"sourceRoot":"webpack:///","sources":["./src/app/shared/attribute-utils.ts","./src/app/custom-elements/live-example/live-example.component.html","./src/app/custom-elements/live-example/live-example.component.ts","./src/app/custom-elements/live-example/live-example.module.ts"],"sourcesContent":["// Utilities for processing HTML element attributes\nimport { ElementRef } from '@angular/core';\n\nexport interface AttrMap {\n [key: string]: string;\n}\n\n/**\n * Get attribute map from element or ElementRef `attributes`.\n * Attribute map keys are forced lowercase for case-insensitive lookup.\n *\n * @param el The source of the attributes.\n */\nexport function getAttrs(el: HTMLElement | ElementRef): AttrMap {\n const attrs: NamedNodeMap = el instanceof ElementRef ? el.nativeElement.attributes : el.attributes;\n const attrMap: AttrMap = {};\n for (const attr of attrs as any as Attr[] /* cast due to https://github.com/Microsoft/TypeScript/issues/2695 */) {\n attrMap[attr.name.toLowerCase()] = attr.value;\n }\n return attrMap;\n}\n\n/**\n * Return the attribute that matches `attr`.\n *\n * @param attr Name of the attribute or a string of candidate attribute names.\n */\nexport function getAttrValue(attrs: AttrMap, attr: string | string[]): string | undefined {\n const key = (typeof attr === 'string')\n ? attr\n : attr.find(a => attrs.hasOwnProperty(a.toLowerCase()));\n\n return (key === undefined) ? undefined : attrs[key.toLowerCase()];\n}\n\n/**\n * Return the boolean state of an attribute value (if supplied).\n *\n * @param attrValue The string value of some attribute (or undefined if attribute not present).\n * @param def Default boolean value when attribute is undefined.\n */\nexport function boolFromValue(attrValue: string | undefined, def: boolean = false) {\n return attrValue === undefined ? def : attrValue.trim() !== 'false';\n}\n\n/**\n * Return the boolean state of attribute from an element.\n *\n * @param el The source of the attributes.\n * @param atty Name of the attribute or a string of candidate attribute names.\n * @param def Default boolean value when attribute is undefined.\n */\nexport function getBoolFromAttribute(\n el: HTMLElement | ElementRef,\n attr: string | string[],\n def: boolean = false): boolean {\n return boolFromValue(getAttrValue(getAttrs(el), attr), def);\n}\n","<!-- Content projection is used to get the content HTML provided to the component. -->\n<span #content style=\"display: none\"><ng-content></ng-content></span>\n\n<span [ngSwitch]=\"mode\">\n <span *ngSwitchCase=\"'embedded'\">\n <div title=\"{{title}}\">\n <aio-embedded-stackblitz [src]=\"stackblitz\"></aio-embedded-stackblitz>\n </div>\n <p *ngIf=\"enableDownload\">\n 你还可以 <a [href]=\"zip\" download title=\"下载范例\">下载这个例子</a>。\n </p>\n </span>\n <span *ngSwitchCase=\"'downloadOnly'\">\n <a [href]=\"zip\" download title=\"{{title}}\">{{title}}</a>\n </span>\n <span *ngSwitchDefault>\n <a [href]=\"stackblitz\" target=\"_blank\" title=\"{{title}}\">{{title}}</a>\n <span *ngIf=\"enableDownload\">\n / <a [href]=\"zip\" download title=\"下载范例\">下载范例</a>\n </span>\n </span>\n</span>\n","/* eslint-disable @angular-eslint/component-selector */\nimport { AfterContentInit, AfterViewInit, Component, ElementRef, Input, ViewChild } from '@angular/core';\nimport { Location } from '@angular/common';\nimport { CONTENT_URL_PREFIX } from 'app/documents/document.service';\nimport { AttrMap, boolFromValue, getAttrs, getAttrValue } from 'app/shared/attribute-utils';\n\n\nconst LIVE_EXAMPLE_BASE = CONTENT_URL_PREFIX + 'live-examples/';\nconst ZIP_BASE = CONTENT_URL_PREFIX + 'zips/';\n\n/**\n * Angular.io Live Example Embedded Component\n *\n * Renders a link to a live/host example of the doc page.\n *\n * All attributes and the text content are optional\n *\n * Usage:\n * <live-example\n * [name=\"...\"] // name of the example directory\n * [stackblitz=\"...\"\"] // name of the stackblitz file (becomes part of zip file name as well)\n * [embedded] // embed the stackblitz in the doc page, else display in new browser tab (default)\n * [noDownload] // no downloadable zip option\n * [downloadOnly] // just the zip\n * [title=\"...\"]> // text for live example link and tooltip\n * text // higher precedence way to specify text for live example link and tooltip\n * </live-example>\n * Example:\n * <p>Run <live-example>Try the live example</live-example></p>.\n * // ~/resources/live-examples/{page}/stackblitz.json\n *\n * <p>Run <live-example name=\"toh-pt1\">this example</live-example></p>.\n * // ~/resources/live-examples/toh-pt1/stackblitz.json\n *\n * // Link to the default stackblitz in the toh-pt1 sample\n * // The title overrides default (\"live example\") with \"Tour of Heroes - Part 1\"\n * <p>Run <live-example name=\"toh-pt1\" title=\"Tour of Heroes - Part 1\"></live-example></p>.\n * // ~/resources/live-examples/toh-pt1/stackblitz.json\n *\n * <p>Run <live-example stackblitz=\"minimal\"></live-example></p>.\n * // ~/resources/live-examples/{page}/minimal.stackblitz.json\n *\n * // Embed the current page's default stackblitz\n * // Text within tag is \"live example\"\n * // No title (no tooltip)\n * <live-example embedded title=\"\"></live-example>\n * // ~/resources/live-examples/{page}/stackblitz.json\n *\n * // Displays within the document page as an embedded style stackblitz editor\n * <live-example name=\"toh-pt1\" embedded stackblitz=\"minimal\">Tour of Heroes - Part 1</live-example>\n * // ~/resources/live-examples/toh-pt1/minimal.stackblitz.json\n */\n@Component({\n selector: 'live-example',\n templateUrl: 'live-example.component.html'\n})\nexport class LiveExampleComponent implements AfterContentInit {\n\n readonly mode: 'default' | 'embedded' | 'downloadOnly';\n readonly enableDownload: boolean;\n readonly stackblitz: string;\n readonly zip: string;\n title: string;\n\n @ViewChild('content', { static: true })\n private content: ElementRef;\n\n constructor(elementRef: ElementRef, location: Location) {\n const attrs = getAttrs(elementRef);\n const exampleDir = this.getExampleDir(attrs, location.path(false));\n const stackblitzName = this.getStackblitzName(attrs);\n\n this.mode = this.getMode(attrs);\n this.enableDownload = this.getEnableDownload(attrs);\n this.stackblitz = this.getStackblitz(exampleDir, stackblitzName, this.mode === 'embedded');\n this.zip = this.getZip(exampleDir, stackblitzName);\n this.title = this.getTitle(attrs);\n }\n\n ngAfterContentInit() {\n // Angular will sanitize this title when displayed, so it should be plain text.\n const textContent = this.content.nativeElement.textContent.trim();\n if (textContent) {\n this.title = textContent;\n }\n }\n\n private getEnableDownload(attrs: AttrMap) {\n const downloadDisabled = boolFromValue(getAttrValue(attrs, 'noDownload'));\n return !downloadDisabled;\n }\n\n private getExampleDir(attrs: AttrMap, path: string) {\n let exampleDir = getAttrValue(attrs, 'name');\n if (!exampleDir) {\n // Take the last path segment, excluding query params and hash fragment.\n const match = path.match(/[^/?#]+(?=\\/?(?:\\?|#|$))/);\n exampleDir = match ? match[0] : 'index';\n }\n return exampleDir.trim();\n }\n\n private getMode(this: LiveExampleComponent, attrs: AttrMap): typeof this.mode {\n const downloadOnly = boolFromValue(getAttrValue(attrs, 'downloadOnly'));\n const isEmbedded = boolFromValue(getAttrValue(attrs, 'embedded'));\n\n return downloadOnly ? 'downloadOnly'\n : isEmbedded ? 'embedded' :\n 'default';\n }\n\n private getStackblitz(exampleDir: string, stackblitzName: string, isEmbedded: boolean) {\n const urlQuery = isEmbedded ? '?ctl=1' : '';\n return `${LIVE_EXAMPLE_BASE}${exampleDir}/${stackblitzName}stackblitz.html${urlQuery}`;\n }\n\n private getStackblitzName(attrs: AttrMap) {\n const attrValue = (getAttrValue(attrs, 'stackblitz') || '').trim();\n return attrValue && `${attrValue}.`;\n }\n\n private getTitle(attrs: AttrMap) {\n return (getAttrValue(attrs, 'title') || '现场演练').trim();\n }\n\n private getZip(exampleDir: string, stackblitzName: string) {\n const zipName = exampleDir.split('/')[0];\n return `${ZIP_BASE}${exampleDir}/${stackblitzName}${zipName}.zip`;\n }\n}\n\n///// EmbeddedStackblitzComponent ///\n/**\n * Hides the <iframe> so we can test LiveExampleComponent without actually triggering\n * a call to stackblitz to load the iframe\n */\n@Component({\n selector: 'aio-embedded-stackblitz',\n template: '<iframe #iframe frameborder=\"0\" width=\"100%\" height=\"100%\"></iframe>',\n styles: [ 'iframe { min-height: 400px; }' ]\n})\nexport class EmbeddedStackblitzComponent implements AfterViewInit {\n @Input() src: string;\n\n @ViewChild('iframe', { static: true }) iframe: ElementRef;\n\n ngAfterViewInit() {\n // DEVELOPMENT TESTING ONLY\n // this.src = 'https://angular.io/resources/live-examples/quickstart/ts/stackblitz.json';\n\n if (this.iframe) {\n // security: the `src` is always authored by the documentation team\n // and is considered to be safe\n this.iframe.nativeElement.src = this.src;\n }\n }\n}\n","import { NgModule, Type } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { EmbeddedStackblitzComponent, LiveExampleComponent } from './live-example.component';\nimport { WithCustomElementComponent } from '../element-registry';\n\n@NgModule({\n imports: [ CommonModule ],\n declarations: [ LiveExampleComponent, EmbeddedStackblitzComponent ]\n})\nexport class LiveExampleModule implements WithCustomElementComponent {\n customElementComponent: Type<any> = LiveExampleComponent;\n}\n"]}