From fe5a424bee7f91817ed1b4b2c7c0b4990a6c5d29 Mon Sep 17 00:00:00 2001 From: Justin Fagnani Date: Fri, 20 Dec 2019 10:23:35 -0800 Subject: [PATCH] Use Rollup to build JS for docs --- docs-src/_includes/example.11ty.cjs | 2 +- docs-src/_includes/nav.11ty.cjs | 8 +- docs-src/_includes/page.11ty.cjs | 6 +- docs/_README/index.html | 4 + docs/api/index.html | 14 +- docs/examples/basic/index.html | 54 ------- docs/examples/index copy/index.html | 66 -------- docs/examples/index.html | 18 +-- docs/examples/name-property/index.html | 18 +-- docs/index.html | 14 +- docs/install/index.html | 14 +- docs/my-element.bundled.js | 199 +++++++++++++++++++++++++ docs/prism-okaidia.css | 123 +++++++++++++++ package.json | 13 +- 14 files changed, 383 insertions(+), 170 deletions(-) delete mode 100644 docs/examples/basic/index.html delete mode 100644 docs/examples/index copy/index.html create mode 100644 docs/my-element.bundled.js create mode 100644 docs/prism-okaidia.css diff --git a/docs-src/_includes/example.11ty.cjs b/docs-src/_includes/example.11ty.cjs index e780bee..b972e71 100644 --- a/docs-src/_includes/example.11ty.cjs +++ b/docs-src/_includes/example.11ty.cjs @@ -21,7 +21,7 @@ const renderExample = ({name, content, collections, page}) => { ? '' : collections.example.map((post) => `
  • - ${ post.data.description.replace('<', '<') } + ${ post.data.description.replace('<', '<') }
  • `).join('')} diff --git a/docs-src/_includes/nav.11ty.cjs b/docs-src/_includes/nav.11ty.cjs index f16b53d..8f51c12 100644 --- a/docs-src/_includes/nav.11ty.cjs +++ b/docs-src/_includes/nav.11ty.cjs @@ -1,9 +1,9 @@ module.exports = function(data) { return ` `; }; diff --git a/docs-src/_includes/page.11ty.cjs b/docs-src/_includes/page.11ty.cjs index 983d622..737ca1c 100644 --- a/docs-src/_includes/page.11ty.cjs +++ b/docs-src/_includes/page.11ty.cjs @@ -11,10 +11,10 @@ module.exports = function(data) { ${data.title} - + - - + + ${header()} diff --git a/docs/_README/index.html b/docs/_README/index.html index e69de29..16d23f2 100644 --- a/docs/_README/index.html +++ b/docs/_README/index.html @@ -0,0 +1,4 @@ +

    This directory containts the sources for the static site contained in the /docs/ directory. The site is based on the eleventy static site generator.

    +

    The site is intended to be used with GitHub pages. To enable the site go to the GitHub settings and change the GitHub Pages "Source" setting to "master branch /docs folder".

    +

    To view the site locally, run npm run serve.

    +

    To edit the site, add to or edit the files in this directory then run npm run docs to build the site. The built files must be checked in and pushed to GitHub to appear on GitHub pages.

    diff --git a/docs/api/index.html b/docs/api/index.html index 5ff487e..f447651 100644 --- a/docs/api/index.html +++ b/docs/api/index.html @@ -6,10 +6,10 @@ <my-element> ⌲ Docs - + - - + + @@ -19,10 +19,10 @@
    diff --git a/docs/examples/basic/index.html b/docs/examples/basic/index.html deleted file mode 100644 index 9df5749..0000000 --- a/docs/examples/basic/index.html +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - <my-element> ⌲ Examples ⌲ Basic - - - - - - - -
    -

    <my-element>

    -

    A web component just for me.

    -
    - - -
    -
    -

    Basic Use

    - - -

    This is child content

    -
    -

    CSS

    -
      p {
    border: solid 1px blue;
    padding: 8px;
    }
    -

    HTML

    -
    <my-element>
    <p>This is child content</p>
    </my-element>
    - -
    -
    - - - - \ No newline at end of file diff --git a/docs/examples/index copy/index.html b/docs/examples/index copy/index.html deleted file mode 100644 index f39949b..0000000 --- a/docs/examples/index copy/index.html +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - <my-element> ⌲ Examples ⌲ Basic - - - - - - - -
    -

    <my-element>

    -

    A web component just for me.

    -
    - - -
    -
    - -

    Examples

    - -

    Basic Use

    - - -

    This is child content

    -
    -

    CSS

    -
      p {
    border: solid 1px blue;
    padding: 8px;
    }
    -

    HTML

    -
    <my-element>
    <p>This is child content</p>
    </my-element>
    - - -
    -
    - - - - \ No newline at end of file diff --git a/docs/examples/index.html b/docs/examples/index.html index 7b29980..32d76ac 100644 --- a/docs/examples/index.html +++ b/docs/examples/index.html @@ -6,10 +6,10 @@ <my-element> ⌲ Examples ⌲ Basic - + - - + + @@ -19,10 +19,10 @@
    @@ -33,11 +33,11 @@ diff --git a/docs/examples/name-property/index.html b/docs/examples/name-property/index.html index 2be54c7..c09f86d 100644 --- a/docs/examples/name-property/index.html +++ b/docs/examples/name-property/index.html @@ -6,10 +6,10 @@ <my-element> ⌲ Examples ⌲ Name Property - + - - + + @@ -19,10 +19,10 @@
    @@ -33,11 +33,11 @@ diff --git a/docs/index.html b/docs/index.html index c318718..ba76fd8 100644 --- a/docs/index.html +++ b/docs/index.html @@ -6,10 +6,10 @@ <my-element> ⌲ Home - + - - + + @@ -19,10 +19,10 @@
    diff --git a/docs/install/index.html b/docs/install/index.html index f5fd2c0..30ec403 100644 --- a/docs/install/index.html +++ b/docs/install/index.html @@ -6,10 +6,10 @@ <my-element> ⌲ Install - + - - + + @@ -19,10 +19,10 @@
    diff --git a/docs/my-element.bundled.js b/docs/my-element.bundled.js new file mode 100644 index 0000000..a4b359d --- /dev/null +++ b/docs/my-element.bundled.js @@ -0,0 +1,199 @@ +/** + * @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 + */ +const t=new WeakMap,s=s=>"function"==typeof s&&t.has(s),i=void 0!==window.customElements&&void 0!==window.customElements.polyfillWrapFlushCallback,e=(t,s,i=null)=>{for(;s!==i;){const i=s.nextSibling;t.removeChild(s),s=i}},n={},o={},r=`{{lit-${String(Math.random()).slice(2)}}}`,h=`\x3c!--${r}--\x3e`,c=new RegExp(`${r}|${h}`),l="$lit$";class a{constructor(t,s){this.parts=[],this.element=s;const i=[],e=[],n=document.createTreeWalker(s.content,133,null,!1);let o=0,h=-1,a=0;const{strings:d,values:{length:w}}=t;for(;a0;){const s=d[a],i=p.exec(s)[2],e=i.toLowerCase()+l,n=t.getAttribute(e);t.removeAttribute(e);const o=n.split(c);this.parts.push({type:"attribute",index:h,name:i,strings:o}),a+=o.length-1}}"TEMPLATE"===t.tagName&&(e.push(t),n.currentNode=t.content)}else if(3===t.nodeType){const s=t.data;if(s.indexOf(r)>=0){const e=t.parentNode,n=s.split(c),o=n.length-1;for(let s=0;s{const i=t.length-s.length;return i>=0&&t.slice(i)===s},d=t=>-1!==t.index,f=()=>document.createComment(""),p=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/; +/** + * @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 + */ +class w{constructor(t,s,i){this.t=[],this.template=t,this.processor=s,this.options=i}update(t){let s=0;for(const i of this.t)void 0!==i&&i.setValue(t[s]),s++;for(const t of this.t)void 0!==t&&t.commit()}_clone(){const t=i?this.template.element.content.cloneNode(!0):document.importNode(this.template.element.content,!0),s=[],e=this.template.parts,n=document.createTreeWalker(t,133,null,!1);let o,r=0,h=0,c=n.nextNode();for(;r-1||i)&&-1===t.indexOf("--\x3e",n+1);const o=p.exec(t);s+=null===o?t+(i?m:h):t.substr(0,o.index)+o[1]+o[2]+l+o[3]+r}return s+=this.strings[t],s}getTemplateElement(){const t=document.createElement("template");return t.innerHTML=this.getHTML(),t}} +/** + * @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 + */const v=t=>null===t||!("object"==typeof t||"function"==typeof t),b=t=>Array.isArray(t)||!(!t||!t[Symbol.iterator]);class g{constructor(t,s,i){this.dirty=!0,this.element=t,this.name=s,this.strings=i,this.parts=[];for(let t=0;tthis.handleEvent(t)}setValue(t){this.s=t}commit(){for(;s(this.s);){const t=this.s;this.s=n,t(this)}if(this.s===n)return;const t=this.s,i=this.value,e=null==t||null!=i&&(t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive),o=null!=t&&(null==i||e);e&&this.element.removeEventListener(this.eventName,this.p,this.m),o&&(this.m=M(t),this.element.addEventListener(this.eventName,this.p,this.m)),this.value=t,this.s=n}handleEvent(t){"function"==typeof this.value?this.value.call(this.eventContext||this.element,t):this.value.handleEvent(t)}}const M=t=>t&&(A?{capture:t.capture,passive:t.passive,once:t.once}:t.capture); +/** + * @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 + */const j=new class{handleAttributeExpressions(t,s,i,e){const n=s[0];if("."===n){return new C(t,s.slice(1),i).parts}return"@"===n?[new P(t,s.slice(1),e.eventContext)]:"?"===n?[new _(t,s.slice(1),i)]:new g(t,s,i).parts}handleTextExpression(t){return new S(t)}}; +/** + * @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 + */function E(t){let s=O.get(t.type);void 0===s&&(s={stringsArray:new WeakMap,keyString:new Map},O.set(t.type,s));let i=s.stringsArray.get(t.strings);if(void 0!==i)return i;const e=t.strings.join(r);return i=s.keyString.get(e),void 0===i&&(i=new a(t,t.getTemplateElement()),s.keyString.set(e,i)),s.stringsArray.set(t.strings,i),i}const O=new Map,$=new WeakMap; +/** + * @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 + */ +/** + * @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 + */ +(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.1.2");const T=(t,...s)=>new y(t,s,"html",j),U=133; +/** + * @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 + */function N(t,s){const{element:{content:i},parts:e}=t,n=document.createTreeWalker(i,U,null,!1);let o=F(e),r=e[o],h=-1,c=0;const l=[];let a=null;for(;n.nextNode();){h++;const t=n.currentNode;for(t.previousSibling===a&&(a=null),s.has(t)&&(l.push(t),null===a&&(a=t)),null!==a&&c++;void 0!==r&&r.index===h;)r.index=null!==a?-1:r.index-c,o=F(e,o),r=e[o]}l.forEach(t=>t.parentNode.removeChild(t))}const V=t=>{let s=11===t.nodeType?0:1;const i=document.createTreeWalker(t,U,null,!1);for(;i.nextNode();)s++;return s},F=(t,s=-1)=>{for(let i=s+1;i`${t}--${s}`;let z=!0;void 0===window.ShadyCSS?z=!1:void 0===window.ShadyCSS.prepareTemplateDom&&(console.warn("Incompatible ShadyCSS version detected. Please update to at least @webcomponents/webcomponentsjs@2.0.2 and @webcomponents/shadycss@1.3.1."),z=!1);const I=t=>s=>{const i=q(s.type,t);let e=O.get(i);void 0===e&&(e={stringsArray:new WeakMap,keyString:new Map},O.set(i,e));let n=e.stringsArray.get(s.strings);if(void 0!==n)return n;const o=s.strings.join(r);if(n=e.keyString.get(o),void 0===n){const i=s.getTemplateElement();z&&window.ShadyCSS.prepareTemplateDom(i,t),n=new a(s,i),e.keyString.set(o,n)}return e.stringsArray.set(s.strings,n),n},R=["html","svg"],J=new Set,W=(t,s,i)=>{J.add(t);const e=i?i.element:document.createElement("template"),n=s.querySelectorAll("style"),{length:o}=n;if(0===o)return void window.ShadyCSS.prepareTemplateStyles(e,t);const r=document.createElement("style");for(let t=0;t{R.forEach(s=>{const i=O.get(q(s,t));void 0!==i&&i.keyString.forEach(t=>{const{element:{content:s}}=t,i=new Set;Array.from(s.querySelectorAll("style")).forEach(t=>{i.add(t)}),N(t,i)})})})(t);const h=e.content;i?function(t,s,i=null){const{element:{content:e},parts:n}=t;if(null==i)return void e.appendChild(s);const o=document.createTreeWalker(e,U,null,!1);let r=F(n),h=0,c=-1;for(;o.nextNode();){for(c++,o.currentNode===i&&(h=V(s),i.parentNode.insertBefore(s,i));-1!==r&&n[r].index===c;){if(h>0){for(;-1!==r;)n[r].index+=h,r=F(n,r);return}r=F(n,r)}}}(i,r,h.firstChild):h.insertBefore(r,h.firstChild),window.ShadyCSS.prepareTemplateStyles(e,t);const c=h.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==c)s.insertBefore(c.cloneNode(!0),s.firstChild);else if(i){h.insertBefore(r,h.firstChild);const t=new Set;t.add(r),N(i,t)}};window.JSCompiler_renameProperty=(t,s)=>t;const H={toAttribute(t,s){switch(s){case Boolean:return t?"":null;case Object:case Array:return null==t?t:JSON.stringify(t)}return t},fromAttribute(t,s){switch(s){case Boolean:return null!==t;case Number:return null===t?null:Number(t);case Object:case Array:return JSON.parse(t)}return t}},L=(t,s)=>s!==t&&(s==s||t==t),B={attribute:!0,type:String,converter:H,reflect:!1,hasChanged:L},D=Promise.resolve(!0),G=1,K=4,Q=8,X=16,Y=32,Z="finalized";class tt extends HTMLElement{constructor(){super(),this._updateState=0,this._instanceProperties=void 0,this._updatePromise=D,this._hasConnectedResolver=void 0,this._changedProperties=new Map,this._reflectingProperties=void 0,this.initialize()}static get observedAttributes(){this.finalize();const t=[];return this._classProperties.forEach((s,i)=>{const e=this._attributeNameForProperty(i,s);void 0!==e&&(this._attributeToPropertyMap.set(e,i),t.push(e))}),t}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;const t=Object.getPrototypeOf(this)._classProperties;void 0!==t&&t.forEach((t,s)=>this._classProperties.set(s,t))}}static createProperty(t,s=B){if(this._ensureClassProperties(),this._classProperties.set(t,s),s.noAccessor||this.prototype.hasOwnProperty(t))return;const i="symbol"==typeof t?Symbol():`__${t}`;Object.defineProperty(this.prototype,t,{get(){return this[i]},set(s){const e=this[t];this[i]=s,this._requestUpdate(t,e)},configurable:!0,enumerable:!0})}static finalize(){const t=Object.getPrototypeOf(this);if(t.hasOwnProperty(Z)||t.finalize(),this[Z]=!0,this._ensureClassProperties(),this._attributeToPropertyMap=new Map,this.hasOwnProperty(JSCompiler_renameProperty("properties",this))){const t=this.properties,s=[...Object.getOwnPropertyNames(t),..."function"==typeof Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]];for(const i of s)this.createProperty(i,t[i])}}static _attributeNameForProperty(t,s){const i=s.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}static _valueHasChanged(t,s,i=L){return i(t,s)}static _propertyValueFromAttribute(t,s){const i=s.type,e=s.converter||H,n="function"==typeof e?e:e.fromAttribute;return n?n(t,i):t}static _propertyValueToAttribute(t,s){if(void 0===s.reflect)return;const i=s.type,e=s.converter;return(e&&e.toAttribute||H.toAttribute)(t,i)}initialize(){this._saveInstanceProperties(),this._requestUpdate()}_saveInstanceProperties(){this.constructor._classProperties.forEach((t,s)=>{if(this.hasOwnProperty(s)){const t=this[s];delete this[s],this._instanceProperties||(this._instanceProperties=new Map),this._instanceProperties.set(s,t)}})}_applyInstanceProperties(){this._instanceProperties.forEach((t,s)=>this[s]=t),this._instanceProperties=void 0}connectedCallback(){this._updateState=this._updateState|Y,this._hasConnectedResolver&&(this._hasConnectedResolver(),this._hasConnectedResolver=void 0)}disconnectedCallback(){}attributeChangedCallback(t,s,i){s!==i&&this._attributeToProperty(t,i)}_propertyToAttribute(t,s,i=B){const e=this.constructor,n=e._attributeNameForProperty(t,i);if(void 0!==n){const t=e._propertyValueToAttribute(s,i);if(void 0===t)return;this._updateState=this._updateState|Q,null==t?this.removeAttribute(n):this.setAttribute(n,t),this._updateState=this._updateState&~Q}}_attributeToProperty(t,s){if(this._updateState&Q)return;const i=this.constructor,e=i._attributeToPropertyMap.get(t);if(void 0!==e){const t=i._classProperties.get(e)||B;this._updateState=this._updateState|X,this[e]=i._propertyValueFromAttribute(s,t),this._updateState=this._updateState&~X}}_requestUpdate(t,s){let i=!0;if(void 0!==t){const e=this.constructor,n=e._classProperties.get(t)||B;e._valueHasChanged(this[t],s,n.hasChanged)?(this._changedProperties.has(t)||this._changedProperties.set(t,s),!0!==n.reflect||this._updateState&X||(void 0===this._reflectingProperties&&(this._reflectingProperties=new Map),this._reflectingProperties.set(t,n))):i=!1}!this._hasRequestedUpdate&&i&&this._enqueueUpdate()}requestUpdate(t,s){return this._requestUpdate(t,s),this.updateComplete}async _enqueueUpdate(){let t,s;this._updateState=this._updateState|K;const i=this._updatePromise;this._updatePromise=new Promise((i,e)=>{t=i,s=e});try{await i}catch(t){}this._hasConnected||await new Promise(t=>this._hasConnectedResolver=t);try{const t=this.performUpdate();null!=t&&await t}catch(t){s(t)}t(!this._hasRequestedUpdate)}get _hasConnected(){return this._updateState&Y}get _hasRequestedUpdate(){return this._updateState&K}get hasUpdated(){return this._updateState&G}performUpdate(){this._instanceProperties&&this._applyInstanceProperties();let t=!1;const s=this._changedProperties;try{t=this.shouldUpdate(s),t&&this.update(s)}catch(s){throw t=!1,s}finally{this._markUpdated()}t&&(this._updateState&G||(this._updateState=this._updateState|G,this.firstUpdated(s)),this.updated(s))}_markUpdated(){this._changedProperties=new Map,this._updateState=this._updateState&~K}get updateComplete(){return this._getUpdateComplete()}_getUpdateComplete(){return this._updatePromise}shouldUpdate(t){return!0}update(t){void 0!==this._reflectingProperties&&this._reflectingProperties.size>0&&(this._reflectingProperties.forEach((t,s)=>this._propertyToAttribute(s,this[s],t)),this._reflectingProperties=void 0)}updated(t){}firstUpdated(t){}}tt[Z]=!0; +/** + * @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 + */ +const st=(t,s)=>"method"!==s.kind||!s.descriptor||"value"in s.descriptor?{kind:"field",key:Symbol(),placement:"own",descriptor:{},initializer(){"function"==typeof s.initializer&&(this[s.key]=s.initializer.call(this))},finisher(i){i.createProperty(s.key,t)}}:Object.assign({},s,{finisher(i){i.createProperty(s.key,t)}}),it=(t,s,i)=>{s.constructor.createProperty(i,t)};function et(t){return(s,i)=>void 0!==i?it(t,s,i):st(t,s)} +/** +@license +Copyright (c) 2019 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 +*/const nt="adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ot=Symbol();class rt{constructor(t,s){if(s!==ot)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t}get styleSheet(){return void 0===this._styleSheet&&(nt?(this._styleSheet=new CSSStyleSheet,this._styleSheet.replaceSync(this.cssText)):this._styleSheet=null),this._styleSheet}toString(){return this.cssText}} +/** + * @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 + */ +(window.litElementVersions||(window.litElementVersions=[])).push("2.2.1");const ht=t=>t.flat?t.flat(1/0):function t(s,i=[]){for(let e=0,n=s.length;e(t.add(s),t),new Set).forEach(t=>s.unshift(t))}else t&&s.push(t);return s}initialize(){super.initialize(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow({mode:"open"})}adoptStyles(){const t=this.constructor._styles;0!==t.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?nt?this.renderRoot.adoptedStyleSheets=t.map(t=>t.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(t.map(t=>t.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(t){super.update(t);const s=this.render();s instanceof y&&this.constructor.render(s,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(t=>{const s=document.createElement("style");s.textContent=t.cssText,this.renderRoot.appendChild(s)}))}render(){}}ct.finalized=!0,ct.render=(t,s,i)=>{if(!i||"object"!=typeof i||!i.scopeName)throw new Error("The `scopeName` option is required.");const n=i.scopeName,o=$.has(s),r=z&&11===s.nodeType&&!!s.host,h=r&&!J.has(n),c=h?document.createDocumentFragment():s;if(((t,s,i)=>{let n=$.get(s);void 0===n&&(e(s,s.firstChild),$.set(s,n=new S(Object.assign({templateFactory:E},i))),n.appendInto(s)),n.setValue(t),n.commit()})(t,c,Object.assign({templateFactory:I(n)},i)),h){const t=$.get(c);$.delete(c);const i=t.value instanceof w?t.value.template:void 0;W(n,c,i),e(s,s.firstChild),s.appendChild(c),$.set(s,t)}!o&&r&&window.ShadyCSS.styleElement(s.host)}; +/** + * @license + * Copyright (c) 2019 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 + */ +var lt=function(t,s,i,e){for(var n,o=arguments.length,r=o<3?s:null===e?e=Object.getOwnPropertyDescriptor(s,i):e,h=t.length-1;h>=0;h--)(n=t[h])&&(r=(o<3?n(r):o>3?n(s,i,r):n(s,i))||r);return o>3&&r&&Object.defineProperty(s,i,r),r};let at=class extends ct{constructor(){super(...arguments),this.name="World",this.count=0}render(){return T` +

    Hello, ${this.name}!

    + + + `}_onClick(){this.count++}foo(){return"foo"}};at.styles=((t,...s)=>{const i=s.reduce((s,i,e)=>s+(t=>{if(t instanceof rt)return t.cssText;if("number"==typeof t)return t;throw new Error(`Value passed to 'css' function must be a 'css' function result: ${t}. Use 'unsafeCSS' to pass non-literal values, but\n take care to ensure page security.`)})(i)+t[e+1],t[0]);return new rt(i,ot)})` + :host { + display: block; + border: solid 1px gray; + padding: 16px; + max-width: 800px; + } + `,lt([et()],at.prototype,"name",void 0),lt([et({type:Number})],at.prototype,"count",void 0),at=lt([(t=>s=>"function"==typeof s?((t,s)=>(window.customElements.define(t,s),s))(t,s):((t,s)=>{const{kind:i,elements:e}=s;return{kind:i,elements:e,finisher(s){window.customElements.define(t,s)}}})(t,s))("my-element")],at);export{at as MyElement}; diff --git a/docs/prism-okaidia.css b/docs/prism-okaidia.css new file mode 100644 index 0000000..767417b --- /dev/null +++ b/docs/prism-okaidia.css @@ -0,0 +1,123 @@ +/** + * okaidia theme for JavaScript, CSS and HTML + * Loosely based on Monokai textmate theme by http://www.monokai.nl/ + * @author ocodia + */ + +code[class*="language-"], +pre[class*="language-"] { + color: #f8f8f2; + background: none; + text-shadow: 0 1px rgba(0, 0, 0, 0.3); + font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; + font-size: 1em; + text-align: left; + white-space: pre; + word-spacing: normal; + word-break: normal; + word-wrap: normal; + line-height: 1.5; + + -moz-tab-size: 4; + -o-tab-size: 4; + tab-size: 4; + + -webkit-hyphens: none; + -moz-hyphens: none; + -ms-hyphens: none; + hyphens: none; +} + +/* Code blocks */ +pre[class*="language-"] { + padding: 1em; + margin: .5em 0; + overflow: auto; + border-radius: 0.3em; +} + +:not(pre) > code[class*="language-"], +pre[class*="language-"] { + background: #272822; +} + +/* Inline code */ +:not(pre) > code[class*="language-"] { + padding: .1em; + border-radius: .3em; + white-space: normal; +} + +.token.comment, +.token.prolog, +.token.doctype, +.token.cdata { + color: slategray; +} + +.token.punctuation { + color: #f8f8f2; +} + +.namespace { + opacity: .7; +} + +.token.property, +.token.tag, +.token.constant, +.token.symbol, +.token.deleted { + color: #f92672; +} + +.token.boolean, +.token.number { + color: #ae81ff; +} + +.token.selector, +.token.attr-name, +.token.string, +.token.char, +.token.builtin, +.token.inserted { + color: #a6e22e; +} + +.token.operator, +.token.entity, +.token.url, +.language-css .token.string, +.style .token.string, +.token.variable { + color: #f8f8f2; +} + +.token.atrule, +.token.attr-value, +.token.function, +.token.class-name { + color: #e6db74; +} + +.token.keyword { + color: #66d9ef; +} + +.token.regex, +.token.important { + color: #fd971f; +} + +.token.important, +.token.bold { + font-weight: bold; +} +.token.italic { + font-style: italic; +} + +.token.entity { + cursor: help; +} diff --git a/package.json b/package.json index ee0cf70..c26be89 100644 --- a/package.json +++ b/package.json @@ -10,10 +10,13 @@ "build:watch": "tsc --watch", "lint": "lit-analyzer && eslint 'src/**/*.ts'", "format": "prettier src/* --write", - "docs": "npm run analyze & eleventy --config=.eleventy.cjs", - "docs:watch": "eleventy --config=.eleventy.cjs --watch", + "docs": "npm run build && npm run analyze && npm run docs:build && npm run docs:assets && npm run docs:gen", + "docs:gen": "eleventy --config=.eleventy.cjs", + "docs:gen:watch": "eleventy --config=.eleventy.cjs --watch", + "docs:build": "rollup -c --file docs/my-element.bundled.js", + "docs:assets": "cp node_modules/prismjs/themes/prism-okaidia.css docs/", + "docs:serve": "es-dev-server --root-dir=docs --node-resolve --watch", "analyze": "wca analyze \"src/**/*.ts\" --outFile custom-elements.json", - "serve": "es-dev-server --node-resolve --watch", "test": "karma start karma.conf.cjs", "test:watch": "karma start karma.conf.cjs --auto-watch=true --single-run=false", "test:update-snapshots": "karma start karma.conf.cjs --update-snapshots", @@ -49,6 +52,10 @@ "lit-analyzer": "^1.1.9", "mocha": "^6.2.2", "prettier": "^1.19.1", + "rollup": "^1.27.13", + "rollup-plugin-filesize": "^6.2.1", + "rollup-plugin-node-resolve": "^5.2.0", + "rollup-plugin-terser": "^5.1.3", "typescript": "^3.7.2", "web-component-analyzer": "^1.0.0" }