update: updating files with ported code

This commit is contained in:
Patrick Stewart 2024-06-15 17:34:25 -07:00
parent b0fcee9aac
commit b09546501f
20 changed files with 601 additions and 0 deletions

View file

@ -0,0 +1,49 @@
import 'dart:async';
// TODO: Replace custom classes with dart equivalents.
abstract class ExceptionHandler {
/// Report or log an exception.
///
/// @param Throwable e
/// @return void
///
/// @throws Throwable
Future<void> report(Exception e);
/// Determine if the exception should be reported.
///
/// @param Throwable e
/// @return bool
bool shouldReport(Exception e);
/// Render an exception into an HTTP response.
///
/// @param Request request
/// @param Throwable e
/// @return Response
///
/// @throws Throwable
Future<Response> render(Request request, Exception e);
/// Render an exception to the console.
///
/// @param OutputInterface output
/// @param Throwable e
/// @return void
///
/// @internal This method is not meant to be used or overwritten outside the framework.
void renderForConsole(OutputInterface output, Exception e);
}
class Request {
// Add your request properties and methods here.
}
class Response {
// Add your response properties and methods here.
}
class OutputInterface {
// Add your output interface properties and methods here.
}

View file

@ -0,0 +1,12 @@
import 'dart:core';
class DecryptException implements Exception {
final String message;
DecryptException([this.message = '']);
@override
String toString() {
return message.isEmpty ? 'DecryptException' : 'DecryptException: $message';
}
}

View file

@ -0,0 +1,9 @@
class EncryptException implements Exception {
final String message;
EncryptException([this.message = '']);
@override
String toString() => 'EncryptException: $message';
}

View file

@ -0,0 +1,34 @@
import 'dart:async';
abstract class Encrypter {
/// Encrypt the given value.
///
/// [value]: The value to be encrypted.
/// [serialize]: Whether to serialize the value before encryption.
/// Returns a string representing the encrypted value.
/// Throws an EncryptException if encryption fails.
Future<String> encrypt(dynamic value, {bool serialize = true});
/// Decrypt the given value.
///
/// [payload]: The encrypted payload to be decrypted.
/// [unserialize]: Whether to unserialize the value after decryption.
/// Returns the decrypted value.
/// Throws a DecryptException if decryption fails.
Future<dynamic> decrypt(String payload, {bool unserialize = true});
/// Get the encryption key that the encrypter is currently using.
///
/// Returns the current encryption key as a string.
String getKey();
/// Get the current encryption key and all previous encryption keys.
///
/// Returns a list of all encryption keys.
List<String> getAllKeys();
/// Get the previous encryption keys.
///
/// Returns a list of previous encryption keys.
List<String> getPreviousKeys();
}

View file

@ -0,0 +1,18 @@
abstract class StringEncrypter {
/// Encrypt a string without serialization.
///
/// @param String value
/// @return String
///
/// @throws EncryptException
String encryptString(String value);
/// Decrypt the given string without unserialization.
///
/// @param String payload
/// @return String
///
/// @throws DecryptException
String decryptString(String payload);
}

View file

@ -0,0 +1,59 @@
abstract class Dispatcher {
/// Register an event listener with the dispatcher.
///
/// @param Closure|string|array events
/// @param Closure|string|array|null listener
/// @return void
void listen(dynamic events, [dynamic listener]);
/// Determine if a given event has listeners.
///
/// @param string eventName
/// @return bool
bool hasListeners(String eventName);
/// Register an event subscriber with the dispatcher.
///
/// @param object|string subscriber
/// @return void
void subscribe(dynamic subscriber);
/// Dispatch an event until the first non-null response is returned.
///
/// @param string|object event
/// @param mixed payload
/// @return mixed
dynamic until(dynamic event, [dynamic payload]);
/// Dispatch an event and call the listeners.
///
/// @param string|object event
/// @param mixed payload
/// @param bool halt
/// @return List<dynamic>|null
List<dynamic>? dispatch(dynamic event, [dynamic payload, bool halt = false]);
/// Register an event and payload to be fired later.
///
/// @param string event
/// @param array payload
/// @return void
void push(String event, [List<dynamic>? payload]);
/// Flush a set of pushed events.
///
/// @param string event
/// @return void
void flush(String event);
/// Remove a set of listeners from the dispatcher.
///
/// @param string event
/// @return void
void forget(String event);
/// Forget all of the queued listeners.
///
/// @return void
void forgetPushed();
}

View file

@ -0,0 +1,3 @@
abstract class ShouldDispatchAfterCommit {
// Interface with no methods
}

View file

@ -0,0 +1,4 @@
abstract class ShouldHandleEventsAfterCommit {
// Add any method signatures if needed in the future
}

View file

@ -0,0 +1,8 @@
import 'filesystem.dart';
abstract class Cloud implements Filesystem {
/// Get the URL for the file at the given path.
///
/// @param String path
/// @return String
String url(String path);
}

View file

