@stdlib/esm
Version:
ES module distribution for Stdlib, a standard library for JavaScript and Node.js.
3 lines • 3.81 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 r from"./../../../utils/define-property.js";import i from"./../../../utils/define-read-only-property.js";import n from"./../../../utils/copy.js";import o from"./../../../utils/keys.js";import a from"./../../../assert/is-plain-object.js";import u from"./../../../assert/has-own-property.js";import h from"./../../../assert/is-positive-number.js";import s from"./../../../assert/is-boolean.js";import l from"./../../../vendor/virtual-dom/h.js";var d=400,m=400,f=!1,g={width:d,height:m,autoRender:f},v=h.isPrimitive;function p(e){return v(e)?null:new TypeError("invalid value. `width` must be a positive number. Value: `"+e+".`")}var c=h.isPrimitive;function w(e){return c(e)?null:new TypeError("invalid value. `height` must be a positive number. Value: `"+e+".`")}var b=s.isPrimitive;function y(e){return b(e)?null:new TypeError("invalid value. `autoRender` must be a boolean primitive. Value: `"+e+".`")}var _=p,R=w,j=y,k={width:_,height:R,autoRender:j},E=o,N=a,V=u,O=k,C=E(O);function T(e,t){var r,i,n,o;if(!N(t))return new TypeError("invalid argument. Options argument must be an object. Value: `"+t+"`.");for(o=0;o<C.length;o++)if(i=C[o],V(t,i)){if(n=t[i],r=O[i](n))return r;e[i]=n}return null}var P="change",x="change",J="change",S={width:P,height:x,autoRender:J},A=S;function D(e){return A[e]}var G=t,M=D,q=p,z=G("background:set:width"),B=M("width");function F(e){var t=q(e);if(t)throw t;z("Current value: %d.",this._width),this._width=e,z("New value: %d.",this._width),this.emit(B)}function H(){return this._width}var I=t,K=D,L=w,Q=I("background:set:height"),U=K("height");function W(e){var t=L(e);if(t)throw t;Q("Current value: %d.",this._height),this._height=e,Q("New Value: %d.",this._height),this.emit(U)}function X(){return this._height}var Y=t,Z=D,$=y,ee=Y("background:set:auto-render"),te=Z("autoRender");function re(e){var t=$(e);if(t)throw t;ee("Current value: %d.",this._autoRender),this._autoRender=e,ee("New Value: %d.",this._autoRender),this.emit(te)}function ie(){return this._autoRender}var ne=t,oe=l,ae=ne("background:render"),ue="rect";function he(){var e,t;return ae("Rendering..."),e={namespace:"http://www.w3.org/2000/svg",className:"background",attributes:{x:0,y:0,width:this.width,height:this.height,fill:"none",stroke:"none"}},ae("Generating a virtual DOM tree (%s) with properties: %s.",ue,JSON.stringify(e)),t=oe(ue,e,[]),this.emit("_render",t),t}var se=e.EventEmitter,le=t,de=r,me=i,fe=n,ge=g,ve=T,pe=F,ce=H,we=W,be=X,ye=re,_e=ie,Re=he,je=le("background:main");function ke(e){var t,r,i;if(!(this instanceof ke))return new ke(e);if(t=this,r=fe(ge),i=ve(r,e))throw i;return je("Creating an instance with the following configuration: %s.",JSON.stringify(r)),se.call(this),de(this,"_width",{configurable:!1,enumerable:!1,writable:!0,value:r.width}),de(this,"_height",{configurable:!1,enumerable:!1,writable:!0,value:r.height}),de(this,"_autoRender",{configurable:!1,enumerable:!1,writable:!0,value:r.autoRender}),this.on("change",(function(){je("Received a change event."),t._autoRender&&t.render()})),this.on("_render",(function(){var e,r;for(je("Received a render event. Re-emitting..."),(e=new Array(arguments.length+1))[0]="render",r=0;r<arguments.length;r++)e[r+1]=arguments[r];t.emit.apply(t,e)})),this}ke.prototype=Object.create(se.prototype),ke.prototype.constructor=ke,de(ke.prototype,"width",{configurable:!1,enumerable:!0,set:pe,get:ce}),de(ke.prototype,"height",{configurable:!1,enumerable:!0,set:we,get:be}),de(ke.prototype,"autoRender",{configurable:!1,enumerable:!0,set:ye,get:_e}),me(ke.prototype,"render",Re);var Ee=ke;export default Ee;
//# sourceMappingURL=background.js.map