Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2e75441058 | ||
|
|
eafef848c8 | ||
|
|
5341bfb2b3 | ||
|
|
11d8e884f7 | ||
|
|
c762161646 | ||
|
|
c489e8c650 | ||
|
|
17373314ae | ||
|
|
931a8b925c | ||
|
|
0e1991de6d | ||
|
|
d950e57352 | ||
|
|
652146ad96 | ||
|
|
dafe769cda | ||
|
|
ad9b10ba94 | ||
|
|
3880127f68 |
No files matched your search
@@ -34,7 +34,6 @@ artcraft-services/
|
||||
├── frontend/
|
||||
│ ├── apps/artcraft-webapp/ # Browser application at app.getartcraft.com
|
||||
│ ├── apps/artcraft-website-next/ # Current public website at getartcraft.com (Next.js)
|
||||
│ ├── apps/artcraft-website/ # Legacy product website (Vite)
|
||||
│ ├── apps/artcraft-desktop-website/ # Static landing page at desktop.getartcraft.com (Vite)
|
||||
│ └── libs/ # Shared React components and TypeScript libraries
|
||||
└── Cargo.toml # Rust workspace
|
||||
@@ -42,9 +41,9 @@ artcraft-services/
|
||||
|
||||
## Updating Desktop Download Links
|
||||
|
||||
Desktop release links are configured independently in **three places**. When
|
||||
Desktop release links are configured independently in **two places**. When
|
||||
updating the advertised ArtCraft release, update both `WINDOWS_VERSION` and
|
||||
`MAC_VERSION` in all three unless the request explicitly targets one platform or
|
||||
`MAC_VERSION` in both unless the request explicitly targets one platform or
|
||||
app:
|
||||
|
||||
1. **Current public website (Next.js):**
|
||||
@@ -52,11 +51,7 @@ app:
|
||||
This controls the installer links and visible version at
|
||||
`https://getartcraft.com/download`. Add the release to `DOWNLOAD_HISTORY`
|
||||
(newest first), then update both version selectors.
|
||||
2. **Legacy website (Vite):**
|
||||
[frontend/apps/artcraft-website/src/config/github_download_links.ts](frontend/apps/artcraft-website/src/config/github_download_links.ts).
|
||||
Add the release to `DOWNLOAD_HISTORY` and update both version selectors.
|
||||
Updating only this file does **not** update the current public website.
|
||||
3. **Browser webapp:**
|
||||
2. **Browser webapp:**
|
||||
[frontend/apps/artcraft-webapp/src/config/github_download_links.ts](frontend/apps/artcraft-webapp/src/config/github_download_links.ts).
|
||||
Update both version constants; these links are used by the welcome and
|
||||
checkout-success pages at `app.getartcraft.com`.
|
||||
@@ -65,7 +60,7 @@ Keep previous releases for rollback. The Next.js download page reads its visible
|
||||
version from `DOWNLOAD_VERSIONS`, which uses the same selectors as the URLs; do
|
||||
not hardcode a separate version in the page component.
|
||||
|
||||
Check that all three configs produce the requested release tag and installer
|
||||
Check that both configs produce the requested release tag and installer
|
||||
filenames for Windows (`ArtCraft_<version>_x64-setup.exe`) and macOS
|
||||
(`ArtCraft_<version>_universal.dmg`). Run `npm run typecheck` from
|
||||
`frontend/apps/artcraft-website-next` after changing its config. Repository edits
|
||||
@@ -89,6 +84,11 @@ report a local update as a deployed update.
|
||||
|
||||
Organize for top-to-bottom reading. Important things first, details later.
|
||||
|
||||
- **`mod.rs` holds module declarations only** (`pub mod foo;`, plus re-exports if needed). Never
|
||||
put functions, structs, enums, constants, impls or tests in a `mod.rs`: give each its own file
|
||||
in that directory (for example `threads/poll_foo_thread/poll_foo.rs`, declared from
|
||||
`threads/poll_foo_thread/mod.rs`).
|
||||
|
||||
- **Constants** at the top (after imports)
|
||||
- **Structs/enums** next; outer structs above inner sub-structs
|
||||
- **API types** in order: Request, Response, Error
|
||||
|
||||
@@ -104,7 +104,7 @@ and signals for state, Three.js for 3D scenes, and shared UI and generation tool
|
||||
| Path | Purpose |
|
||||
|----------------------------------|-----------------------------------------------|
|
||||
| `frontend/apps/artcraft-webapp` | Browser application at `app.getartcraft.com` |
|
||||
| `frontend/apps/artcraft-website` | Product website at `getartcraft.com` |
|
||||
| `frontend/apps/artcraft-website-next` | Product website at `getartcraft.com` (Next.js) |
|
||||
| `frontend/libs/api` | HTTP clients, API host selection, and models |
|
||||
| `frontend/libs/omni-gen` | Shared generation logic |
|
||||
| `frontend/libs/components` | Reusable UI, editors, and generation controls |
|
||||
@@ -190,14 +190,11 @@ The browser app runs at `http://localhost:4201`. `VITE_USE_LOCAL_API=true` selec
|
||||
the hosted API. API host selection lives in
|
||||
[`StorytellerApiHostStore`](./frontend/libs/api/src/lib/config/StorytellerApiHostStore.ts).
|
||||
|
||||
From `frontend`, build the web app or run the product website with:
|
||||
From `frontend`, build the web app with `npx nx build artcraft-webapp`. The
|
||||
product website is a standalone Next.js app (not part of the Nx workspace); run it
|
||||
from the repository root with `./script/website/unix_frontend_website_dev.sh`.
|
||||
|
||||
```bash
|
||||
npx nx build artcraft-webapp
|
||||
npx nx dev artcraft-website
|
||||
```
|
||||
|
||||
The website runs at `http://localhost:4200`. Repository-root launchers are in
|
||||
The website runs at `http://localhost:3000`. Repository-root launchers are in
|
||||
[`script/website`](./script/website). For desktop development, use the
|
||||
[ArtCraft desktop repository](https://github.com/storytold/artcraft).
|
||||
|
||||
|
||||
@@ -255,7 +255,6 @@ From the services repository:
|
||||
SQLX_OFFLINE=true cargo test --offline -p storyteller-web --bin storyteller-web login_challenges
|
||||
cd frontend
|
||||
npm exec vitest -- run --config apps/artcraft-webapp/vite.config.ts src/pages/login/desktop-login.spec.tsx src/pages/login/login-bridge-continuation.spec.tsx
|
||||
npm exec vitest -- run --config apps/artcraft-website/vite.config.ts src/pages/login/desktop-login.spec.tsx
|
||||
```
|
||||
|
||||
`SQLX_OFFLINE` controls compile-time query metadata only. These tests still execute
|
||||
|
||||
@@ -35,6 +35,6 @@ VITE_USE_LOCAL_API=true npx nx dev artcraft-webapp
|
||||
The web app runs at `http://localhost:4201`, using the local backend. To develop
|
||||
against the hosted API, omit `VITE_USE_LOCAL_API=true`.
|
||||
|
||||
For the product website, run `npx nx dev artcraft-website` from `frontend`; it uses
|
||||
`http://localhost:4200`. Repository-root launchers live under [`script/website`](../script/website).
|
||||
For the product website, run `./script/website/unix_frontend_website_dev.sh` from the
|
||||
repository root; it is a standalone Next.js app on `http://localhost:3000`. Repository-root launchers live under [`script/website`](../script/website).
|
||||
See the [frontend README](../frontend/README.md) for builds and troubleshooting.
|
||||
@@ -0,0 +1 @@
|
||||
pub mod release_info;
|
||||
@@ -0,0 +1,203 @@
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
// ── GET /v1/craft_apps/release_info ──
|
||||
//
|
||||
// The latest release of every Craft App (PhotoCraft, VectorCraft, …, and ArtCraft Launcher
|
||||
// itself), as storyteller-web last fetched it from GitHub, plus renames and notices for the
|
||||
// ArtCraft Launcher. The launcher polls this instead of GitHub; GitHub is its fallback.
|
||||
//
|
||||
// Compatibility: clients must ignore fields they don't know, and treat every field as optional.
|
||||
// New fields may be added; existing ones keep their meaning.
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, ToSchema)]
|
||||
pub struct GetCraftAppsReleaseInfoResponse {
|
||||
pub success: bool,
|
||||
|
||||
pub release_info: CraftAppsReleaseInfo,
|
||||
|
||||
/// Apps that changed their name (for example PdfCraft → DocuCraft).
|
||||
pub app_renames: Vec<CraftAppRename>,
|
||||
|
||||
/// Apps whose GitHub repository moved (for example `storytold/photocraft` → `art/photocraft`).
|
||||
pub repo_renames: Vec<CraftAppRepoRename>,
|
||||
|
||||
pub important_notices: CraftAppsImportantNotices,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, Serialize, Deserialize, ToSchema)]
|
||||
pub struct CraftAppsReleaseInfo {
|
||||
/// Keyed by app key: the app's lowercase machine name, as used in its binaries, asset file
|
||||
/// names and `ai.storyteller.<key>` bundle id (`photocraft`, `cadcraft`, `artcraft-launcher`).
|
||||
/// Not the display name and not the repo name. Clients should ignore keys they don't know.
|
||||
pub apps: BTreeMap<String, CraftAppReleaseInfo>,
|
||||
|
||||
/// When the least recently fetched app was fetched: every app's data is at least this fresh.
|
||||
/// Absent until every app has been fetched at least once.
|
||||
pub last_fetched: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, ToSchema)]
|
||||
pub struct CraftAppReleaseInfo {
|
||||
/// Display name (`PhotoCraft`).
|
||||
pub name: String,
|
||||
|
||||
/// GitHub repository, `organization/project` (`storytold/photocraft`).
|
||||
pub repo: String,
|
||||
|
||||
/// The latest published, non-draft, non-prerelease release. Absent when the repository has no
|
||||
/// release yet, or when it hasn't been fetched yet (see `app_last_fetched`).
|
||||
pub latest_release: Option<CraftAppRelease>,
|
||||
|
||||
/// When this app's release data was last fetched successfully. Absent if it never was; then
|
||||
/// `latest_release` says nothing and clients should ask GitHub themselves.
|
||||
pub app_last_fetched: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, ToSchema)]
|
||||
pub struct CraftAppRelease {
|
||||
/// Git tag (`v0.5.0`).
|
||||
pub tag: String,
|
||||
|
||||
/// The tag without its leading `v` (`0.5.0`, `0.6.0-rc.1`).
|
||||
pub version: String,
|
||||
|
||||
/// Release title (`PhotoCraft v0.5.0`).
|
||||
pub name: String,
|
||||
|
||||
pub published_at: Option<DateTime<Utc>>,
|
||||
|
||||
/// The release's page on GitHub.
|
||||
pub html_url: String,
|
||||
|
||||
pub prerelease: bool,
|
||||
|
||||
/// Release notes (Markdown), truncated to 64 KiB.
|
||||
pub notes_markdown: String,
|
||||
|
||||
pub assets: Vec<CraftAppReleaseAsset>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, ToSchema)]
|
||||
pub struct CraftAppReleaseAsset {
|
||||
/// File name (`photocraft-0.5.0-windows-x64.msi`).
|
||||
pub name: String,
|
||||
|
||||
pub size_bytes: u64,
|
||||
|
||||
/// `https://github.com/<repo>/releases/download/<tag>/<name>`.
|
||||
pub download_url: String,
|
||||
|
||||
/// Lowercase hex SHA-256, when GitHub published one for the file.
|
||||
pub sha256: Option<String>,
|
||||
|
||||
/// What the file name says it is, when it follows the Craft App naming scheme
|
||||
/// (`<app>-<version>-<os>-<arch>[-portable].<ext>`).
|
||||
pub platform: Option<CraftAppAssetPlatform>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, ToSchema)]
|
||||
pub struct CraftAppAssetPlatform {
|
||||
pub os: CraftAppOs,
|
||||
|
||||
/// Absent for files that aren't for one CPU (the web build, checksums).
|
||||
pub arch: Option<CraftAppArch>,
|
||||
|
||||
pub package_type: CraftAppPackageType,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, ToSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum CraftAppOs {
|
||||
Windows,
|
||||
Macos,
|
||||
Linux,
|
||||
Freebsd,
|
||||
/// The browser build.
|
||||
Web,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, ToSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum CraftAppArch {
|
||||
X64,
|
||||
X86,
|
||||
Arm64,
|
||||
/// macOS universal binary (Apple silicon and Intel).
|
||||
Universal,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, ToSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum CraftAppPackageType {
|
||||
/// Windows Installer.
|
||||
Msi,
|
||||
/// Windows portable zip.
|
||||
PortableZip,
|
||||
/// macOS disk image.
|
||||
Dmg,
|
||||
/// macOS command-line tools zip.
|
||||
CliZip,
|
||||
AppImage,
|
||||
/// AppImage delta-update file.
|
||||
AppImageZsync,
|
||||
Deb,
|
||||
Rpm,
|
||||
Flatpak,
|
||||
/// Linux or FreeBSD tarball.
|
||||
TarGz,
|
||||
/// The web (WebAssembly) build.
|
||||
WebZip,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, ToSchema)]
|
||||
pub struct CraftAppRename {
|
||||
/// User-facing name before (`PdfCraft`).
|
||||
pub old_name: String,
|
||||
/// Lowercase name before (`pdfcraft`).
|
||||
pub old_name_lower: String,
|
||||
/// User-facing name after (`DocuCraft`).
|
||||
pub new_name: String,
|
||||
/// Lowercase name after (`docucraft`).
|
||||
pub new_name_lower: String,
|
||||
/// A sentence or two to show beside the rename.
|
||||
pub description: String,
|
||||
pub renamed_at: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, ToSchema)]
|
||||
pub struct CraftAppRepoRename {
|
||||
/// `organization/project` before.
|
||||
pub old_name: String,
|
||||
/// `organization/project` after.
|
||||
pub new_name: String,
|
||||
pub renamed_at: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, Serialize, Deserialize, ToSchema)]
|
||||
pub struct CraftAppsImportantNotices {
|
||||
/// News, shown inline; the user can dismiss each.
|
||||
pub announcements: Vec<CraftAppsAnnouncement>,
|
||||
/// Shown as a popup the user acknowledges.
|
||||
pub alerts: Vec<CraftAppsAlert>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, ToSchema)]
|
||||
pub struct CraftAppsAnnouncement {
|
||||
pub title: String,
|
||||
pub body: String,
|
||||
pub created_at: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, ToSchema)]
|
||||
pub struct CraftAppsAlert {
|
||||
pub title: String,
|
||||
pub body: String,
|
||||
/// A page the popup can offer to open.
|
||||
pub maybe_web_link: Option<Url>,
|
||||
pub created_at: Option<DateTime<Utc>>,
|
||||
}
|
||||
@@ -2,6 +2,7 @@ pub mod analytics;
|
||||
pub mod api_keys;
|
||||
pub mod characters;
|
||||
pub mod common;
|
||||
pub mod craft_apps;
|
||||
pub mod credits;
|
||||
pub mod folders;
|
||||
pub mod generate;
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
use std::str::FromStr;
|
||||
use std::time::Duration;
|
||||
|
||||
use log::info;
|
||||
|
||||
use errors::AnyhowResult;
|
||||
use shared_env_var_config::mysql::env_get_mysql_connection_string_or_default;
|
||||
use sqlx::mysql::MySqlPoolOptions;
|
||||
use sqlx::mysql::{MySqlConnectOptions, MySqlPoolOptions};
|
||||
use sqlx::MySqlPool;
|
||||
|
||||
pub async fn connect_to_database() -> AnyhowResult<MySqlPool> {
|
||||
@@ -20,20 +21,37 @@ pub async fn connect_to_database() -> AnyhowResult<MySqlPool> {
|
||||
// shorter timeout sheds load and surfaces the problem instead of hiding it behind long waits.
|
||||
let acquire_timeout_seconds = easyenv::get_env_num::<u64>("MYSQL_ACQUIRE_TIMEOUT_SECONDS", 10)?;
|
||||
|
||||
// NB: Every cached prepared statement stays open on the server until its connection evicts it
|
||||
// or closes, and the server caps the total across ALL clients (`max_prepared_stmt_count`,
|
||||
// 16382 on the managed DB). sqlx's default of 100 per connection let `replicas *
|
||||
// MYSQL_MAX_CONNECTIONS * 100` blow past that cap, failing new prepares with MySQL error 1461.
|
||||
// Keep `replicas * MYSQL_MAX_CONNECTIONS * MYSQL_STATEMENT_CACHE_CAPACITY` well under it.
|
||||
let statement_cache_capacity = easyenv::get_env_num::<usize>("MYSQL_STATEMENT_CACHE_CAPACITY", 25)?;
|
||||
|
||||
// NB: Recycling connections releases any server-side statements orphaned by cancelled queries
|
||||
// (eg. a client disconnect between prepare and close). sqlx's default lifetime is 30 minutes.
|
||||
let max_lifetime_seconds = easyenv::get_env_num::<u64>("MYSQL_MAX_LIFETIME_SECONDS", 600)?;
|
||||
|
||||
// NB: Log the settings before building/connecting so a connect failure has context. We do NOT
|
||||
// log the connection string (it contains credentials).
|
||||
info!(
|
||||
"Building MySQL pool: max_connections={}, min_connections={}, acquire_timeout_seconds={}",
|
||||
"Building MySQL pool: max_connections={}, min_connections={}, acquire_timeout_seconds={}, \
|
||||
statement_cache_capacity={}, max_lifetime_seconds={}",
|
||||
max_connections, min_connections, acquire_timeout_seconds,
|
||||
statement_cache_capacity, max_lifetime_seconds,
|
||||
);
|
||||
|
||||
let connect_options = MySqlConnectOptions::from_str(&db_connection_string)?
|
||||
.statement_cache_capacity(statement_cache_capacity);
|
||||
|
||||
let pool_options = MySqlPoolOptions::new()
|
||||
.max_connections(max_connections)
|
||||
.min_connections(min_connections)
|
||||
.acquire_timeout(Duration::from_secs(acquire_timeout_seconds));
|
||||
.acquire_timeout(Duration::from_secs(acquire_timeout_seconds))
|
||||
.max_lifetime(Some(Duration::from_secs(max_lifetime_seconds)));
|
||||
|
||||
let pool = pool_options
|
||||
.connect(&db_connection_string)
|
||||
.connect_with(connect_options)
|
||||
.await?;
|
||||
|
||||
Ok(pool)
|
||||
|
||||
@@ -162,6 +162,7 @@ use artcraft_api_defs::moderation::user_daily_spends::user_daily_spends_list::*;
|
||||
use artcraft_api_defs::moderation::top_spenders::list::*;
|
||||
use artcraft_api_defs::moderation::user_spend_events::list::*;
|
||||
use artcraft_api_defs::folders::subfolder::*;
|
||||
use artcraft_api_defs::craft_apps::release_info::*;
|
||||
use artcraft_api_defs::tags::add_media_file_tags::*;
|
||||
use artcraft_api_defs::tags::bulk_add_tags::*;
|
||||
use artcraft_api_defs::tags::bulk_list_media_file_tags::*;
|
||||
@@ -734,6 +735,9 @@ use crate::http_server::endpoints::media_files::list::list_batch_generated_redux
|
||||
crate::http_server::endpoints::folders::media_files::bulk_move_folder_media_files_handler::bulk_move_folder_media_files_handler,
|
||||
crate::http_server::endpoints::folders::media_files::bulk_remove_folder_media_files_handler::bulk_remove_folder_media_files_handler,
|
||||
|
||||
// Craft Apps
|
||||
crate::http_server::endpoints::craft_apps::get_craft_apps_release_info_handler::get_craft_apps_release_info_handler,
|
||||
|
||||
// Tags
|
||||
crate::http_server::endpoints::tags::list_tags_handler::list_tags_handler,
|
||||
crate::http_server::endpoints::tags::list_media_file_tags_handler::list_media_file_tags_handler,
|
||||
@@ -1606,6 +1610,20 @@ use crate::http_server::endpoints::media_files::list::list_batch_generated_redux
|
||||
ListTaggedMediaFilesSuccessResponse,
|
||||
ListTagsQueryParams,
|
||||
ListTagsSuccessResponse,
|
||||
GetCraftAppsReleaseInfoResponse,
|
||||
CraftAppsReleaseInfo,
|
||||
CraftAppReleaseInfo,
|
||||
CraftAppRelease,
|
||||
CraftAppReleaseAsset,
|
||||
CraftAppAssetPlatform,
|
||||
CraftAppOs,
|
||||
CraftAppArch,
|
||||
CraftAppPackageType,
|
||||
CraftAppRename,
|
||||
CraftAppRepoRename,
|
||||
CraftAppsImportantNotices,
|
||||
CraftAppsAnnouncement,
|
||||
CraftAppsAlert,
|
||||
ListUntaggedMediaFilesQueryParams,
|
||||
ListUntaggedMediaFilesSuccessResponse,
|
||||
MediaFileTagsEntry,
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use actix_web::http::header::{CacheControl, CacheDirective};
|
||||
use actix_web::{web, HttpResponse};
|
||||
|
||||
use artcraft_api_defs::craft_apps::release_info::{CraftAppsImportantNotices, GetCraftAppsReleaseInfoResponse};
|
||||
|
||||
use crate::state::server_state::ServerState;
|
||||
|
||||
/// Shared caches (Cloudflare) may serve the same answer for this long: the data changes at most
|
||||
/// once per polling round (30 minutes by default).
|
||||
const CACHE_MAX_AGE_SECS: u32 = 60;
|
||||
|
||||
/// The latest release of every Craft App (and ArtCraft Launcher), as storyteller-web last fetched
|
||||
/// it from GitHub, plus app/repo renames and notices for the launcher. Never fails: before the
|
||||
/// first fetch, apps are listed without a release and without `app_last_fetched`.
|
||||
#[utoipa::path(
|
||||
get,
|
||||
tag = "Craft Apps",
|
||||
path = "/v1/craft_apps/release_info",
|
||||
responses(
|
||||
(status = 200, body = GetCraftAppsReleaseInfoResponse),
|
||||
),
|
||||
)]
|
||||
pub async fn get_craft_apps_release_info_handler(
|
||||
server_state: web::Data<Arc<ServerState>>,
|
||||
) -> HttpResponse {
|
||||
let response = GetCraftAppsReleaseInfoResponse {
|
||||
success: true,
|
||||
release_info: server_state.craft_apps_release_cache.snapshot(),
|
||||
// None yet. When there are, they're listed here (newest first).
|
||||
app_renames: Vec::new(),
|
||||
repo_renames: Vec::new(),
|
||||
important_notices: CraftAppsImportantNotices::default(),
|
||||
};
|
||||
HttpResponse::Ok()
|
||||
.insert_header(CacheControl(vec![CacheDirective::Public, CacheDirective::MaxAge(CACHE_MAX_AGE_SECS)]))
|
||||
.json(response)
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
pub mod get_craft_apps_release_info_handler;
|
||||
@@ -5,6 +5,7 @@ pub mod beta_keys;
|
||||
pub mod billing_fakeyou;
|
||||
pub mod characters;
|
||||
pub mod comments;
|
||||
pub mod craft_apps;
|
||||
pub mod credits;
|
||||
pub mod dev;
|
||||
pub mod download_job;
|
||||
|
||||
@@ -63,6 +63,7 @@ use crate::startup::setup_inference_providers::{
|
||||
use crate::startup::setup_pager::build_pager;
|
||||
use crate::startup::setup_static_feature_flags::setup_static_feature_flags;
|
||||
use crate::state::certs::google_sign_in_cert::GoogleSignInCert;
|
||||
use crate::state::craft_apps_release_cache::CraftAppsReleaseCache;
|
||||
use crate::state::memory_cache::model_token_to_info_cache::ModelTokenToInfoCache;
|
||||
use crate::state::server_state::{
|
||||
Dashboards, DataboxDashboards, DurableInMemoryCaches, EnvConfig, EphemeralInMemoryCaches,
|
||||
@@ -702,6 +703,7 @@ pub(crate) fn build_test_server_state(pool: MySqlPool, media_cdn_override_url: S
|
||||
sort_key_crypto: WebSortKeyCrypto::new("test-sort-key"),
|
||||
opaque_cursors: WebOpaqueCursorEncoderV2::new("test-sort-key"),
|
||||
ip_ban_list: IpBanList::new(),
|
||||
craft_apps_release_cache: CraftAppsReleaseCache::new(),
|
||||
cidr_ban_set: BannedCidrSet::new(),
|
||||
troll_bans: TrollBans {
|
||||
user_tokens: TrollUserBanList::new(),
|
||||
|
||||
@@ -3,6 +3,7 @@ use crate::http_server::routes::application_routes::api_keys_routes::add_api_key
|
||||
use crate::http_server::routes::application_routes::billing_fakeyou_routes::add_billing_fakeyou_routes;
|
||||
use crate::http_server::routes::application_routes::character_routes::add_character_routes;
|
||||
use crate::http_server::routes::application_routes::comments_routes::add_comments_routes;
|
||||
use crate::http_server::routes::application_routes::craft_apps_routes::add_craft_apps_routes;
|
||||
use crate::http_server::routes::application_routes::credits_routes::add_credits_routes;
|
||||
use crate::http_server::routes::application_routes::dev_routes::add_dev_routes;
|
||||
use crate::http_server::routes::application_routes::featured_item_routes::add_featured_item_routes;
|
||||
@@ -76,6 +77,7 @@ where
|
||||
app = add_video_info_routes(app); // /v1/video_info/... (video provenance detection)
|
||||
app = add_analytics_routes(app); // /v1/analytics/...
|
||||
app = add_web_referrals_routes(app); // /v1/web_referrals/...
|
||||
app = add_craft_apps_routes(app); // /v1/craft_apps/... (ArtCraft Launcher release info)
|
||||
app = add_dev_routes(app); // /v1/dev/... — dev-only error/response shape probes
|
||||
|
||||
// User and user-adjacent routes
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
use actix_http::body::MessageBody;
|
||||
use actix_service::ServiceFactory;
|
||||
use actix_web::dev::{ServiceRequest, ServiceResponse};
|
||||
use actix_web::{web, App, Error, HttpResponse};
|
||||
|
||||
use crate::http_server::endpoints::craft_apps::get_craft_apps_release_info_handler::get_craft_apps_release_info_handler;
|
||||
|
||||
pub fn add_craft_apps_routes<T, B>(app: App<T>) -> App<T>
|
||||
where
|
||||
B: MessageBody,
|
||||
T: ServiceFactory<
|
||||
ServiceRequest,
|
||||
Config = (),
|
||||
Response = ServiceResponse<B>,
|
||||
Error = Error,
|
||||
InitError = (),
|
||||
>,
|
||||
{
|
||||
app.service(
|
||||
web::scope("/v1/craft_apps")
|
||||
// Release info for ArtCraft Launcher (polled instead of GitHub).
|
||||
.service(
|
||||
web::resource("/release_info")
|
||||
.route(web::get().to(get_craft_apps_release_info_handler))
|
||||
.route(web::head().to(|| HttpResponse::Ok())),
|
||||
),
|
||||
)
|
||||
}
|
||||
@@ -3,6 +3,7 @@ mod api_keys_routes;
|
||||
mod billing_fakeyou_routes;
|
||||
mod character_routes;
|
||||
mod comments_routes;
|
||||
mod craft_apps_routes;
|
||||
mod credits_routes;
|
||||
mod dev_routes;
|
||||
mod featured_item_routes;
|
||||
|
||||
@@ -56,6 +56,8 @@ use crate::startup::setup_metrics::build_metrics;
|
||||
use crate::state::server_state::ServerState;
|
||||
use crate::threads::db_health_checker_thread::db_health_checker_thread::db_health_checker_thread;
|
||||
use crate::threads::expire_login_challenges::expire_login_challenges;
|
||||
use crate::threads::poll_craft_app_releases_thread::config::CraftAppsPollConfig;
|
||||
use crate::threads::poll_craft_app_releases_thread::poll_craft_app_releases::poll_craft_app_releases;
|
||||
use crate::threads::poll_ip_banlist_thread::poll_ip_bans;
|
||||
use crate::threads::poll_model_token_info_thread::poll_model_token_info_thread;
|
||||
|
||||
@@ -150,6 +152,15 @@ async fn main() -> AnyhowResult<()> {
|
||||
poll_model_token_info_thread(model_token_info_cache_clone, mysql_pool_clone).await;
|
||||
});
|
||||
|
||||
info!("Spawning craft app release polling thread.");
|
||||
|
||||
let craft_apps_release_cache_clone = server_state.craft_apps_release_cache.clone();
|
||||
let craft_apps_poll_config = CraftAppsPollConfig::from_env();
|
||||
|
||||
tokio_runtime.spawn(async move {
|
||||
poll_craft_app_releases(craft_apps_release_cache_clone, craft_apps_poll_config).await;
|
||||
});
|
||||
|
||||
// ==================== Metrics worker ==================== //
|
||||
|
||||
let (metrics_collector, maybe_metrics_worker) =
|
||||
|
||||
@@ -41,6 +41,7 @@ use crate::startup::setup_static_feature_flags::setup_static_feature_flags;
|
||||
use crate::startup::setup_stripe_artcraft::setup_stripe_artcraft;
|
||||
use crate::startup::setup_stripe_fakeyou::setup_stripe_fakeyou;
|
||||
use crate::state::certs::google_sign_in_cert::GoogleSignInCert;
|
||||
use crate::state::craft_apps_release_cache::CraftAppsReleaseCache;
|
||||
use crate::state::memory_cache::model_token_to_info_cache::ModelTokenToInfoCache;
|
||||
use crate::state::server_state::{
|
||||
DurableInMemoryCaches, EnvConfig, EphemeralInMemoryCaches,
|
||||
@@ -259,6 +260,7 @@ pub async fn setup_dependencies(server_hostname: &str) -> AnyhowResult<SetupResu
|
||||
}
|
||||
},
|
||||
ip_ban_list,
|
||||
craft_apps_release_cache: CraftAppsReleaseCache::new(),
|
||||
cidr_ban_set,
|
||||
troll_bans: TrollBans {
|
||||
user_tokens: user_token_troll_bans,
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
//! The latest release of every Craft App, as last fetched from GitHub by
|
||||
//! `poll_craft_app_releases_thread`, served by `GET /v1/craft_apps/release_info`.
|
||||
//!
|
||||
//! ## App keys
|
||||
//!
|
||||
//! Apps are keyed by their **app key**: the app's lowercase machine name, the same string the
|
||||
//! Craft Apps use for their binaries, asset file names and `ai.storyteller.<key>` bundle ids.
|
||||
//! For example `photocraft`, `pdfcraft`, `cadcraft`, and `artcraft-launcher` for ArtCraft Launcher
|
||||
//! itself. The key is not the display name (`PhotoCraft`) and not the GitHub repo
|
||||
//! (`storytold/photocraft`, whose project name can differ: the launcher's repo is
|
||||
//! `storytold/craft-launcher`).
|
||||
//!
|
||||
//! The keys come from the polling config (`poll_craft_app_releases_thread::config`: the built-in
|
||||
//! list, or `CRAFT_APPS_RELEASE_APPS`) and are served unchanged as the keys of
|
||||
//! `release_info.apps`, which ArtCraft Launcher matches against its own app ids.
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::sync::{Arc, PoisonError, RwLock};
|
||||
|
||||
use chrono::{DateTime, Utc};
|
||||
|
||||
use artcraft_api_defs::craft_apps::release_info::{CraftAppRelease, CraftAppReleaseInfo, CraftAppsReleaseInfo};
|
||||
|
||||
/// Shared between the polling thread and the HTTP handlers. Cheap to clone.
|
||||
#[derive(Clone, Default)]
|
||||
pub struct CraftAppsReleaseCache {
|
||||
/// App key (lowercase machine name, e.g. `photocraft`; see the module docs) → what's known
|
||||
/// about that app. A `BTreeMap` so the endpoint lists apps in a stable order.
|
||||
inner: Arc<RwLock<BTreeMap<String, CachedCraftApp>>>,
|
||||
}
|
||||
|
||||
/// One app: what's known about it, and the ETag to revalidate it with.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct CachedCraftApp {
|
||||
/// Display name (`PhotoCraft`).
|
||||
pub name: String,
|
||||
|
||||
/// GitHub repository, `organization/project` (`storytold/photocraft`).
|
||||
pub repo: String,
|
||||
|
||||
/// The latest published release. `None` both before the first fetch and when the repository
|
||||
/// has no release; `app_last_fetched` tells the two apart.
|
||||
pub latest_release: Option<CraftAppRelease>,
|
||||
|
||||
/// When this app's release was last fetched (or confirmed unchanged) successfully. `None`
|
||||
/// until the first success.
|
||||
pub app_last_fetched: Option<DateTime<Utc>>,
|
||||
|
||||
/// GitHub's ETag for the last successful answer, sent back as `If-None-Match` so an unchanged
|
||||
/// release costs a `304`.
|
||||
pub etag: Option<String>,
|
||||
}
|
||||
|
||||
impl CraftAppsReleaseCache {
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
/// Makes sure every app in `apps` has an entry, so the endpoint reports apps that haven't been
|
||||
/// fetched yet. Each tuple is `(app key, display name, repo)`, for example
|
||||
/// `("photocraft", "PhotoCraft", "storytold/photocraft")`. Apps already present keep what
|
||||
/// was fetched for them.
|
||||
pub fn register_apps(&self, apps: &[(String, String, String)]) {
|
||||
let mut map = self.inner.write().unwrap_or_else(PoisonError::into_inner);
|
||||
for (key, name, repo) in apps {
|
||||
map.entry(key.clone()).or_insert_with(|| CachedCraftApp {
|
||||
name: name.clone(),
|
||||
repo: repo.clone(),
|
||||
latest_release: None,
|
||||
app_last_fetched: None,
|
||||
etag: None,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// The ETag of the last successful answer for the app with app key `key` (`photocraft`), to
|
||||
/// send as `If-None-Match`.
|
||||
pub fn etag(&self, key: &str) -> Option<String> {
|
||||
let map = self.inner.read().unwrap_or_else(PoisonError::into_inner);
|
||||
map.get(key).and_then(|app| app.etag.clone())
|
||||
}
|
||||
|
||||
/// Records a complete, successful fetch of the app with app key `key` (`photocraft`): its
|
||||
/// latest release (`None` if it has none). Ignored for keys that were never registered.
|
||||
pub fn store(&self, key: &str, latest_release: Option<CraftAppRelease>, etag: Option<String>, fetched_at: DateTime<Utc>) {
|
||||
let mut map = self.inner.write().unwrap_or_else(PoisonError::into_inner);
|
||||
if let Some(app) = map.get_mut(key) {
|
||||
app.latest_release = latest_release;
|
||||
app.etag = etag;
|
||||
app.app_last_fetched = Some(fetched_at);
|
||||
}
|
||||
}
|
||||
|
||||
/// Records that GitHub confirmed the app with app key `key` (`photocraft`) is unchanged
|
||||
/// (`304 Not Modified`). Ignored for keys that were never registered.
|
||||
pub fn confirm_unchanged(&self, key: &str, fetched_at: DateTime<Utc>) {
|
||||
let mut map = self.inner.write().unwrap_or_else(PoisonError::into_inner);
|
||||
if let Some(app) = map.get_mut(key) {
|
||||
app.app_last_fetched = Some(fetched_at);
|
||||
}
|
||||
}
|
||||
|
||||
/// Everything, as the endpoint serves it: `apps` keyed by app key.
|
||||
pub fn snapshot(&self) -> CraftAppsReleaseInfo {
|
||||
let map = self.inner.read().unwrap_or_else(PoisonError::into_inner);
|
||||
let apps: BTreeMap<String, CraftAppReleaseInfo> = map
|
||||
.iter()
|
||||
.map(|(key, app)| {
|
||||
(key.clone(), CraftAppReleaseInfo {
|
||||
name: app.name.clone(),
|
||||
repo: app.repo.clone(),
|
||||
latest_release: app.latest_release.clone(),
|
||||
app_last_fetched: app.app_last_fetched,
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
let last_fetched = least_recently_fetched(&apps);
|
||||
CraftAppsReleaseInfo { apps, last_fetched }
|
||||
}
|
||||
}
|
||||
|
||||
/// The oldest `app_last_fetched`, or `None` while any app has never been fetched.
|
||||
fn least_recently_fetched(apps: &BTreeMap<String, CraftAppReleaseInfo>) -> Option<DateTime<Utc>> {
|
||||
if apps.is_empty() {
|
||||
return None;
|
||||
}
|
||||
let mut oldest: Option<DateTime<Utc>> = None;
|
||||
for app in apps.values() {
|
||||
let fetched = app.app_last_fetched?;
|
||||
oldest = Some(oldest.map_or(fetched, |o| o.min(fetched)));
|
||||
}
|
||||
oldest
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use chrono::TimeZone;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn last_fetched_is_the_oldest_app_and_absent_until_all_are_fetched() {
|
||||
let cache = CraftAppsReleaseCache::new();
|
||||
cache.register_apps(&[
|
||||
("photocraft".into(), "PhotoCraft".into(), "storytold/photocraft".into()),
|
||||
("filmcraft".into(), "FilmCraft".into(), "storytold/filmcraft".into()),
|
||||
]);
|
||||
assert_eq!(cache.snapshot().apps.len(), 2);
|
||||
assert_eq!(cache.snapshot().last_fetched, None);
|
||||
|
||||
let early = Utc.with_ymd_and_hms(2026, 10, 10, 1, 0, 0).unwrap();
|
||||
let late = Utc.with_ymd_and_hms(2026, 10, 10, 2, 0, 0).unwrap();
|
||||
cache.store("photocraft", None, Some("\"abc\"".into()), late);
|
||||
assert_eq!(cache.snapshot().last_fetched, None, "filmcraft hasn't been fetched yet");
|
||||
|
||||
cache.confirm_unchanged("filmcraft", early);
|
||||
assert_eq!(cache.snapshot().last_fetched, Some(early));
|
||||
assert_eq!(cache.etag("photocraft").as_deref(), Some("\"abc\""));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn registering_again_keeps_what_was_fetched() {
|
||||
let cache = CraftAppsReleaseCache::new();
|
||||
let apps = [("photocraft".to_string(), "PhotoCraft".to_string(), "storytold/photocraft".to_string())];
|
||||
cache.register_apps(&apps);
|
||||
let now = Utc::now();
|
||||
cache.confirm_unchanged("photocraft", now);
|
||||
cache.register_apps(&apps);
|
||||
assert_eq!(cache.snapshot().apps["photocraft"].app_last_fetched, Some(now));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
pub mod cached_queries;
|
||||
pub mod flags;
|
||||
pub mod certs;
|
||||
pub mod craft_apps_release_cache;
|
||||
pub mod memory_cache;
|
||||
pub mod server_state;
|
||||
@@ -1,6 +1,7 @@
|
||||
use std::collections::HashSet;
|
||||
|
||||
use crate::configs::app_startup::username_set::UsernameSet;
|
||||
use crate::state::craft_apps_release_cache::CraftAppsReleaseCache;
|
||||
use crate::configs::static_api_tokens::StaticApiTokenSet;
|
||||
use crate::http_server::deprecated_endpoints::categories::tts::list_fully_computed_assigned_tts_categories::list_fully_computed_assigned_tts_categories::ModelTokensByCategoryToken;
|
||||
use crate::http_server::endpoints::media_files::list::list_featured_media_files_handler::ListFeaturedMediaFilesQueryParams;
|
||||
@@ -124,6 +125,9 @@ pub struct ServerState {
|
||||
|
||||
pub caches: InMemoryCaches,
|
||||
|
||||
/// The latest Craft App releases, kept fresh by `poll_craft_app_releases_thread`.
|
||||
pub craft_apps_release_cache: CraftAppsReleaseCache,
|
||||
|
||||
pub google_sign_in_cert: GoogleSignInCert,
|
||||
|
||||
pub temp_dir_creator: ScopedTempDirCreator,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
pub mod db_health_checker_thread;
|
||||
pub mod expire_login_challenges;
|
||||
pub mod poll_craft_app_releases_thread;
|
||||
pub mod poll_ip_banlist_thread;
|
||||
pub mod poll_model_token_info_thread;
|
||||
@@ -0,0 +1,109 @@
|
||||
//! How storyteller-web polls GitHub for Craft App releases, from the environment.
|
||||
//!
|
||||
//! | Variable | Default | Meaning |
|
||||
//! |-------------------------------------------|----------------|-------------------------------------------------|
|
||||
//! | `CRAFT_APPS_RELEASE_POLLING_ENABLED` | `true` | Poll at all (the endpoint still answers) |
|
||||
//! | `CRAFT_APPS_RELEASE_POLL_INTERVAL_SECS` | `1800` (30 m) | Time between rounds; at least 300 |
|
||||
//! | `CRAFT_APPS_RELEASE_MAX_BACKOFF_SECS` | `14400` (4 h) | Longest wait after repeated failures/rate limits |
|
||||
//! | `CRAFT_APPS_RELEASE_GITHUB_TOKEN` | (none) | Raises GitHub's limit from 60 to 5000 per hour |
|
||||
//! | `CRAFT_APPS_RELEASE_APPS` | built-in list | `key=Name=org/repo,…` to replace the app list |
|
||||
//!
|
||||
//! Every instance in the fleet polls on its own, so the defaults are deliberately slow: one round
|
||||
//! is one request per app, and without a token GitHub allows 60 an hour per IP address.
|
||||
|
||||
use std::time::Duration;
|
||||
|
||||
const MIN_INTERVAL_SECS: u64 = 300;
|
||||
|
||||
/// The Craft Apps the launcher knows: `(app key, display name, GitHub repo)`. The app key is
|
||||
/// the app's lowercase machine name; it keys `CraftAppsReleaseCache` and the endpoint's
|
||||
/// `release_info.apps`, and must match the app id ArtCraft Launcher uses. ArtCraft Launcher is
|
||||
/// included (key `artcraft-launcher`, repo `storytold/craft-launcher`) so it can check for its
|
||||
/// own updates.
|
||||
const DEFAULT_APPS: &[(&str, &str, &str)] = &[
|
||||
("photocraft", "PhotoCraft", "storytold/photocraft"),
|
||||
("vectorcraft", "VectorCraft", "storytold/vectorcraft"),
|
||||
("filmcraft", "FilmCraft", "storytold/filmcraft"),
|
||||
("lightcraft", "LightCraft", "storytold/lightcraft"),
|
||||
("pdfcraft", "PdfCraft", "storytold/pdfcraft"),
|
||||
("effectcraft", "EffectCraft", "storytold/effectcraft"),
|
||||
("designcraft", "DesignCraft", "storytold/designcraft"),
|
||||
("wordcraft", "WordCraft", "storytold/wordcraft"),
|
||||
("deckcraft", "DeckCraft", "storytold/deckcraft"),
|
||||
("gridcraft", "GridCraft", "storytold/gridcraft"),
|
||||
("cadcraft", "CADCraft", "storytold/cadcraft"),
|
||||
("soundcraft", "SoundCraft", "storytold/soundcraft"),
|
||||
("artcraft-launcher", "ArtCraft Launcher", "storytold/craft-launcher"),
|
||||
];
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct CraftAppsPollConfig {
|
||||
pub enabled: bool,
|
||||
pub interval: Duration,
|
||||
pub max_backoff: Duration,
|
||||
pub github_token: Option<String>,
|
||||
/// `(app key, display name, repo)`; see [`DEFAULT_APPS`].
|
||||
pub apps: Vec<(String, String, String)>,
|
||||
}
|
||||
|
||||
impl CraftAppsPollConfig {
|
||||
pub fn from_env() -> Self {
|
||||
let interval_secs = easyenv::get_env_num::<u64>("CRAFT_APPS_RELEASE_POLL_INTERVAL_SECS", 1800).unwrap_or(1800).max(MIN_INTERVAL_SECS);
|
||||
let max_backoff_secs = easyenv::get_env_num::<u64>("CRAFT_APPS_RELEASE_MAX_BACKOFF_SECS", 14_400).unwrap_or(14_400).max(interval_secs);
|
||||
let github_token = easyenv::get_env_string_optional("CRAFT_APPS_RELEASE_GITHUB_TOKEN")
|
||||
.map(|t| t.trim().to_string())
|
||||
.filter(|t| !t.is_empty());
|
||||
let apps = easyenv::get_env_string_optional("CRAFT_APPS_RELEASE_APPS")
|
||||
.map(|v| parse_app_list(&v))
|
||||
.filter(|apps| !apps.is_empty())
|
||||
.unwrap_or_else(default_apps);
|
||||
Self {
|
||||
enabled: easyenv::get_env_bool_or_default("CRAFT_APPS_RELEASE_POLLING_ENABLED", true),
|
||||
interval: Duration::from_secs(interval_secs),
|
||||
max_backoff: Duration::from_secs(max_backoff_secs),
|
||||
github_token,
|
||||
apps,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn default_apps() -> Vec<(String, String, String)> {
|
||||
DEFAULT_APPS.iter().map(|(k, n, r)| (k.to_string(), n.to_string(), r.to_string())).collect()
|
||||
}
|
||||
|
||||
/// Reads `key=Name=org/repo,…` (app key, display name, repo). Keys are lowercased. Malformed
|
||||
/// entries are skipped.
|
||||
fn parse_app_list(value: &str) -> Vec<(String, String, String)> {
|
||||
value
|
||||
.split(',')
|
||||
.filter_map(|entry| {
|
||||
let mut parts = entry.trim().splitn(3, '=');
|
||||
let key = parts.next()?.trim().to_lowercase();
|
||||
let name = parts.next()?.trim().to_string();
|
||||
let repo = parts.next()?.trim().to_string();
|
||||
let valid_repo = repo.split('/').count() == 2 && !repo.starts_with('/') && !repo.ends_with('/');
|
||||
(!key.is_empty() && !name.is_empty() && valid_repo).then_some((key, name, repo))
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn reads_an_app_list_and_skips_bad_entries() {
|
||||
let apps = parse_app_list(" PhotoCraft=PhotoCraft=storytold/photocraft, junk, x=X=noslash, k=K=org/repo ");
|
||||
assert_eq!(apps, vec![
|
||||
("photocraft".to_string(), "PhotoCraft".to_string(), "storytold/photocraft".to_string()),
|
||||
("k".to_string(), "K".to_string(), "org/repo".to_string()),
|
||||
]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_default_list_has_the_suite_and_the_launcher() {
|
||||
let apps = default_apps();
|
||||
assert_eq!(apps.len(), 13);
|
||||
assert!(apps.iter().any(|(k, _, r)| k == "artcraft-launcher" && r == "storytold/craft-launcher"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,277 @@
|
||||
//! One request to GitHub for an app's latest release, and reading the answer.
|
||||
|
||||
use std::time::Duration;
|
||||
|
||||
use chrono::{DateTime, Utc};
|
||||
use wreq::header::{ACCEPT, AUTHORIZATION, ETAG, IF_NONE_MATCH, RETRY_AFTER, USER_AGENT};
|
||||
use wreq::StatusCode;
|
||||
use serde_derive::Deserialize;
|
||||
|
||||
use artcraft_api_defs::craft_apps::release_info::{
|
||||
CraftAppArch, CraftAppAssetPlatform, CraftAppOs, CraftAppPackageType, CraftAppRelease, CraftAppReleaseAsset,
|
||||
};
|
||||
|
||||
const API_BASE: &str = "https://api.github.com";
|
||||
const MAX_NOTES_BYTES: usize = 64 * 1024;
|
||||
const MAX_ASSETS: usize = 200;
|
||||
const MAX_BODY_BYTES: usize = 4 * 1024 * 1024;
|
||||
|
||||
/// What one request produced.
|
||||
#[derive(Debug)]
|
||||
pub enum FetchOutcome {
|
||||
/// The latest release (`None`: the repository has no published release).
|
||||
Fetched { release: Option<CraftAppRelease>, etag: Option<String> },
|
||||
/// `If-None-Match` matched: what we have is current.
|
||||
NotModified,
|
||||
/// GitHub refused: out of quota until this time, if it said.
|
||||
RateLimited { retry_at: Option<DateTime<Utc>> },
|
||||
/// Network error, unexpected status or unreadable answer. Nothing is stored.
|
||||
Failed(String),
|
||||
}
|
||||
|
||||
pub fn build_client() -> wreq::Result<wreq::Client> {
|
||||
wreq::Client::builder()
|
||||
.connect_timeout(Duration::from_secs(10))
|
||||
.timeout(Duration::from_secs(30))
|
||||
.build()
|
||||
}
|
||||
|
||||
/// `GET /repos/{repo}/releases/latest`, revalidated with `etag`.
|
||||
pub async fn fetch_latest_release(client: &wreq::Client, repo: &str, etag: Option<&str>, token: Option<&str>) -> FetchOutcome {
|
||||
let url = format!("{API_BASE}/repos/{repo}/releases/latest");
|
||||
let mut request = client
|
||||
.get(&url)
|
||||
.header(USER_AGENT, "storyteller-web (craft apps release poller)")
|
||||
.header(ACCEPT, "application/vnd.github+json")
|
||||
.header("X-GitHub-Api-Version", "2022-11-28");
|
||||
if let Some(etag) = etag {
|
||||
request = request.header(IF_NONE_MATCH, etag);
|
||||
}
|
||||
if let Some(token) = token {
|
||||
request = request.header(AUTHORIZATION, format!("Bearer {token}"));
|
||||
}
|
||||
let response = match request.send().await {
|
||||
Ok(r) => r,
|
||||
Err(err) => return FetchOutcome::Failed(format!("request failed: {err}")),
|
||||
};
|
||||
let status = response.status();
|
||||
let header = |name: &str| response.headers().get(name).and_then(|v| v.to_str().ok()).map(str::to_string);
|
||||
match status {
|
||||
StatusCode::NOT_MODIFIED => FetchOutcome::NotModified,
|
||||
StatusCode::NOT_FOUND => FetchOutcome::Fetched { release: None, etag: None },
|
||||
StatusCode::FORBIDDEN | StatusCode::TOO_MANY_REQUESTS => {
|
||||
let remaining = header("x-ratelimit-remaining");
|
||||
let reset = header("x-ratelimit-reset").and_then(|r| r.parse::<i64>().ok()).and_then(|s| DateTime::from_timestamp(s, 0));
|
||||
let retry_after = header(RETRY_AFTER.as_str())
|
||||
.and_then(|r| r.parse::<i64>().ok())
|
||||
.map(|s| Utc::now() + chrono::Duration::seconds(s.clamp(0, 86_400)));
|
||||
if status == StatusCode::TOO_MANY_REQUESTS || remaining.as_deref() == Some("0") || retry_after.is_some() {
|
||||
FetchOutcome::RateLimited { retry_at: retry_after.or(reset) }
|
||||
} else {
|
||||
FetchOutcome::Failed(format!("HTTP {status}"))
|
||||
}
|
||||
}
|
||||
StatusCode::OK => {
|
||||
let etag = header(ETAG.as_str());
|
||||
let body = match response.bytes().await {
|
||||
Ok(b) if b.len() <= MAX_BODY_BYTES => b,
|
||||
Ok(b) => return FetchOutcome::Failed(format!("answer too large ({} bytes)", b.len())),
|
||||
Err(err) => return FetchOutcome::Failed(format!("unreadable answer: {err}")),
|
||||
};
|
||||
match parse_release(&body, repo) {
|
||||
Ok(release) => FetchOutcome::Fetched { release: Some(release), etag },
|
||||
Err(err) => FetchOutcome::Failed(err),
|
||||
}
|
||||
}
|
||||
other => FetchOutcome::Failed(format!("HTTP {other}")),
|
||||
}
|
||||
}
|
||||
|
||||
/// The parts of GitHub's release object we use. Everything optional: GitHub's answer is input.
|
||||
#[derive(Deserialize)]
|
||||
struct GithubRelease {
|
||||
#[serde(default)]
|
||||
tag_name: Option<String>,
|
||||
#[serde(default)]
|
||||
name: Option<String>,
|
||||
#[serde(default)]
|
||||
html_url: Option<String>,
|
||||
#[serde(default)]
|
||||
published_at: Option<DateTime<Utc>>,
|
||||
#[serde(default)]
|
||||
prerelease: bool,
|
||||
#[serde(default)]
|
||||
draft: bool,
|
||||
#[serde(default)]
|
||||
body: Option<String>,
|
||||
#[serde(default)]
|
||||
assets: Vec<GithubAsset>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct GithubAsset {
|
||||
#[serde(default)]
|
||||
name: Option<String>,
|
||||
#[serde(default)]
|
||||
size: u64,
|
||||
#[serde(default)]
|
||||
browser_download_url: Option<String>,
|
||||
/// `sha256:<hex>` on assets uploaded since mid-2025.
|
||||
#[serde(default)]
|
||||
digest: Option<String>,
|
||||
}
|
||||
|
||||
/// Reads a release, keeping only downloads that really belong to `repo`.
|
||||
pub fn parse_release(body: &[u8], repo: &str) -> Result<CraftAppRelease, String> {
|
||||
let raw: GithubRelease = serde_json::from_slice(body).map_err(|e| format!("unreadable release: {e}"))?;
|
||||
if raw.draft {
|
||||
return Err("the latest release is a draft".into());
|
||||
}
|
||||
let tag = raw.tag_name.filter(|t| !t.is_empty() && t.len() <= 64).ok_or("the release has no tag")?;
|
||||
let releases_page = format!("https://github.com/{repo}/releases/");
|
||||
let html_url = raw.html_url.filter(|u| u.starts_with(&releases_page)).unwrap_or_else(|| format!("{releases_page}tag/{tag}"));
|
||||
let download_prefix = format!("https://github.com/{repo}/releases/download/");
|
||||
let assets = raw
|
||||
.assets
|
||||
.into_iter()
|
||||
.filter_map(|a| {
|
||||
let name = a.name.filter(|n| valid_file_name(n))?;
|
||||
let download_url = a.browser_download_url.filter(|u| u.starts_with(&download_prefix))?;
|
||||
let sha256 = a.digest.as_deref().and_then(|d| d.strip_prefix("sha256:")).filter(|h| h.len() == 64 && h.bytes().all(|b| b.is_ascii_hexdigit())).map(str::to_ascii_lowercase);
|
||||
let platform = parse_platform(&name);
|
||||
Some(CraftAppReleaseAsset { name, size_bytes: a.size, download_url, sha256, platform })
|
||||
})
|
||||
.take(MAX_ASSETS)
|
||||
.collect();
|
||||
Ok(CraftAppRelease {
|
||||
version: tag.strip_prefix(['v', 'V']).unwrap_or(&tag).to_string(),
|
||||
name: raw.name.filter(|n| !n.is_empty()).map(|n| truncate(&n, 200)).unwrap_or_else(|| tag.clone()),
|
||||
tag,
|
||||
published_at: raw.published_at,
|
||||
html_url,
|
||||
prerelease: raw.prerelease,
|
||||
notes_markdown: raw.body.map(|b| truncate(&b, MAX_NOTES_BYTES)).unwrap_or_default(),
|
||||
assets,
|
||||
})
|
||||
}
|
||||
|
||||
/// Reads `<app>-<version>-<os>-<arch>[-portable].<ext>`, `<app>-cli-<version>-macos-universal.zip`
|
||||
/// and `<app>-web-<version>.zip`. `None` for anything else (checksums, unknown files).
|
||||
pub fn parse_platform(name: &str) -> Option<CraftAppAssetPlatform> {
|
||||
if name.contains("-web-") && name.ends_with(".zip") {
|
||||
return Some(CraftAppAssetPlatform { os: CraftAppOs::Web, arch: None, package_type: CraftAppPackageType::WebZip });
|
||||
}
|
||||
const KINDS: [(&str, CraftAppPackageType); 10] = [
|
||||
("-portable.zip", CraftAppPackageType::PortableZip),
|
||||
(".AppImage.zsync", CraftAppPackageType::AppImageZsync),
|
||||
(".AppImage", CraftAppPackageType::AppImage),
|
||||
(".tar.gz", CraftAppPackageType::TarGz),
|
||||
(".msi", CraftAppPackageType::Msi),
|
||||
(".dmg", CraftAppPackageType::Dmg),
|
||||
(".deb", CraftAppPackageType::Deb),
|
||||
(".rpm", CraftAppPackageType::Rpm),
|
||||
(".flatpak", CraftAppPackageType::Flatpak),
|
||||
(".zip", CraftAppPackageType::CliZip),
|
||||
];
|
||||
let (base, package_type) = KINDS.iter().find_map(|(suffix, kind)| name.strip_suffix(suffix).map(|b| (b, *kind)))?;
|
||||
let mut parts = base.rsplitn(3, '-');
|
||||
let (arch, os) = (parts.next()?, parts.next()?);
|
||||
let os = match os {
|
||||
"windows" => CraftAppOs::Windows,
|
||||
"macos" => CraftAppOs::Macos,
|
||||
"linux" => CraftAppOs::Linux,
|
||||
"freebsd" => CraftAppOs::Freebsd,
|
||||
_ => return None,
|
||||
};
|
||||
let arch = match arch {
|
||||
"x64" | "x86_64" => CraftAppArch::X64,
|
||||
"x86" => CraftAppArch::X86,
|
||||
"arm64" | "aarch64" => CraftAppArch::Arm64,
|
||||
"universal" => CraftAppArch::Universal,
|
||||
_ => return None,
|
||||
};
|
||||
// A bare `.zip` is only the macOS command-line tools.
|
||||
if package_type == CraftAppPackageType::CliZip && !(os == CraftAppOs::Macos && base.contains("-cli-")) {
|
||||
return None;
|
||||
}
|
||||
Some(CraftAppAssetPlatform { os, arch: Some(arch), package_type })
|
||||
}
|
||||
|
||||
fn valid_file_name(name: &str) -> bool {
|
||||
!name.is_empty()
|
||||
&& name.len() <= 200
|
||||
&& !name.starts_with('.')
|
||||
&& !name.chars().any(|c| c.is_control() || matches!(c, '/' | '\\' | ':' | '<' | '>' | '"' | '|' | '?' | '*'))
|
||||
}
|
||||
|
||||
fn truncate(s: &str, max: usize) -> String {
|
||||
if s.len() <= max {
|
||||
return s.to_string();
|
||||
}
|
||||
let mut end = max;
|
||||
while !s.is_char_boundary(end) {
|
||||
end -= 1;
|
||||
}
|
||||
format!("{}…", &s[..end])
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
const REPO: &str = "storytold/photocraft";
|
||||
const HASH: &str = "8a5edab282632443219e051e4ade2d1d5bbc671c781051bf1437897cbdfea0f1";
|
||||
|
||||
fn release_json(download_url: &str) -> String {
|
||||
format!(
|
||||
r#"{{"tag_name":"v0.5.0","name":"PhotoCraft v0.5.0","draft":false,"prerelease":false,
|
||||
"html_url":"https://github.com/storytold/photocraft/releases/tag/v0.5.0",
|
||||
"published_at":"2026-10-08T14:52:50Z","body":"Notes","unknown_field":[1,2,3],
|
||||
"assets":[{{"name":"photocraft-0.5.0-windows-x64.msi","size":7,"browser_download_url":"{download_url}","digest":"sha256:{HASH}"}}]}}"#
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reads_a_release() {
|
||||
let r = parse_release(release_json("https://github.com/storytold/photocraft/releases/download/v0.5.0/photocraft-0.5.0-windows-x64.msi").as_bytes(), REPO).unwrap();
|
||||
assert_eq!((r.tag.as_str(), r.version.as_str(), r.name.as_str()), ("v0.5.0", "0.5.0", "PhotoCraft v0.5.0"));
|
||||
assert_eq!(r.assets.len(), 1);
|
||||
assert_eq!(r.assets[0].sha256.as_deref(), Some(HASH));
|
||||
let p = r.assets[0].platform.as_ref().unwrap();
|
||||
assert_eq!((p.os, p.arch, p.package_type), (CraftAppOs::Windows, Some(CraftAppArch::X64), CraftAppPackageType::Msi));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn drops_downloads_that_point_elsewhere_and_rejects_garbage() {
|
||||
for url in ["https://evil.example/x.msi", "https://github.com/storytold/other/releases/download/v1/x.msi"] {
|
||||
assert!(parse_release(release_json(url).as_bytes(), REPO).unwrap().assets.is_empty(), "{url}");
|
||||
}
|
||||
assert!(parse_release(b"<html>", REPO).is_err());
|
||||
assert!(parse_release(br#"{"assets":[]}"#, REPO).is_err());
|
||||
assert!(parse_release(br#"{"tag_name":"v1.0.0","draft":true}"#, REPO).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reads_every_asset_name_the_suite_publishes() {
|
||||
let cases = [
|
||||
("photocraft-0.5.0-macos-universal.dmg", Some((CraftAppOs::Macos, Some(CraftAppArch::Universal), CraftAppPackageType::Dmg))),
|
||||
("photocraft-cli-0.5.0-macos-universal.zip", Some((CraftAppOs::Macos, Some(CraftAppArch::Universal), CraftAppPackageType::CliZip))),
|
||||
("photocraft-0.5.0-windows-arm64-portable.zip", Some((CraftAppOs::Windows, Some(CraftAppArch::Arm64), CraftAppPackageType::PortableZip))),
|
||||
("photocraft-0.5.0-windows-x86.msi", Some((CraftAppOs::Windows, Some(CraftAppArch::X86), CraftAppPackageType::Msi))),
|
||||
("photocraft-0.5.0-linux-aarch64.AppImage", Some((CraftAppOs::Linux, Some(CraftAppArch::Arm64), CraftAppPackageType::AppImage))),
|
||||
("photocraft-0.5.0-linux-x86_64.AppImage.zsync", Some((CraftAppOs::Linux, Some(CraftAppArch::X64), CraftAppPackageType::AppImageZsync))),
|
||||
("photocraft-0.5.0-linux-x86_64.deb", Some((CraftAppOs::Linux, Some(CraftAppArch::X64), CraftAppPackageType::Deb))),
|
||||
("photocraft-0.5.0-linux-x86_64.rpm", Some((CraftAppOs::Linux, Some(CraftAppArch::X64), CraftAppPackageType::Rpm))),
|
||||
("photocraft-0.5.0-linux-x86_64.flatpak", Some((CraftAppOs::Linux, Some(CraftAppArch::X64), CraftAppPackageType::Flatpak))),
|
||||
("photocraft-0.5.0-freebsd-x86_64.tar.gz", Some((CraftAppOs::Freebsd, Some(CraftAppArch::X64), CraftAppPackageType::TarGz))),
|
||||
("photocraft-0.2.0-rc.1-linux-x86_64.tar.gz", Some((CraftAppOs::Linux, Some(CraftAppArch::X64), CraftAppPackageType::TarGz))),
|
||||
("photocraft-web-0.5.0.zip", Some((CraftAppOs::Web, None, CraftAppPackageType::WebZip))),
|
||||
("SHA256SUMS.txt", None),
|
||||
("photocraft-0.5.0-plan9-x64.msi", None),
|
||||
];
|
||||
for (name, want) in cases {
|
||||
let got = parse_platform(name).map(|p| (p.os, p.arch, p.package_type));
|
||||
assert_eq!(got, want, "{name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
pub mod config;
|
||||
pub mod github;
|
||||
pub mod poll_craft_app_releases;
|
||||
@@ -0,0 +1,229 @@
|
||||
//! Polls GitHub for the latest release of every Craft App and keeps it in
|
||||
//! [`CraftAppsReleaseCache`], which `GET /v1/craft_apps/release_info` serves to ArtCraft Launcher
|
||||
//! (so thousands of launchers don't each poll GitHub).
|
||||
//!
|
||||
//! Every instance of storyteller-web polls on its own, so it is gentle: one round at startup,
|
||||
//! then one per `CRAFT_APPS_RELEASE_POLL_INTERVAL_SECS` (30 minutes by default) with jitter, one
|
||||
//! request per app with ETag revalidation, and growing waits after rate limits or failures.
|
||||
//! Each app is all-or-nothing: either its latest release is stored with a fresh
|
||||
//! `app_last_fetched`, or nothing about it changes.
|
||||
|
||||
use std::time::Duration;
|
||||
|
||||
use chrono::{DateTime, Utc};
|
||||
use log::{error, info, warn};
|
||||
|
||||
use crate::state::craft_apps_release_cache::CraftAppsReleaseCache;
|
||||
use crate::threads::poll_craft_app_releases_thread::config::CraftAppsPollConfig;
|
||||
use crate::threads::poll_craft_app_releases_thread::github;
|
||||
use crate::threads::poll_craft_app_releases_thread::github::FetchOutcome;
|
||||
|
||||
/// Spreads a fleet's first round over this window, so a deploy doesn't hit GitHub all at once.
|
||||
const STARTUP_JITTER: Duration = Duration::from_secs(15);
|
||||
/// Pause between the requests of one round.
|
||||
const BETWEEN_REQUESTS: Duration = Duration::from_millis(1_000);
|
||||
/// First wait after a round where every request failed (network trouble); doubles up to the
|
||||
/// normal interval.
|
||||
const FIRST_FAILURE_RETRY: Duration = Duration::from_secs(60);
|
||||
/// Extra margin after GitHub's announced rate-limit reset.
|
||||
const RESET_MARGIN: Duration = Duration::from_secs(60);
|
||||
|
||||
pub async fn poll_craft_app_releases(cache: CraftAppsReleaseCache, config: CraftAppsPollConfig) {
|
||||
cache.register_apps(&config.apps);
|
||||
if !config.enabled {
|
||||
info!("Craft app release polling is disabled (CRAFT_APPS_RELEASE_POLLING_ENABLED=false).");
|
||||
return;
|
||||
}
|
||||
let client = match github::build_client() {
|
||||
Ok(client) => client,
|
||||
Err(err) => {
|
||||
error!("Craft app release polling can't start: no HTTP client: {:?}", err);
|
||||
return;
|
||||
}
|
||||
};
|
||||
info!(
|
||||
"Polling GitHub for {} craft app releases every {:?} (token: {}).",
|
||||
config.apps.len(), config.interval, config.github_token.is_some(),
|
||||
);
|
||||
tokio::time::sleep(jittered(STARTUP_JITTER, 1.0)).await;
|
||||
|
||||
let mut consecutive_trouble = 0u32;
|
||||
loop {
|
||||
let round = poll_round(&client, &cache, &config).await;
|
||||
let wait = next_wait(&config, &round, &mut consecutive_trouble, Utc::now());
|
||||
info!(
|
||||
"Craft app releases: {} fetched, {} unchanged, {} failed{}; next round in {:?}.",
|
||||
round.fetched, round.unchanged, round.failed,
|
||||
if round.rate_limited.is_some() { ", rate limited" } else { "" },
|
||||
wait,
|
||||
);
|
||||
tokio::time::sleep(wait).await;
|
||||
}
|
||||
}
|
||||
|
||||
/// What one round did.
|
||||
#[derive(Debug, Default)]
|
||||
struct RoundResult {
|
||||
fetched: usize,
|
||||
unchanged: usize,
|
||||
failed: usize,
|
||||
/// GitHub refused; `Some(Some(t))` when it said when to come back.
|
||||
rate_limited: Option<Option<DateTime<Utc>>>,
|
||||
}
|
||||
|
||||
async fn poll_round(client: &wreq::Client, cache: &CraftAppsReleaseCache, config: &CraftAppsPollConfig) -> RoundResult {
|
||||
let mut round = RoundResult::default();
|
||||
for (i, (key, _, repo)) in config.apps.iter().enumerate() {
|
||||
if i > 0 {
|
||||
tokio::time::sleep(BETWEEN_REQUESTS).await;
|
||||
}
|
||||
let etag = cache.etag(key);
|
||||
match github::fetch_latest_release(client, repo, etag.as_deref(), config.github_token.as_deref()).await {
|
||||
FetchOutcome::Fetched { release, etag } => {
|
||||
cache.store(key, release, etag, Utc::now());
|
||||
round.fetched += 1;
|
||||
}
|
||||
FetchOutcome::NotModified => {
|
||||
cache.confirm_unchanged(key, Utc::now());
|
||||
round.unchanged += 1;
|
||||
}
|
||||
FetchOutcome::RateLimited { retry_at } => {
|
||||
warn!("GitHub rate limit reached polling {repo}; retry after {:?}.", retry_at);
|
||||
round.rate_limited = Some(retry_at);
|
||||
// The rest of the round would be refused too.
|
||||
break;
|
||||
}
|
||||
FetchOutcome::Failed(why) => {
|
||||
warn!("Couldn't fetch the latest release of {repo}: {why}");
|
||||
round.failed += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
round
|
||||
}
|
||||
|
||||
/// How long to wait before the next round. Rate limits wait for GitHub's reset and back off
|
||||
/// further each time; rounds where everything failed retry sooner, but never faster than a
|
||||
/// minute, doubling up to the normal interval.
|
||||
fn next_wait(config: &CraftAppsPollConfig, round: &RoundResult, consecutive_trouble: &mut u32, now: DateTime<Utc>) -> Duration {
|
||||
let base = if let Some(retry_at) = round.rate_limited {
|
||||
*consecutive_trouble = consecutive_trouble.saturating_add(1);
|
||||
let until_reset = retry_at
|
||||
.and_then(|t| (t - now).to_std().ok())
|
||||
.map(|d| d + RESET_MARGIN)
|
||||
.unwrap_or(Duration::ZERO);
|
||||
let backoff = scaled(config.interval, *consecutive_trouble);
|
||||
until_reset.max(backoff).min(config.max_backoff)
|
||||
} else if round.fetched == 0 && round.unchanged == 0 && round.failed > 0 {
|
||||
*consecutive_trouble = consecutive_trouble.saturating_add(1);
|
||||
scaled(FIRST_FAILURE_RETRY, *consecutive_trouble).min(config.interval)
|
||||
} else {
|
||||
*consecutive_trouble = 0;
|
||||
config.interval
|
||||
};
|
||||
jittered(base, 0.1)
|
||||
}
|
||||
|
||||
/// `base × 2^(n-1)`, without overflow.
|
||||
fn scaled(base: Duration, n: u32) -> Duration {
|
||||
base.saturating_mul(1u32 << n.saturating_sub(1).min(16))
|
||||
}
|
||||
|
||||
/// `base` ± `fraction`, so a fleet doesn't poll in lockstep. With `fraction == 1.0`, anywhere in
|
||||
/// `0..=2×base`; used for the startup spread.
|
||||
fn jittered(base: Duration, fraction: f64) -> Duration {
|
||||
let factor = 1.0 + fraction * (rand::random::<f64>() * 2.0 - 1.0);
|
||||
base.mul_f64(factor.max(0.0))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::threads::poll_craft_app_releases_thread::config::default_apps;
|
||||
|
||||
use super::*;
|
||||
|
||||
fn config() -> CraftAppsPollConfig {
|
||||
CraftAppsPollConfig {
|
||||
enabled: true,
|
||||
interval: Duration::from_secs(1800),
|
||||
max_backoff: Duration::from_secs(14_400),
|
||||
github_token: None,
|
||||
apps: default_apps(),
|
||||
}
|
||||
}
|
||||
|
||||
fn within(d: Duration, around: Duration) -> bool {
|
||||
d >= around.mul_f64(0.89) && d <= around.mul_f64(1.11)
|
||||
}
|
||||
|
||||
/// Live: one real round against GitHub (two apps), then the endpoint's response, written to
|
||||
/// `CRAFT_APPS_SAMPLE_OUT` when set (ArtCraft Launcher's parser reads it back).
|
||||
/// `cargo test -p storyteller-web --bin storyteller-web live_round -- --ignored`
|
||||
#[tokio::test]
|
||||
#[ignore = "needs network access"]
|
||||
async fn live_round_fetches_real_releases() {
|
||||
use artcraft_api_defs::craft_apps::release_info::{CraftAppsImportantNotices, GetCraftAppsReleaseInfoResponse};
|
||||
let mut config = config();
|
||||
config.apps.retain(|(key, _, _)| key == "photocraft" || key == "artcraft-launcher");
|
||||
let cache = CraftAppsReleaseCache::new();
|
||||
cache.register_apps(&config.apps);
|
||||
let client = github::build_client().unwrap();
|
||||
let round = poll_round(&client, &cache, &config).await;
|
||||
assert_eq!(round.fetched + round.unchanged, 2, "{round:?}");
|
||||
// A second round revalidates with ETags.
|
||||
let again = poll_round(&client, &cache, &config).await;
|
||||
assert_eq!(again.fetched + again.unchanged, 2, "{again:?}");
|
||||
let info = cache.snapshot();
|
||||
assert!(info.last_fetched.is_some());
|
||||
let photocraft = info.apps["photocraft"].latest_release.as_ref().unwrap();
|
||||
assert!(photocraft.assets.iter().any(|a| a.platform.is_some() && a.sha256.is_some()));
|
||||
let response = GetCraftAppsReleaseInfoResponse {
|
||||
success: true,
|
||||
release_info: info,
|
||||
app_renames: Vec::new(),
|
||||
repo_renames: Vec::new(),
|
||||
important_notices: CraftAppsImportantNotices::default(),
|
||||
};
|
||||
let json = serde_json::to_string_pretty(&response).unwrap();
|
||||
if let Ok(path) = std::env::var("CRAFT_APPS_SAMPLE_OUT") {
|
||||
std::fs::write(path, &json).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_good_round_waits_the_interval_and_resets_trouble() {
|
||||
let mut trouble = 3;
|
||||
let round = RoundResult { fetched: 5, unchanged: 8, ..RoundResult::default() };
|
||||
assert!(within(next_wait(&config(), &round, &mut trouble, Utc::now()), Duration::from_secs(1800)));
|
||||
assert_eq!(trouble, 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rate_limits_wait_for_the_reset_and_back_off_further_each_time() {
|
||||
let now = Utc::now();
|
||||
let mut trouble = 0;
|
||||
// GitHub says come back in 50 minutes: wait that (plus margin), more than the interval.
|
||||
let round = RoundResult { rate_limited: Some(Some(now + chrono::Duration::minutes(50))), ..RoundResult::default() };
|
||||
assert!(within(next_wait(&config(), &round, &mut trouble, now), Duration::from_secs(51 * 60)));
|
||||
// Again and again, with no reset time: 2×, 4×, … the interval, capped at the maximum.
|
||||
let round = RoundResult { rate_limited: Some(None), ..RoundResult::default() };
|
||||
assert!(within(next_wait(&config(), &round, &mut trouble, now), Duration::from_secs(3600)));
|
||||
assert!(within(next_wait(&config(), &round, &mut trouble, now), Duration::from_secs(7200)));
|
||||
for _ in 0..10 {
|
||||
assert!(next_wait(&config(), &round, &mut trouble, now) <= Duration::from_secs(14_400).mul_f64(1.11));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_round_where_everything_failed_retries_sooner_but_not_in_a_tight_loop() {
|
||||
let now = Utc::now();
|
||||
let mut trouble = 0;
|
||||
let round = RoundResult { failed: 13, ..RoundResult::default() };
|
||||
assert!(within(next_wait(&config(), &round, &mut trouble, now), Duration::from_secs(60)));
|
||||
assert!(within(next_wait(&config(), &round, &mut trouble, now), Duration::from_secs(120)));
|
||||
for _ in 0..20 {
|
||||
let w = next_wait(&config(), &round, &mut trouble, now);
|
||||
assert!(w >= Duration::from_secs(53) && w <= Duration::from_secs(1800).mul_f64(1.11), "{w:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ From the **repository root**, the launcher scripts (these preflight your
|
||||
environment, install dependencies, and free the dev port first):
|
||||
|
||||
```bash
|
||||
./script/website/unix_frontend_website_dev.sh # artcraft-website (marketing site), port 4200
|
||||
./script/website/unix_frontend_website_dev.sh # artcraft-website-next (marketing site), port 3000
|
||||
./script/website/unix_frontend_webapp_dev.sh # artcraft-webapp (user dashboard), port 4201
|
||||
```
|
||||
|
||||
@@ -46,14 +46,12 @@ by its full or relative path:
|
||||
Or directly from this directory:
|
||||
|
||||
```bash
|
||||
nx dev artcraft-website
|
||||
npx nx dev @frontend/artcraft-webapp
|
||||
```
|
||||
|
||||
## Building
|
||||
|
||||
```bash
|
||||
npx nx build artcraft-website
|
||||
npx nx build artcraft-webapp
|
||||
```
|
||||
|
||||
|
||||
@@ -4,8 +4,6 @@ import react from '@vitejs/plugin-react';
|
||||
import wasm from 'vite-plugin-wasm';
|
||||
import topLevelAwait from 'vite-plugin-top-level-await';
|
||||
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
|
||||
import { execSync } from 'child_process';
|
||||
import path from 'path';
|
||||
|
||||
// Dev-only CDN proxy. Media assets (splats, GLBs, images) are fetched with
|
||||
// fetch(), but the CDNs only send CORS headers for the production origin —
|
||||
@@ -71,21 +69,6 @@ function cdnProxyPlugin() {
|
||||
};
|
||||
}
|
||||
|
||||
// Custom plugin to generate news.json on dev server start
|
||||
function generateNewsPlugin() {
|
||||
return {
|
||||
name: 'generate-news',
|
||||
buildStart() {
|
||||
try {
|
||||
const scriptPath = path.resolve(__dirname, '../../scripts/generate-news-json.mjs');
|
||||
execSync(`node "${scriptPath}"`, { stdio: 'inherit' });
|
||||
} catch (e) {
|
||||
console.warn('Failed to generate news.json:', e);
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export default defineConfig(() => ({
|
||||
root: __dirname,
|
||||
cacheDir: '../../node_modules/.vite/apps/artcraft-webapp',
|
||||
@@ -110,7 +93,7 @@ export default defineConfig(() => ({
|
||||
port: 4301,
|
||||
host: 'localhost',
|
||||
},
|
||||
plugins: [cdnProxyPlugin(), generateNewsPlugin(), nxViteTsPaths(), react(), wasm(), topLevelAwait()],
|
||||
plugins: [cdnProxyPlugin(), nxViteTsPaths(), react(), wasm(), topLevelAwait()],
|
||||
// Uncomment this if you are using workers.
|
||||
// worker: {
|
||||
// plugins: [ nxViteTsPaths() ],
|
||||
|
||||
@@ -4,6 +4,10 @@
|
||||
# Manage the build command and publish directory here; leave those UI fields empty.
|
||||
# The Next.js runtime handles routing, the /cdn-media proxy rewrite, and the
|
||||
# legacy-route redirects declared in next.config.ts. Other media is in public/.
|
||||
#
|
||||
# Google Analytics: set NEXT_PUBLIC_GA_MEASUREMENT_ID (G-XXXXXXXXXX) in the
|
||||
# Netlify UI, scoped to the Production context so deploy previews don't
|
||||
# report. It is inlined at build time, so redeploy after changing it.
|
||||
|
||||
[build]
|
||||
command = "npm run build"
|
||||
|
||||
@@ -32,6 +32,18 @@ const nextConfig: NextConfig = {
|
||||
destination: "/apps/vectorcraft",
|
||||
permanent: true,
|
||||
},
|
||||
// PrintCraft was renamed PdfCraft. Old page links and share images
|
||||
// (cached by social sites) follow it.
|
||||
{
|
||||
source: "/apps/printcraft",
|
||||
destination: "/apps/pdfcraft",
|
||||
permanent: true,
|
||||
},
|
||||
{
|
||||
source: "/images/apps/printcraft/:file",
|
||||
destination: "/images/apps/pdfcraft/:file",
|
||||
permanent: true,
|
||||
},
|
||||
// Legacy share-link form (`/media?media=<token>`) from the Vite site;
|
||||
// the canonical route is /media/<token>. Mirrored in netlify.toml so
|
||||
// the edge answers it before the Next runtime.
|
||||
|
||||
|
After Width: | Height: | Size: 86 KiB |
|
After Width: | Height: | Size: 100 KiB |
|
After Width: | Height: | Size: 75 KiB |
|
After Width: | Height: | Size: 75 KiB |
|
After Width: | Height: | Size: 123 KiB |
|
Before Width: | Height: | Size: 86 KiB |
|
Before Width: | Height: | Size: 100 KiB |
|
Before Width: | Height: | Size: 75 KiB |
|
Before Width: | Height: | Size: 75 KiB |
|
Before Width: | Height: | Size: 123 KiB |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 77 KiB |
|
Before Width: | Height: | Size: 99 KiB After Width: | Height: | Size: 102 KiB |
|
After Width: | Height: | Size: 78 KiB |
|
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 92 KiB |
|
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 78 KiB |
@@ -9,6 +9,8 @@ import {
|
||||
KeyboardIcon,
|
||||
} from "lucide-react";
|
||||
import AppCard from "@/components/apps/app-card";
|
||||
import { LauncherDownloadButton } from "@/components/apps/app-downloads";
|
||||
import { craftLauncherRecommended } from "@/components/apps/launcher-callout";
|
||||
import ShareBar from "@/components/apps/share-bar";
|
||||
import {
|
||||
CampaignSection,
|
||||
@@ -22,6 +24,12 @@ import { AppIcon, ColorAccent, appThemeClass } from "@/components/apps/app-wordm
|
||||
import { PageHeader } from "@/components/page/page-header";
|
||||
import RevealManager from "@/components/reveal-manager";
|
||||
import { Button } from "@/components/ui";
|
||||
import { trackAttrs } from "@/lib/analytics";
|
||||
import {
|
||||
CRAFT_LAUNCHER_NAME,
|
||||
CRAFT_LAUNCHER_REPO,
|
||||
craftLauncherReleasePageUrl,
|
||||
} from "@/lib/craft-launcher";
|
||||
import {
|
||||
CRAFTING_APPS,
|
||||
CRAFTING_APPS_COUNT_WORD,
|
||||
@@ -64,6 +72,7 @@ const PRINCIPLE_ICONS = [
|
||||
];
|
||||
|
||||
export default function CraftingAppsPage() {
|
||||
const launcherDownloads = craftLauncherRecommended();
|
||||
return (
|
||||
<>
|
||||
<RevealManager />
|
||||
@@ -80,8 +89,19 @@ export default function CraftingAppsPage() {
|
||||
}
|
||||
lede={`${COVERAGE}. Native, open-source apps from the ArtCraft team, built in Rust and free to use.`}
|
||||
>
|
||||
<div data-reveal className="mt-8 flex flex-wrap gap-3">
|
||||
<DiscordButton size="lg">Join the Discord</DiscordButton>
|
||||
<div data-reveal className="mt-8 flex flex-wrap items-start gap-3">
|
||||
{launcherDownloads.length > 0 && (
|
||||
<LauncherDownloadButton
|
||||
recommended={launcherDownloads}
|
||||
fallbackHref={craftLauncherReleasePageUrl()}
|
||||
/>
|
||||
)}
|
||||
<DiscordButton
|
||||
size="lg"
|
||||
variant={launcherDownloads.length > 0 ? "secondary" : "primary"}
|
||||
>
|
||||
Join the Discord
|
||||
</DiscordButton>
|
||||
<Button
|
||||
href={CRAFTING_APPS_GITHUB_ORG}
|
||||
variant="secondary"
|
||||
@@ -93,6 +113,21 @@ export default function CraftingAppsPage() {
|
||||
Browse on GitHub
|
||||
</Button>
|
||||
</div>
|
||||
{launcherDownloads.length > 0 && (
|
||||
<p data-reveal className="mt-4 max-w-xl leading-relaxed text-muted">
|
||||
<span className="text-ink">Recommended:</span> {CRAFT_LAUNCHER_NAME}{" "}
|
||||
installs every app below and keeps them all up to date. Each app
|
||||
also has its own installers on its page.{" "}
|
||||
<a
|
||||
href={CRAFT_LAUNCHER_REPO}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="text-ink underline decoration-line-strong underline-offset-4 hover:decoration-current"
|
||||
>
|
||||
Learn more
|
||||
</a>
|
||||
</p>
|
||||
)}
|
||||
<ShareBar
|
||||
url={siteUrl("/apps")}
|
||||
text={`Crafting Apps: ${CRAFTING_APPS_COUNT_WORD.toLowerCase()} open-source creative apps from ArtCraft`}
|
||||
@@ -108,6 +143,7 @@ export default function CraftingAppsPage() {
|
||||
key={app.slug}
|
||||
href={craftAppPath(app)}
|
||||
className={`group flex w-18 flex-col items-center gap-2 sm:w-20 ${appThemeClass(app)}`}
|
||||
{...trackAttrs("app_select", { app_name: app.slug })}
|
||||
>
|
||||
<AppIcon
|
||||
app={app}
|
||||
|
||||
@@ -321,14 +321,14 @@ html[data-ruler="on"]::-webkit-scrollbar {
|
||||
.app-vectorcraft { --app: #e8573f; --app-ink: #b83a24; }
|
||||
.app-filmcraft { --app: #8b5cf6; --app-ink: #6a3fd6; }
|
||||
.app-lightcraft { --app: #f2a516; --app-ink: #8a5800; }
|
||||
.app-printcraft { --app: #12a58a; --app-ink: #0a7563; }
|
||||
.app-pdfcraft { --app: #12a58a; --app-ink: #0a7563; }
|
||||
.app-effectcraft { --app: #e0368f; --app-ink: #b0206c; }
|
||||
.app-designcraft { --app: #7bb51c; --app-ink: #457008; }
|
||||
:root[data-theme="dark"] .app-photocraft { --app-ink: #7fb0ff; }
|
||||
:root[data-theme="dark"] .app-vectorcraft { --app-ink: #ff8a70; }
|
||||
:root[data-theme="dark"] .app-filmcraft { --app-ink: #b69cff; }
|
||||
:root[data-theme="dark"] .app-lightcraft { --app-ink: #ffc14d; }
|
||||
:root[data-theme="dark"] .app-printcraft { --app-ink: #3fd6b8; }
|
||||
:root[data-theme="dark"] .app-pdfcraft { --app-ink: #3fd6b8; }
|
||||
:root[data-theme="dark"] .app-effectcraft { --app-ink: #ff7ab8; }
|
||||
:root[data-theme="dark"] .app-designcraft { --app-ink: #a6e04a; }
|
||||
@media (prefers-color-scheme: dark) {
|
||||
@@ -336,7 +336,7 @@ html[data-ruler="on"]::-webkit-scrollbar {
|
||||
:root:not([data-theme="light"]) .app-vectorcraft { --app-ink: #ff8a70; }
|
||||
:root:not([data-theme="light"]) .app-filmcraft { --app-ink: #b69cff; }
|
||||
:root:not([data-theme="light"]) .app-lightcraft { --app-ink: #ffc14d; }
|
||||
:root:not([data-theme="light"]) .app-printcraft { --app-ink: #3fd6b8; }
|
||||
:root:not([data-theme="light"]) .app-pdfcraft { --app-ink: #3fd6b8; }
|
||||
:root:not([data-theme="light"]) .app-effectcraft { --app-ink: #ff7ab8; }
|
||||
:root:not([data-theme="light"]) .app-designcraft { --app-ink: #a6e04a; }
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import SiteNav from "@/components/site-nav";
|
||||
import SiteFooter from "@/components/site-footer";
|
||||
import IntroConductor from "@/components/intro-conductor";
|
||||
import LandingContext from "@/components/landing-context";
|
||||
import Analytics from "@/components/analytics";
|
||||
import MotionProvider from "@/components/motion-provider";
|
||||
import ScrollRuler from "@/components/ruler/scroll-ruler";
|
||||
import TunerPanel from "@/components/dev/tuner-panel";
|
||||
@@ -138,6 +139,7 @@ export default function RootLayout({
|
||||
</MotionProvider>
|
||||
<TunerPanel />
|
||||
<LandingContext />
|
||||
<Analytics />
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect } from "react";
|
||||
import Script from "next/script";
|
||||
import { GA_MEASUREMENT_ID, trackClick } from "@/lib/analytics";
|
||||
|
||||
// Loads gtag.js after hydration and installs the one delegated click
|
||||
// listener behind the site's link and data-track events (lib/analytics.ts).
|
||||
// Renders nothing when no measurement id is configured.
|
||||
export default function Analytics() {
|
||||
useEffect(() => {
|
||||
if (!GA_MEASUREMENT_ID) return;
|
||||
// Capture phase: runs before click-to-play facades swap themselves out,
|
||||
// and before any handler can stop propagation. auxclick covers
|
||||
// middle-click "open in new tab".
|
||||
const onClick = (event: MouseEvent) => {
|
||||
if (event.type === "auxclick" && event.button !== 1) return;
|
||||
trackClick(event.target);
|
||||
};
|
||||
document.addEventListener("click", onClick, true);
|
||||
document.addEventListener("auxclick", onClick, true);
|
||||
return () => {
|
||||
document.removeEventListener("click", onClick, true);
|
||||
document.removeEventListener("auxclick", onClick, true);
|
||||
};
|
||||
}, []);
|
||||
|
||||
if (!GA_MEASUREMENT_ID) return null;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Script
|
||||
src={`https://www.googletagmanager.com/gtag/js?id=${GA_MEASUREMENT_ID}`}
|
||||
strategy="afterInteractive"
|
||||
/>
|
||||
<Script id="ga-init" strategy="afterInteractive">
|
||||
{`window.dataLayer=window.dataLayer||[];window.gtag=function(){dataLayer.push(arguments);};gtag("js",new Date());gtag("config",${JSON.stringify(GA_MEASUREMENT_ID)});`}
|
||||
</Script>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import Link from "next/link";
|
||||
import { ArrowUpRightIcon } from "lucide-react";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
import { Badge } from "@/components/ui";
|
||||
import { trackAttrs } from "@/lib/analytics";
|
||||
import {
|
||||
craftAppName,
|
||||
craftAppPath,
|
||||
@@ -30,6 +31,7 @@ export default function AppCard({
|
||||
<Link
|
||||
href={craftAppPath(app)}
|
||||
data-reveal
|
||||
{...trackAttrs("app_select", { app_name: app.slug })}
|
||||
className={twMerge(
|
||||
"group relative flex h-full flex-col bg-bg",
|
||||
appThemeClass(app),
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
} from "lucide-react";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
import { WindowsIcon } from "@/components/icons";
|
||||
import { Button } from "@/components/ui";
|
||||
import { Button, type ButtonProps } from "@/components/ui";
|
||||
import {
|
||||
CRAFT_DESKTOP_PLATFORMS,
|
||||
type CraftDesktopPlatform,
|
||||
@@ -35,9 +35,17 @@ const PLATFORM_ICONS: Record<CraftDesktopPlatform, ReactNode> = {
|
||||
/**
|
||||
* One card per desktop platform: its recommended build as the main button,
|
||||
* then every other file for that platform. The visitor's platform is tagged
|
||||
* "Your system" and gets the solid button.
|
||||
* "Your system" and gets the solid button. These are the app's standalone
|
||||
* installers, so every card and button names the app (the launcher above
|
||||
* them installs the whole family).
|
||||
*/
|
||||
export function AppPlatformDownloads({ downloads }: { downloads: CraftDownload[] }) {
|
||||
export function AppPlatformDownloads({
|
||||
name,
|
||||
downloads,
|
||||
}: {
|
||||
name: string;
|
||||
downloads: CraftDownload[];
|
||||
}) {
|
||||
const detected = useDetectedDesktop();
|
||||
|
||||
return (
|
||||
@@ -50,7 +58,7 @@ export function AppPlatformDownloads({ downloads }: { downloads: CraftDownload[]
|
||||
const others = files.filter((download) => download !== main);
|
||||
|
||||
return (
|
||||
<article key={platform} data-reveal className="flex flex-col bg-bg">
|
||||
<article key={platform} data-reveal className="flex min-w-0 flex-col bg-bg">
|
||||
<div className="flex items-center justify-between gap-4 border-b border-line px-6 py-2.5 md:px-8">
|
||||
<p className="hud-label text-muted">
|
||||
{isDetected ? (
|
||||
@@ -75,14 +83,16 @@ export function AppPlatformDownloads({ downloads }: { downloads: CraftDownload[]
|
||||
<Button
|
||||
href={main.href}
|
||||
variant={isDetected ? "primary" : "secondary"}
|
||||
className="mt-6 w-full"
|
||||
className="mt-6 w-full whitespace-normal text-center"
|
||||
>
|
||||
<ArrowDownToLineIcon aria-hidden className="h-4 w-4" />
|
||||
Download for {platform}
|
||||
Download {name} for {platform}
|
||||
</Button>
|
||||
{others.length > 0 && (
|
||||
<>
|
||||
<p className="hud-label mt-8 text-faint">Other {platform} downloads</p>
|
||||
<p className="hud-label mt-8 text-faint">
|
||||
Other {name} files for {platform}
|
||||
</p>
|
||||
<ul className="mt-2 border-t border-line">
|
||||
{others.map((download) => (
|
||||
<li key={download.href} className="border-b border-line">
|
||||
@@ -144,6 +154,47 @@ export function AppHeroDownloadButton({
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* ArtCraft Launcher's CTA: a direct download for the visitor's system once
|
||||
* it is known (with the file's platform and build underneath), else a jump
|
||||
* to `fallbackHref`, where every platform is listed.
|
||||
*/
|
||||
export function LauncherDownloadButton({
|
||||
recommended,
|
||||
fallbackHref,
|
||||
size = "lg",
|
||||
variant = "primary",
|
||||
fullWidth = false,
|
||||
className,
|
||||
}: {
|
||||
recommended: CraftDownload[];
|
||||
fallbackHref: string;
|
||||
size?: ButtonProps["size"];
|
||||
variant?: ButtonProps["variant"];
|
||||
fullWidth?: boolean;
|
||||
className?: string;
|
||||
}) {
|
||||
const detected = useDetectedDesktop();
|
||||
const mine = detected && pickDownload(recommended, detected);
|
||||
return (
|
||||
<span className={twMerge("flex flex-col gap-2", className)}>
|
||||
<Button
|
||||
href={mine ? mine.href : fallbackHref}
|
||||
size={size}
|
||||
variant={variant}
|
||||
className={fullWidth ? "w-full" : undefined}
|
||||
>
|
||||
<ArrowDownToLineIcon aria-hidden className="h-4 w-4" />
|
||||
Download ArtCraft Launcher
|
||||
</Button>
|
||||
{/* Reserved line, so the layout doesn't shift when detection lands. */}
|
||||
<span aria-hidden={!mine} className="hud-label min-h-4 text-faint">
|
||||
{mine ? `For ${mine.group} · ${mine.label}` : "\u00a0"}
|
||||
</span>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shown under the hero once the direct download is live, so visitors on
|
||||
* another machine, CPU or package format can still find their build.
|
||||
|
||||
@@ -6,6 +6,8 @@ import DiscordButton from "@/components/discord-button";
|
||||
import { GitHubIcon } from "@/components/icons";
|
||||
import { SectionShell, SectionEyebrow } from "@/components/landing/section-shell";
|
||||
import { Badge, Button, CopyButton } from "@/components/ui";
|
||||
import { trackAttrs } from "@/lib/analytics";
|
||||
import { CRAFT_LAUNCHER_RELEASE } from "@/lib/crafting-app-releases";
|
||||
import {
|
||||
CRAFTING_APPS,
|
||||
craftAppBuildCommand,
|
||||
@@ -24,6 +26,7 @@ import {
|
||||
import AppCard from "./app-card";
|
||||
import { AppPlatformDownloads, DownloadRow } from "./app-downloads";
|
||||
import { ColorAccent } from "./app-wordmark";
|
||||
import { LauncherCallout } from "./launcher-callout";
|
||||
|
||||
// Body sections of an /apps/<slug> page, in page order. Server components;
|
||||
// the client islands are the CopyButton and the OS-aware platform cards.
|
||||
@@ -31,11 +34,12 @@ import { ColorAccent } from "./app-wordmark";
|
||||
const CELL_HEADING_CLASSES =
|
||||
"mt-4 font-display text-3xl font-medium leading-[1.05] tracking-[-0.03em] text-ink-strong sm:text-4xl";
|
||||
|
||||
// The hero carries shot 01. Window captures lead with a full-width shot,
|
||||
// then pair; portrait pages (layout spreads) sit four across.
|
||||
// The hero carries shot 01. Window captures pair up, and an odd one out
|
||||
// leads at full width; portrait pages (layout spreads) sit four across.
|
||||
export function AppGallery({ app, index }: { app: CraftApp; index: string }) {
|
||||
const [, ...shots] = app.shots;
|
||||
const portrait = shots.every((shot) => shot.portrait);
|
||||
const leadFullWidth = !portrait && shots.length % 2 === 1;
|
||||
return (
|
||||
<SectionShell id="gallery">
|
||||
<SectionEyebrow
|
||||
@@ -54,7 +58,7 @@ export function AppGallery({ app, index }: { app: CraftApp; index: string }) {
|
||||
<figure
|
||||
key={shot.file}
|
||||
data-reveal
|
||||
className={twMerge("bg-bg", !portrait && i === 0 && "md:col-span-2")}
|
||||
className={twMerge("bg-bg", leadFullWidth && i === 0 && "md:col-span-2")}
|
||||
>
|
||||
<a
|
||||
href={craftShotSourceUrl(app, shot)}
|
||||
@@ -96,7 +100,8 @@ export function AppGallery({ app, index }: { app: CraftApp; index: string }) {
|
||||
);
|
||||
}
|
||||
|
||||
// Platform cards (your system first-class, every other build one click
|
||||
// ArtCraft Launcher first (installs and updates every app), then this app's
|
||||
// own platform cards (your system first-class, every other build one click
|
||||
// away) above release details and build-from-source. Versions and files come
|
||||
// from crafting-app-releases.ts; a null release there drops the cards and
|
||||
// shows the Discord waitlist instead.
|
||||
@@ -116,9 +121,27 @@ export function AppGetIt({ app, index }: { app: CraftApp; index: string }) {
|
||||
annotation="Free · Open source"
|
||||
/>
|
||||
{release && (
|
||||
<div className="border-b border-line">
|
||||
<AppPlatformDownloads downloads={downloads} />
|
||||
</div>
|
||||
<>
|
||||
{CRAFT_LAUNCHER_RELEASE && (
|
||||
<>
|
||||
<LauncherCallout app={app} />
|
||||
<div data-reveal className="border-y border-line bg-bg p-6 md:p-10">
|
||||
<p className="hud-label text-faint">Option 2 · Standalone</p>
|
||||
<h3 className={CELL_HEADING_CLASSES}>
|
||||
Just {name}? Download it <ColorAccent>standalone</ColorAccent>.
|
||||
</h3>
|
||||
<p className="mt-4 max-w-xl leading-relaxed text-muted">
|
||||
These installers add {name} on its own, without the
|
||||
launcher. Come back here for new versions, or install the
|
||||
launcher later and it will find {name} and keep it updated.
|
||||
</p>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
<div className="border-b border-line">
|
||||
<AppPlatformDownloads name={name} downloads={downloads} />
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
<div className="grid gap-px bg-line md:grid-cols-2">
|
||||
<div data-reveal className="flex flex-col bg-bg p-6 md:p-10">
|
||||
@@ -203,6 +226,7 @@ export function AppGetIt({ app, index }: { app: CraftApp; index: string }) {
|
||||
value={command}
|
||||
variant="ghost"
|
||||
className="h-9 border-l border-line px-3"
|
||||
{...trackAttrs("copy_command", { app_name: app.slug })}
|
||||
/>
|
||||
</div>
|
||||
<pre className="overflow-x-auto p-4 font-mono text-[13px] leading-relaxed text-ink">
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
import { ArrowUpRightIcon, CheckIcon } from "lucide-react";
|
||||
import {
|
||||
CRAFT_LAUNCHER_NAME,
|
||||
CRAFT_LAUNCHER_REPO,
|
||||
craftLauncherDownloads,
|
||||
craftLauncherReleasePageUrl,
|
||||
} from "@/lib/craft-launcher";
|
||||
import { CRAFT_LAUNCHER_RELEASE } from "@/lib/crafting-app-releases";
|
||||
import { craftAppName, type CraftApp, type CraftDownload } from "@/lib/crafting-apps";
|
||||
import { LauncherDownloadButton } from "./app-downloads";
|
||||
import { ColorAccent } from "./app-wordmark";
|
||||
|
||||
// ArtCraft Launcher on the Crafting Apps pages: the "Recommended" callout
|
||||
// that leads every app's Get-it section. The /apps hub header uses
|
||||
// craftLauncherRecommended for its main download button. Server component;
|
||||
// the download button is the client island.
|
||||
|
||||
const CALLOUT_POINTS = ["Every Crafting App", "One-click updates", "Verified downloads"];
|
||||
|
||||
/** The launcher's main download per platform, for the OS-aware buttons. */
|
||||
export function craftLauncherRecommended(): CraftDownload[] {
|
||||
return craftLauncherDownloads().filter((download) => download.recommended);
|
||||
}
|
||||
|
||||
// Leads an app's Get-it section, above that app's own installers: the pitch
|
||||
// beside its download panel, matching the release and build-from-source
|
||||
// cells below it. Renders nothing while the launcher has no release.
|
||||
export function LauncherCallout({ app }: { app: CraftApp }) {
|
||||
const recommended = craftLauncherRecommended();
|
||||
if (!CRAFT_LAUNCHER_RELEASE || recommended.length === 0) return null;
|
||||
const name = craftAppName(app);
|
||||
return (
|
||||
<div
|
||||
data-reveal
|
||||
className="grid gap-px bg-line lg:grid-cols-[minmax(0,7fr)_minmax(0,4fr)]"
|
||||
>
|
||||
<div className="flex flex-col bg-bg p-6 md:p-10">
|
||||
<div className="flex items-center gap-3">
|
||||
<LauncherMark />
|
||||
<p className="hud-label text-(--app-ink,var(--accent-ink))">
|
||||
Option 1 · Recommended
|
||||
</p>
|
||||
</div>
|
||||
<h3 className="mt-6 font-display text-3xl font-medium leading-[1.05] tracking-[-0.03em] text-ink-strong sm:text-4xl">
|
||||
Get {name} with the <ColorAccent>Launcher</ColorAccent>.
|
||||
</h3>
|
||||
<p className="mt-4 max-w-xl leading-relaxed text-muted">
|
||||
{CRAFT_LAUNCHER_NAME} installs {name} and every other Crafting App
|
||||
from one place, picks the right build for your computer and keeps
|
||||
them all up to date. Install it once and every update is a click
|
||||
away.
|
||||
</p>
|
||||
<ul className="mt-6 flex flex-wrap gap-x-6 gap-y-2">
|
||||
{CALLOUT_POINTS.map((point) => (
|
||||
<li key={point} className="hud-label flex items-center gap-1.5 text-muted">
|
||||
<CheckIcon aria-hidden className="h-3.5 w-3.5 text-(--app-ink,var(--accent-ink))" />
|
||||
{point}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
<div className="flex flex-col justify-center bg-bg p-6 md:p-10">
|
||||
<p className="hud-label text-faint">
|
||||
{CRAFT_LAUNCHER_NAME} · v{CRAFT_LAUNCHER_RELEASE.version}
|
||||
</p>
|
||||
<LauncherDownloadButton
|
||||
recommended={recommended}
|
||||
fallbackHref={craftLauncherReleasePageUrl()}
|
||||
fullWidth
|
||||
className="mt-4"
|
||||
/>
|
||||
<a
|
||||
href={CRAFT_LAUNCHER_REPO}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="hud-label mt-4 flex w-fit items-center gap-1.5 text-muted hover:text-ink"
|
||||
>
|
||||
About the Launcher
|
||||
<ArrowUpRightIcon aria-hidden className="h-3.5 w-3.5" />
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// The ArtCraft mark in a hairline square, like the platform icons in the
|
||||
// download cards. Decorative — it always sits beside the launcher's name.
|
||||
function LauncherMark() {
|
||||
return (
|
||||
<span
|
||||
aria-hidden
|
||||
className="flex h-10 w-10 shrink-0 items-center justify-center border border-line"
|
||||
>
|
||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||
<img src="/artcraft-icon.svg" alt="" className="h-5 w-5" />
|
||||
</span>
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { twMerge } from "tailwind-merge";
|
||||
import { Button, CopyButton } from "@/components/ui";
|
||||
import { trackAttrs } from "@/lib/analytics";
|
||||
|
||||
// Share strip: copy-link plus intent links for the networks our audience
|
||||
// posts to. Hairline cells (gap-px over the line color) so it wraps cleanly
|
||||
@@ -40,6 +41,7 @@ export default function ShareBar({
|
||||
text: string;
|
||||
className?: string;
|
||||
}) {
|
||||
const shareParams = { content_type: "page", item_id: new URL(url).pathname };
|
||||
return (
|
||||
<div
|
||||
className={twMerge(
|
||||
@@ -56,6 +58,7 @@ export default function ShareBar({
|
||||
copiedLabel="Link copied"
|
||||
variant="ghost"
|
||||
className={CELL_CLASSES}
|
||||
{...trackAttrs("share", { method: "copy_link", ...shareParams })}
|
||||
/>
|
||||
{TARGETS.map((target) => (
|
||||
<Button
|
||||
@@ -66,6 +69,7 @@ export default function ShareBar({
|
||||
aria-label={`Share on ${target.name}`}
|
||||
variant="ghost"
|
||||
className={CELL_CLASSES}
|
||||
{...trackAttrs("share", { method: target.name.toLowerCase(), ...shareParams })}
|
||||
>
|
||||
{target.name}
|
||||
</Button>
|
||||
|
||||
@@ -4,6 +4,7 @@ import { useState, type FormEvent } from "react";
|
||||
import { CheckIcon } from "lucide-react";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
import { Button, Input, Label } from "@/components/ui";
|
||||
import { trackEvent } from "@/lib/analytics";
|
||||
import { webappUrl } from "@/lib/links";
|
||||
|
||||
// Submissions go to a Google Form whose responses land in a Google Sheet.
|
||||
@@ -83,6 +84,7 @@ export default function BetaForm() {
|
||||
// Google Forms sends no CORS headers, so this is fire-and-forget: the
|
||||
// response is opaque and "request completed" counts as success.
|
||||
await fetch(FORM_RESPONSE_URL, { method: "POST", mode: "no-cors", body });
|
||||
trackEvent("generate_lead", { form_name: "beta", user_type: userType ?? "" });
|
||||
setSubmitted(true);
|
||||
} catch {
|
||||
setSubmitError(
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import { useState, type FormEvent } from "react";
|
||||
import { CheckIcon, EyeIcon, EyeOffIcon } from "lucide-react";
|
||||
import { Button, Input, Modal } from "@/components/ui";
|
||||
import { trackEvent } from "@/lib/analytics";
|
||||
import { login, signup } from "@/lib/api";
|
||||
import {
|
||||
getLandingUrl,
|
||||
@@ -118,8 +119,9 @@ function SignupForm({
|
||||
maybeReferralCode: getReferralCode(),
|
||||
});
|
||||
setLoading(false);
|
||||
if (result.success) onSuccess();
|
||||
else setError(result.errorMessage || "Failed to create account");
|
||||
if (!result.success) return setError(result.errorMessage || "Failed to create account");
|
||||
trackEvent("sign_up", { method: "email", signup_source: signupSource });
|
||||
onSuccess();
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -162,8 +164,9 @@ function LoginForm({ onSuccess }: { onSuccess: () => void }) {
|
||||
setLoading(true);
|
||||
const result = await login({ usernameOrEmail, password });
|
||||
setLoading(false);
|
||||
if (result.success) onSuccess();
|
||||
else setError(result.errorMessage || "Invalid credentials");
|
||||
if (!result.success) return setError(result.errorMessage || "Invalid credentials");
|
||||
trackEvent("login", { method: "email" });
|
||||
onSuccess();
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import { useState } from "react";
|
||||
import { PlayIcon } from "lucide-react";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
import { trackAttrs } from "@/lib/analytics";
|
||||
import type { ExampleVideo } from "@/lib/campaign-data";
|
||||
|
||||
// Click-to-play facades: the mp4s (several MB each) are only requested
|
||||
@@ -69,6 +70,11 @@ function ExampleCard({
|
||||
onClick={() => setActive(true)}
|
||||
aria-label={`Play example: ${example.label}`}
|
||||
className="group absolute inset-0 h-full w-full"
|
||||
{...trackAttrs("video_start", {
|
||||
video_provider: "self_hosted",
|
||||
video_title: example.label,
|
||||
video_url: example.src,
|
||||
})}
|
||||
>
|
||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||
<img
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
XIcon,
|
||||
} from "lucide-react";
|
||||
import { Button, Select, Switch } from "@/components/ui";
|
||||
import { trackEvent } from "@/lib/analytics";
|
||||
import { generateVideo, getVideoJob } from "@/lib/api";
|
||||
import { H3, H3_GATE_PERKS, H3_SAMPLE_PROMPTS } from "@/lib/campaign-data";
|
||||
import { webappUrl } from "@/lib/links";
|
||||
@@ -101,6 +102,7 @@ export default function H3PromptBox() {
|
||||
setSubmitting(false);
|
||||
if (!result.success) {
|
||||
patch(id, { status: "failed", error: result.errorMessage });
|
||||
trackEvent("video_generation", { model: H3.modelId, status: "failed" });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -114,12 +116,15 @@ export default function H3PromptBox() {
|
||||
if (job.status === "complete") {
|
||||
patch(id, { status: "complete", videoUrl: job.videoUrl });
|
||||
stops.current.delete(id);
|
||||
trackEvent("video_generation", { model: H3.modelId, status: "complete" });
|
||||
} else if (job.status === "failed") {
|
||||
patch(id, { status: "failed", error: job.error });
|
||||
stops.current.delete(id);
|
||||
trackEvent("video_generation", { model: H3.modelId, status: "failed" });
|
||||
} else if (attempts >= POLL_MAX_ATTEMPTS) {
|
||||
patch(id, { status: "failed", error: "Generation timed out" });
|
||||
stops.current.delete(id);
|
||||
trackEvent("video_generation", { model: H3.modelId, status: "timeout" });
|
||||
} else {
|
||||
setTimeout(poll, POLL_INTERVAL_MS);
|
||||
}
|
||||
@@ -136,6 +141,14 @@ export default function H3PromptBox() {
|
||||
setError(`Prompt exceeds the ${MAX_PROMPT_LENGTH} character limit for this model`);
|
||||
return;
|
||||
}
|
||||
trackEvent("prompt_submit", {
|
||||
model: H3.modelId,
|
||||
logged_in: loggedIn,
|
||||
aspect_ratio: aspectRatio,
|
||||
resolution,
|
||||
duration_seconds: Number(duration),
|
||||
sound,
|
||||
});
|
||||
if (!loggedIn) {
|
||||
setGateOpen(true);
|
||||
return;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import { useState } from "react";
|
||||
import { PlayIcon } from "lucide-react";
|
||||
import { trackAttrs } from "@/lib/analytics";
|
||||
|
||||
// Click-to-load YouTube embed: a thumbnail until the visitor asks for the
|
||||
// player, so the landing never pays the iframe cost up front.
|
||||
@@ -32,6 +33,11 @@ export default function LiteYouTube({
|
||||
onClick={() => setActivated(true)}
|
||||
className="group absolute inset-0 h-full w-full"
|
||||
aria-label={`Play video: ${title}`}
|
||||
{...trackAttrs("video_start", {
|
||||
video_provider: "youtube",
|
||||
video_title: title,
|
||||
video_url: `https://www.youtube.com/watch?v=${videoId}`,
|
||||
})}
|
||||
>
|
||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||
<img
|
||||
|
||||
@@ -4,6 +4,7 @@ import { useEffect, useRef, useState, type ReactNode } from "react";
|
||||
import Link from "next/link";
|
||||
import { ArrowDownToLineIcon, CheckIcon, CopyIcon, ExternalLinkIcon } from "lucide-react";
|
||||
import { Button } from "@/components/ui";
|
||||
import { trackEvent } from "@/lib/analytics";
|
||||
import { MEDIA_LABELS, corsMediaUrl, mediaDetailLabel, mediaFormat, mediaKind, mediaThumbnail, safeMediaUrl, type MediaDimensions, type MediaPrompt, type SharedMedia } from "@/lib/media";
|
||||
import { getModelDisplayName, getModelIcon, getProviderDisplayName, getProviderIcon } from "@/lib/model-names";
|
||||
|
||||
@@ -35,6 +36,7 @@ export default function MediaDetails({ media, prompt, promptLoading, dimensions
|
||||
}
|
||||
|
||||
async function download() {
|
||||
trackEvent("media_download", { media_type: kind, file_extension: mediaFormat(media) });
|
||||
setDownloading(true);
|
||||
setMessage("");
|
||||
const controller = new AbortController();
|
||||
@@ -102,7 +104,10 @@ export default function MediaDetails({ media, prompt, promptLoading, dimensions
|
||||
<h2 className="hud-label text-faint">Prompt</h2>
|
||||
{prompt?.maybe_positive_prompt && (
|
||||
<button type="button" className="text-muted hover:text-ink" aria-label={copied === "prompt" ? "Prompt copied" : "Copy prompt"}
|
||||
onClick={() => copy(prompt.maybe_positive_prompt!, "prompt")}>
|
||||
onClick={() => {
|
||||
copy(prompt.maybe_positive_prompt!, "prompt");
|
||||
trackEvent("copy_prompt", { media_type: kind });
|
||||
}}>
|
||||
{copied === "prompt" ? <CheckIcon className="h-4 w-4" /> : <CopyIcon className="h-4 w-4" />}
|
||||
</button>
|
||||
)}
|
||||
@@ -143,7 +148,10 @@ export default function MediaDetails({ media, prompt, promptLoading, dimensions
|
||||
<Button onClick={download} loading={downloading} className="w-full">
|
||||
<ArrowDownToLineIcon aria-hidden className="h-4 w-4" />{downloading ? "Downloading" : "Download file"}
|
||||
</Button>
|
||||
<Button variant="secondary" className="w-full" onClick={() => copy(`${SHARE_URL_BASE}${encodeURIComponent(media.token)}`, "link")}>
|
||||
<Button variant="secondary" className="w-full" onClick={() => {
|
||||
copy(`${SHARE_URL_BASE}${encodeURIComponent(media.token)}`, "link");
|
||||
trackEvent("share", { method: "copy_link", content_type: kind, item_id: media.token });
|
||||
}}>
|
||||
{copied === "link" ? <CheckIcon aria-hidden className="h-4 w-4" /> : <CopyIcon aria-hidden className="h-4 w-4" />}
|
||||
{copied === "link" ? "Link copied" : "Copy share link"}
|
||||
</Button>
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
import { twMerge } from "tailwind-merge";
|
||||
import { SectionShell, SectionEyebrow } from "@/components/landing/section-shell";
|
||||
import { Button, Modal } from "@/components/ui";
|
||||
import { trackAttrs } from "@/lib/analytics";
|
||||
import { mediaUrl } from "@/lib/links";
|
||||
import {
|
||||
PRESS_KIT_CATEGORIES,
|
||||
@@ -148,6 +149,10 @@ function AssetCard({
|
||||
onClick={onPlay}
|
||||
aria-label={`Play ${asset.title}`}
|
||||
className="group relative aspect-video w-full overflow-hidden bg-bg-sunken"
|
||||
{...trackAttrs("video_start", {
|
||||
video_provider: asset.type === "embed" ? "youtube" : "self_hosted",
|
||||
video_title: asset.title,
|
||||
})}
|
||||
>
|
||||
{thumbnail}
|
||||
</button>
|
||||
@@ -175,6 +180,7 @@ function AssetCard({
|
||||
rel="noopener noreferrer"
|
||||
variant="secondary"
|
||||
className="w-full"
|
||||
{...trackAttrs("press_kit_download", { asset_name: asset.title })}
|
||||
>
|
||||
<ArrowDownToLineIcon aria-hidden className="h-3.5 w-3.5" />
|
||||
{asset.downloadLabel ?? "Download"}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import { useState } from "react";
|
||||
import { CoinsIcon } from "lucide-react";
|
||||
import { Button } from "@/components/ui";
|
||||
import { trackEvent } from "@/lib/analytics";
|
||||
import { webappUrl } from "@/lib/links";
|
||||
import { useAccount } from "@/lib/use-account";
|
||||
import CreditsModal from "./credits-modal";
|
||||
@@ -28,7 +29,10 @@ export default function CreditsCta() {
|
||||
<Button
|
||||
type="button"
|
||||
variant="secondary"
|
||||
onClick={() => setOpen(true)}
|
||||
onClick={() => {
|
||||
setOpen(true);
|
||||
trackEvent("view_credit_packs", {});
|
||||
}}
|
||||
className="mt-6"
|
||||
>
|
||||
<CoinsIcon aria-hidden className="h-3.5 w-3.5 text-accent-ink" />
|
||||
|
||||
@@ -4,6 +4,7 @@ import { useState } from "react";
|
||||
import { CoinsIcon } from "lucide-react";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
import { Button, Modal } from "@/components/ui";
|
||||
import { trackEvent } from "@/lib/analytics";
|
||||
import { creditsPackCheckout } from "@/lib/api";
|
||||
|
||||
type CreditPack = {
|
||||
@@ -35,6 +36,20 @@ export default function CreditsModal({
|
||||
const purchase = async (pack: CreditPack) => {
|
||||
setPurchasingId(pack.id);
|
||||
setError(null);
|
||||
trackEvent("begin_checkout", {
|
||||
currency: "USD",
|
||||
value: pack.priceUsd,
|
||||
checkout_type: "credits",
|
||||
items: [
|
||||
{
|
||||
item_id: pack.id,
|
||||
item_name: `${pack.total.toLocaleString("en-US")} credits`,
|
||||
item_category: "credits",
|
||||
price: pack.priceUsd,
|
||||
quantity: 1,
|
||||
},
|
||||
],
|
||||
});
|
||||
const result = await creditsPackCheckout(pack.id);
|
||||
if (result.success) {
|
||||
window.location.href = result.data.checkoutUrl;
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
} from "lucide-react";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
import { Badge, Button, TabSelector } from "@/components/ui";
|
||||
import { trackEvent } from "@/lib/analytics";
|
||||
import {
|
||||
getPortalUrl,
|
||||
subscriptionCheckout,
|
||||
@@ -85,9 +86,26 @@ export default function PricingTable({
|
||||
if (plan.slug === activePlanSlug) return;
|
||||
setProcessingPlan(plan.slug);
|
||||
setError(null);
|
||||
const checkoutType = !user ? "signup" : hasActivePlan ? "switch" : "subscribe";
|
||||
const price = cadence === "yearly" ? plan.yearlyPrice : plan.monthlyPrice;
|
||||
trackEvent("begin_checkout", {
|
||||
currency: "USD",
|
||||
value: price,
|
||||
checkout_type: checkoutType,
|
||||
items: [
|
||||
{
|
||||
item_id: plan.slug,
|
||||
item_name: plan.name,
|
||||
item_category: "subscription",
|
||||
item_variant: cadence,
|
||||
price,
|
||||
quantity: 1,
|
||||
},
|
||||
],
|
||||
});
|
||||
const body = { plan: plan.slug, cadence };
|
||||
const redirected = redirect(
|
||||
!user
|
||||
checkoutType === "signup"
|
||||
? await userSignupSubscriptionCheckout({
|
||||
...body,
|
||||
maybeReferralUrl: getReferrer(),
|
||||
@@ -95,7 +113,7 @@ export default function PricingTable({
|
||||
maybeReferralUsername: getReferralUsername(),
|
||||
maybeReferralCode: getReferralCode(),
|
||||
})
|
||||
: hasActivePlan
|
||||
: checkoutType === "switch"
|
||||
? await switchPlan(body)
|
||||
: await subscriptionCheckout(body),
|
||||
);
|
||||
@@ -103,6 +121,7 @@ export default function PricingTable({
|
||||
};
|
||||
|
||||
const managePlan = async () => {
|
||||
trackEvent("manage_subscription", {});
|
||||
setManaging(true);
|
||||
setError(null);
|
||||
if (!redirect(await getPortalUrl())) setManaging(false);
|
||||
@@ -115,7 +134,11 @@ export default function PricingTable({
|
||||
<TabSelector
|
||||
tabs={BILLING_TABS}
|
||||
activeTab={cadence}
|
||||
onTabChange={(id) => setCadence(id as BillingCadence)}
|
||||
onTabChange={(id) => {
|
||||
if (id === cadence) return;
|
||||
setCadence(id as BillingCadence);
|
||||
trackEvent("billing_cadence_change", { cadence: id });
|
||||
}}
|
||||
tabClassName="w-24"
|
||||
/>
|
||||
<Badge
|
||||
@@ -363,6 +386,7 @@ function ContactButtons({ className }: { className?: string }) {
|
||||
try {
|
||||
await navigator.clipboard.writeText(CONTACT_EMAIL);
|
||||
setCopied(true);
|
||||
trackEvent("contact_click", { method: "copy_email" });
|
||||
setTimeout(() => setCopied(false), 1500);
|
||||
} catch {
|
||||
// Clipboard unavailable (insecure context) — the mailto still works.
|
||||
|
||||
@@ -86,6 +86,7 @@ export function Button({
|
||||
</>
|
||||
);
|
||||
|
||||
// Link buttons carry data-cta so analytics can report them as CTA clicks.
|
||||
if (href) {
|
||||
const anchorProps =
|
||||
rest as unknown as AnchorHTMLAttributes<HTMLAnchorElement>;
|
||||
@@ -96,6 +97,7 @@ export function Button({
|
||||
target={target}
|
||||
rel={rel}
|
||||
className={classes}
|
||||
data-cta=""
|
||||
{...anchorProps}
|
||||
>
|
||||
{content}
|
||||
@@ -103,7 +105,7 @@ export function Button({
|
||||
);
|
||||
}
|
||||
return (
|
||||
<Link href={href} className={classes} {...anchorProps}>
|
||||
<Link href={href} className={classes} data-cta="" {...anchorProps}>
|
||||
{content}
|
||||
</Link>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,232 @@
|
||||
// Google Analytics 4 (gtag.js). Off unless NEXT_PUBLIC_GA_MEASUREMENT_ID is
|
||||
// set at build time, so local dev stays out of the reports.
|
||||
//
|
||||
// Page views come from GA4 Enhanced Measurement (it records App Router
|
||||
// navigations via history changes), along with scrolls, outbound clicks and
|
||||
// common file downloads. On top of that, the site sends the events below.
|
||||
// Most link clicks need no per-component code: one delegated listener
|
||||
// (see components/analytics.tsx) classifies them by href, and elements
|
||||
// tagged with trackAttrs() report their event when clicked. Every delegated
|
||||
// event also carries `link_location` (nav, footer, modal or the enclosing
|
||||
// section id).
|
||||
|
||||
import { SOCIAL_LINKS, WEBAPP_URL } from "./links";
|
||||
|
||||
export const GA_MEASUREMENT_ID =
|
||||
process.env.NEXT_PUBLIC_GA_MEASUREMENT_ID?.trim() || undefined;
|
||||
|
||||
export type AnalyticsItem = {
|
||||
item_id: string;
|
||||
item_name: string;
|
||||
item_category: "subscription" | "credits";
|
||||
item_variant?: string;
|
||||
price: number;
|
||||
quantity: number;
|
||||
};
|
||||
|
||||
type AnalyticsEvents = {
|
||||
// Link clicks, classified by href.
|
||||
app_download: {
|
||||
app_name: string;
|
||||
app_version: string;
|
||||
platform: "macos" | "windows" | "linux" | "other";
|
||||
file_name: string;
|
||||
};
|
||||
webapp_click: { destination: string; link_text: string };
|
||||
social_click: { network: string };
|
||||
contact_click: { method: "mailto" | "copy_email" };
|
||||
cta_click: { link_url: string; link_text: string };
|
||||
|
||||
// Clicks on elements tagged with trackAttrs().
|
||||
video_start: { video_provider: string; video_title: string; video_url?: string };
|
||||
share: { method: string; content_type: string; item_id: string };
|
||||
copy_command: { app_name: string };
|
||||
app_select: { app_name: string };
|
||||
press_kit_download: { asset_name: string };
|
||||
|
||||
// Sent from component code.
|
||||
generate_lead: { form_name: string; user_type: string };
|
||||
sign_up: { method: "email"; signup_source: string };
|
||||
login: { method: "email" };
|
||||
prompt_submit: {
|
||||
model: string;
|
||||
logged_in: boolean;
|
||||
aspect_ratio: string;
|
||||
resolution: string;
|
||||
duration_seconds: number;
|
||||
sound: boolean;
|
||||
};
|
||||
video_generation: { model: string; status: "complete" | "failed" | "timeout" };
|
||||
billing_cadence_change: { cadence: string };
|
||||
view_credit_packs: Record<string, never>;
|
||||
begin_checkout: {
|
||||
currency: "USD";
|
||||
value: number;
|
||||
checkout_type: "signup" | "subscribe" | "switch" | "credits";
|
||||
items: AnalyticsItem[];
|
||||
};
|
||||
manage_subscription: Record<string, never>;
|
||||
copy_prompt: { media_type: string };
|
||||
media_download: { media_type: string; file_extension: string };
|
||||
};
|
||||
|
||||
export type AnalyticsEvent = keyof AnalyticsEvents;
|
||||
|
||||
type ParamValue = string | number | boolean | AnalyticsItem[] | undefined;
|
||||
type EventParams = Record<string, ParamValue>;
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
gtag?: (...args: unknown[]) => void;
|
||||
}
|
||||
}
|
||||
|
||||
export function trackEvent<E extends AnalyticsEvent>(
|
||||
event: E,
|
||||
params: AnalyticsEvents[E],
|
||||
): void {
|
||||
send(event, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Data attributes that make an element report `event` when clicked. Works in
|
||||
* server components (no handler needed); spread onto the element or Button.
|
||||
*/
|
||||
export function trackAttrs<E extends AnalyticsEvent>(
|
||||
event: E,
|
||||
params: AnalyticsEvents[E],
|
||||
): Record<`data-track${string}`, string> {
|
||||
const attrs: Record<`data-track${string}`, string> = { "data-track": event };
|
||||
for (const [key, value] of Object.entries(params)) {
|
||||
if (value !== undefined) attrs[`data-track-${key}`] = String(value);
|
||||
}
|
||||
return attrs;
|
||||
}
|
||||
|
||||
/** Delegated click handler: reports tagged elements and classified links. */
|
||||
export function trackClick(target: EventTarget | null): void {
|
||||
if (!(target instanceof Element)) return;
|
||||
|
||||
const tagged = target.closest<HTMLElement>("[data-track]");
|
||||
if (tagged?.dataset.track) {
|
||||
send(tagged.dataset.track, {
|
||||
...taggedParams(tagged),
|
||||
link_location: linkLocation(tagged),
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const anchor = target.closest<HTMLAnchorElement>("a[href]");
|
||||
const link = anchor && classifyLink(anchor);
|
||||
if (link) send(link.event, { ...link.params, link_location: linkLocation(anchor) });
|
||||
}
|
||||
|
||||
function send(event: string, params: EventParams): void {
|
||||
if (!GA_MEASUREMENT_ID) return;
|
||||
window.gtag?.("event", event, params);
|
||||
}
|
||||
|
||||
const WEBAPP_ORIGIN = new URL(WEBAPP_URL).origin;
|
||||
|
||||
// Hostname → network, derived from SOCIAL_LINKS.
|
||||
const SOCIAL_NETWORKS = new Map(
|
||||
Object.entries(SOCIAL_LINKS).map(([name, href]) => [
|
||||
bareHostname(new URL(href).hostname),
|
||||
name.toLowerCase(),
|
||||
]),
|
||||
);
|
||||
|
||||
// github.com/<org>/<repo>/releases/download/<tag>/<file>: the ArtCraft
|
||||
// installers and every Crafting App download.
|
||||
const RELEASE_ASSET_PATH = /^\/[^/]+\/([^/]+)\/releases\/download\/([^/]+)\/([^/]+)$/;
|
||||
|
||||
type ClassifiedLink = {
|
||||
[E in AnalyticsEvent]: { event: E; params: AnalyticsEvents[E] };
|
||||
}[AnalyticsEvent];
|
||||
|
||||
function classifyLink(anchor: HTMLAnchorElement): ClassifiedLink | null {
|
||||
let url: URL;
|
||||
try {
|
||||
url = new URL(anchor.href);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (url.protocol === "mailto:") {
|
||||
return { event: "contact_click", params: { method: "mailto" } };
|
||||
}
|
||||
|
||||
const release = url.hostname === "github.com" && RELEASE_ASSET_PATH.exec(url.pathname);
|
||||
if (release) {
|
||||
const [, repo, tag, file] = release;
|
||||
const fileName = decodeURIComponent(file);
|
||||
return {
|
||||
event: "app_download",
|
||||
params: {
|
||||
app_name: repo,
|
||||
app_version: tag.replace(/^\D*/, ""),
|
||||
platform: downloadPlatform(fileName),
|
||||
file_name: fileName,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
if (url.origin === WEBAPP_ORIGIN) {
|
||||
return {
|
||||
event: "webapp_click",
|
||||
params: { destination: url.pathname, link_text: linkText(anchor) },
|
||||
};
|
||||
}
|
||||
|
||||
const network = SOCIAL_NETWORKS.get(bareHostname(url.hostname));
|
||||
if (network) return { event: "social_click", params: { network } };
|
||||
|
||||
// Remaining Button links (internal CTAs, other outbound buttons). Plain
|
||||
// text links are left to page views and Enhanced Measurement.
|
||||
if (anchor.hasAttribute("data-cta")) {
|
||||
return {
|
||||
event: "cta_click",
|
||||
params: {
|
||||
link_url: url.origin === window.location.origin ? url.pathname + url.hash : url.href,
|
||||
link_text: linkText(anchor),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function linkLocation(element: Element): string {
|
||||
if (element.closest("#site-nav")) return "nav";
|
||||
if (element.closest("footer")) return "footer";
|
||||
if (element.closest('[role="dialog"]')) return "modal";
|
||||
return element.closest("section[id]")?.id || "page";
|
||||
}
|
||||
|
||||
// data-track-<param> attributes surface in the dataset as track<Param>.
|
||||
function taggedParams(element: HTMLElement): EventParams {
|
||||
const params: EventParams = {};
|
||||
for (const [key, value] of Object.entries(element.dataset)) {
|
||||
if (key.length > 5 && key.startsWith("track")) {
|
||||
params[key.charAt(5).toLowerCase() + key.slice(6)] = value;
|
||||
}
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
function downloadPlatform(fileName: string): AnalyticsEvents["app_download"]["platform"] {
|
||||
if (/\.dmg$|macos/i.test(fileName)) return "macos";
|
||||
if (/\.(exe|msi)$|windows/i.test(fileName)) return "windows";
|
||||
if (/\.(appimage|deb|rpm)$|linux/i.test(fileName)) return "linux";
|
||||
return "other";
|
||||
}
|
||||
|
||||
// GA truncates parameter values at 100 characters.
|
||||
function linkText(anchor: HTMLAnchorElement): string {
|
||||
const text = anchor.getAttribute("aria-label") || anchor.textContent || "";
|
||||
return text.replace(/\s+/g, " ").trim().slice(0, 100);
|
||||
}
|
||||
|
||||
function bareHostname(hostname: string): string {
|
||||
return hostname.replace(/^www\./, "");
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import { CRAFT_LAUNCHER_RELEASE } from "./crafting-app-releases";
|
||||
import {
|
||||
CRAFTING_APPS_GITHUB_ORG,
|
||||
craftReleaseTag,
|
||||
releaseDownloads,
|
||||
type CraftDownload,
|
||||
} from "./crafting-apps";
|
||||
|
||||
// ArtCraft Launcher: one small native app that installs, updates and opens
|
||||
// every Crafting App. The /apps hub's main button downloads it and every
|
||||
// /apps/<slug> Get-it section recommends it above that app's own installers.
|
||||
//
|
||||
// Facts come from the craft-launcher README — keep them in sync. Version and
|
||||
// files live in crafting-app-releases.ts (CRAFT_LAUNCHER_RELEASE); null there
|
||||
// hides every launcher download.
|
||||
|
||||
export const CRAFT_LAUNCHER_NAME = "ArtCraft Launcher";
|
||||
export const CRAFT_LAUNCHER_REPO = `${CRAFTING_APPS_GITHUB_ORG}/craft-launcher`;
|
||||
|
||||
/** Every launcher release file, or none while the release is null. */
|
||||
export function craftLauncherDownloads(): CraftDownload[] {
|
||||
return CRAFT_LAUNCHER_RELEASE
|
||||
? releaseDownloads(CRAFT_LAUNCHER_REPO, "artcraft-launcher", CRAFT_LAUNCHER_RELEASE)
|
||||
: [];
|
||||
}
|
||||
|
||||
export function craftLauncherReleasePageUrl(): string {
|
||||
return CRAFT_LAUNCHER_RELEASE
|
||||
? `${CRAFT_LAUNCHER_REPO}/releases/tag/${craftReleaseTag(CRAFT_LAUNCHER_RELEASE)}`
|
||||
: `${CRAFT_LAUNCHER_REPO}/releases`;
|
||||
}
|
||||
@@ -3,17 +3,14 @@ import type { CraftAppSlug } from "./crafting-apps";
|
||||
// GitHub releases for the Crafting Apps, which drive every download button on
|
||||
// the /apps pages.
|
||||
//
|
||||
// To bump every app: change CRAFTING_APPS_LATEST_VERSION.
|
||||
// To pin one app to another version: give it its own release in
|
||||
// CRAFT_APP_RELEASES, e.g. `craftRelease("0.1.1")`.
|
||||
// To bump an app: change its version in CRAFT_APP_RELEASES (each app has its
|
||||
// own, e.g. `craftRelease("0.4.0")`).
|
||||
// To hide an app's downloads (Discord waitlist instead): set it to null.
|
||||
// If a release renames, adds or drops files, edit CRAFT_RELEASE_ASSETS, or
|
||||
// pass a custom list as craftRelease's second argument for a single app.
|
||||
//
|
||||
// Release tags are `v<version>` and live at github.com/storytold/<slug>.
|
||||
|
||||
export const CRAFTING_APPS_LATEST_VERSION = "0.2.0";
|
||||
|
||||
export type CraftDesktopPlatform = "macOS" | "Windows" | "Linux";
|
||||
|
||||
/** Order of the per-platform download buttons. */
|
||||
@@ -22,7 +19,7 @@ export const CRAFT_DESKTOP_PLATFORMS: CraftDesktopPlatform[] = ["macOS", "Window
|
||||
export type CraftReleaseAsset = {
|
||||
/** Asset filename; `{slug}` and `{version}` are filled in per app. */
|
||||
file: string;
|
||||
/** Group in the full file list. "Other" holds the CLI, web build and checksums. */
|
||||
/** Group in the full file list. "Other" holds the FreeBSD build, web build and checksums. */
|
||||
group: CraftDesktopPlatform | "Other";
|
||||
/** Short name, e.g. "Installer (x64)". */
|
||||
label: string;
|
||||
@@ -43,6 +40,8 @@ export type CraftRelease = {
|
||||
version: string;
|
||||
/** Git tag. Defaults to `v<version>`. */
|
||||
tag?: string;
|
||||
/** Fills `{slug}` in filenames. Defaults to the app's slug; a release from before a rename keeps the old one. */
|
||||
fileSlug?: string;
|
||||
assets: readonly CraftReleaseAsset[];
|
||||
};
|
||||
|
||||
@@ -92,6 +91,20 @@ export const CRAFT_RELEASE_ASSETS: readonly CraftReleaseAsset[] = [
|
||||
description: "Unzip and run on 32-bit Windows.",
|
||||
arch: "x86",
|
||||
},
|
||||
{
|
||||
file: "{slug}-{version}-windows-arm64.msi",
|
||||
group: "Windows",
|
||||
label: "Installer (ARM64)",
|
||||
description: "Windows 11 on ARM laptops.",
|
||||
arch: "aarch64",
|
||||
},
|
||||
{
|
||||
file: "{slug}-{version}-windows-arm64-portable.zip",
|
||||
group: "Windows",
|
||||
label: "Portable (ARM64)",
|
||||
description: "Unzip and run on Windows on ARM.",
|
||||
arch: "aarch64",
|
||||
},
|
||||
{
|
||||
file: "{slug}-{version}-linux-x86_64.AppImage",
|
||||
group: "Linux",
|
||||
@@ -100,6 +113,13 @@ export const CRAFT_RELEASE_ASSETS: readonly CraftReleaseAsset[] = [
|
||||
arch: "x86_64",
|
||||
recommended: true,
|
||||
},
|
||||
{
|
||||
file: "{slug}-{version}-linux-x86_64.flatpak",
|
||||
group: "Linux",
|
||||
label: "Flatpak (x86_64)",
|
||||
description: "Sandboxed. Install with flatpak install --user.",
|
||||
arch: "x86_64",
|
||||
},
|
||||
{
|
||||
file: "{slug}-{version}-linux-x86_64.deb",
|
||||
group: "Linux",
|
||||
@@ -129,6 +149,13 @@ export const CRAFT_RELEASE_ASSETS: readonly CraftReleaseAsset[] = [
|
||||
arch: "aarch64",
|
||||
recommended: true,
|
||||
},
|
||||
{
|
||||
file: "{slug}-{version}-linux-aarch64.flatpak",
|
||||
group: "Linux",
|
||||
label: "Flatpak (ARM64)",
|
||||
description: "Sandboxed, on 64-bit ARM.",
|
||||
arch: "aarch64",
|
||||
},
|
||||
{
|
||||
file: "{slug}-{version}-linux-aarch64.deb",
|
||||
group: "Linux",
|
||||
@@ -150,6 +177,12 @@ export const CRAFT_RELEASE_ASSETS: readonly CraftReleaseAsset[] = [
|
||||
description: "Plain binaries for 64-bit ARM.",
|
||||
arch: "aarch64",
|
||||
},
|
||||
{
|
||||
file: "{slug}-{version}-freebsd-x86_64.tar.gz",
|
||||
group: "Other",
|
||||
label: "FreeBSD (x86_64)",
|
||||
description: "Plain binaries for FreeBSD 14.",
|
||||
},
|
||||
{
|
||||
file: "{slug}-web-{version}.zip",
|
||||
group: "Other",
|
||||
@@ -171,15 +204,21 @@ export function craftRelease(
|
||||
return { version, assets };
|
||||
}
|
||||
|
||||
const LATEST = craftRelease(CRAFTING_APPS_LATEST_VERSION);
|
||||
// ArtCraft Launcher (github.com/storytold/craft-launcher) installs and updates
|
||||
// every app above, and the /apps pages recommend it first. Its releases ship
|
||||
// the same file set minus the macOS CLI, named artcraft-launcher-*.
|
||||
export const CRAFT_LAUNCHER_RELEASE: CraftRelease | null = craftRelease(
|
||||
"0.1.0",
|
||||
CRAFT_RELEASE_ASSETS.filter((asset) => !asset.file.startsWith("{slug}-cli-")),
|
||||
);
|
||||
|
||||
// Every app must be listed, so a new slug fails the type check until it is.
|
||||
export const CRAFT_APP_RELEASES: Record<CraftAppSlug, CraftRelease | null> = {
|
||||
photocraft: LATEST,
|
||||
vectorcraft: LATEST,
|
||||
filmcraft: LATEST,
|
||||
lightcraft: LATEST,
|
||||
printcraft: LATEST,
|
||||
effectcraft: LATEST,
|
||||
designcraft: LATEST,
|
||||
photocraft: craftRelease("0.5.0"),
|
||||
vectorcraft: craftRelease("0.6.0"),
|
||||
filmcraft: craftRelease("0.4.0"),
|
||||
lightcraft: craftRelease("0.4.0"),
|
||||
pdfcraft: craftRelease("0.4.0"),
|
||||
effectcraft: craftRelease("0.6.0"),
|
||||
designcraft: craftRelease("0.4.0"),
|
||||
};
|
||||
@@ -25,7 +25,7 @@ export type CraftAppSlug =
|
||||
| "vectorcraft"
|
||||
| "filmcraft"
|
||||
| "lightcraft"
|
||||
| "printcraft"
|
||||
| "pdfcraft"
|
||||
| "effectcraft"
|
||||
| "designcraft";
|
||||
|
||||
@@ -177,25 +177,31 @@ export const CRAFTING_APPS: CraftApp[] = [
|
||||
file: "hero.webp",
|
||||
source: "shot-1-neon.png",
|
||||
caption: "Neon Drive — made in VectorCraft",
|
||||
alt: "VectorCraft editing a synthwave poster titled Neon Drive with an outer glow in the Appearance panel",
|
||||
alt: "VectorCraft editing the Neon Drive poster, with the title's live outer glow settings in the Appearance panel and its character settings in the Properties panel",
|
||||
},
|
||||
{
|
||||
file: "ribbons.webp",
|
||||
source: "shot-2-ribbons.png",
|
||||
caption: "Live blends between editable spines",
|
||||
alt: "VectorCraft showing live blends: 70 smooth-color steps between two ribbon paths",
|
||||
caption: "Live blends and layers",
|
||||
alt: "VectorCraft showing three live blend ribbons clipped to the artboard, one selected with its key paths, and the Layers panel listing the clip group and blends",
|
||||
},
|
||||
{
|
||||
file: "bezier.webp",
|
||||
source: "shot-4-bezier.png",
|
||||
caption: "Pen and direct selection",
|
||||
alt: "VectorCraft direct-selecting the anchor points and bezier handles of a crescent moon, with the contextual task bar below it",
|
||||
},
|
||||
{
|
||||
file: "perspective.webp",
|
||||
source: "shot-5-perspective.png",
|
||||
caption: "Perspective grid, still editable",
|
||||
alt: "VectorCraft with two lit building facades drawn on the left and right planes of a two-point perspective grid at sunset",
|
||||
},
|
||||
{
|
||||
file: "sheet.webp",
|
||||
source: "shot-3-sheet.png",
|
||||
caption: "Booleans, mesh, repeat and envelope",
|
||||
alt: "VectorCraft feature sheet with exact booleans, a gradient mesh, a live radial repeat and an envelope distort",
|
||||
},
|
||||
{
|
||||
file: "bezier.webp",
|
||||
source: "shot-4-bezier.png",
|
||||
caption: "Direct selection on bezier anchors",
|
||||
alt: "VectorCraft direct-selecting the anchors and handles of a crescent moon path",
|
||||
alt: "VectorCraft in its light theme with four artboards: shape booleans, a gradient mesh, a live radial repeat and an envelope distort",
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -328,8 +334,8 @@ export const CRAFTING_APPS: CraftApp[] = [
|
||||
],
|
||||
},
|
||||
{
|
||||
slug: "printcraft",
|
||||
prefix: "Print",
|
||||
slug: "pdfcraft",
|
||||
prefix: "Pdf",
|
||||
category: "PDF workbench",
|
||||
status: "Early alpha",
|
||||
headline: ["The ", "open-source", " PDF workbench."],
|
||||
@@ -367,27 +373,27 @@ export const CRAFTING_APPS: CraftApp[] = [
|
||||
shots: [
|
||||
{
|
||||
file: "hero.webp",
|
||||
source: "printcraft-viewer.png",
|
||||
source: "pdfcraft-viewer.png",
|
||||
caption: "Viewer with threaded comments",
|
||||
alt: "PrintCraft showing a showcase PDF cover with the tools sidebar and threaded comments",
|
||||
alt: "PdfCraft showing a showcase PDF cover with the All tools panel and threaded comments",
|
||||
},
|
||||
{
|
||||
file: "organize.webp",
|
||||
source: "printcraft-organize.png",
|
||||
source: "pdfcraft-organize.png",
|
||||
caption: "Organize pages like cards",
|
||||
alt: "PrintCraft page organizer with three pages selected for rotate, delete and extract",
|
||||
alt: "PdfCraft page organizer with three pages selected and the page tools in the toolbar above",
|
||||
},
|
||||
{
|
||||
file: "palette.webp",
|
||||
source: "printcraft-palette.png",
|
||||
source: "pdfcraft-palette.png",
|
||||
caption: "A command palette for every tool",
|
||||
alt: "PrintCraft command palette filtering page tools by the word page",
|
||||
alt: "PdfCraft command palette searching for page and listing the page tools",
|
||||
},
|
||||
{
|
||||
file: "twoup.webp",
|
||||
source: "printcraft-twoup.png",
|
||||
source: "pdfcraft-twoup.png",
|
||||
caption: "Two-up Read mode, dark theme",
|
||||
alt: "PrintCraft two-up Read mode in the dark theme showing typeset specimen pages",
|
||||
alt: "PdfCraft two-up Read mode in the dark theme showing typeset specimen pages",
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -646,10 +652,19 @@ export function craftReleaseDownloads(
|
||||
app: CraftApp,
|
||||
release: CraftRelease,
|
||||
): CraftDownload[] {
|
||||
const base = `${craftAppRepo(app)}/releases/download/${craftReleaseTag(release)}`;
|
||||
return releaseDownloads(craftAppRepo(app), app.slug, release);
|
||||
}
|
||||
|
||||
/** Every file in a release of `repo`, in catalog order; `{slug}` defaults to `fileSlug`. */
|
||||
export function releaseDownloads(
|
||||
repo: string,
|
||||
fileSlug: string,
|
||||
release: CraftRelease,
|
||||
): CraftDownload[] {
|
||||
const base = `${repo}/releases/download/${craftReleaseTag(release)}`;
|
||||
return release.assets.map(({ file, ...asset }) => {
|
||||
const fileName = file
|
||||
.replaceAll("{slug}", app.slug)
|
||||
.replaceAll("{slug}", release.fileSlug ?? fileSlug)
|
||||
.replaceAll("{version}", release.version);
|
||||
return { ...asset, fileName, href: `${base}/${fileName}` };
|
||||
});
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
# Google OAuth Configuration
|
||||
# Get the Client ID from the Google Cloud Console:
|
||||
# https://console.cloud.google.com/apis/credentials
|
||||
VITE_GOOGLE_CLIENT_ID=YOUR_CLIENT_ID.apps.googleusercontent.com
|
||||
@@ -1,143 +0,0 @@
|
||||
# Website → Webapp Migration
|
||||
|
||||
The marketing site (`artcraft-website`) is being split apart from the app
|
||||
(`artcraft-webapp`). Anything that isn't pure marketing content belongs in
|
||||
the webapp at `app.getartcraft.com`.
|
||||
|
||||
The migration is **gated by a single boolean** so it can be reverted while
|
||||
we soak the new redirect behavior in production. When we're confident the
|
||||
webapp is handling everything cleanly, do the **cleanup pass** below to
|
||||
permanently delete everything that's only kept around for the rollback path.
|
||||
|
||||
---
|
||||
|
||||
## The switch
|
||||
|
||||
`src/config/links.ts`:
|
||||
|
||||
```ts
|
||||
export const USE_WEBAPP_FOR_APP_FEATURES = true;
|
||||
```
|
||||
|
||||
- `true` (default): legacy paths redirect to the webapp; navbar shows
|
||||
"Launch App"; in-page links go cross-origin to `app.getartcraft.com`.
|
||||
- `false`: everything runs locally on the marketing site (the original
|
||||
pre-split behavior).
|
||||
|
||||
In dev, `WEBAPP_URL` auto-switches to `http://localhost:4201/` so cross-app
|
||||
links work against the local webapp Vite server.
|
||||
|
||||
---
|
||||
|
||||
## What's behind the flag
|
||||
|
||||
### Pages that exist locally only as a fallback
|
||||
|
||||
When `USE_WEBAPP_FOR_APP_FEATURES = true`, these routes mount
|
||||
`<WebappRedirect to="…" />` instead of the page component. The page files
|
||||
are kept on disk so we can roll back by flipping the flag.
|
||||
|
||||
- `src/pages/login/`
|
||||
- `src/pages/signup/`
|
||||
- `src/pages/forgot-password/`
|
||||
- `src/pages/create-image/`
|
||||
- `src/pages/create-video/`
|
||||
- `src/pages/create-vfx/` (the `/background-change` route)
|
||||
- `src/pages/library/`
|
||||
- `src/pages/referrals/`
|
||||
- `src/pages/welcome/`
|
||||
- `src/pages/onboarding/`
|
||||
- `src/pages/checkout/` (success + cancel)
|
||||
|
||||
### Components only used by the above
|
||||
|
||||
- `src/components/auth/` (SignupForm, GoogleLoginButton)
|
||||
- `src/components/credits-modal.tsx`
|
||||
- `src/components/generation-gallery/`
|
||||
- `src/components/lightbox/lightbox.tsx` (the modal `Lightbox`; the
|
||||
`LightboxDetails` + `shared.ts` files in the same folder are still used
|
||||
by the public `/media` page and must be kept)
|
||||
- `src/components/navbar/task-queue.tsx`
|
||||
- `src/components/prompt-box/`
|
||||
- `src/components/settings-modal/`
|
||||
|
||||
### Lib files only used by the above
|
||||
|
||||
- `src/lib/cost-estimate-api.ts`
|
||||
- `src/lib/enter-to-generate-store.ts`
|
||||
- `src/lib/omni-gen-hooks.ts`
|
||||
- `src/lib/prompts-cache.ts`
|
||||
- `src/lib/recreate.ts`
|
||||
|
||||
### Files with conditional flag branches (need cleanup, not deletion)
|
||||
|
||||
- `src/app/app.tsx` — drop the `appOrWebapp()` helper, drop the local route
|
||||
imports, leave only the `<WebappRedirect />` routes
|
||||
- `src/components/navbar/navbar.tsx` — drop the `!USE_WEBAPP_FOR_APP_FEATURES`
|
||||
branches (Login + Sign up buttons in desktop and mobile); keep only Launch
|
||||
App for logged-in users and the Pricing + Launch App combo for logged-out
|
||||
users
|
||||
- `src/components/footer/footer.tsx` — drop the conditional Image/Video
|
||||
links in the Pages column
|
||||
- `src/components/download-modal.tsx` — drop the inline `SignupForm` flow
|
||||
and the `view`/`navigate` state; keep only the webapp `/signup` and
|
||||
`/login` link buttons
|
||||
- `src/pages/landing3/landing3.tsx` — `appLink("/create-image")` /
|
||||
`appLink("/create-video")` can become bare `webappUrl("…")` calls (or
|
||||
inline `${WEBAPP_URL}create-image`)
|
||||
- `src/pages/media/media.tsx` — drop the local
|
||||
`applyRecreateFromMediaToken` branch and the `useNavigate` import; keep
|
||||
only the `window.location.href = …` webapp redirect
|
||||
- `src/pages/pricing/pricing.tsx` — the "Buy Credits" section + `CreditsModal`
|
||||
is currently shown unconditionally; once `credits-modal.tsx` is deleted,
|
||||
remove the section, the `creditsModalOpen` state, the `isLoggedIn` state,
|
||||
and the session-check `useEffect`
|
||||
|
||||
### The flag itself
|
||||
|
||||
`src/config/links.ts` — drop `USE_WEBAPP_FOR_APP_FEATURES`, drop the
|
||||
`appLink()` helper (use `webappUrl()` directly everywhere). Keep
|
||||
`WEBAPP_URL`, `webappUrl()`, `SOCIAL_LINKS`, `SUPPORT_EMAIL`, and the dev
|
||||
override.
|
||||
|
||||
---
|
||||
|
||||
## Cleanup pass — what to do when we're ready to commit to the webapp split
|
||||
|
||||
1. **Confirm the flag has been `true` in production for long enough** that
|
||||
we're sure no real users hit the local routes.
|
||||
2. **Delete** every directory and file listed under "Pages that exist
|
||||
locally only as a fallback", "Components only used by the above", and
|
||||
"Lib files only used by the above".
|
||||
3. **Strip the flag branches** from each file under "Files with conditional
|
||||
flag branches".
|
||||
4. **Remove `USE_WEBAPP_FOR_APP_FEATURES`** and `appLink()` from
|
||||
`src/config/links.ts`.
|
||||
5. **Run** `npx tsc -p tsconfig.app.json --noEmit` from
|
||||
`frontend/apps/artcraft-website` and fix any references the cleanup
|
||||
exposed. (Pre-existing errors in `download-button.tsx` `LINUX` and
|
||||
`pricing-table.tsx` `maybeReferralUsername` are unrelated and can be
|
||||
ignored.)
|
||||
6. **Verify** in dev with `nx serve @frontend/artcraft-website` that every
|
||||
navbar/footer/landing/media flow still works and that legacy URLs still
|
||||
redirect to the webapp via `WebappRedirect`.
|
||||
|
||||
---
|
||||
|
||||
## What stays on the marketing site no matter what
|
||||
|
||||
These are pure marketing content and are **not** behind the flag:
|
||||
|
||||
- `/` → `landing3`
|
||||
- `/landing3`
|
||||
- `/seedance-2` → `landing-sd2`
|
||||
- `/download`
|
||||
- `/media`, `/media/:id` (public viewer; the lightbox's "Recreate" button
|
||||
does cross-origin to the webapp, but the viewer itself stays here)
|
||||
- `/press-kit`
|
||||
- `/tutorials`, `/tutorials/:slug`
|
||||
- `/faq`, `/faq/:slug`
|
||||
- `/news`, `/news/:slug`
|
||||
- `/support`
|
||||
- `/pricing` — Stripe checkout flow stays here (PricingTable → Stripe →
|
||||
`/checkout/success` → WebappRedirect → webapp)
|
||||
@@ -1,157 +0,0 @@
|
||||
/background-change /index.html 200
|
||||
/background-change/ /index.html 200
|
||||
/background-change/* /index.html 200
|
||||
|
||||
/checkout_cancel /index.html 200
|
||||
/checkout_cancel/ /index.html 200
|
||||
/checkout_cancel/* /index.html 200
|
||||
|
||||
/onboarding /index.html 200
|
||||
/onboarding/ /index.html 200
|
||||
/onboarding/* /index.html 200
|
||||
|
||||
/portal_closed /index.html 200
|
||||
/portal_closed/ /index.html 200
|
||||
/portal_closed/* /index.html 200
|
||||
|
||||
/checkout_success /index.html 200
|
||||
/checkout_success/ /index.html 200
|
||||
/checkout_success/* /index.html 200
|
||||
|
||||
/checkout* /index.html 200
|
||||
/checkout/* /index.html 200
|
||||
|
||||
/create-image /index.html 200
|
||||
/create-image/ /index.html 200
|
||||
/create-image/* /index.html 200
|
||||
|
||||
/create-video /index.html 200
|
||||
/create-video/ /index.html 200
|
||||
/create-video/* /index.html 200
|
||||
|
||||
/support /index.html 200
|
||||
/support/ /index.html 200
|
||||
/support/* /index.html 200
|
||||
|
||||
/library /index.html 200
|
||||
/library/ /index.html 200
|
||||
/library/* /index.html 200
|
||||
|
||||
/download /index.html 200
|
||||
/download/ /index.html 200
|
||||
|
||||
/tutorials /index.html 200
|
||||
/tutorials/ /index.html 200
|
||||
|
||||
/login /index.html 200
|
||||
/login/ /index.html 200
|
||||
/login/* /index.html 200
|
||||
|
||||
/media /index.html 200
|
||||
/media/ /index.html 200
|
||||
/media/* /index.html 200
|
||||
|
||||
# Prerendered: serve the per-route index.html so social crawlers get the
|
||||
# correct OG/title tags (see scripts/prerender-meta.mjs). The SPA still boots
|
||||
# from this file and React Router takes over for users.
|
||||
/pricing /pricing/index.html 200
|
||||
/pricing/ /pricing/index.html 200
|
||||
/pricing/* /index.html 200
|
||||
|
||||
/beta /beta/index.html 200
|
||||
/beta/ /beta/index.html 200
|
||||
/beta/* /index.html 200
|
||||
|
||||
/faq /index.html 200
|
||||
/faq/ /index.html 200
|
||||
/faq/* /index.html 200
|
||||
|
||||
/news /index.html 200
|
||||
/news/ /index.html 200
|
||||
/news/* /index.html 200
|
||||
|
||||
/press-kit /index.html 200
|
||||
/press-kit/ /index.html 200
|
||||
/press-kit/* /index.html 200
|
||||
|
||||
/referrals /index.html 200
|
||||
/referrals/ /index.html 200
|
||||
/referrals/* /index.html 200
|
||||
|
||||
# Redirects for growth measurement
|
||||
/reddit /?utm_source=reddit 301
|
||||
|
||||
/news.json /index.html 200
|
||||
|
||||
/signup /index.html 200
|
||||
/signup/ /index.html 200
|
||||
/signup/* /index.html 200
|
||||
|
||||
/forgot-password /index.html 200
|
||||
/forgot-password/ /index.html 200
|
||||
/forgot-password/* /index.html 200
|
||||
|
||||
/welcome /index.html 200
|
||||
/welcome/ /index.html 200
|
||||
/welcome/* /index.html 200
|
||||
|
||||
/password-reset /index.html 200
|
||||
/password-reset/ /index.html 200
|
||||
/password-reset/* /index.html 200
|
||||
|
||||
# Prerendered: exact paths serve their per-route index.html (correct OG tags
|
||||
# for social crawlers); deep sub-paths fall back to the SPA shell. See
|
||||
# scripts/prerender-meta.mjs. NOTE: these exact-match serving rules MUST come
|
||||
# before the /seedance2* alias below, otherwise that wildcard would 301
|
||||
# /seedance2-5 away to /seedance-2 (first match wins in _redirects).
|
||||
/seedance2-5 /seedance2-5/index.html 200
|
||||
/seedance2-5/ /seedance2-5/index.html 200
|
||||
/seedance2-5/* /index.html 200
|
||||
|
||||
/seedance-2 /seedance-2/index.html 200
|
||||
/seedance-2/ /seedance-2/index.html 200
|
||||
/seedance-2/* /index.html 200
|
||||
|
||||
/minimax-h3 /minimax-h3/index.html 200
|
||||
/minimax-h3/ /minimax-h3/index.html 200
|
||||
/minimax-h3/* /index.html 200
|
||||
|
||||
/creators/jboogxcreative /creators/jboogxcreative/index.html 200
|
||||
/creators/jboogxcreative/ /creators/jboogxcreative/index.html 200
|
||||
/creators/* /index.html 200
|
||||
|
||||
# Similar URLs — creator spotlight aliases
|
||||
/jboogx /creators/jboogxcreative 301
|
||||
/jboogx/ /creators/jboogxcreative 301
|
||||
/jboogxcreative /creators/jboogxcreative 301
|
||||
/jboogxcreative/ /creators/jboogxcreative 301
|
||||
|
||||
# Similar URLs: MiniMax H3 aliases
|
||||
/minimax /minimax-h3 301
|
||||
/minimax/ /minimax-h3 301
|
||||
/minimaxh3 /minimax-h3 301
|
||||
/minimaxh3* /minimax-h3 301
|
||||
/minimax-h-3 /minimax-h3 301
|
||||
/minimax-h-3* /minimax-h3 301
|
||||
/hailuo /minimax-h3 301
|
||||
/hailuo/ /minimax-h3 301
|
||||
|
||||
# Google ads breakage
|
||||
/seedance-2{ignore} /seedance-2 301
|
||||
/seedance-2{ignore}* /seedance-2 301
|
||||
/seedance-2%7Bignore%7D /seedance-2 301
|
||||
/seedance-2%7Bignore%7D* /seedance-2 301
|
||||
|
||||
# Similar URLs — Seedance 2.5 aliases (kept above the broad /seedance2* rule)
|
||||
/seedance-2-5 /seedance2-5 301
|
||||
/seedance-2-5* /seedance2-5 301
|
||||
/seedance-2.5 /seedance2-5 301
|
||||
/seedance-2.5* /seedance2-5 301
|
||||
/seedance25 /seedance2-5 301
|
||||
/seedance25* /seedance2-5 301
|
||||
|
||||
# Similar URLs — Seedance 2.0 aliases
|
||||
/seedance2 /seedance-2 301
|
||||
/seedance2* /seedance-2 301
|
||||
/seedance-2.0 /seedance-2 301
|
||||
/seedance-2.0* /seedance-2 301
|
||||
@@ -1,52 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<!-- Google tag (gtag.js) -->
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag() {
|
||||
dataLayer.push(arguments);
|
||||
}
|
||||
if (window.location.pathname === "/login/desktop") {
|
||||
const policy = document.createElement("meta");
|
||||
policy.name = "referrer";
|
||||
policy.content = "no-referrer";
|
||||
document.head.appendChild(policy);
|
||||
} else {
|
||||
const analytics = document.createElement("script");
|
||||
analytics.async = true;
|
||||
analytics.src = "https://www.googletagmanager.com/gtag/js?id=G-VKW89949V0";
|
||||
document.head.appendChild(analytics);
|
||||
gtag("js", new Date());
|
||||
gtag("config", "G-VKW89949V0");
|
||||
}
|
||||
</script>
|
||||
|
||||
<meta charset="utf-8" />
|
||||
<title>ArtCraft. AI Video and Images. Fast and Open Desktop App.</title>
|
||||
<meta
|
||||
name="description"
|
||||
content="ArtCraft is an Open Desktop app for generating AI Video and Images. You own ArtCraft!"
|
||||
/>
|
||||
<meta
|
||||
name="keywords"
|
||||
content="ArtCraft, AI, AI Video, AI Images, Open Source"
|
||||
/>
|
||||
|
||||
<base href="/" />
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
|
||||
<link rel="stylesheet" href="/src/styles.css" />
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,200..800&family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Outfit:wght@100..900&family=Source+Sans+3:ital,wght@0,200..900;1,200..900&family=Instrument+Serif:ital@0;1&family=Geist+Mono:wght@300..800&display=swap"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,29 +0,0 @@
|
||||
# Netlify settings used to discover this file:
|
||||
# Base directory: frontend
|
||||
# Package directory: apps/artcraft-website (relative to the base directory)
|
||||
# Manage the build command and publish directory here; leave those UI fields empty.
|
||||
# Paths below are relative to the frontend workspace.
|
||||
|
||||
[build]
|
||||
command = "bash ./apps/artcraft-website/script/netlify_build.sh"
|
||||
publish = "apps/artcraft-website/dist/"
|
||||
|
||||
[[headers]]
|
||||
for = "/build/*"
|
||||
|
||||
[headers.values]
|
||||
"Cache-Control" = "public, max-age=31560000, immutable"
|
||||
|
||||
# [[redirects]]
|
||||
# from = "/ingest/static/*"
|
||||
# to = "https://us-assets.i.posthog.com/static/:splat"
|
||||
# host = "us-assets.i.posthog.com"
|
||||
# status = 200
|
||||
# force = true
|
||||
#
|
||||
# [[redirects]]
|
||||
# from = "/ingest/*"
|
||||
# to = "https://us.i.posthog.com/:splat"
|
||||
# host = "us.i.posthog.com"
|
||||
# status = 200
|
||||
# force = true
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"name": "@frontend/artcraft-website",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"react-masonry-css": "^1.0.16"
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
const { join } = require('path');
|
||||
|
||||
// Note: If you use library-specific PostCSS/Tailwind configuration then you should remove the `postcssConfig` build
|
||||
// option from your application's configuration (i.e. project.json).
|
||||
//
|
||||
// See: https://nx.dev/guides/using-tailwind-css-in-react#step-4:-applying-configuration-to-libraries
|
||||
|
||||
module.exports = {
|
||||
plugins: {
|
||||
tailwindcss: {
|
||||
config: join(__dirname, 'tailwind.config.js'),
|
||||
},
|
||||
autoprefixer: {},
|
||||
},
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg id="Layer_2" data-name="Layer 2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 116.34 97.5">
|
||||
<defs>
|
||||
<style>
|
||||
.cls-1 {
|
||||
fill: #4e7bfb;
|
||||
}
|
||||
</style>
|
||||
</defs>
|
||||
<g id="Layer_1-2" data-name="Layer 1">
|
||||
<path class="cls-1" d="M104.28,49.49L81.55,0h-31.23l-3.17,4.76L14.75,53.63,0,75.85l21.55,21.55,63.79-36.94,16.99,37.04,14.01-21.74-12.06-26.27ZM32.89,65.66l32.42-48.87,10.91,23.77-43.32,25.09Z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 483 B |
|
Before Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 662 KiB |
|
Before Width: | Height: | Size: 45 KiB |
|
Before Width: | Height: | Size: 199 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 463 KiB |
|
Before Width: | Height: | Size: 181 KiB |
|
Before Width: | Height: | Size: 8.8 KiB |
|
Before Width: | Height: | Size: 6.2 KiB |
|
Before Width: | Height: | Size: 1.8 MiB |
|
Before Width: | Height: | Size: 19 MiB |
|
Before Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 20 MiB |
|
Before Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 22 MiB |
|
Before Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 2.0 MiB |
|
Before Width: | Height: | Size: 2.3 MiB |
|
Before Width: | Height: | Size: 1.4 MiB |