@prismicio/simulator 0.1.3 → 0.1.4-pr.19.862cb60
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 +9 -13
- package/dist/SimulatorAPI.cjs +38 -46
- package/dist/SimulatorAPI.cjs.map +1 -1
- package/dist/SimulatorAPI.d.cts +18 -0
- package/dist/SimulatorAPI.d.ts +16 -10
- package/dist/SimulatorAPI.js +37 -46
- package/dist/SimulatorAPI.js.map +1 -1
- package/dist/SimulatorClient.cjs +41 -51
- package/dist/SimulatorClient.cjs.map +1 -1
- package/dist/SimulatorClient.d.cts +16 -0
- package/dist/SimulatorClient.d.ts +15 -9
- package/dist/SimulatorClient.js +40 -51
- package/dist/SimulatorClient.js.map +1 -1
- package/dist/channel/ChannelEmitter.cjs +112 -143
- package/dist/channel/ChannelEmitter.cjs.map +1 -1
- package/dist/channel/ChannelEmitter.d.cts +38 -0
- package/dist/channel/ChannelEmitter.d.ts +36 -36
- package/dist/channel/ChannelEmitter.js +110 -141
- package/dist/channel/ChannelEmitter.js.map +1 -1
- package/dist/channel/ChannelNetwork.cjs +81 -109
- package/dist/channel/ChannelNetwork.cjs.map +1 -1
- package/dist/channel/ChannelNetwork.d.cts +28 -0
- package/dist/channel/ChannelNetwork.d.ts +25 -21
- package/dist/channel/ChannelNetwork.js +81 -109
- package/dist/channel/ChannelNetwork.js.map +1 -1
- package/dist/channel/ChannelReceiver.cjs +69 -92
- package/dist/channel/ChannelReceiver.cjs.map +1 -1
- package/dist/channel/ChannelReceiver.d.cts +20 -0
- package/dist/channel/ChannelReceiver.d.ts +18 -18
- package/dist/channel/ChannelReceiver.js +67 -90
- package/dist/channel/ChannelReceiver.js.map +1 -1
- package/dist/channel/errors.cjs +41 -46
- package/dist/channel/errors.cjs.map +1 -1
- package/dist/channel/errors.d.cts +28 -0
- package/dist/channel/errors.d.ts +22 -19
- package/dist/channel/errors.js +40 -52
- package/dist/channel/errors.js.map +1 -1
- package/dist/channel/messages.cjs +48 -43
- package/dist/channel/messages.cjs.map +1 -1
- package/dist/channel/messages.d.cts +12 -0
- package/dist/channel/messages.d.ts +12 -10
- package/dist/channel/messages.js +50 -53
- package/dist/channel/messages.js.map +1 -1
- package/dist/channel/types.cjs +15 -11
- package/dist/channel/types.cjs.map +1 -1
- package/dist/channel/types.d.cts +53 -0
- package/dist/channel/types.d.ts +42 -50
- package/dist/channel/types.js +13 -13
- package/dist/channel/types.js.map +1 -1
- package/dist/globalExtensions.d.cts +15 -0
- package/dist/globalExtensions.d.ts +15 -0
- package/dist/index.cjs +24 -33
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -7
- package/dist/index.js +5 -25
- package/dist/kit/SimulatorManager.cjs +106 -137
- package/dist/kit/SimulatorManager.cjs.map +1 -1
- package/dist/kit/SimulatorManager.d.cts +19 -0
- package/dist/kit/SimulatorManager.d.ts +16 -12
- package/dist/kit/SimulatorManager.js +103 -134
- package/dist/kit/SimulatorManager.js.map +1 -1
- package/dist/kit/State.cjs +82 -80
- package/dist/kit/State.cjs.map +1 -1
- package/dist/kit/State.d.cts +29 -0
- package/dist/kit/State.d.ts +26 -22
- package/dist/kit/State.js +80 -78
- package/dist/kit/State.js.map +1 -1
- package/dist/kit/domHelpers.cjs +25 -37
- package/dist/kit/domHelpers.cjs.map +1 -1
- package/dist/kit/domHelpers.d.cts +11 -0
- package/dist/kit/domHelpers.d.ts +10 -8
- package/dist/kit/domHelpers.js +25 -43
- package/dist/kit/domHelpers.js.map +1 -1
- package/dist/kit/eventHandlers.cjs +11 -9
- package/dist/kit/eventHandlers.cjs.map +1 -1
- package/dist/kit/eventHandlers.d.cts +8 -0
- package/dist/kit/eventHandlers.d.ts +7 -3
- package/dist/kit/eventHandlers.js +11 -11
- package/dist/kit/eventHandlers.js.map +1 -1
- package/dist/kit/getDefault.cjs +9 -7
- package/dist/kit/getDefault.cjs.map +1 -1
- package/dist/kit/getDefault.d.cts +10 -0
- package/dist/kit/getDefault.d.ts +10 -8
- package/dist/kit/getDefault.js +9 -10
- package/dist/kit/getDefault.js.map +1 -1
- package/dist/kit/messages.cjs +8 -22
- package/dist/kit/messages.cjs.map +1 -1
- package/dist/kit/messages.d.cts +5 -0
- package/dist/kit/messages.d.ts +5 -1
- package/dist/kit/messages.js +8 -23
- package/dist/kit/messages.js.map +1 -1
- package/dist/kit/types.cjs +12 -9
- package/dist/kit/types.cjs.map +1 -1
- package/dist/kit/types.d.cts +28 -0
- package/dist/kit/types.d.ts +24 -19
- package/dist/kit/types.js +11 -10
- package/dist/kit/types.js.map +1 -1
- package/dist/kit.cjs +21 -26
- package/dist/kit.d.cts +8 -0
- package/dist/kit.d.ts +8 -0
- package/dist/kit.js +7 -21
- package/dist/lib/EventEmitter.cjs +16 -25
- package/dist/lib/EventEmitter.cjs.map +1 -1
- package/dist/lib/EventEmitter.d.cts +12 -0
- package/dist/lib/EventEmitter.d.ts +11 -9
- package/dist/lib/EventEmitter.js +16 -26
- package/dist/lib/EventEmitter.js.map +1 -1
- package/dist/lib/throttle.cjs +21 -21
- package/dist/lib/throttle.cjs.map +1 -1
- package/dist/lib/throttle.js +21 -22
- package/dist/lib/throttle.js.map +1 -1
- package/dist/types.cjs +18 -14
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +39 -0
- package/dist/types.d.ts +33 -28
- package/dist/types.js +16 -16
- package/dist/types.js.map +1 -1
- package/package.json +28 -61
- package/src/SimulatorAPI.ts +24 -28
- package/src/SimulatorClient.ts +24 -31
- package/src/channel/ChannelEmitter.ts +71 -74
- package/src/channel/ChannelNetwork.ts +53 -55
- package/src/channel/ChannelReceiver.ts +46 -48
- package/src/channel/errors.ts +14 -14
- package/src/channel/index.ts +10 -10
- package/src/channel/messages.ts +39 -31
- package/src/channel/types.ts +40 -40
- package/src/globalExtensions.ts +13 -0
- package/src/index.ts +9 -7
- package/src/kit/SimulatorManager.ts +64 -63
- package/src/kit/State.ts +45 -44
- package/src/kit/domHelpers.ts +24 -24
- package/src/kit/eventHandlers.ts +6 -6
- package/src/kit/getDefault.ts +8 -8
- package/src/kit/index.ts +8 -8
- package/src/kit/messages.ts +5 -5
- package/src/kit/types.ts +13 -13
- package/src/lib/EventEmitter.ts +8 -8
- package/src/lib/__PRODUCTION__.ts +2 -2
- package/src/lib/throttle.ts +12 -12
- package/src/types.ts +20 -20
- package/dist/channel/index.d.ts +0 -10
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/kit/index.d.ts +0 -8
- package/dist/kit.cjs.map +0 -1
- package/dist/kit.js.map +0 -1
- package/dist/lib/__PRODUCTION__.d.ts +0 -7
- package/dist/lib/throttle.d.ts +0 -1
package/README.md
CHANGED
|
@@ -12,10 +12,6 @@ Replace all on all files (README.md, CONTRIBUTING.md, bug_report.md, package.jso
|
|
|
12
12
|
|
|
13
13
|
[![npm version][npm-version-src]][npm-version-href]
|
|
14
14
|
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
15
|
-
[![Github Actions CI][github-actions-ci-src]][github-actions-ci-href]
|
|
16
|
-
[![Codecov][codecov-src]][codecov-href]
|
|
17
|
-
[![Conventional Commits][conventional-commits-src]][conventional-commits-href]
|
|
18
|
-
[![License][license-src]][license-href]
|
|
19
15
|
|
|
20
16
|
Preview and develop [Prismic][prismic] slices fast with minimal configuration.
|
|
21
17
|
|
|
@@ -25,6 +21,14 @@ Preview and develop [Prismic][prismic] slices fast with minimal configuration.
|
|
|
25
21
|
|
|
26
22
|
## Install
|
|
27
23
|
|
|
24
|
+
> [!WARNING]
|
|
25
|
+
>
|
|
26
|
+
> This is probably not the package you're looking for. For dedicated framework integrations, check out:
|
|
27
|
+
>
|
|
28
|
+
> - [@prismicio/next](https://prismic.io/docs/technical-reference/prismicio-next)
|
|
29
|
+
> - [@nuxtjs/prismic](https://prismic.io/docs/technical-reference/nuxtjs-prismic)
|
|
30
|
+
> - [@prismicio/svelte](https://prismic.io/docs/technical-reference/prismicio-svelte)
|
|
31
|
+
|
|
28
32
|
```bash
|
|
29
33
|
npm install @prismicio/simulator
|
|
30
34
|
```
|
|
@@ -50,7 +54,7 @@ For more clarity on this project and its structure you can also check out the de
|
|
|
50
54
|
## License
|
|
51
55
|
|
|
52
56
|
```
|
|
53
|
-
Copyright 2013-
|
|
57
|
+
Copyright 2013-2026 Prismic <contact@prismic.io> (https://prismic.io)
|
|
54
58
|
|
|
55
59
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
56
60
|
you may not use this file except in compliance with the License.
|
|
@@ -88,11 +92,3 @@ For more clarity on this project and its structure you can also check out the de
|
|
|
88
92
|
[npm-version-href]: https://npmjs.com/package/@prismicio/simulator
|
|
89
93
|
[npm-downloads-src]: https://img.shields.io/npm/dm/@prismicio/simulator.svg
|
|
90
94
|
[npm-downloads-href]: https://npmjs.com/package/@prismicio/simulator
|
|
91
|
-
[github-actions-ci-src]: https://github.com/prismicio/slice-simulator/workflows/ci/badge.svg
|
|
92
|
-
[github-actions-ci-href]: https://github.com/prismicio/slice-simulator/actions?query=workflow%3Aci
|
|
93
|
-
[codecov-src]: https://img.shields.io/codecov/c/github/prismicio/slice-simulator.svg
|
|
94
|
-
[codecov-href]: https://codecov.io/gh/prismicio/slice-simulator
|
|
95
|
-
[conventional-commits-src]: https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196?logo=conventionalcommits&logoColor=white
|
|
96
|
-
[conventional-commits-href]: https://conventionalcommits.org
|
|
97
|
-
[license-src]: https://img.shields.io/npm/l/@prismicio/simulator.svg
|
|
98
|
-
[license-href]: https://npmjs.com/package/@prismicio/simulator
|
package/dist/SimulatorAPI.cjs
CHANGED
|
@@ -1,50 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
6
|
-
return value;
|
|
7
|
-
};
|
|
8
|
-
var _a, _b;
|
|
9
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
10
|
-
const types = require("./types.cjs");
|
|
11
|
-
require("statuses");
|
|
12
|
-
require("./channel/types.cjs");
|
|
13
|
-
const ChannelReceiver = require("./channel/ChannelReceiver.cjs");
|
|
1
|
+
const require_types = require('./types.cjs');
|
|
2
|
+
const require_ChannelReceiver = require('./channel/ChannelReceiver.cjs');
|
|
3
|
+
|
|
4
|
+
//#region src/SimulatorAPI.ts
|
|
14
5
|
const simulatorAPIDefaultOptions = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
6
|
+
requestIDPrefix: "api-",
|
|
7
|
+
activeSliceAPI: false,
|
|
8
|
+
sliceZoneSizeAPI: false
|
|
9
|
+
};
|
|
10
|
+
var SimulatorAPI = class extends require_ChannelReceiver.ChannelReceiver {
|
|
11
|
+
constructor(requestHandlers, options) {
|
|
12
|
+
const debug = (options === null || options === void 0 ? void 0 : options.debug) || /[?&]debug=true/i.test(decodeURIComponent(window.location.search));
|
|
13
|
+
super({
|
|
14
|
+
[require_types.ClientRequestType.Ping]: (_req, res) => {
|
|
15
|
+
return res.success("pong");
|
|
16
|
+
},
|
|
17
|
+
...requestHandlers
|
|
18
|
+
}, {
|
|
19
|
+
...simulatorAPIDefaultOptions,
|
|
20
|
+
...options,
|
|
21
|
+
debug
|
|
22
|
+
});
|
|
23
|
+
if (debug) {
|
|
24
|
+
var _window, _window$prismic, _window$prismic$slice;
|
|
25
|
+
(_window = window).prismic || (_window.prismic = {});
|
|
26
|
+
(_window$prismic = window.prismic).sliceSimulator || (_window$prismic.sliceSimulator = {});
|
|
27
|
+
(_window$prismic$slice = window.prismic.sliceSimulator).api || (_window$prismic$slice.api = []);
|
|
28
|
+
window.prismic.sliceSimulator.api.push(this);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
[require_types.APIRequestType.SetActiveSlice] = async (data) => {
|
|
32
|
+
return await this.postFormattedRequest(require_types.APIRequestType.SetActiveSlice, data);
|
|
33
|
+
};
|
|
34
|
+
[require_types.APIRequestType.SetSliceZoneSize] = async (data) => {
|
|
35
|
+
return await this.postFormattedRequest(require_types.APIRequestType.SetSliceZoneSize, data);
|
|
36
|
+
};
|
|
18
37
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var _a2, _b2;
|
|
22
|
-
const debug = (options == null ? void 0 : options.debug) || /[?&]debug=true/i.test(decodeURIComponent(window.location.search));
|
|
23
|
-
super({
|
|
24
|
-
[types.ClientRequestType.Ping]: (_req, res) => {
|
|
25
|
-
return res.success("pong");
|
|
26
|
-
},
|
|
27
|
-
...requestHandlers
|
|
28
|
-
}, {
|
|
29
|
-
...simulatorAPIDefaultOptions,
|
|
30
|
-
...options,
|
|
31
|
-
debug
|
|
32
|
-
});
|
|
33
|
-
__publicField(this, _a, async (data) => {
|
|
34
|
-
return await this.postFormattedRequest(types.APIRequestType.SetActiveSlice, data);
|
|
35
|
-
});
|
|
36
|
-
__publicField(this, _b, async (data) => {
|
|
37
|
-
return await this.postFormattedRequest(types.APIRequestType.SetSliceZoneSize, data);
|
|
38
|
-
});
|
|
39
|
-
if (debug) {
|
|
40
|
-
window.prismic || (window.prismic = {});
|
|
41
|
-
(_a2 = window.prismic).sliceSimulator || (_a2.sliceSimulator = {});
|
|
42
|
-
(_b2 = window.prismic.sliceSimulator).api || (_b2.api = []);
|
|
43
|
-
window.prismic.sliceSimulator.api.push(this);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
_a = types.APIRequestType.SetActiveSlice, _b = types.APIRequestType.SetSliceZoneSize;
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
48
40
|
exports.SimulatorAPI = SimulatorAPI;
|
|
49
41
|
exports.simulatorAPIDefaultOptions = simulatorAPIDefaultOptions;
|
|
50
|
-
//# sourceMappingURL=SimulatorAPI.cjs.map
|
|
42
|
+
//# sourceMappingURL=SimulatorAPI.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SimulatorAPI.cjs","sources":["
|
|
1
|
+
{"version":3,"file":"SimulatorAPI.cjs","names":["ChannelReceiver","ClientRequestType","APIRequestType"],"sources":["../src/SimulatorAPI.ts"],"sourcesContent":["import type {\n\tAPITransactions,\n\tClientTransactions} from \"./types\";\nimport {\n\tAPIRequestType,\n\tClientRequestType\n} from \"./types\"\n\nimport type {\n\tAllChannelReceiverOptions,\n\tTransactionMethod,\n\tTransactionsHandlers,\n\tTransactionsMethods} from \"./channel\";\nimport {\n\tChannelReceiver\n} from \"./channel\"\n\nexport type SimulatorAPIOptions = {\n\tactiveSliceAPI: boolean\n\tsliceZoneSizeAPI: boolean\n}\n\nexport const simulatorAPIDefaultOptions: Partial<AllChannelReceiverOptions> &\n\tSimulatorAPIOptions = {\n\trequestIDPrefix: \"api-\",\n\tactiveSliceAPI: false,\n\tsliceZoneSizeAPI: false,\n}\n\nexport class SimulatorAPI\n\textends ChannelReceiver<ClientTransactions, SimulatorAPIOptions>\n\timplements TransactionsMethods<APITransactions>\n{\n\tconstructor(\n\t\trequestHandlers: Omit<\n\t\t\tTransactionsHandlers<ClientTransactions>,\n\t\t\tClientRequestType.Ping\n\t\t> &\n\t\t\tPartial<\n\t\t\t\tPick<TransactionsHandlers<ClientTransactions>, ClientRequestType.Ping>\n\t\t\t>,\n\t\toptions?: Partial<AllChannelReceiverOptions & SimulatorAPIOptions>,\n\t) {\n\t\t// True if `options.debug` is true or `debug=true` is among query parameters\n\t\tconst debug =\n\t\t\toptions?.debug ||\n\t\t\t/[?&]debug=true/i.test(decodeURIComponent(window.location.search))\n\n\t\tsuper(\n\t\t\t{\n\t\t\t\t[ClientRequestType.Ping]: (_req, res) => {\n\t\t\t\t\treturn res.success(\"pong\")\n\t\t\t\t},\n\t\t\t\t...requestHandlers,\n\t\t\t},\n\t\t\t{\n\t\t\t\t...simulatorAPIDefaultOptions,\n\t\t\t\t...options,\n\t\t\t\tdebug,\n\t\t\t},\n\t\t)\n\n\t\t// Append API to window object\n\t\tif (debug) {\n\t\t\twindow.prismic ||= {}\n\t\t\twindow.prismic.sliceSimulator ||= {}\n\t\t\twindow.prismic.sliceSimulator.api ||= []\n\t\t\twindow.prismic.sliceSimulator.api.push(this)\n\t\t}\n\t}\n\n\t[APIRequestType.SetActiveSlice]: TransactionMethod<\n\t\tAPITransactions[APIRequestType.SetActiveSlice]\n\t> = async (data) => {\n\t\treturn await this.postFormattedRequest(APIRequestType.SetActiveSlice, data)\n\t};\n\n\t[APIRequestType.SetSliceZoneSize]: TransactionMethod<\n\t\tAPITransactions[APIRequestType.SetSliceZoneSize]\n\t> = async (data) => {\n\t\treturn await this.postFormattedRequest(\n\t\t\tAPIRequestType.SetSliceZoneSize,\n\t\t\tdata,\n\t\t)\n\t}\n}\n"],"mappings":";;;;AAsBA,MAAa,6BACU;CACtB,iBAAiB;CACjB,gBAAgB;CAChB,kBAAkB;CAClB;AAED,IAAa,eAAb,cACSA,wCAET;CACC,YACC,iBAOA,SACC;EAED,MAAM,2DACL,QAAS,UACT,kBAAkB,KAAK,mBAAmB,OAAO,SAAS,OAAO,CAAC;AAEnE,QACC;IACEC,gCAAkB,QAAQ,MAAM,QAAQ;AACxC,WAAO,IAAI,QAAQ,OAAO;;GAE3B,GAAG;GACH,EACD;GACC,GAAG;GACH,GAAG;GACH;GACA,CACD;AAGD,MAAI,OAAO;;AACV,sBAAO,8BAAY,EAAE;AACrB,6BAAO,SAAQ,oDAAmB,EAAE;AACpC,mCAAO,QAAQ,gBAAe,oCAAQ,EAAE;AACxC,UAAO,QAAQ,eAAe,IAAI,KAAK,KAAK;;;CAI9C,CAACC,6BAAe,kBAEZ,OAAO,SAAS;AACnB,SAAO,MAAM,KAAK,qBAAqBA,6BAAe,gBAAgB,KAAK;;CAG5E,CAACA,6BAAe,oBAEZ,OAAO,SAAS;AACnB,SAAO,MAAM,KAAK,qBACjBA,6BAAe,kBACf,KACA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { TransactionMethod, TransactionsHandlers, TransactionsMethods } from "./channel/types.cjs";
|
|
2
|
+
import { AllChannelReceiverOptions, ChannelReceiver } from "./channel/ChannelReceiver.cjs";
|
|
3
|
+
import { APIRequestType, APITransactions, ClientRequestType, ClientTransactions } from "./types.cjs";
|
|
4
|
+
|
|
5
|
+
//#region src/SimulatorAPI.d.ts
|
|
6
|
+
type SimulatorAPIOptions = {
|
|
7
|
+
activeSliceAPI: boolean;
|
|
8
|
+
sliceZoneSizeAPI: boolean;
|
|
9
|
+
};
|
|
10
|
+
declare const simulatorAPIDefaultOptions: Partial<AllChannelReceiverOptions> & SimulatorAPIOptions;
|
|
11
|
+
declare class SimulatorAPI extends ChannelReceiver<ClientTransactions, SimulatorAPIOptions> implements TransactionsMethods<APITransactions> {
|
|
12
|
+
constructor(requestHandlers: Omit<TransactionsHandlers<ClientTransactions>, ClientRequestType.Ping> & Partial<Pick<TransactionsHandlers<ClientTransactions>, ClientRequestType.Ping>>, options?: Partial<AllChannelReceiverOptions & SimulatorAPIOptions>);
|
|
13
|
+
[APIRequestType.SetActiveSlice]: TransactionMethod<APITransactions[APIRequestType.SetActiveSlice]>;
|
|
14
|
+
[APIRequestType.SetSliceZoneSize]: TransactionMethod<APITransactions[APIRequestType.SetSliceZoneSize]>;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { SimulatorAPI, SimulatorAPIOptions, simulatorAPIDefaultOptions };
|
|
18
|
+
//# sourceMappingURL=SimulatorAPI.d.cts.map
|
package/dist/SimulatorAPI.d.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AllChannelReceiverOptions, ChannelReceiver
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { TransactionMethod, TransactionsHandlers, TransactionsMethods } from "./channel/types.js";
|
|
2
|
+
import { AllChannelReceiverOptions, ChannelReceiver } from "./channel/ChannelReceiver.js";
|
|
3
|
+
import { APIRequestType, APITransactions, ClientRequestType, ClientTransactions } from "./types.js";
|
|
4
|
+
|
|
5
|
+
//#region src/SimulatorAPI.d.ts
|
|
6
|
+
type SimulatorAPIOptions = {
|
|
7
|
+
activeSliceAPI: boolean;
|
|
8
|
+
sliceZoneSizeAPI: boolean;
|
|
6
9
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
declare const simulatorAPIDefaultOptions: Partial<AllChannelReceiverOptions> & SimulatorAPIOptions;
|
|
11
|
+
declare class SimulatorAPI extends ChannelReceiver<ClientTransactions, SimulatorAPIOptions> implements TransactionsMethods<APITransactions> {
|
|
12
|
+
constructor(requestHandlers: Omit<TransactionsHandlers<ClientTransactions>, ClientRequestType.Ping> & Partial<Pick<TransactionsHandlers<ClientTransactions>, ClientRequestType.Ping>>, options?: Partial<AllChannelReceiverOptions & SimulatorAPIOptions>);
|
|
13
|
+
[APIRequestType.SetActiveSlice]: TransactionMethod<APITransactions[APIRequestType.SetActiveSlice]>;
|
|
14
|
+
[APIRequestType.SetSliceZoneSize]: TransactionMethod<APITransactions[APIRequestType.SetSliceZoneSize]>;
|
|
12
15
|
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { SimulatorAPI, SimulatorAPIOptions, simulatorAPIDefaultOptions };
|
|
18
|
+
//# sourceMappingURL=SimulatorAPI.d.ts.map
|
package/dist/SimulatorAPI.js
CHANGED
|
@@ -1,50 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => {
|
|
4
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
return value;
|
|
6
|
-
};
|
|
7
|
-
var _a, _b;
|
|
8
|
-
import { ClientRequestType, APIRequestType } from "./types.js";
|
|
9
|
-
import "statuses";
|
|
10
|
-
import "./channel/types.js";
|
|
1
|
+
import { APIRequestType, ClientRequestType } from "./types.js";
|
|
11
2
|
import { ChannelReceiver } from "./channel/ChannelReceiver.js";
|
|
3
|
+
|
|
4
|
+
//#region src/SimulatorAPI.ts
|
|
12
5
|
const simulatorAPIDefaultOptions = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
requestIDPrefix: "api-",
|
|
7
|
+
activeSliceAPI: false,
|
|
8
|
+
sliceZoneSizeAPI: false
|
|
16
9
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
_a = APIRequestType.SetActiveSlice, _b = APIRequestType.SetSliceZoneSize;
|
|
46
|
-
export {
|
|
47
|
-
SimulatorAPI,
|
|
48
|
-
simulatorAPIDefaultOptions
|
|
10
|
+
var SimulatorAPI = class extends ChannelReceiver {
|
|
11
|
+
constructor(requestHandlers, options) {
|
|
12
|
+
const debug = (options === null || options === void 0 ? void 0 : options.debug) || /[?&]debug=true/i.test(decodeURIComponent(window.location.search));
|
|
13
|
+
super({
|
|
14
|
+
[ClientRequestType.Ping]: (_req, res) => {
|
|
15
|
+
return res.success("pong");
|
|
16
|
+
},
|
|
17
|
+
...requestHandlers
|
|
18
|
+
}, {
|
|
19
|
+
...simulatorAPIDefaultOptions,
|
|
20
|
+
...options,
|
|
21
|
+
debug
|
|
22
|
+
});
|
|
23
|
+
if (debug) {
|
|
24
|
+
var _window, _window$prismic, _window$prismic$slice;
|
|
25
|
+
(_window = window).prismic || (_window.prismic = {});
|
|
26
|
+
(_window$prismic = window.prismic).sliceSimulator || (_window$prismic.sliceSimulator = {});
|
|
27
|
+
(_window$prismic$slice = window.prismic.sliceSimulator).api || (_window$prismic$slice.api = []);
|
|
28
|
+
window.prismic.sliceSimulator.api.push(this);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
[APIRequestType.SetActiveSlice] = async (data) => {
|
|
32
|
+
return await this.postFormattedRequest(APIRequestType.SetActiveSlice, data);
|
|
33
|
+
};
|
|
34
|
+
[APIRequestType.SetSliceZoneSize] = async (data) => {
|
|
35
|
+
return await this.postFormattedRequest(APIRequestType.SetSliceZoneSize, data);
|
|
36
|
+
};
|
|
49
37
|
};
|
|
50
|
-
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
export { SimulatorAPI, simulatorAPIDefaultOptions };
|
|
41
|
+
//# sourceMappingURL=SimulatorAPI.js.map
|
package/dist/SimulatorAPI.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SimulatorAPI.js","sources":["
|
|
1
|
+
{"version":3,"file":"SimulatorAPI.js","names":[],"sources":["../src/SimulatorAPI.ts"],"sourcesContent":["import type {\n\tAPITransactions,\n\tClientTransactions} from \"./types\";\nimport {\n\tAPIRequestType,\n\tClientRequestType\n} from \"./types\"\n\nimport type {\n\tAllChannelReceiverOptions,\n\tTransactionMethod,\n\tTransactionsHandlers,\n\tTransactionsMethods} from \"./channel\";\nimport {\n\tChannelReceiver\n} from \"./channel\"\n\nexport type SimulatorAPIOptions = {\n\tactiveSliceAPI: boolean\n\tsliceZoneSizeAPI: boolean\n}\n\nexport const simulatorAPIDefaultOptions: Partial<AllChannelReceiverOptions> &\n\tSimulatorAPIOptions = {\n\trequestIDPrefix: \"api-\",\n\tactiveSliceAPI: false,\n\tsliceZoneSizeAPI: false,\n}\n\nexport class SimulatorAPI\n\textends ChannelReceiver<ClientTransactions, SimulatorAPIOptions>\n\timplements TransactionsMethods<APITransactions>\n{\n\tconstructor(\n\t\trequestHandlers: Omit<\n\t\t\tTransactionsHandlers<ClientTransactions>,\n\t\t\tClientRequestType.Ping\n\t\t> &\n\t\t\tPartial<\n\t\t\t\tPick<TransactionsHandlers<ClientTransactions>, ClientRequestType.Ping>\n\t\t\t>,\n\t\toptions?: Partial<AllChannelReceiverOptions & SimulatorAPIOptions>,\n\t) {\n\t\t// True if `options.debug` is true or `debug=true` is among query parameters\n\t\tconst debug =\n\t\t\toptions?.debug ||\n\t\t\t/[?&]debug=true/i.test(decodeURIComponent(window.location.search))\n\n\t\tsuper(\n\t\t\t{\n\t\t\t\t[ClientRequestType.Ping]: (_req, res) => {\n\t\t\t\t\treturn res.success(\"pong\")\n\t\t\t\t},\n\t\t\t\t...requestHandlers,\n\t\t\t},\n\t\t\t{\n\t\t\t\t...simulatorAPIDefaultOptions,\n\t\t\t\t...options,\n\t\t\t\tdebug,\n\t\t\t},\n\t\t)\n\n\t\t// Append API to window object\n\t\tif (debug) {\n\t\t\twindow.prismic ||= {}\n\t\t\twindow.prismic.sliceSimulator ||= {}\n\t\t\twindow.prismic.sliceSimulator.api ||= []\n\t\t\twindow.prismic.sliceSimulator.api.push(this)\n\t\t}\n\t}\n\n\t[APIRequestType.SetActiveSlice]: TransactionMethod<\n\t\tAPITransactions[APIRequestType.SetActiveSlice]\n\t> = async (data) => {\n\t\treturn await this.postFormattedRequest(APIRequestType.SetActiveSlice, data)\n\t};\n\n\t[APIRequestType.SetSliceZoneSize]: TransactionMethod<\n\t\tAPITransactions[APIRequestType.SetSliceZoneSize]\n\t> = async (data) => {\n\t\treturn await this.postFormattedRequest(\n\t\t\tAPIRequestType.SetSliceZoneSize,\n\t\t\tdata,\n\t\t)\n\t}\n}\n"],"mappings":";;;;AAsBA,MAAa,6BACU;CACtB,iBAAiB;CACjB,gBAAgB;CAChB,kBAAkB;CAClB;AAED,IAAa,eAAb,cACS,gBAET;CACC,YACC,iBAOA,SACC;EAED,MAAM,2DACL,QAAS,UACT,kBAAkB,KAAK,mBAAmB,OAAO,SAAS,OAAO,CAAC;AAEnE,QACC;IACE,kBAAkB,QAAQ,MAAM,QAAQ;AACxC,WAAO,IAAI,QAAQ,OAAO;;GAE3B,GAAG;GACH,EACD;GACC,GAAG;GACH,GAAG;GACH;GACA,CACD;AAGD,MAAI,OAAO;;AACV,sBAAO,8BAAY,EAAE;AACrB,6BAAO,SAAQ,oDAAmB,EAAE;AACpC,mCAAO,QAAQ,gBAAe,oCAAQ,EAAE;AACxC,UAAO,QAAQ,eAAe,IAAI,KAAK,KAAK;;;CAI9C,CAAC,eAAe,kBAEZ,OAAO,SAAS;AACnB,SAAO,MAAM,KAAK,qBAAqB,eAAe,gBAAgB,KAAK;;CAG5E,CAAC,eAAe,oBAEZ,OAAO,SAAS;AACnB,SAAO,MAAM,KAAK,qBACjB,eAAe,kBACf,KACA"}
|
package/dist/SimulatorClient.cjs
CHANGED
|
@@ -1,54 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
const require_types = require('./types.cjs');
|
|
2
|
+
const require_ChannelEmitter = require('./channel/ChannelEmitter.cjs');
|
|
3
|
+
|
|
4
|
+
//#region src/SimulatorClient.ts
|
|
5
|
+
const simulatorClientDefaultOptions = { requestIDPrefix: "client-" };
|
|
6
|
+
var SimulatorClient = class extends require_ChannelEmitter.ChannelEmitter {
|
|
7
|
+
constructor(target, requestHandlers, options) {
|
|
8
|
+
const debug = (options === null || options === void 0 ? void 0 : options.debug) || /[?&]debug=true/i.test(decodeURIComponent(window.location.search));
|
|
9
|
+
super(target, {
|
|
10
|
+
[require_types.APIRequestType.SetActiveSlice]: (_req, res) => {
|
|
11
|
+
return res.success();
|
|
12
|
+
},
|
|
13
|
+
[require_types.APIRequestType.SetSliceZoneSize]: (_req, res) => {
|
|
14
|
+
return res.success();
|
|
15
|
+
},
|
|
16
|
+
...requestHandlers
|
|
17
|
+
}, {
|
|
18
|
+
...simulatorClientDefaultOptions,
|
|
19
|
+
...options,
|
|
20
|
+
debug
|
|
21
|
+
});
|
|
22
|
+
if (debug) {
|
|
23
|
+
var _window, _window$prismic, _window$prismic$slice;
|
|
24
|
+
(_window = window).prismic || (_window.prismic = {});
|
|
25
|
+
(_window$prismic = window.prismic).sliceSimulator || (_window$prismic.sliceSimulator = {});
|
|
26
|
+
(_window$prismic$slice = window.prismic.sliceSimulator).client || (_window$prismic$slice.client = []);
|
|
27
|
+
window.prismic.sliceSimulator.client.push(this);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
[require_types.ClientRequestType.Ping] = async () => {
|
|
31
|
+
return await this.postFormattedRequest(require_types.ClientRequestType.Ping);
|
|
32
|
+
};
|
|
33
|
+
[require_types.ClientRequestType.SetSliceZone] = async (data) => {
|
|
34
|
+
return await this.postFormattedRequest(require_types.ClientRequestType.SetSliceZone, data);
|
|
35
|
+
};
|
|
36
|
+
[require_types.ClientRequestType.ScrollToSlice] = async (data) => {
|
|
37
|
+
return await this.postFormattedRequest(require_types.ClientRequestType.ScrollToSlice, data);
|
|
38
|
+
};
|
|
7
39
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const types = require("./types.cjs");
|
|
11
|
-
require("statuses");
|
|
12
|
-
const ChannelEmitter = require("./channel/ChannelEmitter.cjs");
|
|
13
|
-
require("./channel/types.cjs");
|
|
14
|
-
const simulatorClientDefaultOptions = {
|
|
15
|
-
requestIDPrefix: "client-"
|
|
16
|
-
};
|
|
17
|
-
class SimulatorClient extends ChannelEmitter.ChannelEmitter {
|
|
18
|
-
constructor(target, requestHandlers, options) {
|
|
19
|
-
var _a2, _b2;
|
|
20
|
-
const debug = (options == null ? void 0 : options.debug) || /[?&]debug=true/i.test(decodeURIComponent(window.location.search));
|
|
21
|
-
super(target, {
|
|
22
|
-
[types.APIRequestType.SetActiveSlice]: (_req, res) => {
|
|
23
|
-
return res.success();
|
|
24
|
-
},
|
|
25
|
-
[types.APIRequestType.SetSliceZoneSize]: (_req, res) => {
|
|
26
|
-
return res.success();
|
|
27
|
-
},
|
|
28
|
-
...requestHandlers
|
|
29
|
-
}, {
|
|
30
|
-
...simulatorClientDefaultOptions,
|
|
31
|
-
...options,
|
|
32
|
-
debug
|
|
33
|
-
});
|
|
34
|
-
__publicField(this, _a, async () => {
|
|
35
|
-
return await this.postFormattedRequest(types.ClientRequestType.Ping);
|
|
36
|
-
});
|
|
37
|
-
__publicField(this, _b, async (data) => {
|
|
38
|
-
return await this.postFormattedRequest(types.ClientRequestType.SetSliceZone, data);
|
|
39
|
-
});
|
|
40
|
-
__publicField(this, _c, async (data) => {
|
|
41
|
-
return await this.postFormattedRequest(types.ClientRequestType.ScrollToSlice, data);
|
|
42
|
-
});
|
|
43
|
-
if (debug) {
|
|
44
|
-
window.prismic || (window.prismic = {});
|
|
45
|
-
(_a2 = window.prismic).sliceSimulator || (_a2.sliceSimulator = {});
|
|
46
|
-
(_b2 = window.prismic.sliceSimulator).client || (_b2.client = []);
|
|
47
|
-
window.prismic.sliceSimulator.client.push(this);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
_a = types.ClientRequestType.Ping, _b = types.ClientRequestType.SetSliceZone, _c = types.ClientRequestType.ScrollToSlice;
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
52
42
|
exports.SimulatorClient = SimulatorClient;
|
|
53
43
|
exports.simulatorClientDefaultOptions = simulatorClientDefaultOptions;
|
|
54
|
-
//# sourceMappingURL=SimulatorClient.cjs.map
|
|
44
|
+
//# sourceMappingURL=SimulatorClient.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SimulatorClient.cjs","sources":["
|
|
1
|
+
{"version":3,"file":"SimulatorClient.cjs","names":["ChannelEmitter","APIRequestType","ClientRequestType"],"sources":["../src/SimulatorClient.ts"],"sourcesContent":["import type {\n\tAPITransactions,\n\tClientTransactions} from \"./types\";\nimport {\n\tAPIRequestType,\n\tClientRequestType\n} from \"./types\"\n\nimport type { SimulatorAPIOptions } from \"./SimulatorAPI\"\nimport type {\n\tAllChannelEmitterOptions,\n\tTransactionMethod,\n\tTransactionsHandlers,\n\tTransactionsMethods} from \"./channel\";\nimport {\n\tChannelEmitter\n} from \"./channel\"\n\nexport const simulatorClientDefaultOptions: Partial<AllChannelEmitterOptions> =\n\t{\n\t\trequestIDPrefix: \"client-\",\n\t}\n\nexport class SimulatorClient\n\textends ChannelEmitter<\n\t\tAPITransactions,\n\t\tPartial<AllChannelEmitterOptions>,\n\t\tSimulatorAPIOptions\n\t>\n\timplements TransactionsMethods<ClientTransactions>\n{\n\tconstructor(\n\t\ttarget: HTMLIFrameElement,\n\t\trequestHandlers?: Partial<TransactionsHandlers<APITransactions>>,\n\t\toptions?: Partial<AllChannelEmitterOptions>,\n\t) {\n\t\t// True if `options.debug` is true or `debug=true` is among query parameters\n\t\tconst debug =\n\t\t\toptions?.debug ||\n\t\t\t/[?&]debug=true/i.test(decodeURIComponent(window.location.search))\n\n\t\tsuper(\n\t\t\ttarget,\n\t\t\t{\n\t\t\t\t[APIRequestType.SetActiveSlice]: (_req, res) => {\n\t\t\t\t\treturn res.success()\n\t\t\t\t},\n\t\t\t\t[APIRequestType.SetSliceZoneSize]: (_req, res) => {\n\t\t\t\t\treturn res.success()\n\t\t\t\t},\n\t\t\t\t...requestHandlers,\n\t\t\t},\n\t\t\t{\n\t\t\t\t...simulatorClientDefaultOptions,\n\t\t\t\t...options,\n\t\t\t\tdebug,\n\t\t\t},\n\t\t)\n\n\t\t// Append client to window object\n\t\tif (debug) {\n\t\t\twindow.prismic ||= {}\n\t\t\twindow.prismic.sliceSimulator ||= {}\n\t\t\twindow.prismic.sliceSimulator.client ||= []\n\t\t\twindow.prismic.sliceSimulator.client.push(this)\n\t\t}\n\t}\n\n\t[ClientRequestType.Ping]: TransactionMethod<\n\t\tClientTransactions[ClientRequestType.Ping]\n\t> = async () => {\n\t\treturn await this.postFormattedRequest(ClientRequestType.Ping)\n\t};\n\n\t[ClientRequestType.SetSliceZone]: TransactionMethod<\n\t\tClientTransactions[ClientRequestType.SetSliceZone]\n\t> = async (data) => {\n\t\treturn await this.postFormattedRequest(ClientRequestType.SetSliceZone, data)\n\t};\n\n\t[ClientRequestType.ScrollToSlice]: TransactionMethod<\n\t\tClientTransactions[ClientRequestType.ScrollToSlice]\n\t> = async (data) => {\n\t\treturn await this.postFormattedRequest(\n\t\t\tClientRequestType.ScrollToSlice,\n\t\t\tdata,\n\t\t)\n\t}\n}\n"],"mappings":";;;;AAkBA,MAAa,gCACZ,EACC,iBAAiB,WACjB;AAEF,IAAa,kBAAb,cACSA,sCAMT;CACC,YACC,QACA,iBACA,SACC;EAED,MAAM,2DACL,QAAS,UACT,kBAAkB,KAAK,mBAAmB,OAAO,SAAS,OAAO,CAAC;AAEnE,QACC,QACA;IACEC,6BAAe,kBAAkB,MAAM,QAAQ;AAC/C,WAAO,IAAI,SAAS;;IAEpBA,6BAAe,oBAAoB,MAAM,QAAQ;AACjD,WAAO,IAAI,SAAS;;GAErB,GAAG;GACH,EACD;GACC,GAAG;GACH,GAAG;GACH;GACA,CACD;AAGD,MAAI,OAAO;;AACV,sBAAO,8BAAY,EAAE;AACrB,6BAAO,SAAQ,oDAAmB,EAAE;AACpC,mCAAO,QAAQ,gBAAe,0CAAW,EAAE;AAC3C,UAAO,QAAQ,eAAe,OAAO,KAAK,KAAK;;;CAIjD,CAACC,gCAAkB,QAEf,YAAY;AACf,SAAO,MAAM,KAAK,qBAAqBA,gCAAkB,KAAK;;CAG/D,CAACA,gCAAkB,gBAEf,OAAO,SAAS;AACnB,SAAO,MAAM,KAAK,qBAAqBA,gCAAkB,cAAc,KAAK;;CAG7E,CAACA,gCAAkB,iBAEf,OAAO,SAAS;AACnB,SAAO,MAAM,KAAK,qBACjBA,gCAAkB,eAClB,KACA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TransactionMethod, TransactionsHandlers, TransactionsMethods } from "./channel/types.cjs";
|
|
2
|
+
import { AllChannelEmitterOptions, ChannelEmitter } from "./channel/ChannelEmitter.cjs";
|
|
3
|
+
import { APITransactions, ClientRequestType, ClientTransactions } from "./types.cjs";
|
|
4
|
+
import { SimulatorAPIOptions } from "./SimulatorAPI.cjs";
|
|
5
|
+
|
|
6
|
+
//#region src/SimulatorClient.d.ts
|
|
7
|
+
declare const simulatorClientDefaultOptions: Partial<AllChannelEmitterOptions>;
|
|
8
|
+
declare class SimulatorClient extends ChannelEmitter<APITransactions, Partial<AllChannelEmitterOptions>, SimulatorAPIOptions> implements TransactionsMethods<ClientTransactions> {
|
|
9
|
+
constructor(target: HTMLIFrameElement, requestHandlers?: Partial<TransactionsHandlers<APITransactions>>, options?: Partial<AllChannelEmitterOptions>);
|
|
10
|
+
[ClientRequestType.Ping]: TransactionMethod<ClientTransactions[ClientRequestType.Ping]>;
|
|
11
|
+
[ClientRequestType.SetSliceZone]: TransactionMethod<ClientTransactions[ClientRequestType.SetSliceZone]>;
|
|
12
|
+
[ClientRequestType.ScrollToSlice]: TransactionMethod<ClientTransactions[ClientRequestType.ScrollToSlice]>;
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { SimulatorClient, simulatorClientDefaultOptions };
|
|
16
|
+
//# sourceMappingURL=SimulatorClient.d.cts.map
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { TransactionMethod, TransactionsHandlers, TransactionsMethods } from "./channel/types.js";
|
|
2
|
+
import { AllChannelEmitterOptions, ChannelEmitter } from "./channel/ChannelEmitter.js";
|
|
3
|
+
import { APITransactions, ClientRequestType, ClientTransactions } from "./types.js";
|
|
4
|
+
import { SimulatorAPIOptions } from "./SimulatorAPI.js";
|
|
5
|
+
|
|
6
|
+
//#region src/SimulatorClient.d.ts
|
|
7
|
+
declare const simulatorClientDefaultOptions: Partial<AllChannelEmitterOptions>;
|
|
8
|
+
declare class SimulatorClient extends ChannelEmitter<APITransactions, Partial<AllChannelEmitterOptions>, SimulatorAPIOptions> implements TransactionsMethods<ClientTransactions> {
|
|
9
|
+
constructor(target: HTMLIFrameElement, requestHandlers?: Partial<TransactionsHandlers<APITransactions>>, options?: Partial<AllChannelEmitterOptions>);
|
|
10
|
+
[ClientRequestType.Ping]: TransactionMethod<ClientTransactions[ClientRequestType.Ping]>;
|
|
11
|
+
[ClientRequestType.SetSliceZone]: TransactionMethod<ClientTransactions[ClientRequestType.SetSliceZone]>;
|
|
12
|
+
[ClientRequestType.ScrollToSlice]: TransactionMethod<ClientTransactions[ClientRequestType.ScrollToSlice]>;
|
|
10
13
|
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { SimulatorClient, simulatorClientDefaultOptions };
|
|
16
|
+
//# sourceMappingURL=SimulatorClient.d.ts.map
|
package/dist/SimulatorClient.js
CHANGED
|
@@ -1,54 +1,43 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => {
|
|
4
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
return value;
|
|
6
|
-
};
|
|
7
|
-
var _a, _b, _c;
|
|
8
1
|
import { APIRequestType, ClientRequestType } from "./types.js";
|
|
9
|
-
import "statuses";
|
|
10
2
|
import { ChannelEmitter } from "./channel/ChannelEmitter.js";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
_a = ClientRequestType.Ping, _b = ClientRequestType.SetSliceZone, _c = ClientRequestType.ScrollToSlice;
|
|
50
|
-
export {
|
|
51
|
-
SimulatorClient,
|
|
52
|
-
simulatorClientDefaultOptions
|
|
3
|
+
|
|
4
|
+
//#region src/SimulatorClient.ts
|
|
5
|
+
const simulatorClientDefaultOptions = { requestIDPrefix: "client-" };
|
|
6
|
+
var SimulatorClient = class extends ChannelEmitter {
|
|
7
|
+
constructor(target, requestHandlers, options) {
|
|
8
|
+
const debug = (options === null || options === void 0 ? void 0 : options.debug) || /[?&]debug=true/i.test(decodeURIComponent(window.location.search));
|
|
9
|
+
super(target, {
|
|
10
|
+
[APIRequestType.SetActiveSlice]: (_req, res) => {
|
|
11
|
+
return res.success();
|
|
12
|
+
},
|
|
13
|
+
[APIRequestType.SetSliceZoneSize]: (_req, res) => {
|
|
14
|
+
return res.success();
|
|
15
|
+
},
|
|
16
|
+
...requestHandlers
|
|
17
|
+
}, {
|
|
18
|
+
...simulatorClientDefaultOptions,
|
|
19
|
+
...options,
|
|
20
|
+
debug
|
|
21
|
+
});
|
|
22
|
+
if (debug) {
|
|
23
|
+
var _window, _window$prismic, _window$prismic$slice;
|
|
24
|
+
(_window = window).prismic || (_window.prismic = {});
|
|
25
|
+
(_window$prismic = window.prismic).sliceSimulator || (_window$prismic.sliceSimulator = {});
|
|
26
|
+
(_window$prismic$slice = window.prismic.sliceSimulator).client || (_window$prismic$slice.client = []);
|
|
27
|
+
window.prismic.sliceSimulator.client.push(this);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
[ClientRequestType.Ping] = async () => {
|
|
31
|
+
return await this.postFormattedRequest(ClientRequestType.Ping);
|
|
32
|
+
};
|
|
33
|
+
[ClientRequestType.SetSliceZone] = async (data) => {
|
|
34
|
+
return await this.postFormattedRequest(ClientRequestType.SetSliceZone, data);
|
|
35
|
+
};
|
|
36
|
+
[ClientRequestType.ScrollToSlice] = async (data) => {
|
|
37
|
+
return await this.postFormattedRequest(ClientRequestType.ScrollToSlice, data);
|
|
38
|
+
};
|
|
53
39
|
};
|
|
54
|
-
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { SimulatorClient, simulatorClientDefaultOptions };
|
|
43
|
+
//# sourceMappingURL=SimulatorClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SimulatorClient.js","sources":["
|
|
1
|
+
{"version":3,"file":"SimulatorClient.js","names":[],"sources":["../src/SimulatorClient.ts"],"sourcesContent":["import type {\n\tAPITransactions,\n\tClientTransactions} from \"./types\";\nimport {\n\tAPIRequestType,\n\tClientRequestType\n} from \"./types\"\n\nimport type { SimulatorAPIOptions } from \"./SimulatorAPI\"\nimport type {\n\tAllChannelEmitterOptions,\n\tTransactionMethod,\n\tTransactionsHandlers,\n\tTransactionsMethods} from \"./channel\";\nimport {\n\tChannelEmitter\n} from \"./channel\"\n\nexport const simulatorClientDefaultOptions: Partial<AllChannelEmitterOptions> =\n\t{\n\t\trequestIDPrefix: \"client-\",\n\t}\n\nexport class SimulatorClient\n\textends ChannelEmitter<\n\t\tAPITransactions,\n\t\tPartial<AllChannelEmitterOptions>,\n\t\tSimulatorAPIOptions\n\t>\n\timplements TransactionsMethods<ClientTransactions>\n{\n\tconstructor(\n\t\ttarget: HTMLIFrameElement,\n\t\trequestHandlers?: Partial<TransactionsHandlers<APITransactions>>,\n\t\toptions?: Partial<AllChannelEmitterOptions>,\n\t) {\n\t\t// True if `options.debug` is true or `debug=true` is among query parameters\n\t\tconst debug =\n\t\t\toptions?.debug ||\n\t\t\t/[?&]debug=true/i.test(decodeURIComponent(window.location.search))\n\n\t\tsuper(\n\t\t\ttarget,\n\t\t\t{\n\t\t\t\t[APIRequestType.SetActiveSlice]: (_req, res) => {\n\t\t\t\t\treturn res.success()\n\t\t\t\t},\n\t\t\t\t[APIRequestType.SetSliceZoneSize]: (_req, res) => {\n\t\t\t\t\treturn res.success()\n\t\t\t\t},\n\t\t\t\t...requestHandlers,\n\t\t\t},\n\t\t\t{\n\t\t\t\t...simulatorClientDefaultOptions,\n\t\t\t\t...options,\n\t\t\t\tdebug,\n\t\t\t},\n\t\t)\n\n\t\t// Append client to window object\n\t\tif (debug) {\n\t\t\twindow.prismic ||= {}\n\t\t\twindow.prismic.sliceSimulator ||= {}\n\t\t\twindow.prismic.sliceSimulator.client ||= []\n\t\t\twindow.prismic.sliceSimulator.client.push(this)\n\t\t}\n\t}\n\n\t[ClientRequestType.Ping]: TransactionMethod<\n\t\tClientTransactions[ClientRequestType.Ping]\n\t> = async () => {\n\t\treturn await this.postFormattedRequest(ClientRequestType.Ping)\n\t};\n\n\t[ClientRequestType.SetSliceZone]: TransactionMethod<\n\t\tClientTransactions[ClientRequestType.SetSliceZone]\n\t> = async (data) => {\n\t\treturn await this.postFormattedRequest(ClientRequestType.SetSliceZone, data)\n\t};\n\n\t[ClientRequestType.ScrollToSlice]: TransactionMethod<\n\t\tClientTransactions[ClientRequestType.ScrollToSlice]\n\t> = async (data) => {\n\t\treturn await this.postFormattedRequest(\n\t\t\tClientRequestType.ScrollToSlice,\n\t\t\tdata,\n\t\t)\n\t}\n}\n"],"mappings":";;;;AAkBA,MAAa,gCACZ,EACC,iBAAiB,WACjB;AAEF,IAAa,kBAAb,cACS,eAMT;CACC,YACC,QACA,iBACA,SACC;EAED,MAAM,2DACL,QAAS,UACT,kBAAkB,KAAK,mBAAmB,OAAO,SAAS,OAAO,CAAC;AAEnE,QACC,QACA;IACE,eAAe,kBAAkB,MAAM,QAAQ;AAC/C,WAAO,IAAI,SAAS;;IAEpB,eAAe,oBAAoB,MAAM,QAAQ;AACjD,WAAO,IAAI,SAAS;;GAErB,GAAG;GACH,EACD;GACC,GAAG;GACH,GAAG;GACH;GACA,CACD;AAGD,MAAI,OAAO;;AACV,sBAAO,8BAAY,EAAE;AACrB,6BAAO,SAAQ,oDAAmB,EAAE;AACpC,mCAAO,QAAQ,gBAAe,0CAAW,EAAE;AAC3C,UAAO,QAAQ,eAAe,OAAO,KAAK,KAAK;;;CAIjD,CAAC,kBAAkB,QAEf,YAAY;AACf,SAAO,MAAM,KAAK,qBAAqB,kBAAkB,KAAK;;CAG/D,CAAC,kBAAkB,gBAEf,OAAO,SAAS;AACnB,SAAO,MAAM,KAAK,qBAAqB,kBAAkB,cAAc,KAAK;;CAG7E,CAAC,kBAAkB,iBAEf,OAAO,SAAS;AACnB,SAAO,MAAM,KAAK,qBACjB,kBAAkB,eAClB,KACA"}
|