Commit dcd43d57 authored by Björn Bartels's avatar Björn Bartels

update build, clean-up

parent a7ac92b0
This diff is collapsed.
import"../utils/boot.js";import{resolveUrl,pathFromUrl}from"../utils/resolve-url.js";import{strictTemplatePolicy}from"../utils/settings.js";let modules={},lcModules={};function setModule(id,module){modules[id]=lcModules[id.toLowerCase()]=module}function findModule(id){return modules[id]||lcModules[id.toLowerCase()]}function styleOutsideTemplateCheck(inst){if(inst.querySelector("style")){console.warn("dom-module %s has style outside template",inst.id)}}export class DomModule extends HTMLElement{static get observedAttributes(){return["id"]}static import(id,selector){if(id){let m=findModule(id);if(m&&selector){return m.querySelector(selector)}return m}return null}attributeChangedCallback(name,old,value,namespace){if(old!==value){this.register()}}get assetpath(){if(!this.__assetpath){const owner=window.HTMLImports&&HTMLImports.importForElement?HTMLImports.importForElement(this)||document:this.ownerDocument,url=resolveUrl(this.getAttribute("assetpath")||"",owner.baseURI);this.__assetpath=pathFromUrl(url)}return this.__assetpath}register(id){id=id||this.id;if(id){if(strictTemplatePolicy&&findModule(id)!==void 0){setModule(id,null);throw new Error(`strictTemplatePolicy: dom-module ${id} re-registered`)}this.id=id;setModule(id,this);styleOutsideTemplateCheck(this)}}}DomModule.prototype.modules=modules;customElements.define("dom-module",DomModule);
\ No newline at end of file
/**
@license
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
import '../utils/boot.js';
import { resolveUrl, pathFromUrl } from '../utils/resolve-url.js';
import { strictTemplatePolicy } from '../utils/settings.js';
let modules = {};
let lcModules = {};
/**
* Sets a dom-module into the global registry by id.
*
* @param {string} id dom-module id
* @param {DomModule} module dom-module instance
* @return {void}
*/
function setModule(id, module) {
// store id separate from lowercased id so that
// in all cases mixedCase id will stored distinctly
// and lowercase version is a fallback
modules[id] = lcModules[id.toLowerCase()] = module;
}
/**
* Retrieves a dom-module from the global registry by id.
*
* @param {string} id dom-module id
* @return {DomModule!} dom-module instance
*/
function findModule(id) {
return modules[id] || lcModules[id.toLowerCase()];
}
function styleOutsideTemplateCheck(inst) {
if (inst.querySelector('style')) {
console.warn('dom-module %s has style outside template', inst.id);
}
}
/**
* The `dom-module` element registers the dom it contains to the name given
* by the module's id attribute. It provides a unified database of dom
* accessible via its static `import` API.
*
* A key use case of `dom-module` is for providing custom element `<template>`s
* via HTML imports that are parsed by the native HTML parser, that can be
* relocated during a bundling pass and still looked up by `id`.
*
* Example:
*
* <dom-module id="foo">
* <img src="stuff.png">
* </dom-module>
*
* Then in code in some other location that cannot access the dom-module above
*
* let img = customElements.get('dom-module').import('foo', 'img');
*
* @customElement
* @extends HTMLElement
* @summary Custom element that provides a registry of relocatable DOM content
* by `id` that is agnostic to bundling.
* @unrestricted
*/
export class DomModule extends HTMLElement {
static get observedAttributes() {
return ['id'];
}
/**
* Retrieves the element specified by the css `selector` in the module
* registered by `id`. For example, this.import('foo', 'img');
* @param {string} id The id of the dom-module in which to search.
* @param {string=} selector The css selector by which to find the element.
* @return {Element} Returns the element which matches `selector` in the
* module registered at the specified `id`.
*
* @export
* @nocollapse Referred to indirectly in style-gather.js
*/
static import(id, selector) {
if (id) {
let m = findModule(id);
if (m && selector) {
return m.querySelector(selector);
}
return m;
}
return null;
}
/* eslint-disable no-unused-vars */
/**
* @param {string} name Name of attribute.
* @param {?string} old Old value of attribute.
* @param {?string} value Current value of attribute.
* @param {?string} namespace Attribute namespace.
* @return {void}
* @override
*/
attributeChangedCallback(name, old, value, namespace) {
if (old !== value) {
this.register();
}
}
/* eslint-enable no-unused-args */
/**
* The absolute URL of the original location of this `dom-module`.
*
* This value will differ from this element's `ownerDocument` in the
* following ways:
* - Takes into account any `assetpath` attribute added during bundling
* to indicate the original location relative to the bundled location
* - Uses the HTMLImports polyfill's `importForElement` API to ensure
* the path is relative to the import document's location since
* `ownerDocument` is not currently polyfilled
*/
get assetpath() {
// Don't override existing assetpath.
if (!this.__assetpath) {
// note: assetpath set via an attribute must be relative to this
// element's location; accomodate polyfilled HTMLImports
const owner = window.HTMLImports && HTMLImports.importForElement ? HTMLImports.importForElement(this) || document : this.ownerDocument;
const url = resolveUrl(this.getAttribute('assetpath') || '', owner.baseURI);
this.__assetpath = pathFromUrl(url);
}
return this.__assetpath;
}
/**
* Registers the dom-module at a given id. This method should only be called
* when a dom-module is imperatively created. For
* example, `document.createElement('dom-module').register('foo')`.
* @param {string=} id The id at which to register the dom-module.
* @return {void}
*/
register(id) {
id = id || this.id;
if (id) {
// Under strictTemplatePolicy, reject and null out any re-registered
// dom-module since it is ambiguous whether first-in or last-in is trusted
if (strictTemplatePolicy && findModule(id) !== undefined) {
setModule(id, null);
throw new Error(`strictTemplatePolicy: dom-module ${id} re-registered`);
}
this.id = id;
setModule(id, this);
styleOutsideTemplateCheck(this);
}
}
}
DomModule.prototype['modules'] = modules;
customElements.define('dom-module', DomModule);
\ No newline at end of file
import"../utils/boot.js";import{dedupingMixin}from"../utils/mixin.js";import{PropertiesChanged}from"./properties-changed.js";function normalizeProperties(props){const output={};for(let p in props){const o=props[p];output[p]="function"===typeof o?{type:o}:o}return output}export const PropertiesMixin=dedupingMixin(superClass=>{const base=PropertiesChanged(superClass);function superPropertiesClass(constructor){const superCtor=Object.getPrototypeOf(constructor);return superCtor.prototype instanceof PropertiesMixin?superCtor:null}function ownProperties(constructor){if(!constructor.hasOwnProperty(JSCompiler_renameProperty("__ownProperties",constructor))){let props=null;if(constructor.hasOwnProperty(JSCompiler_renameProperty("properties",constructor))){const properties=constructor.properties;if(properties){props=normalizeProperties(properties)}}constructor.__ownProperties=props}return constructor.__ownProperties}class PropertiesMixin extends base{static get observedAttributes(){const props=this._properties;return props?Object.keys(props).map(p=>this.attributeNameForProperty(p)):[]}static finalize(){if(!this.hasOwnProperty(JSCompiler_renameProperty("__finalized",this))){const superCtor=superPropertiesClass(this);if(superCtor){superCtor.finalize()}this.__finalized=!0;this._finalizeClass()}}static _finalizeClass(){const props=ownProperties(this);if(props){this.createProperties(props)}}static get _properties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("__properties",this))){const superCtor=superPropertiesClass(this);this.__properties=Object.assign({},superCtor&&superCtor._properties,ownProperties(this))}return this.__properties}static typeForProperty(name){const info=this._properties[name];return info&&info.type}_initializeProperties(){this.constructor.finalize();super._initializeProperties()}connectedCallback(){if(super.connectedCallback){super.connectedCallback()}this._enableProperties()}disconnectedCallback(){if(super.disconnectedCallback){super.disconnectedCallback()}}}return PropertiesMixin});
\ No newline at end of file
/**
@license
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
import '../utils/boot.js';
import { dedupingMixin } from '../utils/mixin.js';
import { PropertiesChanged } from './properties-changed.js';
/**
* Creates a copy of `props` with each property normalized such that
* upgraded it is an object with at least a type property { type: Type}.
*
* @param {Object} props Properties to normalize
* @return {Object} Copy of input `props` with normalized properties that
* are in the form {type: Type}
* @private
*/
function normalizeProperties(props) {
const output = {};
for (let p in props) {
const o = props[p];
output[p] = typeof o === 'function' ? {
type: o
} : o;
}
return output;
}
/**
* Mixin that provides a minimal starting point to using the PropertiesChanged
* mixin by providing a mechanism to declare properties in a static
* getter (e.g. static get properties() { return { foo: String } }). Changes
* are reported via the `_propertiesChanged` method.
*
* This mixin provides no specific support for rendering. Users are expected
* to create a ShadowRoot and put content into it and update it in whatever
* way makes sense. This can be done in reaction to properties changing by
* implementing `_propertiesChanged`.
*
* @mixinFunction
* @polymer
* @appliesMixin PropertiesChanged
* @summary Mixin that provides a minimal starting point for using
* the PropertiesChanged mixin by providing a declarative `properties` object.
*/
export const PropertiesMixin = dedupingMixin(superClass => {
/**
* @constructor
* @implements {Polymer_PropertiesChanged}
* @private
*/
const base = PropertiesChanged(superClass);
/**
* Returns the super class constructor for the given class, if it is an
* instance of the PropertiesMixin.
*
* @param {!PropertiesMixinConstructor} constructor PropertiesMixin constructor
* @return {?PropertiesMixinConstructor} Super class constructor
*/
function superPropertiesClass(constructor) {
const superCtor = Object.getPrototypeOf(constructor); // Note, the `PropertiesMixin` class below only refers to the class
// generated by this call to the mixin; the instanceof test only works
// because the mixin is deduped and guaranteed only to apply once, hence
// all constructors in a proto chain will see the same `PropertiesMixin`
return superCtor.prototype instanceof PropertiesMixin ?
/** @type {!PropertiesMixinConstructor} */
superCtor : null;
}
/**
* Returns a memoized version of the `properties` object for the
* given class. Properties not in object format are converted to at
* least {type}.
*
* @param {PropertiesMixinConstructor} constructor PropertiesMixin constructor
* @return {Object} Memoized properties object
*/
function ownProperties(constructor) {
if (!constructor.hasOwnProperty(JSCompiler_renameProperty('__ownProperties', constructor))) {
let props = null;
if (constructor.hasOwnProperty(JSCompiler_renameProperty('properties', constructor))) {
const properties = constructor.properties;
if (properties) {
props = normalizeProperties(properties);
}
}
constructor.__ownProperties = props;
}
return constructor.__ownProperties;
}
/**
* @polymer
* @mixinClass
* @extends {base}
* @implements {Polymer_PropertiesMixin}
* @unrestricted
*/
class PropertiesMixin extends base {
/**
* Implements standard custom elements getter to observes the attributes
* listed in `properties`.
* @suppress {missingProperties} Interfaces in closure do not inherit statics, but classes do
*/
static get observedAttributes() {
const props = this._properties;
return props ? Object.keys(props).map(p => this.attributeNameForProperty(p)) : [];
}
/**
* Finalizes an element definition, including ensuring any super classes
* are also finalized. This includes ensuring property
* accessors exist on the element prototype. This method calls
* `_finalizeClass` to finalize each constructor in the prototype chain.
* @return {void}
*/
static finalize() {
if (!this.hasOwnProperty(JSCompiler_renameProperty('__finalized', this))) {
const superCtor = superPropertiesClass(
/** @type {!PropertiesMixinConstructor} */
this);
if (superCtor) {
superCtor.finalize();
}
this.__finalized = true;
this._finalizeClass();
}
}
/**
* Finalize an element class. This includes ensuring property
* accessors exist on the element prototype. This method is called by
* `finalize` and finalizes the class constructor.
*
* @protected
*/
static _finalizeClass() {
const props = ownProperties(
/** @type {!PropertiesMixinConstructor} */
this);
if (props) {
this.createProperties(props);
}
}
/**
* Returns a memoized version of all properties, including those inherited
* from super classes. Properties not in object format are converted to
* at least {type}.
*
* @return {Object} Object containing properties for this class
* @protected
*/
static get _properties() {
if (!this.hasOwnProperty(JSCompiler_renameProperty('__properties', this))) {
const superCtor = superPropertiesClass(
/** @type {!PropertiesMixinConstructor} */
this);
this.__properties = Object.assign({}, superCtor && superCtor._properties, ownProperties(
/** @type {PropertiesMixinConstructor} */
this));
}
return this.__properties;
}
/**
* Overrides `PropertiesChanged` method to return type specified in the
* static `properties` object for the given property.
* @param {string} name Name of property
* @return {*} Type to which to deserialize attribute
*
* @protected
*/
static typeForProperty(name) {
const info = this._properties[name];
return info && info.type;
}
/**
* Overrides `PropertiesChanged` method and adds a call to
* `finalize` which lazily configures the element's property accessors.
* @override
* @return {void}
*/
_initializeProperties() {
this.constructor.finalize();
super._initializeProperties();
}
/**
* Called when the element is added to a document.
* Calls `_enableProperties` to turn on property system from
* `PropertiesChanged`.
* @suppress {missingProperties} Super may or may not implement the callback
* @return {void}
* @override
*/
connectedCallback() {
if (super.connectedCallback) {
super.connectedCallback();
}
this._enableProperties();
}
/**
* Called when the element is removed from a document
* @suppress {missingProperties} Super may or may not implement the callback
* @return {void}
* @override
*/
disconnectedCallback() {
if (super.disconnectedCallback) {
super.disconnectedCallback();
}
}
}
return PropertiesMixin;
});
\ No newline at end of file
import"./boot.js";let microtaskCurrHandle=0,microtaskLastHandle=0,microtaskCallbacks=[],microtaskNodeContent=0,microtaskNode=document.createTextNode("");new window.MutationObserver(microtaskFlush).observe(microtaskNode,{characterData:!0});function microtaskFlush(){const len=microtaskCallbacks.length;for(let i=0,cb;i<len;i++){cb=microtaskCallbacks[i];if(cb){try{cb()}catch(e){setTimeout(()=>{throw e})}}}microtaskCallbacks.splice(0,len);microtaskLastHandle+=len}const timeOut={after(delay){return{run(fn){return window.setTimeout(fn,delay)},cancel(handle){window.clearTimeout(handle)}}},run(fn,delay){return window.setTimeout(fn,delay)},cancel(handle){window.clearTimeout(handle)}};export{timeOut};const animationFrame={run(fn){return window.requestAnimationFrame(fn)},cancel(handle){window.cancelAnimationFrame(handle)}};export{animationFrame};const idlePeriod={run(fn){return window.requestIdleCallback?window.requestIdleCallback(fn):window.setTimeout(fn,16)},cancel(handle){window.cancelIdleCallback?window.cancelIdleCallback(handle):window.clearTimeout(handle)}};export{idlePeriod};const microTask={run(callback){microtaskNode.textContent=microtaskNodeContent++;microtaskCallbacks.push(callback);return microtaskCurrHandle++},cancel(handle){const idx=handle-microtaskLastHandle;if(0<=idx){if(!microtaskCallbacks[idx]){throw new Error("invalid async handle: "+handle)}microtaskCallbacks[idx]=null}}};export{microTask};
\ No newline at end of file
/**
@license
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
/**
* @fileoverview
*
* This module provides a number of strategies for enqueuing asynchronous
* tasks. Each sub-module provides a standard `run(fn)` interface that returns a
* handle, and a `cancel(handle)` interface for canceling async tasks before
* they run.
*
* @summary Module that provides a number of strategies for enqueuing
* asynchronous tasks.
*/
import './boot.js'; // Microtask implemented using Mutation Observer
let microtaskCurrHandle = 0;
let microtaskLastHandle = 0;
let microtaskCallbacks = [];
let microtaskNodeContent = 0;
let microtaskNode = document.createTextNode('');
new window.MutationObserver(microtaskFlush).observe(microtaskNode, {
characterData: true
});
function microtaskFlush() {
const len = microtaskCallbacks.length;
for (let i = 0; i < len; i++) {
let cb = microtaskCallbacks[i];
if (cb) {
try {
cb();
} catch (e) {
setTimeout(() => {
throw e;
});
}
}
}
microtaskCallbacks.splice(0, len);
microtaskLastHandle += len;
}
/**
* Async interface wrapper around `setTimeout`.
*
* @namespace
* @summary Async interface wrapper around `setTimeout`.
*/
const timeOut = {
/**
* Returns a sub-module with the async interface providing the provided
* delay.
*
* @memberof timeOut
* @param {number=} delay Time to wait before calling callbacks in ms
* @return {!AsyncInterface} An async timeout interface
*/
after(delay) {
return {
run(fn) {
return window.setTimeout(fn, delay);
},
cancel(handle) {
window.clearTimeout(handle);
}
};
},
/**
* Enqueues a function called in the next task.
*
* @memberof timeOut
* @param {!Function} fn Callback to run
* @param {number=} delay Delay in milliseconds
* @return {number} Handle used for canceling task
*/
run(fn, delay) {
return window.setTimeout(fn, delay);
},
/**
* Cancels a previously enqueued `timeOut` callback.
*
* @memberof timeOut
* @param {number} handle Handle returned from `run` of callback to cancel
* @return {void}
*/
cancel(handle) {
window.clearTimeout(handle);
}
};
export { timeOut };
/**
* Async interface wrapper around `requestAnimationFrame`.
*
* @namespace
* @summary Async interface wrapper around `requestAnimationFrame`.
*/
const animationFrame = {
/**
* Enqueues a function called at `requestAnimationFrame` timing.
*
* @memberof animationFrame
* @param {function(number):void} fn Callback to run
* @return {number} Handle used for canceling task
*/
run(fn) {
return window.requestAnimationFrame(fn);
},
/**
* Cancels a previously enqueued `animationFrame` callback.
*
* @memberof animationFrame
* @param {number} handle Handle returned from `run` of callback to cancel
* @return {void}
*/
cancel(handle) {
window.cancelAnimationFrame(handle);
}
};
export { animationFrame };
/**
* Async interface wrapper around `requestIdleCallback`. Falls back to
* `setTimeout` on browsers that do not support `requestIdleCallback`.
*
* @namespace
* @summary Async interface wrapper around `requestIdleCallback`.
*/
const idlePeriod = {
/**
* Enqueues a function called at `requestIdleCallback` timing.
*
* @memberof idlePeriod
* @param {function(!IdleDeadline):void} fn Callback to run
* @return {number} Handle used for canceling task
*/
run(fn) {
return window.requestIdleCallback ? window.requestIdleCallback(fn) : window.setTimeout(fn, 16);
},
/**
* Cancels a previously enqueued `idlePeriod` callback.
*
* @memberof idlePeriod
* @param {number} handle Handle returned from `run` of callback to cancel
* @return {void}
*/
cancel(handle) {
window.cancelIdleCallback ? window.cancelIdleCallback(handle) : window.clearTimeout(handle);
}
};
export { idlePeriod };
/**
* Async interface for enqueuing callbacks that run at microtask timing.
*
* Note that microtask timing is achieved via a single `MutationObserver`,
* and thus callbacks enqueued with this API will all run in a single
* batch, and not interleaved with other microtasks such as promises.
* Promises are avoided as an implementation choice for the time being
* due to Safari bugs that cause Promises to lack microtask guarantees.
*
* @namespace
* @summary Async interface for enqueuing callbacks that run at microtask
* timing.
*/
const microTask = {
/**
* Enqueues a function called at microtask timing.
*
* @memberof microTask
* @param {!Function=} callback Callback to run
* @return {number} Handle used for canceling task
*/
run(callback) {
microtaskNode.textContent = microtaskNodeContent++;
microtaskCallbacks.push(callback);
return microtaskCurrHandle++;
},
/**
* Cancels a previously enqueued `microTask` callback.
*
* @memberof microTask
* @param {number} handle Handle returned from `run` of callback to cancel
* @return {void}
*/
cancel(handle) {
const idx = handle - microtaskLastHandle;
if (idx >= 0) {
if (!microtaskCallbacks[idx]) {
throw new Error('invalid async handle: ' + handle);
}
microtaskCallbacks[idx] = null;
}
}
};
export { microTask };
\ No newline at end of file
window.JSCompiler_renameProperty=function(prop,obj){return prop};export{};
\ No newline at end of file
/**
@license
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
/* eslint-disable no-unused-vars */
/**
* When using Closure Compiler, JSCompiler_renameProperty(property, object