-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding vyuh_feature_system and vyuh_extension_script packages
- Loading branch information
1 parent
5b060d9
commit 4227710
Showing
82 changed files
with
3,158 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Miscellaneous | ||
*.class | ||
*.log | ||
*.pyc | ||
*.swp | ||
.DS_Store | ||
.atom/ | ||
.buildlog/ | ||
.history | ||
.svn/ | ||
migrate_working_dir/ | ||
|
||
# IntelliJ related | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
# The .vscode folder contains launch configuration and tasks you configure in | ||
# VS Code which you may wish to be included in version control, so this line | ||
# is commented out by default. | ||
#.vscode/ | ||
|
||
# Flutter/Dart/Pub related | ||
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. | ||
/pubspec.lock | ||
**/doc/api/ | ||
.dart_tool/ | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# This file tracks properties of this Flutter project. | ||
# Used by Flutter tool to assess capabilities and perform upgrades etc. | ||
# | ||
# This file should be version controlled and should not be manually edited. | ||
|
||
version: | ||
revision: "ba393198430278b6595976de84fe170f553cc728" | ||
channel: "stable" | ||
|
||
project_type: package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## 1.0.0-beta.1 | ||
|
||
* Initial release | ||
* Contains support for running JavaScript code inside a Dart context using `flutter_js` | ||
* Provides extensibility via the `ScriptExtensionDescriptor` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Vyuh.tech | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<!-- | ||
This README describes the package. If you publish this package to pub.dev, | ||
this README's contents appear on the landing page for your package. | ||
For information about how to write a good package README, see the guide for | ||
[writing package pages](https://dart.dev/guides/libraries/writing-package-pages). | ||
For general information about developing packages, see the Dart guide for | ||
[creating packages](https://dart.dev/guides/libraries/create-library-packages) | ||
and the Flutter guide for | ||
[developing packages and plugins](https://flutter.dev/developing-packages). | ||
--> | ||
|
||
TODO: Put a short description of the package here that helps potential users | ||
know whether this package might be useful for them. | ||
|
||
## Features | ||
|
||
TODO: List what your package can do. Maybe include images, gifs, or videos. | ||
|
||
## Getting started | ||
|
||
TODO: List prerequisites and provide or point to information on how to | ||
start using the package. | ||
|
||
## Usage | ||
|
||
TODO: Include short and useful examples for package users. Add longer examples | ||
to `/example` folder. | ||
|
||
```dart | ||
const like = 'sample'; | ||
``` | ||
|
||
## Additional information | ||
|
||
TODO: Tell users more about the package: where to find more information, how to | ||
contribute to the package, how to file issues, what response they can expect | ||
from the package authors, and more. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
include: package:flutter_lints/flutter.yaml | ||
|
||
# Additional information about this file can be found at | ||
# https://dart.dev/guides/language/analysis-options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
targets: | ||
$default: | ||
builders: | ||
json_serializable: | ||
options: | ||
# Options configure how source code is generated for every | ||
# `@JsonSerializable`-annotated class in the package. | ||
# | ||
# The default value for each is listed. | ||
any_map: false | ||
checked: false | ||
constructor: '' | ||
create_factory: true | ||
create_field_map: false | ||
create_per_field_to_json: false | ||
create_to_json: false | ||
disallow_unrecognized_keys: false | ||
explicit_to_json: false | ||
field_rename: none | ||
generic_argument_factories: false | ||
ignore_unannotated: false | ||
include_if_null: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:json_annotation/json_annotation.dart'; | ||
import 'package:vyuh_core/vyuh_core.dart'; | ||
import 'package:vyuh_extension_content/vyuh_extension_content.dart'; | ||
|
||
import 'script_runtime.dart' | ||
if (dart.library.html) 'web_script_runtime.dart' as rt; | ||
|
||
part 'js_script.g.dart'; | ||
|
||
@JsonSerializable() | ||
final class JavaScriptAction extends ActionConfiguration { | ||
static const schemaName = 'vyuh.action.javascript'; | ||
|
||
static final typeDescriptor = TypeDescriptor( | ||
schemaType: JavaScriptAction.schemaName, | ||
title: 'JavaScript Action', | ||
fromJson: JavaScriptAction.fromJson, | ||
); | ||
|
||
@JsonKey(defaultValue: '') | ||
final String script; | ||
|
||
JavaScriptAction({required this.script, super.isAsync}) | ||
: super(schemaType: schemaName); | ||
|
||
factory JavaScriptAction.fromJson(Map<String, dynamic> json) => | ||
_$JavaScriptActionFromJson(json); | ||
|
||
@override | ||
void execute(BuildContext context) { | ||
rt.ScriptRuntime.evaluate(script, context); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
packages/system/vyuh_extension_script/lib/js_script.g.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
packages/system/vyuh_extension_script/lib/script_extension.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:vyuh_core/vyuh_core.dart'; | ||
|
||
import 'script_runtime.dart' if (dart.library.html) 'web_script_runtime.dart' | ||
as rt; | ||
|
||
final class ScriptExtensionDescriptor extends FeatureExtensionDescriptor { | ||
final String name; | ||
|
||
String get runtime => 'javascript'; | ||
|
||
final FutureOr<dynamic> Function(dynamic args) function; | ||
|
||
ScriptExtensionDescriptor({required this.name, required this.function}) | ||
: super(title: 'ScriptExtension: $name'); | ||
} | ||
|
||
final class ScriptExtensionBuilder extends FeatureExtensionBuilder { | ||
ScriptExtensionBuilder() | ||
: super( | ||
extensionType: ScriptExtensionDescriptor, title: 'ScriptExtension'); | ||
|
||
@override | ||
void build(List<FeatureExtensionDescriptor> extensions) { | ||
for (final extension in extensions.cast<ScriptExtensionDescriptor>()) { | ||
rt.ScriptRuntime.registerFunction(extension.name, extension.function); | ||
} | ||
} | ||
|
||
@override | ||
void init() { | ||
rt.ScriptRuntime.init(); | ||
} | ||
} |
Oops, something went wrong.