@wix/site-service-site-theme 1.0.1

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 +48 -0
  2. package/cjs/build/definition/index.d.ts +19 -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/siteThemeService.d.ts +6 -0
  9. package/cjs/build/implementations/siteThemeService.js +35 -0
  10. package/cjs/build/implementations/siteThemeService.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 +10 -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 +19 -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/siteThemeService.d.ts +6 -0
  29. package/dist/implementations/siteThemeService.js +32 -0
  30. package/dist/implementations/siteThemeService.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 +10 -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 +22 -0
  43. package/src/implementations/index.ts +1 -0
  44. package/src/implementations/siteThemeService.ts +38 -0
  45. package/src/index.ts +2 -0
  46. package/src/service.ts +5 -0
  47. package/src/types/index.ts +7 -0
  48. package/types/package.json +3 -0
package/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # @wix/site-service-site-theme
2
+
3
+ Provides the site's color palette, font settings, and ordered color array for theme-consistent styling.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ yarn add @wix/site-service-site-theme
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { SiteThemeDefinition } from '@wix/site-service-site-theme/definition'
15
+ import { SiteThemeService } from '@wix/site-service-site-theme/implementations'
16
+
17
+ createServicesMap().addService(SiteThemeDefinition, SiteThemeService, config)
18
+
19
+ const service = servicesManager.getService(SiteThemeDefinition)
20
+ service.colors // ← site color palette
21
+ service.fonts // ← site font settings
22
+ service.colorsMap // ← ordered colors array
23
+ ```
24
+
25
+ ## API
26
+
27
+ | Member | Type | Throws when | Description |
28
+ |---|---|---|---|
29
+ | `colors` | `SiteColors` | never | Site colour palette indexed by colour name (e.g. `"color_1"`) |
30
+ | `fonts` | `SiteFonts` | never | Site font settings indexed by font name (e.g. `"font_1"`) |
31
+ | `colorsMap` | `ColorsMap` | never | Ordered array of colour hex strings (positionally indexed) |
32
+ | `_updateConfig` | `(Partial<ISiteThemeServiceConfig>) => void` | never | Replace-on-write per provided field |
33
+
34
+ ## Configuration
35
+
36
+ `ISiteThemeServiceConfig`:
37
+
38
+ ```ts
39
+ type ISiteThemeServiceConfig = {
40
+ siteColors: SiteColors // { [colorIndex: string]: string }
41
+ siteFonts: SiteFonts // { [fontIndex: string]: string }
42
+ colorsMap: ColorsMap // Array<string>
43
+ }
44
+ ```
45
+
46
+ ## Reactivity
47
+
48
+ This service is a thin signal wrapper over `@wix/services-definitions/core-services/signals`. Every property is signal-backed; wrap reads in `effect` / `computed` to react to changes. Signals are not exposed directly.
@@ -0,0 +1,19 @@
1
+ import type { ServiceDefinition } from '@wix/services-definitions';
2
+ import type { SiteColors, SiteFonts, ColorsMap } from '../types';
3
+ export type ISiteThemeServiceConfig = {
4
+ siteColors: SiteColors;
5
+ siteFonts: SiteFonts;
6
+ colorsMap: ColorsMap;
7
+ };
8
+ export interface ISiteThemeService {
9
+ readonly colors: SiteColors;
10
+ readonly fonts: SiteFonts;
11
+ readonly colorsMap: ColorsMap;
12
+ _updateConfig: (config: Partial<ISiteThemeServiceConfig>) => void;
13
+ }
14
+ export type ISiteThemeDefinition = ServiceDefinition<ISiteThemeService, ISiteThemeServiceConfig>;
15
+ export declare const SiteThemeDefinition: string & {
16
+ __api: ISiteThemeService;
17
+ __config: ISiteThemeServiceConfig;
18
+ isServiceDefinition?: boolean;
19
+ } & ISiteThemeService;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SiteThemeDefinition = void 0;
4
+ const services_definitions_1 = require("@wix/services-definitions");
5
+ exports.SiteThemeDefinition = (0, services_definitions_1.defineService)('@wix/site-service-site-theme');
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/definition/index.ts"],"names":[],"mappings":";;;AAAA,oEAAyD;AAmB5C,QAAA,mBAAmB,GAAG,IAAA,oCAAa,EAC5C,8BAA8B,CACjC,CAAA"}
@@ -0,0 +1 @@
1
+ export { SiteThemeService } from './siteThemeService';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SiteThemeService = void 0;
4
+ var siteThemeService_1 = require("./siteThemeService");
5
+ Object.defineProperty(exports, "SiteThemeService", { enumerable: true, get: function () { return siteThemeService_1.SiteThemeService; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/implementations/index.ts"],"names":[],"mappings":";;;AAAA,uDAAqD;AAA5C,oHAAA,gBAAgB,OAAA"}
@@ -0,0 +1,6 @@
1
+ import type { ISiteThemeService, ISiteThemeServiceConfig } from '../definition';
2
+ export declare const SiteThemeService: import("@wix/services-definitions").ServiceFactory<string & {
3
+ __api: ISiteThemeService;
4
+ __config: ISiteThemeServiceConfig;
5
+ isServiceDefinition?: boolean;
6
+ } & ISiteThemeService, ISiteThemeServiceConfig>;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SiteThemeService = 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.SiteThemeService = (0, services_definitions_1.implementService)(definition_1.SiteThemeDefinition, ({ config, getService }) => {
8
+ const { signal } = getService(signals_1.SignalsServiceDefinition);
9
+ const _colors = signal(config.siteColors);
10
+ const _fonts = signal(config.siteFonts);
11
+ const _colorsMap = signal(config.colorsMap);
12
+ return {
13
+ get colors() {
14
+ return _colors.get();
15
+ },
16
+ get fonts() {
17
+ return _fonts.get();
18
+ },
19
+ get colorsMap() {
20
+ return _colorsMap.get();
21
+ },
22
+ _updateConfig({ siteColors, siteFonts, colorsMap }) {
23
+ if (siteColors !== undefined) {
24
+ _colors.set(siteColors);
25
+ }
26
+ if (siteFonts !== undefined) {
27
+ _fonts.set(siteFonts);
28
+ }
29
+ if (colorsMap !== undefined) {
30
+ _colorsMap.set(colorsMap);
31
+ }
32
+ },
33
+ };
34
+ });
35
+ //# sourceMappingURL=siteThemeService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"siteThemeService.js","sourceRoot":"","sources":["../../../src/implementations/siteThemeService.ts"],"names":[],"mappings":";;;AAAA,oEAA4D;AAE5D,6EAA0F;AAE1F,8CAAmD;AAEtC,QAAA,gBAAgB,GAAG,IAAA,uCAAgB,EAC5C,gCAAmB,EACnB,CAAC,EAAE,MAAM,EAAE,UAAU,EAA+C,EAAqB,EAAE;IACvF,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,kCAAwB,CAAC,CAAA;IACvD,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;IACzC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;IACvC,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;IAE3C,OAAO;QACH,IAAI,MAAM;YACN,OAAO,OAAO,CAAC,GAAG,EAAE,CAAA;QACxB,CAAC;QACD,IAAI,KAAK;YACL,OAAO,MAAM,CAAC,GAAG,EAAE,CAAA;QACvB,CAAC;QACD,IAAI,SAAS;YACT,OAAO,UAAU,CAAC,GAAG,EAAE,CAAA;QAC3B,CAAC;QACD,aAAa,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAoC;YAChF,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;gBAC3B,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;YAC3B,CAAC;YACD,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;gBAC1B,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;YACzB,CAAC;YACD,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;gBAC1B,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;YAC7B,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 { SiteThemeService } from './implementations/siteThemeService';
2
+ export declare const definition: string & {
3
+ __api: import("./definition").ISiteThemeService;
4
+ __config: import("./definition").ISiteThemeServiceConfig;
5
+ isServiceDefinition?: boolean;
6
+ } & import("./definition").ISiteThemeService;
7
+ export default SiteThemeService;
@@ -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 siteThemeService_1 = require("./implementations/siteThemeService");
6
+ exports.definition = definition_1.SiteThemeDefinition;
7
+ exports.default = siteThemeService_1.SiteThemeService;
8
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/service.ts"],"names":[],"mappings":";;;AAAA,6CAAkD;AAClD,yEAAqE;AAExD,QAAA,UAAU,GAAG,gCAAmB,CAAA;AAC7C,kBAAe,mCAAgB,CAAA"}
@@ -0,0 +1,10 @@
1
+ /** CSS colour value, e.g. `'#fff'`, `'#ffffff'`, `'rgb(255,255,255)'` */
2
+ export type Color = string;
3
+ export type SiteColors = {
4
+ [colorIndex: string]: Color;
5
+ };
6
+ export type SiteFonts = {
7
+ [fontIndex: string]: string;
8
+ };
9
+ export type ColorsMap = Array<Color>;
10
+ export type { ISiteThemeService, ISiteThemeServiceConfig, ISiteThemeDefinition } 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,19 @@
1
+ import type { ServiceDefinition } from '@wix/services-definitions';
2
+ import type { SiteColors, SiteFonts, ColorsMap } from '../types';
3
+ export type ISiteThemeServiceConfig = {
4
+ siteColors: SiteColors;
5
+ siteFonts: SiteFonts;
6
+ colorsMap: ColorsMap;
7
+ };
8
+ export interface ISiteThemeService {
9
+ readonly colors: SiteColors;
10
+ readonly fonts: SiteFonts;
11
+ readonly colorsMap: ColorsMap;
12
+ _updateConfig: (config: Partial<ISiteThemeServiceConfig>) => void;
13
+ }
14
+ export type ISiteThemeDefinition = ServiceDefinition<ISiteThemeService, ISiteThemeServiceConfig>;
15
+ export declare const SiteThemeDefinition: string & {
16
+ __api: ISiteThemeService;
17
+ __config: ISiteThemeServiceConfig;
18
+ isServiceDefinition?: boolean;
19
+ } & ISiteThemeService;
@@ -0,0 +1,3 @@
1
+ import { defineService } from '@wix/services-definitions';
2
+ export const SiteThemeDefinition = defineService('@wix/site-service-site-theme');
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;AAmBzD,MAAM,CAAC,MAAM,mBAAmB,GAAG,aAAa,CAC5C,8BAA8B,CACjC,CAAA"}
@@ -0,0 +1 @@
1
+ export { SiteThemeService } from './siteThemeService';
@@ -0,0 +1,2 @@
1
+ export { SiteThemeService } from './siteThemeService';
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,gBAAgB,EAAE,MAAM,oBAAoB,CAAA"}
@@ -0,0 +1,6 @@
1
+ import type { ISiteThemeService, ISiteThemeServiceConfig } from '../definition';
2
+ export declare const SiteThemeService: import("@wix/services-definitions").ServiceFactory<string & {
3
+ __api: ISiteThemeService;
4
+ __config: ISiteThemeServiceConfig;
5
+ isServiceDefinition?: boolean;
6
+ } & ISiteThemeService, ISiteThemeServiceConfig>;
@@ -0,0 +1,32 @@
1
+ import { implementService } from '@wix/services-definitions';
2
+ import { SignalsServiceDefinition } from '@wix/services-definitions/core-services/signals';
3
+ import { SiteThemeDefinition } from '../definition';
4
+ export const SiteThemeService = implementService(SiteThemeDefinition, ({ config, getService }) => {
5
+ const { signal } = getService(SignalsServiceDefinition);
6
+ const _colors = signal(config.siteColors);
7
+ const _fonts = signal(config.siteFonts);
8
+ const _colorsMap = signal(config.colorsMap);
9
+ return {
10
+ get colors() {
11
+ return _colors.get();
12
+ },
13
+ get fonts() {
14
+ return _fonts.get();
15
+ },
16
+ get colorsMap() {
17
+ return _colorsMap.get();
18
+ },
19
+ _updateConfig({ siteColors, siteFonts, colorsMap }) {
20
+ if (siteColors !== undefined) {
21
+ _colors.set(siteColors);
22
+ }
23
+ if (siteFonts !== undefined) {
24
+ _fonts.set(siteFonts);
25
+ }
26
+ if (colorsMap !== undefined) {
27
+ _colorsMap.set(colorsMap);
28
+ }
29
+ },
30
+ };
31
+ });
32
+ //# sourceMappingURL=siteThemeService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"siteThemeService.js","sourceRoot":"","sources":["../../src/implementations/siteThemeService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAE5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,iDAAiD,CAAA;AAE1F,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAEnD,MAAM,CAAC,MAAM,gBAAgB,GAAG,gBAAgB,CAC5C,mBAAmB,EACnB,CAAC,EAAE,MAAM,EAAE,UAAU,EAA+C,EAAqB,EAAE;IACvF,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,wBAAwB,CAAC,CAAA;IACvD,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;IACzC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;IACvC,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;IAE3C,OAAO;QACH,IAAI,MAAM;YACN,OAAO,OAAO,CAAC,GAAG,EAAE,CAAA;QACxB,CAAC;QACD,IAAI,KAAK;YACL,OAAO,MAAM,CAAC,GAAG,EAAE,CAAA;QACvB,CAAC;QACD,IAAI,SAAS;YACT,OAAO,UAAU,CAAC,GAAG,EAAE,CAAA;QAC3B,CAAC;QACD,aAAa,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAoC;YAChF,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;gBAC3B,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;YAC3B,CAAC;YACD,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;gBAC1B,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;YACzB,CAAC;YACD,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;gBAC1B,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;YAC7B,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 { SiteThemeService } from './implementations/siteThemeService';
2
+ export declare const definition: string & {
3
+ __api: import("./definition").ISiteThemeService;
4
+ __config: import("./definition").ISiteThemeServiceConfig;
5
+ isServiceDefinition?: boolean;
6
+ } & import("./definition").ISiteThemeService;
7
+ export default SiteThemeService;
@@ -0,0 +1,5 @@
1
+ import { SiteThemeDefinition } from './definition';
2
+ import { SiteThemeService } from './implementations/siteThemeService';
3
+ export const definition = SiteThemeDefinition;
4
+ export default SiteThemeService;
5
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAA;AAErE,MAAM,CAAC,MAAM,UAAU,GAAG,mBAAmB,CAAA;AAC7C,eAAe,gBAAgB,CAAA"}
@@ -0,0 +1,10 @@
1
+ /** CSS colour value, e.g. `'#fff'`, `'#ffffff'`, `'rgb(255,255,255)'` */
2
+ export type Color = string;
3
+ export type SiteColors = {
4
+ [colorIndex: string]: Color;
5
+ };
6
+ export type SiteFonts = {
7
+ [fontIndex: string]: string;
8
+ };
9
+ export type ColorsMap = Array<Color>;
10
+ export type { ISiteThemeService, ISiteThemeServiceConfig, ISiteThemeDefinition } 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-site-theme",
3
+ "version": "1.0.1",
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-site-theme",
68
+ "targets": {
69
+ "static": false,
70
+ "docker": false
71
+ }
72
+ },
73
+ "validations": {
74
+ "postBuild": [
75
+ "test",
76
+ "lint"
77
+ ]
78
+ }
79
+ },
80
+ "falconPackageHash": "17e1cd64cf50d100168656e2e3ecbc50024def169623c696f679e7d5"
81
+ }
@@ -0,0 +1,22 @@
1
+ import { defineService } from '@wix/services-definitions'
2
+ import type { ServiceDefinition } from '@wix/services-definitions'
3
+ import type { SiteColors, SiteFonts, ColorsMap } from '../types'
4
+
5
+ export type ISiteThemeServiceConfig = {
6
+ siteColors: SiteColors
7
+ siteFonts: SiteFonts
8
+ colorsMap: ColorsMap
9
+ }
10
+
11
+ export interface ISiteThemeService {
12
+ readonly colors: SiteColors
13
+ readonly fonts: SiteFonts
14
+ readonly colorsMap: ColorsMap
15
+ _updateConfig: (config: Partial<ISiteThemeServiceConfig>) => void
16
+ }
17
+
18
+ export type ISiteThemeDefinition = ServiceDefinition<ISiteThemeService, ISiteThemeServiceConfig>
19
+
20
+ export const SiteThemeDefinition = defineService<ISiteThemeService, ISiteThemeServiceConfig>(
21
+ '@wix/site-service-site-theme'
22
+ )
@@ -0,0 +1 @@
1
+ export { SiteThemeService } from './siteThemeService'
@@ -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 { ISiteThemeService, ISiteThemeServiceConfig } from '../definition'
5
+ import { SiteThemeDefinition } from '../definition'
6
+
7
+ export const SiteThemeService = implementService(
8
+ SiteThemeDefinition,
9
+ ({ config, getService }: ServiceFactoryOpts<ISiteThemeServiceConfig>): ISiteThemeService => {
10
+ const { signal } = getService(SignalsServiceDefinition)
11
+ const _colors = signal(config.siteColors)
12
+ const _fonts = signal(config.siteFonts)
13
+ const _colorsMap = signal(config.colorsMap)
14
+
15
+ return {
16
+ get colors() {
17
+ return _colors.get()
18
+ },
19
+ get fonts() {
20
+ return _fonts.get()
21
+ },
22
+ get colorsMap() {
23
+ return _colorsMap.get()
24
+ },
25
+ _updateConfig({ siteColors, siteFonts, colorsMap }: Partial<ISiteThemeServiceConfig>) {
26
+ if (siteColors !== undefined) {
27
+ _colors.set(siteColors)
28
+ }
29
+ if (siteFonts !== undefined) {
30
+ _fonts.set(siteFonts)
31
+ }
32
+ if (colorsMap !== undefined) {
33
+ _colorsMap.set(colorsMap)
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 { SiteThemeDefinition } from './definition'
2
+ import { SiteThemeService } from './implementations/siteThemeService'
3
+
4
+ export const definition = SiteThemeDefinition
5
+ export default SiteThemeService
@@ -0,0 +1,7 @@
1
+ /** CSS colour value, e.g. `'#fff'`, `'#ffffff'`, `'rgb(255,255,255)'` */
2
+ export type Color = string
3
+ export type SiteColors = { [colorIndex: string]: Color }
4
+ export type SiteFonts = { [fontIndex: string]: string }
5
+ export type ColorsMap = Array<Color>
6
+
7
+ export type { ISiteThemeService, ISiteThemeServiceConfig, ISiteThemeDefinition } from '../definition'
@@ -0,0 +1,3 @@
1
+ {
2
+ "main": "../cjs/build/types/index.js"
3
+ }