@sixbell-telco/sdk 4.6.1 → 4.8.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/CHANGELOG.md +43 -0
- package/fesm2022/sixbell-telco-sdk-layouts.mjs +32 -2
- package/fesm2022/sixbell-telco-sdk-layouts.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-utils-mfe.mjs +5 -14
- package/fesm2022/sixbell-telco-sdk-utils-mfe.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-utils-runtime-config.mjs +15 -3
- package/fesm2022/sixbell-telco-sdk-utils-runtime-config.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-utils-translation-testing.mjs +5 -1
- package/fesm2022/sixbell-telco-sdk-utils-translation-testing.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-utils-translation.mjs +358 -129
- package/fesm2022/sixbell-telco-sdk-utils-translation.mjs.map +1 -1
- package/layouts/README.md +7 -2
- package/layouts/src/page-banner/page-banner.component.d.ts +10 -0
- package/manifest.json +1 -1
- package/package.json +1 -1
- package/src/_index.css +29 -7
- package/utils/mfe/README.md +1 -1
- package/utils/mfe/src/provide-mfe-shadow-shell.d.ts +5 -1
- package/utils/runtime-config/src/http-client.d.ts +7 -0
- package/utils/translation/README.md +9 -5
- package/utils/translation/src/title-strategy/translated-title-strategy.d.ts +9 -0
- package/utils/translation/src/translation.service.d.ts +81 -6
- package/utils/translation/testing/src/translation-testing.d.ts +2 -0
|
@@ -114,7 +114,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
114
114
|
|
|
115
115
|
const importModule = (url) => import(/* @vite-ignore */ /* webpackIgnore: true */ url);
|
|
116
116
|
const hrefCache = new Map();
|
|
117
|
-
const PRELOAD_ATTRIBUTE = 'data-st-mfe-styles-preload';
|
|
118
117
|
/**
|
|
119
118
|
* Resolves the child's compiled stylesheet href: the hashed name written after the build, read from
|
|
120
119
|
* `stylesheetHrefModule`, or `<basePath>styles.css` when that module is missing.
|
|
@@ -130,27 +129,19 @@ async function resolveMfeStylesheetHref(config, importer = importModule) {
|
|
|
130
129
|
return fallback;
|
|
131
130
|
}
|
|
132
131
|
}
|
|
133
|
-
/**
|
|
132
|
+
/**
|
|
133
|
+
* One resolution per child per page load. The stylesheet itself is requested by the shell's
|
|
134
|
+
* `<link rel="stylesheet">` when it mounts. A `<link rel="preload">` in the document head would be
|
|
135
|
+
* left unused (and warned about by the browser) whenever the user leaves before the child mounts.
|
|
136
|
+
*/
|
|
134
137
|
function mfeStylesheetHref(config) {
|
|
135
138
|
let href = hrefCache.get(config.basePath);
|
|
136
139
|
if (!href) {
|
|
137
140
|
href = resolveMfeStylesheetHref(config);
|
|
138
141
|
hrefCache.set(config.basePath, href);
|
|
139
|
-
void href.then(preloadStylesheet);
|
|
140
142
|
}
|
|
141
143
|
return href;
|
|
142
144
|
}
|
|
143
|
-
function preloadStylesheet(href) {
|
|
144
|
-
const head = globalThis.document?.head;
|
|
145
|
-
if (!head || head.querySelector(`link[${PRELOAD_ATTRIBUTE}][href="${href}"]`))
|
|
146
|
-
return;
|
|
147
|
-
const preload = globalThis.document.createElement('link');
|
|
148
|
-
preload.rel = 'preload';
|
|
149
|
-
preload.as = 'style';
|
|
150
|
-
preload.href = href;
|
|
151
|
-
preload.setAttribute(PRELOAD_ATTRIBUTE, '');
|
|
152
|
-
head.append(preload);
|
|
153
|
-
}
|
|
154
145
|
/**
|
|
155
146
|
* Route providers for a federated child mounted through `MfeShadowShellComponent`: the shell config,
|
|
156
147
|
* the shadow-root registry, and CDK Overlay/Dialog scoped to the route so overlays open inside it.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sixbell-telco-sdk-utils-mfe.mjs","sources":["../../../projects/sdk/utils/mfe/src/mfe-shadow-root.ts","../../../projects/sdk/utils/mfe/src/hoist-property-rules.ts","../../../projects/sdk/utils/mfe/src/shadow-root-overlay-container.ts","../../../projects/sdk/utils/mfe/src/provide-mfe-shadow-shell.ts","../../../projects/sdk/utils/mfe/src/mfe-shadow-shell.component.ts","../../../projects/sdk/utils/mfe/sixbell-telco-sdk-utils-mfe.ts"],"sourcesContent":["import { Injectable, InjectionToken, signal } from '@angular/core';\n\n/** Where a federated child MFE serves its compiled stylesheet. */\nexport interface MfeShadowShellConfig {\n\t/** Public path the host mounts the child under, with a trailing slash (e.g. `/mfe-aux-tables/`). */\n\tbasePath: string;\n\t/**\n\t * Module (relative to `basePath`) whose export holds the hashed stylesheet href written after the build.\n\t * Defaults to `assets/stylesheet-href.js`.\n\t */\n\tstylesheetHrefModule?: string;\n\t/** Export name read from `stylesheetHrefModule`. Defaults to `stylesheetHref`. */\n\tstylesheetHrefExport?: string;\n\t/** Reveal the content after this delay even if the stylesheet never answers. Defaults to 1500 ms. */\n\trevealTimeoutMs?: number;\n}\n\nexport const MFE_SHADOW_SHELL_CONFIG = new InjectionToken<MfeShadowShellConfig>('MFE_SHADOW_SHELL_CONFIG');\n\n/** Route-scoped registry of the shell's shadow root, so overlays opened by the child render inside it. */\n@Injectable()\nexport class MfeShadowRoot {\n\treadonly root = signal<ShadowRoot | null>(null);\n}\n","const PROPERTIES_ATTRIBUTE = 'data-st-mfe-properties';\nconst PROPERTY_NAME = /^@property\\s+(--[^\\s{]+)/;\n\n/** Outcome of {@link hoistMfePropertyRules}. */\nexport type MfePropertyHoistResult = 'hoisted' | 'nothing-to-hoist' | 'already-hoisted' | 'unreadable';\n\nfunction collectPropertyRules(rules: CSSRuleList, into: string[]): void {\n\tfor (const rule of Array.from(rules)) {\n\t\tif (rule.cssText.startsWith('@property')) into.push(rule.cssText);\n\t\telse if ('cssRules' in rule) collectPropertyRules((rule as CSSGroupingRule).cssRules, into);\n\t}\n}\n\nfunction propertyName(rule: string): string | null {\n\treturn PROPERTY_NAME.exec(rule)?.[1] ?? null;\n}\n\n/** Names of the custom properties the document already registers with `@property`, readable sheets only. */\nfunction documentPropertyNames(document: Document): Set<string> {\n\tconst names = new Set<string>();\n\tfor (const sheet of Array.from(document.styleSheets)) {\n\t\tconst rules: string[] = [];\n\t\ttry {\n\t\t\tcollectPropertyRules(sheet.cssRules, rules);\n\t\t} catch {\n\t\t\tcontinue;\n\t\t}\n\t\trules.forEach((rule) => names.add(propertyName(rule) ?? ''));\n\t}\n\tfor (const style of Array.from(document.head?.querySelectorAll(`style[${PROPERTIES_ATTRIBUTE}]`) ?? [])) {\n\t\tfor (const match of (style.textContent ?? '').matchAll(/@property\\s+(--[^\\s{]+)/g)) names.add(match[1]);\n\t}\n\tnames.delete('');\n\treturn names;\n}\n\n/**\n * Registers a child stylesheet's `@property` rules at document level, once per `source`.\n *\n * Browsers ignore `@property` inside a shadow root, and Tailwind v4 relies on it for the initial values of\n * `--tw-*` variables (`border`, `shadow-*`, `ring-*`, `translate-*`, gradients...). Registration is global\n * and the first one wins, so properties the document already registers are skipped: a child built with a\n * different Tailwind version never changes the host's initial values.\n *\n * Returns `'unreadable'` when the sheet's rules cannot be read (a cross-origin sheet served without CORS).\n */\nexport function hoistMfePropertyRules(sheet: CSSStyleSheet | null, source: string, document: Document): MfePropertyHoistResult {\n\tif (!document.head || !sheet) return 'nothing-to-hoist';\n\tconst hoisted = Array.from(document.head.querySelectorAll(`style[${PROPERTIES_ATTRIBUTE}]`));\n\tif (hoisted.some((style) => style.getAttribute(PROPERTIES_ATTRIBUTE) === source)) return 'already-hoisted';\n\tconst rules: string[] = [];\n\ttry {\n\t\tcollectPropertyRules(sheet.cssRules, rules);\n\t} catch {\n\t\treturn 'unreadable';\n\t}\n\tconst registered = documentPropertyNames(document);\n\tconst missing = rules.filter((rule) => {\n\t\tconst name = propertyName(rule);\n\t\tif (!name || registered.has(name)) return false;\n\t\tregistered.add(name);\n\t\treturn true;\n\t});\n\tif (!missing.length) return 'nothing-to-hoist';\n\tconst style = document.createElement('style');\n\tstyle.setAttribute(PROPERTIES_ATTRIBUTE, source);\n\tstyle.textContent = missing.join('\\n');\n\tdocument.head.append(style);\n\treturn 'hoisted';\n}\n","import { OverlayContainer } from '@angular/cdk/overlay';\nimport { Injectable, inject } from '@angular/core';\nimport { MfeShadowRoot } from './mfe-shadow-root';\n\n/**\n * CDK overlay container that renders inside the federated child's shadow root, so the child's\n * compiled stylesheet styles its dialogs, menus and popovers. Without a registered shell (the\n * standalone dev harness) it stays on the document body, where the styles are global.\n */\n@Injectable()\nexport class ShadowRootOverlayContainer extends OverlayContainer {\n\tprivate readonly shell = inject(MfeShadowRoot, { optional: true });\n\n\toverride getContainerElement(): HTMLElement {\n\t\tconst container = super.getContainerElement();\n\t\tconst shadowRoot = this.shell?.root();\n\t\tif (shadowRoot && container.parentNode !== shadowRoot) {\n\t\t\tshadowRoot.appendChild(container);\n\t\t}\n\t\treturn container;\n\t}\n}\n","import { Dialog } from '@angular/cdk/dialog';\nimport { Overlay, OverlayContainer } from '@angular/cdk/overlay';\nimport { Provider } from '@angular/core';\nimport { MFE_SHADOW_SHELL_CONFIG, MfeShadowRoot, MfeShadowShellConfig } from './mfe-shadow-root';\nimport { ShadowRootOverlayContainer } from './shadow-root-overlay-container';\n\ntype StylesheetModuleImporter = (url: string) => Promise<Record<string, unknown>>;\n\nconst importModule: StylesheetModuleImporter = (url) => import(/* @vite-ignore */ /* webpackIgnore: true */ url);\nconst hrefCache = new Map<string, Promise<string>>();\nconst PRELOAD_ATTRIBUTE = 'data-st-mfe-styles-preload';\n\n/**\n * Resolves the child's compiled stylesheet href: the hashed name written after the build, read from\n * `stylesheetHrefModule`, or `<basePath>styles.css` when that module is missing.\n */\nexport async function resolveMfeStylesheetHref(config: MfeShadowShellConfig, importer: StylesheetModuleImporter = importModule): Promise<string> {\n\tconst fallback = `${config.basePath}styles.css`;\n\ttry {\n\t\tconst module = await importer(`${config.basePath}${config.stylesheetHrefModule ?? 'assets/stylesheet-href.js'}?v=${Date.now()}`);\n\t\tconst href = module[config.stylesheetHrefExport ?? 'stylesheetHref'];\n\t\treturn typeof href === 'string' && href ? href : fallback;\n\t} catch {\n\t\treturn fallback;\n\t}\n}\n\n/** One resolution per child per page load; also preloads the stylesheet in the document head. */\nexport function mfeStylesheetHref(config: MfeShadowShellConfig): Promise<string> {\n\tlet href = hrefCache.get(config.basePath);\n\tif (!href) {\n\t\thref = resolveMfeStylesheetHref(config);\n\t\threfCache.set(config.basePath, href);\n\t\tvoid href.then(preloadStylesheet);\n\t}\n\treturn href;\n}\n\nfunction preloadStylesheet(href: string): void {\n\tconst head = globalThis.document?.head;\n\tif (!head || head.querySelector(`link[${PRELOAD_ATTRIBUTE}][href=\"${href}\"]`)) return;\n\tconst preload = globalThis.document.createElement('link');\n\tpreload.rel = 'preload';\n\tpreload.as = 'style';\n\tpreload.href = href;\n\tpreload.setAttribute(PRELOAD_ATTRIBUTE, '');\n\thead.append(preload);\n}\n\n/**\n * Route providers for a federated child mounted through `MfeShadowShellComponent`: the shell config,\n * the shadow-root registry, and CDK Overlay/Dialog scoped to the route so overlays open inside it.\n *\n * ```ts\n * { path: '', component: MfeShadowShellComponent, providers: provideMfeShadowShell({ basePath: '/mfe-aux-tables/' }), children }\n * ```\n */\nexport function provideMfeShadowShell(config: MfeShadowShellConfig): Provider[] {\n\tvoid mfeStylesheetHref(config);\n\treturn [\n\t\t{ provide: MFE_SHADOW_SHELL_CONFIG, useValue: config },\n\t\tMfeShadowRoot,\n\t\t{ provide: OverlayContainer, useClass: ShadowRootOverlayContainer },\n\t\t{ provide: Overlay, useClass: Overlay },\n\t\t{ provide: Dialog, useClass: Dialog },\n\t];\n}\n","import { DOCUMENT } from '@angular/common';\nimport {\n\tChangeDetectionStrategy,\n\tComponent,\n\tDestroyRef,\n\tElementRef,\n\tViewEncapsulation,\n\tafterNextRender,\n\tcomputed,\n\tinject,\n\tisDevMode,\n\tsignal,\n} from '@angular/core';\nimport { RouterOutlet } from '@angular/router';\nimport { LoggerService } from '@sixbell-telco/sdk/utils/logger';\nimport { hoistMfePropertyRules } from './hoist-property-rules';\nimport { MFE_SHADOW_SHELL_CONFIG, MfeShadowRoot } from './mfe-shadow-root';\nimport { mfeStylesheetHref } from './provide-mfe-shadow-shell';\n\nconst STYLES_ATTRIBUTE = 'data-st-mfe-styles';\n\n/**\n * Route component that mounts a federated child inside its own shadow root: it attaches the child's\n * compiled stylesheet there, hides the content until it loads (no unstyled flash), and registers the\n * shadow root so CDK overlays opened by the child render inside it. Theme tokens inherit from the host.\n * Its Tailwind `@property` registrations the document lacks are hoisted to it, where browsers honour them.\n * Configure it with `provideMfeShadowShell` on the same route.\n */\n@Component({\n\tselector: 'st-mfe-shadow-shell',\n\timports: [RouterOutlet],\n\ttemplate: '<div [style.visibility]=\"visibility()\"><router-outlet /></div>',\n\tstyles: ':host { display: block; }',\n\tencapsulation: ViewEncapsulation.ShadowDom,\n\tchangeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class MfeShadowShellComponent {\n\tprivate readonly config = inject(MFE_SHADOW_SHELL_CONFIG);\n\tprivate readonly registry = inject(MfeShadowRoot);\n\tprivate readonly document = inject(DOCUMENT);\n\tprivate readonly host = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;\n\tprivate readonly destroyRef = inject(DestroyRef);\n\tprivate readonly logger = inject(LoggerService);\n\tprivate readonly stylesReady = signal(false);\n\n\tprotected readonly visibility = computed(() => (this.stylesReady() ? 'visible' : 'hidden'));\n\n\tconstructor() {\n\t\tconst shadowRoot = this.host.shadowRoot;\n\t\tif (shadowRoot) this.registry.root.set(shadowRoot);\n\t\tthis.destroyRef.onDestroy(() => this.registry.root.set(null));\n\t\tafterNextRender(() => void this.attachStylesheet(shadowRoot));\n\t}\n\n\tprivate async attachStylesheet(shadowRoot: ShadowRoot | null): Promise<void> {\n\t\tif (!shadowRoot || shadowRoot.querySelector(`link[${STYLES_ATTRIBUTE}]`)) {\n\t\t\tthis.stylesReady.set(true);\n\t\t\treturn;\n\t\t}\n\t\tconst link = this.document.createElement('link');\n\t\tlink.rel = 'stylesheet';\n\t\tlink.setAttribute(STYLES_ATTRIBUTE, '');\n\t\tconst reveal = () => this.stylesReady.set(true);\n\t\tlink.addEventListener(\n\t\t\t'load',\n\t\t\t() => {\n\t\t\t\tthis.hoistPropertyRules(link);\n\t\t\t\treveal();\n\t\t\t},\n\t\t\t{ once: true },\n\t\t);\n\t\tlink.addEventListener('error', reveal, { once: true });\n\t\tconst timer = setTimeout(reveal, this.config.revealTimeoutMs ?? 1500);\n\t\tthis.destroyRef.onDestroy(() => clearTimeout(timer));\n\t\tlink.href = await mfeStylesheetHref(this.config);\n\t\tshadowRoot.prepend(link);\n\t}\n\n\tprivate hoistPropertyRules(link: HTMLLinkElement): void {\n\t\tconst href = link.getAttribute('href') ?? '';\n\t\tif (hoistMfePropertyRules(link.sheet, href, this.document) !== 'unreadable' || !isDevMode()) return;\n\t\tthis.logger.warn(\n\t\t\t`MFE shadow shell: cannot read the rules of ${href} (cross-origin without CORS?), so its @property rules were not hoisted and Tailwind border, shadow, ring and translate utilities may not resolve. Serve it with CORS or from the host origin.`,\n\t\t\t{ component: 'MfeShadowShellComponent', href },\n\t\t);\n\t}\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;MAiBa,uBAAuB,GAAG,IAAI,cAAc,CAAuB,yBAAyB;AAEzG;MAEa,aAAa,CAAA;AAChB,IAAA,IAAI,GAAG,MAAM,CAAoB,IAAI,CAAC;wGADnC,aAAa,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;4GAAb,aAAa,EAAA,CAAA;;4FAAb,aAAa,EAAA,UAAA,EAAA,CAAA;kBADzB;;;ACpBD,MAAM,oBAAoB,GAAG,wBAAwB;AACrD,MAAM,aAAa,GAAG,0BAA0B;AAKhD,SAAS,oBAAoB,CAAC,KAAkB,EAAE,IAAc,EAAA;IAC/D,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC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telco-sdk-utils-mfe.mjs","sources":["../../../projects/sdk/utils/mfe/src/mfe-shadow-root.ts","../../../projects/sdk/utils/mfe/src/hoist-property-rules.ts","../../../projects/sdk/utils/mfe/src/shadow-root-overlay-container.ts","../../../projects/sdk/utils/mfe/src/provide-mfe-shadow-shell.ts","../../../projects/sdk/utils/mfe/src/mfe-shadow-shell.component.ts","../../../projects/sdk/utils/mfe/sixbell-telco-sdk-utils-mfe.ts"],"sourcesContent":["import { Injectable, InjectionToken, signal } from '@angular/core';\n\n/** Where a federated child MFE serves its compiled stylesheet. */\nexport interface MfeShadowShellConfig {\n\t/** Public path the host mounts the child under, with a trailing slash (e.g. `/mfe-aux-tables/`). */\n\tbasePath: string;\n\t/**\n\t * Module (relative to `basePath`) whose export holds the hashed stylesheet href written after the build.\n\t * Defaults to `assets/stylesheet-href.js`.\n\t */\n\tstylesheetHrefModule?: string;\n\t/** Export name read from `stylesheetHrefModule`. Defaults to `stylesheetHref`. */\n\tstylesheetHrefExport?: string;\n\t/** Reveal the content after this delay even if the stylesheet never answers. Defaults to 1500 ms. */\n\trevealTimeoutMs?: number;\n}\n\nexport const MFE_SHADOW_SHELL_CONFIG = new InjectionToken<MfeShadowShellConfig>('MFE_SHADOW_SHELL_CONFIG');\n\n/** Route-scoped registry of the shell's shadow root, so overlays opened by the child render inside it. */\n@Injectable()\nexport class MfeShadowRoot {\n\treadonly root = signal<ShadowRoot | null>(null);\n}\n","const PROPERTIES_ATTRIBUTE = 'data-st-mfe-properties';\nconst PROPERTY_NAME = /^@property\\s+(--[^\\s{]+)/;\n\n/** Outcome of {@link hoistMfePropertyRules}. */\nexport type MfePropertyHoistResult = 'hoisted' | 'nothing-to-hoist' | 'already-hoisted' | 'unreadable';\n\nfunction collectPropertyRules(rules: CSSRuleList, into: string[]): void {\n\tfor (const rule of Array.from(rules)) {\n\t\tif (rule.cssText.startsWith('@property')) into.push(rule.cssText);\n\t\telse if ('cssRules' in rule) collectPropertyRules((rule as CSSGroupingRule).cssRules, into);\n\t}\n}\n\nfunction propertyName(rule: string): string | null {\n\treturn PROPERTY_NAME.exec(rule)?.[1] ?? null;\n}\n\n/** Names of the custom properties the document already registers with `@property`, readable sheets only. */\nfunction documentPropertyNames(document: Document): Set<string> {\n\tconst names = new Set<string>();\n\tfor (const sheet of Array.from(document.styleSheets)) {\n\t\tconst rules: string[] = [];\n\t\ttry {\n\t\t\tcollectPropertyRules(sheet.cssRules, rules);\n\t\t} catch {\n\t\t\tcontinue;\n\t\t}\n\t\trules.forEach((rule) => names.add(propertyName(rule) ?? ''));\n\t}\n\tfor (const style of Array.from(document.head?.querySelectorAll(`style[${PROPERTIES_ATTRIBUTE}]`) ?? [])) {\n\t\tfor (const match of (style.textContent ?? '').matchAll(/@property\\s+(--[^\\s{]+)/g)) names.add(match[1]);\n\t}\n\tnames.delete('');\n\treturn names;\n}\n\n/**\n * Registers a child stylesheet's `@property` rules at document level, once per `source`.\n *\n * Browsers ignore `@property` inside a shadow root, and Tailwind v4 relies on it for the initial values of\n * `--tw-*` variables (`border`, `shadow-*`, `ring-*`, `translate-*`, gradients...). Registration is global\n * and the first one wins, so properties the document already registers are skipped: a child built with a\n * different Tailwind version never changes the host's initial values.\n *\n * Returns `'unreadable'` when the sheet's rules cannot be read (a cross-origin sheet served without CORS).\n */\nexport function hoistMfePropertyRules(sheet: CSSStyleSheet | null, source: string, document: Document): MfePropertyHoistResult {\n\tif (!document.head || !sheet) return 'nothing-to-hoist';\n\tconst hoisted = Array.from(document.head.querySelectorAll(`style[${PROPERTIES_ATTRIBUTE}]`));\n\tif (hoisted.some((style) => style.getAttribute(PROPERTIES_ATTRIBUTE) === source)) return 'already-hoisted';\n\tconst rules: string[] = [];\n\ttry {\n\t\tcollectPropertyRules(sheet.cssRules, rules);\n\t} catch {\n\t\treturn 'unreadable';\n\t}\n\tconst registered = documentPropertyNames(document);\n\tconst missing = rules.filter((rule) => {\n\t\tconst name = propertyName(rule);\n\t\tif (!name || registered.has(name)) return false;\n\t\tregistered.add(name);\n\t\treturn true;\n\t});\n\tif (!missing.length) return 'nothing-to-hoist';\n\tconst style = document.createElement('style');\n\tstyle.setAttribute(PROPERTIES_ATTRIBUTE, source);\n\tstyle.textContent = missing.join('\\n');\n\tdocument.head.append(style);\n\treturn 'hoisted';\n}\n","import { OverlayContainer } from '@angular/cdk/overlay';\nimport { Injectable, inject } from '@angular/core';\nimport { MfeShadowRoot } from './mfe-shadow-root';\n\n/**\n * CDK overlay container that renders inside the federated child's shadow root, so the child's\n * compiled stylesheet styles its dialogs, menus and popovers. Without a registered shell (the\n * standalone dev harness) it stays on the document body, where the styles are global.\n */\n@Injectable()\nexport class ShadowRootOverlayContainer extends OverlayContainer {\n\tprivate readonly shell = inject(MfeShadowRoot, { optional: true });\n\n\toverride getContainerElement(): HTMLElement {\n\t\tconst container = super.getContainerElement();\n\t\tconst shadowRoot = this.shell?.root();\n\t\tif (shadowRoot && container.parentNode !== shadowRoot) {\n\t\t\tshadowRoot.appendChild(container);\n\t\t}\n\t\treturn container;\n\t}\n}\n","import { Dialog } from '@angular/cdk/dialog';\nimport { Overlay, OverlayContainer } from '@angular/cdk/overlay';\nimport { Provider } from '@angular/core';\nimport { MFE_SHADOW_SHELL_CONFIG, MfeShadowRoot, MfeShadowShellConfig } from './mfe-shadow-root';\nimport { ShadowRootOverlayContainer } from './shadow-root-overlay-container';\n\ntype StylesheetModuleImporter = (url: string) => Promise<Record<string, unknown>>;\n\nconst importModule: StylesheetModuleImporter = (url) => import(/* @vite-ignore */ /* webpackIgnore: true */ url);\nconst hrefCache = new Map<string, Promise<string>>();\n\n/**\n * Resolves the child's compiled stylesheet href: the hashed name written after the build, read from\n * `stylesheetHrefModule`, or `<basePath>styles.css` when that module is missing.\n */\nexport async function resolveMfeStylesheetHref(config: MfeShadowShellConfig, importer: StylesheetModuleImporter = importModule): Promise<string> {\n\tconst fallback = `${config.basePath}styles.css`;\n\ttry {\n\t\tconst module = await importer(`${config.basePath}${config.stylesheetHrefModule ?? 'assets/stylesheet-href.js'}?v=${Date.now()}`);\n\t\tconst href = module[config.stylesheetHrefExport ?? 'stylesheetHref'];\n\t\treturn typeof href === 'string' && href ? href : fallback;\n\t} catch {\n\t\treturn fallback;\n\t}\n}\n\n/**\n * One resolution per child per page load. The stylesheet itself is requested by the shell's\n * `<link rel=\"stylesheet\">` when it mounts. A `<link rel=\"preload\">` in the document head would be\n * left unused (and warned about by the browser) whenever the user leaves before the child mounts.\n */\nexport function mfeStylesheetHref(config: MfeShadowShellConfig): Promise<string> {\n\tlet href = hrefCache.get(config.basePath);\n\tif (!href) {\n\t\thref = resolveMfeStylesheetHref(config);\n\t\threfCache.set(config.basePath, href);\n\t}\n\treturn href;\n}\n\n/**\n * Route providers for a federated child mounted through `MfeShadowShellComponent`: the shell config,\n * the shadow-root registry, and CDK Overlay/Dialog scoped to the route so overlays open inside it.\n *\n * ```ts\n * { path: '', component: MfeShadowShellComponent, providers: provideMfeShadowShell({ basePath: '/mfe-aux-tables/' }), children }\n * ```\n */\nexport function provideMfeShadowShell(config: MfeShadowShellConfig): Provider[] {\n\tvoid mfeStylesheetHref(config);\n\treturn [\n\t\t{ provide: MFE_SHADOW_SHELL_CONFIG, useValue: config },\n\t\tMfeShadowRoot,\n\t\t{ provide: OverlayContainer, useClass: ShadowRootOverlayContainer },\n\t\t{ provide: Overlay, useClass: Overlay },\n\t\t{ provide: Dialog, useClass: Dialog },\n\t];\n}\n","import { DOCUMENT } from '@angular/common';\nimport {\n\tChangeDetectionStrategy,\n\tComponent,\n\tDestroyRef,\n\tElementRef,\n\tViewEncapsulation,\n\tafterNextRender,\n\tcomputed,\n\tinject,\n\tisDevMode,\n\tsignal,\n} from '@angular/core';\nimport { RouterOutlet } from '@angular/router';\nimport { LoggerService } from '@sixbell-telco/sdk/utils/logger';\nimport { hoistMfePropertyRules } from './hoist-property-rules';\nimport { MFE_SHADOW_SHELL_CONFIG, MfeShadowRoot } from './mfe-shadow-root';\nimport { mfeStylesheetHref } from './provide-mfe-shadow-shell';\n\nconst STYLES_ATTRIBUTE = 'data-st-mfe-styles';\n\n/**\n * Route component that mounts a federated child inside its own shadow root: it attaches the child's\n * compiled stylesheet there, hides the content until it loads (no unstyled flash), and registers the\n * shadow root so CDK overlays opened by the child render inside it. Theme tokens inherit from the host.\n * Its Tailwind `@property` registrations the document lacks are hoisted to it, where browsers honour them.\n * Configure it with `provideMfeShadowShell` on the same route.\n */\n@Component({\n\tselector: 'st-mfe-shadow-shell',\n\timports: [RouterOutlet],\n\ttemplate: '<div [style.visibility]=\"visibility()\"><router-outlet /></div>',\n\tstyles: ':host { display: block; }',\n\tencapsulation: ViewEncapsulation.ShadowDom,\n\tchangeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class MfeShadowShellComponent {\n\tprivate readonly config = inject(MFE_SHADOW_SHELL_CONFIG);\n\tprivate readonly registry = inject(MfeShadowRoot);\n\tprivate readonly document = inject(DOCUMENT);\n\tprivate readonly host = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;\n\tprivate readonly destroyRef = inject(DestroyRef);\n\tprivate readonly logger = inject(LoggerService);\n\tprivate readonly stylesReady = signal(false);\n\n\tprotected readonly visibility = computed(() => (this.stylesReady() ? 'visible' : 'hidden'));\n\n\tconstructor() {\n\t\tconst shadowRoot = this.host.shadowRoot;\n\t\tif (shadowRoot) this.registry.root.set(shadowRoot);\n\t\tthis.destroyRef.onDestroy(() => this.registry.root.set(null));\n\t\tafterNextRender(() => void this.attachStylesheet(shadowRoot));\n\t}\n\n\tprivate async attachStylesheet(shadowRoot: ShadowRoot | null): Promise<void> {\n\t\tif (!shadowRoot || shadowRoot.querySelector(`link[${STYLES_ATTRIBUTE}]`)) {\n\t\t\tthis.stylesReady.set(true);\n\t\t\treturn;\n\t\t}\n\t\tconst link = this.document.createElement('link');\n\t\tlink.rel = 'stylesheet';\n\t\tlink.setAttribute(STYLES_ATTRIBUTE, '');\n\t\tconst reveal = () => this.stylesReady.set(true);\n\t\tlink.addEventListener(\n\t\t\t'load',\n\t\t\t() => {\n\t\t\t\tthis.hoistPropertyRules(link);\n\t\t\t\treveal();\n\t\t\t},\n\t\t\t{ once: true },\n\t\t);\n\t\tlink.addEventListener('error', reveal, { once: true });\n\t\tconst timer = setTimeout(reveal, this.config.revealTimeoutMs ?? 1500);\n\t\tthis.destroyRef.onDestroy(() => clearTimeout(timer));\n\t\tlink.href = await mfeStylesheetHref(this.config);\n\t\tshadowRoot.prepend(link);\n\t}\n\n\tprivate hoistPropertyRules(link: HTMLLinkElement): void {\n\t\tconst href = link.getAttribute('href') ?? '';\n\t\tif (hoistMfePropertyRules(link.sheet, href, this.document) !== 'unreadable' || !isDevMode()) return;\n\t\tthis.logger.warn(\n\t\t\t`MFE shadow shell: cannot read the rules of ${href} (cross-origin without CORS?), so its @property rules were not hoisted and Tailwind border, shadow, ring and translate utilities may not resolve. Serve it with CORS or from the host origin.`,\n\t\t\t{ component: 'MfeShadowShellComponent', href },\n\t\t);\n\t}\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;MAiBa,uBAAuB,GAAG,IAAI,cAAc,CAAuB,yBAAyB;AAEzG;MAEa,aAAa,CAAA;AAChB,IAAA,IAAI,GAAG,MAAM,CAAoB,IAAI,CAAC;wGADnC,aAAa,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;4GAAb,aAAa,EAAA,CAAA;;4FAAb,aAAa,EAAA,UAAA,EAAA,CAAA;kBADzB;;;ACpBD,MAAM,oBAAoB,GAAG,wBAAwB;AACrD,MAAM,aAAa,GAAG,0BAA0B;AAKhD,SAAS,oBAAoB,CAAC,KAAkB,EAAE,IAAc,EAAA;IAC/D,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;AACrC,QAAA,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC;AAA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A,CAAA,EAAA,QAAA,EAAA,CAAA,QAAA,CAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,aAAA,EAAA,EAAA,CAAA,iBAAA,CAAA,SAAA,EAAA,CAAA;;4FAMV,uBAAuB,EAAA,UAAA,EAAA,CAAA;kBARnC,SAAS;AACC,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,qBAAqB,EAAA,OAAA,EACtB,CAAC,YAAY,CAAC,EAAA,QAAA,EACb,gEAAgE,EAAA,aAAA,EAE3D,iBAAiB,CAAC,SAAS,EAAA,eAAA,EACzB,uBAAuB,CAAC,MAAM,EAAA,MAAA,EAAA,CAAA,wBAAA,CAAA,EAAA;;;AClChD;;AAEG;;;;"}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import Dexie from 'dexie';
|
|
2
2
|
|
|
3
|
+
/** A response with a non-2xx status. `status` lets callers tell a missing file (404) from a failure. */
|
|
4
|
+
class RuntimeHttpError extends Error {
|
|
5
|
+
status;
|
|
6
|
+
constructor(status, statusText) {
|
|
7
|
+
super(`HTTP ${status}: ${statusText}`);
|
|
8
|
+
this.status = status;
|
|
9
|
+
this.name = 'RuntimeHttpError';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
3
12
|
class RuntimeHttpClient {
|
|
4
13
|
options;
|
|
5
14
|
constructor(options = {}) {
|
|
@@ -16,6 +25,9 @@ class RuntimeHttpClient {
|
|
|
16
25
|
}
|
|
17
26
|
catch (error) {
|
|
18
27
|
lastError = error instanceof Error ? error : new Error(String(error));
|
|
28
|
+
if (error instanceof RuntimeHttpError && this.options.noRetryStatuses?.includes(error.status)) {
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
19
31
|
if (attempt < retries && retryDelayMs > 0) {
|
|
20
32
|
await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
|
|
21
33
|
}
|
|
@@ -27,7 +39,7 @@ class RuntimeHttpClient {
|
|
|
27
39
|
if (!timeoutMs || timeoutMs <= 0) {
|
|
28
40
|
const response = await fetch(url, init);
|
|
29
41
|
if (!response.ok) {
|
|
30
|
-
throw new
|
|
42
|
+
throw new RuntimeHttpError(response.status, response.statusText);
|
|
31
43
|
}
|
|
32
44
|
return response;
|
|
33
45
|
}
|
|
@@ -39,7 +51,7 @@ class RuntimeHttpClient {
|
|
|
39
51
|
signal: controller.signal,
|
|
40
52
|
});
|
|
41
53
|
if (!response.ok) {
|
|
42
|
-
throw new
|
|
54
|
+
throw new RuntimeHttpError(response.status, response.statusText);
|
|
43
55
|
}
|
|
44
56
|
return response;
|
|
45
57
|
}
|
|
@@ -335,5 +347,5 @@ class RuntimeUpdateAdapter {
|
|
|
335
347
|
* Generated bundle index. Do not edit.
|
|
336
348
|
*/
|
|
337
349
|
|
|
338
|
-
export { RuntimeConfigLoader, RuntimeConfigStore, RuntimeHttpClient, RuntimeUpdateAdapter };
|
|
350
|
+
export { RuntimeConfigLoader, RuntimeConfigStore, RuntimeHttpClient, RuntimeHttpError, RuntimeUpdateAdapter };
|
|
339
351
|
//# sourceMappingURL=sixbell-telco-sdk-utils-runtime-config.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sixbell-telco-sdk-utils-runtime-config.mjs","sources":["../../../projects/sdk/utils/runtime-config/src/http-client.ts","../../../projects/sdk/utils/runtime-config/src/runtime-config-loader.ts","../../../projects/sdk/utils/runtime-config/src/runtime-config-store.ts","../../../projects/sdk/utils/runtime-config/src/runtime-update-adapter.ts","../../../projects/sdk/utils/runtime-config/sixbell-telco-sdk-utils-runtime-config.ts"],"sourcesContent":["export interface HttpClientOptions {\n\tretries?: number;\n\tretryDelayMs?: number;\n\ttimeoutMs?: number;\n}\n\nexport class RuntimeHttpClient {\n\tconstructor(private readonly options: HttpClientOptions = {}) {}\n\n\tasync fetch(url: string, init?: RequestInit): Promise<Response> {\n\t\tconst retries = this.options.retries ?? 0;\n\t\tconst retryDelayMs = this.options.retryDelayMs ?? 0;\n\t\tconst timeoutMs = this.options.timeoutMs ?? 0;\n\t\tlet lastError: Error | null = null;\n\n\t\tfor (let attempt = 0; attempt <= retries; attempt += 1) {\n\t\t\ttry {\n\t\t\t\treturn await this.attemptFetch(url, init, timeoutMs);\n\t\t\t} catch (error) {\n\t\t\t\tlastError = error instanceof Error ? error : new Error(String(error));\n\t\t\t\tif (attempt < retries && retryDelayMs > 0) {\n\t\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, retryDelayMs));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthrow lastError ?? new Error('Failed to fetch');\n\t}\n\n\tprivate async attemptFetch(url: string, init: RequestInit | undefined, timeoutMs: number): Promise<Response> {\n\t\tif (!timeoutMs || timeoutMs <= 0) {\n\t\t\tconst response = await fetch(url, init);\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow new Error(`HTTP ${response.status}: ${response.statusText}`);\n\t\t\t}\n\t\t\treturn response;\n\t\t}\n\n\t\tconst controller = new AbortController();\n\t\tconst timeoutHandle = setTimeout(() => controller.abort(), timeoutMs);\n\t\ttry {\n\t\t\tconst response = await fetch(url, {\n\t\t\t\t...init,\n\t\t\t\tsignal: controller.signal,\n\t\t\t});\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow new Error(`HTTP ${response.status}: ${response.statusText}`);\n\t\t\t}\n\t\t\treturn response;\n\t\t} finally {\n\t\t\tclearTimeout(timeoutHandle);\n\t\t}\n\t}\n}\n","import { RuntimeHttpClient } from './http-client';\nimport type { RuntimeConfigCheckResult, RuntimeConfigLoadResult, RuntimeConfigLoaderOptions, RuntimeConfigMeta } from './types';\n\nconst DEFAULT_RETRIES = 2;\nconst DEFAULT_RETRY_DELAY_MS = 400;\nconst DEFAULT_TIMEOUT_MS = 8000;\n\nexport class RuntimeConfigLoader<T> {\n\tprivate readonly httpClient: RuntimeHttpClient;\n\tprivate readonly parser: (response: Response) => Promise<T>;\n\tprivate readonly cacheKey: string;\n\n\tconstructor(\n\t\tprivate readonly configPath: string,\n\t\tprivate readonly options: RuntimeConfigLoaderOptions<T>,\n\t\tprivate readonly retries = DEFAULT_RETRIES,\n\t\tprivate readonly retryDelayMs = DEFAULT_RETRY_DELAY_MS,\n\t\tprivate readonly timeoutMs = DEFAULT_TIMEOUT_MS,\n\t) {\n\t\tthis.httpClient = new RuntimeHttpClient({\n\t\t\tretries: this.retries,\n\t\t\tretryDelayMs: this.retryDelayMs,\n\t\t\ttimeoutMs: this.timeoutMs,\n\t\t});\n\t\tthis.parser = options.parser ?? (async (response: Response) => (await response.json()) as T);\n\t\tthis.cacheKey = this.buildCacheKey();\n\t}\n\n\tasync loadLatest(): Promise<RuntimeConfigLoadResult<T>> {\n\t\tconst logger = this.options.logger;\n\t\tconst cached = await this.loadFromStore();\n\t\tif (cached) {\n\t\t\tlogger?.debug('Runtime config loaded from cache', {\n\t\t\t\tcomponent: 'RuntimeConfigLoader',\n\t\t\t\taction: 'loadLatest',\n\t\t\t\tresource: this.options.resource,\n\t\t\t\tconfigPath: this.configPath,\n\t\t\t\tmeta: cached.meta,\n\t\t\t});\n\t\t\treturn { ...cached, source: 'cache' };\n\t\t}\n\t\ttry {\n\t\t\tconst response = await this.fetchNoStore();\n\t\t\tconst data = await this.parser(response);\n\t\t\tconst meta = this.extractMeta(data);\n\t\t\tconst hash = await this.resolveHash(data, meta);\n\t\t\tconst result: RuntimeConfigLoadResult<T> = { data, meta, source: 'network', hash };\n\t\t\tawait this.storeResult(result);\n\t\t\tlogger?.debug('Runtime config loaded', {\n\t\t\t\tcomponent: 'RuntimeConfigLoader',\n\t\t\t\taction: 'loadLatest',\n\t\t\t\tresource: this.options.resource,\n\t\t\t\tconfigPath: this.configPath,\n\t\t\t\tmeta,\n\t\t\t});\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tlogger?.warn('Runtime config load failed, falling back', {\n\t\t\t\tcomponent: 'RuntimeConfigLoader',\n\t\t\t\taction: 'loadLatest',\n\t\t\t\tresource: this.options.resource,\n\t\t\t\tconfigPath: this.configPath,\n\t\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\t});\n\t\t\tconst fallback = this.options.fallbackData;\n\t\t\ttry {\n\t\t\t\tconst meta = this.extractMeta(fallback);\n\t\t\t\tconst hash = await this.resolveHash(fallback, meta);\n\t\t\t\treturn { data: fallback, meta, source: 'fallback', hash };\n\t\t\t} catch {\n\t\t\t\treturn { data: fallback, meta: {}, source: 'fallback', hash: '' };\n\t\t\t}\n\t\t}\n\t}\n\n\tasync checkForUpdates(currentHash: string): Promise<RuntimeConfigCheckResult> {\n\t\ttry {\n\t\t\tconst response = await this.fetchNoStore();\n\t\t\tconst data = await this.parser(response);\n\t\t\tconst meta = this.extractMeta(data);\n\t\t\tconst hash = await this.resolveHash(data, meta);\n\t\t\treturn { updated: hash !== currentHash, meta, hash };\n\t\t} catch {\n\t\t\treturn { updated: false, meta: {}, hash: currentHash };\n\t\t}\n\t}\n\n\tasync refresh(): Promise<RuntimeConfigLoadResult<T>> {\n\t\tconst response = await this.fetchNoStore();\n\t\tconst data = await this.parser(response);\n\t\tconst meta = this.extractMeta(data);\n\t\tconst hash = await this.resolveHash(data, meta);\n\t\tconst result: RuntimeConfigLoadResult<T> = { data, meta, source: 'network', hash };\n\t\tawait this.storeResult(result);\n\t\treturn result;\n\t}\n\n\tprivate async loadFromStore(): Promise<RuntimeConfigLoadResult<T> | null> {\n\t\tif (!this.options.store) {\n\t\t\treturn null;\n\t\t}\n\t\tconst cached = await this.options.store.get(this.cacheKey);\n\t\tif (!cached) {\n\t\t\treturn null;\n\t\t}\n\t\tif (this.options.schemaVersion) {\n\t\t\tconst cachedSchema = cached.meta.schemaVersion;\n\t\t\tif (cachedSchema !== this.options.schemaVersion) {\n\t\t\t\tawait this.options.store.remove(this.cacheKey);\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t\treturn cached;\n\t}\n\n\tprivate async storeResult(result: RuntimeConfigLoadResult<T>): Promise<void> {\n\t\tif (!this.options.store) {\n\t\t\treturn;\n\t\t}\n\t\tawait this.options.store.set(this.cacheKey, result);\n\t}\n\n\tprivate extractMeta(data: T): RuntimeConfigMeta {\n\t\tconst meta = (data as { meta?: RuntimeConfigMeta }).meta;\n\t\tif (!meta?.hash) {\n\t\t\tthrow new Error('Runtime config missing required meta.hash');\n\t\t}\n\t\treturn meta;\n\t}\n\n\tprivate async resolveHash(data: T, meta: RuntimeConfigMeta): Promise<string> {\n\t\treturn meta.hash ?? this.hashValue(data);\n\t}\n\n\tprivate async hashValue(data: T): Promise<string> {\n\t\tconst value = JSON.stringify(data);\n\t\tif (typeof crypto?.subtle?.digest === 'function') {\n\t\t\tconst encoded = new TextEncoder().encode(value);\n\t\t\tconst buffer = await crypto.subtle.digest('SHA-256', encoded);\n\t\t\treturn this.bufferToHex(buffer);\n\t\t}\n\t\tlet hash = 0;\n\t\tfor (let i = 0; i < value.length; i += 1) {\n\t\t\thash = (hash * 31 + value.charCodeAt(i)) >>> 0;\n\t\t}\n\t\treturn `fallback-${hash.toString(16)}`;\n\t}\n\n\tprivate bufferToHex(buffer: ArrayBuffer): string {\n\t\tconst bytes = new Uint8Array(buffer);\n\t\tlet hex = '';\n\t\tfor (const byte of bytes) {\n\t\t\thex += byte.toString(16).padStart(2, '0');\n\t\t}\n\t\treturn hex;\n\t}\n\n\tprivate buildCacheKey(): string {\n\t\tconst prefix = this.options.appId ? `${this.options.appId}:` : '';\n\t\tconst schema = this.options.schemaVersion ? `:schema:${this.options.schemaVersion}` : '';\n\t\treturn `${prefix}${this.options.resource}:${this.configPath}${schema}`;\n\t}\n\n\tprivate async fetchNoStore(): Promise<Response> {\n\t\treturn this.httpClient.fetch(this.configPath, { cache: 'no-store' });\n\t}\n}\n","import Dexie, { Table } from 'dexie';\nimport type { RuntimeConfigLoadResult, RuntimeConfigStoreContract } from './types';\n\nconst DEFAULT_DB_NAME = 'sixbell-runtime-config';\n\ninterface RuntimeConfigRecord<T> {\n\tkey: string;\n\tpayload: RuntimeConfigLoadResult<T>;\n\tupdatedAt: number;\n}\n\nclass RuntimeConfigDexie<T> extends Dexie {\n\tconfigs!: Table<RuntimeConfigRecord<T>, string>;\n\n\tconstructor(dbName: string) {\n\t\tsuper(dbName);\n\t\tthis.version(1).stores({\n\t\t\tconfigs: 'key,updatedAt',\n\t\t});\n\t}\n}\n\nexport class RuntimeConfigStore<T> implements RuntimeConfigStoreContract<T> {\n\tprivate readonly db?: RuntimeConfigDexie<T>;\n\tprivate readonly fallbackStore = new Map<string, RuntimeConfigLoadResult<T>>();\n\n\tconstructor(\n\t\tprivate readonly cacheName: string,\n\t\tappId?: string,\n\t\tindexedDbName: string = DEFAULT_DB_NAME,\n\t) {\n\t\tconst resolvedDbName = appId ? `${DEFAULT_DB_NAME}:${appId}` : indexedDbName;\n\t\tif (typeof indexedDB === 'undefined') {\n\t\t\tthis.db = undefined;\n\t\t\treturn;\n\t\t}\n\t\tthis.db = new RuntimeConfigDexie<T>(resolvedDbName);\n\t}\n\n\tasync get(key: string): Promise<RuntimeConfigLoadResult<T> | null> {\n\t\tif (!this.db) {\n\t\t\treturn this.fallbackStore.get(key) ?? null;\n\t\t}\n\t\tconst entry = await this.db.configs.get(this.buildKey(key));\n\t\treturn entry?.payload ?? null;\n\t}\n\n\tasync set(key: string, value: RuntimeConfigLoadResult<T>): Promise<void> {\n\t\tif (!this.db) {\n\t\t\tthis.fallbackStore.set(key, value);\n\t\t\treturn;\n\t\t}\n\t\tawait this.db.configs.put({\n\t\t\tkey: this.buildKey(key),\n\t\t\tpayload: value,\n\t\t\tupdatedAt: Date.now(),\n\t\t});\n\t}\n\n\tasync remove(key: string): Promise<void> {\n\t\tif (!this.db) {\n\t\t\tthis.fallbackStore.delete(key);\n\t\t\treturn;\n\t\t}\n\t\tawait this.db.configs.delete(this.buildKey(key));\n\t}\n\n\tprivate buildKey(key: string): string {\n\t\treturn `${this.cacheName}:${key}`;\n\t}\n}\n","import type { Observable, Subscription } from 'rxjs';\nimport type { RuntimeUpdateAdapterOptions, RuntimeUpdateEvent, RuntimeUpdateSource } from './types';\n\nexport type RuntimeUpdateHandler = (event: RuntimeUpdateEvent, source: RuntimeUpdateSource) => void;\n\nexport class RuntimeUpdateAdapter {\n\tprivate eventSource?: EventSource;\n\tprivate streamSubscription?: Subscription;\n\n\tconstructor(private readonly handler: RuntimeUpdateHandler) {}\n\n\tconnectSse(url: string, options: RuntimeUpdateAdapterOptions): void {\n\t\tthis.disconnectSse();\n\t\tthis.eventSource = new EventSource(url, { withCredentials: options.withCredentials });\n\t\tconst eventType = options.eventType ?? 'message';\n\t\tthis.eventSource.addEventListener(eventType, (event) => {\n\t\t\tconst message = event as MessageEvent;\n\t\t\tconst parsed = this.parseMessage(message, options);\n\t\t\tif (parsed) {\n\t\t\t\tthis.handler(parsed, 'sse');\n\t\t\t}\n\t\t});\n\t\tif (this.eventSource) {\n\t\t\tthis.eventSource.onerror = null;\n\t\t}\n\t\tthis.eventSource.addEventListener('error', () => {\n\t\t\toptions.logger?.debug('Runtime update stream disconnected', {\n\t\t\t\tcomponent: 'RuntimeUpdateAdapter',\n\t\t\t\taction: 'connectSse',\n\t\t\t\turl,\n\t\t\t});\n\t\t});\n\t}\n\n\tconnectStream(stream: Observable<RuntimeUpdateEvent>): void {\n\t\tthis.disconnectStream();\n\t\tthis.streamSubscription = stream.subscribe((event) => {\n\t\t\tthis.handler(event, 'stream');\n\t\t});\n\t}\n\n\tdisconnect(): void {\n\t\tthis.disconnectSse();\n\t\tthis.disconnectStream();\n\t}\n\n\tprivate disconnectSse(): void {\n\t\tif (this.eventSource) {\n\t\t\tthis.eventSource.close();\n\t\t\tthis.eventSource = undefined;\n\t\t}\n\t}\n\n\tprivate disconnectStream(): void {\n\t\tthis.streamSubscription?.unsubscribe();\n\t\tthis.streamSubscription = undefined;\n\t}\n\n\tprivate parseMessage(event: MessageEvent, options: RuntimeUpdateAdapterOptions): RuntimeUpdateEvent | null {\n\t\tif (options.transform) {\n\t\t\treturn options.transform(event);\n\t\t}\n\t\tif (!event.data) {\n\t\t\treturn { resource: options.resource } as RuntimeUpdateEvent;\n\t\t}\n\t\ttry {\n\t\t\tconst parsed = JSON.parse(event.data as string) as RuntimeUpdateEvent;\n\t\t\treturn parsed;\n\t\t} catch {\n\t\t\toptions.logger?.warn('Failed to parse runtime update event', {\n\t\t\t\tcomponent: 'RuntimeUpdateAdapter',\n\t\t\t\taction: 'parseMessage',\n\t\t\t});\n\t\t\treturn { resource: options.resource } as RuntimeUpdateEvent;\n\t\t}\n\t}\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;MAMa,iBAAiB,CAAA;AACA,IAAA,OAAA;AAA7B,IAAA,WAAA,CAA6B,UAA6B,EAAE,EAAA;QAA/B,IAAA,CAAA,OAAO,GAAP,OAAO;IAA2B;AAE/D,IAAA,MAAM,KAAK,CAAC,GAAW,EAAE,IAAkB,EAAA;QAC1C,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,CAAC;QACzC,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,IAAI,CAAC;QACnD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,IAAI,CAAC;QAC7C,IAAI,SAAS,GAAiB,IAAI;AAElC,QAAA,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,OAAO,EAAE,OAAO,IAAI,CAAC,EAAE;AACvD,YAAA,IAAI;gBACH,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,IAAI,EAAE,SAAS,CAAC;YACrD;YAAE,OAAO,KAAK,EAAE;AACf,gBAAA,SAAS,GAAG,KAAK,YAAY,KAAK,GAAG,KAAK,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACrE,IAAI,OAAO,GAAG,OAAO,IAAI,YAAY,GAAG,CAAC,EAAE;AAC1C,oBAAA,MAAM,IAAI,OAAO,CAAC,C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CAAC,CAAC;IACH;IAEA,UAAU,GAAA;QACT,IAAI,CAAC,aAAa,EAAE;QACpB,IAAI,CAAC,gBAAgB,EAAE;IACxB;IAEQ,aAAa,GAAA;AACpB,QAAA,IAAI,IAAI,CAAC,WAAW,EAAE;AACrB,YAAA,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE;AACxB,YAAA,IAAI,CAAC,WAAW,GAAG,SAAS;QAC7B;IACD;IAEQ,gBAAgB,GAAA;AACvB,QAAA,IAAI,CAAC,kBAAkB,EAAE,WAAW,EAAE;AACtC,QAAA,IAAI,CAAC,kBAAkB,GAAG,SAAS;IACpC;IAEQ,YAAY,CAAC,KAAmB,EAAE,OAAoC,EAAA;AAC7E,QAAA,IAAI,OAAO,CAAC,SAAS,EAAE;AACtB,YAAA,OAAO,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC;QAChC;AACA,QAAA,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;AAChB,YAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAwB;QAC5D;AACA,QAAA,IAAI;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAc,CAAuB;AACrE,YAAA,OAAO,MAAM;QACd;AAAE,QAAA,MAAM;AACP,YAAA,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,sCAAsC,EAAE;AAC5D,gBAAA,SAAS,EAAE,sBAAsB;AACjC,gBAAA,MAAM,EAAE,cAAc;AACtB,aAAA,CAAC;AACF,YAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAwB;QAC5D;IACD;AACA;;AC5ED;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"sixbell-telco-sdk-utils-runtime-config.mjs","sources":["../../../projects/sdk/utils/runtime-config/src/http-client.ts","../../../projects/sdk/utils/runtime-config/src/runtime-config-loader.ts","../../../projects/sdk/utils/runtime-config/src/runtime-config-store.ts","../../../projects/sdk/utils/runtime-config/src/runtime-update-adapter.ts","../../../projects/sdk/utils/runtime-config/sixbell-telco-sdk-utils-runtime-config.ts"],"sourcesContent":["export interface HttpClientOptions {\n\tretries?: number;\n\tretryDelayMs?: number;\n\ttimeoutMs?: number;\n\t/** HTTP statuses that fail at once, without retries (e.g. `[404]` for a file that does not exist). */\n\tnoRetryStatuses?: number[];\n}\n\n/** A response with a non-2xx status. `status` lets callers tell a missing file (404) from a failure. */\nexport class RuntimeHttpError extends Error {\n\tconstructor(\n\t\treadonly status: number,\n\t\tstatusText: string,\n\t) {\n\t\tsuper(`HTTP ${status}: ${statusText}`);\n\t\tthis.name = 'RuntimeHttpError';\n\t}\n}\n\nexport class RuntimeHttpClient {\n\tconstructor(private readonly options: HttpClientOptions = {}) {}\n\n\tasync fetch(url: string, init?: RequestInit): Promise<Response> {\n\t\tconst retries = this.options.retries ?? 0;\n\t\tconst retryDelayMs = this.options.retryDelayMs ?? 0;\n\t\tconst timeoutMs = this.options.timeoutMs ?? 0;\n\t\tlet lastError: Error | null = null;\n\n\t\tfor (let attempt = 0; attempt <= retries; attempt += 1) {\n\t\t\ttry {\n\t\t\t\treturn await this.attemptFetch(url, init, timeoutMs);\n\t\t\t} catch (error) {\n\t\t\t\tlastError = error instanceof Error ? error : new Error(String(error));\n\t\t\t\tif (error instanceof RuntimeHttpError && this.options.noRetryStatuses?.includes(error.status)) {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t\tif (attempt < retries && retryDelayMs > 0) {\n\t\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, retryDelayMs));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthrow lastError ?? new Error('Failed to fetch');\n\t}\n\n\tprivate async attemptFetch(url: string, init: RequestInit | undefined, timeoutMs: number): Promise<Response> {\n\t\tif (!timeoutMs || timeoutMs <= 0) {\n\t\t\tconst response = await fetch(url, init);\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow new RuntimeHttpError(response.status, response.statusText);\n\t\t\t}\n\t\t\treturn response;\n\t\t}\n\n\t\tconst controller = new AbortController();\n\t\tconst timeoutHandle = setTimeout(() => controller.abort(), timeoutMs);\n\t\ttry {\n\t\t\tconst response = await fetch(url, {\n\t\t\t\t...init,\n\t\t\t\tsignal: controller.signal,\n\t\t\t});\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow new RuntimeHttpError(response.status, response.statusText);\n\t\t\t}\n\t\t\treturn response;\n\t\t} finally {\n\t\t\tclearTimeout(timeoutHandle);\n\t\t}\n\t}\n}\n","import { RuntimeHttpClient } from './http-client';\nimport type { RuntimeConfigCheckResult, RuntimeConfigLoadResult, RuntimeConfigLoaderOptions, RuntimeConfigMeta } from './types';\n\nconst DEFAULT_RETRIES = 2;\nconst DEFAULT_RETRY_DELAY_MS = 400;\nconst DEFAULT_TIMEOUT_MS = 8000;\n\nexport class RuntimeConfigLoader<T> {\n\tprivate readonly httpClient: RuntimeHttpClient;\n\tprivate readonly parser: (response: Response) => Promise<T>;\n\tprivate readonly cacheKey: string;\n\n\tconstructor(\n\t\tprivate readonly configPath: string,\n\t\tprivate readonly options: RuntimeConfigLoaderOptions<T>,\n\t\tprivate readonly retries = DEFAULT_RETRIES,\n\t\tprivate readonly retryDelayMs = DEFAULT_RETRY_DELAY_MS,\n\t\tprivate readonly timeoutMs = DEFAULT_TIMEOUT_MS,\n\t) {\n\t\tthis.httpClient = new RuntimeHttpClient({\n\t\t\tretries: this.retries,\n\t\t\tretryDelayMs: this.retryDelayMs,\n\t\t\ttimeoutMs: this.timeoutMs,\n\t\t});\n\t\tthis.parser = options.parser ?? (async (response: Response) => (await response.json()) as T);\n\t\tthis.cacheKey = this.buildCacheKey();\n\t}\n\n\tasync loadLatest(): Promise<RuntimeConfigLoadResult<T>> {\n\t\tconst logger = this.options.logger;\n\t\tconst cached = await this.loadFromStore();\n\t\tif (cached) {\n\t\t\tlogger?.debug('Runtime config loaded from cache', {\n\t\t\t\tcomponent: 'RuntimeConfigLoader',\n\t\t\t\taction: 'loadLatest',\n\t\t\t\tresource: this.options.resource,\n\t\t\t\tconfigPath: this.configPath,\n\t\t\t\tmeta: cached.meta,\n\t\t\t});\n\t\t\treturn { ...cached, source: 'cache' };\n\t\t}\n\t\ttry {\n\t\t\tconst response = await this.fetchNoStore();\n\t\t\tconst data = await this.parser(response);\n\t\t\tconst meta = this.extractMeta(data);\n\t\t\tconst hash = await this.resolveHash(data, meta);\n\t\t\tconst result: RuntimeConfigLoadResult<T> = { data, meta, source: 'network', hash };\n\t\t\tawait this.storeResult(result);\n\t\t\tlogger?.debug('Runtime config loaded', {\n\t\t\t\tcomponent: 'RuntimeConfigLoader',\n\t\t\t\taction: 'loadLatest',\n\t\t\t\tresource: this.options.resource,\n\t\t\t\tconfigPath: this.configPath,\n\t\t\t\tmeta,\n\t\t\t});\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tlogger?.warn('Runtime config load failed, falling back', {\n\t\t\t\tcomponent: 'RuntimeConfigLoader',\n\t\t\t\taction: 'loadLatest',\n\t\t\t\tresource: this.options.resource,\n\t\t\t\tconfigPath: this.configPath,\n\t\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\t});\n\t\t\tconst fallback = this.options.fallbackData;\n\t\t\ttry {\n\t\t\t\tconst meta = this.extractMeta(fallback);\n\t\t\t\tconst hash = await this.resolveHash(fallback, meta);\n\t\t\t\treturn { data: fallback, meta, source: 'fallback', hash };\n\t\t\t} catch {\n\t\t\t\treturn { data: fallback, meta: {}, source: 'fallback', hash: '' };\n\t\t\t}\n\t\t}\n\t}\n\n\tasync checkForUpdates(currentHash: string): Promise<RuntimeConfigCheckResult> {\n\t\ttry {\n\t\t\tconst response = await this.fetchNoStore();\n\t\t\tconst data = await this.parser(response);\n\t\t\tconst meta = this.extractMeta(data);\n\t\t\tconst hash = await this.resolveHash(data, meta);\n\t\t\treturn { updated: hash !== currentHash, meta, hash };\n\t\t} catch {\n\t\t\treturn { updated: false, meta: {}, hash: currentHash };\n\t\t}\n\t}\n\n\tasync refresh(): Promise<RuntimeConfigLoadResult<T>> {\n\t\tconst response = await this.fetchNoStore();\n\t\tconst data = await this.parser(response);\n\t\tconst meta = this.extractMeta(data);\n\t\tconst hash = await this.resolveHash(data, meta);\n\t\tconst result: RuntimeConfigLoadResult<T> = { data, meta, source: 'network', hash };\n\t\tawait this.storeResult(result);\n\t\treturn result;\n\t}\n\n\tprivate async loadFromStore(): Promise<RuntimeConfigLoadResult<T> | null> {\n\t\tif (!this.options.store) {\n\t\t\treturn null;\n\t\t}\n\t\tconst cached = await this.options.store.get(this.cacheKey);\n\t\tif (!cached) {\n\t\t\treturn null;\n\t\t}\n\t\tif (this.options.schemaVersion) {\n\t\t\tconst cachedSchema = cached.meta.schemaVersion;\n\t\t\tif (cachedSchema !== this.options.schemaVersion) {\n\t\t\t\tawait this.options.store.remove(this.cacheKey);\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t\treturn cached;\n\t}\n\n\tprivate async storeResult(result: RuntimeConfigLoadResult<T>): Promise<void> {\n\t\tif (!this.options.store) {\n\t\t\treturn;\n\t\t}\n\t\tawait this.options.store.set(this.cacheKey, result);\n\t}\n\n\tprivate extractMeta(data: T): RuntimeConfigMeta {\n\t\tconst meta = (data as { meta?: RuntimeConfigMeta }).meta;\n\t\tif (!meta?.hash) {\n\t\t\tthrow new Error('Runtime config missing required meta.hash');\n\t\t}\n\t\treturn meta;\n\t}\n\n\tprivate async resolveHash(data: T, meta: RuntimeConfigMeta): Promise<string> {\n\t\treturn meta.hash ?? this.hashValue(data);\n\t}\n\n\tprivate async hashValue(data: T): Promise<string> {\n\t\tconst value = JSON.stringify(data);\n\t\tif (typeof crypto?.subtle?.digest === 'function') {\n\t\t\tconst encoded = new TextEncoder().encode(value);\n\t\t\tconst buffer = await crypto.subtle.digest('SHA-256', encoded);\n\t\t\treturn this.bufferToHex(buffer);\n\t\t}\n\t\tlet hash = 0;\n\t\tfor (let i = 0; i < value.length; i += 1) {\n\t\t\thash = (hash * 31 + value.charCodeAt(i)) >>> 0;\n\t\t}\n\t\treturn `fallback-${hash.toString(16)}`;\n\t}\n\n\tprivate bufferToHex(buffer: ArrayBuffer): string {\n\t\tconst bytes = new Uint8Array(buffer);\n\t\tlet hex = '';\n\t\tfor (const byte of bytes) {\n\t\t\thex += byte.toString(16).padStart(2, '0');\n\t\t}\n\t\treturn hex;\n\t}\n\n\tprivate buildCacheKey(): string {\n\t\tconst prefix = this.options.appId ? `${this.options.appId}:` : '';\n\t\tconst schema = this.options.schemaVersion ? `:schema:${this.options.schemaVersion}` : '';\n\t\treturn `${prefix}${this.options.resource}:${this.configPath}${schema}`;\n\t}\n\n\tprivate async fetchNoStore(): Promise<Response> {\n\t\treturn this.httpClient.fetch(this.configPath, { cache: 'no-store' });\n\t}\n}\n","import Dexie, { Table } from 'dexie';\nimport type { RuntimeConfigLoadResult, RuntimeConfigStoreContract } from './types';\n\nconst DEFAULT_DB_NAME = 'sixbell-runtime-config';\n\ninterface RuntimeConfigRecord<T> {\n\tkey: string;\n\tpayload: RuntimeConfigLoadResult<T>;\n\tupdatedAt: number;\n}\n\nclass RuntimeConfigDexie<T> extends Dexie {\n\tconfigs!: Table<RuntimeConfigRecord<T>, string>;\n\n\tconstructor(dbName: string) {\n\t\tsuper(dbName);\n\t\tthis.version(1).stores({\n\t\t\tconfigs: 'key,updatedAt',\n\t\t});\n\t}\n}\n\nexport class RuntimeConfigStore<T> implements RuntimeConfigStoreContract<T> {\n\tprivate readonly db?: RuntimeConfigDexie<T>;\n\tprivate readonly fallbackStore = new Map<string, RuntimeConfigLoadResult<T>>();\n\n\tconstructor(\n\t\tprivate readonly cacheName: string,\n\t\tappId?: string,\n\t\tindexedDbName: string = DEFAULT_DB_NAME,\n\t) {\n\t\tconst resolvedDbName = appId ? `${DEFAULT_DB_NAME}:${appId}` : indexedDbName;\n\t\tif (typeof indexedDB === 'undefined') {\n\t\t\tthis.db = undefined;\n\t\t\treturn;\n\t\t}\n\t\tthis.db = new RuntimeConfigDexie<T>(resolvedDbName);\n\t}\n\n\tasync get(key: string): Promise<RuntimeConfigLoadResult<T> | null> {\n\t\tif (!this.db) {\n\t\t\treturn this.fallbackStore.get(key) ?? null;\n\t\t}\n\t\tconst entry = await this.db.configs.get(this.buildKey(key));\n\t\treturn entry?.payload ?? null;\n\t}\n\n\tasync set(key: string, value: RuntimeConfigLoadResult<T>): Promise<void> {\n\t\tif (!this.db) {\n\t\t\tthis.fallbackStore.set(key, value);\n\t\t\treturn;\n\t\t}\n\t\tawait this.db.configs.put({\n\t\t\tkey: this.buildKey(key),\n\t\t\tpayload: value,\n\t\t\tupdatedAt: Date.now(),\n\t\t});\n\t}\n\n\tasync remove(key: string): Promise<void> {\n\t\tif (!this.db) {\n\t\t\tthis.fallbackStore.delete(key);\n\t\t\treturn;\n\t\t}\n\t\tawait this.db.configs.delete(this.buildKey(key));\n\t}\n\n\tprivate buildKey(key: string): string {\n\t\treturn `${this.cacheName}:${key}`;\n\t}\n}\n","import type { Observable, Subscription } from 'rxjs';\nimport type { RuntimeUpdateAdapterOptions, RuntimeUpdateEvent, RuntimeUpdateSource } from './types';\n\nexport type RuntimeUpdateHandler = (event: RuntimeUpdateEvent, source: RuntimeUpdateSource) => void;\n\nexport class RuntimeUpdateAdapter {\n\tprivate eventSource?: EventSource;\n\tprivate streamSubscription?: Subscription;\n\n\tconstructor(private readonly handler: RuntimeUpdateHandler) {}\n\n\tconnectSse(url: string, options: RuntimeUpdateAdapterOptions): void {\n\t\tthis.disconnectSse();\n\t\tthis.eventSource = new EventSource(url, { withCredentials: options.withCredentials });\n\t\tconst eventType = options.eventType ?? 'message';\n\t\tthis.eventSource.addEventListener(eventType, (event) => {\n\t\t\tconst message = event as MessageEvent;\n\t\t\tconst parsed = this.parseMessage(message, options);\n\t\t\tif (parsed) {\n\t\t\t\tthis.handler(parsed, 'sse');\n\t\t\t}\n\t\t});\n\t\tif (this.eventSource) {\n\t\t\tthis.eventSource.onerror = null;\n\t\t}\n\t\tthis.eventSource.addEventListener('error', () => {\n\t\t\toptions.logger?.debug('Runtime update stream disconnected', {\n\t\t\t\tcomponent: 'RuntimeUpdateAdapter',\n\t\t\t\taction: 'connectSse',\n\t\t\t\turl,\n\t\t\t});\n\t\t});\n\t}\n\n\tconnectStream(stream: Observable<RuntimeUpdateEvent>): void {\n\t\tthis.disconnectStream();\n\t\tthis.streamSubscription = stream.subscribe((event) => {\n\t\t\tthis.handler(event, 'stream');\n\t\t});\n\t}\n\n\tdisconnect(): void {\n\t\tthis.disconnectSse();\n\t\tthis.disconnectStream();\n\t}\n\n\tprivate disconnectSse(): void {\n\t\tif (this.eventSource) {\n\t\t\tthis.eventSource.close();\n\t\t\tthis.eventSource = undefined;\n\t\t}\n\t}\n\n\tprivate disconnectStream(): void {\n\t\tthis.streamSubscription?.unsubscribe();\n\t\tthis.streamSubscription = undefined;\n\t}\n\n\tprivate parseMessage(event: MessageEvent, options: RuntimeUpdateAdapterOptions): RuntimeUpdateEvent | null {\n\t\tif (options.transform) {\n\t\t\treturn options.transform(event);\n\t\t}\n\t\tif (!event.data) {\n\t\t\treturn { resource: options.resource } as RuntimeUpdateEvent;\n\t\t}\n\t\ttry {\n\t\t\tconst parsed = JSON.parse(event.data as string) as RuntimeUpdateEvent;\n\t\t\treturn parsed;\n\t\t} catch {\n\t\t\toptions.logger?.warn('Failed to parse runtime update event', {\n\t\t\t\tcomponent: 'RuntimeUpdateAdapter',\n\t\t\t\taction: 'parseMessage',\n\t\t\t});\n\t\t\treturn { resource: options.resource } as RuntimeUpdateEvent;\n\t\t}\n\t}\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AAQA;AACM,MAAO,gBAAiB,SAAQ,KAAK,CAAA;AAEhC,IAAA,MAAA;IADV,WAAA,CACU,MAAc,EACvB,UAAkB,EAAA;AAElB,QAAA,KAAK,CAAC,CAAA,KAAA,EAAQ,MAAM,KAAK,UAAU,CAAA,CAAE,CAAC;QAH7B,IAAA,C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GAAG,SAAS;QAC7B;IACD;IAEQ,gBAAgB,GAAA;AACvB,QAAA,IAAI,CAAC,kBAAkB,EAAE,WAAW,EAAE;AACtC,QAAA,IAAI,CAAC,kBAAkB,GAAG,SAAS;IACpC;IAEQ,YAAY,CAAC,KAAmB,EAAE,OAAoC,EAAA;AAC7E,QAAA,IAAI,OAAO,CAAC,SAAS,EAAE;AACtB,YAAA,OAAO,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC;QAChC;AACA,QAAA,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;AAChB,YAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAwB;QAC5D;AACA,QAAA,IAAI;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAc,CAAuB;AACrE,YAAA,OAAO,MAAM;QACd;AAAE,QAAA,MAAM;AACP,YAAA,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,sCAAsC,EAAE;AAC5D,gBAAA,SAAS,EAAE,sBAAsB;AACjC,gBAAA,MAAM,EAAE,cAAc;AACtB,aAAA,CAAC;AACF,YAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAwB;QAC5D;IACD;AACA;;AC5ED;;AAEG;;;;"}
|
|
@@ -70,9 +70,13 @@ class FakeTranslationService {
|
|
|
70
70
|
this.setLanguage(this.currentLanguage());
|
|
71
71
|
this.translationTick.update((value) => value + 1);
|
|
72
72
|
}
|
|
73
|
+
/** @deprecated No effect, as in `TranslationService`. */
|
|
73
74
|
enablePrefetch() {
|
|
74
75
|
// Translations are in memory; there is nothing to prefetch.
|
|
75
76
|
}
|
|
77
|
+
async addTranslationPaths() {
|
|
78
|
+
// Translations are in memory; there are no files to add.
|
|
79
|
+
}
|
|
76
80
|
async refreshInactiveLanguages() {
|
|
77
81
|
// Translations are in memory; there is nothing to reload.
|
|
78
82
|
}
|
|
@@ -100,7 +104,7 @@ class FakeTranslationService {
|
|
|
100
104
|
return this.localeConfig().defaultLocale ?? this.defaultLanguage;
|
|
101
105
|
}
|
|
102
106
|
getAvailableLanguages() {
|
|
103
|
-
return
|
|
107
|
+
return this.getAvailableLanguageCodes();
|
|
104
108
|
}
|
|
105
109
|
getDefaultLanguage() {
|
|
106
110
|
return this.defaultLanguage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sixbell-telco-sdk-utils-translation-testing.mjs","sources":["../../../projects/sdk/utils/translation/testing/src/translation-testing.ts","../../../projects/sdk/utils/translation/testing/sixbell-telco-sdk-utils-translation-testing.ts"],"sourcesContent":["import { computed, DestroyRef, inject, Injectable, InjectionToken, Provider, signal } from '@angular/core';\nimport { provideTranslateService, TranslateLoader, TranslateService, TranslationObject } from '@ngx-translate/core';\nimport type { RuntimeConfigLoader, RuntimeConfigLoadResult, RuntimeUpdateEvent } from '@sixbell-telco/sdk/utils/runtime-config';\nimport {\n\textendDefaultLanguages,\n\tLanguageDefinition,\n\tTranslationConfig,\n\tTranslationLocaleConfig,\n\tTranslationService,\n} from '@sixbell-telco/sdk/utils/translation';\nimport { Observable, of } from 'rxjs';\n\n/** Translations per language code, for example `{ en: { sdk: { close: 'Close' } }, es: { sdk: { close: 'Cerrar' } } }`. */\nexport type TranslationTestingBundles = Record<string, TranslationObject>;\n\nexport interface TranslationTestingOptions {\n\t/** In-memory translations per language. */\n\ttranslations: TranslationTestingBundles;\n\t/** Active language at start. Defaults to the first language in `translations`, or `en`. */\n\tlang?: string;\n\t/** Language used for keys missing in the active one. Defaults to `lang`. */\n\tfallbackLang?: string;\n\t/** Languages `TranslationService` reports as available. Defaults to the languages in `translations`. */\n\tlanguages?: LanguageDefinition[];\n\t/** Locale mapping returned by `TranslationService.resolveLocale()`. */\n\tlocale?: TranslationLocaleConfig;\n}\n\nexport const TRANSLATION_TESTING_OPTIONS = new InjectionToken<TranslationTestingOptions>('TRANSLATION_TESTING_OPTIONS');\n\n/** Serves translations from memory, synchronously, so `use()` switches language within the same tick. */\nexport class InMemoryTranslateLoader implements TranslateLoader {\n\tconstructor(private readonly translations: TranslationTestingBundles) {}\n\n\tgetTranslation(lang: string): Observable<TranslationObject> {\n\t\treturn of(this.translations[lang] ?? {});\n\t}\n}\n\ntype TranslationServiceApi = { [K in keyof TranslationService]: TranslationService[K] };\n\nconst resolveLang = (options: TranslationTestingOptions): string => options.lang ?? Object.keys(options.translations)[0] ?? 'en';\n\nconst resolveLanguages = (options: TranslationTestingOptions): LanguageDefinition[] => {\n\tif (options.languages) {\n\t\treturn [...options.languages];\n\t}\n\tconst known = extendDefaultLanguages([]);\n\tconst codes = Object.keys(options.translations);\n\treturn (codes.length ? codes : [resolveLang(options)]).map((code) => known.find((language) => language.code === code) ?? { code, name: code });\n};\n\n/**\n * Test double for the SDK `TranslationService` with its full public API. It delegates to the real ngx-translate\n * `TranslateService`, so `instant()` reads the active language when it is called, `{{param}}` placeholders are\n * interpolated, and switching language emits `onLangChange`. Runtime-config methods resolve without network access.\n */\n@Injectable()\nexport class FakeTranslationService implements TranslationServiceApi {\n\tprivate readonly translate = inject(TranslateService);\n\tprivate readonly options = inject(TRANSLATION_TESTING_OPTIONS);\n\tprivate readonly translationTick = signal(0);\n\tprivate languages = resolveLanguages(this.options);\n\tprivate defaultLanguage = resolveLang(this.options);\n\tprivate readonly localeConfig = signal<TranslationLocaleConfig>(this.options.locale ?? {});\n\n\tpublic readonly updateAvailable = signal(false);\n\tpublic readonly lastRefreshFailed = signal(false);\n\tpublic readonly currentLanguage = signal<string>(this.translate.getCurrentLang() ?? this.defaultLanguage);\n\tpublic readonly currentLocale = computed(() => this.resolveLocale(this.currentLanguage()));\n\tpublic readonly onLanguageChange$ = this.translate.onLangChange;\n\tpublic readonly onLanguageChange = signal<number>(0);\n\tpublic readonly ready = signal(true);\n\tpublic readonly changes = computed(() => this.translationTick());\n\n\tconstructor() {\n\t\tconst subscription = this.translate.onLangChange.subscribe(({ lang }) => {\n\t\t\tthis.currentLanguage.set(lang);\n\t\t\tthis.onLanguageChange.update((value) => value + 1);\n\t\t\tthis.translationTick.update((value) => value + 1);\n\t\t});\n\t\tinject(DestroyRef).onDestroy(() => subscription.unsubscribe());\n\t}\n\n\tconfigure(config: TranslationConfig): void {\n\t\tlet languages = [...this.languages, ...(config.additionalLanguages ?? [])];\n\t\tif (config.excludeLanguages) {\n\t\t\tlanguages = languages.filter((language) => !config.excludeLanguages?.includes(language.code));\n\t\t}\n\t\tthis.languages = languages;\n\t\tif (config.defaultLang) {\n\t\t\tthis.defaultLanguage = config.defaultLang;\n\t\t}\n\t\tif (config.locale) {\n\t\t\tthis.localeConfig.set(config.locale);\n\t\t}\n\t}\n\n\tasync setRuntimeConfig(config: TranslationConfig): Promise<void> {\n\t\tthis.configure(config);\n\t\tthis.setLanguage(this.currentLanguage());\n\t\tthis.translationTick.update((value) => value + 1);\n\t}\n\n\tenablePrefetch(): void {\n\t\t// Translations are in memory; there is nothing to prefetch.\n\t}\n\n\tasync refreshInactiveLanguages(): Promise<void> {\n\t\t// Translations are in memory; there is nothing to reload.\n\t}\n\n\tsetLanguage(lang: string): void {\n\t\tif (!lang) {\n\t\t\treturn;\n\t\t}\n\t\tconst target = this.getAvailableLanguageCodes().includes(lang) ? lang : this.defaultLanguage;\n\t\tthis.translate.use(target);\n\t}\n\n\tgetCurrentLanguage(): string {\n\t\treturn this.translate.getCurrentLang() ?? this.defaultLanguage;\n\t}\n\n\tgetCurrentLocale(): string {\n\t\treturn this.currentLocale();\n\t}\n\n\tgetLocaleConfig(): TranslationLocaleConfig {\n\t\treturn this.localeConfig();\n\t}\n\n\tresolveLocale(language?: string | null): string {\n\t\tconst normalized = language?.trim();\n\t\tif (normalized) {\n\t\t\treturn this.localeConfig().languageToLocale?.[normalized] ?? normalized;\n\t\t}\n\t\treturn this.localeConfig().defaultLocale ?? this.defaultLanguage;\n\t}\n\n\tgetAvailableLanguages(): string[] {\n\t\treturn [...this.translate.getLangs()];\n\t}\n\n\tgetDefaultLanguage(): string {\n\t\treturn this.defaultLanguage;\n\t}\n\n\tinstant(key: string, params?: object): string {\n\t\treturn this.translate.instant(key, params);\n\t}\n\n\tget(key: string, params?: object) {\n\t\treturn this.translate.get(key, params);\n\t}\n\n\tstream(key: string, params?: object) {\n\t\treturn this.translate.stream(key, params);\n\t}\n\n\tgetAvailableLanguagesConfig(): LanguageDefinition[] {\n\t\treturn this.languages;\n\t}\n\n\tgetAvailableLanguageCodes(): string[] {\n\t\treturn this.languages.map((language) => language.code);\n\t}\n\n\tgetLanguageByCode(code: string): LanguageDefinition | undefined {\n\t\treturn this.languages.find((language) => language.code === code);\n\t}\n\n\tgetLanguageDisplayName(code: string): string {\n\t\treturn this.getLanguageByCode(code)?.name ?? code.toUpperCase();\n\t}\n\n\tgetLocalizedLanguageName(code: string): string {\n\t\tconst key = `sdk.language.languages.${code}`;\n\t\tconst translated = this.translate.instant(key);\n\t\treturn translated && translated !== key ? translated : this.getLanguageDisplayName(code);\n\t}\n\n\tisReady() {\n\t\treturn this.ready.asReadonly();\n\t}\n\n\tasync waitForTranslations(): Promise<void> {\n\t\t// Translations are in memory and always ready.\n\t}\n\n\tinit(): void {\n\t\t// The constructor already follows language changes.\n\t}\n\n\tasync applyRuntimeConfig(result: RuntimeConfigLoadResult<TranslationConfig>): Promise<void> {\n\t\tawait this.setRuntimeConfig(result.data);\n\t}\n\n\tsetRuntimeLoader(): void {\n\t\tthis.updateAvailable.set(false);\n\t\tthis.lastRefreshFailed.set(false);\n\t}\n\n\tasync checkForTranslationUpdates(_loader: RuntimeConfigLoader<TranslationConfig>, event?: RuntimeUpdateEvent): Promise<void> {\n\t\tif (!event?.resource || event.resource === 'translation' || event.resource === 'both') {\n\t\t\tthis.updateAvailable.set(true);\n\t\t}\n\t}\n\n\tasync refreshTranslation(): Promise<void> {\n\t\tthis.updateAvailable.set(false);\n\t\tthis.translationTick.update((value) => value + 1);\n\t}\n\n\twithTranslationsReady<T>(fn: () => T): T | undefined {\n\t\tthis.changes();\n\t\treturn this.ready() ? fn() : undefined;\n\t}\n\n\tcreateTranslateLoader(): TranslateLoader {\n\t\treturn new InMemoryTranslateLoader(this.options.translations);\n\t}\n}\n\n/**\n * Providers for specs: the real ngx-translate `TranslateService` fed from memory, and `FakeTranslationService`\n * for the SDK `TranslationService`. Switch language with either service and assert the re-rendered labels.\n *\n * @example\n * ```ts\n * TestBed.configureTestingModule({\n * providers: [provideTranslationTesting({ translations: { en: { greet: 'Hi {{name}}' }, es: { greet: 'Hola {{name}}' } } })],\n * });\n * TestBed.inject(TranslationService).setLanguage('es');\n * ```\n */\nexport function provideTranslationTesting(options: TranslationTestingOptions): Provider[] {\n\tconst lang = resolveLang(options);\n\treturn [\n\t\t{ provide: TRANSLATION_TESTING_OPTIONS, useValue: options },\n\t\tprovideTranslateService({\n\t\t\tlang,\n\t\t\tfallbackLang: options.fallbackLang ?? lang,\n\t\t\tloader: { provide: TranslateLoader, useValue: new InMemoryTranslateLoader(options.translations) },\n\t\t}),\n\t\tFakeTranslationService,\n\t\t{ provide: TranslationService, useExisting: FakeTranslationService },\n\t];\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;MA4Ba,2BAA2B,GAAG,IAAI,cAAc,CAA4B,6BAA6B;AAEtH;MACa,uBAAuB,CAAA;AACN,IAAA,YAAA;AAA7B,IAAA,WAAA,CAA6B,YAAuC,EAAA;QAAvC,IAAA,CAAA,YAAY,GAAZ,YAAY;IAA8B;AAEvE,IAAA,cAAc,CAAC,IAAY,EAAA;QAC1B,OAAO,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IACzC;AACA;AAID,MAAM,WAAW,GAAG,CAAC,OAAkC,KAAa,OAAO,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI;AAEhI,MAAM,gBAAgB,GAAG,CAAC,OAAkC,KAA0B;A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A,EAAA,CAAA;kBADlC;;AAuKD;;;;;;;;;;;AAWG;AACG,SAAU,yBAAyB,CAAC,OAAkC,EAAA;AAC3E,IAAA,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC;IACjC,OAAO;AACN,QAAA,EAAE,OAAO,EAAE,2BAA2B,EAAE,QAAQ,EAAE,OAAO,EAAE;AAC3D,QAAA,uBAAuB,CAAC;YACvB,IAAI;AACJ,YAAA,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,IAAI;AAC1C,YAAA,MAAM,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,IAAI,uBAAuB,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE;SACjG,CAAC;QACF,sBAAsB;AACtB,QAAA,EAAE,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,sBAAsB,EAAE;KACpE;AACF;;ACxPA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"sixbell-telco-sdk-utils-translation-testing.mjs","sources":["../../../projects/sdk/utils/translation/testing/src/translation-testing.ts","../../../projects/sdk/utils/translation/testing/sixbell-telco-sdk-utils-translation-testing.ts"],"sourcesContent":["import { computed, DestroyRef, inject, Injectable, InjectionToken, Provider, signal } from '@angular/core';\nimport { provideTranslateService, TranslateLoader, TranslateService, TranslationObject } from '@ngx-translate/core';\nimport type { RuntimeConfigLoader, RuntimeConfigLoadResult, RuntimeUpdateEvent } from '@sixbell-telco/sdk/utils/runtime-config';\nimport {\n\textendDefaultLanguages,\n\tLanguageDefinition,\n\tTranslationConfig,\n\tTranslationLocaleConfig,\n\tTranslationService,\n} from '@sixbell-telco/sdk/utils/translation';\nimport { Observable, of } from 'rxjs';\n\n/** Translations per language code, for example `{ en: { sdk: { close: 'Close' } }, es: { sdk: { close: 'Cerrar' } } }`. */\nexport type TranslationTestingBundles = Record<string, TranslationObject>;\n\nexport interface TranslationTestingOptions {\n\t/** In-memory translations per language. */\n\ttranslations: TranslationTestingBundles;\n\t/** Active language at start. Defaults to the first language in `translations`, or `en`. */\n\tlang?: string;\n\t/** Language used for keys missing in the active one. Defaults to `lang`. */\n\tfallbackLang?: string;\n\t/** Languages `TranslationService` reports as available. Defaults to the languages in `translations`. */\n\tlanguages?: LanguageDefinition[];\n\t/** Locale mapping returned by `TranslationService.resolveLocale()`. */\n\tlocale?: TranslationLocaleConfig;\n}\n\nexport const TRANSLATION_TESTING_OPTIONS = new InjectionToken<TranslationTestingOptions>('TRANSLATION_TESTING_OPTIONS');\n\n/** Serves translations from memory, synchronously, so `use()` switches language within the same tick. */\nexport class InMemoryTranslateLoader implements TranslateLoader {\n\tconstructor(private readonly translations: TranslationTestingBundles) {}\n\n\tgetTranslation(lang: string): Observable<TranslationObject> {\n\t\treturn of(this.translations[lang] ?? {});\n\t}\n}\n\ntype TranslationServiceApi = { [K in keyof TranslationService]: TranslationService[K] };\n\nconst resolveLang = (options: TranslationTestingOptions): string => options.lang ?? Object.keys(options.translations)[0] ?? 'en';\n\nconst resolveLanguages = (options: TranslationTestingOptions): LanguageDefinition[] => {\n\tif (options.languages) {\n\t\treturn [...options.languages];\n\t}\n\tconst known = extendDefaultLanguages([]);\n\tconst codes = Object.keys(options.translations);\n\treturn (codes.length ? codes : [resolveLang(options)]).map((code) => known.find((language) => language.code === code) ?? { code, name: code });\n};\n\n/**\n * Test double for the SDK `TranslationService` with its full public API. It delegates to the real ngx-translate\n * `TranslateService`, so `instant()` reads the active language when it is called, `{{param}}` placeholders are\n * interpolated, and switching language emits `onLangChange`. Runtime-config methods resolve without network access.\n */\n@Injectable()\nexport class FakeTranslationService implements TranslationServiceApi {\n\tprivate readonly translate = inject(TranslateService);\n\tprivate readonly options = inject(TRANSLATION_TESTING_OPTIONS);\n\tprivate readonly translationTick = signal(0);\n\tprivate languages = resolveLanguages(this.options);\n\tprivate defaultLanguage = resolveLang(this.options);\n\tprivate readonly localeConfig = signal<TranslationLocaleConfig>(this.options.locale ?? {});\n\n\tpublic readonly updateAvailable = signal(false);\n\tpublic readonly lastRefreshFailed = signal(false);\n\tpublic readonly currentLanguage = signal<string>(this.translate.getCurrentLang() ?? this.defaultLanguage);\n\tpublic readonly currentLocale = computed(() => this.resolveLocale(this.currentLanguage()));\n\tpublic readonly onLanguageChange$ = this.translate.onLangChange;\n\tpublic readonly onLanguageChange = signal<number>(0);\n\tpublic readonly ready = signal(true);\n\tpublic readonly changes = computed(() => this.translationTick());\n\n\tconstructor() {\n\t\tconst subscription = this.translate.onLangChange.subscribe(({ lang }) => {\n\t\t\tthis.currentLanguage.set(lang);\n\t\t\tthis.onLanguageChange.update((value) => value + 1);\n\t\t\tthis.translationTick.update((value) => value + 1);\n\t\t});\n\t\tinject(DestroyRef).onDestroy(() => subscription.unsubscribe());\n\t}\n\n\tconfigure(config: TranslationConfig): void {\n\t\tlet languages = [...this.languages, ...(config.additionalLanguages ?? [])];\n\t\tif (config.excludeLanguages) {\n\t\t\tlanguages = languages.filter((language) => !config.excludeLanguages?.includes(language.code));\n\t\t}\n\t\tthis.languages = languages;\n\t\tif (config.defaultLang) {\n\t\t\tthis.defaultLanguage = config.defaultLang;\n\t\t}\n\t\tif (config.locale) {\n\t\t\tthis.localeConfig.set(config.locale);\n\t\t}\n\t}\n\n\tasync setRuntimeConfig(config: TranslationConfig): Promise<void> {\n\t\tthis.configure(config);\n\t\tthis.setLanguage(this.currentLanguage());\n\t\tthis.translationTick.update((value) => value + 1);\n\t}\n\n\t/** @deprecated No effect, as in `TranslationService`. */\n\tenablePrefetch(): void {\n\t\t// Translations are in memory; there is nothing to prefetch.\n\t}\n\n\tasync addTranslationPaths(): Promise<void> {\n\t\t// Translations are in memory; there are no files to add.\n\t}\n\n\tasync refreshInactiveLanguages(): Promise<void> {\n\t\t// Translations are in memory; there is nothing to reload.\n\t}\n\n\tsetLanguage(lang: string): void {\n\t\tif (!lang) {\n\t\t\treturn;\n\t\t}\n\t\tconst target = this.getAvailableLanguageCodes().includes(lang) ? lang : this.defaultLanguage;\n\t\tthis.translate.use(target);\n\t}\n\n\tgetCurrentLanguage(): string {\n\t\treturn this.translate.getCurrentLang() ?? this.defaultLanguage;\n\t}\n\n\tgetCurrentLocale(): string {\n\t\treturn this.currentLocale();\n\t}\n\n\tgetLocaleConfig(): TranslationLocaleConfig {\n\t\treturn this.localeConfig();\n\t}\n\n\tresolveLocale(language?: string | null): string {\n\t\tconst normalized = language?.trim();\n\t\tif (normalized) {\n\t\t\treturn this.localeConfig().languageToLocale?.[normalized] ?? normalized;\n\t\t}\n\t\treturn this.localeConfig().defaultLocale ?? this.defaultLanguage;\n\t}\n\n\tgetAvailableLanguages(): string[] {\n\t\treturn this.getAvailableLanguageCodes();\n\t}\n\n\tgetDefaultLanguage(): string {\n\t\treturn this.defaultLanguage;\n\t}\n\n\tinstant(key: string, params?: object): string {\n\t\treturn this.translate.instant(key, params);\n\t}\n\n\tget(key: string, params?: object) {\n\t\treturn this.translate.get(key, params);\n\t}\n\n\tstream(key: string, params?: object) {\n\t\treturn this.translate.stream(key, params);\n\t}\n\n\tgetAvailableLanguagesConfig(): LanguageDefinition[] {\n\t\treturn this.languages;\n\t}\n\n\tgetAvailableLanguageCodes(): string[] {\n\t\treturn this.languages.map((language) => language.code);\n\t}\n\n\tgetLanguageByCode(code: string): LanguageDefinition | undefined {\n\t\treturn this.languages.find((language) => language.code === code);\n\t}\n\n\tgetLanguageDisplayName(code: string): string {\n\t\treturn this.getLanguageByCode(code)?.name ?? code.toUpperCase();\n\t}\n\n\tgetLocalizedLanguageName(code: string): string {\n\t\tconst key = `sdk.language.languages.${code}`;\n\t\tconst translated = this.translate.instant(key);\n\t\treturn translated && translated !== key ? translated : this.getLanguageDisplayName(code);\n\t}\n\n\tisReady() {\n\t\treturn this.ready.asReadonly();\n\t}\n\n\tasync waitForTranslations(): Promise<void> {\n\t\t// Translations are in memory and always ready.\n\t}\n\n\tinit(): void {\n\t\t// The constructor already follows language changes.\n\t}\n\n\tasync applyRuntimeConfig(result: RuntimeConfigLoadResult<TranslationConfig>): Promise<void> {\n\t\tawait this.setRuntimeConfig(result.data);\n\t}\n\n\tsetRuntimeLoader(): void {\n\t\tthis.updateAvailable.set(false);\n\t\tthis.lastRefreshFailed.set(false);\n\t}\n\n\tasync checkForTranslationUpdates(_loader: RuntimeConfigLoader<TranslationConfig>, event?: RuntimeUpdateEvent): Promise<void> {\n\t\tif (!event?.resource || event.resource === 'translation' || event.resource === 'both') {\n\t\t\tthis.updateAvailable.set(true);\n\t\t}\n\t}\n\n\tasync refreshTranslation(): Promise<void> {\n\t\tthis.updateAvailable.set(false);\n\t\tthis.translationTick.update((value) => value + 1);\n\t}\n\n\twithTranslationsReady<T>(fn: () => T): T | undefined {\n\t\tthis.changes();\n\t\treturn this.ready() ? fn() : undefined;\n\t}\n\n\tcreateTranslateLoader(): TranslateLoader {\n\t\treturn new InMemoryTranslateLoader(this.options.translations);\n\t}\n}\n\n/**\n * Providers for specs: the real ngx-translate `TranslateService` fed from memory, and `FakeTranslationService`\n * for the SDK `TranslationService`. Switch language with either service and assert the re-rendered labels.\n *\n * @example\n * ```ts\n * TestBed.configureTestingModule({\n * providers: [provideTranslationTesting({ translations: { en: { greet: 'Hi {{name}}' }, es: { greet: 'Hola {{name}}' } } })],\n * });\n * TestBed.inject(TranslationService).setLanguage('es');\n * ```\n */\nexport function provideTranslationTesting(options: TranslationTestingOptions): Provider[] {\n\tconst lang = resolveLang(options);\n\treturn [\n\t\t{ provide: TRANSLATION_TESTING_OPTIONS, useValue: options },\n\t\tprovideTranslateService({\n\t\t\tlang,\n\t\t\tfallbackLang: options.fallbackLang ?? lang,\n\t\t\tloader: { provide: TranslateLoader, useValue: new InMemoryTranslateLoader(options.translations) },\n\t\t}),\n\t\tFakeTranslationService,\n\t\t{ provide: TranslationService, useExisting: FakeTranslationService },\n\t];\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;MA4Ba,2BAA2B,GAAG,IAAI,cAAc,CAA4B,6BAA6B;AAEtH;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