ngx-ode-sijil 4.6.0-dev.0 → 4.6.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/esm2020/lib/components/s5l.component.mjs +52 -0
- package/esm2020/lib/ngx-ode-sijil.module.mjs +42 -0
- package/esm2020/lib/pipes/translate.pipe.mjs +18 -0
- package/esm2020/lib/services/bundles.service.mjs +98 -0
- package/esm2020/lib/services/parser/fragments.parser.mjs +142 -0
- package/esm2020/lib/services/parser/parser.interface.mjs +15 -0
- package/esm2020/lib/services/require/httprequire.service.mjs +23 -0
- package/esm2020/lib/services/require/require.interface.mjs +8 -0
- package/esm2020/lib/services/sijil.opts.mjs +11 -0
- package/esm2020/ngx-ode-sijil.mjs +5 -0
- package/esm2020/public-api.mjs +8 -0
- package/fesm2015/{ngx-ode-sijil.js → ngx-ode-sijil.mjs} +74 -349
- package/fesm2015/ngx-ode-sijil.mjs.map +1 -0
- package/fesm2020/ngx-ode-sijil.mjs +403 -0
- package/fesm2020/ngx-ode-sijil.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/components/s5l.component.d.ts +3 -0
- package/lib/ngx-ode-sijil.module.d.ts +9 -2
- package/lib/pipes/translate.pipe.d.ts +3 -0
- package/lib/services/require/httprequire.service.d.ts +3 -0
- package/package.json +27 -17
- package/CHANGELOG.md +0 -12
- package/bundles/ngx-ode-sijil.umd.js +0 -1029
- package/bundles/ngx-ode-sijil.umd.js.map +0 -1
- package/bundles/ngx-ode-sijil.umd.min.js +0 -16
- package/bundles/ngx-ode-sijil.umd.min.js.map +0 -1
- package/esm2015/lib/components/s5l.component.js +0 -92
- package/esm2015/lib/ngx-ode-sijil.module.js +0 -51
- package/esm2015/lib/pipes/translate.pipe.js +0 -39
- package/esm2015/lib/services/bundles.service.js +0 -154
- package/esm2015/lib/services/parser/fragments.parser.js +0 -208
- package/esm2015/lib/services/parser/parser.interface.js +0 -40
- package/esm2015/lib/services/require/httprequire.service.js +0 -47
- package/esm2015/lib/services/require/require.interface.js +0 -22
- package/esm2015/lib/services/sijil.opts.js +0 -25
- package/esm2015/ngx-ode-sijil.js +0 -15
- package/esm2015/public-api.js +0 -13
- package/esm5/lib/components/s5l.component.js +0 -98
- package/esm5/lib/ngx-ode-sijil.module.js +0 -64
- package/esm5/lib/pipes/translate.pipe.js +0 -44
- package/esm5/lib/services/bundles.service.js +0 -243
- package/esm5/lib/services/parser/fragments.parser.js +0 -230
- package/esm5/lib/services/parser/parser.interface.js +0 -57
- package/esm5/lib/services/require/httprequire.service.js +0 -50
- package/esm5/lib/services/require/require.interface.js +0 -38
- package/esm5/lib/services/sijil.opts.js +0 -41
- package/esm5/ngx-ode-sijil.js +0 -15
- package/esm5/public-api.js +0 -13
- package/fesm2015/ngx-ode-sijil.js.map +0 -1
- package/fesm5/ngx-ode-sijil.js +0 -829
- package/fesm5/ngx-ode-sijil.js.map +0 -1
- package/ngx-ode-sijil.d.ts +0 -9
- package/ngx-ode-sijil.metadata.json +0 -1
|
@@ -1,11 +1,8 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
1
2
|
import { Component, ChangeDetectionStrategy, ViewChild, Input, Pipe, Injectable, NgModule } from '@angular/core';
|
|
2
|
-
import
|
|
3
|
+
import * as i1 from '@angular/common/http';
|
|
4
|
+
import { HttpClientModule } from '@angular/common/http';
|
|
3
5
|
|
|
4
|
-
/**
|
|
5
|
-
* @fileoverview added by tsickle
|
|
6
|
-
* Generated from: lib/services/bundles.service.ts
|
|
7
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
8
|
-
*/
|
|
9
6
|
/**
|
|
10
7
|
* Defines a BundlesService, whice is the main entry point for Sijil operations.
|
|
11
8
|
*
|
|
@@ -15,11 +12,6 @@ import { HttpClient, HttpClientModule } from '@angular/common/http';
|
|
|
15
12
|
* - SijilOpts : An object containing custom settings
|
|
16
13
|
*/
|
|
17
14
|
class BundlesService {
|
|
18
|
-
/**
|
|
19
|
-
* @param {?} requireService
|
|
20
|
-
* @param {?} parser
|
|
21
|
-
* @param {?} sijilOpts
|
|
22
|
-
*/
|
|
23
15
|
constructor(requireService, parser, sijilOpts) {
|
|
24
16
|
this.requireService = requireService;
|
|
25
17
|
this.parser = parser;
|
|
@@ -33,12 +25,10 @@ class BundlesService {
|
|
|
33
25
|
/**
|
|
34
26
|
* Add keys/values to an existing bundle, or create it if missing.
|
|
35
27
|
*
|
|
36
|
-
* @param
|
|
37
|
-
* @param
|
|
38
|
-
* @return {?}
|
|
28
|
+
* @param bundle An object containing translations as key / values.
|
|
29
|
+
* @param lang The language to map the bundle with, or the current langugage if omitted.
|
|
39
30
|
*/
|
|
40
31
|
addToBundle(bundle, lang) {
|
|
41
|
-
/** @type {?} */
|
|
42
32
|
const targetLanguage = lang || this.currentLanguage || this.defaultLanguage || 'en';
|
|
43
33
|
if (!this.bundles[targetLanguage]) {
|
|
44
34
|
this.bundles[targetLanguage] = {};
|
|
@@ -52,47 +42,36 @@ class BundlesService {
|
|
|
52
42
|
* Loads a bundle and associates it with a language.
|
|
53
43
|
* If the target language already contains key/values, then we mixin the new bundle and the existing one.
|
|
54
44
|
*
|
|
55
|
-
* @param
|
|
56
|
-
* @param
|
|
57
|
-
* @
|
|
45
|
+
* @param where The path, or whatever the RequireService needs to fetch the bundle.
|
|
46
|
+
* @param lang The target language, or the current language if omitted.
|
|
47
|
+
* @returns A Promise, because the RequireService can be (is - by default) asynchronous.
|
|
58
48
|
*/
|
|
59
49
|
loadBundle(where, lang) {
|
|
60
50
|
return this.requireService.load(where)
|
|
61
|
-
.then(
|
|
62
|
-
* @param {?} bundle
|
|
63
|
-
* @return {?}
|
|
64
|
-
*/
|
|
65
|
-
bundle => {
|
|
51
|
+
.then(bundle => {
|
|
66
52
|
this.addToBundle(bundle, lang);
|
|
67
|
-
})
|
|
53
|
+
});
|
|
68
54
|
}
|
|
69
55
|
/**
|
|
70
56
|
* Loads multiple bundles and associates then with a language.
|
|
71
57
|
*
|
|
72
|
-
* @see {
|
|
73
|
-
* @param {?} specs
|
|
74
|
-
* @return {?}
|
|
58
|
+
* @see {@link loadBundle}
|
|
75
59
|
*/
|
|
76
60
|
loadBundles(specs) {
|
|
77
|
-
return Promise.all(specs.map((
|
|
78
|
-
* @param {?} spec
|
|
79
|
-
* @return {?}
|
|
80
|
-
*/
|
|
81
|
-
(spec) => {
|
|
61
|
+
return Promise.all(specs.map((spec) => {
|
|
82
62
|
return this.loadBundle(spec.where, spec.lang);
|
|
83
|
-
}))
|
|
63
|
+
}));
|
|
84
64
|
}
|
|
85
65
|
/**
|
|
86
66
|
* Removes a bundle from the bundles list.
|
|
87
67
|
*
|
|
88
|
-
* @param
|
|
89
|
-
* @return {?}
|
|
68
|
+
* @param lang Language to remove.
|
|
90
69
|
*/
|
|
91
70
|
unloadBundle(lang) {
|
|
92
71
|
delete this.bundles[lang];
|
|
93
72
|
}
|
|
94
73
|
/**
|
|
95
|
-
* @
|
|
74
|
+
* @returns Returns a list of all loaded languages.
|
|
96
75
|
*/
|
|
97
76
|
getLoadedLanguages() {
|
|
98
77
|
return Object.keys(this.bundles);
|
|
@@ -100,15 +79,13 @@ class BundlesService {
|
|
|
100
79
|
/**
|
|
101
80
|
* Translates a single key into a target language, using the parameters provided if needed.
|
|
102
81
|
*
|
|
103
|
-
* @param
|
|
104
|
-
* @param
|
|
105
|
-
* @param
|
|
106
|
-
* @
|
|
82
|
+
* @param key Key to translate
|
|
83
|
+
* @param parameters Parameters to use if the translation contains logic.
|
|
84
|
+
* @param lang Target language, of the current language if omitted.
|
|
85
|
+
* @returns The computed translation, or the key if no match was found in the bundles (including the fallback language bundle).
|
|
107
86
|
*/
|
|
108
87
|
translate(key, parameters, lang) {
|
|
109
|
-
/** @type {?} */
|
|
110
88
|
const targetLanguage = lang || this.currentLanguage;
|
|
111
|
-
/** @type {?} */
|
|
112
89
|
const rawTranslation = this.bundles[targetLanguage] &&
|
|
113
90
|
this.bundles[targetLanguage][key] ||
|
|
114
91
|
this.defaultLanguage &&
|
|
@@ -116,80 +93,30 @@ class BundlesService {
|
|
|
116
93
|
this.bundles[this.defaultLanguage][key] ||
|
|
117
94
|
key;
|
|
118
95
|
if (rawTranslation !== key && parameters) {
|
|
119
|
-
return this.parser.compile(rawTranslation, parameters, (
|
|
120
|
-
* @param {?} e
|
|
121
|
-
* @return {?}
|
|
122
|
-
*/
|
|
123
|
-
(e) => { console.error(e); return key; }));
|
|
96
|
+
return this.parser.compile(rawTranslation, parameters, (e) => { console.error(e); return key; });
|
|
124
97
|
}
|
|
125
98
|
else {
|
|
126
99
|
return rawTranslation;
|
|
127
100
|
}
|
|
128
101
|
}
|
|
129
102
|
}
|
|
130
|
-
if (false) {
|
|
131
|
-
/**
|
|
132
|
-
* @type {?}
|
|
133
|
-
* @private
|
|
134
|
-
*/
|
|
135
|
-
BundlesService.prototype.bundles;
|
|
136
|
-
/**
|
|
137
|
-
* Fallback language.
|
|
138
|
-
* @type {?}
|
|
139
|
-
*/
|
|
140
|
-
BundlesService.prototype.defaultLanguage;
|
|
141
|
-
/**
|
|
142
|
-
* Current language.
|
|
143
|
-
* @type {?}
|
|
144
|
-
*/
|
|
145
|
-
BundlesService.prototype.currentLanguage;
|
|
146
|
-
/**
|
|
147
|
-
* @type {?}
|
|
148
|
-
* @private
|
|
149
|
-
*/
|
|
150
|
-
BundlesService.prototype.requireService;
|
|
151
|
-
/**
|
|
152
|
-
* @type {?}
|
|
153
|
-
* @private
|
|
154
|
-
*/
|
|
155
|
-
BundlesService.prototype.parser;
|
|
156
|
-
}
|
|
157
103
|
|
|
158
|
-
/**
|
|
159
|
-
* @fileoverview added by tsickle
|
|
160
|
-
* Generated from: lib/components/s5l.component.ts
|
|
161
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
162
|
-
*/
|
|
163
104
|
class S5lComponent {
|
|
164
|
-
/**
|
|
165
|
-
* @param {?} bundlesService
|
|
166
|
-
*/
|
|
167
105
|
constructor(bundlesService) {
|
|
168
106
|
this.bundlesService = bundlesService;
|
|
169
107
|
}
|
|
170
|
-
/**
|
|
171
|
-
* @private
|
|
172
|
-
* @return {?}
|
|
173
|
-
*/
|
|
174
108
|
refreshTranslation() {
|
|
175
|
-
/** @type {?} */
|
|
176
109
|
const newDisplayedValue = this.bundlesService.translate(this.value, this.parameters, this.fixedLanguage);
|
|
177
110
|
if (this.displayedValue !== newDisplayedValue) {
|
|
178
111
|
this.displayedValue = newDisplayedValue;
|
|
179
112
|
this.wrapperRef.nativeElement.innerHTML = this.displayedValue;
|
|
180
113
|
}
|
|
181
114
|
}
|
|
182
|
-
/**
|
|
183
|
-
* @return {?}
|
|
184
|
-
*/
|
|
185
115
|
ngAfterViewInit() {
|
|
186
116
|
this.value = this.wrapperRef.nativeElement.innerHTML.trim();
|
|
187
117
|
this.loaded = true;
|
|
188
118
|
this.refreshTranslation();
|
|
189
119
|
}
|
|
190
|
-
/**
|
|
191
|
-
* @return {?}
|
|
192
|
-
*/
|
|
193
120
|
ngDoCheck() {
|
|
194
121
|
if (!this.loaded) {
|
|
195
122
|
return;
|
|
@@ -197,228 +124,101 @@ class S5lComponent {
|
|
|
197
124
|
this.refreshTranslation();
|
|
198
125
|
}
|
|
199
126
|
}
|
|
200
|
-
S5lComponent
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
127
|
+
S5lComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: S5lComponent, deps: [{ token: BundlesService }], target: i0.ɵɵFactoryTarget.Component });
|
|
128
|
+
S5lComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.1.1", type: S5lComponent, selector: "s5l", inputs: { parameters: ["s5l-params", "parameters"], fixedLanguage: ["s5l-lang", "fixedLanguage"] }, viewQueries: [{ propertyName: "wrapperRef", first: true, predicate: ["wrapper"], descendants: true }], ngImport: i0, template: `
|
|
129
|
+
<span #wrapper>
|
|
130
|
+
<ng-content></ng-content>
|
|
131
|
+
</span>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
132
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: S5lComponent, decorators: [{
|
|
133
|
+
type: Component,
|
|
134
|
+
args: [{
|
|
135
|
+
selector: 's5l',
|
|
136
|
+
template: `
|
|
204
137
|
<span #wrapper>
|
|
205
138
|
<ng-content></ng-content>
|
|
206
139
|
</span>`,
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
];
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
};
|
|
219
|
-
if (false) {
|
|
220
|
-
/** @type {?} */
|
|
221
|
-
S5lComponent.prototype.wrapperRef;
|
|
222
|
-
/**
|
|
223
|
-
* @type {?}
|
|
224
|
-
* @private
|
|
225
|
-
*/
|
|
226
|
-
S5lComponent.prototype.value;
|
|
227
|
-
/**
|
|
228
|
-
* @type {?}
|
|
229
|
-
* @private
|
|
230
|
-
*/
|
|
231
|
-
S5lComponent.prototype.loaded;
|
|
232
|
-
/**
|
|
233
|
-
* @type {?}
|
|
234
|
-
* @private
|
|
235
|
-
*/
|
|
236
|
-
S5lComponent.prototype.displayedValue;
|
|
237
|
-
/** @type {?} */
|
|
238
|
-
S5lComponent.prototype.parameters;
|
|
239
|
-
/** @type {?} */
|
|
240
|
-
S5lComponent.prototype.fixedLanguage;
|
|
241
|
-
/**
|
|
242
|
-
* @type {?}
|
|
243
|
-
* @private
|
|
244
|
-
*/
|
|
245
|
-
S5lComponent.prototype.bundlesService;
|
|
246
|
-
}
|
|
140
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
141
|
+
}]
|
|
142
|
+
}], ctorParameters: function () { return [{ type: BundlesService }]; }, propDecorators: { wrapperRef: [{
|
|
143
|
+
type: ViewChild,
|
|
144
|
+
args: ['wrapper']
|
|
145
|
+
}], parameters: [{
|
|
146
|
+
type: Input,
|
|
147
|
+
args: ["s5l-params"]
|
|
148
|
+
}], fixedLanguage: [{
|
|
149
|
+
type: Input,
|
|
150
|
+
args: ["s5l-lang"]
|
|
151
|
+
}] } });
|
|
247
152
|
|
|
248
|
-
/**
|
|
249
|
-
* @fileoverview added by tsickle
|
|
250
|
-
* Generated from: lib/pipes/translate.pipe.ts
|
|
251
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
252
|
-
*/
|
|
253
153
|
class TranslatePipe {
|
|
254
|
-
/**
|
|
255
|
-
* @param {?} bundlesService
|
|
256
|
-
*/
|
|
257
154
|
constructor(bundlesService) {
|
|
258
155
|
this.bundlesService = bundlesService;
|
|
259
156
|
}
|
|
260
|
-
/**
|
|
261
|
-
* @param {?} key
|
|
262
|
-
* @param {?=} parameters
|
|
263
|
-
* @param {?=} lang
|
|
264
|
-
* @return {?}
|
|
265
|
-
*/
|
|
266
157
|
transform(key, parameters, lang) {
|
|
267
158
|
return this.bundlesService.translate(key, parameters, lang);
|
|
268
159
|
}
|
|
269
160
|
}
|
|
270
|
-
TranslatePipe
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
];
|
|
277
|
-
if (false) {
|
|
278
|
-
/**
|
|
279
|
-
* @type {?}
|
|
280
|
-
* @private
|
|
281
|
-
*/
|
|
282
|
-
TranslatePipe.prototype.bundlesService;
|
|
283
|
-
}
|
|
161
|
+
TranslatePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: TranslatePipe, deps: [{ token: BundlesService }], target: i0.ɵɵFactoryTarget.Pipe });
|
|
162
|
+
TranslatePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.1.1", ngImport: i0, type: TranslatePipe, name: "translate", pure: false });
|
|
163
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: TranslatePipe, decorators: [{
|
|
164
|
+
type: Pipe,
|
|
165
|
+
args: [{ name: 'translate', pure: false }]
|
|
166
|
+
}], ctorParameters: function () { return [{ type: BundlesService }]; } });
|
|
284
167
|
|
|
285
|
-
/**
|
|
286
|
-
* @fileoverview added by tsickle
|
|
287
|
-
* Generated from: lib/services/require/require.interface.ts
|
|
288
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
289
|
-
*/
|
|
290
168
|
/**
|
|
291
169
|
* Service used to fetch bundles.
|
|
292
170
|
*
|
|
293
171
|
* @export
|
|
294
|
-
* @abstract
|
|
295
172
|
*/
|
|
296
173
|
class RequireService {
|
|
297
174
|
}
|
|
298
|
-
if (false) {
|
|
299
|
-
/**
|
|
300
|
-
* Fetch a bundle.
|
|
301
|
-
* \@memberOf RequireService
|
|
302
|
-
* @type {?}
|
|
303
|
-
*/
|
|
304
|
-
RequireService.prototype.load;
|
|
305
|
-
}
|
|
306
175
|
|
|
307
|
-
/**
|
|
308
|
-
* @fileoverview added by tsickle
|
|
309
|
-
* Generated from: lib/services/parser/parser.interface.ts
|
|
310
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
311
|
-
*/
|
|
312
176
|
class ParserError extends Error {
|
|
313
|
-
/**
|
|
314
|
-
* @param {?} message
|
|
315
|
-
* @param {?} fragment
|
|
316
|
-
*/
|
|
317
177
|
constructor(message, fragment) {
|
|
318
178
|
super(message);
|
|
319
179
|
this.message = message;
|
|
320
180
|
this.fragment = fragment;
|
|
321
181
|
}
|
|
322
182
|
}
|
|
323
|
-
if (false) {
|
|
324
|
-
/** @type {?} */
|
|
325
|
-
ParserError.prototype.message;
|
|
326
|
-
/** @type {?} */
|
|
327
|
-
ParserError.prototype.fragment;
|
|
328
|
-
}
|
|
329
183
|
/**
|
|
330
184
|
* Parses logic inside translations.
|
|
331
185
|
*
|
|
332
186
|
* @export
|
|
333
|
-
* @abstract
|
|
334
187
|
*/
|
|
335
188
|
class Parser {
|
|
336
189
|
}
|
|
337
|
-
if (false) {
|
|
338
|
-
/**
|
|
339
|
-
* Processes a string, isolating logic fragments and compiling them.
|
|
340
|
-
*
|
|
341
|
-
* \@memberOf Parser
|
|
342
|
-
* @type {?}
|
|
343
|
-
*/
|
|
344
|
-
Parser.prototype.compile;
|
|
345
|
-
}
|
|
346
190
|
|
|
347
|
-
/**
|
|
348
|
-
* @fileoverview added by tsickle
|
|
349
|
-
* Generated from: lib/services/sijil.opts.ts
|
|
350
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
351
|
-
*/
|
|
352
191
|
/**
|
|
353
192
|
* Contains Sijil options.
|
|
354
193
|
*
|
|
355
194
|
* @export
|
|
356
|
-
* @abstract
|
|
357
195
|
*/
|
|
358
196
|
class SijilOpts {
|
|
359
197
|
}
|
|
360
|
-
if (false) {
|
|
361
|
-
/**
|
|
362
|
-
* Fallback language when a translation is not available in the current language.
|
|
363
|
-
* @type {?}
|
|
364
|
-
*/
|
|
365
|
-
SijilOpts.prototype.defaultLanguage;
|
|
366
|
-
}
|
|
367
|
-
/** @type {?} */
|
|
368
198
|
let defaultSijilOpts = {
|
|
369
199
|
defaultLanguage: window ? window.navigator.language.split('-')[0] : undefined
|
|
370
200
|
};
|
|
371
201
|
|
|
372
|
-
/**
|
|
373
|
-
* @fileoverview added by tsickle
|
|
374
|
-
* Generated from: lib/services/require/httprequire.service.ts
|
|
375
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
376
|
-
*/
|
|
377
202
|
/**
|
|
378
203
|
* Fetches a bundle from a target url.
|
|
379
204
|
*
|
|
380
205
|
* @export
|
|
381
206
|
*/
|
|
382
207
|
class HttpRequireService {
|
|
383
|
-
/**
|
|
384
|
-
* @param {?} httpClient
|
|
385
|
-
*/
|
|
386
208
|
constructor(httpClient) {
|
|
387
209
|
this.httpClient = httpClient;
|
|
388
210
|
}
|
|
389
|
-
/**
|
|
390
|
-
* @param {?} url
|
|
391
|
-
* @return {?}
|
|
392
|
-
*/
|
|
393
211
|
load(url) {
|
|
394
212
|
return this.httpClient.get(url).toPromise()
|
|
395
|
-
.then(
|
|
396
|
-
* @param {?} data
|
|
397
|
-
* @return {?}
|
|
398
|
-
*/
|
|
399
|
-
data => data));
|
|
213
|
+
.then(data => data);
|
|
400
214
|
}
|
|
401
215
|
}
|
|
402
|
-
HttpRequireService
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
{ type: HttpClient }
|
|
408
|
-
];
|
|
409
|
-
if (false) {
|
|
410
|
-
/**
|
|
411
|
-
* @type {?}
|
|
412
|
-
* @private
|
|
413
|
-
*/
|
|
414
|
-
HttpRequireService.prototype.httpClient;
|
|
415
|
-
}
|
|
216
|
+
HttpRequireService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: HttpRequireService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
217
|
+
HttpRequireService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: HttpRequireService });
|
|
218
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: HttpRequireService, decorators: [{
|
|
219
|
+
type: Injectable
|
|
220
|
+
}], ctorParameters: function () { return [{ type: i1.HttpClient }]; } });
|
|
416
221
|
|
|
417
|
-
/**
|
|
418
|
-
* @fileoverview added by tsickle
|
|
419
|
-
* Generated from: lib/services/parser/fragments.parser.ts
|
|
420
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
421
|
-
*/
|
|
422
222
|
/**
|
|
423
223
|
* The default Sijil parser.
|
|
424
224
|
*
|
|
@@ -453,15 +253,7 @@ if (false) {
|
|
|
453
253
|
// @dynamic
|
|
454
254
|
class FragmentsParser {
|
|
455
255
|
constructor() { }
|
|
456
|
-
/**
|
|
457
|
-
* @private
|
|
458
|
-
* @param {?} parameters
|
|
459
|
-
* @param {?} fragment
|
|
460
|
-
* @param {?=} strict
|
|
461
|
-
* @return {?}
|
|
462
|
-
*/
|
|
463
256
|
getParameter(parameters, fragment, strict) {
|
|
464
|
-
/** @type {?} */
|
|
465
257
|
const splittedFrag = fragment.split(/\s+/);
|
|
466
258
|
if (splittedFrag.length === 1) {
|
|
467
259
|
return fragment[0] === '$' ?
|
|
@@ -472,44 +264,24 @@ class FragmentsParser {
|
|
|
472
264
|
parameters[fragment] :
|
|
473
265
|
fragment;
|
|
474
266
|
}
|
|
475
|
-
return fragment.split(/\s+/).reduce((
|
|
476
|
-
* @param {?} l
|
|
477
|
-
* @param {?} r
|
|
478
|
-
* @return {?}
|
|
479
|
-
*/
|
|
480
|
-
(l, r) => {
|
|
267
|
+
return fragment.split(/\s+/).reduce((l, r) => {
|
|
481
268
|
l.push(r[0] === '$' ? parameters[r.substr(1)] : r);
|
|
482
269
|
return l;
|
|
483
|
-
}
|
|
270
|
+
}, []).join(' ');
|
|
484
271
|
}
|
|
485
|
-
/**
|
|
486
|
-
* @private
|
|
487
|
-
* @param {?} fragment
|
|
488
|
-
* @param {?} parameters
|
|
489
|
-
* @return {?}
|
|
490
|
-
*/
|
|
491
272
|
compileFragment(fragment, parameters) {
|
|
492
273
|
fragment = fragment.replace(/{{|}}/g, '');
|
|
493
|
-
/** @type {?} */
|
|
494
274
|
let interrogationIndex;
|
|
495
|
-
/** @type {?} */
|
|
496
275
|
let dotsIndex;
|
|
497
276
|
if ((interrogationIndex = fragment.indexOf('?')) > 0 && (dotsIndex = fragment.lastIndexOf(':')) > 1) {
|
|
498
|
-
/** @type {?} */
|
|
499
277
|
const condition = fragment.substring(0, interrogationIndex).trim();
|
|
500
|
-
/** @type {?} */
|
|
501
278
|
const trueReturn = fragment.substring(interrogationIndex + 1, dotsIndex).trim();
|
|
502
|
-
/** @type {?} */
|
|
503
279
|
const falseReturn = fragment.substring(dotsIndex + 1).trim();
|
|
504
|
-
/** @type {?} */
|
|
505
280
|
const computedTrueReturn = this.getParameter(parameters, trueReturn);
|
|
506
|
-
/** @type {?} */
|
|
507
281
|
const computedFalseReturn = this.getParameter(parameters, falseReturn);
|
|
508
|
-
/** @type {?} */
|
|
509
282
|
const splittedCondition = condition.split(/\s+/);
|
|
510
283
|
if (splittedCondition.length === 1) {
|
|
511
284
|
// Single variable case
|
|
512
|
-
/** @type {?} */
|
|
513
285
|
const variable = parameters[splittedCondition[0]];
|
|
514
286
|
return variable ?
|
|
515
287
|
computedTrueReturn :
|
|
@@ -517,11 +289,8 @@ class FragmentsParser {
|
|
|
517
289
|
}
|
|
518
290
|
else if (splittedCondition.length === 3) {
|
|
519
291
|
// Operator case
|
|
520
|
-
/** @type {?} */
|
|
521
292
|
const leftHandParam = this.getParameter(parameters, splittedCondition[0], parameters instanceof Array);
|
|
522
|
-
/** @type {?} */
|
|
523
293
|
const rightHand = this.getParameter(parameters, splittedCondition[2], parameters instanceof Array);
|
|
524
|
-
/** @type {?} */
|
|
525
294
|
const comparisonOperator = splittedCondition[1];
|
|
526
295
|
switch (comparisonOperator) {
|
|
527
296
|
case '==':
|
|
@@ -557,18 +326,9 @@ class FragmentsParser {
|
|
|
557
326
|
return parameters[fragment];
|
|
558
327
|
}
|
|
559
328
|
}
|
|
560
|
-
/**
|
|
561
|
-
* @param {?} rawTranslation
|
|
562
|
-
* @param {?} parameters
|
|
563
|
-
* @param {?=} onError
|
|
564
|
-
* @return {?}
|
|
565
|
-
*/
|
|
566
329
|
compile(rawTranslation, parameters, onError) {
|
|
567
|
-
/** @type {?} */
|
|
568
330
|
const parts = rawTranslation.split(FragmentsParser.delimRegexp);
|
|
569
|
-
/** @type {?} */
|
|
570
331
|
const fragments = rawTranslation.match(FragmentsParser.delimRegexp);
|
|
571
|
-
/** @type {?} */
|
|
572
332
|
let compiledTranslation = '';
|
|
573
333
|
if (!onError) {
|
|
574
334
|
onError = FragmentsParser.defaultErrorCallback;
|
|
@@ -595,44 +355,12 @@ class FragmentsParser {
|
|
|
595
355
|
}
|
|
596
356
|
FragmentsParser.delimiters = ['{{', '}}'];
|
|
597
357
|
FragmentsParser.delimRegexp = new RegExp(`${FragmentsParser.delimiters[0]}[^}]+${FragmentsParser.delimiters[1]}`, 'gm');
|
|
598
|
-
FragmentsParser.defaultErrorCallback = (
|
|
599
|
-
* @param {?} e
|
|
600
|
-
* @return {?}
|
|
601
|
-
*/
|
|
602
|
-
(e) => {
|
|
358
|
+
FragmentsParser.defaultErrorCallback = (e) => {
|
|
603
359
|
console.error(e);
|
|
604
360
|
return e.fragment;
|
|
605
|
-
}
|
|
606
|
-
if (false) {
|
|
607
|
-
/**
|
|
608
|
-
* @type {?}
|
|
609
|
-
* @private
|
|
610
|
-
*/
|
|
611
|
-
FragmentsParser.delimiters;
|
|
612
|
-
/**
|
|
613
|
-
* @type {?}
|
|
614
|
-
* @private
|
|
615
|
-
*/
|
|
616
|
-
FragmentsParser.delimRegexp;
|
|
617
|
-
/**
|
|
618
|
-
* @type {?}
|
|
619
|
-
* @private
|
|
620
|
-
*/
|
|
621
|
-
FragmentsParser.defaultErrorCallback;
|
|
622
|
-
}
|
|
361
|
+
};
|
|
623
362
|
|
|
624
|
-
/**
|
|
625
|
-
* @fileoverview added by tsickle
|
|
626
|
-
* Generated from: lib/ngx-ode-sijil.module.ts
|
|
627
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
628
|
-
*/
|
|
629
363
|
class NgxOdeSijilModule {
|
|
630
|
-
/**
|
|
631
|
-
* @param {?=} require
|
|
632
|
-
* @param {?=} parser
|
|
633
|
-
* @param {?=} options
|
|
634
|
-
* @return {?}
|
|
635
|
-
*/
|
|
636
364
|
static forRoot(require, parser, options) {
|
|
637
365
|
return {
|
|
638
366
|
ngModule: NgxOdeSijilModule,
|
|
@@ -644,9 +372,6 @@ class NgxOdeSijilModule {
|
|
|
644
372
|
]
|
|
645
373
|
};
|
|
646
374
|
}
|
|
647
|
-
/**
|
|
648
|
-
* @return {?}
|
|
649
|
-
*/
|
|
650
375
|
static forChild() {
|
|
651
376
|
return {
|
|
652
377
|
ngModule: NgxOdeSijilModule,
|
|
@@ -654,25 +379,25 @@ class NgxOdeSijilModule {
|
|
|
654
379
|
};
|
|
655
380
|
}
|
|
656
381
|
}
|
|
657
|
-
NgxOdeSijilModule
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
]
|
|
382
|
+
NgxOdeSijilModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: NgxOdeSijilModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
383
|
+
NgxOdeSijilModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.1.1", ngImport: i0, type: NgxOdeSijilModule, declarations: [S5lComponent, TranslatePipe], imports: [HttpClientModule], exports: [S5lComponent, TranslatePipe] });
|
|
384
|
+
NgxOdeSijilModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: NgxOdeSijilModule, imports: [HttpClientModule] });
|
|
385
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: NgxOdeSijilModule, decorators: [{
|
|
386
|
+
type: NgModule,
|
|
387
|
+
args: [{
|
|
388
|
+
declarations: [S5lComponent, TranslatePipe],
|
|
389
|
+
imports: [HttpClientModule],
|
|
390
|
+
exports: [S5lComponent, TranslatePipe]
|
|
391
|
+
}]
|
|
392
|
+
}] });
|
|
664
393
|
|
|
665
|
-
|
|
666
|
-
*
|
|
667
|
-
* Generated from: public-api.ts
|
|
668
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
394
|
+
/*
|
|
395
|
+
* Public API Surface of ngx-ode-sijil
|
|
669
396
|
*/
|
|
670
397
|
|
|
671
398
|
/**
|
|
672
|
-
*
|
|
673
|
-
* Generated from: ngx-ode-sijil.ts
|
|
674
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
399
|
+
* Generated bundle index. Do not edit.
|
|
675
400
|
*/
|
|
676
401
|
|
|
677
|
-
export { BundlesService, NgxOdeSijilModule, S5lComponent, TranslatePipe
|
|
678
|
-
//# sourceMappingURL=ngx-ode-sijil.
|
|
402
|
+
export { BundlesService, NgxOdeSijilModule, S5lComponent, TranslatePipe };
|
|
403
|
+
//# sourceMappingURL=ngx-ode-sijil.mjs.map
|