@wix/site-service-site-info 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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @wix/site-service-site-info
2
2
 
3
- Information about the site that is being rendered: its display name and its revision. The host (Thunderbolt) supplies both values and updates them when the editor renames the site or the site gets a new revision.
3
+ Information about the site that is being rendered: its display name, its revision and its site ID. The host (Thunderbolt) supplies the values and updates them when the editor renames the site, the site gets a new revision, or an unsaved site gets its site ID.
4
4
 
5
5
  ## Install
6
6
 
@@ -17,6 +17,7 @@ const siteInfo = servicesManager.getService(SiteInfoDefinition)
17
17
 
18
18
  siteInfo.name // 'My Bakery'
19
19
  siteInfo.revision // 42
20
+ siteInfo.siteId // '6bd3b2c9-3f4a-4c1e-9b7e-2a1d5e8f0c43'
20
21
  ```
21
22
 
22
23
  Read through the service object, not a destructured copy: a destructured value doesn't see later updates.
@@ -29,6 +30,7 @@ Declare `'@wix/site-service-site-info'` in your component's `serviceDependencies
29
30
  |---|---|---|---|
30
31
  | `name` | `string` | never | Display name of the site, as set in the site's settings. `''` when the site has none. Same value as [`site.getSiteDisplayName()`](https://dev.wix.com/docs/sdk/frontend-modules/site/get-site-display-name). |
31
32
  | `revision` | `number` | never | Revision of the site that is being rendered. `0` when there is no revision. |
33
+ | `siteId` | `string` | never | ID of the site (its meta site ID). `''` when the site has none yet, for example an unsaved template in the editor. Replaces `getMetaSiteId()` from `@wix/viewer-service-environment`. |
32
34
  | `_updateConfig` | `(Partial<ISiteInfoServiceConfig>) => void` | never | Private replace-on-write updater for provided fields. |
33
35
 
34
36
  ## Configuration
@@ -39,11 +41,12 @@ Declare `'@wix/site-service-site-info'` in your component's `serviceDependencies
39
41
  type ISiteInfoServiceConfig = {
40
42
  name: string
41
43
  revision: number
44
+ siteId: string
42
45
  }
