@limetech/lime-web-components 5.38.1 → 5.39.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 CHANGED
@@ -1,3 +1,12 @@
1
+ ## [5.39.0](https://github.com/Lundalogik/lime-web-components/compare/v5.38.1...v5.39.0) (2024-11-21)
2
+
3
+
4
+ ### Features
5
+
6
+
7
+ * **core:** add event that dispatches current idle status of the user ([c625b0f](https://github.com/Lundalogik/lime-web-components/commit/c625b0f7d5349f97577cfbec77f4fe27f92814f3)), closes [Lundalogik/crm-feature#4482](https://github.com/Lundalogik/crm-feature/issues/4482)
8
+ * **poller:** add poller and poller factory ([7a59130](https://github.com/Lundalogik/lime-web-components/commit/7a59130906a3de4c2a7dda58ffd0f6b16fabffc8)), closes [Lundalogik/crm-feature#4482](https://github.com/Lundalogik/crm-feature/issues/4482)
9
+
1
10
  ## [5.38.1](https://github.com/Lundalogik/lime-web-components/compare/v5.38.0...v5.38.1) (2024-10-28)
2
11
 
3
12
 
@@ -0,0 +1,25 @@
1
+ /**
2
+ * The user's idle state. When set to `active` the user is actively using the
3
+ * application. When set to `idle`, the user has either minimized the
4
+ * application or not used it actively for a while.
5
+ * @beta
6
+ * @group Core
7
+ */
8
+ export type IdleState = 'active' | 'idle';
9
+ /**
10
+ * The event emitted by {@link EventDispatcher} when the user's idle state
11
+ * changes
12
+ * @beta
13
+ * @group Core
14
+ */
15
+ export type IdleStateChangeEvent = CustomEvent<{
16
+ state: IdleState;
17
+ }>;
18
+ /**
19
+ * Name of the event emitted by {@link EventDispatcher} when the user's idle
20
+ * state changes
21
+ * @beta
22
+ * @group Core
23
+ */
24
+ export declare const IdleStateEventName: "idle-state";
25
+ //# sourceMappingURL=idle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"idle.d.ts","sourceRoot":"","sources":["../../src/core/idle.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,GAAG,WAAW,CAAC;IAAE,KAAK,EAAE,SAAS,CAAA;CAAE,CAAC,CAAC;AAErE;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,cAAwB,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Name of the event emitted by {@link EventDispatcher} when the user's idle
3
+ * state changes
4
+ * @beta
5
+ * @group Core
6
+ */
7
+ export const IdleStateEventName = 'idle-state';
@@ -5,4 +5,5 @@ export * from './plugin-loader';
5
5
  export * from './state';
6
6
  export * from './decorators';
7
7
  export * from './metadata';
8
+ export * from './idle';
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC"}
@@ -5,3 +5,4 @@ export * from './plugin-loader';
5
5
  export * from './state';
6
6
  export * from './decorators';
7
7
  export * from './metadata';
8
+ export * from './idle';
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IdleStateEventName = void 0;
4
+ exports.IdleStateEventName = 'idle-state';
@@ -8,3 +8,4 @@ tslib_1.__exportStar(require("./plugin-loader"), exports);
8
8
  tslib_1.__exportStar(require("./state"), exports);
9
9
  tslib_1.__exportStar(require("./decorators"), exports);
10
10
  tslib_1.__exportStar(require("./metadata"), exports);
11
+ tslib_1.__exportStar(require("./idle"), exports);
package/dist/es5/index.js CHANGED
@@ -27,3 +27,4 @@ tslib_1.__exportStar(require("./conditionregistry"), exports);
27
27
  tslib_1.__exportStar(require("./view"), exports);
28
28
  tslib_1.__exportStar(require("./webcomponent"), exports);
29
29
  tslib_1.__exportStar(require("./notification-service"), exports);
30
+ tslib_1.__exportStar(require("./poller"), exports);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./factory"), exports);
5
+ tslib_1.__exportStar(require("./poller"), exports);
6
+ tslib_1.__exportStar(require("./types"), exports);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var platform_1 = require("../core/platform");
4
+ var SERVICE_NAME = 'pollerFactory';
5
+ platform_1.PlatformServiceName.PollerFactory = SERVICE_NAME;
package/dist/index.d.ts CHANGED
@@ -46,4 +46,5 @@ export * from './conditionregistry';
46
46
  export * from './view';
47
47
  export * from './webcomponent';
48
48
  export * from './notification-service';
49
+ export * from './poller';
49
50
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAA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ACpC,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,UAAU,CAAC"}
package/dist/index.js CHANGED
@@ -46,3 +46,4 @@ export * from './conditionregistry';
46
46
  export * from './view';
47
47
  export * from './webcomponent';
48
48
  export * from './notification-service';
49
+ export * from './poller';
@@ -0,0 +1,49 @@
1
+ import { IdleState } from '../core';
2
+ import { Poller } from './poller';
3
+ /**
4
+ * Factory for creating pollers.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * const poller = factory.create(
9
+ * async () => fetchDataFromAPI(),
10
+ * 60000 // Polling every 1 minute
11
+ * );
12
+ *
13
+ * const unsubscribe = poller.subscribe((data) => {
14
+ * console.log('Received data:', data);
15
+ * });
16
+ *
17
+ * unsubscribe();
18
+ * ```
19
+ * @beta
20
+ * @group Poller
21
+ */
22
+ export interface PollerFactory {
23
+ /**
24
+ * Creates a generic poller
25
+ *
26
+ * @param callback - An asynchronous function that will be executed
27
+ * periodically by the poller.
28
+ * @param intervalMs - The interval, in milliseconds, at which the callback
29
+ * should be executed.
30
+ * @returns the poller
31
+ */
32
+ create<T>(callback: () => Promise<T>, intervalMs: number): Poller<T>;
33
+ /**
34
+ * Creates a poller that executes its callback based on the users idle
35
+ * status
36
+ *
37
+ * @param callback - An asynchronous function that will be executed
38
+ * periodically by the poller based on the users idle status.
39
+ * @param intervalMs - The interval, in milliseconds, at which the callback
40
+ * should be executed.
41
+ * @param idleState - The idle state when the poller is active. When set to
42
+ * `active`, the poller will only execute while the user is actively using
43
+ * the application. When set to `idle`, the poller will only execute while
44
+ * the user is idle. Default value is `active`.
45
+ * @returns the poller
46
+ */
47
+ createIdlePoller<T>(callback: () => Promise<T>, intervalMs: number, idleState?: IdleState): Poller<T>;
48
+ }
49
+ //# sourceMappingURL=factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/poller/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,aAAa;IAC1B;;;;;;;;OAQG;IACH,MAAM,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IAErE;;;;;;;;;;;;;OAaG;IACH,gBAAgB,CAAC,CAAC,EACd,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAC1B,UAAU,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,SAAS,GACtB,MAAM,CAAC,CAAC,CAAC,CAAC;CAChB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export * from './factory';
2
+ export * from './poller';
3
+ export * from './types';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/poller/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './factory';
2
+ export * from './poller';
3
+ export * from './types';
@@ -0,0 +1,49 @@
1
+ /**
2
+ * A generic interface for a poller that periodically executes a callback and
3
+ * notifies subscribers of the result. The poller manages its lifecycle
4
+ * automatically, ensuring that polling starts when the first subscriber
5
+ * registers and stops when the last subscriber unsubscribes.
6
+ *
7
+ * The poller caches the most recent value from the callback and immediately
8
+ * delivers it to any new subscriber without waiting for the next polling
9
+ * cycle. This ensures that subscribers always receive the latest available
10
+ * data as soon as they register.
11
+ *
12
+ * Consumers are only concerned with subscribing to updates. The poller
13
+ * implementation handles polling intervals, error management, and subscriber
14
+ * lifecycle internally, making it simple and reliable for end users.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * // Add a subscriber
19
+ * const unsubscribe = poller.subscribe((result) => {
20
+ * console.log('Received data:', result);
21
+ * });
22
+ *
23
+ * // Remove the subscriber
24
+ * unsubscribe();
25
+ * ```
26
+ * @beta
27
+ * @group Poller
28
+ */
29
+ export interface Poller<T> {
30
+ /**
31
+ * Subscribes a callback to receive updates from the poller.
32
+ *
33
+ * When the first subscriber registers, the poller automatically starts
34
+ * polling. Any new subscriber immediately receives the latest cached value,
35
+ * and all subscribers are notified of subsequent polling results.
36
+ *
37
+ * @param callback - A function that will be called with the latest value
38
+ * from the poller callback. If no value is available, the callback will
39
+ * receive `undefined`.
40
+ * @returns A function to unsubscribe from the poller.
41
+ */
42
+ subscribe(callback: (value?: T) => void): () => void;
43
+ /**
44
+ * Immediately forces the poller to trigger its callback and reset the
45
+ * internal timer
46
+ */
47
+ trigger(): void;
48
+ }
49
+ //# sourceMappingURL=poller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"poller.d.ts","sourceRoot":"","sources":["../../src/poller/poller.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,WAAW,MAAM,CAAC,CAAC;IACrB;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAErD;;;OAGG;IACH,OAAO,IAAI,IAAI,CAAC;CACnB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ import { PollerFactory as PollerFactoryService } from './factory';
2
+ declare const SERVICE_NAME = "pollerFactory";
3
+ declare module '../core/platform' {
4
+ interface PlatformServiceNameType {
5
+ /**
6
+ * @see {@link PollerFactoryService}
7
+ */
8
+ PollerFactory: typeof SERVICE_NAME;
9
+ }
10
+ interface LimeWebComponentPlatform {
11
+ get(name: PlatformServiceNameType['PollerFactory']): PollerFactoryService;
12
+ }
13
+ }
14
+ export {};
15
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/poller/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAGlE,QAAA,MAAM,YAAY,kBAAkB,CAAC;AAIrC,OAAO,QAAQ,kBAAkB,CAAC;IAC9B,UAAU,uBAAuB;QAC7B;;WAEG;QACH,aAAa,EAAE,OAAO,YAAY,CAAC;KACtC;IAED,UAAU,wBAAwB;QAC9B,GAAG,CACC,IAAI,EAAE,uBAAuB,CAAC,eAAe,CAAC,GAC/C,oBAAoB,CAAC;KAC3B;CACJ"}
@@ -0,0 +1,3 @@
1
+ import { PlatformServiceName } from '../core/platform';
2
+ const SERVICE_NAME = 'pollerFactory';
3
+ PlatformServiceName.PollerFactory = SERVICE_NAME;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@limetech/lime-web-components",
3
- "version": "5.38.1",
3
+ "version": "5.39.0",
4
4
  "description": "Lime Web Components",
5
5
  "author": "Lime Technologies",
6
6
  "license": "Apache-2.0",
@@ -30,10 +30,10 @@
30
30
  "dependencies": {
31
31
  "@stencil/core": "^2.22.3",
32
32
  "rxjs": "^7.8.1",
33
- "tslib": "^2.8.0"
33
+ "tslib": "^2.8.1"
34
34
  },
35
35
  "devDependencies": {
36
- "@commitlint/config-conventional": "^19.5.0",
36
+ "@commitlint/config-conventional": "^19.6.0",
37
37
  "@microsoft/api-extractor": "^7.47.11",
38
38
  "@types/jest": "^27.5.0",
39
39
  "@typescript-eslint/eslint-plugin": "^7.5.0",