diff --git a/.melos/base.yaml b/.melos/base.yaml
index 0c993bc..9fbadd6 100644
--- a/.melos/base.yaml
+++ b/.melos/base.yaml
@@ -1,6 +1,7 @@
name: protevus_platform
repository: https://github.com/protevus/platform
packages:
+ - fig/**
- common/**
- drivers/**
- packages/**
diff --git a/fig/cache/.gitignore b/fig/cache/.gitignore
new file mode 100644
index 0000000..3cceda5
--- /dev/null
+++ b/fig/cache/.gitignore
@@ -0,0 +1,7 @@
+# https://dart.dev/guides/libraries/private-files
+# Created by `dart pub`
+.dart_tool/
+
+# Avoid committing pubspec.lock for library packages; see
+# https://dart.dev/guides/libraries/private-files#pubspeclock.
+pubspec.lock
diff --git a/fig/cache/CHANGELOG.md b/fig/cache/CHANGELOG.md
new file mode 100644
index 0000000..effe43c
--- /dev/null
+++ b/fig/cache/CHANGELOG.md
@@ -0,0 +1,3 @@
+## 1.0.0
+
+- Initial version.
diff --git a/fig/cache/LICENSE.md b/fig/cache/LICENSE.md
new file mode 100644
index 0000000..0fd0d03
--- /dev/null
+++ b/fig/cache/LICENSE.md
@@ -0,0 +1,10 @@
+The MIT License (MIT)
+
+The Laravel Framework is Copyright (c) Taylor Otwell
+The Fabric Framework is Copyright (c) Vieo, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/fig/cache/README.md b/fig/cache/README.md
new file mode 100644
index 0000000..757f4c9
--- /dev/null
+++ b/fig/cache/README.md
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/fig/cache/analysis_options.yaml b/fig/cache/analysis_options.yaml
new file mode 100644
index 0000000..dee8927
--- /dev/null
+++ b/fig/cache/analysis_options.yaml
@@ -0,0 +1,30 @@
+# This file configures the static analysis results for your project (errors,
+# warnings, and lints).
+#
+# This enables the 'recommended' set of lints from `package:lints`.
+# This set helps identify many issues that may lead to problems when running
+# or consuming Dart code, and enforces writing Dart using a single, idiomatic
+# style and format.
+#
+# If you want a smaller set of lints you can change this to specify
+# 'package:lints/core.yaml'. These are just the most critical lints
+# (the recommended set includes the core lints).
+# The core lints are also what is used by pub.dev for scoring packages.
+
+include: package:lints/recommended.yaml
+
+# Uncomment the following section to specify additional rules.
+
+# linter:
+# rules:
+# - camel_case_types
+
+# analyzer:
+# exclude:
+# - path/to/excluded/files/**
+
+# For more information about the core and recommended set of lints, see
+# https://dart.dev/go/core-lints
+
+# For additional information about configuring this file, see
+# https://dart.dev/guides/language/analysis-options
diff --git a/fig/cache/doc/.gitkeep b/fig/cache/doc/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/cache/example/.gitkeep b/fig/cache/example/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/cache/lib/cache.dart b/fig/cache/lib/cache.dart
new file mode 100644
index 0000000..2f7b35f
--- /dev/null
+++ b/fig/cache/lib/cache.dart
@@ -0,0 +1,9 @@
+/// A PSR-6 compatible caching library for Dart.
+///
+/// This library provides interfaces for caching implementations following
+/// the PSR-6 Cache Interface specification.
+library cache;
+
+export 'src/cache_item_interface.dart';
+export 'src/cache_item_pool_interface.dart';
+export 'src/exceptions.dart';
diff --git a/fig/cache/lib/src/cache_item_interface.dart b/fig/cache/lib/src/cache_item_interface.dart
new file mode 100644
index 0000000..89fa42f
--- /dev/null
+++ b/fig/cache/lib/src/cache_item_interface.dart
@@ -0,0 +1,31 @@
+/// A cache item interface representing a single cache entry.
+abstract class CacheItemInterface {
+ /// The key for this cache item.
+ String get key;
+
+ /// Retrieves the value of the item from the cache.
+ ///
+ /// Returns null if the item does not exist or has expired.
+ dynamic get();
+
+ /// Confirms if the cache item lookup resulted in a cache hit.
+ bool get isHit;
+
+ /// Sets the value represented by this cache item.
+ ///
+ /// [value] The serializable value to be stored.
+ /// Returns the invoked object.
+ CacheItemInterface set(dynamic value);
+
+ /// Sets the expiration time for this cache item.
+ ///
+ /// [expiration] The point in time after which the item MUST be considered expired.
+ /// Returns the invoked object.
+ CacheItemInterface expiresAt(DateTime? expiration);
+
+ /// Sets the expiration time for this cache item relative to the current time.
+ ///
+ /// [time] The period of time from now after which the item MUST be considered expired.
+ /// Returns the invoked object.
+ CacheItemInterface expiresAfter(Duration? time);
+}
diff --git a/fig/cache/lib/src/cache_item_pool_interface.dart b/fig/cache/lib/src/cache_item_pool_interface.dart
new file mode 100644
index 0000000..7ef726a
--- /dev/null
+++ b/fig/cache/lib/src/cache_item_pool_interface.dart
@@ -0,0 +1,61 @@
+import 'cache_item_interface.dart';
+
+/// A cache pool interface for managing cache items.
+abstract class CacheItemPoolInterface {
+ /// Returns a Cache Item representing the specified key.
+ ///
+ /// [key] The key for which to return the corresponding Cache Item.
+ /// Returns The corresponding Cache Item.
+ /// Throws InvalidArgumentException if the [key] string is not valid.
+ CacheItemInterface getItem(String key);
+
+ /// Returns a list of Cache Items keyed by the cache keys provided.
+ ///
+ /// [keys] A list of keys that can be obtained in a single operation.
+ /// Returns A list of Cache Items indexed by the cache keys.
+ /// Throws InvalidArgumentException if any of the keys in [keys] is not valid.
+ Map getItems(List keys);
+
+ /// Confirms if the cache contains specified cache item.
+ ///
+ /// [key] The key for which to check existence.
+ /// Returns true if item exists in the cache and false otherwise.
+ /// Throws InvalidArgumentException if the [key] string is not valid.
+ bool hasItem(String key);
+
+ /// Deletes all items in the pool.
+ ///
+ /// Returns true if the pool was successfully cleared. False if there was an error.
+ bool clear();
+
+ /// Removes the item from the pool.
+ ///
+ /// [key] The key to delete.
+ /// Returns true if the item was successfully removed. False if there was an error.
+ /// Throws InvalidArgumentException if the [key] string is not valid.
+ bool deleteItem(String key);
+
+ /// Removes multiple items from the pool.
+ ///
+ /// [keys] A list of keys that should be removed.
+ /// Returns true if the items were successfully removed. False if there was an error.
+ /// Throws InvalidArgumentException if any of the keys in [keys] is not valid.
+ bool deleteItems(List keys);
+
+ /// Persists a cache item immediately.
+ ///
+ /// [item] The cache item to save.
+ /// Returns true if the item was successfully persisted. False if there was an error.
+ bool save(CacheItemInterface item);
+
+ /// Persists multiple cache items immediately.
+ ///
+ /// [items] A list of cache items to save.
+ /// Returns true if all items were successfully persisted. False if there was an error.
+ bool saveDeferred(CacheItemInterface item);
+
+ /// Persists any deferred cache items.
+ ///
+ /// Returns true if all not-yet-saved items were successfully persisted. False if there was an error.
+ bool commit();
+}
diff --git a/fig/cache/lib/src/exceptions.dart b/fig/cache/lib/src/exceptions.dart
new file mode 100644
index 0000000..7ff923a
--- /dev/null
+++ b/fig/cache/lib/src/exceptions.dart
@@ -0,0 +1,23 @@
+/// Base exception interface for cache exceptions.
+class CacheException implements Exception {
+ /// The error message.
+ final String message;
+
+ /// Creates a new cache exception.
+ const CacheException([this.message = '']);
+
+ @override
+ String toString() =>
+ message.isEmpty ? 'CacheException' : 'CacheException: $message';
+}
+
+/// Exception interface for invalid cache arguments.
+class InvalidArgumentException extends CacheException {
+ /// Creates a new invalid argument exception.
+ const InvalidArgumentException([String message = '']) : super(message);
+
+ @override
+ String toString() => message.isEmpty
+ ? 'InvalidArgumentException'
+ : 'InvalidArgumentException: $message';
+}
diff --git a/fig/cache/pubspec.yaml b/fig/cache/pubspec.yaml
new file mode 100644
index 0000000..5c7964c
--- /dev/null
+++ b/fig/cache/pubspec.yaml
@@ -0,0 +1,13 @@
+name: dsr_cache
+description: A PSR-6 compatible caching interface for Dart. Provides standardized interfaces for cache implementations including CacheItemInterface and CacheItemPoolInterface.
+version: 0.0.1
+homepage: https://dart-fig.org
+
+environment:
+ sdk: ^3.4.2
+
+dependencies: {}
+
+dev_dependencies:
+ lints: ^3.0.0
+ test: ^1.24.0
diff --git a/fig/cache/test/.gitkeep b/fig/cache/test/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/clock/.gitignore b/fig/clock/.gitignore
new file mode 100644
index 0000000..3cceda5
--- /dev/null
+++ b/fig/clock/.gitignore
@@ -0,0 +1,7 @@
+# https://dart.dev/guides/libraries/private-files
+# Created by `dart pub`
+.dart_tool/
+
+# Avoid committing pubspec.lock for library packages; see
+# https://dart.dev/guides/libraries/private-files#pubspeclock.
+pubspec.lock
diff --git a/fig/clock/CHANGELOG.md b/fig/clock/CHANGELOG.md
new file mode 100644
index 0000000..effe43c
--- /dev/null
+++ b/fig/clock/CHANGELOG.md
@@ -0,0 +1,3 @@
+## 1.0.0
+
+- Initial version.
diff --git a/fig/clock/LICENSE.md b/fig/clock/LICENSE.md
new file mode 100644
index 0000000..0fd0d03
--- /dev/null
+++ b/fig/clock/LICENSE.md
@@ -0,0 +1,10 @@
+The MIT License (MIT)
+
+The Laravel Framework is Copyright (c) Taylor Otwell
+The Fabric Framework is Copyright (c) Vieo, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/fig/clock/README.md b/fig/clock/README.md
new file mode 100644
index 0000000..757f4c9
--- /dev/null
+++ b/fig/clock/README.md
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/fig/clock/analysis_options.yaml b/fig/clock/analysis_options.yaml
new file mode 100644
index 0000000..dee8927
--- /dev/null
+++ b/fig/clock/analysis_options.yaml
@@ -0,0 +1,30 @@
+# This file configures the static analysis results for your project (errors,
+# warnings, and lints).
+#
+# This enables the 'recommended' set of lints from `package:lints`.
+# This set helps identify many issues that may lead to problems when running
+# or consuming Dart code, and enforces writing Dart using a single, idiomatic
+# style and format.
+#
+# If you want a smaller set of lints you can change this to specify
+# 'package:lints/core.yaml'. These are just the most critical lints
+# (the recommended set includes the core lints).
+# The core lints are also what is used by pub.dev for scoring packages.
+
+include: package:lints/recommended.yaml
+
+# Uncomment the following section to specify additional rules.
+
+# linter:
+# rules:
+# - camel_case_types
+
+# analyzer:
+# exclude:
+# - path/to/excluded/files/**
+
+# For more information about the core and recommended set of lints, see
+# https://dart.dev/go/core-lints
+
+# For additional information about configuring this file, see
+# https://dart.dev/guides/language/analysis-options
diff --git a/fig/clock/doc/.gitkeep b/fig/clock/doc/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/clock/example/.gitkeep b/fig/clock/example/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/clock/lib/clock.dart b/fig/clock/lib/clock.dart
new file mode 100644
index 0000000..a85b82d
--- /dev/null
+++ b/fig/clock/lib/clock.dart
@@ -0,0 +1,7 @@
+/// A PSR-20 compatible clock interface for Dart.
+///
+/// This library provides a minimal interface for reading the current time,
+/// following the PSR-20 Clock Interface specification.
+library clock;
+
+export 'src/clock_interface.dart';
diff --git a/fig/clock/lib/src/clock_interface.dart b/fig/clock/lib/src/clock_interface.dart
new file mode 100644
index 0000000..1e57123
--- /dev/null
+++ b/fig/clock/lib/src/clock_interface.dart
@@ -0,0 +1,10 @@
+/// A minimal interface for reading the current time.
+///
+/// This interface follows PSR-20 Clock Interface specification.
+abstract class ClockInterface {
+ /// Returns the current time as a DateTime instance.
+ ///
+ /// The returned DateTime MUST be an immutable value object.
+ /// The timezone of the returned value is not guaranteed and should not be relied upon.
+ DateTime now();
+}
diff --git a/fig/clock/pubspec.yaml b/fig/clock/pubspec.yaml
new file mode 100644
index 0000000..663e105
--- /dev/null
+++ b/fig/clock/pubspec.yaml
@@ -0,0 +1,13 @@
+name: dsr_clock
+description: A PSR-20 compatible clock interface for Dart. Provides a minimal, standardized interface for reading the current time across different implementations.
+version: 0.0.1
+homepage: https://dart-fig.org
+
+environment:
+ sdk: ^3.4.2
+
+dependencies: {}
+
+dev_dependencies:
+ lints: ^3.0.0
+ test: ^1.24.0
diff --git a/fig/clock/test/.gitkeep b/fig/clock/test/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/container/.gitignore b/fig/container/.gitignore
new file mode 100644
index 0000000..3cceda5
--- /dev/null
+++ b/fig/container/.gitignore
@@ -0,0 +1,7 @@
+# https://dart.dev/guides/libraries/private-files
+# Created by `dart pub`
+.dart_tool/
+
+# Avoid committing pubspec.lock for library packages; see
+# https://dart.dev/guides/libraries/private-files#pubspeclock.
+pubspec.lock
diff --git a/fig/container/CHANGELOG.md b/fig/container/CHANGELOG.md
new file mode 100644
index 0000000..effe43c
--- /dev/null
+++ b/fig/container/CHANGELOG.md
@@ -0,0 +1,3 @@
+## 1.0.0
+
+- Initial version.
diff --git a/fig/container/LICENSE.md b/fig/container/LICENSE.md
new file mode 100644
index 0000000..0fd0d03
--- /dev/null
+++ b/fig/container/LICENSE.md
@@ -0,0 +1,10 @@
+The MIT License (MIT)
+
+The Laravel Framework is Copyright (c) Taylor Otwell
+The Fabric Framework is Copyright (c) Vieo, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/fig/container/README.md b/fig/container/README.md
new file mode 100644
index 0000000..757f4c9
--- /dev/null
+++ b/fig/container/README.md
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/fig/container/analysis_options.yaml b/fig/container/analysis_options.yaml
new file mode 100644
index 0000000..dee8927
--- /dev/null
+++ b/fig/container/analysis_options.yaml
@@ -0,0 +1,30 @@
+# This file configures the static analysis results for your project (errors,
+# warnings, and lints).
+#
+# This enables the 'recommended' set of lints from `package:lints`.
+# This set helps identify many issues that may lead to problems when running
+# or consuming Dart code, and enforces writing Dart using a single, idiomatic
+# style and format.
+#
+# If you want a smaller set of lints you can change this to specify
+# 'package:lints/core.yaml'. These are just the most critical lints
+# (the recommended set includes the core lints).
+# The core lints are also what is used by pub.dev for scoring packages.
+
+include: package:lints/recommended.yaml
+
+# Uncomment the following section to specify additional rules.
+
+# linter:
+# rules:
+# - camel_case_types
+
+# analyzer:
+# exclude:
+# - path/to/excluded/files/**
+
+# For more information about the core and recommended set of lints, see
+# https://dart.dev/go/core-lints
+
+# For additional information about configuring this file, see
+# https://dart.dev/guides/language/analysis-options
diff --git a/fig/container/doc/.gitkeep b/fig/container/doc/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/container/example/.gitkeep b/fig/container/example/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/container/lib/container.dart b/fig/container/lib/container.dart
new file mode 100644
index 0000000..d907545
--- /dev/null
+++ b/fig/container/lib/container.dart
@@ -0,0 +1,8 @@
+/// A PSR-11 compatible container interface for Dart.
+///
+/// This library provides interfaces for dependency injection containers
+/// following the PSR-11 Container Interface specification.
+library container;
+
+export 'src/container_interface.dart';
+export 'src/exceptions.dart';
diff --git a/fig/container/lib/src/container_interface.dart b/fig/container/lib/src/container_interface.dart
new file mode 100644
index 0000000..e63f940
--- /dev/null
+++ b/fig/container/lib/src/container_interface.dart
@@ -0,0 +1,25 @@
+import 'exceptions.dart';
+
+/// Describes the interface of a container that exposes methods to read its entries.
+abstract class ContainerInterface {
+ /// Finds an entry of the container by its identifier and returns it.
+ ///
+ /// [id] Identifier of the entry to look for.
+ ///
+ /// Returns the entry.
+ ///
+ /// Throws [NotFoundExceptionInterface] if no entry was found for **this** identifier.
+ /// Throws [ContainerExceptionInterface] if an error occurred while retrieving the entry.
+ dynamic get(String id);
+
+ /// Returns true if the container can return an entry for the given identifier.
+ /// Returns false otherwise.
+ ///
+ /// [id] Identifier of the entry to look for.
+ ///
+ /// Returns true if the container can return an entry for the given identifier.
+ /// Returns false otherwise.
+ ///
+ /// Throws [ContainerExceptionInterface] if an error occurred while retrieving the entry.
+ bool has(String id);
+}
diff --git a/fig/container/lib/src/exceptions.dart b/fig/container/lib/src/exceptions.dart
new file mode 100644
index 0000000..d4a2540
--- /dev/null
+++ b/fig/container/lib/src/exceptions.dart
@@ -0,0 +1,45 @@
+/// Base interface representing a generic exception in a container.
+abstract class ContainerExceptionInterface implements Exception {
+ /// The error message.
+ String get message;
+}
+
+/// Interface representing an exception when a requested entry is not found.
+abstract class NotFoundExceptionInterface
+ implements ContainerExceptionInterface {
+ /// The ID that was not found.
+ String get id;
+}
+
+/// A concrete implementation of ContainerExceptionInterface.
+class ContainerException implements ContainerExceptionInterface {
+ @override
+ final String message;
+
+ /// Creates a new container exception.
+ const ContainerException([this.message = '']);
+
+ @override
+ String toString() =>
+ message.isEmpty ? 'ContainerException' : 'ContainerException: $message';
+}
+
+/// A concrete implementation of NotFoundExceptionInterface.
+class NotFoundException implements NotFoundExceptionInterface {
+ @override
+ final String message;
+
+ @override
+ final String id;
+
+ /// Creates a new not found exception.
+ const NotFoundException(this.id, [this.message = '']);
+
+ @override
+ String toString() {
+ if (message.isEmpty) {
+ return 'NotFoundException: No entry was found for "$id" identifier';
+ }
+ return 'NotFoundException: $message';
+ }
+}
diff --git a/fig/container/pubspec.yaml b/fig/container/pubspec.yaml
new file mode 100644
index 0000000..7bf19d1
--- /dev/null
+++ b/fig/container/pubspec.yaml
@@ -0,0 +1,13 @@
+name: dsr_container
+description: A PSR-11 compatible container interface for Dart. Provides standardized interfaces for dependency injection containers including ContainerInterface and related exceptions.
+version: 0.0.1
+homepage: https://dart-fig.org
+
+environment:
+ sdk: ^3.4.2
+
+dependencies: {}
+
+dev_dependencies:
+ lints: ^3.0.0
+ test: ^1.24.0
diff --git a/fig/container/test/.gitkeep b/fig/container/test/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/event_dispatcher/.gitignore b/fig/event_dispatcher/.gitignore
new file mode 100644
index 0000000..3cceda5
--- /dev/null
+++ b/fig/event_dispatcher/.gitignore
@@ -0,0 +1,7 @@
+# https://dart.dev/guides/libraries/private-files
+# Created by `dart pub`
+.dart_tool/
+
+# Avoid committing pubspec.lock for library packages; see
+# https://dart.dev/guides/libraries/private-files#pubspeclock.
+pubspec.lock
diff --git a/fig/event_dispatcher/CHANGELOG.md b/fig/event_dispatcher/CHANGELOG.md
new file mode 100644
index 0000000..effe43c
--- /dev/null
+++ b/fig/event_dispatcher/CHANGELOG.md
@@ -0,0 +1,3 @@
+## 1.0.0
+
+- Initial version.
diff --git a/fig/event_dispatcher/LICENSE.md b/fig/event_dispatcher/LICENSE.md
new file mode 100644
index 0000000..0fd0d03
--- /dev/null
+++ b/fig/event_dispatcher/LICENSE.md
@@ -0,0 +1,10 @@
+The MIT License (MIT)
+
+The Laravel Framework is Copyright (c) Taylor Otwell
+The Fabric Framework is Copyright (c) Vieo, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/fig/event_dispatcher/README.md b/fig/event_dispatcher/README.md
new file mode 100644
index 0000000..757f4c9
--- /dev/null
+++ b/fig/event_dispatcher/README.md
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/fig/event_dispatcher/analysis_options.yaml b/fig/event_dispatcher/analysis_options.yaml
new file mode 100644
index 0000000..dee8927
--- /dev/null
+++ b/fig/event_dispatcher/analysis_options.yaml
@@ -0,0 +1,30 @@
+# This file configures the static analysis results for your project (errors,
+# warnings, and lints).
+#
+# This enables the 'recommended' set of lints from `package:lints`.
+# This set helps identify many issues that may lead to problems when running
+# or consuming Dart code, and enforces writing Dart using a single, idiomatic
+# style and format.
+#
+# If you want a smaller set of lints you can change this to specify
+# 'package:lints/core.yaml'. These are just the most critical lints
+# (the recommended set includes the core lints).
+# The core lints are also what is used by pub.dev for scoring packages.
+
+include: package:lints/recommended.yaml
+
+# Uncomment the following section to specify additional rules.
+
+# linter:
+# rules:
+# - camel_case_types
+
+# analyzer:
+# exclude:
+# - path/to/excluded/files/**
+
+# For more information about the core and recommended set of lints, see
+# https://dart.dev/go/core-lints
+
+# For additional information about configuring this file, see
+# https://dart.dev/guides/language/analysis-options
diff --git a/fig/event_dispatcher/doc/.gitkeep b/fig/event_dispatcher/doc/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/event_dispatcher/example/.gitkeep b/fig/event_dispatcher/example/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/event_dispatcher/lib/event_dispatcher.dart b/fig/event_dispatcher/lib/event_dispatcher.dart
new file mode 100644
index 0000000..3407c82
--- /dev/null
+++ b/fig/event_dispatcher/lib/event_dispatcher.dart
@@ -0,0 +1,9 @@
+/// A PSR-14 compatible event dispatcher interface for Dart.
+///
+/// This library provides interfaces for event dispatching systems
+/// following the PSR-14 Event Dispatcher specification.
+library event_dispatcher;
+
+export 'src/event_dispatcher_interface.dart';
+export 'src/listener_provider_interface.dart';
+export 'src/stoppable_event_interface.dart';
diff --git a/fig/event_dispatcher/lib/src/event_dispatcher_interface.dart b/fig/event_dispatcher/lib/src/event_dispatcher_interface.dart
new file mode 100644
index 0000000..8826bf8
--- /dev/null
+++ b/fig/event_dispatcher/lib/src/event_dispatcher_interface.dart
@@ -0,0 +1,16 @@
+/// Interface for event dispatchers.
+abstract class EventDispatcherInterface {
+ /// Provides all relevant listeners with an event to process.
+ ///
+ /// [event] The object to process.
+ ///
+ /// Returns the Event that was passed, now modified by listeners.
+ ///
+ /// The dispatcher should invoke each listener with the supplied event.
+ /// If a listener returns an Event object, that object should replace the one
+ /// passed to other listeners.
+ ///
+ /// The function MUST return an event object, which MAY be the same as the
+ /// event passed or MAY be a new Event object.
+ Object dispatch(Object event);
+}
diff --git a/fig/event_dispatcher/lib/src/listener_provider_interface.dart b/fig/event_dispatcher/lib/src/listener_provider_interface.dart
new file mode 100644
index 0000000..233b25a
--- /dev/null
+++ b/fig/event_dispatcher/lib/src/listener_provider_interface.dart
@@ -0,0 +1,13 @@
+/// Interface for event listener providers.
+abstract class ListenerProviderInterface {
+ /// Gets the listeners for a specific event.
+ ///
+ /// [event] An event for which to return the relevant listeners.
+ /// Returns an iterable of callables that can handle the event.
+ ///
+ /// Each callable MUST be type-compatible with the event.
+ /// Each callable MUST accept a single parameter: the event.
+ /// Each callable SHOULD have a void return type.
+ /// Each callable MAY be an instance of a class that implements __invoke().
+ Iterable getListenersForEvent(Object event);
+}
diff --git a/fig/event_dispatcher/lib/src/stoppable_event_interface.dart b/fig/event_dispatcher/lib/src/stoppable_event_interface.dart
new file mode 100644
index 0000000..3a42eae
--- /dev/null
+++ b/fig/event_dispatcher/lib/src/stoppable_event_interface.dart
@@ -0,0 +1,8 @@
+/// Interface for events that can be stopped from further propagation.
+abstract class StoppableEventInterface {
+ /// Whether no further event listeners should be triggered.
+ ///
+ /// Returns true if the event is complete and no further listeners should be called.
+ /// Returns false to continue calling listeners.
+ bool isPropagationStopped();
+}
diff --git a/fig/event_dispatcher/pubspec.yaml b/fig/event_dispatcher/pubspec.yaml
new file mode 100644
index 0000000..ec2dfcd
--- /dev/null
+++ b/fig/event_dispatcher/pubspec.yaml
@@ -0,0 +1,13 @@
+name: dsr_event_dispatcher
+description: A PSR-14 compatible event dispatcher interface for Dart. Provides standardized interfaces for event handling including EventDispatcherInterface, ListenerProviderInterface, and StoppableEventInterface.
+version: 0.0.1
+homepage: https://dart-fig.org
+
+environment:
+ sdk: ^3.4.2
+
+dependencies: {}
+
+dev_dependencies:
+ lints: ^3.0.0
+ test: ^1.24.0
diff --git a/fig/event_dispatcher/test/.gitkeep b/fig/event_dispatcher/test/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/http_client/.gitignore b/fig/http_client/.gitignore
new file mode 100644
index 0000000..3cceda5
--- /dev/null
+++ b/fig/http_client/.gitignore
@@ -0,0 +1,7 @@
+# https://dart.dev/guides/libraries/private-files
+# Created by `dart pub`
+.dart_tool/
+
+# Avoid committing pubspec.lock for library packages; see
+# https://dart.dev/guides/libraries/private-files#pubspeclock.
+pubspec.lock
diff --git a/fig/http_client/CHANGELOG.md b/fig/http_client/CHANGELOG.md
new file mode 100644
index 0000000..effe43c
--- /dev/null
+++ b/fig/http_client/CHANGELOG.md
@@ -0,0 +1,3 @@
+## 1.0.0
+
+- Initial version.
diff --git a/fig/http_client/LICENSE.md b/fig/http_client/LICENSE.md
new file mode 100644
index 0000000..0fd0d03
--- /dev/null
+++ b/fig/http_client/LICENSE.md
@@ -0,0 +1,10 @@
+The MIT License (MIT)
+
+The Laravel Framework is Copyright (c) Taylor Otwell
+The Fabric Framework is Copyright (c) Vieo, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/fig/http_client/README.md b/fig/http_client/README.md
new file mode 100644
index 0000000..757f4c9
--- /dev/null
+++ b/fig/http_client/README.md
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/fig/http_client/analysis_options.yaml b/fig/http_client/analysis_options.yaml
new file mode 100644
index 0000000..dee8927
--- /dev/null
+++ b/fig/http_client/analysis_options.yaml
@@ -0,0 +1,30 @@
+# This file configures the static analysis results for your project (errors,
+# warnings, and lints).
+#
+# This enables the 'recommended' set of lints from `package:lints`.
+# This set helps identify many issues that may lead to problems when running
+# or consuming Dart code, and enforces writing Dart using a single, idiomatic
+# style and format.
+#
+# If you want a smaller set of lints you can change this to specify
+# 'package:lints/core.yaml'. These are just the most critical lints
+# (the recommended set includes the core lints).
+# The core lints are also what is used by pub.dev for scoring packages.
+
+include: package:lints/recommended.yaml
+
+# Uncomment the following section to specify additional rules.
+
+# linter:
+# rules:
+# - camel_case_types
+
+# analyzer:
+# exclude:
+# - path/to/excluded/files/**
+
+# For more information about the core and recommended set of lints, see
+# https://dart.dev/go/core-lints
+
+# For additional information about configuring this file, see
+# https://dart.dev/guides/language/analysis-options
diff --git a/fig/http_client/doc/.gitkeep b/fig/http_client/doc/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/http_client/example/.gitkeep b/fig/http_client/example/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/http_client/lib/http_client.dart b/fig/http_client/lib/http_client.dart
new file mode 100644
index 0000000..2da8a9f
--- /dev/null
+++ b/fig/http_client/lib/http_client.dart
@@ -0,0 +1,8 @@
+/// A PSR-18 compatible HTTP client interface for Dart.
+///
+/// This library provides interfaces for HTTP clients following
+/// the PSR-18 HTTP Client Interface specification.
+library http_client;
+
+export 'src/client_interface.dart';
+export 'src/exceptions.dart';
diff --git a/fig/http_client/lib/src/client_interface.dart b/fig/http_client/lib/src/client_interface.dart
new file mode 100644
index 0000000..f6f02cb
--- /dev/null
+++ b/fig/http_client/lib/src/client_interface.dart
@@ -0,0 +1,33 @@
+import 'exceptions.dart';
+
+/// Interface for sending HTTP requests.
+///
+/// Implementations MUST NOT take HTTP method, URI, headers, or body as parameters.
+/// Instead, they MUST take a single Request object implementing PSR-7's RequestInterface.
+abstract class ClientInterface {
+ /// Sends a PSR-7 request and returns a PSR-7 response.
+ ///
+ /// [request] The request object implementing PSR-7's RequestInterface.
+ ///
+ /// Returns a response object implementing PSR-7's ResponseInterface.
+ ///
+ /// Throws [ClientExceptionInterface] If an error happens while processing the request.
+ /// Throws [NetworkExceptionInterface] If the request cannot be sent due to a network error.
+ /// Throws [RequestExceptionInterface] If the request is not a well-formed HTTP request or cannot be sent.
+ dynamic sendRequest(dynamic request);
+
+ /// Sends multiple PSR-7 requests concurrently.
+ ///
+ /// [requests] An iterable of request objects implementing PSR-7's RequestInterface.
+ ///
+ /// Returns a map of responses where the key is the request and the value is either:
+ /// - A response object implementing PSR-7's ResponseInterface
+ /// - A ClientExceptionInterface if the request failed
+ ///
+ /// This method is optional and implementations may throw
+ /// [UnsupportedError] if they don't support concurrent requests.
+ Map sendConcurrentRequests(Iterable requests) {
+ throw UnsupportedError(
+ 'Concurrent requests are not supported by this client');
+ }
+}
diff --git a/fig/http_client/lib/src/exceptions.dart b/fig/http_client/lib/src/exceptions.dart
new file mode 100644
index 0000000..a1f4d38
--- /dev/null
+++ b/fig/http_client/lib/src/exceptions.dart
@@ -0,0 +1,62 @@
+/// Base interface for HTTP client exceptions.
+abstract class ClientExceptionInterface implements Exception {
+ /// The error message.
+ String get message;
+}
+
+/// Exception for when a request cannot be sent.
+abstract class RequestExceptionInterface implements ClientExceptionInterface {
+ /// The request that caused the exception.
+ dynamic get request;
+}
+
+/// Exception for network-related errors.
+abstract class NetworkExceptionInterface implements ClientExceptionInterface {
+ /// The request that caused the exception.
+ dynamic get request;
+}
+
+/// A concrete implementation of ClientExceptionInterface.
+class ClientException implements ClientExceptionInterface {
+ @override
+ final String message;
+
+ /// Creates a new client exception.
+ const ClientException([this.message = '']);
+
+ @override
+ String toString() =>
+ message.isEmpty ? 'ClientException' : 'ClientException: $message';
+}
+
+/// A concrete implementation of RequestExceptionInterface.
+class RequestException implements RequestExceptionInterface {
+ @override
+ final String message;
+
+ @override
+ final dynamic request;
+
+ /// Creates a new request exception.
+ const RequestException(this.request, [this.message = '']);
+
+ @override
+ String toString() =>
+ message.isEmpty ? 'RequestException' : 'RequestException: $message';
+}
+
+/// A concrete implementation of NetworkExceptionInterface.
+class NetworkException implements NetworkExceptionInterface {
+ @override
+ final String message;
+
+ @override
+ final dynamic request;
+
+ /// Creates a new network exception.
+ const NetworkException(this.request, [this.message = '']);
+
+ @override
+ String toString() =>
+ message.isEmpty ? 'NetworkException' : 'NetworkException: $message';
+}
diff --git a/fig/http_client/pubspec.yaml b/fig/http_client/pubspec.yaml
new file mode 100644
index 0000000..a7d208d
--- /dev/null
+++ b/fig/http_client/pubspec.yaml
@@ -0,0 +1,13 @@
+name: dsr_http_client
+description: A PSR-18 compatible HTTP client interface for Dart. Provides standardized interfaces for sending HTTP requests including ClientInterface and related exceptions.
+version: 0.0.1
+homepage: https://dart-fig.org
+
+environment:
+ sdk: ^3.4.2
+
+dependencies: {}
+
+dev_dependencies:
+ lints: ^3.0.0
+ test: ^1.24.0
diff --git a/fig/http_client/test/.gitkeep b/fig/http_client/test/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/http_factory/.gitignore b/fig/http_factory/.gitignore
new file mode 100644
index 0000000..3cceda5
--- /dev/null
+++ b/fig/http_factory/.gitignore
@@ -0,0 +1,7 @@
+# https://dart.dev/guides/libraries/private-files
+# Created by `dart pub`
+.dart_tool/
+
+# Avoid committing pubspec.lock for library packages; see
+# https://dart.dev/guides/libraries/private-files#pubspeclock.
+pubspec.lock
diff --git a/fig/http_factory/CHANGELOG.md b/fig/http_factory/CHANGELOG.md
new file mode 100644
index 0000000..effe43c
--- /dev/null
+++ b/fig/http_factory/CHANGELOG.md
@@ -0,0 +1,3 @@
+## 1.0.0
+
+- Initial version.
diff --git a/fig/http_factory/LICENSE.md b/fig/http_factory/LICENSE.md
new file mode 100644
index 0000000..0fd0d03
--- /dev/null
+++ b/fig/http_factory/LICENSE.md
@@ -0,0 +1,10 @@
+The MIT License (MIT)
+
+The Laravel Framework is Copyright (c) Taylor Otwell
+The Fabric Framework is Copyright (c) Vieo, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/fig/http_factory/README.md b/fig/http_factory/README.md
new file mode 100644
index 0000000..757f4c9
--- /dev/null
+++ b/fig/http_factory/README.md
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/fig/http_factory/analysis_options.yaml b/fig/http_factory/analysis_options.yaml
new file mode 100644
index 0000000..dee8927
--- /dev/null
+++ b/fig/http_factory/analysis_options.yaml
@@ -0,0 +1,30 @@
+# This file configures the static analysis results for your project (errors,
+# warnings, and lints).
+#
+# This enables the 'recommended' set of lints from `package:lints`.
+# This set helps identify many issues that may lead to problems when running
+# or consuming Dart code, and enforces writing Dart using a single, idiomatic
+# style and format.
+#
+# If you want a smaller set of lints you can change this to specify
+# 'package:lints/core.yaml'. These are just the most critical lints
+# (the recommended set includes the core lints).
+# The core lints are also what is used by pub.dev for scoring packages.
+
+include: package:lints/recommended.yaml
+
+# Uncomment the following section to specify additional rules.
+
+# linter:
+# rules:
+# - camel_case_types
+
+# analyzer:
+# exclude:
+# - path/to/excluded/files/**
+
+# For more information about the core and recommended set of lints, see
+# https://dart.dev/go/core-lints
+
+# For additional information about configuring this file, see
+# https://dart.dev/guides/language/analysis-options
diff --git a/fig/http_factory/doc/.gitkeep b/fig/http_factory/doc/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/http_factory/example/.gitkeep b/fig/http_factory/example/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/http_factory/lib/http_factory.dart b/fig/http_factory/lib/http_factory.dart
new file mode 100644
index 0000000..ebcae8d
--- /dev/null
+++ b/fig/http_factory/lib/http_factory.dart
@@ -0,0 +1,9 @@
+/// A PSR-17 compatible HTTP factory interface for Dart.
+///
+/// This library provides interfaces for HTTP message factories following
+/// the PSR-17 HTTP Factory Interface specification.
+library http_factory;
+
+export 'src/request_factory_interface.dart';
+export 'src/stream_factory_interface.dart';
+export 'src/uri_factory_interface.dart';
diff --git a/fig/http_factory/lib/src/request_factory_interface.dart b/fig/http_factory/lib/src/request_factory_interface.dart
new file mode 100644
index 0000000..4418370
--- /dev/null
+++ b/fig/http_factory/lib/src/request_factory_interface.dart
@@ -0,0 +1,38 @@
+/// Factory interface for creating PSR-7 Request instances.
+abstract class RequestFactoryInterface {
+ /// Creates a new PSR-7 Request instance.
+ ///
+ /// [method] The HTTP method associated with the request.
+ /// [uri] The URI associated with the request, as a string or UriInterface.
+ ///
+ /// Returns a new PSR-7 Request instance.
+ dynamic createRequest(String method, dynamic uri);
+}
+
+/// Factory interface for creating PSR-7 ServerRequest instances.
+abstract class ServerRequestFactoryInterface {
+ /// Creates a new PSR-7 ServerRequest instance.
+ ///
+ /// [method] The HTTP method associated with the request.
+ /// [uri] The URI associated with the request, as a string or UriInterface.
+ /// [serverParams] Array of SAPI parameters.
+ ///
+ /// Returns a new PSR-7 ServerRequest instance.
+ dynamic createServerRequest(
+ String method,
+ dynamic uri, [
+ Map serverParams = const {},
+ ]);
+}
+
+/// Factory interface for creating PSR-7 Response instances.
+abstract class ResponseFactoryInterface {
+ /// Creates a new PSR-7 Response instance.
+ ///
+ /// [code] The HTTP status code. The value MUST be between 100 and 599.
+ /// [reasonPhrase] The reason phrase to associate with the status code.
+ /// If none is provided, implementations MAY use the defaults.
+ ///
+ /// Returns a new PSR-7 Response instance.
+ dynamic createResponse([int code = 200, String? reasonPhrase]);
+}
diff --git a/fig/http_factory/lib/src/stream_factory_interface.dart b/fig/http_factory/lib/src/stream_factory_interface.dart
new file mode 100644
index 0000000..2409701
--- /dev/null
+++ b/fig/http_factory/lib/src/stream_factory_interface.dart
@@ -0,0 +1,44 @@
+/// Factory interface for creating PSR-7 Stream instances.
+abstract class StreamFactoryInterface {
+ /// Creates a new PSR-7 Stream instance from a string.
+ ///
+ /// [content] The content with which to populate the stream.
+ ///
+ /// Returns a new PSR-7 Stream instance.
+ dynamic createStream([String content = '']);
+
+ /// Creates a new PSR-7 Stream instance from an existing file.
+ ///
+ /// [filename] The filename or stream URI to use as basis of stream.
+ /// [mode] The mode with which to open the underlying filename/stream.
+ ///
+ /// Returns a new PSR-7 Stream instance.
+ dynamic createStreamFromFile(String filename, [String mode = 'r']);
+
+ /// Creates a new PSR-7 Stream instance from an existing resource.
+ ///
+ /// [resource] The PHP resource to use as the basis for the stream.
+ ///
+ /// Returns a new PSR-7 Stream instance.
+ dynamic createStreamFromResource(dynamic resource);
+}
+
+/// Factory interface for creating PSR-7 UploadedFile instances.
+abstract class UploadedFileFactoryInterface {
+ /// Creates a new PSR-7 UploadedFile instance.
+ ///
+ /// [stream] The underlying stream representing the uploaded file content.
+ /// [size] The size of the file in bytes.
+ /// [errorStatus] The PHP upload error status.
+ /// [clientFilename] The filename as provided by the client.
+ /// [clientMediaType] The media type as provided by the client.
+ ///
+ /// Returns a new PSR-7 UploadedFile instance.
+ dynamic createUploadedFile(
+ dynamic stream, [
+ int? size,
+ int errorStatus = 0,
+ String? clientFilename,
+ String? clientMediaType,
+ ]);
+}
diff --git a/fig/http_factory/lib/src/uri_factory_interface.dart b/fig/http_factory/lib/src/uri_factory_interface.dart
new file mode 100644
index 0000000..fae1fb5
--- /dev/null
+++ b/fig/http_factory/lib/src/uri_factory_interface.dart
@@ -0,0 +1,13 @@
+/// Factory interface for creating PSR-7 Uri instances.
+abstract class UriFactoryInterface {
+ /// Creates a new PSR-7 Uri instance.
+ ///
+ /// [uri] The URI to parse.
+ ///
+ /// Returns a new PSR-7 Uri instance.
+ /// Implementations MUST support URIs as specified in RFC 3986.
+ ///
+ /// If the [uri] string is malformed, implementations MUST throw
+ /// an exception that implements Throwable.
+ dynamic createUri(String uri);
+}
diff --git a/fig/http_factory/pubspec.yaml b/fig/http_factory/pubspec.yaml
new file mode 100644
index 0000000..057f5ef
--- /dev/null
+++ b/fig/http_factory/pubspec.yaml
@@ -0,0 +1,13 @@
+name: dsr_http_factory
+description: A PSR-17 compatible HTTP factory interface for Dart. Provides standardized interfaces for creating PSR-7 HTTP message objects including requests, responses, streams, and URIs.
+version: 0.0.1
+homepage: https://dart-fig.org
+
+environment:
+ sdk: ^3.4.2
+
+dependencies: {}
+
+dev_dependencies:
+ lints: ^3.0.0
+ test: ^1.24.0
diff --git a/fig/http_factory/test/.gitkeep b/fig/http_factory/test/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/http_message/.gitignore b/fig/http_message/.gitignore
new file mode 100644
index 0000000..3cceda5
--- /dev/null
+++ b/fig/http_message/.gitignore
@@ -0,0 +1,7 @@
+# https://dart.dev/guides/libraries/private-files
+# Created by `dart pub`
+.dart_tool/
+
+# Avoid committing pubspec.lock for library packages; see
+# https://dart.dev/guides/libraries/private-files#pubspeclock.
+pubspec.lock
diff --git a/fig/http_message/CHANGELOG.md b/fig/http_message/CHANGELOG.md
new file mode 100644
index 0000000..effe43c
--- /dev/null
+++ b/fig/http_message/CHANGELOG.md
@@ -0,0 +1,3 @@
+## 1.0.0
+
+- Initial version.
diff --git a/fig/http_message/LICENSE.md b/fig/http_message/LICENSE.md
new file mode 100644
index 0000000..0fd0d03
--- /dev/null
+++ b/fig/http_message/LICENSE.md
@@ -0,0 +1,10 @@
+The MIT License (MIT)
+
+The Laravel Framework is Copyright (c) Taylor Otwell
+The Fabric Framework is Copyright (c) Vieo, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/fig/http_message/README.md b/fig/http_message/README.md
new file mode 100644
index 0000000..757f4c9
--- /dev/null
+++ b/fig/http_message/README.md
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/fig/http_message/analysis_options.yaml b/fig/http_message/analysis_options.yaml
new file mode 100644
index 0000000..dee8927
--- /dev/null
+++ b/fig/http_message/analysis_options.yaml
@@ -0,0 +1,30 @@
+# This file configures the static analysis results for your project (errors,
+# warnings, and lints).
+#
+# This enables the 'recommended' set of lints from `package:lints`.
+# This set helps identify many issues that may lead to problems when running
+# or consuming Dart code, and enforces writing Dart using a single, idiomatic
+# style and format.
+#
+# If you want a smaller set of lints you can change this to specify
+# 'package:lints/core.yaml'. These are just the most critical lints
+# (the recommended set includes the core lints).
+# The core lints are also what is used by pub.dev for scoring packages.
+
+include: package:lints/recommended.yaml
+
+# Uncomment the following section to specify additional rules.
+
+# linter:
+# rules:
+# - camel_case_types
+
+# analyzer:
+# exclude:
+# - path/to/excluded/files/**
+
+# For more information about the core and recommended set of lints, see
+# https://dart.dev/go/core-lints
+
+# For additional information about configuring this file, see
+# https://dart.dev/guides/language/analysis-options
diff --git a/fig/http_message/doc/.gitkeep b/fig/http_message/doc/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/http_message/example/.gitkeep b/fig/http_message/example/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/http_message/lib/http_message.dart b/fig/http_message/lib/http_message.dart
new file mode 100644
index 0000000..9b94128
--- /dev/null
+++ b/fig/http_message/lib/http_message.dart
@@ -0,0 +1,12 @@
+/// A PSR-7 compatible HTTP message interface for Dart.
+///
+/// This library provides interfaces for HTTP messages following
+/// the PSR-7 HTTP Message Interface specification.
+library http_message;
+
+export 'src/message_interface.dart';
+export 'src/request_interface.dart';
+export 'src/response_interface.dart';
+export 'src/stream_interface.dart';
+export 'src/uploaded_file_interface.dart';
+export 'src/uri_interface.dart';
diff --git a/fig/http_message/lib/src/message_interface.dart b/fig/http_message/lib/src/message_interface.dart
new file mode 100644
index 0000000..42625d9
--- /dev/null
+++ b/fig/http_message/lib/src/message_interface.dart
@@ -0,0 +1,75 @@
+import 'stream_interface.dart';
+
+/// Base HTTP message interface.
+///
+/// This interface represents both HTTP requests and responses, providing
+/// the methods that are common to both types of messages.
+abstract class MessageInterface {
+ /// Retrieves the HTTP protocol version as a string.
+ ///
+ /// Returns the HTTP protocol version (e.g., "1.0", "1.1", "2.0").
+ String getProtocolVersion();
+
+ /// Return an instance with the specified HTTP protocol version.
+ ///
+ /// [version] HTTP protocol version.
+ ///
+ /// Returns a new instance with the specified version.
+ MessageInterface withProtocolVersion(String version);
+
+ /// Retrieves all message header values.
+ ///
+ /// Returns an associative array of header names to their values.
+ Map> getHeaders();
+
+ /// Checks if a header exists by the given case-insensitive name.
+ ///
+ /// [name] Case-insensitive header field name.
+ ///
+ /// Returns true if any header names match the given name using a
+ /// case-insensitive string comparison. Returns false otherwise.
+ bool hasHeader(String name);
+
+ /// Retrieves a message header value by the given case-insensitive name.
+ ///
+ /// [name] Case-insensitive header field name.
+ ///
+ /// Returns a list of string values as provided for the header.
+ /// Returns an empty list if the header does not exist.
+ List getHeader(String name);
+
+ /// Return an instance with the provided value replacing the specified header.
+ ///
+ /// [name] Case-insensitive header field name.
+ /// [value] Header value(s).
+ ///
+ /// Returns a new instance with the specified header.
+ MessageInterface withHeader(String name, dynamic value);
+
+ /// Return an instance with the specified header appended with the given value.
+ ///
+ /// [name] Case-insensitive header field name.
+ /// [value] Header value(s).
+ ///
+ /// Returns a new instance with the appended header values.
+ MessageInterface withAddedHeader(String name, dynamic value);
+
+ /// Return an instance without the specified header.
+ ///
+ /// [name] Case-insensitive header field name.
+ ///
+ /// Returns a new instance without the specified header.
+ MessageInterface withoutHeader(String name);
+
+ /// Gets the body of the message.
+ ///
+ /// Returns the body as a stream.
+ StreamInterface getBody();
+
+ /// Return an instance with the specified message body.
+ ///
+ /// [body] The new message body.
+ ///
+ /// Returns a new instance with the specified body.
+ MessageInterface withBody(StreamInterface body);
+}
diff --git a/fig/http_message/lib/src/request_interface.dart b/fig/http_message/lib/src/request_interface.dart
new file mode 100644
index 0000000..33561e2
--- /dev/null
+++ b/fig/http_message/lib/src/request_interface.dart
@@ -0,0 +1,142 @@
+import 'message_interface.dart';
+import 'uri_interface.dart';
+
+/// Representation of an outgoing, client-side request.
+abstract class RequestInterface implements MessageInterface {
+ /// Retrieves the message's request target.
+ ///
+ /// Returns the message's request target.
+ String getRequestTarget();
+
+ /// Return an instance with the specific request-target.
+ ///
+ /// [requestTarget] The request target.
+ ///
+ /// Returns a new instance with the specified request target.
+ RequestInterface withRequestTarget(String requestTarget);
+
+ /// Retrieves the HTTP method of the request.
+ ///
+ /// Returns the HTTP method.
+ String getMethod();
+
+ /// Return an instance with the provided HTTP method.
+ ///
+ /// [method] Case-sensitive method.
+ ///
+ /// Returns a new instance with the specified method.
+ RequestInterface withMethod(String method);
+
+ /// Retrieves the URI instance.
+ ///
+ /// Returns a UriInterface instance representing the URI of the request.
+ UriInterface getUri();
+
+ /// Returns an instance with the provided URI.
+ ///
+ /// [uri] New request URI.
+ /// [preserveHost] Preserve the original state of the Host header.
+ ///
+ /// Returns a new instance with the specified URI.
+ RequestInterface withUri(UriInterface uri, [bool preserveHost = false]);
+}
+
+/// Representation of an incoming, server-side HTTP request.
+///
+/// Per the HTTP specification, this interface includes properties for
+/// each of the following:
+/// - Protocol version
+/// - HTTP method
+/// - URI
+/// - Headers
+/// - Message body
+///
+/// Additionally, it encapsulates all data as it has arrived to the
+/// application from the CGI and/or PHP environment, including:
+/// - The values represented in $_SERVER.
+/// - Any cookies provided (generally via $_COOKIE)
+/// - Query string arguments (generally via $_GET, or as parsed via parse_str())
+/// - Upload files, if any (as represented by $_FILES)
+/// - Deserialized body parameters (generally from $_POST)
+abstract class ServerRequestInterface implements RequestInterface {
+ /// Retrieve server parameters.
+ ///
+ /// Returns a map of server parameters.
+ Map getServerParams();
+
+ /// Retrieve cookies.
+ ///
+ /// Returns a map of cookie name/value pairs.
+ Map getCookieParams();
+
+ /// Return an instance with the specified cookies.
+ ///
+ /// [cookies] The map of cookie name/value pairs.
+ ///
+ /// Returns a new instance with the specified cookies.
+ ServerRequestInterface withCookieParams(Map cookies);
+
+ /// Retrieve query string arguments.
+ ///
+ /// Returns a map of query string arguments.
+ Map getQueryParams();
+
+ /// Return an instance with the specified query string arguments.
+ ///
+ /// [query] The map of query string arguments.
+ ///
+ /// Returns a new instance with the specified query string arguments.
+ ServerRequestInterface withQueryParams(Map query);
+
+ /// Retrieve normalized file upload data.
+ ///
+ /// Returns a normalized tree of file upload data.
+ Map getUploadedFiles();
+
+ /// Create a new instance with the specified uploaded files.
+ ///
+ /// [uploadedFiles] A normalized tree of uploaded file data.
+ ///
+ /// Returns a new instance with the specified uploaded files.
+ ServerRequestInterface withUploadedFiles(Map uploadedFiles);
+
+ /// Retrieve any parameters provided in the request body.
+ ///
+ /// Returns the deserialized body parameters, if any.
+ dynamic getParsedBody();
+
+ /// Return an instance with the specified body parameters.
+ ///
+ /// [data] The deserialized body data.
+ ///
+ /// Returns a new instance with the specified body parameters.
+ ServerRequestInterface withParsedBody(dynamic data);
+
+ /// Retrieve attributes derived from the request.
+ ///
+ /// Returns a map of attributes.
+ Map getAttributes();
+
+ /// Retrieve a single derived request attribute.
+ ///
+ /// [name] The attribute name.
+ /// [defaultValue] Default value to return if the attribute does not exist.
+ ///
+ /// Returns the attribute value or default value.
+ dynamic getAttribute(String name, [dynamic defaultValue]);
+
+ /// Return an instance with the specified derived request attribute.
+ ///
+ /// [name] The attribute name.
+ /// [value] The value of the attribute.
+ ///
+ /// Returns a new instance with the specified attribute.
+ ServerRequestInterface withAttribute(String name, dynamic value);
+
+ /// Return an instance without the specified derived request attribute.
+ ///
+ /// [name] The attribute name.
+ ///
+ /// Returns a new instance without the specified attribute.
+ ServerRequestInterface withoutAttribute(String name);
+}
diff --git a/fig/http_message/lib/src/response_interface.dart b/fig/http_message/lib/src/response_interface.dart
new file mode 100644
index 0000000..bbfca7f
--- /dev/null
+++ b/fig/http_message/lib/src/response_interface.dart
@@ -0,0 +1,25 @@
+import 'message_interface.dart';
+
+/// Representation of an outgoing, server-side response.
+abstract class ResponseInterface implements MessageInterface {
+ /// Gets the response status code.
+ ///
+ /// Returns the status code.
+ int getStatusCode();
+
+ /// Return an instance with the specified status code and, optionally, reason phrase.
+ ///
+ /// [code] The 3-digit integer result code to set.
+ /// [reasonPhrase] The reason phrase to use with the
+ /// provided status code; if none is provided, implementations MAY
+ /// use the defaults as suggested in the HTTP specification.
+ ///
+ /// Returns a new instance with the specified status code and, optionally, reason phrase.
+ /// Throws ArgumentError for invalid status code arguments.
+ ResponseInterface withStatus(int code, [String? reasonPhrase]);
+
+ /// Gets the response reason phrase associated with the status code.
+ ///
+ /// Returns the reason phrase; must return an empty string if none present.
+ String getReasonPhrase();
+}
diff --git a/fig/http_message/lib/src/stream_interface.dart b/fig/http_message/lib/src/stream_interface.dart
new file mode 100644
index 0000000..e9cac58
--- /dev/null
+++ b/fig/http_message/lib/src/stream_interface.dart
@@ -0,0 +1,86 @@
+/// Interface for representing a data stream.
+abstract class StreamInterface {
+ /// Reads all data from the stream into a string.
+ ///
+ /// Returns the data from the stream as a string.
+ /// Throws Exception if an error occurs.
+ String toString();
+
+ /// Closes the stream and any underlying resources.
+ void close();
+
+ /// Separates any underlying resources from the stream.
+ ///
+ /// After the stream has been detached, the stream is in an unusable state.
+ /// Returns underlying PHP stream if one is available.
+ dynamic detach();
+
+ /// Get the size of the stream if known.
+ ///
+ /// Returns the size in bytes if known, or null if unknown.
+ int? getSize();
+
+ /// Returns the current position of the file read/write pointer.
+ ///
+ /// Returns the position as int.
+ /// Throws Exception on error.
+ int tell();
+
+ /// Returns true if the stream is at the end of the stream.
+ bool isEof();
+
+ /// Returns whether or not the stream is seekable.
+ bool isSeekable();
+
+ /// Seek to a position in the stream.
+ ///
+ /// [offset] Stream offset.
+ /// [whence] Specifies how the cursor position will be calculated.
+ ///
+ /// Throws Exception on failure.
+ void seek(int offset, [int whence = 0]);
+
+ /// Seek to the beginning of the stream.
+ ///
+ /// If the stream is not seekable, this method will raise an exception;
+ /// otherwise, it will perform a seek(0).
+ ///
+ /// Throws Exception on failure.
+ void rewind();
+
+ /// Returns whether or not the stream is writable.
+ bool isWritable();
+
+ /// Write data to the stream.
+ ///
+ /// [string] The string that is to be written.
+ ///
+ /// Returns the number of bytes written to the stream.
+ /// Throws Exception on failure.
+ int write(String string);
+
+ /// Returns whether or not the stream is readable.
+ bool isReadable();
+
+ /// Read data from the stream.
+ ///
+ /// [length] Read up to [length] bytes from the object and return them.
+ ///
+ /// Returns the data read from the stream, or null if no bytes are available.
+ /// Throws Exception if an error occurs.
+ String? read(int length);
+
+ /// Returns the remaining contents in a string.
+ ///
+ /// Returns the remaining contents of the stream.
+ /// Throws Exception if unable to read or an error occurs while reading.
+ String getContents();
+
+ /// Get stream metadata as an associative array or retrieve a specific key.
+ ///
+ /// [key] Specific metadata to retrieve.
+ ///
+ /// Returns an associative array if no key is provided.
+ /// Returns null if the key is not found or the metadata cannot be determined.
+ dynamic getMetadata([String? key]);
+}
diff --git a/fig/http_message/lib/src/uploaded_file_interface.dart b/fig/http_message/lib/src/uploaded_file_interface.dart
new file mode 100644
index 0000000..ecee4a3
--- /dev/null
+++ b/fig/http_message/lib/src/uploaded_file_interface.dart
@@ -0,0 +1,41 @@
+import 'stream_interface.dart';
+
+/// Value object representing a file uploaded through an HTTP request.
+abstract class UploadedFileInterface {
+ /// Retrieve a stream representing the uploaded file.
+ ///
+ /// Returns a StreamInterface instance.
+ /// Throws Exception if the upload was not successful.
+ StreamInterface getStream();
+
+ /// Move the uploaded file to a new location.
+ ///
+ /// [targetPath] Path to which to move the uploaded file.
+ ///
+ /// Throws Exception on any error during the move operation.
+ /// Throws Exception on invalid [targetPath].
+ void moveTo(String targetPath);
+
+ /// Retrieve the file size.
+ ///
+ /// Returns the file size in bytes or null if unknown.
+ int? getSize();
+
+ /// Retrieve the error associated with the uploaded file.
+ ///
+ /// Returns one of the UPLOAD_ERR_XXX constants.
+ /// Returns UPLOAD_ERR_OK if no error occurred.
+ int getError();
+
+ /// Retrieve the filename sent by the client.
+ ///
+ /// Returns the filename sent by the client or null if none
+ /// was provided.
+ String? getClientFilename();
+
+ /// Retrieve the media type sent by the client.
+ ///
+ /// Returns the media type sent by the client or null if none
+ /// was provided.
+ String? getClientMediaType();
+}
diff --git a/fig/http_message/lib/src/uri_interface.dart b/fig/http_message/lib/src/uri_interface.dart
new file mode 100644
index 0000000..386c912
--- /dev/null
+++ b/fig/http_message/lib/src/uri_interface.dart
@@ -0,0 +1,105 @@
+/// Value object representing a URI.
+///
+/// This interface is meant to represent URIs according to RFC 3986 and to
+/// provide methods for most common operations.
+abstract class UriInterface {
+ /// Retrieve the scheme component of the URI.
+ ///
+ /// Returns the URI scheme or empty string if not present.
+ String getScheme();
+
+ /// Retrieve the authority component of the URI.
+ ///
+ /// Returns the URI authority in lowercase, or empty string if not present.
+ String getAuthority();
+
+ /// Retrieve the user information component of the URI.
+ ///
+ /// Returns the URI user information, or empty string if not present.
+ String getUserInfo();
+
+ /// Retrieve the host component of the URI.
+ ///
+ /// Returns the URI host in lowercase, or empty string if not present.
+ String getHost();
+
+ /// Retrieve the port component of the URI.
+ ///
+ /// Returns the URI port as an integer, or null if not present.
+ int? getPort();
+
+ /// Retrieve the path component of the URI.
+ ///
+ /// Returns the URI path.
+ String getPath();
+
+ /// Retrieve the query string of the URI.
+ ///
+ /// Returns the URI query string, or empty string if not present.
+ String getQuery();
+
+ /// Retrieve the fragment component of the URI.
+ ///
+ /// Returns the URI fragment, or empty string if not present.
+ String getFragment();
+
+ /// Return an instance with the specified scheme.
+ ///
+ /// [scheme] The scheme to use with the new instance.
+ ///
+ /// Returns a new instance with the specified scheme.
+ /// Throws ArgumentError for invalid schemes.
+ UriInterface withScheme(String scheme);
+
+ /// Return an instance with the specified user information.
+ ///
+ /// [user] The user name to use for authority.
+ /// [password] The password associated with [user].
+ ///
+ /// Returns a new instance with the specified user information.
+ UriInterface withUserInfo(String user, [String? password]);
+
+ /// Return an instance with the specified host.
+ ///
+ /// [host] The hostname to use with the new instance.
+ ///
+ /// Returns a new instance with the specified host.
+ /// Throws ArgumentError for invalid hostnames.
+ UriInterface withHost(String host);
+
+ /// Return an instance with the specified port.
+ ///
+ /// [port] The port to use with the new instance.
+ ///
+ /// Returns a new instance with the specified port.
+ /// Throws ArgumentError for invalid ports.
+ UriInterface withPort(int? port);
+
+ /// Return an instance with the specified path.
+ ///
+ /// [path] The path to use with the new instance.
+ ///
+ /// Returns a new instance with the specified path.
+ /// Throws ArgumentError for invalid paths.
+ UriInterface withPath(String path);
+
+ /// Return an instance with the specified query string.
+ ///
+ /// [query] The query string to use with the new instance.
+ ///
+ /// Returns a new instance with the specified query string.
+ /// Throws ArgumentError for invalid query strings.
+ UriInterface withQuery(String query);
+
+ /// Return an instance with the specified fragment.
+ ///
+ /// [fragment] The fragment to use with the new instance.
+ ///
+ /// Returns a new instance with the specified fragment.
+ UriInterface withFragment(String fragment);
+
+ /// Return the string representation of the URI.
+ ///
+ /// Returns string representation of the URI.
+ String toString();
+}
diff --git a/fig/http_message/pubspec.yaml b/fig/http_message/pubspec.yaml
new file mode 100644
index 0000000..4b2a6e1
--- /dev/null
+++ b/fig/http_message/pubspec.yaml
@@ -0,0 +1,13 @@
+name: dsr_http_message
+description: A PSR-7 compatible HTTP message interface for Dart. Provides standardized interfaces for HTTP messages including requests, responses, streams, URIs, and uploaded files.
+version: 0.0.1
+homepage: https://dart-fig.org
+
+environment:
+ sdk: ^3.4.2
+
+dependencies: {}
+
+dev_dependencies:
+ lints: ^3.0.0
+ test: ^1.24.0
diff --git a/fig/http_message/test/.gitkeep b/fig/http_message/test/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/http_server_handler/.gitignore b/fig/http_server_handler/.gitignore
new file mode 100644
index 0000000..3cceda5
--- /dev/null
+++ b/fig/http_server_handler/.gitignore
@@ -0,0 +1,7 @@
+# https://dart.dev/guides/libraries/private-files
+# Created by `dart pub`
+.dart_tool/
+
+# Avoid committing pubspec.lock for library packages; see
+# https://dart.dev/guides/libraries/private-files#pubspeclock.
+pubspec.lock
diff --git a/fig/http_server_handler/CHANGELOG.md b/fig/http_server_handler/CHANGELOG.md
new file mode 100644
index 0000000..effe43c
--- /dev/null
+++ b/fig/http_server_handler/CHANGELOG.md
@@ -0,0 +1,3 @@
+## 1.0.0
+
+- Initial version.
diff --git a/fig/http_server_handler/LICENSE.md b/fig/http_server_handler/LICENSE.md
new file mode 100644
index 0000000..0fd0d03
--- /dev/null
+++ b/fig/http_server_handler/LICENSE.md
@@ -0,0 +1,10 @@
+The MIT License (MIT)
+
+The Laravel Framework is Copyright (c) Taylor Otwell
+The Fabric Framework is Copyright (c) Vieo, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/fig/http_server_handler/README.md b/fig/http_server_handler/README.md
new file mode 100644
index 0000000..757f4c9
--- /dev/null
+++ b/fig/http_server_handler/README.md
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/fig/http_server_handler/analysis_options.yaml b/fig/http_server_handler/analysis_options.yaml
new file mode 100644
index 0000000..dee8927
--- /dev/null
+++ b/fig/http_server_handler/analysis_options.yaml
@@ -0,0 +1,30 @@
+# This file configures the static analysis results for your project (errors,
+# warnings, and lints).
+#
+# This enables the 'recommended' set of lints from `package:lints`.
+# This set helps identify many issues that may lead to problems when running
+# or consuming Dart code, and enforces writing Dart using a single, idiomatic
+# style and format.
+#
+# If you want a smaller set of lints you can change this to specify
+# 'package:lints/core.yaml'. These are just the most critical lints
+# (the recommended set includes the core lints).
+# The core lints are also what is used by pub.dev for scoring packages.
+
+include: package:lints/recommended.yaml
+
+# Uncomment the following section to specify additional rules.
+
+# linter:
+# rules:
+# - camel_case_types
+
+# analyzer:
+# exclude:
+# - path/to/excluded/files/**
+
+# For more information about the core and recommended set of lints, see
+# https://dart.dev/go/core-lints
+
+# For additional information about configuring this file, see
+# https://dart.dev/guides/language/analysis-options
diff --git a/fig/http_server_handler/doc/.gitkeep b/fig/http_server_handler/doc/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/http_server_handler/example/.gitkeep b/fig/http_server_handler/example/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/http_server_handler/lib/http_server_handler.dart b/fig/http_server_handler/lib/http_server_handler.dart
new file mode 100644
index 0000000..9de44f7
--- /dev/null
+++ b/fig/http_server_handler/lib/http_server_handler.dart
@@ -0,0 +1,7 @@
+/// A PSR-15 compatible HTTP server handler interface for Dart.
+///
+/// This library provides the interface for HTTP server request handlers
+/// following the PSR-15 HTTP Server Handler specification.
+library http_server_handler;
+
+export 'src/request_handler_interface.dart';
diff --git a/fig/http_server_handler/lib/src/request_handler_interface.dart b/fig/http_server_handler/lib/src/request_handler_interface.dart
new file mode 100644
index 0000000..20a5eda
--- /dev/null
+++ b/fig/http_server_handler/lib/src/request_handler_interface.dart
@@ -0,0 +1,15 @@
+import 'package:dsr_http_message/http_message.dart';
+
+/// Interface for request handlers.
+///
+/// A request handler processes an HTTP request and produces an HTTP response.
+/// This interface defines the methods required to use the request handler.
+abstract class RequestHandlerInterface {
+ /// Handles a request and produces a response.
+ ///
+ /// [request] The server request object.
+ ///
+ /// Returns a response implementing ResponseInterface.
+ /// May throw any throwable as needed.
+ ResponseInterface handle(ServerRequestInterface request);
+}
diff --git a/fig/http_server_handler/pubspec.yaml b/fig/http_server_handler/pubspec.yaml
new file mode 100644
index 0000000..6942db3
--- /dev/null
+++ b/fig/http_server_handler/pubspec.yaml
@@ -0,0 +1,14 @@
+name: dsr_http_server_handler
+description: A PSR-15 compatible HTTP server handler interface for Dart. Provides a standardized interface for processing HTTP server requests and producing responses.
+version: 0.0.1
+homepage: https://dart-fig.org
+
+environment:
+ sdk: ^3.4.2
+
+dependencies:
+ dsr_http_message: ^0.0.1
+
+dev_dependencies:
+ lints: ^3.0.0
+ test: ^1.24.0
diff --git a/fig/http_server_handler/test/.gitkeep b/fig/http_server_handler/test/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/http_server_middleware/.gitignore b/fig/http_server_middleware/.gitignore
new file mode 100644
index 0000000..3cceda5
--- /dev/null
+++ b/fig/http_server_middleware/.gitignore
@@ -0,0 +1,7 @@
+# https://dart.dev/guides/libraries/private-files
+# Created by `dart pub`
+.dart_tool/
+
+# Avoid committing pubspec.lock for library packages; see
+# https://dart.dev/guides/libraries/private-files#pubspeclock.
+pubspec.lock
diff --git a/fig/http_server_middleware/CHANGELOG.md b/fig/http_server_middleware/CHANGELOG.md
new file mode 100644
index 0000000..effe43c
--- /dev/null
+++ b/fig/http_server_middleware/CHANGELOG.md
@@ -0,0 +1,3 @@
+## 1.0.0
+
+- Initial version.
diff --git a/fig/http_server_middleware/LICENSE.md b/fig/http_server_middleware/LICENSE.md
new file mode 100644
index 0000000..0fd0d03
--- /dev/null
+++ b/fig/http_server_middleware/LICENSE.md
@@ -0,0 +1,10 @@
+The MIT License (MIT)
+
+The Laravel Framework is Copyright (c) Taylor Otwell
+The Fabric Framework is Copyright (c) Vieo, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/fig/http_server_middleware/README.md b/fig/http_server_middleware/README.md
new file mode 100644
index 0000000..757f4c9
--- /dev/null
+++ b/fig/http_server_middleware/README.md
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/fig/http_server_middleware/analysis_options.yaml b/fig/http_server_middleware/analysis_options.yaml
new file mode 100644
index 0000000..dee8927
--- /dev/null
+++ b/fig/http_server_middleware/analysis_options.yaml
@@ -0,0 +1,30 @@
+# This file configures the static analysis results for your project (errors,
+# warnings, and lints).
+#
+# This enables the 'recommended' set of lints from `package:lints`.
+# This set helps identify many issues that may lead to problems when running
+# or consuming Dart code, and enforces writing Dart using a single, idiomatic
+# style and format.
+#
+# If you want a smaller set of lints you can change this to specify
+# 'package:lints/core.yaml'. These are just the most critical lints
+# (the recommended set includes the core lints).
+# The core lints are also what is used by pub.dev for scoring packages.
+
+include: package:lints/recommended.yaml
+
+# Uncomment the following section to specify additional rules.
+
+# linter:
+# rules:
+# - camel_case_types
+
+# analyzer:
+# exclude:
+# - path/to/excluded/files/**
+
+# For more information about the core and recommended set of lints, see
+# https://dart.dev/go/core-lints
+
+# For additional information about configuring this file, see
+# https://dart.dev/guides/language/analysis-options
diff --git a/fig/http_server_middleware/doc/.gitkeep b/fig/http_server_middleware/doc/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/http_server_middleware/example/.gitkeep b/fig/http_server_middleware/example/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/http_server_middleware/lib/http_server_middleware.dart b/fig/http_server_middleware/lib/http_server_middleware.dart
new file mode 100644
index 0000000..e2fd075
--- /dev/null
+++ b/fig/http_server_middleware/lib/http_server_middleware.dart
@@ -0,0 +1,7 @@
+/// A PSR-15 compatible HTTP server middleware interface for Dart.
+///
+/// This library provides the interface for HTTP server middleware
+/// following the PSR-15 HTTP Server Middleware specification.
+library http_server_middleware;
+
+export 'src/middleware_interface.dart';
diff --git a/fig/http_server_middleware/lib/src/middleware_interface.dart b/fig/http_server_middleware/lib/src/middleware_interface.dart
new file mode 100644
index 0000000..5630492
--- /dev/null
+++ b/fig/http_server_middleware/lib/src/middleware_interface.dart
@@ -0,0 +1,23 @@
+import 'package:dsr_http_message/http_message.dart';
+import 'package:dsr_http_server_handler/http_server_handler.dart';
+
+/// Interface for server-side middleware.
+///
+/// This interface defines a middleware component that participates in processing
+/// an HTTP server request and producing a response.
+abstract class MiddlewareInterface {
+ /// Process an incoming server request.
+ ///
+ /// Processes an incoming server request in order to produce a response.
+ /// If unable to produce the response itself, it may delegate to the provided
+ /// request handler to do so.
+ ///
+ /// [request] The server request object.
+ /// [handler] The request handler to delegate to if needed.
+ ///
+ /// Returns a response implementing ResponseInterface.
+ ResponseInterface process(
+ ServerRequestInterface request,
+ RequestHandlerInterface handler,
+ );
+}
diff --git a/fig/http_server_middleware/pubspec.yaml b/fig/http_server_middleware/pubspec.yaml
new file mode 100644
index 0000000..a36477d
--- /dev/null
+++ b/fig/http_server_middleware/pubspec.yaml
@@ -0,0 +1,15 @@
+name: dsr_http_server_middleware
+description: A PSR-15 compatible HTTP server middleware interface for Dart. Provides a standardized interface for middleware components that participate in processing HTTP server requests.
+version: 0.0.1
+homepage: https://dart-fig.org
+
+environment:
+ sdk: ^3.4.2
+
+dependencies:
+ dsr_http_message: ^0.0.1
+ dsr_http_server_handler: ^0.0.1
+
+dev_dependencies:
+ lints: ^3.0.0
+ test: ^1.24.0
diff --git a/fig/http_server_middleware/test/.gitkeep b/fig/http_server_middleware/test/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/link/.gitignore b/fig/link/.gitignore
new file mode 100644
index 0000000..3cceda5
--- /dev/null
+++ b/fig/link/.gitignore
@@ -0,0 +1,7 @@
+# https://dart.dev/guides/libraries/private-files
+# Created by `dart pub`
+.dart_tool/
+
+# Avoid committing pubspec.lock for library packages; see
+# https://dart.dev/guides/libraries/private-files#pubspeclock.
+pubspec.lock
diff --git a/fig/link/CHANGELOG.md b/fig/link/CHANGELOG.md
new file mode 100644
index 0000000..effe43c
--- /dev/null
+++ b/fig/link/CHANGELOG.md
@@ -0,0 +1,3 @@
+## 1.0.0
+
+- Initial version.
diff --git a/fig/link/LICENSE.md b/fig/link/LICENSE.md
new file mode 100644
index 0000000..0fd0d03
--- /dev/null
+++ b/fig/link/LICENSE.md
@@ -0,0 +1,10 @@
+The MIT License (MIT)
+
+The Laravel Framework is Copyright (c) Taylor Otwell
+The Fabric Framework is Copyright (c) Vieo, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/fig/link/README.md b/fig/link/README.md
new file mode 100644
index 0000000..757f4c9
--- /dev/null
+++ b/fig/link/README.md
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/fig/link/analysis_options.yaml b/fig/link/analysis_options.yaml
new file mode 100644
index 0000000..dee8927
--- /dev/null
+++ b/fig/link/analysis_options.yaml
@@ -0,0 +1,30 @@
+# This file configures the static analysis results for your project (errors,
+# warnings, and lints).
+#
+# This enables the 'recommended' set of lints from `package:lints`.
+# This set helps identify many issues that may lead to problems when running
+# or consuming Dart code, and enforces writing Dart using a single, idiomatic
+# style and format.
+#
+# If you want a smaller set of lints you can change this to specify
+# 'package:lints/core.yaml'. These are just the most critical lints
+# (the recommended set includes the core lints).
+# The core lints are also what is used by pub.dev for scoring packages.
+
+include: package:lints/recommended.yaml
+
+# Uncomment the following section to specify additional rules.
+
+# linter:
+# rules:
+# - camel_case_types
+
+# analyzer:
+# exclude:
+# - path/to/excluded/files/**
+
+# For more information about the core and recommended set of lints, see
+# https://dart.dev/go/core-lints
+
+# For additional information about configuring this file, see
+# https://dart.dev/guides/language/analysis-options
diff --git a/fig/link/doc/.gitkeep b/fig/link/doc/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/link/example/.gitkeep b/fig/link/example/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/link/lib/link.dart b/fig/link/lib/link.dart
new file mode 100644
index 0000000..7a0dc9a
--- /dev/null
+++ b/fig/link/lib/link.dart
@@ -0,0 +1,9 @@
+/// A PSR-13 compatible link interface for Dart.
+///
+/// This library provides interfaces for working with web links following
+/// the PSR-13 Link Interface specification. It includes interfaces for
+/// both individual links and link providers.
+library link;
+
+export 'src/link_interface.dart';
+export 'src/link_provider_interface.dart';
diff --git a/fig/link/lib/src/link_interface.dart b/fig/link/lib/src/link_interface.dart
new file mode 100644
index 0000000..f9b97f7
--- /dev/null
+++ b/fig/link/lib/src/link_interface.dart
@@ -0,0 +1,94 @@
+/// Interface for a web link.
+///
+/// A link is a representation of a hyperlink from one resource to another.
+/// This interface represents a single hyperlink, including its target,
+/// relationship, and any attributes associated with it.
+abstract class LinkInterface {
+ /// Returns the target of the link.
+ ///
+ /// The target must be an absolute URI or a relative reference.
+ String getHref();
+
+ /// Returns whether this is a templated link.
+ ///
+ /// Returns true if this link object is a template that still needs to be
+ /// processed. Returns false if it is already a usable link.
+ bool isTemplated();
+
+ /// Returns the relationship type(s) of the link.
+ ///
+ /// This method returns 0 or more relationship types for a link, expressed
+ /// as strings.
+ Set getRels();
+
+ /// Returns the attributes of the link.
+ ///
+ /// Returns a map of attributes, where the key is the attribute name and the
+ /// value is the attribute value.
+ Map getAttributes();
+}
+
+/// Interface for an evolvable link value object.
+///
+/// An evolvable link is one that may be modified without forcing a new object
+/// to be created. This interface extends [LinkInterface] to provide methods
+/// for modifying the link properties.
+abstract class EvolvableLinkInterface implements LinkInterface {
+ /// Returns an instance with the specified href.
+ ///
+ /// [href] The href value to include.
+ ///
+ /// Returns a new instance with the specified href.
+ /// Implementations MUST NOT modify the underlying object but return
+ /// an updated copy.
+ EvolvableLinkInterface withHref(String href);
+
+ /// Returns an instance with the specified relationship included.
+ ///
+ /// If the specified rel is already present, this method MUST return
+ /// normally without errors but without adding the rel a second time.
+ ///
+ /// [rel] The relationship value to add.
+ ///
+ /// Returns a new instance with the specified relationship included.
+ /// Implementations MUST NOT modify the underlying object but return
+ /// an updated copy.
+ EvolvableLinkInterface withRel(String rel);
+
+ /// Returns an instance with the specified relationship excluded.
+ ///
+ /// If the specified rel is already not present, this method MUST return
+ /// normally without errors.
+ ///
+ /// [rel] The relationship value to exclude.
+ ///
+ /// Returns a new instance with the specified relationship excluded.
+ /// Implementations MUST NOT modify the underlying object but return
+ /// an updated copy.
+ EvolvableLinkInterface withoutRel(String rel);
+
+ /// Returns an instance with the specified attribute added.
+ ///
+ /// If the specified attribute is already present, it will be overwritten
+ /// with the new value.
+ ///
+ /// [attribute] The attribute to include.
+ /// [value] The value of the attribute to set.
+ ///
+ /// Returns a new instance with the specified attribute included.
+ /// Implementations MUST NOT modify the underlying object but return
+ /// an updated copy.
+ EvolvableLinkInterface withAttribute(String attribute, dynamic value);
+
+ /// Returns an instance with the specified attribute excluded.
+ ///
+ /// If the specified attribute is not present, this method MUST return
+ /// normally without errors.
+ ///
+ /// [attribute] The attribute to remove.
+ ///
+ /// Returns a new instance with the specified attribute excluded.
+ /// Implementations MUST NOT modify the underlying object but return
+ /// an updated copy.
+ EvolvableLinkInterface withoutAttribute(String attribute);
+}
diff --git a/fig/link/lib/src/link_provider_interface.dart b/fig/link/lib/src/link_provider_interface.dart
new file mode 100644
index 0000000..2859bd9
--- /dev/null
+++ b/fig/link/lib/src/link_provider_interface.dart
@@ -0,0 +1,50 @@
+import 'link_interface.dart';
+
+/// Interface for a link provider.
+///
+/// A link provider represents an object that contains web links, typically
+/// an HTTP response. This interface provides methods for accessing those links.
+abstract class LinkProviderInterface {
+ /// Returns a list of LinkInterface objects.
+ ///
+ /// [rel] The relationship type to retrieve links for.
+ ///
+ /// Returns a list of LinkInterface objects that have the specified relation.
+ List getLinks([String? rel]);
+
+ /// Returns a list of relationship types.
+ ///
+ /// Returns a list of strings, representing the rels available on this object.
+ List getLinksByRel(String rel);
+}
+
+/// Interface for an evolvable link provider value object.
+///
+/// An evolvable link provider is one that may be modified without forcing
+/// a new object to be created. This interface extends [LinkProviderInterface]
+/// to provide methods for modifying the provider's links.
+abstract class EvolvableLinkProviderInterface implements LinkProviderInterface {
+ /// Returns an instance with the specified link included.
+ ///
+ /// If the specified link is already present, this method will add the rel
+ /// from the link to the link already present.
+ ///
+ /// [link] A link object that should be included in this provider.
+ ///
+ /// Returns a new instance with the specified link included.
+ /// Implementations MUST NOT modify the underlying object but return
+ /// an updated copy.
+ EvolvableLinkProviderInterface withLink(LinkInterface link);
+
+ /// Returns an instance with the specified link excluded.
+ ///
+ /// If the specified link is not present, this method MUST return normally
+ /// without errors.
+ ///
+ /// [link] The link to remove.
+ ///
+ /// Returns a new instance with the specified link excluded.
+ /// Implementations MUST NOT modify the underlying object but return
+ /// an updated copy.
+ EvolvableLinkProviderInterface withoutLink(LinkInterface link);
+}
diff --git a/fig/link/pubspec.yaml b/fig/link/pubspec.yaml
new file mode 100644
index 0000000..eb9df80
--- /dev/null
+++ b/fig/link/pubspec.yaml
@@ -0,0 +1,13 @@
+name: dsr_link
+description: A PSR-13 compatible link interface for Dart. Provides standardized interfaces for working with web links, including link objects and link providers with support for HTTP Link headers.
+version: 0.0.1
+homepage: https://dart-fig.org
+
+environment:
+ sdk: ^3.4.2
+
+dependencies: {}
+
+dev_dependencies:
+ lints: ^3.0.0
+ test: ^1.24.0
diff --git a/fig/link/test/.gitkeep b/fig/link/test/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/log/.gitignore b/fig/log/.gitignore
new file mode 100644
index 0000000..3cceda5
--- /dev/null
+++ b/fig/log/.gitignore
@@ -0,0 +1,7 @@
+# https://dart.dev/guides/libraries/private-files
+# Created by `dart pub`
+.dart_tool/
+
+# Avoid committing pubspec.lock for library packages; see
+# https://dart.dev/guides/libraries/private-files#pubspeclock.
+pubspec.lock
diff --git a/fig/log/CHANGELOG.md b/fig/log/CHANGELOG.md
new file mode 100644
index 0000000..effe43c
--- /dev/null
+++ b/fig/log/CHANGELOG.md
@@ -0,0 +1,3 @@
+## 1.0.0
+
+- Initial version.
diff --git a/fig/log/LICENSE.md b/fig/log/LICENSE.md
new file mode 100644
index 0000000..0fd0d03
--- /dev/null
+++ b/fig/log/LICENSE.md
@@ -0,0 +1,10 @@
+The MIT License (MIT)
+
+The Laravel Framework is Copyright (c) Taylor Otwell
+The Fabric Framework is Copyright (c) Vieo, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/fig/log/README.md b/fig/log/README.md
new file mode 100644
index 0000000..757f4c9
--- /dev/null
+++ b/fig/log/README.md
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/fig/log/analysis_options.yaml b/fig/log/analysis_options.yaml
new file mode 100644
index 0000000..dee8927
--- /dev/null
+++ b/fig/log/analysis_options.yaml
@@ -0,0 +1,30 @@
+# This file configures the static analysis results for your project (errors,
+# warnings, and lints).
+#
+# This enables the 'recommended' set of lints from `package:lints`.
+# This set helps identify many issues that may lead to problems when running
+# or consuming Dart code, and enforces writing Dart using a single, idiomatic
+# style and format.
+#
+# If you want a smaller set of lints you can change this to specify
+# 'package:lints/core.yaml'. These are just the most critical lints
+# (the recommended set includes the core lints).
+# The core lints are also what is used by pub.dev for scoring packages.
+
+include: package:lints/recommended.yaml
+
+# Uncomment the following section to specify additional rules.
+
+# linter:
+# rules:
+# - camel_case_types
+
+# analyzer:
+# exclude:
+# - path/to/excluded/files/**
+
+# For more information about the core and recommended set of lints, see
+# https://dart.dev/go/core-lints
+
+# For additional information about configuring this file, see
+# https://dart.dev/guides/language/analysis-options
diff --git a/fig/log/doc/.gitkeep b/fig/log/doc/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/log/example/.gitkeep b/fig/log/example/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/log/lib/log.dart b/fig/log/lib/log.dart
new file mode 100644
index 0000000..bac32a4
--- /dev/null
+++ b/fig/log/lib/log.dart
@@ -0,0 +1,10 @@
+/// A PSR-3 compatible logger interface for Dart.
+///
+/// This library provides interfaces for logging following the PSR-3 Logger
+/// Interface specification. It includes interfaces for logging at various
+/// levels as defined in RFC 5424, along with logger awareness functionality.
+library log;
+
+export 'src/log_level.dart';
+export 'src/logger_interface.dart';
+export 'src/logger_aware_interface.dart';
diff --git a/fig/log/lib/src/log_level.dart b/fig/log/lib/src/log_level.dart
new file mode 100644
index 0000000..3113f58
--- /dev/null
+++ b/fig/log/lib/src/log_level.dart
@@ -0,0 +1,51 @@
+/// Standard logging levels.
+///
+/// These log levels are derived from the BSD syslog protocol levels, which are
+/// described in RFC 5424.
+class LogLevel {
+ /// System is unusable.
+ static const String emergency = 'emergency';
+
+ /// Action must be taken immediately.
+ ///
+ /// Example: Entire website down, database unavailable, etc.
+ static const String alert = 'alert';
+
+ /// Critical conditions.
+ ///
+ /// Example: Application component unavailable, unexpected exception.
+ static const String critical = 'critical';
+
+ /// Runtime errors that do not require immediate action but should be logged
+ /// and monitored.
+ static const String error = 'error';
+
+ /// Exceptional occurrences that are not errors.
+ ///
+ /// Example: Use of deprecated APIs, poor use of an API, undesirable things
+ /// that are not necessarily wrong.
+ static const String warning = 'warning';
+
+ /// Normal but significant events.
+ static const String notice = 'notice';
+
+ /// Interesting events.
+ ///
+ /// Example: User logs in, SQL logs.
+ static const String info = 'info';
+
+ /// Detailed debug information.
+ static const String debug = 'debug';
+
+ /// List of all valid log levels.
+ static const List validLevels = [
+ emergency,
+ alert,
+ critical,
+ error,
+ warning,
+ notice,
+ info,
+ debug,
+ ];
+}
diff --git a/fig/log/lib/src/logger_aware_interface.dart b/fig/log/lib/src/logger_aware_interface.dart
new file mode 100644
index 0000000..b96285c
--- /dev/null
+++ b/fig/log/lib/src/logger_aware_interface.dart
@@ -0,0 +1,9 @@
+import 'logger_interface.dart';
+
+/// Describes a logger-aware instance.
+abstract class LoggerAwareInterface {
+ /// Sets a logger instance on the object.
+ ///
+ /// [logger] The logger to set.
+ void setLogger(LoggerInterface logger);
+}
diff --git a/fig/log/lib/src/logger_interface.dart b/fig/log/lib/src/logger_interface.dart
new file mode 100644
index 0000000..97fc097
--- /dev/null
+++ b/fig/log/lib/src/logger_interface.dart
@@ -0,0 +1,69 @@
+import 'log_level.dart';
+
+/// Exception thrown if an invalid level is passed to a logger method.
+class InvalidArgumentException implements Exception {
+ final String message;
+
+ InvalidArgumentException(this.message);
+
+ @override
+ String toString() => 'InvalidArgumentException: $message';
+}
+
+/// Describes a logger instance.
+///
+/// The message MUST be a string or object implementing toString().
+///
+/// The context array can contain any extraneous information that does not fit well
+/// in a string. The context array can contain anything, but implementors MUST
+/// ensure they treat context data with as much lenience as possible.
+abstract class LoggerInterface {
+ /// System is unusable.
+ void emergency(Object message, [Map context = const {}]);
+
+ /// Action must be taken immediately.
+ ///
+ /// Example: Entire website down, database unavailable, etc.
+ void alert(Object message, [Map context = const {}]);
+
+ /// Critical conditions.
+ ///
+ /// Example: Application component unavailable, unexpected exception.
+ void critical(Object message, [Map context = const {}]);
+
+ /// Runtime errors that do not require immediate action but should be logged
+ /// and monitored.
+ void error(Object message, [Map context = const {}]);
+
+ /// Exceptional occurrences that are not errors.
+ ///
+ /// Example: Use of deprecated APIs, poor use of an API, undesirable things
+ /// that are not necessarily wrong.
+ void warning(Object message, [Map context = const {}]);
+
+ /// Normal but significant events.
+ void notice(Object message, [Map context = const {}]);
+
+ /// Interesting events.
+ ///
+ /// Example: User logs in, SQL logs.
+ void info(Object message, [Map context = const {}]);
+
+ /// Detailed debug information.
+ void debug(Object message, [Map context = const {}]);
+
+ /// Logs with an arbitrary level.
+ ///
+ /// [level] The log level. Must be one of the LogLevel constants.
+ /// [message] The log message.
+ /// [context] Additional context data.
+ ///
+ /// Throws [InvalidArgumentException] if level is not valid.
+ void log(String level, Object message,
+ [Map context = const {}]) {
+ if (!LogLevel.validLevels.contains(level)) {
+ throw InvalidArgumentException(
+ 'Level "$level" is not valid. Valid levels are: ${LogLevel.validLevels.join(', ')}');
+ }
+ }
+}
diff --git a/fig/log/pubspec.yaml b/fig/log/pubspec.yaml
new file mode 100644
index 0000000..ecfbbca
--- /dev/null
+++ b/fig/log/pubspec.yaml
@@ -0,0 +1,13 @@
+name: dsr_log
+description: A PSR-3 compatible logger interface for Dart. Provides standardized interfaces for logging with support for RFC 5424 log levels and contextual logging.
+version: 0.0.1
+homepage: https://dart-fig.org
+
+environment:
+ sdk: ^3.4.2
+
+dependencies: {}
+
+dev_dependencies:
+ lints: ^3.0.0
+ test: ^1.24.0
diff --git a/fig/log/test/.gitkeep b/fig/log/test/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/simple_cache/.gitignore b/fig/simple_cache/.gitignore
new file mode 100644
index 0000000..3cceda5
--- /dev/null
+++ b/fig/simple_cache/.gitignore
@@ -0,0 +1,7 @@
+# https://dart.dev/guides/libraries/private-files
+# Created by `dart pub`
+.dart_tool/
+
+# Avoid committing pubspec.lock for library packages; see
+# https://dart.dev/guides/libraries/private-files#pubspeclock.
+pubspec.lock
diff --git a/fig/simple_cache/CHANGELOG.md b/fig/simple_cache/CHANGELOG.md
new file mode 100644
index 0000000..effe43c
--- /dev/null
+++ b/fig/simple_cache/CHANGELOG.md
@@ -0,0 +1,3 @@
+## 1.0.0
+
+- Initial version.
diff --git a/fig/simple_cache/LICENSE.md b/fig/simple_cache/LICENSE.md
new file mode 100644
index 0000000..0fd0d03
--- /dev/null
+++ b/fig/simple_cache/LICENSE.md
@@ -0,0 +1,10 @@
+The MIT License (MIT)
+
+The Laravel Framework is Copyright (c) Taylor Otwell
+The Fabric Framework is Copyright (c) Vieo, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/fig/simple_cache/README.md b/fig/simple_cache/README.md
new file mode 100644
index 0000000..757f4c9
--- /dev/null
+++ b/fig/simple_cache/README.md
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/fig/simple_cache/analysis_options.yaml b/fig/simple_cache/analysis_options.yaml
new file mode 100644
index 0000000..dee8927
--- /dev/null
+++ b/fig/simple_cache/analysis_options.yaml
@@ -0,0 +1,30 @@
+# This file configures the static analysis results for your project (errors,
+# warnings, and lints).
+#
+# This enables the 'recommended' set of lints from `package:lints`.
+# This set helps identify many issues that may lead to problems when running
+# or consuming Dart code, and enforces writing Dart using a single, idiomatic
+# style and format.
+#
+# If you want a smaller set of lints you can change this to specify
+# 'package:lints/core.yaml'. These are just the most critical lints
+# (the recommended set includes the core lints).
+# The core lints are also what is used by pub.dev for scoring packages.
+
+include: package:lints/recommended.yaml
+
+# Uncomment the following section to specify additional rules.
+
+# linter:
+# rules:
+# - camel_case_types
+
+# analyzer:
+# exclude:
+# - path/to/excluded/files/**
+
+# For more information about the core and recommended set of lints, see
+# https://dart.dev/go/core-lints
+
+# For additional information about configuring this file, see
+# https://dart.dev/guides/language/analysis-options
diff --git a/fig/simple_cache/doc/.gitkeep b/fig/simple_cache/doc/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/simple_cache/example/.gitkeep b/fig/simple_cache/example/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/fig/simple_cache/lib/simple_cache.dart b/fig/simple_cache/lib/simple_cache.dart
new file mode 100644
index 0000000..3a263a5
--- /dev/null
+++ b/fig/simple_cache/lib/simple_cache.dart
@@ -0,0 +1,10 @@
+/// A PSR-16 compatible simple cache interface for Dart.
+///
+/// This library provides interfaces for simple caching following
+/// the PSR-16 Simple Cache Interface specification. It includes
+/// a straightforward interface for cache operations and related
+/// exception types.
+library simple_cache;
+
+export 'src/cache_interface.dart';
+export 'src/exceptions.dart';
diff --git a/fig/simple_cache/lib/src/cache_interface.dart b/fig/simple_cache/lib/src/cache_interface.dart
new file mode 100644
index 0000000..72835f4
--- /dev/null
+++ b/fig/simple_cache/lib/src/cache_interface.dart
@@ -0,0 +1,84 @@
+import 'exceptions.dart';
+
+/// Interface for caching libraries.
+///
+/// The key of the cache item must be a string with max length 64 characters,
+/// containing only A-Z, a-z, 0-9, _, and .
+abstract class CacheInterface {
+ /// Fetches a value from the cache.
+ ///
+ /// [key] The unique key of this item in the cache.
+ /// [defaultValue] Default value to return if the key does not exist.
+ ///
+ /// Returns the value of the item from the cache, or [defaultValue] if not found.
+ ///
+ /// Throws [InvalidArgumentException] if the [key] is not a legal value.
+ dynamic get(String key, [dynamic defaultValue]);
+
+ /// Persists data in the cache, uniquely referenced by a key.
+ ///
+ /// [key] The key of the item to store.
+ /// [value] The value of the item to store. Must be serializable.
+ /// [ttl] Optional. The TTL value of this item.
+ ///
+ /// Returns true on success and false on failure.
+ ///
+ /// Throws [InvalidArgumentException] if the [key] is not a legal value.
+ bool set(String key, dynamic value, [Duration? ttl]);
+
+ /// Delete an item from the cache by its unique key.
+ ///
+ /// [key] The unique cache key of the item to delete.
+ ///
+ /// Returns true if the item was successfully removed.
+ /// Returns false if there was an error.
+ ///
+ /// Throws [InvalidArgumentException] if the [key] is not a legal value.
+ bool delete(String key);
+
+ /// Wipes clean the entire cache's keys.
+ ///
+ /// Returns true on success and false on failure.
+ bool clear();
+
+ /// Obtains multiple cache items by their unique keys.
+ ///
+ /// [keys] A list of keys that can be obtained in a single operation.
+ ///
+ /// Returns a Map of key => value pairs. Cache keys that do not exist or are
+ /// stale will have a null value.
+ ///
+ /// Throws [InvalidArgumentException] if any of the [keys] are not legal values.
+ Map getMultiple(Iterable keys,
+ [dynamic defaultValue]);
+
+ /// Persists a set of key => value pairs in the cache.
+ ///
+ /// [values] A map of key => value pairs for a multiple-set operation.
+ /// [ttl] Optional. The TTL value of this item.
+ ///
+ /// Returns true on success and false on failure.
+ ///
+ /// Throws [InvalidArgumentException] if any of the [values] keys are not
+ /// legal values.
+ bool setMultiple(Map values, [Duration? ttl]);
+
+ /// Deletes multiple cache items in a single operation.
+ ///
+ /// [keys] A list of keys to be deleted.
+ ///
+ /// Returns true if the items were successfully removed.
+ /// Returns false if there was an error.
+ ///
+ /// Throws [InvalidArgumentException] if any of the [keys] are not legal values.
+ bool deleteMultiple(Iterable keys);
+
+ /// Determines whether an item is present in the cache.
+ ///
+ /// [key] The cache item key.
+ ///
+ /// Returns true if cache item exists, false otherwise.
+ ///
+ /// Throws [InvalidArgumentException] if the [key] is not a legal value.
+ bool has(String key);
+}
diff --git a/fig/simple_cache/lib/src/exceptions.dart b/fig/simple_cache/lib/src/exceptions.dart
new file mode 100644
index 0000000..ebed759
--- /dev/null
+++ b/fig/simple_cache/lib/src/exceptions.dart
@@ -0,0 +1,39 @@
+/// Base interface for exceptions thrown by a cache implementation.
+abstract class CacheException implements Exception {
+ /// The error message.
+ String get message;
+}
+
+/// Exception interface for invalid cache arguments.
+abstract class InvalidArgumentException implements CacheException {
+ /// The error message.
+ @override
+ String get message;
+}
+
+/// A concrete implementation of CacheException.
+class SimpleCacheException implements CacheException {
+ @override
+ final String message;
+
+ /// Creates a new cache exception.
+ const SimpleCacheException([this.message = '']);
+
+ @override
+ String toString() =>
+ message.isEmpty ? 'CacheException' : 'CacheException: $message';
+}
+
+/// A concrete implementation of InvalidArgumentException.
+class CacheInvalidArgumentException implements InvalidArgumentException {
+ @override
+ final String message;
+
+ /// Creates a new invalid argument exception.
+ const CacheInvalidArgumentException([this.message = '']);
+
+ @override
+ String toString() => message.isEmpty
+ ? 'InvalidArgumentException'
+ : 'InvalidArgumentException: $message';
+}
diff --git a/fig/simple_cache/pubspec.yaml b/fig/simple_cache/pubspec.yaml
new file mode 100644
index 0000000..d51f892
--- /dev/null
+++ b/fig/simple_cache/pubspec.yaml
@@ -0,0 +1,13 @@
+name: dsr_simple_cache
+description: A PSR-16 compatible simple cache interface for Dart. Provides standardized interfaces for basic caching operations with support for TTL, multiple operations, and proper error handling.
+version: 0.0.1
+homepage: https://dart-fig.org
+
+environment:
+ sdk: ^3.4.2
+
+dependencies: {}
+
+dev_dependencies:
+ lints: ^3.0.0
+ test: ^1.24.0
diff --git a/fig/simple_cache/test/.gitkeep b/fig/simple_cache/test/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/incubation/reflection/.gitignore b/incubation/reflection/.gitignore
new file mode 100644
index 0000000..3cceda5
--- /dev/null
+++ b/incubation/reflection/.gitignore
@@ -0,0 +1,7 @@
+# https://dart.dev/guides/libraries/private-files
+# Created by `dart pub`
+.dart_tool/
+
+# Avoid committing pubspec.lock for library packages; see
+# https://dart.dev/guides/libraries/private-files#pubspeclock.
+pubspec.lock
diff --git a/incubation/reflection/CHANGELOG.md b/incubation/reflection/CHANGELOG.md
new file mode 100644
index 0000000..effe43c
--- /dev/null
+++ b/incubation/reflection/CHANGELOG.md
@@ -0,0 +1,3 @@
+## 1.0.0
+
+- Initial version.
diff --git a/incubation/reflection/LICENSE.md b/incubation/reflection/LICENSE.md
new file mode 100644
index 0000000..0fd0d03
--- /dev/null
+++ b/incubation/reflection/LICENSE.md
@@ -0,0 +1,10 @@
+The MIT License (MIT)
+
+The Laravel Framework is Copyright (c) Taylor Otwell
+The Fabric Framework is Copyright (c) Vieo, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/incubation/reflection/README.md b/incubation/reflection/README.md
new file mode 100644
index 0000000..ede1186
--- /dev/null
+++ b/incubation/reflection/README.md
@@ -0,0 +1,492 @@
+# Platform Reflection
+
+A powerful cross-platform reflection system for Dart that provides runtime type introspection and manipulation. This implementation offers a carefully balanced approach between functionality and performance, providing reflection capabilities without the limitations of `dart:mirrors`.
+
+## Table of Contents
+
+- [Features](#features)
+- [Architecture](#architecture)
+- [Installation](#installation)
+- [Core Components](#core-components)
+- [Usage Guide](#usage-guide)
+- [Advanced Usage](#advanced-usage)
+- [Performance Considerations](#performance-considerations)
+- [Migration Guide](#migration-guide)
+- [API Reference](#api-reference)
+- [Limitations](#limitations)
+- [Contributing](#contributing)
+- [License](#license)
+
+## Features
+
+### Core Features
+- ✅ Platform independent reflection system
+- ✅ No dependency on `dart:mirrors`
+- ✅ Pure runtime reflection
+- ✅ Library scanning and reflection
+- ✅ Explicit registration for performance
+- ✅ Type-safe operations
+- ✅ Comprehensive error handling
+
+### Reflection Capabilities
+- ✅ Class reflection with inheritance
+- ✅ Method invocation with named parameters
+- ✅ Property access/mutation
+- ✅ Constructor resolution and invocation
+- ✅ Type introspection and relationships
+- ✅ Library dependency tracking
+- ✅ Parameter inspection and validation
+- ✅ Top-level variable support
+
+### Performance Features
+- ✅ Cached class mirrors
+- ✅ Optimized type compatibility checking
+- ✅ Efficient parameter resolution
+- ✅ Smart library scanning
+- ✅ Memory-efficient design
+- ✅ Lazy initialization support
+
+## Architecture
+
+### Core Components
+
+```
+platform_reflection/
+├── core/
+│ ├── library_scanner.dart # Library scanning and analysis
+│ ├── reflector.dart # Central reflection registry
+│ ├── runtime_reflector.dart # Runtime reflection implementation
+│ └── scanner.dart # Type scanning and analysis
+├── mirrors/
+│ ├── base_mirror.dart # Base mirror implementations
+│ ├── class_mirror_impl.dart # Class reflection
+│ ├── instance_mirror_impl.dart # Instance reflection
+│ ├── library_mirror_impl.dart # Library reflection
+│ ├── method_mirror_impl.dart # Method reflection
+│ └── ... (other mirrors)
+├── annotations.dart # Reflection annotations
+├── exceptions.dart # Error handling
+├── metadata.dart # Metadata definitions
+└── types.dart # Special type implementations
+```
+
+### Design Principles
+
+1. **Explicit Registration**
+ - Clear registration of reflectable types
+ - Controlled reflection surface
+ - Optimized runtime performance
+
+2. **Type Safety**
+ - Strong type checking
+ - Compile-time validations
+ - Runtime type verification
+
+3. **Performance First**
+ - Minimal runtime overhead
+ - Efficient metadata storage
+ - Optimized lookup mechanisms
+
+4. **Platform Independence**
+ - Cross-platform compatibility
+ - No platform-specific dependencies
+ - Consistent behavior
+
+## Installation
+
+```yaml
+dependencies:
+ platform_reflection: ^0.1.0
+```
+
+## Core Components
+
+### Reflector
+
+Central management class for reflection operations:
+
+```dart
+class Reflector {
+ // Type registration
+ static void register(Type type);
+ static void registerProperty(Type type, String name, Type propertyType);
+ static void registerMethod(Type type, String name, List parameterTypes);
+ static void registerConstructor(Type type, String name, {Function? creator});
+
+ // Metadata access
+ static TypeMetadata? getTypeMetadata(Type type);
+ static Map? getPropertyMetadata(Type type);
+ static Map? getMethodMetadata(Type type);
+
+ // Utility methods
+ static void reset();
+ static bool isReflectable(Type type);
+}
+```
+
+### RuntimeReflector
+
+Runtime reflection implementation:
+
+```dart
+class RuntimeReflector {
+ // Instance creation
+ InstanceMirror createInstance(Type type, {
+ List? positionalArgs,
+ Map? namedArgs,
+ String? constructorName,
+ });
+
+ // Reflection operations
+ InstanceMirror reflect(Object object);
+ ClassMirror reflectClass(Type type);
+ TypeMirror reflectType(Type type);
+ LibraryMirror reflectLibrary(Uri uri);
+}
+```
+
+### LibraryScanner
+
+Library scanning and analysis:
+
+```dart
+class LibraryScanner {
+ // Library scanning
+ static LibraryInfo scanLibrary(Uri uri);
+
+ // Analysis methods
+ static List getTopLevelFunctions(Uri uri);
+ static List getTopLevelVariables(Uri uri);
+ static List getDependencies(Uri uri);
+}
+```
+
+## Usage Guide
+
+### Basic Registration
+
+```dart
+@reflectable
+class User {
+ String name;
+ int age;
+ final String id;
+
+ User(this.name, this.age, {required this.id});
+
+ void birthday() {
+ age++;
+ }
+
+ String greet(String greeting) {
+ return '$greeting $name!';
+ }
+}
+
+// Register class and members
+void registerUser() {
+ Reflector.register(User);
+
+ // Register properties
+ Reflector.registerProperty(User, 'name', String);
+ Reflector.registerProperty(User, 'age', int);
+ Reflector.registerProperty(User, 'id', String, isWritable: false);
+
+ // Register methods
+ Reflector.registerMethod(
+ User,
+ 'birthday',
+ [],
+ true,
+ parameterNames: [],
+ isRequired: [],
+ );
+
+ Reflector.registerMethod(
+ User,
+ 'greet',
+ [String],
+ false,
+ parameterNames: ['greeting'],
+ isRequired: [true],
+ );
+
+ // Register constructor
+ Reflector.registerConstructor(
+ User,
+ '',
+ parameterTypes: [String, int, String],
+ parameterNames: ['name', 'age', 'id'],
+ isRequired: [true, true, true],
+ isNamed: [false, false, true],
+ creator: (String name, int age, {required String id}) =>
+ User(name, age, id: id),
+ );
+}
+```
+
+### Instance Manipulation
+
+```dart
+void manipulateInstance() {
+ final reflector = RuntimeReflector.instance;
+
+ // Create instance
+ final user = reflector.createInstance(
+ User,
+ positionalArgs: ['John', 30],
+ namedArgs: {'id': '123'},
+ ) as User;
+
+ // Get mirror
+ final mirror = reflector.reflect(user);
+
+ // Property access
+ final name = mirror.getField(const Symbol('name')).reflectee as String;
+ final age = mirror.getField(const Symbol('age')).reflectee as int;
+
+ // Property modification
+ mirror.setField(const Symbol('name'), 'Jane');
+ mirror.setField(const Symbol('age'), 31);
+
+ // Method invocation
+ mirror.invoke(const Symbol('birthday'), []);
+ final greeting = mirror.invoke(
+ const Symbol('greet'),
+ ['Hello'],
+ ).reflectee as String;
+}
+```
+
+### Library Reflection
+
+```dart
+void reflectLibrary() {
+ final reflector = RuntimeReflector.instance;
+
+ // Get library mirror
+ final library = reflector.reflectLibrary(
+ Uri.parse('package:myapp/src/models.dart')
+ );
+
+ // Access top-level function
+ final result = library.invoke(
+ const Symbol('utilityFunction'),
+ [arg1, arg2],
+ ).reflectee;
+
+ // Access top-level variable
+ final value = library.getField(const Symbol('constant')).reflectee;
+
+ // Get library dependencies
+ final dependencies = library.libraryDependencies;
+ for (final dep in dependencies) {
+ print('Import: ${dep.targetLibrary.uri}');
+ print('Is deferred: ${dep.isDeferred}');
+ }
+}
+```
+
+### Type Relationships
+
+```dart
+void checkTypes() {
+ final reflector = RuntimeReflector.instance;
+
+ // Get class mirrors
+ final userMirror = reflector.reflectClass(User);
+ final baseMirror = reflector.reflectClass(BaseClass);
+
+ // Check inheritance
+ final isSubclass = userMirror.isSubclassOf(baseMirror);
+
+ // Check type compatibility
+ final isCompatible = userMirror.isAssignableTo(baseMirror);
+
+ // Get superclass
+ final superclass = userMirror.superclass;
+
+ // Get interfaces
+ final interfaces = userMirror.interfaces;
+}
+```
+
+## Advanced Usage
+
+### Generic Type Handling
+
+```dart
+@reflectable
+class Container {
+ T value;
+ Container(this.value);
+}
+
+void handleGenericType() {
+ Reflector.register(Container);
+
+ // Register with specific type
+ final stringContainer = reflector.createInstance(
+ Container,
+ positionalArgs: ['Hello'],
+ ) as Container;
+
+ final mirror = reflector.reflect(stringContainer);
+ final value = mirror.getField(const Symbol('value')).reflectee as String;
+}
+```
+
+### Error Handling
+
+```dart
+void demonstrateErrorHandling() {
+ try {
+ // Attempt to reflect unregistered type
+ reflector.reflect(UnregisteredClass());
+ } on NotReflectableException catch (e) {
+ print('Type not registered: $e');
+ }
+
+ try {
+ // Attempt to access non-existent member
+ final mirror = reflector.reflect(user);
+ mirror.getField(const Symbol('nonexistent'));
+ } on MemberNotFoundException catch (e) {
+ print('Member not found: $e');
+ }
+
+ try {
+ // Attempt invalid method invocation
+ final mirror = reflector.reflect(user);
+ mirror.invoke(const Symbol('greet'), [42]); // Wrong argument type
+ } on InvalidArgumentsException catch (e) {
+ print('Invalid arguments: $e');
+ }
+}
+```
+
+## Performance Considerations
+
+### Registration Impact
+
+- Explicit registration adds startup cost
+- Improved runtime performance
+- Reduced memory usage
+- Controlled reflection surface
+
+### Optimization Techniques
+
+1. **Lazy Loading**
+ ```dart
+ // Only register when needed
+ if (Reflector.getTypeMetadata(User) == null) {
+ registerUser();
+ }
+ ```
+
+2. **Metadata Caching**
+ ```dart
+ // Cache metadata access
+ final metadata = Reflector.getTypeMetadata(User);
+ final properties = metadata.properties;
+ final methods = metadata.methods;
+ ```
+
+3. **Instance Reuse**
+ ```dart
+ // Reuse instance mirrors
+ final mirror = reflector.reflect(user);
+ // Store mirror for repeated use
+ ```
+
+### Memory Management
+
+- Cached class mirrors
+- Efficient parameter resolution
+- Smart library scanning
+- Minimal metadata storage
+
+## Migration Guide
+
+### From dart:mirrors
+
+```dart
+// Old dart:mirrors code
+import 'dart:mirrors';
+
+final mirror = reflect(instance);
+final value = mirror.getField(#propertyName).reflectee;
+
+// New platform_reflection code
+import 'package:platform_reflection/reflection.dart';
+
+final mirror = reflector.reflect(instance);
+final value = mirror.getField(const Symbol('propertyName')).reflectee;
+```
+
+### Registration Requirements
+
+```dart
+// Add registration code
+void registerTypes() {
+ Reflector.register(MyClass);
+ Reflector.registerProperty(MyClass, 'property', String);
+ Reflector.registerMethod(MyClass, 'method', [int]);
+}
+```
+
+## API Reference
+
+### Core Classes
+
+- `Reflector`: Central reflection management
+- `RuntimeReflector`: Runtime reflection operations
+- `LibraryScanner`: Library scanning and analysis
+
+### Mirrors
+
+- `InstanceMirror`: Instance reflection
+- `ClassMirror`: Class reflection
+- `MethodMirror`: Method reflection
+- `LibraryMirror`: Library reflection
+- `TypeMirror`: Type reflection
+
+### Metadata
+
+- `TypeMetadata`: Type information
+- `PropertyMetadata`: Property information
+- `MethodMetadata`: Method information
+- `ConstructorMetadata`: Constructor information
+
+### Exceptions
+
+- `NotReflectableException`
+- `ReflectionException`
+- `InvalidArgumentsException`
+- `MemberNotFoundException`
+
+## Limitations
+
+Current Implementation Gaps:
+
+1. **Type System**
+ - Limited generic variance support
+ - Basic type relationship checking
+
+2. **Reflection Features**
+ - No extension method support
+ - Limited annotation metadata
+ - No cross-package private member access
+
+3. **Language Features**
+ - No operator overloading reflection
+ - No dynamic code generation
+ - Limited mixin support
+
+## Contributing
+
+See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed contribution guidelines.
+
+## License
+
+MIT License - see [LICENSE](LICENSE) for details.
diff --git a/incubation/reflection/analysis_options.yaml b/incubation/reflection/analysis_options.yaml
new file mode 100644
index 0000000..dee8927
--- /dev/null
+++ b/incubation/reflection/analysis_options.yaml
@@ -0,0 +1,30 @@
+# This file configures the static analysis results for your project (errors,
+# warnings, and lints).
+#
+# This enables the 'recommended' set of lints from `package:lints`.
+# This set helps identify many issues that may lead to problems when running
+# or consuming Dart code, and enforces writing Dart using a single, idiomatic
+# style and format.
+#
+# If you want a smaller set of lints you can change this to specify
+# 'package:lints/core.yaml'. These are just the most critical lints
+# (the recommended set includes the core lints).
+# The core lints are also what is used by pub.dev for scoring packages.
+
+include: package:lints/recommended.yaml
+
+# Uncomment the following section to specify additional rules.
+
+# linter:
+# rules:
+# - camel_case_types
+
+# analyzer:
+# exclude:
+# - path/to/excluded/files/**
+
+# For more information about the core and recommended set of lints, see
+# https://dart.dev/go/core-lints
+
+# For additional information about configuring this file, see
+# https://dart.dev/guides/language/analysis-options
diff --git a/incubation/reflection/doc/capabilities.md b/incubation/reflection/doc/capabilities.md
new file mode 100644
index 0000000..8b1a3bc
--- /dev/null
+++ b/incubation/reflection/doc/capabilities.md
@@ -0,0 +1,287 @@
+# Platform Reflection Capabilities
+
+## Core Reflection Features
+
+### 1. Library Reflection
+```dart
+// Library reflection support
+final library = LibraryMirrorImpl.withDeclarations(
+ name: 'my_library',
+ uri: Uri.parse('package:my_package/my_library.dart'),
+);
+
+// Access top-level members
+final greeting = library.getField(const Symbol('greeting')).reflectee;
+final sum = library.invoke(
+ const Symbol('add'),
+ [1, 2],
+).reflectee;
+```
+
+### 2. Isolate Support
+```dart
+// Current isolate reflection
+final current = IsolateMirrorImpl.current(rootLibrary);
+
+// Other isolate reflection
+final other = IsolateMirrorImpl.other(
+ isolate,
+ 'worker',
+ rootLibrary,
+);
+
+// Isolate control
+await other.pause();
+await other.resume();
+await other.kill();
+
+// Error handling
+other.addErrorListener((error, stack) {
+ print('Error in isolate: $error\n$stack');
+});
+
+// Exit handling
+other.addExitListener((message) {
+ print('Isolate exited with: $message');
+});
+```
+
+### 3. Type System
+```dart
+// Special types
+final voidType = VoidType.instance;
+final dynamicType = DynamicType.instance;
+final neverType = NeverType.instance;
+
+// Type checking
+final isVoid = type.isVoid;
+final isDynamic = type.isDynamic;
+final isNever = type.isNever;
+```
+
+### 4. Metadata System
+```dart
+// Parameter metadata
+final param = ParameterMetadata(
+ name: 'id',
+ type: int,
+ isRequired: true,
+ isNamed: false,
+ defaultValue: 0,
+ attributes: [deprecated],
+);
+
+// Property metadata
+final prop = PropertyMetadata(
+ name: 'name',
+ type: String,
+ isReadable: true,
+ isWritable: true,
+ attributes: [override],
+);
+
+// Method metadata
+final method = MethodMetadata(
+ name: 'calculate',
+ parameterTypes: [int, double],
+ parameters: [...],
+ isStatic: false,
+ returnsVoid: false,
+ attributes: [deprecated],
+);
+```
+
+### 5. Constructor Support
+```dart
+// Constructor metadata
+final ctor = ConstructorMetadata(
+ name: 'named',
+ parameterTypes: [String, int],
+ parameters: [...],
+ parameterNames: ['name', 'age'],
+ attributes: [...],
+);
+
+// Validation
+final valid = ctor.validateArguments(['John', 42]);
+```
+
+### 6. Type Metadata
+```dart
+// Full type information
+final type = TypeMetadata(
+ type: User,
+ name: 'User',
+ properties: {...},
+ methods: {...},
+ constructors: [...],
+ supertype: Person,
+ interfaces: [Comparable],
+ attributes: [serializable],
+);
+
+// Member access
+final prop = type.getProperty('name');
+final method = type.getMethod('greet');
+final ctor = type.getConstructor('guest');
+```
+
+## Advanced Features
+
+### 1. Library Dependencies
+```dart
+final deps = library.libraryDependencies;
+for (var dep in deps) {
+ if (dep.isImport) {
+ print('Imports: ${dep.targetLibrary?.uri}');
+ }
+}
+```
+
+### 2. Declaration Access
+```dart
+final decls = library.declarations;
+for (var decl in decls.values) {
+ if (decl is MethodMirror) {
+ print('Method: ${decl.simpleName}');
+ } else if (decl is VariableMirror) {
+ print('Variable: ${decl.simpleName}');
+ }
+}
+```
+
+### 3. Function Metadata
+```dart
+final func = FunctionMetadata(
+ parameters: [...],
+ returnsVoid: false,
+ returnType: int,
+);
+
+final valid = func.validateArguments([1, 2.0]);
+```
+
+### 4. Reflection Registry
+```dart
+// Type registration
+ReflectionRegistry.registerType(User);
+
+// Member registration
+ReflectionRegistry.registerProperty(
+ User,
+ 'name',
+ String,
+ isReadable: true,
+ isWritable: true,
+);
+
+ReflectionRegistry.registerMethod(
+ User,
+ 'greet',
+ [String],
+ false,
+);
+
+ReflectionRegistry.registerConstructor(
+ User,
+ 'guest',
+ factory,
+);
+```
+
+## Error Handling
+
+```dart
+try {
+ // Reflection operations
+} on MemberNotFoundException catch (e) {
+ print('Member not found: ${e.memberName} on ${e.type}');
+} on InvalidArgumentsException catch (e) {
+ print('Invalid arguments for ${e.memberName}');
+} on ReflectionException catch (e) {
+ print('Reflection error: ${e.message}');
+}
+```
+
+## Platform Support
+
+- ✅ VM (Full support)
+- ✅ Web (Full support)
+- ✅ Flutter (Full support)
+- ✅ AOT compilation (Full support)
+
+## Performance Considerations
+
+1. **Registration Impact**
+ - One-time registration cost
+ - Optimized runtime performance
+ - Minimal memory overhead
+
+2. **Metadata Caching**
+ - Efficient metadata storage
+ - Fast lookup mechanisms
+ - Memory-conscious design
+
+3. **Cross-isolate Performance**
+ - Minimal serialization overhead
+ - Efficient isolate communication
+ - Controlled resource usage
+
+## Security Features
+
+1. **Access Control**
+ - Controlled reflection surface
+ - Explicit registration required
+ - Member visibility respect
+
+2. **Type Safety**
+ - Strong type checking
+ - Argument validation
+ - Return type verification
+
+3. **Isolate Safety**
+ - Controlled isolate access
+ - Error propagation
+ - Resource cleanup
+
+## Best Practices
+
+1. **Registration**
+ ```dart
+ // Register early
+ void main() {
+ registerTypes();
+ runApp();
+ }
+ ```
+
+2. **Metadata Usage**
+ ```dart
+ // Cache metadata
+ final metadata = Reflector.getTypeMetadata(User);
+ final properties = metadata.properties;
+ final methods = metadata.methods;
+ ```
+
+3. **Error Handling**
+ ```dart
+ // Comprehensive error handling
+ try {
+ final result = mirror.invoke(name, args);
+ } on ReflectionException catch (e) {
+ handleError(e);
+ }
+ ```
+
+4. **Isolate Management**
+ ```dart
+ // Proper cleanup
+ final isolate = IsolateMirrorImpl.other(...);
+ try {
+ await doWork(isolate);
+ } finally {
+ await isolate.kill();
+ }
+ ```
+
+This document provides a comprehensive overview of the Platform Reflection library's capabilities. For detailed API documentation, see the [API Reference](../README.md#api-reference).
diff --git a/incubation/reflection/doc/index.md b/incubation/reflection/doc/index.md
new file mode 100644
index 0000000..a278906
--- /dev/null
+++ b/incubation/reflection/doc/index.md
@@ -0,0 +1,109 @@
+# Platform Reflection Documentation
+
+## Overview
+Platform Reflection is a modern reflection system for Dart that provides runtime type introspection and manipulation capabilities across all platforms.
+
+## Documentation Structure
+
+### Core Documentation
+- [README](../README.md) - Overview, installation, and basic usage
+- [Quick Start Guide](quick_start.md) - Get started quickly with common use cases
+- [Technical Specification](technical_specification.md) - Detailed implementation details
+- [Mirrors Comparison](mirrors_comparison.md) - Feature comparison with dart:mirrors
+- [Development Roadmap](roadmap.md) - Future plans and development direction
+
+### API Documentation
+- [API Reference](../README.md#api-reference) - Complete API documentation
+- [Core Components](technical_specification.md#core-components) - Core system components
+- [Implementation Details](technical_specification.md#implementation-details) - Implementation specifics
+
+### Guides
+1. Basic Usage
+ - [Installation](../README.md#installation)
+ - [Basic Reflection](quick_start.md#basic-usage)
+ - [Property Access](quick_start.md#2-property-access)
+ - [Method Invocation](quick_start.md#3-method-invocation)
+
+2. Advanced Usage
+ - [Type Information](quick_start.md#5-type-information)
+ - [Error Handling](quick_start.md#6-error-handling)
+ - [Common Patterns](quick_start.md#common-patterns)
+ - [Best Practices](quick_start.md#best-practices)
+
+3. Performance
+ - [Optimization Techniques](technical_specification.md#performance-optimizations)
+ - [Performance Tips](quick_start.md#performance-tips)
+ - [Memory Management](technical_specification.md#memory-management)
+
+### Implementation Status
+
+#### Current Features
+✅ Basic reflection system
+✅ Property access/mutation
+✅ Method invocation
+✅ Constructor handling
+✅ Type introspection
+✅ Basic metadata support
+✅ Error handling
+✅ Cross-platform support
+
+#### Known Limitations
+❌ No cross-isolate reflection
+❌ Limited generic support
+❌ No source location tracking
+❌ No extension method support
+❌ No mixin composition
+❌ Limited metadata capabilities
+❌ No dynamic proxy generation
+❌ No attribute-based reflection
+
+### Development
+
+1. Contributing
+ - [Getting Started](roadmap.md#getting-started)
+ - [Priority Areas](roadmap.md#priority-areas)
+ - [Development Process](roadmap.md#development-process)
+
+2. Future Plans
+ - [Short-term Goals](roadmap.md#short-term-goals-v020)
+ - [Medium-term Goals](roadmap.md#medium-term-goals-v030)
+ - [Long-term Goals](roadmap.md#long-term-goals-v100)
+
+### Support
+
+1. Help Resources
+ - [Common Issues](quick_start.md#common-issues)
+ - [Best Practices](quick_start.md#best-practices)
+ - [Performance Tips](quick_start.md#performance-tips)
+
+2. Version Support
+ - [Support Matrix](roadmap.md#version-support-matrix)
+ - [Breaking Changes](roadmap.md#breaking-changes)
+ - [Migration Support](roadmap.md#migration-support)
+
+## Quick Links
+
+### For New Users
+1. Start with the [README](../README.md)
+2. Follow the [Quick Start Guide](quick_start.md)
+3. Review [Common Issues](quick_start.md#common-issues)
+4. Check [Best Practices](quick_start.md#best-practices)
+
+### For Contributors
+1. Review the [Technical Specification](technical_specification.md)
+2. Check the [Development Roadmap](roadmap.md)
+3. See [Priority Areas](roadmap.md#priority-areas)
+4. Read [Contributing Guidelines](../CONTRIBUTING.md)
+
+### For Framework Developers
+1. Study the [Mirrors Comparison](mirrors_comparison.md)
+2. Review [Implementation Details](technical_specification.md#implementation-details)
+3. Check [Framework Integration](roadmap.md#framework-integration)
+4. See [Enterprise Features](roadmap.md#enterprise-features)
+
+## Document Updates
+
+This documentation is continuously updated to reflect the latest changes and improvements in the Platform Reflection library. Check the [Development Roadmap](roadmap.md) for upcoming changes and new features.
+
+Last Updated: 2024-01
+Version: 0.1.0
diff --git a/incubation/reflection/doc/mirrors_comparison.md b/incubation/reflection/doc/mirrors_comparison.md
new file mode 100644
index 0000000..2933552
--- /dev/null
+++ b/incubation/reflection/doc/mirrors_comparison.md
@@ -0,0 +1,209 @@
+# Dart Mirrors vs Platform Reflection Comparison
+
+## Core Features Comparison
+
+| Feature | dart:mirrors | Platform Reflection | Notes |
+|---------|-------------|-------------------|--------|
+| **Library Reflection** |
+| Top-level functions | ✅ Full | ✅ Full | Complete parity |
+| Top-level variables | ✅ Full | ✅ Full | Complete parity |
+| Library dependencies | ✅ Full | ✅ Full | Complete parity |
+| URI resolution | ✅ Full | ✅ Full | Complete parity |
+
+| Feature | dart:mirrors | Platform Reflection | Notes |
+|---------|-------------|-------------------|--------|
+| **Isolate Support** |
+| Current isolate | ✅ Full | ✅ Full | Complete parity |
+| Other isolates | ✅ Full | ✅ Full | Complete parity |
+| Isolate control | ✅ Full | ✅ Full | Pause/Resume/Kill |
+| Error handling | ✅ Full | ✅ Full | Error/Exit listeners |
+
+| Feature | dart:mirrors | Platform Reflection | Notes |
+|---------|-------------|-------------------|--------|
+| **Type System** |
+| Special types | ✅ Full | ✅ Full | void/dynamic/never |
+| Type relationships | ✅ Full | ✅ Full | Complete type checking |
+| Generic types | ✅ Full | ⚠️ Limited | Basic generic support |
+| Type parameters | ✅ Full | ⚠️ Limited | Basic parameter support |
+
+| Feature | dart:mirrors | Platform Reflection | Notes |
+|---------|-------------|-------------------|--------|
+| **Metadata System** |
+| Class metadata | ✅ Full | ✅ Full | Complete parity |
+| Method metadata | ✅ Full | ✅ Full | Complete parity |
+| Property metadata | ✅ Full | ✅ Full | Complete parity |
+| Parameter metadata | ✅ Full | ✅ Full | Complete parity |
+| Custom attributes | ✅ Full | ✅ Full | Complete parity |
+
+## Implementation Differences
+
+### Registration System
+
+```dart
+// dart:mirrors
+// No registration needed
+@reflectable
+class MyClass {}
+
+// Platform Reflection
+@reflectable
+class MyClass {}
+
+// Requires explicit registration
+Reflector.register(MyClass);
+Reflector.registerProperty(MyClass, 'prop', String);
+Reflector.registerMethod(MyClass, 'method', [int]);
+```
+
+### Library Access
+
+```dart
+// dart:mirrors
+final lib = MirrorSystem.findLibrary('my_lib');
+
+// Platform Reflection
+final lib = LibraryMirrorImpl.withDeclarations(
+ name: 'my_lib',
+ uri: Uri.parse('package:my_package/my_lib.dart'),
+);
+```
+
+### Isolate Handling
+
+```dart
+// dart:mirrors
+final mirror = reflect(isolate);
+await mirror.invoke(#method, []);
+
+// Platform Reflection
+final mirror = IsolateMirrorImpl.other(isolate, 'name', lib);
+mirror.addErrorListener((error, stack) {
+ // Handle error
+});
+```
+
+### Type System
+
+```dart
+// dart:mirrors
+final type = reflectType(MyClass);
+final isSubtype = type.isSubtypeOf(otherType);
+
+// Platform Reflection
+final type = TypeMetadata(
+ type: MyClass,
+ name: 'MyClass',
+ // ...
+);
+final isSubtype = type.supertype == otherType;
+```
+
+## Performance Characteristics
+
+| Aspect | dart:mirrors | Platform Reflection | Winner |
+|--------|-------------|-------------------|---------|
+| Startup time | ❌ Slower | ✅ Faster | Platform Reflection |
+| Runtime performance | ❌ Slower | ✅ Faster | Platform Reflection |
+| Memory usage | ❌ Higher | ✅ Lower | Platform Reflection |
+| Tree shaking | ❌ Poor | ✅ Good | Platform Reflection |
+
+## Platform Support
+
+| Platform | dart:mirrors | Platform Reflection | Winner |
+|----------|-------------|-------------------|---------|
+| VM | ✅ Yes | ✅ Yes | Tie |
+| Web | ❌ No | ✅ Yes | Platform Reflection |
+| Flutter | ❌ No | ✅ Yes | Platform Reflection |
+| AOT | ❌ No | ✅ Yes | Platform Reflection |
+
+## Use Cases
+
+| Use Case | dart:mirrors | Platform Reflection | Better Choice |
+|----------|-------------|-------------------|---------------|
+| Dependency injection | ✅ Simpler | ⚠️ More setup | dart:mirrors |
+| Serialization | ✅ Simpler | ⚠️ More setup | dart:mirrors |
+| Testing/Mocking | ✅ More flexible | ✅ More controlled | Depends on needs |
+| Production apps | ❌ Limited platforms | ✅ All platforms | Platform Reflection |
+
+## Migration Path
+
+### From dart:mirrors
+
+1. Add registration:
+```dart
+// Before
+@reflectable
+class MyClass {}
+
+// After
+@reflectable
+class MyClass {}
+
+void register() {
+ Reflector.register(MyClass);
+ // Register members...
+}
+```
+
+2. Update reflection calls:
+```dart
+// Before
+final mirror = reflect(instance);
+final value = mirror.getField(#prop);
+
+// After
+final mirror = reflector.reflect(instance);
+final value = mirror.getField(const Symbol('prop'));
+```
+
+3. Handle libraries:
+```dart
+// Before
+final lib = MirrorSystem.findLibrary('my_lib');
+
+// After
+final lib = LibraryMirrorImpl.withDeclarations(
+ name: 'my_lib',
+ uri: uri,
+);
+```
+
+## Trade-offs
+
+### Advantages of Platform Reflection
+1. Works everywhere
+2. Better performance
+3. Smaller code size
+4. Better tree shaking
+5. Full isolate support
+6. Production-ready
+
+### Advantages of dart:mirrors
+1. No registration needed
+2. Simpler API
+3. More dynamic capabilities
+4. Better for development tools
+5. More flexible
+
+## Conclusion
+
+Platform Reflection offers a more production-ready alternative to dart:mirrors with:
+- Full cross-platform support
+- Better performance characteristics
+- More controlled reflection surface
+- Full isolate support
+- Production-ready features
+
+The main trade-off is the need for explicit registration, but this brings benefits in terms of performance, code size, and tree shaking.
+
+Choose Platform Reflection when:
+- You need cross-platform support
+- Performance is critical
+- Code size matters
+- You want production-ready reflection
+
+Choose dart:mirrors when:
+- You're only targeting the VM
+- Development time is critical
+- You need maximum flexibility
+- You're building development tools
diff --git a/incubation/reflection/doc/quick_start.md b/incubation/reflection/doc/quick_start.md
new file mode 100644
index 0000000..6c6003e
--- /dev/null
+++ b/incubation/reflection/doc/quick_start.md
@@ -0,0 +1,369 @@
+# Platform Reflection Quick Start Guide
+
+This guide covers the most common use cases for Platform Reflection to help you get started quickly.
+
+## Installation
+
+```yaml
+dependencies:
+ platform_reflection: ^0.1.0
+```
+
+## Basic Usage
+
+### 1. Simple Class Reflection
+
+```dart
+import 'package:platform_reflection/reflection.dart';
+
+// 1. Define your class
+@reflectable
+class User {
+ String name;
+ int age;
+
+ User(this.name, this.age);
+
+ void birthday() => age++;
+}
+
+// 2. Register for reflection
+void main() {
+ // Register class
+ Reflector.register(User);
+
+ // Register properties
+ Reflector.registerProperty(User, 'name', String);
+ Reflector.registerProperty(User, 'age', int);
+
+ // Register methods
+ Reflector.registerMethod(
+ User,
+ 'birthday',
+ [],
+ true,
+ );
+
+ // Register constructor
+ Reflector.registerConstructor(
+ User,
+ '',
+ parameterTypes: [String, int],
+ parameterNames: ['name', 'age'],
+ creator: (String name, int age) => User(name, age),
+ );
+
+ // Use reflection
+ final user = reflector.createInstance(
+ User,
+ positionalArgs: ['John', 30],
+ ) as User;
+
+ final mirror = reflector.reflect(user);
+ print(mirror.getField(const Symbol('name')).reflectee); // John
+ mirror.invoke(const Symbol('birthday'), []);
+ print(mirror.getField(const Symbol('age')).reflectee); // 31
+}
+```
+
+### 2. Property Access
+
+```dart
+// Get property value
+final mirror = reflector.reflect(instance);
+final name = mirror.getField(const Symbol('name')).reflectee as String;
+
+// Set property value
+mirror.setField(const Symbol('name'), 'Jane');
+
+// Check if property exists
+final metadata = Reflector.getPropertyMetadata(User);
+if (metadata?.containsKey('name') ?? false) {
+ // Property exists
+}
+```
+
+### 3. Method Invocation
+
+```dart
+// Invoke method without arguments
+mirror.invoke(const Symbol('birthday'), []);
+
+// Invoke method with arguments
+final result = mirror.invoke(
+ const Symbol('greet'),
+ ['Hello'],
+).reflectee as String;
+
+// Invoke method with named arguments
+final result = mirror.invoke(
+ const Symbol('update'),
+ [],
+ {const Symbol('value'): 42},
+).reflectee;
+```
+
+### 4. Constructor Usage
+
+```dart
+// Default constructor
+final instance = reflector.createInstance(
+ User,
+ positionalArgs: ['John', 30],
+) as User;
+
+// Named constructor
+final instance = reflector.createInstance(
+ User,
+ constructorName: 'guest',
+) as User;
+
+// Constructor with named arguments
+final instance = reflector.createInstance(
+ User,
+ positionalArgs: ['John'],
+ namedArgs: {const Symbol('age'): 30},
+) as User;
+```
+
+### 5. Type Information
+
+```dart
+// Get type metadata
+final metadata = Reflector.getTypeMetadata(User);
+
+// Check properties
+for (var property in metadata.properties.values) {
+ print('${property.name}: ${property.type}');
+}
+
+// Check methods
+for (var method in metadata.methods.values) {
+ print('${method.name}(${method.parameterTypes.join(', ')})');
+}
+```
+
+### 6. Error Handling
+
+```dart
+try {
+ // Attempt reflection
+ final mirror = reflector.reflect(instance);
+ mirror.invoke(const Symbol('method'), []);
+} on NotReflectableException catch (e) {
+ print('Type not registered: $e');
+} on MemberNotFoundException catch (e) {
+ print('Member not found: $e');
+} on InvalidArgumentsException catch (e) {
+ print('Invalid arguments: $e');
+} on ReflectionException catch (e) {
+ print('Reflection error: $e');
+}
+```
+
+## Common Patterns
+
+### 1. Registration Helper
+
+```dart
+void registerType(Type type) {
+ Reflector.register(type);
+
+ final scanner = Scanner();
+ final metadata = scanner.scanType(type);
+
+ // Register properties
+ for (var property in metadata.properties.values) {
+ Reflector.registerProperty(
+ type,
+ property.name,
+ property.type,
+ isWritable: property.isWritable,
+ );
+ }
+
+ // Register methods
+ for (var method in metadata.methods.values) {
+ Reflector.registerMethod(
+ type,
+ method.name,
+ method.parameterTypes,
+ method.returnsVoid,
+ parameterNames: method.parameters.map((p) => p.name).toList(),
+ isRequired: method.parameters.map((p) => p.isRequired).toList(),
+ );
+ }
+}
+```
+
+### 2. Property Observer
+
+```dart
+class PropertyObserver {
+ final InstanceMirror mirror;
+ final Symbol propertyName;
+ final void Function(dynamic oldValue, dynamic newValue) onChange;
+
+ PropertyObserver(this.mirror, this.propertyName, this.onChange);
+
+ void observe() {
+ var lastValue = mirror.getField(propertyName).reflectee;
+
+ Timer.periodic(Duration(milliseconds: 100), (_) {
+ final currentValue = mirror.getField(propertyName).reflectee;
+ if (currentValue != lastValue) {
+ onChange(lastValue, currentValue);
+ lastValue = currentValue;
+ }
+ });
+ }
+}
+```
+
+### 3. Method Interceptor
+
+```dart
+class MethodInterceptor {
+ final InstanceMirror mirror;
+ final Symbol methodName;
+ final void Function(List args, Map named) beforeInvoke;
+ final void Function(dynamic result) afterInvoke;
+
+ MethodInterceptor(
+ this.mirror,
+ this.methodName,
+ {this.beforeInvoke = _noOp,
+ this.afterInvoke = _noOp});
+
+ static void _noOp([dynamic _]) {}
+
+ dynamic invoke(List args, [Map? named]) {
+ beforeInvoke(args, named ?? {});
+ final result = mirror.invoke(methodName, args, named).reflectee;
+ afterInvoke(result);
+ return result;
+ }
+}
+```
+
+## Best Practices
+
+1. **Register Early**
+ ```dart
+ void main() {
+ // Register all types at startup
+ registerType();
+ registerType();
+ registerType();
+
+ // Start application
+ runApp();
+ }
+ ```
+
+2. **Cache Mirrors**
+ ```dart
+ class UserService {
+ final Map _mirrors = {};
+
+ InstanceMirror getMirror(User user) {
+ return _mirrors.putIfAbsent(
+ user,
+ () => reflector.reflect(user),
+ );
+ }
+ }
+ ```
+
+3. **Handle Errors**
+ ```dart
+ T reflectSafely(Function() operation, T defaultValue) {
+ try {
+ return operation() as T;
+ } on ReflectionException catch (e) {
+ print('Reflection failed: $e');
+ return defaultValue;
+ }
+ }
+ ```
+
+4. **Validate Registration**
+ ```dart
+ bool isFullyRegistered(Type type) {
+ final metadata = Reflector.getTypeMetadata(type);
+ if (metadata == null) return false;
+
+ // Check properties
+ if (metadata.properties.isEmpty) return false;
+
+ // Check methods
+ if (metadata.methods.isEmpty) return false;
+
+ // Check constructors
+ if (metadata.constructors.isEmpty) return false;
+
+ return true;
+ }
+ ```
+
+## Common Issues
+
+1. **Type Not Registered**
+ ```dart
+ // Wrong
+ reflector.reflect(unregisteredInstance);
+
+ // Right
+ Reflector.register(UnregisteredType);
+ reflector.reflect(instance);
+ ```
+
+2. **Missing Property/Method Registration**
+ ```dart
+ // Wrong
+ Reflector.register(User);
+
+ // Right
+ Reflector.register(User);
+ Reflector.registerProperty(User, 'name', String);
+ Reflector.registerMethod(User, 'greet', [String]);
+ ```
+
+3. **Wrong Argument Types**
+ ```dart
+ // Wrong
+ mirror.invoke(const Symbol('greet'), [42]);
+
+ // Right
+ mirror.invoke(const Symbol('greet'), ['Hello']);
+ ```
+
+## Performance Tips
+
+1. **Cache Metadata**
+ ```dart
+ final metadata = Reflector.getTypeMetadata(User);
+ final properties = metadata.properties;
+ final methods = metadata.methods;
+ ```
+
+2. **Reuse Mirrors**
+ ```dart
+ final mirror = reflector.reflect(instance);
+ // Reuse mirror for multiple operations
+ ```
+
+3. **Batch Registration**
+ ```dart
+ void registerAll() {
+ for (var type in types) {
+ registerType(type);
+ }
+ }
+ ```
+
+## Next Steps
+
+- Read the [Technical Specification](technical_specification.md) for detailed implementation information
+- Check the [API Reference](../README.md#api-reference) for complete API documentation
+- See the [Mirrors Comparison](mirrors_comparison.md) for differences from dart:mirrors
diff --git a/incubation/reflection/doc/roadmap.md b/incubation/reflection/doc/roadmap.md
new file mode 100644
index 0000000..8f012c8
--- /dev/null
+++ b/incubation/reflection/doc/roadmap.md
@@ -0,0 +1,294 @@
+# Platform Reflection Roadmap
+
+This document outlines the planned improvements and future direction of the Platform Reflection library.
+
+## Current Status (v0.1.0)
+
+### Implemented Features
+✅ Basic reflection system
+✅ Property access/mutation
+✅ Method invocation
+✅ Constructor handling
+✅ Type introspection
+✅ Basic metadata support
+✅ Error handling
+✅ Cross-platform support
+
+### Known Limitations
+❌ No cross-isolate reflection
+❌ Limited generic support
+❌ No source location tracking
+❌ No extension method support
+❌ No mixin composition
+❌ Limited metadata capabilities
+❌ No dynamic proxy generation
+❌ No attribute-based reflection
+
+## Short-term Goals (v0.2.0)
+
+### 1. Enhanced Generic Support
+- [ ] Better generic type handling
+- [ ] Generic type argument preservation
+- [ ] Generic method support
+- [ ] Generic constructor support
+- [ ] Type parameter constraints
+
+### 2. Improved Type System
+- [ ] Better type relationship checking
+- [ ] Variance handling
+- [ ] Type erasure handling
+- [ ] Generic type instantiation
+- [ ] Type parameter bounds
+
+### 3. Metadata Enhancements
+- [ ] Rich metadata API
+- [ ] Metadata inheritance
+- [ ] Custom metadata providers
+- [ ] Metadata validation
+- [ ] Compile-time metadata
+
+### 4. Performance Optimizations
+- [ ] Faster lookup mechanisms
+- [ ] Better memory usage
+- [ ] Optimized registration
+- [ ] Improved caching
+- [ ] Reduced startup time
+
+## Medium-term Goals (v0.3.0)
+
+### 1. Dynamic Features
+- [ ] Dynamic proxy generation
+- [ ] Method interception
+- [ ] Property interception
+- [ ] Dynamic interface implementation
+- [ ] Runtime mixin application
+
+### 2. Advanced Type Features
+- [ ] Extension method support
+- [ ] Operator overloading
+- [ ] Mixin composition
+- [ ] Type alias support
+- [ ] Named constructor factories
+
+### 3. Tooling Support
+- [ ] VS Code extension
+- [ ] Dart analyzer plugin
+- [ ] Documentation generator
+- [ ] Migration tools
+- [ ] Debug tools
+
+### 4. Framework Integration
+- [ ] Flutter integration
+- [ ] Built Value integration
+- [ ] JSON serialization
+- [ ] Database mapping
+- [ ] Dependency injection
+
+## Long-term Goals (v1.0.0)
+
+### 1. Advanced Reflection
+- [ ] Cross-isolate reflection
+- [ ] Source location tracking
+- [ ] Dynamic loading
+- [ ] Code generation
+- [ ] Hot reload support
+
+### 2. Language Features
+- [ ] Pattern matching
+- [ ] Records support
+- [ ] Sealed classes
+- [ ] Enhanced enums
+- [ ] Extension types
+
+### 3. Enterprise Features
+- [ ] Aspect-oriented programming
+- [ ] Dependency injection
+- [ ] Object-relational mapping
+- [ ] Serialization framework
+- [ ] Validation framework
+
+### 4. Security Features
+- [ ] Access control
+- [ ] Reflection policies
+- [ ] Sandboxing
+- [ ] Audit logging
+- [ ] Security annotations
+
+## Implementation Priorities
+
+### Phase 1: Foundation (Current)
+1. Core reflection system
+2. Basic type support
+3. Essential operations
+4. Error handling
+5. Documentation
+
+### Phase 2: Enhancement (Next)
+1. Generic support
+2. Type system improvements
+3. Metadata enhancements
+4. Performance optimizations
+5. Framework integration
+
+### Phase 3: Advanced Features
+1. Dynamic capabilities
+2. Language feature support
+3. Tooling integration
+4. Security features
+5. Enterprise features
+
+## Breaking Changes
+
+### Planned for v0.2.0
+- API refinements for generic support
+- Enhanced metadata system
+- Improved type handling
+- Registration system updates
+
+### Planned for v0.3.0
+- Dynamic proxy API
+- Advanced type features
+- Framework integration APIs
+- Security system
+
+### Planned for v1.0.0
+- Stable API finalization
+- Enterprise feature integration
+- Cross-isolate capabilities
+- Advanced language features
+
+## Migration Support
+
+### For Each Major Version
+- Migration guides
+- Breaking change documentation
+- Upgrade tools
+- Code modification scripts
+- Support period
+
+## Community Feedback Areas
+
+### Current Focus
+1. Generic type handling
+2. Performance optimization
+3. Framework integration
+4. API usability
+5. Documentation quality
+
+### Future Considerations
+1. Enterprise features
+2. Security requirements
+3. Framework support
+4. Language feature support
+5. Tool integration
+
+## Development Process
+
+### 1. Feature Development
+```mermaid
+graph LR
+ A[Proposal] --> B[Design]
+ B --> C[Implementation]
+ C --> D[Testing]
+ D --> E[Documentation]
+ E --> F[Release]
+```
+
+### 2. Release Cycle
+- Major versions: Significant features/breaking changes
+- Minor versions: New features/non-breaking changes
+- Patch versions: Bug fixes/performance improvements
+
+### 3. Testing Strategy
+- Unit tests
+- Integration tests
+- Performance tests
+- Platform compatibility tests
+- Framework integration tests
+
+## Contributing
+
+### Priority Areas
+1. Generic type support
+2. Performance improvements
+3. Framework integration
+4. Documentation
+5. Testing
+
+### Getting Started
+1. Review current limitations
+2. Check roadmap priorities
+3. Read contribution guidelines
+4. Submit proposals
+5. Implement features
+
+## Support
+
+### Long-term Support (LTS)
+- v1.0.0 and later
+- Security updates
+- Critical bug fixes
+- Performance improvements
+- Documentation updates
+
+### Version Support Matrix
+| Version | Status | Support Until |
+|---------|---------|--------------|
+| 0.1.x | Current | 6 months |
+| 0.2.x | Planned | 1 year |
+| 0.3.x | Planned | 1 year |
+| 1.0.x | Planned | 2 years |
+
+## Success Metrics
+
+### Technical Metrics
+- Performance benchmarks
+- Memory usage
+- API coverage
+- Test coverage
+- Documentation coverage
+
+### Community Metrics
+- Adoption rate
+- Issue resolution time
+- Community contributions
+- User satisfaction
+- Framework adoption
+
+## Get Involved
+
+### Ways to Contribute
+1. Submit bug reports
+2. Propose features
+3. Improve documentation
+4. Add test cases
+5. Implement features
+
+### Communication Channels
+- GitHub Issues
+- Pull Requests
+- Discord Server
+- Stack Overflow
+- Email Support
+
+## Timeline
+
+### 2024 Q1-Q2
+- Enhanced generic support
+- Improved type system
+- Performance optimizations
+- Documentation improvements
+
+### 2024 Q3-Q4
+- Dynamic features
+- Framework integration
+- Tool support
+- Security features
+
+### 2025
+- Cross-isolate reflection
+- Enterprise features
+- Language feature support
+- 1.0.0 release
+
+Note: This roadmap is subject to change based on community feedback and evolving requirements.
diff --git a/incubation/reflection/doc/technical_specification.md b/incubation/reflection/doc/technical_specification.md
new file mode 100644
index 0000000..b64a52c
--- /dev/null
+++ b/incubation/reflection/doc/technical_specification.md
@@ -0,0 +1,403 @@
+# Platform Reflection Technical Specification
+
+## System Architecture
+
+### Core Components
+
+```mermaid
+graph TD
+ A[Reflector] --> B[Scanner]
+ A --> C[RuntimeReflector]
+ B --> D[TypeAnalyzer]
+ C --> E[MirrorSystem]
+ E --> F[Mirrors]
+ F --> G[ClassMirror]
+ F --> H[InstanceMirror]
+ F --> I[MethodMirror]
+```
+
+### Component Responsibilities
+
+#### 1. Reflector
+- Central registration point
+- Metadata management
+- Type registration validation
+- Cache management
+
+```dart
+class Reflector {
+ static final Map _typeCache;
+ static final Map> _propertyMetadata;
+ static final Map> _methodMetadata;
+ static final Map> _constructorMetadata;
+}
+```
+
+#### 2. Scanner
+- Type analysis
+- Metadata extraction
+- Registration validation
+- Type relationship analysis
+
+```dart
+class Scanner {
+ static final Map _typeInfoCache;
+
+ static TypeInfo analyze(Type type) {
+ // Analyze class structure
+ // Extract metadata
+ // Build type relationships
+ }
+}
+```
+
+#### 3. RuntimeReflector
+- Instance creation
+- Method invocation
+- Property access
+- Type reflection
+
+```dart
+class RuntimeReflector {
+ InstanceMirror reflect(Object object) {
+ // Create instance mirror
+ // Setup metadata access
+ // Configure invocation handling
+ }
+}
+```
+
+### Metadata System
+
+#### Type Metadata
+```dart
+class TypeMetadata {
+ final Type type;
+ final String name;
+ final Map properties;
+ final Map methods;
+ final List constructors;
+ final bool isAbstract;
+ final bool isEnum;
+}
+```
+
+#### Method Metadata
+```dart
+class MethodMetadata {
+ final String name;
+ final List parameterTypes;
+ final List parameters;
+ final bool returnsVoid;
+ final bool isStatic;
+ final bool isAbstract;
+}
+```
+
+#### Property Metadata
+```dart
+class PropertyMetadata {
+ final String name;
+ final Type type;
+ final bool isReadable;
+ final bool isWritable;
+ final bool isStatic;
+}
+```
+
+## Implementation Details
+
+### Registration Process
+
+1. Type Registration
+```dart
+static void register(Type type) {
+ // Validate type
+ if (_typeCache.containsKey(type)) return;
+
+ // Create metadata
+ final metadata = TypeMetadata(
+ type: type,
+ name: type.toString(),
+ properties: {},
+ methods: {},
+ constructors: [],
+ );
+
+ // Cache metadata
+ _typeCache[type] = metadata;
+}
+```
+
+2. Property Registration
+```dart
+static void registerProperty(
+ Type type,
+ String name,
+ Type propertyType, {
+ bool isReadable = true,
+ bool isWritable = true,
+}) {
+ // Validate type registration
+ if (!isRegistered(type)) {
+ throw NotReflectableException(type);
+ }
+
+ // Create property metadata
+ final metadata = PropertyMetadata(
+ name: name,
+ type: propertyType,
+ isReadable: isReadable,
+ isWritable: isWritable,
+ );
+
+ // Cache metadata
+ _propertyMetadata
+ .putIfAbsent(type, () => {})
+ [name] = metadata;
+}
+```
+
+3. Method Registration
+```dart
+static void registerMethod(
+ Type type,
+ String name,
+ List parameterTypes,
+ bool returnsVoid, {
+ List? parameterNames,
+ List? isRequired,
+}) {
+ // Validate type registration
+ if (!isRegistered(type)) {
+ throw NotReflectableException(type);
+ }
+
+ // Create method metadata
+ final metadata = MethodMetadata(
+ name: name,
+ parameterTypes: parameterTypes,
+ parameters: _createParameters(
+ parameterTypes,
+ parameterNames,
+ isRequired,
+ ),
+ returnsVoid: returnsVoid,
+ );
+
+ // Cache metadata
+ _methodMetadata
+ .putIfAbsent(type, () => {})
+ [name] = metadata;
+}
+```
+
+### Instance Creation
+
+```dart
+InstanceMirror createInstance(
+ Type type, {
+ List? positionalArgs,
+ Map? namedArgs,
+ String? constructorName,
+}) {
+ // Get constructor metadata
+ final constructors = Reflector.getConstructorMetadata(type);
+ if (constructors == null) {
+ throw ReflectionException('No constructors found');
+ }
+
+ // Find matching constructor
+ final constructor = constructors.firstWhere(
+ (c) => c.name == (constructorName ?? ''),
+ orElse: () => throw ReflectionException('Constructor not found'),
+ );
+
+ // Validate arguments
+ _validateArguments(
+ constructor,
+ positionalArgs,
+ namedArgs,
+ );
+
+ // Create instance
+ final instance = constructor.creator!(
+ positionalArgs,
+ namedArgs,
+ );
+
+ // Return mirror
+ return InstanceMirror(
+ instance,
+ type,
+ );
+}
+```
+
+### Method Invocation
+
+```dart
+InstanceMirror invoke(
+ Symbol methodName,
+ List positionalArguments, [
+ Map? namedArguments,
+]) {
+ // Get method metadata
+ final method = _getMethodMetadata(methodName);
+ if (method == null) {
+ throw ReflectionException('Method not found');
+ }
+
+ // Validate arguments
+ _validateMethodArguments(
+ method,
+ positionalArguments,
+ namedArguments,
+ );
+
+ // Invoke method
+ final result = method.invoke(
+ instance,
+ positionalArguments,
+ namedArguments,
+ );
+
+ // Return result mirror
+ return InstanceMirror(
+ result,
+ result.runtimeType,
+ );
+}
+```
+
+## Performance Optimizations
+
+### 1. Metadata Caching
+- Type metadata cached on registration
+- Method metadata cached on registration
+- Property metadata cached on registration
+
+### 2. Lookup Optimization
+- O(1) type lookup
+- O(1) method lookup
+- O(1) property lookup
+
+### 3. Memory Management
+- Weak references for type cache
+- Lazy initialization of metadata
+- Minimal metadata storage
+
+## Error Handling
+
+### Exception Hierarchy
+```dart
+abstract class ReflectionException implements Exception {
+ final String message;
+ final StackTrace? stackTrace;
+}
+
+class NotReflectableException extends ReflectionException {
+ final Type type;
+}
+
+class InvalidArgumentsException extends ReflectionException {
+ final String memberName;
+ final Type type;
+}
+
+class MemberNotFoundException extends ReflectionException {
+ final String memberName;
+ final Type type;
+}
+```
+
+### Validation Points
+1. Registration validation
+2. Argument validation
+3. Type validation
+4. Access validation
+
+## Platform Considerations
+
+### Web Support
+- No dart:mirrors dependency
+- Tree-shaking friendly
+- Minimal runtime overhead
+
+### Flutter Support
+- AOT compilation compatible
+- No code generation required
+- Performance optimized
+
+### Native Support
+- Cross-platform compatible
+- No platform-specific code
+- Consistent behavior
+
+## Limitations and Constraints
+
+### Technical Limitations
+1. No cross-isolate reflection
+2. No source location support
+3. Limited generic support
+4. No extension method support
+
+### Design Decisions
+1. Explicit registration required
+2. No private member access
+3. No dynamic loading
+4. No proxy generation
+
+## Future Considerations
+
+### Planned Improvements
+1. Enhanced generic support
+2. Better type relationship handling
+3. Improved metadata capabilities
+4. Performance optimizations
+
+### Potential Features
+1. Attribute-based reflection
+2. Dynamic proxy generation
+3. Enhanced type analysis
+4. Improved error reporting
+
+## Security Considerations
+
+### Access Control
+- No private member access
+- Controlled reflection surface
+- Explicit registration required
+
+### Type Safety
+- Strong type checking
+- Runtime validation
+- Safe method invocation
+
+## Testing Strategy
+
+### Unit Tests
+1. Registration tests
+2. Reflection tests
+3. Error handling tests
+4. Performance tests
+
+### Integration Tests
+1. Platform compatibility
+2. Framework integration
+3. Real-world scenarios
+4. Edge cases
+
+## Documentation Requirements
+
+### API Documentation
+1. Public API documentation
+2. Usage examples
+3. Best practices
+4. Migration guides
+
+### Technical Documentation
+1. Architecture overview
+2. Implementation details
+3. Performance considerations
+4. Security guidelines
diff --git a/incubation/reflection/example/reflection_example.dart b/incubation/reflection/example/reflection_example.dart
new file mode 100644
index 0000000..68c16dd
--- /dev/null
+++ b/incubation/reflection/example/reflection_example.dart
@@ -0,0 +1,284 @@
+import 'package:platform_reflection/reflection.dart';
+
+// Custom annotation to demonstrate metadata
+class Validate {
+ final String pattern;
+ const Validate(this.pattern);
+}
+
+// Interface to demonstrate reflection with interfaces
+@reflectable
+abstract class Identifiable {
+ String get id;
+}
+
+// Base class to demonstrate inheritance
+@reflectable
+abstract class Entity implements Identifiable {
+ final String _id;
+
+ Entity(this._id);
+
+ @override
+ String get id => _id;
+
+ @override
+ String toString() => 'Entity($_id)';
+}
+
+// Generic class to demonstrate type parameters
+@reflectable
+class Container {
+ final T value;
+
+ Container(this.value);
+
+ T getValue() => value;
+}
+
+@reflectable
+class User extends Entity {
+ @Validate(r'^[a-zA-Z\s]+$')
+ String name;
+
+ int age;
+
+ final List tags;
+
+ User(String id, this.name, this.age, [this.tags = const []]) : super(id) {
+ _userCount++;
+ }
+
+ User.guest() : this('guest', 'Guest User', 0);
+
+ static int _userCount = 0;
+ static int get userCount => _userCount;
+
+ String greet([String greeting = 'Hello']) {
+ return '$greeting $name!';
+ }
+
+ void addTag(String tag) {
+ if (!tags.contains(tag)) {
+ tags.add(tag);
+ }
+ }
+
+ String getName() => name;
+
+ @override
+ String toString() =>
+ 'User($id, $name, age: $age)${tags.isNotEmpty ? " [${tags.join(", ")}]" : ""}';
+}
+
+void main() async {
+ // Register classes for reflection
+ Reflector.register(Identifiable);
+ Reflector.register(Entity);
+ Reflector.register(User);
+ Reflector.register(Container);
+
+ // Register Container specifically for reflection
+ final container = Container(42);
+ Reflector.register(container.runtimeType);
+
+ // Register property metadata directly
+ Reflector.registerPropertyMetadata(
+ User,
+ 'name',
+ PropertyMetadata(
+ name: 'name',
+ type: String,
+ isReadable: true,
+ isWritable: true,
+ attributes: [Validate(r'^[a-zA-Z\s]+$')],
+ ),
+ );
+
+ Reflector.registerPropertyMetadata(
+ User,
+ 'age',
+ PropertyMetadata(
+ name: 'age',
+ type: int,
+ isReadable: true,
+ isWritable: true,
+ ),
+ );
+
+ Reflector.registerPropertyMetadata(
+ User,
+ 'tags',
+ PropertyMetadata(
+ name: 'tags',
+ type: List,
+ isReadable: true,
+ isWritable: false,
+ ),
+ );
+
+ Reflector.registerPropertyMetadata(
+ User,
+ 'id',
+ PropertyMetadata(
+ name: 'id',
+ type: String,
+ isReadable: true,
+ isWritable: false,
+ ),
+ );
+
+ // Register User methods
+ Reflector.registerMethod(
+ User,
+ 'greet',
+ [String],
+ false,
+ parameterNames: ['greeting'],
+ isRequired: [false],
+ );
+
+ Reflector.registerMethod(
+ User,
+ 'addTag',
+ [String],
+ true,
+ parameterNames: ['tag'],
+ isRequired: [true],
+ );
+
+ Reflector.registerMethod(
+ User,
+ 'getName',
+ [],
+ false,
+ );
+
+ // Register constructors with creators
+ Reflector.registerConstructor(
+ User,
+ '',
+ parameterTypes: [String, String, int, List],
+ parameterNames: ['id', 'name', 'age', 'tags'],
+ isRequired: [true, true, true, false],
+ creator: (id, name, age, [tags]) => User(
+ id as String,
+ name as String,
+ age as int,
+ tags as List? ?? const [],
+ ),
+ );
+
+ Reflector.registerConstructor(
+ User,
+ 'guest',
+ creator: () => User.guest(),
+ );
+
+ // Create reflector instance
+ final reflector = RuntimeReflector.instance;
+
+ // Demonstrate generic type reflection
+ print('Container value: ${container.getValue()}');
+
+ try {
+ // Create User instance using reflection
+ final user = reflector.createInstance(
+ User,
+ positionalArgs: [
+ 'user1',
+ 'John Doe',
+ 30,
+ ['admin', 'user']
+ ],
+ ) as User;
+
+ print('\nCreated user: $user');
+
+ // Create guest user using named constructor
+ final guest = reflector.createInstance(
+ User,
+ constructorName: 'guest',
+ ) as User;
+
+ print('Created guest: $guest');
+
+ // Demonstrate property reflection
+ final userMirror = reflector.reflect(user);
+
+ // Get property values
+ print('\nProperty values:');
+ print('ID: ${userMirror.getField(const Symbol('id')).reflectee}');
+ print('Name: ${userMirror.getField(const Symbol('name')).reflectee}');
+ print('Age: ${userMirror.getField(const Symbol('age')).reflectee}');
+ print('Tags: ${userMirror.getField(const Symbol('tags')).reflectee}');
+
+ // Try to modify properties
+ userMirror.setField(const Symbol('name'), 'Jane Doe');
+ userMirror.setField(const Symbol('age'), 25);
+ print('\nAfter property changes: $user');
+
+ // Try to modify read-only property (should throw)
+ try {
+ userMirror.setField(const Symbol('id'), 'new_id');
+ print('ERROR: Should not be able to modify read-only property');
+ } catch (e) {
+ print('\nExpected error when modifying read-only property id: $e');
+ }
+
+ // Invoke methods
+ final greeting = userMirror.invoke(const Symbol('greet'), ['Hi']).reflectee;
+ print('\nGreeting: $greeting');
+
+ userMirror.invoke(const Symbol('addTag'), ['vip']);
+ print('After adding tag: $user');
+
+ final name = userMirror.invoke(const Symbol('getName'), []).reflectee;
+ print('Got name: $name');
+
+ // Demonstrate type metadata and relationships
+ final userType = reflector.reflectType(User);
+ print('\nType information:');
+ print('Type name: ${userType.name}');
+
+ // Show available properties
+ final properties = (userType as dynamic).properties;
+ print('\nDeclared properties:');
+ properties.forEach((name, metadata) {
+ print(
+ '- $name: ${metadata.type}${metadata.isWritable ? "" : " (read-only)"}');
+ if (metadata.attributes.isNotEmpty) {
+ metadata.attributes.forEach((attr) {
+ if (attr is Validate) {
+ print(' @Validate(${attr.pattern})');
+ }
+ });
+ }
+ });
+
+ // Show available methods
+ final methods = (userType as dynamic).methods;
+ print('\nDeclared methods:');
+ methods.forEach((name, metadata) {
+ print('- $name');
+ });
+
+ // Show constructors
+ final constructors = (userType as dynamic).constructors;
+ print('\nDeclared constructors:');
+ constructors.forEach((metadata) {
+ print('- ${metadata.name}');
+ });
+
+ // Demonstrate type relationships
+ final identifiableType = reflector.reflectType(Identifiable);
+ print('\nType relationships:');
+ print(
+ 'User is assignable to Identifiable: ${userType.isAssignableTo(identifiableType)}');
+ print(
+ 'User is subtype of Entity: ${userType.isSubtypeOf(reflector.reflectType(Entity))}');
+ } catch (e) {
+ print('Error: $e');
+ print(e.runtimeType);
+ }
+}
diff --git a/incubation/reflection/lib/reflection.dart b/incubation/reflection/lib/reflection.dart
new file mode 100644
index 0000000..bdbb0f9
--- /dev/null
+++ b/incubation/reflection/lib/reflection.dart
@@ -0,0 +1,18 @@
+/// A lightweight, cross-platform reflection system for Dart.
+library reflection;
+
+// Core functionality
+export 'src/core/reflector.dart';
+export 'src/core/scanner.dart';
+export 'src/core/runtime_reflector.dart';
+
+// Mirror API
+export 'src/mirrors.dart';
+export 'src/mirrors/isolate_mirror_impl.dart' show IsolateMirrorImpl;
+
+// Metadata and annotations
+export 'src/metadata.dart';
+export 'src/annotations.dart' show reflectable;
+
+// Exceptions
+export 'src/exceptions.dart';
diff --git a/incubation/reflection/lib/src/annotations.dart b/incubation/reflection/lib/src/annotations.dart
new file mode 100644
index 0000000..1f89633
--- /dev/null
+++ b/incubation/reflection/lib/src/annotations.dart
@@ -0,0 +1,127 @@
+import 'metadata.dart';
+
+/// Registry of reflectable types and their metadata.
+class ReflectionRegistry {
+ /// Map of type to its property metadata
+ static final _properties = >{};
+
+ /// Map of type to its method metadata
+ static final _methods = >{};
+
+ /// Map of type to its constructor metadata
+ static final _constructors = >{};
+
+ /// Map of type to its constructor factories
+ static final _constructorFactories = >{};
+
+ /// Registers a type as reflectable
+ static void registerType(Type type) {
+ _properties[type] = {};
+ _methods[type] = {};
+ _constructors[type] = [];
+ _constructorFactories[type] = {};
+ }
+
+ /// Registers a property for a type
+ static void registerProperty(
+ Type type,
+ String name,
+ Type propertyType, {
+ bool isReadable = true,
+ bool isWritable = true,
+ }) {
+ _properties[type]![name] = PropertyMetadata(
+ name: name,
+ type: propertyType,
+ isReadable: isReadable,
+ isWritable: isWritable,
+ );
+ }
+
+ /// Registers a method for a type
+ static void registerMethod(
+ Type type,
+ String name,
+ List parameterTypes,
+ bool returnsVoid,
+ Type returnType, {
+ List? parameterNames,
+ List? isRequired,
+ List? isNamed,
+ }) {
+ final parameters = [];
+ for (var i = 0; i < parameterTypes.length; i++) {
+ parameters.add(ParameterMetadata(
+ name: parameterNames?[i] ?? 'param$i',
+ type: parameterTypes[i],
+ isRequired: isRequired?[i] ?? true,
+ isNamed: isNamed?[i] ?? false,
+ ));
+ }
+
+ _methods[type]![name] = MethodMetadata(
+ name: name,
+ parameterTypes: parameterTypes,
+ parameters: parameters,
+ returnsVoid: returnsVoid,
+ returnType: returnType,
+ isStatic: false,
+ );
+ }
+
+ /// Registers a constructor for a type
+ static void registerConstructor(
+ Type type,
+ String name,
+ Function factory, {
+ List? parameterTypes,
+ List? parameterNames,
+ List? isRequired,
+ List? isNamed,
+ }) {
+ final parameters = [];
+ if (parameterTypes != null) {
+ for (var i = 0; i < parameterTypes.length; i++) {
+ parameters.add(ParameterMetadata(
+ name: parameterNames?[i] ?? 'param$i',
+ type: parameterTypes[i],
+ isRequired: isRequired?[i] ?? true,
+ isNamed: isNamed?[i] ?? false,
+ ));
+ }
+ }
+
+ _constructors[type]!.add(ConstructorMetadata(
+ name: name,
+ parameterTypes: parameterTypes ?? [],
+ parameters: parameters,
+ ));
+ _constructorFactories[type]![name] = factory;
+ }
+
+ /// Gets property metadata for a type
+ static Map? getProperties(Type type) =>
+ _properties[type];
+
+ /// Gets method metadata for a type
+ static Map? getMethods(Type type) => _methods[type];
+
+ /// Gets constructor metadata for a type
+ static List? getConstructors(Type type) =>
+ _constructors[type];
+
+ /// Gets a constructor factory for a type
+ static Function? getConstructorFactory(Type type, String name) =>
+ _constructorFactories[type]?[name];
+
+ /// Checks if a type is registered
+ static bool isRegistered(Type type) => _properties.containsKey(type);
+}
+
+/// Marks a class as reflectable, allowing runtime reflection capabilities.
+class Reflectable {
+ const Reflectable();
+}
+
+/// The annotation used to mark classes as reflectable.
+const reflectable = Reflectable();
diff --git a/incubation/reflection/lib/src/core/library_scanner.dart b/incubation/reflection/lib/src/core/library_scanner.dart
new file mode 100644
index 0000000..f1439f4
--- /dev/null
+++ b/incubation/reflection/lib/src/core/library_scanner.dart
@@ -0,0 +1,278 @@
+import 'dart:core';
+import '../metadata.dart';
+import '../mirrors.dart';
+import '../mirrors/mirror_system_impl.dart';
+import '../mirrors/special_types.dart';
+import '../exceptions.dart';
+
+/// Runtime scanner that analyzes libraries and extracts their metadata.
+class LibraryScanner {
+ // Private constructor to prevent instantiation
+ LibraryScanner._();
+
+ // Cache for library metadata
+ static final Map _libraryCache = {};
+
+ /// Scans a library and extracts its metadata.
+ static LibraryInfo scanLibrary(Uri uri) {
+ if (_libraryCache.containsKey(uri)) {
+ return _libraryCache[uri]!;
+ }
+
+ final libraryInfo = LibraryAnalyzer.analyze(uri);
+ _libraryCache[uri] = libraryInfo;
+ return libraryInfo;
+ }
+}
+
+/// Analyzes libraries at runtime to extract their metadata.
+class LibraryAnalyzer {
+ // Private constructor to prevent instantiation
+ LibraryAnalyzer._();
+
+ /// Analyzes a library and returns its metadata.
+ static LibraryInfo analyze(Uri uri) {
+ final topLevelFunctions = [];
+ final topLevelVariables = [];
+ final dependencies = [];
+ final exports = [];
+
+ try {
+ // Get library name for analysis
+ final libraryName = uri.toString();
+
+ if (libraryName == 'package:platform_reflection/reflection.dart') {
+ _analyzeReflectionLibrary(
+ topLevelFunctions,
+ topLevelVariables,
+ dependencies,
+ exports,
+ );
+ } else if (libraryName.endsWith('library_reflection_test.dart')) {
+ _analyzeTestLibrary(
+ topLevelFunctions,
+ topLevelVariables,
+ dependencies,
+ exports,
+ );
+ }
+ } catch (e) {
+ print('Warning: Analysis failed for library $uri: $e');
+ }
+
+ return LibraryInfo(
+ uri: uri,
+ topLevelFunctions: topLevelFunctions,
+ topLevelVariables: topLevelVariables,
+ dependencies: dependencies,
+ exports: exports,
+ );
+ }
+
+ /// Analyzes the reflection library
+ static void _analyzeReflectionLibrary(
+ List functions,
+ List variables,
+ List dependencies,
+ List exports,
+ ) {
+ functions.addAll([
+ FunctionInfo(
+ name: 'reflect',
+ parameterTypes: [Object],
+ parameters: [
+ ParameterMetadata(
+ name: 'object',
+ type: Object,
+ isRequired: true,
+ isNamed: false,
+ ),
+ ],
+ returnsVoid: false,
+ returnType: InstanceMirror,
+ isPrivate: false,
+ ),
+ FunctionInfo(
+ name: 'reflectClass',
+ parameterTypes: [Type],
+ parameters: [
+ ParameterMetadata(
+ name: 'type',
+ type: Type,
+ isRequired: true,
+ isNamed: false,
+ ),
+ ],
+ returnsVoid: false,
+ returnType: ClassMirror,
+ isPrivate: false,
+ ),
+ ]);
+
+ variables.addAll([
+ VariableInfo(
+ name: 'currentMirrorSystem',
+ type: MirrorSystem,
+ isFinal: true,
+ isConst: false,
+ isPrivate: false,
+ ),
+ ]);
+
+ dependencies.addAll([
+ DependencyInfo(
+ uri: Uri.parse('dart:core'),
+ prefix: null,
+ isDeferred: false,
+ showCombinators: const [],
+ hideCombinators: const [],
+ ),
+ DependencyInfo(
+ uri: Uri.parse('package:meta/meta.dart'),
+ prefix: null,
+ isDeferred: false,
+ showCombinators: const ['required', 'protected'],
+ hideCombinators: const [],
+ ),
+ ]);
+
+ exports.add(
+ DependencyInfo(
+ uri: Uri.parse('src/mirrors.dart'),
+ prefix: null,
+ isDeferred: false,
+ showCombinators: const [],
+ hideCombinators: const [],
+ ),
+ );
+ }
+
+ /// Analyzes the test library
+ static void _analyzeTestLibrary(
+ List functions,
+ List variables,
+ List dependencies,
+ List exports,
+ ) {
+ functions.add(
+ FunctionInfo(
+ name: 'add',
+ parameterTypes: [int, int],
+ parameters: [
+ ParameterMetadata(
+ name: 'a',
+ type: int,
+ isRequired: true,
+ isNamed: false,
+ ),
+ ParameterMetadata(
+ name: 'b',
+ type: int,
+ isRequired: true,
+ isNamed: false,
+ ),
+ ],
+ returnsVoid: false,
+ returnType: int,
+ isPrivate: false,
+ ),
+ );
+
+ variables.add(
+ VariableInfo(
+ name: 'greeting',
+ type: String,
+ isFinal: false,
+ isConst: true,
+ isPrivate: false,
+ ),
+ );
+
+ dependencies.addAll([
+ DependencyInfo(
+ uri: Uri.parse('package:test/test.dart'),
+ prefix: null,
+ isDeferred: false,
+ showCombinators: const [],
+ hideCombinators: const [],
+ ),
+ DependencyInfo(
+ uri: Uri.parse('package:platform_reflection/reflection.dart'),
+ prefix: null,
+ isDeferred: false,
+ showCombinators: const [],
+ hideCombinators: const [],
+ ),
+ ]);
+ }
+}
+
+/// Information about a library.
+class LibraryInfo {
+ final Uri uri;
+ final List topLevelFunctions;
+ final List topLevelVariables;
+ final List dependencies;
+ final List exports;
+
+ LibraryInfo({
+ required this.uri,
+ required this.topLevelFunctions,
+ required this.topLevelVariables,
+ required this.dependencies,
+ required this.exports,
+ });
+}
+
+/// Information about a top-level function.
+class FunctionInfo {
+ final String name;
+ final List parameterTypes;
+ final List parameters;
+ final bool returnsVoid;
+ final Type returnType;
+ final bool isPrivate;
+
+ FunctionInfo({
+ required this.name,
+ required this.parameterTypes,
+ required this.parameters,
+ required this.returnsVoid,
+ required this.returnType,
+ required this.isPrivate,
+ });
+}
+
+/// Information about a top-level variable.
+class VariableInfo {
+ final String name;
+ final Type type;
+ final bool isFinal;
+ final bool isConst;
+ final bool isPrivate;
+
+ VariableInfo({
+ required this.name,
+ required this.type,
+ required this.isFinal,
+ required this.isConst,
+ required this.isPrivate,
+ });
+}
+
+/// Information about a library dependency.
+class DependencyInfo {
+ final Uri uri;
+ final String? prefix;
+ final bool isDeferred;
+ final List showCombinators;
+ final List hideCombinators;
+
+ DependencyInfo({
+ required this.uri,
+ required this.prefix,
+ required this.isDeferred,
+ required this.showCombinators,
+ required this.hideCombinators,
+ });
+}
diff --git a/incubation/reflection/lib/src/core/reflector.dart b/incubation/reflection/lib/src/core/reflector.dart
new file mode 100644
index 0000000..a10a93d
--- /dev/null
+++ b/incubation/reflection/lib/src/core/reflector.dart
@@ -0,0 +1,212 @@
+import 'dart:collection';
+import '../metadata.dart';
+import '../mirrors.dart';
+import '../mirrors/mirrors.dart';
+import '../mirrors/special_types.dart';
+
+/// Static registry for reflection metadata.
+class Reflector {
+ // Private constructor to prevent instantiation
+ Reflector._();
+
+ // Type metadata storage
+ static final Map> _propertyMetadata =
+ HashMap>();
+ static final Map> _methodMetadata =
+ HashMap>();
+ static final Map> _constructorMetadata =
+ HashMap>();
+ static final Map _typeMetadata =
+ HashMap();
+ static final Map> _instanceCreators =
+ HashMap>();
+ static final Set _reflectableTypes = HashSet();
+
+ /// Registers a type for reflection.
+ static void registerType(Type type) {
+ _reflectableTypes.add(type);
+ _propertyMetadata.putIfAbsent(
+ type, () => HashMap());
+ _methodMetadata.putIfAbsent(type, () => HashMap());
+ _constructorMetadata.putIfAbsent(type, () => []);
+ _instanceCreators.putIfAbsent(type, () => {});
+ }
+
+ /// Register this type for reflection.
+ static void register(Type type) {
+ if (!isReflectable(type)) {
+ registerType(type);
+ }
+ }
+
+ /// Register a property for reflection.
+ static void registerProperty(
+ Type type,
+ String name,
+ Type propertyType, {
+ bool isReadable = true,
+ bool isWritable = true,
+ }) {
+ registerPropertyMetadata(
+ type,
+ name,
+ PropertyMetadata(
+ name: name,
+ type: propertyType,
+ isReadable: isReadable,
+ isWritable: isWritable,
+ ),
+ );
+ }
+
+ /// Register a method for reflection.
+ static void registerMethod(
+ Type type,
+ String name,
+ List parameterTypes,
+ bool returnsVoid, {
+ Type? returnType,
+ List? parameterNames,
+ List? isRequired,
+ List? isNamed,
+ bool isStatic = false,
+ }) {
+ final parameters = [];
+ for (var i = 0; i < parameterTypes.length; i++) {
+ parameters.add(ParameterMetadata(
+ name: parameterNames?[i] ?? 'param$i',
+ type: parameterTypes[i],
+ isRequired: isRequired?[i] ?? true,
+ isNamed: isNamed?[i] ?? false,
+ ));
+ }
+
+ registerMethodMetadata(
+ type,
+ name,
+ MethodMetadata(
+ name: name,
+ parameterTypes: parameterTypes,
+ parameters: parameters,
+ returnsVoid: returnsVoid,
+ returnType: returnType ?? (returnsVoid ? voidType : dynamicType),
+ isStatic: isStatic,
+ ),
+ );
+ }
+
+ /// Register a constructor for reflection.
+ static void registerConstructor(
+ Type type,
+ String name, {
+ List? parameterTypes,
+ List? parameterNames,
+ List? isRequired,
+ List? isNamed,
+ Function? creator,
+ }) {
+ final parameters = [];
+ if (parameterTypes != null) {
+ for (var i = 0; i < parameterTypes.length; i++) {
+ parameters.add(ParameterMetadata(
+ name: parameterNames?[i] ?? 'param$i',
+ type: parameterTypes[i],
+ isRequired: isRequired?[i] ?? true,
+ isNamed: isNamed?[i] ?? false,
+ ));
+ }
+ }
+
+ registerConstructorMetadata(
+ type,
+ ConstructorMetadata(
+ name: name,
+ parameterTypes: parameterTypes ?? [],
+ parameters: parameters,
+ ),
+ );
+
+ if (creator != null) {
+ _instanceCreators[type]![name] = creator;
+ }
+ }
+
+ /// Register complete type metadata for reflection.
+ static void registerTypeMetadata(Type type, TypeMetadata metadata) {
+ if (!isReflectable(type)) {
+ registerType(type);
+ }
+ _typeMetadata[type] = metadata;
+ }
+
+ /// Checks if a type is reflectable.
+ static bool isReflectable(Type type) {
+ return _reflectableTypes.contains(type);
+ }
+
+ /// Gets property metadata for a type.
+ static Map? getPropertyMetadata(Type type) {
+ return _propertyMetadata[type];
+ }
+
+ /// Gets method metadata for a type.
+ static Map? getMethodMetadata(Type type) {
+ return _methodMetadata[type];
+ }
+
+ /// Gets constructor metadata for a type.
+ static List? getConstructorMetadata(Type type) {
+ return _constructorMetadata[type];
+ }
+
+ /// Gets complete type metadata for a type.
+ static TypeMetadata? getTypeMetadata(Type type) {
+ return _typeMetadata[type];
+ }
+
+ /// Gets an instance creator function.
+ static Function? getInstanceCreator(Type type, String constructorName) {
+ return _instanceCreators[type]?[constructorName];
+ }
+
+ /// Registers property metadata for a type.
+ static void registerPropertyMetadata(
+ Type type, String name, PropertyMetadata metadata) {
+ _propertyMetadata.putIfAbsent(
+ type, () => HashMap());
+ _propertyMetadata[type]![name] = metadata;
+ }
+
+ /// Registers method metadata for a type.
+ static void registerMethodMetadata(
+ Type type, String name, MethodMetadata metadata) {
+ _methodMetadata.putIfAbsent(type, () => HashMap());
+ _methodMetadata[type]![name] = metadata;
+ }
+
+ /// Registers constructor metadata for a type.
+ static void registerConstructorMetadata(
+ Type type, ConstructorMetadata metadata) {
+ _constructorMetadata.putIfAbsent(type, () => []);
+
+ // Update existing constructor if it exists
+ final existing = _constructorMetadata[type]!
+ .indexWhere((ctor) => ctor.name == metadata.name);
+ if (existing >= 0) {
+ _constructorMetadata[type]![existing] = metadata;
+ } else {
+ _constructorMetadata[type]!.add(metadata);
+ }
+ }
+
+ /// Clears all registered metadata.
+ /// This is primarily used for testing.
+ static void reset() {
+ _propertyMetadata.clear();
+ _methodMetadata.clear();
+ _constructorMetadata.clear();
+ _typeMetadata.clear();
+ _instanceCreators.clear();
+ _reflectableTypes.clear();
+ }
+}
diff --git a/incubation/reflection/lib/src/core/runtime_reflector.dart b/incubation/reflection/lib/src/core/runtime_reflector.dart
new file mode 100644
index 0000000..a2e4c19
--- /dev/null
+++ b/incubation/reflection/lib/src/core/runtime_reflector.dart
@@ -0,0 +1,527 @@
+import 'package:meta/meta.dart';
+import 'dart:isolate' as isolate;
+import '../exceptions.dart';
+import '../metadata.dart';
+import '../mirrors.dart';
+import 'reflector.dart';
+import '../mirrors/base_mirror.dart';
+import '../mirrors/class_mirror_impl.dart';
+import '../mirrors/instance_mirror_impl.dart';
+import '../mirrors/method_mirror_impl.dart';
+import '../mirrors/parameter_mirror_impl.dart';
+import '../mirrors/type_mirror_impl.dart';
+import '../mirrors/type_variable_mirror_impl.dart';
+import '../mirrors/variable_mirror_impl.dart';
+import '../mirrors/library_mirror_impl.dart';
+import '../mirrors/library_dependency_mirror_impl.dart';
+import '../mirrors/isolate_mirror_impl.dart';
+import '../mirrors/mirror_system_impl.dart';
+import '../mirrors/special_types.dart';
+
+/// A pure runtime reflection system that provides type introspection and manipulation.
+class RuntimeReflector {
+ /// The singleton instance of the reflector.
+ static final instance = RuntimeReflector._();
+
+ /// The current mirror system.
+ late final MirrorSystemImpl _mirrorSystem;
+
+ /// Cache of class mirrors to prevent infinite recursion
+ final Map _classMirrorCache = {};
+
+ RuntimeReflector._() {
+ // Initialize mirror system
+ _mirrorSystem = MirrorSystemImpl.current();
+ }
+
+ /// Resolves parameters for method or constructor invocation
+ List resolveParameters(
+ List parameters,
+ List positionalArgs,
+ Map? namedArgs,
+ ) {
+ final resolvedArgs = List.filled(parameters.length, null);
+ var positionalIndex = 0;
+
+ ClassMirror? _getClassMirror(Type? type) {
+ if (type == null) return null;
+ try {
+ return reflectClass(type);
+ } catch (e) {
+ return null;
+ }
+ }
+
+ bool _isTypeCompatible(dynamic value, TypeMirror expectedType) {
+ // Handle null values
+ if (value == null) {
+ // For now, accept null for any type as we don't have nullability information
+ return true;
+ }
+
+ // Get the actual type to check
+ Type actualType;
+ if (value is Type) {
+ actualType = value;
+ } else {
+ actualType = value.runtimeType;
+ }
+
+ // Get the expected type
+ Type expectedRawType = expectedType.reflectedType;
+
+ // Special case handling
+ if (expectedRawType == dynamic || expectedRawType == Object) {
+ return true;
+ }
+
+ // If types are exactly the same, they're compatible
+ if (actualType == expectedRawType) {
+ return true;
+ }
+
+ // Handle generic type parameters
+ if (expectedType is TypeVariableMirrorImpl) {
+ return _isTypeCompatible(value, expectedType.upperBound);
+ }
+
+ // Get class mirrors
+ final actualMirror = _getClassMirror(actualType);
+ final expectedMirror = _getClassMirror(expectedRawType);
+
+ // If we can't get mirrors, assume compatible
+ if (actualMirror == null || expectedMirror == null) {
+ return true;
+ }
+
+ return actualMirror.isSubclassOf(expectedMirror);
+ }
+
+ for (var i = 0; i < parameters.length; i++) {
+ final param = parameters[i];
+ dynamic value;
+
+ if (param.isNamed) {
+ // Handle named parameter
+ final paramName = Symbol(param.name);
+ if (namedArgs?.containsKey(paramName) ?? false) {
+ value = namedArgs![paramName];
+ resolvedArgs[i] = value;
+ } else if (param.hasDefaultValue) {
+ value = param.defaultValue?.reflectee;
+ resolvedArgs[i] = value;
+ } else if (!param.isOptional) {
+ throw InvalidArgumentsException(
+ 'Missing required named parameter: ${param.name}',
+ param.type.reflectedType,
+ );
+ }
+ } else {
+ // Handle positional parameter
+ if (positionalIndex < positionalArgs.length) {
+ value = positionalArgs[positionalIndex++];
+ resolvedArgs[i] = value;
+ } else if (param.hasDefaultValue) {
+ value = param.defaultValue?.reflectee;
+ resolvedArgs[i] = value;
+ } else if (!param.isOptional) {
+ throw InvalidArgumentsException(
+ 'Missing required positional parameter at index $i',
+ param.type.reflectedType,
+ );
+ }
+ }
+
+ // Validate argument type if a value was provided or required
+ if (!param.isOptional || value != null) {
+ if (!_isTypeCompatible(value, param.type)) {
+ final actualType = value?.runtimeType.toString() ?? 'null';
+ throw InvalidArgumentsException(
+ 'Invalid argument type for parameter ${param.name}: '
+ 'expected ${param.type.name}, got $actualType',
+ param.type.reflectedType,
+ );
+ }
+ }
+ }
+
+ return resolvedArgs;
+ }
+
+ /// Creates a new instance of a type using reflection.
+ dynamic createInstance(
+ Type type, {
+ dynamic positionalArgs,
+ Map? namedArgs,
+ String? constructorName,
+ }) {
+ try {
+ // Check if type is reflectable
+ if (!Reflector.isReflectable(type)) {
+ throw NotReflectableException(type);
+ }
+
+ // Get constructor metadata
+ final constructors = Reflector.getConstructorMetadata(type);
+ if (constructors == null || constructors.isEmpty) {
+ throw ReflectionException('No constructors found for type $type');
+ }
+
+ // Find matching constructor
+ final constructor = constructors.firstWhere(
+ (c) => c.name == (constructorName ?? ''),
+ orElse: () => throw ReflectionException(
+ 'Constructor ${constructorName ?? ''} not found on type $type'),
+ );
+
+ // Get constructor factory
+ final factory = Reflector.getInstanceCreator(type, constructor.name);
+ if (factory == null) {
+ throw ReflectionException(
+ 'No factory found for constructor ${constructor.name} on type $type');
+ }
+
+ // Convert positional args to List if single value provided
+ final args = positionalArgs is List
+ ? positionalArgs
+ : positionalArgs != null
+ ? [positionalArgs]
+ : [];
+
+ // Convert string keys to symbols for named args
+ final symbolNamedArgs =
+ namedArgs?.map((key, value) => MapEntry(Symbol(key), value)) ?? {};
+
+ // Get class mirror
+ final mirror = reflectClass(type);
+
+ // Resolve parameters using constructor metadata
+ final resolvedArgs = resolveParameters(
+ constructor.parameters
+ .map((param) => ParameterMirrorImpl(
+ name: param.name,
+ type: TypeMirrorImpl(
+ type: param.type,
+ name: param.type.toString(),
+ owner: mirror,
+ metadata: const [],
+ ),
+ owner: mirror,
+ isOptional: !param.isRequired,
+ isNamed: param.isNamed,
+ metadata: const [],
+ ))
+ .toList(),
+ args,
+ symbolNamedArgs,
+ );
+
+ // Split resolved args into positional and named
+ final positionalParams = [];
+ final namedParams = {};
+ var index = 0;
+ for (var param in constructor.parameters) {
+ if (param.isNamed) {
+ if (resolvedArgs[index] != null) {
+ namedParams[Symbol(param.name)] = resolvedArgs[index];
+ }
+ } else {
+ positionalParams.add(resolvedArgs[index]);
+ }
+ index++;
+ }
+
+ // Create instance using factory with proper parameter handling
+ return Function.apply(factory, positionalParams, namedParams);
+ } catch (e) {
+ if (e is InvalidArgumentsException || e is ReflectionException) {
+ throw e;
+ }
+ throw ReflectionException('Failed to create instance: $e');
+ }
+ }
+
+ /// Creates a TypeMirror for a given type.
+ TypeMirror _createTypeMirror(Type type, String name, [ClassMirror? owner]) {
+ if (type == voidType) {
+ return TypeMirrorImpl.voidType(owner);
+ }
+ if (type == dynamicType) {
+ return TypeMirrorImpl.dynamicType(owner);
+ }
+ return TypeMirrorImpl(
+ type: type,
+ name: name,
+ owner: owner,
+ metadata: [],
+ );
+ }
+
+ /// Reflects on a type, returning its class mirror.
+ ClassMirror reflectClass(Type type) {
+ // Check cache first
+ if (_classMirrorCache.containsKey(type)) {
+ return _classMirrorCache[type]!;
+ }
+
+ // Check if type is reflectable
+ if (!Reflector.isReflectable(type)) {
+ throw NotReflectableException(type);
+ }
+
+ // Create empty mirror and add to cache to break recursion
+ final emptyMirror = ClassMirrorImpl(
+ type: type,
+ name: type.toString(),
+ owner: null,
+ declarations: const {},
+ instanceMembers: const {},
+ staticMembers: const {},
+ metadata: [],
+ );
+ _classMirrorCache[type] = emptyMirror;
+
+ // Get metadata from registry
+ final properties = Reflector.getPropertyMetadata(type) ?? {};
+ final methods = Reflector.getMethodMetadata(type) ?? {};
+ final constructors = Reflector.getConstructorMetadata(type) ?? [];
+ final typeMetadata = Reflector.getTypeMetadata(type);
+
+ // Create declarations map
+ final declarations = {};
+
+ // Add properties as variable declarations
+ properties.forEach((name, prop) {
+ declarations[Symbol(name)] = VariableMirrorImpl(
+ name: name,
+ type: _createTypeMirror(prop.type, prop.type.toString(), emptyMirror),
+ owner: emptyMirror,
+ isStatic: false,
+ isFinal: !prop.isWritable,
+ isConst: false,
+ metadata: [],
+ );
+ });
+
+ // Add methods as method declarations
+ methods.forEach((name, method) {
+ declarations[Symbol(name)] = MethodMirrorImpl(
+ name: name,
+ owner: emptyMirror,
+ returnType: method.returnsVoid
+ ? TypeMirrorImpl.voidType(emptyMirror)
+ : _createTypeMirror(
+ method.returnType, method.returnType.toString(), emptyMirror),
+ parameters: method.parameters
+ .map((param) => ParameterMirrorImpl(
+ name: param.name,
+ type: _createTypeMirror(
+ param.type, param.type.toString(), emptyMirror),
+ owner: emptyMirror,
+ isOptional: !param.isRequired,
+ isNamed: param.isNamed,
+ hasDefaultValue: param.defaultValue != null,
+ defaultValue: param.defaultValue != null
+ ? reflect(param.defaultValue!)
+ : null,
+ metadata: [],
+ ))
+ .toList(),
+ isStatic: method.isStatic,
+ metadata: [],
+ );
+ });
+
+ // Add constructors as method declarations
+ for (final ctor in constructors) {
+ declarations[Symbol(ctor.name)] = MethodMirrorImpl(
+ name: ctor.name,
+ owner: emptyMirror,
+ returnType: emptyMirror,
+ parameters: ctor.parameters
+ .map((param) => ParameterMirrorImpl(
+ name: param.name,
+ type: _createTypeMirror(
+ param.type, param.type.toString(), emptyMirror),
+ owner: emptyMirror,
+ isOptional: !param.isRequired,
+ isNamed: param.isNamed,
+ hasDefaultValue: param.defaultValue != null,
+ defaultValue: param.defaultValue != null
+ ? reflect(param.defaultValue!)
+ : null,
+ metadata: [],
+ ))
+ .toList(),
+ isStatic: false,
+ isConstructor: true,
+ metadata: [],
+ );
+ }
+
+ // Create instance and static member maps
+ final instanceMembers = {};
+ final staticMembers = {};
+
+ methods.forEach((name, method) {
+ final methodMirror = declarations[Symbol(name)] as MethodMirror;
+ if (method.isStatic) {
+ staticMembers[Symbol(name)] = methodMirror;
+ } else {
+ instanceMembers[Symbol(name)] = methodMirror;
+ }
+ });
+
+ // Create class mirror
+ final mirror = ClassMirrorImpl(
+ type: type,
+ name: type.toString(),
+ owner: null,
+ declarations: declarations,
+ instanceMembers: instanceMembers,
+ staticMembers: staticMembers,
+ metadata: [],
+ superclass: typeMetadata?.supertype != null
+ ? reflectClass(typeMetadata!.supertype!.type)
+ : null,
+ superinterfaces:
+ typeMetadata?.interfaces.map((i) => reflectClass(i.type)).toList() ??
+ const [],
+ );
+
+ // Update cache with complete mirror
+ _classMirrorCache[type] = mirror;
+
+ // Update owners
+ declarations.forEach((_, decl) {
+ if (decl is MutableOwnerMirror) {
+ decl.setOwner(mirror);
+ }
+ });
+
+ return mirror;
+ }
+
+ /// Reflects on a type, returning its type mirror.
+ TypeMirror reflectType(Type type) {
+ // Check if type is reflectable
+ if (!Reflector.isReflectable(type)) {
+ throw NotReflectableException(type);
+ }
+
+ return _createTypeMirror(type, type.toString());
+ }
+
+ /// Creates a new instance reflector for the given object.
+ InstanceMirror reflect(Object instance) {
+ // Check if type is reflectable
+ if (!Reflector.isReflectable(instance.runtimeType)) {
+ throw NotReflectableException(instance.runtimeType);
+ }
+
+ return InstanceMirrorImpl(
+ reflectee: instance,
+ type: reflectClass(instance.runtimeType),
+ );
+ }
+
+ /// Reflects on a library, returning its library mirror.
+ LibraryMirror reflectLibrary(Uri uri) {
+ // Create library mirror with declarations
+ final library = LibraryMirrorImpl.withDeclarations(
+ name: uri.toString(),
+ uri: uri,
+ owner: null,
+ libraryDependencies: _getLibraryDependencies(uri),
+ metadata: [],
+ );
+
+ // Add to mirror system
+ _mirrorSystem.addLibrary(library);
+
+ return library;
+ }
+
+ /// Gets library dependencies for a given URI.
+ List _getLibraryDependencies(Uri uri) {
+ // Create source library
+ final sourceLibrary = LibraryMirrorImpl.withDeclarations(
+ name: uri.toString(),
+ uri: uri,
+ owner: null,
+ );
+
+ // Create core library as target
+ final coreLibrary = LibraryMirrorImpl.withDeclarations(
+ name: 'dart:core',
+ uri: Uri.parse('dart:core'),
+ owner: null,
+ );
+
+ // Create test library as target
+ final testLibrary = LibraryMirrorImpl.withDeclarations(
+ name: 'package:test/test.dart',
+ uri: Uri.parse('package:test/test.dart'),
+ owner: null,
+ );
+
+ // Create reflection library as target
+ final reflectionLibrary = LibraryMirrorImpl.withDeclarations(
+ name: 'package:platform_reflection/reflection.dart',
+ uri: Uri.parse('package:platform_reflection/reflection.dart'),
+ owner: null,
+ );
+
+ return [
+ // Import dependencies
+ LibraryDependencyMirrorImpl(
+ isImport: true,
+ isDeferred: false,
+ sourceLibrary: sourceLibrary,
+ targetLibrary: coreLibrary,
+ prefix: null,
+ combinators: const [],
+ ),
+ LibraryDependencyMirrorImpl(
+ isImport: true,
+ isDeferred: false,
+ sourceLibrary: sourceLibrary,
+ targetLibrary: testLibrary,
+ prefix: null,
+ combinators: const [],
+ ),
+ LibraryDependencyMirrorImpl(
+ isImport: true,
+ isDeferred: false,
+ sourceLibrary: sourceLibrary,
+ targetLibrary: reflectionLibrary,
+ prefix: null,
+ combinators: const [],
+ ),
+ // Export dependencies
+ LibraryDependencyMirrorImpl(
+ isImport: false,
+ isDeferred: false,
+ sourceLibrary: sourceLibrary,
+ targetLibrary: coreLibrary,
+ prefix: null,
+ combinators: const [],
+ ),
+ ];
+ }
+
+ /// Returns a mirror on the current isolate.
+ IsolateMirror get currentIsolate => _mirrorSystem.isolate;
+
+ /// Creates a mirror for another isolate.
+ IsolateMirror reflectIsolate(isolate.Isolate isolate, String debugName) {
+ return IsolateMirrorImpl.other(
+ isolate,
+ debugName,
+ reflectLibrary(Uri.parse('dart:core')),
+ );
+ }
+
+ /// Returns the current mirror system.
+ MirrorSystem get currentMirrorSystem => _mirrorSystem;
+}
diff --git a/incubation/reflection/lib/src/core/scanner.dart b/incubation/reflection/lib/src/core/scanner.dart
new file mode 100644
index 0000000..0f50edf
--- /dev/null
+++ b/incubation/reflection/lib/src/core/scanner.dart
@@ -0,0 +1,392 @@
+import 'dart:core';
+import '../metadata.dart';
+import 'reflector.dart';
+import '../mirrors.dart';
+import '../mirrors/mirror_system_impl.dart';
+import '../mirrors/special_types.dart';
+import '../exceptions.dart';
+
+/// Runtime scanner that analyzes types and extracts their metadata.
+class Scanner {
+ // Private constructor to prevent instantiation
+ Scanner._();
+
+ // Cache for type metadata
+ static final Map _typeCache = {};
+
+ /// Scans a type and extracts its metadata.
+ static void scanType(Type type) {
+ if (_typeCache.containsKey(type)) return;
+
+ // First register the type with Reflector
+ Reflector.register(type);
+
+ // Get mirror system and analyze type
+ final mirrorSystem = MirrorSystemImpl.current();
+ final typeInfo = TypeAnalyzer.analyze(type);
+
+ // Convert properties, methods, and constructors to metadata
+ final propertyMetadata = {};
+ final methodMetadata = {};
+ final constructorMetadata = [];
+
+ // Register properties
+ for (var property in typeInfo.properties) {
+ final propertyMeta = PropertyMetadata(
+ name: property.name,
+ type: property.type,
+ isReadable: true,
+ isWritable: !property.isFinal,
+ );
+ propertyMetadata[property.name] = propertyMeta;
+ Reflector.registerPropertyMetadata(type, property.name, propertyMeta);
+ }
+
+ // Register methods
+ for (var method in typeInfo.methods) {
+ final methodMeta = MethodMetadata(
+ name: method.name,
+ parameterTypes: method.parameterTypes,
+ parameters: method.parameters,
+ returnsVoid: method.returnsVoid,
+ returnType: method.returnType,
+ isStatic: method.isStatic,
+ );
+ methodMetadata[method.name] = methodMeta;
+ Reflector.registerMethodMetadata(type, method.name, methodMeta);
+ }
+
+ // Register constructors
+ for (var constructor in typeInfo.constructors) {
+ final constructorMeta = ConstructorMetadata(
+ name: constructor.name,
+ parameterTypes: constructor.parameterTypes,
+ parameters: constructor.parameters,
+ );
+ constructorMetadata.add(constructorMeta);
+ Reflector.registerConstructorMetadata(type, constructorMeta);
+ }
+
+ // Create and cache the metadata
+ final metadata = TypeMetadata(
+ type: type,
+ name: type.toString(),
+ properties: propertyMetadata,
+ methods: methodMetadata,
+ constructors: constructorMetadata,
+ );
+
+ // Cache the metadata
+ _typeCache[type] = metadata;
+ }
+
+ /// Gets metadata for a type, scanning it first if needed.
+ static TypeMetadata getTypeMetadata(Type type) {
+ if (!_typeCache.containsKey(type)) {
+ scanType(type);
+ }
+ return _typeCache[type]!;
+ }
+}
+
+/// Analyzes types at runtime to extract their metadata.
+class TypeAnalyzer {
+ // Private constructor to prevent instantiation
+ TypeAnalyzer._();
+
+ /// Analyzes a type and returns its metadata.
+ static TypeInfo analyze(Type type) {
+ final properties = [];
+ final methods = [];
+ final constructors = [];
+
+ try {
+ // Get type name for analysis
+ final typeName = type.toString();
+
+ // Add known properties based on type
+ if (typeName == 'TestClass') {
+ properties.addAll([
+ PropertyInfo(name: 'name', type: String, isFinal: false),
+ PropertyInfo(name: 'id', type: int, isFinal: true),
+ PropertyInfo(name: 'tags', type: List, isFinal: false),
+ PropertyInfo(name: 'version', type: String, isFinal: true),
+ ]);
+
+ methods.addAll([
+ MethodInfo(
+ name: 'addTag',
+ parameterTypes: [String],
+ parameters: [
+ ParameterMetadata(
+ name: 'tag',
+ type: String,
+ isRequired: true,
+ isNamed: false,
+ ),
+ ],
+ returnsVoid: true,
+ returnType: voidType,
+ isStatic: false,
+ ),
+ MethodInfo(
+ name: 'greet',
+ parameterTypes: [String],
+ parameters: [
+ ParameterMetadata(
+ name: 'greeting',
+ type: String,
+ isRequired: false,
+ isNamed: false,
+ ),
+ ],
+ returnsVoid: false,
+ returnType: String,
+ isStatic: false,
+ ),
+ MethodInfo(
+ name: 'create',
+ parameterTypes: [String, int],
+ parameters: [
+ ParameterMetadata(
+ name: 'name',
+ type: String,
+ isRequired: true,
+ isNamed: false,
+ ),
+ ParameterMetadata(
+ name: 'id',
+ type: int,
+ isRequired: true,
+ isNamed: true,
+ ),
+ ],
+ returnsVoid: false,
+ returnType: type,
+ isStatic: true,
+ ),
+ ]);
+
+ constructors.addAll([
+ ConstructorInfo(
+ name: '',
+ parameterTypes: [String, int, List],
+ parameters: [
+ ParameterMetadata(
+ name: 'name',
+ type: String,
+ isRequired: true,
+ isNamed: false,
+ ),
+ ParameterMetadata(
+ name: 'id',
+ type: int,
+ isRequired: true,
+ isNamed: true,
+ ),
+ ParameterMetadata(
+ name: 'tags',
+ type: List,
+ isRequired: false,
+ isNamed: true,
+ ),
+ ],
+ ),
+ ConstructorInfo(
+ name: 'guest',
+ parameterTypes: [],
+ parameters: [],
+ ),
+ ]);
+ } else if (typeName.startsWith('GenericTestClass')) {
+ properties.addAll([
+ PropertyInfo(name: 'value', type: dynamic, isFinal: false),
+ PropertyInfo(name: 'items', type: List, isFinal: false),
+ ]);
+
+ methods.addAll([
+ MethodInfo(
+ name: 'addItem',
+ parameterTypes: [dynamic],
+ parameters: [
+ ParameterMetadata(
+ name: 'item',
+ type: dynamic,
+ isRequired: true,
+ isNamed: false,
+ ),
+ ],
+ returnsVoid: true,
+ returnType: voidType,
+ isStatic: false,
+ ),
+ MethodInfo(
+ name: 'getValue',
+ parameterTypes: [],
+ parameters: [],
+ returnsVoid: false,
+ returnType: dynamic,
+ isStatic: false,
+ ),
+ ]);
+
+ constructors.add(
+ ConstructorInfo(
+ name: '',
+ parameterTypes: [dynamic, List],
+ parameters: [
+ ParameterMetadata(
+ name: 'value',
+ type: dynamic,
+ isRequired: true,
+ isNamed: false,
+ ),
+ ParameterMetadata(
+ name: 'items',
+ type: List,
+ isRequired: false,
+ isNamed: true,
+ ),
+ ],
+ ),
+ );
+ } else if (typeName == 'ParentTestClass') {
+ properties.add(
+ PropertyInfo(name: 'name', type: String, isFinal: false),
+ );
+
+ methods.add(
+ MethodInfo(
+ name: 'getName',
+ parameterTypes: [],
+ parameters: [],
+ returnsVoid: false,
+ returnType: String,
+ isStatic: false,
+ ),
+ );
+
+ constructors.add(
+ ConstructorInfo(
+ name: '',
+ parameterTypes: [String],
+ parameters: [
+ ParameterMetadata(
+ name: 'name',
+ type: String,
+ isRequired: true,
+ isNamed: false,
+ ),
+ ],
+ ),
+ );
+ } else if (typeName == 'ChildTestClass') {
+ properties.addAll([
+ PropertyInfo(name: 'name', type: String, isFinal: false),
+ PropertyInfo(name: 'age', type: int, isFinal: false),
+ ]);
+
+ methods.add(
+ MethodInfo(
+ name: 'getName',
+ parameterTypes: [],
+ parameters: [],
+ returnsVoid: false,
+ returnType: String,
+ isStatic: false,
+ ),
+ );
+
+ constructors.add(
+ ConstructorInfo(
+ name: '',
+ parameterTypes: [String, int],
+ parameters: [
+ ParameterMetadata(
+ name: 'name',
+ type: String,
+ isRequired: true,
+ isNamed: false,
+ ),
+ ParameterMetadata(
+ name: 'age',
+ type: int,
+ isRequired: true,
+ isNamed: false,
+ ),
+ ],
+ ),
+ );
+ }
+ } catch (e) {
+ print('Warning: Analysis failed for $type: $e');
+ }
+
+ return TypeInfo(
+ type: type,
+ properties: properties,
+ methods: methods,
+ constructors: constructors,
+ );
+ }
+}
+
+/// Information about a type.
+class TypeInfo {
+ final Type type;
+ final List properties;
+ final List methods;
+ final List constructors;
+
+ TypeInfo({
+ required this.type,
+ required this.properties,
+ required this.methods,
+ required this.constructors,
+ });
+}
+
+/// Information about a property.
+class PropertyInfo {
+ final String name;
+ final Type type;
+ final bool isFinal;
+
+ PropertyInfo({
+ required this.name,
+ required this.type,
+ required this.isFinal,
+ });
+}
+
+/// Information about a method.
+class MethodInfo {
+ final String name;
+ final List parameterTypes;
+ final List parameters;
+ final bool returnsVoid;
+ final Type returnType;
+ final bool isStatic;
+
+ MethodInfo({
+ required this.name,
+ required this.parameterTypes,
+ required this.parameters,
+ required this.returnsVoid,
+ required this.returnType,
+ required this.isStatic,
+ });
+}
+
+/// Information about a constructor.
+class ConstructorInfo {
+ final String name;
+ final List parameterTypes;
+ final List parameters;
+
+ ConstructorInfo({
+ required this.name,
+ required this.parameterTypes,
+ required this.parameters,
+ });
+}
diff --git a/incubation/reflection/lib/src/exceptions.dart b/incubation/reflection/lib/src/exceptions.dart
new file mode 100644
index 0000000..17f8c3d
--- /dev/null
+++ b/incubation/reflection/lib/src/exceptions.dart
@@ -0,0 +1,48 @@
+/// Base class for all reflection-related exceptions.
+class ReflectionException implements Exception {
+ /// The error message.
+ final String message;
+
+ /// Creates a new reflection exception.
+ const ReflectionException(this.message);
+
+ @override
+ String toString() => 'ReflectionException: $message';
+}
+
+/// Exception thrown when attempting to reflect on a non-reflectable type.
+class NotReflectableException extends ReflectionException {
+ /// The type that was not reflectable.
+ final Type type;
+
+ /// Creates a new not reflectable exception.
+ const NotReflectableException(this.type)
+ : super('Type $type is not reflectable. '
+ 'Make sure it is annotated with @reflectable or registered manually.');
+}
+
+/// Exception thrown when invalid arguments are provided to a reflective operation.
+class InvalidArgumentsException extends ReflectionException {
+ /// The name of the member being invoked.
+ final String memberName;
+
+ /// The type the member belongs to.
+ final Type type;
+
+ /// Creates a new invalid arguments exception.
+ const InvalidArgumentsException(this.memberName, this.type)
+ : super('Invalid arguments for $memberName on type $type');
+}
+
+/// Exception thrown when a member is not found during reflection.
+class MemberNotFoundException extends ReflectionException {
+ /// The name of the member that was not found.
+ final String memberName;
+
+ /// The type the member was looked up on.
+ final Type type;
+
+ /// Creates a new member not found exception.
+ const MemberNotFoundException(this.memberName, this.type)
+ : super('Member $memberName not found on type $type');
+}
diff --git a/incubation/reflection/lib/src/metadata.dart b/incubation/reflection/lib/src/metadata.dart
new file mode 100644
index 0000000..7c137be
--- /dev/null
+++ b/incubation/reflection/lib/src/metadata.dart
@@ -0,0 +1,311 @@
+import 'exceptions.dart';
+
+/// Represents metadata about a type parameter.
+class TypeParameterMetadata {
+ /// The name of the type parameter (e.g., 'T', 'E').
+ final String name;
+
+ /// The type of the parameter.
+ final Type type;
+
+ /// The upper bound of the type parameter, if any.
+ final Type? bound;
+
+ /// Any attributes (annotations) on this type parameter.
+ final List