@wix/site-service-site-info 1.0.5 → 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 +6 -3
- package/cjs/build/definition/index.d.ts +19 -1
- package/cjs/build/definition/index.js.map +1 -1
- package/cjs/build/implementations/siteInfoService.js +7 -0
- package/cjs/build/implementations/siteInfoService.js.map +1 -1
- package/dist/definition/index.d.ts +19 -1
- package/dist/definition/index.js.map +1 -1
- package/dist/implementations/siteInfoService.js +7 -0
- package/dist/implementations/siteInfoService.js.map +1 -1
- package/package.json +2 -2
- package/src/definition/index.ts +19 -1
- package/src/implementations/siteInfoService.ts +7 -0
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
|
|
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`.
|
|
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,8 +13,14 @@ 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
|
|
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.
|
|
@@ -42,6 +48,18 @@ export interface ISiteInfoService {
|
|
|
42
48
|
* @exampleValue 42
|
|
43
49
|
*/
|
|
44
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;
|
|
45
63
|
/** @internal Host-only. Replaces config values when the host's state changes. */
|
|
46
64
|
_updateConfig: (config: Partial<ISiteInfoServiceConfig>) => void;
|
|
47
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/definition/index.ts"],"names":[],"mappings":";;;AAAA,oEAAyD;
|
|
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;
|
|
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,8 +13,14 @@ 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
|
|
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.
|
|
@@ -42,6 +48,18 @@ export interface ISiteInfoService {
|
|
|
42
48
|
* @exampleValue 42
|
|
43
49
|
*/
|
|
44
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;
|
|
45
63
|
/** @internal Host-only. Replaces config values when the host's state changes. */
|
|
46
64
|
_updateConfig: (config: Partial<ISiteInfoServiceConfig>) => void;
|
|
47
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/definition/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,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;
|
|
1
|
+
{"version":3,"file":"siteInfoService.js","sourceRoot":"","sources":["../../src/implementations/siteInfoService.ts"],"names":[],"mappings":"AAAA,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/site-service-site-info",
|
|
3
|
-
"version": "1.0.
|
|
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": "
|
|
80
|
+
"falconPackageHash": "19dc63e9d20d5a46566d8e41fa11959e7eb862d95fe6bff8a1b9fcaf"
|
|
81
81
|
}
|
package/src/definition/index.ts
CHANGED
|
@@ -15,9 +15,15 @@ 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
|
|
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.
|
|
@@ -45,6 +51,18 @@ export interface ISiteInfoService {
|
|
|
45
51
|
* @exampleValue 42
|
|
46
52
|
*/
|
|
47
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
|
|
48
66
|
/** @internal Host-only. Replaces config values when the host's state changes. */
|
|
49
67
|
_updateConfig: (config: Partial<ISiteInfoServiceConfig>) => void
|
|
50
68
|
}
|
|
@@ -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
|
}
|