@wix/site-service-device-info 1.0.2

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 (48) hide show
  1. package/README.md +47 -0
  2. package/cjs/build/definition/index.d.ts +17 -0
  3. package/cjs/build/definition/index.js +6 -0
  4. package/cjs/build/definition/index.js.map +1 -0
  5. package/cjs/build/implementations/deviceInfoService.d.ts +6 -0
  6. package/cjs/build/implementations/deviceInfoService.js +30 -0
  7. package/cjs/build/implementations/deviceInfoService.js.map +1 -0
  8. package/cjs/build/implementations/index.d.ts +1 -0
  9. package/cjs/build/implementations/index.js +6 -0
  10. package/cjs/build/implementations/index.js.map +1 -0
  11. package/cjs/build/index.d.ts +2 -0
  12. package/cjs/build/index.js +19 -0
  13. package/cjs/build/index.js.map +1 -0
  14. package/cjs/build/service.d.ts +7 -0
  15. package/cjs/build/service.js +8 -0
  16. package/cjs/build/service.js.map +1 -0
  17. package/cjs/build/types/index.d.ts +2 -0
  18. package/cjs/build/types/index.js +3 -0
  19. package/cjs/build/types/index.js.map +1 -0
  20. package/cjs/package.json +3 -0
  21. package/definition/package.json +3 -0
  22. package/dist/definition/index.d.ts +17 -0
  23. package/dist/definition/index.js +3 -0
  24. package/dist/definition/index.js.map +1 -0
  25. package/dist/implementations/deviceInfoService.d.ts +6 -0
  26. package/dist/implementations/deviceInfoService.js +27 -0
  27. package/dist/implementations/deviceInfoService.js.map +1 -0
  28. package/dist/implementations/index.d.ts +1 -0
  29. package/dist/implementations/index.js +2 -0
  30. package/dist/implementations/index.js.map +1 -0
  31. package/dist/index.d.ts +2 -0
  32. package/dist/index.js +3 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/service.d.ts +7 -0
  35. package/dist/service.js +5 -0
  36. package/dist/service.js.map +1 -0
  37. package/dist/types/index.d.ts +2 -0
  38. package/dist/types/index.js +2 -0
  39. package/dist/types/index.js.map +1 -0
  40. package/implementations/package.json +3 -0
  41. package/package.json +81 -0
  42. package/src/definition/index.ts +20 -0
  43. package/src/implementations/deviceInfoService.ts +35 -0
  44. package/src/implementations/index.ts +1 -0
  45. package/src/index.ts +2 -0
  46. package/src/service.ts +5 -0
  47. package/src/types/index.ts +3 -0
  48. package/types/package.json +3 -0
