-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
287 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use anyhow::{Context, Result}; | ||
|
||
use crate::asset::{Asset, AssetVc}; | ||
|
||
/// An asset that should be outputted, e. g. written to disk or served from a | ||
/// server. | ||
#[turbo_tasks::value_trait] | ||
pub trait OutputAsset: Asset {} | ||
|
||
#[turbo_tasks::value(transparent)] | ||
pub struct OutputAssets(Vec<OutputAssetVc>); | ||
|
||
#[turbo_tasks::value_impl] | ||
impl OutputAssetsVc { | ||
#[turbo_tasks::function] | ||
pub fn empty() -> Self { | ||
Self::cell(Vec::new()) | ||
} | ||
} | ||
|
||
/// This is a temporary function that should be removed once the [OutputAsset] | ||
/// trait completely replaces the [Asset] trait. | ||
/// TODO make this function unnecessary | ||
#[turbo_tasks::function] | ||
pub async fn asset_to_output_asset(asset: AssetVc) -> Result<OutputAssetVc> { | ||
OutputAssetVc::resolve_from(asset) | ||
.await? | ||
.context("Asset must be a OutputAsset") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use crate::{ | ||
asset::{Asset, AssetContentVc, AssetVc}, | ||
ident::AssetIdentVc, | ||
output::{OutputAsset, OutputAssetVc}, | ||
source::SourceVc, | ||
}; | ||
|
||
/// A module where source code doesn't need to be parsed but can be used as is. | ||
/// This module has no references to other modules. | ||
#[turbo_tasks::value] | ||
pub struct RawOutput { | ||
source: SourceVc, | ||
} | ||
|
||
#[turbo_tasks::value_impl] | ||
impl OutputAsset for RawOutput {} | ||
|
||
#[turbo_tasks::value_impl] | ||
impl Asset for RawOutput { | ||
#[turbo_tasks::function] | ||
fn ident(&self) -> AssetIdentVc { | ||
self.source.ident() | ||
} | ||
|
||
#[turbo_tasks::function] | ||
fn content(&self) -> AssetContentVc { | ||
self.source.content() | ||
} | ||
} | ||
|
||
#[turbo_tasks::value_impl] | ||
impl RawOutputVc { | ||
#[turbo_tasks::function] | ||
pub fn new(source: SourceVc) -> RawOutputVc { | ||
RawOutput { source }.cell() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.