@limetech/lime-web-components 6.6.0 → 6.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/error/error.d.ts +15 -0
  3. package/dist/error/error.d.ts.map +1 -0
  4. package/dist/error/error.spec.d.ts +2 -0
  5. package/dist/error/error.spec.d.ts.map +1 -0
  6. package/dist/error/index.d.ts +2 -0
  7. package/dist/error/index.d.ts.map +1 -0
  8. package/dist/eventdispatcher/eventdispatcher.d.ts +76 -10
  9. package/dist/eventdispatcher/eventdispatcher.d.ts.map +1 -1
  10. package/dist/filter/decorator.d.ts +21 -3
  11. package/dist/filter/decorator.d.ts.map +1 -1
  12. package/dist/filter/repository.d.ts +84 -6
  13. package/dist/filter/repository.d.ts.map +1 -1
  14. package/dist/http/http.d.ts +244 -37
  15. package/dist/http/http.d.ts.map +1 -1
  16. package/dist/index.cjs +3 -2
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.ts +1 -0
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.esm.js +467 -333
  21. package/dist/index.esm.js.map +1 -1
  22. package/dist/keybindings/registry.d.ts +140 -27
  23. package/dist/keybindings/registry.d.ts.map +1 -1
  24. package/dist/logger/factory.d.ts +51 -0
  25. package/dist/logger/factory.d.ts.map +1 -0
  26. package/dist/logger/factory.spec.d.ts +2 -0
  27. package/dist/logger/factory.spec.d.ts.map +1 -0
  28. package/dist/logger/index.d.ts +1 -0
  29. package/dist/logger/index.d.ts.map +1 -1
  30. package/dist/problem/index.d.ts +6 -0
  31. package/dist/problem/index.d.ts.map +1 -0
  32. package/dist/problem/problem.d.ts +394 -0
  33. package/dist/problem/problem.d.ts.map +1 -0
  34. package/dist/problem/provider.d.ts +192 -0
  35. package/dist/problem/provider.d.ts.map +1 -0
  36. package/dist/problem/query.d.ts +312 -0
  37. package/dist/problem/query.d.ts.map +1 -0
  38. package/dist/problem/repository.d.ts +111 -0
  39. package/dist/problem/repository.d.ts.map +1 -0
  40. package/dist/problem/types.d.ts +15 -0
  41. package/dist/problem/types.d.ts.map +1 -0
  42. package/package.json +6 -6
@@ -6,31 +6,66 @@
6
6
  * to individual keys typed by a user. The key combination can be pressing a single
7
7
  * key or a sequence of keys one after the other.
8
8
  *
9
- * The service works together with the `CommandBus` to execute the commands and
9
+ * The service works together with the {@link CommandBus} to execute the commands and
10
10
  * a command needs to already be registered on the command bus in order to be
11
11
  * bound as a keyboard shortcut.
12
12
  *
13
- * The following example registers the command `MyCommand` to be handled by
14
- * `MyHandler` and creates a keybinding for it. The `bind` method takes the key
15
- * combination and command object as input.
13
+ * Keybindings are scoped to the component that creates them and should be
14
+ * cleaned up when the component is removed from the DOM to prevent memory leaks
15
+ * and unintended behavior.
16
16
  *
17
- * Later, if the keybinding no longer is needed it can be removed with the
18
- * `unbind` method.
17
+ * ## Key Combination Format
19
18
  *
20
- * @example
19
+ * Key combinations can be:
20
+ * - Single keys: `'a'`, `'enter'`, `'escape'`
21
+ * - Modifier combinations: `'ctrl+s'`, `'alt+shift+n'`, `'meta+k'`
22
+ * - Sequences: `'g i'` (press 'g' then 'i')
23
+ *
24
+ * Supported modifiers: `ctrl`, `alt`, `shift`, `meta` (Command on Mac)
25
+ *
26
+ * @example Binding a command to a key combination
27
+ * ```ts
28
+ * const saveCommand = new SaveCommand();
29
+ * commandBus.register(SaveCommand, { handle: (cmd) => handleSave(cmd) });
30
+ * const registry = platform.get(PlatformServiceName.KeybindingRegistry);
31
+ * registry.bind('ctrl+s', saveCommand);
32
+ * ```
33
+ *
34
+ * @example Checking for conflicts before binding
35
+ * ```ts
36
+ * const registry = platform.get(PlatformServiceName.KeybindingRegistry);
37
+ * if (!registry.isBound('j')) {
38
+ * registry.bind('j', navigateNextCommand);
39
+ * }
40
+ * ```
41
+ *
42
+ * @example Vim-style key sequences
43
+ * ```ts
44
+ * const registry = platform.get(PlatformServiceName.KeybindingRegistry);
45
+ * registry.bind('g i', goToInboxCommand);
46
+ * registry.bind('g s', goToSentCommand);
47
+ * registry.bind('g d', goToDraftsCommand);
21
48
  * ```
