diff --git a/experiment/container/example1/analysis_options.yaml b/experiment/container/example1/analysis_options.yaml new file mode 100644 index 00000000..ea2c9e94 --- /dev/null +++ b/experiment/container/example1/analysis_options.yaml @@ -0,0 +1 @@ +include: package:lints/recommended.yaml \ No newline at end of file diff --git a/experiment/container/example1/bin/example.dart b/experiment/container/example1/bin/example.dart new file mode 100644 index 00000000..f4c3067c --- /dev/null +++ b/experiment/container/example1/bin/example.dart @@ -0,0 +1,25 @@ +import 'package:angel3_container/mirrors.dart'; +import 'package:angel3_framework/angel3_framework.dart'; +import 'package:angel3_framework/http.dart'; +import 'package:logging/logging.dart'; + +void main() async { + print("Starting up"); + //Logger.root.onRecord.listen(print); + + var app = Angel(logger: Logger('example'), reflector: MirrorsReflector()); + var http = AngelHttp(app); + + app.get("/", (req, res) => "Hello, world!"); + + // Simple fallback to throw a 404 on unknown paths. + app.fallback((req, res) { + throw AngelHttpException.notFound( + message: 'Unknown path: "${req.uri?.path}"', + ); + }); + + var server = await http.startServer('localhost', 3000); + + print("End"); +} diff --git a/experiment/container/example1/pubspec.yaml b/experiment/container/example1/pubspec.yaml new file mode 100644 index 00000000..0dfe86bc --- /dev/null +++ b/experiment/container/example1/pubspec.yaml @@ -0,0 +1,48 @@ +name: example1 +version: 0.0.1 +description: Example 1. +environment: + sdk: '>=2.17.0 <3.0.0' +dependencies: + angel3_container: ^7.0.0 + angel3_http_exception: ^7.0.0 + angel3_framework: ^7.0.0 + angel3_model: ^7.0.0 + angel3_route: ^7.0.0 + angel3_mock_request: ^7.0.0 + belatuk_merge_map: ^4.0.0 + belatuk_combinator: ^4.0.0 + belatuk_http_server: ^3.0.0 + charcode: ^1.2.0 + file: ^6.1.0 + http_parser: ^4.0.0 + http2: ^2.0.0 + logging: ^1.0.0 + matcher: ^0.12.10 + meta: ^1.3.0 + mime: ^1.0.0 + path: ^1.8.0 + quiver: ^3.0.1 + recase: ^4.0.0 + stack_trace: ^1.10.0 + string_scanner: ^1.1.0 + tuple: ^2.0.0 + uuid: ^3.0.1 + collection: ^1.15.0 +dev_dependencies: + http: ^0.13.1 + io: ^1.0.0 + test: ^1.21.0 + lints: ^2.0.0 +# dependency_overrides: +# angel3_container: +# path: ../container/angel_container +# angel3_http_exception: +# path: ../http_exception +# angel3_model: +# path: ../model +# angel3_route: +# path: ../route +# angel3_mock_request: +# path: ../mock_request + diff --git a/experiment/container/example2/analysis_options.yaml b/experiment/container/example2/analysis_options.yaml new file mode 100644 index 00000000..ea2c9e94 --- /dev/null +++ b/experiment/container/example2/analysis_options.yaml @@ -0,0 +1 @@ +include: package:lints/recommended.yaml \ No newline at end of file diff --git a/experiment/container/example2/bin/example.dart b/experiment/container/example2/bin/example.dart new file mode 100644 index 00000000..c2f45790 --- /dev/null +++ b/experiment/container/example2/bin/example.dart @@ -0,0 +1,30 @@ +import 'package:angel3_container/angel3_container.dart'; +import 'package:angel3_container_generator/angel3_container_generator.dart'; +import 'package:angel3_framework/angel3_framework.dart'; +import 'package:angel3_framework/http.dart'; + +import 'example.reflectable.dart'; + +@Expose('/controller') +class MyController extends Controller { + @Expose('/') + a() => "Hello, world!"; +} + +void main() async { + var reflector = const GeneratedReflector(); + Container container = Container(reflector); + + container.registerSingleton(MyController()); + + initializeReflectable(); + + var app = Angel(reflector: reflector); + + var http = AngelHttp(app); + + await app.mountController(); + + var server = await http.startServer(); + print("Angel server listening at ${http.uri}"); +} diff --git a/experiment/container/example2/bin/example.reflectable.dart b/experiment/container/example2/bin/example.reflectable.dart new file mode 100644 index 00000000..66225fce --- /dev/null +++ b/experiment/container/example2/bin/example.reflectable.dart @@ -0,0 +1,300 @@ +// This file has been generated by the reflectable package. +// https://github.com/dart-lang/reflectable. +// @dart = 2.12 + +import 'dart:core'; +import 'package:angel3_container_generator/angel3_container_generator.dart' + as prefix0; +import 'package:reflectable/capability.dart' as prefix1; +import 'package:reflectable/mirrors.dart' as prefix2; + +// ignore_for_file: camel_case_types +// ignore_for_file: implementation_imports +// ignore_for_file: prefer_adjacent_string_concatenation +// ignore_for_file: prefer_collection_literals +// ignore_for_file: unnecessary_const + +// ignore:unused_import +import 'package:reflectable/mirrors.dart' as m; +// ignore:unused_import +import 'package:reflectable/src/reflectable_builder_based.dart' as r; +// ignore:unused_import +import 'package:reflectable/reflectable.dart' as r show Reflectable; + +final _data = { + const prefix0.ContainedReflectable(): r.ReflectorData( + [ + r.NonGenericClassMirrorImpl( + r'ContainedReflectable', + r'.ContainedReflectable', + 134217735, + 0, + const prefix0.ContainedReflectable(), + const [0], + const [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], + const [], + -1, + {}, + {}, + {r'': (bool b) => () => b ? prefix0.ContainedReflectable() : null}, + 0, + 0, + const [], + const [prefix0.contained], + null) + ], + [ + r.MethodMirrorImpl(r'', 128, 0, -1, 0, 0, const [], const [], + const prefix0.ContainedReflectable(), const []), + r.MethodMirrorImpl(r'==', 2097154, -1, -1, 1, 1, const [], + const [0], const prefix0.ContainedReflectable(), const []), + r.MethodMirrorImpl(r'toString', 2097154, -1, -1, 2, 2, const [], + const [], const prefix0.ContainedReflectable(), const []), + r.MethodMirrorImpl( + r'noSuchMethod', + 524290, + -1, + -1, + -1, + -1, + const [], + const [1], + const prefix0.ContainedReflectable(), + const []), + r.MethodMirrorImpl(r'hashCode', 2097155, -1, -1, 3, 3, const [], + const [], const prefix0.ContainedReflectable(), const []), + r.MethodMirrorImpl(r'runtimeType', 2097155, -1, -1, 4, 4, const [], + const [], const prefix0.ContainedReflectable(), const []), + r.MethodMirrorImpl( + r'capabilities', + 35651587, + -1, + -1, + 6, + 7, + const [5], + const [], + const prefix0.ContainedReflectable(), + const []), + r.MethodMirrorImpl( + r'canReflect', + 2097154, + -1, + -1, + 1, + 1, + const [], + const [2], + const prefix0.ContainedReflectable(), + const [override]), + r.MethodMirrorImpl( + r'reflect', + 2097154, + -1, + -1, + 8, + 8, + const [], + const [3], + const prefix0.ContainedReflectable(), + const [override]), + r.MethodMirrorImpl( + r'canReflectType', + 2097154, + -1, + -1, + 1, + 1, + const [], + const [4], + const prefix0.ContainedReflectable(), + const [override]), + r.MethodMirrorImpl( + r'reflectType', + 2097154, + -1, + -1, + 9, + 9, + const [], + const [5], + const prefix0.ContainedReflectable(), + const [override]), + r.MethodMirrorImpl( + r'findLibrary', + 2097154, + -1, + -1, + 10, + 10, + const [], + const [6], + const prefix0.ContainedReflectable(), + const [override]), + r.MethodMirrorImpl( + r'libraries', + 35651587, + -1, + -1, + 12, + 13, + const [11, 10], + const [], + const prefix0.ContainedReflectable(), + const [override]), + r.MethodMirrorImpl( + r'annotatedClasses', + 35651587, + -1, + -1, + 15, + 16, + const [14], + const [], + const prefix0.ContainedReflectable(), + const [override]) + ], + [ + r.ParameterMirrorImpl( + r'other', + 134348806, + 1, + const prefix0.ContainedReflectable(), + -1, + 17, + 17, + const [], + const [], + null, + null), + r.ParameterMirrorImpl( + r'invocation', + 134348806, + 3, + const prefix0.ContainedReflectable(), + -1, + 18, + 18, + const [], + const [], + null, + null), + r.ParameterMirrorImpl( + r'reflectee', + 134348806, + 7, + const prefix0.ContainedReflectable(), + -1, + 17, + 17, + const [], + const [], + null, + null), + r.ParameterMirrorImpl( + r'reflectee', + 134348806, + 8, + const prefix0.ContainedReflectable(), + -1, + 17, + 17, + const [], + const [], + null, + null), + r.ParameterMirrorImpl( + r'type', + 134348806, + 9, + const prefix0.ContainedReflectable(), + -1, + 4, + 4, + const [], + const [], + null, + null), + r.ParameterMirrorImpl( + r'type', + 134348806, + 10, + const prefix0.ContainedReflectable(), + -1, + 4, + 4, + const [], + const [], + null, + null), + r.ParameterMirrorImpl( + r'libraryName', + 134348806, + 11, + const prefix0.ContainedReflectable(), + -1, + 2, + 2, + const [], + const [], + null, + null) + ], + [ + prefix0.ContainedReflectable, + bool, + String, + int, + Type, + prefix1.ReflectCapability, + const m.TypeValue>().type, + List, + prefix2.InstanceMirror, + prefix2.TypeMirror, + prefix2.LibraryMirror, + Uri, + const m.TypeValue>().type, + Map, + prefix2.ClassMirror, + const m.TypeValue>().type, + Iterable, + Object, + Invocation + ], + 1, + { + r'==': (dynamic instance) => (x) => instance == x, + r'toString': (dynamic instance) => instance.toString, + r'noSuchMethod': (dynamic instance) => instance.noSuchMethod, + r'hashCode': (dynamic instance) => instance.hashCode, + r'runtimeType': (dynamic instance) => instance.runtimeType, + r'capabilities': (dynamic instance) => instance.capabilities, + r'canReflect': (dynamic instance) => instance.canReflect, + r'reflect': (dynamic instance) => instance.reflect, + r'canReflectType': (dynamic instance) => instance.canReflectType, + r'reflectType': (dynamic instance) => instance.reflectType, + r'findLibrary': (dynamic instance) => instance.findLibrary, + r'libraries': (dynamic instance) => instance.libraries, + r'annotatedClasses': (dynamic instance) => instance.annotatedClasses + }, + {}, + [ + r.LibraryMirrorImpl( + r'', + Uri.parse(r'reflectable://0/'), + const prefix0.ContainedReflectable(), + const [], + {}, + {}, + const [], + null) + ], + []) +}; + +final _memberSymbolMap = null; + +void initializeReflectable() { + r.data = _data; + r.memberSymbolMap = _memberSymbolMap; +} diff --git a/experiment/container/example2/pubspec.yaml b/experiment/container/example2/pubspec.yaml new file mode 100644 index 00000000..82d0f706 --- /dev/null +++ b/experiment/container/example2/pubspec.yaml @@ -0,0 +1,49 @@ +name: example2 +version: 0.0.1 +description: Example 2. +environment: + sdk: '>=2.17.0 <3.0.0' +dependencies: + angel3_container: ^7.0.0 + angel3_container_generator: ^7.0.0 + angel3_http_exception: ^7.0.0 + angel3_framework: ^7.0.0 + angel3_model: ^7.0.0 + angel3_route: ^7.0.0 + angel3_mock_request: ^7.0.0 + belatuk_merge_map: ^4.0.0 + belatuk_combinator: ^4.0.0 + belatuk_http_server: ^3.0.0 + charcode: ^1.2.0 + file: ^6.1.0 + http_parser: ^4.0.0 + http2: ^2.0.0 + logging: ^1.0.0 + matcher: ^0.12.10 + meta: ^1.3.0 + mime: ^1.0.0 + path: ^1.8.0 + quiver: ^3.0.1 + recase: ^4.0.0 + stack_trace: ^1.10.0 + string_scanner: ^1.1.0 + tuple: ^2.0.0 + uuid: ^3.0.1 + collection: ^1.15.0 +dev_dependencies: + http: ^0.13.1 + io: ^1.0.0 + test: ^1.21.0 + lints: ^2.0.0 +# dependency_overrides: +# angel3_container: +# path: ../container/angel_container +# angel3_http_exception: +# path: ../http_exception +# angel3_model: +# path: ../model +# angel3_route: +# path: ../route +# angel3_mock_request: +# path: ../mock_request +