@wix/site-service-above-the-fold 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 +44 -0
  2. package/cjs/build/definition/index.d.ts +15 -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/aboveTheFoldService.d.ts +6 -0
  6. package/cjs/build/implementations/aboveTheFoldService.js +11 -0
  7. package/cjs/build/implementations/aboveTheFoldService.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 +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 +15 -0
  23. package/dist/definition/index.js +3 -0
  24. package/dist/definition/index.js.map +1 -0
  25. package/dist/implementations/aboveTheFoldService.d.ts +6 -0
  26. package/dist/implementations/aboveTheFoldService.js +8 -0
  27. package/dist/implementations/aboveTheFoldService.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 +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 +19 -0
  43. package/src/implementations/aboveTheFoldService.ts +13 -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 +7 -0
  48. package/types/package.json +3 -0
package/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # @wix/site-service-above-the-fold
2
+
3
+ Service for checking whether a component id/path is marked as above the fold.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ yarn add @wix/site-service-above-the-fold
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { AboveTheFoldDefinition } from '@wix/site-service-above-the-fold/definition'
15
+ import { AboveTheFoldService } from '@wix/site-service-above-the-fold/implementations'
16
+
17
+ createServicesMap().addService(AboveTheFoldDefinition, AboveTheFoldService, config)
18
+
19
+ const service = servicesManager.getService(AboveTheFoldDefinition)
20
+ const isAboveTheFold = service.isInFirstFold('comp-k4x3')
21
+ ```
22
+
23
+ ## API
24
+
25
+ | Member | Type | Throws when | Description |
26
+ |---|---|---|---|
27
+ | `isInFirstFold` | `(key: CompId \| CompPath) => boolean \| undefined` | never | Returns whether the passed component id/path is marked as above-the-fold in config. |
28
+
29
+ ## Configuration
30
+
31
+ `IAboveTheFoldServiceConfig`:
32
+
33
+ ```ts
34
+ type CompId = string
35
+ type CompPath = string
36
+
37
+ type IAboveTheFoldServiceConfig = Record<CompId | CompPath, boolean>
38
+ ```
39
+
40
+ When a key does not exist in config, `isInFirstFold` returns `undefined`.
41
+
42
+ ## Reactivity
43
+
44
+ This is a read-only lookup service and does not expose runtime update APIs.
@@ -0,0 +1,15 @@
1
+ import type { ServiceDefinition } from '@wix/services-definitions';
2
+ export type CompId = string;
3
+ export type CompPath = string;
4
+ export type IAboveTheFoldServiceConfig = {
5
+ [key: CompId | CompPath]: boolean;
6
+ };
7
+ export interface IAboveTheFoldService {
8
+ isInFirstFold: (key: CompId | CompPath) => boolean | undefined;
9
+ }
10
+ export type IAboveTheFoldDefinition = ServiceDefinition<IAboveTheFoldService, IAboveTheFoldServiceConfig>;
11
+ export declare const AboveTheFoldDefinition: string & {
12
+ __api: IAboveTheFoldService;
13
+ __config: IAboveTheFoldServiceConfig;
14
+ isServiceDefinition?: boolean;
15
+ } & IAboveTheFoldService;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AboveTheFoldDefinition = void 0;
4
+ const services_definitions_1 = require("@wix/services-definitions");
5
+ exports.AboveTheFoldDefinition = (0, services_definitions_1.defineService)('@wix/site-service-above-the-fold');
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/definition/index.ts"],"names":[],"mappings":";;;AAAA,oEAAyD;AAgB5C,QAAA,sBAAsB,GAAG,IAAA,oCAAa,EAC/C,kCAAkC,CACrC,CAAA"}
@@ -0,0 +1,6 @@
1
+ import type { IAboveTheFoldService, IAboveTheFoldServiceConfig } from '../definition';
2
+ export declare const AboveTheFoldService: import("@wix/services-definitions").ServiceFactory<string & {
3
+ __api: IAboveTheFoldService;
4
+ __config: IAboveTheFoldServiceConfig;
5
+ isServiceDefinition?: boolean;
6
+ } & IAboveTheFoldService, IAboveTheFoldServiceConfig>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AboveTheFoldService = void 0;
4
+ const services_definitions_1 = require("@wix/services-definitions");
5
+ const definition_1 = require("../definition");
6
+ exports.AboveTheFoldService = (0, services_definitions_1.implementService)(definition_1.AboveTheFoldDefinition, ({ config }) => {
7
+ return {
8
+ isInFirstFold: key => config[key],
9
+ };
10
+ });
11
+ //# sourceMappingURL=aboveTheFoldService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aboveTheFoldService.js","sourceRoot":"","sources":["../../../src/implementations/aboveTheFoldService.ts"],"names":[],"mappings":";;;AAAA,oEAA4D;AAG5D,8CAAsD;AAEzC,QAAA,mBAAmB,GAAG,IAAA,uCAAgB,EAC/C,mCAAsB,EACtB,CAAC,EAAE,MAAM,EAAkD,EAAwB,EAAE;IACjF,OAAO;QACH,aAAa,EAAE,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC;KACpC,CAAA;AACL,CAAC,CACJ,CAAA"}
@@ -0,0 +1 @@
1
+ export { AboveTheFoldService } from './aboveTheFoldService';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AboveTheFoldService = void 0;
4
+ var aboveTheFoldService_1 = require("./aboveTheFoldService");
5
+ Object.defineProperty(exports, "AboveTheFoldService", { enumerable: true, get: function () { return aboveTheFoldService_1.AboveTheFoldService; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/implementations/index.ts"],"names":[],"mappings":";;;AAAA,6DAA2D;AAAlD,0HAAA,mBAAmB,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 { AboveTheFoldService } from './implementations/aboveTheFoldService';
2
+ export declare const definition: string & {
3
+ __api: import("./definition").IAboveTheFoldService;
4
+ __config: import("./definition").IAboveTheFoldServiceConfig;
5
+ isServiceDefinition?: boolean;
6
+ } & import("./definition").IAboveTheFoldService;
7
+ export default AboveTheFoldService;
@@ -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 aboveTheFoldService_1 = require("./implementations/aboveTheFoldService");
6
+ exports.definition = definition_1.AboveTheFoldDefinition;
7
+ exports.default = aboveTheFoldService_1.AboveTheFoldService;
8
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/service.ts"],"names":[],"mappings":";;;AAAA,6CAAqD;AACrD,+EAA2E;AAE9D,QAAA,UAAU,GAAG,mCAAsB,CAAA;AAChD,kBAAe,yCAAmB,CAAA"}
@@ -0,0 +1 @@
1
+ export type { CompId, CompPath, IAboveTheFoldService, IAboveTheFoldServiceConfig, IAboveTheFoldDefinition, } 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,15 @@
1
+ import type { ServiceDefinition } from '@wix/services-definitions';
2
+ export type CompId = string;
3
+ export type CompPath = string;
4
+ export type IAboveTheFoldServiceConfig = {
5
+ [key: CompId | CompPath]: boolean;
6
+ };
7
+ export interface IAboveTheFoldService {
8
+ isInFirstFold: (key: CompId | CompPath) => boolean | undefined;
9
+ }
10
+ export type IAboveTheFoldDefinition = ServiceDefinition<IAboveTheFoldService, IAboveTheFoldServiceConfig>;
11
+ export declare const AboveTheFoldDefinition: string & {
12
+ __api: IAboveTheFoldService;
13
+ __config: IAboveTheFoldServiceConfig;
14
+ isServiceDefinition?: boolean;
15
+ } & IAboveTheFoldService;
@@ -0,0 +1,3 @@
1
+ import { defineService } from '@wix/services-definitions';
2
+ export const AboveTheFoldDefinition = defineService('@wix/site-service-above-the-fold');
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;AAgBzD,MAAM,CAAC,MAAM,sBAAsB,GAAG,aAAa,CAC/C,kCAAkC,CACrC,CAAA"}
@@ -0,0 +1,6 @@
1
+ import type { IAboveTheFoldService, IAboveTheFoldServiceConfig } from '../definition';
2
+ export declare const AboveTheFoldService: import("@wix/services-definitions").ServiceFactory<string & {
3
+ __api: IAboveTheFoldService;
4
+ __config: IAboveTheFoldServiceConfig;
5
+ isServiceDefinition?: boolean;
6
+ } & IAboveTheFoldService, IAboveTheFoldServiceConfig>;
@@ -0,0 +1,8 @@
1
+ import { implementService } from '@wix/services-definitions';
2
+ import { AboveTheFoldDefinition } from '../definition';
3
+ export const AboveTheFoldService = implementService(AboveTheFoldDefinition, ({ config }) => {
4
+ return {
5
+ isInFirstFold: key => config[key],
6
+ };
7
+ });
8
+ //# sourceMappingURL=aboveTheFoldService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aboveTheFoldService.js","sourceRoot":"","sources":["../../src/implementations/aboveTheFoldService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAG5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAEtD,MAAM,CAAC,MAAM,mBAAmB,GAAG,gBAAgB,CAC/C,sBAAsB,EACtB,CAAC,EAAE,MAAM,EAAkD,EAAwB,EAAE;IACjF,OAAO;QACH,aAAa,EAAE,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC;KACpC,CAAA;AACL,CAAC,CACJ,CAAA"}
@@ -0,0 +1 @@
1
+ export { AboveTheFoldService } from './aboveTheFoldService';
@@ -0,0 +1,2 @@
1
+ export { AboveTheFoldService } from './aboveTheFoldService';
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,mBAAmB,EAAE,MAAM,uBAAuB,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 { AboveTheFoldService } from './implementations/aboveTheFoldService';
2
+ export declare const definition: string & {
3
+ __api: import("./definition").IAboveTheFoldService;
4
+ __config: import("./definition").IAboveTheFoldServiceConfig;
5
+ isServiceDefinition?: boolean;
6
+ } & import("./definition").IAboveTheFoldService;
7
+ export default AboveTheFoldService;
@@ -0,0 +1,5 @@
1
+ import { AboveTheFoldDefinition } from './definition';
2
+ import { AboveTheFoldService } from './implementations/aboveTheFoldService';
3
+ export const definition = AboveTheFoldDefinition;
4
+ export default AboveTheFoldService;
5
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAA;AAE3E,MAAM,CAAC,MAAM,UAAU,GAAG,sBAAsB,CAAA;AAChD,eAAe,mBAAmB,CAAA"}
@@ -0,0 +1 @@
1
+ export type { CompId, CompPath, IAboveTheFoldService, IAboveTheFoldServiceConfig, IAboveTheFoldDefinition, } 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-above-the-fold",
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-above-the-fold",
68
+ "targets": {
69
+ "static": false,
70
+ "docker": false
71
+ }
72
+ },
73
+ "validations": {
74
+ "postBuild": [
75
+ "test",
76
+ "lint"
77
+ ]
78
+ }
79
+ },
80
+ "falconPackageHash": "00da8034caed556c00b670fe1126f1a7856355d195916b6e16ddfeeb"
81
+ }
@@ -0,0 +1,19 @@
1
+ import { defineService } from '@wix/services-definitions'
2
+ import type { ServiceDefinition } from '@wix/services-definitions'
3
+
4
+ export type CompId = string
5
+ export type CompPath = string
6
+
7
+ export type IAboveTheFoldServiceConfig = {
8
+ [key: CompId | CompPath]: boolean
9
+ }
10
+
11
+ export interface IAboveTheFoldService {
12
+ isInFirstFold: (key: CompId | CompPath) => boolean | undefined
13
+ }
14
+
15
+ export type IAboveTheFoldDefinition = ServiceDefinition<IAboveTheFoldService, IAboveTheFoldServiceConfig>
16
+
17
+ export const AboveTheFoldDefinition = defineService<IAboveTheFoldService, IAboveTheFoldServiceConfig>(
18
+ '@wix/site-service-above-the-fold'
19
+ )
@@ -0,0 +1,13 @@
1
+ import { implementService } from '@wix/services-definitions'
2
+ import type { ServiceFactoryOpts } from '@wix/services-definitions'
3
+ import type { IAboveTheFoldService, IAboveTheFoldServiceConfig } from '../definition'
4
+ import { AboveTheFoldDefinition } from '../definition'
5
+
6
+ export const AboveTheFoldService = implementService(
7
+ AboveTheFoldDefinition,
8
+ ({ config }: ServiceFactoryOpts<IAboveTheFoldServiceConfig>): IAboveTheFoldService => {
9
+ return {
10
+ isInFirstFold: key => config[key],
11
+ }
12
+ }
13
+ )
@@ -0,0 +1 @@
1
+ export { AboveTheFoldService } from './aboveTheFoldService'
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 { AboveTheFoldDefinition } from './definition'
2
+ import { AboveTheFoldService } from './implementations/aboveTheFoldService'
3
+
4
+ export const definition = AboveTheFoldDefinition
5
+ export default AboveTheFoldService
@@ -0,0 +1,7 @@
1
+ export type {
2
+ CompId,
3
+ CompPath,
4
+ IAboveTheFoldService,
5
+ IAboveTheFoldServiceConfig,
6
+ IAboveTheFoldDefinition,
7
+ } from '../definition'
@@ -0,0 +1,3 @@
1
+ {
2
+ "main": "../cjs/build/types/index.js"
3
+ }