@wix/site-service-editor-context 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 +47 -0
  2. package/cjs/build/definition/index.d.ts +17 -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/editorContextService.d.ts +6 -0
  6. package/cjs/build/implementations/editorContextService.js +25 -0
  7. package/cjs/build/implementations/editorContextService.js.map +1 -0
  8. package/cjs/build/implementations/index.d.ts +1 -0
  9. package/cjs/build/implementations/index.js +6 -0
  10. package/cjs/build/implementations/index.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 +2 -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 +17 -0
  23. package/dist/definition/index.js +3 -0
  24. package/dist/definition/index.js.map +1 -0
  25. package/dist/implementations/editorContextService.d.ts +6 -0
  26. package/dist/implementations/editorContextService.js +22 -0
  27. package/dist/implementations/editorContextService.js.map +1 -0
  28. package/dist/implementations/index.d.ts +1 -0
  29. package/dist/implementations/index.js +2 -0
  30. package/dist/implementations/index.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 +2 -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 +20 -0
  43. package/src/implementations/editorContextService.ts +28 -0
  44. package/src/implementations/index.ts +1 -0
  45. package/src/index.ts +2 -0
  46. package/src/service.ts +5 -0
  47. package/src/types/index.ts +2 -0
  48. package/types/package.json +3 -0
