@wix/site-service-rendering-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 +45 -0
  2. package/cjs/build/definition/index.d.ts +14 -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/renderingContextService.d.ts +6 -0
  9. package/cjs/build/implementations/renderingContextService.js +18 -0
  10. package/cjs/build/implementations/renderingContextService.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 +14 -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/renderingContextService.d.ts +6 -0
  29. package/dist/implementations/renderingContextService.js +15 -0
  30. package/dist/implementations/renderingContextService.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 +17 -0
  43. package/src/implementations/index.ts +1 -0
  44. package/src/implementations/renderingContextService.ts +21 -0
  45. package/src/index.ts +2 -0
  46. package/src/service.ts +5 -0
  47. package/src/types/index.ts +5 -0
  48. package/types/package.json +3 -0
package/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # @wix/site-service-rendering-context
2
+
3
+ Service exposing rendering-context flags (`SSR`, `SEO`) as a dedicated site-service.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ yarn add @wix/site-service-rendering-context
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { RenderingContextDefinition } from '@wix/site-service-rendering-context/definition'
15
+ import { RenderingContextService } from '@wix/site-service-rendering-context/implementations'
16
+
17
+ createServicesMap().addService(RenderingContextDefinition, RenderingContextService, config)
18
+
19
+ const service = servicesManager.getService(RenderingContextDefinition)
20
+ // service.<property> ← TS getter
21
+ ```
22
+
23
+ ## API
24
+
25
+ | Member | Type | Throws when | Description |
26
+ |---|---|---|---|
27
+ | `SSR` | `boolean` | never | Whether current runtime is server-side rendering. |
28
+ | `SEO` | `boolean` | never | Whether current rendering context is SEO mode. |
29
+
30
+ ## Configuration
31
+
32
+ `IRenderingContextServiceConfig`:
33
+
34
+ ```ts
35
+ type IRenderingContextServiceConfig = {
36
+ seo?: boolean
37
+ }
38
+ ```
39
+
40
+ `SSR` is not configurable — it is always derived at runtime from `globalThis.window === undefined`.
41
+ When `seo` is not provided, it defaults to `false`.
42
+
43
+ ## Reactivity
44
+
45
+ This service is read-only and not signal-backed. Values are resolved once at initialization.
@@ -0,0 +1,14 @@
1
+ import type { ServiceDefinition } from '@wix/services-definitions';
2
+ export type IRenderingContextServiceConfig = {
3
+ readonly seo?: boolean;
4
+ };
5
+ export interface IRenderingContextService {
6
+ readonly SSR: boolean;
7
+ readonly SEO: boolean;
8
+ }
9
+ export type IRenderingContextDefinition = ServiceDefinition<IRenderingContextService, IRenderingContextServiceConfig>;
10
+ export declare const RenderingContextDefinition: string & {
11
+ __api: IRenderingContextService;
12
+ __config: IRenderingContextServiceConfig;
13
+ isServiceDefinition?: boolean;
14
+ } & IRenderingContextService;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RenderingContextDefinition = void 0;
4
+ const services_definitions_1 = require("@wix/services-definitions");
5
+ exports.RenderingContextDefinition = (0, services_definitions_1.defineService)('@wix/site-service-rendering-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;AAc5C,QAAA,0BAA0B,GAAG,IAAA,oCAAa,EACnD,qCAAqC,CACxC,CAAA"}
@@ -0,0 +1 @@
1
+ export { RenderingContextService } from './renderingContextService';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RenderingContextService = void 0;
4
+ var renderingContextService_1 = require("./renderingContextService");
5
+ Object.defineProperty(exports, "RenderingContextService", { enumerable: true, get: function () { return renderingContextService_1.RenderingContextService; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/implementations/index.ts"],"names":[],"mappings":";;;AAAA,qEAAmE;AAA1D,kIAAA,uBAAuB,OAAA"}
@@ -0,0 +1,6 @@
1
+ import type { IRenderingContextService, IRenderingContextServiceConfig } from '../definition';
2
+ export declare const RenderingContextService: import("@wix/services-definitions").ServiceFactory<string & {
3
+ __api: IRenderingContextService;
4
+ __config: IRenderingContextServiceConfig;
5
+ isServiceDefinition?: boolean;
6
+ } & IRenderingContextService, IRenderingContextServiceConfig>;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RenderingContextService = void 0;
4
+ const services_definitions_1 = require("@wix/services-definitions");
5
+ const definition_1 = require("../definition");
6
+ exports.RenderingContextService = (0, services_definitions_1.implementService)(definition_1.RenderingContextDefinition, ({ config }) => {
7
+ const SSR = globalThis.window === undefined;
8
+ const SEO = config.seo ?? false;
9
+ return {
10
+ get SSR() {
11
+ return SSR;
12
+ },
13
+ get SEO() {
14
+ return SEO;
15
+ },
16
+ };
17
+ });
18
+ //# sourceMappingURL=renderingContextService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderingContextService.js","sourceRoot":"","sources":["../../../src/implementations/renderingContextService.ts"],"names":[],"mappings":";;;AAAA,oEAA4D;AAG5D,8CAA0D;AAE7C,QAAA,uBAAuB,GAAG,IAAA,uCAAgB,EACnD,uCAA0B,EAC1B,CAAC,EAAE,MAAM,EAAsD,EAA4B,EAAE;IACzF,MAAM,GAAG,GAAG,UAAU,CAAC,MAAM,KAAK,SAAS,CAAA;IAC3C,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,IAAI,KAAK,CAAA;IAE/B,OAAO;QACH,IAAI,GAAG;YACH,OAAO,GAAG,CAAA;QACd,CAAC;QACD,IAAI,GAAG;YACH,OAAO,GAAG,CAAA;QACd,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 { RenderingContextService } from './implementations/renderingContextService';
2
+ export declare const definition: string & {
3
+ __api: import("./definition").IRenderingContextService;
4
+ __config: import("./definition").IRenderingContextServiceConfig;
5
+ isServiceDefinition?: boolean;
6
+ } & import("./definition").IRenderingContextService;
7
+ export default RenderingContextService;
@@ -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 renderingContextService_1 = require("./implementations/renderingContextService");
6
+ exports.definition = definition_1.RenderingContextDefinition;
7
+ exports.default = renderingContextService_1.RenderingContextService;
8
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/service.ts"],"names":[],"mappings":";;;AAAA,6CAAyD;AACzD,uFAAmF;AAEtE,QAAA,UAAU,GAAG,uCAA0B,CAAA;AACpD,kBAAe,iDAAuB,CAAA"}
@@ -0,0 +1 @@
1
+ export type { IRenderingContextService, IRenderingContextServiceConfig, IRenderingContextDefinition, } 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,14 @@
1
+ import type { ServiceDefinition } from '@wix/services-definitions';
2
+ export type IRenderingContextServiceConfig = {
3
+ readonly seo?: boolean;
4
+ };
5
+ export interface IRenderingContextService {
6
+ readonly SSR: boolean;
7
+ readonly SEO: boolean;
8
+ }
9
+ export type IRenderingContextDefinition = ServiceDefinition<IRenderingContextService, IRenderingContextServiceConfig>;
10
+ export declare const RenderingContextDefinition: string & {
11
+ __api: IRenderingContextService;
12
+ __config: IRenderingContextServiceConfig;
13
+ isServiceDefinition?: boolean;
14
+ } & IRenderingContextService;
@@ -0,0 +1,3 @@
1
+ import { defineService } from '@wix/services-definitions';
2
+ export const RenderingContextDefinition = defineService('@wix/site-service-rendering-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;AAczD,MAAM,CAAC,MAAM,0BAA0B,GAAG,aAAa,CACnD,qCAAqC,CACxC,CAAA"}
@@ -0,0 +1 @@
1
+ export { RenderingContextService } from './renderingContextService';
@@ -0,0 +1,2 @@
1
+ export { RenderingContextService } from './renderingContextService';
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,uBAAuB,EAAE,MAAM,2BAA2B,CAAA"}
@@ -0,0 +1,6 @@
1
+ import type { IRenderingContextService, IRenderingContextServiceConfig } from '../definition';
2
+ export declare const RenderingContextService: import("@wix/services-definitions").ServiceFactory<string & {
3
+ __api: IRenderingContextService;
4
+ __config: IRenderingContextServiceConfig;
5
+ isServiceDefinition?: boolean;
6
+ } & IRenderingContextService, IRenderingContextServiceConfig>;
@@ -0,0 +1,15 @@
1
+ import { implementService } from '@wix/services-definitions';
2
+ import { RenderingContextDefinition } from '../definition';
3
+ export const RenderingContextService = implementService(RenderingContextDefinition, ({ config }) => {
4
+ const SSR = globalThis.window === undefined;
5
+ const SEO = config.seo ?? false;
6
+ return {
7
+ get SSR() {
8
+ return SSR;
9
+ },
10
+ get SEO() {
11
+ return SEO;
12
+ },
13
+ };
14
+ });
15
+ //# sourceMappingURL=renderingContextService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderingContextService.js","sourceRoot":"","sources":["../../src/implementations/renderingContextService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAG5D,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAA;AAE1D,MAAM,CAAC,MAAM,uBAAuB,GAAG,gBAAgB,CACnD,0BAA0B,EAC1B,CAAC,EAAE,MAAM,EAAsD,EAA4B,EAAE;IACzF,MAAM,GAAG,GAAG,UAAU,CAAC,MAAM,KAAK,SAAS,CAAA;IAC3C,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,IAAI,KAAK,CAAA;IAE/B,OAAO;QACH,IAAI,GAAG;YACH,OAAO,GAAG,CAAA;QACd,CAAC;QACD,IAAI,GAAG;YACH,OAAO,GAAG,CAAA;QACd,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 { RenderingContextService } from './implementations/renderingContextService';
2
+ export declare const definition: string & {
3
+ __api: import("./definition").IRenderingContextService;
4
+ __config: import("./definition").IRenderingContextServiceConfig;
5
+ isServiceDefinition?: boolean;
6
+ } & import("./definition").IRenderingContextService;
7
+ export default RenderingContextService;
@@ -0,0 +1,5 @@
1
+ import { RenderingContextDefinition } from './definition';
2
+ import { RenderingContextService } from './implementations/renderingContextService';
3
+ export const definition = RenderingContextDefinition;
4
+ export default RenderingContextService;
5
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAA;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAA;AAEnF,MAAM,CAAC,MAAM,UAAU,GAAG,0BAA0B,CAAA;AACpD,eAAe,uBAAuB,CAAA"}
@@ -0,0 +1 @@
1
+ export type { IRenderingContextService, IRenderingContextServiceConfig, IRenderingContextDefinition, } 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-rendering-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-rendering-context",
68
+ "targets": {
69
+ "static": false,
70
+ "docker": false
71
+ }
72
+ },
73
+ "validations": {
74
+ "postBuild": [
75
+ "test",
76
+ "lint"
77
+ ]
78
+ }
79
+ },
80
+ "falconPackageHash": "64c62d1ad6336e747e51cc0abfe9da9b50ede0be14a4f13b30711bad"
81
+ }
@@ -0,0 +1,17 @@
1
+ import { defineService } from '@wix/services-definitions'
2
+ import type { ServiceDefinition } from '@wix/services-definitions'
3
+
4
+ export type IRenderingContextServiceConfig = {
5
+ readonly seo?: boolean
6
+ }
7
+
8
+ export interface IRenderingContextService {
9
+ readonly SSR: boolean
10
+ readonly SEO: boolean
11
+ }
12
+
13
+ export type IRenderingContextDefinition = ServiceDefinition<IRenderingContextService, IRenderingContextServiceConfig>
14
+
15
+ export const RenderingContextDefinition = defineService<IRenderingContextService, IRenderingContextServiceConfig>(
16
+ '@wix/site-service-rendering-context'
17
+ )
@@ -0,0 +1 @@
1
+ export { RenderingContextService } from './renderingContextService'
@@ -0,0 +1,21 @@
1
+ import { implementService } from '@wix/services-definitions'
2
+ import type { ServiceFactoryOpts } from '@wix/services-definitions'
3
+ import type { IRenderingContextService, IRenderingContextServiceConfig } from '../definition'
4
+ import { RenderingContextDefinition } from '../definition'
5
+
6
+ export const RenderingContextService = implementService(
7
+ RenderingContextDefinition,
8
+ ({ config }: ServiceFactoryOpts<IRenderingContextServiceConfig>): IRenderingContextService => {
9
+ const SSR = globalThis.window === undefined
10
+ const SEO = config.seo ?? false
11
+
12
+ return {
13
+ get SSR() {
14
+ return SSR
15
+ },
16
+ get SEO() {
17
+ return SEO
18
+ },
19
+ }
20
+ }
21
+ )
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 { RenderingContextDefinition } from './definition'
2
+ import { RenderingContextService } from './implementations/renderingContextService'
3
+
4
+ export const definition = RenderingContextDefinition
5
+ export default RenderingContextService
@@ -0,0 +1,5 @@
1
+ export type {
2
+ IRenderingContextService,
3
+ IRenderingContextServiceConfig,
4
+ IRenderingContextDefinition,
5
+ } from '../definition'
@@ -0,0 +1,3 @@
1
+ {
2
+ "main": "../cjs/build/types/index.js"
3
+ }