22
- * // The command bus needs to have a handler registered for the command
23
- * // before it can be bound to a key sequence
24
- * const handler = new MyHandler();
25
- * commandBus.register(MyCommand, handler);
26
49
  *
27
- * // Bind 'ctrl+s' to trigger the command
28
- * const command = new MyCommand();
29
- * keybindingRegistry.bind('ctrl+s', command);
50
+ * @example Usage in a component
51
+ * ```ts
52
+ * class MyComponent {
53
+ * private saveCommand = new SaveCommand();
30
54
  *
31
- * // Remove the binding when we no longer need it to trigger the command
32
- * keybindingRegistry.unbind('ctrl+s')
55
+ * connectedCallback() {
56
+ * this.keybindingRegistry.bind('ctrl+s', this.saveCommand);
57
+ * }
58
+ *
59
+ * disconnectedCallback() {
60
+ * this.keybindingRegistry.unbind('ctrl+s', this.saveCommand);
61
+ * }
62
+ *
63
+ * private get keybindingRegistry() {
64
+ * return this.platform.get(PlatformServiceName.KeybindingRegistry);
65
+ * }
66
+ * }
33
67
  * ```
68
+ *
34
69
  * @note This service is work in progress
35
70
  * @beta
36
71
  * @group Keyboard shortcuts
@@ -39,46 +74,124 @@ export interface KeybindingRegistry {
39
74
  /**
40
75
  * Bind a command to a specific key combination to add it to the registry
41
76
  *
42
- * @param keys - the string representation of keys
43
- * @param command - the command to trigger when keys are pressed
44
- * @throws Will throw an error if the command is invalid or not registered
77
+ * When a user presses the specified key combination, the command will be
78
+ * dispatched through the {@link CommandBus}. The command must already have
79
+ * a handler registered on the command bus before binding.
80
+ *
81
+ * If the same key combination is bound to multiple commands, all commands
82
+ * will be executed in the order they were registered.
83
+ *
84
+ * @param keys - the string representation of keys (e.g., 'ctrl+s', 'alt+shift+n', 'g i')
85
+ * @param command - the command instance to trigger when keys are pressed
86
+ * @throws Will throw an error if the command is invalid or not registered on the command bus
87
+ *
88
+ * @example
89
+ * ```ts
90
+ * const command = new SaveCommand();
91
+ * const registry = platform.get(PlatformServiceName.KeybindingRegistry);
92
+ * registry.bind('ctrl+s', command);
93
+ * ```
45
94
  */
46
95
  bind: (keys: string, command: object) => void;
47
96
  /**
48
97
  * Unbind a keybinding to remove it from the registry
49
98
  *
50
- * @param keys - the string representation of the key combination
51
- * @param command - the command connected to the key combination
99
+ * Removes the association between a key combination and a command. After
100
+ * unbinding, pressing the key combination will no longer trigger the command.
101
+ * This is essential for cleanup when components are removed from the DOM.
102
+ *
103
+ * If multiple commands are bound to the same key combination, only the
104
+ * specified command will be unbound.
105
+ *
106
+ * @param keys - the string representation of the key combination (e.g., 'ctrl+s')
107
+ * @param command - the command instance connected to the key combination
108
+ *
109
+ * @example
110
+ * ```ts
111
+ * const registry = platform.get(PlatformServiceName.KeybindingRegistry);
112
+ * registry.unbind('ctrl+s', saveCommand);
113
+ * ```
52
114
  */
53
115
  unbind: (keys: string, command: object) => void;
54
116
  /**
55
117
  * Get a list of the key bindings that are currently in the registry
56
118
  *
57
- * @returns the list of command and its specific key combination
119
+ * Returns all active keybindings across all components. Useful for debugging,
120
+ * displaying keyboard shortcuts to users, or detecting conflicts.
121
+ *
122
+ * @returns the list of all active keybindings with their commands
123
+ *
124
+ * @example
125
+ * ```ts
126
+ * const registry = platform.get(PlatformServiceName.KeybindingRegistry);
127
+ * const bindings = registry.getKeybindings();
128
+ * bindings.forEach(binding => {
129
+ * console.log(`${binding.keys} → ${binding.command}`);
130
+ * });
131
+ * ```
58
132
  */
59
133
  getKeybindings: () => Keybinding[];
60
134
  /**
61
135
  * Checks if a key combination or a specific keybinding is already bound
62
136
  *
63
- * @param keys - the string representation of a key combination
64
- * @param command - the command connected to the key combination
65
- * @returns true if key combination already exists, else false
137
+ * Use this method to detect conflicts before binding new keybindings.
138
+ * When called with just a key combination, returns true if any command
139
+ * is bound to those keys. When called with both keys and a command,
140
+ * returns true only if that specific combination exists.
141
+ *
142
+ * @param keys - the string representation of a key combination (e.g., 'ctrl+s')
143
+ * @param command - optional command instance to check for a specific binding
144
+ * @returns true if the key combination is bound (to any or the specified command), false otherwise
145
+ *
146
+ * @example Check if any command is bound to keys
147
+ * ```ts
148
+ * const registry = platform.get(PlatformServiceName.KeybindingRegistry);
149
+ * if (registry.isBound('ctrl+s')) {
150
+ * console.warn('ctrl+s is already bound');
151
+ * }
152
+ * ```
153
+ *
154
+ * @example Check if a specific command is bound to keys
155
+ * ```ts
156
+ * const registry = platform.get(PlatformServiceName.KeybindingRegistry);
157
+ * if (registry.isBound('ctrl+s', saveCommand)) {
158
+ * console.log('Save command is bound to ctrl+s');
159
+ * }
160
+ * ```
66
161
  */
67
162
  isBound: (keys: string, command?: object) => boolean;
68
163
  }
