tiny-essentials 1.8.4 → 1.8.5
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/TinyBasicsEs.js +30 -0
- package/dist/TinyBasicsEs.min.js +1 -1
- package/dist/TinyEssentials.js +30 -0
- package/dist/TinyEssentials.min.js +1 -1
- package/dist/legacy/crypto/decrypt.cjs +1 -1
- package/dist/legacy/crypto/decrypt.mjs +3 -3
- package/dist/legacy/crypto/default.cjs +0 -2
- package/dist/legacy/crypto/default.mjs +0 -1
- package/dist/legacy/crypto/encrypt.cjs +1 -2
- package/dist/legacy/crypto/encrypt.mjs +3 -4
- package/dist/legacy/crypto/index.cjs +1 -1
- package/dist/legacy/crypto/index.mjs +0 -1
- package/dist/legacy/firebase/database/presence.cjs +4 -1
- package/dist/legacy/firebase/database/presence.d.mts +3 -0
- package/dist/legacy/firebase/database/presence.mjs +4 -1
- package/dist/legacy/firebase/databaseLogger.cjs +2 -2
- package/dist/legacy/firebase/discord/get/cookie-session.cjs +2 -2
- package/dist/legacy/firebase/discord/get/errorValidator.cjs +2 -2
- package/dist/legacy/firebase/discord/http/login.cjs +7 -7
- package/dist/legacy/firebase/discord/http/logout.cjs +4 -4
- package/dist/legacy/firebase/discord/http/redirect.cjs +7 -7
- package/dist/legacy/firebase/discord/http/refreshToken.cjs +5 -5
- package/dist/legacy/firebase/discord/template/cookie-session.cjs +8 -8
- package/dist/legacy/firebase/logger.cjs +7 -7
- package/dist/legacy/firebase/mySQL.cjs +1 -0
- package/dist/legacy/firebase/mysqlConnector/sameUser.cjs +2 -2
- package/dist/legacy/get/countObj.cjs +2 -22
- package/dist/legacy/get/countObj.d.mts +2 -11
- package/dist/legacy/get/countObj.mjs +2 -22
- package/dist/legacy/get/decimalColor.cjs +10 -11
- package/dist/legacy/get/decimalColor.mjs +10 -10
- package/dist/legacy/get/objType.cjs +2 -40
- package/dist/legacy/get/objType.d.mts +2 -19
- package/dist/legacy/get/objType.mjs +2 -41
- package/dist/legacy/get/pagination.cjs +30 -25
- package/dist/legacy/get/pagination.d.mts +29 -12
- package/dist/legacy/get/pagination.mjs +30 -23
- package/dist/legacy/get/queryUrlByName.cjs +0 -2
- package/dist/legacy/get/queryUrlByName.mjs +0 -1
- package/dist/legacy/get/queryUrlJSON.cjs +2 -2
- package/dist/legacy/get/queryUrlJSON.mjs +1 -1
- package/dist/legacy/get/super_string_filter.cjs +14 -6
- package/dist/legacy/get/super_string_filter.mjs +11 -1
- package/dist/legacy/get/versionCheck.cjs +18 -19
- package/dist/legacy/get/versionCheck.d.mts +15 -5
- package/dist/legacy/get/versionCheck.mjs +16 -16
- package/dist/legacy/http/HTTP-1.0.cjs +2 -4
- package/dist/legacy/http/HTTP-1.0.d.mts +1 -1
- package/dist/legacy/http/HTTP-1.0.mjs +2 -3
- package/dist/legacy/http/auth.cjs +2 -4
- package/dist/legacy/http/auth.d.mts +4 -4
- package/dist/legacy/http/auth.mjs +2 -3
- package/dist/legacy/http/check_domain.cjs +15 -9
- package/dist/legacy/http/check_domain.d.mts +5 -6
- package/dist/legacy/http/check_domain.mjs +12 -8
- package/dist/legacy/http/csrfTokenAnalyze.cjs +5 -4
- package/dist/legacy/http/csrfTokenAnalyze.d.mts +3 -3
- package/dist/legacy/http/csrfTokenAnalyze.mjs +7 -4
- package/dist/legacy/http/domainValidator.cjs +13 -9
- package/dist/legacy/http/domainValidator.d.mts +15 -6
- package/dist/legacy/http/domainValidator.mjs +11 -6
- package/dist/legacy/http/errorsCallback.cjs +10 -4
- package/dist/legacy/http/errorsCallback.d.mts +13 -3
- package/dist/legacy/http/errorsCallback.mjs +12 -4
- package/dist/legacy/http/fetch/json.cjs +1 -3
- package/dist/legacy/http/fetch/json.mjs +1 -1
- package/dist/legacy/http/fetch/text.cjs +1 -3
- package/dist/legacy/http/fetch/text.mjs +1 -1
- package/dist/legacy/http/fileCache.cjs +2 -5
- package/dist/legacy/http/fileCache.d.mts +3 -3
- package/dist/legacy/http/fileCache.mjs +2 -3
- package/dist/legacy/http/getDomainURL.cjs +4 -7
- package/dist/legacy/http/getDomainURL.d.mts +2 -2
- package/dist/legacy/http/getDomainURL.mjs +4 -5
- package/dist/legacy/http/userIP.cjs +7 -5
- package/dist/legacy/http/userIP.d.mts +10 -4
- package/dist/legacy/http/userIP.mjs +7 -4
- package/dist/legacy/index.cjs +3 -4
- package/dist/legacy/index.d.mts +8 -9
- package/dist/legacy/libs/arraySortPositions.cjs +1 -3
- package/dist/legacy/libs/arraySortPositions.d.mts +2 -2
- package/dist/legacy/libs/arraySortPositions.mjs +1 -2
- package/dist/legacy/libs/capitalize.cjs +0 -2
- package/dist/legacy/libs/capitalize.mjs +0 -1
- package/dist/legacy/libs/convertBytes.cjs +1 -3
- package/dist/legacy/libs/convertBytes.mjs +1 -2
- package/dist/legacy/libs/custom_module_loader.cjs +13 -9
- package/dist/legacy/libs/custom_module_loader.d.mts +1 -1
- package/dist/legacy/libs/custom_module_loader.mjs +10 -5
- package/dist/legacy/libs/dice.cjs +0 -2
- package/dist/legacy/libs/dice.mjs +0 -1
- package/dist/legacy/libs/markdown.cjs +13 -4
- package/dist/legacy/libs/markdown.d.mts +7 -71
- package/dist/legacy/libs/markdown.mjs +13 -3
- package/dist/legacy/libs/percentage.cjs +0 -2
- package/dist/legacy/libs/percentage.mjs +0 -1
- package/dist/legacy/libs/regex/getLetter.cjs +0 -2
- package/dist/legacy/libs/regex/getLetter.mjs +0 -1
- package/dist/legacy/libs/rule3.cjs +0 -2
- package/dist/legacy/libs/rule3.mjs +0 -1
- package/dist/legacy/momentjs/getAge.cjs +0 -3
- package/dist/legacy/momentjs/getAge.d.mts +1 -0
- package/dist/legacy/momentjs/getAge.mjs +0 -1
- package/dist/legacy/momentjs/index.cjs +1 -1
- package/dist/legacy/momentjs/index.mjs +0 -1
- package/dist/legacy/momentjs/timeDuration.cjs +1 -3
- package/dist/legacy/momentjs/timeDuration.d.mts +1 -0
- package/dist/legacy/momentjs/timeDuration.mjs +1 -1
- package/dist/legacy/socket.io/antiFlood/index.cjs +1 -1
- package/dist/legacy/socket.io/antiFlood/index.mjs +0 -1
- package/dist/legacy/socket.io/antiFlood/install.cjs +3 -5
- package/dist/legacy/socket.io/antiFlood/install.d.mts +5 -3
- package/dist/legacy/socket.io/antiFlood/install.mjs +3 -3
- package/dist/legacy/socket.io/antiFlood/verify.cjs +10 -6
- package/dist/legacy/socket.io/antiFlood/verify.d.mts +8 -3
- package/dist/legacy/socket.io/antiFlood/verify.mjs +10 -6
- package/dist/legacy/socket.io/cookie-session.cjs +1 -2
- package/dist/legacy/socket.io/cookie-session.mjs +1 -1
- package/dist/legacy/socket.io/discord.cjs +0 -3
- package/dist/legacy/socket.io/discord.mjs +0 -1
- package/dist/legacy/socket.io/index.cjs +0 -3
- package/dist/legacy/socket.io/index.mjs +0 -1
- package/dist/v1/basics/index.cjs +2 -0
- package/dist/v1/basics/index.d.mts +2 -1
- package/dist/v1/basics/index.mjs +2 -1
- package/dist/v1/index.cjs +2 -0
- package/dist/v1/index.d.mts +2 -1
- package/dist/v1/index.mjs +2 -1
- package/docs/basics/array.md +61 -0
- package/package.json +8 -2
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Sends a stringified file as a response with caching, security headers, and optional metadata.
|
|
5
5
|
* If `data.file` is not a string, the request is passed to the next middleware.
|
|
6
6
|
*
|
|
7
|
-
* @param {
|
|
8
|
-
* @param {
|
|
7
|
+
* @param {import('express').Response} res - Express response object.
|
|
8
|
+
* @param {import('express').NextFunction} next - Express next middleware function.
|
|
9
9
|
* @param {object} data - Configuration object for the file response.
|
|
10
10
|
* @param {string} [data.file] - The content of the file to send (must be a string).
|
|
11
11
|
* @param {number} [data.fileMaxAge] - Max age in seconds for cache expiration.
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* });
|
|
27
27
|
* });
|
|
28
28
|
*/
|
|
29
|
-
export default function fileCache(res:
|
|
29
|
+
export default function fileCache(res: import("express").Response, next: import("express").NextFunction, data: {
|
|
30
30
|
file?: string | undefined;
|
|
31
31
|
fileMaxAge?: number | undefined;
|
|
32
32
|
date?: string | undefined;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import _ from 'lodash';
|
|
3
2
|
import moment from 'moment-timezone';
|
|
4
3
|
import md5 from 'md5';
|
|
@@ -9,8 +8,8 @@ import byteLength from 'byte-length';
|
|
|
9
8
|
* Sends a stringified file as a response with caching, security headers, and optional metadata.
|
|
10
9
|
* If `data.file` is not a string, the request is passed to the next middleware.
|
|
11
10
|
*
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {
|
|
11
|
+
* @param {import('express').Response} res - Express response object.
|
|
12
|
+
* @param {import('express').NextFunction} next - Express next middleware function.
|
|
14
13
|
* @param {object} data - Configuration object for the file response.
|
|
15
14
|
* @param {string} [data.file] - The content of the file to send (must be a string).
|
|
16
15
|
* @param {number} [data.fileMaxAge] - Max age in seconds for cache expiration.
|
|
@@ -2,16 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
var check_domain = require('./check_domain.cjs');
|
|
4
4
|
|
|
5
|
-
// @ts-nocheck
|
|
6
|
-
|
|
7
|
-
|
|
8
5
|
/**
|
|
9
6
|
* @function getDomainURL
|
|
10
7
|
*
|
|
11
8
|
* Constructs a full URL string from a domain and optional port, determining the proper protocol.
|
|
12
9
|
* It also supports extracting the domain from an Express `req` object via `checkDomain.get(req)`.
|
|
13
10
|
*
|
|
14
|
-
* @param {string|
|
|
11
|
+
* @param {string|import('express').Request} domain - A domain string (e.g. "example.com") or Express `req` object.
|
|
15
12
|
* @param {number} [port] - Optional port to include in the URL (not added for ports 80 or 443).
|
|
16
13
|
* @param {string} [httpResult='https'] - The protocol to use (usually "http" or "https").
|
|
17
14
|
*
|
|
@@ -34,16 +31,16 @@ function getDomainURL(domain, port, httpResult = 'https') {
|
|
|
34
31
|
// Domain
|
|
35
32
|
if (typeof domainSelected === 'string') {
|
|
36
33
|
// Port
|
|
37
|
-
let finalPort =
|
|
34
|
+
let finalPort = '';
|
|
38
35
|
let finalURL = '';
|
|
39
|
-
if (typeof
|
|
36
|
+
if (typeof port === 'number' && port !== 80 && port !== 443) {
|
|
40
37
|
finalPort = ':' + finalPort;
|
|
41
38
|
} else {
|
|
42
39
|
finalPort = '';
|
|
43
40
|
}
|
|
44
41
|
|
|
45
42
|
// Normal Domain
|
|
46
|
-
if (!domainSelected.startsWith('localhost:') &&
|
|
43
|
+
if (!domainSelected.startsWith('localhost:') && domainSelected !== 'localhost')
|
|
47
44
|
finalURL = `${httpResult}://${domainSelected}`;
|
|
48
45
|
// Localhost
|
|
49
46
|
else finalURL = `http://${domainSelected}`;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Constructs a full URL string from a domain and optional port, determining the proper protocol.
|
|
5
5
|
* It also supports extracting the domain from an Express `req` object via `checkDomain.get(req)`.
|
|
6
6
|
*
|
|
7
|
-
* @param {string|
|
|
7
|
+
* @param {string|import('express').Request} domain - A domain string (e.g. "example.com") or Express `req` object.
|
|
8
8
|
* @param {number} [port] - Optional port to include in the URL (not added for ports 80 or 443).
|
|
9
9
|
* @param {string} [httpResult='https'] - The protocol to use (usually "http" or "https").
|
|
10
10
|
*
|
|
@@ -15,5 +15,5 @@
|
|
|
15
15
|
* getDomainURL('localhost', 3000); // "http://localhost:3000"
|
|
16
16
|
* getDomainURL(req, 8080); // Uses domain from request object
|
|
17
17
|
*/
|
|
18
|
-
export default function getDomainURL(domain: string |
|
|
18
|
+
export default function getDomainURL(domain: string | import("express").Request, port?: number, httpResult?: string): string;
|
|
19
19
|
//# sourceMappingURL=getDomainURL.d.mts.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import checkDomain from './check_domain.mjs';
|
|
3
2
|
/**
|
|
4
3
|
* @function getDomainURL
|
|
@@ -6,7 +5,7 @@ import checkDomain from './check_domain.mjs';
|
|
|
6
5
|
* Constructs a full URL string from a domain and optional port, determining the proper protocol.
|
|
7
6
|
* It also supports extracting the domain from an Express `req` object via `checkDomain.get(req)`.
|
|
8
7
|
*
|
|
9
|
-
* @param {string|
|
|
8
|
+
* @param {string|import('express').Request} domain - A domain string (e.g. "example.com") or Express `req` object.
|
|
10
9
|
* @param {number} [port] - Optional port to include in the URL (not added for ports 80 or 443).
|
|
11
10
|
* @param {string} [httpResult='https'] - The protocol to use (usually "http" or "https").
|
|
12
11
|
*
|
|
@@ -29,16 +28,16 @@ export default function getDomainURL(domain, port, httpResult = 'https') {
|
|
|
29
28
|
// Domain
|
|
30
29
|
if (typeof domainSelected === 'string') {
|
|
31
30
|
// Port
|
|
32
|
-
let finalPort =
|
|
31
|
+
let finalPort = '';
|
|
33
32
|
let finalURL = '';
|
|
34
|
-
if (typeof
|
|
33
|
+
if (typeof port === 'number' && port !== 80 && port !== 443) {
|
|
35
34
|
finalPort = ':' + finalPort;
|
|
36
35
|
}
|
|
37
36
|
else {
|
|
38
37
|
finalPort = '';
|
|
39
38
|
}
|
|
40
39
|
// Normal Domain
|
|
41
|
-
if (!domainSelected.startsWith('localhost:') &&
|
|
40
|
+
if (!domainSelected.startsWith('localhost:') && domainSelected !== 'localhost')
|
|
42
41
|
finalURL = `${httpResult}://${domainSelected}`;
|
|
43
42
|
// Localhost
|
|
44
43
|
else
|
|
@@ -2,18 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
var _ = require('lodash');
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {{ value: string[] | string, type: string | null }} IpResult
|
|
7
|
+
*/
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Retrieves the client's IP address from the Express request object,
|
|
10
11
|
* supporting detection for Firebase/Cloud Functions, proxies, and direct connections.
|
|
11
12
|
*
|
|
12
13
|
* @param {import('express').Request} req - The Express request object.
|
|
13
|
-
* @param {
|
|
14
|
+
* @param {Object} [options] - Optional configuration.
|
|
14
15
|
* @param {boolean} [options.isFirebase=false] - Enable detection for Firebase environments (e.g., Fastly).
|
|
15
16
|
*
|
|
16
|
-
* @returns {
|
|
17
|
+
* @returns {IpResult} An object containing the list of IP addresses and the detection source type.
|
|
17
18
|
*
|
|
18
19
|
* @example
|
|
19
20
|
* const ipInfo = userIp(req);
|
|
@@ -21,7 +22,8 @@ var _ = require('lodash');
|
|
|
21
22
|
* console.log(ipInfo.type); // 'x-forwarded-for'
|
|
22
23
|
*/
|
|
23
24
|
function userIp(req, options) {
|
|
24
|
-
|
|
25
|
+
/** @type {IpResult} */
|
|
26
|
+
const ip = {};
|
|
25
27
|
|
|
26
28
|
const tinyCfg = _.defaultsDeep({}, options, {
|
|
27
29
|
isFirebase: false,
|
|
@@ -1,20 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {{ value: string[] | string, type: string | null }} IpResult
|
|
3
|
+
*/
|
|
1
4
|
/**
|
|
2
5
|
* Retrieves the client's IP address from the Express request object,
|
|
3
6
|
* supporting detection for Firebase/Cloud Functions, proxies, and direct connections.
|
|
4
7
|
*
|
|
5
8
|
* @param {import('express').Request} req - The Express request object.
|
|
6
|
-
* @param {
|
|
9
|
+
* @param {Object} [options] - Optional configuration.
|
|
7
10
|
* @param {boolean} [options.isFirebase=false] - Enable detection for Firebase environments (e.g., Fastly).
|
|
8
11
|
*
|
|
9
|
-
* @returns {
|
|
12
|
+
* @returns {IpResult} An object containing the list of IP addresses and the detection source type.
|
|
10
13
|
*
|
|
11
14
|
* @example
|
|
12
15
|
* const ipInfo = userIp(req);
|
|
13
16
|
* console.log(ipInfo.value); // ['192.168.0.1']
|
|
14
17
|
* console.log(ipInfo.type); // 'x-forwarded-for'
|
|
15
18
|
*/
|
|
16
|
-
export default function userIp(req: import("express").Request, options?:
|
|
17
|
-
|
|
19
|
+
export default function userIp(req: import("express").Request, options?: {
|
|
20
|
+
isFirebase?: boolean | undefined;
|
|
21
|
+
}): IpResult;
|
|
22
|
+
export type IpResult = {
|
|
23
|
+
value: string[] | string;
|
|
18
24
|
type: string | null;
|
|
19
25
|
};
|
|
20
26
|
//# sourceMappingURL=userIP.d.mts.map
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import _ from 'lodash';
|
|
2
|
+
/**
|
|
3
|
+
* @typedef {{ value: string[] | string, type: string | null }} IpResult
|
|
4
|
+
*/
|
|
3
5
|
/**
|
|
4
6
|
* Retrieves the client's IP address from the Express request object,
|
|
5
7
|
* supporting detection for Firebase/Cloud Functions, proxies, and direct connections.
|
|
6
8
|
*
|
|
7
9
|
* @param {import('express').Request} req - The Express request object.
|
|
8
|
-
* @param {
|
|
10
|
+
* @param {Object} [options] - Optional configuration.
|
|
9
11
|
* @param {boolean} [options.isFirebase=false] - Enable detection for Firebase environments (e.g., Fastly).
|
|
10
12
|
*
|
|
11
|
-
* @returns {
|
|
13
|
+
* @returns {IpResult} An object containing the list of IP addresses and the detection source type.
|
|
12
14
|
*
|
|
13
15
|
* @example
|
|
14
16
|
* const ipInfo = userIp(req);
|
|
@@ -16,7 +18,8 @@ import _ from 'lodash';
|
|
|
16
18
|
* console.log(ipInfo.type); // 'x-forwarded-for'
|
|
17
19
|
*/
|
|
18
20
|
export default function userIp(req, options) {
|
|
19
|
-
|
|
21
|
+
/** @type {IpResult} */
|
|
22
|
+
const ip = {};
|
|
20
23
|
const tinyCfg = _.defaultsDeep({}, options, {
|
|
21
24
|
isFirebase: false,
|
|
22
25
|
});
|
package/dist/legacy/index.cjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var objType = require('./get/objType.cjs');
|
|
3
|
+
var objFilter = require('../v1/basics/objFilter.cjs');
|
|
5
4
|
var super_string_filter = require('./get/super_string_filter.cjs');
|
|
6
5
|
var auth = require('./http/auth.cjs');
|
|
7
6
|
var check_domain = require('./http/check_domain.cjs');
|
|
@@ -48,10 +47,10 @@ const legacyModules = {
|
|
|
48
47
|
checkDomain: check_domain,
|
|
49
48
|
|
|
50
49
|
// Get Obj Type
|
|
51
|
-
getObjType: objType,
|
|
50
|
+
getObjType: objFilter.objType,
|
|
52
51
|
|
|
53
52
|
// Count Obj
|
|
54
|
-
countObj: countObj,
|
|
53
|
+
countObj: objFilter.countObj,
|
|
55
54
|
|
|
56
55
|
// HTTP Auth Generator
|
|
57
56
|
httpAuth: auth,
|
package/dist/legacy/index.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ export default legacyModules;
|
|
|
2
2
|
declare const legacyModules: {
|
|
3
3
|
convertBytes: {
|
|
4
4
|
list: any;
|
|
5
|
-
sequence:
|
|
5
|
+
sequence: string[];
|
|
6
6
|
get: (bytes: number, selected: SizeUnit) => number;
|
|
7
7
|
convert: (bytes: number, selected: SizeUnit) => number;
|
|
8
8
|
};
|
|
@@ -10,18 +10,17 @@ declare const legacyModules: {
|
|
|
10
10
|
readonly list: {
|
|
11
11
|
[x: number]: string;
|
|
12
12
|
};
|
|
13
|
-
send: (res: import("express").Response, http_code: number, callback?: (arg0: number) =>
|
|
13
|
+
send: (res: import("express").Response, http_code: number, callback?: (arg0: number) => import("express").Response) => import("express").Response;
|
|
14
14
|
sendAsync: (res: import("express").Response, http_code: number, callback?: (arg0: number) => Promise<any>) => Promise<any>;
|
|
15
15
|
};
|
|
16
16
|
momentjs: typeof momentjs;
|
|
17
17
|
checkDomain: {
|
|
18
|
-
validators:
|
|
18
|
+
validators: {
|
|
19
19
|
type: string;
|
|
20
|
-
callback: (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
get: (req: Record<string, any>) => string | null;
|
|
20
|
+
callback: (req: import("express").Request, the_domain: string) => string | boolean | string[] | null | undefined;
|
|
21
|
+
}[];
|
|
22
|
+
validator: (req: import("express").Request, the_domain: string) => boolean;
|
|
23
|
+
get: (req: import("express").Request) => string | true | string[] | null;
|
|
25
24
|
};
|
|
26
25
|
getObjType: typeof objType;
|
|
27
26
|
countObj: typeof countObj;
|
|
@@ -31,7 +30,7 @@ declare const legacyModules: {
|
|
|
31
30
|
superStringFilter: typeof super_string_filter;
|
|
32
31
|
customModuleManager: {
|
|
33
32
|
validator: (custom_modules: Record<string, any>, type: string) => boolean;
|
|
34
|
-
run: (custom_modules:
|
|
33
|
+
run: (custom_modules: Record<string, Function> | Function[], db_prepare: any, hookType: string, options?: Record<string, any>) => Promise<void>;
|
|
35
34
|
};
|
|
36
35
|
errorsCallback: typeof errorsCallback;
|
|
37
36
|
domainValidator: typeof domainValidator;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
// @ts-nocheck
|
|
4
|
-
|
|
5
3
|
/**
|
|
6
4
|
* Generates a comparator function to sort an array of objects by a given key.
|
|
7
5
|
*
|
|
8
6
|
* @param {string} item - The object key to sort by.
|
|
9
7
|
* @param {boolean} [isReverse=false] - If `true`, the sorting will be in descending order.
|
|
10
|
-
* @returns {(a: Object, b: Object) => number} Comparator function compatible with Array.prototype.sort().
|
|
8
|
+
* @returns {(a: Object<string|number, *>, b: Object<string|number, *>) => number} Comparator function compatible with Array.prototype.sort().
|
|
11
9
|
*
|
|
12
10
|
* @example
|
|
13
11
|
* const arr = [{ pos: 2 }, { pos: 1 }, { pos: 3 }];
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @param {string} item - The object key to sort by.
|
|
5
5
|
* @param {boolean} [isReverse=false] - If `true`, the sorting will be in descending order.
|
|
6
|
-
* @returns {(a: Object, b: Object) => number} Comparator function compatible with Array.prototype.sort().
|
|
6
|
+
* @returns {(a: Object<string|number, *>, b: Object<string|number, *>) => number} Comparator function compatible with Array.prototype.sort().
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* const arr = [{ pos: 2 }, { pos: 1 }, { pos: 3 }];
|
|
@@ -13,5 +13,5 @@
|
|
|
13
13
|
* const arr = [{ pos: 2 }, { pos: 1 }, { pos: 3 }];
|
|
14
14
|
* arr.sort(arraySortPositions('pos', true)); // Descending: [{pos: 3}, {pos: 2}, {pos: 1}]
|
|
15
15
|
*/
|
|
16
|
-
export default function arraySortPositions(item: string, isReverse?: boolean): (a:
|
|
16
|
+
export default function arraySortPositions(item: string, isReverse?: boolean): (a: any, b: any) => number;
|
|
17
17
|
//# sourceMappingURL=arraySortPositions.d.mts.map
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
/**
|
|
3
2
|
* Generates a comparator function to sort an array of objects by a given key.
|
|
4
3
|
*
|
|
5
4
|
* @param {string} item - The object key to sort by.
|
|
6
5
|
* @param {boolean} [isReverse=false] - If `true`, the sorting will be in descending order.
|
|
7
|
-
* @returns {(a: Object, b: Object) => number} Comparator function compatible with Array.prototype.sort().
|
|
6
|
+
* @returns {(a: Object<string|number, *>, b: Object<string|number, *>) => number} Comparator function compatible with Array.prototype.sort().
|
|
8
7
|
*
|
|
9
8
|
* @example
|
|
10
9
|
* const arr = [{ pos: 2 }, { pos: 1 }, { pos: 3 }];
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
// @ts-nocheck
|
|
4
|
-
|
|
5
3
|
/**
|
|
6
4
|
* A utility module to convert between bytes and higher order units (KB, MB, GB, etc).
|
|
7
5
|
*/
|
|
@@ -32,7 +30,7 @@ const convertBytes = {
|
|
|
32
30
|
|
|
33
31
|
/**
|
|
34
32
|
* Ordered list of size units.
|
|
35
|
-
* @type {
|
|
33
|
+
* @type {string[]}
|
|
36
34
|
*/
|
|
37
35
|
sequence: sequence,
|
|
38
36
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
/**
|
|
3
2
|
* A utility module to convert between bytes and higher order units (KB, MB, GB, etc).
|
|
4
3
|
*/
|
|
@@ -25,7 +24,7 @@ const convertBytes = {
|
|
|
25
24
|
list: convertList,
|
|
26
25
|
/**
|
|
27
26
|
* Ordered list of size units.
|
|
28
|
-
* @type {
|
|
27
|
+
* @type {string[]}
|
|
29
28
|
*/
|
|
30
29
|
sequence: sequence,
|
|
31
30
|
/**
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
// @ts-nocheck
|
|
6
|
-
|
|
3
|
+
var objFilter = require('../../v1/basics/objFilter.cjs');
|
|
7
4
|
|
|
8
5
|
/**
|
|
9
6
|
* A custom module manager to validate and run hooks on external modules dynamically.
|
|
@@ -34,7 +31,7 @@ const custom_module_manager = {
|
|
|
34
31
|
* Executes all functions inside the given modules.
|
|
35
32
|
* Accepts either an array of functions or an object with typed module arrays.
|
|
36
33
|
*
|
|
37
|
-
* @param {
|
|
34
|
+
* @param {Record<string, function>|function[]} custom_modules - The modules or functions to run.
|
|
38
35
|
* @param {*} db_prepare - A value to pass to each module when called.
|
|
39
36
|
* @param {string} hookType - A string representing the hook (e.g., 'before', 'after').
|
|
40
37
|
* @param {Record<string, any>} [options] - Optional. Object with keys matching types in `custom_modules`.
|
|
@@ -45,11 +42,18 @@ const custom_module_manager = {
|
|
|
45
42
|
* await custom_module_manager.run(customModules, db, 'after', { paypal: true });
|
|
46
43
|
*/
|
|
47
44
|
run: async function (custom_modules, db_prepare, hookType, options) {
|
|
45
|
+
/**
|
|
46
|
+
* @async
|
|
47
|
+
* @param {string} [type]
|
|
48
|
+
*/
|
|
48
49
|
const run_custom_module = async function (type) {
|
|
49
50
|
let module_list = null;
|
|
50
51
|
|
|
51
|
-
if (type) {
|
|
52
|
-
|
|
52
|
+
if (typeof type === 'string') {
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
if (custom_modules && typeof custom_modules[type] === 'function')
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
module_list = custom_modules[type];
|
|
53
57
|
} else module_list = custom_modules;
|
|
54
58
|
|
|
55
59
|
if (Array.isArray(module_list)) {
|
|
@@ -59,7 +63,6 @@ const custom_module_manager = {
|
|
|
59
63
|
await module_list[item](db_prepare, hookType);
|
|
60
64
|
} catch (err) {
|
|
61
65
|
console.error(err);
|
|
62
|
-
console.error(err.message);
|
|
63
66
|
}
|
|
64
67
|
} else {
|
|
65
68
|
const err = new Error(
|
|
@@ -72,8 +75,9 @@ const custom_module_manager = {
|
|
|
72
75
|
}
|
|
73
76
|
};
|
|
74
77
|
|
|
75
|
-
if (objType(options, 'object')) {
|
|
78
|
+
if (objFilter.objType(options, 'object')) {
|
|
76
79
|
for (const item in options) {
|
|
80
|
+
// @ts-ignore
|
|
77
81
|
if (options[item] && Array.isArray(custom_modules[item])) await run_custom_module(item);
|
|
78
82
|
}
|
|
79
83
|
} else {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default custom_module_manager;
|
|
2
2
|
declare namespace custom_module_manager {
|
|
3
3
|
function validator(custom_modules: Record<string, any>, type: string): boolean;
|
|
4
|
-
function run(custom_modules:
|
|
4
|
+
function run(custom_modules: Record<string, Function> | Function[], db_prepare: any, hookType: string, options?: Record<string, any>): Promise<void>;
|
|
5
5
|
}
|
|
6
6
|
//# sourceMappingURL=custom_module_loader.d.mts.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import objType from '../get/objType.mjs';
|
|
3
2
|
/**
|
|
4
3
|
* A custom module manager to validate and run hooks on external modules dynamically.
|
|
@@ -27,7 +26,7 @@ const custom_module_manager = {
|
|
|
27
26
|
* Executes all functions inside the given modules.
|
|
28
27
|
* Accepts either an array of functions or an object with typed module arrays.
|
|
29
28
|
*
|
|
30
|
-
* @param {
|
|
29
|
+
* @param {Record<string, function>|function[]} custom_modules - The modules or functions to run.
|
|
31
30
|
* @param {*} db_prepare - A value to pass to each module when called.
|
|
32
31
|
* @param {string} hookType - A string representing the hook (e.g., 'before', 'after').
|
|
33
32
|
* @param {Record<string, any>} [options] - Optional. Object with keys matching types in `custom_modules`.
|
|
@@ -38,10 +37,16 @@ const custom_module_manager = {
|
|
|
38
37
|
* await custom_module_manager.run(customModules, db, 'after', { paypal: true });
|
|
39
38
|
*/
|
|
40
39
|
run: async function (custom_modules, db_prepare, hookType, options) {
|
|
40
|
+
/**
|
|
41
|
+
* @async
|
|
42
|
+
* @param {string} [type]
|
|
43
|
+
*/
|
|
41
44
|
const run_custom_module = async function (type) {
|
|
42
45
|
let module_list = null;
|
|
43
|
-
if (type) {
|
|
44
|
-
|
|
46
|
+
if (typeof type === 'string') {
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
if (custom_modules && typeof custom_modules[type] === 'function')
|
|
49
|
+
// @ts-ignore
|
|
45
50
|
module_list = custom_modules[type];
|
|
46
51
|
}
|
|
47
52
|
else
|
|
@@ -54,7 +59,6 @@ const custom_module_manager = {
|
|
|
54
59
|
}
|
|
55
60
|
catch (err) {
|
|
56
61
|
console.error(err);
|
|
57
|
-
console.error(err.message);
|
|
58
62
|
}
|
|
59
63
|
}
|
|
60
64
|
else {
|
|
@@ -67,6 +71,7 @@ const custom_module_manager = {
|
|
|
67
71
|
};
|
|
68
72
|
if (objType(options, 'object')) {
|
|
69
73
|
for (const item in options) {
|
|
74
|
+
// @ts-ignore
|
|
70
75
|
if (options[item] && Array.isArray(custom_modules[item]))
|
|
71
76
|
await run_custom_module(item);
|
|
72
77
|
}
|
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
// @ts-nocheck
|
|
4
|
-
|
|
5
3
|
/**
|
|
6
4
|
* A lightweight Markdown parser that can convert to HTML or BBCode.
|
|
7
5
|
* @namespace markdownManager
|
|
8
6
|
*/
|
|
9
7
|
const markdownManager = {
|
|
10
8
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* A dictionary of Markdown element conversion rules.
|
|
10
|
+
*
|
|
11
|
+
* Each key represents a Markdown syntax identifier (like `h1`, `strong`, `image`, etc.),
|
|
12
|
+
* and its value contains the regular expression used to match the Markdown element,
|
|
13
|
+
* along with its HTML and BBCode equivalents.
|
|
14
|
+
*
|
|
15
|
+
* @type {{
|
|
16
|
+
* [key: string]: {
|
|
17
|
+
* regex: RegExp, // The regex pattern used to identify the Markdown syntax.
|
|
18
|
+
* result: string, // The HTML output replacement string, using capture groups.
|
|
19
|
+
* bbcode: string // The BBCode equivalent of the Markdown syntax.
|
|
20
|
+
* }
|
|
21
|
+
* }}
|
|
13
22
|
*/
|
|
14
23
|
values: {
|
|
15
24
|
h3: {
|
|
@@ -1,76 +1,12 @@
|
|
|
1
1
|
export default markdownManager;
|
|
2
2
|
declare namespace markdownManager {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
let regex_1: RegExp;
|
|
11
|
-
export { regex_1 as regex };
|
|
12
|
-
let result_1: string;
|
|
13
|
-
export { result_1 as result };
|
|
14
|
-
let bbcode_1: string;
|
|
15
|
-
export { bbcode_1 as bbcode };
|
|
16
|
-
}
|
|
17
|
-
namespace h1 {
|
|
18
|
-
let regex_2: RegExp;
|
|
19
|
-
export { regex_2 as regex };
|
|
20
|
-
let result_2: string;
|
|
21
|
-
export { result_2 as result };
|
|
22
|
-
let bbcode_2: string;
|
|
23
|
-
export { bbcode_2 as bbcode };
|
|
24
|
-
}
|
|
25
|
-
namespace blockquote {
|
|
26
|
-
let regex_3: RegExp;
|
|
27
|
-
export { regex_3 as regex };
|
|
28
|
-
let result_3: string;
|
|
29
|
-
export { result_3 as result };
|
|
30
|
-
let bbcode_3: string;
|
|
31
|
-
export { bbcode_3 as bbcode };
|
|
32
|
-
}
|
|
33
|
-
namespace strong {
|
|
34
|
-
let regex_4: RegExp;
|
|
35
|
-
export { regex_4 as regex };
|
|
36
|
-
let result_4: string;
|
|
37
|
-
export { result_4 as result };
|
|
38
|
-
let bbcode_4: string;
|
|
39
|
-
export { bbcode_4 as bbcode };
|
|
40
|
-
}
|
|
41
|
-
namespace italic {
|
|
42
|
-
let regex_5: RegExp;
|
|
43
|
-
export { regex_5 as regex };
|
|
44
|
-
let result_5: string;
|
|
45
|
-
export { result_5 as result };
|
|
46
|
-
let bbcode_5: string;
|
|
47
|
-
export { bbcode_5 as bbcode };
|
|
48
|
-
}
|
|
49
|
-
namespace image {
|
|
50
|
-
let regex_6: RegExp;
|
|
51
|
-
export { regex_6 as regex };
|
|
52
|
-
let result_6: string;
|
|
53
|
-
export { result_6 as result };
|
|
54
|
-
let bbcode_6: string;
|
|
55
|
-
export { bbcode_6 as bbcode };
|
|
56
|
-
}
|
|
57
|
-
namespace url {
|
|
58
|
-
let regex_7: RegExp;
|
|
59
|
-
export { regex_7 as regex };
|
|
60
|
-
let result_7: string;
|
|
61
|
-
export { result_7 as result };
|
|
62
|
-
let bbcode_7: string;
|
|
63
|
-
export { bbcode_7 as bbcode };
|
|
64
|
-
}
|
|
65
|
-
namespace br {
|
|
66
|
-
let regex_8: RegExp;
|
|
67
|
-
export { regex_8 as regex };
|
|
68
|
-
let result_8: string;
|
|
69
|
-
export { result_8 as result };
|
|
70
|
-
let bbcode_8: string;
|
|
71
|
-
export { bbcode_8 as bbcode };
|
|
72
|
-
}
|
|
73
|
-
}
|
|
3
|
+
let values: {
|
|
4
|
+
[key: string]: {
|
|
5
|
+
regex: RegExp;
|
|
6
|
+
result: string;
|
|
7
|
+
bbcode: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
74
10
|
function parseMarkdown(markdownText: string, type?: "result" | "bbcode"): string;
|
|
75
11
|
}
|
|
76
12
|
//# sourceMappingURL=markdown.d.mts.map
|
|
@@ -1,12 +1,22 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
/**
|
|
3
2
|
* A lightweight Markdown parser that can convert to HTML or BBCode.
|
|
4
3
|
* @namespace markdownManager
|
|
5
4
|
*/
|
|
6
5
|
const markdownManager = {
|
|
7
6
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* A dictionary of Markdown element conversion rules.
|
|
8
|
+
*
|
|
9
|
+
* Each key represents a Markdown syntax identifier (like `h1`, `strong`, `image`, etc.),
|
|
10
|
+
* and its value contains the regular expression used to match the Markdown element,
|
|
11
|
+
* along with its HTML and BBCode equivalents.
|
|
12
|
+
*
|
|
13
|
+
* @type {{
|
|
14
|
+
* [key: string]: {
|
|
15
|
+
* regex: RegExp, // The regex pattern used to identify the Markdown syntax.
|
|
16
|
+
* result: string, // The HTML output replacement string, using capture groups.
|
|
17
|
+
* bbcode: string // The BBCode equivalent of the Markdown syntax.
|
|
18
|
+
* }
|
|
19
|
+
* }}
|
|
10
20
|
*/
|
|
11
21
|
values: {
|
|
12
22
|
h3: {
|