Files
zeekayandHanzo Dev 751ef5c778 rename the framework to @hanzo/gui and the loader to @hanzogui/loader
Both old names are owned by a different npm account (artemis-prime), so
publishing them returns 403 — which is how this surfaced: the 8.0.0 run
shipped @hanzogui/logo and @hanzogui/demos depending on [email protected], a
version that cannot be published and therefore does not exist. Those two
were uninstallable.

@hanzo/gui and @hanzogui/* are ours, so the framework now carries the name
it is imported by everywhere downstream, and the loader moves under the
scope we control.

The rewrite is limited to package references. `DEBUG?.startsWith('hanzogui')`
is a log-namespace filter and join(dir, 'hanzogui') is a path — rewriting
either would change behaviour, so both are untouched.

Co-authored-by: Hanzo Dev <[email protected]>
2026-07-30 20:23:18 -07:00

82 lines
1.8 KiB
TypeScript

import { createStudioThemes } from '@hanzogui/theme-builder'
import type { BuildThemeSuiteProps } from '@hanzogui/themes'
import type { ThemeName } from '@hanzo/gui'
import { debounce, mutateThemes } from '@hanzo/gui'
const STUDIO_INTERNAL_THEME_NAME = 'studiodemointernal'
export function getStudioInternalThemeName(id: string) {
return `${STUDIO_INTERNAL_THEME_NAME}${id}` as ThemeName
}
const running = new Map()
export const builtThemes: Record<string, any> = {}
export let lastInserted = null as any
if (process.env.NODE_ENV === 'development') {
globalThis['builtThemes'] = builtThemes
}
const themeCache = new Map<
string,
{
palettes: any
schemes: any
templateStrategy: string
themes: any
}
>()
export async function updatePreviewTheme(
args: BuildThemeSuiteProps & {
id: string
}
) {
const cacheKey = args.id
const cached = themeCache.get(cacheKey)
if (
cached &&
JSON.stringify(cached.palettes) === JSON.stringify(args.palettes) &&
JSON.stringify(cached.schemes) === JSON.stringify(args.schemes) &&
cached.templateStrategy === args.templateStrategy
) {
return false
}
const { themes } = createStudioThemes(args)
themeCache.set(cacheKey, {
palettes: args.palettes,
schemes: args.schemes,
templateStrategy: args.templateStrategy ?? 'base',
themes,
})
let insertThemes: any[] = []
for (const themeName in themes) {
const theme = themes[themeName]
const [scheme, ...rest] = themeName.split('_')
const finalName = [scheme, getStudioInternalThemeName(args.id), ...rest].join('_')
insertThemes.push({
name: finalName,
theme,
})
}
if (process.env.NODE_ENV === 'development') {
builtThemes[args.id] = themes
}
lastInserted = themes
mutateThemes({
themes: insertThemes,
batch: 'themes',
})
return true
}