Nomad changes
All checks were successful
Deploy fil (kreuzberg) / deploy (push) Successful in 49s

This commit is contained in:
Henrik Jess Nielsen
2026-06-01 23:40:55 +02:00
parent 72b1a0a6ed
commit b4c07d3693
5723 changed files with 1130655 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
```dart title="Dart"
import 'package:kreuzberg/kreuzberg.dart';
Future<void> main() async {
// The Dart binding exposes bulk-clear entry points for OCR backends,
// post-processors, and validators. Document-extractor clearing is not
// surfaced through flutter_rust_bridge; the built-in extractors are
// registered automatically by the kreuzberg core when the library
// initializes.
await KreuzbergBridge.clearOcrBackends();
await KreuzbergBridge.clearPostProcessors();
await KreuzbergBridge.clearValidators();
print('OCR backends, post-processors, and validators cleared');
}
```

View File

@@ -0,0 +1,15 @@
<!-- snippet:skip reason="Dart cannot construct the opaque BoxFn closure types required by createEmbeddingBackendDartImpl — flutter_rust_bridge generates them as RustOpaqueInterface with no Dart-side wrapper. Custom embedding backends must be written in Rust." -->
```dart title="Dart"
import 'package:kreuzberg/kreuzberg.dart';
Future<void> main() async {
// A Dart implementation of the `EmbeddingBackend` trait cannot be plugged
// into the global registry. `Kreuzberg.registerEmbeddingBackend(impl)`
// exists, but its `createEmbeddingBackendDartImpl` factory takes opaque
// `BoxFn*` closure values whose constructors are not surfaced through
// flutter_rust_bridge.
//
// Implement the backend in Rust as `Plugin + EmbeddingBackend` and register
// it via `register_embedding_backend` in a Rust shim crate.
}
```

View File

@@ -0,0 +1,15 @@
<!-- snippet:skip reason="DocumentExtractor trait has no createDocumentExtractorDartImpl factory; custom extractors must be implemented in Rust." -->
```dart title="Dart"
import 'package:kreuzberg/kreuzberg.dart';
Future<void> main() async {
// Custom document extractors cannot be registered from Dart. While
// registerDocumentExtractor exists in the KreuzbergBridge API, there is
// no createDocumentExtractorDartImpl factory to construct a Dart-based
// extractor implementation.
//
// Built-in extractors are registered automatically when the library
// initializes. Custom extractors must be written in Rust and linked into
// a Rust shim crate before the Dart host process loads the dynamic library.
}
```

View File

@@ -0,0 +1,17 @@
```dart title="Dart"
import 'package:kreuzberg/kreuzberg.dart';
Future<void> main() async {
final extractors = await KreuzbergBridge.listDocumentExtractors();
print('Registered extractors: $extractors');
final processors = await KreuzbergBridge.listPostProcessors();
print('Registered processors: $processors');
final backends = await KreuzbergBridge.listOcrBackends();
print('Registered OCR backends: $backends');
final validators = await KreuzbergBridge.listValidators();
print('Registered validators: $validators');
}
```

View File

@@ -0,0 +1,16 @@
<!-- snippet:skip reason="Dart cannot construct the opaque BoxFn closure types required by createValidatorDartImpl — flutter_rust_bridge generates them as RustOpaqueInterface with no Dart-side wrapper. Custom validators must be written in Rust." -->
```dart title="Dart"
import 'package:kreuzberg/kreuzberg.dart';
Future<void> main() async {
// A Dart implementation of the `Validator` trait that asserts a minimum
// content length cannot be plugged into the global validator registry.
// `Kreuzberg.registerValidator(impl)` exists, but its
// `createValidatorDartImpl` factory takes opaque `BoxFn*` closure
// arguments whose constructors are not surfaced through
// flutter_rust_bridge.
//
// Implement the validator in Rust and register it via `register_validator`
// in a Rust shim crate.
}
```

View File

@@ -0,0 +1,15 @@
<!-- snippet:skip reason="DocumentExtractor trait has no createDocumentExtractorDartImpl factory; custom extractors must be implemented in Rust." -->
```dart title="Dart"
import 'package:kreuzberg/kreuzberg.dart';
Future<void> main() async {
// Custom document extractors cannot be implemented in Dart. Creating a
// PDF metadata extractor would require implementing the DocumentExtractor
// trait, but flutter_rust_bridge does not generate the
// createDocumentExtractorDartImpl factory function.
//
// Implement the PDF metadata extractor in Rust and register it via a
// Rust shim crate that links kreuzberg before the Dart host loads the
// dynamic library.
}
```