@ -0,0 +1,9 @@
import 'filesystem.dart';
abstract class Factory {
/// Get a filesystem implementation.
///
/// @param String? name
/// @return Filesystem
Filesystem disk([String? name]);
}

View file

@ -0,0 +1,9 @@
class FileNotFoundException implements Exception {
final String message;
FileNotFoundException([this.message = 'File not found']);
@override
String toString() => 'FileNotFoundException: $message';
}

View file

@ -0,0 +1,164 @@
import 'dart:typed_data';
import 'dart:io';
abstract class Filesystem {
/// The public visibility setting.
static const String VISIBILITY_PUBLIC = 'public';
/// The private visibility setting.
static const String VISIBILITY_PRIVATE = 'private';
/// Get the full path to the file that exists at the given relative path.
///
/// @param String path
/// @return String
String path(String path);
/// Determine if a file exists.
///
/// @param String path
/// @return bool
bool exists(String path);
/// Get the contents of a file.
///
/// @param String path
/// @return Uint8List? (null if file doesn't exist)
Uint8List? get(String path);
/// Get a resource to read the file.
///
/// @param String path
/// @return Stream<List<int>>? (null if file doesn't exist)
Stream<List<int>>? readStream(String path);
/// Write the contents of a file.
///
/// @param String path
/// @param dynamic contents
/// @param Map<String, dynamic>? options
/// @return bool
bool put(String path, dynamic contents, [Map<String, dynamic>? options]);
/// Store the uploaded file on the disk.
///
/// @param String path
/// @param dynamic file
/// @param Map<String, dynamic>? options
/// @return String|false
dynamic putFile(String path, dynamic file, [Map<String, dynamic>? options]);
/// Store the uploaded file on the disk with a given name.
///
/// @param String path
/// @param dynamic file
/// @param String? name
/// @param Map<String, dynamic>? options
/// @return String|false
dynamic putFileAs(String path, dynamic file, [String? name, Map<String, dynamic>? options]);
/// Write a new file using a stream.
///
/// @param String path
/// @param Stream<List<int>> resource
/// @param Map<String, dynamic>? options
/// @return bool
bool writeStream(String path, Stream<List<int>> resource, [Map<String, dynamic>? options]);
/// Get the visibility for the given path.
///
/// @param String path
/// @return String
String getVisibility(String path);
/// Set the visibility for the given path.
///
/// @param String path
/// @param String visibility
/// @return bool
bool setVisibility(String path, String visibility);
/// Prepend to a file.
///
/// @param String path
/// @param String data
/// @return bool
bool prepend(String path, String data);
/// Append to a file.
///
/// @param String path
/// @param String data
/// @return bool
bool append(String path, String data);
/// Delete the file at a given path.
///
/// @param dynamic paths
/// @return bool
bool delete(dynamic paths);
/// Copy a file to a new location.
///
/// @param String from
/// @param String to
/// @return bool
bool copy(String from, String to);
/// Move a file to a new location.
///
/// @param String from
/// @param String to
/// @return bool
bool move(String from, String to);
/// Get the file size of a given file.
///
/// @param String path
/// @return int
int size(String path);
/// Get the file's last modification time.
///
/// @param String path
/// @return DateTime
DateTime lastModified(String path);
/// Get an array of all files in a directory.
///
/// @param String? directory
/// @param bool recursive
/// @return List<String>
List<String> files([String? directory, bool recursive = false]);
/// Get all of the files from the given directory (recursive).
///
/// @param String? directory
/// @return List<String>
List<String> allFiles([String? directory]);
/// Get all of the directories within a given directory.
///
/// @param String? directory
/// @param bool recursive
/// @return List<String>
List<String> directories([String? directory, bool recursive = false]);
/// Get all (recursive) of the directories within a given directory.
///
/// @param String? directory
/// @return List<String>
List<String> allDirectories([String? directory]);
/// Create a directory.
///
/// @param String path
/// @return bool
bool makeDirectory(String path);
/// Recursively delete a directory.
///
/// @param String directory
/// @return bool
bool deleteDirectory(String directory);
}

View file

@ -0,0 +1,12 @@
import 'dart:io';
class LockTimeoutException implements IOException {
final String message;
LockTimeoutException([this.message = '']);
@override
String toString() {
return 'LockTimeoutException: $message';
}
}

View file

