Compare commits

...
Author SHA1 Message Date
Brandon Thomas 8f6a4b2416 less logging 2025-09-25 05:37:05 -04:00
Brandon Thomas 581112ce1d nx breaks singleton behavior - this bypasses it. Yuck. 2025-09-25 05:29:34 -04:00
Brandon Thomas 1ca32b0964 debug logging 2025-09-25 03:53:09 -04:00
4 changed files with 40 additions and 9 deletions
+2 -4
View File
@@ -98,15 +98,15 @@ export class UsersApi extends ApiManager {
usernameOrEmail: string;
password: string;
}): Promise<ApiResponse<{ signedSession?: string }>> {
console.log("Logging in with usernameOrEmail:", usernameOrEmail);
console.log("libs/api - Logging in with usernameOrEmail:", usernameOrEmail);
const endpoint = `${this.getApiSchemeAndHost()}/v1/login`;
console.log("libs/api - Login endpoint", endpoint);
const body = {
username_or_email: usernameOrEmail,
password: password,
};
try {
console.log("calling auth fetch")
const response = await this.authFetch<
{ username_or_email: string; password: string },
{
@@ -119,8 +119,6 @@ export class UsersApi extends ApiManager {
method: "POST",
body: body,
});
console.log(response)
console.log("Auth fetch response!!! above")
return {
success: response.success,
data: response.success
@@ -1,8 +1,14 @@
// Artcraft / Storyteller API backend
const DEFAULT_API_HOST = "https://api.storyteller.ai";
// NB(bt,2025-09-25): 'nx' is creating multiple copies of the library with name
// mangling, so the singleton pattern fails to resolve to a single instance.
(window as any).STORYTELLER_API_HOST_STORE = undefined;
export class StorytellerApiHostStore {
private static instance: StorytellerApiHostStore;
// NB(bt,2025-09-25): 'nx' is creating multiple copies of the library with name
// mangling, so the singleton pattern fails to resolve to a single instance.
// private static instance: StorytellerApiHostStore;
/**
* The scheme and host of the API.
@@ -11,17 +17,29 @@ export class StorytellerApiHostStore {
*/
private apiSchemeAndHost: string;
// NB(bt,2025-09-25): 'nx' is creating multiple copies of the library with name
// mangling, so the singleton pattern fails to resolve to a single instance.
// public static getInstance(): StorytellerApiHostStore {
// if (StorytellerApiHostStore.instance !== undefined) {
// return StorytellerApiHostStore.instance;
// }
// const instance = new StorytellerApiHostStore(DEFAULT_API_HOST);
// StorytellerApiHostStore.instance = instance;
// return instance;
// }
public static getInstance(): StorytellerApiHostStore {
if (StorytellerApiHostStore.instance !== undefined) {
return StorytellerApiHostStore.instance;
if ((window as any).STORYTELLER_API_HOST_STORE !== undefined) {
return (window as any).STORYTELLER_API_HOST_STORE;
}
const instance = new StorytellerApiHostStore(DEFAULT_API_HOST);
StorytellerApiHostStore.instance = instance;
(window as any).STORYTELLER_API_HOST_STORE = instance;
return instance;
}
/** Get the API scheme and host. */
public getApiSchemeAndHost(): string {
console.debug("StorytellerApiHostStore.getApiSchemeAndHost()", this.apiSchemeAndHost, this.constructor.name);
return this.apiSchemeAndHost;
}
@@ -30,14 +48,18 @@ export class StorytellerApiHostStore {
* This is used to sync with Tauri for enabling easier development.
*/
public setApiSchemeAndHost(apiSchemeAndHost: string) {
console.debug("StorytellerApiHostStore.setApiSchemeAndHost()", apiSchemeAndHost, this.constructor.name);
// TODO(bt,2025-07-06): Actually parse URL.
if (!apiSchemeAndHost.startsWith("http://") && !apiSchemeAndHost.startsWith("https://")) {
throw new Error(`Scheme not included in URL: ${apiSchemeAndHost}`);
}
const FINAL_VALID_SLASH = "https://".lastIndexOf("/");
if (apiSchemeAndHost.lastIndexOf("/") > FINAL_VALID_SLASH) {
throw new Error(`Path components should not be included in URL: ${apiSchemeAndHost}`);
}
this.apiSchemeAndHost = apiSchemeAndHost;
}
+11
View File
@@ -33,6 +33,17 @@ export default defineConfig(() => ({
// External packages that should not be bundled into your library.
external: []
},
// NB(bt,2025-09-25): This mangling config doesn't seem like it works:
//terserOptions: {
// compress: {
// keep_classnames: true,
// keep_fnames: true,
// },
// mangle: {
// keep_classnames: true,
// keep_fnames: true,
// }
//},
},
test: {
watch: false,
@@ -64,7 +64,7 @@ export const PromptBoxImage = ({
}: PromptBoxImageProps) => {
useSignals();
console.log("Selected model:", selectedModel);
console.debug("Selected model:", selectedModel);
useEffect(() => {
if (imageMediaId && url) {