orcas-angular 1.0.4 → 1.0.6

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.
Files changed (37) hide show
  1. package/fesm2022/orcas-angular.mjs +1608 -0
  2. package/fesm2022/orcas-angular.mjs.map +1 -0
  3. package/package.json +39 -36
  4. package/types/orcas-angular.d.ts +460 -0
  5. package/.claude/settings.local.json +0 -8
  6. package/async/async.ts +0 -16
  7. package/async/cancellation-token.ts +0 -90
  8. package/dev/console-hook.ts +0 -25
  9. package/dev/debug.service.ts.example +0 -29
  10. package/framework/services-init.ts +0 -25
  11. package/index.ts +0 -25
  12. package/localization/localization.interface.ts +0 -18
  13. package/localization/localization.service.ts +0 -131
  14. package/localization/localize.pipe.ts +0 -30
  15. package/log/echo-provider.ts +0 -27
  16. package/log/echo.ts +0 -635
  17. package/log/index.ts +0 -6
  18. package/log/log-systems.ts +0 -20
  19. package/navigation/back-on-click.directive.ts +0 -19
  20. package/navigation/index.ts +0 -3
  21. package/navigation/navigation-stack.service.ts +0 -33
  22. package/ng-package.json +0 -7
  23. package/storage/capacitor-files.service.ts +0 -38
  24. package/storage/file-box.service.ts +0 -112
  25. package/storage/files.ts +0 -42
  26. package/storage/key-signals.ts +0 -49
  27. package/storage/local-storage-files.service.ts +0 -49
  28. package/storage/settings-signals.service.ts +0 -24
  29. package/storage/settings.service.ts +0 -24
  30. package/storage/tauri-files.service.ts +0 -69
  31. package/theme/theme.service.ts +0 -33
  32. package/tsconfig.lib.json +0 -11
  33. package/ui/context-menu/context-button.component.ts +0 -55
  34. package/ui/context-menu/context-header.component.ts +0 -15
  35. package/ui/context-menu/context-menu-trigger.directive.ts +0 -26
  36. package/ui/context-menu/context-menu.component.ts +0 -95
  37. package/ui/context-menu/index.ts +0 -4
