@stdlib/esm
Version:
ES module distribution for Stdlib, a standard library for JavaScript and Node.js.
3 lines • 4.79 kB
JavaScript
// This file is a part of stdlib. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0
import e from"./../../../vendor/events.js";import t from"./../../../vendor/debug.js";import i from"./../../../utils/define-property.js";import r from"./../../../utils/define-read-only-property.js";import n from"./../../../random/base/minstd.js";import a from"./../../../utils/copy.js";import o from"./../../../utils/keys.js";import u from"./../../../assert/is-plain-object.js";import s from"./../../../assert/has-own-property.js";import h from"./../../../assert/is-positive-number.js";import l from"./../../../assert/is-string.js";import p from"./../../../assert/is-boolean.js";import d from"./../../../vendor/virtual-dom/h.js";var m=400,c=400,v="",f=!1,g={width:m,height:c,id:v,autoRender:f},w=h.isPrimitive;function b(e){return w(e)?null:new TypeError("invalid value. `width` must be a positive number. Value: `"+e+".`")}var y=h.isPrimitive;function _(e){return y(e)?null:new TypeError("invalid value. `height` must be a positive number. Value: `"+e+".`")}var R=l.isPrimitive;function j(e){return R(e)?null:new TypeError("invalid value. `id` must be a string. Value: `"+e+".`")}var N=p.isPrimitive;function E(e){return N(e)?null:new TypeError("invalid value. `autoRender` must be a boolean primitive. Value: `"+e+".`")}var O=b,V=_,P=j,C=E,T={width:O,height:V,id:P,autoRender:C},S=o,J=u,D=s,G=T,M=S(G);function k(e,t){var i,r,n,a;if(!J(t))return new TypeError("invalid argument. Options argument must be an object. Value: `"+t+"`.");for(a=0;a<M.length;a++)if(r=M[a],D(t,r)){if(n=t[r],i=G[r](n))return i;e[r]=n}return null}var x="change",A="change",q="change",z="change",B={width:x,height:A,id:q,autoRender:z},F=B;function H(e){return F[e]}var I=t,K=H,L=b,Q=I("clippath:set:width"),U=K("width");function W(e){var t=L(e);if(t)throw t;Q("Current value: %d.",this._width),this._width=e,Q("New value: %d.",this._width),this.emit(U)}function X(){return this._width}var Y=t,Z=H,$=_,ee=Y("clippath:set:height"),te=Z("height");function ie(e){var t=$(e);if(t)throw t;ee("Current value: %d.",this._height),this._height=e,ee("New Value: %d.",this._height),this.emit(te)}function re(){return this._height}var ne=t,ae=H,oe=j,ue=ne("clippath:set:id"),se=ae("id");function he(e){var t=oe(e);if(t)throw t;ue("Current value: %s.",this._id),this._id=e,ue("New value: %s.",this._id),this.emit(se)}function le(){return this._id}var pe=t,de=H,me=E,ce=pe("clip-path:set:auto-render"),ve=de("autoRender");function fe(e){var t=me(e);if(t)throw t;ce("Current value: %d.",this._autoRender),this._autoRender=e,ce("New Value: %d.",this._autoRender),this.emit(ve)}function ge(){return this._autoRender}var we=t,be=d,ye=we("clippath:components:rect"),_e="rect";function Re(e){var t={namespace:"http://www.w3.org/2000/svg",className:"clipPath",attributes:{width:e.width,height:e.height}};return ye("Generating a virtual DOM tree (%s) with properties: %s.",_e,JSON.stringify(t)),be(_e,t,[])}var je=t,Ne=d,Ee=Re,Oe=je("clippath:components:main"),Ve="clipPath";function Pe(e){var t,i;return i={namespace:"http://www.w3.org/2000/svg",id:e.id},Oe("Rendering clipping path rectangle..."),t=[Ee(e)],Oe("Generating a virtual DOM tree (%s) with properties: %s.",Ve,JSON.stringify(i)),Ne(Ve,i,t)}var Ce=t,Te=Pe,Se=Ce("clippath:render");function Je(){var e;return Se("Rendering..."),e=Te(this),this.emit("_render",e),e}var De=e.EventEmitter,Ge=t,Me=i,ke=r,xe=n,Ae=a,qe=g,ze=k,Be=W,Fe=X,He=ie,Ie=re,Ke=he,Le=le,Qe=fe,Ue=ge,We=Je,Xe=Ge("clippath:main");function Ye(e){var t,i,r;if(!(this instanceof Ye))return new Ye(e);if(t=this,i=Ae(qe),r=ze(i,e))throw r;return Xe("Creating an instance with the following configuration: %s.",JSON.stringify(i)),De.call(this),Me(this,"_width",{configurable:!1,enumerable:!1,writable:!0,value:i.width}),Me(this,"_height",{configurable:!1,enumerable:!1,writable:!0,value:i.height}),Me(this,"_id",{configurable:!1,enumerable:!1,writable:!0,value:i.id||xe().toString()}),Me(this,"_autoRender",{configurable:!1,enumerable:!1,writable:!0,value:i.autoRender}),this.on("change",(function(){Xe("Received a change event."),t._autoRender&&t.render()})),this.on("_render",(function(){var e,i;for(Xe("Received a render event. Re-emitting..."),(e=new Array(arguments.length+1))[0]="render",i=0;i<arguments.length;i++)e[i+1]=arguments[i];t.emit.apply(t,e)})),this}Ye.prototype=Object.create(De.prototype),Ye.prototype.constructor=Ye,Me(Ye.prototype,"width",{configurable:!1,enumerable:!0,set:Be,get:Fe}),Me(Ye.prototype,"height",{configurable:!1,enumerable:!0,set:He,get:Ie}),Me(Ye.prototype,"id",{configurable:!1,enumerable:!0,set:Ke,get:Le}),Me(Ye.prototype,"autoRender",{configurable:!1,enumerable:!0,set:Qe,get:Ue}),ke(Ye.prototype,"render",We);var Ze=Ye;export default Ze;
//# sourceMappingURL=clip-path.js.map