@stdlib/esm
Version:
ES module distribution for Stdlib, a standard library for JavaScript and Node.js.
27 lines • 7.01 kB
JavaScript
// Copyright (c) 2014 Matt-Esch.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
var nativeIsArray=Array.isArray,toString=Object.prototype.toString,xIsArray=nativeIsArray||isArray;function isArray(e){return"[object Array]"===toString.call(e)}var version="2",isVnode=isVirtualNode;function isVirtualNode(e){return e&&"VirtualNode"===e.type&&e.version===version}var isWidget_1=isWidget;function isWidget(e){return e&&"Widget"===e.type}var isThunk_1=isThunk;function isThunk(e){return e&&"Thunk"===e.type}var isVhook=isHook;function isHook(e){return e&&("function"==typeof e.hook&&!e.hasOwnProperty("hook")||"function"==typeof e.unhook&&!e.hasOwnProperty("unhook"))}var vnode=VirtualNode,noProperties={},noChildren=[];function VirtualNode(e,t,n,o,r){this.tagName=e,this.properties=t||noProperties,this.children=n||noChildren,this.key=null!=o?String(o):void 0,this.namespace="string"==typeof r?r:null;var i,s=n&&n.length||0,a=0,u=!1,l=!1,h=!1;for(var p in t)if(t.hasOwnProperty(p)){var d=t[p];isVhook(d)&&d.unhook&&(i||(i={}),i[p]=d)}for(var v=0;v<s;v++){var f=n[v];isVnode(f)?(a+=f.count||0,!u&&f.hasWidgets&&(u=!0),!l&&f.hasThunks&&(l=!0),h||!f.hooks&&!f.descendantHooks||(h=!0)):!u&&isWidget_1(f)?"function"==typeof f.destroy&&(u=!0):!l&&isThunk_1(f)&&(l=!0)}this.count=s+a,this.hasWidgets=u,this.hasThunks=l,this.hooks=i,this.descendantHooks=h}VirtualNode.prototype.version=version,VirtualNode.prototype.type="VirtualNode";var vtext=VirtualText;function VirtualText(e){this.text=String(e)}VirtualText.prototype.version=version,VirtualText.prototype.type="VirtualText";var isVtext=isVirtualText;function isVirtualText(e){return e&&"VirtualText"===e.type&&e.version===version}
/*!
* Cross-Browser Split 1.1.1
* Copyright 2007-2012 Steven Levithan <stevenlevithan.com>
* Available under the MIT License
* ECMAScript compliant, uniform cross-browser split method
*/var browserSplit=function(e){var t=String.prototype.split,n=/()??/.exec("")[1]===e;return function(o,r,i){if("[object RegExp]"!==Object.prototype.toString.call(r))return t.call(o,r,i);var s,a,u,l,h=[],p=(r.ignoreCase?"i":"")+(r.multiline?"m":"")+(r.extended?"x":"")+(r.sticky?"y":""),d=0;r=new RegExp(r.source,p+"g");for(o+="",n||(s=new RegExp("^"+r.source+"$(?!\\s)",p)),i=i===e?-1>>>0:i>>>0;(a=r.exec(o))&&!((u=a.index+a[0].length)>d&&(h.push(o.slice(d,a.index)),!n&&a.length>1&&a[0].replace(s,(function(){for(var t=1;t<arguments.length-2;t++)arguments[t]===e&&(a[t]=e)})),a.length>1&&a.index<o.length&&Array.prototype.push.apply(h,a.slice(1)),l=a[0].length,d=u,h.length>=i));)r.lastIndex===a.index&&r.lastIndex++;return d===o.length?!l&&r.test("")||h.push(""):h.push(o.slice(d)),h.length>i?h.slice(0,i):h}}(),classIdSplit=/([\.#]?[a-zA-Z0-9\u007F-\uFFFF_:-]+)/,notClassId=/^\.|#/,parseTag_1=parseTag;function parseTag(e,t){if(!e)return"DIV";var n,o,r,i,s=!t.hasOwnProperty("id"),a=browserSplit(e,classIdSplit),u=null;for(notClassId.test(a[1])&&(u="DIV"),i=0;i<a.length;i++)(o=a[i])&&(r=o.charAt(0),u?"."===r?(n=n||[]).push(o.substring(1,o.length)):"#"===r&&s&&(t.id=o.substring(1,o.length)):u=o);return n&&(t.className&&n.push(t.className),t.className=n.join(" ")),t.namespace?u:u.toUpperCase()}var softSetHook=SoftSetHook;function SoftSetHook(e){if(!(this instanceof SoftSetHook))return new SoftSetHook(e);this.value=e}SoftSetHook.prototype.hook=function(e,t){e[t]!==this.value&&(e[t]=this.value)};var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},root="undefined"!=typeof window?window:void 0!==commonjsGlobal?commonjsGlobal:{},individual=Individual;function Individual(e,t){return e in root?root[e]:(root[e]=t,t)}var oneVersion=OneVersion;function OneVersion(e,t,n){var o="__INDIVIDUAL_ONE_VERSION_"+e,r=individual(o+"_ENFORCE_SINGLETON",t);if(r!==t)throw new Error("Can only have one copy of "+e+".\nYou already have version "+r+" installed.\nThis means you cannot install version "+t);return individual(o,n)}var MY_VERSION="7";oneVersion("ev-store",MY_VERSION);var hashKey="__EV_STORE_KEY@"+MY_VERSION,evStore=EvStore;function EvStore(e){var t=e[hashKey];return t||(t=e[hashKey]={}),t}var evHook=EvHook;function EvHook(e){if(!(this instanceof EvHook))return new EvHook(e);this.value=e}EvHook.prototype.hook=function(e,t){evStore(e)[t.substr(3)]=this.value},EvHook.prototype.unhook=function(e,t){evStore(e)[t.substr(3)]=void 0};var virtualHyperscript=h;function h(e,t,n){var o,r,i,s,a=[];return!n&&isChildren(t)&&(n=t,r={}),o=parseTag_1(e,r=r||t||{}),r.hasOwnProperty("key")&&(i=r.key,r.key=void 0),r.hasOwnProperty("namespace")&&(s=r.namespace,r.namespace=void 0),"INPUT"!==o||s||!r.hasOwnProperty("value")||void 0===r.value||isVhook(r.value)||(r.value=softSetHook(r.value)),transformProperties(r),null!=n&&addChild(n,a,o,r),new vnode(o,r,a,i,s)}function addChild(e,t,n,o){if("string"==typeof e)t.push(new vtext(e));else if("number"==typeof e)t.push(new vtext(String(e)));else if(isChild(e))t.push(e);else{if(!xIsArray(e)){if(null==e)return;throw UnexpectedVirtualElement({foreignObject:e,parentVnode:{tagName:n,properties:o}})}for(var r=0;r<e.length;r++)addChild(e[r],t,n,o)}}function transformProperties(e){for(var t in e)if(e.hasOwnProperty(t)){var n=e[t];if(isVhook(n))continue;"ev-"===t.substr(0,3)&&(e[t]=evHook(n))}}function isChild(e){return isVnode(e)||isVtext(e)||isWidget_1(e)||isThunk_1(e)}function isChildren(e){return"string"==typeof e||xIsArray(e)||isChild(e)}function UnexpectedVirtualElement(e){var t=new Error;return t.type="virtual-hyperscript.unexpected.virtual-element",t.message="Unexpected virtual child passed to h().\nExpected a VNode / Vthunk / VWidget / string but:\ngot:\n"+errorString(e.foreignObject)+".\nThe parent vnode is:\n"+errorString(e.parentVnode),t.foreignObject=e.foreignObject,t.parentVnode=e.parentVnode,t}function errorString(e){try{return JSON.stringify(e,null," ")}catch(t){return String(e)}}var h_1=virtualHyperscript;export default h_1;