@@ -1,18 +0,0 @@
1
- import {Signal} from '@angular/core';
2
-
3
- export interface ILocalizationService {
4
- /** Emits the current language as a signal */
5
- $currentLang: Signal<string>;
6
-
7
- /** Gets the current active language code */
8
- getLanguage(): string;
9
-
10
- /** Gets the default language code */
11
- getDefaultLanguage(): string;
12
-
13
- /** Sets the current active language */
14
- setActiveLanguage(lang: string): void;
15
-
16
- /** Translates a key, possibly with params and for a specific language */
17
- translate(key: string, params?: any, language?: string): string;
18
- }
@@ -1,131 +0,0 @@
1
- import { computed, inject, Injectable, signal } from '@angular/core';
2
- import { HttpClient } from '@angular/common/http';
3
- import { ILocalizationService } from './localization.interface';
4
-
5
- @Injectable({
6
- providedIn: 'root'
7
- })
8
- export class LocalizationService implements ILocalizationService {
9
- private defaultLanguage = 'en';
10
- private storageKey = 'orcas-language';
11
-
12
- private translations: any = {};
13
- private loaded = false;
14
-
15
- private $language: ReturnType<typeof signal<string>>;
16
- public $currentLang = computed(() => this.$language());
17
-
18
- private http = inject(HttpClient);
19
-
20
- constructor() {
21
- this.$language = signal(this.getStoredLanguage());
22
- }
23
-
24
- public async init(
25
- jsonPath: string = 'assets/translations.json',
26
- defaultLanguage: string = 'en',
27
- storageKey: string = 'orcas-language'
28
- ): Promise<void> {
29
- this.defaultLanguage = defaultLanguage;
30
- this.storageKey = storageKey;
31
- this.$language.set(this.getStoredLanguage());
32
-
33
- try {
34
- this.translations = await this.http.get(jsonPath).toPromise();
35
- this.loaded = true;
36
- }
37
- catch (err) {
38
- console.error('Failed to load translations:', err);
39
- }
40
- }
41
-
42
- getLanguage(): string {
43
- return this.$language();
44
- }
45
-
46
- getDefaultLanguage(): string {
47
- return this.defaultLanguage;
48
- }
49
-
50
- setActiveLanguage(lang: string): void {
51
- if (lang !== this.$language()) {
52
- localStorage.setItem(this.storageKey, lang);
53
- this.$language.set(lang);
54
- }
55
- }
56
-
57
- translate(key: string, params?: any, language?: string): string {
58
- const lang = language || this.getLanguage();
59
-
60
- if (!this.loaded) {
61
- console.error('Localization: Translations not loaded yet!');
62
- return key;
63
- }
64
-
65
- let translation = null;
66
-
67
- // Handle pluralization: try singular suffix __1 first if count is 1
68
- if (params && params.count === 1)
69
- translation = this.resolveKey(`${key}__1`);
70
-
71
- if (!translation)
72
- translation = this.resolveKey(key);
73
-
74
- if (!translation) {
75
- console.warn(`Localization: Key not found for "${key}".`);
76
- return key;
77
- }
78
-
79
- let translatedText = translation[lang];
80
-
81
- if (!translatedText) {
82
- console.warn(`Localization: Key "${key}" not found for language "${lang}". Falling back to default language.`);
83
- translatedText = translation[this.defaultLanguage];
84
- }
85
-
86
- if (!translatedText) {
87
- console.error(`Localization: Key "${key}" not found for default language "${this.defaultLanguage}".`);
88
- return key;
89
- }
90
-
91
- if (params) {
92
- if (Array.isArray(params))
93
- return this.replaceArrayParams(translatedText, params);
94
- else
95
- return this.replaceObjectParams(translatedText, params);
96
- }
97
-
98
- return translatedText;
99
- }
100
-
101
- private resolveKey(key: string): any {
102
- const keys = key.split('.');
103
- let translation = this.translations;
104
- for (const k of keys) {
105
- if (!translation[k])
106
- return null;
107
- translation = translation[k];
108
- }
109
- return translation;
110
- }
111
-
112
- private getStoredLanguage(): string {
113
- return localStorage.getItem(this.storageKey) || this.defaultLanguage;
114
- }
115
-
116
- private replaceArrayParams(text: string, params: any[]): string {
117
- let result = text;
118
- params.forEach((param, index) => {
119
- result = result.replace(new RegExp(`\\{\\{${index}\\}\\}`, 'g'), param.toString());
120
- });
121
- return result;
122
- }
123
-
124
- private replaceObjectParams(text: string, params: any): string {
125
- let result = text;
126
- Object.keys(params).forEach(key => {
127
- result = result.replace(new RegExp(`\\{\\{${key}\\}\\}`, 'g'), params[key].toString());
128
- });
129
- return result;
130
- }
131
- }
@@ -1,30 +0,0 @@
1
- import {Pipe, PipeTransform} from '@angular/core';
2
- import {LocalizationService} from './localization.service';
3
-
4
- @Pipe({
5
- name: 'localize',
6
- standalone: true,
7
- pure: false
8
- })
9
- export class LocalizePipe implements PipeTransform {
10
- private lastLanguage: string = '';
11
- private lastKey: string = '';
12
- private lastParams: any;
13
- private lastResult: string = '';
14
-
15
- constructor(private localizationService: LocalizationService) {
16
- }
17
-
18
- transform(key: string, params?: any): string {
19
- if (this.localizationService.$currentLang() !== this.lastLanguage
20
- || key !== this.lastKey
21
- || params !== this.lastParams) {
22
- this.lastLanguage = this.localizationService.$currentLang();
23
- this.lastKey = key;
24
- this.lastParams = params;
25
- this.lastResult = this.localizationService.translate(key, params);
26
- }
27
-
28
- return this.lastResult;
29
- }
30
- }
@@ -1,27 +0,0 @@
1
- /**
2
- * Echo provider for Angular dependency injection.
3
- * Provides a singleton Echo instance with console writer.
4
- */
5
- import { InjectionToken, Provider } from '@angular/core';
6
- import { Echo, EchoConsole } from './echo';
7
-
8
- /**
9
- * Injection token for Echo logger instance
10
- */
11
- export const ECHO = new InjectionToken<Echo>('Echo Logger Instance');
12
-
13
- /**
14
- * Factory function to create Echo instance
15
- */
16
- export function echoFactory(): Echo {
17
- return EchoConsole.new();
18
- }
19
-
20
- /**
21
- * Provider for Echo logger
22
- * Use this in your module providers or inject it in services
23
- */
24
- export const ECHO_PROVIDER: Provider = {
25
- provide: ECHO,
26
- useFactory: echoFactory
27
- };