package/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # @wix/site-service-device-info
2
+
3
+ A thin signal-backed service that exposes current device classification and reduced-motion preference.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ yarn add @wix/site-service-device-info
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { DeviceInfoDefinition } from '@wix/site-service-device-info/definition'
15
+ import { DeviceInfoService } from '@wix/site-service-device-info/implementations'
16
+
17
+ createServicesMap().addService(DeviceInfoDefinition, DeviceInfoService, config)
18
+
19
+ const service = servicesManager.getService(DeviceInfoDefinition)
20
+
21
+ // getters:
22
+ service.deviceType
23
+ service.reducedMotion
24
+ ```
25
+
26
+ ## API
27
+
28
+ | Member | Type | Throws when | Description |
29
+ |---|---|---|---|
30
+ | `deviceType` | `DeviceType` | never | Current device classification (`Desktop`, `Smartphone`, `Tablet`, `Other`). |
31
+ | `reducedMotion` | `boolean` | never | Whether reduced motion should be respected for the current session. |
32
+ | `_updateConfig` | `(Partial<IDeviceInfoServiceConfig>) => void` | never | Private replace-on-write updater for provided fields. |
33
+
34
+ ## Configuration
35
+
36
+ `IDeviceInfoServiceConfig`:
37
+
38
+ ```ts
39
+ type IDeviceInfoServiceConfig = {
40
+ deviceType?: DeviceType
41
+ reducedMotion?: boolean
42
+ }
43
+ ```
44
+
45
+ ## Reactivity
46
+
47
+ This service is a thin signal wrapper over `@wix/services-definitions/core-services/signals`. Every property is signal-backed under the hood; wrap reads in `effect` / `computed` to react to changes. Signals are not exposed directly.
@@ -0,0 +1,17 @@
1
+ import type { ServiceDefinition } from '@wix/services-definitions';
2
+ import type { DeviceType } from '../types';
3
+ export type IDeviceInfoServiceConfig = {
4
+ deviceType?: DeviceType;
5
+ reducedMotion?: boolean;
6
+ };
7
+ export interface IDeviceInfoService {
8
+ readonly deviceType: DeviceType;
9
+ readonly reducedMotion: boolean;
10
+ _updateConfig: (config: Partial<IDeviceInfoServiceConfig>) => void;
11
+ }
12
+ export type IDeviceInfoDefinition = ServiceDefinition<IDeviceInfoService, IDeviceInfoServiceConfig>;
13
+ export declare const DeviceInfoDefinition: string & {
14
+ __api: IDeviceInfoService;
15
+ __config: IDeviceInfoServiceConfig;
16
+ isServiceDefinition?: boolean;
17
+ } & IDeviceInfoService;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeviceInfoDefinition = void 0;
4
+ const services_definitions_1 = require("@wix/services-definitions");
5
+ exports.DeviceInfoDefinition = (0, services_definitions_1.defineService)('@wix/site-service-device-info');
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/definition/index.ts"],"names":[],"mappings":";;;AAAA,oEAAyD;AAiB5C,QAAA,oBAAoB,GAAG,IAAA,oCAAa,EAC7C,+BAA+B,CAClC,CAAA"}
@@ -0,0 +1,6 @@
1
+ import type { IDeviceInfoService, IDeviceInfoServiceConfig } from '../definition';
2
+ export declare const DeviceInfoService: import("@wix/services-definitions").ServiceFactory<string & {
3
+ __api: IDeviceInfoService;
4
+ __config: IDeviceInfoServiceConfig;
5
+ isServiceDefinition?: boolean;
6
+ } & IDeviceInfoService, IDeviceInfoServiceConfig>;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeviceInfoService = void 0;
4
+ const services_definitions_1 = require("@wix/services-definitions");
5
+ const signals_1 = require("@wix/services-definitions/core-services/signals");
6
+ const definition_1 = require("../definition");
7
+ const DEFAULT_DEVICE_TYPE = 'Desktop';
8
+ const DEFAULT_REDUCED_MOTION = false;
9
+ exports.DeviceInfoService = (0, services_definitions_1.implementService)(definition_1.DeviceInfoDefinition, ({ config, getService }) => {
10
+ const { signal } = getService(signals_1.SignalsServiceDefinition);
11
+ const _deviceType = signal(config.deviceType ?? DEFAULT_DEVICE_TYPE);
12
+ const _reducedMotion = signal(config.reducedMotion ?? DEFAULT_REDUCED_MOTION);
13
+ return {
14
+ get deviceType() {
15
+ return _deviceType.get();
16
+ },
17
+ get reducedMotion() {
18
+ return _reducedMotion.get();
19
+ },
20
+ _updateConfig({ deviceType, reducedMotion }) {
21
+ if (typeof deviceType !== 'undefined') {
22
+ _deviceType.set(deviceType);
23
+ }
24
+ if (typeof reducedMotion !== 'undefined') {
25
+ _reducedMotion.set(reducedMotion);
26
+ }
27
+ },
28
+ };
29
+ });
30
+ //# sourceMappingURL=deviceInfoService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deviceInfoService.js","sourceRoot":"","sources":["../../../src/implementations/deviceInfoService.ts"],"names":[],"mappings":";;;AAAA,oEAA4D;AAE5D,6EAA0F;AAE1F,8CAAoD;AAGpD,MAAM,mBAAmB,GAAe,SAAS,CAAA;AACjD,MAAM,sBAAsB,GAAG,KAAK,CAAA;AAEvB,QAAA,iBAAiB,GAAG,IAAA,uCAAgB,EAC7C,iCAAoB,EACpB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAgD,EAAsB,EAAE;IACzF,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,kCAAwB,CAAC,CAAA;IACvD,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,IAAI,mBAAmB,CAAC,CAAA;IACpE,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,IAAI,sBAAsB,CAAC,CAAA;IAE7E,OAAO;QACH,IAAI,UAAU;YACV,OAAO,WAAW,CAAC,GAAG,EAAE,CAAA;QAC5B,CAAC;QACD,IAAI,aAAa;YACb,OAAO,cAAc,CAAC,GAAG,EAAE,CAAA;QAC/B,CAAC;QACD,aAAa,CAAC,EAAE,UAAU,EAAE,aAAa,EAAqC;YAC1E,IAAI,OAAO,UAAU,KAAK,WAAW,EAAE,CAAC;gBACpC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;YAC/B,CAAC;YACD,IAAI,OAAO,aAAa,KAAK,WAAW,EAAE,CAAC;gBACvC,cAAc,CAAC,GAAG,CAAC,aAAa,CAAC,CAAA;YACrC,CAAC;QACL,CAAC;KACJ,CAAA;AACL,CAAC,CACJ,CAAA"}
@@ -0,0 +1 @@
1
+ export { DeviceInfoService } from './deviceInfoService';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeviceInfoService = void 0;
4
+ var deviceInfoService_1 = require("./deviceInfoService");
5
+ Object.defineProperty(exports, "DeviceInfoService", { enumerable: true, get: function () { return deviceInfoService_1.DeviceInfoService; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/implementations/index.ts"],"names":[],"mappings":";;;AAAA,yDAAuD;AAA9C,sHAAA,iBAAiB,OAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './definition';
2
+ export * from './implementations';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./definition"), exports);
18
+ __exportStar(require("./implementations"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA4B;AAC5B,oDAAiC"}
@@ -0,0 +1,7 @@
1
+ import { DeviceInfoService } from './implementations/deviceInfoService';
2
+ export declare const definition: string & {
3
+ __api: import("./definition").IDeviceInfoService;
4
+ __config: import("./definition").IDeviceInfoServiceConfig;
5
+ isServiceDefinition?: boolean;
6
+ } & import("./definition").IDeviceInfoService;
7
+ export default DeviceInfoService;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.definition = void 0;
4
+ const definition_1 = require("./definition");
5
+ const deviceInfoService_1 = require("./implementations/deviceInfoService");
6
+ exports.definition = definition_1.DeviceInfoDefinition;
7
+ exports.default = deviceInfoService_1.DeviceInfoService;
8
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/service.ts"],"names":[],"mappings":";;;AAAA,6CAAmD;AACnD,2EAAuE;AAE1D,QAAA,UAAU,GAAG,iCAAoB,CAAA;AAC9C,kBAAe,qCAAiB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export type DeviceType = 'Desktop' | 'Smartphone' | 'Tablet' | 'Other';
2
+ export type { IDeviceInfoService, IDeviceInfoServiceConfig, IDeviceInfoDefinition } from '../definition';
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "main": "../cjs/build/definition/index.js"
3
+ }
@@ -0,0 +1,17 @@
1
+ import type { ServiceDefinition } from '@wix/services-definitions';
2
+ import type { DeviceType } from '../types';
3
+ export type IDeviceInfoServiceConfig = {
4
+ deviceType?: DeviceType;
5
+ reducedMotion?: boolean;
6
+ };
7
+ export interface IDeviceInfoService {
8
+ readonly deviceType: DeviceType;
9
+ readonly reducedMotion: boolean;
10
+ _updateConfig: (config: Partial<IDeviceInfoServiceConfig>) => void;
11
+ }
12
+ export type IDeviceInfoDefinition = ServiceDefinition<IDeviceInfoService, IDeviceInfoServiceConfig>;
13
+ export declare const DeviceInfoDefinition: string & {
14
+ __api: IDeviceInfoService;
15
+ __config: IDeviceInfoServiceConfig;
16
+ isServiceDefinition?: boolean;
17
+ } & IDeviceInfoService;
@@ -0,0 +1,3 @@
1
+ import { defineService } from '@wix/services-definitions';
2
+ export const DeviceInfoDefinition = defineService('@wix/site-service-device-info');
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/definition/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAiBzD,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAC7C,+BAA+B,CAClC,CAAA"}
@@ -0,0 +1,6 @@
1
+ import type { IDeviceInfoService, IDeviceInfoServiceConfig } from '../definition';
2
+ export declare const DeviceInfoService: import("@wix/services-definitions").ServiceFactory<string & {
3
+ __api: IDeviceInfoService;
4
+ __config: IDeviceInfoServiceConfig;
5
+ isServiceDefinition?: boolean;
6
+ } & IDeviceInfoService, IDeviceInfoServiceConfig>;
@@ -0,0 +1,27 @@
1
+ import { implementService } from '@wix/services-definitions';
2
+ import { SignalsServiceDefinition } from '@wix/services-definitions/core-services/signals';
3
+ import { DeviceInfoDefinition } from '../definition';
4
+ const DEFAULT_DEVICE_TYPE = 'Desktop';
5
+ const DEFAULT_REDUCED_MOTION = false;
6
+ export const DeviceInfoService = implementService(DeviceInfoDefinition, ({ config, getService }) => {
7
+ const { signal } = getService(SignalsServiceDefinition);
8
+ const _deviceType = signal(config.deviceType ?? DEFAULT_DEVICE_TYPE);
9
+ const _reducedMotion = signal(config.reducedMotion ?? DEFAULT_REDUCED_MOTION);
10
+ return {
11
+ get deviceType() {
12
+ return _deviceType.get();
13
+ },
14
+ get reducedMotion() {
15
+ return _reducedMotion.get();
16
+ },
17
+ _updateConfig({ deviceType, reducedMotion }) {
18
+ if (typeof deviceType !== 'undefined') {
19
+ _deviceType.set(deviceType);
20
+ }
21
+ if (typeof reducedMotion !== 'undefined') {
22
+ _reducedMotion.set(reducedMotion);
23
+ }
24
+ },
25
+ };
26
+ });
27
+ //# sourceMappingURL=deviceInfoService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deviceInfoService.js","sourceRoot":"","sources":["../../src/implementations/deviceInfoService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAE5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,iDAAiD,CAAA;AAE1F,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AAGpD,MAAM,mBAAmB,GAAe,SAAS,CAAA;AACjD,MAAM,sBAAsB,GAAG,KAAK,CAAA;AAEpC,MAAM,CAAC,MAAM,iBAAiB,GAAG,gBAAgB,CAC7C,oBAAoB,EACpB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAgD,EAAsB,EAAE;IACzF,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,wBAAwB,CAAC,CAAA;IACvD,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,IAAI,mBAAmB,CAAC,CAAA;IACpE,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,IAAI,sBAAsB,CAAC,CAAA;IAE7E,OAAO;QACH,IAAI,UAAU;YACV,OAAO,WAAW,CAAC,GAAG,EAAE,CAAA;QAC5B,CAAC;QACD,IAAI,aAAa;YACb,OAAO,cAAc,CAAC,GAAG,EAAE,CAAA;QAC/B,CAAC;QACD,aAAa,CAAC,EAAE,UAAU,EAAE,aAAa,EAAqC;YAC1E,IAAI,OAAO,UAAU,KAAK,WAAW,EAAE,CAAC;gBACpC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;YAC/B,CAAC;YACD,IAAI,OAAO,aAAa,KAAK,WAAW,EAAE,CAAC;gBACvC,cAAc,CAAC,GAAG,CAAC,aAAa,CAAC,CAAA;YACrC,CAAC;QACL,CAAC;KACJ,CAAA;AACL,CAAC,CACJ,CAAA"}
@@ -0,0 +1 @@
1
+ export { DeviceInfoService } from './deviceInfoService';
@@ -0,0 +1,2 @@
1
+ export { DeviceInfoService } from './deviceInfoService';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/implementations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './definition';
2
+ export * from './implementations';
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from './definition';
2
+ export * from './implementations';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,mBAAmB,CAAA"}
@@ -0,0 +1,7 @@
1
+ import { DeviceInfoService } from './implementations/deviceInfoService';
2
+ export declare const definition: string & {
3
+ __api: import("./definition").IDeviceInfoService;
4
+ __config: import("./definition").IDeviceInfoServiceConfig;
5
+ isServiceDefinition?: boolean;
6
+ } & import("./definition").IDeviceInfoService;
7
+ export default DeviceInfoService;
@@ -0,0 +1,5 @@
1
+ import { DeviceInfoDefinition } from './definition';
2
+ import { DeviceInfoService } from './implementations/deviceInfoService';
3
+ export const definition = DeviceInfoDefinition;
4
+ export default DeviceInfoService;
5
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAA;AAEvE,MAAM,CAAC,MAAM,UAAU,GAAG,oBAAoB,CAAA;AAC9C,eAAe,iBAAiB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export type DeviceType = 'Desktop' | 'Smartphone' | 'Tablet' | 'Other';
2
+ export type { IDeviceInfoService, IDeviceInfoServiceConfig, IDeviceInfoDefinition } from '../definition';
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ {
2
+ "main": "../cjs/build/implementations/index.js"
3
+ }
package/package.json ADDED
@@ -0,0 +1,81 @@
1
+ {
2
+ "name": "@wix/site-service-device-info",
3
+ "version": "1.0.2",
4
+ "main": "cjs/build/index.js",
5
+ "module": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "license": "UNLICENSED",
8
+ "files": [
9
+ "dist",
10
+ "src",
11
+ "cjs",
12
+ "definition",
13
+ "implementations",
14
+ "types",
15
+ "!**/*.tsbuildinfo"
16
+ ],
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "import": "./dist/index.js",
21
+ "require": "./cjs/build/index.js"
22
+ },
23
+ "./definition": {
24
+ "types": "./dist/definition/index.d.ts",
25
+ "import": "./dist/definition/index.js",
26
+ "require": "./cjs/build/definition/index.js"
27
+ },
28
+ "./implementations": {
29
+ "types": "./dist/implementations/index.d.ts",
30
+ "import": "./dist/implementations/index.js",
31
+ "require": "./cjs/build/implementations/index.js"
32
+ },
33
+ "./types": {
34
+ "types": "./dist/types/index.d.ts",
35
+ "import": "./dist/types/index.js",
36
+ "require": "./cjs/build/types/index.js"
37
+ },
38
+ "./service": {
39
+ "types": "./dist/service.d.ts",
40
+ "import": "./dist/service.js",
41
+ "require": "./cjs/build/service.js"
42
+ }
43
+ },
44
+ "dependencies": {
45
+ "@wix/services-definitions": "^0.1.4",
46
+ "@wix/services-manager": "^0.2.20"
47
+ },
48
+ "devDependencies": {
49
+ "typescript": "^5.3.3",
50
+ "vitest": "4.1.0"
51
+ },
52
+ "scripts": {
53
+ "build": "tsc -b . --force && tsc --project tsconfig.cjs.json",
54
+ "lint": "yarn run -T lint:package $npm_package_name",
55
+ "test": "vitest --run && yarn test-type-check",
56
+ "test-type-check": "echo 'validating typescript in test files' && tsc --project tsconfig.test.json && echo 'Finished validating typescript in test files successfully'"
57
+ },
58
+ "publishUnscoped": false,
59
+ "publishConfig": {
60
+ "registry": "https://registry.npmjs.org/",
61
+ "access": "public"
62
+ },
63
+ "sideEffects": false,
64
+ "wix": {
65
+ "artifact": {
66
+ "groupId": "com.wixpress.npm",
67
+ "artifactId": "site-service-device-info",
68
+ "targets": {
69
+ "static": false,
70
+ "docker": false
71
+ }
72
+ },
73
+ "validations": {
74
+ "postBuild": [
75
+ "test",
76
+ "lint"
77
+ ]
78
+ }
79
+ },
80
+ "falconPackageHash": "f50afe63b4773794f8348ccf6b0020cf16f859b5046fcee215b675f3"
81
+ }
@@ -0,0 +1,20 @@
1
+ import { defineService } from '@wix/services-definitions'
2
+ import type { ServiceDefinition } from '@wix/services-definitions'
3
+ import type { DeviceType } from '../types'
4
+
5
+ export type IDeviceInfoServiceConfig = {
6
+ deviceType?: DeviceType
7
+ reducedMotion?: boolean
8
+ }
9
+
10
+ export interface IDeviceInfoService {
11
+ readonly deviceType: DeviceType
12
+ readonly reducedMotion: boolean
13
+ _updateConfig: (config: Partial<IDeviceInfoServiceConfig>) => void
14
+ }
15
+
16
+ export type IDeviceInfoDefinition = ServiceDefinition<IDeviceInfoService, IDeviceInfoServiceConfig>
17
+
18
+ export const DeviceInfoDefinition = defineService<IDeviceInfoService, IDeviceInfoServiceConfig>(
19
+ '@wix/site-service-device-info'
20
+ )
@@ -0,0 +1,35 @@
1
+ import { implementService } from '@wix/services-definitions'
2
+ import type { ServiceFactoryOpts } from '@wix/services-definitions'
3
+ import { SignalsServiceDefinition } from '@wix/services-definitions/core-services/signals'
4
+ import type { IDeviceInfoService, IDeviceInfoServiceConfig } from '../definition'
5
+ import { DeviceInfoDefinition } from '../definition'
6
+ import type { DeviceType } from '../types'
7
+
8
+ const DEFAULT_DEVICE_TYPE: DeviceType = 'Desktop'
9
+ const DEFAULT_REDUCED_MOTION = false
10
+
11
+ export const DeviceInfoService = implementService(
12
+ DeviceInfoDefinition,
13
+ ({ config, getService }: ServiceFactoryOpts<IDeviceInfoServiceConfig>): IDeviceInfoService => {
14
+ const { signal } = getService(SignalsServiceDefinition)
15
+ const _deviceType = signal(config.deviceType ?? DEFAULT_DEVICE_TYPE)
16
+ const _reducedMotion = signal(config.reducedMotion ?? DEFAULT_REDUCED_MOTION)
17
+
18
+ return {
19
+ get deviceType() {
20
+ return _deviceType.get()
21
+ },
22
+ get reducedMotion() {
23
+ return _reducedMotion.get()
24
+ },
25
+ _updateConfig({ deviceType, reducedMotion }: Partial<IDeviceInfoServiceConfig>) {
26
+ if (typeof deviceType !== 'undefined') {
27
+ _deviceType.set(deviceType)
28
+ }
29
+ if (typeof reducedMotion !== 'undefined') {
30
+ _reducedMotion.set(reducedMotion)
31
+ }
32
+ },
33
+ }
34
+ }
35
+ )
@@ -0,0 +1 @@
1
+ export { DeviceInfoService } from './deviceInfoService'
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './definition'
2
+ export * from './implementations'
package/src/service.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { DeviceInfoDefinition } from './definition'
2
+ import { DeviceInfoService } from './implementations/deviceInfoService'
3
+
4
+ export const definition = DeviceInfoDefinition
5
+ export default DeviceInfoService
@@ -0,0 +1,3 @@
1
+ export type DeviceType = 'Desktop' | 'Smartphone' | 'Tablet' | 'Other'
2
+
3
+ export type { IDeviceInfoService, IDeviceInfoServiceConfig, IDeviceInfoDefinition } from '../definition'
@@ -0,0 +1,3 @@
1
+ {
2
+ "main": "../cjs/build/types/index.js"
3
+ }