@wix/site-service-device-info 1.0.5 → 1.0.7

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/README.md CHANGED
@@ -5,7 +5,7 @@ A thin signal-backed service that exposes current device classification and redu
5
5
  ## Install
6
6
 
7
7
  ```sh
8
- yarn add @wix/site-service-device-info
8
+ pnpm add @wix/site-service-device-info
9
9
  ```
10
10
 
11
11
  ## Usage
@@ -4,12 +4,46 @@ export type IDeviceInfoServiceConfig = {
4
4
  deviceType?: DeviceType;
5
5
  reducedMotion?: boolean;
6
6
  };
7
+ /**
8
+ * Reports the class of device the site visitor is using and whether they prefer reduced motion, so code
9
+ * running on the site can adapt components to the site visitor's device and accessibility settings.
10
+ */
7
11
  export interface IDeviceInfoService {
12
+ /**
13
+ * Class of device the site visitor is using.
14
+ *
15
+ * It's set for the page request, so it's the same while the page renders on the server
16
+ * and in the browser, and it's safe to choose markup with it. It describes the site visitor's device,
17
+ * not the browser window or the site's layout. It doesn't change when the site visitor resizes the
18
+ * window, and `Smartphone` doesn't mean the site shows its mobile version. For layout, use CSS media
19
+ * queries.
20
+ *
21
+ * The host classifies the device from the browser's user agent.
22
+ *
23
+ * @exampleValue 'Smartphone'
24
+ */
8
25
  readonly deviceType: DeviceType;
26
+ /**
27
+ * Whether the site visitor has asked their system to minimize motion.
28
+ *
29
+ * It reflects the site visitor's reduced-motion setting, which is the
30
+ * [`prefers-reduced-motion`](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion)
31
+ * media feature. For animations defined in CSS, the media query alone is enough. Use `reducedMotion`
32
+ * for motion that code starts, such as an animation library or a video that a component plays.
33
+ *
34
+ * The setting isn't available while the page renders on the server, so the value there can differ from
35
+ * the browser value for the same page view. Apply it in browser code, such as an effect, so the server
36
+ * HTML matches the browser render.
37
+ *
38
+ * @exampleValue true
39
+ */
9
40
  readonly reducedMotion: boolean;
41
+ /** @internal Host-only. Replaces config values when the host's state changes. */
10
42
  _updateConfig: (config: Partial<IDeviceInfoServiceConfig>) => void;
11
43
  }
44
+ /** Definition of the Device Info service, used to resolve it from the services manager. */
12
45
  export type IDeviceInfoDefinition = ServiceDefinition<IDeviceInfoService, IDeviceInfoServiceConfig>;