69
164
  /**
70
165
  * A key combination and its corresponding command that will be triggered when
71
166
  * the key combination is pressed
167
+ *
168
+ * Represents an active binding in the {@link KeybindingRegistry}. Each keybinding
169
+ * associates a specific key combination with a command instance that will be
170
+ * executed via the {@link CommandBus} when the keys are pressed.
171
+ *
172
+ * @example
173
+ * ```ts
174
+ * const binding: Keybinding = {
175
+ * keys: 'ctrl+s',
176
+ * command: new SaveCommand(),
177
+ * };
178
+ * ```
179
+ *
72
180
  * @beta
73
181
  * @group Keyboard shortcuts
74
182
  */
75
183
  export interface Keybinding {
76
184
  /**
77
- * The string representation of key combination
185
+ * The string representation of a key combination
186
+ *
187
+ * Examples: `'ctrl+s'`, `'alt+shift+n'`, `'g i'`, `'escape'`
78
188
  */
79
189
  keys: string;
80
190
  /**
81
- * The command to trigger when the key combination is pressed
191
+ * The command instance to trigger when the key combination is pressed
192
+ *
193
+ * This command must be registered on the {@link CommandBus} before the
194
+ * keybinding is created.
82
195
  */
83
196
  command: object;
84
197
  }
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/keybindings/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,WAAW,kBAAkB;IAC/B;;;;;;OAMG;IACH,IAAI,EAAE,CAAC,IAAI,EAAE,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AE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,51 @@
1
+ import { Logger } from './logger';
2
+ /**
3
+ * Creates a logger instance using the platform's logger factory
4
+ *
5
+ * This function retrieves the logger factory from the global Lime platform
6
+ * object and creates a scoped logger. If the platform factory is not available,
7
+ * it falls back to the browser console.
8
+ *
9
+ * The package name is automatically determined from the module's URL on the first
10
+ * call and cached for all subsequent calls. This ensures consistent logger scopes
11
+ * across all loggers created from the same module instance.
12
+ *
13
+ * @param scope - The scope/category for the logger (e.g., 'my-component', 'http-client')
14
+ * @returns A logger instance integrated with the platform or console fallback
15
+ *
16
+ * @remarks
17
+ * The console fallback is provided for development scenarios where the full
18
+ * Lime platform is not available. The console object does not fully implement
19
+ * the Logger interface but provides compatible logging methods.
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * const logger = createLogger('my-component');
24
+ * logger.info('Component initialized');
25
+ * logger.debug('Processing data', { count: 42 });
26
+ * ```
27
+ *
28
+ * @beta
29
+ * @group Logger
30
+ */
31
+ export declare function createLogger(scope: string): Logger;
32
+ /**
33
+ * Extracts the package name from a given URL
34
+ *
35
+ * Supports multiple URL patterns:
36
+ * - `/packages/@scope/name/version/...` → extracts `name`
37
+ * - `/static/name+version/...` → extracts `name`
38
+ * - `/static/directory/name+version/...` → extracts `name`
39
+ * - `/static/name/...` → extracts `name`
40
+ *
41
+ * The extracted name is cleaned by removing common prefixes and suffixes.
42
+ *
43
+ * @param url - The URL string to extract the package name from
44
+ *
45
+ * @returns The extracted package name, or null if not found
46
+ *
47
+ * @beta
48
+ * @group Logger
49
+ */
50
+ export declare function getPackageNameFromUrl(url: string | null): string | null;
51
+ //# sourceMappingURL=factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/logger/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAKlC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAqBlD;AAqCD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAcvE"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=factory.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.spec.d.ts","sourceRoot":"","sources":["../../src/logger/factory.spec.ts"],"names":[],"mappings":""}
@@ -1,3 +1,4 @@
1
1
  export * from './logger';
2
2
  export * from './types';
3
+ export { createLogger, getPackageNameFromUrl } from './factory';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logger/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logger/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from './problem';
2
+ export * from './query';
3
+ export * from './provider';
4
+ export * from './repository';
5
+ export * from './types';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/problem/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}