mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-09 19:41:32 +00:00
fix nx singleton mangling (#851)
This commit is contained in:
1 parent
41940839fd
commit
7374076506
4 files changed
+40
-9
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user