aprog 2.0.6 → 2.0.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aprog",
3
- "version": "2.0.6",
3
+ "version": "2.0.7",
4
4
  "description": "Допоміжна JavaScript-бібліотека для проєктів",
5
5
  "main": "index.js",
6
6
  "exports": {
@@ -10,7 +10,10 @@
10
10
  }
11
11
  },
12
12
  "scripts": {
13
- "test": "jest"
13
+ "test": "jest",
14
+ "postinstall": "node ./publish.js",
15
+ "publish-files": "node ./publish.js",
16
+ "publish-force": "node ./publish.js --force"
14
17
  },
15
18
  "repository": {
16
19
  "type": "git",
@@ -0,0 +1,45 @@
1
+ import {button, GUID} from "aprog";
2
+
3
+ /**
4
+ * AprogJS Constructor
5
+ * --- ButtonSearchConstructor ---
6
+ * Copyright (c) 2025 AlexProger.
7
+ */
8
+ export const ButtonConstructor = {
9
+ /**
10
+ * create HTMLElement
11
+ */
12
+ constructor() {
13
+ const instance = Object.create(this);
14
+ instance.class = GUID();
15
+ return instance;
16
+ },
17
+
18
+ /**
19
+ * set HTMLElement
20
+ */
21
+ element({
22
+ id = undefined,
23
+ className = "",
24
+ style = {},
25
+ type = undefined,
26
+ text = "",
27
+ callback = () => {},
28
+ } = {}) {
29
+ return this.is = button({
30
+ id: id || GUID(),
31
+ class: `${this.class} btn ${className} disabled`,
32
+ style: style,
33
+ ...(type && {type: type}),
34
+ value: text,
35
+ onClick: callback
36
+ });
37
+ },
38
+
39
+ /**
40
+ * get target [HTMLElement]
41
+ */
42
+ get target() {
43
+ return this?.is;
44
+ }
45
+ };
@@ -0,0 +1,50 @@
1
+ import {GUID, input} from "aprog";
2
+
3
+ /**
4
+ * AprogJS Constructor
5
+ * --- InputConstructor ---
6
+ * Copyright (c) 2025 AlexProger.
7
+ */
8
+ export const InputConstructor = {
9
+ /**
10
+ * create HTMLElement
11
+ */
12
+ constructor() {
13
+ const instance = Object.create(this);
14
+ instance.class = GUID();
15
+ return instance;
16
+ },
17
+
18
+ /**
19
+ * set HTMLElement
20
+ */
21
+ element({
22
+ id = undefined,
23
+ className = "",
24
+ style = {},
25
+ type = undefined,
26
+ focus = false,
27
+ placeholder = undefined,
28
+ value = undefined,
29
+ nameCallback = "onInput",
30
+ callback = () => {},
31
+ } = {}) {
32
+ return this.is = input({
33
+ id: id || GUID(),
34
+ class: `${this.class} input ${className}`,
35
+ style: style,
36
+ ...(type && {type: type}),
37
+ focus: focus,
38
+ ...(placeholder && {placeholder: placeholder}),
39
+ ...(value && {value: value}),
40
+ [nameCallback]: callback,
41
+ });
42
+ },
43
+
44
+ /**
45
+ * get target [HTMLElement]
46
+ */
47
+ get target() {
48
+ return this?.is;
49
+ }
50
+ };
package/src/publish.js ADDED
@@ -0,0 +1,48 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import { fileURLToPath } from 'url';
4
+
5
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
6
+ const force = process.argv.includes('--force');
7
+
8
+ /**
9
+ * Копіює файл, якщо його ще нема, або перезаписує, якщо --force
10
+ */
11
+ function copyFile(from, to) {
12
+ fs.mkdirSync(path.dirname(to), { recursive: true });
13
+
14
+ if (!fs.existsSync(to) || force) {
15
+ fs.copyFileSync(from, to);
16
+ console.log(`✅ Копійовано: ${from} → ${to}`);
17
+ } else {
18
+ console.log(`ℹ️ Пропущено (вже існує): ${to}`);
19
+ }
20
+ }
21
+
22
+ /**
23
+ * Копіює всі .js файли з src/constructs у resources/js/components/constructs
24
+ */
25
+ function copyConstructs() {
26
+ const srcDir = path.resolve(__dirname, 'src/constructs');
27
+ const destDir = path.resolve(process.cwd(), 'resources/js/components/constructs');
28
+
29
+ if (!fs.existsSync(srcDir)) {
30
+ console.error(`❌ Не знайдено директорії: ${srcDir}`);
31
+ process.exit(1);
32
+ }
33
+
34
+ const files = fs.readdirSync(srcDir);
35
+
36
+ files.forEach(file => {
37
+ const from = path.join(srcDir, file);
38
+ const to = path.join(destDir, file);
39
+
40
+ if (fs.statSync(from).isFile() && path.extname(from) === '.js') {
41
+ copyFile(from, to);
42
+ }
43
+ });
44
+ }
45
+
46
+ console.log('📦 Починаю копіювання файлів з Aprog...');
47
+ copyConstructs();
48
+ console.log('🏁 Готово.');
package/src/redirect.js CHANGED
@@ -28,23 +28,25 @@ export const validatePassword = (password) => {
28
28
  /**
29
29
  * --- Функція для відкладеного запуску скрипта ---
30
30
  * ідентична `setTimeout`, але використовує секунди
31
- * @param handler
32
- * @param seconds
33
- * @param args
31
+ * @param {TimerHandler} handler
32
+ * @param {int|float} seconds
33
+ * @param {any[]} args
34
+ * @return {number}
34
35
  */
35
36
  export const delay = (handler, seconds, args = []) => {
36
37
  seconds *= 1000;
37
- setTimeout(handler, seconds, ...args);
38
+ return setTimeout(handler, seconds, ...args);
38
39
  };
39
40
 
40
41
  /**
41
42
  * --- Функція для циклічності скрипта ---
42
43
  * ідентична `setInterval`, але використовує секунди
43
- * @param handler
44
- * @param seconds
45
- * @param args
44
+ * @param {TimerHandler} handler
45
+ * @param {int|float} seconds
46
+ * @param {any[]} args
47
+ * @return {number}
46
48
  */
47
49
  export const cycle = (handler, seconds, args = []) => {
48
50
  seconds *= 1000;
49
- setInterval(handler, seconds, ...args)
51
+ return setInterval(handler, seconds, ...args)
50
52
  };