diff --git a/src/app/args.ts b/src/app/args.ts index e4945cd17..ccdb5936b 100644 --- a/src/app/args.ts +++ b/src/app/args.ts @@ -1,8 +1,8 @@ import { CommandLineOptions } from "https://dev.cdn.unyt.org/command-line-args/main.ts" import { Path } from "../utils/path.ts"; import { getExistingFile } from "../utils/file-utils.ts"; -import { UIX } from "../../uix.ts"; import { ESCAPE_SEQUENCES } from "datex-core-legacy/utils/logger.ts"; +import { version as UIX_VERSION } from "../utils/version.ts"; export const command_line_options = new CommandLineOptions("UIX", "Fullstack Web Framework with DATEX Integration.\nVisit https://unyt.org/uix for more information", "../RUN.md"); @@ -40,7 +40,7 @@ const version = command_line_options.option("version", {type:"boolean", descript if (version) { const DATEX_VERSION = (await import("datex-core-legacy/VERSION.ts")).default; - let log = `${ESCAPE_SEQUENCES.BOLD}${ESCAPE_SEQUENCES.UNYT_BLUE}UIX ${UIX.version == "beta" ? "beta" : "v" + UIX.version}${ESCAPE_SEQUENCES.RESET} (${new URL("../../", import.meta.url)})`; + let log = `${ESCAPE_SEQUENCES.BOLD}${ESCAPE_SEQUENCES.UNYT_BLUE}UIX ${UIX_VERSION == "beta" ? "beta" : "v" + UIX_VERSION}${ESCAPE_SEQUENCES.RESET} (${new URL("../../", import.meta.url)})`; log += `\n\n${ESCAPE_SEQUENCES.BOLD}DATEX Core: ${ESCAPE_SEQUENCES.RESET} ${DATEX_VERSION == "beta" ? "beta" : "v" + DATEX_VERSION} (${import.meta.resolve("datex-core-legacy/")})` log += `\n${ESCAPE_SEQUENCES.BOLD}Deno: ${ESCAPE_SEQUENCES.RESET} ${Deno.version.deno}` log += `\n${ESCAPE_SEQUENCES.BOLD}TypeScript: ${ESCAPE_SEQUENCES.RESET} ${Deno.version.typescript}` diff --git a/src/utils/version.ts b/src/utils/version.ts new file mode 100644 index 000000000..74f5fcda0 --- /dev/null +++ b/src/utils/version.ts @@ -0,0 +1,12 @@ + +/** + * get version from ./version file + */ +let _version = "beta"; +try { + _version = (await import("../../VERSION.ts")).default +} +catch { + console.error("Could not determine UIX version") +} +export const version = _version; \ No newline at end of file diff --git a/uix.ts b/uix.ts index b47d9f59b..0497805df 100644 --- a/uix.ts +++ b/uix.ts @@ -3,25 +3,15 @@ import { client_type } from "datex-core-legacy/utils/constants.ts"; import { getThemeManager } from "./src/base/theme-manager.ts"; import { UIX_COOKIE, setCookie } from "./src/session/cookies.ts"; import { Path } from "./src/utils/path.ts"; -import { Datex } from "datex-core-legacy/mod.ts"; +import { Datex } from "datex-core-legacy"; import { cache_path } from "datex-core-legacy/runtime/cache_path.ts"; +import { version } from "./src/utils/version.ts"; /** * get UIX cache path */ const cacheDir = client_type == "deno" ? new Path('./uix/', cache_path) : new Path('/@uix/cache/', location.origin); -/** - * get version from ./version file - */ -let version = "beta"; -try { - version = (await import("./VERSION.ts")).default -} -catch { - console.error("Could not determine DATEX version") -} - export const UIX = { version, get context() { @@ -41,14 +31,10 @@ export const UIX = { if (client_type == "browser") { // update uix-language cookie (only works if runtime initialized!) - try { - Datex.Ref.observe(Datex.Runtime.ENV.$.LANG, lang => { - setCookie(UIX_COOKIE.language, lang) - document.documentElement?.setAttribute("lang", lang) - }) - } catch (e) { - console.error(e); - } + Datex.Ref.observe(Datex.Runtime.ENV.$.LANG, lang => { + setCookie(UIX_COOKIE.language, lang) + document.documentElement?.setAttribute("lang", lang) + }) // make sure UIX theme manager is activated getThemeManager();