GUI-STUDIO commited on
Commit
cf0cee0
·
1 Parent(s): 3db16d9

Refactor setup states into unified FilmSetupState component

Browse files

Consolidate loading and error state handling by creating a new FilmSetupState component that replaces separate FilmFailed and FilmLoading components. Move test data to server-side and make environment variable lookups dynamic. Add @ui path alias and minor fixes to bucket utilities, border-radius SCSS, and URL routing.

src/lib/bucket.ts CHANGED
@@ -13,21 +13,30 @@ const HF_BUCKET_ACCESS_TOKEN = () =>
13
  const HF_BUCKET_REPO = () =>
14
  NS_runtime.ENV_VAR_DB?.HF_BUCKET_REPO || process.env.HF_BUCKET_REPO;
15
 
16
- export const STORAGE_ROOT =
17
- process.env.STORAGE_ROOT || path.join(process.cwd(), "S3");
18
-
19
- export const repo: RepoDesignation = {
20
- type: "bucket",
21
- name: HF_BUCKET_REPO() || ""
 
 
 
 
 
22
  };
23
 
24
- export const credentials: { accessToken: AccessToken } = {
25
- accessToken: HF_BUCKET_ACCESS_TOKEN()!
 
 
 
 
26
  };
27
 
28
  // await hub.createRepo({
29
- // repo,
30
- // accessToken: credentials.accessToken,
31
  // private: false
32
  // });
33
 