package/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # @wix/site-service-editor-context
2
+
3
+ Signal-backed editor runtime context for site services.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ yarn add @wix/site-service-editor-context
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { EditorContextDefinition } from '@wix/site-service-editor-context/definition'
15
+ import { EditorContextService } from '@wix/site-service-editor-context/implementations'
16
+
17
+ createServicesMap().addService(EditorContextDefinition, EditorContextService, config)
18
+
19
+ const service = servicesManager.getService(EditorContextDefinition)
20
+ service.previewMode
21
+ service.editorName
22
+ ```
23
+
24
+ ## API
25
+
26
+ | Member | Type | Throws when | Description |
27
+ |---|---|---|---|
28
+ | `editorName` | `EditorName` | never | Internal editor variant name. |
29
+ | `previewMode` | `boolean` | never | Whether the site is currently running in editor preview mode. |
30
+ | `_updateConfig` | `(Partial<IEditorContextServiceUpdateConfig>) => void` | never | Private Thunderbolt config-push entry point for `previewMode`. |
31
+
32
+ ## Configuration
33
+
34
+ `IEditorContextServiceConfig`:
35
+
36
+ ```ts
37
+ export type IEditorContextServiceConfig = {
38
+ editorName?: EditorName
39
+ previewMode?: boolean
40
+ }
41
+
42
+ export type IEditorContextServiceUpdateConfig = Pick<IEditorContextServiceConfig, 'previewMode'>
43
+ ```
44
+
45
+ ## Reactivity
46
+
47
+ This service is a thin signal wrapper over `@wix/services-definitions/core-services/signals`. Every property is signal-backed under the hood; wrap reads in `effect` / `computed` to react to changes. Signals are not exposed directly.
@@ -0,0 +1,17 @@
1
+ import type { ServiceDefinition } from '@wix/services-definitions';
2
+ import type { EditorName } from '../types';
3
+ export type IEditorContextServiceConfig = {
4
+ editorName?: EditorName;
5
+ previewMode?: boolean;
6
+ };
7
+ export interface IEditorContextService {
8
+ readonly editorName: EditorName;
9
+ readonly previewMode: boolean;
10
+ _updateConfig: (config: Partial<IEditorContextServiceConfig>) => void;
11
+ }
12
+ export type IEditorContextDefinition = ServiceDefinition<IEditorContextService, IEditorContextServiceConfig>;
13
+ export declare const EditorContextDefinition: string & {
14
+ __api: IEditorContextService;
15
+ __config: IEditorContextServiceConfig;
16
+ isServiceDefinition?: boolean;
17
+ } & IEditorContextService;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EditorContextDefinition = void 0;
4
+ const services_definitions_1 = require("@wix/services-definitions");
5
+ exports.EditorContextDefinition = (0, services_definitions_1.defineService)('@wix/site-service-editor-context');
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/definition/index.ts"],"names":[],"mappings":";;;AAAA,oEAAyD;AAiB5C,QAAA,uBAAuB,GAAG,IAAA,oCAAa,EAChD,kCAAkC,CACrC,CAAA"}
@@ -0,0 +1,6 @@
1
+ import type { IEditorContextService, IEditorContextServiceConfig } from '../definition';
2
+ export declare const EditorContextService: import("@wix/services-definitions").ServiceFactory<string & {
3
+ __api: IEditorContextService;
4
+ __config: IEditorContextServiceConfig;
5
+ isServiceDefinition?: boolean;
6
+ } & IEditorContextService, IEditorContextServiceConfig>;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EditorContextService = 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.EditorContextService = (0, services_definitions_1.implementService)(definition_1.EditorContextDefinition, ({ config, getService }) => {
8
+ const { signal } = getService(signals_1.SignalsServiceDefinition);
9
+ const editorName = config.editorName ?? 'Studio';
10
+ const _previewMode = signal(config.previewMode ?? false);
11
+ return {
12
+ get editorName() {
13
+ return editorName;
14
+ },
15
+ get previewMode() {
16
+ return _previewMode.get();
17
+ },
18
+ _updateConfig(config) {
19
+ if (config.previewMode !== undefined) {
20
+ _previewMode.set(config.previewMode);
21
+ }
22
+ },
23
+ };
24
+ });
25
+ //# sourceMappingURL=editorContextService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editorContextService.js","sourceRoot":"","sources":["../../../src/implementations/editorContextService.ts"],"names":[],"mappings":";;;AAAA,oEAA4D;AAE5D,6EAA0F;AAE1F,8CAAuD;AAE1C,QAAA,oBAAoB,GAAG,IAAA,uCAAgB,EAChD,oCAAuB,EACvB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAmD,EAAyB,EAAE;IAC/F,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,kCAAwB,CAAC,CAAA;IACvD,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,QAAQ,CAAA;IAChD,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,IAAI,KAAK,CAAC,CAAA;IAExD,OAAO;QACH,IAAI,UAAU;YACV,OAAO,UAAU,CAAA;QACrB,CAAC;QACD,IAAI,WAAW;YACX,OAAO,YAAY,CAAC,GAAG,EAAE,CAAA;QAC7B,CAAC;QACD,aAAa,CAAC,MAA4C;YACtD,IAAI,MAAM,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;gBACnC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,CAAA;YACxC,CAAC;QACL,CAAC;KACJ,CAAA;AACL,CAAC,CACJ,CAAA"}
@@ -0,0 +1 @@
1
+ export { EditorContextService } from './editorContextService';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EditorContextService = void 0;
4
+ var editorContextService_1 = require("./editorContextService");
5
+ Object.defineProperty(exports, "EditorContextService", { enumerable: true, get: function () { return editorContextService_1.EditorContextService; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/implementations/index.ts"],"names":[],"mappings":";;;AAAA,+DAA6D;AAApD,4HAAA,oBAAoB,OAAA"}
@@ -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 { EditorContextService } from './implementations/editorContextService';
2
+ export declare const definition: string & {
3
+ __api: import("./definition").IEditorContextService;
4
+ __config: import("./definition").IEditorContextServiceConfig;
5
+ isServiceDefinition?: boolean;
6
+ } & import("./definition").IEditorContextService;
7
+ export default EditorContextService;
@@ -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 editorContextService_1 = require("./implementations/editorContextService");
6
+ exports.definition = definition_1.EditorContextDefinition;
7
+ exports.default = editorContextService_1.EditorContextService;
8
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/service.ts"],"names":[],"mappings":";;;AAAA,6CAAsD;AACtD,iFAA6E;AAEhE,QAAA,UAAU,GAAG,oCAAuB,CAAA;AACjD,kBAAe,2CAAoB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export type { IEditorContextService, IEditorContextServiceConfig, IEditorContextDefinition } from '../definition';
2
+ export type EditorName = string;
@@ -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,17 @@
1
+ import type { ServiceDefinition } from '@wix/services-definitions';
2
+ import type { EditorName } from '../types';
3
+ export type IEditorContextServiceConfig = {
4
+ editorName?: EditorName;
5
+ previewMode?: boolean;
6
+ };
7
+ export interface IEditorContextService {
8
+ readonly editorName: EditorName;
9
+ readonly previewMode: boolean;
10
+ _updateConfig: (config: Partial<IEditorContextServiceConfig>) => void;
11
+ }
12
+ export type IEditorContextDefinition = ServiceDefinition<IEditorContextService, IEditorContextServiceConfig>;
13
+ export declare const EditorContextDefinition: string & {
14
+ __api: IEditorContextService;
15
+ __config: IEditorContextServiceConfig;
16
+ isServiceDefinition?: boolean;
17
+ } & IEditorContextService;
@@ -0,0 +1,3 @@
1
+ import { defineService } from '@wix/services-definitions';
2
+ export const EditorContextDefinition = defineService('@wix/site-service-editor-context');
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;AAiBzD,MAAM,CAAC,MAAM,uBAAuB,GAAG,aAAa,CAChD,kCAAkC,CACrC,CAAA"}
@@ -0,0 +1,6 @@
1
+ import type { IEditorContextService, IEditorContextServiceConfig } from '../definition';
2
+ export declare const EditorContextService: import("@wix/services-definitions").ServiceFactory<string & {
3
+ __api: IEditorContextService;
4
+ __config: IEditorContextServiceConfig;
5
+ isServiceDefinition?: boolean;
6
+ } & IEditorContextService, IEditorContextServiceConfig>;
@@ -0,0 +1,22 @@
1
+ import { implementService } from '@wix/services-definitions';
2
+ import { SignalsServiceDefinition } from '@wix/services-definitions/core-services/signals';
3
+ import { EditorContextDefinition } from '../definition';
4
+ export const EditorContextService = implementService(EditorContextDefinition, ({ config, getService }) => {
5
+ const { signal } = getService(SignalsServiceDefinition);
6
+ const editorName = config.editorName ?? 'Studio';
7
+ const _previewMode = signal(config.previewMode ?? false);
8
+ return {
9
+ get editorName() {
10
+ return editorName;
11
+ },
12
+ get previewMode() {
13
+ return _previewMode.get();
14
+ },
15
+ _updateConfig(config) {
16
+ if (config.previewMode !== undefined) {
17
+ _previewMode.set(config.previewMode);
18
+ }
19
+ },
20
+ };
21
+ });
22
+ //# sourceMappingURL=editorContextService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editorContextService.js","sourceRoot":"","sources":["../../src/implementations/editorContextService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAE5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,iDAAiD,CAAA;AAE1F,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAA;AAEvD,MAAM,CAAC,MAAM,oBAAoB,GAAG,gBAAgB,CAChD,uBAAuB,EACvB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAmD,EAAyB,EAAE;IAC/F,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,wBAAwB,CAAC,CAAA;IACvD,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,QAAQ,CAAA;IAChD,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,IAAI,KAAK,CAAC,CAAA;IAExD,OAAO;QACH,IAAI,UAAU;YACV,OAAO,UAAU,CAAA;QACrB,CAAC;QACD,IAAI,WAAW;YACX,OAAO,YAAY,CAAC,GAAG,EAAE,CAAA;QAC7B,CAAC;QACD,aAAa,CAAC,MAA4C;YACtD,IAAI,MAAM,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;gBACnC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,CAAA;YACxC,CAAC;QACL,CAAC;KACJ,CAAA;AACL,CAAC,CACJ,CAAA"}
@@ -0,0 +1 @@
1
+ export { EditorContextService } from './editorContextService';
@@ -0,0 +1,2 @@
1
+ export { EditorContextService } from './editorContextService';
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,oBAAoB,EAAE,MAAM,wBAAwB,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 { EditorContextService } from './implementations/editorContextService';
2
+ export declare const definition: string & {
3
+ __api: import("./definition").IEditorContextService;
4
+ __config: import("./definition").IEditorContextServiceConfig;
5
+ isServiceDefinition?: boolean;
6
+ } & import("./definition").IEditorContextService;
7
+ export default EditorContextService;
@@ -0,0 +1,5 @@
1
+ import { EditorContextDefinition } from './definition';
2
+ import { EditorContextService } from './implementations/editorContextService';
3
+ export const definition = EditorContextDefinition;
4
+ export default EditorContextService;
5
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAA;AAE7E,MAAM,CAAC,MAAM,UAAU,GAAG,uBAAuB,CAAA;AACjD,eAAe,oBAAoB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export type { IEditorContextService, IEditorContextServiceConfig, IEditorContextDefinition } from '../definition';
2
+ export type EditorName = string;
@@ -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-editor-context",
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-editor-context",
68
+ "targets": {
69
+ "static": false,
70
+ "docker": false
71
+ }
72
+ },
73
+ "validations": {
74
+ "postBuild": [
75
+ "test",
76
+ "lint"
77
+ ]
78
+ }
79
+ },
80
+ "falconPackageHash": "5dd230f43c09bd699bcacd65b7897eea5d9c7251d9d8817e58090df4"
81
+ }
@@ -0,0 +1,20 @@
1
+ import { defineService } from '@wix/services-definitions'
2
+ import type { ServiceDefinition } from '@wix/services-definitions'
3
+ import type { EditorName } from '../types'
4
+
5
+ export type IEditorContextServiceConfig = {
6
+ editorName?: EditorName
7
+ previewMode?: boolean
8
+ }
9
+
10
+ export interface IEditorContextService {
11
+ readonly editorName: EditorName
12
+ readonly previewMode: boolean
13
+ _updateConfig: (config: Partial<IEditorContextServiceConfig>) => void
14
+ }
15
+
16
+ export type IEditorContextDefinition = ServiceDefinition<IEditorContextService, IEditorContextServiceConfig>
17
+
18
+ export const EditorContextDefinition = defineService<IEditorContextService, IEditorContextServiceConfig>(
19
+ '@wix/site-service-editor-context'
20
+ )
@@ -0,0 +1,28 @@
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 { IEditorContextService, IEditorContextServiceConfig } from '../definition'
5
+ import { EditorContextDefinition } from '../definition'
6
+
7
+ export const EditorContextService = implementService(
8
+ EditorContextDefinition,
9
+ ({ config, getService }: ServiceFactoryOpts<IEditorContextServiceConfig>): IEditorContextService => {
10
+ const { signal } = getService(SignalsServiceDefinition)
11
+ const editorName = config.editorName ?? 'Studio'
12
+ const _previewMode = signal(config.previewMode ?? false)
13
+
14
+ return {
15
+ get editorName() {
16
+ return editorName
17
+ },
18
+ get previewMode() {
19
+ return _previewMode.get()
20
+ },
21
+ _updateConfig(config: Partial<IEditorContextServiceConfig>) {
22
+ if (config.previewMode !== undefined) {
23
+ _previewMode.set(config.previewMode)
24
+ }
25
+ },
26
+ }
27
+ }
28
+ )
@@ -0,0 +1 @@
1
+ export { EditorContextService } from './editorContextService'
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 { EditorContextDefinition } from './definition'
2
+ import { EditorContextService } from './implementations/editorContextService'
3
+
4
+ export const definition = EditorContextDefinition
5
+ export default EditorContextService
@@ -0,0 +1,2 @@
1
+ export type { IEditorContextService, IEditorContextServiceConfig, IEditorContextDefinition } from '../definition'
2
+ export type EditorName = string
@@ -0,0 +1,3 @@
1
+ {
2
+ "main": "../cjs/build/types/index.js"
3
+ }