nextemos 6.2.1 → 6.3.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/dist/helpers/getConfigs.d.ts +0 -4
- package/dist/helpers/getConfigs.js +0 -4
- package/dist/helpers/index.d.ts +0 -4
- package/dist/helpers/index.js +1 -9
- package/package.json +2 -4
- package/dist/helpers/cdn.d.ts +0 -21
- package/dist/helpers/cdn.js +0 -104
- package/dist/helpers/decodeHTML.d.ts +0 -2
- package/dist/helpers/decodeHTML.js +0 -11
- package/dist/helpers/toIntArray.d.ts +0 -12
- package/dist/helpers/toIntArray.js +0 -20
- package/dist/helpers/toQueryString.d.ts +0 -8
- package/dist/helpers/toQueryString.js +0 -21
package/dist/helpers/index.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
1
|
export { default as fetchRequest } from './fetchRequest';
|
|
2
|
-
export { default as toIntArray } from './toIntArray';
|
|
3
|
-
export { default as toQueryString } from './toQueryString';
|
|
4
|
-
export { default as cdn } from './cdn';
|
|
5
|
-
export { default as decodeHTML } from './decodeHTML';
|
|
6
2
|
export { default as NEXTEMOS_CONFIG } from './getConfigs';
|
package/dist/helpers/index.js
CHANGED
|
@@ -3,17 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.NEXTEMOS_CONFIG = exports.
|
|
6
|
+
exports.NEXTEMOS_CONFIG = exports.fetchRequest = void 0;
|
|
7
7
|
/// helpers
|
|
8
8
|
var fetchRequest_1 = require("./fetchRequest");
|
|
9
9
|
Object.defineProperty(exports, "fetchRequest", { enumerable: true, get: function () { return __importDefault(fetchRequest_1).default; } });
|
|
10
|
-
var toIntArray_1 = require("./toIntArray");
|
|
11
|
-
Object.defineProperty(exports, "toIntArray", { enumerable: true, get: function () { return __importDefault(toIntArray_1).default; } });
|
|
12
|
-
var toQueryString_1 = require("./toQueryString");
|
|
13
|
-
Object.defineProperty(exports, "toQueryString", { enumerable: true, get: function () { return __importDefault(toQueryString_1).default; } });
|
|
14
|
-
var cdn_1 = require("./cdn");
|
|
15
|
-
Object.defineProperty(exports, "cdn", { enumerable: true, get: function () { return __importDefault(cdn_1).default; } });
|
|
16
|
-
var decodeHTML_1 = require("./decodeHTML");
|
|
17
|
-
Object.defineProperty(exports, "decodeHTML", { enumerable: true, get: function () { return __importDefault(decodeHTML_1).default; } });
|
|
18
10
|
var getConfigs_1 = require("./getConfigs");
|
|
19
11
|
Object.defineProperty(exports, "NEXTEMOS_CONFIG", { enumerable: true, get: function () { return __importDefault(getConfigs_1).default; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nextemos",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.3.0",
|
|
4
4
|
"description": "For helpers and hooks used in NextJS projects",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -32,7 +32,5 @@
|
|
|
32
32
|
"typescript",
|
|
33
33
|
"nextemos"
|
|
34
34
|
],
|
|
35
|
-
"dependencies": {
|
|
36
|
-
"html-entities": "^2.5.2"
|
|
37
|
-
}
|
|
35
|
+
"dependencies": {}
|
|
38
36
|
}
|
package/dist/helpers/cdn.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
interface IThumbImage {
|
|
2
|
-
width: number;
|
|
3
|
-
height?: number;
|
|
4
|
-
path: string;
|
|
5
|
-
quality?: number;
|
|
6
|
-
format?: string;
|
|
7
|
-
options?: {
|
|
8
|
-
service?: string;
|
|
9
|
-
backColor?: string;
|
|
10
|
-
quality?: number;
|
|
11
|
-
customOptions?: string;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
declare const cdn: {
|
|
15
|
-
url: string;
|
|
16
|
-
videoUrl: string;
|
|
17
|
-
thumbImage: (props: IThumbImage) => string;
|
|
18
|
-
getFile: (path?: string) => string;
|
|
19
|
-
getVideo: (path?: string) => string;
|
|
20
|
-
};
|
|
21
|
-
export default cdn;
|
package/dist/helpers/cdn.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const html_entities_1 = require("html-entities");
|
|
7
|
-
const getConfigs_1 = __importDefault(require("./getConfigs"));
|
|
8
|
-
const { CDN_URL, VIDEO_CDN_URL, CDN_PROVIDER, THUMBOR_SOURCE } = getConfigs_1.default;
|
|
9
|
-
// CDN işlemleri için kullanılan nesne
|
|
10
|
-
const cdn = {
|
|
11
|
-
// CDN URL'sini döndüren özellik
|
|
12
|
-
url: CDN_URL,
|
|
13
|
-
// Video CDN URL'sini döndüren özellik
|
|
14
|
-
videoUrl: VIDEO_CDN_URL,
|
|
15
|
-
// Thumbnail URL'si oluşturan fonksiyon
|
|
16
|
-
thumbImage: function (props) {
|
|
17
|
-
switch (CDN_PROVIDER // CDN sağlayıcısına göre işlemci fonksiyonunu seçiyor
|
|
18
|
-
) {
|
|
19
|
-
case "huawei":
|
|
20
|
-
return huaweiImageProcessor(props); // Huawei işlemcisi kullanılıyor
|
|
21
|
-
case "medianova":
|
|
22
|
-
return medianovaImageProcessor(props); // Medianova işlemcisi kullanılıyor
|
|
23
|
-
default:
|
|
24
|
-
return thumborImageProcessor(props); // Varsayılan olarak Thumbor işlemcisi kullanılıyor
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
// CDN'deki dosyayı linkini getiren fonksiyon
|
|
28
|
-
getFile: function (path = "") {
|
|
29
|
-
return `${this.url}/${encodeURI((0, html_entities_1.decode)(path))}`;
|
|
30
|
-
},
|
|
31
|
-
// CDN'deki video url'ini getiren fonksiyon
|
|
32
|
-
getVideo: function (path = "") {
|
|
33
|
-
return `${this.videoUrl}/${encodeURI((0, html_entities_1.decode)(path))}`;
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
// Değerin geçerli olup olmadığını kontrol eden ve string olarak döndüren yardımcı fonksiyon
|
|
37
|
-
const getValueOrDefault = (value) => !value || value <= 0 ? "-" : value.toString(); // Geçerli değilse "-" döner, aksi halde değeri string olarak döner
|
|
38
|
-
// Huawei CDN sağlayıcısı için thumbnail URL'si oluşturan fonksiyon
|
|
39
|
-
const huaweiImageProcessor = (props) => {
|
|
40
|
-
var _a, _b, _c, _d, _e, _f;
|
|
41
|
-
// Varsayılan servis türü "mnresize" olarak ayarlanıyor
|
|
42
|
-
let service = "mnresize";
|
|
43
|
-
// Varsayılan genişlik ve yükseklik 0 olarak atanıyor
|
|
44
|
-
const width = (_a = props.width) !== null && _a !== void 0 ? _a : 0;
|
|
45
|
-
const height = (_b = props.height) !== null && _b !== void 0 ? _b : 0;
|
|
46
|
-
// Eğer props içinde servis belirtilmişse, o servis kullanılıyor
|
|
47
|
-
if ((_c = props.options) === null || _c === void 0 ? void 0 : _c.service)
|
|
48
|
-
service = (_d = props.options) === null || _d === void 0 ? void 0 : _d.service;
|
|
49
|
-
// Thumbnail URL'si oluşturmak için bir dizi başlatılıyor
|
|
50
|
-
const thumbUrl = new Array();
|
|
51
|
-
thumbUrl.push(CDN_URL); // CDN URL'si ekleniyor
|
|
52
|
-
thumbUrl.push(service); // Seçilen servis türü ekleniyor
|
|
53
|
-
thumbUrl.push(getValueOrDefault(width)); // Genişlik ekleniyor
|
|
54
|
-
thumbUrl.push(getValueOrDefault(height)); // Yükseklik ekleniyor
|
|
55
|
-
// Eğer arka plan rengi belirtilmişse, o da ekleniyor
|
|
56
|
-
if ((_e = props.options) === null || _e === void 0 ? void 0 : _e.backColor)
|
|
57
|
-
thumbUrl.push((_f = props.options) === null || _f === void 0 ? void 0 : _f.backColor);
|
|
58
|
-
// Görüntü yolu ekleniyor
|
|
59
|
-
thumbUrl.push(encodeURI((0, html_entities_1.decode)(props.path)));
|
|
60
|
-
// Sonuç olarak oluşturulan URL döndürülüyor
|
|
61
|
-
return thumbUrl.join("/");
|
|
62
|
-
};
|
|
63
|
-
// Medianova CDN sağlayıcısı için thumbnail URL'si oluşturan fonksiyon
|
|
64
|
-
const medianovaImageProcessor = (props) => {
|
|
65
|
-
// Şu an için Huawei işlemcisi ile aynı işlevi görüyor
|
|
66
|
-
return huaweiImageProcessor(props);
|
|
67
|
-
};
|
|
68
|
-
// Thumbor CDN sağlayıcısı için thumbnail URL'si oluşturan fonksiyon
|
|
69
|
-
const thumborImageProcessor = (props) => {
|
|
70
|
-
var _a, _b, _c, _d, _e, _f;
|
|
71
|
-
// Varsayılan hash değeri "unsafe" olarak ayarlanıyor
|
|
72
|
-
let hash = "unsafe";
|
|
73
|
-
// Varsayılan genişlik ve yükseklik 0 olarak atanıyor
|
|
74
|
-
const width = (_a = props.width) !== null && _a !== void 0 ? _a : 0;
|
|
75
|
-
const height = (_b = props.height) !== null && _b !== void 0 ? _b : 0;
|
|
76
|
-
// Thumbnail URL'si oluşturmak için bir dizi başlatılıyor
|
|
77
|
-
const thumbUrl = new Array();
|
|
78
|
-
thumbUrl.push(CDN_URL); // CDN URL'si ekleniyor
|
|
79
|
-
thumbUrl.push(hash); // Hash ekleniyor
|
|
80
|
-
// Genişlik veya yükseklik tanımlıysa, boyutlar ekleniyor
|
|
81
|
-
if (width > 0 || height > 0)
|
|
82
|
-
thumbUrl.push(`${props.width}x${props.height}`);
|
|
83
|
-
// Filtreler için bir dizi başlatılıyor
|
|
84
|
-
const filters = new Array();
|
|
85
|
-
// Kalite tanımlıysa ve 0'dan büyükse, kalite filtresi ekleniyor
|
|
86
|
-
if (((_c = props.options) === null || _c === void 0 ? void 0 : _c.quality) && ((_d = props.options) === null || _d === void 0 ? void 0 : _d.quality) > 0)
|
|
87
|
-
filters.push(`:quality(${props.options.quality})`);
|
|
88
|
-
// Arka plan rengi tanımlıysa, arka plan rengi filtresi ekleniyor
|
|
89
|
-
if ((_e = props.options) === null || _e === void 0 ? void 0 : _e.backColor)
|
|
90
|
-
filters.push(`:background_color(${props.options.backColor})`);
|
|
91
|
-
// Özelleştirilmiş diğer seçenekler tanımlıysa, onlar da ekleniyor
|
|
92
|
-
if ((_f = props.options) === null || _f === void 0 ? void 0 : _f.customOptions)
|
|
93
|
-
filters.push(`:(${props.options.customOptions})`);
|
|
94
|
-
// Filtreler birleştirilerek URL'ye ekleniyor
|
|
95
|
-
thumbUrl.push(filters.join(""));
|
|
96
|
-
// Ortam değişkeninden Thumbor kaynağı alınıyor, eğer tanımlıysa URL'ye ekleniyor
|
|
97
|
-
if (THUMBOR_SOURCE)
|
|
98
|
-
thumbUrl.push(THUMBOR_SOURCE);
|
|
99
|
-
// Görüntü yolu ekleniyor
|
|
100
|
-
thumbUrl.push(encodeURI((0, html_entities_1.decode)(props.path)));
|
|
101
|
-
// Sonuç olarak oluşturulan URL döndürülüyor
|
|
102
|
-
return thumbUrl.join("/");
|
|
103
|
-
};
|
|
104
|
-
exports.default = cdn;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const html_entities_1 = require("html-entities");
|
|
4
|
-
const decodeHTML = (html) => {
|
|
5
|
-
return isHTML(html) ? html : (0, html_entities_1.decode)(html);
|
|
6
|
-
};
|
|
7
|
-
const isHTML = (string) => {
|
|
8
|
-
const htmlPattern = /<\/?[a-z][\s\S]*>/i;
|
|
9
|
-
return htmlPattern.test(string);
|
|
10
|
-
};
|
|
11
|
-
exports.default = decodeHTML;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* toIntArray Function
|
|
3
|
-
*
|
|
4
|
-
* @description
|
|
5
|
-
* A function that converts a string of numbers separated by a specified separator into an array of integers.
|
|
6
|
-
*
|
|
7
|
-
* @param {string} str - The input string containing numbers separated by the specified separator.
|
|
8
|
-
* @param {string} [separator=','] - The separator used to split the input string. Default is ','.
|
|
9
|
-
* @returns {Array} An array of integers extracted from the input string.
|
|
10
|
-
*/
|
|
11
|
-
declare function toIntArray(str: string, separator?: string): number[];
|
|
12
|
-
export default toIntArray;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* toIntArray Function
|
|
5
|
-
*
|
|
6
|
-
* @description
|
|
7
|
-
* A function that converts a string of numbers separated by a specified separator into an array of integers.
|
|
8
|
-
*
|
|
9
|
-
* @param {string} str - The input string containing numbers separated by the specified separator.
|
|
10
|
-
* @param {string} [separator=','] - The separator used to split the input string. Default is ','.
|
|
11
|
-
* @returns {Array} An array of integers extracted from the input string.
|
|
12
|
-
*/
|
|
13
|
-
function toIntArray(str, separator = ',') {
|
|
14
|
-
// Split the input string using the specified separator
|
|
15
|
-
const numbers = str.split(separator);
|
|
16
|
-
// Convert the array of strings to an array of integers
|
|
17
|
-
const intArray = numbers.map((num) => parseInt(num, 10));
|
|
18
|
-
return intArray;
|
|
19
|
-
}
|
|
20
|
-
exports.default = toIntArray;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Converts a given object into a query string format.
|
|
3
|
-
*
|
|
4
|
-
* @param obj - The object to be converted into a query string.
|
|
5
|
-
* @returns {string} - The query string representation of the object.
|
|
6
|
-
*/
|
|
7
|
-
declare const toQueryString: (obj: Record<string, any>) => string;
|
|
8
|
-
export default toQueryString;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Converts a given object into a query string format.
|
|
5
|
-
*
|
|
6
|
-
* @param obj - The object to be converted into a query string.
|
|
7
|
-
* @returns {string} - The query string representation of the object.
|
|
8
|
-
*/
|
|
9
|
-
const toQueryString = (obj) => {
|
|
10
|
-
if (Object.keys(obj).length === 0)
|
|
11
|
-
return '';
|
|
12
|
-
const queryString = [];
|
|
13
|
-
for (const key in obj) {
|
|
14
|
-
if (obj.hasOwnProperty(key)) {
|
|
15
|
-
const value = encodeURIComponent(obj[key]);
|
|
16
|
-
queryString.push(`${encodeURIComponent(key)}=${value}`);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return queryString.join('&');
|
|
20
|
-
};
|
|
21
|
-
exports.default = toQueryString;
|