├── .dart-version ├── .editorconfig ├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── custom.md │ └── feature_request.md ├── dependabot.yml └── workflows │ └── dart.yml ├── .gitignore ├── .gitignore_global ├── .pubignore ├── .vscode └── settings.json ├── AUTHORS.txt ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── CONTRIBUTORS.md ├── LICENSE ├── OWNERS ├── PACKAGES.md ├── README.md ├── SECURITY.md ├── docs ├── README.md ├── custom │ ├── components.md │ └── introduction.md ├── design │ └── template.md ├── phs.md └── routing.md ├── example ├── .gitignore ├── CHANGELOG.md ├── README.md ├── analysis_options.yaml ├── build.yaml ├── lib │ ├── App.phs │ ├── App.scss │ └── components │ │ ├── Component.phs │ │ ├── component.dart │ │ └── styles.css ├── pheasant.yaml ├── pubspec.yaml └── web │ ├── index.html │ ├── main.dart │ └── styles.css ├── modules └── README.md ├── mono_repo.yaml ├── packages ├── pheasant │ ├── .github │ │ └── workflows │ │ │ └── dart.yml │ ├── .gitignore │ ├── .pubignore │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── analysis_options.yaml │ ├── example │ │ └── example.md │ ├── lib │ │ ├── build.dart │ │ ├── custom.dart │ │ ├── pheasant.dart │ │ └── router.dart │ ├── mono_pkg.yaml │ ├── pubspec.yaml │ └── test │ │ └── pheasant_test.dart ├── pheasant_assets │ ├── .github │ │ └── workflows │ │ │ └── dart.yml │ ├── .gitignore │ ├── .pubignore │ ├── CHANGELOG.md │ ├── CODE_OF_CONDUCT.md │ ├── CONTRIBUTING.md │ ├── LICENSE │ ├── README.md │ ├── analysis_options.yaml │ ├── example │ │ ├── README.md │ │ └── lib │ │ │ ├── css.dart │ │ │ ├── pae_css.dart │ │ │ ├── pae_scss.dart │ │ │ ├── scss.dart │ │ │ └── styles.css │ ├── lib │ │ ├── pheasant_assets.dart │ │ ├── pheasant_build.dart │ │ └── src │ │ │ ├── assets.dart │ │ │ ├── compile │ │ │ ├── compile.dart │ │ │ ├── parse.dart │ │ │ └── scope.dart │ │ │ ├── constants │ │ │ └── syntax.dart │ │ │ ├── css │ │ │ ├── extract.dart │ │ │ └── id_scope.dart │ │ │ ├── exceptions │ │ │ ├── errors.dart │ │ │ └── exceptions.dart │ │ │ └── sass │ │ │ └── logger.dart │ ├── mono_pkg.yaml │ ├── pubspec.yaml │ └── test │ │ ├── pheasant_assets_test.dart │ │ └── src │ │ ├── main.css │ │ ├── main.scss │ │ └── styles.sass ├── pheasant_build │ ├── .github │ │ └── workflows │ │ │ └── dart.yml │ ├── .gitignore │ ├── .pubignore │ ├── CHANGELOG.md │ ├── CODE_OF_CONDUCT.md │ ├── CONTRIBUTING.md │ ├── LICENSE │ ├── README.md │ ├── analysis_options.yaml │ ├── example │ │ └── example.md │ ├── lib │ │ ├── pheasant_build.dart │ │ └── src │ │ │ ├── build │ │ │ ├── builder.dart │ │ │ └── src │ │ │ │ ├── pheasant_file_builder.dart │ │ │ │ ├── pheasant_main_builder.dart │ │ │ │ └── pheasant_router_builder.dart │ │ │ ├── src │ │ │ ├── app.dart │ │ │ ├── base.dart │ │ │ ├── render.dart │ │ │ └── src.dart │ │ │ └── tools │ │ │ ├── config.dart │ │ │ └── input.dart │ ├── mono_pkg.yaml │ ├── pubspec.yaml │ └── test │ │ └── pheasant_build_test.dart ├── pheasant_cli │ ├── .github │ │ └── workflows │ │ │ └── dart.yml │ ├── .gitignore │ ├── .pubignore │ ├── AUTHORS │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── analysis_options.yaml │ ├── bin │ │ └── pheasant.dart │ ├── example │ │ └── README.md │ ├── lib │ │ └── src │ │ │ ├── commands │ │ │ ├── add │ │ │ │ └── add_plugins.dart │ │ │ ├── build │ │ │ │ └── build_application.dart │ │ │ ├── commands.dart │ │ │ ├── doctor │ │ │ │ └── sdksearch.dart │ │ │ ├── general │ │ │ │ ├── configfile.dart │ │ │ │ ├── errors.dart │ │ │ │ ├── validate_project.dart │ │ │ │ └── welcome.dart │ │ │ ├── handle.dart │ │ │ ├── init │ │ │ │ ├── app │ │ │ │ │ ├── appgen.dart │ │ │ │ │ └── custom_file.dart │ │ │ │ ├── config.dart │ │ │ │ ├── interface.dart │ │ │ │ └── plugin │ │ │ │ │ ├── pluginconfig.dart │ │ │ │ │ └── plugingen.dart │ │ │ ├── remove │ │ │ │ └── remove_plugins.dart │ │ │ └── run │ │ │ │ ├── bg_process.dart │ │ │ │ ├── getters │ │ │ │ ├── configfile.dart │ │ │ │ └── filesearch.dart │ │ │ │ ├── handle_config.dart │ │ │ │ ├── log │ │ │ │ ├── analyze_log.dart │ │ │ │ └── expr.dart │ │ │ │ ├── main_process.dart │ │ │ │ └── prereq │ │ │ │ ├── get_plugins.dart │ │ │ │ └── precheck.dart │ │ │ ├── config │ │ │ ├── config.dart │ │ │ └── configfile.dart │ │ │ ├── constants │ │ │ ├── buildfile.dart │ │ │ ├── clidoc.dart │ │ │ ├── config.dart │ │ │ └── constants.dart │ │ │ ├── meta │ │ │ └── metadata.dart │ │ │ ├── pheasant_cli.dart │ │ │ └── utils │ │ │ ├── enum │ │ │ └── platforms.dart │ │ │ ├── handle.dart │ │ │ ├── parse.dart │ │ │ └── src │ │ │ └── usage.dart │ ├── mono_pkg.yaml │ ├── pubspec.yaml │ ├── template │ │ └── pheasant.yaml │ └── test │ │ └── pheasant_cli_test.dart ├── pheasant_meta │ ├── .github │ │ └── workflows │ │ │ └── dart.yml │ ├── .gitignore │ ├── .pubignore │ ├── CHANGELOG.md │ ├── CODE_OF_CONDUCT.md │ ├── CONTRIBUTING.md │ ├── LICENSE │ ├── README.md │ ├── analysis_options.yaml │ ├── example │ │ └── example.md │ ├── lib │ │ ├── pheasant_meta.dart │ │ └── src │ │ │ ├── exceptions │ │ │ └── exceptions.dart │ │ │ └── meta │ │ │ ├── basic │ │ │ ├── annotations.dart │ │ │ └── objects.dart │ │ │ ├── metadata.dart │ │ │ ├── obj │ │ │ └── obj.dart │ │ │ └── pheasant_temp │ │ │ └── props.dart │ ├── mono_pkg.yaml │ ├── pubspec.yaml │ └── test │ │ ├── annotation_test.dart │ │ ├── exception_test.dart │ │ └── pme_test.dart └── pheasant_temp │ ├── .github │ └── workflows │ │ └── dart.yml │ ├── .gitignore │ ├── .pubignore │ ├── ATTRIBUTIONS │ ├── CHANGELOG.md │ ├── CODE_OF_CONDUCT.md │ ├── CONTRIBUTING.md │ ├── LICENSE │ ├── README.md │ ├── analysis_options.yaml │ ├── example │ └── main.dart │ ├── lib │ ├── pheasant_build.dart │ ├── pheasant_custom.dart │ ├── pheasant_temp.dart │ └── src │ │ ├── base.dart │ │ ├── builder │ │ ├── analyze │ │ │ ├── analyze.dart │ │ │ ├── enums │ │ │ │ └── get_enums.dart │ │ │ ├── functions │ │ │ │ ├── deps.dart │ │ │ │ └── functions.dart │ │ │ ├── imports │ │ │ │ ├── combinators.dart │ │ │ │ ├── extension.dart │ │ │ │ └── get_imports.dart │ │ │ ├── shared │ │ │ │ ├── extractor_result.dart │ │ │ │ ├── metadata │ │ │ │ │ ├── annotation_info.dart │ │ │ │ │ └── props.dart │ │ │ │ └── parse_code.dart │ │ │ └── variables │ │ │ │ ├── variable_declarations.dart │ │ │ │ ├── variable_extractor_visitor.dart │ │ │ │ └── variable_info.dart │ │ ├── builder.dart │ │ ├── code │ │ │ ├── code.dart │ │ │ ├── compile.dart │ │ │ ├── components │ │ │ │ ├── cc.dart │ │ │ │ └── custom_components.dart │ │ │ ├── constants │ │ │ │ ├── defs.dart │ │ │ │ ├── lists.dart │ │ │ │ └── tempclass.dart │ │ │ ├── create_render.dart │ │ │ └── src │ │ │ │ ├── code_body.dart │ │ │ │ ├── events.dart │ │ │ │ └── utils │ │ │ │ ├── custom_element.dart │ │ │ │ └── text_node.dart │ │ └── create │ │ │ └── mainbuilder.dart │ │ ├── components │ │ ├── attributes │ │ │ ├── attr.dart │ │ │ └── attr_list.dart │ │ ├── components.dart │ │ ├── custom │ │ │ ├── custom.dart │ │ │ └── helpers │ │ │ │ └── html.dart │ │ ├── elements │ │ │ ├── element_list.dart │ │ │ ├── tags.dart │ │ │ └── types.dart │ │ └── render.dart │ │ ├── exceptions │ │ └── exceptions.dart │ │ ├── routing │ │ ├── routing.dart │ │ ├── src │ │ │ ├── pop.dart │ │ │ ├── push.dart │ │ │ ├── refresh.dart │ │ │ ├── replace.dart │ │ │ ├── route.dart │ │ │ └── shared │ │ │ │ ├── current_path.dart │ │ │ │ └── helpers.dart │ │ └── unknown │ │ │ └── unknown.dart │ │ └── state │ │ └── state.dart │ ├── mono_pkg.yaml │ ├── pubspec.yaml │ └── test │ ├── benchmark │ ├── main_test.dart │ └── render_test.dart │ └── main │ ├── build_file_test.dart │ ├── build_file_test.html │ ├── main_file_test.dart │ └── render_file_test.dart ├── pheasant.code-workspace ├── pubspec.yaml └── tool └── ci.sh /.dart-version: -------------------------------------------------------------------------------- 1 | >=3.0.0 -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # top-most EditorConfig file 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 4 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = false 10 | insert_final_newline = false -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | example/*.html linguist-vendored 2 | example/*.scss linguist-vendored 3 | example/*.css linguist-vendored 4 | *.sh linguist-vendored 5 | tool/*.sh linguist-vendored -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "[Pheasant Bug]" 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Pub Information (optional but helpful)** 21 | 1. The Package Information 22 | 2. Any other packages used in sync 23 | 3. The CLI Information 24 | 25 | **Expected behavior** 26 | A clear and concise description of what you expected to happen. 27 | 28 | **Screenshots** 29 | If applicable, add screenshots to help explain your problem. 30 | 31 | **Desktop (please complete the following information):** 32 | - OS: [e.g. iOS] 33 | - Browser [e.g. chrome, safari] 34 | - Version [e.g. 22] 35 | 36 | **Smartphone (please complete the following information):** 37 | - Device: [e.g. iPhone6] 38 | - OS: [e.g. iOS8.1] 39 | - Browser [e.g. stock browser, safari] 40 | - Version [e.g. 22] 41 | 42 | **Additional context** 43 | Add any other context about the problem here. 44 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/custom.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Custom issue template 3 | about: Describe this issue template's purpose here. 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: "[Suggested Pheasant Feature]" 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **What Dependent Packages will your feature affect** 17 | List all pheasant children packages, including the cli, that may be affected by this change. 18 | 19 | **Describe alternatives you've considered** 20 | A clear and concise description of any alternative solutions or features you've considered. 21 | 22 | **Additional context** 23 | Add any other context or screenshots about the feature request here. 24 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # Created with package:mono_repo v6.6.1 2 | { 3 | "version": 2, 4 | "updates": [ 5 | { 6 | "package-ecosystem": "github-actions", 7 | "directory": "/", 8 | "schedule": { 9 | "interval": "monthly" 10 | } 11 | }, 12 | { 13 | "package-ecosystem": "pub", 14 | "directory": "pheasant", 15 | "schedule": { 16 | "interval": "weekly" 17 | } 18 | }, 19 | { 20 | "package-ecosystem": "pub", 21 | "directory": "pheasant_assets", 22 | "schedule": { 23 | "interval": "weekly" 24 | } 25 | }, 26 | { 27 | "package-ecosystem": "pub", 28 | "directory": "pheasant_build", 29 | "schedule": { 30 | "interval": "weekly" 31 | } 32 | }, 33 | { 34 | "package-ecosystem": "pub", 35 | "directory": "pheasant_cli", 36 | "schedule": { 37 | "interval": "weekly" 38 | } 39 | }, 40 | { 41 | "package-ecosystem": "pub", 42 | "directory": "pheasant_meta", 43 | "schedule": { 44 | "interval": "weekly" 45 | } 46 | }, 47 | { 48 | "package-ecosystem": "pub", 49 | "directory": "pheasant_temp", 50 | "schedule": { 51 | "interval": "weekly" 52 | } 53 | } 54 | ] 55 | } 56 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **.info.md 2 | 3 | .DS_Store 4 | 5 | demo/ 6 | 7 | scripts/ 8 | 9 | pubspec_overrides.yaml 10 | 11 | .dart_tool/ 12 | 13 | pubspec.lock 14 | 15 | doc_files.sh 16 | **/pubspec.lock 17 | 18 | .env 19 | private/ 20 | internal/ 21 | -------------------------------------------------------------------------------- /.gitignore_global: -------------------------------------------------------------------------------- 1 | build/ 2 | 3 | .vscode/ 4 | 5 | .DS_Store 6 | 7 | changes.md 8 | 9 | laws.md 10 | 11 | **.sh -------------------------------------------------------------------------------- /.pubignore: -------------------------------------------------------------------------------- 1 | example/ 2 | 3 | scripts/ 4 | 5 | demo/ -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.tabSize": 2, 3 | "editor.insertSpaces": true 4 | } -------------------------------------------------------------------------------- /AUTHORS.txt: -------------------------------------------------------------------------------- 1 | # Below is a list of people and organizations that have contributed to the 2 | # Pheasant Framework. Names should be added to the list like so: 3 | # 4 | # Name - Organization - 5 | Nikechukwu Okoronkwo - Private - -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log for The Pheasant Framework 2 | All relevant changes will be documented in this changelog file. 3 | 4 | ## 0.1.0-beta 5 | - Added support for state management. 6 | - Added support for passing data to child components from parent via the `@prop` and `@noprop` metadata. 7 | - Added support for binding data 8 | - Added support for event handling 9 | - Extended support for Custom Components 10 | 11 | ## 0.1.0-alpha 12 | - Initial creation of the framework -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | ## Overview 4 | 5 | As contributors and maintainers of The Pheasant Framework project, we pledge to create a respectful and inclusive environment for everyone involved. We value the participation of each member and want to ensure a positive experience for all. 6 | 7 | ## Expected Behavior 8 | 9 | All contributors are expected to exhibit the following behaviors: 10 | 11 | - Be respectful and considerate towards others. 12 | - Avoid any form of harassment, discrimination, or offensive language. 13 | - Be open to constructive criticism and willing to learn from others. 14 | - Focus on the technical aspects of discussions and contributions. 15 | 16 | ## Unacceptable Behavior 17 | 18 | The following behaviors are considered unacceptable and will not be tolerated: 19 | 20 | - Harassment, discrimination, or any form of offensive behavior. 21 | - Intimidation or unwelcome attention. 22 | - Any form of trolling, insulting, or derogatory comments. 23 | - Advocating for or encouraging any of the above behaviors. 24 | 25 | ## Reporting Violations 26 | 27 | If you witness or experience any behavior that violates this code of conduct, please report it to the project maintainers at [maintainer's email]. All reports will be kept confidential. 28 | 29 | ## Enforcement 30 | 31 | Violations of the code of conduct may result in appropriate actions, including but not limited to: 32 | 33 | - Warning the individual responsible for the violation. 34 | - Temporary or permanent exclusion from the project. 35 | 36 | Project maintainers have the right and responsibility to remove, edit, or reject comments, code, issues, and other contributions that do not align with this code of conduct. 37 | 38 | ## Attribution 39 | 40 | This code of conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 41 | 42 | For any questions or clarifications regarding this code of conduct, please contact [this email](raven@tech.nugegroup.com). 43 | 44 | Thank you for your cooperation and commitment to fostering a positive and inclusive community for The Pheasant Framework. 45 | -------------------------------------------------------------------------------- /CONTRIBUTORS.md: -------------------------------------------------------------------------------- 1 | # Contributors 2 | - NIMA 3 | - Nikechukwu Okoronkwo -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [2023] [The Pheasant Group] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /OWNERS: -------------------------------------------------------------------------------- 1 | Nikechukwu Okoronkwo -------------------------------------------------------------------------------- /PACKAGES.md: -------------------------------------------------------------------------------- 1 | | Package | Description | Version | 2 | |---|---|---| 3 | | [pheasant](pheasant/) | The Pheasant Framework is a progressive, fast-reload, modern frontend web framework that allows you to make powerful web applications in Dart. | [![pub package](https://img.shields.io/pub/v/pheasant.svg)](https://pub.dev/packages/pheasant) | 4 | | [pheasant_assets](pheasant_assets/) | Package for rendering styles and other external assets from the Pheasant Framework for Component Files. | [![pub package](https://img.shields.io/pub/v/pheasant_assets.svg)](https://pub.dev/packages/pheasant_assets) | 5 | | [pheasant_build](pheasant_build/) | The build package for all pheasant related compilation, as well as pheasant project configuration. | [![pub package](https://img.shields.io/pub/v/pheasant_build.svg)](https://pub.dev/packages/pheasant_build) | 6 | | [pheasant_cli](pheasant_cli/) | The official cli for running, creating and working with Pheasant projects and applications. | [![pub package](https://img.shields.io/pub/v/pheasant_cli.svg)](https://pub.dev/packages/pheasant_cli) | 7 | | [pheasant_meta](pheasant_meta/) | Metadata to use in The Pheasant Framework. This also enlists base objects such as exceptions, errors and more for use in sibling packages. | [![pub package](https://img.shields.io/pub/v/pheasant_meta.svg)](https://pub.dev/packages/pheasant_meta) | 8 | | [pheasant_temp](pheasant_temp/) | The Pheasant Framework Templating Engine to Create Renderable Dart Code for Pheasant Code. | [![pub package](https://img.shields.io/pub/v/pheasant_temp.svg)](https://pub.dev/packages/pheasant_temp) | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # Pheasant Documentation 2 | This is the documentation for this project. If you are getting started on this project, you can check out the wiki for a quickstart activity. -------------------------------------------------------------------------------- /docs/design/template.md: -------------------------------------------------------------------------------- 1 | # Pheasant Template Design Features 2 | 3 | Here are some design features used in pheasant that might interest you. 4 | 5 | ## Double Braces vs Single Braces 6 | If you want to make use of a variable, function or anything similar that returns a value, or compute a value, we make use of double braces. 7 | 8 | Single braces, on the other hand, are used in loops or any other similar situations where you may need to make use of the key value being used. 9 | ```html 10 | 17 | ``` 18 | 19 | Despite this difference, you shouldn't name variables in such manner with similar names -------------------------------------------------------------------------------- /docs/routing.md: -------------------------------------------------------------------------------- 1 | # Routing 2 | The Pheasant Framework includes built-in support for single-page application routing out of the box. That way you can have fast and efficient page routing in your application. 3 | 4 | ```dart 5 | import '.routes.dart'; 6 | 7 | import '.routes.dart' show RouteTo; 8 | ``` 9 | 10 | ```dart 11 | RouteTo() 12 | ``` 13 | 14 | ```dart 15 | var router = Router( 16 | initialLocation: '/', 17 | routes: [ 18 | Route( 19 | path: '/', 20 | component: RouteTo('src/Body.phs') // Using standard .phs files. 21 | // You must add "import '.routes.dart';" to use this function. 22 | ), 23 | Route( 24 | path: '/files', 25 | component: MyComponent(); // Importing/Using custom components 26 | ) 27 | ] 28 | ) 29 | ``` 30 | 31 | TODO: Complete Documentation -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # https://dart.dev/guides/libraries/private-files 2 | # Created by `dart pub` 3 | .dart_tool/ 4 | 5 | pubspec.lock 6 | 7 | build/ 8 | 9 | doc/ 10 | 11 | # Mac 12 | .DS_Store 13 | 14 | # Generated dart files 15 | *.phs.dart 16 | 17 | # Avoid committing generated Javascript files: 18 | *.dart.js 19 | *.info.json # Produced by the --dump-info flag. 20 | *.js # When generated by dart2js. Don't specify *.js if your 21 | # project includes source files written in JavaScript. 22 | *.js_ 23 | *.js.deps 24 | *.js.map 25 | -------------------------------------------------------------------------------- /example/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 1.0.0 2 | 3 | - Initial version. 4 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # Example Code for Pheasant 2 | 3 | Here is an example project that makes use of the pheasant framework in order to run. 4 | 5 | In order to run this code, you can use the following command: 6 | ```bash 7 | pheasant run 8 | ``` 9 | 10 | And the app will run on your system. (Safari is not advised for development servers). -------------------------------------------------------------------------------- /example/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the static analysis results for your project (errors, 2 | # warnings, and lints). 3 | # 4 | # This enables the 'recommended' set of lints from `package:lints`. 5 | # This set helps identify many issues that may lead to problems when running 6 | # or consuming Dart code, and enforces writing Dart using a single, idiomatic 7 | # style and format. 8 | # 9 | # If you want a smaller set of lints you can change this to specify 10 | # 'package:lints/core.yaml'. These are just the most critical lints 11 | # (the recommended set includes the core lints). 12 | # The core lints are also what is used by pub.dev for scoring packages. 13 | 14 | include: package:lints/recommended.yaml 15 | 16 | # Uncomment the following section to specify additional rules. 17 | 18 | # linter: 19 | # rules: 20 | # uri_does_not_exist: false 21 | # undefined_identifier: false 22 | 23 | analyzer: 24 | exclude: [build/**] 25 | errors: 26 | uri_has_not_been_generated: ignore 27 | 28 | # For more information about the core and recommended set of lints, see 29 | # https://dart.dev/go/core-lints 30 | 31 | # For additional information about configuring this file, see 32 | # https://dart.dev/guides/language/analysis-options 33 | -------------------------------------------------------------------------------- /example/build.yaml: -------------------------------------------------------------------------------- 1 | targets: 2 | $default: 3 | builders: 4 | phse|pheasantMainBuilder: 5 | options: 6 | entry: lib/App.phs 7 | phse|pheasantFileBuilder: 8 | options: 9 | entry: lib/App.phs 10 | sass: true 11 | phsComponents: true 12 | builders: 13 | pheasantMainBuilder: 14 | import: package:pheasant_build/src/build/builder.dart 15 | builder_factories: 16 | - pheasantMainBuilder 17 | build_extensions: 18 | $package$: 19 | - lib/main.phs.dart 20 | build_to: cache 21 | auto_apply: root_package 22 | pheasantFileBuilder: 23 | import: package:pheasant_build/src/build/builder.dart 24 | builder_factories: 25 | - pheasantFileBuilder 26 | build_extensions: 27 | .phs: 28 | - .phs.dart 29 | build_to: cache 30 | auto_apply: root_package -------------------------------------------------------------------------------- /example/lib/App.phs: -------------------------------------------------------------------------------- 1 | 6 | 7 | 29 | 30 | -------------------------------------------------------------------------------- /example/lib/App.scss: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;1,300&family=Roboto+Mono:wght@200&display=swap'); 2 | 3 | $font: 'Lato'; 4 | $monoFont: 'Roboto Mono'; 5 | $primary-color: red; 6 | 7 | .foo { 8 | color: rgb(245, 193, 66); 9 | align-content: flex-start; 10 | font-family: $font, sans-serif; 11 | 12 | a { 13 | color: #d9d9d9; 14 | font-style: italic; 15 | font-weight: 300; 16 | } 17 | 18 | p { 19 | font-weight: 100; 20 | } 21 | 22 | code { 23 | font-family: $monoFont, monospace; 24 | } 25 | } 26 | 27 | div { 28 | align-items: flex-start; 29 | text-align: left; 30 | align-self: start; 31 | } -------------------------------------------------------------------------------- /example/lib/components/Component.phs: -------------------------------------------------------------------------------- 1 | 9 | 10 | 19 | 20 | -------------------------------------------------------------------------------- /example/lib/components/component.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | int get code => 1; 10 | -------------------------------------------------------------------------------- /example/lib/components/styles.css: -------------------------------------------------------------------------------- 1 | #like { 2 | color: aquamarine; 3 | } -------------------------------------------------------------------------------- /example/pheasant.yaml: -------------------------------------------------------------------------------- 1 | project: example 2 | version: 1.0.0 3 | env: dart 4 | entry: 5 | main: web/main.dart 6 | app: lib/App.phs 7 | config: 8 | sass: true 9 | js: true 10 | linter: true 11 | formatter: true 12 | phsComponents: true 13 | plugins: [] 14 | dependencies: [] 15 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: phse 2 | description: A web app made with Pheasant. 3 | version: 1.0.0 4 | 5 | environment: 6 | sdk: ^3.2.3 7 | 8 | dependencies: 9 | pheasant: any 10 | 11 | dev_dependencies: 12 | build_runner: ^2.4.0 13 | build_web_compilers: ^4.0.0 14 | lints: ^2.1.0 15 | -------------------------------------------------------------------------------- /example/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | phse 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /example/web/main.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | // https://mit-license.org 9 | 10 | import 'package:pheasant/pheasant.dart'; 11 | 12 | // File will be generated. 13 | import 'package:phse/main.phs.dart'; 14 | 15 | void main() { 16 | createApp(App); 17 | } 18 | -------------------------------------------------------------------------------- /example/web/styles.css: -------------------------------------------------------------------------------- 1 | @import url(https://fonts.googleapis.com/css?family=Roboto); 2 | 3 | html, body { 4 | width: 100%; 5 | height: 100%; 6 | margin: 0; 7 | padding: 0; 8 | font-family: 'Roboto', sans-serif; 9 | background-color: #9d9d9d; 10 | } 11 | 12 | #output { 13 | padding: 20px; 14 | text-align: center; 15 | } 16 | -------------------------------------------------------------------------------- /modules/README.md: -------------------------------------------------------------------------------- 1 | # Pheasant Modules 2 | 3 | The packages located here are to be used for interfacing with other tools -------------------------------------------------------------------------------- /mono_repo.yaml: -------------------------------------------------------------------------------- 1 | github: 2 | dependabot: 3 | updates: 4 | - package-ecosystem: "github-actions" 5 | directory: "/" 6 | schedule: 7 | interval: "monthly" 8 | 9 | self_validate: analyze 10 | 11 | coverage_service: 12 | 13 | - coveralls -------------------------------------------------------------------------------- /packages/pheasant/.github/workflows/dart.yml: -------------------------------------------------------------------------------- 1 | # This workflow uses actions that are not certified by GitHub. 2 | # They are provided by a third-party and are governed by 3 | # separate terms of service, privacy policy, and support 4 | # documentation. 5 | 6 | name: Dart 7 | 8 | on: 9 | push: 10 | branches: [ "main" ] 11 | pull_request: 12 | branches: [ "main" ] 13 | workflow_dispatch: 14 | inputs: 15 | logLevel: 16 | description: 'Log level' 17 | required: true 18 | default: 'warning' 19 | type: choice 20 | options: 21 | - info 22 | - warning 23 | - debug 24 | 25 | jobs: 26 | log-the-inputs: 27 | runs-on: ubuntu-latest 28 | steps: 29 | - run: | 30 | echo "Log level: $LEVEL" 31 | env: 32 | LEVEL: ${{ inputs.logLevel }} 33 | build: 34 | runs-on: ubuntu-latest 35 | 36 | steps: 37 | - name: First interaction 38 | uses: actions/first-interaction@v1.3.0 39 | with: 40 | # Token for the repository. Can be passed in using {{ secrets.GITHUB_TOKEN }} 41 | repo-token: ${{ secrets.GITHUB_TOKEN }} 42 | # Comment to post on an individual's first issue 43 | issue-message: Welcome to the Pheasant Metadata Package. This is ${{ github.actor }}'s first issue. 44 | # Comment to post on an individual's first pull request 45 | pr-message: Welcome to the Pheasant Metadata Package. This is ${{ github.actor }}'s first pull request. 46 | 47 | - uses: actions/checkout@v3 48 | 49 | # Note: This workflow uses the latest stable version of the Dart SDK. 50 | # You can specify other versions if desired, see documentation here: 51 | # https://github.com/dart-lang/setup-dart/blob/main/README.md 52 | # - uses: dart-lang/setup-dart@v1 53 | - uses: dart-lang/setup-dart@9a04e6d73cca37bd455e0608d7e5092f881fd603 54 | 55 | - name: Install dependencies 56 | run: dart pub get 57 | 58 | # Uncomment this step to verify the use of 'dart format' on each commit. 59 | - name: Verify formatting 60 | run: dart format --output=none --set-exit-if-changed . 61 | 62 | # Consider passing '--fatal-infos' for slightly stricter analysis. 63 | - name: Analyze project source 64 | run: dart analyze 65 | 66 | # Your project will need to have tests in test/ and a dependency on 67 | # package:test for this step to succeed. Note that Flutter projects will 68 | # want to change this to 'flutter test'. 69 | # - name: Run tests 70 | # run: dart test 71 | -------------------------------------------------------------------------------- /packages/pheasant/.gitignore: -------------------------------------------------------------------------------- 1 | # https://dart.dev/guides/libraries/private-files 2 | # Created by `dart pub` 3 | .dart_tool/ 4 | 5 | # Avoid committing pubspec.lock for library packages; see 6 | # https://dart.dev/guides/libraries/private-files#pubspeclock. 7 | pubspec.lock 8 | 9 | pubspec_overrides.yaml 10 | 11 | doc/api/ 12 | 13 | .DS_Store 14 | 15 | .vscode/ -------------------------------------------------------------------------------- /packages/pheasant/.pubignore: -------------------------------------------------------------------------------- 1 | # https://dart.dev/guides/libraries/private-files 2 | # Created by `dart pub` 3 | .dart_tool/ 4 | 5 | # Avoid committing pubspec.lock for library packages; see 6 | # https://dart.dev/guides/libraries/private-files#pubspeclock. 7 | pubspec.lock 8 | 9 | doc/api/ 10 | 11 | .DS_Store 12 | 13 | .vscode/ 14 | 15 | pubspec_overrides.yaml -------------------------------------------------------------------------------- /packages/pheasant/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.1.0-grade 2 | - Added Support for Routing and App Extensions 3 | - New `PheasantApp` component 4 | 5 | ## 0.1.0-extended 6 | - Added Custom Components API for creating custom components and attributes 7 | 8 | ## 0.1.0-beta.1 9 | - Added state support for deeply nested state 10 | - Fixed GitHub Link 11 | 12 | ## 0.1.0-beta 13 | - Added support for state management and event handling. 14 | - Extended support for Custom Components 15 | - Added support for passing data to child via `@prop` and `@noprop`. 16 | 17 | ## 0.1.0-alpha 18 | - Initial creation of the framework 19 | - Support for basic features in `.phs` files 20 | - Ability to import `.phs` component files and render -------------------------------------------------------------------------------- /packages/pheasant/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [2023] [The Pheasant Group] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /packages/pheasant/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the static analysis results for your project (errors, 2 | # warnings, and lints). 3 | # 4 | # This enables the 'recommended' set of lints from `package:lints`. 5 | # This set helps identify many issues that may lead to problems when running 6 | # or consuming Dart code, and enforces writing Dart using a single, idiomatic 7 | # style and format. 8 | # 9 | # If you want a smaller set of lints you can change this to specify 10 | # 'package:lints/core.yaml'. These are just the most critical lints 11 | # (the recommended set includes the core lints). 12 | # The core lints are also what is used by pub.dev for scoring packages. 13 | 14 | include: package:lints/recommended.yaml 15 | 16 | # Uncomment the following section to specify additional rules. 17 | 18 | # linter: 19 | # rules: 20 | # - camel_case_types 21 | 22 | # analyzer: 23 | # exclude: 24 | # - path/to/excluded/files/** 25 | 26 | # For more information about the core and recommended set of lints, see 27 | # https://dart.dev/go/core-lints 28 | 29 | # For additional information about configuring this file, see 30 | # https://dart.dev/guides/language/analysis-options 31 | -------------------------------------------------------------------------------- /packages/pheasant/example/example.md: -------------------------------------------------------------------------------- 1 | # Example 2 | 3 | You can check out the example in the upper repository [here](https://github.com/pheasantframework/pheasant). -------------------------------------------------------------------------------- /packages/pheasant/lib/build.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | // https://mit-license.org 9 | 10 | /// This is the library used in all generated pheasant files, from the compiled dart code generated from the Pheasant Components to the `main.phs.dart` file also. 11 | /// 12 | /// This library only exposes the two functions from the `html` library used in the compiled dart code, and the `PheasantTemplate` class, which represents the backbone for all Pheasant-Compiled File Components 13 | library build; 14 | 15 | export 'package:pheasant_temp/pheasant_build.dart' 16 | show 17 | PheasantTemplate, 18 | TemplateState, 19 | ChangeWatcher, 20 | ElementChangeWatcher, 21 | AppState, 22 | Prop, 23 | prop, 24 | noprop, 25 | navigateTo, 26 | navigateWith, 27 | onBack, 28 | GlobalRoute, 29 | getCurrentRoute, 30 | UnknownPheasantTemplate, 31 | fetchState, 32 | initPage; 33 | export 'package:html/parser.dart' show parse, parseFragment; 34 | -------------------------------------------------------------------------------- /packages/pheasant/lib/custom.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | // https://mit-license.org 9 | 10 | /// The Pheasant Framework Plugins/Custom Components API 11 | /// 12 | /// This is the library for creating and defining custom functionality for your Pheasant Application. 13 | /// With this library, you can make your own plugins for others to use (check [this link](https://github.com/pheasantframework/pheasant/blob/main/docs/custom/introduction.md) for a guided introduction), or add some custom functionality to your application. 14 | /// 15 | /// Currently, the custom API includes support for the following: 16 | /// - Creating your own Custom Components to use in Pheasant Files and Applications via the [PheasantComponent] class. 17 | /// - Extending your Pheasant Application to include custom functionality such as custom routing via the [PheasantBaseApp] and [PheasantApp] classes. 18 | /// 19 | /// In the neartime future, we plan to support some other functionality. 20 | library custom; 21 | 22 | export 'package:pheasant_temp/pheasant_custom.dart' 23 | show PheasantComponent, html; 24 | export 'dart:html'; 25 | export 'package:pheasant_temp/pheasant_build.dart' show TemplateState, State; 26 | export 'package:pheasant_build/pheasant_build.dart' 27 | show PheasantApp, PheasantBaseApp; 28 | -------------------------------------------------------------------------------- /packages/pheasant/lib/pheasant.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | // https://mit-license.org 9 | 10 | /// The library used in all main entrypoints of a pheasant application. 11 | /// 12 | /// The only function exposed by this library is the `createApp` function, used to "create" the application. 13 | /// 14 | /// NOTE: In further versions, there will be more libraries to expose other APIs such as plugin support, custom component supports and custom library support. 15 | library pheasant; 16 | 17 | export 'package:pheasant_build/pheasant_build.dart' show createApp, PheasantApp; 18 | -------------------------------------------------------------------------------- /packages/pheasant/lib/router.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | // https://mit-license.org 9 | 10 | library router; 11 | 12 | export 'package:pheasant_temp/pheasant_build.dart' 13 | show Route, RouteBase, Router, GlobalRoute; 14 | -------------------------------------------------------------------------------- /packages/pheasant/mono_pkg.yaml: -------------------------------------------------------------------------------- 1 | sdk: 2 | - dev 3 | - pubspec 4 | 5 | stages: 6 | - unit_test: 7 | - test -------------------------------------------------------------------------------- /packages/pheasant/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: pheasant 2 | description: >- 3 | The Pheasant Framework is a progressive, fast-reload, modern frontend web framework that allows you to make powerful web applications in Dart. 4 | version: 0.1.0-grade 5 | repository: https://github.com/pheasantframework/pheasant 6 | 7 | environment: 8 | sdk: '>=3.0.0 <4.0.0' 9 | 10 | dependencies: 11 | pheasant_build: ^0.1.0-grade 12 | pheasant_temp: ^0.1.0-grade 13 | html: ^0.15.4 14 | 15 | dev_dependencies: 16 | build_runner: ^2.4.7 17 | build_web_compilers: ^4.0.7 18 | lints: ^4.0.0 19 | test: ^1.24.0 20 | 21 | topics: 22 | - pheasant 23 | - web 24 | - framework -------------------------------------------------------------------------------- /packages/pheasant/test/pheasant_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | // https://mit-license.org 9 | 10 | import 'package:test/test.dart'; 11 | 12 | void main() { 13 | group('A group of tests', () { 14 | setUp(() { 15 | // Additional setup goes here. 16 | }); 17 | 18 | test('First Test', () {}); 19 | }); 20 | } 21 | -------------------------------------------------------------------------------- /packages/pheasant_assets/.github/workflows/dart.yml: -------------------------------------------------------------------------------- 1 | # This workflow uses actions that are not certified by GitHub. 2 | # They are provided by a third-party and are governed by 3 | # separate terms of service, privacy policy, and support 4 | # documentation. 5 | 6 | name: Dart 7 | 8 | on: 9 | push: 10 | branches: [ "main" ] 11 | pull_request: 12 | branches: [ "main" ] 13 | workflow_dispatch: 14 | inputs: 15 | logLevel: 16 | description: 'Log level' 17 | required: true 18 | default: 'warning' 19 | type: choice 20 | options: 21 | - info 22 | - warning 23 | - debug 24 | 25 | jobs: 26 | log-the-inputs: 27 | runs-on: ubuntu-latest 28 | steps: 29 | - run: | 30 | echo "Log level: $LEVEL" 31 | env: 32 | LEVEL: ${{ inputs.logLevel }} 33 | build: 34 | runs-on: ubuntu-latest 35 | 36 | steps: 37 | - name: First interaction 38 | uses: actions/first-interaction@v1.3.0 39 | with: 40 | # Token for the repository. Can be passed in using {{ secrets.GITHUB_TOKEN }} 41 | repo-token: ${{ secrets.GITHUB_TOKEN }} 42 | # Comment to post on an individual's first issue 43 | issue-message: Welcome to the Pheasant Metadata Package. This is ${{ github.actor }}'s first issue. 44 | # Comment to post on an individual's first pull request 45 | pr-message: Welcome to the Pheasant Metadata Package. This is ${{ github.actor }}'s first pull request. 46 | 47 | - uses: actions/checkout@v3 48 | 49 | # Note: This workflow uses the latest stable version of the Dart SDK. 50 | # You can specify other versions if desired, see documentation here: 51 | # https://github.com/dart-lang/setup-dart/blob/main/README.md 52 | # - uses: dart-lang/setup-dart@v1 53 | - uses: dart-lang/setup-dart@9a04e6d73cca37bd455e0608d7e5092f881fd603 54 | 55 | - name: Install dependencies 56 | run: dart pub get 57 | 58 | # Uncomment this step to verify the use of 'dart format' on each commit. 59 | - name: Verify formatting 60 | run: dart format --output=none --set-exit-if-changed . 61 | 62 | # Consider passing '--fatal-infos' for slightly stricter analysis. 63 | - name: Analyze project source 64 | run: dart analyze 65 | 66 | # Your project will need to have tests in test/ and a dependency on 67 | # package:test for this step to succeed. Note that Flutter projects will 68 | # want to change this to 'flutter test'. 69 | # - name: Run tests 70 | # run: dart test 71 | -------------------------------------------------------------------------------- /packages/pheasant_assets/.gitignore: -------------------------------------------------------------------------------- 1 | # https://dart.dev/guides/libraries/private-files 2 | # Created by `dart pub` 3 | .dart_tool/ 4 | 5 | # Avoid committing pubspec.lock for library packages; see 6 | # https://dart.dev/guides/libraries/private-files#pubspeclock. 7 | pubspec.lock 8 | 9 | # Mac 10 | .DS_Store 11 | 12 | # Directory created by dartdoc 13 | # If you don't generate documentation locally you can remove this line. 14 | doc/api/ -------------------------------------------------------------------------------- /packages/pheasant_assets/.pubignore: -------------------------------------------------------------------------------- 1 | # https://dart.dev/guides/libraries/private-files 2 | # Created by `dart pub` 3 | .dart_tool/ 4 | 5 | # Avoid committing pubspec.lock for library packages; see 6 | # https://dart.dev/guides/libraries/private-files#pubspeclock. 7 | pubspec.lock 8 | 9 | # Mac 10 | .DS_Store 11 | 12 | # Directory created by dartdoc 13 | # If you don't generate documentation locally you can remove this line. 14 | doc/api/ 15 | 16 | pubspec_overrides.yaml -------------------------------------------------------------------------------- /packages/pheasant_assets/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.1.0-tested 2 | - Incorporated Tests 3 | 4 | 5 | ## 0.1.0-beta 6 | - Added `sassEnabled` parameter to functions to allow configs from sibling packages 7 | 8 | ## 0.1.0-alpha 9 | - Initial version. 10 | -------------------------------------------------------------------------------- /packages/pheasant_assets/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | ## Overview 4 | 5 | As contributors and maintainers of The Pheasant Framework Metadata Package project, we pledge to create a respectful and inclusive environment for everyone involved. We value the participation of each member and want to ensure a positive experience for all. 6 | 7 | ## Expected Behavior 8 | 9 | All contributors are expected to exhibit the following behaviors: 10 | 11 | - Be respectful and considerate towards others. 12 | - Avoid any form of harassment, discrimination, or offensive language. 13 | - Be open to constructive criticism and willing to learn from others. 14 | - Focus on the technical aspects of discussions and contributions. 15 | 16 | ## Unacceptable Behavior 17 | 18 | The following behaviors are considered unacceptable and will not be tolerated: 19 | 20 | - Harassment, discrimination, or any form of offensive behavior. 21 | - Intimidation or unwelcome attention. 22 | - Any form of trolling, insulting, or derogatory comments. 23 | - Advocating for or encouraging any of the above behaviors. 24 | 25 | ## Reporting Violations 26 | 27 | If you witness or experience any behavior that violates this code of conduct, please report it to the project maintainers at [maintainer's email]. All reports will be kept confidential. 28 | 29 | ## Enforcement 30 | 31 | Violations of the code of conduct may result in appropriate actions, including but not limited to: 32 | 33 | - Warning the individual responsible for the violation. 34 | - Temporary or permanent exclusion from the project. 35 | 36 | Project maintainers have the right and responsibility to remove, edit, or reject comments, code, issues, and other contributions that do not align with this code of conduct. 37 | 38 | ## Attribution 39 | 40 | This code of conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 41 | 42 | For any questions or clarifications regarding this code of conduct, please contact [this email](raven@tech.nugegroup.com). 43 | 44 | Thank you for your cooperation and commitment to fostering a positive and inclusive community for The Pheasant Framework Metadata Package. 45 | -------------------------------------------------------------------------------- /packages/pheasant_assets/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [2023] [The Pheasant Group] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /packages/pheasant_assets/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the static analysis results for your project (errors, 2 | # warnings, and lints). 3 | # 4 | # This enables the 'recommended' set of lints from `package:lints`. 5 | # This set helps identify many issues that may lead to problems when running 6 | # or consuming Dart code, and enforces writing Dart using a single, idiomatic 7 | # style and format. 8 | # 9 | # If you want a smaller set of lints you can change this to specify 10 | # 'package:lints/core.yaml'. These are just the most critical lints 11 | # (the recommended set includes the core lints). 12 | # The core lints are also what is used by pub.dev for scoring packages. 13 | 14 | include: package:lints/recommended.yaml 15 | 16 | # Uncomment the following section to specify additional rules. 17 | 18 | # linter: 19 | # rules: 20 | # - camel_case_types 21 | 22 | # analyzer: 23 | # exclude: 24 | # - path/to/excluded/files/** 25 | 26 | # For more information about the core and recommended set of lints, see 27 | # https://dart.dev/go/core-lints 28 | 29 | # For additional information about configuring this file, see 30 | # https://dart.dev/guides/language/analysis-options 31 | -------------------------------------------------------------------------------- /packages/pheasant_assets/example/README.md: -------------------------------------------------------------------------------- 1 | # Example 2 | 3 | The Examples are located in the `lib` directory of this directory. It consist of two examples: one to represent css compilation - [css.dart](lib/css.dart), and another to represent scss compilation - [scss.dart](lib/scss.dart). 4 | -------------------------------------------------------------------------------- /packages/pheasant_assets/example/lib/css.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | // https://mit-license.org 9 | 10 | 11 | import 'package:pheasant_assets/pheasant_assets.dart'; 12 | 13 | void main() { 14 | PheasantStyle myStyle = getStyleInput(''); 15 | PheasantStyleScoped scopedStyle = scopeComponents(myStyle, isDev: true); 16 | print("CSS Data: ${scopedStyle.css}"); 17 | print("CSS Scoping ID: ${scopedStyle.id}"); 18 | } 19 | -------------------------------------------------------------------------------- /packages/pheasant_assets/example/lib/pae_css.dart: -------------------------------------------------------------------------------- 1 | import 'package:pheasant_assets/pheasant_assets.dart'; 2 | 3 | void main() { 4 | PheasantStyle myStyle = getStyleInput(''); 5 | PheasantStyleScoped scopedStyle = scopeComponents(myStyle, isDev: true); 6 | print("CSS Data: ${scopedStyle.css}"); 7 | print("CSS Scoping ID: ${scopedStyle.id}"); 8 | } 9 | -------------------------------------------------------------------------------- /packages/pheasant_assets/example/lib/pae_scss.dart: -------------------------------------------------------------------------------- 1 | // ignore: unused_import 2 | import 'package:pheasant_assets/pheasant_assets.dart'; 3 | 4 | void main() { 5 | String scssString = ''' 6 | 58 | '''; 59 | PheasantStyle pheasantStyle = getStyleInput(scssString); 60 | PheasantStyleScoped scopedPheasantStyle = scopeComponents(pheasantStyle); 61 | 62 | print('Style Syntax: ${scopedPheasantStyle.syntax}'); 63 | print('Style General Class ID: ${scopedPheasantStyle.id}'); 64 | } 65 | -------------------------------------------------------------------------------- /packages/pheasant_assets/example/lib/scss.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | // https://mit-license.org 9 | 10 | 11 | // ignore: unused_import 12 | import 'package:pheasant_assets/pheasant_assets.dart'; 13 | 14 | void main() { 15 | String scssString = ''' 16 | 68 | '''; 69 | PheasantStyle pheasantStyle = getStyleInput(scssString); 70 | PheasantStyleScoped scopedPheasantStyle = scopeComponents(pheasantStyle); 71 | 72 | print('Style Syntax: ${scopedPheasantStyle.syntax}'); 73 | print('Style General Class ID: ${scopedPheasantStyle.id}'); 74 | } 75 | -------------------------------------------------------------------------------- /packages/pheasant_assets/example/lib/styles.css: -------------------------------------------------------------------------------- 1 | /* Reset some default styles */ 2 | body, h1, p { 3 | margin: 0; 4 | padding: 0; 5 | } 6 | 7 | /* Set a background color for the body */ 8 | body { 9 | background-color: #f0f0f0; 10 | font-family: Arial, sans-serif; 11 | } 12 | 13 | /* Style the header */ 14 | header { 15 | background-color: #333; 16 | color: #fff; 17 | padding: 10px; 18 | text-align: center; 19 | } 20 | 21 | /* Style the main content */ 22 | main { 23 | max-width: 800px; 24 | margin: 20px auto; 25 | padding: 20px; 26 | background-color: #fff; 27 | box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); 28 | } 29 | 30 | /* Style links */ 31 | a { 32 | color: #007bff; 33 | text-decoration: none; 34 | } 35 | 36 | a:hover { 37 | text-decoration: underline; 38 | } 39 | 40 | /* Style the footer */ 41 | footer { 42 | text-align: center; 43 | padding: 10px; 44 | background-color: #333; 45 | color: #fff; 46 | } 47 | 48 | /* Responsive design - adjust the layout for smaller screens */ 49 | @media (max-width: 600px) { 50 | main { 51 | padding: 10px; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /packages/pheasant_assets/lib/pheasant_assets.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | /// The major and general library containing all functionality to parse, scope and process css/sass in a Pheasant Component 11 | /// 12 | /// This library helps with the parsing, analyzing, rendering and scoping of styles located in the `styles` part of a pheasant file. 13 | /// 14 | /// The library includes support for not only css, but also for scss and sass. 15 | /// If you want to use a different preprocessor, you may want to look at the npm version of this project. Check it out for how you can add support for other css preprocessors. 16 | /// 17 | /// Support for sass and scss is built in (you won't need to configure support for it). 18 | /// 19 | /// Every `style` component has three options - `syntax`, `src` (if the data is in a separate file) and then the scope: `global` or `local`. 20 | /// 21 | /// All styles are first parsed an analayzed as [PheasantStyle] objects, then scoped and rendered as [PheasantStyleScoped] objects 22 | library pheasant_assets; 23 | 24 | export 'src/assets.dart'; 25 | export 'src/compile/compile.dart'; 26 | export 'src/compile/scope.dart'; 27 | export 'src/compile/parse.dart'; 28 | export 'src/exceptions/errors.dart'; 29 | export 'src/exceptions/exceptions.dart'; 30 | -------------------------------------------------------------------------------- /packages/pheasant_assets/lib/pheasant_build.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | /// Minified version of the general `pheasant_assets` library for use during build. 11 | /// 12 | /// This library is usually used in the `pheasant_build` package, but you can use it for simple and quick encapsulation of asset processing code. 13 | /// 14 | /// This library gives the functionality needed to run the pheasant web app on the web without importing VM functionality, which could prevent the app from not running. 15 | library pheasant_assets_build; 16 | 17 | export 'src/assets.dart'; 18 | export 'src/compile/parse.dart'; 19 | -------------------------------------------------------------------------------- /packages/pheasant_assets/lib/src/compile/parse.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | import '../assets.dart' hide PheasantStyleScoped; 11 | import '../exceptions/exceptions.dart'; 12 | 13 | /// Code to extract a [PheasantStyle] from a `style` component in a pheasant file. 14 | /// 15 | /// The function extracts relevant information about the component using the [RegExp]. 16 | /// The data from the opening tag and the internal data is then processed and then used to create a new [PheasantStyle] object. 17 | /// 18 | /// If [sassEnabled] is set to true, then the `syntax` of the [PheasantStyle] can be adjusted. Else, the `syntax` is set to `"css"` despite what may have been denoted in the style tag. 19 | /// By default, [sassEnabled] is set to `true`. 20 | PheasantStyle getStyleInput(String style, {bool sassEnabled = true}) { 21 | RegExp regex = RegExp( 22 | r'', // Match the closing angle bracket '>' 27 | ); 28 | if (!style.contains(regex)) { 29 | throw PheasantStyleException( 30 | "There seems to be an error in the source parsed. There's no ")) { 33 | throw PheasantStyleException( 34 | "There seems to be an error in the source parsed. There's no ', '').trim(); 40 | return sassEnabled 41 | ? PheasantStyle.sassEnabled( 42 | syntax: mainMatch[2] ?? 'css', 43 | src: mainMatch[1], 44 | data: data.isEmpty ? null : data, 45 | scope: 46 | mainMatch[3] == 'global' ? StyleScope.global : StyleScope.local) 47 | : PheasantStyle( 48 | src: mainMatch[1], 49 | data: data.isEmpty ? null : data, 50 | scope: 51 | mainMatch[3] == 'global' ? StyleScope.global : StyleScope.local); 52 | } 53 | -------------------------------------------------------------------------------- /packages/pheasant_assets/lib/src/constants/syntax.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | /// List of valid css syntaxes to use. Can be modified in the case that Pheasant is running on npm. 11 | List syntax = ['css', 'sass', 'scss']; 12 | -------------------------------------------------------------------------------- /packages/pheasant_assets/lib/src/css/extract.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | import '../assets.dart' show PheasantStyle; 11 | import '../compile/compile.dart'; 12 | import '../exceptions/exceptions.dart'; 13 | 14 | /// Function used to extract and compile css. 15 | /// It gets the required parameters needed for specific compilation from the [PheasantStyle] object, and uses it to compile the css. 16 | /// 17 | /// Throws a [PheasantStyleException] if exception occurs (if `data` and `src` are both null). 18 | String css(PheasantStyle pheasantStyle, 19 | {bool dev = false, String appPath = 'lib', bool sassEnabled = false}) { 20 | String styleData = pheasantStyle.data ?? ""; 21 | if (pheasantStyle.data == null) { 22 | if (pheasantStyle.src == null) { 23 | return ''; 24 | } else { 25 | styleData = compileSassFile(pheasantStyle, pheasantStyle.src!, 26 | devDirPath: dev ? 'example' : null, 27 | componentDirPath: appPath, 28 | sassEnabled: sassEnabled); 29 | return styleData; 30 | } 31 | } 32 | return compileCss(pheasantStyle, styleData, sassEnabled: sassEnabled); 33 | } 34 | -------------------------------------------------------------------------------- /packages/pheasant_assets/lib/src/css/id_scope.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | import '../assets.dart' hide StyleScope; 11 | 12 | /// Small function to help in the creation of ids used to identify and scope component styles in a pheasant component. 13 | /// 14 | /// This function is used in the conversion of styles from [PheasantStyle] to [PheasantStyleScoped]. 15 | /// 16 | /// The id produced is unique to each component. 17 | String makeId(PheasantStyle pheasantStyle) { 18 | String pheasantPrefix = "phs-"; 19 | String specialid = ".$pheasantPrefix${pheasantStyle.hashCode}"; 20 | return specialid; 21 | } 22 | -------------------------------------------------------------------------------- /packages/pheasant_assets/lib/src/exceptions/errors.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | import 'package:pheasant_meta/pheasant_meta.dart' show PheasantError; 11 | 12 | /// Pheasant Style Implementation of [PheasantError] 13 | class PheasantStyleError extends PheasantError {} 14 | -------------------------------------------------------------------------------- /packages/pheasant_assets/lib/src/exceptions/exceptions.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | import 'package:pheasant_meta/pheasant_meta.dart' show PheasantException; 11 | 12 | /// Pheasant Style Implementation of [PheasantException] for use in this package 13 | /// When build runs, and an exception occurs, the [message] is printed out to the build cli, as seen in the [toString] override. 14 | class PheasantStyleException extends PheasantException { 15 | /// Default Constructor 16 | PheasantStyleException(super.message); 17 | 18 | /// Prints out the error message 19 | @override 20 | String toString() { 21 | return "Pheasant Style Exception: $message"; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /packages/pheasant_assets/lib/src/sass/logger.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | import 'package:sass/sass.dart' as sass show Logger; 11 | 12 | /// Generic logger 13 | const sassLogger = sass.Logger.stderr(color: true); 14 | -------------------------------------------------------------------------------- /packages/pheasant_assets/mono_pkg.yaml: -------------------------------------------------------------------------------- 1 | sdk: 2 | - dev 3 | - pubspec 4 | 5 | stages: 6 | - analyze: 7 | - analyze 8 | - format 9 | - unit_test: 10 | - test 11 | - cron: 12 | - test: 13 | os: 14 | - linux 15 | - windows 16 | -------------------------------------------------------------------------------- /packages/pheasant_assets/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: pheasant_assets 2 | description: >- 3 | Package for rendering styles and other external assets from the Pheasant Framework for Component Files. 4 | version: 0.1.0-tested 5 | repository: https://github.com/pheasantframework/pheasant/tree/main/pheasant_assets 6 | 7 | environment: 8 | sdk: '>=3.0.0 <4.0.0' 9 | # Add regular dependencies here. 10 | dependencies: 11 | csslib: ^1.0.0 12 | sass: ^1.69.7 13 | pheasant_meta: ^0.1.0-alpha 14 | path: ^1.8.0 15 | 16 | dev_dependencies: 17 | lints: ^4.0.0 18 | test: ^1.24.0 19 | 20 | -------------------------------------------------------------------------------- /packages/pheasant_assets/test/src/main.css: -------------------------------------------------------------------------------- 1 | /* Random CSS styles */ 2 | body { 3 | font-family: Arial, sans-serif; 4 | background-color: #f0f0f0; 5 | } 6 | 7 | .container { 8 | max-width: 960px; 9 | margin: 0 auto; 10 | } 11 | 12 | .button { 13 | display: inline-block; 14 | padding: 10px 20px; 15 | background-color: #3498db; 16 | color: #fff; 17 | border: none; 18 | border-radius: 5px; 19 | cursor: pointer; 20 | } 21 | 22 | .button:hover { 23 | background-color: #2980b9; 24 | } 25 | -------------------------------------------------------------------------------- /packages/pheasant_assets/test/src/main.scss: -------------------------------------------------------------------------------- 1 | // Random SCSS styles 2 | $primary-color: #ff6347; 3 | $secondary-color: #2ecc71; 4 | 5 | body { 6 | font-family: "Open Sans", sans-serif; 7 | background-color: #f5f5f5; 8 | } 9 | 10 | .container { 11 | max-width: 1200px; 12 | margin: 0 auto; 13 | } 14 | 15 | .button { 16 | display: inline-block; 17 | padding: 10px 20px; 18 | background-color: $primary-color; 19 | color: #fff; 20 | border: none; 21 | border-radius: 5px; 22 | cursor: pointer; 23 | 24 | &:hover { 25 | background-color: darken($primary-color, 10%); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /packages/pheasant_assets/test/src/styles.sass: -------------------------------------------------------------------------------- 1 | // Random SASS styles 2 | $primary-color: #9b59b6 3 | $secondary-color: #1abc9c 4 | 5 | body 6 | font-family: "Roboto", sans-serif 7 | background-color: #ecf0f1 8 | 9 | .container 10 | max-width: 1400px 11 | margin: 0 auto 12 | 13 | .button 14 | display: inline-block 15 | padding: 10px 20px 16 | background-color: $primary-color 17 | color: #fff 18 | border: none 19 | border-radius: 5px 20 | cursor: pointer 21 | 22 | &:hover 23 | background-color: darken($primary-color, 10%) 24 | -------------------------------------------------------------------------------- /packages/pheasant_build/.gitignore: -------------------------------------------------------------------------------- 1 | # https://dart.dev/guides/libraries/private-files 2 | # Created by `dart pub` 3 | .dart_tool/ 4 | 5 | # Avoid committing pubspec.lock for library packages; see 6 | # https://dart.dev/guides/libraries/private-files#pubspeclock. 7 | pubspec.lock 8 | 9 | pubspec_overrides.yaml 10 | 11 | # Mac 12 | .DS_Store 13 | 14 | # Directory created by dartdoc 15 | # If you don't generate documentation locally you can remove this line. 16 | doc/api/ 17 | 18 | # Avoid committing generated Javascript files: 19 | *.dart.js 20 | *.info.json # Produced by the --dump-info flag. 21 | *.js # When generated by dart2js. Don't specify *.js if your 22 | # project includes source files written in JavaScript. 23 | *.js_ 24 | *.js.deps 25 | *.js.map 26 | pubspec_overrides.yaml 27 | -------------------------------------------------------------------------------- /packages/pheasant_build/.pubignore: -------------------------------------------------------------------------------- 1 | # https://dart.dev/guides/libraries/private-files 2 | # Created by `dart pub` 3 | .dart_tool/ 4 | 5 | # Avoid committing pubspec.lock for library packages; see 6 | # https://dart.dev/guides/libraries/private-files#pubspeclock. 7 | pubspec.lock 8 | 9 | # Mac 10 | .DS_Store 11 | 12 | pubspec_overrides.yaml 13 | 14 | # Directory created by dartdoc 15 | # If you don't generate documentation locally you can remove this line. 16 | doc/api/ 17 | 18 | # Avoid committing generated Javascript files: 19 | *.dart.js 20 | *.info.json # Produced by the --dump-info flag. 21 | *.js # When generated by dart2js. Don't specify *.js if your 22 | # project includes source files written in JavaScript. 23 | *.js_ 24 | *.js.deps 25 | *.js.map -------------------------------------------------------------------------------- /packages/pheasant_build/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.1.0-tested.1 2 | - Minor error in code imports 3 | 4 | ## 0.1.0-tested 5 | - Added tests 6 | 7 | ## 0.1.0-grade 8 | - Added Support for Routing 9 | - Build Source Generator for Routing `.phs` files 10 | 11 | ## 0.1.0-dev.2 12 | - Made fix on parsing function to allow undefined but arranged tags. 13 | 14 | ## 0.1.0-dev.1 15 | - Made `renderElement` private 16 | - Added state support 17 | 18 | ## 0.1.0-dev 19 | - Added Configuration support for JavaScript and SASS 20 | 21 | ## 0.1.0-beta 22 | 23 | - Reconstructed the two app rendering functions to allow for state management 24 | - Completed support for cli configuration 25 | 26 | ## 0.1.0-alpha 27 | 28 | - Initial version. 29 | -------------------------------------------------------------------------------- /packages/pheasant_build/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | ## Overview 4 | 5 | As contributors and maintainers of The Pheasant Builder Package, we pledge to create a respectful and inclusive environment for everyone involved. We value the participation of each member and want to ensure a positive experience for all. 6 | 7 | ## Expected Behavior 8 | 9 | All contributors are expected to exhibit the following behaviors: 10 | 11 | - Be respectful and considerate towards others. 12 | - Avoid any form of harassment, discrimination, or offensive language. 13 | - Be open to constructive criticism and willing to learn from others. 14 | - Focus on the technical aspects of discussions and contributions. 15 | 16 | ## Unacceptable Behavior 17 | 18 | The following behaviors are considered unacceptable and will not be tolerated: 19 | 20 | - Harassment, discrimination, or any form of offensive behavior. 21 | - Intimidation or unwelcome attention. 22 | - Any form of trolling, insulting, or derogatory comments. 23 | - Advocating for or encouraging any of the above behaviors. 24 | 25 | ## Reporting Violations 26 | 27 | If you witness or experience any behavior that violates this code of conduct, please report it to the project maintainers at [maintainer's email]. All reports will be kept confidential. 28 | 29 | ## Enforcement 30 | 31 | Violations of the code of conduct may result in appropriate actions, including but not limited to: 32 | 33 | - Warning the individual responsible for the violation. 34 | - Temporary or permanent exclusion from the project. 35 | 36 | Project maintainers have the right and responsibility to remove, edit, or reject comments, code, issues, and other contributions that do not align with this code of conduct. 37 | 38 | ## Attribution 39 | 40 | This code of conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 41 | 42 | For any questions or clarifications regarding this code of conduct, please contact [this email](raven@tech.nugegroup.com). 43 | 44 | Thank you for your cooperation and commitment to fostering a positive and inclusive community for The Pheasant Framework Builder Package. 45 | -------------------------------------------------------------------------------- /packages/pheasant_build/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [2023] [The Pheasant Group] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /packages/pheasant_build/README.md: -------------------------------------------------------------------------------- 1 | #
The Pheasant Framework Build Package
2 | 3 | ![Pub Version](https://img.shields.io/pub/v/pheasant_build?labelColor=rgb(245%2C%20193%2C%2066)&link=https%3A%2F%2Fpub.dev%2Fpackages%2Fpheasant_build) ![Pub Publisher](https://img.shields.io/pub/publisher/pheasant_build?labelColor=rgb(245%2C%20193%2C%2066)&link=https%3A%2F%2Fpub.dev%2Fpackages%2Fpheasant_build) 4 | 5 | 6 | This package contains the build processes used in compiling pheasant files to valid dart code, including core pheasant framework functions like `createApp` used in "creating" the compiled application. It is not intended for direct use by the end user. 7 | 8 | It also contains app configuration capabilities used by the framework's cli `pheasant`. 9 | 10 | ## Getting started 11 | 12 | Get this package by running `dart pub` 13 | ```bash 14 | dart pub add dev:pheasant_build 15 | ``` 16 | 17 | Then you can make use of it directly in your project. 18 | 19 | This package isn't intended for direct use, but encapsulates the build processes used in building the code for a Pheasant Application Project. 20 | -------------------------------------------------------------------------------- /packages/pheasant_build/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the static analysis results for your project (errors, 2 | # warnings, and lints). 3 | # 4 | # This enables the 'recommended' set of lints from `package:lints`. 5 | # This set helps identify many issues that may lead to problems when running 6 | # or consuming Dart code, and enforces writing Dart using a single, idiomatic 7 | # style and format. 8 | # 9 | # If you want a smaller set of lints you can change this to specify 10 | # 'package:lints/core.yaml'. These are just the most critical lints 11 | # (the recommended set includes the core lints). 12 | # The core lints are also what is used by pub.dev for scoring packages. 13 | 14 | include: package:lints/recommended.yaml 15 | 16 | # Uncomment the following section to specify additional rules. 17 | 18 | # linter: 19 | # rules: 20 | # - camel_case_types 21 | 22 | # analyzer: 23 | # exclude: 24 | # - path/to/excluded/files/** 25 | 26 | # For more information about the core and recommended set of lints, see 27 | # https://dart.dev/go/core-lints 28 | 29 | # For additional information about configuring this file, see 30 | # https://dart.dev/guides/language/analysis-options 31 | -------------------------------------------------------------------------------- /packages/pheasant_build/example/example.md: -------------------------------------------------------------------------------- 1 | # Example 2 | An example can be found via the `example` folder found at the top-level of the pheasant framework [github page](https://github.com/pheasantframework/pheasant). -------------------------------------------------------------------------------- /packages/pheasant_build/lib/pheasant_build.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | /// Library for the build process involved in building Pheasant Files. 11 | /// 12 | /// There's not much to this library, except the `createApp` function, used in rendering the app, as a nice-looking api. 13 | library pheasant_build; 14 | 15 | export 'src/src/src.dart'; 16 | -------------------------------------------------------------------------------- /packages/pheasant_build/lib/src/build/builder.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | import 'package:build/build.dart' show Builder, BuilderOptions; 11 | import 'package:path/path.dart' show basenameWithoutExtension; 12 | 13 | import '../tools/config.dart' hide relativeFilePath; 14 | import 'src/pheasant_router_builder.dart' show PheasantRouterBuilder; 15 | import 'src/pheasant_main_builder.dart'; 16 | import 'src/pheasant_file_builder.dart'; 17 | 18 | Builder pheasantRouterBuilder(BuilderOptions builderOptions) => 19 | PheasantRouterBuilder(); 20 | 21 | /// The Pheasant File Builder used to render Pheasant Files during build. 22 | Builder pheasantFileBuilder(BuilderOptions builderOptions) { 23 | AppConfig config = PheasantAppConfig.fromYamlMap(builderOptions.config); 24 | return PheasantFileBuilder( 25 | js: config.js, 26 | sass: config.sass, 27 | ); 28 | } 29 | 30 | /// The Pheasant Builder used to render the `main.phs.dart` file during build. 31 | Builder pheasantMainBuilder(BuilderOptions builderOptions) { 32 | AppConfig config = PheasantAppConfig.fromYamlMap(builderOptions.config); 33 | return PheasantMainBuilder( 34 | mainEntry: config.mainEntry, 35 | appName: '${basenameWithoutExtension(config.appEntryPoint)}Component', 36 | fileExtension: '${config.extension}.dart', 37 | ); 38 | } 39 | -------------------------------------------------------------------------------- /packages/pheasant_build/lib/src/build/src/pheasant_file_builder.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | import 'dart:async' show FutureOr; 11 | 12 | import 'package:build/build.dart' show BuildStep, Builder; 13 | import 'package:path/path.dart' show basenameWithoutExtension, dirname; 14 | import 'package:pheasant_temp/pheasant_temp.dart' show compilePhs; 15 | 16 | import '../../src/base.dart'; 17 | import '../../tools/input.dart' hide PheasantInput; 18 | 19 | /// Builder Class used in building, processing and creating the dart-type Pheasant Files. 20 | /// 21 | /// This class is used in compiling Pheasant Files to dart-html component files to inject into the DOM, through the use of [compilePhs]. 22 | class PheasantFileBuilder extends Builder { 23 | String fileExtension; 24 | bool js; 25 | bool sass; 26 | 27 | PheasantFileBuilder({ 28 | this.fileExtension = '.phs.dart', 29 | this.sass = false, 30 | this.js = false, 31 | }); 32 | 33 | @override 34 | FutureOr build(BuildStep buildStep) async { 35 | var inpId = buildStep.inputId; 36 | var filename = basenameWithoutExtension(inpId.path); 37 | 38 | var data = await buildStep.readAsString(inpId); 39 | 40 | final String pathAtLib = dirname(inpId.path); 41 | var outId = inpId.changeExtension(fileExtension); 42 | 43 | PheasantComposedInput composedInput = 44 | renderInput(phsData: data, sassEnabled: sass); 45 | PheasantFile myIn = composedInput.input; 46 | 47 | final dartCode = compilePhs( 48 | script: myIn.script, 49 | template: myIn.template, 50 | componentName: "${filename}Component", 51 | pheasantStyle: composedInput.style, 52 | appDirPath: pathAtLib, 53 | js: js, 54 | sass: sass); 55 | 56 | await buildStep.writeAsString(outId, dartCode); 57 | } 58 | 59 | @override 60 | Map> get buildExtensions => { 61 | '.phs': [fileExtension] 62 | }; 63 | } 64 | -------------------------------------------------------------------------------- /packages/pheasant_build/lib/src/build/src/pheasant_main_builder.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | import 'dart:async' show FutureOr; 11 | import 'package:build/build.dart' show AssetId, BuildStep, Builder; 12 | import 'package:pheasant_temp/pheasant_temp.dart' show renderMain; 13 | 14 | /// Builder Class used in building the `main.phs.dart` file, used as a bridge between the main entrypoint (`web/main.dart` for instance), and the compiled Pheasant Files (`App.phs.dart` for instance). 15 | class PheasantMainBuilder extends Builder { 16 | String fileExtension; 17 | String appName; 18 | String mainEntry; 19 | String? entrypoint; 20 | 21 | PheasantMainBuilder({ 22 | this.fileExtension = '.phs.dart', 23 | this.appName = 'AppComponent', 24 | this.mainEntry = 'App.phs', 25 | this.entrypoint, 26 | }); 27 | 28 | @override 29 | FutureOr build(BuildStep buildStep) async { 30 | await buildStep.writeAsString( 31 | AssetId( 32 | buildStep.inputId.package, entrypoint ?? 'lib/main$fileExtension'), 33 | renderMain( 34 | appName: appName, 35 | fileExtension: fileExtension, 36 | mainEntry: mainEntry)); 37 | } 38 | 39 | @override 40 | Map> get buildExtensions => { 41 | r'$package$': [entrypoint ?? 'lib/main$fileExtension'] 42 | }; 43 | } 44 | -------------------------------------------------------------------------------- /packages/pheasant_build/lib/src/src/render.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | import 'dart:html' show Element, querySelector; 11 | 12 | import 'package:pheasant_temp/pheasant_build.dart' 13 | show PheasantTemplate, AppState, ElementChangeWatcher; 14 | 15 | /// Function used to encapsulate the injection of the processed [PheasantTemplate] into the DOM 16 | /// 17 | /// This function injects the [PheasantTemplate] into the DOM, and makes use of the [AppState] to watch for changes in the [app]. 18 | /// Whenever a change is emitted, the application is rerendered in the DOM. 19 | /// 20 | /// If [appState] is not provided, then the state is generated in the beginning of the app lifecycle. 21 | void _renderElement(PheasantTemplate app, 22 | {AppState? appState, String? selector}) { 23 | AppState state = appState ?? 24 | AppState(component: app, watchers: List.empty(growable: true)); 25 | PheasantTemplate appObj = app; 26 | Element elementApp = appObj.render(appObj.template!, state); 27 | querySelector(selector ?? '#output')?.children.add(elementApp); 28 | 29 | state.stateStream.listen( 30 | (event) { 31 | elementApp = appObj.render(appObj.template!, state); 32 | querySelector(selector ?? '#output')?.children.first = elementApp; 33 | state.watchers 34 | .whereType() 35 | .forEach((element) => element.reflectChanges()); 36 | }, 37 | ); 38 | } 39 | 40 | /// Function used to create a Pheasant Application 41 | /// 42 | /// The function accepts a pheasant file object - [PheasantTemplate] - and then processes the application. 43 | /// Once it is done, then it is injected into the DOM. 44 | void createApp(PheasantTemplate pheasantTemplate, 45 | {AppState? appState, String? selector}) { 46 | _renderElement(pheasantTemplate, appState: appState); 47 | } 48 | -------------------------------------------------------------------------------- /packages/pheasant_build/lib/src/src/src.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | export 'render.dart'; 11 | export 'app.dart'; 12 | -------------------------------------------------------------------------------- /packages/pheasant_build/lib/src/tools/input.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | import 'package:pheasant_assets/pheasant_build.dart' show PheasantStyle; 11 | 12 | /// Base Class for a Pheasant File. 13 | abstract class PheasantFile { 14 | /// The data from the `script` component of the file 15 | String script; 16 | 17 | /// The data from the `template` component of the file 18 | String template; 19 | 20 | /// The data from the `style` component of the file 21 | String styles; 22 | 23 | PheasantFile( 24 | {required this.script, required this.template, required this.styles}); 25 | } 26 | 27 | /// Class used to accept the main input of a pheasant file during build. 28 | class PheasantInput extends PheasantFile { 29 | PheasantInput( 30 | {required super.script, required super.template, required super.styles}); 31 | } 32 | 33 | /// Class used to extend [PheasantInput] to encapsulate styles too, with the use of [PheasantStyle] 34 | class PheasantComposedInput { 35 | /// The class object used to encapsulate the data from the `template` and `script` components of the file 36 | final PheasantInput input; 37 | 38 | /// The class object used to encapsulate the data from the `style` component of the file 39 | final PheasantStyle style; 40 | 41 | PheasantComposedInput({required this.input, required this.style}); 42 | 43 | @override 44 | String toString() { 45 | return "Template: ${input.template} \nStyle: ${input.styles} \nScript: ${input.script}"; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /packages/pheasant_build/mono_pkg.yaml: -------------------------------------------------------------------------------- 1 | sdk: 2 | - dev 3 | - pubspec 4 | 5 | stages: 6 | - analyze: 7 | - analyze 8 | - format 9 | - unit_test: 10 | - test 11 | - cron: 12 | - test: 13 | os: 14 | - linux 15 | - windows 16 | 17 | -------------------------------------------------------------------------------- /packages/pheasant_build/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: pheasant_build 2 | description: >- 3 | The build package for all pheasant related compilation, as well as pheasant project configuration. 4 | version: 0.1.0-tested.1 5 | repository: https://github.com/pheasantframework/pheasant/tree/main/pheasant_build 6 | 7 | environment: 8 | sdk: '^3.0.0' 9 | 10 | # Add regular dependencies here. 11 | dependencies: 12 | build: ^2.4.1 13 | build_runner: ^2.4.7 14 | build_web_compilers: ^4.0.7 15 | pheasant_temp: ^0.1.0-grade 16 | pheasant_meta: ^0.1.0-beta.1 17 | pheasant_assets: ^0.1.0-beta 18 | path: ^1.9.0 19 | source_gen: ^1.5.0 20 | 21 | dev_dependencies: 22 | build_test: ^2.2.2 23 | lints: ^4.0.0 24 | test: ^1.24.0 25 | 26 | topics: 27 | - pheasant 28 | - web -------------------------------------------------------------------------------- /packages/pheasant_build/test/pheasant_build_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | // https://mit-license.org 9 | 10 | import 'package:build_test/build_test.dart'; 11 | import 'package:pheasant_build/src/build/src/pheasant_file_builder.dart'; 12 | import 'package:test/test.dart'; 13 | 14 | import 'package:pheasant_build/src/build/src/pheasant_router_builder.dart' 15 | show PheasantRouterBuilder; 16 | 17 | void main() { 18 | group('normal builder', () { 19 | test('router builder', () async { 20 | var assets = { 21 | 'a|lib/source.dart': ''' 22 | import 'package:pheasant/router.dart'; 23 | 24 | import 'source.routes.dart' show RouteTo; 25 | 26 | var routes = Router( 27 | initialLocation: '/', 28 | routes: [ 29 | Route( 30 | path: '/', 31 | component: RouteTo('src/App.phs') 32 | ) 33 | ] 34 | ); 35 | ''' 36 | }; 37 | 38 | await testBuilder(PheasantRouterBuilder(), assets, onLog: print); 39 | }); 40 | 41 | test('render file', () async { 42 | var assets = { 43 | 'a|lib/App.phs': ''' 44 | 50 | ''', 51 | 'b|lib/App.phs': ''' 52 | 55 | 56 | 66 | ''' 67 | }; 68 | 69 | await testBuilder( 70 | PheasantFileBuilder(sass: true, js: true), 71 | assets, 72 | onLog: print, 73 | ); 74 | }); 75 | 76 | test('main file', () async { 77 | return null; 78 | }); 79 | 80 | }); 81 | } 82 | -------------------------------------------------------------------------------- /packages/pheasant_cli/.github/workflows/dart.yml: -------------------------------------------------------------------------------- 1 | # This workflow uses actions that are not certified by GitHub. 2 | # They are provided by a third-party and are governed by 3 | # separate terms of service, privacy policy, and support 4 | # documentation. 5 | 6 | name: Dart 7 | 8 | on: 9 | push: 10 | branches: [ "main" ] 11 | pull_request: 12 | branches: [ "main" ] 13 | workflow_dispatch: 14 | inputs: 15 | logLevel: 16 | description: 'Log level' 17 | required: true 18 | default: 'warning' 19 | type: choice 20 | options: 21 | - info 22 | - warning 23 | - debug 24 | 25 | jobs: 26 | log-the-inputs: 27 | runs-on: ubuntu-latest 28 | steps: 29 | - run: | 30 | echo "Log level: $LEVEL" 31 | env: 32 | LEVEL: ${{ inputs.logLevel }} 33 | build: 34 | runs-on: ubuntu-latest 35 | 36 | steps: 37 | - name: First interaction 38 | uses: actions/first-interaction@v1.3.0 39 | with: 40 | # Token for the repository. Can be passed in using {{ secrets.GITHUB_TOKEN }} 41 | repo-token: ${{ secrets.GITHUB_TOKEN }} 42 | # Comment to post on an individual's first issue 43 | issue-message: Welcome to the Pheasant Metadata Package. This is ${{ github.actor }}'s first issue. 44 | # Comment to post on an individual's first pull request 45 | pr-message: Welcome to the Pheasant Metadata Package. This is ${{ github.actor }}'s first pull request. 46 | 47 | - uses: actions/checkout@v3 48 | 49 | # Note: This workflow uses the latest stable version of the Dart SDK. 50 | # You can specify other versions if desired, see documentation here: 51 | # https://github.com/dart-lang/setup-dart/blob/main/README.md 52 | # - uses: dart-lang/setup-dart@v1 53 | - uses: dart-lang/setup-dart@9a04e6d73cca37bd455e0608d7e5092f881fd603 54 | 55 | - name: Install dependencies 56 | run: dart pub get 57 | 58 | # Uncomment this step to verify the use of 'dart format' on each commit. 59 | - name: Verify formatting 60 | run: dart format --output=none --set-exit-if-changed . 61 | 62 | # Consider passing '--fatal-infos' for slightly stricter analysis. 63 | - name: Analyze project source 64 | run: dart analyze 65 | 66 | # Your project will need to have tests in test/ and a dependency on 67 | # package:test for this step to succeed. Note that Flutter projects will 68 | # want to change this to 'flutter test'. 69 | # - name: Run tests 70 | # run: dart test 71 | -------------------------------------------------------------------------------- /packages/pheasant_cli/.gitignore: -------------------------------------------------------------------------------- 1 | # https://dart.dev/guides/libraries/private-files 2 | # Created by `dart pub` 3 | .dart_tool/ 4 | 5 | pubspec.lock 6 | 7 | doc/api/ -------------------------------------------------------------------------------- /packages/pheasant_cli/.pubignore: -------------------------------------------------------------------------------- 1 | # https://dart.dev/guides/libraries/private-files 2 | # Created by `dart pub` 3 | .dart_tool/ 4 | 5 | pubspec.lock 6 | 7 | doc/api/ -------------------------------------------------------------------------------- /packages/pheasant_cli/AUTHORS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pheasantframework/pheasant/c4ea0c0a0a026b97cb1af1ec4327304e1cb8ccd4/packages/pheasant_cli/AUTHORS -------------------------------------------------------------------------------- /packages/pheasant_cli/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.1.0-extended 2 | - Extended Plugin Scaffolding Support. 3 | 4 | ## 0.1.0-beta.1 5 | - Minor `run` fixes 6 | 7 | ## 0.1.0-beta 8 | - Minor bugs 9 | - Worked on `run` command 10 | 11 | ## 0.1.0-alpha.1 12 | - Fixed minor issue with generated build.yaml file 13 | 14 | ## 0.1.0-alpha 15 | 16 | - Initial version. 17 | -------------------------------------------------------------------------------- /packages/pheasant_cli/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [2023] [The Pheasant Group] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /packages/pheasant_cli/README.md: -------------------------------------------------------------------------------- 1 | # The Pheasant Framework CLI 2 | This is the package for the Pheasant Command Line Interface Application. 3 | 4 | > There is current work on a new CLI for serving Pheasant Applications, which can be followed [here](https://github.com/nikeokoronkwo/pcli) 5 | 6 | `pheasant` is a cli tool for creating, testing, running and working on pheasant applications. With this tool, you can quickly get started with creating your pheasant projects with ease. 7 | 8 | ## New to Pheasant? 9 | You can get started with the pheasant framework [here](https://github.com/pheasantframework/pheasant). 10 | 11 | ## Getting Started 12 | ### NOTE 13 | Because of the scope/range of the dart compiler, you may not be able to run development versions of your projects outside Google Chrome. For now, ensure that you have Google Chrome installed on your system, or run your projects in release mode. 14 | 15 | In order to install the cli, all you need to do is run the following command 16 | ```bash 17 | dart pub global activate pheasant_cli 18 | ``` 19 | 20 | Once this command is run, the pheasant cli executable will be installed to your system. From there you can start using the `pheasant` command 21 | 22 | ```bash 23 | pheasant -v 24 | ``` 25 | 26 | ## Useful Commands 27 | ### Create a Project 28 | In order to create a new pheasant project, run the following command and answer the prompts to configure the project (the answers to "`y/N`" questions default to "No"). 29 | ```bash 30 | pheasant init [-d ] 31 | ``` 32 | 33 | You can also use the `create` command in place of the `init` commmand. 34 | 35 | ### Run a Project Server 36 | Run the following command at the root of your project: 37 | ```bash 38 | pheasant run [-p ] 39 | ``` 40 | 41 | You can also use the `serve` command in place of the `run` command, but you may not be able to run release modes of the project with the `serve` command. 42 | 43 | ### Build a Project Server for Deployment 44 | ```bash 45 | pheasant build 46 | ``` 47 | 48 | If you want to check out all the commands this has, you can quickly run `pheasant` or `pheasant --help`. In order to get info on a certain command, run `pheasant help `. 49 | 50 | ## License 51 | This project uses the [MIT License](LICENSE). -------------------------------------------------------------------------------- /packages/pheasant_cli/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the static analysis results for your project (errors, 2 | # warnings, and lints). 3 | # 4 | # This enables the 'recommended' set of lints from `package:lints`. 5 | # This set helps identify many issues that may lead to problems when running 6 | # or consuming Dart code, and enforces writing Dart using a single, idiomatic 7 | # style and format. 8 | # 9 | # If you want a smaller set of lints you can change this to specify 10 | # 'package:lints/core.yaml'. These are just the most critical lints 11 | # (the recommended set includes the core lints). 12 | # The core lints are also what is used by pub.dev for scoring packages. 13 | 14 | include: package:lints/recommended.yaml 15 | 16 | # Uncomment the following section to specify additional rules. 17 | 18 | # linter: 19 | # rules: 20 | # - camel_case_types 21 | 22 | # analyzer: 23 | # exclude: 24 | # - path/to/excluded/files/** 25 | 26 | # For more information about the core and recommended set of lints, see 27 | # https://dart.dev/go/core-lints 28 | 29 | # For additional information about configuring this file, see 30 | # https://dart.dev/guides/language/analysis-options 31 | -------------------------------------------------------------------------------- /packages/pheasant_cli/bin/pheasant.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | // https://mit-license.org 9 | 10 | import 'package:pheasant_cli/src/pheasant_cli.dart'; 11 | 12 | Future main(List arguments) async { 13 | handleArguments(arguments); 14 | } 15 | -------------------------------------------------------------------------------- /packages/pheasant_cli/example/README.md: -------------------------------------------------------------------------------- 1 | # Example 2 | 3 | This is a command-line application, there is no example at the moment. -------------------------------------------------------------------------------- /packages/pheasant_cli/lib/src/commands/build/build_application.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | import 'dart:io'; 10 | 11 | import 'package:args/args.dart'; 12 | import 'package:cli_util/cli_logging.dart'; 13 | import 'package:io/io.dart'; 14 | import 'package:pubspec_parse/pubspec_parse.dart' as pub; 15 | 16 | import '../general/errors.dart'; 17 | import '../general/validate_project.dart'; 18 | import '../../config/config.dart'; 19 | import '../../constants/buildfile.dart'; 20 | 21 | Future buildApplication(Progress progress, Logger logger, 22 | ProcessManager manager, ArgResults results) async { 23 | progress = logger.progress('Cleaning Cache'); 24 | var cacheClean = 25 | await manager.spawnDetached('dart', ['run', 'build_runner', 'clean']); 26 | await errorCheck(cacheClean, logger, progress); 27 | progress.finish(showTiming: true); 28 | progress = logger.progress('Building Code'); 29 | List args = ['build']; 30 | if (results.command!.wasParsed('output')) { 31 | args.addAll(['--output', results.command!['output']]); 32 | } 33 | if (results.command!.wasParsed('release')) args.add('--release'); 34 | var buildProject = await manager.spawnDetached('webdev', args); 35 | await errorCheck(buildProject, logger, progress); 36 | } 37 | 38 | Future checkProjectBeforeBuild( 39 | Logger logger, List configArgs) async { 40 | var progress = logger.progress('Checking Project'); 41 | logger.trace( 42 | 'Verifying code is running in project root, and all files are ready'); 43 | AppConfig appConfig = await validateProject(logger, configArgs); 44 | logger.trace('Checking "build.yaml" file'); 45 | bool buildFileExists = await File('build.yaml').exists(); 46 | if (!buildFileExists) { 47 | File buildFile = await File('build.yaml').create(); 48 | final data = pub.Pubspec.parse(File('pubspec.yaml').readAsStringSync()); 49 | buildFile = await buildFile 50 | .writeAsString(genBuildFile(appConfig, projNameFromPubspec: data.name)); 51 | } 52 | progress.finish(showTiming: true); 53 | return progress; 54 | } 55 | -------------------------------------------------------------------------------- /packages/pheasant_cli/lib/src/commands/doctor/sdksearch.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | import 'package:cli_util/cli_logging.dart'; 10 | import 'package:cli_util/cli_util.dart'; 11 | import 'package:io/ansi.dart'; 12 | 13 | Future findSdk(Logger logger) async { 14 | var dartProgress = 15 | logger.progress(styleBold.wrap('Searching for the Dart SDK')!); 16 | await Future.delayed(Duration(milliseconds: 500)); 17 | logger.trace('Searching for SDK'); 18 | var sdkPath = getSdkPath(); 19 | logger.trace('Dart SDK Found at $sdkPath'); 20 | dartProgress.finish(showTiming: true); 21 | } 22 | -------------------------------------------------------------------------------- /packages/pheasant_cli/lib/src/commands/general/configfile.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | // ignore_for_file: constant_identifier_names 10 | 11 | import 'dart:async'; 12 | import 'dart:io'; 13 | import 'package:io/ansi.dart'; 14 | import 'package:pheasant_cli/src/config/config.dart'; 15 | import 'package:yaml_edit/yaml_edit.dart'; 16 | 17 | Future writeConfigToFile(AppConfig appConfig) async { 18 | Map yamlMap = appConfig.toMap(); 19 | final yamlEditor = YamlEditor(''); 20 | yamlEditor.update([], yamlMap); 21 | bool exist = File('./pheasant.yaml').existsSync(); 22 | if (!exist) { 23 | stderr.writeln(red.wrap( 24 | "\nError: ${wrapWith("The 'pheasant.yaml' file doesn't exist", [ 25 | white, 26 | styleBold 27 | ])}")); 28 | exit(2); 29 | } 30 | await File('./pheasant.yaml').writeAsString(yamlEditor.toString()); 31 | } 32 | -------------------------------------------------------------------------------- /packages/pheasant_cli/lib/src/commands/general/errors.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | import 'dart:convert'; 10 | import 'dart:io'; 11 | import 'package:cli_util/cli_logging.dart'; 12 | import 'package:io/ansi.dart'; 13 | 14 | Future errorCheck( 15 | Process spawn, Logger logger, Progress? genProgress) async { 16 | var exitCode = await spawn.exitCode; 17 | if (exitCode != 0) { 18 | logger.trace(red.wrap('Error: Program exited with exit code - $exitCode')!); 19 | final errorStream = spawn.stderr; 20 | logger.trace('Stream: ${await errorStream.transform(utf8.decoder).join()}'); 21 | genProgress?.finish(showTiming: true); 22 | logger.stderr( 23 | "Couldn't create project: Program exited with exit code $exitCode"); 24 | exit(exitCode); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /packages/pheasant_cli/lib/src/commands/general/validate_project.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | import 'dart:io'; 10 | 11 | import 'package:cli_config/cli_config.dart'; 12 | import 'package:cli_util/cli_logging.dart'; 13 | 14 | import '../run/getters/configfile.dart'; 15 | import '../run/handle_config.dart'; 16 | import '../run/prereq/precheck.dart'; 17 | import '../../config/config.dart'; 18 | import '../../config/configfile.dart'; 19 | 20 | Future validateProject(Logger logger, List configArgs, 21 | {bool plugin = false}) async { 22 | await checkConfigFiles(logger); 23 | logger.trace('Reading Data for Config File'); 24 | var configFileData = File(configFile).readAsStringSync(); 25 | var config = Config.fromConfigFileContents( 26 | fileContents: configFileData, 27 | commandLineDefines: configArgs, 28 | environment: Platform.environment); 29 | var appConfig = configFileType == PheasantConfigFile.yaml 30 | ? PheasantCliBaseConfig.fromYaml(configFileData, configOverrides: config) 31 | : PheasantCliBaseConfig.fromJson(configFileData, configOverrides: config); 32 | handleConfig(config, appConfig: appConfig); 33 | // Verify you are in right directory 34 | await checkProject(logger, appConfig, plugin: plugin); 35 | return appConfig; 36 | } 37 | -------------------------------------------------------------------------------- /packages/pheasant_cli/lib/src/commands/general/welcome.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | import 'dart:io'; 10 | import 'package:args/args.dart'; 11 | import 'package:io/ansi.dart'; 12 | import 'package:pheasant_cli/src/utils/src/usage.dart'; 13 | 14 | void welcome(ArgParser argParser) { 15 | stdout.writeln(wrapWith('Pheasant\n', [styleBold, yellow])); 16 | stdout.writeln( 17 | 'Welcome to the Pheasant CLI. Get started with your ${wrapWith('new web app!', [ 18 | lightYellow 19 | ])}'); 20 | printUsage(argParser); 21 | } 22 | -------------------------------------------------------------------------------- /packages/pheasant_cli/lib/src/commands/handle.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | import 'dart:io'; 10 | import 'package:args/args.dart'; 11 | 12 | import 'general/welcome.dart'; 13 | import 'commands.dart'; 14 | 15 | void handleCommand(ArgResults argResults, ArgParser argParser) { 16 | switch (argResults.command?.name) { 17 | case 'init': 18 | case 'create': 19 | initCommand(argResults); 20 | break; 21 | case 'doctor': 22 | doctorCommand(argResults); 23 | break; 24 | case 'help': 25 | helpCommand(argResults, argParser); 26 | break; 27 | case 'run': 28 | case 'serve': 29 | runCommand(argResults); 30 | break; 31 | case 'build': 32 | buildCommand(argResults); 33 | break; 34 | case 'add': 35 | addCommand(argResults); 36 | break; 37 | case 'remove': 38 | removeCommand(argResults); 39 | break; 40 | default: 41 | if (argResults.command != null) stderr.writeln('Invalid Command'); 42 | welcome(argParser); 43 | break; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /packages/pheasant_cli/lib/src/commands/init/app/custom_file.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | import 'dart:io'; 10 | 11 | import 'package:cli_util/cli_logging.dart'; 12 | 13 | Future componentFileConfig( 14 | Logger logger, String projName, String proj, String resolvedPath) async { 15 | logger.trace('Setting Up Main File'); 16 | 17 | String mainDartFileData = ''' 18 | import 'package:pheasant/pheasant.dart'; 19 | 20 | // File will be generated. 21 | // ignore: uri_does_not_exist 22 | import 'package:$projName/main.phs.dart'; 23 | 24 | void main() { 25 | createApp(App); 26 | } 27 | '''; 28 | await File('$proj/web/main.dart').writeAsString(mainDartFileData); 29 | 30 | logger.trace('Adding Base Components'); 31 | File mainComponentFile = 32 | await File('$proj/lib/App.phs').create(recursive: true); 33 | File componentComponentFile = 34 | await File('$proj/lib/components/Component.phs').create(recursive: true); 35 | 36 | logger.trace('Adding Data to Base Components'); 37 | String mainComponentFileData = ''' 38 | 42 | 43 | 49 | 50 | 55 | '''; 56 | await mainComponentFile.writeAsString(mainComponentFileData); 57 | String componentComponentFileData = ''' 58 | 60 | 61 | 67 | 68 | 70 | '''; 71 | await componentComponentFile.writeAsString(componentComponentFileData); 72 | } 73 | -------------------------------------------------------------------------------- /packages/pheasant_cli/lib/src/commands/remove/remove_plugins.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | // ignore_for_file: constant_identifier_names 10 | 11 | import 'dart:io'; 12 | import 'package:io/ansi.dart'; 13 | import 'package:pheasant_cli/src/config/config.dart'; 14 | 15 | void removePlugins(AppConfig appConfig, List plugins) { 16 | if (appConfig.plugins 17 | .where((element) => plugins.contains(element.name)) 18 | .isNotEmpty) { 19 | for (var el in plugins) { 20 | appConfig.plugins.removeWhere((element) => element.name == el); 21 | } 22 | } else if (appConfig.devPlugins 23 | .where((element) => plugins.contains(element.name)) 24 | .isNotEmpty) { 25 | for (var el in plugins) { 26 | appConfig.devPlugins.removeWhere((element) => element.name == el); 27 | } 28 | } else { 29 | stderr.writeln(red.wrap( 30 | "Error: ${wrapWith("The given plugin${plugins.length == 1 ? "" : "s"}: ${plugins.join(', ')}, ${plugins.length == 1 ? "does" : "do"} not exist", [ 31 | white, 32 | styleBold 33 | ])}")); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /packages/pheasant_cli/lib/src/commands/run/bg_process.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | import 'dart:convert'; 10 | import 'dart:io'; 11 | import 'package:cli_util/cli_logging.dart'; 12 | import 'package:io/ansi.dart'; 13 | import 'package:io/io.dart'; 14 | import '../general/errors.dart'; 15 | 16 | Future bgProcess(ProcessManager manager, Logger logger) async { 17 | // Test 18 | var process = 19 | await manager.spawnDetached('dart', ['run', 'build_runner', 'watch']) 20 | ..stdout.transform(utf8.decoder).forEach((event) { 21 | if (event.contains('Succeeded')) { 22 | stdout.writeln('\nBuild Succeeded'); 23 | } 24 | }); 25 | await errorCheck(process, logger, null); 26 | 27 | ProcessSignal.sigint.watch().listen((event) { 28 | stdout.write(styleItalic.wrap('\nExiting Web App...')); 29 | process.kill(); 30 | File('build.yaml').deleteSync(); 31 | }); 32 | } 33 | -------------------------------------------------------------------------------- /packages/pheasant_cli/lib/src/commands/run/getters/configfile.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | import 'dart:io'; 10 | import 'package:io/ansi.dart'; 11 | import 'filesearch.dart'; 12 | import '../../../config/configfile.dart'; 13 | 14 | String get configFile { 15 | if (searchFile('pheasant.yaml', '.')) { 16 | if (searchFile('pheasant.json', '.')) { 17 | stderr.writeln('${wrapWith('Error:', [ 18 | styleBold, 19 | red 20 | ])} Only one pheasant config file can be used per project.'); 21 | exit(2); 22 | } else { 23 | return './pheasant.yaml'; 24 | } 25 | } else { 26 | if (searchFile('pheasant.json', '.')) { 27 | return './pheasant.json'; 28 | } else { 29 | stderr.writeln('${wrapWith('Error:', [ 30 | styleBold, 31 | red 32 | ])} Could not find config file - ${red.wrap('pheasant.yaml/pheasant.json')} - in current directory.'); 33 | exit(1); 34 | } 35 | } 36 | } 37 | 38 | PheasantConfigFile get configFileType { 39 | return configFile.contains('pheasant.yaml') 40 | ? PheasantConfigFile.yaml 41 | : PheasantConfigFile.json; 42 | } 43 | -------------------------------------------------------------------------------- /packages/pheasant_cli/lib/src/commands/run/getters/filesearch.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | import 'dart:io'; 10 | 11 | bool searchFile(String fileName, String directoryPath) { 12 | // Create a Directory object for the specified directory path 13 | Directory directory = Directory(directoryPath); 14 | 15 | // List all files in the directory 16 | List files = directory.listSync(); 17 | 18 | // Search for the file with the specified name 19 | for (FileSystemEntity file in files) { 20 | if (file is File && file.uri.pathSegments.last == fileName) { 21 | return true; 22 | } 23 | } 24 | 25 | // If the loop completes without finding the file 26 | return false; 27 | } 28 | -------------------------------------------------------------------------------- /packages/pheasant_cli/lib/src/commands/run/handle_config.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | import 'package:cli_config/cli_config.dart'; 10 | import 'package:pheasant_cli/src/config/config.dart'; 11 | 12 | /// Unimplemented yet 13 | void handleConfig(Config config, {PheasantCliBaseConfig? appConfig}) {} 14 | -------------------------------------------------------------------------------- /packages/pheasant_cli/lib/src/commands/run/log/analyze_log.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | import 'expr.dart'; 10 | 11 | String analyzeLog(String stream) { 12 | StringBuffer buffer = StringBuffer(); 13 | if (stream.contains('WARNING')) { 14 | String newstream = stream.replaceFirst('[WARNING]', 'WARN -'); 15 | if (stream.contains('AssetNotFoundException')) { 16 | } else if (stream.contains('this is not a known Builder')) { 17 | } else { 18 | buffer.write(newstream); 19 | } 20 | } else if (stream.contains('SEVERE')) { 21 | String newstream = stream.replaceFirst('[SEVERE]', 'PROBLEM -'); 22 | if (stream.contains('AssetNotFoundException') || 23 | stream.contains('Please check the following imports:')) { 24 | buffer.writeAll([ 25 | 'There is an error in your application. Fix the error in your pheasant files and try again.' 26 | ]); 27 | } else if (stream.contains('this is not a known Builder')) { 28 | } else if (stream.contains('phse:pheasantFileBuilder on')) { 29 | String filename = stream.split(' ')[3].replaceFirst('lib/', ''); 30 | buffer.writeAll([ 31 | 'Error found in $filename: ', 32 | if (stream.split(':')[1].contains('RangeError (index):')) 33 | 'There is no data in the file.' 34 | ]); 35 | } else { 36 | buffer.write(newstream); 37 | } 38 | } 39 | return buffer.toString(); 40 | } 41 | 42 | String analyzeStream(String stream) { 43 | StringBuffer buffer = StringBuffer(); 44 | buffer.writeln(extractExpressionInBrackets(stream)); 45 | // if (stream.contains('Error')) { 46 | 47 | // } 48 | return buffer.toString(); 49 | } 50 | -------------------------------------------------------------------------------- /packages/pheasant_cli/lib/src/commands/run/log/expr.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | String? extractExpressionInBrackets(String input) { 10 | RegExp regExp = RegExp( 11 | r'\((.*?)\)'); // Regular expression to match content within parentheses 12 | 13 | Match? match = regExp.firstMatch(input); 14 | 15 | if (match != null) { 16 | return match.group(1); // Group 1 contains the content within parentheses 17 | } else { 18 | return null; // No match found 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /packages/pheasant_cli/lib/src/commands/run/prereq/precheck.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | import 'dart:io'; 10 | import 'package:cli_util/cli_logging.dart'; 11 | import 'package:io/ansi.dart'; 12 | import 'package:pheasant_cli/src/commands/run/getters/configfile.dart'; 13 | import '../../../config/config.dart'; 14 | 15 | Future checkConfigFiles(Logger logger) async { 16 | logger.trace('Searching for Pubspec File'); 17 | bool pubspec = await File('pubspec.yaml').exists(); 18 | if (!pubspec) { 19 | stderr.writeln('${wrapWith('Error:', [ 20 | styleBold, 21 | red 22 | ])} Could not find pubspec file in current directory.'); 23 | exit(1); 24 | } 25 | logger.trace('Searching for Config File'); 26 | if (!File(configFile).existsSync()) { 27 | stderr.writeln('${wrapWith('Error:', [ 28 | styleBold, 29 | red 30 | ])} Could not find config file - ${red.wrap('pheasant.yaml/pheasant.json')} - in current directory.'); 31 | exit(1); 32 | } 33 | } 34 | 35 | Future checkProject(Logger logger, PheasantCliBaseConfig appConfig, 36 | {bool plugin = false}) async { 37 | if (!plugin) { 38 | logger.trace('Ensuring program is running in correct directory'); 39 | bool appFile = await File(appConfig.entrypoints!['main']!).exists(); 40 | bool mainFile = await File(appConfig.entrypoints!['app']!).exists(); 41 | 42 | if (!appFile) { 43 | stderr.writeln('${wrapWith('Error:', [ 44 | styleBold, 45 | red 46 | ])} Could not find app entry point - ${red.wrap(appConfig.entrypoints?['app'])} - in current directory.'); 47 | exit(1); 48 | } 49 | if (!mainFile) { 50 | stderr.writeln('${wrapWith('Error:', [ 51 | styleBold, 52 | red 53 | ])} Could not find main entry point - ${red.wrap(appConfig.entrypoints?['main'])} - in current directory.'); 54 | exit(1); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /packages/pheasant_cli/lib/src/config/configfile.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | enum PheasantConfigFile { yaml, json } 10 | -------------------------------------------------------------------------------- /packages/pheasant_cli/lib/src/constants/clidoc.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | Map get cmdInfo => { 10 | 'init': 'Create or start a new Pheasant project', 11 | 'doctor': 12 | 'Ensures all requirements and prerequisites are met to run the framework', 13 | 'create': 'Alias for "init"', 14 | 'help': 'Get help for any command', 15 | 'run': 'Run a project from the server', 16 | 'serve': 'Alias for "run"', 17 | 'build': 'Build a project for deployment', 18 | 'test': 'Run tests for the pheasant project', 19 | 'add': 'Add Plugins/Dependencies to your project' 20 | }; 21 | 22 | Map get cmdDetailed => { 23 | 'doctor': 24 | '''Check for any issues that may inhibit the working of the framework. 25 | Ensures all requirements and prerequisites are met to run the framework.''' 26 | }; 27 | -------------------------------------------------------------------------------- /packages/pheasant_cli/lib/src/constants/config.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | Map get pheasantDemo => { 10 | 'project': 'projName', 11 | 'version': '1.0.0', 12 | 'env': 'dart', 13 | 'entry': {'main': 'web/main.dart', 'app': 'lib/App.phs'}, 14 | 'config': { 15 | 'sass': true, 16 | 'js': true, 17 | 'linter': true, 18 | 'formatter': true, 19 | 'phsComponents': true 20 | }, 21 | 'plugins': [ 22 | { 23 | 'pheasant-router': {'version': '1.0.0'} 24 | }, 25 | { 26 | 'pheasant-styles': {'version': '1.0.0'} 27 | }, 28 | ], 29 | 'dependencies': [ 30 | { 31 | 'pheasant-lints': {'version': '1.0.0'} 32 | }, 33 | { 34 | 'pheasant-wasm': {'version': '1.0.0'} 35 | }, 36 | ] 37 | }; 38 | -------------------------------------------------------------------------------- /packages/pheasant_cli/lib/src/constants/constants.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | /// Version Information of the cli 10 | const String version = '0.1.0-extended'; 11 | 12 | Map get githubLink => { 13 | 'url': 'https://github.com/pheasantframework/pheasant.git', 14 | 'ref': 'development', 15 | 'path': 'pheasant', 16 | }; 17 | -------------------------------------------------------------------------------- /packages/pheasant_cli/lib/src/meta/metadata.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | // ignore: camel_case_types 10 | class platform { 11 | final String platformName; 12 | 13 | const platform(this.platformName); 14 | } 15 | -------------------------------------------------------------------------------- /packages/pheasant_cli/lib/src/pheasant_cli.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | export 'utils/handle.dart'; 10 | -------------------------------------------------------------------------------- /packages/pheasant_cli/lib/src/utils/enum/platforms.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | -------------------------------------------------------------------------------- /packages/pheasant_cli/lib/src/utils/handle.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | import 'dart:io'; 10 | import 'package:args/args.dart'; 11 | 12 | import '../commands/handle.dart'; 13 | 14 | import 'parse.dart'; 15 | import '../constants/constants.dart'; 16 | import 'src/usage.dart'; 17 | 18 | void handleArguments(List arguments) { 19 | final ArgParser argParser = buildPheasantParser(); 20 | try { 21 | final ArgResults results = argParser.parse(arguments); 22 | 23 | if (results.wasParsed('help')) { 24 | printUsage(argParser); 25 | return; 26 | } 27 | 28 | if (results.wasParsed('version')) { 29 | print('pheasant version -> $version'); 30 | return; 31 | } 32 | 33 | handleCommand(results, argParser); 34 | } on FormatException catch (e) { 35 | // Print usage information if an invalid argument was provided. 36 | print(e.message); 37 | print(''); 38 | printUsage(argParser); 39 | exit(1); 40 | } on Exception { 41 | print('An error occured: '); 42 | exit(2); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /packages/pheasant_cli/lib/src/utils/src/usage.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | import 'dart:io'; 10 | 11 | import 'package:args/args.dart'; 12 | import 'package:io/ansi.dart'; 13 | import '../../constants/clidoc.dart'; 14 | 15 | void printUsage(ArgParser argParser) { 16 | stdout.writeln('Usage: pheasant [arguments]\n'); 17 | stdout.writeln(styleBold.wrap('Commands')); 18 | cmdInfo.forEach( 19 | (key, value) { 20 | stdout.writeln(' ${key.padRight(13)} $value'); 21 | }, 22 | ); 23 | stdout.writeln(styleBold.wrap('\nGlobal Options')); 24 | stdout.writeln(argParser.usage); 25 | } 26 | 27 | String commandUsage(ArgParser argParser, String command) { 28 | StringBuffer buffer = StringBuffer(); 29 | buffer.writeln(cmdInfo[command]); 30 | buffer.writeln(); 31 | buffer.writeln( 32 | 'Usage: pheasant $command ${command == 'init' ? '' : '[arguments]'}'); 33 | buffer.write(argParser.commands[command]?.usage); 34 | 35 | return buffer.toString(); 36 | } 37 | -------------------------------------------------------------------------------- /packages/pheasant_cli/mono_pkg.yaml: -------------------------------------------------------------------------------- 1 | sdk: 2 | - dev 3 | - pubspec 4 | 5 | stages: 6 | - analyze: 7 | - analyze 8 | - format 9 | - unit_test: 10 | - test -------------------------------------------------------------------------------- /packages/pheasant_cli/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: pheasant_cli 2 | description: The official cli for running, creating and working with Pheasant projects and applications. 3 | version: 0.1.0-extended 4 | repository: https://github.com/pheasantframework/pheasant/tree/main/pheasant_cli 5 | 6 | executables: 7 | pheasant: 8 | 9 | environment: 10 | sdk: ^3.2.3 11 | 12 | dependencies: 13 | args: ^2.4.2 14 | cli_config: ^0.2.0 15 | cli_util: ^0.4.1 16 | io: ^1.0.4 17 | path: ^1.9.0 18 | pubspec_parse: ^1.2.3 19 | yaml: ^3.1.2 20 | yaml_edit: ^2.1.1 21 | 22 | dev_dependencies: 23 | lints: ^4.0.0 24 | test: ^1.24.0 25 | -------------------------------------------------------------------------------- /packages/pheasant_cli/template/pheasant.yaml: -------------------------------------------------------------------------------- 1 | project: example 2 | version: 1.0.0 3 | env: dart 4 | entry: 5 | main: web/main.dart 6 | app: lib/App.phs 7 | config: 8 | sass: true 9 | js: true 10 | linter: true 11 | formatter: true 12 | phsComponents: true 13 | plugins: 14 | main: 15 | - pheasant_router: 16 | version: ^0.1.0 17 | source: path 18 | path: ../path/to/dir 19 | - pheasantjs_ext: 20 | version: any 21 | source: git 22 | url: https://github.com/username/repo 23 | - pheasant_tests: 24 | version: latest 25 | dev: [] 26 | dependencies: [] 27 | -------------------------------------------------------------------------------- /packages/pheasant_cli/test/pheasant_cli_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:test/test.dart'; 2 | 3 | void main() { 4 | group('cli test', () {}); 5 | } 6 | -------------------------------------------------------------------------------- /packages/pheasant_meta/.github/workflows/dart.yml: -------------------------------------------------------------------------------- 1 | # This workflow uses actions that are not certified by GitHub. 2 | # They are provided by a third-party and are governed by 3 | # separate terms of service, privacy policy, and support 4 | # documentation. 5 | 6 | name: Dart 7 | 8 | on: 9 | push: 10 | branches: [ "main" ] 11 | pull_request: 12 | branches: [ "main" ] 13 | workflow_dispatch: 14 | inputs: 15 | logLevel: 16 | description: 'Log level' 17 | required: true 18 | default: 'warning' 19 | type: choice 20 | options: 21 | - info 22 | - warning 23 | - debug 24 | 25 | jobs: 26 | log-the-inputs: 27 | runs-on: ubuntu-latest 28 | steps: 29 | - run: | 30 | echo "Log level: $LEVEL" 31 | env: 32 | LEVEL: ${{ inputs.logLevel }} 33 | build: 34 | runs-on: ubuntu-latest 35 | 36 | steps: 37 | - name: First interaction 38 | uses: actions/first-interaction@v1.3.0 39 | with: 40 | # Token for the repository. Can be passed in using {{ secrets.GITHUB_TOKEN }} 41 | repo-token: ${{ secrets.GITHUB_TOKEN }} 42 | # Comment to post on an individual's first issue 43 | issue-message: Welcome to the Pheasant Metadata Package. This is ${{ github.actor }}'s first issue. 44 | # Comment to post on an individual's first pull request 45 | pr-message: Welcome to the Pheasant Metadata Package. This is ${{ github.actor }}'s first pull request. 46 | 47 | - uses: actions/checkout@v3 48 | 49 | # Note: This workflow uses the latest stable version of the Dart SDK. 50 | # You can specify other versions if desired, see documentation here: 51 | # https://github.com/dart-lang/setup-dart/blob/main/README.md 52 | # - uses: dart-lang/setup-dart@v1 53 | - uses: dart-lang/setup-dart@9a04e6d73cca37bd455e0608d7e5092f881fd603 54 | 55 | - name: Install dependencies 56 | run: dart pub get 57 | 58 | # Uncomment this step to verify the use of 'dart format' on each commit. 59 | - name: Verify formatting 60 | run: dart format --output=none --set-exit-if-changed . 61 | 62 | # Consider passing '--fatal-infos' for slightly stricter analysis. 63 | - name: Analyze project source 64 | run: dart analyze 65 | 66 | # Your project will need to have tests in test/ and a dependency on 67 | # package:test for this step to succeed. Note that Flutter projects will 68 | # want to change this to 'flutter test'. 69 | - name: Run tests 70 | run: dart test 71 | -------------------------------------------------------------------------------- /packages/pheasant_meta/.gitignore: -------------------------------------------------------------------------------- 1 | # https://dart.dev/guides/libraries/private-files 2 | # Created by `dart pub` 3 | .dart_tool/ 4 | 5 | # Avoid committing pubspec.lock for library packages; see 6 | # https://dart.dev/guides/libraries/private-files#pubspeclock. 7 | pubspec.lock 8 | 9 | # Mac 10 | .DS_Store 11 | 12 | # VSCode 13 | .vscode/ 14 | 15 | # Directory created by dartdoc 16 | # If you don't generate documentation locally you can remove this line. 17 | doc/api/ 18 | -------------------------------------------------------------------------------- /packages/pheasant_meta/.pubignore: -------------------------------------------------------------------------------- 1 | # https://dart.dev/guides/libraries/private-files 2 | # Created by `dart pub` 3 | .dart_tool/ 4 | 5 | # Avoid committing pubspec.lock for library packages; see 6 | # https://dart.dev/guides/libraries/private-files#pubspeclock. 7 | pubspec.lock 8 | 9 | # Mac 10 | .DS_Store 11 | 12 | pubspec_overrides.yaml 13 | 14 | # VSCode 15 | .vscode/ 16 | 17 | doc/api/ -------------------------------------------------------------------------------- /packages/pheasant_meta/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.1.0-tested 2 | - Added unit tests for metadata. 3 | - Updated dependency constraints 4 | 5 | ## 0.1.0-beta.2 6 | 7 | - Constraint problems fixed 8 | 9 | ## 0.1.0-beta.1 10 | 11 | - Minor Updates to the `Prop` constructor reflected in `pheasant_temp v0.1.0-beta.1` 12 | 13 | ## 0.1.0-beta 14 | 15 | - Added more metadata objects for `pheasant_temp v0.1.0-beta` 16 | 17 | ## 0.1.0-alpha.1 18 | 19 | - Minor changes to improve pub score. 20 | - Added API for custom annotation objects 21 | 22 | ## 0.1.0-alpha 23 | 24 | - Initial version. -------------------------------------------------------------------------------- /packages/pheasant_meta/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | ## Overview 4 | 5 | As contributors and maintainers of The Pheasant Framework Metadata Package, we pledge to create a respectful and inclusive environment for everyone involved. We value the participation of each member and want to ensure a positive experience for all. 6 | 7 | ## Expected Behavior 8 | 9 | All contributors are expected to exhibit the following behaviors: 10 | 11 | - Be respectful and considerate towards others. 12 | - Avoid any form of harassment, discrimination, or offensive language. 13 | - Be open to constructive criticism and willing to learn from others. 14 | - Focus on the technical aspects of discussions and contributions. 15 | 16 | ## Unacceptable Behavior 17 | 18 | The following behaviors are considered unacceptable and will not be tolerated: 19 | 20 | - Harassment, discrimination, or any form of offensive behavior. 21 | - Intimidation or unwelcome attention. 22 | - Any form of trolling, insulting, or derogatory comments. 23 | - Advocating for or encouraging any of the above behaviors. 24 | 25 | ## Reporting Violations 26 | 27 | If you witness or experience any behavior that violates this code of conduct, please report it to the project maintainers at [maintainer's email]. All reports will be kept confidential. 28 | 29 | ## Enforcement 30 | 31 | Violations of the code of conduct may result in appropriate actions, including but not limited to: 32 | 33 | - Warning the individual responsible for the violation. 34 | - Temporary or permanent exclusion from the project. 35 | 36 | Project maintainers have the right and responsibility to remove, edit, or reject comments, code, issues, and other contributions that do not align with this code of conduct. 37 | 38 | ## Attribution 39 | 40 | This code of conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 41 | 42 | For any questions or clarifications regarding this code of conduct, please contact [this email](raven@tech.nugegroup.com). 43 | 44 | Thank you for your cooperation and commitment to fostering a positive and inclusive community for The Pheasant Framework. 45 | -------------------------------------------------------------------------------- /packages/pheasant_meta/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [2023] [The Pheasant Group] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /packages/pheasant_meta/README.md: -------------------------------------------------------------------------------- 1 | #
The Pheasant Framework Metadata Package
2 | 3 | ![Pub Version](https://img.shields.io/pub/v/pheasant_meta?labelColor=rgb(245%2C%20193%2C%2066)&link=https%3A%2F%2Fpub.dev%2Fpackages%2Fpheasant_meta) ![Pub Publisher](https://img.shields.io/pub/publisher/pheasant_meta?labelColor=rgb(245%2C%20193%2C%2066)&link=https%3A%2F%2Fpub.dev%2Fpackages%2Fpheasant_meta) 4 | ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/pheasantframework/pheasant_meta/dart.yml?labelColor=rgb(245%2C%20193%2C%2066)) 5 | 6 | 7 | 8 | This package contains metadata, constants and the likes used in the subsequent packages in the framework. It is not intended for direct use, but can be depended on as a dev depenedency when developing plugins and libraries for the Pheasant Framework. 9 | 10 | It also contains base classes for creating your own custom metadata for your plugins to be rendered by the framework. 11 | 12 | ## Getting started 13 | 14 | Get this package by running `dart pub` 15 | ```bash 16 | dart pub add pheasant_meta 17 | dart pub add dev:pheasant_meta 18 | ``` 19 | 20 | Then you can make use of it directly in your project. 21 | 22 | ## Usage 23 | 24 | ```dart 25 | import 'package:pheasant_meta/pheasant_meta.dart'; 26 | ``` 27 | -------------------------------------------------------------------------------- /packages/pheasant_meta/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the static analysis results for your project (errors, 2 | # warnings, and lints). 3 | # 4 | # This enables the 'recommended' set of lints from `package:lints`. 5 | # This set helps identify many issues that may lead to problems when running 6 | # or consuming Dart code, and enforces writing Dart using a single, idiomatic 7 | # style and format. 8 | # 9 | # If you want a smaller set of lints you can change this to specify 10 | # 'package:lints/core.yaml'. These are just the most critical lints 11 | # (the recommended set includes the core lints). 12 | # The core lints are also what is used by pub.dev for scoring packages. 13 | 14 | include: package:lints/recommended.yaml 15 | 16 | # Uncomment the following section to specify additional rules. 17 | 18 | # linter: 19 | # rules: 20 | # - camel_case_types 21 | 22 | # analyzer: 23 | # exclude: 24 | # - path/to/excluded/files/** 25 | 26 | # For more information about the core and recommended set of lints, see 27 | # https://dart.dev/go/core-lints 28 | 29 | # For additional information about configuring this file, see 30 | # https://dart.dev/guides/language/analysis-options 31 | -------------------------------------------------------------------------------- /packages/pheasant_meta/example/example.md: -------------------------------------------------------------------------------- 1 | # Example 2 | 3 | There is no example at the moment. -------------------------------------------------------------------------------- /packages/pheasant_meta/lib/pheasant_meta.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | /// The Pheasant Metadata Library 11 | library pheasant_meta; 12 | 13 | export 'src/meta/metadata.dart'; 14 | export 'src/exceptions/exceptions.dart'; 15 | export 'src/meta/pheasant_temp/props.dart' hide BuildAnnotationObject; 16 | 17 | export 'package:meta/meta.dart'; 18 | export 'package:meta/dart2js.dart'; 19 | export 'package:meta/meta_meta.dart'; 20 | -------------------------------------------------------------------------------- /packages/pheasant_meta/lib/src/exceptions/exceptions.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | /// Base class for an exception in the Pheasant Framework 11 | class PheasantException implements Exception { 12 | final dynamic message; 13 | 14 | PheasantException([this.message]); 15 | 16 | @override 17 | String toString() { 18 | return message; 19 | } 20 | } 21 | 22 | /// Base class for an error in the Pheasant Framework 23 | class PheasantError extends Error { 24 | final dynamic what; 25 | 26 | PheasantError({this.what = ""}); 27 | 28 | factory PheasantError.unsupported(String message) => 29 | PheasantUnsupportedError(message); 30 | 31 | factory PheasantError.unimplemented() => PheasantUnimplementedError(); 32 | } 33 | 34 | /// Implementation of Unsupported Error in the Pheasant Framework 35 | class PheasantUnsupportedError extends UnsupportedError 36 | implements PheasantError { 37 | PheasantUnsupportedError(super.message); 38 | 39 | @override 40 | get what => message; 41 | } 42 | 43 | /// Implementation of Unimplemented Error in the Pheasant Framework 44 | class PheasantUnimplementedError extends UnimplementedError 45 | implements PheasantError { 46 | PheasantUnimplementedError([String? message]) { 47 | if (message != null) what = message; 48 | } 49 | 50 | set what(String msg) => what = msg; 51 | @override 52 | String get what => "No implementation"; 53 | } 54 | -------------------------------------------------------------------------------- /packages/pheasant_meta/lib/src/meta/basic/annotations.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | import 'objects.dart'; 11 | 12 | /// Declares objects that are only supported in HTML5 Standard. These should therefore not be used outside a HTML5 interface. 13 | const html5 = AnnotationObject(info: 'This object is only allowed in HTML5'); 14 | 15 | /// Declares objects that are not supported in HTML5 Standard. These should therefore not be used in a HTML5 interface. 16 | /// The build system takes note of this and excludes all instances of the object this annotation is annotated to. 17 | const nohtml5 = 18 | RestrictedAnnotation(info: 'This object is not allowed in HTML5'); 19 | 20 | /// Declares functions or objects that are not working, or are broken 21 | const broken = 22 | RestrictedAnnotation(info: 'This object or function does not work'); 23 | 24 | /// Declares variables under this annotation as bearing state. 25 | /// 26 | /// This is used in `.phs` files during code writing and is used while generating code to watch variables annotated under this. 27 | const state = StateAnnotation( 28 | info: 'This object is under reactive state and should be watched'); 29 | -------------------------------------------------------------------------------- /packages/pheasant_meta/lib/src/meta/basic/objects.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | /// A base annotation object 11 | class AnnotationObject extends Object { 12 | /// The info portrayed by the object 13 | final String info; 14 | 15 | const AnnotationObject({required this.info}); 16 | } 17 | 18 | /// An annotation object used to represent restricted functionality. 19 | class RestrictedAnnotation extends AnnotationObject { 20 | const RestrictedAnnotation({required super.info}); 21 | } 22 | 23 | /// An annotation object for the sole purpose of portaying information 24 | class InfoAnnotation extends AnnotationObject { 25 | const InfoAnnotation({required super.info}); 26 | } 27 | 28 | /// Annotation Object used for all annotations requiring and dealing with state management. 29 | /// 30 | /// This is not used directly, but used in constant objects to declare state annotation objects. 31 | class StateAnnotation extends AnnotationObject { 32 | const StateAnnotation({required super.info}); 33 | } 34 | -------------------------------------------------------------------------------- /packages/pheasant_meta/lib/src/meta/metadata.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | /// Pheasant-generated metadata 11 | library; 12 | 13 | export 'basic/annotations.dart'; 14 | export 'obj/obj.dart'; 15 | export 'basic/objects.dart'; 16 | -------------------------------------------------------------------------------- /packages/pheasant_meta/mono_pkg.yaml: -------------------------------------------------------------------------------- 1 | sdk: 2 | - dev 3 | - pubspec 4 | 5 | stages: 6 | - analyze: 7 | - analyze 8 | - format 9 | - unit_test: 10 | - test 11 | - cron: 12 | - test: 13 | os: 14 | - linux 15 | - windows 16 | 17 | -------------------------------------------------------------------------------- /packages/pheasant_meta/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: pheasant_meta 2 | description: >- 3 | Metadata to use in The Pheasant Framework. This also enlists base objects such as exceptions, errors and more for use in sibling packages. 4 | version: 0.1.0-tested 5 | repository: https://github.com/pheasantframework/pheasant/tree/main/pheasant_meta 6 | 7 | environment: 8 | sdk: '^3.0.0' 9 | 10 | # Add regular dependencies here. 11 | dependencies: 12 | meta: ^1.11.0 13 | 14 | dev_dependencies: 15 | lints: ^4.0.0 16 | test: ^1.24.0 17 | 18 | topics: 19 | - pheasant 20 | - meta 21 | - metadata -------------------------------------------------------------------------------- /packages/pheasant_meta/test/annotation_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | // https://mit-license.org 9 | 10 | import 'package:pheasant_meta/pheasant_meta.dart'; 11 | import 'package:test/test.dart'; 12 | 13 | void main() { 14 | group("Tests for metadata used in packages", () { 15 | test('Constant Metadata Tests', () => null); 16 | test('Class Metadata Tests', () { 17 | final fromObject = From('1.0.0'); 18 | expect(fromObject.info, 19 | equals("This functionality takes effect from the given version.")); 20 | }); 21 | }); 22 | group("Tests for metadata used in build files", () { 23 | test('"prop" Metadata', () { 24 | final testprop = prop; 25 | 26 | expect(testprop.defaultTo, isNull); 27 | expect(testprop.optional, isFalse); 28 | }); 29 | 30 | test('"Prop" Metadata', () { 31 | final testprop = Prop(defaultTo: 8, optional: true); 32 | 33 | expect(testprop.defaultTo, isNotNull); 34 | assert(testprop.defaultTo is int); 35 | assert(testprop.defaultTo == 8); 36 | 37 | expect(testprop.optional, isTrue); 38 | }); 39 | }); 40 | } 41 | -------------------------------------------------------------------------------- /packages/pheasant_meta/test/exception_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | // https://mit-license.org 9 | 10 | // import 'package:pheasant_meta/pheasant_meta.dart'; 11 | import 'package:test/test.dart'; 12 | 13 | void main() { 14 | group("Exception Tests", () => null); 15 | } 16 | -------------------------------------------------------------------------------- /packages/pheasant_meta/test/pme_test.dart: -------------------------------------------------------------------------------- 1 | // import 'package:pheasant_meta/pheasant_meta.dart'; 2 | import 'package:test/test.dart'; 3 | 4 | void main() { 5 | group('A group of tests', () { 6 | setUp(() { 7 | // Additional setup goes here. 8 | }); 9 | 10 | test('First Test', () {}); 11 | }); 12 | } 13 | -------------------------------------------------------------------------------- /packages/pheasant_temp/.github/workflows/dart.yml: -------------------------------------------------------------------------------- 1 | # This workflow uses actions that are not certified by GitHub. 2 | # They are provided by a third-party and are governed by 3 | # separate terms of service, privacy policy, and support 4 | # documentation. 5 | 6 | name: Dart 7 | 8 | on: 9 | push: 10 | branches: [ "main" ] 11 | pull_request: 12 | branches: [ "main" ] 13 | workflow_dispatch: 14 | inputs: 15 | logLevel: 16 | description: 'Log level' 17 | required: true 18 | default: 'warning' 19 | type: choice 20 | options: 21 | - info 22 | - warning 23 | - debug 24 | 25 | jobs: 26 | log-the-inputs: 27 | runs-on: ubuntu-latest 28 | steps: 29 | - run: | 30 | echo "Log level: $LEVEL" 31 | env: 32 | LEVEL: ${{ inputs.logLevel }} 33 | build: 34 | runs-on: ubuntu-latest 35 | 36 | steps: 37 | - name: First interaction 38 | uses: actions/first-interaction@v1.3.0 39 | with: 40 | # Token for the repository. Can be passed in using {{ secrets.GITHUB_TOKEN }} 41 | repo-token: ${{ secrets.GITHUB_TOKEN }} 42 | # Comment to post on an individual's first issue 43 | issue-message: Welcome to the Pheasant Metadata Package. This is ${{ github.actor }}'s first issue. 44 | # Comment to post on an individual's first pull request 45 | pr-message: Welcome to the Pheasant Metadata Package. This is ${{ github.actor }}'s first pull request. 46 | 47 | - uses: actions/checkout@v3 48 | 49 | # Note: This workflow uses the latest stable version of the Dart SDK. 50 | # You can specify other versions if desired, see documentation here: 51 | # https://github.com/dart-lang/setup-dart/blob/main/README.md 52 | # - uses: dart-lang/setup-dart@v1 53 | - uses: dart-lang/setup-dart@9a04e6d73cca37bd455e0608d7e5092f881fd603 54 | 55 | - name: Install dependencies 56 | run: dart pub get 57 | 58 | # Uncomment this step to verify the use of 'dart format' on each commit. 59 | - name: Verify formatting 60 | run: dart format --output=none --set-exit-if-changed . 61 | 62 | # Consider passing '--fatal-infos' for slightly stricter analysis. 63 | - name: Analyze project source 64 | run: dart analyze 65 | 66 | # Your project will need to have tests in test/ and a dependency on 67 | # package:test for this step to succeed. Note that Flutter projects will 68 | # want to change this to 'flutter test'. 69 | # - name: Run tests 70 | # run: dart test 71 | -------------------------------------------------------------------------------- /packages/pheasant_temp/.gitignore: -------------------------------------------------------------------------------- 1 | # https://dart.dev/guides/libraries/private-files 2 | # Created by `dart pub` 3 | .dart_tool/ 4 | 5 | # Avoid committing pubspec.lock for library packages; see 6 | # https://dart.dev/guides/libraries/private-files#pubspeclock. 7 | pubspec.lock 8 | 9 | build/ 10 | 11 | # Mac 12 | .DS_Store 13 | 14 | private/ 15 | 16 | example/example.dart 17 | 18 | 19 | # Directory created by dartdoc 20 | # If you don't generate documentation locally you can remove this line. 21 | doc/api/ 22 | 23 | # Avoid committing generated Javascript files: 24 | *.dart.js 25 | *.info.json # Produced by the --dump-info flag. 26 | *.js # When generated by dart2js. Don't specify *.js if your 27 | # project includes source files written in JavaScript. 28 | *.js_ 29 | *.js.deps 30 | *.js.map 31 | **/unimplemented/*.dart 32 | example/demo.dart 33 | -------------------------------------------------------------------------------- /packages/pheasant_temp/.pubignore: -------------------------------------------------------------------------------- 1 | # https://dart.dev/guides/libraries/private-files 2 | # Created by `dart pub` 3 | .dart_tool/ 4 | 5 | # Avoid committing pubspec.lock for library packages; see 6 | # https://dart.dev/guides/libraries/private-files#pubspeclock. 7 | pubspec.lock 8 | 9 | pubspec_overrides.yaml 10 | 11 | build/ 12 | 13 | private/ 14 | 15 | # Mac 16 | .DS_Store 17 | 18 | .vscode 19 | 20 | example/example.dart 21 | 22 | # Directory created by dartdoc 23 | # If you don't generate documentation locally you can remove this line. 24 | doc/api/ 25 | -------------------------------------------------------------------------------- /packages/pheasant_temp/ATTRIBUTIONS: -------------------------------------------------------------------------------- 1 | Badge Logo Attributions: https://www.dartlang.org/(now: https://dart.dev/), CC BY 3.0 , via Wikimedia Commons -------------------------------------------------------------------------------- /packages/pheasant_temp/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.1.0-tested 2 | - Implemented tests. 3 | - Updated Dependency Constraints 4 | 5 | ## 0.1.0-grade 6 | - Added Support for Routing via `p-route` attribute 7 | - Added new routing directives 8 | - Made Some code parsing fixes 9 | - Many Bug Fixes 10 | 11 | ## 0.1.0-extended.1 12 | - Some minor bug fixes 13 | 14 | ## 0.1.0-extended 15 | - Added support for custom components 16 | 17 | ## 0.1.0-dev.1 18 | - Fixed State Tree 19 | - Added new state features for state tree fix. 20 | - Fixed some minor attribute issues. 21 | 22 | ## 0.1.0-dev 23 | - Started support for JS (JS into Dart) via normal JS Interop (if you want to use other features, please import the normal imports). 24 | - Fixed issues concerning external function extraction and custom components (did not take attributes into consideration). 25 | - Added `action` tag to help run dart code in your html 26 | - Added configuration for JavaScript and Sass 27 | - Made minor fixes 28 | 29 | ## 0.1.0-beta.2 30 | - Fixed dependency graph to work with `pheasant_meta ^0.1.0-beta.1`. 31 | 32 | ## 0.1.0-beta.1 33 | - Added input binding 34 | - Added prevent default support 35 | - Added support for rendering actions without state using the `nostate` attribute 36 | 37 | ## 0.1.0-beta 38 | - Added Support for Event Handling 39 | - Added basic state management support 40 | - Added support for passing data to child. 41 | - Extended support for custom components via slots 42 | 43 | ## 0.1.0-alpha 44 | 45 | - Initial version. 46 | - Added Basic Features for Pheasant File Handling -------------------------------------------------------------------------------- /packages/pheasant_temp/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | ## Overview 4 | 5 | As contributors and maintainers of The Pheasant Framework Template Package project, we pledge to create a respectful and inclusive environment for everyone involved. We value the participation of each member and want to ensure a positive experience for all. 6 | 7 | ## Expected Behavior 8 | 9 | All contributors are expected to exhibit the following behaviors: 10 | 11 | - Be respectful and considerate towards others. 12 | - Avoid any form of harassment, discrimination, or offensive language. 13 | - Be open to constructive criticism and willing to learn from others. 14 | - Focus on the technical aspects of discussions and contributions. 15 | 16 | ## Unacceptable Behavior 17 | 18 | The following behaviors are considered unacceptable and will not be tolerated: 19 | 20 | - Harassment, discrimination, or any form of offensive behavior. 21 | - Intimidation or unwelcome attention. 22 | - Any form of trolling, insulting, or derogatory comments. 23 | - Advocating for or encouraging any of the above behaviors. 24 | 25 | ## Reporting Violations 26 | 27 | If you witness or experience any behavior that violates this code of conduct, please report it to the project maintainers at [maintainer's email]. All reports will be kept confidential. 28 | 29 | ## Enforcement 30 | 31 | Violations of the code of conduct may result in appropriate actions, including but not limited to: 32 | 33 | - Warning the individual responsible for the violation. 34 | - Temporary or permanent exclusion from the project. 35 | 36 | Project maintainers have the right and responsibility to remove, edit, or reject comments, code, issues, and other contributions that do not align with this code of conduct. 37 | 38 | ## Attribution 39 | 40 | This code of conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 41 | 42 | For any questions or clarifications regarding this code of conduct, please contact [this email](raven@tech.nugegroup.com). 43 | 44 | Thank you for your cooperation and commitment to fostering a positive and inclusive community for The Pheasant Framework Template Package. 45 | -------------------------------------------------------------------------------- /packages/pheasant_temp/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [2023] [The Pheasant Group] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /packages/pheasant_temp/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:lints/recommended.yaml 2 | -------------------------------------------------------------------------------- /packages/pheasant_temp/example/main.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | // https://mit-license.org 9 | 10 | 11 | import 'package:pheasant_temp/pheasant_temp.dart'; 12 | 13 | void main() { 14 | print(compilePhs(script: """ 15 | import './Component.phs' as Component; 16 | import '../fruit/fruit.phs' as fruit; 17 | 18 | var number = 9; 19 | 20 | List nums = [1, 2, 3, 4]; 21 | 22 | void addNum() { 23 | number++; 24 | } 25 | 26 | void subtractNum() { 27 | number -= 1; 28 | } 29 | 30 | @JS('console.log') 31 | external void log(String data); 32 | 33 | """, template: """ 34 |
35 | Welcome to Pheasant 36 |

Hello World {{number}}

37 | Click Here 38 |

Aloha

39 |

{{nums[0]}}

40 | 41 | 42 | # Hello 43 | Welcome to the Pheasant Template Example Base 44 | It's quite fun here, and this text here was actually originally markdown. 45 | We can write single `code` and multiblock code like this 46 | ```dart 47 | void main() { 48 | print("Hello World"); 49 | } 50 | ``` 51 | 52 | 53 |
54 | """, buildExtension: '.phs.dart', appDirPath: "App.phs")); 55 | print(renderMain()); 56 | } 57 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/pheasant_build.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | /// This library is not intended for use within this package, but is used by sibling packages like pheasant_build for the [createApp] function. 11 | /// This is also the library used in all compiled pheasant files cached during development. 12 | /// 13 | /// The reason this library is separate from [pheasant_temp] is becuase of unsupported libraries like "dart:html". 14 | /// 15 | /// In this library, the base definition for [RavenTemplate] is defined here, and so is used for external functions or processes, 16 | /// like the files built from the text returned by [renderFunc] and [renderMain], in order to make use of the functionality during build processes. 17 | /// 18 | /// This library also contains the definitions for the `State` classes, which are used for state management. 19 | /// The main classes used in the application are [TemplateState] and [AppState]. 20 | library pheasant_build; 21 | 22 | export 'src/base.dart'; 23 | export 'src/routing/routing.dart'; 24 | export 'src/routing/unknown/unknown.dart'; 25 | export 'src/state/state.dart' 26 | hide 27 | StateTarget, 28 | ChangeEmitter, 29 | ChangeReceiver, 30 | ExtraFunctionality, 31 | TimedState; 32 | export 'package:pheasant_meta/src/meta/pheasant_temp/props.dart' 33 | hide BuildAnnotationObject; 34 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/pheasant_custom.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | /// The Pheasant Template Library used in designing Custom Components and Elements. 11 | /// 12 | /// This library serves as part of the complete API for designing plugins for the pheasant framework. 13 | library pheasant_custom; 14 | 15 | export 'src/components/custom/custom.dart'; 16 | export 'src/components/custom/helpers/html.dart'; 17 | export 'src/routing/unknown/unknown.dart'; 18 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/pheasant_temp.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | /// Library for pheasant templating engine 11 | /// 12 | /// This library is the main templating library, and contains the main functionality for creating rendered pheasant code. 13 | /// Normal usage of this package would require the import of this library only. 14 | /// 15 | /// Defined in this library is the [renderFunc] function and the [renderMain] function. 16 | library pheasant_temp; 17 | 18 | export 'src/components/components.dart'; 19 | export 'src/builder/builder.dart'; 20 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/builder/analyze/enums/get_enums.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | // https://mit-license.org 9 | 10 | 11 | import 'package:analyzer/dart/ast/ast.dart'; 12 | 13 | /// Function used to get enum declarations from a [CompilationUnit] 14 | List getEnums(CompilationUnit unit) { 15 | final enumerations = []; 16 | 17 | for (var declaration in unit.declarations) { 18 | if (declaration is EnumDeclaration) { 19 | enumerations.add(declaration); 20 | } 21 | } 22 | 23 | return enumerations; 24 | } 25 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/builder/analyze/functions/deps.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | import 'package:analyzer/dart/ast/ast.dart' 11 | show FunctionDeclaration, VariableDeclaration; 12 | import 'package:analyzer/dart/ast/ast.dart'; 13 | import 'package:code_builder/code_builder.dart' 14 | show Code, FieldModifier, MethodModifier; 15 | 16 | FieldModifier modifier(VariableDeclaration vd) { 17 | String mod = vd.beginToken.isModifier ? vd.beginToken.toString() : 'dynamic'; 18 | if (mod == 'const') { 19 | return FieldModifier.constant; 20 | } else if (mod == 'final') { 21 | return FieldModifier.final$; 22 | } else { 23 | return FieldModifier.var$; 24 | } 25 | } 26 | 27 | Code? funBody(FunctionDeclaration fd) { 28 | String body = _getFunBody(fd); 29 | if (funModifier(fd) != null) { 30 | switch (funModifier(fd)!) { 31 | case MethodModifier.async: 32 | body = body.replaceFirst("async", ""); 33 | break; 34 | case MethodModifier.asyncStar: 35 | body = body.replaceFirst("async*", ""); 36 | break; 37 | case MethodModifier.syncStar: 38 | body = body.replaceFirst("sync*", ""); 39 | break; 40 | } 41 | } 42 | if (body.startsWith(RegExp(r'\s*=>'))) { 43 | body = '${body.replaceFirst(RegExp(r'\s*=>'), 'return')};'; 44 | } 45 | return body.isEmpty ? null : Code(body); 46 | } 47 | 48 | MethodModifier? funModifier(FunctionDeclaration function) { 49 | String body = _getFunBody(function); 50 | if (body.startsWith("async")) { 51 | return MethodModifier.async; 52 | } else if (body.startsWith("async*")) { 53 | return MethodModifier.asyncStar; 54 | } else if (body.startsWith("sync*")) { 55 | return MethodModifier.syncStar; 56 | } else { 57 | return null; 58 | } 59 | } 60 | 61 | String _getFunBody(FunctionDeclaration function) { 62 | var body = function.functionExpression.body.toSource(); 63 | body = body.replaceRange(body.length - 1, null, '').replaceFirst('{', ''); 64 | return body; 65 | } 66 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/builder/analyze/functions/functions.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | import 'package:analyzer/dart/ast/ast.dart' 11 | show CompilationUnit, FunctionDeclaration; 12 | 13 | /// Function used for extracting function info from a [CompilationUnit] and then return a List of [FunctionDeclaration] containing these declarations. 14 | List extractFunctions(CompilationUnit unit) { 15 | final functions = []; 16 | 17 | for (var declaration in unit.declarations) { 18 | if (declaration is FunctionDeclaration) { 19 | functions.add(declaration); 20 | } 21 | } 22 | 23 | return functions; 24 | } 25 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/builder/analyze/imports/combinators.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | import 'package:analyzer/dart/ast/ast.dart' show ImportDirective; 11 | 12 | /// Function to get the items placed in a `show` combinator in an import directive. 13 | /// 14 | /// Returns a List of Strings which represent the items being 'shown' in the [ImportDirective] 15 | List getShowCombinators(ImportDirective directive) { 16 | List items = []; 17 | for (final item in directive.combinators) { 18 | if (item.keyword.toString() == 'show') { 19 | String stringList = item.toSource().replaceFirst('show ', ''); 20 | items.addAll(stringList.split(', ')); 21 | } 22 | } 23 | return items; 24 | } 25 | 26 | /// Function to get the items placed in a `hide` combinator in an import directive. 27 | /// 28 | /// Returns a List of Strings which represent the items being 'hidden' in the [ImportDirective] 29 | List getHideCombinators(ImportDirective directive) { 30 | List items = []; 31 | for (final item in directive.combinators) { 32 | if (item.keyword.toString() == 'hide') { 33 | String stringList = item.toSource().replaceFirst('hide ', ''); 34 | items.addAll(stringList.split(', ')); 35 | } 36 | } 37 | return items; 38 | } 39 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/builder/analyze/imports/extension.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | /// Function to help get file extension, without using the `path` package 11 | String fileExtension(String filePath) { 12 | return Uri.file(filePath).path.split('.').last.replaceFirst('\'', ''); 13 | } 14 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/builder/analyze/imports/get_imports.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | // https://mit-license.org 9 | 10 | 11 | import 'package:analyzer/dart/ast/ast.dart'; 12 | 13 | List getImports(CompilationUnit newUnit) { 14 | return newUnit.directives.whereType().toList(); 15 | } 16 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/builder/analyze/shared/extractor_result.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | // https://mit-license.org 9 | 10 | 11 | import 'package:analyzer/dart/ast/ast.dart'; 12 | import 'package:pheasant_temp/src/builder/analyze/variables/variable_info.dart'; 13 | 14 | /// Class used to encapsulate the result of complete parsing of a script source file. 15 | class PheasantExtractorResult { 16 | final List variables; 17 | final List functions; 18 | final List imports; 19 | final List enums; 20 | 21 | PheasantExtractorResult( 22 | this.variables, this.functions, this.imports, this.enums); 23 | } 24 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/builder/analyze/shared/metadata/annotation_info.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | /// Class used to encapsulate compound annotation info. 11 | /// 12 | /// This class is used to get and encapsulate annotation info in annotations where parameters are passed such as the `@Prop()` annotation. 13 | /// 14 | /// The name of the annotation is passed into the [name] variable, while the data, including the parameter name and value, are passed as a [Map] to [data]. 15 | class AnnotationInfo { 16 | /// The name of the annotation 17 | final String name; 18 | 19 | /// Map connecting the parameter name to its value. 20 | final Map data; 21 | 22 | const AnnotationInfo({required this.name, this.data = const {}}); 23 | 24 | /// Description of the annotation as a string 25 | @override 26 | String toString() => "$name : $data"; 27 | } 28 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/builder/analyze/shared/metadata/props.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | import 'package:code_builder/code_builder.dart' show Field; 11 | import 'annotation_info.dart'; 12 | 13 | /// Class to encapsulate data for a prop field. 14 | /// 15 | /// This class contains info about the field as a [Field], and information about the `@prop` annotation encapsulated as [AnnotationInfo]. 16 | class PropField { 17 | final Field fieldDef; 18 | final AnnotationInfo annotationInfo; 19 | 20 | const PropField({required this.fieldDef, required this.annotationInfo}); 21 | 22 | @override 23 | String toString() => "Annotation: $annotationInfo \nField: $fieldDef"; 24 | } 25 | 26 | /// An extended class of AnnotationInfo for sole usage for the `@prop` and `@Prop()` annotations. 27 | class PropAnnotationInfo extends AnnotationInfo { 28 | const PropAnnotationInfo({super.data = const {}}) : super(name: 'prop'); 29 | } 30 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/builder/analyze/shared/parse_code.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | // https://mit-license.org 9 | 10 | 11 | import 'package:analyzer/dart/analysis/results.dart'; 12 | import 'package:analyzer/dart/analysis/utilities.dart' show parseString; 13 | import '../../../exceptions/exceptions.dart'; 14 | 15 | ParseStringResult parseCode(String script) { 16 | final result = parseString(content: script); 17 | if (result.errors.isNotEmpty) { 18 | throw PheasantTemplateException( 19 | ''' 20 | Error Reading Script Component: Variable Error: ${result.errors.map((e) => e.problemMessage)} 21 | Fix: ${result.errors.map((e) => e.correctionMessage)} 22 | ''', 23 | exitCode: result.errors.map((e) => e.errorCode.numParameters).first, 24 | ); 25 | } 26 | return result; 27 | } 28 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/builder/analyze/variables/variable_declarations.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | // https://mit-license.org 9 | 10 | 11 | import 'package:analyzer/dart/ast/ast.dart'; 12 | import 'variable_extractor_visitor.dart'; 13 | import 'variable_info.dart'; 14 | 15 | List getVariableDeclarations(CompilationUnit newUnit) { 16 | List outputList = []; 17 | VariableExtractorVisitor visitor = VariableExtractorVisitor(); 18 | 19 | for (var element in newUnit.declarations) { 20 | element.accept(visitor); 21 | outputList.addAll( 22 | visitor.variableList.map((e) => e..annotations = element.metadata)); 23 | visitor = VariableExtractorVisitor(); 24 | } 25 | return outputList 26 | .where((element) => 27 | element.declaration.parent?.parent?.parent?.parent is! FunctionBody) 28 | .toList(); 29 | } 30 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/builder/analyze/variables/variable_extractor_visitor.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | import 'package:analyzer/dart/ast/ast.dart' 11 | show CompilationUnit, VariableDeclaration, VariableDeclarationList; 12 | import 'package:analyzer/dart/ast/visitor.dart' show RecursiveAstVisitor; 13 | import 'variable_info.dart'; 14 | 15 | /// Visitor used to get variables from a [CompilationUnit] 16 | /// 17 | /// The difference between this and a normal Variable Visitor, is the use of the class [VariableDefinition] rather than [VariableDeclaration] 18 | class VariableExtractorVisitor extends RecursiveAstVisitor { 19 | List variableList = []; 20 | 21 | @override 22 | void visitVariableDeclaration(VariableDeclaration node) { 23 | super.visitVariableDeclaration(node); 24 | try { 25 | variableList.add(VariableDefinition( 26 | declaration: node, 27 | dataType: (node.parent as VariableDeclarationList).type?.toSource() ?? 28 | 'dynamic')); 29 | } catch (e) { 30 | // Do not include 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/builder/analyze/variables/variable_info.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | import 'package:analyzer/dart/ast/ast.dart' 11 | show Annotation, VariableDeclaration; 12 | 13 | /// The class used as an encapsulated extension for [VariableDeclaration] 14 | /// 15 | /// The main difference here is just the presence of the [dataType] variable, a [String] that represents the variable data type. 16 | class VariableDefinition { 17 | VariableDeclaration declaration; 18 | String dataType; 19 | List annotations; 20 | 21 | VariableDefinition( 22 | {required this.declaration, 23 | required this.dataType, 24 | this.annotations = const []}); 25 | 26 | @override 27 | String toString() => "$dataType $declaration"; 28 | } 29 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/builder/builder.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | library; 11 | 12 | export 'create/mainbuilder.dart'; 13 | export 'analyze/analyze.dart'; 14 | export 'code/code.dart'; 15 | export 'code/compile.dart'; 16 | export 'code/create_render.dart'; 17 | export 'code/components/custom_components.dart'; 18 | export 'code/src/code_body.dart'; 19 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/builder/code/code.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | library; 11 | 12 | export 'compile.dart'; 13 | export 'create_render.dart'; 14 | export 'src/code_body.dart'; 15 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/builder/code/components/cc.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | import 'package:html/dom.dart' show Element, Node; 11 | 12 | import 'package:pheasant_meta/pheasant_meta.dart' show AltVersion; 13 | 14 | /// Function to help in serving custom components 15 | /// 16 | /// This helps in rendering singular custom components (self-closing) that are of the form `` by displacing the children that the `parse` function would have created. 17 | void serveSingleComponents(Node root, String tagName) { 18 | List elementCategories = findAllElements(root, tagName); 19 | for (var element in elementCategories) { 20 | element.reparentChildren(element.parentNode ?? root); 21 | } 22 | } 23 | 24 | /// Recursive Function to get all occurences of a component 25 | /// 26 | /// This function is much like `querySelector`, but then it has support for any element tag name, including custom components. 27 | List findAllElements(Node root, String tagName) { 28 | List result = []; 29 | 30 | void searchElements(Node node) { 31 | if (node is Element && node.localName == tagName) { 32 | result.add(node); 33 | } 34 | 35 | if (node.hasChildNodes()) { 36 | node.nodes.forEach(searchElements); 37 | } 38 | } 39 | 40 | searchElements(root); 41 | 42 | return result; 43 | } 44 | 45 | @AltVersion('findAllElements', version: '0.3.0') 46 | List _findAllElementsNonRecursive(Node root, String tagName) { 47 | List result = []; 48 | List stack = [root]; 49 | 50 | while (stack.isNotEmpty) { 51 | var currentNode = stack.removeLast(); 52 | 53 | if (currentNode is Element && currentNode.localName == tagName) { 54 | result.add(currentNode); 55 | } 56 | 57 | if (currentNode.hasChildNodes()) { 58 | stack.addAll(currentNode.nodes); 59 | } 60 | } 61 | 62 | return result; 63 | } 64 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/builder/code/constants/defs.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | import 'tempclass.dart'; 11 | 12 | /// Typedef to shorten name 13 | typedef PheasantTC = TempPheasantRenderClass; 14 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/builder/code/constants/lists.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | import 'package:pheasant_temp/src/components/attributes/attr_list.dart' as phs; 11 | 12 | Iterable className = ['class', 'className']; 13 | 14 | Iterable nonStringAttr = ['href', 'id']; 15 | 16 | Iterable pheasantAttr = [ 17 | ...phs.attributes.map((e) => e.name), 18 | ...phs.eventAttributes.map((e) => e.name), 19 | ..._depAttrs 20 | ]; 21 | 22 | Iterable _depAttrs = ['p-bind', 'p-slot']; 23 | 24 | bool _containsItem(Iterable attrs, String data) { 25 | return attrs.where((element) => data.contains(element)).isNotEmpty; 26 | } 27 | 28 | bool containsDepAttrs(String attr) => _containsItem(_depAttrs, attr); 29 | 30 | Iterable _nonRenderable = ['preventdefault', '@', 'nostate']; 31 | 32 | bool nonrenderableAttrs(String attr) => _containsItem(_nonRenderable, attr); 33 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/builder/code/constants/tempclass.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | /// A temporary class containing the new `beginningFunc` String [value] and the new `closebracket` integer [number]. 11 | /// 12 | /// This class is not intended for public use and is only for one singular purpose - to get a return value for the `pheasantAttributes` function 13 | class TempPheasantRenderClass extends _PheasantTempClass { 14 | int number; 15 | String value; 16 | 17 | TempPheasantRenderClass({required this.number, required this.value}); 18 | } 19 | 20 | class _PheasantTempClass {} 21 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/builder/code/src/events.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | import 'package:html/dom.dart' show Element; 11 | import 'package:pheasant_meta/pheasant_meta.dart' show From; 12 | import '../../../components/attributes/attr.dart' 13 | show PheasantEventHandlingAttribute; 14 | 15 | /// Pre-defined functions that can be used to manipulate the state of an object. 16 | /// 17 | /// Normal state operations can be undergone through the use of event-handling attributes - [PheasantEventHandlingAttribute] 18 | /// 19 | /// In the case you want more control over the state, such as to activate and deactivate the state, then you can apply the following constant functions in order to perform such operations. 20 | /// 21 | /// These options have the choice of activating, deactivating and reloading state altogether, as well as other more interesting features. 22 | /// 23 | /// This getter returns a [Map] connecting the constant function names to the appropiate statements to apply. 24 | @From('0.1.0') 25 | Map get defaultStateAttributes => { 26 | 'freezeState': 'state?.freeze();', 27 | 'reloadState': 'state?.reload();', 28 | 'unfreezeState': 'state?.unfreeze();' 29 | }; 30 | 31 | bool preventDefaultCheck(Element pheasantHtml, String name) { 32 | if ((pheasantHtml.attributes.keys).contains('preventdefault')) { 33 | return true; 34 | } else if ((pheasantHtml.attributes.keys).contains('preventdefaults') && 35 | (pheasantHtml.attributes.entries 36 | .firstWhere((element) => element.key == 'preventdefaults') 37 | .value 38 | .split(' ') 39 | .contains(name))) { 40 | return true; 41 | } 42 | return false; 43 | } 44 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/builder/code/src/utils/text_node.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | import 'package:html/dom.dart' show Node; 11 | 12 | String textNodeRendering( 13 | Node element, String beginningFunc, String elementName) { 14 | if ((element.text ?? '').contains(RegExp(r'\{\{([^\}]+)\}\}'))) { 15 | // Remove interpolation and add desired value 16 | final regex = RegExp(r'\{\{([^\}]+)\}\}'); 17 | element.text = '${element.text?.splitMapJoin( 18 | regex, 19 | onMatch: (m) => '\${${m[1]}}', 20 | )}'; 21 | } else if ((element.text ?? '').contains(RegExp(r'\{([^\}]+)\}'))) { 22 | // Remove interpolation and add desired value 23 | final regex = RegExp(r'\{([^\}]+)\}'); 24 | element.text = '${element.text?.splitMapJoin( 25 | regex, 26 | onMatch: (m) => '\${${m[1]}}', 27 | )}'; 28 | } 29 | beginningFunc += '$elementName.append(_i2.Text("""${element.text}"""));'; 30 | return beginningFunc; 31 | } 32 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/builder/create/mainbuilder.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | import 'package:code_builder/code_builder.dart'; 11 | import 'package:dart_style/dart_style.dart' show DartFormatter; 12 | 13 | /// Simple Function to render the `main` pheasant file entry. 14 | /// 15 | /// This function writes the code used to create the `App` getter that is used in the `cerateApp` function defined in the `pheasant_build` package that is eventually used in the `main.dart` file. 16 | /// 17 | /// This function writes code to define a getter `App` which returns the main app rendered pheasant component [appName] originally defined at [mainEntry]. 18 | /// 19 | /// The function does not require any parameters to run, as all parameters are optional and set to standard options unless defined otherwise in the pheasant config file. 20 | /// 21 | /// Therefore, [appName] is set to `'AppComponent'` by default, 22 | /// [mainEntry] is set to `'App.phs'` by default, and 23 | /// [fileExtension], the file extension for all generated dart files from pheasant components, is set to `'.phs.dart'` by default. 24 | /// 25 | /// Here is how the returned string code for a main file (defaultly computed to `main.phs.dart`) 26 | /// ```dart 27 | /// // ignore_for_file: no_leading_underscores_for_library_prefixes 28 | /// import 'package:pheasant/build.dart' as _i1; 29 | /// import 'App.phs.dart'; 30 | /// 31 | /// _i1.PheasantTemplate get App { 32 | /// return AppComponent(); 33 | /// } 34 | /// ``` 35 | String renderMain( 36 | {String appName = 'AppComponent', 37 | String fileExtension = '.phs.dart', 38 | String mainEntry = 'App.phs'}) { 39 | final formatter = DartFormatter(); 40 | final emitter = DartEmitter.scoped(); 41 | var item = LibraryBuilder(); 42 | 43 | item.directives.addAll([ 44 | Directive.import('${mainEntry.replaceFirst('.phs', '')}$fileExtension'), 45 | ]); 46 | item.body.add(Method((m) => m 47 | ..name = 'App' 48 | ..returns = refer('PheasantTemplate', 'package:pheasant/build.dart') 49 | ..type = MethodType.getter 50 | ..body = Code('return $appName();'))); 51 | 52 | return formatter.format("${item.build().accept(emitter)}"); 53 | } 54 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/components/attributes/attr_list.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | import 'package:pheasant_temp/src/components/attributes/attr.dart'; 11 | 12 | List _attributes = PheasantAttribute.values; 13 | 14 | List _eventAttributes = 15 | PheasantEventHandlingAttribute.values; 16 | 17 | /// Total number of attributes used in the application 18 | List get attributes => _attributes; 19 | 20 | /// Total number of event handling attributes used in the application 21 | List get eventAttributes => 22 | _eventAttributes; 23 | 24 | /// Function to add attributes to the register for the application. Usually implemented for custom attributes. 25 | void addAttribute(PheasantAttributeType attribute) { 26 | _attributes.add(attribute); 27 | } 28 | 29 | /// Function to add event-handling attributes to the register for the application. Usually implemented for custom attributes. 30 | void addEventHandlingAttribute(PheasantEventHandlingAttributeType attribute) { 31 | _eventAttributes.add(attribute); 32 | } 33 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/components/components.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | library; 11 | 12 | export 'elements/types.dart'; 13 | export 'attributes/attr.dart'; 14 | export 'render.dart'; 15 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/components/custom/custom.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | import 'dart:html'; 11 | 12 | import 'package:pheasant_temp/src/base.dart'; 13 | import 'package:pheasant_temp/src/state/state.dart'; 14 | 15 | /// Base component for creating a custom component 16 | abstract class PheasantComponent extends PheasantTemplate { 17 | PheasantComponent() : super(template: ""); 18 | 19 | @override 20 | void init() {} 21 | 22 | @override 23 | void del() {} 24 | 25 | // String? styleSheet; 26 | 27 | Element renderComponent([TemplateState? state]); 28 | 29 | Map attributes = {}; 30 | 31 | @override 32 | Element render(String temp, [TemplateState? state]) { 33 | return _render(state); 34 | } 35 | 36 | Element _render([TemplateState? state]) { 37 | return renderComponent(state); 38 | } 39 | } 40 | 41 | typedef AttrFunc = void Function(String value, Element target); 42 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/components/custom/helpers/html.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | import 'dart:html'; 11 | 12 | import 'package:markdown/markdown.dart' as md; 13 | 14 | Element html(String html, 15 | {String parent = 'div', Map attributes = const {}}) { 16 | return _html(parent, html, attributes); 17 | } 18 | 19 | Element _html(String parent, String html, Map attributes) { 20 | return Element.tag(parent) 21 | ..innerHtml = html 22 | ..attributes = attributes; 23 | } 24 | 25 | Element markdown(String markdown, 26 | {String parent = 'div', Map attributes = const {}}) { 27 | return _md(parent, markdown, attributes); 28 | } 29 | 30 | Element _md(String parent, String markdown, Map attributes) { 31 | return Element.tag(parent) 32 | ..innerHtml = md.markdownToHtml(markdown) 33 | ..attributes = attributes; 34 | } 35 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/components/elements/element_list.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | import 'package:pheasant_temp/src/components/elements/types.dart'; 11 | 12 | typedef PheasantElementType = ElementComponentType; 13 | typedef PheasantCustomElementType = CustomComponentType; 14 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/components/render.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/exceptions/exceptions.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | 9 | 10 | import 'package:pheasant_meta/pheasant_meta.dart' show PheasantException; 11 | 12 | /// Pheasant Style Implementation of [PheasantException] for use in this package 13 | /// When build runs, and an exception occurs, the [message] is printed out to the build cli, as seen in the [toString] override. 14 | class PheasantTemplateException extends PheasantException { 15 | int exitCode; 16 | late PheasantTemplateExceptionLevel? level; 17 | 18 | PheasantTemplateException(super.message, 19 | {this.exitCode = 1, int levelNo = 0}) { 20 | switch (levelNo) { 21 | case 0: 22 | level = null; 23 | break; 24 | case 1: 25 | level = PheasantTemplateExceptionLevel.info; 26 | break; 27 | case 2: 28 | level = PheasantTemplateExceptionLevel.warning; 29 | break; 30 | default: 31 | level = PheasantTemplateExceptionLevel.severe; 32 | break; 33 | } 34 | } 35 | } 36 | 37 | enum PheasantTemplateExceptionLevel { info, warning, severe } 38 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/routing/src/pop.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | // https://mit-license.org 9 | 10 | 11 | import 'dart:html'; 12 | 13 | void _onPageChange(void Function(Event event) func, [bool? useCapture]) { 14 | return window.addEventListener( 15 | 'popstate', (event) => func(event), useCapture); 16 | } 17 | 18 | void onBack(void Function(Event event) func) => _onPageChange(func); 19 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/routing/src/push.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | // https://mit-license.org 9 | 10 | 11 | import 'dart:js_interop'; 12 | 13 | import 'shared/helpers.dart'; 14 | 15 | @JS('history.pushState') 16 | external void _pushState(JSObject? state, String? title, String path); 17 | 18 | @JS('history.state') 19 | external JSObject get _histState; 20 | 21 | /// Function used in pushing state 22 | void pushState(Object? state, String? title, String path) { 23 | _pushState( 24 | state == null ? JSObject() : state.jsify() as JSObject, title, path); 25 | } 26 | 27 | /// Function used in getting current state data. 28 | dynamic getStateData() { 29 | return _histState.toDartMap; 30 | } 31 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/routing/src/refresh.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | // https://mit-license.org 9 | 10 | 11 | import 'dart:js_interop'; 12 | 13 | @JS('history.go') 14 | external void _go(int index); 15 | 16 | void _routeTo(int index) => _go(index); 17 | 18 | /// Function used to refresh the current page 19 | void refreshPage() => _routeTo(0); 20 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/routing/src/replace.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | // https://mit-license.org 9 | 10 | 11 | import 'dart:js_interop'; 12 | 13 | @JS('history.replaceState') 14 | external void _replaceState(JSObject? state, String? title, String path); 15 | 16 | /// Function used in replacing state 17 | void replaceState(Object? state, String? title, String path) { 18 | _replaceState( 19 | state == null ? JSObject() : state.jsify() as JSObject, title, path); 20 | } 21 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/routing/src/route.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | // https://mit-license.org 9 | 10 | 11 | import '../routing.dart'; 12 | import 'push.dart'; 13 | import 'replace.dart'; 14 | 15 | export 'pop.dart'; 16 | export 'refresh.dart'; 17 | 18 | /// Initialise current state of page 19 | void initPage(String url, [Object? pageInfo]) { 20 | replaceState(pageInfo, null, url); 21 | } 22 | 23 | /// Function used in navigating to a new page 24 | void navigateTo(String url, [String? title]) { 25 | pushState(null, title, url); 26 | GlobalRoute.currentRoute = url; 27 | } 28 | 29 | /// Function used in navigating to a new page with data 30 | void navigateWith(String url, Object data, [String? title]) { 31 | pushState(data, title, url); 32 | GlobalRoute.currentRoute = url; 33 | } 34 | 35 | /// Function used to get the current page state for a Pheasant Application. 36 | dynamic fetchState() => getStateData(); 37 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/routing/src/shared/current_path.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | // https://mit-license.org 9 | 10 | 11 | import 'dart:js_interop'; 12 | 13 | /// Get the current path of the page 14 | @JS('window.location.pathname') 15 | external String get currentPath; 16 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/routing/src/shared/helpers.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | // https://mit-license.org 9 | 10 | 11 | import 'dart:convert'; 12 | import 'dart:js_interop'; 13 | 14 | @JS('JSON.stringify') 15 | external String _stringify(JSObject object); 16 | 17 | extension MapObj on JSObject { 18 | dynamic get toDartMap => json.decode(_stringify(this)); 19 | } 20 | -------------------------------------------------------------------------------- /packages/pheasant_temp/lib/src/routing/unknown/unknown.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | // https://mit-license.org 9 | 10 | 11 | import 'dart:html'; 12 | 13 | import '../../base.dart'; 14 | import '../../state/state.dart'; 15 | 16 | /// A base implementation for any unknown component, mostly used as a displayable error message. 17 | class UnknownPheasantTemplate extends PheasantTemplate { 18 | UnknownPheasantTemplate() : super(template: ""); 19 | 20 | @override 21 | Element render(String temp, [TemplateState? state]) { 22 | return _errorMessage(); 23 | } 24 | 25 | DivElement _errorMessage() => 26 | DivElement()..text = "This Component Does not Exist"; 27 | } 28 | -------------------------------------------------------------------------------- /packages/pheasant_temp/mono_pkg.yaml: -------------------------------------------------------------------------------- 1 | sdk: 2 | - dev 3 | - pubspec 4 | 5 | stages: 6 | - analyze: 7 | - analyze 8 | - format 9 | - unit_test: 10 | - test 11 | - cron: 12 | - test: 13 | os: 14 | - linux 15 | - windows 16 | -------------------------------------------------------------------------------- /packages/pheasant_temp/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: pheasant_temp 2 | description: >- 3 | The Pheasant Framework Templating Engine to Create Renderable Dart Code for Pheasant Code. 4 | version: 0.1.0-tested 5 | repository: https://github.com/pheasantframework/pheasant/tree/main/pheasant_temp 6 | 7 | environment: 8 | sdk: '>=3.0.0 <4.0.0' 9 | 10 | # Add regular dependencies here. 11 | dependencies: 12 | analyzer: ^6.3.0 13 | code_builder: ^4.9.0 14 | dart_style: ^2.3.4 15 | html: ^0.15.4 16 | markdown: ^7.1.1 17 | pheasant_meta: ^0.1.0-beta.1 18 | pheasant_assets: ^0.1.0-beta 19 | 20 | dev_dependencies: 21 | lints: ^4.0.0 22 | test: ^1.24.0 23 | 24 | topics: 25 | - pheasant 26 | - web -------------------------------------------------------------------------------- /packages/pheasant_temp/test/benchmark/main_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | // https://mit-license.org 9 | 10 | @Timeout(Duration(seconds: 1)) 11 | 12 | import 'dart:developer'; 13 | 14 | import 'package:pheasant_temp/pheasant_temp.dart'; 15 | import 'package:test/test.dart'; 16 | 17 | void main() { 18 | log('Pheasant Benchmark Tests for: renderMain'); 19 | group('speed test', () { 20 | List results = List.filled(5, ''); 21 | 22 | test('speed run', () { 23 | final Stopwatch stopwatch = Stopwatch()..start(); 24 | 25 | results[0] = renderMain(); 26 | log('Result 1: ${stopwatch.elapsedMilliseconds}ms'); 27 | stopwatch.reset(); 28 | 29 | results[1] = renderMain(appName: "HomeComponent"); 30 | log('Result 2: ${stopwatch.elapsedMilliseconds}ms'); 31 | stopwatch.reset(); 32 | 33 | results[2] = renderMain( 34 | appName: 35 | "ThisIsAnExtremelyLongClassNameThatServesNoPracticalPurposeButIsUsedHereForDemonstrationPurposesComponent"); 36 | log('Result 3: ${stopwatch.elapsedMilliseconds}ms'); 37 | stopwatch.reset(); 38 | 39 | results[3] = renderMain(appName: "HomeComponent", mainEntry: "Home.phs"); 40 | log('Result 4: ${stopwatch.elapsedMilliseconds}ms'); 41 | stopwatch.reset(); 42 | 43 | results[4] = renderMain( 44 | appName: 45 | "ThisIsAnExtremelyLongClassNameThatServesNoPracticalPurposeButIsUsedHereForDemonstrationPurposesComponent", 46 | mainEntry: 47 | "ThisIsAnExtremelyLongClassNameThatServesNoPracticalPurposeButIsUsedHereForDemonstrationPurposes.phs"); 48 | log('Result 5: ${stopwatch.elapsedMilliseconds}ms'); 49 | stopwatch.stop(); 50 | }); 51 | }); 52 | } 53 | -------------------------------------------------------------------------------- /packages/pheasant_temp/test/main/build_file_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | // https://mit-license.org 9 | 10 | @TestOn('browser') 11 | @Tags(['browser']) 12 | 13 | import 'package:test/test.dart'; 14 | import 'package:pheasant_temp/pheasant_build.dart'; 15 | 16 | import 'dart:html'; 17 | 18 | class TestComponent extends PheasantTemplate { 19 | TestComponent({super.template}); 20 | 21 | @override 22 | String? template = ''' 23 |
24 |

Hello

25 |

Welcome to Pheasant Template Tests

26 |
27 | '''; 28 | 29 | @override 30 | Element render(String temp, [TemplateState? state]) { 31 | return DivElement() 32 | ..children = [ 33 | ParagraphElement()..text = "Hello", 34 | ParagraphElement()..text = "Welcome to Pheasant Template Test" 35 | ]; 36 | } 37 | } 38 | 39 | void main() { 40 | group('html group tests', () { 41 | var testComponent = TestComponent(); 42 | test('html test', () { 43 | assert(testComponent.template != null); 44 | 45 | querySelector('#input') 46 | ?.children 47 | .add(testComponent.render(testComponent.template!)); 48 | 49 | expect(document.body?.children, isNotEmpty); 50 | expect(querySelector('#input')?.children, isNotEmpty); 51 | 52 | expect( 53 | querySelector('#input')?.innerHtml, contains(testComponent.template)); 54 | }); 55 | }); 56 | } 57 | -------------------------------------------------------------------------------- /packages/pheasant_temp/test/main/build_file_test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Custom Pheasant Template Test 6 | 7 | 8 | 9 | 10 |
11 | 12 | -------------------------------------------------------------------------------- /packages/pheasant_temp/test/main/main_file_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 The Pheasant Group. All Rights Reserved. 2 | // Please see the AUTHORS files for more information. 3 | // Intellectual property of third-party. 4 | // 5 | // This file, as well as use of the code in it, is governed by an MIT License 6 | // that can be found in the LICENSE file. 7 | // You may use this file only in accordance with the license. 8 | // https://mit-license.org 9 | 10 | import 'package:pheasant_temp/pheasant_temp.dart' show renderMain; 11 | import 'package:test/test.dart'; 12 | 13 | void main() { 14 | group('main file tests', () { 15 | String output = renderMain(); 16 | 17 | test('import directives', () { 18 | expect(output, contains("import 'App.phs.dart';")); 19 | expect(output, contains("import 'package:pheasant/build.dart'")); 20 | }); 21 | 22 | test('body of file', () { 23 | expect(output, contains('''_i1.PheasantTemplate get App { 24 | return AppComponent(); 25 | }''')); 26 | }); 27 | }); 28 | 29 | group('defined main file tests', () { 30 | String appName = "CoreComponent"; 31 | String mainEntry = "Core.phs"; 32 | 33 | String output = renderMain(appName: appName, mainEntry: mainEntry); 34 | 35 | test('import directives', () { 36 | expect(output, contains("import 'Core.phs.dart';")); 37 | expect(output, contains("import 'package:pheasant/build.dart'")); 38 | }); 39 | 40 | test('body of file', () { 41 | expect(output, contains('''_i1.PheasantTemplate get App { 42 | return CoreComponent(); 43 | }''')); 44 | }); 45 | }); 46 | } 47 | -------------------------------------------------------------------------------- /pheasant.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | } 6 | ], 7 | "settings": {} 8 | } -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: pheasant_workspace 2 | 3 | environment: 4 | sdk: '>=3.0.0 <4.0.0' --------------------------------------------------------------------------------