43
46
  ```
44
47
 
45
- Injected by the host. `name` comes from the site's properties, and `revision` from the published site. The host passes `0` when it has no revision.
48
+ Injected by the host. `name` comes from the site's properties, and `revision` from the published site. The host passes `0` when it has no revision, and `''` when the site has no site ID yet.
46
49
 
47
50
  ## Reactivity
48
51
 
49
- This service is a thin signal wrapper over `@wix/services-definitions/core-services/signals`. Both properties are signal-backed; wrap reads in `effect` / `computed` to react to a rename or a new revision. Signals are not exposed directly.
52
+ This service is a thin signal wrapper over `@wix/services-definitions/core-services/signals`. All properties are signal-backed; wrap reads in `effect` / `computed` to react to a rename, a new revision or a new site ID. Signals are not exposed directly.
@@ -13,17 +13,22 @@ export type ISiteInfoServiceConfig = {
13
13
  * @exampleValue 42
14
14
  */
15
15
  revision: number;
16
+ /**
17
+ * ID of the site (its meta site ID), or `''` when the site has none yet (an unsaved template in the editor).
18
+ *
19
+ * @exampleValue '6bd3b2c9-3f4a-4c1e-9b7e-2a1d5e8f0c43'
20
+ */
21
+ siteId: string;
16
22
  };
17
- /** Reports the display name and revision number of the site your code runs on. */
23
+ /** Reports the display name, revision number and ID of the site your code runs on. */
18
24
  export interface ISiteInfoService {
19
25
  /**
20
26
  * Site's display name.
21
27
  *
22
28
  * A Wix user sets it in the Website Settings section of the site's dashboard.
23
29
  *
24
- * This value can change while the page is open. It changes when a Wix user renames the site while
25
- * editing it. Read it while a component renders, or inside an `effect` or `computed`, to react to
26
- * changes.
30
+ * This value can change while the page is open. It changes when a Wix user renames the site while editing
31
+ * it. Read it while a component renders, so the component updates when it changes.
27
32
  *
28
33
  * `''` when the site has no display name.
29
34
  *
@@ -35,21 +40,32 @@ export interface ISiteInfoService {
35
40
  *
36
41
  * The site gets a new revision each time a Wix user saves or publishes it after a change.
37
42
  *
38
- * This value can change while the page is open. It changes when the site gets a new revision while a
39
- * Wix user is editing it. Read it while a component renders, or inside an `effect` or `computed`, to
40
- * react to changes.
43
+ * This value can change while the page is open. It changes when the site gets a new revision while a Wix
44
+ * user is editing it. Read it while a component renders, so the component updates when it changes.
41
45
  *
42
46
  * `0` when no revision is available.
43
47
  *
44
48
  * @exampleValue 42
45
49
  */
46
50
  readonly revision: number;
51
+ /**
52
+ * Site's ID: the ID that Wix APIs and analytics use to identify the site.
53
+ *
54
+ * This value can change while the page is open. It changes when a Wix user saves an unsaved template
55
+ * while editing it. Read it while a component renders, or inside an `effect` or `computed`, to react to
56
+ * changes.
57
+ *
58
+ * `''` when the site has no ID yet, for example an unsaved template in the editor.
59
+ *
60
+ * @exampleValue '6bd3b2c9-3f4a-4c1e-9b7e-2a1d5e8f0c43'
61
+ */
62
+ readonly siteId: string;
47
63
  /** @internal Host-only. Replaces config values when the host's state changes. */
48
64
  _updateConfig: (config: Partial<ISiteInfoServiceConfig>) => void;
49
65
  }
50
66
  /** Definition of the Site Info service, used to resolve it from the services manager. */
51
67
  export type ISiteInfoDefinition = ServiceDefinition<ISiteInfoService, ISiteInfoServiceConfig>;
52
- /** Definition of the Site Info service. Specify it in `useService()` or `servicesManager.getService()`. */
68
+ /** Definition of the Site Info service. Specify it in `useService()`. */
53
69
  export declare const SiteInfoDefinition: string & {
54
70
  __api: ISiteInfoService;
55
71
  __config: ISiteInfoServiceConfig;
@@ -2,6 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SiteInfoDefinition = void 0;
4
4
  const services_definitions_1 = require("@wix/services-definitions");
5
- /** Definition of the Site Info service. Specify it in `useService()` or `servicesManager.getService()`. */
5
+ /** Definition of the Site Info service. Specify it in `useService()`. */
6
6
  exports.SiteInfoDefinition = (0, services_definitions_1.defineService)('@wix/site-service-site-info');
7
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/definition/index.ts"],"names":[],"mappings":";;;AAAA,oEAAyD;AAwDzD,2GAA2G;AAC9F,QAAA,kBAAkB,GAAG,IAAA,oCAAa,EAA2C,6BAA6B,CAAC,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/definition/index.ts"],"names":[],"mappings":";;;AAAA,oEAAyD;AAwEzD,yEAAyE;AAC5D,QAAA,kBAAkB,GAAG,IAAA,oCAAa,EAA2C,6BAA6B,CAAC,CAAA"}
@@ -8,6 +8,7 @@ exports.SiteInfoService = (0, services_definitions_1.implementService)(definitio
8
8
  const { signal } = getService(signals_1.SignalsServiceDefinition);
9
9
  const _name = signal(config.name);
10
10
  const _revision = signal(config.revision);
11
+ const _siteId = signal(config.siteId);
11
12
  return {
12
13
  get name() {
13
14
  return _name.get();
@@ -15,6 +16,9 @@ exports.SiteInfoService = (0, services_definitions_1.implementService)(definitio
15
16
  get revision() {
16
17
  return _revision.get();
17
18
  },
19
+ get siteId() {
20
+ return _siteId.get();
21
+ },
18
22
  _updateConfig(update) {
19
23
  if (typeof update.name !== 'undefined') {
20
24
  _name.set(update.name);
@@ -22,6 +26,9 @@ exports.SiteInfoService = (0, services_definitions_1.implementService)(definitio
22
26
  if (typeof update.revision !== 'undefined') {
23
27
  _revision.set(update.revision);
24
28
  }
29
+ if (typeof update.siteId !== 'undefined') {
30
+ _siteId.set(update.siteId);
31
+ }
25
32
  },
26
33
  };
27
34
  });
@@ -1 +1 @@
1
- {"version":3,"file":"siteInfoService.js","sourceRoot":"","sources":["../../../src/implementations/siteInfoService.ts"],"names":[],"mappings":";;;AAAA,oEAA4D;AAE5D,6EAA0F;AAE1F,8CAAkD;AAErC,QAAA,eAAe,GAAG,IAAA,uCAAgB,EAC9C,+BAAkB,EAClB,CAAC,EAAE,MAAM,EAAE,UAAU,EAA8C,EAAoB,EAAE;IACxF,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,kCAAwB,CAAC,CAAA;IACvD,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACjC,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IAEzC,OAAO;QACN,IAAI,IAAI;YACP,OAAO,KAAK,CAAC,GAAG,EAAE,CAAA;QACnB,CAAC;QACD,IAAI,QAAQ;YACX,OAAO,SAAS,CAAC,GAAG,EAAE,CAAA;QACvB,CAAC;QACD,aAAa,CAAC,MAAuC;YACpD,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;gBACxC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;YACvB,CAAC;YACD,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW,EAAE,CAAC;gBAC5C,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;YAC/B,CAAC;QACF,CAAC;KACD,CAAA;AACF,CAAC,CACD,CAAA"}
1
+ {"version":3,"file":"siteInfoService.js","sourceRoot":"","sources":["../../../src/implementations/siteInfoService.ts"],"names":[],"mappings":";;;AAAA,oEAA4D;AAE5D,6EAA0F;AAE1F,8CAAkD;AAErC,QAAA,eAAe,GAAG,IAAA,uCAAgB,EAC9C,+BAAkB,EAClB,CAAC,EAAE,MAAM,EAAE,UAAU,EAA8C,EAAoB,EAAE;IACxF,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,kCAAwB,CAAC,CAAA;IACvD,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACjC,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IACzC,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAErC,OAAO;QACN,IAAI,IAAI;YACP,OAAO,KAAK,CAAC,GAAG,EAAE,CAAA;QACnB,CAAC;QACD,IAAI,QAAQ;YACX,OAAO,SAAS,CAAC,GAAG,EAAE,CAAA;QACvB,CAAC;QACD,IAAI,MAAM;YACT,OAAO,OAAO,CAAC,GAAG,EAAE,CAAA;QACrB,CAAC;QACD,aAAa,CAAC,MAAuC;YACpD,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;gBACxC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;YACvB,CAAC;YACD,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW,EAAE,CAAC;gBAC5C,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;YAC/B,CAAC;YACD,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;gBAC1C,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;YAC3B,CAAC;QACF,CAAC;KACD,CAAA;AACF,CAAC,CACD,CAAA"}
@@ -13,17 +13,22 @@ export type ISiteInfoServiceConfig = {
13
13
  * @exampleValue 42
14
14
  */
15
15
  revision: number;
16
+ /**
17
+ * ID of the site (its meta site ID), or `''` when the site has none yet (an unsaved template in the editor).
18
+ *
19
+ * @exampleValue '6bd3b2c9-3f4a-4c1e-9b7e-2a1d5e8f0c43'
20
+ */
21
+ siteId: string;
16
22
  };
17
- /** Reports the display name and revision number of the site your code runs on. */
23
+ /** Reports the display name, revision number and ID of the site your code runs on. */
18
24
  export interface ISiteInfoService {
19
25
  /**
20
26
  * Site's display name.
21
27
  *
22
28
  * A Wix user sets it in the Website Settings section of the site's dashboard.
23
29
  *
24
- * This value can change while the page is open. It changes when a Wix user renames the site while
25
- * editing it. Read it while a component renders, or inside an `effect` or `computed`, to react to
26
- * changes.
30
+ * This value can change while the page is open. It changes when a Wix user renames the site while editing
31
+ * it. Read it while a component renders, so the component updates when it changes.
27
32
  *
28
33
  * `''` when the site has no display name.
29
34
  *
@@ -35,21 +40,32 @@ export interface ISiteInfoService {
35
40
  *
36
41
  * The site gets a new revision each time a Wix user saves or publishes it after a change.
37
42
  *
38
- * This value can change while the page is open. It changes when the site gets a new revision while a
39
- * Wix user is editing it. Read it while a component renders, or inside an `effect` or `computed`, to
40
- * react to changes.
43
+ * This value can change while the page is open. It changes when the site gets a new revision while a Wix
44
+ * user is editing it. Read it while a component renders, so the component updates when it changes.
41
45
  *
42
46
  * `0` when no revision is available.
43
47
  *
44
48
  * @exampleValue 42
45
49
  */
46
50
  readonly revision: number;
51
+ /**
52
+ * Site's ID: the ID that Wix APIs and analytics use to identify the site.
53
+ *
54
+ * This value can change while the page is open. It changes when a Wix user saves an unsaved template
55
+ * while editing it. Read it while a component renders, or inside an `effect` or `computed`, to react to
56
+ * changes.
57
+ *
58
+ * `''` when the site has no ID yet, for example an unsaved template in the editor.
59
+ *
60
+ * @exampleValue '6bd3b2c9-3f4a-4c1e-9b7e-2a1d5e8f0c43'
61
+ */
62
+ readonly siteId: string;
47
63
  /** @internal Host-only. Replaces config values when the host's state changes. */
48
64
  _updateConfig: (config: Partial<ISiteInfoServiceConfig>) => void;
49
65
  }
50
66
  /** Definition of the Site Info service, used to resolve it from the services manager. */
51
67
  export type ISiteInfoDefinition = ServiceDefinition<ISiteInfoService, ISiteInfoServiceConfig>;
52
- /** Definition of the Site Info service. Specify it in `useService()` or `servicesManager.getService()`. */
68
+ /** Definition of the Site Info service. Specify it in `useService()`. */
53
69
  export declare const SiteInfoDefinition: string & {
54
70
  __api: ISiteInfoService;
55
71
  __config: ISiteInfoServiceConfig;
@@ -1,4 +1,4 @@
1
1
  import { defineService } from '@wix/services-definitions';
2
- /** Definition of the Site Info service. Specify it in `useService()` or `servicesManager.getService()`. */
2
+ /** Definition of the Site Info service. Specify it in `useService()`. */
3
3
  export const SiteInfoDefinition = defineService('@wix/site-service-site-info');
4
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;AAwDzD,2GAA2G;AAC3G,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAA2C,6BAA6B,CAAC,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/definition/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAwEzD,yEAAyE;AACzE,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAA2C,6BAA6B,CAAC,CAAA"}
@@ -5,6 +5,7 @@ export const SiteInfoService = implementService(SiteInfoDefinition, ({ config, g
5
5
  const { signal } = getService(SignalsServiceDefinition);
6
6
  const _name = signal(config.name);
7
7
  const _revision = signal(config.revision);
8
+ const _siteId = signal(config.siteId);
8
9
  return {
9
10
  get name() {
10
11
  return _name.get();
@@ -12,6 +13,9 @@ export const SiteInfoService = implementService(SiteInfoDefinition, ({ config, g
12
13
  get revision() {
13
14
  return _revision.get();
14
15
  },
16
+ get siteId() {
17
+ return _siteId.get();
18
+ },
15
19
  _updateConfig(update) {
16
20
  if (typeof update.name !== 'undefined') {
17
21
  _name.set(update.name);
@@ -19,6 +23,9 @@ export const SiteInfoService = implementService(SiteInfoDefinition, ({ config, g
19
23
  if (typeof update.revision !== 'undefined') {
20
24
  _revision.set(update.revision);
21
25
  }
26
+ if (typeof update.siteId !== 'undefined') {
27
+ _siteId.set(update.siteId);
28
+ }
22
29
  },
23
30
  };
24
31
  });
@@ -1 +1 @@
1
- {"version":3,"file":"siteInfoService.js","sourceRoot":"","sources":["../../src/implementations/siteInfoService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAE5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,iDAAiD,CAAA;AAE1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAElD,MAAM,CAAC,MAAM,eAAe,GAAG,gBAAgB,CAC9C,kBAAkB,EAClB,CAAC,EAAE,MAAM,EAAE,UAAU,EAA8C,EAAoB,EAAE;IACxF,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,wBAAwB,CAAC,CAAA;IACvD,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACjC,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IAEzC,OAAO;QACN,IAAI,IAAI;YACP,OAAO,KAAK,CAAC,GAAG,EAAE,CAAA;QACnB,CAAC;QACD,IAAI,QAAQ;YACX,OAAO,SAAS,CAAC,GAAG,EAAE,CAAA;QACvB,CAAC;QACD,aAAa,CAAC,MAAuC;YACpD,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;gBACxC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;YACvB,CAAC;YACD,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW,EAAE,CAAC;gBAC5C,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;YAC/B,CAAC;QACF,CAAC;KACD,CAAA;AACF,CAAC,CACD,CAAA"}
1
+ {"version":3,"file":"siteInfoService.js","sourceRoot":"","sources":["../../src/implementations/siteInfoService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAE5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,iDAAiD,CAAA;AAE1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAElD,MAAM,CAAC,MAAM,eAAe,GAAG,gBAAgB,CAC9C,kBAAkB,EAClB,CAAC,EAAE,MAAM,EAAE,UAAU,EAA8C,EAAoB,EAAE;IACxF,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,wBAAwB,CAAC,CAAA;IACvD,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACjC,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IACzC,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAErC,OAAO;QACN,IAAI,IAAI;YACP,OAAO,KAAK,CAAC,GAAG,EAAE,CAAA;QACnB,CAAC;QACD,IAAI,QAAQ;YACX,OAAO,SAAS,CAAC,GAAG,EAAE,CAAA;QACvB,CAAC;QACD,IAAI,MAAM;YACT,OAAO,OAAO,CAAC,GAAG,EAAE,CAAA;QACrB,CAAC;QACD,aAAa,CAAC,MAAuC;YACpD,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;gBACxC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;YACvB,CAAC;YACD,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW,EAAE,CAAC;gBAC5C,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;YAC/B,CAAC;YACD,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;gBAC1C,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;YAC3B,CAAC;QACF,CAAC;KACD,CAAA;AACF,CAAC,CACD,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/site-service-site-info",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "license": "UNLICENSED",
5
5
  "files": [
6
6
  "dist",
@@ -77,5 +77,5 @@
77
77
  ]
78
78
  }
79
79
  },
80
- "falconPackageHash": "9ca22f2f212b83bd0b77df5bf34004090d28fb13ab1342b33e2b7bdc"
80
+ "falconPackageHash": "19dc63e9d20d5a46566d8e41fa11959e7eb862d95fe6bff8a1b9fcaf"
81
81
  }
@@ -15,18 +15,23 @@ export type ISiteInfoServiceConfig = {
15
15
  * @exampleValue 42
16
16
  */
17
17
  revision: number
18
+ /**
19
+ * ID of the site (its meta site ID), or `''` when the site has none yet (an unsaved template in the editor).
20
+ *
21
+ * @exampleValue '6bd3b2c9-3f4a-4c1e-9b7e-2a1d5e8f0c43'
22
+ */
23
+ siteId: string
18
24
  }
19
25
 
20
- /** Reports the display name and revision number of the site your code runs on. */
26
+ /** Reports the display name, revision number and ID of the site your code runs on. */
21
27
  export interface ISiteInfoService {
22
28
  /**
23
29
  * Site's display name.
24
30
  *
25
31
  * A Wix user sets it in the Website Settings section of the site's dashboard.
26
32
  *
27
- * This value can change while the page is open. It changes when a Wix user renames the site while
28
- * editing it. Read it while a component renders, or inside an `effect` or `computed`, to react to
29
- * changes.
33
+ * This value can change while the page is open. It changes when a Wix user renames the site while editing
34
+ * it. Read it while a component renders, so the component updates when it changes.
30
35
  *
31
36
  * `''` when the site has no display name.
32
37
  *
@@ -38,15 +43,26 @@ export interface ISiteInfoService {
38
43
  *
39
44
  * The site gets a new revision each time a Wix user saves or publishes it after a change.
40
45
  *
41
- * This value can change while the page is open. It changes when the site gets a new revision while a
42
- * Wix user is editing it. Read it while a component renders, or inside an `effect` or `computed`, to
43
- * react to changes.
46
+ * This value can change while the page is open. It changes when the site gets a new revision while a Wix
47
+ * user is editing it. Read it while a component renders, so the component updates when it changes.
44
48
  *
45
49
  * `0` when no revision is available.
46
50
  *
47
51
  * @exampleValue 42
48
52
  */
49
53
  readonly revision: number
54
+ /**
55
+ * Site's ID: the ID that Wix APIs and analytics use to identify the site.
56
+ *
57
+ * This value can change while the page is open. It changes when a Wix user saves an unsaved template
58
+ * while editing it. Read it while a component renders, or inside an `effect` or `computed`, to react to
59
+ * changes.
60
+ *
61
+ * `''` when the site has no ID yet, for example an unsaved template in the editor.
62
+ *
63
+ * @exampleValue '6bd3b2c9-3f4a-4c1e-9b7e-2a1d5e8f0c43'
64
+ */
65
+ readonly siteId: string
50
66
  /** @internal Host-only. Replaces config values when the host's state changes. */
51
67
  _updateConfig: (config: Partial<ISiteInfoServiceConfig>) => void
52
68
  }
@@ -54,5 +70,5 @@ export interface ISiteInfoService {
54
70
  /** Definition of the Site Info service, used to resolve it from the services manager. */
55
71
  export type ISiteInfoDefinition = ServiceDefinition<ISiteInfoService, ISiteInfoServiceConfig>
56
72
 
57
- /** Definition of the Site Info service. Specify it in `useService()` or `servicesManager.getService()`. */
73
+ /** Definition of the Site Info service. Specify it in `useService()`. */
58
74
  export const SiteInfoDefinition = defineService<ISiteInfoService, ISiteInfoServiceConfig>('@wix/site-service-site-info')
@@ -10,6 +10,7 @@ export const SiteInfoService = implementService(
10
10
  const { signal } = getService(SignalsServiceDefinition)
11
11
  const _name = signal(config.name)
12
12
  const _revision = signal(config.revision)
13
+ const _siteId = signal(config.siteId)
13
14
 
14
15
  return {
15
16
  get name() {
@@ -18,6 +19,9 @@ export const SiteInfoService = implementService(
18
19
  get revision() {
19
20
  return _revision.get()
20
21
  },
22
+ get siteId() {
23
+ return _siteId.get()
24
+ },
21
25
  _updateConfig(update: Partial<ISiteInfoServiceConfig>) {
22
26
  if (typeof update.name !== 'undefined') {
23
27
  _name.set(update.name)
@@ -25,6 +29,9 @@ export const SiteInfoService = implementService(
25
29
  if (typeof update.revision !== 'undefined') {
26
30
  _revision.set(update.revision)
27
31
  }
32
+ if (typeof update.siteId !== 'undefined') {
33
+ _siteId.set(update.siteId)
34
+ }
28
35
  },
29
36
  }
30
37
  }