46
+ /** Definition of the Device Info service. Specify it in `useService()` or `servicesManager.getService()`. */
13
47
  export declare const DeviceInfoDefinition: string & {
14
48
  __api: IDeviceInfoService;
15
49
  __config: IDeviceInfoServiceConfig;
@@ -2,5 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DeviceInfoDefinition = void 0;
4
4
  const services_definitions_1 = require("@wix/services-definitions");
5
+ /** Definition of the Device Info service. Specify it in `useService()` or `servicesManager.getService()`. */
5
6
  exports.DeviceInfoDefinition = (0, services_definitions_1.defineService)('@wix/site-service-device-info');
6
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/definition/index.ts"],"names":[],"mappings":";;;AAAA,oEAAyD;AAiB5C,QAAA,oBAAoB,GAAG,IAAA,oCAAa,EAChD,+BAA+B,CAC/B,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/definition/index.ts"],"names":[],"mappings":";;;AAAA,oEAAyD;AAkDzD,6GAA6G;AAChG,QAAA,oBAAoB,GAAG,IAAA,oCAAa,EAChD,+BAA+B,CAC/B,CAAA"}
@@ -1,2 +1,11 @@
1
- export type DeviceType = 'Desktop' | 'Smartphone' | 'Tablet' | 'Other';
1
+ /** Class of device a site visitor is using. */
2
+ export type DeviceType =
3
+ /** A desktop or laptop computer. */
4
+ 'Desktop'
5
+ /** A phone. */
6
+ | 'Smartphone'
7
+ /** A tablet. Some tablets, such as iPads that request desktop sites, count as `Desktop`. */
8
+ | 'Tablet'
9
+ /** Any other device, such as a smart TV or a game console, or one the host can't classify. */
10
+ | 'Other';
2
11
  export type { IDeviceInfoService, IDeviceInfoServiceConfig, IDeviceInfoDefinition } from '../definition';
@@ -4,12 +4,46 @@ export type IDeviceInfoServiceConfig = {
4
4
  deviceType?: DeviceType;
5
5
  reducedMotion?: boolean;
6
6
  };
7
+ /**
8
+ * Reports the class of device the site visitor is using and whether they prefer reduced motion, so code
9
+ * running on the site can adapt components to the site visitor's device and accessibility settings.
10
+ */
7
11
  export interface IDeviceInfoService {
12
+ /**
13
+ * Class of device the site visitor is using.
14
+ *
15
+ * It's set for the page request, so it's the same while the page renders on the server
16
+ * and in the browser, and it's safe to choose markup with it. It describes the site visitor's device,
17
+ * not the browser window or the site's layout. It doesn't change when the site visitor resizes the
18
+ * window, and `Smartphone` doesn't mean the site shows its mobile version. For layout, use CSS media
19
+ * queries.
20
+ *
21
+ * The host classifies the device from the browser's user agent.
22
+ *
23
+ * @exampleValue 'Smartphone'
24
+ */
8
25
  readonly deviceType: DeviceType;
26
+ /**
27
+ * Whether the site visitor has asked their system to minimize motion.
28
+ *
29
+ * It reflects the site visitor's reduced-motion setting, which is the
30
+ * [`prefers-reduced-motion`](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion)
31
+ * media feature. For animations defined in CSS, the media query alone is enough. Use `reducedMotion`
32
+ * for motion that code starts, such as an animation library or a video that a component plays.
33
+ *
34
+ * The setting isn't available while the page renders on the server, so the value there can differ from
35
+ * the browser value for the same page view. Apply it in browser code, such as an effect, so the server
36
+ * HTML matches the browser render.
37
+ *
38
+ * @exampleValue true
39
+ */
9
40
  readonly reducedMotion: boolean;
41
+ /** @internal Host-only. Replaces config values when the host's state changes. */
10
42
  _updateConfig: (config: Partial<IDeviceInfoServiceConfig>) => void;
11
43
  }
44
+ /** Definition of the Device Info service, used to resolve it from the services manager. */
12
45
  export type IDeviceInfoDefinition = ServiceDefinition<IDeviceInfoService, IDeviceInfoServiceConfig>;
46
+ /** Definition of the Device Info service. Specify it in `useService()` or `servicesManager.getService()`. */
13
47
  export declare const DeviceInfoDefinition: string & {
14
48
  __api: IDeviceInfoService;
15
49
  __config: IDeviceInfoServiceConfig;
@@ -1,3 +1,4 @@
1
1
  import { defineService } from '@wix/services-definitions';
2
+ /** Definition of the Device Info service. Specify it in `useService()` or `servicesManager.getService()`. */
2
3
  export const DeviceInfoDefinition = defineService('@wix/site-service-device-info');
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +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,CAChD,+BAA+B,CAC/B,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/definition/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAkDzD,6GAA6G;AAC7G,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAChD,+BAA+B,CAC/B,CAAA"}
@@ -1,2 +1,11 @@
1
- export type DeviceType = 'Desktop' | 'Smartphone' | 'Tablet' | 'Other';
1
+ /** Class of device a site visitor is using. */
2
+ export type DeviceType =
3
+ /** A desktop or laptop computer. */
4
+ 'Desktop'
5
+ /** A phone. */
6
+ | 'Smartphone'
7
+ /** A tablet. Some tablets, such as iPads that request desktop sites, count as `Desktop`. */
8
+ | 'Tablet'
9
+ /** Any other device, such as a smart TV or a game console, or one the host can't classify. */
10
+ | 'Other';
2
11
  export type { IDeviceInfoService, IDeviceInfoServiceConfig, IDeviceInfoDefinition } from '../definition';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/site-service-device-info",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "license": "UNLICENSED",
5
5
  "files": [
6
6
  "dist",
@@ -48,8 +48,8 @@
48
48
  },
49
49
  "scripts": {
50
50
  "build": "tsc -b . && tsc --project tsconfig.cjs.json",
51
- "lint": "yarn run -T lint:package $npm_package_name",
52
- "test": "vitest --run && yarn test-type-check",
51
+ "lint": "pnpm --workspace-root run lint:package --package $npm_package_name",
52
+ "test": "vitest --run && pnpm run test-type-check",
53
53
  "test-type-check": "echo 'validating typescript in test files' && tsc --project tsconfig.test.json && echo 'Finished validating typescript in test files successfully'"
54
54
  },
55
55
  "dependencies": {
@@ -77,5 +77,5 @@
77
77
  ]
78
78
  }
79
79
  },
