1 | | | import '../pool/worker_pool.dart'; |
2 | | | import 'target_platform.dart'; |
3 | | |
|
4 | | | const localService = SquadronService.local(); |
5 | | | const vmService = SquadronService.vm(); |
6 | | | const localWorker = LocalWorkerParam._(); |
7 | | |
|
8 | | | class LocalWorkerParam { |
9 | | 12 | const LocalWorkerParam._(); |
10 | | | } |
11 | | |
|
12 | | | /// Annotation for service classes to be wrapped as workers. |
13 | | | class SquadronService { |
14 | | 13 | const SquadronService({ |
15 | | | this.pool = true, |
16 | | | this.targetPlatform = TargetPlatform.all, |
17 | | | String? baseUrl, |
18 | | | }) : baseUrl = baseUrl ?? '', |
19 | | | local = false; |
20 | | |
|
21 | | 1 | const SquadronService.web({bool pool = true, String? baseUrl}) |
22 | | 1 | : this(pool: pool, targetPlatform: TargetPlatform.web, baseUrl: baseUrl); |
23 | | |
|
24 | | 12 | const SquadronService.vm({bool pool = true}) |
25 | | 0 | : this(pool: pool, targetPlatform: TargetPlatform.vm); |
26 | | |
|
27 | | 12 | const SquadronService.local() |
28 | | | : pool = false, |
29 | | | local = true, |
30 | | | targetPlatform = TargetPlatform.none, |
31 | | | baseUrl = ''; |
32 | | |
|
33 | | | /// Controls code generation of a [WorkerPool] exposing the target service |
34 | | | /// class. `true` by default. |
35 | | | final bool pool; |
36 | | |
|
37 | | | /// Controls code generation of a [LocalWorkerClient] exposing the target |
38 | | | /// service class. `false` by default. |
39 | | | final bool local; |
40 | | |
|
41 | | | /// Controls code generation of a entry points for various platforms. |
42 | | | final int targetPlatform; |
43 | | |
|
44 | | | /// For Web-based workers, indicates the [baseUrl] where the Web Worker will |
45 | | | /// be exposed in production. |
46 | | | final String baseUrl; |
47 | | | } |