@lisergia/utilities 24.0.0 → 25.0.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/CHANGELOG.md DELETED
@@ -1,265 +0,0 @@
1
- # @lisergia/utilities
2
-
3
- ## 24.0.0
4
-
5
- ### Major Changes
6
-
7
- - Remove onPopState prevent default.
8
-
9
- ### Patch Changes
10
-
11
- - Updated dependencies
12
- - @lisergia/config-tsconfig@24.0.0
13
-
14
- ## 23.0.0
15
-
16
- ### Major Changes
17
-
18
- - Add IS_LINKS_ENABLED flag.
19
-
20
- ### Patch Changes
21
-
22
- - Updated dependencies
23
- - @lisergia/config-tsconfig@23.0.0
24
-
25
- ## 22.0.0
26
-
27
- ### Major Changes
28
-
29
- - Make sure Viewport unsubscribes events.
30
-
31
- ### Patch Changes
32
-
33
- - Updated dependencies
34
- - @lisergia/config-tsconfig@22.0.0
35
-
36
- ## 21.0.0
37
-
38
- ### Major Changes
39
-
40
- - Cleanup GSAP and Lenis events.
41
-
42
- ### Patch Changes
43
-
44
- - Updated dependencies
45
- - @lisergia/config-tsconfig@21.0.0
46
-
47
- ## 20.0.0
48
-
49
- ### Major Changes
50
-
51
- - Delete Map entries.
52
-
53
- ### Patch Changes
54
-
55
- - Updated dependencies
56
- - @lisergia/config-tsconfig@20.0.0
57
-
58
- ## 19.0.0
59
-
60
- ### Major Changes
61
-
62
- - Cleanup elements from Component on destroy.
63
-
64
- ### Patch Changes
65
-
66
- - Updated dependencies
67
- - @lisergia/config-tsconfig@19.0.0
68
-
69
- ## 18.0.0
70
-
71
- ### Major Changes
72
-
73
- - Fix memory leak from DOMParser.
74
-
75
- ### Patch Changes
76
-
77
- - Updated dependencies
78
- - @lisergia/config-tsconfig@18.0.0
79
-
80
- ## 17.0.0
81
-
82
- ### Major Changes
83
-
84
- - Fix bug with pushState.
85
-
86
- ### Patch Changes
87
-
88
- - Updated dependencies
89
- - @lisergia/config-tsconfig@17.0.0
90
-
91
- ## 16.0.0
92
-
93
- ### Major Changes
94
-
95
- - Update routing popState logic.
96
-
97
- ### Patch Changes
98
-
99
- - Updated dependencies
100
- - @lisergia/config-tsconfig@16.0.0
101
-
102
- ## 15.0.0
103
-
104
- ### Major Changes
105
-
106
- - Fix Link class URL redirect and build from Changesets.
107
-
108
- ### Patch Changes
109
-
110
- - Updated dependencies
111
- - @lisergia/config-tsconfig@15.0.0
112
-
113
- ## 14.0.0
114
-
115
- ### Major Changes
116
-
117
- - Avoid route to contain pathname.
118
-
119
- ### Patch Changes
120
-
121
- - Updated dependencies
122
- - @lisergia/config-tsconfig@14.0.0
123
-
124
- ## 13.0.0
125
-
126
- ### Major Changes
127
-
128
- - Add missing ScrollTrigger dependency.
129
-
130
- ### Patch Changes
131
-
132
- - Updated dependencies
133
- - @lisergia/config-tsconfig@13.0.0
134
-
135
- ## 12.0.0
136
-
137
- ### Major Changes
138
-
139
- - Fix hashchange and popstate conflict.
140
-
141
- ### Patch Changes
142
-
143
- - Updated dependencies
144
- - @lisergia/config-tsconfig@12.0.0
145
-
146
- ## 11.0.0
147
-
148
- ### Major Changes
149
-
150
- - Add GSAP with lagSmoothing fix.
151
-
152
- ### Patch Changes
153
-
154
- - Updated dependencies
155
- - @lisergia/config-tsconfig@11.0.0
156
-
157
- ## 10.0.0
158
-
159
- ### Major Changes
160
-
161
- - Update ESLint configuration with sort.
162
-
163
- ### Patch Changes
164
-
165
- - Updated dependencies
166
- - @lisergia/config-tsconfig@10.0.0
167
-
168
- ## 9.0.0
169
-
170
- ### Major Changes
171
-
172
- - Update Prettier configuration.
173
-
174
- ### Patch Changes
175
-
176
- - Updated dependencies
177
- - @lisergia/config-tsconfig@9.0.0
178
-
179
- ## 8.0.0
180
-
181
- ### Major Changes
182
-
183
- - Fix styles reference to include-media.
184
-
185
- ### Patch Changes
186
-
187
- - Updated dependencies
188
- - @lisergia/config-tsconfig@8.0.0
189
-
190
- ## 7.0.0
191
-
192
- ### Major Changes
193
-
194
- - Fix hash querySelector.
195
-
196
- ### Patch Changes
197
-
198
- - Updated dependencies
199
- - @lisergia/config-tsconfig@7.0.0
200
-
201
- ## 6.0.0
202
-
203
- ### Major Changes
204
-
205
- - Fix Prettier dependency.
206
-
207
- ### Patch Changes
208
-
209
- - Updated dependencies
210
- - @lisergia/config-tsconfig@6.0.0
211
-
212
- ## 5.0.0
213
-
214
- ### Major Changes
215
-
216
- - - Add Tempus utilities.
217
- - Remove module type from packages.
218
- - Add Prettier configuration as dependency.
219
- - Move Front End and Back End packages to separate repositories.
220
-
221
- ### Patch Changes
222
-
223
- - Updated dependencies
224
- - @lisergia/config-tsconfig@5.0.0
225
-
226
- ## 4.0.0
227
-
228
- ### Major Changes
229
-
230
- - Update build.
231
-
232
- ### Patch Changes
233
-
234
- - Updated dependencies
235
- - @lisergia/config-tsconfig@4.0.0
236
-
237
- ## 3.0.0
238
-
239
- ### Major Changes
240
-
241
- - Fix issue on managers distribution.
242
-
243
- ### Patch Changes
244
-
245
- - Updated dependencies
246
- - @lisergia/config-tsconfig@3.0.0
247
-
248
- ## 2.0.0
249
-
250
- ### Major Changes
251
-
252
- - Update build and serving of npm packages.
253
- - Updating build and serving of npm packages.
254
-
255
- ### Patch Changes
256
-
257
- - Updated dependencies
258
- - Updated dependencies
259
- - @lisergia/config-tsconfig@2.0.0
260
-
261
- ## 1.0.0
262
-
263
- ### Major Changes
264
-
265
- - 9c70654: Initial release of Lisergia packages.
package/dist/index.cjs DELETED
@@ -1,279 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- CanvasUtils: () => CanvasUtils,
24
- DOMUtils: () => DOMUtils,
25
- Detection: () => Detection,
26
- DetectionManager: () => DetectionManager,
27
- MathUtils: () => MathUtils,
28
- TempusUtils: () => TempusUtils,
29
- TempusUtilsManager: () => TempusUtilsManager
30
- });
31
- module.exports = __toCommonJS(index_exports);
32
-
33
- // src/Polyfill.ts
34
- var HTMLElementPrototype = HTMLElement.prototype;
35
- var NodeListPrototype = NodeList.prototype;
36
- if (!HTMLElementPrototype.forEach) {
37
- HTMLElementPrototype.forEach = function(callback, thisArg) {
38
- thisArg = thisArg || window;
39
- callback.call(thisArg, this, this, this);
40
- };
41
- }
42
- if (!NodeListPrototype.filter) {
43
- NodeListPrototype.filter = Array.prototype.filter;
44
- }
45
- if (!NodeListPrototype.find) {
46
- NodeListPrototype.find = Array.prototype.find;
47
- }
48
- if (!NodeListPrototype.map) {
49
- NodeListPrototype.map = Array.prototype.map;
50
- }
51
-
52
- // src/Canvas.ts
53
- function trim(canvas) {
54
- const context = canvas.getContext("2d");
55
- const copy = document.createElement("canvas").getContext("2d", { willReadFrequently: true });
56
- const pixels = context.getImageData(0, 0, canvas.width, canvas.height);
57
- const length = pixels.data.length;
58
- const bound = {
59
- bottom: null,
60
- left: null,
61
- right: null,
62
- top: null
63
- };
64
- let x;
65
- let y;
66
- for (let i = 0; i < length; i += 4) {
67
- if (pixels.data[i + 3] !== 0) {
68
- x = i / 4 % canvas.width;
69
- y = ~~(i / 4 / canvas.width);
70
- if (bound.top === null) {
71
- bound.top = y;
72
- }
73
- if (bound.left === null) {
74
- bound.left = x;
75
- } else if (x < bound.left) {
76
- bound.left = x;
77
- }
78
- if (bound.right === null) {
79
- bound.right = x;
80
- } else if (bound.right < x) {
81
- bound.right = x;
82
- }
83
- if (bound.bottom === null) {
84
- bound.bottom = y;
85
- } else if (bound.bottom < y) {
86
- bound.bottom = y;
87
- }
88
- }
89
- }
90
- const trimHeight = bound.bottom - bound.top;
91
- const trimWidth = bound.right - bound.left;
92
- const trimmed = context.getImageData(bound.left, bound.top, trimWidth, trimHeight);
93
- copy.canvas.width = trimWidth;
94
- copy.canvas.height = trimHeight;
95
- copy.putImageData(trimmed, 0, 0);
96
- return copy.canvas;
97
- }
98
- var CanvasUtils = {
99
- trim
100
- };
101
-
102
- // src/Detection.ts
103
- var DetectionManager = class {
104
- isMobile() {
105
- return !document.documentElement.classList.contains("desktop");
106
- }
107
- };
108
- var Detection = new DetectionManager();
109
-
110
- // src/DOM.ts
111
- function getBounds(element, top = 0) {
112
- const box = element.getBoundingClientRect();
113
- return {
114
- bottom: box.bottom,
115
- height: box.height,
116
- left: box.left,
117
- top: box.top + top,
118
- width: box.width
119
- };
120
- }
121
- var DOMUtils = {
122
- getBounds
123
- };
124
-
125
- // src/Math.ts
126
- function lerp(start, end, time) {
127
- return start + (end - start) * time;
128
- }
129
- function clamp(value, min, max) {
130
- return Math.min(Math.max(value, min), max);
131
- }
132
- function random(min, max) {
133
- return Math.random() * (max - min) + min;
134
- }
135
- function map(value, inMin, inMax, outMin, outMax, clamp2 = false) {
136
- let mapped = (value - inMin) * (outMax - outMin) / (inMax - inMin) + outMin;
137
- if (clamp2) {
138
- const [minOut, maxOut] = outMin < outMax ? [outMin, outMax] : [outMax, outMin];
139
- mapped = Math.min(Math.max(mapped, minOut), maxOut);
140
- }
141
- return mapped;
142
- }
143
- var MathUtils = {
144
- clamp,
145
- lerp,
146
- map,
147
- random
148
- };
149
-
150
- // ../../node_modules/tempus/dist/tempus.mjs
151
- var index = 0;
152
- function getUID() {
153
- return index++;
154
- }
155
- var isClient = typeof window !== "undefined";
156
- var originalRAF = isClient && window.requestAnimationFrame;
157
- var originalCancelRAF = isClient && window.cancelAnimationFrame;
158
- var Framerate = class {
159
- callbacks;
160
- fps;
161
- time;
162
- lastTickDate;
163
- constructor(fps = Number.POSITIVE_INFINITY) {
164
- this.callbacks = [];
165
- this.fps = fps;
166
- this.time = 0;
167
- this.lastTickDate = performance.now();
168
- }
169
- get executionTime() {
170
- return 1e3 / this.fps;
171
- }
172
- dispatch(time, deltaTime) {
173
- var _a;
174
- for (let i = 0; i < this.callbacks.length; i++) {
175
- (_a = this.callbacks[i]) == null ? void 0 : _a.callback(time, deltaTime);
176
- }
177
- }
178
- raf(time, deltaTime) {
179
- this.time += deltaTime;
180
- if (this.fps === Number.POSITIVE_INFINITY) {
181
- this.dispatch(time, deltaTime);
182
- } else if (this.time >= this.executionTime) {
183
- this.time = this.time % this.executionTime;
184
- const deltaTime2 = time - this.lastTickDate;
185
- this.lastTickDate = time;
186
- this.dispatch(time, deltaTime2);
187
- }
188
- }
189
- add({ callback, priority }) {
190
- if (typeof callback !== "function")
191
- console.error("Tempus.add: callback is not a function");
192
- const uid = getUID();
193
- this.callbacks.push({ callback, priority, uid });
194
- this.callbacks.sort((a, b) => a.priority - b.priority);
195
- return () => this.remove(uid);
196
- }
197
- remove(uid) {
198
- this.callbacks = this.callbacks.filter(({ uid: u }) => uid !== u);
199
- }
200
- };
201
- var TempusImpl = class {
202
- framerates;
203
- time;
204
- constructor() {
205
- this.framerates = {};
206
- this.time = isClient ? performance.now() : 0;
207
- if (!isClient) return;
208
- requestAnimationFrame(this.raf);
209
- }
210
- add(callback, { priority = 0, fps = Number.POSITIVE_INFINITY } = {}) {
211
- if (!isClient) return;
212
- if (typeof fps === "number") {
213
- if (!this.framerates[fps]) this.framerates[fps] = new Framerate(fps);
214
- return this.framerates[fps].add({ callback, priority });
215
- }
216
- }
217
- raf = (time) => {
218
- if (!isClient) return;
219
- requestAnimationFrame(this.raf, true);
220
- const deltaTime = time - this.time;
221
- this.time = time;
222
- for (const framerate of Object.values(this.framerates)) {
223
- framerate.raf(time, deltaTime);
224
- }
225
- };
226
- patch() {
227
- if (!isClient) return;
228
- window.requestAnimationFrame = (callback, { priority = 0, fps = Number.POSITIVE_INFINITY } = {}) => {
229
- if (callback === this.raf || !callback.toString().includes("requestAnimationFrame(")) {
230
- return originalRAF(callback);
231
- }
232
- if (!callback.__tempusPatched) {
233
- callback.__tempusPatched = true;
234
- callback.__tempusUnsubscribe = this.add(callback, { priority, fps });
235
- }
236
- return callback.__tempusUnsubscribe;
237
- };
238
- window.cancelAnimationFrame = (callback) => {
239
- if (typeof callback === "function") {
240
- callback == null ? void 0 : callback();
241
- return;
242
- }
243
- return originalCancelRAF(callback);
244
- };
245
- }
246
- unpatch() {
247
- if (!isClient) return;
248
- window.requestAnimationFrame = originalRAF;
249
- window.cancelAnimationFrame = originalCancelRAF;
250
- }
251
- };
252
- var Tempus = new TempusImpl();
253
-
254
- // src/Tempus.ts
255
- var TempusUtilsManager = class {
256
- cache = /* @__PURE__ */ new Map();
257
- add(callback, options) {
258
- const cancel = Tempus.add(callback, options);
259
- this.cache.set(callback, cancel);
260
- }
261
- remove(callback) {
262
- const cancel = this.cache.get(callback);
263
- if (cancel) {
264
- cancel();
265
- this.cache.delete(callback);
266
- }
267
- }
268
- };
269
- var TempusUtils = new TempusUtilsManager();
270
- // Annotate the CommonJS export names for ESM import in node:
271
- 0 && (module.exports = {
272
- CanvasUtils,
273
- DOMUtils,
274
- Detection,
275
- DetectionManager,
276
- MathUtils,
277
- TempusUtils,
278
- TempusUtilsManager
279
- });
package/dist/index.d.cts DELETED
@@ -1,43 +0,0 @@
1
- import { TempusCallback, TempusOptions } from 'tempus';
2
-
3
- declare function trim(canvas: HTMLCanvasElement): HTMLCanvasElement;
4
- declare const CanvasUtils: {
5
- trim: typeof trim;
6
- };
7
-
8
- declare class DetectionManager {
9
- isMobile(): boolean;
10
- }
11
- declare const Detection: DetectionManager;
12
-
13
- interface DOMRectBounds {
14
- bottom: number;
15
- height: number;
16
- left: number;
17
- top: number;
18
- width: number;
19
- }
20
- declare function getBounds(element: HTMLElement, top?: number): DOMRectBounds;
21
- declare const DOMUtils: {
22
- getBounds: typeof getBounds;
23
- };
24
-
25
- declare function lerp(start: number, end: number, time: number): number;
26
- declare function clamp(value: number, min: number, max: number): number;
27
- declare function random(min: number, max: number): number;
28
- declare function map(value: number, inMin: number, inMax: number, outMin: number, outMax: number, clamp?: boolean): number;
29
- declare const MathUtils: {
30
- clamp: typeof clamp;
31
- lerp: typeof lerp;
32
- map: typeof map;
33
- random: typeof random;
34
- };
35
-
36
- declare class TempusUtilsManager {
37
- cache: Map<any, any>;
38
- add(callback: TempusCallback, options?: TempusOptions): void;
39
- remove(callback: TempusCallback): void;
40
- }
41
- declare const TempusUtils: TempusUtilsManager;
42
-
43
- export { CanvasUtils, type DOMRectBounds, DOMUtils, Detection, DetectionManager, MathUtils, TempusUtils, TempusUtilsManager };
package/src/Canvas.ts DELETED
@@ -1,65 +0,0 @@
1
- function trim(canvas: HTMLCanvasElement) {
2
- const context = canvas.getContext('2d')!
3
-
4
- const copy = document.createElement('canvas').getContext('2d', { willReadFrequently: true })
5
- const pixels = context.getImageData(0, 0, canvas.width, canvas.height)
6
- const length = pixels.data.length
7
-
8
- const bound: {
9
- bottom: number | null
10
- left: number | null
11
- right: number | null
12
- top: number | null
13
- } = {
14
- bottom: null,
15
- left: null,
16
- right: null,
17
- top: null,
18
- }
19
-
20
- let x: number
21
- let y: number
22
-
23
- for (let i = 0; i < length; i += 4) {
24
- if (pixels.data[i + 3] !== 0) {
25
- x = (i / 4) % canvas.width
26
- y = ~~(i / 4 / canvas.width)
27
-
28
- if (bound.top === null) {
29
- bound.top = y
30
- }
31
-
32
- if (bound.left === null) {
33
- bound.left = x
34
- } else if (x < bound.left) {
35
- bound.left = x
36
- }
37
-
38
- if (bound.right === null) {
39
- bound.right = x
40
- } else if (bound.right < x) {
41
- bound.right = x
42
- }
43
-
44
- if (bound.bottom === null) {
45
- bound.bottom = y
46
- } else if (bound.bottom < y) {
47
- bound.bottom = y
48
- }
49
- }
50
- }
51
-
52
- const trimHeight = bound.bottom! - bound.top!
53
- const trimWidth = bound.right! - bound.left!
54
- const trimmed = context.getImageData(bound.left!, bound.top!, trimWidth, trimHeight)
55
-
56
- copy!.canvas.width = trimWidth
57
- copy!.canvas.height = trimHeight
58
- copy!.putImageData(trimmed, 0, 0)
59
-
60
- return copy!.canvas
61
- }
62
-
63
- export const CanvasUtils = {
64
- trim,
65
- }
package/src/DOM.ts DELETED
@@ -1,23 +0,0 @@
1
- export interface DOMRectBounds {
2
- bottom: number
3
- height: number
4
- left: number
5
- top: number
6
- width: number
7
- }
8
-
9
- function getBounds(element: HTMLElement, top = 0) {
10
- const box = element.getBoundingClientRect()
11
-
12
- return {
13
- bottom: box.bottom,
14
- height: box.height,
15
- left: box.left,
16
- top: box.top + top,
17
- width: box.width,
18
- } as DOMRectBounds
19
- }
20
-
21
- export const DOMUtils = {
22
- getBounds,
23
- }
package/src/Detection.ts DELETED
@@ -1,7 +0,0 @@
1
- export class DetectionManager {
2
- isMobile() {
3
- return !document.documentElement.classList.contains('desktop')
4
- }
5
- }
6
-
7
- export const Detection = new DetectionManager()
package/src/Math.ts DELETED
@@ -1,37 +0,0 @@
1
- function lerp(start: number, end: number, time: number) {
2
- return start + (end - start) * time
3
- }
4
-
5
- function clamp(value: number, min: number, max: number) {
6
- return Math.min(Math.max(value, min), max)
7
- }
8
-
9
- function random(min: number, max: number) {
10
- return Math.random() * (max - min) + min
11
- }
12
-
13
- function map(
14
- value: number,
15
- inMin: number,
16
- inMax: number,
17
- outMin: number,
18
- outMax: number,
19
- clamp: boolean = false,
20
- ): number {
21
- let mapped = ((value - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin
22
-
23
- if (clamp) {
24
- const [minOut, maxOut] = outMin < outMax ? [outMin, outMax] : [outMax, outMin]
25
-
26
- mapped = Math.min(Math.max(mapped, minOut), maxOut)
27
- }
28
-
29
- return mapped
30
- }
31
-
32
- export const MathUtils = {
33
- clamp,
34
- lerp,
35
- map,
36
- random,
37
- }