@lingo.dev/compiler 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +201 -0
- package/README.md +192 -0
- package/build/_virtual/rolldown_runtime.cjs +29 -0
- package/build/_virtual/rolldown_runtime.mjs +7 -0
- package/build/index.cjs +0 -0
- package/build/index.d.cts +2 -0
- package/build/index.d.mts +2 -0
- package/build/index.mjs +1 -0
- package/build/metadata/manager.cjs +131 -0
- package/build/metadata/manager.mjs +123 -0
- package/build/metadata/manager.mjs.map +1 -0
- package/build/plugin/build-translator.cjs +198 -0
- package/build/plugin/build-translator.mjs +196 -0
- package/build/plugin/build-translator.mjs.map +1 -0
- package/build/plugin/cleanup.cjs +20 -0
- package/build/plugin/cleanup.mjs +20 -0
- package/build/plugin/cleanup.mjs.map +1 -0
- package/build/plugin/next-compiler-loader.cjs +41 -0
- package/build/plugin/next-compiler-loader.d.cts +12 -0
- package/build/plugin/next-compiler-loader.d.cts.map +1 -0
- package/build/plugin/next-compiler-loader.d.mts +13 -0
- package/build/plugin/next-compiler-loader.d.mts.map +1 -0
- package/build/plugin/next-compiler-loader.mjs +42 -0
- package/build/plugin/next-compiler-loader.mjs.map +1 -0
- package/build/plugin/next-config-loader.cjs +13 -0
- package/build/plugin/next-config-loader.d.cts +8 -0
- package/build/plugin/next-config-loader.d.cts.map +1 -0
- package/build/plugin/next-config-loader.d.mts +9 -0
- package/build/plugin/next-config-loader.d.mts.map +1 -0
- package/build/plugin/next-config-loader.mjs +14 -0
- package/build/plugin/next-config-loader.mjs.map +1 -0
- package/build/plugin/next-locale-client-loader.cjs +9 -0
- package/build/plugin/next-locale-client-loader.d.cts +8 -0
- package/build/plugin/next-locale-client-loader.d.cts.map +1 -0
- package/build/plugin/next-locale-client-loader.d.mts +9 -0
- package/build/plugin/next-locale-client-loader.d.mts.map +1 -0
- package/build/plugin/next-locale-client-loader.mjs +10 -0
- package/build/plugin/next-locale-client-loader.mjs.map +1 -0
- package/build/plugin/next-locale-server-loader.cjs +9 -0
- package/build/plugin/next-locale-server-loader.d.cts +8 -0
- package/build/plugin/next-locale-server-loader.d.cts.map +1 -0
- package/build/plugin/next-locale-server-loader.d.mts +9 -0
- package/build/plugin/next-locale-server-loader.d.mts.map +1 -0
- package/build/plugin/next-locale-server-loader.mjs +10 -0
- package/build/plugin/next-locale-server-loader.mjs.map +1 -0
- package/build/plugin/next.cjs +220 -0
- package/build/plugin/next.d.cts +9 -0
- package/build/plugin/next.d.cts.map +1 -0
- package/build/plugin/next.d.mts +9 -0
- package/build/plugin/next.d.mts.map +1 -0
- package/build/plugin/next.mjs +222 -0
- package/build/plugin/next.mjs.map +1 -0
- package/build/plugin/transform/babel-compat.cjs +13 -0
- package/build/plugin/transform/babel-compat.mjs +10 -0
- package/build/plugin/transform/babel-compat.mjs.map +1 -0
- package/build/plugin/transform/index.cjs +44 -0
- package/build/plugin/transform/index.mjs +42 -0
- package/build/plugin/transform/index.mjs.map +1 -0
- package/build/plugin/transform/metadata.cjs +142 -0
- package/build/plugin/transform/metadata.mjs +141 -0
- package/build/plugin/transform/metadata.mjs.map +1 -0
- package/build/plugin/transform/parse-override.cjs +145 -0
- package/build/plugin/transform/parse-override.mjs +144 -0
- package/build/plugin/transform/parse-override.mjs.map +1 -0
- package/build/plugin/transform/process-file.cjs +391 -0
- package/build/plugin/transform/process-file.mjs +390 -0
- package/build/plugin/transform/process-file.mjs.map +1 -0
- package/build/plugin/transform/use-i18n.cjs +8 -0
- package/build/plugin/transform/use-i18n.mjs +7 -0
- package/build/plugin/transform/use-i18n.mjs.map +1 -0
- package/build/plugin/transform/utils.cjs +205 -0
- package/build/plugin/transform/utils.mjs +192 -0
- package/build/plugin/transform/utils.mjs.map +1 -0
- package/build/plugin/unplugin.cjs +188 -0
- package/build/plugin/unplugin.d.cts +8 -0
- package/build/plugin/unplugin.d.cts.map +1 -0
- package/build/plugin/unplugin.d.mts +8 -0
- package/build/plugin/unplugin.d.mts.map +1 -0
- package/build/plugin/unplugin.mjs +186 -0
- package/build/plugin/unplugin.mjs.map +1 -0
- package/build/plugin/vite.cjs +28 -0
- package/build/plugin/vite.d.cts +9 -0
- package/build/plugin/vite.d.cts.map +1 -0
- package/build/plugin/vite.d.mts +9 -0
- package/build/plugin/vite.d.mts.map +1 -0
- package/build/plugin/vite.mjs +29 -0
- package/build/plugin/vite.mjs.map +1 -0
- package/build/plugin/webpack.cjs +27 -0
- package/build/plugin/webpack.d.cts +8 -0
- package/build/plugin/webpack.d.cts.map +1 -0
- package/build/plugin/webpack.d.mts +8 -0
- package/build/plugin/webpack.d.mts.map +1 -0
- package/build/plugin/webpack.mjs +28 -0
- package/build/plugin/webpack.mjs.map +1 -0
- package/build/react/client/index.cjs +9 -0
- package/build/react/client/index.d.cts +5 -0
- package/build/react/client/index.d.mts +5 -0
- package/build/react/client/index.mjs +6 -0
- package/build/react/client/useTranslation.cjs +71 -0
- package/build/react/client/useTranslation.d.cts +42 -0
- package/build/react/client/useTranslation.d.cts.map +1 -0
- package/build/react/client/useTranslation.d.mts +42 -0
- package/build/react/client/useTranslation.d.mts.map +1 -0
- package/build/react/client/useTranslation.mjs +71 -0
- package/build/react/client/useTranslation.mjs.map +1 -0
- package/build/react/next/client.cjs +25 -0
- package/build/react/next/client.d.cts +9 -0
- package/build/react/next/client.d.cts.map +1 -0
- package/build/react/next/client.d.mts +9 -0
- package/build/react/next/client.d.mts.map +1 -0
- package/build/react/next/client.mjs +24 -0
- package/build/react/next/client.mjs.map +1 -0
- package/build/react/next/cookie-locale-resolver.cjs +29 -0
- package/build/react/next/cookie-locale-resolver.d.cts +33 -0
- package/build/react/next/cookie-locale-resolver.d.cts.map +1 -0
- package/build/react/next/cookie-locale-resolver.d.mts +33 -0
- package/build/react/next/cookie-locale-resolver.d.mts.map +1 -0
- package/build/react/next/cookie-locale-resolver.mjs +29 -0
- package/build/react/next/cookie-locale-resolver.mjs.map +1 -0
- package/build/react/next/server.cjs +21 -0
- package/build/react/next/server.d.cts +13 -0
- package/build/react/next/server.d.cts.map +1 -0
- package/build/react/next/server.d.mts +14 -0
- package/build/react/next/server.d.mts.map +1 -0
- package/build/react/next/server.mjs +20 -0
- package/build/react/next/server.mjs.map +1 -0
- package/build/react/server/ServerLingoProvider.cjs +19 -0
- package/build/react/server/ServerLingoProvider.d.cts +12 -0
- package/build/react/server/ServerLingoProvider.d.cts.map +1 -0
- package/build/react/server/ServerLingoProvider.d.mts +12 -0
- package/build/react/server/ServerLingoProvider.d.mts.map +1 -0
- package/build/react/server/ServerLingoProvider.mjs +19 -0
- package/build/react/server/ServerLingoProvider.mjs.map +1 -0
- package/build/react/server/index.cjs +7 -0
- package/build/react/server/index.d.cts +4 -0
- package/build/react/server/index.d.mts +4 -0
- package/build/react/server/index.mjs +5 -0
- package/build/react/server/useTranslation.cjs +60 -0
- package/build/react/server/useTranslation.d.cts +36 -0
- package/build/react/server/useTranslation.d.cts.map +1 -0
- package/build/react/server/useTranslation.d.mts +36 -0
- package/build/react/server/useTranslation.d.mts.map +1 -0
- package/build/react/server/useTranslation.mjs +60 -0
- package/build/react/server/useTranslation.mjs.map +1 -0
- package/build/react/server-only/index.cjs +42 -0
- package/build/react/server-only/index.d.cts +38 -0
- package/build/react/server-only/index.d.cts.map +1 -0
- package/build/react/server-only/index.d.mts +38 -0
- package/build/react/server-only/index.d.mts.map +1 -0
- package/build/react/server-only/index.mjs +42 -0
- package/build/react/server-only/index.mjs.map +1 -0
- package/build/react/server-only/translations.cjs +85 -0
- package/build/react/server-only/translations.mjs +85 -0
- package/build/react/server-only/translations.mjs.map +1 -0
- package/build/react/shared/LingoContext.cjs +14 -0
- package/build/react/shared/LingoContext.d.cts +41 -0
- package/build/react/shared/LingoContext.d.cts.map +1 -0
- package/build/react/shared/LingoContext.d.mts +41 -0
- package/build/react/shared/LingoContext.d.mts.map +1 -0
- package/build/react/shared/LingoContext.mjs +13 -0
- package/build/react/shared/LingoContext.mjs.map +1 -0
- package/build/react/shared/LingoProvider.cjs +274 -0
- package/build/react/shared/LingoProvider.d.cts +76 -0
- package/build/react/shared/LingoProvider.d.cts.map +1 -0
- package/build/react/shared/LingoProvider.d.mts +76 -0
- package/build/react/shared/LingoProvider.d.mts.map +1 -0
- package/build/react/shared/LingoProvider.mjs +274 -0
- package/build/react/shared/LingoProvider.mjs.map +1 -0
- package/build/react/shared/LocaleSwitcher.cjs +61 -0
- package/build/react/shared/LocaleSwitcher.d.cts +71 -0
- package/build/react/shared/LocaleSwitcher.d.cts.map +1 -0
- package/build/react/shared/LocaleSwitcher.d.mts +71 -0
- package/build/react/shared/LocaleSwitcher.d.mts.map +1 -0
- package/build/react/shared/LocaleSwitcher.mjs +61 -0
- package/build/react/shared/LocaleSwitcher.mjs.map +1 -0
- package/build/react/shared/render-rich-text.cjs +55 -0
- package/build/react/shared/render-rich-text.d.cts +17 -0
- package/build/react/shared/render-rich-text.d.cts.map +1 -0
- package/build/react/shared/render-rich-text.d.mts +17 -0
- package/build/react/shared/render-rich-text.d.mts.map +1 -0
- package/build/react/shared/render-rich-text.mjs +54 -0
- package/build/react/shared/render-rich-text.mjs.map +1 -0
- package/build/react/shared/utils.cjs +34 -0
- package/build/react/shared/utils.mjs +35 -0
- package/build/react/shared/utils.mjs.map +1 -0
- package/build/react/types.d.cts +16 -0
- package/build/react/types.d.cts.map +1 -0
- package/build/react/types.d.mts +16 -0
- package/build/react/types.d.mts.map +1 -0
- package/build/translation-server/logger.cjs +37 -0
- package/build/translation-server/logger.mjs +37 -0
- package/build/translation-server/logger.mjs.map +1 -0
- package/build/translation-server/translation-server.cjs +547 -0
- package/build/translation-server/translation-server.mjs +544 -0
- package/build/translation-server/translation-server.mjs.map +1 -0
- package/build/translation-server/ws-events.cjs +15 -0
- package/build/translation-server/ws-events.mjs +15 -0
- package/build/translation-server/ws-events.mjs.map +1 -0
- package/build/translators/api.cjs +12 -0
- package/build/translators/api.mjs +12 -0
- package/build/translators/api.mjs.map +1 -0
- package/build/translators/cache-factory.cjs +26 -0
- package/build/translators/cache-factory.mjs +27 -0
- package/build/translators/cache-factory.mjs.map +1 -0
- package/build/translators/lingo/model-factory.cjs +179 -0
- package/build/translators/lingo/model-factory.mjs +174 -0
- package/build/translators/lingo/model-factory.mjs.map +1 -0
- package/build/translators/lingo/prompt.cjs +43 -0
- package/build/translators/lingo/prompt.mjs +43 -0
- package/build/translators/lingo/prompt.mjs.map +1 -0
- package/build/translators/lingo/service.cjs +152 -0
- package/build/translators/lingo/service.mjs +152 -0
- package/build/translators/lingo/service.mjs.map +1 -0
- package/build/translators/lingo/shots.cjs +28 -0
- package/build/translators/lingo/shots.mjs +28 -0
- package/build/translators/lingo/shots.mjs.map +1 -0
- package/build/translators/local-cache.cjs +115 -0
- package/build/translators/local-cache.mjs +113 -0
- package/build/translators/local-cache.mjs.map +1 -0
- package/build/translators/parse-xml.cjs +109 -0
- package/build/translators/parse-xml.mjs +108 -0
- package/build/translators/parse-xml.mjs.map +1 -0
- package/build/translators/pluralization/icu-validator.cjs +36 -0
- package/build/translators/pluralization/icu-validator.mjs +36 -0
- package/build/translators/pluralization/icu-validator.mjs.map +1 -0
- package/build/translators/pluralization/pattern-detector.cjs +25 -0
- package/build/translators/pluralization/pattern-detector.mjs +25 -0
- package/build/translators/pluralization/pattern-detector.mjs.map +1 -0
- package/build/translators/pluralization/prompt.cjs +98 -0
- package/build/translators/pluralization/prompt.mjs +98 -0
- package/build/translators/pluralization/prompt.mjs.map +1 -0
- package/build/translators/pluralization/service.cjs +247 -0
- package/build/translators/pluralization/service.mjs +247 -0
- package/build/translators/pluralization/service.mjs.map +1 -0
- package/build/translators/pluralization/shots.cjs +53 -0
- package/build/translators/pluralization/shots.mjs +53 -0
- package/build/translators/pluralization/shots.mjs.map +1 -0
- package/build/translators/pluralization/types.d.cts +17 -0
- package/build/translators/pluralization/types.d.cts.map +1 -0
- package/build/translators/pluralization/types.d.mts +17 -0
- package/build/translators/pluralization/types.d.mts.map +1 -0
- package/build/translators/pseudotranslator/index.cjs +129 -0
- package/build/translators/pseudotranslator/index.mjs +129 -0
- package/build/translators/pseudotranslator/index.mjs.map +1 -0
- package/build/translators/translation-service.cjs +182 -0
- package/build/translators/translation-service.mjs +183 -0
- package/build/translators/translation-service.mjs.map +1 -0
- package/build/translators/translator-factory.cjs +49 -0
- package/build/translators/translator-factory.mjs +50 -0
- package/build/translators/translator-factory.mjs.map +1 -0
- package/build/types.d.cts +161 -0
- package/build/types.d.cts.map +1 -0
- package/build/types.d.mts +161 -0
- package/build/types.d.mts.map +1 -0
- package/build/utils/config-factory.cjs +58 -0
- package/build/utils/config-factory.mjs +58 -0
- package/build/utils/config-factory.mjs.map +1 -0
- package/build/utils/hash.cjs +17 -0
- package/build/utils/hash.mjs +16 -0
- package/build/utils/hash.mjs.map +1 -0
- package/build/utils/is-valid-locale.cjs +14 -0
- package/build/utils/is-valid-locale.mjs +14 -0
- package/build/utils/is-valid-locale.mjs.map +1 -0
- package/build/utils/logger.cjs +51 -0
- package/build/utils/logger.mjs +50 -0
- package/build/utils/logger.mjs.map +1 -0
- package/build/utils/path-helpers.cjs +49 -0
- package/build/utils/path-helpers.mjs +47 -0
- package/build/utils/path-helpers.mjs.map +1 -0
- package/build/utils/timeout.cjs +42 -0
- package/build/utils/timeout.mjs +41 -0
- package/build/utils/timeout.mjs.map +1 -0
- package/build/virtual/code-generator.cjs +54 -0
- package/build/virtual/code-generator.mjs +53 -0
- package/build/virtual/code-generator.mjs.map +1 -0
- package/build/virtual/config.cjs +10 -0
- package/build/virtual/config.d.cts +9 -0
- package/build/virtual/config.d.cts.map +1 -0
- package/build/virtual/config.d.mts +9 -0
- package/build/virtual/config.d.mts.map +1 -0
- package/build/virtual/config.mjs +8 -0
- package/build/virtual/config.mjs.map +1 -0
- package/build/virtual/locale/client.cjs +23 -0
- package/build/virtual/locale/client.d.cts +19 -0
- package/build/virtual/locale/client.d.cts.map +1 -0
- package/build/virtual/locale/client.d.mts +19 -0
- package/build/virtual/locale/client.d.mts.map +1 -0
- package/build/virtual/locale/client.mjs +22 -0
- package/build/virtual/locale/client.mjs.map +1 -0
- package/build/virtual/locale/server.cjs +13 -0
- package/build/virtual/locale/server.d.cts +13 -0
- package/build/virtual/locale/server.d.cts.map +1 -0
- package/build/virtual/locale/server.d.mts +13 -0
- package/build/virtual/locale/server.d.mts.map +1 -0
- package/build/virtual/locale/server.mjs +13 -0
- package/build/virtual/locale/server.mjs.map +1 -0
- package/build/widget/lingo-dev-widget.cjs +228 -0
- package/build/widget/lingo-dev-widget.mjs +229 -0
- package/build/widget/lingo-dev-widget.mjs.map +1 -0
- package/package.json +189 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/virtual/locale/server.ts
|
|
2
|
+
/**
|
|
3
|
+
* Get the current locale on the server
|
|
4
|
+
* Uses cookies, headers, or other server-side mechanisms
|
|
5
|
+
* @returns Resolved locale code
|
|
6
|
+
*/
|
|
7
|
+
async function getServerLocale() {
|
|
8
|
+
return "en";
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { getServerLocale };
|
|
13
|
+
//# sourceMappingURL=server.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.mjs","names":[],"sources":["../../../src/virtual/locale/server.ts"],"sourcesContent":["import type { LocaleCode } from \"lingo.dev/spec\";\n\n/**\n * Get the current locale on the server\n * Uses cookies, headers, or other server-side mechanisms\n * @returns Resolved locale code\n */\nexport async function getServerLocale(): Promise<LocaleCode> {\n return \"en\";\n}\n"],"mappings":";;;;;;AAOA,eAAsB,kBAAuC;AAC3D,QAAO"}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
const require_logger = require('../utils/logger.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/widget/lingo-dev-widget.ts
|
|
4
|
+
/**
|
|
5
|
+
* Lingo.dev Dev Widget Custom Element
|
|
6
|
+
*
|
|
7
|
+
* This Web Component displays translation status and updates based on
|
|
8
|
+
* window.__LINGO_DEV_STATE__ changes triggered by LingoProvider.
|
|
9
|
+
*/
|
|
10
|
+
var LingoDevWidget = class extends HTMLElement {
|
|
11
|
+
shadow;
|
|
12
|
+
state = null;
|
|
13
|
+
ws = null;
|
|
14
|
+
reconnectAttempts = 0;
|
|
15
|
+
maxReconnectAttempts = 5;
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
this.shadow = this.attachShadow({ mode: "open" });
|
|
19
|
+
}
|
|
20
|
+
connectedCallback() {
|
|
21
|
+
window.__LINGO_DEV_UPDATE__ = () => {
|
|
22
|
+
this.state = window.__LINGO_DEV_STATE__ || null;
|
|
23
|
+
this.render();
|
|
24
|
+
};
|
|
25
|
+
if (window.__LINGO_DEV_STATE__) {
|
|
26
|
+
this.state = window.__LINGO_DEV_STATE__;
|
|
27
|
+
this.render();
|
|
28
|
+
}
|
|
29
|
+
this.connectWebSocket();
|
|
30
|
+
}
|
|
31
|
+
disconnectedCallback() {
|
|
32
|
+
if (window.__LINGO_DEV_UPDATE__) delete window.__LINGO_DEV_UPDATE__;
|
|
33
|
+
if (this.ws) {
|
|
34
|
+
this.ws.close();
|
|
35
|
+
this.ws = null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
connectWebSocket() {
|
|
39
|
+
const wsUrl = window.__LINGO_DEV_WS_URL__;
|
|
40
|
+
if (!wsUrl) {
|
|
41
|
+
require_logger.logger.warn("WebSocket URL not available, real-time updates disabled");
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
const url = new URL(wsUrl);
|
|
46
|
+
url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
|
|
47
|
+
this.ws = new WebSocket(url.toString());
|
|
48
|
+
this.ws.onopen = () => {
|
|
49
|
+
require_logger.logger.info("WebSocket connected");
|
|
50
|
+
this.reconnectAttempts = 0;
|
|
51
|
+
};
|
|
52
|
+
this.ws.onmessage = (event) => {
|
|
53
|
+
try {
|
|
54
|
+
const data = JSON.parse(event.data);
|
|
55
|
+
this.handleServerEvent(data);
|
|
56
|
+
} catch (error) {
|
|
57
|
+
require_logger.logger.error("Failed to parse WebSocket message:", error);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
this.ws.onerror = (error) => {
|
|
61
|
+
require_logger.logger.error("WebSocket error:", error);
|
|
62
|
+
};
|
|
63
|
+
this.ws.onclose = () => {
|
|
64
|
+
require_logger.logger.info("WebSocket disconnected");
|
|
65
|
+
this.ws = null;
|
|
66
|
+
if (this.reconnectAttempts < this.maxReconnectAttempts) {
|
|
67
|
+
const delay = Math.min(1e3 * Math.pow(2, this.reconnectAttempts), 1e4);
|
|
68
|
+
this.reconnectAttempts++;
|
|
69
|
+
require_logger.logger.info(`Reconnecting in ${delay}ms (attempt ${this.reconnectAttempts}/${this.maxReconnectAttempts})`);
|
|
70
|
+
setTimeout(() => this.connectWebSocket(), delay);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
} catch (error) {
|
|
74
|
+
require_logger.logger.error("Failed to create WebSocket connection:", error);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
handleServerEvent(event) {
|
|
78
|
+
switch (event.type) {
|
|
79
|
+
case "connected":
|
|
80
|
+
require_logger.logger.info(`Connected to translation server: ${event.serverUrl}`);
|
|
81
|
+
break;
|
|
82
|
+
case "batch:start":
|
|
83
|
+
if (this.state) {
|
|
84
|
+
this.state.serverProgress = {
|
|
85
|
+
locale: event.locale,
|
|
86
|
+
total: event.total,
|
|
87
|
+
completed: 0,
|
|
88
|
+
status: "in-progress"
|
|
89
|
+
};
|
|
90
|
+
this.render();
|
|
91
|
+
}
|
|
92
|
+
break;
|
|
93
|
+
case "batch:progress":
|
|
94
|
+
if (this.state && this.state.serverProgress) {
|
|
95
|
+
this.state.serverProgress.completed = event.completed;
|
|
96
|
+
this.render();
|
|
97
|
+
}
|
|
98
|
+
break;
|
|
99
|
+
case "batch:complete":
|
|
100
|
+
if (this.state && this.state.serverProgress) {
|
|
101
|
+
this.state.serverProgress.status = "complete";
|
|
102
|
+
this.render();
|
|
103
|
+
setTimeout(() => {
|
|
104
|
+
if (this.state) {
|
|
105
|
+
this.state.serverProgress = void 0;
|
|
106
|
+
this.render();
|
|
107
|
+
}
|
|
108
|
+
}, 2e3);
|
|
109
|
+
}
|
|
110
|
+
break;
|
|
111
|
+
case "batch:error":
|
|
112
|
+
if (this.state && this.state.serverProgress) {
|
|
113
|
+
this.state.serverProgress.status = "error";
|
|
114
|
+
this.render();
|
|
115
|
+
}
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
render() {
|
|
120
|
+
if (!this.state) {
|
|
121
|
+
this.shadow.innerHTML = "";
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const { isLoading, locale, pendingCount, position, serverProgress } = this.state;
|
|
125
|
+
const showLoader = isLoading || serverProgress?.status === "in-progress";
|
|
126
|
+
this.shadow.innerHTML = `
|
|
127
|
+
<style>
|
|
128
|
+
${this.getStyles(position)}
|
|
129
|
+
</style>
|
|
130
|
+
<div class="container">
|
|
131
|
+
${showLoader ? this.renderLoader() : this.renderLogo()}
|
|
132
|
+
<svg height="26" viewBox="0 0 650 171" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
133
|
+
<path d="M391.372 137.084H373.458V119.326H391.372V137.084Z" fill="white"/>
|
|
134
|
+
<path d="M420.766 133.46C415.204 130 410.808 125.121 407.566 118.842C404.329 112.562 402.685 105.422 402.685 97.4631C402.685 89.5033 404.306 82.4043 407.566 76.1645C410.808 69.925 415.227 65.0853 420.766 61.6257C426.327 58.1659 432.506 56.446 439.326 56.446C449.283 56.446 457.245 60.2258 463.222 67.7652H464.001V27.0283H479.56V137.08H466.204L464.624 127.02H463.845C457.764 134.78 449.583 138.66 439.326 138.66C432.506 138.66 426.327 136.94 420.766 133.48V133.46ZM452.606 120.881C456.102 118.681 458.883 115.542 460.943 111.442C462.985 107.362 464.001 102.683 464.001 97.4429C464.001 92.2033 462.985 87.5637 460.943 83.5241C458.906 79.4843 456.126 76.3645 452.606 74.1647C449.087 71.9649 445.285 70.865 441.206 70.865C437.127 70.865 433.187 71.9649 429.726 74.1647C426.264 76.3645 423.506 79.4843 421.464 83.5241C419.427 87.5637 418.406 92.2033 418.406 97.4429C418.406 102.683 419.427 107.482 421.464 111.522C423.506 115.562 426.264 118.681 429.726 120.881C433.187 123.081 437.006 124.181 441.206 124.181C445.406 124.181 449.087 123.081 452.606 120.881Z" fill="white"/>
|
|
135
|
+
<path d="M516.206 119.059C521.006 122.619 525.904 125.118 532.083 125.118C536.485 125.118 540.362 124.118 543.725 122.139C547.083 120.139 549.581 117.579 551.266 114.44H567.46C565.043 121.459 560.802 127.258 554.722 131.818C548.641 136.378 541.106 138.658 532.083 138.658C524.745 138.658 518.087 136.897 512.127 133.398C506.145 129.898 501.466 125.018 498.045 118.779C494.647 112.54 492.945 105.44 492.945 97.481C492.945 89.5212 494.647 82.5819 498.045 76.3423C501.448 70.1028 506.145 65.2432 512.127 61.7234C518.104 58.2237 524.745 56.4638 532.083 56.4638C539.422 56.4638 545.462 58.1437 551.185 61.5034C556.902 64.8632 561.402 69.4628 564.702 75.3424C568.002 81.2221 569.664 87.8216 569.664 95.141C569.664 98.8004 569.404 101.581 568.879 103.48H508.447L521.404 91.541H554.283C553.764 85.2618 551.445 80.062 547.366 75.9824C543.281 71.9026 538.181 69.8428 532.124 69.8428C526.066 69.8428 520.545 71.8826 516.247 75.9824C511.948 80.062 509.387 85.2618 508.545 91.541C508.545 91.541 505.227 110.98 516.247 119.119L516.206 119.059Z" fill="white"/>
|
|
136
|
+
<path d="M621.998 137.084H599.197L571.378 58.0104H587.74L609.115 119.486H612.259L633.634 58.0104H649.996L622.015 137.084H621.998Z" fill="white"/>
|
|
137
|
+
<path d="M96.158 43.0674H79.18V27.3486H96.158V43.0674ZM95.378 137.08H79.82V58.0063H95.378V137.08Z" fill="white"/>
|
|
138
|
+
<path d="M112.508 137.082V58.0083H125.867L127.447 66.1877H128.227C130.207 63.6678 133.247 61.428 137.346 59.4281C141.426 57.4283 146.146 56.4484 151.505 56.4484C157.585 56.4484 163.004 57.8483 167.784 60.6081C172.544 63.3879 176.284 67.2876 178.943 72.3272C181.623 77.3668 182.943 83.1266 182.943 89.6257V137.102H167.384V90.8857C167.384 85.2261 165.544 80.5066 161.885 76.7269C158.225 72.9471 153.665 71.0673 148.205 71.0673C144.546 71.0673 141.166 71.9672 138.066 73.7471C134.967 75.5269 132.546 77.9468 130.747 80.9868C128.967 84.0261 128.067 87.3261 128.067 90.8857V137.102H112.508V137.082Z" fill="white"/>
|
|
139
|
+
<path d="M214.923 165.84C209.523 163.02 205.403 159.481 202.583 155.221C199.763 150.962 198.244 146.662 198.024 142.243H213.742C214.162 145.902 216.162 149.142 219.722 151.901C223.282 154.682 228.221 156.061 234.501 156.061C240.78 156.061 246.18 154.221 250.06 150.562C253.939 146.882 255.88 142.022 255.88 135.943V123.364H255.1C252.379 126.404 248.96 128.823 244.88 130.603C240.801 132.383 236.281 133.283 231.361 133.283C224.542 133.283 218.402 131.663 212.883 128.403C207.383 125.163 203.063 120.604 199.924 114.725C196.784 108.865 195.204 102.205 195.204 94.766C195.204 87.3266 196.784 80.6873 199.924 74.8875C203.063 69.0679 207.383 64.5482 212.883 61.2885C218.382 58.0487 224.542 56.4088 231.361 56.4088C236.401 56.4088 241.02 57.4088 245.28 59.3887C249.52 61.3885 252.96 64.0483 255.58 67.4081H256.36L257.939 57.9687H271.458V136.103C271.458 142.802 269.998 148.722 267.059 153.861C264.119 159.001 259.859 162.981 254.239 165.801C248.64 168.64 242.06 170.04 234.501 170.04C226.942 170.04 220.322 168.62 214.923 165.801V165.84ZM244.78 116.084C248.18 114.044 250.88 111.165 252.88 107.445C254.879 103.726 255.859 99.5054 255.859 94.7862C255.859 90.0664 254.86 85.8866 252.88 82.2069C250.88 78.5472 248.18 75.6874 244.78 73.6476C241.38 71.6077 237.581 70.5878 233.381 70.5878C226.882 70.5878 221.522 72.8476 217.262 77.3473C213.023 81.8469 210.903 87.6664 210.903 94.8058C210.903 101.945 213.023 107.905 217.262 112.405C221.502 116.904 226.882 119.164 233.381 119.164C237.581 119.164 241.38 118.144 244.78 116.105V116.084Z" fill="white"/>
|
|
140
|
+
<path d="M303.031 133.382C297.051 129.883 292.372 125.003 288.952 118.764C285.552 112.524 283.852 105.425 283.852 97.4655C283.852 89.5057 285.552 82.5664 288.952 76.3269C292.351 70.0874 297.051 65.2277 303.031 61.708C309.011 58.2082 315.65 56.4484 322.989 56.4484C330.329 56.4484 336.948 58.2082 342.868 61.708C348.787 65.2277 353.447 70.0874 356.867 76.3269C360.267 82.5664 361.966 89.6061 361.966 97.4655C361.966 105.325 360.267 112.524 356.867 118.764C353.467 125.003 348.787 129.883 342.868 133.382C336.948 136.902 330.309 138.642 322.989 138.642C315.67 138.642 308.99 136.882 303.031 133.382ZM334.848 120.883C338.468 118.684 341.328 115.544 343.408 111.444C345.507 107.364 346.548 102.685 346.548 97.4453C346.548 92.2057 345.507 87.5661 343.408 83.5264C341.308 79.4867 338.448 76.3669 334.848 74.1671C331.228 71.9672 327.269 70.8673 322.989 70.8673C318.71 70.8673 314.73 71.9672 311.13 74.1671C307.511 76.3669 304.651 79.4867 302.571 83.5264C300.471 87.5661 299.431 92.2057 299.431 97.4453C299.431 102.685 300.471 107.345 302.571 111.444C304.67 115.524 307.53 118.684 311.13 120.883C314.75 123.083 318.71 124.183 322.989 124.183C327.269 124.183 331.249 123.083 334.848 120.883Z" fill="white"/>
|
|
141
|
+
<path d="M69.795 135.861H0V25.81H16.498V120.143L16.798 135.861L34.097 120.143H69.795V135.861Z" fill="white"/>
|
|
142
|
+
</svg>
|
|
143
|
+
</div>
|
|
144
|
+
`;
|
|
145
|
+
}
|
|
146
|
+
getStyles(position) {
|
|
147
|
+
return `
|
|
148
|
+
:host {
|
|
149
|
+
position: fixed;
|
|
150
|
+
z-index: 99999;
|
|
151
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", sans-serif;
|
|
152
|
+
font-size: 12px;
|
|
153
|
+
pointer-events: auto;
|
|
154
|
+
${{
|
|
155
|
+
"bottom-left": "bottom: 60px; left: 16px;",
|
|
156
|
+
"bottom-right": "bottom: 60px; right: 16px;",
|
|
157
|
+
"top-left": "top: 16px; left: 16px;",
|
|
158
|
+
"top-right": "top: 16px; right: 16px;"
|
|
159
|
+
}[position]}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.container {
|
|
163
|
+
display: flex;
|
|
164
|
+
align-items: center;
|
|
165
|
+
gap: 8px;
|
|
166
|
+
transition: all 0.2s ease-in-out;
|
|
167
|
+
border-radius: 8px;
|
|
168
|
+
padding: 8px 12px;
|
|
169
|
+
background: rgba(0, 0, 0, 0.8);
|
|
170
|
+
box-shadow: 0 0 0 1px #373737, inset 0 0 0 1px rgba(0, 0, 0, 0.24), 0px 16px 32px -8px rgba(0, 0, 0, 0.24);
|
|
171
|
+
backdrop-filter: blur(48px);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.logo {
|
|
175
|
+
width: 26px;
|
|
176
|
+
height: 26px;
|
|
177
|
+
flex-shrink: 0;
|
|
178
|
+
}
|
|
179
|
+
`;
|
|
180
|
+
}
|
|
181
|
+
renderLogo() {
|
|
182
|
+
return `
|
|
183
|
+
<svg height="26" viewBox="0 0 147 171" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
184
|
+
<path d="M0.304987 76.63L54.9149 136.206C55.1326 136.441 55.4362 136.579 55.757 136.579H145.288C146.308 136.579 146.817 135.347 146.096 134.625L106.804 95.3334H75.87V110.801L39.7802 74.711H1.14708C0.150317 74.711 -0.370977 75.8968 0.304987 76.63Z" fill="#69E300"/>
|
|
185
|
+
<path d="M146.304 93.4186L91.6883 33.8424C91.4702 33.6075 91.1668 33.47 90.846 33.47H1.31509C0.289683 33.47 -0.220155 34.7017 0.501637 35.4235L39.7935 74.7153H70.7275V59.2483L106.817 95.3381H145.456C146.453 95.3381 146.974 94.1519 146.298 93.4186H146.304Z" fill="#69E300"/>
|
|
186
|
+
</g>
|
|
187
|
+
</svg>
|
|
188
|
+
`;
|
|
189
|
+
}
|
|
190
|
+
renderLoader() {
|
|
191
|
+
return `
|
|
192
|
+
<svg height="26" viewBox="0 0 147 171" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
193
|
+
<style>
|
|
194
|
+
@keyframes moveDown {
|
|
195
|
+
0%, 100% { transform: translateY(0); }
|
|
196
|
+
50% { transform: translateY(12px); }
|
|
197
|
+
}
|
|
198
|
+
@keyframes moveUp {
|
|
199
|
+
0%, 100% { transform: translateY(0); }
|
|
200
|
+
50% { transform: translateY(-12px); }
|
|
201
|
+
}
|
|
202
|
+
.bottom-part { animation: moveDown 1.5s ease-in-out infinite; transform-origin: center; }
|
|
203
|
+
.top-part { animation: moveUp 1.5s ease-in-out infinite; transform-origin: center; }
|
|
204
|
+
</style>
|
|
205
|
+
<path class="bottom-part" d="M0.304987 76.63L54.9149 136.206C55.1326 136.441 55.4362 136.579 55.757 136.579H145.288C146.308 136.579 146.817 135.347 146.096 134.625L106.804 95.3334H75.87V110.801L39.7802 74.711H1.14708C0.150317 74.711 -0.370977 75.8968 0.304987 76.63Z" fill="grey"/>
|
|
206
|
+
<path class="top-part" d="M146.304 93.4186L91.6883 33.8424C91.4702 33.6075 91.1668 33.47 90.846 33.47H1.31509C0.289683 33.47 -0.220155 34.7017 0.501637 35.4235L39.7935 74.7153H70.7275V59.2483L106.817 95.3381H145.456C146.453 95.3381 146.974 94.1519 146.298 93.4186H146.304Z" fill="grey"/>
|
|
207
|
+
</g>
|
|
208
|
+
</svg>
|
|
209
|
+
`;
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
require_logger.logger.debug("Loading Lingo Dev Widget...");
|
|
213
|
+
if (typeof window !== "undefined") {
|
|
214
|
+
customElements.define("lingo-dev-widget", LingoDevWidget);
|
|
215
|
+
const widget = document.createElement("lingo-dev-widget");
|
|
216
|
+
document.body.appendChild(widget);
|
|
217
|
+
if (!window.__LINGO_DEV_STATE__) window.__LINGO_DEV_STATE__ = {
|
|
218
|
+
isLoading: false,
|
|
219
|
+
locale: "en",
|
|
220
|
+
sourceLocale: "en",
|
|
221
|
+
pendingCount: 0,
|
|
222
|
+
position: "bottom-left"
|
|
223
|
+
};
|
|
224
|
+
if (window.__LINGO_DEV_UPDATE__) window.__LINGO_DEV_UPDATE__();
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
//#endregion
|
|
228
|
+
exports.LingoDevWidget = LingoDevWidget;
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { logger } from "../utils/logger.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/widget/lingo-dev-widget.ts
|
|
4
|
+
/**
|
|
5
|
+
* Lingo.dev Dev Widget Custom Element
|
|
6
|
+
*
|
|
7
|
+
* This Web Component displays translation status and updates based on
|
|
8
|
+
* window.__LINGO_DEV_STATE__ changes triggered by LingoProvider.
|
|
9
|
+
*/
|
|
10
|
+
var LingoDevWidget = class extends HTMLElement {
|
|
11
|
+
shadow;
|
|
12
|
+
state = null;
|
|
13
|
+
ws = null;
|
|
14
|
+
reconnectAttempts = 0;
|
|
15
|
+
maxReconnectAttempts = 5;
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
this.shadow = this.attachShadow({ mode: "open" });
|
|
19
|
+
}
|
|
20
|
+
connectedCallback() {
|
|
21
|
+
window.__LINGO_DEV_UPDATE__ = () => {
|
|
22
|
+
this.state = window.__LINGO_DEV_STATE__ || null;
|
|
23
|
+
this.render();
|
|
24
|
+
};
|
|
25
|
+
if (window.__LINGO_DEV_STATE__) {
|
|
26
|
+
this.state = window.__LINGO_DEV_STATE__;
|
|
27
|
+
this.render();
|
|
28
|
+
}
|
|
29
|
+
this.connectWebSocket();
|
|
30
|
+
}
|
|
31
|
+
disconnectedCallback() {
|
|
32
|
+
if (window.__LINGO_DEV_UPDATE__) delete window.__LINGO_DEV_UPDATE__;
|
|
33
|
+
if (this.ws) {
|
|
34
|
+
this.ws.close();
|
|
35
|
+
this.ws = null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
connectWebSocket() {
|
|
39
|
+
const wsUrl = window.__LINGO_DEV_WS_URL__;
|
|
40
|
+
if (!wsUrl) {
|
|
41
|
+
logger.warn("WebSocket URL not available, real-time updates disabled");
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
const url = new URL(wsUrl);
|
|
46
|
+
url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
|
|
47
|
+
this.ws = new WebSocket(url.toString());
|
|
48
|
+
this.ws.onopen = () => {
|
|
49
|
+
logger.info("WebSocket connected");
|
|
50
|
+
this.reconnectAttempts = 0;
|
|
51
|
+
};
|
|
52
|
+
this.ws.onmessage = (event) => {
|
|
53
|
+
try {
|
|
54
|
+
const data = JSON.parse(event.data);
|
|
55
|
+
this.handleServerEvent(data);
|
|
56
|
+
} catch (error) {
|
|
57
|
+
logger.error("Failed to parse WebSocket message:", error);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
this.ws.onerror = (error) => {
|
|
61
|
+
logger.error("WebSocket error:", error);
|
|
62
|
+
};
|
|
63
|
+
this.ws.onclose = () => {
|
|
64
|
+
logger.info("WebSocket disconnected");
|
|
65
|
+
this.ws = null;
|
|
66
|
+
if (this.reconnectAttempts < this.maxReconnectAttempts) {
|
|
67
|
+
const delay = Math.min(1e3 * Math.pow(2, this.reconnectAttempts), 1e4);
|
|
68
|
+
this.reconnectAttempts++;
|
|
69
|
+
logger.info(`Reconnecting in ${delay}ms (attempt ${this.reconnectAttempts}/${this.maxReconnectAttempts})`);
|
|
70
|
+
setTimeout(() => this.connectWebSocket(), delay);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
} catch (error) {
|
|
74
|
+
logger.error("Failed to create WebSocket connection:", error);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
handleServerEvent(event) {
|
|
78
|
+
switch (event.type) {
|
|
79
|
+
case "connected":
|
|
80
|
+
logger.info(`Connected to translation server: ${event.serverUrl}`);
|
|
81
|
+
break;
|
|
82
|
+
case "batch:start":
|
|
83
|
+
if (this.state) {
|
|
84
|
+
this.state.serverProgress = {
|
|
85
|
+
locale: event.locale,
|
|
86
|
+
total: event.total,
|
|
87
|
+
completed: 0,
|
|
88
|
+
status: "in-progress"
|
|
89
|
+
};
|
|
90
|
+
this.render();
|
|
91
|
+
}
|
|
92
|
+
break;
|
|
93
|
+
case "batch:progress":
|
|
94
|
+
if (this.state && this.state.serverProgress) {
|
|
95
|
+
this.state.serverProgress.completed = event.completed;
|
|
96
|
+
this.render();
|
|
97
|
+
}
|
|
98
|
+
break;
|
|
99
|
+
case "batch:complete":
|
|
100
|
+
if (this.state && this.state.serverProgress) {
|
|
101
|
+
this.state.serverProgress.status = "complete";
|
|
102
|
+
this.render();
|
|
103
|
+
setTimeout(() => {
|
|
104
|
+
if (this.state) {
|
|
105
|
+
this.state.serverProgress = void 0;
|
|
106
|
+
this.render();
|
|
107
|
+
}
|
|
108
|
+
}, 2e3);
|
|
109
|
+
}
|
|
110
|
+
break;
|
|
111
|
+
case "batch:error":
|
|
112
|
+
if (this.state && this.state.serverProgress) {
|
|
113
|
+
this.state.serverProgress.status = "error";
|
|
114
|
+
this.render();
|
|
115
|
+
}
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
render() {
|
|
120
|
+
if (!this.state) {
|
|
121
|
+
this.shadow.innerHTML = "";
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const { isLoading, locale, pendingCount, position, serverProgress } = this.state;
|
|
125
|
+
const showLoader = isLoading || serverProgress?.status === "in-progress";
|
|
126
|
+
this.shadow.innerHTML = `
|
|
127
|
+
<style>
|
|
128
|
+
${this.getStyles(position)}
|
|
129
|
+
</style>
|
|
130
|
+
<div class="container">
|
|
131
|
+
${showLoader ? this.renderLoader() : this.renderLogo()}
|
|
132
|
+
<svg height="26" viewBox="0 0 650 171" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
133
|
+
<path d="M391.372 137.084H373.458V119.326H391.372V137.084Z" fill="white"/>
|
|
134
|
+
<path d="M420.766 133.46C415.204 130 410.808 125.121 407.566 118.842C404.329 112.562 402.685 105.422 402.685 97.4631C402.685 89.5033 404.306 82.4043 407.566 76.1645C410.808 69.925 415.227 65.0853 420.766 61.6257C426.327 58.1659 432.506 56.446 439.326 56.446C449.283 56.446 457.245 60.2258 463.222 67.7652H464.001V27.0283H479.56V137.08H466.204L464.624 127.02H463.845C457.764 134.78 449.583 138.66 439.326 138.66C432.506 138.66 426.327 136.94 420.766 133.48V133.46ZM452.606 120.881C456.102 118.681 458.883 115.542 460.943 111.442C462.985 107.362 464.001 102.683 464.001 97.4429C464.001 92.2033 462.985 87.5637 460.943 83.5241C458.906 79.4843 456.126 76.3645 452.606 74.1647C449.087 71.9649 445.285 70.865 441.206 70.865C437.127 70.865 433.187 71.9649 429.726 74.1647C426.264 76.3645 423.506 79.4843 421.464 83.5241C419.427 87.5637 418.406 92.2033 418.406 97.4429C418.406 102.683 419.427 107.482 421.464 111.522C423.506 115.562 426.264 118.681 429.726 120.881C433.187 123.081 437.006 124.181 441.206 124.181C445.406 124.181 449.087 123.081 452.606 120.881Z" fill="white"/>
|
|
135
|
+
<path d="M516.206 119.059C521.006 122.619 525.904 125.118 532.083 125.118C536.485 125.118 540.362 124.118 543.725 122.139C547.083 120.139 549.581 117.579 551.266 114.44H567.46C565.043 121.459 560.802 127.258 554.722 131.818C548.641 136.378 541.106 138.658 532.083 138.658C524.745 138.658 518.087 136.897 512.127 133.398C506.145 129.898 501.466 125.018 498.045 118.779C494.647 112.54 492.945 105.44 492.945 97.481C492.945 89.5212 494.647 82.5819 498.045 76.3423C501.448 70.1028 506.145 65.2432 512.127 61.7234C518.104 58.2237 524.745 56.4638 532.083 56.4638C539.422 56.4638 545.462 58.1437 551.185 61.5034C556.902 64.8632 561.402 69.4628 564.702 75.3424C568.002 81.2221 569.664 87.8216 569.664 95.141C569.664 98.8004 569.404 101.581 568.879 103.48H508.447L521.404 91.541H554.283C553.764 85.2618 551.445 80.062 547.366 75.9824C543.281 71.9026 538.181 69.8428 532.124 69.8428C526.066 69.8428 520.545 71.8826 516.247 75.9824C511.948 80.062 509.387 85.2618 508.545 91.541C508.545 91.541 505.227 110.98 516.247 119.119L516.206 119.059Z" fill="white"/>
|
|
136
|
+
<path d="M621.998 137.084H599.197L571.378 58.0104H587.74L609.115 119.486H612.259L633.634 58.0104H649.996L622.015 137.084H621.998Z" fill="white"/>
|
|
137
|
+
<path d="M96.158 43.0674H79.18V27.3486H96.158V43.0674ZM95.378 137.08H79.82V58.0063H95.378V137.08Z" fill="white"/>
|
|
138
|
+
<path d="M112.508 137.082V58.0083H125.867L127.447 66.1877H128.227C130.207 63.6678 133.247 61.428 137.346 59.4281C141.426 57.4283 146.146 56.4484 151.505 56.4484C157.585 56.4484 163.004 57.8483 167.784 60.6081C172.544 63.3879 176.284 67.2876 178.943 72.3272C181.623 77.3668 182.943 83.1266 182.943 89.6257V137.102H167.384V90.8857C167.384 85.2261 165.544 80.5066 161.885 76.7269C158.225 72.9471 153.665 71.0673 148.205 71.0673C144.546 71.0673 141.166 71.9672 138.066 73.7471C134.967 75.5269 132.546 77.9468 130.747 80.9868C128.967 84.0261 128.067 87.3261 128.067 90.8857V137.102H112.508V137.082Z" fill="white"/>
|
|
139
|
+
<path d="M214.923 165.84C209.523 163.02 205.403 159.481 202.583 155.221C199.763 150.962 198.244 146.662 198.024 142.243H213.742C214.162 145.902 216.162 149.142 219.722 151.901C223.282 154.682 228.221 156.061 234.501 156.061C240.78 156.061 246.18 154.221 250.06 150.562C253.939 146.882 255.88 142.022 255.88 135.943V123.364H255.1C252.379 126.404 248.96 128.823 244.88 130.603C240.801 132.383 236.281 133.283 231.361 133.283C224.542 133.283 218.402 131.663 212.883 128.403C207.383 125.163 203.063 120.604 199.924 114.725C196.784 108.865 195.204 102.205 195.204 94.766C195.204 87.3266 196.784 80.6873 199.924 74.8875C203.063 69.0679 207.383 64.5482 212.883 61.2885C218.382 58.0487 224.542 56.4088 231.361 56.4088C236.401 56.4088 241.02 57.4088 245.28 59.3887C249.52 61.3885 252.96 64.0483 255.58 67.4081H256.36L257.939 57.9687H271.458V136.103C271.458 142.802 269.998 148.722 267.059 153.861C264.119 159.001 259.859 162.981 254.239 165.801C248.64 168.64 242.06 170.04 234.501 170.04C226.942 170.04 220.322 168.62 214.923 165.801V165.84ZM244.78 116.084C248.18 114.044 250.88 111.165 252.88 107.445C254.879 103.726 255.859 99.5054 255.859 94.7862C255.859 90.0664 254.86 85.8866 252.88 82.2069C250.88 78.5472 248.18 75.6874 244.78 73.6476C241.38 71.6077 237.581 70.5878 233.381 70.5878C226.882 70.5878 221.522 72.8476 217.262 77.3473C213.023 81.8469 210.903 87.6664 210.903 94.8058C210.903 101.945 213.023 107.905 217.262 112.405C221.502 116.904 226.882 119.164 233.381 119.164C237.581 119.164 241.38 118.144 244.78 116.105V116.084Z" fill="white"/>
|
|
140
|
+
<path d="M303.031 133.382C297.051 129.883 292.372 125.003 288.952 118.764C285.552 112.524 283.852 105.425 283.852 97.4655C283.852 89.5057 285.552 82.5664 288.952 76.3269C292.351 70.0874 297.051 65.2277 303.031 61.708C309.011 58.2082 315.65 56.4484 322.989 56.4484C330.329 56.4484 336.948 58.2082 342.868 61.708C348.787 65.2277 353.447 70.0874 356.867 76.3269C360.267 82.5664 361.966 89.6061 361.966 97.4655C361.966 105.325 360.267 112.524 356.867 118.764C353.467 125.003 348.787 129.883 342.868 133.382C336.948 136.902 330.309 138.642 322.989 138.642C315.67 138.642 308.99 136.882 303.031 133.382ZM334.848 120.883C338.468 118.684 341.328 115.544 343.408 111.444C345.507 107.364 346.548 102.685 346.548 97.4453C346.548 92.2057 345.507 87.5661 343.408 83.5264C341.308 79.4867 338.448 76.3669 334.848 74.1671C331.228 71.9672 327.269 70.8673 322.989 70.8673C318.71 70.8673 314.73 71.9672 311.13 74.1671C307.511 76.3669 304.651 79.4867 302.571 83.5264C300.471 87.5661 299.431 92.2057 299.431 97.4453C299.431 102.685 300.471 107.345 302.571 111.444C304.67 115.524 307.53 118.684 311.13 120.883C314.75 123.083 318.71 124.183 322.989 124.183C327.269 124.183 331.249 123.083 334.848 120.883Z" fill="white"/>
|
|
141
|
+
<path d="M69.795 135.861H0V25.81H16.498V120.143L16.798 135.861L34.097 120.143H69.795V135.861Z" fill="white"/>
|
|
142
|
+
</svg>
|
|
143
|
+
</div>
|
|
144
|
+
`;
|
|
145
|
+
}
|
|
146
|
+
getStyles(position) {
|
|
147
|
+
return `
|
|
148
|
+
:host {
|
|
149
|
+
position: fixed;
|
|
150
|
+
z-index: 99999;
|
|
151
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", sans-serif;
|
|
152
|
+
font-size: 12px;
|
|
153
|
+
pointer-events: auto;
|
|
154
|
+
${{
|
|
155
|
+
"bottom-left": "bottom: 60px; left: 16px;",
|
|
156
|
+
"bottom-right": "bottom: 60px; right: 16px;",
|
|
157
|
+
"top-left": "top: 16px; left: 16px;",
|
|
158
|
+
"top-right": "top: 16px; right: 16px;"
|
|
159
|
+
}[position]}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.container {
|
|
163
|
+
display: flex;
|
|
164
|
+
align-items: center;
|
|
165
|
+
gap: 8px;
|
|
166
|
+
transition: all 0.2s ease-in-out;
|
|
167
|
+
border-radius: 8px;
|
|
168
|
+
padding: 8px 12px;
|
|
169
|
+
background: rgba(0, 0, 0, 0.8);
|
|
170
|
+
box-shadow: 0 0 0 1px #373737, inset 0 0 0 1px rgba(0, 0, 0, 0.24), 0px 16px 32px -8px rgba(0, 0, 0, 0.24);
|
|
171
|
+
backdrop-filter: blur(48px);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.logo {
|
|
175
|
+
width: 26px;
|
|
176
|
+
height: 26px;
|
|
177
|
+
flex-shrink: 0;
|
|
178
|
+
}
|
|
179
|
+
`;
|
|
180
|
+
}
|
|
181
|
+
renderLogo() {
|
|
182
|
+
return `
|
|
183
|
+
<svg height="26" viewBox="0 0 147 171" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
184
|
+
<path d="M0.304987 76.63L54.9149 136.206C55.1326 136.441 55.4362 136.579 55.757 136.579H145.288C146.308 136.579 146.817 135.347 146.096 134.625L106.804 95.3334H75.87V110.801L39.7802 74.711H1.14708C0.150317 74.711 -0.370977 75.8968 0.304987 76.63Z" fill="#69E300"/>
|
|
185
|
+
<path d="M146.304 93.4186L91.6883 33.8424C91.4702 33.6075 91.1668 33.47 90.846 33.47H1.31509C0.289683 33.47 -0.220155 34.7017 0.501637 35.4235L39.7935 74.7153H70.7275V59.2483L106.817 95.3381H145.456C146.453 95.3381 146.974 94.1519 146.298 93.4186H146.304Z" fill="#69E300"/>
|
|
186
|
+
</g>
|
|
187
|
+
</svg>
|
|
188
|
+
`;
|
|
189
|
+
}
|
|
190
|
+
renderLoader() {
|
|
191
|
+
return `
|
|
192
|
+
<svg height="26" viewBox="0 0 147 171" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
193
|
+
<style>
|
|
194
|
+
@keyframes moveDown {
|
|
195
|
+
0%, 100% { transform: translateY(0); }
|
|
196
|
+
50% { transform: translateY(12px); }
|
|
197
|
+
}
|
|
198
|
+
@keyframes moveUp {
|
|
199
|
+
0%, 100% { transform: translateY(0); }
|
|
200
|
+
50% { transform: translateY(-12px); }
|
|
201
|
+
}
|
|
202
|
+
.bottom-part { animation: moveDown 1.5s ease-in-out infinite; transform-origin: center; }
|
|
203
|
+
.top-part { animation: moveUp 1.5s ease-in-out infinite; transform-origin: center; }
|
|
204
|
+
</style>
|
|
205
|
+
<path class="bottom-part" d="M0.304987 76.63L54.9149 136.206C55.1326 136.441 55.4362 136.579 55.757 136.579H145.288C146.308 136.579 146.817 135.347 146.096 134.625L106.804 95.3334H75.87V110.801L39.7802 74.711H1.14708C0.150317 74.711 -0.370977 75.8968 0.304987 76.63Z" fill="grey"/>
|
|
206
|
+
<path class="top-part" d="M146.304 93.4186L91.6883 33.8424C91.4702 33.6075 91.1668 33.47 90.846 33.47H1.31509C0.289683 33.47 -0.220155 34.7017 0.501637 35.4235L39.7935 74.7153H70.7275V59.2483L106.817 95.3381H145.456C146.453 95.3381 146.974 94.1519 146.298 93.4186H146.304Z" fill="grey"/>
|
|
207
|
+
</g>
|
|
208
|
+
</svg>
|
|
209
|
+
`;
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
logger.debug("Loading Lingo Dev Widget...");
|
|
213
|
+
if (typeof window !== "undefined") {
|
|
214
|
+
customElements.define("lingo-dev-widget", LingoDevWidget);
|
|
215
|
+
const widget = document.createElement("lingo-dev-widget");
|
|
216
|
+
document.body.appendChild(widget);
|
|
217
|
+
if (!window.__LINGO_DEV_STATE__) window.__LINGO_DEV_STATE__ = {
|
|
218
|
+
isLoading: false,
|
|
219
|
+
locale: "en",
|
|
220
|
+
sourceLocale: "en",
|
|
221
|
+
pendingCount: 0,
|
|
222
|
+
position: "bottom-left"
|
|
223
|
+
};
|
|
224
|
+
if (window.__LINGO_DEV_UPDATE__) window.__LINGO_DEV_UPDATE__();
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
//#endregion
|
|
228
|
+
export { LingoDevWidget };
|
|
229
|
+
//# sourceMappingURL=lingo-dev-widget.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lingo-dev-widget.mjs","names":[],"sources":["../../src/widget/lingo-dev-widget.ts"],"sourcesContent":["/**\n * Framework-agnostic dev widget using Web Components\n * Displays translation status in development mode\n *\n * IMPORTANT: This module must be dynamically imported client-side only!\n * It extends HTMLElement which doesn't exist in Node.js (SSR).\n * See TranslationContext.tsx for proper usage with useEffect + dynamic import.\n */\n\nimport type { LingoDevState, WidgetPosition } from \"./types\";\nimport { logger } from \"../utils/logger\";\n\n/**\n * Lingo.dev Dev Widget Custom Element\n *\n * This Web Component displays translation status and updates based on\n * window.__LINGO_DEV_STATE__ changes triggered by LingoProvider.\n */\nclass LingoDevWidget extends HTMLElement {\n private shadow: ShadowRoot;\n private state: LingoDevState | null = null;\n private ws: WebSocket | null = null;\n private reconnectAttempts = 0;\n private maxReconnectAttempts = 5;\n\n constructor() {\n super();\n this.shadow = this.attachShadow({ mode: \"open\" });\n }\n\n connectedCallback() {\n // Subscribe to state updates\n window.__LINGO_DEV_UPDATE__ = () => {\n this.state = window.__LINGO_DEV_STATE__ || null;\n this.render();\n };\n\n // Initial render with existing state\n if (window.__LINGO_DEV_STATE__) {\n this.state = window.__LINGO_DEV_STATE__;\n this.render();\n }\n\n this.connectWebSocket();\n }\n\n disconnectedCallback() {\n if (window.__LINGO_DEV_UPDATE__) {\n delete window.__LINGO_DEV_UPDATE__;\n }\n\n if (this.ws) {\n this.ws.close();\n this.ws = null;\n }\n }\n\n private connectWebSocket() {\n const wsUrl = window.__LINGO_DEV_WS_URL__;\n if (!wsUrl) {\n logger.warn(\"WebSocket URL not available, real-time updates disabled\");\n return;\n }\n\n try {\n const url = new URL(wsUrl);\n url.protocol = url.protocol === \"https:\" ? \"wss:\" : \"ws:\";\n\n this.ws = new WebSocket(url.toString());\n\n this.ws.onopen = () => {\n logger.info(\"WebSocket connected\");\n this.reconnectAttempts = 0;\n };\n\n this.ws.onmessage = (event) => {\n try {\n const data = JSON.parse(event.data);\n this.handleServerEvent(data);\n } catch (error) {\n logger.error(\"Failed to parse WebSocket message:\", error);\n }\n };\n\n this.ws.onerror = (error) => {\n logger.error(\"WebSocket error:\", error);\n };\n\n this.ws.onclose = () => {\n logger.info(\"WebSocket disconnected\");\n this.ws = null;\n\n // Attempt to reconnect with exponential backoff\n if (this.reconnectAttempts < this.maxReconnectAttempts) {\n const delay = Math.min(\n 1000 * Math.pow(2, this.reconnectAttempts),\n 10000,\n );\n this.reconnectAttempts++;\n logger.info(\n `Reconnecting in ${delay}ms (attempt ${this.reconnectAttempts}/${this.maxReconnectAttempts})`,\n );\n setTimeout(() => this.connectWebSocket(), delay);\n }\n };\n } catch (error) {\n logger.error(\"Failed to create WebSocket connection:\", error);\n }\n }\n\n private handleServerEvent(event: any) {\n switch (event.type) {\n case \"connected\":\n logger.info(`Connected to translation server: ${event.serverUrl}`);\n break;\n\n case \"batch:start\":\n // Update state to show server translation is in progress\n if (this.state) {\n this.state.serverProgress = {\n locale: event.locale,\n total: event.total,\n completed: 0,\n status: \"in-progress\",\n };\n this.render();\n }\n break;\n\n case \"batch:progress\":\n // Update progress\n if (this.state && this.state.serverProgress) {\n this.state.serverProgress.completed = event.completed;\n this.render();\n }\n break;\n\n case \"batch:complete\":\n // Clear server progress after a delay\n if (this.state && this.state.serverProgress) {\n this.state.serverProgress.status = \"complete\";\n this.render();\n\n setTimeout(() => {\n if (this.state) {\n this.state.serverProgress = undefined;\n this.render();\n }\n }, 2000);\n }\n break;\n\n case \"batch:error\":\n if (this.state && this.state.serverProgress) {\n this.state.serverProgress.status = \"error\";\n this.render();\n }\n break;\n }\n }\n\n private render() {\n // Hide widget when on source locale\n if (!this.state) {\n this.shadow.innerHTML = \"\";\n return;\n }\n\n const { isLoading, locale, pendingCount, position, serverProgress } =\n this.state;\n\n // Show loader if either client or server translations are in progress\n const showLoader = isLoading || serverProgress?.status === \"in-progress\";\n\n this.shadow.innerHTML = `\n <style>\n ${this.getStyles(position)}\n </style>\n <div class=\"container\">\n ${showLoader ? this.renderLoader() : this.renderLogo()}\n <svg height=\"26\" viewBox=\"0 0 650 171\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M391.372 137.084H373.458V119.326H391.372V137.084Z\" fill=\"white\"/>\n<path d=\"M420.766 133.46C415.204 130 410.808 125.121 407.566 118.842C404.329 112.562 402.685 105.422 402.685 97.4631C402.685 89.5033 404.306 82.4043 407.566 76.1645C410.808 69.925 415.227 65.0853 420.766 61.6257C426.327 58.1659 432.506 56.446 439.326 56.446C449.283 56.446 457.245 60.2258 463.222 67.7652H464.001V27.0283H479.56V137.08H466.204L464.624 127.02H463.845C457.764 134.78 449.583 138.66 439.326 138.66C432.506 138.66 426.327 136.94 420.766 133.48V133.46ZM452.606 120.881C456.102 118.681 458.883 115.542 460.943 111.442C462.985 107.362 464.001 102.683 464.001 97.4429C464.001 92.2033 462.985 87.5637 460.943 83.5241C458.906 79.4843 456.126 76.3645 452.606 74.1647C449.087 71.9649 445.285 70.865 441.206 70.865C437.127 70.865 433.187 71.9649 429.726 74.1647C426.264 76.3645 423.506 79.4843 421.464 83.5241C419.427 87.5637 418.406 92.2033 418.406 97.4429C418.406 102.683 419.427 107.482 421.464 111.522C423.506 115.562 426.264 118.681 429.726 120.881C433.187 123.081 437.006 124.181 441.206 124.181C445.406 124.181 449.087 123.081 452.606 120.881Z\" fill=\"white\"/>\n<path d=\"M516.206 119.059C521.006 122.619 525.904 125.118 532.083 125.118C536.485 125.118 540.362 124.118 543.725 122.139C547.083 120.139 549.581 117.579 551.266 114.44H567.46C565.043 121.459 560.802 127.258 554.722 131.818C548.641 136.378 541.106 138.658 532.083 138.658C524.745 138.658 518.087 136.897 512.127 133.398C506.145 129.898 501.466 125.018 498.045 118.779C494.647 112.54 492.945 105.44 492.945 97.481C492.945 89.5212 494.647 82.5819 498.045 76.3423C501.448 70.1028 506.145 65.2432 512.127 61.7234C518.104 58.2237 524.745 56.4638 532.083 56.4638C539.422 56.4638 545.462 58.1437 551.185 61.5034C556.902 64.8632 561.402 69.4628 564.702 75.3424C568.002 81.2221 569.664 87.8216 569.664 95.141C569.664 98.8004 569.404 101.581 568.879 103.48H508.447L521.404 91.541H554.283C553.764 85.2618 551.445 80.062 547.366 75.9824C543.281 71.9026 538.181 69.8428 532.124 69.8428C526.066 69.8428 520.545 71.8826 516.247 75.9824C511.948 80.062 509.387 85.2618 508.545 91.541C508.545 91.541 505.227 110.98 516.247 119.119L516.206 119.059Z\" fill=\"white\"/>\n<path d=\"M621.998 137.084H599.197L571.378 58.0104H587.74L609.115 119.486H612.259L633.634 58.0104H649.996L622.015 137.084H621.998Z\" fill=\"white\"/>\n<path d=\"M96.158 43.0674H79.18V27.3486H96.158V43.0674ZM95.378 137.08H79.82V58.0063H95.378V137.08Z\" fill=\"white\"/>\n<path d=\"M112.508 137.082V58.0083H125.867L127.447 66.1877H128.227C130.207 63.6678 133.247 61.428 137.346 59.4281C141.426 57.4283 146.146 56.4484 151.505 56.4484C157.585 56.4484 163.004 57.8483 167.784 60.6081C172.544 63.3879 176.284 67.2876 178.943 72.3272C181.623 77.3668 182.943 83.1266 182.943 89.6257V137.102H167.384V90.8857C167.384 85.2261 165.544 80.5066 161.885 76.7269C158.225 72.9471 153.665 71.0673 148.205 71.0673C144.546 71.0673 141.166 71.9672 138.066 73.7471C134.967 75.5269 132.546 77.9468 130.747 80.9868C128.967 84.0261 128.067 87.3261 128.067 90.8857V137.102H112.508V137.082Z\" fill=\"white\"/>\n<path d=\"M214.923 165.84C209.523 163.02 205.403 159.481 202.583 155.221C199.763 150.962 198.244 146.662 198.024 142.243H213.742C214.162 145.902 216.162 149.142 219.722 151.901C223.282 154.682 228.221 156.061 234.501 156.061C240.78 156.061 246.18 154.221 250.06 150.562C253.939 146.882 255.88 142.022 255.88 135.943V123.364H255.1C252.379 126.404 248.96 128.823 244.88 130.603C240.801 132.383 236.281 133.283 231.361 133.283C224.542 133.283 218.402 131.663 212.883 128.403C207.383 125.163 203.063 120.604 199.924 114.725C196.784 108.865 195.204 102.205 195.204 94.766C195.204 87.3266 196.784 80.6873 199.924 74.8875C203.063 69.0679 207.383 64.5482 212.883 61.2885C218.382 58.0487 224.542 56.4088 231.361 56.4088C236.401 56.4088 241.02 57.4088 245.28 59.3887C249.52 61.3885 252.96 64.0483 255.58 67.4081H256.36L257.939 57.9687H271.458V136.103C271.458 142.802 269.998 148.722 267.059 153.861C264.119 159.001 259.859 162.981 254.239 165.801C248.64 168.64 242.06 170.04 234.501 170.04C226.942 170.04 220.322 168.62 214.923 165.801V165.84ZM244.78 116.084C248.18 114.044 250.88 111.165 252.88 107.445C254.879 103.726 255.859 99.5054 255.859 94.7862C255.859 90.0664 254.86 85.8866 252.88 82.2069C250.88 78.5472 248.18 75.6874 244.78 73.6476C241.38 71.6077 237.581 70.5878 233.381 70.5878C226.882 70.5878 221.522 72.8476 217.262 77.3473C213.023 81.8469 210.903 87.6664 210.903 94.8058C210.903 101.945 213.023 107.905 217.262 112.405C221.502 116.904 226.882 119.164 233.381 119.164C237.581 119.164 241.38 118.144 244.78 116.105V116.084Z\" fill=\"white\"/>\n<path d=\"M303.031 133.382C297.051 129.883 292.372 125.003 288.952 118.764C285.552 112.524 283.852 105.425 283.852 97.4655C283.852 89.5057 285.552 82.5664 288.952 76.3269C292.351 70.0874 297.051 65.2277 303.031 61.708C309.011 58.2082 315.65 56.4484 322.989 56.4484C330.329 56.4484 336.948 58.2082 342.868 61.708C348.787 65.2277 353.447 70.0874 356.867 76.3269C360.267 82.5664 361.966 89.6061 361.966 97.4655C361.966 105.325 360.267 112.524 356.867 118.764C353.467 125.003 348.787 129.883 342.868 133.382C336.948 136.902 330.309 138.642 322.989 138.642C315.67 138.642 308.99 136.882 303.031 133.382ZM334.848 120.883C338.468 118.684 341.328 115.544 343.408 111.444C345.507 107.364 346.548 102.685 346.548 97.4453C346.548 92.2057 345.507 87.5661 343.408 83.5264C341.308 79.4867 338.448 76.3669 334.848 74.1671C331.228 71.9672 327.269 70.8673 322.989 70.8673C318.71 70.8673 314.73 71.9672 311.13 74.1671C307.511 76.3669 304.651 79.4867 302.571 83.5264C300.471 87.5661 299.431 92.2057 299.431 97.4453C299.431 102.685 300.471 107.345 302.571 111.444C304.67 115.524 307.53 118.684 311.13 120.883C314.75 123.083 318.71 124.183 322.989 124.183C327.269 124.183 331.249 123.083 334.848 120.883Z\" fill=\"white\"/>\n<path d=\"M69.795 135.861H0V25.81H16.498V120.143L16.798 135.861L34.097 120.143H69.795V135.861Z\" fill=\"white\"/>\n</svg>\n </div>\n `;\n }\n\n private getStyles(position: WidgetPosition): string {\n const positions = {\n \"bottom-left\": \"bottom: 60px; left: 16px;\",\n \"bottom-right\": \"bottom: 60px; right: 16px;\",\n \"top-left\": \"top: 16px; left: 16px;\",\n \"top-right\": \"top: 16px; right: 16px;\",\n };\n\n return `\n :host {\n position: fixed;\n z-index: 99999;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", \"Roboto\", \"Oxygen\", \"Ubuntu\", \"Cantarell\", sans-serif;\n font-size: 12px;\n pointer-events: auto;\n ${positions[position]}\n }\n\n .container {\n display: flex;\n align-items: center;\n gap: 8px;\n transition: all 0.2s ease-in-out;\n border-radius: 8px;\n padding: 8px 12px;\n background: rgba(0, 0, 0, 0.8);\n box-shadow: 0 0 0 1px #373737, inset 0 0 0 1px rgba(0, 0, 0, 0.24), 0px 16px 32px -8px rgba(0, 0, 0, 0.24);\n backdrop-filter: blur(48px);\n }\n\n .logo {\n width: 26px;\n height: 26px;\n flex-shrink: 0;\n }\n `;\n }\n\n private renderLogo(): string {\n return `\n<svg height=\"26\" viewBox=\"0 0 147 171\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M0.304987 76.63L54.9149 136.206C55.1326 136.441 55.4362 136.579 55.757 136.579H145.288C146.308 136.579 146.817 135.347 146.096 134.625L106.804 95.3334H75.87V110.801L39.7802 74.711H1.14708C0.150317 74.711 -0.370977 75.8968 0.304987 76.63Z\" fill=\"#69E300\"/>\n<path d=\"M146.304 93.4186L91.6883 33.8424C91.4702 33.6075 91.1668 33.47 90.846 33.47H1.31509C0.289683 33.47 -0.220155 34.7017 0.501637 35.4235L39.7935 74.7153H70.7275V59.2483L106.817 95.3381H145.456C146.453 95.3381 146.974 94.1519 146.298 93.4186H146.304Z\" fill=\"#69E300\"/>\n</g>\n</svg>\n `;\n }\n\n private renderLoader(): string {\n return `\n<svg height=\"26\" viewBox=\"0 0 147 171\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<style>\n @keyframes moveDown {\n 0%, 100% { transform: translateY(0); }\n 50% { transform: translateY(12px); }\n }\n @keyframes moveUp {\n 0%, 100% { transform: translateY(0); }\n 50% { transform: translateY(-12px); }\n }\n .bottom-part { animation: moveDown 1.5s ease-in-out infinite; transform-origin: center; }\n .top-part { animation: moveUp 1.5s ease-in-out infinite; transform-origin: center; }\n</style>\n<path class=\"bottom-part\" d=\"M0.304987 76.63L54.9149 136.206C55.1326 136.441 55.4362 136.579 55.757 136.579H145.288C146.308 136.579 146.817 135.347 146.096 134.625L106.804 95.3334H75.87V110.801L39.7802 74.711H1.14708C0.150317 74.711 -0.370977 75.8968 0.304987 76.63Z\" fill=\"grey\"/>\n<path class=\"top-part\" d=\"M146.304 93.4186L91.6883 33.8424C91.4702 33.6075 91.1668 33.47 90.846 33.47H1.31509C0.289683 33.47 -0.220155 34.7017 0.501637 35.4235L39.7935 74.7153H70.7275V59.2483L106.817 95.3381H145.456C146.453 95.3381 146.974 94.1519 146.298 93.4186H146.304Z\" fill=\"grey\"/>\n</g>\n</svg>\n `;\n }\n}\n\nlogger.debug(\"Loading Lingo Dev Widget...\");\nif (typeof window !== \"undefined\") {\n customElements.define(\"lingo-dev-widget\", LingoDevWidget);\n const widget = document.createElement(\"lingo-dev-widget\");\n document.body.appendChild(widget);\n\n // Initialize state if not already set (will be updated by LingoProvider)\n if (!window.__LINGO_DEV_STATE__) {\n window.__LINGO_DEV_STATE__ = {\n isLoading: false,\n locale: \"en\",\n sourceLocale: \"en\",\n pendingCount: 0,\n position: \"bottom-left\",\n };\n }\n\n // Trigger initial render\n if (window.__LINGO_DEV_UPDATE__) {\n window.__LINGO_DEV_UPDATE__();\n }\n}\n\nexport { LingoDevWidget };\n"],"mappings":";;;;;;;;;AAkBA,IAAM,iBAAN,cAA6B,YAAY;CACvC,AAAQ;CACR,AAAQ,QAA8B;CACtC,AAAQ,KAAuB;CAC/B,AAAQ,oBAAoB;CAC5B,AAAQ,uBAAuB;CAE/B,cAAc;AACZ,SAAO;AACP,OAAK,SAAS,KAAK,aAAa,EAAE,MAAM,QAAQ,CAAC;;CAGnD,oBAAoB;AAElB,SAAO,6BAA6B;AAClC,QAAK,QAAQ,OAAO,uBAAuB;AAC3C,QAAK,QAAQ;;AAIf,MAAI,OAAO,qBAAqB;AAC9B,QAAK,QAAQ,OAAO;AACpB,QAAK,QAAQ;;AAGf,OAAK,kBAAkB;;CAGzB,uBAAuB;AACrB,MAAI,OAAO,qBACT,QAAO,OAAO;AAGhB,MAAI,KAAK,IAAI;AACX,QAAK,GAAG,OAAO;AACf,QAAK,KAAK;;;CAId,AAAQ,mBAAmB;EACzB,MAAM,QAAQ,OAAO;AACrB,MAAI,CAAC,OAAO;AACV,UAAO,KAAK,0DAA0D;AACtE;;AAGF,MAAI;GACF,MAAM,MAAM,IAAI,IAAI,MAAM;AAC1B,OAAI,WAAW,IAAI,aAAa,WAAW,SAAS;AAEpD,QAAK,KAAK,IAAI,UAAU,IAAI,UAAU,CAAC;AAEvC,QAAK,GAAG,eAAe;AACrB,WAAO,KAAK,sBAAsB;AAClC,SAAK,oBAAoB;;AAG3B,QAAK,GAAG,aAAa,UAAU;AAC7B,QAAI;KACF,MAAM,OAAO,KAAK,MAAM,MAAM,KAAK;AACnC,UAAK,kBAAkB,KAAK;aACrB,OAAO;AACd,YAAO,MAAM,sCAAsC,MAAM;;;AAI7D,QAAK,GAAG,WAAW,UAAU;AAC3B,WAAO,MAAM,oBAAoB,MAAM;;AAGzC,QAAK,GAAG,gBAAgB;AACtB,WAAO,KAAK,yBAAyB;AACrC,SAAK,KAAK;AAGV,QAAI,KAAK,oBAAoB,KAAK,sBAAsB;KACtD,MAAM,QAAQ,KAAK,IACjB,MAAO,KAAK,IAAI,GAAG,KAAK,kBAAkB,EAC1C,IACD;AACD,UAAK;AACL,YAAO,KACL,mBAAmB,MAAM,cAAc,KAAK,kBAAkB,GAAG,KAAK,qBAAqB,GAC5F;AACD,sBAAiB,KAAK,kBAAkB,EAAE,MAAM;;;WAG7C,OAAO;AACd,UAAO,MAAM,0CAA0C,MAAM;;;CAIjE,AAAQ,kBAAkB,OAAY;AACpC,UAAQ,MAAM,MAAd;GACE,KAAK;AACH,WAAO,KAAK,oCAAoC,MAAM,YAAY;AAClE;GAEF,KAAK;AAEH,QAAI,KAAK,OAAO;AACd,UAAK,MAAM,iBAAiB;MAC1B,QAAQ,MAAM;MACd,OAAO,MAAM;MACb,WAAW;MACX,QAAQ;MACT;AACD,UAAK,QAAQ;;AAEf;GAEF,KAAK;AAEH,QAAI,KAAK,SAAS,KAAK,MAAM,gBAAgB;AAC3C,UAAK,MAAM,eAAe,YAAY,MAAM;AAC5C,UAAK,QAAQ;;AAEf;GAEF,KAAK;AAEH,QAAI,KAAK,SAAS,KAAK,MAAM,gBAAgB;AAC3C,UAAK,MAAM,eAAe,SAAS;AACnC,UAAK,QAAQ;AAEb,sBAAiB;AACf,UAAI,KAAK,OAAO;AACd,YAAK,MAAM,iBAAiB;AAC5B,YAAK,QAAQ;;QAEd,IAAK;;AAEV;GAEF,KAAK;AACH,QAAI,KAAK,SAAS,KAAK,MAAM,gBAAgB;AAC3C,UAAK,MAAM,eAAe,SAAS;AACnC,UAAK,QAAQ;;AAEf;;;CAIN,AAAQ,SAAS;AAEf,MAAI,CAAC,KAAK,OAAO;AACf,QAAK,OAAO,YAAY;AACxB;;EAGF,MAAM,EAAE,WAAW,QAAQ,cAAc,UAAU,mBACjD,KAAK;EAGP,MAAM,aAAa,aAAa,gBAAgB,WAAW;AAE3D,OAAK,OAAO,YAAY;;UAElB,KAAK,UAAU,SAAS,CAAC;;;UAGzB,aAAa,KAAK,cAAc,GAAG,KAAK,YAAY,CAAC;;;;;;;;;;;;;;;CAgB7D,AAAQ,UAAU,UAAkC;AAQlD,SAAO;;;;;;;UAPW;GAChB,eAAe;GACf,gBAAgB;GAChB,YAAY;GACZ,aAAa;GACd,CASe,UAAU;;;;;;;;;;;;;;;;;;;;;;CAuB5B,AAAQ,aAAqB;AAC3B,SAAO;;;;;;;;CAST,AAAQ,eAAuB;AAC7B,SAAO;;;;;;;;;;;;;;;;;;;;;AAsBX,OAAO,MAAM,8BAA8B;AAC3C,IAAI,OAAO,WAAW,aAAa;AACjC,gBAAe,OAAO,oBAAoB,eAAe;CACzD,MAAM,SAAS,SAAS,cAAc,mBAAmB;AACzD,UAAS,KAAK,YAAY,OAAO;AAGjC,KAAI,CAAC,OAAO,oBACV,QAAO,sBAAsB;EAC3B,WAAW;EACX,QAAQ;EACR,cAAc;EACd,cAAc;EACd,UAAU;EACX;AAIH,KAAI,OAAO,qBACT,QAAO,sBAAsB"}
|