diff --git a/com/static/bundled/com/moderation-alert-index.ts b/com/static/bundled/com/moderation-alert-index.ts index 70dc871c..029ff87e 100644 --- a/com/static/bundled/com/moderation-alert-index.ts +++ b/com/static/bundled/com/moderation-alert-index.ts @@ -1,4 +1,3 @@ -import { exportToHtml } from "#core:utils/globals.ts"; import { newsDeleteNews, newsFetchNewsDates, newsPublishNews } from "#openapi"; // This will be used in jinja templates, @@ -13,7 +12,8 @@ const AlertState = { // biome-ignore lint/style/useNamingConvention: this feels more like an enum DISPLAYED: 4, // When published at page generation }; -exportToHtml("AlertState", AlertState); +// biome-ignore lint/style/useNamingConvention: it's an enum, PascalCase is better +Object.assign(window, { AlertState }); document.addEventListener("alpine:init", () => { Alpine.data("moderationAlert", (newsId: number) => ({ diff --git a/core/static/bundled/sentry-popup-index.ts b/core/static/bundled/sentry-popup-index.ts index ea16c092..d8b84197 100644 --- a/core/static/bundled/sentry-popup-index.ts +++ b/core/static/bundled/sentry-popup-index.ts @@ -1,6 +1,5 @@ // biome-ignore lint/performance/noNamespaceImport: this is the recommended way from the documentation import * as Sentry from "@sentry/browser"; -import { exportToHtml } from "#core:utils/globals.ts"; interface LoggedUser { name: string; @@ -13,7 +12,7 @@ interface SentryOptions { user?: LoggedUser; } -exportToHtml("loadSentryPopup", (options: SentryOptions) => { +const loadSentryPopup = (options: SentryOptions) => { Sentry.init({ dsn: options.dsn, }); @@ -21,4 +20,5 @@ exportToHtml("loadSentryPopup", (options: SentryOptions) => { eventId: options.eventId, ...(options.user ?? {}), }); -}); +}; +Object.assign(window, { loadSentryPopup }); diff --git a/core/static/bundled/utils/globals.ts b/core/static/bundled/utils/globals.ts index b4f9a457..71c15cb0 100644 --- a/core/static/bundled/utils/globals.ts +++ b/core/static/bundled/utils/globals.ts @@ -5,17 +5,3 @@ declare global { const gettext: (text: string) => string; const interpolate: (fmt: string, args: string[] | T, isNamed?: boolean) => string; } - -/** - * Helper function to export typescript functions to regular html and jinja files - * Without it, you either have to use the any keyword and suppress warnings or do a - * very painful type conversion workaround which is only here to please the linter - * - * This is only useful if you're using typescript, this is equivalent to doing - * window.yourFunction = yourFunction - **/ -// biome-ignore lint/suspicious/noExplicitAny: Avoid strange tricks to export functions -export function exportToHtml(name: string, func: any) { - // biome-ignore lint/suspicious/noExplicitAny: Avoid strange tricks to export functions - (window as any)[name] = func; -} diff --git a/docs/tutorial/front/localstorage.md b/docs/tutorial/front/localstorage.md index 43275bc9..fac974ab 100644 --- a/docs/tutorial/front/localstorage.md +++ b/docs/tutorial/front/localstorage.md @@ -51,7 +51,7 @@ Dans le cas où une paire clef-valeur du localStorage subit un changement dans son schéma de données, utilisez `versionedLocalStorage` : ```typescript -import { versionedLocalStorage } from "#core:core/cache"; +import { versionedLocalStorage } from "#core:core/localstorage"; const foo = () => { let obj = versionedLocalStorage.getItem("", { version: 1 }); diff --git a/eboutic/static/bundled/eboutic/eboutic-index.ts b/eboutic/static/bundled/eboutic/eboutic-index.ts index 3d0f81d8..18573158 100644 --- a/eboutic/static/bundled/eboutic/eboutic-index.ts +++ b/eboutic/static/bundled/eboutic/eboutic-index.ts @@ -1,4 +1,4 @@ -import { versionedLocalStorage } from "#core:core/cache"; +import { versionedLocalStorage } from "#core:core/localstorage"; interface BasketItem { priceId: number;