View File

@@ -0,0 +1,17 @@
<!-- snippet:skip reason="Dart cannot construct the opaque BoxFn closure types required by createPostProcessorDartImpl — flutter_rust_bridge generates them as RustOpaqueInterface with no Dart-side wrapper. The ProcessingStage enum is also not surfaced. Custom post-processors must be written in Rust." -->
```dart title="Dart"
import 'package:kreuzberg/kreuzberg.dart';
Future<void> main() async {
// A Dart implementation of the `PostProcessor` trait that gates on PDF
// MIME type cannot be plugged into the global registry.
// `Kreuzberg.registerPostProcessor(impl)` exists, but its
// `createPostProcessorDartImpl` factory takes opaque `BoxFn*` closure
// values plus a `BoxFnDartFnFutureProcessingStage` whose constructors are
// not surfaced through flutter_rust_bridge. The `ProcessingStage` enum is
// not exported to Dart either.
//
// Implement the post-processor in Rust as `Plugin + PostProcessor` and
// register it via `register_post_processor` in a Rust shim crate.
}
```

View File

@@ -0,0 +1,15 @@
<!-- snippet:skip reason="DocumentExtractor trait has no createDocumentExtractorDartImpl factory in the generated Dart binding; custom extractors must be written and registered in Rust." -->
```dart title="Dart"
import 'package:kreuzberg/kreuzberg.dart';
Future<void> main() async {
// Custom document extractors cannot be implemented in Dart. While the
// traits.dart file includes the DocumentExtractor abstract class,
// flutter_rust_bridge does not generate a createDocumentExtractorDartImpl
// factory function, so there is no way to bridge Dart closures into the
// extractor registry.
//
// Implement custom extractors in Rust and register them via a Rust shim
// crate that links kreuzberg before the Dart host loads the dynamic library.
}
```

View File

@@ -0,0 +1,15 @@
<!-- snippet:skip reason="Plugin trait lifecycle methods (initialize, shutdown) are not exposed in Dart; logging must be implemented in Rust." -->
```dart title="Dart"
import 'package:kreuzberg/kreuzberg.dart';
Future<void> main() async {
// Plugin lifecycle logging hooks are not available in Dart. The Plugin
// trait methods (initialize, shutdown) that enable structured logging are
// only exposed in Rust. Dart plugins (OcrBackend, PostProcessor, Validator,
// EmbeddingBackend) cannot implement Plugin methods directly.
//
// For logging, implement plugins in Rust using the tracing or log crate,
// then register them via a Rust shim crate before the Dart host loads the
// dynamic library.
}
```

View File

@@ -0,0 +1,16 @@
<!-- snippet:skip reason="Testing Dart plugins via package:test is not practical because test closure capture varies by test framework; test via integration after registration or via Rust unit tests." -->
```dart title="Dart"
import 'package:kreuzberg/kreuzberg.dart';
Future<void> main() async {
// Plugin testing with Dart is different from Rust. Dart plugins cannot be
// unit-tested in isolation because the registration mechanism uses closures
// captured in the plugin factory, and test framework async contexts vary.
//
// Recommended approaches:
// 1. Test core plugin logic directly in unit tests with mock data
// 2. Write integration tests that register the plugin and exercise it via
// KreuzbergBridge.extractFile or other extraction methods
// 3. For complex plugins, implement in Rust and test with #[tokio::test]
}
```

View File

@@ -0,0 +1,16 @@
<!-- snippet:skip reason="Dart cannot construct the opaque BoxFn closure types required by createValidatorDartImpl — flutter_rust_bridge generates them as RustOpaqueInterface with no Dart-side wrapper. Custom validators must be written in Rust." -->
```dart title="Dart"
import 'package:kreuzberg/kreuzberg.dart';
Future<void> main() async {
// A Dart implementation of the `Validator` trait that gates on MIME type
// cannot be plugged into the global validator registry.
// `Kreuzberg.registerValidator(impl)` exists, but its
// `createValidatorDartImpl` factory requires opaque `BoxFn*` closure
// values whose constructors are not surfaced through
// flutter_rust_bridge.
//
// Implement the validator in Rust and register it via `register_validator`
// in a Rust shim crate.
}
```

