nextemos 3.6.5 → 3.7.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/cdn.d.ts +18 -0
- package/dist/helpers/cdn.js +92 -0
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.js +3 -1
- package/package.json +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
thumbImage: (props: IThumbImage) => string;
|
|
17
|
+
};
|
|
18
|
+
export default cdn;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// Ortam değişkenlerinden CDN URL'si alınıyor, tanımlı değilse varsayılan olarak 'https://images.proj-e.com' kullanılıyor
|
|
4
|
+
const CDN_URL = process.env.CDN_URL || 'https://images.proj-e.com';
|
|
5
|
+
// Ortam değişkenlerinden CDN sağlayıcısı alınıyor
|
|
6
|
+
const CDN_PROVIDER = process.env.CDN_PROVIDER;
|
|
7
|
+
// CDN işlemleri için kullanılan nesne
|
|
8
|
+
const cdn = {
|
|
9
|
+
// CDN URL'sini döndüren özellik
|
|
10
|
+
url: CDN_URL,
|
|
11
|
+
// Thumbnail URL'si oluşturan fonksiyon
|
|
12
|
+
thumbImage: function (props) {
|
|
13
|
+
switch (CDN_PROVIDER) { // CDN sağlayıcısına göre işlemci fonksiyonunu seçiyor
|
|
14
|
+
case 'huawei':
|
|
15
|
+
return huaweiImageProcessor(props); // Huawei işlemcisi kullanılıyor
|
|
16
|
+
case 'medianova':
|
|
17
|
+
return medianovaImageProcessor(props); // Medianova işlemcisi kullanılıyor
|
|
18
|
+
default:
|
|
19
|
+
return thumborImageProcessor(props); // Varsayılan olarak Thumbor işlemcisi kullanılıyor
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
// Değerin geçerli olup olmadığını kontrol eden ve string olarak döndüren yardımcı fonksiyon
|
|
24
|
+
const getValueOrDefault = (value) => (!value || value <= 0) ? "-" : value.toString(); // Geçerli değilse "-" döner, aksi halde değeri string olarak döner
|
|
25
|
+
// Huawei CDN sağlayıcısı için thumbnail URL'si oluşturan fonksiyon
|
|
26
|
+
const huaweiImageProcessor = (props) => {
|
|
27
|
+
var _a, _b, _c, _d, _e, _f;
|
|
28
|
+
// Varsayılan servis türü "mnresize" olarak ayarlanıyor
|
|
29
|
+
let service = "mnresize";
|
|
30
|
+
// Varsayılan genişlik ve yükseklik 0 olarak atanıyor
|
|
31
|
+
const width = (_a = props.width) !== null && _a !== void 0 ? _a : 0;
|
|
32
|
+
const height = (_b = props.height) !== null && _b !== void 0 ? _b : 0;
|
|
33
|
+
// Eğer props içinde servis belirtilmişse, o servis kullanılıyor
|
|
34
|
+
if ((_c = props.options) === null || _c === void 0 ? void 0 : _c.service)
|
|
35
|
+
service = (_d = props.options) === null || _d === void 0 ? void 0 : _d.service;
|
|
36
|
+
// Thumbnail URL'si oluşturmak için bir dizi başlatılıyor
|
|
37
|
+
const thumbUrl = new Array();
|
|
38
|
+
thumbUrl.push(CDN_URL); // CDN URL'si ekleniyor
|
|
39
|
+
thumbUrl.push(service); // Seçilen servis türü ekleniyor
|
|
40
|
+
thumbUrl.push(getValueOrDefault(width)); // Genişlik ekleniyor
|
|
41
|
+
thumbUrl.push(getValueOrDefault(height)); // Yükseklik ekleniyor
|
|
42
|
+
// Eğer arka plan rengi belirtilmişse, o da ekleniyor
|
|
43
|
+
if ((_e = props.options) === null || _e === void 0 ? void 0 : _e.backColor)
|
|
44
|
+
thumbUrl.push((_f = props.options) === null || _f === void 0 ? void 0 : _f.backColor);
|
|
45
|
+
// Görüntü yolu ekleniyor
|
|
46
|
+
thumbUrl.push(props.path);
|
|
47
|
+
// Sonuç olarak oluşturulan URL döndürülüyor
|
|
48
|
+
return thumbUrl.join('/');
|
|
49
|
+
};
|
|
50
|
+
// Medianova CDN sağlayıcısı için thumbnail URL'si oluşturan fonksiyon
|
|
51
|
+
const medianovaImageProcessor = (props) => {
|
|
52
|
+
// Şu an için Huawei işlemcisi ile aynı işlevi görüyor
|
|
53
|
+
return huaweiImageProcessor(props);
|
|
54
|
+
};
|
|
55
|
+
// Thumbor CDN sağlayıcısı için thumbnail URL'si oluşturan fonksiyon
|
|
56
|
+
const thumborImageProcessor = (props) => {
|
|
57
|
+
var _a, _b, _c, _d, _e, _f;
|
|
58
|
+
// Varsayılan hash değeri "unsafe" olarak ayarlanıyor
|
|
59
|
+
let hash = "unsafe";
|
|
60
|
+
// Varsayılan genişlik ve yükseklik 0 olarak atanıyor
|
|
61
|
+
const width = (_a = props.width) !== null && _a !== void 0 ? _a : 0;
|
|
62
|
+
const height = (_b = props.height) !== null && _b !== void 0 ? _b : 0;
|
|
63
|
+
// Thumbnail URL'si oluşturmak için bir dizi başlatılıyor
|
|
64
|
+
const thumbUrl = new Array();
|
|
65
|
+
thumbUrl.push(CDN_URL); // CDN URL'si ekleniyor
|
|
66
|
+
thumbUrl.push(hash); // Hash ekleniyor
|
|
67
|
+
// Genişlik veya yükseklik tanımlıysa, boyutlar ekleniyor
|
|
68
|
+
if (width > 0 || height > 0)
|
|
69
|
+
thumbUrl.push(`${props.width}x${props.height}`);
|
|
70
|
+
// Filtreler için bir dizi başlatılıyor
|
|
71
|
+
const filters = new Array();
|
|
72
|
+
// Kalite tanımlıysa ve 0'dan büyükse, kalite filtresi ekleniyor
|
|
73
|
+
if (((_c = props.options) === null || _c === void 0 ? void 0 : _c.quality) && ((_d = props.options) === null || _d === void 0 ? void 0 : _d.quality) > 0)
|
|
74
|
+
filters.push(`:quality(${props.options.quality})`);
|
|
75
|
+
// Arka plan rengi tanımlıysa, arka plan rengi filtresi ekleniyor
|
|
76
|
+
if ((_e = props.options) === null || _e === void 0 ? void 0 : _e.backColor)
|
|
77
|
+
filters.push(`:background_color(${props.options.backColor})`);
|
|
78
|
+
// Özelleştirilmiş diğer seçenekler tanımlıysa, onlar da ekleniyor
|
|
79
|
+
if ((_f = props.options) === null || _f === void 0 ? void 0 : _f.customOptions)
|
|
80
|
+
filters.push(`:(${props.options.customOptions})`);
|
|
81
|
+
// Filtreler birleştirilerek URL'ye ekleniyor
|
|
82
|
+
thumbUrl.push(filters.join(''));
|
|
83
|
+
// Ortam değişkeninden Thumbor kaynağı alınıyor, eğer tanımlıysa URL'ye ekleniyor
|
|
84
|
+
const source = process.env.THUMBOR_SOURCE || '';
|
|
85
|
+
if (source)
|
|
86
|
+
thumbUrl.push(source);
|
|
87
|
+
// Görüntü yolu ekleniyor
|
|
88
|
+
thumbUrl.push(props.path);
|
|
89
|
+
// Sonuç olarak oluşturulan URL döndürülüyor
|
|
90
|
+
return thumbUrl.join('/');
|
|
91
|
+
};
|
|
92
|
+
exports.default = cdn;
|
package/dist/helpers/index.d.ts
CHANGED
package/dist/helpers/index.js
CHANGED
|
@@ -3,7 +3,7 @@ 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.toQueryString = exports.toIntArray = exports.fetchRequest = void 0;
|
|
6
|
+
exports.cdn = exports.toQueryString = exports.toIntArray = 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; } });
|
|
@@ -11,3 +11,5 @@ var toIntArray_1 = require("./toIntArray");
|
|
|
11
11
|
Object.defineProperty(exports, "toIntArray", { enumerable: true, get: function () { return __importDefault(toIntArray_1).default; } });
|
|
12
12
|
var toQueryString_1 = require("./toQueryString");
|
|
13
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; } });
|