80
- "falconPackageHash": "d577e54a4d7ce64a91d0988c3a7598b953d2e71eac79b47079e3e866"
80
+ "falconPackageHash": "74255f01c24278df16f8113a595560155fb0a557ee9b15362fb89fa0"
81
81
  }
@@ -7,14 +7,48 @@ export type IDeviceInfoServiceConfig = {
7
7
  reducedMotion?: boolean
8
8
  }
9
9
 
10
+ /**
11
+ * Reports the class of device the site visitor is using and whether they prefer reduced motion, so code
12
+ * running on the site can adapt components to the site visitor's device and accessibility settings.
13
+ */
10
14
  export interface IDeviceInfoService {
15
+ /**
16
+ * Class of device the site visitor is using.
17
+ *
18
+ * It's set for the page request, so it's the same while the page renders on the server
19
+ * and in the browser, and it's safe to choose markup with it. It describes the site visitor's device,
20
+ * not the browser window or the site's layout. It doesn't change when the site visitor resizes the
21
+ * window, and `Smartphone` doesn't mean the site shows its mobile version. For layout, use CSS media
22
+ * queries.
23
+ *
24
+ * The host classifies the device from the browser's user agent.
25
+ *
26
+ * @exampleValue 'Smartphone'
27
+ */
11
28
  readonly deviceType: DeviceType
29
+ /**
30
+ * Whether the site visitor has asked their system to minimize motion.
31
+ *
32
+ * It reflects the site visitor's reduced-motion setting, which is the
33
+ * [`prefers-reduced-motion`](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion)
34
+ * media feature. For animations defined in CSS, the media query alone is enough. Use `reducedMotion`
35
+ * for motion that code starts, such as an animation library or a video that a component plays.
36
+ *
37
+ * The setting isn't available while the page renders on the server, so the value there can differ from
38
+ * the browser value for the same page view. Apply it in browser code, such as an effect, so the server
39
+ * HTML matches the browser render.
40
+ *
41
+ * @exampleValue true
42
+ */
12
43
  readonly reducedMotion: boolean
44
+ /** @internal Host-only. Replaces config values when the host's state changes. */
13
45
  _updateConfig: (config: Partial<IDeviceInfoServiceConfig>) => void
14
46
  }
15
47
 
48
+ /** Definition of the Device Info service, used to resolve it from the services manager. */
16
49
  export type IDeviceInfoDefinition = ServiceDefinition<IDeviceInfoService, IDeviceInfoServiceConfig>
17
50
 
51
+ /** Definition of the Device Info service. Specify it in `useService()` or `servicesManager.getService()`. */
18
52
  export const DeviceInfoDefinition = defineService<IDeviceInfoService, IDeviceInfoServiceConfig>(
19
53
  '@wix/site-service-device-info'
20
54
  )
@@ -1,3 +1,12 @@
1
- export type DeviceType = 'Desktop' | 'Smartphone' | 'Tablet' | 'Other'
1
+ /** Class of device a site visitor is using. */
2
+ export type DeviceType =
3
+ /** A desktop or laptop computer. */
4
+ | 'Desktop'
5
+ /** A phone. */
6
+ | 'Smartphone'
7
+ /** A tablet. Some tablets, such as iPads that request desktop sites, count as `Desktop`. */
8
+ | 'Tablet'
9
+ /** Any other device, such as a smart TV or a game console, or one the host can't classify. */
10
+ | 'Other'
2
11
 
3
12
  export type { IDeviceInfoService, IDeviceInfoServiceConfig, IDeviceInfoDefinition } from '../definition'