| @@ -66,7 +66,7 export class TemplateParser implements I | |||||
| 66 | } |
|
66 | } | |
| 67 |
|
67 | |||
| 68 | value() { |
|
68 | value() { | |
| 69 |
if ( |
|
69 | if (this._value === undefined) | |
| 70 | throw new Error("The current token doesn't have a value"); |
|
70 | throw new Error("The current token doesn't have a value"); | |
| 71 | return this._value; |
|
71 | return this._value; | |
| 72 | } |
|
72 | } | |
| @@ -38,10 +38,17 compile.load = (id: string, require: Req | |||||
| 38 | trace.debug("{0}: compiled", url); |
|
38 | trace.debug("{0}: compiled", url); | |
| 39 | callback(cache[url] = tc); |
|
39 | callback(cache[url] = tc); | |
| 40 | }, (err: any) => { |
|
40 | }, (err: any) => { | |
| 41 |
callback.error |
|
41 | if (callback.error) | |
| 42 |
|
|
42 | callback.error({ | |
| 43 | src: "@implab/core/text/template-compile" |
|
43 | inner: err, | |
| 44 | }); |
|
44 | from: "@implab/core/text/template-compile" | |
|
|
45 | }); | |||
|
|
46 | else | |||
|
|
47 | trace.error({ | |||
|
|
48 | message: `Failed to load: ${url}`, | |||
|
|
49 | error: err, | |||
|
|
50 | from: "@implab/core/text/template-compile" | |||
|
|
51 | }); | |||
| 45 | }); |
|
52 | }); | |
| 46 | } |
|
53 | } | |
| 47 | }; |
|
54 | }; | |
| @@ -1,12 +1,14 | |||||
| 1 |
export class ConfigError |
|
1 | export class ConfigError { | |
| 2 | inner?: {}; |
|
2 | inner?: {}; | |
| 3 |
|
3 | |||
|
|
4 | message: string; | |||
|
|
5 | ||||
| 4 | path?: string; |
|
6 | path?: string; | |
| 5 |
|
7 | |||
| 6 | configName?: string; |
|
8 | configName?: string; | |
| 7 |
|
9 | |||
| 8 | constructor(message: string, inner?: {}) { |
|
10 | constructor(message: string, inner?: {}) { | |
| 9 |
|
|
11 | this.message = message; | |
| 10 | this.inner = inner; |
|
12 | this.inner = inner; | |
| 11 | } |
|
13 | } | |
| 12 | } |
|
14 | } | |
| @@ -6,7 +6,7 import { | |||||
| 6 | ILifetime, ServiceContainer |
|
6 | ILifetime, ServiceContainer | |
| 7 | } from "./interfaces"; |
|
7 | } from "./interfaces"; | |
| 8 |
|
8 | |||
| 9 | import { argumentNotEmptyString, isPrimitive, isPromise, delegate, argumentOfType, argumentNotNull, get, primitive } from "../safe"; |
|
9 | import { argumentNotEmptyString, isPrimitive, isPromise, delegate, argumentOfType, argumentNotNull, get, primitive, oid, mixin } from "../safe"; | |
| 10 | import { AggregateDescriptor } from "./AggregateDescriptor"; |
|
10 | import { AggregateDescriptor } from "./AggregateDescriptor"; | |
| 11 | import { ValueDescriptor } from "./ValueDescriptor"; |
|
11 | import { ValueDescriptor } from "./ValueDescriptor"; | |
| 12 | import { ReferenceDescriptor } from "./ReferenceDescriptor"; |
|
12 | import { ReferenceDescriptor } from "./ReferenceDescriptor"; | |
| @@ -20,6 +20,7 import { ICancellation } from "../interf | |||||
| 20 | import { isDescriptor } from "./traits"; |
|
20 | import { isDescriptor } from "./traits"; | |
| 21 | import { LazyReferenceDescriptor } from "./LazyReferenceDescriptor"; |
|
21 | import { LazyReferenceDescriptor } from "./LazyReferenceDescriptor"; | |
| 22 | import { LifetimeManager } from "./LifetimeManager"; |
|
22 | import { LifetimeManager } from "./LifetimeManager"; | |
|
|
23 | import { ServiceDescriptorParams } from "./ServiceDescriptor"; | |||
| 23 |
|
24 | |||
| 24 | export interface RegistrationScope<S extends object> { |
|
25 | export interface RegistrationScope<S extends object> { | |
| 25 |
|
26 | |||
| @@ -339,8 +340,8 export class Configuration<S extends obj | |||||
| 339 | } |
|
340 | } | |
| 340 |
|
341 | |||
| 341 | _makeServiceParams(data: ServiceRegistration<any, S>) { |
|
342 | _makeServiceParams(data: ServiceRegistration<any, S>) { | |
| 342 | const opts: any = { |
|
343 | const opts: any = {}; | |
| 343 | }; |
|
344 | ||
| 344 | if (data.services) |
|
345 | if (data.services) | |
| 345 | opts.services = this._visitRegistrations(data.services, "services"); |
|
346 | opts.services = this._visitRegistrations(data.services, "services"); | |
| 346 |
|
347 | |||
| @@ -361,7 +362,7 export class Configuration<S extends obj | |||||
| 361 | this._visit(data.params, "params"); |
|
362 | this._visit(data.params, "params"); | |
| 362 |
|
363 | |||
| 363 | if (data.activation) { |
|
364 | if (data.activation) { | |
| 364 |
opts. |
|
365 | opts.lifetime = this._getLifetimeManager(data.activation, data.typeId); | |
| 365 | } |
|
366 | } | |
| 366 |
|
367 | |||
| 367 | if (data.cleanup) |
|
368 | if (data.cleanup) | |
| @@ -395,7 +396,7 export class Configuration<S extends obj | |||||
| 395 | argumentNotNull(data.$type, "data.$type"); |
|
396 | argumentNotNull(data.$type, "data.$type"); | |
| 396 | this._enter(name); |
|
397 | this._enter(name); | |
| 397 |
|
398 | |||
| 398 | const opts = this._makeServiceParams(data); |
|
399 | const opts = {} as any; | |
| 399 | if (data.$type instanceof Function) { |
|
400 | if (data.$type instanceof Function) { | |
| 400 | opts.type = data.$type; |
|
401 | opts.type = data.$type; | |
| 401 | } else { |
|
402 | } else { | |
| @@ -407,6 +408,11 export class Configuration<S extends obj | |||||
| 407 | }); |
|
408 | }); | |
| 408 | } |
|
409 | } | |
| 409 |
|
410 | |||
|
|
411 | if (!data.typeId && data.activation === "singleton") | |||
|
|
412 | data.typeId = oid(opts.type); | |||
|
|
413 | ||||
|
|
414 | mixin(opts, this._makeServiceParams(data)); | |||
|
|
415 | ||||
| 410 | const d = new TypeServiceDescriptor<S, any, any[]>( |
|
416 | const d = new TypeServiceDescriptor<S, any, any[]>( | |
| 411 | await mapAll(opts) |
|
417 | await mapAll(opts) | |
| 412 | ); |
|
418 | ); | |
| @@ -420,6 +426,9 export class Configuration<S extends obj | |||||
| 420 | argumentOfType(data.$factory, Function, "data.$factory"); |
|
426 | argumentOfType(data.$factory, Function, "data.$factory"); | |
| 421 | this._enter(name); |
|
427 | this._enter(name); | |
| 422 |
|
428 | |||
|
|
429 | if (!data.typeId && data.activation === "singleton") | |||
|
|
430 | data.typeId = oid(data.$factory); | |||
|
|
431 | ||||
| 423 | const opts = this._makeServiceParams(data); |
|
432 | const opts = this._makeServiceParams(data); | |
| 424 | opts.factory = data.$factory; |
|
433 | opts.factory = data.$factory; | |
| 425 |
|
434 | |||
| @@ -149,7 +149,7 export function get(member: string, cont | |||||
| 149 | * <c>this</c> в <c>cb</c>. |
|
149 | * <c>this</c> в <c>cb</c>. | |
| 150 | * @returns {void} |
|
150 | * @returns {void} | |
| 151 | */ |
|
151 | */ | |
| 152 | export function each<T>(obj: T, cb: <X extends keyof T>(v: NonNullable<T[X]>, k: X) => void): void; |
|
152 | export function each<T>(obj: T, cb: <X extends Extract<keyof T, string>>(v: NonNullable<T[X]>, k: X) => void): void; | |
| 153 | export function each<T>(array: T[], cb: (v: T, i: number) => void): void; |
|
153 | export function each<T>(array: T[], cb: (v: T, i: number) => void): void; | |
| 154 | export function each(obj: any, cb: any, thisArg?: any): any; |
|
154 | export function each(obj: any, cb: any, thisArg?: any): any; | |
| 155 | export function each(obj: any, cb: any, thisArg?: any) { |
|
155 | export function each(obj: any, cb: any, thisArg?: any) { | |
General Comments 0
You need to be logged in to leave comments.
Login now