@ -0,0 +1,102 @@
import 'container.dart'; // Assuming Container is defined in container.dart
import 'maintenance_mode.dart'; // Assuming MaintenanceMode is defined in maintenance_mode.dart
// TODO: Replace missing imports with dar equivalents.
abstract class Application extends Container {
/// Get the version number of the application.
String version();
/// Get the base path of the installation.
String basePath([String path = '']);
/// Get the path to the bootstrap directory.
String bootstrapPath([String path = '']);
/// Get the path to the application configuration files.
String configPath([String path = '']);
/// Get the path to the database directory.
String databasePath([String path = '']);
/// Get the path to the language files.
String langPath([String path = '']);
/// Get the path to the public directory.
String publicPath([String path = '']);
/// Get the path to the resources directory.
String resourcePath([String path = '']);
/// Get the path to the storage directory.
String storagePath([String path = '']);
/// Get or check the current application environment.
dynamic environment(List<String> environments);
/// Determine if the application is running in the console.
bool runningInConsole();
/// Determine if the application is running unit tests.
bool runningUnitTests();
/// Determine if the application is running with debug mode enabled.
bool hasDebugModeEnabled();
/// Get an instance of the maintenance mode manager implementation.
MaintenanceMode maintenanceMode();
/// Determine if the application is currently down for maintenance.
bool isDownForMaintenance();
/// Register all of the configured providers.
void registerConfiguredProviders();
/// Register a service provider with the application.
ServiceProvider register(dynamic provider, [bool force = false]);
/// Register a deferred provider and service.
void registerDeferredProvider(String provider, [String? service]);
/// Resolve a service provider instance from the class name.
ServiceProvider resolveProvider(String provider);
/// Boot the application's service providers.
void boot();
/// Register a new boot listener.
void booting(Function callback);
/// Register a new "booted" listener.
void booted(Function callback);
/// Run the given array of bootstrap classes.
void bootstrapWith(List<String> bootstrappers);
/// Get the current application locale.
String getLocale();
/// Get the application namespace.
String getNamespace();
/// Get the registered service provider instances if any exist.
List<ServiceProvider> getProviders(dynamic provider);
/// Determine if the application has been bootstrapped before.
bool hasBeenBootstrapped();
/// Load and boot all of the remaining deferred providers.
void loadDeferredProviders();
/// Set the current application locale.
void setLocale(String locale);
/// Determine if middleware has been disabled for the application.
bool shouldSkipMiddleware();
/// Register a terminating callback with the application.
Application terminating(dynamic callback);
/// Terminate the application.
void terminate();
}

View file

@ -0,0 +1,17 @@
abstract class CachesConfiguration {
/// Determine if the application configuration is cached.
///
/// Returns a boolean indicating if the configuration is cached.
bool configurationIsCached();
/// Get the path to the configuration cache file.
///
/// Returns a string representing the path to the configuration cache file.
String getCachedConfigPath();
/// Get the path to the cached services file.
///
/// Returns a string representing the path to the cached services file.
String getCachedServicesPath();
}

View file

@ -0,0 +1,11 @@
abstract class CachesRoutes {
/// Determine if the application routes are cached.
///
/// @return bool
bool routesAreCached();
/// Get the path to the routes cache file.
///
/// @return string
String getCachedRoutesPath();
}

View file

@ -0,0 +1,7 @@
abstract class ExceptionRenderer {
/// Renders the given exception as HTML.
///
/// @param Exception throwable
/// @return String
String render(Exception throwable);
}

View file

@ -0,0 +1,19 @@
abstract class MaintenanceMode {
/// Take the application down for maintenance.
///
/// [payload] - The payload containing maintenance details.
void activate(Map<String, dynamic> payload);
/// Take the application out of maintenance.
void deactivate();
/// Determine if the application is currently down for maintenance.
///
/// Returns `true` if the application is in maintenance mode, `false` otherwise.
bool active();
/// Get the data map which was provided when the application was placed into maintenance.
///
/// Returns a map containing maintenance data.
Map<String, dynamic> data();
}

View file

@ -0,0 +1,29 @@
abstract class Hasher {
/// Get information about the given hashed value.
///
/// @param String hashedValue
/// @return Map<String, dynamic>
Map<String, dynamic> info(String hashedValue);
/// Hash the given value.
///
/// @param String value
/// @param Map<String, dynamic> options
/// @return String
String make(String value, {Map<String, dynamic> options = const {}});
/// Check the given plain value against a hash.
///
/// @param String value
/// @param String hashedValue
/// @param Map<String, dynamic> options
/// @return bool
bool check(String value, String hashedValue, {Map<String, dynamic> options = const {}});
/// Check if the given hash has been hashed using the given options.
///
/// @param String hashedValue
/// @param Map<String, dynamic> options
/// @return bool
bool needsRehash(String hashedValue, {Map<String, dynamic> options = const {}});
}

View file

@ -0,0 +1,26 @@
import 'package:symfony_http/symfony_http.dart' as symfony;
import 'package:illuminate_foundation/illuminate_foundation.dart';
// TODO: Find replacements for missing imports.
abstract class Kernel {
/// Bootstrap the application for HTTP requests.
void bootstrap();
/// Handle an incoming HTTP request.
///
/// @param symfony.Request request
/// @return symfony.Response
symfony.Response handle(symfony.Request request);
/// Perform any final actions for the request lifecycle.
///
/// @param symfony.Request request
/// @param symfony.Response response
void terminate(symfony.Request request, symfony.Response response);
/// Get the application instance.
///
/// @return Application
Application getApplication();
}