cook-web 1.4.0 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cubes.js +1 -1
- package/package.json +41 -41
package/dist/cubes.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.cubes=e():t.cubes=e()}(self,(()=>(()=>{"use strict";var t={d:(e,i)=>{for(var n in i)t.o(i,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:i[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{ArrayTools:()=>l,DateTime:()=>c,DomAnimation:()=>_,DragDiff:()=>p,DragList:()=>u,Iteration:()=>h,MathBase:()=>g,MathLine:()=>w,MathPoint:()=>y,MathPolygon:()=>x,MathRect:()=>m,Notice:()=>o,_RectPosition:()=>s});var i,n,r,s=function(t){return t.left_mid="left-mid",t.left_top="left-top",t.left_bottom="left-bottom",t.top_mid="top-mid",t.bottom_mid="bottom-mid",t.right_top="right-top",t.right_mid="right-mid",t.right_bottom="right_bottom",t.center="center",t}({});class o{static rope(t,e){return(...i)=>{let n=Symbol();return this.scope[t]=n,e((()=>n===this.scope[t]),...i)}}static throttle(t,e=100){let i;return function(...n){i||(i=setTimeout((()=>{t(...n),i=void 0}),e))}}static debounce(t,e=100){let i;return function(...n){clearTimeout(i),i=setTimeout((()=>{t(...n)}),e)}}}r={},(n="scope")in(i=o)?Object.defineProperty(i,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):i[n]=r;class h{static*zip(...t){let e=t.map((t=>Array.isArray(t)?t:[t])),i=e.map((t=>t.length)),n=Math.min(...i);for(let t=0;t<n;t++){let i=[];for(let n=0;n<e.length;n++)i.push(e[n][t]);yield i}}}function a(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class c{static get_month_name(t){let e;return e=t||new Date,this.month_names[e.getMonth()]}static get_week_name(t){let e;return e=t||new Date,this.weeks_names[e.getDay()]}static get_date_string(t){return`${t.getFullYear()}-${t.getMonth()+1}-${t.getDate()}`}static get_week_string(t){let e;e=t||new Date;const i=e.getDate(),n=e.getDay(),r=new Date(e.getFullYear(),e.getMonth(),i-n),s=new Date(e.getFullYear(),e.getMonth(),i+(6-n));return`${this.get_date_string(r)}:${this.get_date_string(s)}`}static get_week_days(t){const e=[];let i;i=t||new Date;const n=i.getFullYear(),r=i.getMonth(),s=i.getDate(),o=i.getDay(),h=new Date(n,r,s-o),a=h.getFullYear(),c=h.getMonth(),_=h.getDate();e.push(h);for(let t=1;t<=6;t++)e.push(new Date(a,c,_+t));return e}}a(c,"month_names",["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]),a(c,"weeks_names",["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]);class _{static scroll_element(t,e,i="vertical"){let n=e;const r=()=>{if(Math.abs(n)>2){let e=n/10;n-=e,"vertical"===i?t.scrollTop+=e:t.scrollLeft+=e,requestAnimationFrame(r)}"vertical"===i?t.scrollTop+=n:t.scrollLeft+=n};r()}}class l{static swap(t,e,i){const n=t[e],r=t[i];t[e]=r,t[i]=n}}function d(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class u{init(){const t=this.order,e=new Set;this.order=[];for(let t=0;t<this.container.children.length;t++){const i=this.container.children[t],n=i.getAttribute(this.attr);n&&i instanceof HTMLElement&&(i.setAttribute("draggable","true"),i.style.position="absolute","horizental"===this.dir?i.style.left="0px":i.style.top="0px",this.order_origin.push(n),e.add(n),this.map.has(n)||this.register(i),this.map.set(n,i))}const i=this.init_container();this.container.addEventListener("dragenter",(t=>{t.preventDefault()})),this.container.addEventListener("dragover",(t=>{t.preventDefault()}));for(let i of t)e.has(i)?(this.order.push(i),e.delete(i)):this.map.delete(i);for(let t of e)this.order.push(t);return this.sort(),i}sort(){for(let t=0;t<this.order.length;t++){const e=this.order[t],i=this.map.get(e);if(!i)continue;const n=this.sum_translate(this.order.slice(0,t));"horizental"===this.dir?i.style.transform=`translateX(${n}px)`:i.style.transform=`translateY(${n}px)`}for(let t of this.callback)t([...this.order])}init_container(){let t=0;for(const[e,i]of this.map)"horizental"===this.dir?t+=i.getBoundingClientRect().width/this.scale_h:t+=i.getBoundingClientRect().height/this.scale_v;return"horizental"===this.dir?this.container.style.width=t+"px":this.container.style.height=t+"px",t}sum_translate(t){let e=0;for(let i of t){const t=this.map.get(i);t&&("horizental"===this.dir?e+=t.getBoundingClientRect().width/this.scale_h:e+=t.getBoundingClientRect().height/this.scale_v)}return e}register(t){this._func_start=this.on_dragstart.bind(this),this._func_over=this.on_dragover.bind(this),this._func_enter=this.on_dragenter.bind(this),this._func_end=this.on_dragend.bind(this),t.addEventListener("dragstart",this._func_start,{capture:!0}),t.addEventListener("dragover",this._func_over,{capture:!0}),t.addEventListener("dragenter",this._func_enter,{capture:!0}),t.addEventListener("dragend",this._func_end,{capture:!0}),this.realtime||t.addEventListener("drop",this.on_drop.bind(this),{capture:!0})}on_dragstart(t){t.stopPropagation();const e=t.currentTarget;if(e instanceof HTMLElement&&(this.drag_id=e.getAttribute(this.attr),this.drag_id))for(let e of this.callback_start)e(t,this.drag_id);this.container.style.setProperty(this.css_var_point_events,"none")}on_dragenter(t){if(t.stopPropagation(),t.preventDefault(),!this.realtime)return;const e=t.currentTarget;if(t.target!==e)return;if(!(e instanceof HTMLElement))return;const i=e.getAttribute(this.attr),n=this.drag_id;if(!i||!n||i===n)return;const r=this.order.indexOf(i),s=this.order.indexOf(n);r<0||s<0||("swap"===this.effect?l.swap(this.order,r,s):(this.order.splice(s,1),this.order.splice(r,0,n)),this.init_container(),this.sort())}on_dragover(t){t.preventDefault(),t.stopPropagation()}on_drop(t){t.stopPropagation();const e=t.target;if(!(e instanceof HTMLElement))return;const i=e.getAttribute(this.attr),n=this.drag_id;if(!i||!n||i===n)return;const r=this.order.indexOf(i),s=this.order.indexOf(n);r<0||s<0||("swap"===this.effect?l.swap(this.order,r,s):(this.order.splice(s,1),this.order.splice(r,0,n)),this.sort())}on_dragend(t){this.container.style.setProperty(this.css_var_point_events,"auto");for(let e of this.callback_end)e(t)}register_start(t){this.callback_start.add(t)}register_dropend(t){this.callback_end.add(t)}register_callback(t){this.callback.add(t)}off_callback(t){this.callback.delete(t)}off_callback_start(t){this.callback_start.delete(t)}off_callback_drop(t){this.callback_end.delete(t)}constructor(t,e,i,n,r=!0){d(this,"container",void 0),d(this,"drag_id",void 0),d(this,"dir","vertical"),d(this,"effect",void 0),d(this,"attr",void 0),d(this,"realtime",!0),d(this,"order_origin",[]),d(this,"order",[]),d(this,"css_var_point_events","--drag-item-point-event"),d(this,"map",new Map),d(this,"callback",new Set),d(this,"callback_start",new Set),d(this,"callback_end",new Set),d(this,"scale_h",1),d(this,"scale_v",1),d(this,"_func_start",void 0),d(this,"_func_over",void 0),d(this,"_func_enter",void 0),d(this,"_func_end",void 0),d(this,"_callback_start",void 0),this.container=t,this.dir=e,this.attr=i,this.realtime=r,this.effect=n,t.style.position="relative"}}function f(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class p{get el(){return this._el}init(){this._handler_down=t=>this._pointdown(t),this._handler_move=t=>this._pointmove(t),this._handler_up=t=>this._pointup(t),this._handler_cancel=t=>this._pointercancel(t),this.el.addEventListener("pointerdown",this._handler_down),document.documentElement.addEventListener("pointermove",this._handler_move),document.documentElement.addEventListener("pointerup",this._handler_up),document.documentElement.addEventListener("pointercancel",this._handler_cancel)}_pointdown(t){t.stopPropagation(),t.preventDefault();const e=t.target;this.el.contains(e)&&(this._is_down=!0,this._down_point={x:t.clientX,y:t.clientY},this._func_down&&this._func_down())}_pointmove(t){if(!this._is_down||!this._down_point||t.buttons<=0)return;t.stopPropagation(),t.preventDefault(),this._is_move=!0;const e=t.clientX-this._down_point.x,i=t.clientY-this._down_point.y;this._func_move&&this._func_move(e,i)}_pointup(t){if(t.preventDefault(),t.stopPropagation(),!this._is_down||!this._is_move)return;if(this._is_down=!1,this._is_move=!1,!this._down_point)return;const e=t.clientX-this._down_point.x,i=t.clientY-this._down_point.y;this._down_point=void 0,this._func_up&&this._func_up(e,i)}_pointercancel(t){this._is_down&&this._is_move&&(this._is_down=!1,this._is_move=!1,this._down_point=void 0,this._func_cancel&&this._func_cancel())}off(){this.el.removeEventListener("pointerdown",this._handler_down),document.documentElement.removeEventListener("pointermove",this._handler_move),document.documentElement.removeEventListener("pointerup",this._handler_up),document.documentElement.removeEventListener("pointercancel",this._handler_cancel)}register_down(t){this._func_down=t}register_move(t){this._func_move=t}register_up(t){this._func_up=t}register_cancel(t){this._func_cancel=t}constructor(t){f(this,"_el",void 0),f(this,"_handler_down",void 0),f(this,"_handler_move",void 0),f(this,"_handler_up",void 0),f(this,"_handler_cancel",void 0),f(this,"_func_down",void 0),f(this,"_func_move",void 0),f(this,"_func_up",void 0),f(this,"_func_cancel",void 0),f(this,"_is_down",!1),f(this,"_is_move",!1),f(this,"_down_point",void 0),this._el=t,this.init()}}class g{static sum(t){let e=0;for(let i of t)e+=i;return e}}class m{static get_rect_point(t,e){const{x:i,y:n,width:r,height:o}=t,h=n+o,a=i+r,c=i+r/2,_=n+o/2;if(e===s.left_bottom)return{x:i,y:h};if(e===s.left_top)return{x:i,y:n};if(e===s.left_mid)return{x:i,y:_};if(e===s.right_top)return{x:a,y:n};if(e===s.right_mid)return{x:a,y:_};if(e===s.right_bottom)return{x:a,y:h};if(e===s.bottom_mid)return{x:c,y:h};if(e===s.top_mid)return{x:c,y:n};if(e===s.center)return{x:c,y:_};throw Error("MathRect: the position keyword is invalid")}static is_point_in_rect(t,e,i=!0){const n=t.x===e.x||t.x===e.x+e.width,r=t.y===e.y||t.y===e.y+e.height,s=t.x>e.x&&t.x<e.x+e.width,o=t.y>e.y&&t.y<e.y+e.height;return i?(s||n)&&(o||r):s&&o}static get_point_in_rects(t,e,i=!0){const n=[];for(let r of e)this.is_point_in_rect(t,r,i)&&n.push(r);return n}static get_point_center(t){return{x:t.x+t.width/2,y:t.y+t.height/2}}static move_rect_to_other(t,e,i,n=5){const r={width:t.width,height:Math.abs(t.y-i.y)},s={width:t.width,height:Math.abs(t.height-(i.y+i.height))},o={width:Math.abs(i.x-t.x),height:t.height},h={width:Math.abs(t.width-(i.x+i.width)),height:t.height};if(this.can_include(s,e)){const r=e.width+i.x-t.width,s=i.y+i.height+n;return{x:r<0?i.x:i.x-r,y:s}}if(this.can_include(r,e)){const r=e.width+i.x-t.width,s=i.y-e.height-n;return{x:r<0?i.x:i.x-r,y:s}}if(this.can_include(o,e)){const r=i.y+e.height-t.height;return{x:i.x-e.width-n,y:r<0?i.y:i.y-r}}if(this.can_include(h,e)){const r=i.y+e.height-t.height;return{x:i.x+i.width+n,y:r<0?i.y:i.y-r}}return e}static can_include(t,e){return e.width<=t.width&&e.height<=t.height}static can_contain(t,e){return!(!this.can_include(t,e)||e.x<t.x||e.x>t.x+t.width-e.width||e.y<t.y||e.y>t.y+t.height-e.height)}static check_intersection(t,e){const i=t.x+t.width/2,n=t.y+t.height/2,r=e.x+e.width/2,s=e.y+e.height/2,o=Math.abs(i-r),h=Math.abs(n-s);return o<=(t.width+e.width)/2&&h<=(t.height+e.height)/2}static limit_point_in_rect(t,e){const i=e.x,n=e.y,r=e.x+e.width,s=e.y+e.height;let o=t.x,h=t.y;return o<i&&(o=i),o>r&&(o=r),h<n&&(h=n),h>s&&(h=s),{x:o,y:h}}static point_distance_with_rect(t,e){if(this.is_point_in_rect(t,e,!0))return 0;const i=e.x+e.width/2,n=e.y+e.height/2,r=e.width/2,s=e.height/2,o=Math.abs(i-t.x),h=Math.abs(n-t.y);return o<=r&&h>s?h-s:h<=s&&o>r?o-r:Math.sqrt(Math.pow(o-r,2)+Math.pow(h-s,2))}static get_nearest_rect(t,e){if(0===e.length)return;let i,n=Number.POSITIVE_INFINITY;for(let r of e){let e=this.point_distance_with_rect(t,r);e<n&&(n=e,i=r)}return i}static get_shadow_point_horizental(t,e){let i=e.x,n=e.y+e.height/2;return i=t.x<=e.x?e.x:t.x>=e.x+e.width?e.x+e.width:t.x,{x:i,y:n}}static merge(...t){const e=t[0];let i=e.x,n=e.x+e.width,r=e.y,s=e.y+e.height;for(let e of t.slice(1)){const{x:t,y:o,width:h,height:a}=e;t<i&&(i=t),t+h>n&&(n=t+h),o<r&&(r=o),o+a>s&&(s=o+a)}return{x:i,y:r,width:n-i,height:s-r}}}class y{static svg_path_sample(t,e=24){if(!t||e<2)return[];this.path.setAttribute("d",t);const i=[],n=this.path.getTotalLength()/e;for(let t=0;t<e;t++){const e=t*n,r=this.path.getPointAtLength(e);i.push({x:r.x,y:r.y})}return i}static get_line_k(t,e,i=100){const n=e.y-t.y,r=e.x-t.x;return 0===r?Number.POSITIVE_INFINITY:n/r}static distance(t,e){const i=t.x-e.x,n=t.y-e.y;return Math.sqrt(i*i+n*n)}static find_closet_point(t,e){let i=1/0,n=t[0];const{x:r,y:s}=e;for(let e of t){let t=Math.pow(r-e.x,2)+Math.pow(s-e.y,2);t<i&&(i=t,n=e)}return n}static offset_points(t,e){const i=[],{x:n,y:r}=e;for(let e of t)i.push({x:e.x+n,y:e.y+r});return i}static find_closest_points(t,e){let i=1/0,n=t[0],r=e[0];for(let s=0;s<t.length;s++){const o=t[s];for(let t=0;t<e.length;t++){const s=e[t],h=o.x-s.x,a=o.y-s.y,c=h*h+a*a;c<i&&(i=c,n=o,r=s)}}return{from:n,to:r}}}!function(t,e,i){e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i}(y,"path",document.createElementNS("http://www.w3.org/2000/svg","path"));class x{static polygon_center(t){let e=0,i=0,n=0;const r=t.length;for(let s=0;s<r;s++){const{x:o,y:h}=t[s],{x:a,y:c}=t[(s+1)%r],_=o*c-a*h;n+=_,e+=(o+a)*_,i+=(h+c)*_}return n*=.5,e/=6*n,i/=6*n,{x:e,y:i}}static get_polygon_area(t){let e=0;const i=t.length;for(let n=0;n<i;n++){const{x:r,y:s}=t[n],{x:o,y:h}=t[(n+1)%i];e+=r*h-o*s}return e/2}}class w{static check_intersection(t,e){const{from:i,to:n}=t,{from:r,to:s}=e;let o,h;if(o=i.x===n.x?Number.POSITIVE_INFINITY:(n.y-i.y)/(n.x-i.x),h=r.x===s.x?Number.POSITIVE_INFINITY:(s.y-r.y)/(s.x-r.x),o===h)return!1;const a=Math.min(i.x,n.x),c=Math.max(i.x,n.x),_=Math.min(i.y,n.y),l=Math.max(i.y,n.y),d=Math.min(r.x,s.x),u=Math.max(r.x,s.x),f=Math.min(r.y,s.y),p=Math.max(r.y,s.y);if(o===Number.POSITIVE_INFINITY){const t=i.x,e=h*(t-r.x)+r.y;return t>=a&&t<=c&&t>=d&&t<=u&&e>=_&&e<=l&&e>=f&&e<=p}if(h===Number.POSITIVE_INFINITY){const t=r.x,e=(n.y-i.y)/(n.x-i.x)*(t-i.x)+i.y;return t>=a&&t<=c&&t>=d&&t<=u&&e>=_&&e<=l&&e>=f&&e<=p}{const t=(r.y-i.y+o*i.x-h*r.x)/(o-h),e=o*(t-i.x)+i.y;return t>=a&&t<=c&&t>=d&&t<=u&&e>=_&&e<=l&&e>=f&&e<=p}}}return e})()));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.cubes=e():t.cubes=e()}(self,(()=>(()=>{"use strict";var t={d:(e,i)=>{for(var n in i)t.o(i,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:i[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{ArrayTools:()=>l,DateTime:()=>c,DomAnimation:()=>_,DragDiff:()=>p,DragList:()=>u,Iteration:()=>h,MathBase:()=>g,MathLine:()=>w,MathPoint:()=>y,MathPolygon:()=>x,MathRect:()=>m,Notice:()=>o,_RectPosition:()=>s});var i,n,r,s=function(t){return t.left_mid="left-mid",t.left_top="left-top",t.left_bottom="left-bottom",t.top_mid="top-mid",t.bottom_mid="bottom-mid",t.right_top="right-top",t.right_mid="right-mid",t.right_bottom="right_bottom",t.center="center",t}({});class o{static rope(t,e){return(...i)=>{let n=Symbol();return this.scope[t]=n,e((()=>n===this.scope[t]),...i)}}static throttle(t,e=100){let i;return function(...n){i||(i=setTimeout((()=>{t(...n),i=void 0}),e))}}static debounce(t,e=100){let i;return function(...n){clearTimeout(i),i=setTimeout((()=>{t(...n)}),e)}}}r={},(n="scope")in(i=o)?Object.defineProperty(i,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):i[n]=r;class h{static*zip(...t){let e=t.map((t=>Array.isArray(t)?t:[t])),i=e.map((t=>t.length)),n=Math.min(...i);for(let t=0;t<n;t++){let i=[];for(let n=0;n<e.length;n++)i.push(e[n][t]);yield i}}}function a(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class c{static get_month_name(t){let e;return e=t||new Date,this.month_names[e.getMonth()]}static get_week_name(t){let e;return e=t||new Date,this.weeks_names[e.getDay()]}static get_date_string(t){return`${t.getFullYear()}-${t.getMonth()+1}-${t.getDate()}`}static get_week_string(t){let e;e=t||new Date;const i=e.getDate(),n=e.getDay(),r=new Date(e.getFullYear(),e.getMonth(),i-n),s=new Date(e.getFullYear(),e.getMonth(),i+(6-n));return`${this.get_date_string(r)}:${this.get_date_string(s)}`}static get_week_days(t){const e=[];let i;i=t||new Date;const n=i.getFullYear(),r=i.getMonth(),s=i.getDate(),o=i.getDay(),h=new Date(n,r,s-o),a=h.getFullYear(),c=h.getMonth(),_=h.getDate();e.push(h);for(let t=1;t<=6;t++)e.push(new Date(a,c,_+t));return e}}a(c,"month_names",["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]),a(c,"weeks_names",["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]);class _{static scroll_element(t,e,i="vertical"){let n=e;const r=()=>{if(Math.abs(n)>2){let e=n/10;n-=e,"vertical"===i?t.scrollTop+=e:t.scrollLeft+=e,requestAnimationFrame(r)}"vertical"===i?t.scrollTop+=n:t.scrollLeft+=n};r()}}class l{static swap(t,e,i){const n=t[e],r=t[i];t[e]=r,t[i]=n}}function d(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class u{init(){const t=this.order,e=new Set;this.order=[];for(let t=0;t<this.container.children.length;t++){const i=this.container.children[t],n=i.getAttribute(this.attr);n&&i instanceof HTMLElement&&(i.setAttribute("draggable","true"),i.style.position="absolute","horizental"===this.dir?i.style.left="0px":i.style.top="0px",this.order_origin.push(n),e.add(n),this.map.has(n)||this.register(i),this.map.set(n,i))}const i=this.init_container();this.container.addEventListener("dragenter",(t=>{t.preventDefault()})),this.container.addEventListener("dragover",(t=>{t.preventDefault()}));for(let i of t)e.has(i)?(this.order.push(i),e.delete(i)):this.map.delete(i);for(let t of e)this.order.push(t);return this.sort(),i}sort(){for(let t=0;t<this.order.length;t++){const e=this.order[t],i=this.map.get(e);if(!i)continue;const n=this.sum_translate(this.order.slice(0,t));"horizental"===this.dir?i.style.transform=`translateX(${n}px)`:i.style.transform=`translateY(${n}px)`}for(let t of this.callback)t([...this.order])}init_container(){let t=0;for(const[e,i]of this.map)"horizental"===this.dir?t+=i.getBoundingClientRect().width/this.scale_h:t+=i.getBoundingClientRect().height/this.scale_v;return"horizental"===this.dir?this.container.style.width=t+"px":this.container.style.height=t+"px",t}sum_translate(t){let e=0;for(let i of t){const t=this.map.get(i);t&&("horizental"===this.dir?e+=t.getBoundingClientRect().width/this.scale_h:e+=t.getBoundingClientRect().height/this.scale_v)}return e}register(t){this._func_start=this.on_dragstart.bind(this),this._func_over=this.on_dragover.bind(this),this._func_enter=this.on_dragenter.bind(this),this._func_end=this.on_dragend.bind(this),t.addEventListener("dragstart",this._func_start,{capture:!0}),t.addEventListener("dragover",this._func_over,{capture:!0}),t.addEventListener("dragenter",this._func_enter,{capture:!0}),t.addEventListener("dragend",this._func_end,{capture:!0}),this.realtime||t.addEventListener("drop",this.on_drop.bind(this),{capture:!0})}on_dragstart(t){t.stopPropagation();const e=t.currentTarget;if(e instanceof HTMLElement&&(this.drag_id=e.getAttribute(this.attr),this.drag_id))for(let e of this.callback_start)e(t,this.drag_id);this.container.style.setProperty(this.css_var_point_events,"none")}on_dragenter(t){if(t.stopPropagation(),t.preventDefault(),!this.realtime)return;const e=t.currentTarget;if(t.target!==e)return;if(!(e instanceof HTMLElement))return;const i=e.getAttribute(this.attr),n=this.drag_id;if(!i||!n||i===n)return;const r=this.order.indexOf(i),s=this.order.indexOf(n);r<0||s<0||("swap"===this.effect?l.swap(this.order,r,s):(this.order.splice(s,1),this.order.splice(r,0,n)),this.init_container(),this.sort())}on_dragover(t){t.preventDefault(),t.stopPropagation()}on_drop(t){t.stopPropagation();const e=t.target;if(!(e instanceof HTMLElement))return;const i=e.getAttribute(this.attr),n=this.drag_id;if(!i||!n||i===n)return;const r=this.order.indexOf(i),s=this.order.indexOf(n);r<0||s<0||("swap"===this.effect?l.swap(this.order,r,s):(this.order.splice(s,1),this.order.splice(r,0,n)),this.sort())}on_dragend(t){this.container.style.setProperty(this.css_var_point_events,"auto");for(let e of this.callback_end)e(t)}register_start(t){this.callback_start.add(t)}register_dropend(t){this.callback_end.add(t)}register_callback(t){this.callback.add(t)}off_callback(t){this.callback.delete(t)}off_callback_start(t){this.callback_start.delete(t)}off_callback_drop(t){this.callback_end.delete(t)}constructor(t,e,i,n,r=!0){d(this,"container",void 0),d(this,"drag_id",void 0),d(this,"dir","vertical"),d(this,"effect",void 0),d(this,"attr",void 0),d(this,"realtime",!0),d(this,"order_origin",[]),d(this,"order",[]),d(this,"css_var_point_events","--drag-item-point-event"),d(this,"map",new Map),d(this,"callback",new Set),d(this,"callback_start",new Set),d(this,"callback_end",new Set),d(this,"scale_h",1),d(this,"scale_v",1),d(this,"_func_start",void 0),d(this,"_func_over",void 0),d(this,"_func_enter",void 0),d(this,"_func_end",void 0),d(this,"_callback_start",void 0),this.container=t,this.dir=e,this.attr=i,this.realtime=r,this.effect=n,t.style.position="relative"}}function f(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class p{get el(){return this._el}init(){this._handler_down=t=>this._pointdown(t),this._handler_move=t=>this._pointmove(t),this._handler_up=t=>this._pointup(t),this._handler_cancel=t=>this._pointercancel(t),this.el.addEventListener("pointerdown",this._handler_down),document.documentElement.addEventListener("pointermove",this._handler_move),document.documentElement.addEventListener("pointerup",this._handler_up),document.documentElement.addEventListener("pointercancel",this._handler_cancel)}_pointdown(t){t.stopPropagation(),t.preventDefault();const e=t.target;this.el.contains(e)&&(this._is_down=!0,this._down_point={x:t.clientX,y:t.clientY},this._func_down&&this._func_down())}_pointmove(t){if(!this._is_down||!this._down_point||t.buttons<=0)return;t.stopPropagation(),t.preventDefault(),this._is_move=!0;const e=t.clientX-this._down_point.x,i=t.clientY-this._down_point.y;this._func_move&&this._func_move(e,i)}_pointup(t){if(t.preventDefault(),t.stopPropagation(),!this._is_down||!this._is_move)return;if(this._is_down=!1,this._is_move=!1,!this._down_point)return;const e=t.clientX-this._down_point.x,i=t.clientY-this._down_point.y;this._down_point=void 0,this._func_up&&this._func_up(e,i)}_pointercancel(t){this._is_down&&this._is_move&&(this._is_down=!1,this._is_move=!1,this._down_point=void 0,this._func_cancel&&this._func_cancel())}off(){this.el.removeEventListener("pointerdown",this._handler_down),document.documentElement.removeEventListener("pointermove",this._handler_move),document.documentElement.removeEventListener("pointerup",this._handler_up),document.documentElement.removeEventListener("pointercancel",this._handler_cancel)}register_down(t){this._func_down=t}register_move(t){this._func_move=t}register_up(t){this._func_up=t}register_cancel(t){this._func_cancel=t}constructor(t){f(this,"_el",void 0),f(this,"_handler_down",void 0),f(this,"_handler_move",void 0),f(this,"_handler_up",void 0),f(this,"_handler_cancel",void 0),f(this,"_func_down",void 0),f(this,"_func_move",void 0),f(this,"_func_up",void 0),f(this,"_func_cancel",void 0),f(this,"_is_down",!1),f(this,"_is_move",!1),f(this,"_down_point",void 0),this._el=t,this.init()}}class g{static sum(t){let e=0;for(let i of t)e+=i;return e}}class m{static get_rect_point(t,e){const{x:i,y:n,width:r,height:o}=t,h=n+o,a=i+r,c=i+r/2,_=n+o/2;if(e===s.left_bottom)return{x:i,y:h};if(e===s.left_top)return{x:i,y:n};if(e===s.left_mid)return{x:i,y:_};if(e===s.right_top)return{x:a,y:n};if(e===s.right_mid)return{x:a,y:_};if(e===s.right_bottom)return{x:a,y:h};if(e===s.bottom_mid)return{x:c,y:h};if(e===s.top_mid)return{x:c,y:n};if(e===s.center)return{x:c,y:_};throw Error("MathRect: the position keyword is invalid")}static is_point_in_rect(t,e,i=!0){const n=t.x===e.x||t.x===e.x+e.width,r=t.y===e.y||t.y===e.y+e.height,s=t.x>e.x&&t.x<e.x+e.width,o=t.y>e.y&&t.y<e.y+e.height;return i?(s||n)&&(o||r):s&&o}static get_point_in_rects(t,e,i=!0){const n=[];for(let r of e)this.is_point_in_rect(t,r,i)&&n.push(r);return n}static get_point_center(t){return{x:t.x+t.width/2,y:t.y+t.height/2}}static move_rect_to_other(t,e,i,n=5){const r={width:t.width,height:Math.abs(t.y-i.y)},s={width:t.width,height:Math.abs(t.height-(i.y+i.height))},o={width:Math.abs(i.x-t.x),height:t.height},h={width:Math.abs(t.width-(i.x+i.width)),height:t.height};if(m.can_include(s,e)){const r=e.width+i.x-t.width,s=i.y+i.height+n;return{x:r<0?i.x:i.x-r,y:s}}if(m.can_include(r,e)){const r=e.width+i.x-t.width,s=i.y-e.height-n;return{x:r<0?i.x:i.x-r,y:s}}if(m.can_include(o,e)){const r=i.y+e.height-t.height;return{x:i.x-e.width-n,y:r<0?i.y:i.y-r}}if(m.can_include(h,e)){const r=i.y+e.height-t.height;return{x:i.x+i.width+n,y:r<0?i.y:i.y-r}}if(m.can_include(t,e)){const n=t.y+t.height-e.height;let r=i.x;return h.width>=e.width?r=i.x+i.width:o.width>=e.width&&(r=i.x-e.width),{x:r,y:n}}return{x:i.x,y:0}}static can_include(t,e){return e.width<=t.width&&e.height<=t.height}static can_contain(t,e){return!(!this.can_include(t,e)||e.x<t.x||e.x>t.x+t.width-e.width||e.y<t.y||e.y>t.y+t.height-e.height)}static check_intersection(t,e){const i=t.x+t.width/2,n=t.y+t.height/2,r=e.x+e.width/2,s=e.y+e.height/2,o=Math.abs(i-r),h=Math.abs(n-s);return o<=(t.width+e.width)/2&&h<=(t.height+e.height)/2}static limit_point_in_rect(t,e){const i=e.x,n=e.y,r=e.x+e.width,s=e.y+e.height;let o=t.x,h=t.y;return o<i&&(o=i),o>r&&(o=r),h<n&&(h=n),h>s&&(h=s),{x:o,y:h}}static point_distance_with_rect(t,e){if(this.is_point_in_rect(t,e,!0))return 0;const i=e.x+e.width/2,n=e.y+e.height/2,r=e.width/2,s=e.height/2,o=Math.abs(i-t.x),h=Math.abs(n-t.y);return o<=r&&h>s?h-s:h<=s&&o>r?o-r:Math.sqrt(Math.pow(o-r,2)+Math.pow(h-s,2))}static get_nearest_rect(t,e){if(0===e.length)return;let i,n=Number.POSITIVE_INFINITY;for(let r of e){let e=this.point_distance_with_rect(t,r);e<n&&(n=e,i=r)}return i}static get_shadow_point_horizental(t,e){let i=e.x,n=e.y+e.height/2;return i=t.x<=e.x?e.x:t.x>=e.x+e.width?e.x+e.width:t.x,{x:i,y:n}}static merge(...t){const e=t[0];let i=e.x,n=e.x+e.width,r=e.y,s=e.y+e.height;for(let e of t.slice(1)){const{x:t,y:o,width:h,height:a}=e;t<i&&(i=t),t+h>n&&(n=t+h),o<r&&(r=o),o+a>s&&(s=o+a)}return{x:i,y:r,width:n-i,height:s-r}}}class y{static svg_path_sample(t,e=24){if(!t||e<2)return[];this.path.setAttribute("d",t);const i=[],n=this.path.getTotalLength()/e;for(let t=0;t<e;t++){const e=t*n,r=this.path.getPointAtLength(e);i.push({x:r.x,y:r.y})}return i}static get_line_k(t,e,i=100){const n=e.y-t.y,r=e.x-t.x;return 0===r?Number.POSITIVE_INFINITY:n/r}static distance(t,e){const i=t.x-e.x,n=t.y-e.y;return Math.sqrt(i*i+n*n)}static find_closet_point(t,e){let i=1/0,n=t[0];const{x:r,y:s}=e;for(let e of t){let t=Math.pow(r-e.x,2)+Math.pow(s-e.y,2);t<i&&(i=t,n=e)}return n}static offset_points(t,e){const i=[],{x:n,y:r}=e;for(let e of t)i.push({x:e.x+n,y:e.y+r});return i}static find_closest_points(t,e){let i=1/0,n=t[0],r=e[0];for(let s=0;s<t.length;s++){const o=t[s];for(let t=0;t<e.length;t++){const s=e[t],h=o.x-s.x,a=o.y-s.y,c=h*h+a*a;c<i&&(i=c,n=o,r=s)}}return{from:n,to:r}}}!function(t,e,i){e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i}(y,"path",document.createElementNS("http://www.w3.org/2000/svg","path"));class x{static polygon_center(t){let e=0,i=0,n=0;const r=t.length;for(let s=0;s<r;s++){const{x:o,y:h}=t[s],{x:a,y:c}=t[(s+1)%r],_=o*c-a*h;n+=_,e+=(o+a)*_,i+=(h+c)*_}return n*=.5,e/=6*n,i/=6*n,{x:e,y:i}}static get_polygon_area(t){let e=0;const i=t.length;for(let n=0;n<i;n++){const{x:r,y:s}=t[n],{x:o,y:h}=t[(n+1)%i];e+=r*h-o*s}return e/2}}class w{static check_intersection(t,e){const{from:i,to:n}=t,{from:r,to:s}=e;let o,h;if(o=i.x===n.x?Number.POSITIVE_INFINITY:(n.y-i.y)/(n.x-i.x),h=r.x===s.x?Number.POSITIVE_INFINITY:(s.y-r.y)/(s.x-r.x),o===h)return!1;const a=Math.min(i.x,n.x),c=Math.max(i.x,n.x),_=Math.min(i.y,n.y),l=Math.max(i.y,n.y),d=Math.min(r.x,s.x),u=Math.max(r.x,s.x),f=Math.min(r.y,s.y),p=Math.max(r.y,s.y);if(o===Number.POSITIVE_INFINITY){const t=i.x,e=h*(t-r.x)+r.y;return t>=a&&t<=c&&t>=d&&t<=u&&e>=_&&e<=l&&e>=f&&e<=p}if(h===Number.POSITIVE_INFINITY){const t=r.x,e=(n.y-i.y)/(n.x-i.x)*(t-i.x)+i.y;return t>=a&&t<=c&&t>=d&&t<=u&&e>=_&&e<=l&&e>=f&&e<=p}{const t=(r.y-i.y+o*i.x-h*r.x)/(o-h),e=o*(t-i.x)+i.y;return t>=a&&t<=c&&t>=d&&t<=u&&e>=_&&e<=l&&e>=f&&e<=p}}}return e})()));
|
package/package.json
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "cook-web",
|
|
3
|
-
"version": "1.4.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "./dist/cubes.js",
|
|
6
|
-
"files": [
|
|
7
|
-
"dist"
|
|
8
|
-
],
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"webpack-
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
}
|
|
41
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "cook-web",
|
|
3
|
+
"version": "1.4.2",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "./dist/cubes.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"types": "./dist/cubes.d.ts",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
12
|
+
"dev": "webpack server --config ./webpack.dev.js ",
|
|
13
|
+
"build": "webpack --config ./webpack.pro.js && tsc && dts-bundle-generator -o ./dist/cubes.d.ts ./dts/index.d.ts",
|
|
14
|
+
"yalc": "pnpm build && yalc publish",
|
|
15
|
+
"p": "pnpm version patch --git-tag-version false",
|
|
16
|
+
"minor": "pnpm version minor --git-tag-version false",
|
|
17
|
+
"major": "pnpm version major --git-tag-version false"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [],
|
|
20
|
+
"author": "",
|
|
21
|
+
"license": "ISC",
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@swc/core": "^1.11.8",
|
|
24
|
+
"@types/node": "^24.5.2",
|
|
25
|
+
"@vue/compiler-sfc": "^3.5.12",
|
|
26
|
+
"clean-webpack-plugin": "^4.0.0",
|
|
27
|
+
"cross-env": "^7.0.3",
|
|
28
|
+
"css-loader": "^7.1.2",
|
|
29
|
+
"dts-bundle-generator": "^9.5.1",
|
|
30
|
+
"html-webpack-plugin": "^5.6.0",
|
|
31
|
+
"ip": "^2.0.1",
|
|
32
|
+
"mini-css-extract-plugin": "^2.9.1",
|
|
33
|
+
"swc-loader": "^0.2.6",
|
|
34
|
+
"typescript": "^5.5.4",
|
|
35
|
+
"vue-loader": "^17.4.2",
|
|
36
|
+
"webpack": "^5.94.0",
|
|
37
|
+
"webpack-cli": "^5.1.4",
|
|
38
|
+
"webpack-dev-server": "^5.0.4",
|
|
39
|
+
"webpackbar": "^6.0.1"
|
|
40
|
+
}
|
|
41
|
+
}
|