@wix/site-service-lightbox 0.0.0-stage → 1.0.0
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.
- package/README.md +75 -2
- package/cjs/build/definition/index.d.ts +23 -0
- package/cjs/build/definition/index.js +6 -0
- package/cjs/build/definition/index.js.map +1 -0
- package/cjs/build/implementations/index.d.ts +1 -0
- package/cjs/build/implementations/index.js +6 -0
- package/cjs/build/implementations/index.js.map +1 -0
- package/cjs/build/implementations/lightboxService.d.ts +6 -0
- package/cjs/build/implementations/lightboxService.js +15 -0
- package/cjs/build/implementations/lightboxService.js.map +1 -0
- package/cjs/build/index.d.ts +2 -0
- package/cjs/build/index.js +19 -0
- package/cjs/build/index.js.map +1 -0
- package/cjs/build/service.d.ts +7 -0
- package/cjs/build/service.js +8 -0
- package/cjs/build/service.js.map +1 -0
- package/cjs/build/types/index.d.ts +1 -0
- package/cjs/build/types/index.js +3 -0
- package/cjs/build/types/index.js.map +1 -0
- package/cjs/package.json +3 -0
- package/definition/package.json +3 -0
- package/dist/definition/index.d.ts +23 -0
- package/dist/definition/index.js +3 -0
- package/dist/definition/index.js.map +1 -0
- package/dist/implementations/index.d.ts +1 -0
- package/dist/implementations/index.js +2 -0
- package/dist/implementations/index.js.map +1 -0
- package/dist/implementations/lightboxService.d.ts +6 -0
- package/dist/implementations/lightboxService.js +12 -0
- package/dist/implementations/lightboxService.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/service.d.ts +7 -0
- package/dist/service.js +5 -0
- package/dist/service.js.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/implementations/package.json +3 -0
- package/package.json +78 -3
- package/src/definition/index.ts +26 -0
- package/src/implementations/index.ts +1 -0
- package/src/implementations/lightboxService.ts +17 -0
- package/src/index.ts +2 -0
- package/src/service.ts +5 -0
- package/src/types/index.ts +7 -0
- package/types/package.json +3 -0
package/README.md
CHANGED
|
@@ -1,3 +1,76 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @wix/site-service-lightbox
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Opens and closes **lightboxes** (popups) and reads the context the open lightbox was
|
|
4
|
+
opened with. Only one lightbox is open at a time. UI & Viewport category.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
yarn add @wix/site-service-lightbox
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { LightboxDefinition } from '@wix/site-service-lightbox/definition'
|
|
16
|
+
|
|
17
|
+
const lightbox = useService(LightboxDefinition)
|
|
18
|
+
|
|
19
|
+
type SignupContext = { source: string }
|
|
20
|
+
|
|
21
|
+
// Open a lightbox page, passing it some context:
|
|
22
|
+
await lightbox.open<SignupContext>({ pageId: 'lightbox-page-id', context: { source: 'signup' } })
|
|
23
|
+
|
|
24
|
+
// In a component rendered inside the lightbox:
|
|
25
|
+
const context = lightbox.getContext<SignupContext>()
|
|
26
|
+
lightbox.close()
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
The host (Thunderbolt) registers the service and injects the actual behavior:
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { LightboxDefinition } from '@wix/site-service-lightbox/definition'
|
|
33
|
+
import { LightboxService } from '@wix/site-service-lightbox/implementations'
|
|
34
|
+
|
|
35
|
+
createServicesMap().addService(LightboxDefinition, LightboxService, {
|
|
36
|
+
open: async ({ pageId, context }) => {
|
|
37
|
+
/* open the lightbox page */
|
|
38
|
+
},
|
|
39
|
+
close: () => {
|
|
40
|
+
/* close the open lightbox */
|
|
41
|
+
},
|
|
42
|
+
getContext: () => {
|
|
43
|
+
/* return the open lightbox's context */
|
|
44
|
+
},
|
|
45
|
+
})
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## API
|
|
49
|
+
|
|
50
|
+
| Member | Type | Description |
|
|
51
|
+
|---|---|---|
|
|
52
|
+
| `open` | `<TContext = LightboxContext>(options: { pageId: string; context?: TContext }) => Promise<void>` | Opens the lightbox page `pageId` with `context`. Returns the host's promise. |
|
|
53
|
+
| `close` | `() => void` | Closes the currently open lightbox. Fire-and-forget: returns nothing, even if the host's close is async. |
|
|
54
|
+
| `getContext` | `<TContext = LightboxContext>() => TContext` | Returns the context the open lightbox was opened with. |
|
|
55
|
+
|
|
56
|
+
All three are plain methods — this service exposes no property getters.
|
|
57
|
+
|
|
58
|
+
The context is opaque to the service: it passes the value through unchanged and never reads it
|
|
59
|
+
(`LightboxContext` is `unknown`).
|
|
60
|
+
`TContext` types it for the caller, but nothing checks that `getContext<TContext>()` asks for
|
|
61
|
+
the same type the lightbox was opened with; that is the caller's assertion.
|
|
62
|
+
|
|
63
|
+
## Configuration
|
|
64
|
+
|
|
65
|
+
`ILightboxServiceConfig`:
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
export type ILightboxServiceConfig = {
|
|
69
|
+
open: (options: LightboxOpenOptions) => Promise<void>
|
|
70
|
+
close: () => void
|
|
71
|
+
getContext: () => LightboxContext
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
- `open`, `close`, `getContext` — the host's implementations. The service calls them on each use.
|
|
76
|
+
All three are required; the service has no fallback behavior.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ServiceDefinition } from '@wix/services-definitions';
|
|
2
|
+
export type LightboxContext = unknown;
|
|
3
|
+
export type LightboxOpenOptions<TContext = LightboxContext> = {
|
|
4
|
+
pageId: string;
|
|
5
|
+
context?: TContext;
|
|
6
|
+
};
|
|
7
|
+
export type ILightboxServiceConfig = {
|
|
8
|
+
open: (options: LightboxOpenOptions) => Promise<void>;
|
|
9
|
+
close: () => void;
|
|
10
|
+
getContext: () => LightboxContext;
|
|
11
|
+
};
|
|
12
|
+
export interface ILightboxService {
|
|
13
|
+
open<TContext = LightboxContext>(options: LightboxOpenOptions<TContext>): Promise<void>;
|
|
14
|
+
close(): void;
|
|
15
|
+
/** Not checked against the context passed to `open`; the caller asserts its type. */
|
|
16
|
+
getContext<TContext = LightboxContext>(): TContext;
|
|
17
|
+
}
|
|
18
|
+
export type ILightboxDefinition = ServiceDefinition<ILightboxService, ILightboxServiceConfig>;
|
|
19
|
+
export declare const LightboxDefinition: string & {
|
|
20
|
+
__api: ILightboxService;
|
|
21
|
+
__config: ILightboxServiceConfig;
|
|
22
|
+
isServiceDefinition?: boolean;
|
|
23
|
+
} & ILightboxService;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LightboxDefinition = void 0;
|
|
4
|
+
const services_definitions_1 = require("@wix/services-definitions");
|
|
5
|
+
exports.LightboxDefinition = (0, services_definitions_1.defineService)('@wix/site-service-lightbox');
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/definition/index.ts"],"names":[],"mappings":";;;AAAA,oEAAyD;AAyB5C,QAAA,kBAAkB,GAAG,IAAA,oCAAa,EAA2C,4BAA4B,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LightboxService } from './lightboxService';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LightboxService = void 0;
|
|
4
|
+
var lightboxService_1 = require("./lightboxService");
|
|
5
|
+
Object.defineProperty(exports, "LightboxService", { enumerable: true, get: function () { return lightboxService_1.LightboxService; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/implementations/index.ts"],"names":[],"mappings":";;;AAAA,qDAAmD;AAA1C,kHAAA,eAAe,OAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ILightboxService, ILightboxServiceConfig } from '../definition';
|
|
2
|
+
export declare const LightboxService: import("@wix/services-definitions").ServiceFactory<string & {
|
|
3
|
+
__api: ILightboxService;
|
|
4
|
+
__config: ILightboxServiceConfig;
|
|
5
|
+
isServiceDefinition?: boolean;
|
|
6
|
+
} & ILightboxService, ILightboxServiceConfig>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LightboxService = void 0;
|
|
4
|
+
const services_definitions_1 = require("@wix/services-definitions");
|
|
5
|
+
const definition_1 = require("../definition");
|
|
6
|
+
exports.LightboxService = (0, services_definitions_1.implementService)(definition_1.LightboxDefinition, ({ config }) => {
|
|
7
|
+
return {
|
|
8
|
+
open: (options) => config.open(options),
|
|
9
|
+
close: () => {
|
|
10
|
+
config.close();
|
|
11
|
+
},
|
|
12
|
+
getContext: () => config.getContext(),
|
|
13
|
+
};
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=lightboxService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lightboxService.js","sourceRoot":"","sources":["../../../src/implementations/lightboxService.ts"],"names":[],"mappings":";;;AAAA,oEAA4D;AAG5D,8CAAkD;AAErC,QAAA,eAAe,GAAG,IAAA,uCAAgB,EAC9C,+BAAkB,EAClB,CAAC,EAAE,MAAM,EAA8C,EAAoB,EAAE;IAC5E,OAAO;QACN,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;QACvC,KAAK,EAAE,GAAG,EAAE;YACX,MAAM,CAAC,KAAK,EAAE,CAAA;QACf,CAAC;QACD,UAAU,EAAE,GAAa,EAAE,CAAC,MAAM,CAAC,UAAU,EAAc;KAC3D,CAAA;AACF,CAAC,CACD,CAAA"}
|
|
@@ -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 { LightboxService } from './implementations/lightboxService';
|
|
2
|
+
export declare const definition: string & {
|
|
3
|
+
__api: import("./definition").ILightboxService;
|
|
4
|
+
__config: import("./definition").ILightboxServiceConfig;
|
|
5
|
+
isServiceDefinition?: boolean;
|
|
6
|
+
} & import("./definition").ILightboxService;
|
|
7
|
+
export default LightboxService;
|
|
@@ -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 lightboxService_1 = require("./implementations/lightboxService");
|
|
6
|
+
exports.definition = definition_1.LightboxDefinition;
|
|
7
|
+
exports.default = lightboxService_1.LightboxService;
|
|
8
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/service.ts"],"names":[],"mappings":";;;AAAA,6CAAiD;AACjD,uEAAmE;AAEtD,QAAA,UAAU,GAAG,+BAAkB,CAAA;kBAC7B,iCAAe"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { ILightboxService, ILightboxServiceConfig, ILightboxDefinition, LightboxContext, LightboxOpenOptions, } from '../definition';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":""}
|
package/cjs/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ServiceDefinition } from '@wix/services-definitions';
|
|
2
|
+
export type LightboxContext = unknown;
|
|
3
|
+
export type LightboxOpenOptions<TContext = LightboxContext> = {
|
|
4
|
+
pageId: string;
|
|
5
|
+
context?: TContext;
|
|
6
|
+
};
|
|
7
|
+
export type ILightboxServiceConfig = {
|
|
8
|
+
open: (options: LightboxOpenOptions) => Promise<void>;
|
|
9
|
+
close: () => void;
|
|
10
|
+
getContext: () => LightboxContext;
|
|
11
|
+
};
|
|
12
|
+
export interface ILightboxService {
|
|
13
|
+
open<TContext = LightboxContext>(options: LightboxOpenOptions<TContext>): Promise<void>;
|
|
14
|
+
close(): void;
|
|
15
|
+
/** Not checked against the context passed to `open`; the caller asserts its type. */
|
|
16
|
+
getContext<TContext = LightboxContext>(): TContext;
|
|
17
|
+
}
|
|
18
|
+
export type ILightboxDefinition = ServiceDefinition<ILightboxService, ILightboxServiceConfig>;
|
|
19
|
+
export declare const LightboxDefinition: string & {
|
|
20
|
+
__api: ILightboxService;
|
|
21
|
+
__config: ILightboxServiceConfig;
|
|
22
|
+
isServiceDefinition?: boolean;
|
|
23
|
+
} & ILightboxService;
|
|
@@ -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;AAyBzD,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAA2C,4BAA4B,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LightboxService } from './lightboxService';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/implementations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ILightboxService, ILightboxServiceConfig } from '../definition';
|
|
2
|
+
export declare const LightboxService: import("@wix/services-definitions").ServiceFactory<string & {
|
|
3
|
+
__api: ILightboxService;
|
|
4
|
+
__config: ILightboxServiceConfig;
|
|
5
|
+
isServiceDefinition?: boolean;
|
|
6
|
+
} & ILightboxService, ILightboxServiceConfig>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { implementService } from '@wix/services-definitions';
|
|
2
|
+
import { LightboxDefinition } from '../definition';
|
|
3
|
+
export const LightboxService = implementService(LightboxDefinition, ({ config }) => {
|
|
4
|
+
return {
|
|
5
|
+
open: (options) => config.open(options),
|
|
6
|
+
close: () => {
|
|
7
|
+
config.close();
|
|
8
|
+
},
|
|
9
|
+
getContext: () => config.getContext(),
|
|
10
|
+
};
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=lightboxService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lightboxService.js","sourceRoot":"","sources":["../../src/implementations/lightboxService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAG5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAElD,MAAM,CAAC,MAAM,eAAe,GAAG,gBAAgB,CAC9C,kBAAkB,EAClB,CAAC,EAAE,MAAM,EAA8C,EAAoB,EAAE;IAC5E,OAAO;QACN,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;QACvC,KAAK,EAAE,GAAG,EAAE;YACX,MAAM,CAAC,KAAK,EAAE,CAAA;QACf,CAAC;QACD,UAAU,EAAE,GAAa,EAAE,CAAC,MAAM,CAAC,UAAU,EAAc;KAC3D,CAAA;AACF,CAAC,CACD,CAAA"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -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 { LightboxService } from './implementations/lightboxService';
|
|
2
|
+
export declare const definition: string & {
|
|
3
|
+
__api: import("./definition").ILightboxService;
|
|
4
|
+
__config: import("./definition").ILightboxServiceConfig;
|
|
5
|
+
isServiceDefinition?: boolean;
|
|
6
|
+
} & import("./definition").ILightboxService;
|
|
7
|
+
export default LightboxService;
|
package/dist/service.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AAEnE,MAAM,CAAC,MAAM,UAAU,GAAG,kBAAkB,CAAA;AAC5C,eAAe,eAAe,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { ILightboxService, ILightboxServiceConfig, ILightboxDefinition, LightboxContext, LightboxOpenOptions, } from '../definition';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,81 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/site-service-lightbox",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"license": "UNLICENSED",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist",
|
|
7
|
+
"src",
|
|
8
|
+
"cjs",
|
|
9
|
+
"definition",
|
|
10
|
+
"implementations",
|
|
11
|
+
"types",
|
|
12
|
+
"!**/*.tsbuildinfo"
|
|
13
|
+
],
|
|
14
|
+
"sideEffects": false,
|
|
15
|
+
"main": "cjs/build/index.js",
|
|
16
|
+
"module": "dist/index.js",
|
|
17
|
+
"types": "dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js",
|
|
22
|
+
"require": "./cjs/build/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./definition": {
|
|
25
|
+
"types": "./dist/definition/index.d.ts",
|
|
26
|
+
"import": "./dist/definition/index.js",
|
|
27
|
+
"require": "./cjs/build/definition/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./implementations": {
|
|
30
|
+
"types": "./dist/implementations/index.d.ts",
|
|
31
|
+
"import": "./dist/implementations/index.js",
|
|
32
|
+
"require": "./cjs/build/implementations/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./types": {
|
|
35
|
+
"types": "./dist/types/index.d.ts",
|
|
36
|
+
"import": "./dist/types/index.js",
|
|
37
|
+
"require": "./cjs/build/types/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./service": {
|
|
40
|
+
"types": "./dist/service.d.ts",
|
|
41
|
+
"import": "./dist/service.js",
|
|
42
|
+
"require": "./cjs/build/service.js"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"registry": "https://registry.npmjs.org/",
|
|
47
|
+
"access": "public"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "tsc -b . --force && tsc --project tsconfig.cjs.json",
|
|
51
|
+
"lint": "yarn run -T lint:package $npm_package_name",
|
|
52
|
+
"test": "vitest --run && yarn test-type-check",
|
|
53
|
+
"test-type-check": "echo 'validating typescript in test files' && tsc --project tsconfig.test.json && echo 'Finished validating typescript in test files successfully'"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@wix/services-definitions": "^0.1.4",
|
|
57
|
+
"@wix/services-manager": "^0.2.20"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"typescript": "~7.0.2",
|
|
61
|
+
"vitest": "4.1.11"
|
|
62
|
+
},
|
|
63
|
+
"publishUnscoped": false,
|
|
64
|
+
"wix": {
|
|
65
|
+
"artifact": {
|
|
66
|
+
"groupId": "com.wixpress.npm",
|
|
67
|
+
"artifactId": "site-service-lightbox",
|
|
68
|
+
"targets": {
|
|
69
|
+
"static": false,
|
|
70
|
+
"docker": false
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"validations": {
|
|
74
|
+
"postBuild": [
|
|
75
|
+
"test",
|
|
76
|
+
"lint"
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"falconPackageHash": "3aed728a64fa9c464fcfd8b4cc9c55256a46fe73218949841f21360f"
|
|
6
81
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { defineService } from '@wix/services-definitions'
|
|
2
|
+
import type { ServiceDefinition } from '@wix/services-definitions'
|
|
3
|
+
|
|
4
|
+
export type LightboxContext = unknown
|
|
5
|
+
|
|
6
|
+
export type LightboxOpenOptions<TContext = LightboxContext> = {
|
|
7
|
+
pageId: string
|
|
8
|
+
context?: TContext
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type ILightboxServiceConfig = {
|
|
12
|
+
open: (options: LightboxOpenOptions) => Promise<void>
|
|
13
|
+
close: () => void
|
|
14
|
+
getContext: () => LightboxContext
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ILightboxService {
|
|
18
|
+
open<TContext = LightboxContext>(options: LightboxOpenOptions<TContext>): Promise<void>
|
|
19
|
+
close(): void
|
|
20
|
+
/** Not checked against the context passed to `open`; the caller asserts its type. */
|
|
21
|
+
getContext<TContext = LightboxContext>(): TContext
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type ILightboxDefinition = ServiceDefinition<ILightboxService, ILightboxServiceConfig>
|
|
25
|
+
|
|
26
|
+
export const LightboxDefinition = defineService<ILightboxService, ILightboxServiceConfig>('@wix/site-service-lightbox')
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LightboxService } from './lightboxService'
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { implementService } from '@wix/services-definitions'
|
|
2
|
+
import type { ServiceFactoryOpts } from '@wix/services-definitions'
|
|
3
|
+
import type { ILightboxService, ILightboxServiceConfig } from '../definition'
|
|
4
|
+
import { LightboxDefinition } from '../definition'
|
|
5
|
+
|
|
6
|
+
export const LightboxService = implementService(
|
|
7
|
+
LightboxDefinition,
|
|
8
|
+
({ config }: ServiceFactoryOpts<ILightboxServiceConfig>): ILightboxService => {
|
|
9
|
+
return {
|
|
10
|
+
open: (options) => config.open(options),
|
|
11
|
+
close: () => {
|
|
12
|
+
config.close()
|
|
13
|
+
},
|
|
14
|
+
getContext: <TContext>() => config.getContext() as TContext,
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
)
|
package/src/index.ts
ADDED
package/src/service.ts
ADDED