@stemy/ngx-utils 11.0.7 → 11.0.11
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/bundles/stemy-ngx-utils.umd.js +41 -19
- package/bundles/stemy-ngx-utils.umd.js.map +1 -1
- package/bundles/stemy-ngx-utils.umd.min.js +1 -1
- package/bundles/stemy-ngx-utils.umd.min.js.map +1 -1
- package/esm2015/ngx-utils/common-types.js +2 -1
- package/esm2015/ngx-utils/ngx-utils.module.js +6 -2
- package/esm2015/ngx-utils/services/base-http.service.js +11 -6
- package/esm2015/ngx-utils/services/config.service.js +7 -4
- package/esm2015/ngx-utils/services/promise.service.js +4 -1
- package/esm2015/ngx-utils/services/static-language.service.js +19 -13
- package/esm2015/public_api.js +2 -2
- package/fesm2015/stemy-ngx-utils.js +41 -19
- package/fesm2015/stemy-ngx-utils.js.map +1 -1
- package/ngx-utils/common-types.d.ts +3 -0
- package/ngx-utils/services/base-http.service.d.ts +5 -2
- package/ngx-utils/services/config.service.d.ts +3 -1
- package/ngx-utils/services/promise.service.d.ts +5 -4
- package/ngx-utils/services/static-language.service.d.ts +4 -2
- package/package.json +1 -1
- package/public_api.d.ts +1 -1
- package/stemy-ngx-utils.metadata.json +1 -1
|
@@ -780,6 +780,7 @@
|
|
|
780
780
|
var CONFIG_SERVICE = new core.InjectionToken("config-service");
|
|
781
781
|
var BASE_CONFIG = new core.InjectionToken("base-config");
|
|
782
782
|
var SCRIPT_PARAMS = new core.InjectionToken("script-params");
|
|
783
|
+
var ROOT_ELEMENT = new core.InjectionToken("app-root-element");
|
|
783
784
|
var ERROR_HANDLER = new core.InjectionToken("error-handler-callback");
|
|
784
785
|
// --- Valued promise ---
|
|
785
786
|
var ValuedPromise = /** @class */ (function (_super) {
|
|
@@ -2785,6 +2786,8 @@
|
|
|
2785
2786
|
this.toaster = toaster;
|
|
2786
2787
|
this.configs = configs;
|
|
2787
2788
|
this.request = request;
|
|
2789
|
+
this.requestHeaders = {};
|
|
2790
|
+
this.requestParams = {};
|
|
2788
2791
|
this.cache = {};
|
|
2789
2792
|
}
|
|
2790
2793
|
Object.defineProperty(BaseHttpService.prototype, "name", {
|
|
@@ -3011,10 +3014,9 @@
|
|
|
3011
3014
|
if (method === void 0) { method = "GET"; }
|
|
3012
3015
|
// Set base options
|
|
3013
3016
|
options = options ? Object.assign({}, options) : {};
|
|
3014
|
-
options.
|
|
3017
|
+
options.method = method;
|
|
3015
3018
|
options.observe = "body";
|
|
3016
3019
|
options.originalHeaders = options.originalHeaders || options.headers || {};
|
|
3017
|
-
options.method = method;
|
|
3018
3020
|
options.withCredentials = ObjectUtils.isBoolean(options.withCredentials) ? options.withCredentials : this.withCredentials;
|
|
3019
3021
|
options.body = body || {};
|
|
3020
3022
|
// Set cookies from server side request
|
|
@@ -3022,12 +3024,15 @@
|
|
|
3022
3024
|
if (this.checkHeaders(headers)) {
|
|
3023
3025
|
options.headers["Cookie"] = headers.cookie;
|
|
3024
3026
|
}
|
|
3025
|
-
options.headers = this.makeHeaders(options
|
|
3027
|
+
options.headers = this.makeHeaders(options);
|
|
3028
|
+
options.params = this.makeParams(options);
|
|
3026
3029
|
return options;
|
|
3027
3030
|
};
|
|
3028
|
-
BaseHttpService.prototype.makeHeaders = function (
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
+
BaseHttpService.prototype.makeHeaders = function (options) {
|
|
3032
|
+
return this.client.makeHeaders(Object.assign({}, this.requestHeaders, (options === null || options === void 0 ? void 0 : options.headers) || {}));
|
|
3033
|
+
};
|
|
3034
|
+
BaseHttpService.prototype.makeParams = function (options) {
|
|
3035
|
+
return this.client.makeParams(Object.assign({}, this.requestParams, (options === null || options === void 0 ? void 0 : options.params) || {}));
|
|
3031
3036
|
};
|
|
3032
3037
|
BaseHttpService.prototype.parseResponse = function (response, url, options) {
|
|
3033
3038
|
return response;
|
|
@@ -3126,12 +3131,13 @@
|
|
|
3126
3131
|
}());
|
|
3127
3132
|
|
|
3128
3133
|
var ConfigService = /** @class */ (function () {
|
|
3129
|
-
function ConfigService(http, universal, baseConfig, scriptParams) {
|
|
3134
|
+
function ConfigService(http, universal, rootElement, baseConfig, scriptParams) {
|
|
3130
3135
|
var _this = this;
|
|
3131
3136
|
if (baseConfig === void 0) { baseConfig = null; }
|
|
3132
3137
|
if (scriptParams === void 0) { scriptParams = null; }
|
|
3133
3138
|
this.http = http;
|
|
3134
3139
|
this.universal = universal;
|
|
3140
|
+
this.rootElement = rootElement;
|
|
3135
3141
|
for (var key in []) {
|
|
3136
3142
|
Object.defineProperty(Array.prototype, key, {
|
|
3137
3143
|
enumerable: false
|
|
@@ -3146,7 +3152,8 @@
|
|
|
3146
3152
|
baseUrl = scriptSrc.substr(0, srcParts[0].lastIndexOf("/") + 1);
|
|
3147
3153
|
}
|
|
3148
3154
|
}
|
|
3149
|
-
this.
|
|
3155
|
+
this.baseConfig = baseConfig || {};
|
|
3156
|
+
this.loadedConfig = Object.assign(!baseUrl ? {} : { baseUrl: baseUrl }, this.baseConfig);
|
|
3150
3157
|
this.scriptParameters = scriptParams || {};
|
|
3151
3158
|
this.loaderFunc = function () {
|
|
3152
3159
|
_this.loader = _this.loader || new Promise(function (resolve, reject) {
|
|
@@ -3230,6 +3237,7 @@
|
|
|
3230
3237
|
ConfigService.ctorParameters = function () { return [
|
|
3231
3238
|
{ type: http.HttpClient },
|
|
3232
3239
|
{ type: UniversalService },
|
|
3240
|
+
{ type: undefined, decorators: [{ type: core.Inject, args: [ROOT_ELEMENT,] }] },
|
|
3233
3241
|
{ type: IConfiguration, decorators: [{ type: core.Optional }, { type: core.Inject, args: [BASE_CONFIG,] }] },
|
|
3234
3242
|
{ type: undefined, decorators: [{ type: core.Optional }, { type: core.Inject, args: [SCRIPT_PARAMS,] }] }
|
|
3235
3243
|
]; };
|
|
@@ -3427,10 +3435,11 @@
|
|
|
3427
3435
|
IconService.ctorParameters = function () { return []; };
|
|
3428
3436
|
|
|
3429
3437
|
var StaticLanguageService = /** @class */ (function () {
|
|
3430
|
-
function StaticLanguageService(events, storage, configs, client) {
|
|
3438
|
+
function StaticLanguageService(events, storage, configs, promises, client) {
|
|
3431
3439
|
this.events = events;
|
|
3432
3440
|
this.storage = storage;
|
|
3433
3441
|
this.configs = configs;
|
|
3442
|
+
this.promises = promises;
|
|
3434
3443
|
this.client = client;
|
|
3435
3444
|
this.editLang = null;
|
|
3436
3445
|
this.currentLang = null;
|
|
@@ -3539,14 +3548,18 @@
|
|
|
3539
3548
|
});
|
|
3540
3549
|
StaticLanguageService.prototype.initService = function () {
|
|
3541
3550
|
};
|
|
3542
|
-
StaticLanguageService.prototype.
|
|
3551
|
+
StaticLanguageService.prototype.replaceLanguages = function (languages) {
|
|
3543
3552
|
var _this = this;
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3553
|
+
languages = Array.isArray(languages) && languages.length > 0 ? languages : this.languageList;
|
|
3554
|
+
this.languageList = Array.from(new Set(languages));
|
|
3555
|
+
this.languageList.forEach(function (lang) {
|
|
3556
|
+
_this.translations[lang] = _this.translations[lang] || {};
|
|
3548
3557
|
});
|
|
3549
|
-
|
|
3558
|
+
};
|
|
3559
|
+
StaticLanguageService.prototype.addLanguages = function (languages) {
|
|
3560
|
+
if (!Array.isArray(languages) || languages.length == 0)
|
|
3561
|
+
return;
|
|
3562
|
+
this.replaceLanguages(this.languageList.concat(languages));
|
|
3550
3563
|
};
|
|
3551
3564
|
StaticLanguageService.prototype.getTranslationSync = function (key, params) {
|
|
3552
3565
|
if (params === void 0) { params = null; }
|
|
@@ -3559,7 +3572,7 @@
|
|
|
3559
3572
|
throw new Error("Parameter \"key\" required");
|
|
3560
3573
|
}
|
|
3561
3574
|
var translation = ObjectUtils.getValue(this.dictionary, key, key) || key;
|
|
3562
|
-
return
|
|
3575
|
+
return this.promises.resolve(this.interpolate(translation, params));
|
|
3563
3576
|
};
|
|
3564
3577
|
StaticLanguageService.prototype.getTranslations = function () {
|
|
3565
3578
|
var _this = this;
|
|
@@ -3567,8 +3580,8 @@
|
|
|
3567
3580
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
3568
3581
|
keys[_i] = arguments[_i];
|
|
3569
3582
|
}
|
|
3570
|
-
return
|
|
3571
|
-
|
|
3583
|
+
return this.promises.create(function (resolve) {
|
|
3584
|
+
_this.promises.all(keys.map(function (key) { return _this.getTranslation(key); })).then(function (translations) {
|
|
3572
3585
|
resolve(keys.reduce(function (result, key, i) {
|
|
3573
3586
|
result[key] = translations[i];
|
|
3574
3587
|
return result;
|
|
@@ -3611,7 +3624,8 @@
|
|
|
3611
3624
|
{ type: EventsService, decorators: [{ type: core.Inject, args: [EventsService,] }] },
|
|
3612
3625
|
{ type: StorageService, decorators: [{ type: core.Inject, args: [StorageService,] }] },
|
|
3613
3626
|
{ type: undefined, decorators: [{ type: core.Inject, args: [CONFIG_SERVICE,] }] },
|
|
3614
|
-
{ type:
|
|
3627
|
+
{ type: undefined, decorators: [{ type: core.Inject, args: [PROMISE_SERVICE,] }] },
|
|
3628
|
+
{ type: BaseHttpClient, decorators: [{ type: core.Inject, args: [BaseHttpClient,] }] }
|
|
3615
3629
|
]; };
|
|
3616
3630
|
|
|
3617
3631
|
var LanguageService = /** @class */ (function (_super) {
|
|
@@ -3953,6 +3967,9 @@
|
|
|
3953
3967
|
PromiseService.prototype.resolve = function (value) {
|
|
3954
3968
|
return this.add(this.zone.runOutsideAngular(function () { return Promise.resolve(value); }));
|
|
3955
3969
|
};
|
|
3970
|
+
PromiseService.prototype.reject = function (value) {
|
|
3971
|
+
return this.add(this.zone.runOutsideAngular(function () { return Promise.reject(value); }));
|
|
3972
|
+
};
|
|
3956
3973
|
PromiseService.prototype.promiseFinished = function () {
|
|
3957
3974
|
if (this.promiseCount == 0)
|
|
3958
3975
|
return;
|
|
@@ -5846,6 +5863,10 @@
|
|
|
5846
5863
|
provide: CONFIG_SERVICE,
|
|
5847
5864
|
useExisting: (!config ? null : config.configService) || ConfigService
|
|
5848
5865
|
},
|
|
5866
|
+
{
|
|
5867
|
+
provide: ROOT_ELEMENT,
|
|
5868
|
+
useValue: null
|
|
5869
|
+
},
|
|
5849
5870
|
{
|
|
5850
5871
|
provide: core.APP_INITIALIZER,
|
|
5851
5872
|
useFactory: (!config ? null : config.initializeApp) || loadConfig,
|
|
@@ -5944,6 +5965,7 @@
|
|
|
5944
5965
|
exports.PaginationMenuComponent = PaginationMenuComponent;
|
|
5945
5966
|
exports.Point = Point;
|
|
5946
5967
|
exports.PromiseService = PromiseService;
|
|
5968
|
+
exports.ROOT_ELEMENT = ROOT_ELEMENT;
|
|
5947
5969
|
exports.Rect = Rect;
|
|
5948
5970
|
exports.ReducePipe = ReducePipe;
|
|
5949
5971
|
exports.ReflectUtils = ReflectUtils;
|