View File

@@ -0,0 +1,18 @@
<!-- snippet:skip reason="Dart cannot construct the opaque BoxFn closure types required by createValidatorDartImpl — flutter_rust_bridge generates them as RustOpaqueInterface with no Dart-side wrapper. Custom validators must be written in Rust." -->
```dart title="Dart"
import 'package:kreuzberg/kreuzberg.dart';
Future<void> main() async {
// A Dart implementation of the `Validator` trait that inspects
// `metadata.additional["quality_score"]` cannot be plugged into the global
// validator registry. The Dart binding exposes
// `Kreuzberg.registerValidator(impl)` and the `createValidatorDartImpl`
// factory, but every closure parameter (`validate`, `shouldValidate`,
// `priority`) is typed as an opaque `BoxFn*` whose constructor is not
// surfaced through flutter_rust_bridge.
//
// Implement the validator in Rust as `Plugin + Validator` and register it
// via `register_validator` in a Rust shim crate that links kreuzberg
// before the Dart host process loads the dynamic library.
}
```

View File

@@ -0,0 +1,16 @@
<!-- snippet:skip reason="Dart cannot construct the opaque BoxFn closure types required by createPostProcessorDartImpl — flutter_rust_bridge generates them as RustOpaqueInterface with no Dart-side wrapper. The closure-captured state pattern is therefore unreachable. Custom plugins must be written in Rust." -->
```dart title="Dart"
import 'package:kreuzberg/kreuzberg.dart';
Future<void> main() async {
// A stateful Dart `PostProcessor` that captures mutable counters in its
// closure cannot be plugged into the global registry.
// `Kreuzberg.registerPostProcessor(impl)` exists, but the
// `createPostProcessorDartImpl` factory takes opaque `BoxFn*` closure
// values whose constructors are not surfaced through flutter_rust_bridge,
// so the closure-capture pattern is unreachable from Dart.
//
// Implement stateful plugins in Rust using `Mutex`/`AtomicU64` for
// interior mutability, then register them in a Rust shim crate.
}
```

View File

@@ -0,0 +1,23 @@
```dart title="Dart"
import 'package:kreuzberg/kreuzberg.dart';
Future<void> main() async {
// Custom-plugin construction (createXxxDartImpl) is unreachable from Dart
// due to opaque BoxFn closure types in the flutter_rust_bridge binding,
// so this snippet exercises the lifecycle against the *built-in* renderer
// registry (markdown / html / djot / plain).
var renderers = await KreuzbergBridge.listRenderers();
print('Renderers before unregister: $renderers');
// Unregister a single renderer by name.
await KreuzbergBridge.unregisterRenderer('plain');
renderers = await KreuzbergBridge.listRenderers();
print('Renderers after unregister: $renderers');
// Bulk-clear all renderers (including remaining built-ins).
await KreuzbergBridge.clearRenderers();
renderers = await KreuzbergBridge.listRenderers();
print('Renderers after clear: $renderers');
}
```

View File

@@ -0,0 +1,16 @@
<!-- snippet:skip reason="Dart cannot construct the opaque BoxFn closure types required by createPostProcessorDartImpl — flutter_rust_bridge generates them as RustOpaqueInterface with no Dart-side wrapper. The ProcessingStage enum is also not surfaced. Custom post-processors must be written in Rust." -->
```dart title="Dart"
import 'package:kreuzberg/kreuzberg.dart';
Future<void> main() async {
// A Dart implementation of the `PostProcessor` trait that counts words in
// the extracted content cannot be plugged into the global registry.
// `Kreuzberg.registerPostProcessor(impl)` exists, but its
// `createPostProcessorDartImpl` factory takes opaque `BoxFn*` closure
// values plus a `BoxFnDartFnFutureProcessingStage` whose constructors are
// not surfaced through flutter_rust_bridge.
//
// Implement the post-processor in Rust as `Plugin + PostProcessor` and
// register it via `register_post_processor` in a Rust shim crate.
}
```