@@ -116,6 +125,9 @@ function trackProgress_v2(
116
  async function get_hf_bucket_file_info(arg0: { file_path: string }) {
117
  const { file_path } = arg0;
118
 
 
 
 
119
  if (
120
  !credentials.accessToken ||
121
  typeof file_path !== "string" ||
@@ -138,6 +150,9 @@ async function get_hf_bucket_file_info(arg0: { file_path: string }) {
138
  }
139
 
140
  async function get_hf_bucket_list_of_files() {
 
 
 
141
  if (!credentials.accessToken) return;
142
 
143
  const available_files = await Array.fromAsync(
@@ -157,6 +172,8 @@ async function get_latest_hf_bucket_file_by_name(arg0: {
157
  sbe_id?: string;
158
  }) {
159
  const { folder_path, human_filename, sbe_id } = arg0;
 
 
160
  if (
161
  !credentials.accessToken ||
162
  typeof folder_path !== "string" ||
@@ -245,6 +262,9 @@ async function upload_to_bucket(arg0: {
245
  }) {
246
  const { job_id, bucket_path, skip, file_with_path, REQ0 } = arg0;
247
 
 
 
 
248
  upload_jobs.set(job_id, {
249
  status: "in-progress",
250
  created_at: Date.now()
 
13
  const HF_BUCKET_REPO = () =>
14
  NS_runtime.ENV_VAR_DB?.HF_BUCKET_REPO || process.env.HF_BUCKET_REPO;
15
 
16
+ export const STORAGE_ROOT = () =>
17
+ NS_runtime.ENV_VAR_DB?.STORAGE_ROOT ||
18
+ process.env.STORAGE_ROOT ||
19
+ path.join(process.cwd(), "S3");
20
+
21
+ export const hf_repo = () => {
22
+ const data: RepoDesignation = {
23
+ type: "bucket",
24
+ name: HF_BUCKET_REPO() || ""
25
+ };
26
+ return data;
27
  };
28
 
29
+ export const bucket_credentials = () => {
30
+ const data: { accessToken: AccessToken } = {
31
+ accessToken: HF_BUCKET_ACCESS_TOKEN()!
32
+ };
33
+
34
+ return data;
35
  };
36
 
37
  // await hub.createRepo({
38
+ // repo: hf_repo(),
39
+ // accessToken: bucket_credentials().accessToken,
40
  // private: false
41
  // });
42
 
 
125
  async function get_hf_bucket_file_info(arg0: { file_path: string }) {
126
  const { file_path } = arg0;
127
 
128
+ const credentials = bucket_credentials();
129
+ const repo = hf_repo();
130
+
131
  if (
132
  !credentials.accessToken ||
133
  typeof file_path !== "string" ||
 
150
  }
151
 
152
  async function get_hf_bucket_list_of_files() {
153
+ const credentials = bucket_credentials();
154
+ const repo = hf_repo();
155
+
156
  if (!credentials.accessToken) return;
157
 
158
  const available_files = await Array.fromAsync(
 
172
  sbe_id?: string;
173
  }) {
174
  const { folder_path, human_filename, sbe_id } = arg0;
175
+ const credentials = bucket_credentials();
176
+ const repo = hf_repo();
177
  if (
178
  !credentials.accessToken ||
179
  typeof folder_path !== "string" ||
 
262
  }) {
263
  const { job_id, bucket_path, skip, file_with_path, REQ0 } = arg0;
264
 
265
+ const credentials = bucket_credentials();
266
+ const repo = hf_repo();
267
+
268
  upload_jobs.set(job_id, {
269
  status: "in-progress",
270
  created_at: Date.now()
src/sub-router/ffmpeg/v2.ts CHANGED
@@ -337,11 +337,11 @@ const sub_router = new Elysia({ prefix: "/ffmpeg/v2" }).post(
337
 
338
  (delivery_payload as any).cache_id = key;
339
 
340
- // if (APP_ENV() === "dev") {
341
- // offline_store.set(key, delivery_payload);
342
- // } else {
343
  await redis().set(key, delivery_payload, { ex: ONE_MONTH_IN_SECONDS });
344
- // }
345
 
346
  return key;
347
  })();
 
337
 
338
  (delivery_payload as any).cache_id = key;
339
 
340
+ if (APP_ENV() === "dev") {
341
+ offline_store.set(key, delivery_payload);
342
+ } else {
343
  await redis().set(key, delivery_payload, { ex: ONE_MONTH_IN_SECONDS });
344
+ }
345
 
346
  return key;
347
  })();
src/sub-router/showtime/v2.ts CHANGED
@@ -7,16 +7,13 @@ import { NS_ffmpeg } from "../../lib/ffmpeg";
7
  import { redis } from "../../lib/upstash";
8
  import path from "node:path";
9
  import ky from "ky";
10
- import * as hub from "@huggingface/hub";
11
- import { NS_mongo_db_record_factory } from "../../../../../../packages/db/index";
12
- import { NS_bucket, repo, credentials, STORAGE_ROOT } from "../../lib/bucket";
13
  import { offline_store } from "../../lib/offline-store";
14
  import { T_delivery_payload } from "../ffmpeg/v2";
15
  import { NS_ffmpeg_v2 } from "../../lib/ffmpeg-v2";
16
  import { spawn } from "node:child_process";
17
  import { NS_showtime_v2_helper } from "./helper";
18
  import { T_playback } from "../ffmpeg/validator-v2";
19
- import { NS_routes_c } from "../../../../../../packages/lib/helpers/client/route";
20
  import { NS_runtime } from "../../../../../../packages/lib/env.runtime";
21
 
22
  const APP_ENV = () => NS_runtime.ENV_VAR_DB?.APP_ENV || process?.env?.APP_ENV;
@@ -115,7 +112,7 @@ const sub_router = new Elysia({ prefix: "/showtimeV2" }).get(
115
 
116
  const cache_folder = `cache/${sbe_id}`;
117
 
118
- const S3Dir = path.join(STORAGE_ROOT, `${cache_folder}`);
119
 
120
  const file_with_path = (() => {
121
  if (!is_download_mode) return;
 
7
  import { redis } from "../../lib/upstash";
8
  import path from "node:path";
9
  import ky from "ky";
10
+ import { NS_bucket, STORAGE_ROOT } from "../../lib/bucket";
 
 
11
  import { offline_store } from "../../lib/offline-store";
12
  import { T_delivery_payload } from "../ffmpeg/v2";
13
  import { NS_ffmpeg_v2 } from "../../lib/ffmpeg-v2";
14
  import { spawn } from "node:child_process";
15
  import { NS_showtime_v2_helper } from "./helper";
16
  import { T_playback } from "../ffmpeg/validator-v2";
 
17
  import { NS_runtime } from "../../../../../../packages/lib/env.runtime";
18
 
19
  const APP_ENV = () => NS_runtime.ENV_VAR_DB?.APP_ENV || process?.env?.APP_ENV;
 
112
 
113
  const cache_folder = `cache/${sbe_id}`;
114
 
115
+ const S3Dir = path.join(STORAGE_ROOT(), `${cache_folder}`);
116
 
117
  const file_with_path = (() => {
118
  if (!is_download_mode) return;