@celljs/core 3.0.0 → 3.1.1
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/lib/browser/application/frontend-application-state.js +2 -7
- package/lib/browser/application/frontend-application-state.js.map +1 -1
- package/lib/browser/application/frontend-application.js +8 -16
- package/lib/browser/application/frontend-application.js.map +1 -1
- package/lib/browser/application/index.js +3 -16
- package/lib/browser/application/index.js.map +1 -1
- package/lib/browser/index.js +4 -17
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/shell/application-shell.js +2 -7
- package/lib/browser/shell/application-shell.js.map +1 -1
- package/lib/browser/shell/index.js +3 -16
- package/lib/browser/shell/index.js.map +1 -1
- package/lib/common/annotation/aspect.js +1 -1
- package/lib/common/annotation/aspect.js.map +1 -1
- package/lib/common/annotation/autowired.js +1 -1
- package/lib/common/annotation/autowired.js.map +1 -1
- package/lib/common/annotation/component.js +7 -2
- package/lib/common/annotation/component.js.map +1 -1
- package/lib/common/annotation/detached/index.js +4 -17
- package/lib/common/annotation/detached/index.js.map +1 -1
- package/lib/common/annotation/index.js +18 -31
- package/lib/common/annotation/index.js.map +1 -1
- package/lib/common/annotation/value.js +1 -1
- package/lib/common/annotation/value.js.map +1 -1
- package/lib/common/aop/aop-proxy-factory.js +2 -7
- package/lib/common/aop/aop-proxy-factory.js.map +1 -1
- package/lib/common/aop/class-filter.js +2 -7
- package/lib/common/aop/class-filter.js.map +1 -1
- package/lib/common/aop/index.js +4 -17
- package/lib/common/aop/index.js.map +1 -1
- package/lib/common/application/application-protocol.js +5 -13
- package/lib/common/application/application-protocol.js.map +1 -1
- package/lib/common/application/application-state.js +2 -7
- package/lib/common/application/application-state.js.map +1 -1
- package/lib/common/application/application.js +4 -12
- package/lib/common/application/application.js.map +1 -1
- package/lib/common/application/index.js +3 -16
- package/lib/common/application/index.js.map +1 -1
- package/lib/common/config/config-provider.js +4 -12
- package/lib/common/config/config-provider.js.map +1 -1
- package/lib/common/config/index.js +4 -17
- package/lib/common/config/index.js.map +1 -1
- package/lib/common/container/index.js +6 -19
- package/lib/common/container/index.js.map +1 -1
- package/lib/common/el/core-context-initializer.js +5 -13
- package/lib/common/el/core-context-initializer.js.map +1 -1
- package/lib/common/el/expression-compiler.js +4 -12
- package/lib/common/el/expression-compiler.js.map +1 -1
- package/lib/common/el/expression-context-provider.js +5 -16
- package/lib/common/el/expression-context-provider.js.map +1 -1
- package/lib/common/el/expression-handler.js +8 -16
- package/lib/common/el/expression-handler.js.map +1 -1
- package/lib/common/el/index.js +7 -20
- package/lib/common/el/index.js.map +1 -1
- package/lib/common/el/jexl-engine-provider.js +2 -7
- package/lib/common/el/jexl-engine-provider.js.map +1 -1
- package/lib/common/error/{cutom-error.d.ts → custom-error.d.ts} +1 -1
- package/lib/common/error/custom-error.d.ts.map +1 -0
- package/lib/common/error/{cutom-error.js → custom-error.js} +1 -1
- package/lib/common/error/custom-error.js.map +1 -0
- package/lib/common/error/error-protocol.d.ts +1 -1
- package/lib/common/error/error-protocol.d.ts.map +1 -1
- package/lib/common/error/illegal-argument-error.d.ts +1 -1
- package/lib/common/error/illegal-argument-error.d.ts.map +1 -1
- package/lib/common/error/illegal-argument-error.js +2 -2
- package/lib/common/error/illegal-argument-error.js.map +1 -1
- package/lib/common/error/illegal-state-error.d.ts +4 -0
- package/lib/common/error/illegal-state-error.d.ts.map +1 -0
- package/lib/common/error/illegal-state-error.js +8 -0
- package/lib/common/error/illegal-state-error.js.map +1 -0
- package/lib/common/error/index.d.ts +3 -1
- package/lib/common/error/index.d.ts.map +1 -1
- package/lib/common/error/index.js +6 -17
- package/lib/common/error/index.js.map +1 -1
- package/lib/common/error/invalid-mime-type-error.d.ts +6 -0
- package/lib/common/error/invalid-mime-type-error.d.ts.map +1 -0
- package/lib/common/error/invalid-mime-type-error.js +12 -0
- package/lib/common/error/invalid-mime-type-error.js.map +1 -0
- package/lib/common/index.js +12 -25
- package/lib/common/index.js.map +1 -1
- package/lib/common/logger/abstract-logger.js +5 -13
- package/lib/common/logger/abstract-logger.js.map +1 -1
- package/lib/common/logger/index.js +4 -17
- package/lib/common/logger/index.js.map +1 -1
- package/lib/common/logger/logger.js +2 -7
- package/lib/common/logger/logger.js.map +1 -1
- package/lib/common/provider/component-filter-registry.js +5 -16
- package/lib/common/provider/component-filter-registry.js.map +1 -1
- package/lib/common/provider/index.js +6 -19
- package/lib/common/provider/index.js.map +1 -1
- package/lib/common/provider/provider-creator.js +2 -7
- package/lib/common/provider/provider-creator.js.map +1 -1
- package/lib/common/test/index.js +2 -15
- package/lib/common/test/index.js.map +1 -1
- package/lib/common/test/mock-logger.js +2 -7
- package/lib/common/test/mock-logger.js.map +1 -1
- package/lib/common/utils/assert.d.ts +174 -0
- package/lib/common/utils/assert.d.ts.map +1 -0
- package/lib/common/utils/assert.js +287 -0
- package/lib/common/utils/assert.js.map +1 -0
- package/lib/common/utils/index.d.ts +3 -0
- package/lib/common/utils/index.d.ts.map +1 -1
- package/lib/common/utils/index.js +20 -30
- package/lib/common/utils/index.js.map +1 -1
- package/lib/common/utils/mime-type-util.d.ts +37 -0
- package/lib/common/utils/mime-type-util.d.ts.map +1 -0
- package/lib/common/utils/mime-type-util.js +172 -0
- package/lib/common/utils/mime-type-util.js.map +1 -0
- package/lib/common/utils/mime-type.d.ts +33 -0
- package/lib/common/utils/mime-type.d.ts.map +1 -0
- package/lib/common/utils/mime-type.js +262 -0
- package/lib/common/utils/mime-type.js.map +1 -0
- package/lib/common/utils/os.d.ts +2 -2
- package/lib/common/utils/os.js +2 -2
- package/lib/node/application/backend-application-state.js +2 -7
- package/lib/node/application/backend-application-state.js.map +1 -1
- package/lib/node/application/backend-application.js +4 -12
- package/lib/node/application/backend-application.js.map +1 -1
- package/lib/node/application/index.js +3 -16
- package/lib/node/application/index.js.map +1 -1
- package/lib/node/context/index.js +2 -15
- package/lib/node/context/index.js.map +1 -1
- package/lib/node/index.js +4 -17
- package/lib/node/index.js.map +1 -1
- package/lib/node/utils/index.js +2 -15
- package/lib/node/utils/index.js.map +1 -1
- package/package.json +5 -4
- package/src/common/error/error-protocol.ts +1 -1
- package/src/common/error/illegal-argument-error.ts +1 -1
- package/src/common/error/illegal-state-error.ts +5 -0
- package/src/common/error/index.ts +3 -1
- package/src/common/error/invalid-mime-type-error.ts +7 -0
- package/src/common/utils/assert.ts +300 -0
- package/src/common/utils/index.ts +3 -0
- package/src/common/utils/mime-type-util.ts +180 -0
- package/src/common/utils/mime-type.ts +276 -0
- package/src/common/utils/os.ts +2 -2
- package/lib/common/error/cutom-error.d.ts.map +0 -1
- package/lib/common/error/cutom-error.js.map +0 -1
- /package/src/common/error/{cutom-error.ts → custom-error.ts} +0 -0
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { Assert } from './assert';
|
|
2
|
+
import { MimeTypeUtils } from './mime-type-util';
|
|
3
|
+
|
|
4
|
+
export class MimeType {
|
|
5
|
+
private static readonly WILDCARD_TYPE = '*';
|
|
6
|
+
private static readonly PARAM_CHARSET = 'charset';
|
|
7
|
+
private static TOKEN: Set<number> = new Set();
|
|
8
|
+
|
|
9
|
+
private readonly type: string;
|
|
10
|
+
private readonly subtype: string;
|
|
11
|
+
private readonly parameters: Map<string, string>;
|
|
12
|
+
|
|
13
|
+
private charset?: string;
|
|
14
|
+
|
|
15
|
+
static {
|
|
16
|
+
const ctl = new Set<number>();
|
|
17
|
+
for (let i = 0; i <= 31; i++) {
|
|
18
|
+
ctl.add(i);
|
|
19
|
+
}
|
|
20
|
+
ctl.add(127);
|
|
21
|
+
|
|
22
|
+
const separators = new Set<number>();
|
|
23
|
+
separators.add('('.charCodeAt(0));
|
|
24
|
+
separators.add(')'.charCodeAt(0));
|
|
25
|
+
separators.add('<'.charCodeAt(0));
|
|
26
|
+
separators.add('>'.charCodeAt(0));
|
|
27
|
+
separators.add('@'.charCodeAt(0));
|
|
28
|
+
separators.add(','.charCodeAt(0));
|
|
29
|
+
separators.add(';'.charCodeAt(0));
|
|
30
|
+
separators.add(':'.charCodeAt(0));
|
|
31
|
+
separators.add('\\'.charCodeAt(0));
|
|
32
|
+
separators.add('"'.charCodeAt(0));
|
|
33
|
+
separators.add('/'.charCodeAt(0));
|
|
34
|
+
separators.add('['.charCodeAt(0));
|
|
35
|
+
separators.add(']'.charCodeAt(0));
|
|
36
|
+
separators.add('?'.charCodeAt(0));
|
|
37
|
+
separators.add('='.charCodeAt(0));
|
|
38
|
+
separators.add('{'.charCodeAt(0));
|
|
39
|
+
separators.add('}'.charCodeAt(0));
|
|
40
|
+
separators.add(' '.charCodeAt(0));
|
|
41
|
+
separators.add('\t'.charCodeAt(0));
|
|
42
|
+
|
|
43
|
+
for (let i = 0; i < 128; i++) {
|
|
44
|
+
if (!ctl.has(i) && !separators.has(i)) {
|
|
45
|
+
this.TOKEN.add(i);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
constructor(type: string, subtype: string = MimeType.WILDCARD_TYPE, parameters?: Map<string, string>) {
|
|
51
|
+
Assert.hasLength(type, '"type" must not be empty');
|
|
52
|
+
Assert.hasLength(subtype, '"subtype" must not be empty');
|
|
53
|
+
this.checkToken(type);
|
|
54
|
+
this.checkToken(subtype);
|
|
55
|
+
this.type = type.toLowerCase();
|
|
56
|
+
this.subtype = subtype.toLowerCase();
|
|
57
|
+
if (parameters) {
|
|
58
|
+
const map: Map<string, string> = new Map();
|
|
59
|
+
for (const [key, value] of Object.entries(parameters)) {
|
|
60
|
+
this.checkParameters(key, value);
|
|
61
|
+
map.set(key.toLowerCase(), value);
|
|
62
|
+
}
|
|
63
|
+
this.parameters = map;
|
|
64
|
+
} else {
|
|
65
|
+
this.parameters = new Map();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private checkToken(token: string) {
|
|
70
|
+
for (let i = 0; i < token.length; i++) {
|
|
71
|
+
const ch = token.charCodeAt(i);
|
|
72
|
+
if (!MimeType.TOKEN.has(ch)) {
|
|
73
|
+
throw new Error(`Invalid token character "${String.fromCharCode(ch)}" in token "${token}"`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
protected checkParameters(parameter: string, value: string) {
|
|
79
|
+
Assert.hasLength(parameter, '"parameter" must not be empty');
|
|
80
|
+
Assert.hasLength(value, '"value" must not be empty');
|
|
81
|
+
this.checkToken(parameter);
|
|
82
|
+
if (MimeType.PARAM_CHARSET === parameter) {
|
|
83
|
+
if (!this.charset) {
|
|
84
|
+
this.charset = this.unquote(value);
|
|
85
|
+
}
|
|
86
|
+
} else if (!this.isQuotedString(value)) {
|
|
87
|
+
this.checkToken(value);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
private isQuotedString(s: string): boolean {
|
|
92
|
+
if (s.length < 2) {
|
|
93
|
+
return false;
|
|
94
|
+
} else {
|
|
95
|
+
return ((s.startsWith('"') && s.endsWith('"')) || (s.startsWith('\'') && s.endsWith('\'')));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
protected unquote(s: string): string {
|
|
100
|
+
return (this.isQuotedString(s) ? s.substring(1, s.length - 1) : s);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
isWildcardType(): boolean {
|
|
104
|
+
return MimeType.WILDCARD_TYPE === this.getType();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
isWildcardSubtype(): boolean {
|
|
108
|
+
const subtype = this.getSubtype();
|
|
109
|
+
return (MimeType.WILDCARD_TYPE === subtype || subtype.startsWith('*+'));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
isConcrete(): boolean {
|
|
113
|
+
return !this.isWildcardType() && !this.isWildcardSubtype();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
getType(): string {
|
|
117
|
+
return this.type;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
getSubtype(): string {
|
|
121
|
+
return this.subtype;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
getSubtypeSuffix(): string | undefined {
|
|
125
|
+
const suffixIndex = this.subtype.lastIndexOf('+');
|
|
126
|
+
if (suffixIndex !== -1 && this.subtype.length > suffixIndex) {
|
|
127
|
+
return this.subtype.substring(suffixIndex + 1);
|
|
128
|
+
}
|
|
129
|
+
return undefined;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
getCharset(): string | undefined {
|
|
133
|
+
return this.charset;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
getParameter(name: string): string | undefined {
|
|
137
|
+
return this.parameters.get(name);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
getParameters(): Map<string, string> {
|
|
141
|
+
return this.parameters;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
includes(other?: MimeType): boolean {
|
|
145
|
+
if (other === undefined) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
if (this.isWildcardType()) {
|
|
149
|
+
return true;
|
|
150
|
+
} else if (this.getType() === other.getType()) {
|
|
151
|
+
if (this.getSubtype() === other.getSubtype()) {
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
if (this.isWildcardSubtype()) {
|
|
155
|
+
const thisPlusIdx = this.getSubtype().lastIndexOf('+');
|
|
156
|
+
if (thisPlusIdx === -1) {
|
|
157
|
+
return true;
|
|
158
|
+
} else {
|
|
159
|
+
const otherPlusIdx = other.getSubtype().lastIndexOf('+');
|
|
160
|
+
if (otherPlusIdx !== -1) {
|
|
161
|
+
const thisSubtypeNoSuffix = this.getSubtype().substring(0, thisPlusIdx);
|
|
162
|
+
const thisSubtypeSuffix = this.getSubtype().substring(thisPlusIdx + 1);
|
|
163
|
+
const otherSubtypeSuffix = other.getSubtype().substring(otherPlusIdx + 1);
|
|
164
|
+
if (thisSubtypeSuffix === otherSubtypeSuffix && MimeType.WILDCARD_TYPE === thisSubtypeNoSuffix) {
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
isCompatibleWith(other?: MimeType): boolean {
|
|
175
|
+
if (other === undefined) {
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
if (this.isWildcardType() || other.isWildcardType()) {
|
|
179
|
+
return true;
|
|
180
|
+
} else if (this.getType() === other.getType()) {
|
|
181
|
+
if (this.getSubtype() === other.getSubtype()) {
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
184
|
+
if (this.isWildcardSubtype() || other.isWildcardSubtype()) {
|
|
185
|
+
const thisSuffix = this.getSubtypeSuffix();
|
|
186
|
+
const otherSuffix = other.getSubtypeSuffix();
|
|
187
|
+
if (this.getSubtype() === MimeType.WILDCARD_TYPE || other.getSubtype() === MimeType.WILDCARD_TYPE) {
|
|
188
|
+
return true;
|
|
189
|
+
} else if (this.isWildcardSubtype() && thisSuffix !== undefined) {
|
|
190
|
+
return (thisSuffix === other.getSubtype() || thisSuffix === otherSuffix);
|
|
191
|
+
} else if (other.isWildcardSubtype() && otherSuffix !== undefined) {
|
|
192
|
+
return (this.getSubtype() === otherSuffix || otherSuffix === thisSuffix);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
equalsTypeAndSubtype(other?: MimeType): boolean {
|
|
200
|
+
if (other === undefined) {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
return this.type.toLowerCase() === other.type.toLowerCase() && this.subtype.toLowerCase() === other.subtype.toLowerCase();
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
isPresentIn(mimeTypes: MimeType[]): boolean {
|
|
207
|
+
for (const mimeType of mimeTypes) {
|
|
208
|
+
if (mimeType.equalsTypeAndSubtype(this)) {
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
equals(other: unknown): boolean {
|
|
216
|
+
return (this === other || (other instanceof MimeType &&
|
|
217
|
+
this.type.toLowerCase() === other.type.toLowerCase() &&
|
|
218
|
+
this.subtype.toLowerCase() === other.subtype.toLowerCase() &&
|
|
219
|
+
this.parametersAreEqual(other)));
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
private parametersAreEqual(other: MimeType): boolean {
|
|
223
|
+
if (this.parameters.size !== other.parameters.size) {
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
for (const [key, value] of this.parameters) {
|
|
228
|
+
if (!other.parameters.has(key)) {
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
if (MimeType.PARAM_CHARSET === key) {
|
|
232
|
+
if (this.getCharset() !== other.getCharset()) {
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
} else if (value !== other.parameters.get(key)) {
|
|
236
|
+
return false;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return true;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
isMoreSpecific(other: MimeType): boolean {
|
|
244
|
+
Assert.notNull(other, 'Other must not be null');
|
|
245
|
+
const thisWildcard = this.isWildcardType();
|
|
246
|
+
const otherWildcard = other.isWildcardType();
|
|
247
|
+
if (thisWildcard && !otherWildcard) {
|
|
248
|
+
return false;
|
|
249
|
+
} else if (!thisWildcard && otherWildcard) {
|
|
250
|
+
return true;
|
|
251
|
+
} else {
|
|
252
|
+
const thisWildcardSubtype = this.isWildcardSubtype();
|
|
253
|
+
const otherWildcardSubtype = other.isWildcardSubtype();
|
|
254
|
+
if (thisWildcardSubtype && !otherWildcardSubtype) {
|
|
255
|
+
return false;
|
|
256
|
+
} else if (!thisWildcardSubtype && otherWildcardSubtype) {
|
|
257
|
+
return true;
|
|
258
|
+
} else if (this.getType() === other.getType() && this.getSubtype() === other.getSubtype()) {
|
|
259
|
+
const paramsSize1 = this.getParameters().size;
|
|
260
|
+
const paramsSize2 = other.getParameters().size;
|
|
261
|
+
return paramsSize1 > paramsSize2;
|
|
262
|
+
} else {
|
|
263
|
+
return false;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
isLessSpecific(other: MimeType): boolean {
|
|
269
|
+
Assert.notNull(other, 'Other must not be null');
|
|
270
|
+
return other.isMoreSpecific(this);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
static valueOf(value: string): MimeType {
|
|
274
|
+
return MimeTypeUtils.parseMimeType(value);
|
|
275
|
+
}
|
|
276
|
+
}
|
package/src/common/utils/os.ts
CHANGED
|
@@ -33,8 +33,8 @@ export namespace OS {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
* Returns with the type of the operating system. If it is neither
|
|
37
|
-
* it always
|
|
36
|
+
* Returns with the type of the operating system. If it is neither Windows nor OS X, then
|
|
37
|
+
* it always returns with the `Linux` OS type.
|
|
38
38
|
*/
|
|
39
39
|
export function type(): OS.Type {
|
|
40
40
|
if (isWindows) {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cutom-error.d.ts","sourceRoot":"","sources":["../../../src/common/error/cutom-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEjE,qBAAa,WAAY,SAAQ,eAAe;CAE/C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cutom-error.js","sourceRoot":"","sources":["../../../src/common/error/cutom-error.ts"],"names":[],"mappings":";;;AAAA,qDAAiE;AAEjE,MAAa,WAAY,SAAQ,6BAAe;CAE/C;AAFD,kCAEC"}
|
|
File without changes
|