()
| 319 | * ``` |
| 320 | */ |
| 321 | export const Service = <Self>() => |
| 322 | < |
| 323 | const Id extends string, |
| 324 | Options extends |
| 325 | | NoExcessProperties< |
| 326 | { |
| 327 | readonly lookup: (key: any) => Layer.Layer<any, any, any> |
| 328 | readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> |
| 329 | readonly idleTimeToLive?: Duration.DurationInput | undefined |
| 330 | readonly preloadKeys?: |
| 331 | | Iterable<Options extends { readonly lookup: (key: infer K) => any } ? K : never> |
| 332 | | undefined |
| 333 | }, |
| 334 | Options |
| 335 | > |
| 336 | | NoExcessProperties<{ |
| 337 | readonly layers: Record<string, Layer.Layer<any, any, any>> |
| 338 | readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> |
| 339 | readonly idleTimeToLive?: Duration.DurationInput | undefined |
| 340 | readonly preload?: boolean |
| 341 | }, Options> |
| 342 | >( |
| 343 | id: Id, |
| 344 | options: Options |
| 345 | ): TagClass< |
| 346 | Self, |
| 347 | Id, |
| 348 | Options extends { readonly lookup: (key: infer K) => any } ? K |
| 349 | : Options extends { readonly layers: infer Layers } ? keyof Layers |
| 350 | : never, |
| 351 | Service.Success<Options>, |
| 352 | Options extends { readonly preload: true } ? never : Service.Error<Options>, |
| 353 | Service.Context<Options>, |
| 354 | Options extends { readonly preload: true } ? Service.Error<Options> |
| 355 | : Options extends { readonly preloadKey: Iterable<any> } ? Service.Error<Options> |
| 356 | : never, |
| 357 | Options extends { readonly dependencies: ReadonlyArray<any> } ? Options["dependencies"][number] : never |
| 358 | > => { |
| 359 | const Err = globalThis.Error as any |
| 360 | const limit = Err.stackTraceLimit |
| 361 | Err.stackTraceLimit = 2 |
| 362 | const creationError = new Err() |
| 363 | Err.stackTraceLimit = limit |
| 364 | |
| 365 | function TagClass() {} |
| 366 | const TagClass_ = TagClass as any as Mutable<TagClass<Self, Id, string, any, any, any, any, any>> |
| 367 | Object.setPrototypeOf(TagClass, Object.getPrototypeOf(Context.GenericTag<Self, any>(id))) |
| 368 | TagClass.key = id |
| 369 | Object.defineProperty(TagClass, "stack", { |
| 370 | get() { |
| 371 | return creationError.stack |
| 372 | } |
| 373 | }) |
| 374 | |
| 375 | TagClass_.DefaultWithoutDependencies = Layer.scoped( |
| 376 | TagClass_, |
| 377 | "lookup" in options |
| 378 | ? make(options.lookup, options) |
nothing calls this directly
no test coverage detected