@wix/site-service-pages 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 +62 -0
  2. package/cjs/build/definition/index.d.ts +38 -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/index.d.ts +1 -0
  6. package/cjs/build/implementations/index.js +6 -0
  7. package/cjs/build/implementations/index.js.map +1 -0
  8. package/cjs/build/implementations/pagesService.d.ts +6 -0
  9. package/cjs/build/implementations/pagesService.js +35 -0
  10. package/cjs/build/implementations/pagesService.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 +1 -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 +38 -0
  23. package/dist/definition/index.js +3 -0
  24. package/dist/definition/index.js.map +1 -0
  25. package/dist/implementations/index.d.ts +1 -0
  26. package/dist/implementations/index.js +2 -0
  27. package/dist/implementations/index.js.map +1 -0
  28. package/dist/implementations/pagesService.d.ts +6 -0
  29. package/dist/implementations/pagesService.js +32 -0
  30. package/dist/implementations/pagesService.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 +1 -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 +37 -0
  43. package/src/implementations/index.ts +1 -0
  44. package/src/implementations/pagesService.ts +38 -0
  45. package/src/index.ts +2 -0
  46. package/src/service.ts +5 -0
  47. package/src/types/index.ts +1 -0
  48. package/types/package.json +3 -0
package/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # @wix/site-service-pages
2
+
3
+ Provides all site pages (with popup flag), the current page, and the main page.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ yarn add @wix/site-service-pages
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { PagesDefinition } from '@wix/site-service-pages/definition'
15
+ import { PagesService } from '@wix/site-service-pages/implementations'
16
+
17
+ createServicesMap().addService(PagesDefinition, PagesService, config)
18
+
19
+ const service = servicesManager.getService(PagesDefinition)
20
+ // service.pages ← Record<string, Page>
21
+ // service.mainPage ← Page (resolved by provider, stored as-is)
22
+ // service.currentPage ← Page (resolved by provider, stored as-is)
23
+ ```
24
+
25
+ ## API
26
+
27
+ | Member | Type | Throws when | Description |
28
+ |---|---|---|---|
29
+ | `pages` | `Record<string, Page>` | never | All pages with `id` stamped from map key. |
30
+ | `mainPage` | `Page` | never | The site's main/home page as provided. |
31
+ | `currentPage` | `Page` | never | The currently active page as provided. |
32
+ | `_updateConfig` | `(Partial<IPagesServiceConfig>) => void` | never | Replace-on-write per field. Re-stamps `id` on `pages` update. |
33
+
34
+ ## Configuration
35
+
36
+ `IPagesServiceConfig`:
37
+
38
+ ```ts
39
+ type IPagesServiceConfig = {
40
+ /** id-as-key map; values omit `id` (P3). Service stamps id at write time (P16). */
41
+ pages: Record<string, PageConfig>
42
+ /** Provider resolves and passes the full main page object. */
43
+ mainPage: Page
44
+ /** Provider resolves and passes the full current page object. */
45
+ currentPage: Page
46
+ }
47
+
48
+ type PageConfig = {
49
+ title: string
50
+ path: string
51
+ parentPageId?: string
52
+ popup: boolean
53
+ }
54
+
55
+ type Page = PageConfig & { id: string }
56
+ ```
57
+
58
+ The provider is responsible for resolving which page is `mainPage` / `currentPage` before injecting config. The service stores them as independent signals and does no internal lookup.
59
+
60
+ ## Reactivity
61
+
62
+ This service is a thin signal wrapper over `@wix/services-definitions/core-services/signals`. All three properties are signal-backed; wrap reads in `effect` / `computed` to react to changes. Signals are not exposed directly.
@@ -0,0 +1,38 @@
1
+ import type { ServiceDefinition } from '@wix/services-definitions';
2
+ export type Page = {
3
+ id: string;
4
+ title: string;
5
+ path: string;
6
+ parentPageId?: string;
7
+ popup: boolean;
8
+ };
9
+ export type PageConfig = {
10
+ title: string;
11
+ path: string;
12
+ parentPageId?: string;
13
+ popup: boolean;
14
+ };
15
+ export type IPagesServiceConfig = {
16
+ /** id-as-key map; values omit `id` — callers use the key as the id (P3). */
17
+ pages: {
18
+ [pageId: string]: PageConfig;
19
+ };
20
+ /** Provider resolves and passes the full main page object; service stores it as-is. */
21
+ mainPage: Page;
22
+ /** Provider resolves and passes the full current page object; service stores it as-is. */
23
+ currentPage: Page;
24
+ };
25
+ export interface IPagesService {
26
+ readonly pages: {
27
+ [pageId: string]: PageConfig;
28
+ };
29
+ readonly mainPage: Page;
30
+ readonly currentPage: Page;
31
+ _updateConfig: (config: Partial<IPagesServiceConfig>) => void;
32
+ }
33
+ export type IPagesDefinition = ServiceDefinition<IPagesService, IPagesServiceConfig>;
34
+ export declare const PagesDefinition: string & {
35
+ __api: IPagesService;
36
+ __config: IPagesServiceConfig;
37
+ isServiceDefinition?: boolean;
38
+ } & IPagesService;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PagesDefinition = void 0;
4
+ const services_definitions_1 = require("@wix/services-definitions");
5
+ exports.PagesDefinition = (0, services_definitions_1.defineService)('@wix/site-service-pages');
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/definition/index.ts"],"names":[],"mappings":";;;AAAA,oEAAyD;AAoC5C,QAAA,eAAe,GAAG,IAAA,oCAAa,EAAqC,yBAAyB,CAAC,CAAA"}
@@ -0,0 +1 @@
1
+ export { PagesService } from './pagesService';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PagesService = void 0;
4
+ var pagesService_1 = require("./pagesService");
5
+ Object.defineProperty(exports, "PagesService", { enumerable: true, get: function () { return pagesService_1.PagesService; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/implementations/index.ts"],"names":[],"mappings":";;;AAAA,+CAA6C;AAApC,4GAAA,YAAY,OAAA"}
@@ -0,0 +1,6 @@
1
+ import type { IPagesService, IPagesServiceConfig } from '../definition';
2
+ export declare const PagesService: import("@wix/services-definitions").ServiceFactory<string & {
3
+ __api: IPagesService;
4
+ __config: IPagesServiceConfig;
5
+ isServiceDefinition?: boolean;
6
+ } & IPagesService, IPagesServiceConfig>;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PagesService = 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.PagesService = (0, services_definitions_1.implementService)(definition_1.PagesDefinition, ({ config, getService }) => {
8
+ const { signal } = getService(signals_1.SignalsServiceDefinition);
9
+ const _pages = signal(config.pages);
10
+ const _mainPage = signal(config.mainPage);
11
+ const _currentPage = signal(config.currentPage);
12
+ return {
13
+ get pages() {
14
+ return _pages.get();
15
+ },
16
+ get mainPage() {
17
+ return _mainPage.get();
18
+ },
19
+ get currentPage() {
20
+ return _currentPage.get();
21
+ },
22
+ _updateConfig(partialConfig) {
23
+ if (partialConfig.pages) {
24
+ _pages.set(partialConfig.pages);
25
+ }
26
+ if (partialConfig.mainPage) {
27
+ _mainPage.set(partialConfig.mainPage);
28
+ }
29
+ if (partialConfig.currentPage) {
30
+ _currentPage.set(partialConfig.currentPage);
31
+ }
32
+ },
33
+ };
34
+ });
35
+ //# sourceMappingURL=pagesService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagesService.js","sourceRoot":"","sources":["../../../src/implementations/pagesService.ts"],"names":[],"mappings":";;;AAAA,oEAA4D;AAE5D,6EAA0F;AAE1F,8CAA+C;AAElC,QAAA,YAAY,GAAG,IAAA,uCAAgB,EACxC,4BAAe,EACf,CAAC,EAAE,MAAM,EAAE,UAAU,EAA2C,EAAiB,EAAE;IAC/E,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,kCAAwB,CAAC,CAAA;IACvD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IACnC,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IACzC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAA;IAE/C,OAAO;QACH,IAAI,KAAK;YACL,OAAO,MAAM,CAAC,GAAG,EAAE,CAAA;QACvB,CAAC;QACD,IAAI,QAAQ;YACR,OAAO,SAAS,CAAC,GAAG,EAAE,CAAA;QAC1B,CAAC;QACD,IAAI,WAAW;YACX,OAAO,YAAY,CAAC,GAAG,EAAE,CAAA;QAC7B,CAAC;QACD,aAAa,CAAC,aAAa;YACvB,IAAI,aAAa,CAAC,KAAK,EAAE,CAAC;gBACtB,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;YACnC,CAAC;YACD,IAAI,aAAa,CAAC,QAAQ,EAAE,CAAC;gBACzB,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;YACzC,CAAC;YACD,IAAI,aAAa,CAAC,WAAW,EAAE,CAAC;gBAC5B,YAAY,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,CAAC,CAAA;YAC/C,CAAC;QACL,CAAC;KACJ,CAAA;AACL,CAAC,CACJ,CAAA"}
@@ -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 { PagesService } from './implementations/pagesService';
2
+ export declare const definition: string & {
3
+ __api: import("./definition").IPagesService;
4
+ __config: import("./definition").IPagesServiceConfig;
5
+ isServiceDefinition?: boolean;
6
+ } & import("./definition").IPagesService;
7
+ export default PagesService;
@@ -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 pagesService_1 = require("./implementations/pagesService");
6
+ exports.definition = definition_1.PagesDefinition;
7
+ exports.default = pagesService_1.PagesService;
8
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/service.ts"],"names":[],"mappings":";;;AAAA,6CAA8C;AAC9C,iEAA6D;AAEhD,QAAA,UAAU,GAAG,4BAAe,CAAA;AACzC,kBAAe,2BAAY,CAAA"}
@@ -0,0 +1 @@
1
+ export type { Page, PageConfig, IPagesService, IPagesServiceConfig, IPagesDefinition } 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,38 @@
1
+ import type { ServiceDefinition } from '@wix/services-definitions';
2
+ export type Page = {
3
+ id: string;
4
+ title: string;
5
+ path: string;
6
+ parentPageId?: string;
7
+ popup: boolean;
8
+ };
9
+ export type PageConfig = {
10
+ title: string;
11
+ path: string;
12
+ parentPageId?: string;
13
+ popup: boolean;
14
+ };
15
+ export type IPagesServiceConfig = {
16
+ /** id-as-key map; values omit `id` — callers use the key as the id (P3). */
17
+ pages: {
18
+ [pageId: string]: PageConfig;
19
+ };
20
+ /** Provider resolves and passes the full main page object; service stores it as-is. */
21
+ mainPage: Page;
22
+ /** Provider resolves and passes the full current page object; service stores it as-is. */
23
+ currentPage: Page;
24
+ };
25
+ export interface IPagesService {
26
+ readonly pages: {
27
+ [pageId: string]: PageConfig;
28
+ };
29
+ readonly mainPage: Page;
30
+ readonly currentPage: Page;
31
+ _updateConfig: (config: Partial<IPagesServiceConfig>) => void;
32
+ }
33
+ export type IPagesDefinition = ServiceDefinition<IPagesService, IPagesServiceConfig>;
34
+ export declare const PagesDefinition: string & {
35
+ __api: IPagesService;
36
+ __config: IPagesServiceConfig;
37
+ isServiceDefinition?: boolean;
38
+ } & IPagesService;
@@ -0,0 +1,3 @@
1
+ import { defineService } from '@wix/services-definitions';
2
+ export const PagesDefinition = defineService('@wix/site-service-pages');
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;AAoCzD,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAqC,yBAAyB,CAAC,CAAA"}
@@ -0,0 +1 @@
1
+ export { PagesService } from './pagesService';
@@ -0,0 +1,2 @@
1
+ export { PagesService } from './pagesService';
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,YAAY,EAAE,MAAM,gBAAgB,CAAA"}
@@ -0,0 +1,6 @@
1
+ import type { IPagesService, IPagesServiceConfig } from '../definition';
2
+ export declare const PagesService: import("@wix/services-definitions").ServiceFactory<string & {
3
+ __api: IPagesService;
4
+ __config: IPagesServiceConfig;
5
+ isServiceDefinition?: boolean;
6
+ } & IPagesService, IPagesServiceConfig>;
@@ -0,0 +1,32 @@
1
+ import { implementService } from '@wix/services-definitions';
2
+ import { SignalsServiceDefinition } from '@wix/services-definitions/core-services/signals';
3
+ import { PagesDefinition } from '../definition';
4
+ export const PagesService = implementService(PagesDefinition, ({ config, getService }) => {
5
+ const { signal } = getService(SignalsServiceDefinition);
6
+ const _pages = signal(config.pages);
7
+ const _mainPage = signal(config.mainPage);
8
+ const _currentPage = signal(config.currentPage);
9
+ return {
10
+ get pages() {
11
+ return _pages.get();
12
+ },
13
+ get mainPage() {
14
+ return _mainPage.get();
15
+ },
16
+ get currentPage() {
17
+ return _currentPage.get();
18
+ },
19
+ _updateConfig(partialConfig) {
20
+ if (partialConfig.pages) {
21
+ _pages.set(partialConfig.pages);
22
+ }
23
+ if (partialConfig.mainPage) {
24
+ _mainPage.set(partialConfig.mainPage);
25
+ }
26
+ if (partialConfig.currentPage) {
27
+ _currentPage.set(partialConfig.currentPage);
28
+ }
29
+ },
30
+ };
31
+ });
32
+ //# sourceMappingURL=pagesService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagesService.js","sourceRoot":"","sources":["../../src/implementations/pagesService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAE5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,iDAAiD,CAAA;AAE1F,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAE/C,MAAM,CAAC,MAAM,YAAY,GAAG,gBAAgB,CACxC,eAAe,EACf,CAAC,EAAE,MAAM,EAAE,UAAU,EAA2C,EAAiB,EAAE;IAC/E,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,wBAAwB,CAAC,CAAA;IACvD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IACnC,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IACzC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAA;IAE/C,OAAO;QACH,IAAI,KAAK;YACL,OAAO,MAAM,CAAC,GAAG,EAAE,CAAA;QACvB,CAAC;QACD,IAAI,QAAQ;YACR,OAAO,SAAS,CAAC,GAAG,EAAE,CAAA;QAC1B,CAAC;QACD,IAAI,WAAW;YACX,OAAO,YAAY,CAAC,GAAG,EAAE,CAAA;QAC7B,CAAC;QACD,aAAa,CAAC,aAAa;YACvB,IAAI,aAAa,CAAC,KAAK,EAAE,CAAC;gBACtB,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;YACnC,CAAC;YACD,IAAI,aAAa,CAAC,QAAQ,EAAE,CAAC;gBACzB,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;YACzC,CAAC;YACD,IAAI,aAAa,CAAC,WAAW,EAAE,CAAC;gBAC5B,YAAY,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,CAAC,CAAA;YAC/C,CAAC;QACL,CAAC;KACJ,CAAA;AACL,CAAC,CACJ,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 { PagesService } from './implementations/pagesService';
2
+ export declare const definition: string & {
3
+ __api: import("./definition").IPagesService;
4
+ __config: import("./definition").IPagesServiceConfig;
5
+ isServiceDefinition?: boolean;
6
+ } & import("./definition").IPagesService;
7
+ export default PagesService;
@@ -0,0 +1,5 @@
1
+ import { PagesDefinition } from './definition';
2
+ import { PagesService } from './implementations/pagesService';
3
+ export const definition = PagesDefinition;
4
+ export default PagesService;
5
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAA;AAE7D,MAAM,CAAC,MAAM,UAAU,GAAG,eAAe,CAAA;AACzC,eAAe,YAAY,CAAA"}
@@ -0,0 +1 @@
1
+ export type { Page, PageConfig, IPagesService, IPagesServiceConfig, IPagesDefinition } 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-pages",
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-pages",
68
+ "targets": {
69
+ "static": false,
70
+ "docker": false
71
+ }
72
+ },
73
+ "validations": {
74
+ "postBuild": [
75
+ "test",
76
+ "lint"
77
+ ]
78
+ }
79
+ },
80
+ "falconPackageHash": "3ff54f019adc45b0bfc800cd99bbe11da3dd1be133207c04a6b6ddf5"
81
+ }
@@ -0,0 +1,37 @@
1
+ import { defineService } from '@wix/services-definitions'
2
+ import type { ServiceDefinition } from '@wix/services-definitions'
3
+
4
+ export type Page = {
5
+ id: string
6
+ title: string
7
+ path: string
8
+ parentPageId?: string
9
+ popup: boolean
10
+ }
11
+
12
+ export type PageConfig = {
13
+ title: string
14
+ path: string
15
+ parentPageId?: string
16
+ popup: boolean
17
+ }
18
+
19
+ export type IPagesServiceConfig = {
20
+ /** id-as-key map; values omit `id` — callers use the key as the id (P3). */
21
+ pages: { [pageId: string]: PageConfig }
22
+ /** Provider resolves and passes the full main page object; service stores it as-is. */
23
+ mainPage: Page
24
+ /** Provider resolves and passes the full current page object; service stores it as-is. */
25
+ currentPage: Page
26
+ }
27
+
28
+ export interface IPagesService {
29
+ readonly pages: { [pageId: string]: PageConfig }
30
+ readonly mainPage: Page
31
+ readonly currentPage: Page
32
+ _updateConfig: (config: Partial<IPagesServiceConfig>) => void
33
+ }
34
+
35
+ export type IPagesDefinition = ServiceDefinition<IPagesService, IPagesServiceConfig>
36
+
37
+ export const PagesDefinition = defineService<IPagesService, IPagesServiceConfig>('@wix/site-service-pages')
@@ -0,0 +1 @@
1
+ export { PagesService } from './pagesService'
@@ -0,0 +1,38 @@
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 { IPagesService, IPagesServiceConfig } from '../definition'
5
+ import { PagesDefinition } from '../definition'
6
+
7
+ export const PagesService = implementService(
8
+ PagesDefinition,
9
+ ({ config, getService }: ServiceFactoryOpts<IPagesServiceConfig>): IPagesService => {
10
+ const { signal } = getService(SignalsServiceDefinition)
11
+ const _pages = signal(config.pages)
12
+ const _mainPage = signal(config.mainPage)
13
+ const _currentPage = signal(config.currentPage)
14
+
15
+ return {
16
+ get pages() {
17
+ return _pages.get()
18
+ },
19
+ get mainPage() {
20
+ return _mainPage.get()
21
+ },
22
+ get currentPage() {
23
+ return _currentPage.get()
24
+ },
25
+ _updateConfig(partialConfig) {
26
+ if (partialConfig.pages) {
27
+ _pages.set(partialConfig.pages)
28
+ }
29
+ if (partialConfig.mainPage) {
30
+ _mainPage.set(partialConfig.mainPage)
31
+ }
32
+ if (partialConfig.currentPage) {
33
+ _currentPage.set(partialConfig.currentPage)
34
+ }
35
+ },
36
+ }
37
+ }
38
+ )
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 { PagesDefinition } from './definition'
2
+ import { PagesService } from './implementations/pagesService'
3
+
4
+ export const definition = PagesDefinition
5
+ export default PagesService
@@ -0,0 +1 @@
1
+ export type { Page, PageConfig, IPagesService, IPagesServiceConfig, IPagesDefinition } from '../definition'
@@ -0,0 +1,3 @@
1
+ {
2
+ "main": "../cjs/build/types/index.js"
3
+ }