@kamen/create-webapp 1.0.26 → 1.0.28
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/index.js +84 -9
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -65,28 +65,62 @@ export function randomFromList(list = []) {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
|
-
* @param {string} [text='']
|
|
69
68
|
* @param {number} [saturation=80]
|
|
70
69
|
* @param {number} [lightness=80]
|
|
71
70
|
* @param {number} [alpha=1]
|
|
72
71
|
* @returns {string}
|
|
73
72
|
*/
|
|
74
|
-
export function
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
73
|
+
export function randomColorFromSaturationLightnessAlpha(saturation = 80, lightness = 80, alpha = 1) {
|
|
74
|
+
const hue = randomFromRange(0, 359);
|
|
75
|
+
return `hsla(${hue}, ${saturation}%, ${lightness}%, ${alpha})`;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @param {number} [min=0]
|
|
80
|
+
* @param {number} [max=255]
|
|
81
|
+
* @returns {Function<number>}
|
|
82
|
+
*/
|
|
83
|
+
export function createRandomFromRange(min = 0, max = 255) {
|
|
84
|
+
return function () {
|
|
85
|
+
return randomFromRange(min, max);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @template T
|
|
91
|
+
* @param {T[]} [list=[]]
|
|
92
|
+
* @returns {Function<T>}
|
|
93
|
+
*/
|
|
94
|
+
export function createRandomFromList(list = []) {
|
|
95
|
+
return function () {
|
|
96
|
+
return randomFromList(list);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @param {number} [saturation=80]
|
|
102
|
+
* @param {number} [lightness=80]
|
|
103
|
+
* @param {number} [alpha=1]
|
|
104
|
+
* @returns {Function<string>}
|
|
105
|
+
*/
|
|
106
|
+
export function createRandomColorFromSaturationLightnessAlpha(saturation = 80, lightness = 80, alpha = 1) {
|
|
107
|
+
return function () {
|
|
108
|
+
return randomColorFromSaturationLightnessAlpha(saturation, lightness, alpha);
|
|
109
|
+
}
|
|
79
110
|
}
|
|
80
111
|
|
|
81
112
|
/**
|
|
113
|
+
* @param {string} [text='']
|
|
82
114
|
* @param {number} [saturation=80]
|
|
83
115
|
* @param {number} [lightness=80]
|
|
84
116
|
* @param {number} [alpha=1]
|
|
85
117
|
* @returns {string}
|
|
86
118
|
*/
|
|
87
|
-
export function
|
|
88
|
-
|
|
89
|
-
|
|
119
|
+
export function textToHsla(text = '', saturation = 80, lightness = 80, alpha = 1) {
|
|
120
|
+
let hash = 0;
|
|
121
|
+
for (let i = 0, {length} = text; i < length; i++)
|
|
122
|
+
hash = text.charCodeAt(i) + ((hash << 5) - hash);
|
|
123
|
+
return `hsla(${hash % 360}, ${saturation}%, ${lightness}%, ${alpha})`;
|
|
90
124
|
}
|
|
91
125
|
|
|
92
126
|
/**
|
|
@@ -221,4 +255,45 @@ export function findVue(version = 2, root = document, hook = '__VUE_DEVTOOLS_GLO
|
|
|
221
255
|
}
|
|
222
256
|
|
|
223
257
|
return 'Vue mountpoint not found';
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* URL wrapper implementing builder pattern
|
|
262
|
+
*/
|
|
263
|
+
export class URLBuilder {
|
|
264
|
+
static create(url, base) {
|
|
265
|
+
return new this(url, base);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
constructor(url, base) {
|
|
269
|
+
this.url = new URL(url, base);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
appendParams(name, value) {
|
|
273
|
+
this.url.searchParams.append(name, value);
|
|
274
|
+
return this;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
deleteParams(name, value) {
|
|
278
|
+
this.url.searchParams.delete(name, value);
|
|
279
|
+
return this;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
setParams(name, value) {
|
|
283
|
+
this.url.searchParams.set(name, value);
|
|
284
|
+
return this;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
createParams(options) {
|
|
288
|
+
this.url.searchParams = new URLSearchParams(options);
|
|
289
|
+
return this;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
get hash() {
|
|
293
|
+
return this.url.hash;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
toString() {
|
|
297
|
+
return this.url.toString();
|
|
298
|
+
}
|
|
224
299
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kamen/create-webapp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.28",
|
|
4
4
|
"description": "npm init @kamen/webapp",
|
|
5
5
|
"homepage": "https://www.npmjs.com/package/@kamen/create-webapp",
|
|
6
6
|
"license": "GPL-2.0-only",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"repository": {
|
|
22
22
|
"type": "git",
|
|
23
|
-
"url": "git+https://github.com/L1feF0rm/
|
|
23
|
+
"url": "git+https://github.com/L1feF0rm/create-webapp.git"
|
|
24
24
|
},
|
|
25
25
|
"engines": {
|
|
26
26
|
"node": ">=20",
|