@wix/site-service-site-info 1.0.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/README.md +49 -0
- package/cjs/build/definition/index.d.ts +43 -0
- package/cjs/build/definition/index.js +6 -0
- package/cjs/build/definition/index.js.map +1 -0
- package/cjs/build/implementations/index.d.ts +1 -0
- package/cjs/build/implementations/index.js +6 -0
- package/cjs/build/implementations/index.js.map +1 -0
- package/cjs/build/implementations/siteInfoService.d.ts +6 -0
- package/cjs/build/implementations/siteInfoService.js +28 -0
- package/cjs/build/implementations/siteInfoService.js.map +1 -0
- package/cjs/build/index.d.ts +2 -0
- package/cjs/build/index.js +19 -0
- package/cjs/build/index.js.map +1 -0
- package/cjs/build/service.d.ts +7 -0
- package/cjs/build/service.js +8 -0
- package/cjs/build/service.js.map +1 -0
- package/cjs/build/types/index.d.ts +1 -0
- package/cjs/build/types/index.js +3 -0
- package/cjs/build/types/index.js.map +1 -0
- package/cjs/package.json +3 -0
- package/definition/package.json +3 -0
- package/dist/definition/index.d.ts +43 -0
- package/dist/definition/index.js +3 -0
- package/dist/definition/index.js.map +1 -0
- package/dist/implementations/index.d.ts +1 -0
- package/dist/implementations/index.js +2 -0
- package/dist/implementations/index.js.map +1 -0
- package/dist/implementations/siteInfoService.d.ts +6 -0
- package/dist/implementations/siteInfoService.js +25 -0
- package/dist/implementations/siteInfoService.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/service.d.ts +7 -0
- package/dist/service.js +5 -0
- package/dist/service.js.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/implementations/package.json +3 -0
- package/package.json +81 -0
- package/src/definition/index.ts +44 -0
- package/src/implementations/index.ts +1 -0
- package/src/implementations/siteInfoService.ts +31 -0
- package/src/index.ts +2 -0
- package/src/service.ts +5 -0
- package/src/types/index.ts +1 -0
- package/types/package.json +3 -0
package/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# @wix/site-service-site-info
|
|
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.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
yarn add @wix/site-service-site-info
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { SiteInfoDefinition } from '@wix/site-service-site-info/definition'
|
|
15
|
+
|
|
16
|
+
const siteInfo = servicesManager.getService(SiteInfoDefinition)
|
|
17
|
+
|
|
18
|
+
siteInfo.siteName // 'My Bakery'
|
|
19
|
+
siteInfo.siteRevision // 42
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Read through the service object, not a destructured copy: a destructured value doesn't see later updates.
|
|
23
|
+
|
|
24
|
+
Declare `'@wix/site-service-site-info'` in your component's `serviceDependencies`.
|
|
25
|
+
|
|
26
|
+
## API
|
|
27
|
+
|
|
28
|
+
| Member | Type | Throws when | Description |
|
|
29
|
+
|---|---|---|---|
|
|
30
|
+
| `siteName` | `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
|
+
| `siteRevision` | `number` | never | Revision of the site that is being rendered. `0` when there is no revision. |
|
|
32
|
+
| `_updateConfig` | `(Partial<ISiteInfoServiceConfig>) => void` | never | Private replace-on-write updater for provided fields. |
|
|
33
|
+
|
|
34
|
+
## Configuration
|
|
35
|
+
|
|
36
|
+
`ISiteInfoServiceConfig`:
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
type ISiteInfoServiceConfig = {
|
|
40
|
+
siteName: string
|
|
41
|
+
siteRevision: number
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Injected by the host. `siteName` comes from the site's properties, and `siteRevision` from the published site. The host passes `0` when it has no revision.
|
|
46
|
+
|
|
47
|
+
## Reactivity
|
|
48
|
+
|
|
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.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ServiceDefinition } from '@wix/services-definitions';
|
|
2
|
+
/** Values the host supplies when it creates the service. */
|
|
3
|
+
export type ISiteInfoServiceConfig = {
|
|
4
|
+
/**
|
|
5
|
+
* Display name of the site, or `''` when the site has none.
|
|
6
|
+
*
|
|
7
|
+
* @exampleValue 'My Bakery'
|
|
8
|
+
*/
|
|
9
|
+
siteName: string;
|
|
10
|
+
/**
|
|
11
|
+
* Revision of the site that is being rendered. `0` when the host has no revision.
|
|
12
|
+
*
|
|
13
|
+
* @exampleValue 42
|
|
14
|
+
*/
|
|
15
|
+
siteRevision: number;
|
|
16
|
+
};
|
|
17
|
+
/** Information about the site that is being rendered. Both values can change during an editor session. */
|
|
18
|
+
export interface ISiteInfoService {
|
|
19
|
+
/**
|
|
20
|
+
* Display name of the site, as set in the site's settings.
|
|
21
|
+
*
|
|
22
|
+
* `''` when the site has no display name.
|
|
23
|
+
*
|
|
24
|
+
* @exampleValue 'My Bakery'
|
|
25
|
+
*/
|
|
26
|
+
readonly siteName: string;
|
|
27
|
+
/**
|
|
28
|
+
* Revision of the site that is being rendered.
|
|
29
|
+
*
|
|
30
|
+
* `0` when there is no revision.
|
|
31
|
+
*
|
|
32
|
+
* @exampleValue 42
|
|
33
|
+
*/
|
|
34
|
+
readonly siteRevision: number;
|
|
35
|
+
/** Called by the host when the site is renamed or gets a new revision. Fields left out keep their value. */
|
|
36
|
+
_updateConfig: (config: Partial<ISiteInfoServiceConfig>) => void;
|
|
37
|
+
}
|
|
38
|
+
export type ISiteInfoDefinition = ServiceDefinition<ISiteInfoService, ISiteInfoServiceConfig>;
|
|
39
|
+
export declare const SiteInfoDefinition: string & {
|
|
40
|
+
__api: ISiteInfoService;
|
|
41
|
+
__config: ISiteInfoServiceConfig;
|
|
42
|
+
isServiceDefinition?: boolean;
|
|
43
|
+
} & ISiteInfoService;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SiteInfoDefinition = void 0;
|
|
4
|
+
const services_definitions_1 = require("@wix/services-definitions");
|
|
5
|
+
exports.SiteInfoDefinition = (0, services_definitions_1.defineService)('@wix/site-service-site-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;AA2C5C,QAAA,kBAAkB,GAAG,IAAA,oCAAa,EAA2C,6BAA6B,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SiteInfoService } from './siteInfoService';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SiteInfoService = void 0;
|
|
4
|
+
var siteInfoService_1 = require("./siteInfoService");
|
|
5
|
+
Object.defineProperty(exports, "SiteInfoService", { enumerable: true, get: function () { return siteInfoService_1.SiteInfoService; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/implementations/index.ts"],"names":[],"mappings":";;;AAAA,qDAAmD;AAA1C,kHAAA,eAAe,OAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ISiteInfoService, ISiteInfoServiceConfig } from '../definition';
|
|
2
|
+
export declare const SiteInfoService: import("@wix/services-definitions").ServiceFactory<string & {
|
|
3
|
+
__api: ISiteInfoService;
|
|
4
|
+
__config: ISiteInfoServiceConfig;
|
|
5
|
+
isServiceDefinition?: boolean;
|
|
6
|
+
} & ISiteInfoService, ISiteInfoServiceConfig>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SiteInfoService = 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
|
+
exports.SiteInfoService = (0, services_definitions_1.implementService)(definition_1.SiteInfoDefinition, ({ config, getService }) => {
|
|
8
|
+
const { signal } = getService(signals_1.SignalsServiceDefinition);
|
|
9
|
+
const _siteName = signal(config.siteName);
|
|
10
|
+
const _siteRevision = signal(config.siteRevision);
|
|
11
|
+
return {
|
|
12
|
+
get siteName() {
|
|
13
|
+
return _siteName.get();
|
|
14
|
+
},
|
|
15
|
+
get siteRevision() {
|
|
16
|
+
return _siteRevision.get();
|
|
17
|
+
},
|
|
18
|
+
_updateConfig(update) {
|
|
19
|
+
if (typeof update.siteName !== 'undefined') {
|
|
20
|
+
_siteName.set(update.siteName);
|
|
21
|
+
}
|
|
22
|
+
if (typeof update.siteRevision !== 'undefined') {
|
|
23
|
+
_siteRevision.set(update.siteRevision);
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
//# sourceMappingURL=siteInfoService.js.map
|
|
@@ -0,0 +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,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IACzC,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAA;IAEjD,OAAO;QACN,IAAI,QAAQ;YACX,OAAO,SAAS,CAAC,GAAG,EAAE,CAAA;QACvB,CAAC;QACD,IAAI,YAAY;YACf,OAAO,aAAa,CAAC,GAAG,EAAE,CAAA;QAC3B,CAAC;QACD,aAAa,CAAC,MAAuC;YACpD,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,YAAY,KAAK,WAAW,EAAE,CAAC;gBAChD,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,CAAA;YACvC,CAAC;QACF,CAAC;KACD,CAAA;AACF,CAAC,CACD,CAAA"}
|
|
@@ -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 { SiteInfoService } from './implementations/siteInfoService';
|
|
2
|
+
export declare const definition: string & {
|
|
3
|
+
__api: import("./definition").ISiteInfoService;
|
|
4
|
+
__config: import("./definition").ISiteInfoServiceConfig;
|
|
5
|
+
isServiceDefinition?: boolean;
|
|
6
|
+
} & import("./definition").ISiteInfoService;
|
|
7
|
+
export default SiteInfoService;
|
|
@@ -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 siteInfoService_1 = require("./implementations/siteInfoService");
|
|
6
|
+
exports.definition = definition_1.SiteInfoDefinition;
|
|
7
|
+
exports.default = siteInfoService_1.SiteInfoService;
|
|
8
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/service.ts"],"names":[],"mappings":";;;AAAA,6CAAiD;AACjD,uEAAmE;AAEtD,QAAA,UAAU,GAAG,+BAAkB,CAAA;kBAC7B,iCAAe"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { ISiteInfoService, ISiteInfoServiceConfig, ISiteInfoDefinition } from '../definition';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":""}
|
package/cjs/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ServiceDefinition } from '@wix/services-definitions';
|
|
2
|
+
/** Values the host supplies when it creates the service. */
|
|
3
|
+
export type ISiteInfoServiceConfig = {
|
|
4
|
+
/**
|
|
5
|
+
* Display name of the site, or `''` when the site has none.
|
|
6
|
+
*
|
|
7
|
+
* @exampleValue 'My Bakery'
|
|
8
|
+
*/
|
|
9
|
+
siteName: string;
|
|
10
|
+
/**
|
|
11
|
+
* Revision of the site that is being rendered. `0` when the host has no revision.
|
|
12
|
+
*
|
|
13
|
+
* @exampleValue 42
|
|
14
|
+
*/
|
|
15
|
+
siteRevision: number;
|
|
16
|
+
};
|
|
17
|
+
/** Information about the site that is being rendered. Both values can change during an editor session. */
|
|
18
|
+
export interface ISiteInfoService {
|
|
19
|
+
/**
|
|
20
|
+
* Display name of the site, as set in the site's settings.
|
|
21
|
+
*
|
|
22
|
+
* `''` when the site has no display name.
|
|
23
|
+
*
|
|
24
|
+
* @exampleValue 'My Bakery'
|
|
25
|
+
*/
|
|
26
|
+
readonly siteName: string;
|
|
27
|
+
/**
|
|
28
|
+
* Revision of the site that is being rendered.
|
|
29
|
+
*
|
|
30
|
+
* `0` when there is no revision.
|
|
31
|
+
*
|
|
32
|
+
* @exampleValue 42
|
|
33
|
+
*/
|
|
34
|
+
readonly siteRevision: number;
|
|
35
|
+
/** Called by the host when the site is renamed or gets a new revision. Fields left out keep their value. */
|
|
36
|
+
_updateConfig: (config: Partial<ISiteInfoServiceConfig>) => void;
|
|
37
|
+
}
|
|
38
|
+
export type ISiteInfoDefinition = ServiceDefinition<ISiteInfoService, ISiteInfoServiceConfig>;
|
|
39
|
+
export declare const SiteInfoDefinition: string & {
|
|
40
|
+
__api: ISiteInfoService;
|
|
41
|
+
__config: ISiteInfoServiceConfig;
|
|
42
|
+
isServiceDefinition?: boolean;
|
|
43
|
+
} & ISiteInfoService;
|
|
@@ -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;AA2CzD,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAA2C,6BAA6B,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SiteInfoService } from './siteInfoService';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/implementations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ISiteInfoService, ISiteInfoServiceConfig } from '../definition';
|
|
2
|
+
export declare const SiteInfoService: import("@wix/services-definitions").ServiceFactory<string & {
|
|
3
|
+
__api: ISiteInfoService;
|
|
4
|
+
__config: ISiteInfoServiceConfig;
|
|
5
|
+
isServiceDefinition?: boolean;
|
|
6
|
+
} & ISiteInfoService, ISiteInfoServiceConfig>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { implementService } from '@wix/services-definitions';
|
|
2
|
+
import { SignalsServiceDefinition } from '@wix/services-definitions/core-services/signals';
|
|
3
|
+
import { SiteInfoDefinition } from '../definition';
|
|
4
|
+
export const SiteInfoService = implementService(SiteInfoDefinition, ({ config, getService }) => {
|
|
5
|
+
const { signal } = getService(SignalsServiceDefinition);
|
|
6
|
+
const _siteName = signal(config.siteName);
|
|
7
|
+
const _siteRevision = signal(config.siteRevision);
|
|
8
|
+
return {
|
|
9
|
+
get siteName() {
|
|
10
|
+
return _siteName.get();
|
|
11
|
+
},
|
|
12
|
+
get siteRevision() {
|
|
13
|
+
return _siteRevision.get();
|
|
14
|
+
},
|
|
15
|
+
_updateConfig(update) {
|
|
16
|
+
if (typeof update.siteName !== 'undefined') {
|
|
17
|
+
_siteName.set(update.siteName);
|
|
18
|
+
}
|
|
19
|
+
if (typeof update.siteRevision !== 'undefined') {
|
|
20
|
+
_siteRevision.set(update.siteRevision);
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=siteInfoService.js.map
|
|
@@ -0,0 +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,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IACzC,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAA;IAEjD,OAAO;QACN,IAAI,QAAQ;YACX,OAAO,SAAS,CAAC,GAAG,EAAE,CAAA;QACvB,CAAC;QACD,IAAI,YAAY;YACf,OAAO,aAAa,CAAC,GAAG,EAAE,CAAA;QAC3B,CAAC;QACD,aAAa,CAAC,MAAuC;YACpD,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,YAAY,KAAK,WAAW,EAAE,CAAC;gBAChD,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,CAAA;YACvC,CAAC;QACF,CAAC;KACD,CAAA;AACF,CAAC,CACD,CAAA"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -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 { SiteInfoService } from './implementations/siteInfoService';
|
|
2
|
+
export declare const definition: string & {
|
|
3
|
+
__api: import("./definition").ISiteInfoService;
|
|
4
|
+
__config: import("./definition").ISiteInfoServiceConfig;
|
|
5
|
+
isServiceDefinition?: boolean;
|
|
6
|
+
} & import("./definition").ISiteInfoService;
|
|
7
|
+
export default SiteInfoService;
|
package/dist/service.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AAEnE,MAAM,CAAC,MAAM,UAAU,GAAG,kBAAkB,CAAA;AAC5C,eAAe,eAAe,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { ISiteInfoService, ISiteInfoServiceConfig, ISiteInfoDefinition } from '../definition';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wix/site-service-site-info",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"license": "UNLICENSED",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist",
|
|
7
|
+
"src",
|
|
8
|
+
"cjs",
|
|
9
|
+
"definition",
|
|
10
|
+
"implementations",
|
|
11
|
+
"types",
|
|
12
|
+
"!**/*.tsbuildinfo"
|
|
13
|
+
],
|
|
14
|
+
"sideEffects": false,
|
|
15
|
+
"main": "cjs/build/index.js",
|
|
16
|
+
"module": "dist/index.js",
|
|
17
|
+
"types": "dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js",
|
|
22
|
+
"require": "./cjs/build/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./definition": {
|
|
25
|
+
"types": "./dist/definition/index.d.ts",
|
|
26
|
+
"import": "./dist/definition/index.js",
|
|
27
|
+
"require": "./cjs/build/definition/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./implementations": {
|
|
30
|
+
"types": "./dist/implementations/index.d.ts",
|
|
31
|
+
"import": "./dist/implementations/index.js",
|
|
32
|
+
"require": "./cjs/build/implementations/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./types": {
|
|
35
|
+
"types": "./dist/types/index.d.ts",
|
|
36
|
+
"import": "./dist/types/index.js",
|
|
37
|
+
"require": "./cjs/build/types/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./service": {
|
|
40
|
+
"types": "./dist/service.d.ts",
|
|
41
|
+
"import": "./dist/service.js",
|
|
42
|
+
"require": "./cjs/build/service.js"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"registry": "https://registry.npmjs.org/",
|
|
47
|
+
"access": "public"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "tsc -b . --force && tsc --project tsconfig.cjs.json",
|
|
51
|
+
"lint": "yarn run -T lint:package $npm_package_name",
|
|
52
|
+
"test": "vitest --run && yarn test-type-check",
|
|
53
|
+
"test-type-check": "echo 'validating typescript in test files' && tsc --project tsconfig.test.json && echo 'Finished validating typescript in test files successfully'"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@wix/services-definitions": "^0.1.4",
|
|
57
|
+
"@wix/services-manager": "^0.2.20"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"typescript": "~7.0.2",
|
|
61
|
+
"vitest": "4.1.11"
|
|
62
|
+
},
|
|
63
|
+
"publishUnscoped": false,
|
|
64
|
+
"wix": {
|
|
65
|
+
"artifact": {
|
|
66
|
+
"groupId": "com.wixpress.npm",
|
|
67
|
+
"artifactId": "site-service-site-info",
|
|
68
|
+
"targets": {
|
|
69
|
+
"static": false,
|
|
70
|
+
"docker": false
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"validations": {
|
|
74
|
+
"postBuild": [
|
|
75
|
+
"test",
|
|
76
|
+
"lint"
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"falconPackageHash": "57adc89677e747ce1214468335f3ac20d2203cf6d2d6223797a83bb4"
|
|
81
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { defineService } from '@wix/services-definitions'
|
|
2
|
+
import type { ServiceDefinition } from '@wix/services-definitions'
|
|
3
|
+
|
|
4
|
+
/** Values the host supplies when it creates the service. */
|
|
5
|
+
export type ISiteInfoServiceConfig = {
|
|
6
|
+
/**
|
|
7
|
+
* Display name of the site, or `''` when the site has none.
|
|
8
|
+
*
|
|
9
|
+
* @exampleValue 'My Bakery'
|
|
10
|
+
*/
|
|
11
|
+
siteName: string
|
|
12
|
+
/**
|
|
13
|
+
* Revision of the site that is being rendered. `0` when the host has no revision.
|
|
14
|
+
*
|
|
15
|
+
* @exampleValue 42
|
|
16
|
+
*/
|
|
17
|
+
siteRevision: number
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Information about the site that is being rendered. Both values can change during an editor session. */
|
|
21
|
+
export interface ISiteInfoService {
|
|
22
|
+
/**
|
|
23
|
+
* Display name of the site, as set in the site's settings.
|
|
24
|
+
*
|
|
25
|
+
* `''` when the site has no display name.
|
|
26
|
+
*
|
|
27
|
+
* @exampleValue 'My Bakery'
|
|
28
|
+
*/
|
|
29
|
+
readonly siteName: string
|
|
30
|
+
/**
|
|
31
|
+
* Revision of the site that is being rendered.
|
|
32
|
+
*
|
|
33
|
+
* `0` when there is no revision.
|
|
34
|
+
*
|
|
35
|
+
* @exampleValue 42
|
|
36
|
+
*/
|
|
37
|
+
readonly siteRevision: number
|
|
38
|
+
/** Called by the host when the site is renamed or gets a new revision. Fields left out keep their value. */
|
|
39
|
+
_updateConfig: (config: Partial<ISiteInfoServiceConfig>) => void
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type ISiteInfoDefinition = ServiceDefinition<ISiteInfoService, ISiteInfoServiceConfig>
|
|
43
|
+
|
|
44
|
+
export const SiteInfoDefinition = defineService<ISiteInfoService, ISiteInfoServiceConfig>('@wix/site-service-site-info')
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SiteInfoService } from './siteInfoService'
|
|
@@ -0,0 +1,31 @@
|
|
|
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 { ISiteInfoService, ISiteInfoServiceConfig } from '../definition'
|
|
5
|
+
import { SiteInfoDefinition } from '../definition'
|
|
6
|
+
|
|
7
|
+
export const SiteInfoService = implementService(
|
|
8
|
+
SiteInfoDefinition,
|
|
9
|
+
({ config, getService }: ServiceFactoryOpts<ISiteInfoServiceConfig>): ISiteInfoService => {
|
|
10
|
+
const { signal } = getService(SignalsServiceDefinition)
|
|
11
|
+
const _siteName = signal(config.siteName)
|
|
12
|
+
const _siteRevision = signal(config.siteRevision)
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
get siteName() {
|
|
16
|
+
return _siteName.get()
|
|
17
|
+
},
|
|
18
|
+
get siteRevision() {
|
|
19
|
+
return _siteRevision.get()
|
|
20
|
+
},
|
|
21
|
+
_updateConfig(update: Partial<ISiteInfoServiceConfig>) {
|
|
22
|
+
if (typeof update.siteName !== 'undefined') {
|
|
23
|
+
_siteName.set(update.siteName)
|
|
24
|
+
}
|
|
25
|
+
if (typeof update.siteRevision !== 'undefined') {
|
|
26
|
+
_siteRevision.set(update.siteRevision)
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
)
|
package/src/index.ts
ADDED
package/src/service.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { ISiteInfoService, ISiteInfoServiceConfig, ISiteInfoDefinition } from '../definition'
|