cook-web 1.4.0
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/LICENSE +21 -0
- package/README.md +1 -0
- package/dist/cubes.d.ts +163 -0
- package/dist/cubes.js +1 -0
- package/package.json +41 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 deepskying
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# cook
|
package/dist/cubes.d.ts
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
export interface _Point {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
}
|
|
7
|
+
export interface _PointDiff {
|
|
8
|
+
dx: number;
|
|
9
|
+
dy: number;
|
|
10
|
+
}
|
|
11
|
+
export interface _RectArea {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
}
|
|
15
|
+
export type _Rect = _Point & _RectArea;
|
|
16
|
+
export declare enum _RectPosition {
|
|
17
|
+
left_mid = "left-mid",
|
|
18
|
+
left_top = "left-top",
|
|
19
|
+
left_bottom = "left-bottom",
|
|
20
|
+
top_mid = "top-mid",
|
|
21
|
+
bottom_mid = "bottom-mid",
|
|
22
|
+
right_top = "right-top",
|
|
23
|
+
right_mid = "right-mid",
|
|
24
|
+
right_bottom = "right_bottom",
|
|
25
|
+
center = "center"
|
|
26
|
+
}
|
|
27
|
+
export interface _Line {
|
|
28
|
+
from: _Point;
|
|
29
|
+
to: _Point;
|
|
30
|
+
}
|
|
31
|
+
export type _RopeCheck = () => boolean;
|
|
32
|
+
export type _RopeFunction = (isnew: _RopeCheck, ...args: any[]) => any;
|
|
33
|
+
export type _DragDiffResultFunc = (dx: number, dy: number) => any;
|
|
34
|
+
export declare class Notice {
|
|
35
|
+
protected static scope: Record<string, symbol>;
|
|
36
|
+
static rope(namespace: string, func: _RopeFunction): (...args: any[]) => any;
|
|
37
|
+
static throttle(func: Function, wait?: number): (...args: any[]) => void;
|
|
38
|
+
static debounce(func: Function, wait?: number): (...args: any[]) => void;
|
|
39
|
+
}
|
|
40
|
+
export declare class Iteration {
|
|
41
|
+
static zip(...args: any[]): Generator<any[], void, unknown>;
|
|
42
|
+
}
|
|
43
|
+
export declare class DateTime {
|
|
44
|
+
static month_names: string[];
|
|
45
|
+
static weeks_names: string[];
|
|
46
|
+
static get_month_name(day?: Date): string;
|
|
47
|
+
static get_week_name(day?: Date): string;
|
|
48
|
+
static get_date_string(date: Date): string;
|
|
49
|
+
static get_week_string(day?: Date): string;
|
|
50
|
+
static get_week_days(day?: Date): Date[];
|
|
51
|
+
}
|
|
52
|
+
export declare class DomAnimation {
|
|
53
|
+
static scroll_element(element: Element, distance: number, dir?: "vertical" | "horizental"): void;
|
|
54
|
+
}
|
|
55
|
+
export type _DragDirection = "vertical" | "horizental";
|
|
56
|
+
export type _DragEffect = "swap" | "insert";
|
|
57
|
+
export type _DragCallback = (ids: string[]) => any;
|
|
58
|
+
export type _DragCallbackStart = (e: DragEvent, startid: string) => any;
|
|
59
|
+
export type _DragCallbackEnd = (e: DragEvent) => any;
|
|
60
|
+
export declare class DragList {
|
|
61
|
+
container: HTMLElement;
|
|
62
|
+
drag_id: string | null;
|
|
63
|
+
dir: _DragDirection;
|
|
64
|
+
effect: _DragEffect;
|
|
65
|
+
attr: string;
|
|
66
|
+
realtime: boolean;
|
|
67
|
+
order_origin: string[];
|
|
68
|
+
order: string[];
|
|
69
|
+
css_var_point_events: string;
|
|
70
|
+
map: Map<string, HTMLElement>;
|
|
71
|
+
callback: Set<_DragCallback>;
|
|
72
|
+
callback_start: Set<_DragCallbackStart>;
|
|
73
|
+
callback_end: Set<_DragCallbackEnd>;
|
|
74
|
+
scale_h: number;
|
|
75
|
+
scale_v: number;
|
|
76
|
+
protected _func_start: any;
|
|
77
|
+
protected _func_over: any;
|
|
78
|
+
protected _func_enter: any;
|
|
79
|
+
protected _func_end: any;
|
|
80
|
+
protected _callback_start: any;
|
|
81
|
+
constructor(container: HTMLElement, dir: _DragDirection, attr: string, effect: _DragEffect, realtime?: boolean);
|
|
82
|
+
init(): number;
|
|
83
|
+
protected sort(): void;
|
|
84
|
+
protected init_container(): number;
|
|
85
|
+
protected sum_translate(ids: string[]): number;
|
|
86
|
+
protected register(el: HTMLElement): void;
|
|
87
|
+
protected on_dragstart(e: DragEvent): void;
|
|
88
|
+
protected on_dragenter(e: DragEvent): void;
|
|
89
|
+
protected on_dragover(e: DragEvent): void;
|
|
90
|
+
protected on_drop(e: DragEvent): void;
|
|
91
|
+
protected on_dragend(e: DragEvent): void;
|
|
92
|
+
register_start(func: _DragCallbackStart): void;
|
|
93
|
+
register_dropend(func: _DragCallbackEnd): void;
|
|
94
|
+
register_callback(func: _DragCallback): void;
|
|
95
|
+
off_callback(func: _DragCallback): void;
|
|
96
|
+
off_callback_start(func: _DragCallbackStart): void;
|
|
97
|
+
off_callback_drop(func: _DragCallbackEnd): void;
|
|
98
|
+
}
|
|
99
|
+
export declare class DragDiff {
|
|
100
|
+
protected _el: HTMLElement;
|
|
101
|
+
protected _handler_down: any;
|
|
102
|
+
protected _handler_move: any;
|
|
103
|
+
protected _handler_up: any;
|
|
104
|
+
protected _handler_cancel: any;
|
|
105
|
+
protected _func_down: any;
|
|
106
|
+
protected _func_move: any;
|
|
107
|
+
protected _func_up: any;
|
|
108
|
+
protected _func_cancel: any;
|
|
109
|
+
protected _is_down: boolean;
|
|
110
|
+
protected _is_move: boolean;
|
|
111
|
+
protected _down_point: _Point | undefined;
|
|
112
|
+
get el(): HTMLElement;
|
|
113
|
+
constructor(el: HTMLElement);
|
|
114
|
+
protected init(): void;
|
|
115
|
+
protected _pointdown(e: PointerEvent): void;
|
|
116
|
+
protected _pointmove(e: PointerEvent): void;
|
|
117
|
+
protected _pointup(e: PointerEvent): void;
|
|
118
|
+
protected _pointercancel(e: PointerEvent): void;
|
|
119
|
+
off(): void;
|
|
120
|
+
register_down(func: Function): void;
|
|
121
|
+
register_move(func: _DragDiffResultFunc): void;
|
|
122
|
+
register_up(func: _DragDiffResultFunc): void;
|
|
123
|
+
register_cancel(func: Function): void;
|
|
124
|
+
}
|
|
125
|
+
export declare class MathBase {
|
|
126
|
+
static sum(args: Iterable<number>): number;
|
|
127
|
+
}
|
|
128
|
+
export declare class MathRect {
|
|
129
|
+
static get_rect_point(rect: _Rect, pos: _RectPosition): _Point;
|
|
130
|
+
static is_point_in_rect(point: _Point, rect: _Rect, include_edge?: boolean): boolean;
|
|
131
|
+
static get_point_in_rects(point: _Point, rects: _Rect[], include_edge?: boolean): _Rect[];
|
|
132
|
+
static get_point_center(rect: _Rect): _Point;
|
|
133
|
+
static move_rect_to_other(area: _Rect, move: _Rect, target: _Rect, gap?: number): _Point;
|
|
134
|
+
static can_include(container: _RectArea, target: _RectArea): boolean;
|
|
135
|
+
static can_contain(tank: _Rect, target: _Rect): boolean;
|
|
136
|
+
static check_intersection(rect1: _Rect, rect2: _Rect): boolean;
|
|
137
|
+
static limit_point_in_rect(point: _Point, rect: _Rect): _Point;
|
|
138
|
+
static point_distance_with_rect(point: _Point, rect: _Rect): number;
|
|
139
|
+
static get_nearest_rect(point: _Point, rects: _Rect[]): _Rect | undefined;
|
|
140
|
+
static get_shadow_point_horizental(point: _Point, rect: _Rect): _Point;
|
|
141
|
+
static merge(...rects: _Rect[]): _Rect;
|
|
142
|
+
}
|
|
143
|
+
export declare class MathPoint {
|
|
144
|
+
static path: SVGPathElement;
|
|
145
|
+
static svg_path_sample(d: string, count?: number): _Point[];
|
|
146
|
+
static get_line_k(p1: _Point, p2: _Point, scale?: number): number;
|
|
147
|
+
static distance(p1: _Point, p2: _Point): number;
|
|
148
|
+
static find_closet_point(points: _Point[], p: _Point): _Point;
|
|
149
|
+
static offset_points(points: _Point[], offset: _Point): _Point[];
|
|
150
|
+
static find_closest_points(pointsA: _Point[], pointsB: _Point[]): _Line;
|
|
151
|
+
}
|
|
152
|
+
export declare class MathPolygon {
|
|
153
|
+
static polygon_center(points: _Point[]): _Point;
|
|
154
|
+
static get_polygon_area(points: _Point[]): number;
|
|
155
|
+
}
|
|
156
|
+
export declare class MathLine {
|
|
157
|
+
static check_intersection(line1: _Line, line2: _Line): boolean;
|
|
158
|
+
}
|
|
159
|
+
export declare class ArrayTools {
|
|
160
|
+
static swap(list: Array<any>, index1: number, index2: number): void;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export {};
|
package/dist/cubes.js
ADDED
|
@@ -0,0 +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})()));
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cook-web",
|
|
3
|
+
"version": "1.4.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "./dist/cubes.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"type": "module",
|
|
10
|
+
"types": "./dist/cubes.d.ts",
|
|
11
|
+
"keywords": [],
|
|
12
|
+
"author": "",
|
|
13
|
+
"license": "ISC",
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@swc/core": "^1.11.8",
|
|
16
|
+
"@types/node": "^24.5.2",
|
|
17
|
+
"@vue/compiler-sfc": "^3.5.12",
|
|
18
|
+
"clean-webpack-plugin": "^4.0.0",
|
|
19
|
+
"cross-env": "^7.0.3",
|
|
20
|
+
"css-loader": "^7.1.2",
|
|
21
|
+
"dts-bundle-generator": "^9.5.1",
|
|
22
|
+
"html-webpack-plugin": "^5.6.0",
|
|
23
|
+
"ip": "^2.0.1",
|
|
24
|
+
"mini-css-extract-plugin": "^2.9.1",
|
|
25
|
+
"swc-loader": "^0.2.6",
|
|
26
|
+
"typescript": "^5.5.4",
|
|
27
|
+
"vue-loader": "^17.4.2",
|
|
28
|
+
"webpack": "^5.94.0",
|
|
29
|
+
"webpack-cli": "^5.1.4",
|
|
30
|
+
"webpack-dev-server": "^5.0.4",
|
|
31
|
+
"webpackbar": "^6.0.1"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
35
|
+
"dev": "webpack server --config ./webpack.dev.js ",
|
|
36
|
+
"yalc": "webpack --config ./webpack.pro.js && tsc && dts-bundle-generator -o ./dist/cubes.d.ts ./dts/index.d.ts && yalc publish",
|
|
37
|
+
"p": "pnpm version patch --git-tag-version false",
|
|
38
|
+
"minor": "pnpm version minor --git-tag-version false",
|
|
39
|
+
"major": "pnpm version major --git-tag-version false"
|
|
40
|
+
}
|
|
41
|
+
}
|