@prismicio/simulator 0.2.3 → 0.2.4-canary.3d405bc
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/dist/SimulatorAPI.cjs +6 -6
- package/dist/SimulatorAPI.cjs.map +1 -1
- package/dist/SimulatorAPI.d.cts +3 -5
- package/dist/SimulatorAPI.d.cts.map +1 -1
- package/dist/SimulatorAPI.d.ts +3 -5
- package/dist/SimulatorAPI.d.ts.map +1 -1
- package/dist/SimulatorAPI.js +6 -6
- package/dist/SimulatorAPI.js.map +1 -1
- package/dist/SimulatorClient.cjs +9 -9
- package/dist/SimulatorClient.cjs.map +1 -1
- package/dist/SimulatorClient.d.cts +2 -4
- package/dist/SimulatorClient.d.cts.map +1 -1
- package/dist/SimulatorClient.d.ts +2 -4
- package/dist/SimulatorClient.d.ts.map +1 -1
- package/dist/SimulatorClient.js +9 -9
- package/dist/SimulatorClient.js.map +1 -1
- package/dist/channel/ChannelEmitter.cjs +6 -8
- package/dist/channel/ChannelEmitter.cjs.map +1 -1
- package/dist/channel/ChannelEmitter.d.cts +3 -5
- package/dist/channel/ChannelEmitter.d.cts.map +1 -1
- package/dist/channel/ChannelEmitter.d.ts +3 -5
- package/dist/channel/ChannelEmitter.d.ts.map +1 -1
- package/dist/channel/ChannelEmitter.js +6 -9
- package/dist/channel/ChannelEmitter.js.map +1 -1
- package/dist/channel/ChannelNetwork.cjs +13 -11
- package/dist/channel/ChannelNetwork.cjs.map +1 -1
- package/dist/channel/ChannelNetwork.d.cts +3 -5
- package/dist/channel/ChannelNetwork.d.cts.map +1 -1
- package/dist/channel/ChannelNetwork.d.ts +3 -5
- package/dist/channel/ChannelNetwork.d.ts.map +1 -1
- package/dist/channel/ChannelNetwork.js +13 -12
- package/dist/channel/ChannelNetwork.js.map +1 -1
- package/dist/channel/ChannelReceiver.cjs +6 -8
- package/dist/channel/ChannelReceiver.cjs.map +1 -1
- package/dist/channel/ChannelReceiver.d.cts +3 -5
- package/dist/channel/ChannelReceiver.d.cts.map +1 -1
- package/dist/channel/ChannelReceiver.d.ts +3 -5
- package/dist/channel/ChannelReceiver.d.ts.map +1 -1
- package/dist/channel/ChannelReceiver.js +6 -9
- package/dist/channel/ChannelReceiver.js.map +1 -1
- package/dist/channel/errors.cjs.map +1 -1
- package/dist/channel/errors.d.cts +7 -9
- package/dist/channel/errors.d.cts.map +1 -1
- package/dist/channel/errors.d.ts +7 -9
- package/dist/channel/errors.d.ts.map +1 -1
- package/dist/channel/errors.js.map +1 -1
- package/dist/channel/messages.cjs.map +1 -1
- package/dist/channel/messages.d.cts +5 -7
- package/dist/channel/messages.d.cts.map +1 -1
- package/dist/channel/messages.d.ts +5 -7
- package/dist/channel/messages.d.ts.map +1 -1
- package/dist/channel/messages.js.map +1 -1
- package/dist/channel/types.d.cts +21 -22
- package/dist/channel/types.d.cts.map +1 -1
- package/dist/channel/types.d.ts +21 -22
- package/dist/channel/types.d.ts.map +1 -1
- package/dist/globalExtensions.d.cts +2 -2
- package/dist/globalExtensions.d.cts.map +1 -1
- package/dist/globalExtensions.d.ts +1 -2
- package/dist/globalExtensions.d.ts.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/kit/SimulatorManager.cjs +7 -6
- package/dist/kit/SimulatorManager.cjs.map +1 -1
- package/dist/kit/SimulatorManager.d.cts +1 -3
- package/dist/kit/SimulatorManager.d.cts.map +1 -1
- package/dist/kit/SimulatorManager.d.ts +1 -3
- package/dist/kit/SimulatorManager.d.ts.map +1 -1
- package/dist/kit/SimulatorManager.js +7 -6
- package/dist/kit/SimulatorManager.js.map +1 -1
- package/dist/kit/State.cjs +4 -4
- package/dist/kit/State.cjs.map +1 -1
- package/dist/kit/State.d.cts +1 -3
- package/dist/kit/State.d.cts.map +1 -1
- package/dist/kit/State.d.ts +1 -3
- package/dist/kit/State.d.ts.map +1 -1
- package/dist/kit/State.js +4 -4
- package/dist/kit/State.js.map +1 -1
- package/dist/kit/domHelpers.cjs.map +1 -1
- package/dist/kit/domHelpers.d.cts +4 -5
- package/dist/kit/domHelpers.d.cts.map +1 -1
- package/dist/kit/domHelpers.d.ts +4 -5
- package/dist/kit/domHelpers.d.ts.map +1 -1
- package/dist/kit/domHelpers.js.map +1 -1
- package/dist/kit/eventHandlers.cjs.map +1 -1
- package/dist/kit/eventHandlers.d.cts +2 -3
- package/dist/kit/eventHandlers.d.cts.map +1 -1
- package/dist/kit/eventHandlers.d.ts +2 -3
- package/dist/kit/eventHandlers.d.ts.map +1 -1
- package/dist/kit/eventHandlers.js.map +1 -1
- package/dist/kit/getDefault.cjs.map +1 -1
- package/dist/kit/getDefault.d.cts +3 -5
- package/dist/kit/getDefault.d.cts.map +1 -1
- package/dist/kit/getDefault.d.ts +3 -5
- package/dist/kit/getDefault.d.ts.map +1 -1
- package/dist/kit/getDefault.js.map +1 -1
- package/dist/kit/messages.cjs.map +1 -1
- package/dist/kit/messages.d.cts +1 -2
- package/dist/kit/messages.d.cts.map +1 -1
- package/dist/kit/messages.d.ts +1 -2
- package/dist/kit/messages.d.ts.map +1 -1
- package/dist/kit/messages.js.map +1 -1
- package/dist/kit/types.cjs.map +1 -1
- package/dist/kit/types.d.cts +5 -7
- package/dist/kit/types.d.cts.map +1 -1
- package/dist/kit/types.d.ts +5 -7
- package/dist/kit/types.d.ts.map +1 -1
- package/dist/kit/types.js.map +1 -1
- package/dist/lib/EventEmitter.cjs.map +1 -1
- package/dist/lib/EventEmitter.d.cts +3 -4
- package/dist/lib/EventEmitter.d.cts.map +1 -1
- package/dist/lib/EventEmitter.d.ts +3 -4
- package/dist/lib/EventEmitter.d.ts.map +1 -1
- package/dist/lib/EventEmitter.js.map +1 -1
- package/dist/lib/throttle.cjs.map +1 -1
- package/dist/lib/throttle.js.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.js +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +6 -8
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.ts +6 -8
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +11 -11
- package/src/kit/SimulatorManager.ts +1 -0
- package/dist/channel/types.cjs +0 -14
- package/dist/channel/types.cjs.map +0 -1
- package/dist/channel/types.js +0 -13
- package/dist/channel/types.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ResponseError } from "../channel/errors.js";
|
|
2
|
-
import
|
|
2
|
+
import "../types.js";
|
|
3
3
|
import { SimulatorAPI } from "../SimulatorAPI.js";
|
|
4
4
|
import { throttle } from "../lib/throttle.js";
|
|
5
5
|
import { getSimulatorDOM, getSimulatorRootDOM, getSliceZoneDOM } from "./domHelpers.js";
|
|
6
6
|
import { sliceSimulatorAccessedDirectly } from "./messages.js";
|
|
7
|
-
import
|
|
7
|
+
import "./types.js";
|
|
8
8
|
import { State } from "./State.js";
|
|
9
9
|
//#region src/kit/SimulatorManager.ts
|
|
10
10
|
var SimulatorManager = class {
|
|
@@ -34,11 +34,11 @@ var SimulatorManager = class {
|
|
|
34
34
|
}
|
|
35
35
|
async _initAPI() {
|
|
36
36
|
this._api = new SimulatorAPI({
|
|
37
|
-
[
|
|
37
|
+
["setSliceZone"]: (req, res) => {
|
|
38
38
|
this.state.setSliceZone(req.data);
|
|
39
39
|
return res.success();
|
|
40
40
|
},
|
|
41
|
-
[
|
|
41
|
+
["scrollToSlice"]: (req, res) => {
|
|
42
42
|
if (req.data.sliceIndex < 0) return res.error("`sliceIndex` must be > 0", 400);
|
|
43
43
|
else if (req.data.sliceIndex >= this.state.slices.length) return res.error(`\`sliceIndex\` must be < ${this.state.slices.length} (\`<SliceZone />\` current length)`, 400);
|
|
44
44
|
const $sliceZone = getSliceZoneDOM(this.state.slices.length);
|
|
@@ -68,10 +68,10 @@ var SimulatorManager = class {
|
|
|
68
68
|
window.addEventListener("mousewheel", () => {
|
|
69
69
|
setTimeout(this.state.setActiveSlice, 200);
|
|
70
70
|
});
|
|
71
|
-
this.state.on(
|
|
71
|
+
this.state.on("slices", () => {
|
|
72
72
|
this.state.setActiveSlice();
|
|
73
73
|
});
|
|
74
|
-
this.state.on(
|
|
74
|
+
this.state.on("activeSlice", async (activeSlice) => {
|
|
75
75
|
if (this._api) try {
|
|
76
76
|
await this._api.setActiveSlice(activeSlice);
|
|
77
77
|
} catch (error) {
|
|
@@ -99,6 +99,7 @@ var SimulatorManager = class {
|
|
|
99
99
|
subtree: false,
|
|
100
100
|
childList: true
|
|
101
101
|
});
|
|
102
|
+
observeSimulatorRoot();
|
|
102
103
|
}
|
|
103
104
|
}
|
|
104
105
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SimulatorManager.js","names":[],"sources":["../../src/kit/SimulatorManager.ts"],"sourcesContent":["import type { SliceZone } from \"@prismicio/client\"\n\nimport { ResponseError } from \"../channel\"\nimport { throttle } from \"../lib/throttle\"\nimport { SimulatorAPI } from \"../SimulatorAPI\"\nimport { ClientRequestType } from \"../types\"\nimport { getSimulatorDOM, getSimulatorRootDOM, getSliceZoneDOM } from \"./domHelpers\"\nimport { sliceSimulatorAccessedDirectly } from \"./messages\"\nimport { State } from \"./State\"\nimport { StateEventType } from \"./types\"\n\ntype ManagerConstructorArgs = {\n\tslices?: SliceZone\n}\n\nexport class SimulatorManager {\n\tpublic state: State\n\tprivate _api: SimulatorAPI | null\n\tprivate _initialized: boolean\n\n\tconstructor(args?: ManagerConstructorArgs) {\n\t\tthis.state = new State(args)\n\t\tthis._api = null\n\t\tthis._initialized = false\n\t}\n\n\tasync init(): Promise<void> {\n\t\tif (this._initialized) {\n\t\t\treturn\n\t\t} else {\n\t\t\tthis._initialized = true\n\t\t}\n\n\t\t// Init state manager\n\t\tawait this.state.init()\n\n\t\t// Do not init the API is the simulator is accessed directly\n\t\tif (window.parent === window) {\n\t\t\tthis.state.message = sliceSimulatorAccessedDirectly\n\t\t\treturn\n\t\t}\n\n\t\t// Init API\n\t\ttry {\n\t\t\tawait this._initAPI()\n\t\t} catch (error) {\n\t\t\tconsole.error(error)\n\n\t\t\treturn\n\t\t}\n\n\t\t// Init listeners\n\t\tthis._initListeners()\n\t}\n\n\tprivate async _initAPI(): Promise<void> {\n\t\t// Register SimulatorAPI request handlers\n\t\tthis._api = new SimulatorAPI({\n\t\t\t[ClientRequestType.SetSliceZone]: (req, res) => {\n\t\t\t\tthis.state.setSliceZone(req.data)\n\n\t\t\t\treturn res.success()\n\t\t\t},\n\t\t\t[ClientRequestType.ScrollToSlice]: (req, res) => {\n\t\t\t\t// Error if `sliceIndex` is invalid\n\t\t\t\tif (req.data.sliceIndex < 0) {\n\t\t\t\t\treturn res.error(\"`sliceIndex` must be > 0\", 400)\n\t\t\t\t} else if (req.data.sliceIndex >= this.state.slices.length) {\n\t\t\t\t\treturn res.error(\n\t\t\t\t\t\t`\\`sliceIndex\\` must be < ${this.state.slices.length} (\\`<SliceZone />\\` current length)`,\n\t\t\t\t\t\t400,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tconst $sliceZone = getSliceZoneDOM(this.state.slices.length)\n\t\t\t\tif (!$sliceZone) {\n\t\t\t\t\treturn res.error(\"Failed to find `<SliceZone />`\", 500)\n\t\t\t\t}\n\n\t\t\t\t// Destroy existing active slice as we're about to scroll\n\t\t\t\tthis.state.activeSlice = null\n\n\t\t\t\tconst $slice = $sliceZone.children[req.data.sliceIndex]\n\t\t\t\tif (!$slice) {\n\t\t\t\t\treturn res.error(\n\t\t\t\t\t\t`Failed fo find slice at index $\\`{req.data.sliceIndex}\\` in \\`<SliceZone />\\``,\n\t\t\t\t\t\t500,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\t// Scroll to Slice\n\t\t\t\t$slice.scrollIntoView({\n\t\t\t\t\tbehavior: req.data.behavior,\n\t\t\t\t\tblock: req.data.block,\n\t\t\t\t\tinline: req.data.inline,\n\t\t\t\t})\n\n\t\t\t\t// Update active slice after scrolling\n\t\t\t\tif (this._api?.options.activeSliceAPI) {\n\t\t\t\t\tsetTimeout(this.state.setActiveSlice, 750)\n\t\t\t\t}\n\n\t\t\t\treturn res.success()\n\t\t\t},\n\t\t})\n\n\t\t// Mark API as ready\n\t\tawait this._api.ready()\n\t}\n\n\tprivate _initListeners(): void {\n\t\tif (this._api?.options.activeSliceAPI) {\n\t\t\t// Update active slice on mouse move\n\t\t\twindow.addEventListener(\"mousemove\", () => {\n\t\t\t\tthis.state.setActiveSlice()\n\t\t\t})\n\t\t\t// Update active slice on events impacting slices rendering\n\t\t\twindow.addEventListener(\"resize\", () => {\n\t\t\t\tthis.state.setActiveSlice()\n\t\t\t})\n\t\t\twindow.addEventListener(\"mousewheel\", () => {\n\t\t\t\tsetTimeout(this.state.setActiveSlice, 200)\n\t\t\t})\n\n\t\t\t// Update active slice when slices are set\n\t\t\tthis.state.on(StateEventType.Slices, () => {\n\t\t\t\tthis.state.setActiveSlice()\n\t\t\t})\n\t\t\t// Send active slices to renderer\n\t\t\tthis.state.on(StateEventType.ActiveSlice, async (activeSlice) => {\n\t\t\t\tif (this._api) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this._api.setActiveSlice(activeSlice)\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t// Just log bad requests, throw everything else\n\t\t\t\t\t\tif (error instanceof ResponseError && error.response.status === 400) {\n\t\t\t\t\t\t\tconsole.error(error.response)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthrow error\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\n\t\tif (this._api?.options.sliceZoneSizeAPI) {\n\t\t\t// Monitor Simulator root node size\n\t\t\tconst resizeObserver = new ResizeObserver(\n\t\t\t\tthrottle(async (entries) => {\n\t\t\t\t\tconst [entry] = entries\n\n\t\t\t\t\tif (this._api && entry) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tawait this._api.setSliceZoneSize({ rect: entry.contentRect })\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t// Just log bad requests, throw everything else\n\t\t\t\t\t\t\tif (error instanceof ResponseError && error.response.status === 400) {\n\t\t\t\t\t\t\t\tconsole.error(error.response)\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthrow error\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}, 16),\n\t\t\t)\n\t\t\tconst observeSimulatorRoot = () => {\n\t\t\t\tconst simulatorRootDOM = getSimulatorRootDOM()\n\t\t\t\tresizeObserver.disconnect()\n\t\t\t\tif (simulatorRootDOM) {\n\t\t\t\t\tresizeObserver.observe(simulatorRootDOM)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Monitor Simulator root node in DOM\n\t\t\tconst mutationObserver = new MutationObserver(observeSimulatorRoot)\n\t\t\t// We want it to fail if not found\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tmutationObserver.observe(getSimulatorDOM()!, {\n\t\t\t\tsubtree: false,\n\t\t\t\tchildList: true,\n\t\t\t})\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;AAeA,IAAa,mBAAb,MAA8B;CAC7B;CACA;CACA;CAEA,YAAY,MAA+B;
|
|
1
|
+
{"version":3,"file":"SimulatorManager.js","names":[],"sources":["../../src/kit/SimulatorManager.ts"],"sourcesContent":["import type { SliceZone } from \"@prismicio/client\"\n\nimport { ResponseError } from \"../channel\"\nimport { throttle } from \"../lib/throttle\"\nimport { SimulatorAPI } from \"../SimulatorAPI\"\nimport { ClientRequestType } from \"../types\"\nimport { getSimulatorDOM, getSimulatorRootDOM, getSliceZoneDOM } from \"./domHelpers\"\nimport { sliceSimulatorAccessedDirectly } from \"./messages\"\nimport { State } from \"./State\"\nimport { StateEventType } from \"./types\"\n\ntype ManagerConstructorArgs = {\n\tslices?: SliceZone\n}\n\nexport class SimulatorManager {\n\tpublic state: State\n\tprivate _api: SimulatorAPI | null\n\tprivate _initialized: boolean\n\n\tconstructor(args?: ManagerConstructorArgs) {\n\t\tthis.state = new State(args)\n\t\tthis._api = null\n\t\tthis._initialized = false\n\t}\n\n\tasync init(): Promise<void> {\n\t\tif (this._initialized) {\n\t\t\treturn\n\t\t} else {\n\t\t\tthis._initialized = true\n\t\t}\n\n\t\t// Init state manager\n\t\tawait this.state.init()\n\n\t\t// Do not init the API is the simulator is accessed directly\n\t\tif (window.parent === window) {\n\t\t\tthis.state.message = sliceSimulatorAccessedDirectly\n\t\t\treturn\n\t\t}\n\n\t\t// Init API\n\t\ttry {\n\t\t\tawait this._initAPI()\n\t\t} catch (error) {\n\t\t\tconsole.error(error)\n\n\t\t\treturn\n\t\t}\n\n\t\t// Init listeners\n\t\tthis._initListeners()\n\t}\n\n\tprivate async _initAPI(): Promise<void> {\n\t\t// Register SimulatorAPI request handlers\n\t\tthis._api = new SimulatorAPI({\n\t\t\t[ClientRequestType.SetSliceZone]: (req, res) => {\n\t\t\t\tthis.state.setSliceZone(req.data)\n\n\t\t\t\treturn res.success()\n\t\t\t},\n\t\t\t[ClientRequestType.ScrollToSlice]: (req, res) => {\n\t\t\t\t// Error if `sliceIndex` is invalid\n\t\t\t\tif (req.data.sliceIndex < 0) {\n\t\t\t\t\treturn res.error(\"`sliceIndex` must be > 0\", 400)\n\t\t\t\t} else if (req.data.sliceIndex >= this.state.slices.length) {\n\t\t\t\t\treturn res.error(\n\t\t\t\t\t\t`\\`sliceIndex\\` must be < ${this.state.slices.length} (\\`<SliceZone />\\` current length)`,\n\t\t\t\t\t\t400,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tconst $sliceZone = getSliceZoneDOM(this.state.slices.length)\n\t\t\t\tif (!$sliceZone) {\n\t\t\t\t\treturn res.error(\"Failed to find `<SliceZone />`\", 500)\n\t\t\t\t}\n\n\t\t\t\t// Destroy existing active slice as we're about to scroll\n\t\t\t\tthis.state.activeSlice = null\n\n\t\t\t\tconst $slice = $sliceZone.children[req.data.sliceIndex]\n\t\t\t\tif (!$slice) {\n\t\t\t\t\treturn res.error(\n\t\t\t\t\t\t`Failed fo find slice at index $\\`{req.data.sliceIndex}\\` in \\`<SliceZone />\\``,\n\t\t\t\t\t\t500,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\t// Scroll to Slice\n\t\t\t\t$slice.scrollIntoView({\n\t\t\t\t\tbehavior: req.data.behavior,\n\t\t\t\t\tblock: req.data.block,\n\t\t\t\t\tinline: req.data.inline,\n\t\t\t\t})\n\n\t\t\t\t// Update active slice after scrolling\n\t\t\t\tif (this._api?.options.activeSliceAPI) {\n\t\t\t\t\tsetTimeout(this.state.setActiveSlice, 750)\n\t\t\t\t}\n\n\t\t\t\treturn res.success()\n\t\t\t},\n\t\t})\n\n\t\t// Mark API as ready\n\t\tawait this._api.ready()\n\t}\n\n\tprivate _initListeners(): void {\n\t\tif (this._api?.options.activeSliceAPI) {\n\t\t\t// Update active slice on mouse move\n\t\t\twindow.addEventListener(\"mousemove\", () => {\n\t\t\t\tthis.state.setActiveSlice()\n\t\t\t})\n\t\t\t// Update active slice on events impacting slices rendering\n\t\t\twindow.addEventListener(\"resize\", () => {\n\t\t\t\tthis.state.setActiveSlice()\n\t\t\t})\n\t\t\twindow.addEventListener(\"mousewheel\", () => {\n\t\t\t\tsetTimeout(this.state.setActiveSlice, 200)\n\t\t\t})\n\n\t\t\t// Update active slice when slices are set\n\t\t\tthis.state.on(StateEventType.Slices, () => {\n\t\t\t\tthis.state.setActiveSlice()\n\t\t\t})\n\t\t\t// Send active slices to renderer\n\t\t\tthis.state.on(StateEventType.ActiveSlice, async (activeSlice) => {\n\t\t\t\tif (this._api) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this._api.setActiveSlice(activeSlice)\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t// Just log bad requests, throw everything else\n\t\t\t\t\t\tif (error instanceof ResponseError && error.response.status === 400) {\n\t\t\t\t\t\t\tconsole.error(error.response)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthrow error\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\n\t\tif (this._api?.options.sliceZoneSizeAPI) {\n\t\t\t// Monitor Simulator root node size\n\t\t\tconst resizeObserver = new ResizeObserver(\n\t\t\t\tthrottle(async (entries) => {\n\t\t\t\t\tconst [entry] = entries\n\n\t\t\t\t\tif (this._api && entry) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tawait this._api.setSliceZoneSize({ rect: entry.contentRect })\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t// Just log bad requests, throw everything else\n\t\t\t\t\t\t\tif (error instanceof ResponseError && error.response.status === 400) {\n\t\t\t\t\t\t\t\tconsole.error(error.response)\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthrow error\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}, 16),\n\t\t\t)\n\t\t\tconst observeSimulatorRoot = () => {\n\t\t\t\tconst simulatorRootDOM = getSimulatorRootDOM()\n\t\t\t\tresizeObserver.disconnect()\n\t\t\t\tif (simulatorRootDOM) {\n\t\t\t\t\tresizeObserver.observe(simulatorRootDOM)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Monitor Simulator root node in DOM\n\t\t\tconst mutationObserver = new MutationObserver(observeSimulatorRoot)\n\t\t\t// We want it to fail if not found\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tmutationObserver.observe(getSimulatorDOM()!, {\n\t\t\t\tsubtree: false,\n\t\t\t\tchildList: true,\n\t\t\t})\n\t\t\tobserveSimulatorRoot()\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;AAeA,IAAa,mBAAb,MAA8B;CAC7B;CACA;CACA;CAEA,YAAY,MAA+B;EAC1C,KAAK,QAAQ,IAAI,MAAM,IAAI;EAC3B,KAAK,OAAO;EACZ,KAAK,eAAe;CACrB;CAEA,MAAM,OAAsB;EAC3B,IAAI,KAAK,cACR;OAEA,KAAK,eAAe;EAIrB,MAAM,KAAK,MAAM,KAAK;EAGtB,IAAI,OAAO,WAAW,QAAQ;GAC7B,KAAK,MAAM,UAAU;GACrB;EACD;EAGA,IAAI;GACH,MAAM,KAAK,SAAS;EACrB,SAAS,OAAO;GACf,QAAQ,MAAM,KAAK;GAEnB;EACD;EAGA,KAAK,eAAe;CACrB;CAEA,MAAc,WAA0B;EAEvC,KAAK,OAAO,IAAI,aAAa;IACO,kBAAA,KAAK,QAAQ;IAC/C,KAAK,MAAM,aAAa,IAAI,IAAI;IAEhC,OAAO,IAAI,QAAQ;GACpB;IACoC,mBAAA,KAAK,QAAQ;IAEhD,IAAI,IAAI,KAAK,aAAa,GACzB,OAAO,IAAI,MAAM,4BAA4B,GAAG;SAC1C,IAAI,IAAI,KAAK,cAAc,KAAK,MAAM,OAAO,QACnD,OAAO,IAAI,MACV,4BAA4B,KAAK,MAAM,OAAO,OAAO,sCACrD,GACD;IAGD,MAAM,aAAa,gBAAgB,KAAK,MAAM,OAAO,MAAM;IAC3D,IAAI,CAAC,YACJ,OAAO,IAAI,MAAM,kCAAkC,GAAG;IAIvD,KAAK,MAAM,cAAc;IAEzB,MAAM,SAAS,WAAW,SAAS,IAAI,KAAK;IAC5C,IAAI,CAAC,QACJ,OAAO,IAAI,MACV,iFACA,GACD;IAID,OAAO,eAAe;KACrB,UAAU,IAAI,KAAK;KACnB,OAAO,IAAI,KAAK;KAChB,QAAQ,IAAI,KAAK;IAClB,CAAC;IAGD,IAAI,KAAK,MAAM,QAAQ,gBACtB,WAAW,KAAK,MAAM,gBAAgB,GAAG;IAG1C,OAAO,IAAI,QAAQ;GACpB;EACD,CAAC;EAGD,MAAM,KAAK,KAAK,MAAM;CACvB;CAEA,iBAA+B;EAC9B,IAAI,KAAK,MAAM,QAAQ,gBAAgB;GAEtC,OAAO,iBAAiB,mBAAmB;IAC1C,KAAK,MAAM,eAAe;GAC3B,CAAC;GAED,OAAO,iBAAiB,gBAAgB;IACvC,KAAK,MAAM,eAAe;GAC3B,CAAC;GACD,OAAO,iBAAiB,oBAAoB;IAC3C,WAAW,KAAK,MAAM,gBAAgB,GAAG;GAC1C,CAAC;GAGD,KAAK,MAAM,GAAA,gBAAgC;IAC1C,KAAK,MAAM,eAAe;GAC3B,CAAC;GAED,KAAK,MAAM,GAAA,eAA+B,OAAO,gBAAgB;IAChE,IAAI,KAAK,MACR,IAAI;KACH,MAAM,KAAK,KAAK,eAAe,WAAW;IAC3C,SAAS,OAAO;KAEf,IAAI,iBAAiB,iBAAiB,MAAM,SAAS,WAAW,KAC/D,QAAQ,MAAM,MAAM,QAAQ;UAE5B,MAAM;IAER;GAEF,CAAC;EACF;EAEA,IAAI,KAAK,MAAM,QAAQ,kBAAkB;GAExC,MAAM,iBAAiB,IAAI,eAC1B,SAAS,OAAO,YAAY;IAC3B,MAAM,CAAC,SAAS;IAEhB,IAAI,KAAK,QAAQ,OAChB,IAAI;KACH,MAAM,KAAK,KAAK,iBAAiB,EAAE,MAAM,MAAM,YAAY,CAAC;IAC7D,SAAS,OAAO;KAEf,IAAI,iBAAiB,iBAAiB,MAAM,SAAS,WAAW,KAC/D,QAAQ,MAAM,MAAM,QAAQ;UAE5B,MAAM;IAER;GAEF,GAAG,EAAE,CACN;GACA,MAAM,6BAA6B;IAClC,MAAM,mBAAmB,oBAAoB;IAC7C,eAAe,WAAW;IAC1B,IAAI,kBACH,eAAe,QAAQ,gBAAgB;GAEzC;GAMA,IAH6B,iBAAiB,oBAG/B,CAAC,CAAC,QAAQ,gBAAgB,GAAI;IAC5C,SAAS;IACT,WAAW;GACZ,CAAC;GACD,qBAAqB;EACtB;CACD;AACD"}
|
package/dist/kit/State.cjs
CHANGED
|
@@ -2,14 +2,14 @@ const require_throttle = require("../lib/throttle.cjs");
|
|
|
2
2
|
const require_domHelpers = require("./domHelpers.cjs");
|
|
3
3
|
const require_EventEmitter = require("../lib/EventEmitter.cjs");
|
|
4
4
|
const require_getDefault = require("./getDefault.cjs");
|
|
5
|
-
|
|
5
|
+
require("./types.cjs");
|
|
6
6
|
//#region src/kit/State.ts
|
|
7
7
|
var State = class extends require_EventEmitter.EventEmitter {
|
|
8
8
|
_slices;
|
|
9
9
|
set slices(slices) {
|
|
10
10
|
this._slices = slices;
|
|
11
11
|
this.message = "";
|
|
12
|
-
this.emit(
|
|
12
|
+
this.emit("slices", this.slices);
|
|
13
13
|
}
|
|
14
14
|
get slices() {
|
|
15
15
|
return window.parent !== window ? this._slices : [];
|
|
@@ -17,7 +17,7 @@ var State = class extends require_EventEmitter.EventEmitter {
|
|
|
17
17
|
_activeSlice;
|
|
18
18
|
set activeSlice(activeSlice) {
|
|
19
19
|
this._activeSlice = activeSlice;
|
|
20
|
-
this.emit(
|
|
20
|
+
this.emit("activeSlice", this.activeSlice);
|
|
21
21
|
}
|
|
22
22
|
get activeSlice() {
|
|
23
23
|
return this._activeSlice;
|
|
@@ -25,7 +25,7 @@ var State = class extends require_EventEmitter.EventEmitter {
|
|
|
25
25
|
_message;
|
|
26
26
|
set message(message) {
|
|
27
27
|
this._message = message;
|
|
28
|
-
this.emit(
|
|
28
|
+
this.emit("message", this.message);
|
|
29
29
|
}
|
|
30
30
|
get message() {
|
|
31
31
|
return this._message;
|
package/dist/kit/State.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"State.cjs","names":["EventEmitter","
|
|
1
|
+
{"version":3,"file":"State.cjs","names":["EventEmitter","getDefaultSlices","getSliceZoneDOM","getActiveSliceDOM","throttle"],"sources":["../../src/kit/State.ts"],"sourcesContent":["import type { SharedSlice, SliceZone } from \"@prismicio/client\"\n\nimport { __PRODUCTION__ } from \"../lib/__PRODUCTION__\"\nimport { EventEmitter } from \"../lib/EventEmitter\"\nimport { throttle } from \"../lib/throttle\"\nimport type { ActiveSlice } from \"../types\"\nimport { getActiveSliceDOM, getSliceZoneDOM } from \"./domHelpers\"\nimport { getDefaultSlices } from \"./getDefault\"\nimport type { StateEvents } from \"./types\"\nimport { StateEventType } from \"./types\"\n\ntype StateConstructorArgs = {\n\tslices?: SliceZone\n}\n\nexport class State extends EventEmitter<StateEvents> {\n\tprivate _slices: SliceZone\n\tpublic set slices(slices: SliceZone) {\n\t\tthis._slices = slices\n\t\t// Clean up message\n\t\tthis.message = \"\"\n\t\t// Dispatch event\n\t\tthis.emit(StateEventType.Slices, this.slices)\n\t}\n\tpublic get slices(): SliceZone {\n\t\treturn window.parent !== window ? this._slices : []\n\t}\n\n\tprivate _activeSlice: ActiveSlice | null\n\tpublic set activeSlice(activeSlice: ActiveSlice | null) {\n\t\tthis._activeSlice = activeSlice\n\t\tthis.emit(StateEventType.ActiveSlice, this.activeSlice)\n\t}\n\tpublic get activeSlice(): ActiveSlice | null {\n\t\treturn this._activeSlice\n\t}\n\n\tprivate _message: string\n\tpublic set message(message: string) {\n\t\tthis._message = message\n\t\tthis.emit(StateEventType.Message, this.message)\n\t}\n\tpublic get message(): string {\n\t\treturn this._message\n\t}\n\n\tprivate _mouse: { x: number; y: number }\n\n\tconstructor(args?: StateConstructorArgs) {\n\t\tsuper()\n\n\t\tthis._slices = args?.slices || getDefaultSlices()\n\t\tthis._activeSlice = null\n\t\tthis._message = \"\"\n\n\t\t// StateManager needs to keep track of mouse position for the active slice\n\t\tthis._mouse = { x: 0, y: 0 }\n\t}\n\n\tasync init(): Promise<void> {\n\t\t// Init listener\n\t\twindow.addEventListener(\"mousemove\", (event) => {\n\t\t\tthis._mouse = { x: event.clientX, y: event.clientY }\n\t\t})\n\t}\n\n\tprivate _setActiveSlice = (): void => {\n\t\t// There can't be an active slice if there's no slice displayed\n\t\tif (this.slices.length === 0) {\n\t\t\tthis.activeSlice = null\n\n\t\t\treturn\n\t\t}\n\n\t\tconst $sliceZone = getSliceZoneDOM(this.slices.length)\n\n\t\t// SliceZone has not been found, therefore active slice cannot be found\n\t\tif (!$sliceZone) {\n\t\t\tthis.activeSlice = null\n\n\t\t\treturn\n\t\t}\n\n\t\tconst $activeSlice = getActiveSliceDOM($sliceZone, this._mouse)\n\n\t\t// Active slice has not been found\n\t\tif (!$activeSlice) {\n\t\t\tthis.activeSlice = null\n\n\t\t\treturn\n\t\t}\n\n\t\tconst activeSliceIndex = Array.prototype.indexOf.call($sliceZone.children, $activeSlice)\n\n\t\t// Active slice has been found\n\t\tthis.activeSlice = {\n\t\t\trect: $activeSlice.getBoundingClientRect(),\n\t\t\tsliceID: this.slices[activeSliceIndex].slice_type,\n\t\t\tvariationID: (this.slices[activeSliceIndex] as SharedSlice).variation,\n\t\t\tindex: activeSliceIndex,\n\t\t}\n\t}\n\tsetActiveSlice = throttle(this._setActiveSlice, 16)\n\n\tsetSliceZone(slices: SliceZone): void {\n\t\t// Set slices\n\t\tthis.slices = slices\n\t}\n}\n"],"mappings":";;;;;;AAeA,IAAa,QAAb,cAA2BA,qBAAAA,aAA0B;CACpD;CACA,IAAW,OAAO,QAAmB;EACpC,KAAK,UAAU;EAEf,KAAK,UAAU;EAEf,KAAK,KAAA,UAA4B,KAAK,MAAM;CAC7C;CACA,IAAW,SAAoB;EAC9B,OAAO,OAAO,WAAW,SAAS,KAAK,UAAU,CAAC;CACnD;CAEA;CACA,IAAW,YAAY,aAAiC;EACvD,KAAK,eAAe;EACpB,KAAK,KAAA,eAAiC,KAAK,WAAW;CACvD;CACA,IAAW,cAAkC;EAC5C,OAAO,KAAK;CACb;CAEA;CACA,IAAW,QAAQ,SAAiB;EACnC,KAAK,WAAW;EAChB,KAAK,KAAA,WAA6B,KAAK,OAAO;CAC/C;CACA,IAAW,UAAkB;EAC5B,OAAO,KAAK;CACb;CAEA;CAEA,YAAY,MAA6B;EACxC,MAAM;EAEN,KAAK,UAAU,MAAM,UAAUC,mBAAAA,iBAAiB;EAChD,KAAK,eAAe;EACpB,KAAK,WAAW;EAGhB,KAAK,SAAS;GAAE,GAAG;GAAG,GAAG;EAAE;CAC5B;CAEA,MAAM,OAAsB;EAE3B,OAAO,iBAAiB,cAAc,UAAU;GAC/C,KAAK,SAAS;IAAE,GAAG,MAAM;IAAS,GAAG,MAAM;GAAQ;EACpD,CAAC;CACF;CAEA,wBAAsC;EAErC,IAAI,KAAK,OAAO,WAAW,GAAG;GAC7B,KAAK,cAAc;GAEnB;EACD;EAEA,MAAM,aAAaC,mBAAAA,gBAAgB,KAAK,OAAO,MAAM;EAGrD,IAAI,CAAC,YAAY;GAChB,KAAK,cAAc;GAEnB;EACD;EAEA,MAAM,eAAeC,mBAAAA,kBAAkB,YAAY,KAAK,MAAM;EAG9D,IAAI,CAAC,cAAc;GAClB,KAAK,cAAc;GAEnB;EACD;EAEA,MAAM,mBAAmB,MAAM,UAAU,QAAQ,KAAK,WAAW,UAAU,YAAY;EAGvF,KAAK,cAAc;GAClB,MAAM,aAAa,sBAAsB;GACzC,SAAS,KAAK,OAAO,iBAAiB,CAAC;GACvC,aAAc,KAAK,OAAO,iBAAiB,CAAiB;GAC5D,OAAO;EACR;CACD;CACA,iBAAiBC,iBAAAA,SAAS,KAAK,iBAAiB,EAAE;CAElD,aAAa,QAAyB;EAErC,KAAK,SAAS;CACf;AACD"}
|
package/dist/kit/State.d.cts
CHANGED
|
@@ -2,12 +2,11 @@ import { ActiveSlice } from "../types.cjs";
|
|
|
2
2
|
import { EventEmitter } from "../lib/EventEmitter.cjs";
|
|
3
3
|
import { StateEvents } from "./types.cjs";
|
|
4
4
|
import { SliceZone } from "@prismicio/client";
|
|
5
|
-
|
|
6
5
|
//#region src/kit/State.d.ts
|
|
7
6
|
type StateConstructorArgs = {
|
|
8
7
|
slices?: SliceZone;
|
|
9
8
|
};
|
|
10
|
-
declare class State extends EventEmitter<StateEvents> {
|
|
9
|
+
export declare class State extends EventEmitter<StateEvents> {
|
|
11
10
|
private _slices;
|
|
12
11
|
set slices(slices: SliceZone);
|
|
13
12
|
get slices(): SliceZone;
|
|
@@ -25,5 +24,4 @@ declare class State extends EventEmitter<StateEvents> {
|
|
|
25
24
|
setSliceZone(slices: SliceZone): void;
|
|
26
25
|
}
|
|
27
26
|
//#endregion
|
|
28
|
-
export { State };
|
|
29
27
|
//# sourceMappingURL=State.d.cts.map
|
package/dist/kit/State.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"State.d.cts","names":[],"sources":["../../src/kit/State.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"State.d.cts","names":[],"sources":["../../src/kit/State.ts"],"mappings":";;;;;KAWK;EACJ,SAAS;;qBAGG,cAAc,aAAa;UAC/B;MACG,OAAO,QAAQ;MAOf,UAAU;UAIb;MACG,YAAY,aAAa;MAIzB,eAAe;UAIlB;MACG,QAAQ;MAIR;UAIH;EAER,YAAY,OAAO;EAWb,QAAQ;UAON;EAoCR;EAEA,aAAa,QAAQ"}
|
package/dist/kit/State.d.ts
CHANGED
|
@@ -2,12 +2,11 @@ import { ActiveSlice } from "../types.js";
|
|
|
2
2
|
import { EventEmitter } from "../lib/EventEmitter.js";
|
|
3
3
|
import { StateEvents } from "./types.js";
|
|
4
4
|
import { SliceZone } from "@prismicio/client";
|
|
5
|
-
|
|
6
5
|
//#region src/kit/State.d.ts
|
|
7
6
|
type StateConstructorArgs = {
|
|
8
7
|
slices?: SliceZone;
|
|
9
8
|
};
|
|
10
|
-
declare class State extends EventEmitter<StateEvents> {
|
|
9
|
+
export declare class State extends EventEmitter<StateEvents> {
|
|
11
10
|
private _slices;
|
|
12
11
|
set slices(slices: SliceZone);
|
|
13
12
|
get slices(): SliceZone;
|
|
@@ -25,5 +24,4 @@ declare class State extends EventEmitter<StateEvents> {
|
|
|
25
24
|
setSliceZone(slices: SliceZone): void;
|
|
26
25
|
}
|
|
27
26
|
//#endregion
|
|
28
|
-
export { State };
|
|
29
27
|
//# sourceMappingURL=State.d.ts.map
|
package/dist/kit/State.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"State.d.ts","names":[],"sources":["../../src/kit/State.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"State.d.ts","names":[],"sources":["../../src/kit/State.ts"],"mappings":";;;;;KAWK;EACJ,SAAS;;qBAGG,cAAc,aAAa;UAC/B;MACG,OAAO,QAAQ;MAOf,UAAU;UAIb;MACG,YAAY,aAAa;MAIzB,eAAe;UAIlB;MACG,QAAQ;MAIR;UAIH;EAER,YAAY,OAAO;EAWb,QAAQ;UAON;EAoCR;EAEA,aAAa,QAAQ"}
|
package/dist/kit/State.js
CHANGED
|
@@ -2,14 +2,14 @@ import { throttle } from "../lib/throttle.js";
|
|
|
2
2
|
import { getActiveSliceDOM, getSliceZoneDOM } from "./domHelpers.js";
|
|
3
3
|
import { EventEmitter } from "../lib/EventEmitter.js";
|
|
4
4
|
import { getDefaultSlices } from "./getDefault.js";
|
|
5
|
-
import
|
|
5
|
+
import "./types.js";
|
|
6
6
|
//#region src/kit/State.ts
|
|
7
7
|
var State = class extends EventEmitter {
|
|
8
8
|
_slices;
|
|
9
9
|
set slices(slices) {
|
|
10
10
|
this._slices = slices;
|
|
11
11
|
this.message = "";
|
|
12
|
-
this.emit(
|
|
12
|
+
this.emit("slices", this.slices);
|
|
13
13
|
}
|
|
14
14
|
get slices() {
|
|
15
15
|
return window.parent !== window ? this._slices : [];
|
|
@@ -17,7 +17,7 @@ var State = class extends EventEmitter {
|
|
|
17
17
|
_activeSlice;
|
|
18
18
|
set activeSlice(activeSlice) {
|
|
19
19
|
this._activeSlice = activeSlice;
|
|
20
|
-
this.emit(
|
|
20
|
+
this.emit("activeSlice", this.activeSlice);
|
|
21
21
|
}
|
|
22
22
|
get activeSlice() {
|
|
23
23
|
return this._activeSlice;
|
|
@@ -25,7 +25,7 @@ var State = class extends EventEmitter {
|
|
|
25
25
|
_message;
|
|
26
26
|
set message(message) {
|
|
27
27
|
this._message = message;
|
|
28
|
-
this.emit(
|
|
28
|
+
this.emit("message", this.message);
|
|
29
29
|
}
|
|
30
30
|
get message() {
|
|
31
31
|
return this._message;
|
package/dist/kit/State.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"State.js","names":[],"sources":["../../src/kit/State.ts"],"sourcesContent":["import type { SharedSlice, SliceZone } from \"@prismicio/client\"\n\nimport { __PRODUCTION__ } from \"../lib/__PRODUCTION__\"\nimport { EventEmitter } from \"../lib/EventEmitter\"\nimport { throttle } from \"../lib/throttle\"\nimport type { ActiveSlice } from \"../types\"\nimport { getActiveSliceDOM, getSliceZoneDOM } from \"./domHelpers\"\nimport { getDefaultSlices } from \"./getDefault\"\nimport type { StateEvents } from \"./types\"\nimport { StateEventType } from \"./types\"\n\ntype StateConstructorArgs = {\n\tslices?: SliceZone\n}\n\nexport class State extends EventEmitter<StateEvents> {\n\tprivate _slices: SliceZone\n\tpublic set slices(slices: SliceZone) {\n\t\tthis._slices = slices\n\t\t// Clean up message\n\t\tthis.message = \"\"\n\t\t// Dispatch event\n\t\tthis.emit(StateEventType.Slices, this.slices)\n\t}\n\tpublic get slices(): SliceZone {\n\t\treturn window.parent !== window ? this._slices : []\n\t}\n\n\tprivate _activeSlice: ActiveSlice | null\n\tpublic set activeSlice(activeSlice: ActiveSlice | null) {\n\t\tthis._activeSlice = activeSlice\n\t\tthis.emit(StateEventType.ActiveSlice, this.activeSlice)\n\t}\n\tpublic get activeSlice(): ActiveSlice | null {\n\t\treturn this._activeSlice\n\t}\n\n\tprivate _message: string\n\tpublic set message(message: string) {\n\t\tthis._message = message\n\t\tthis.emit(StateEventType.Message, this.message)\n\t}\n\tpublic get message(): string {\n\t\treturn this._message\n\t}\n\n\tprivate _mouse: { x: number; y: number }\n\n\tconstructor(args?: StateConstructorArgs) {\n\t\tsuper()\n\n\t\tthis._slices = args?.slices || getDefaultSlices()\n\t\tthis._activeSlice = null\n\t\tthis._message = \"\"\n\n\t\t// StateManager needs to keep track of mouse position for the active slice\n\t\tthis._mouse = { x: 0, y: 0 }\n\t}\n\n\tasync init(): Promise<void> {\n\t\t// Init listener\n\t\twindow.addEventListener(\"mousemove\", (event) => {\n\t\t\tthis._mouse = { x: event.clientX, y: event.clientY }\n\t\t})\n\t}\n\n\tprivate _setActiveSlice = (): void => {\n\t\t// There can't be an active slice if there's no slice displayed\n\t\tif (this.slices.length === 0) {\n\t\t\tthis.activeSlice = null\n\n\t\t\treturn\n\t\t}\n\n\t\tconst $sliceZone = getSliceZoneDOM(this.slices.length)\n\n\t\t// SliceZone has not been found, therefore active slice cannot be found\n\t\tif (!$sliceZone) {\n\t\t\tthis.activeSlice = null\n\n\t\t\treturn\n\t\t}\n\n\t\tconst $activeSlice = getActiveSliceDOM($sliceZone, this._mouse)\n\n\t\t// Active slice has not been found\n\t\tif (!$activeSlice) {\n\t\t\tthis.activeSlice = null\n\n\t\t\treturn\n\t\t}\n\n\t\tconst activeSliceIndex = Array.prototype.indexOf.call($sliceZone.children, $activeSlice)\n\n\t\t// Active slice has been found\n\t\tthis.activeSlice = {\n\t\t\trect: $activeSlice.getBoundingClientRect(),\n\t\t\tsliceID: this.slices[activeSliceIndex].slice_type,\n\t\t\tvariationID: (this.slices[activeSliceIndex] as SharedSlice).variation,\n\t\t\tindex: activeSliceIndex,\n\t\t}\n\t}\n\tsetActiveSlice = throttle(this._setActiveSlice, 16)\n\n\tsetSliceZone(slices: SliceZone): void {\n\t\t// Set slices\n\t\tthis.slices = slices\n\t}\n}\n"],"mappings":";;;;;;AAeA,IAAa,QAAb,cAA2B,aAA0B;CACpD;CACA,IAAW,OAAO,QAAmB;
|
|
1
|
+
{"version":3,"file":"State.js","names":[],"sources":["../../src/kit/State.ts"],"sourcesContent":["import type { SharedSlice, SliceZone } from \"@prismicio/client\"\n\nimport { __PRODUCTION__ } from \"../lib/__PRODUCTION__\"\nimport { EventEmitter } from \"../lib/EventEmitter\"\nimport { throttle } from \"../lib/throttle\"\nimport type { ActiveSlice } from \"../types\"\nimport { getActiveSliceDOM, getSliceZoneDOM } from \"./domHelpers\"\nimport { getDefaultSlices } from \"./getDefault\"\nimport type { StateEvents } from \"./types\"\nimport { StateEventType } from \"./types\"\n\ntype StateConstructorArgs = {\n\tslices?: SliceZone\n}\n\nexport class State extends EventEmitter<StateEvents> {\n\tprivate _slices: SliceZone\n\tpublic set slices(slices: SliceZone) {\n\t\tthis._slices = slices\n\t\t// Clean up message\n\t\tthis.message = \"\"\n\t\t// Dispatch event\n\t\tthis.emit(StateEventType.Slices, this.slices)\n\t}\n\tpublic get slices(): SliceZone {\n\t\treturn window.parent !== window ? this._slices : []\n\t}\n\n\tprivate _activeSlice: ActiveSlice | null\n\tpublic set activeSlice(activeSlice: ActiveSlice | null) {\n\t\tthis._activeSlice = activeSlice\n\t\tthis.emit(StateEventType.ActiveSlice, this.activeSlice)\n\t}\n\tpublic get activeSlice(): ActiveSlice | null {\n\t\treturn this._activeSlice\n\t}\n\n\tprivate _message: string\n\tpublic set message(message: string) {\n\t\tthis._message = message\n\t\tthis.emit(StateEventType.Message, this.message)\n\t}\n\tpublic get message(): string {\n\t\treturn this._message\n\t}\n\n\tprivate _mouse: { x: number; y: number }\n\n\tconstructor(args?: StateConstructorArgs) {\n\t\tsuper()\n\n\t\tthis._slices = args?.slices || getDefaultSlices()\n\t\tthis._activeSlice = null\n\t\tthis._message = \"\"\n\n\t\t// StateManager needs to keep track of mouse position for the active slice\n\t\tthis._mouse = { x: 0, y: 0 }\n\t}\n\n\tasync init(): Promise<void> {\n\t\t// Init listener\n\t\twindow.addEventListener(\"mousemove\", (event) => {\n\t\t\tthis._mouse = { x: event.clientX, y: event.clientY }\n\t\t})\n\t}\n\n\tprivate _setActiveSlice = (): void => {\n\t\t// There can't be an active slice if there's no slice displayed\n\t\tif (this.slices.length === 0) {\n\t\t\tthis.activeSlice = null\n\n\t\t\treturn\n\t\t}\n\n\t\tconst $sliceZone = getSliceZoneDOM(this.slices.length)\n\n\t\t// SliceZone has not been found, therefore active slice cannot be found\n\t\tif (!$sliceZone) {\n\t\t\tthis.activeSlice = null\n\n\t\t\treturn\n\t\t}\n\n\t\tconst $activeSlice = getActiveSliceDOM($sliceZone, this._mouse)\n\n\t\t// Active slice has not been found\n\t\tif (!$activeSlice) {\n\t\t\tthis.activeSlice = null\n\n\t\t\treturn\n\t\t}\n\n\t\tconst activeSliceIndex = Array.prototype.indexOf.call($sliceZone.children, $activeSlice)\n\n\t\t// Active slice has been found\n\t\tthis.activeSlice = {\n\t\t\trect: $activeSlice.getBoundingClientRect(),\n\t\t\tsliceID: this.slices[activeSliceIndex].slice_type,\n\t\t\tvariationID: (this.slices[activeSliceIndex] as SharedSlice).variation,\n\t\t\tindex: activeSliceIndex,\n\t\t}\n\t}\n\tsetActiveSlice = throttle(this._setActiveSlice, 16)\n\n\tsetSliceZone(slices: SliceZone): void {\n\t\t// Set slices\n\t\tthis.slices = slices\n\t}\n}\n"],"mappings":";;;;;;AAeA,IAAa,QAAb,cAA2B,aAA0B;CACpD;CACA,IAAW,OAAO,QAAmB;EACpC,KAAK,UAAU;EAEf,KAAK,UAAU;EAEf,KAAK,KAAA,UAA4B,KAAK,MAAM;CAC7C;CACA,IAAW,SAAoB;EAC9B,OAAO,OAAO,WAAW,SAAS,KAAK,UAAU,CAAC;CACnD;CAEA;CACA,IAAW,YAAY,aAAiC;EACvD,KAAK,eAAe;EACpB,KAAK,KAAA,eAAiC,KAAK,WAAW;CACvD;CACA,IAAW,cAAkC;EAC5C,OAAO,KAAK;CACb;CAEA;CACA,IAAW,QAAQ,SAAiB;EACnC,KAAK,WAAW;EAChB,KAAK,KAAA,WAA6B,KAAK,OAAO;CAC/C;CACA,IAAW,UAAkB;EAC5B,OAAO,KAAK;CACb;CAEA;CAEA,YAAY,MAA6B;EACxC,MAAM;EAEN,KAAK,UAAU,MAAM,UAAU,iBAAiB;EAChD,KAAK,eAAe;EACpB,KAAK,WAAW;EAGhB,KAAK,SAAS;GAAE,GAAG;GAAG,GAAG;EAAE;CAC5B;CAEA,MAAM,OAAsB;EAE3B,OAAO,iBAAiB,cAAc,UAAU;GAC/C,KAAK,SAAS;IAAE,GAAG,MAAM;IAAS,GAAG,MAAM;GAAQ;EACpD,CAAC;CACF;CAEA,wBAAsC;EAErC,IAAI,KAAK,OAAO,WAAW,GAAG;GAC7B,KAAK,cAAc;GAEnB;EACD;EAEA,MAAM,aAAa,gBAAgB,KAAK,OAAO,MAAM;EAGrD,IAAI,CAAC,YAAY;GAChB,KAAK,cAAc;GAEnB;EACD;EAEA,MAAM,eAAe,kBAAkB,YAAY,KAAK,MAAM;EAG9D,IAAI,CAAC,cAAc;GAClB,KAAK,cAAc;GAEnB;EACD;EAEA,MAAM,mBAAmB,MAAM,UAAU,QAAQ,KAAK,WAAW,UAAU,YAAY;EAGvF,KAAK,cAAc;GAClB,MAAM,aAAa,sBAAsB;GACzC,SAAS,KAAK,OAAO,iBAAiB,CAAC;GACvC,aAAc,KAAK,OAAO,iBAAiB,CAAiB;GAC5D,OAAO;EACR;CACD;CACA,iBAAiB,SAAS,KAAK,iBAAiB,EAAE;CAElD,aAAa,QAAyB;EAErC,KAAK,SAAS;CACf;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domHelpers.cjs","names":[],"sources":["../../src/kit/domHelpers.ts"],"sourcesContent":["export const simulatorClass = \"slice-simulator\"\nexport const simulatorRootClass = \"slice-simulator--root\"\n\nexport const getSimulatorDOM = (): Element | null => {\n\treturn document.querySelector(`.${simulatorClass}`)\n}\n\nexport const getSimulatorRootDOM = (): Element | null => {\n\treturn document.querySelector(`.${simulatorRootClass}`)\n}\n\nexport const getSliceZoneDOM = (expectedNumberOfChildren: number): Element | null => {\n\t// If SliceZone has been tagged (#5)\n\tlet node = document.querySelector(`.${simulatorClass} [data-slice-zone]`)\n\tif (node) {\n\t\tif (node.children.length !== expectedNumberOfChildren) {\n\t\t\tconsole.warn(\n\t\t\t\t`Flagged SliceZone has an unexpected number of children, found ${node.children.length} but expected ${expectedNumberOfChildren}. This might lead to unexpected behaviors. Are you sure you tagged the right element?`,\n\t\t\t)\n\t\t}\n\n\t\treturn node\n\t}\n\n\t// Start searching\n\tnode = document.querySelector(`.${simulatorClass} .${simulatorRootClass}`)\n\n\tif (!node) {\n\t\treturn null\n\t}\n\n\tconst searchDepth = 5\n\tfor (let i = 0; i < searchDepth; i++) {\n\t\tif (node.children.length === expectedNumberOfChildren) {\n\t\t\t// Return the first node that matches the expected number of children\n\t\t\treturn node\n\t\t} else if (node.children.length) {\n\t\t\t// Continue searching if current node has children\n\t\t\tnode = node.children[0]\n\t\t} else {\n\t\t\t// Stop searching if current node has no children\n\t\t\tbreak\n\t\t}\n\t}\n\n\t// Failed to find SliceZone\n\treturn null\n}\n\nexport const getActiveSliceDOM = (\n\t$sliceZone: Element,\n\tmouse: { x: number; y: number },\n): Element | null => {\n\t// Raycast cursor position on DOM\n\tconst raycast = document.elementsFromPoint(mouse.x, mouse.y).reverse()\n\n\t// Find SliceZone in raycast\n\tconst sliceZoneIndex = raycast.indexOf($sliceZone)\n\n\t// SliceZone is not part of raycast\n\tif (sliceZoneIndex === -1) {\n\t\treturn null\n\t}\n\n\tconst $slice = raycast[sliceZoneIndex + 1]\n\n\t// Slice is not part of raycast\n\tif (!$slice) {\n\t\treturn null\n\t}\n\n\treturn $slice\n}\n"],"mappings":";AAAA,MAAa,iBAAiB;AAC9B,MAAa,qBAAqB;AAElC,MAAa,wBAAwC;
|
|
1
|
+
{"version":3,"file":"domHelpers.cjs","names":[],"sources":["../../src/kit/domHelpers.ts"],"sourcesContent":["export const simulatorClass = \"slice-simulator\"\nexport const simulatorRootClass = \"slice-simulator--root\"\n\nexport const getSimulatorDOM = (): Element | null => {\n\treturn document.querySelector(`.${simulatorClass}`)\n}\n\nexport const getSimulatorRootDOM = (): Element | null => {\n\treturn document.querySelector(`.${simulatorRootClass}`)\n}\n\nexport const getSliceZoneDOM = (expectedNumberOfChildren: number): Element | null => {\n\t// If SliceZone has been tagged (#5)\n\tlet node = document.querySelector(`.${simulatorClass} [data-slice-zone]`)\n\tif (node) {\n\t\tif (node.children.length !== expectedNumberOfChildren) {\n\t\t\tconsole.warn(\n\t\t\t\t`Flagged SliceZone has an unexpected number of children, found ${node.children.length} but expected ${expectedNumberOfChildren}. This might lead to unexpected behaviors. Are you sure you tagged the right element?`,\n\t\t\t)\n\t\t}\n\n\t\treturn node\n\t}\n\n\t// Start searching\n\tnode = document.querySelector(`.${simulatorClass} .${simulatorRootClass}`)\n\n\tif (!node) {\n\t\treturn null\n\t}\n\n\tconst searchDepth = 5\n\tfor (let i = 0; i < searchDepth; i++) {\n\t\tif (node.children.length === expectedNumberOfChildren) {\n\t\t\t// Return the first node that matches the expected number of children\n\t\t\treturn node\n\t\t} else if (node.children.length) {\n\t\t\t// Continue searching if current node has children\n\t\t\tnode = node.children[0]\n\t\t} else {\n\t\t\t// Stop searching if current node has no children\n\t\t\tbreak\n\t\t}\n\t}\n\n\t// Failed to find SliceZone\n\treturn null\n}\n\nexport const getActiveSliceDOM = (\n\t$sliceZone: Element,\n\tmouse: { x: number; y: number },\n): Element | null => {\n\t// Raycast cursor position on DOM\n\tconst raycast = document.elementsFromPoint(mouse.x, mouse.y).reverse()\n\n\t// Find SliceZone in raycast\n\tconst sliceZoneIndex = raycast.indexOf($sliceZone)\n\n\t// SliceZone is not part of raycast\n\tif (sliceZoneIndex === -1) {\n\t\treturn null\n\t}\n\n\tconst $slice = raycast[sliceZoneIndex + 1]\n\n\t// Slice is not part of raycast\n\tif (!$slice) {\n\t\treturn null\n\t}\n\n\treturn $slice\n}\n"],"mappings":";AAAA,MAAa,iBAAiB;AAC9B,MAAa,qBAAqB;AAElC,MAAa,wBAAwC;CACpD,OAAO,SAAS,cAAc,IAAI,gBAAgB;AACnD;AAEA,MAAa,4BAA4C;CACxD,OAAO,SAAS,cAAc,IAAI,oBAAoB;AACvD;AAEA,MAAa,mBAAmB,6BAAqD;CAEpF,IAAI,OAAO,SAAS,cAAc,IAAI,eAAe,mBAAmB;CACxE,IAAI,MAAM;EACT,IAAI,KAAK,SAAS,WAAW,0BAC5B,QAAQ,KACP,iEAAiE,KAAK,SAAS,OAAO,gBAAgB,yBAAyB,sFAChI;EAGD,OAAO;CACR;CAGA,OAAO,SAAS,cAAc,IAAI,eAAe,IAAI,oBAAoB;CAEzE,IAAI,CAAC,MACJ,OAAO;CAGR,MAAM,cAAc;CACpB,KAAK,IAAI,IAAI,GAAG,IAAI,aAAa,KAChC,IAAI,KAAK,SAAS,WAAW,0BAE5B,OAAO;MACD,IAAI,KAAK,SAAS,QAExB,OAAO,KAAK,SAAS;MAGrB;CAKF,OAAO;AACR;AAEA,MAAa,qBACZ,YACA,UACoB;CAEpB,MAAM,UAAU,SAAS,kBAAkB,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,QAAQ;CAGrE,MAAM,iBAAiB,QAAQ,QAAQ,UAAU;CAGjD,IAAI,mBAAmB,IACtB,OAAO;CAGR,MAAM,SAAS,QAAQ,iBAAiB;CAGxC,IAAI,CAAC,QACJ,OAAO;CAGR,OAAO;AACR"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
//#region src/kit/domHelpers.d.ts
|
|
2
|
-
declare const simulatorClass = "slice-simulator";
|
|
3
|
-
declare const simulatorRootClass = "slice-simulator--root";
|
|
4
|
-
declare const getSliceZoneDOM: (expectedNumberOfChildren: number) => Element | null;
|
|
5
|
-
declare const getActiveSliceDOM: ($sliceZone: Element, mouse: {
|
|
2
|
+
export declare const simulatorClass = "slice-simulator";
|
|
3
|
+
export declare const simulatorRootClass = "slice-simulator--root";
|
|
4
|
+
export declare const getSliceZoneDOM: (expectedNumberOfChildren: number) => Element | null;
|
|
5
|
+
export declare const getActiveSliceDOM: ($sliceZone: Element, mouse: {
|
|
6
6
|
x: number;
|
|
7
7
|
y: number;
|
|
8
8
|
}) => Element | null;
|
|
9
9
|
//#endregion
|
|
10
|
-
export { getActiveSliceDOM, getSliceZoneDOM, simulatorClass, simulatorRootClass };
|
|
11
10
|
//# sourceMappingURL=domHelpers.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domHelpers.d.cts","names":[],"sources":["../../src/kit/domHelpers.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"domHelpers.d.cts","names":[],"sources":["../../src/kit/domHelpers.ts"],"mappings":";qBAAa;qBACA;qBAUA,kBAAe,qCAAuC;qBAsCtD,oBAAiB,YACjB,SAAO;EACV;EAAW;MAClB"}
|
package/dist/kit/domHelpers.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
//#region src/kit/domHelpers.d.ts
|
|
2
|
-
declare const simulatorClass = "slice-simulator";
|
|
3
|
-
declare const simulatorRootClass = "slice-simulator--root";
|
|
4
|
-
declare const getSliceZoneDOM: (expectedNumberOfChildren: number) => Element | null;
|
|
5
|
-
declare const getActiveSliceDOM: ($sliceZone: Element, mouse: {
|
|
2
|
+
export declare const simulatorClass = "slice-simulator";
|
|
3
|
+
export declare const simulatorRootClass = "slice-simulator--root";
|
|
4
|
+
export declare const getSliceZoneDOM: (expectedNumberOfChildren: number) => Element | null;
|
|
5
|
+
export declare const getActiveSliceDOM: ($sliceZone: Element, mouse: {
|
|
6
6
|
x: number;
|
|
7
7
|
y: number;
|
|
8
8
|
}) => Element | null;
|
|
9
9
|
//#endregion
|
|
10
|
-
export { getActiveSliceDOM, getSliceZoneDOM, simulatorClass, simulatorRootClass };
|
|
11
10
|
//# sourceMappingURL=domHelpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domHelpers.d.ts","names":[],"sources":["../../src/kit/domHelpers.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"domHelpers.d.ts","names":[],"sources":["../../src/kit/domHelpers.ts"],"mappings":";qBAAa;qBACA;qBAUA,kBAAe,qCAAuC;qBAsCtD,oBAAiB,YACjB,SAAO;EACV;EAAW;MAClB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domHelpers.js","names":[],"sources":["../../src/kit/domHelpers.ts"],"sourcesContent":["export const simulatorClass = \"slice-simulator\"\nexport const simulatorRootClass = \"slice-simulator--root\"\n\nexport const getSimulatorDOM = (): Element | null => {\n\treturn document.querySelector(`.${simulatorClass}`)\n}\n\nexport const getSimulatorRootDOM = (): Element | null => {\n\treturn document.querySelector(`.${simulatorRootClass}`)\n}\n\nexport const getSliceZoneDOM = (expectedNumberOfChildren: number): Element | null => {\n\t// If SliceZone has been tagged (#5)\n\tlet node = document.querySelector(`.${simulatorClass} [data-slice-zone]`)\n\tif (node) {\n\t\tif (node.children.length !== expectedNumberOfChildren) {\n\t\t\tconsole.warn(\n\t\t\t\t`Flagged SliceZone has an unexpected number of children, found ${node.children.length} but expected ${expectedNumberOfChildren}. This might lead to unexpected behaviors. Are you sure you tagged the right element?`,\n\t\t\t)\n\t\t}\n\n\t\treturn node\n\t}\n\n\t// Start searching\n\tnode = document.querySelector(`.${simulatorClass} .${simulatorRootClass}`)\n\n\tif (!node) {\n\t\treturn null\n\t}\n\n\tconst searchDepth = 5\n\tfor (let i = 0; i < searchDepth; i++) {\n\t\tif (node.children.length === expectedNumberOfChildren) {\n\t\t\t// Return the first node that matches the expected number of children\n\t\t\treturn node\n\t\t} else if (node.children.length) {\n\t\t\t// Continue searching if current node has children\n\t\t\tnode = node.children[0]\n\t\t} else {\n\t\t\t// Stop searching if current node has no children\n\t\t\tbreak\n\t\t}\n\t}\n\n\t// Failed to find SliceZone\n\treturn null\n}\n\nexport const getActiveSliceDOM = (\n\t$sliceZone: Element,\n\tmouse: { x: number; y: number },\n): Element | null => {\n\t// Raycast cursor position on DOM\n\tconst raycast = document.elementsFromPoint(mouse.x, mouse.y).reverse()\n\n\t// Find SliceZone in raycast\n\tconst sliceZoneIndex = raycast.indexOf($sliceZone)\n\n\t// SliceZone is not part of raycast\n\tif (sliceZoneIndex === -1) {\n\t\treturn null\n\t}\n\n\tconst $slice = raycast[sliceZoneIndex + 1]\n\n\t// Slice is not part of raycast\n\tif (!$slice) {\n\t\treturn null\n\t}\n\n\treturn $slice\n}\n"],"mappings":";AAAA,MAAa,iBAAiB;AAC9B,MAAa,qBAAqB;AAElC,MAAa,wBAAwC;
|
|
1
|
+
{"version":3,"file":"domHelpers.js","names":[],"sources":["../../src/kit/domHelpers.ts"],"sourcesContent":["export const simulatorClass = \"slice-simulator\"\nexport const simulatorRootClass = \"slice-simulator--root\"\n\nexport const getSimulatorDOM = (): Element | null => {\n\treturn document.querySelector(`.${simulatorClass}`)\n}\n\nexport const getSimulatorRootDOM = (): Element | null => {\n\treturn document.querySelector(`.${simulatorRootClass}`)\n}\n\nexport const getSliceZoneDOM = (expectedNumberOfChildren: number): Element | null => {\n\t// If SliceZone has been tagged (#5)\n\tlet node = document.querySelector(`.${simulatorClass} [data-slice-zone]`)\n\tif (node) {\n\t\tif (node.children.length !== expectedNumberOfChildren) {\n\t\t\tconsole.warn(\n\t\t\t\t`Flagged SliceZone has an unexpected number of children, found ${node.children.length} but expected ${expectedNumberOfChildren}. This might lead to unexpected behaviors. Are you sure you tagged the right element?`,\n\t\t\t)\n\t\t}\n\n\t\treturn node\n\t}\n\n\t// Start searching\n\tnode = document.querySelector(`.${simulatorClass} .${simulatorRootClass}`)\n\n\tif (!node) {\n\t\treturn null\n\t}\n\n\tconst searchDepth = 5\n\tfor (let i = 0; i < searchDepth; i++) {\n\t\tif (node.children.length === expectedNumberOfChildren) {\n\t\t\t// Return the first node that matches the expected number of children\n\t\t\treturn node\n\t\t} else if (node.children.length) {\n\t\t\t// Continue searching if current node has children\n\t\t\tnode = node.children[0]\n\t\t} else {\n\t\t\t// Stop searching if current node has no children\n\t\t\tbreak\n\t\t}\n\t}\n\n\t// Failed to find SliceZone\n\treturn null\n}\n\nexport const getActiveSliceDOM = (\n\t$sliceZone: Element,\n\tmouse: { x: number; y: number },\n): Element | null => {\n\t// Raycast cursor position on DOM\n\tconst raycast = document.elementsFromPoint(mouse.x, mouse.y).reverse()\n\n\t// Find SliceZone in raycast\n\tconst sliceZoneIndex = raycast.indexOf($sliceZone)\n\n\t// SliceZone is not part of raycast\n\tif (sliceZoneIndex === -1) {\n\t\treturn null\n\t}\n\n\tconst $slice = raycast[sliceZoneIndex + 1]\n\n\t// Slice is not part of raycast\n\tif (!$slice) {\n\t\treturn null\n\t}\n\n\treturn $slice\n}\n"],"mappings":";AAAA,MAAa,iBAAiB;AAC9B,MAAa,qBAAqB;AAElC,MAAa,wBAAwC;CACpD,OAAO,SAAS,cAAc,IAAI,gBAAgB;AACnD;AAEA,MAAa,4BAA4C;CACxD,OAAO,SAAS,cAAc,IAAI,oBAAoB;AACvD;AAEA,MAAa,mBAAmB,6BAAqD;CAEpF,IAAI,OAAO,SAAS,cAAc,IAAI,eAAe,mBAAmB;CACxE,IAAI,MAAM;EACT,IAAI,KAAK,SAAS,WAAW,0BAC5B,QAAQ,KACP,iEAAiE,KAAK,SAAS,OAAO,gBAAgB,yBAAyB,sFAChI;EAGD,OAAO;CACR;CAGA,OAAO,SAAS,cAAc,IAAI,eAAe,IAAI,oBAAoB;CAEzE,IAAI,CAAC,MACJ,OAAO;CAGR,MAAM,cAAc;CACpB,KAAK,IAAI,IAAI,GAAG,IAAI,aAAa,KAChC,IAAI,KAAK,SAAS,WAAW,0BAE5B,OAAO;MACD,IAAI,KAAK,SAAS,QAExB,OAAO,KAAK,SAAS;MAGrB;CAKF,OAAO;AACR;AAEA,MAAa,qBACZ,YACA,UACoB;CAEpB,MAAM,UAAU,SAAS,kBAAkB,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,QAAQ;CAGrE,MAAM,iBAAiB,QAAQ,QAAQ,UAAU;CAGjD,IAAI,mBAAmB,IACtB,OAAO;CAGR,MAAM,SAAS,QAAQ,iBAAiB;CAGxC,IAAI,CAAC,QACJ,OAAO;CAGR,OAAO;AACR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventHandlers.cjs","names":[],"sources":["../../src/kit/eventHandlers.ts"],"sourcesContent":["export const disableEventHandler = (event: Event): void => {\n\tevent.preventDefault()\n\tevent.stopPropagation()\n}\n\nexport const onClickHandler = (event: MouseEvent & { path?: HTMLElement[] }): void => {\n\tif (event.path && event.path.slice(0, 5).some((el) => el instanceof HTMLAnchorElement)) {\n\t\tevent.preventDefault()\n\t\tevent.stopPropagation()\n\t}\n}\n"],"mappings":";AAAA,MAAa,uBAAuB,UAAuB;
|
|
1
|
+
{"version":3,"file":"eventHandlers.cjs","names":[],"sources":["../../src/kit/eventHandlers.ts"],"sourcesContent":["export const disableEventHandler = (event: Event): void => {\n\tevent.preventDefault()\n\tevent.stopPropagation()\n}\n\nexport const onClickHandler = (event: MouseEvent & { path?: HTMLElement[] }): void => {\n\tif (event.path && event.path.slice(0, 5).some((el) => el instanceof HTMLAnchorElement)) {\n\t\tevent.preventDefault()\n\t\tevent.stopPropagation()\n\t}\n}\n"],"mappings":";AAAA,MAAa,uBAAuB,UAAuB;CAC1D,MAAM,eAAe;CACrB,MAAM,gBAAgB;AACvB;AAEA,MAAa,kBAAkB,UAAuD;CACrF,IAAI,MAAM,QAAQ,MAAM,KAAK,MAAM,GAAG,CAAC,CAAC,CAAC,MAAM,OAAO,cAAc,iBAAiB,GAAG;EACvF,MAAM,eAAe;EACrB,MAAM,gBAAgB;CACvB;AACD"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
//#region src/kit/eventHandlers.d.ts
|
|
2
|
-
declare const disableEventHandler: (event: Event) => void;
|
|
3
|
-
declare const onClickHandler: (event: MouseEvent & {
|
|
2
|
+
export declare const disableEventHandler: (event: Event) => void;
|
|
3
|
+
export declare const onClickHandler: (event: MouseEvent & {
|
|
4
4
|
path?: HTMLElement[];
|
|
5
5
|
}) => void;
|
|
6
6
|
//#endregion
|
|
7
|
-
export { disableEventHandler, onClickHandler };
|
|
8
7
|
//# sourceMappingURL=eventHandlers.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventHandlers.d.cts","names":[],"sources":["../../src/kit/eventHandlers.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"eventHandlers.d.cts","names":[],"sources":["../../src/kit/eventHandlers.ts"],"mappings":";qBAAa,sBAAmB,OAAW;qBAK9B,iBAAc,OAAW;EAAe,OAAO"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
//#region src/kit/eventHandlers.d.ts
|
|
2
|
-
declare const disableEventHandler: (event: Event) => void;
|
|
3
|
-
declare const onClickHandler: (event: MouseEvent & {
|
|
2
|
+
export declare const disableEventHandler: (event: Event) => void;
|
|
3
|
+
export declare const onClickHandler: (event: MouseEvent & {
|
|
4
4
|
path?: HTMLElement[];
|
|
5
5
|
}) => void;
|
|
6
6
|
//#endregion
|
|
7
|
-
export { disableEventHandler, onClickHandler };
|
|
8
7
|
//# sourceMappingURL=eventHandlers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventHandlers.d.ts","names":[],"sources":["../../src/kit/eventHandlers.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"eventHandlers.d.ts","names":[],"sources":["../../src/kit/eventHandlers.ts"],"mappings":";qBAAa,sBAAmB,OAAW;qBAK9B,iBAAc,OAAW;EAAe,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventHandlers.js","names":[],"sources":["../../src/kit/eventHandlers.ts"],"sourcesContent":["export const disableEventHandler = (event: Event): void => {\n\tevent.preventDefault()\n\tevent.stopPropagation()\n}\n\nexport const onClickHandler = (event: MouseEvent & { path?: HTMLElement[] }): void => {\n\tif (event.path && event.path.slice(0, 5).some((el) => el instanceof HTMLAnchorElement)) {\n\t\tevent.preventDefault()\n\t\tevent.stopPropagation()\n\t}\n}\n"],"mappings":";AAAA,MAAa,uBAAuB,UAAuB;
|
|
1
|
+
{"version":3,"file":"eventHandlers.js","names":[],"sources":["../../src/kit/eventHandlers.ts"],"sourcesContent":["export const disableEventHandler = (event: Event): void => {\n\tevent.preventDefault()\n\tevent.stopPropagation()\n}\n\nexport const onClickHandler = (event: MouseEvent & { path?: HTMLElement[] }): void => {\n\tif (event.path && event.path.slice(0, 5).some((el) => el instanceof HTMLAnchorElement)) {\n\t\tevent.preventDefault()\n\t\tevent.stopPropagation()\n\t}\n}\n"],"mappings":";AAAA,MAAa,uBAAuB,UAAuB;CAC1D,MAAM,eAAe;CACrB,MAAM,gBAAgB;AACvB;AAEA,MAAa,kBAAkB,UAAuD;CACrF,IAAI,MAAM,QAAQ,MAAM,KAAK,MAAM,GAAG,CAAC,CAAC,CAAC,MAAM,OAAO,cAAc,iBAAiB,GAAG;EACvF,MAAM,eAAe;EACrB,MAAM,gBAAgB;CACvB;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDefault.cjs","names":[],"sources":["../../src/kit/getDefault.ts"],"sourcesContent":["import type { SliceZone } from \"@prismicio/client\"\n\nimport type { SliceSimulatorProps } from \"./types\"\n\nexport const getDefaultProps = (): Required<{\n\t[K in keyof SliceSimulatorProps]: NonNullable<SliceSimulatorProps[K]>\n}> => ({\n\tzIndex: 100,\n\tbackground: \"#ffffff\",\n})\n\nexport const getDefaultSlices = (): SliceZone => {\n\treturn []\n}\n\nexport const getDefaultMessage = (): string => {\n\treturn \"\"\n}\n"],"mappings":";AAIA,MAAa,yBAEN;CACN,QAAQ;CACR,YAAY;
|
|
1
|
+
{"version":3,"file":"getDefault.cjs","names":[],"sources":["../../src/kit/getDefault.ts"],"sourcesContent":["import type { SliceZone } from \"@prismicio/client\"\n\nimport type { SliceSimulatorProps } from \"./types\"\n\nexport const getDefaultProps = (): Required<{\n\t[K in keyof SliceSimulatorProps]: NonNullable<SliceSimulatorProps[K]>\n}> => ({\n\tzIndex: 100,\n\tbackground: \"#ffffff\",\n})\n\nexport const getDefaultSlices = (): SliceZone => {\n\treturn []\n}\n\nexport const getDefaultMessage = (): string => {\n\treturn \"\"\n}\n"],"mappings":";AAIA,MAAa,yBAEN;CACN,QAAQ;CACR,YAAY;AACb;AAEA,MAAa,yBAAoC;CAChD,OAAO,CAAC;AACT;AAEA,MAAa,0BAAkC;CAC9C,OAAO;AACR"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { SliceSimulatorProps } from "./types.cjs";
|
|
2
2
|
import { SliceZone } from "@prismicio/client";
|
|
3
|
-
|
|
4
3
|
//#region src/kit/getDefault.d.ts
|
|
5
|
-
declare const getDefaultProps: () => Required<{ [K in keyof SliceSimulatorProps]: NonNullable<SliceSimulatorProps[K]
|
|
6
|
-
declare const getDefaultSlices: () => SliceZone;
|
|
7
|
-
declare const getDefaultMessage: () => string;
|
|
4
|
+
export declare const getDefaultProps: () => Required<{ [K in keyof SliceSimulatorProps]: NonNullable<SliceSimulatorProps[K]>; }>;
|
|
5
|
+
export declare const getDefaultSlices: () => SliceZone;
|
|
6
|
+
export declare const getDefaultMessage: () => string;
|
|
8
7
|
//#endregion
|
|
9
|
-
export { getDefaultMessage, getDefaultProps, getDefaultSlices };
|
|
10
8
|
//# sourceMappingURL=getDefault.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDefault.d.cts","names":[],"sources":["../../src/kit/getDefault.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getDefault.d.cts","names":[],"sources":["../../src/kit/getDefault.ts"],"mappings":";;;qBAIa,uBAAsB,YACjC,WAAW,sBAAsB,YAAY,oBAAoB;qBAMtD,wBAAuB;qBAIvB"}
|
package/dist/kit/getDefault.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { SliceSimulatorProps } from "./types.js";
|
|
2
2
|
import { SliceZone } from "@prismicio/client";
|
|
3
|
-
|
|
4
3
|
//#region src/kit/getDefault.d.ts
|
|
5
|
-
declare const getDefaultProps: () => Required<{ [K in keyof SliceSimulatorProps]: NonNullable<SliceSimulatorProps[K]
|
|
6
|
-
declare const getDefaultSlices: () => SliceZone;
|
|
7
|
-
declare const getDefaultMessage: () => string;
|
|
4
|
+
export declare const getDefaultProps: () => Required<{ [K in keyof SliceSimulatorProps]: NonNullable<SliceSimulatorProps[K]>; }>;
|
|
5
|
+
export declare const getDefaultSlices: () => SliceZone;
|
|
6
|
+
export declare const getDefaultMessage: () => string;
|
|
8
7
|
//#endregion
|
|
9
|
-
export { getDefaultMessage, getDefaultProps, getDefaultSlices };
|
|
10
8
|
//# sourceMappingURL=getDefault.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDefault.d.ts","names":[],"sources":["../../src/kit/getDefault.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getDefault.d.ts","names":[],"sources":["../../src/kit/getDefault.ts"],"mappings":";;;qBAIa,uBAAsB,YACjC,WAAW,sBAAsB,YAAY,oBAAoB;qBAMtD,wBAAuB;qBAIvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDefault.js","names":[],"sources":["../../src/kit/getDefault.ts"],"sourcesContent":["import type { SliceZone } from \"@prismicio/client\"\n\nimport type { SliceSimulatorProps } from \"./types\"\n\nexport const getDefaultProps = (): Required<{\n\t[K in keyof SliceSimulatorProps]: NonNullable<SliceSimulatorProps[K]>\n}> => ({\n\tzIndex: 100,\n\tbackground: \"#ffffff\",\n})\n\nexport const getDefaultSlices = (): SliceZone => {\n\treturn []\n}\n\nexport const getDefaultMessage = (): string => {\n\treturn \"\"\n}\n"],"mappings":";AAIA,MAAa,yBAEN;CACN,QAAQ;CACR,YAAY;
|
|
1
|
+
{"version":3,"file":"getDefault.js","names":[],"sources":["../../src/kit/getDefault.ts"],"sourcesContent":["import type { SliceZone } from \"@prismicio/client\"\n\nimport type { SliceSimulatorProps } from \"./types\"\n\nexport const getDefaultProps = (): Required<{\n\t[K in keyof SliceSimulatorProps]: NonNullable<SliceSimulatorProps[K]>\n}> => ({\n\tzIndex: 100,\n\tbackground: \"#ffffff\",\n})\n\nexport const getDefaultSlices = (): SliceZone => {\n\treturn []\n}\n\nexport const getDefaultMessage = (): string => {\n\treturn \"\"\n}\n"],"mappings":";AAIA,MAAa,yBAEN;CACN,QAAQ;CACR,YAAY;AACb;AAEA,MAAa,yBAAoC;CAChD,OAAO,CAAC;AACT;AAEA,MAAa,0BAAkC;CAC9C,OAAO;AACR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.cjs","names":["version"],"sources":["../../src/kit/messages.ts"],"sourcesContent":["import { version } from \"../../package.json\"\n\nconst div = (content: string) =>\n\t`<div style=\"word-spacing: initial; white-space: pre; line-height: initial; font-family: monospace; color: #ffffff; mix-blend-mode: difference; padding: 1rem; font-size: 1rem;\">${content}</div>`\n\nconst a = (href: string, label?: string) =>\n\t`<a href=\"${href}\" style=\"text-decoration: underline;\">${label || href}<a>`\n\nconst header =\n\t` _____ ___ _____ _ __ __ \\n / ___// (_)_______ / ___/(_)___ ___ __ __/ /___ _/ /_____ _____\\n \\\\__ \\\\/ / / ___/ _ \\\\\\\\__ \\\\/ / __ \\`__ \\\\/ / / / / __ \\`/ __/ __ \\\\/ ___/\\n ___/ / / / /__/ __/__/ / / / / / / / /_/ / / /_/ / /_/ /_/ / / \\n/____/_/_/\\\\___/\\\\___/____/_/_/ /_/ /_/\\\\__,_/_/\\\\__,_/\\\\__/\\\\____/_/ \\n / /_ __ __ / __ \\\\_____(_)________ ___ (_)____\\n / __ \\\\/ / / / / /_/ / ___/ / ___/ __ \\`__ \\\\/ / ___/\\n / /_/ / /_/ / / ____/ / / (__ ) / / / / / / /__ \\n /_.___/\\\\__, / /_/ /_/ /_/____/_/ /_/ /_/_/\\\\___/ \\n /____/ v${version}\\n\\n`\n\nconst footer = \"\\n\\n\\n\\n - The Prismic team\"\n\nexport const sliceSimulatorAccessedDirectly = div(\n`${header}\n\n\n\nYou're seeing this page because you're accessing Slice simulator\ndirectly, e.g:\n\n - ${a(\"http://localhost:3000/slice-simulator\")}\n\n\n\nThe Slice simulator can only be accessed through Slice Machine or\nyour repository.\n\n\n\nIf you believe this is an error, please reach out to us:\n\n - ${a(\"https://github.com/prismicio/slice-simulator/issues/new/choose\")}\n\n\n\n${footer}`,\n)\n"],"mappings":";;AAEA,MAAM,OAAO,YACZ,mLAAmL,QAAQ;AAE5L,MAAM,KAAK,MAAc,UACxB,YAAY,KAAK,wCAAwC,SAAS,KAAK;AAOxE,MAAa,iCAAiC,IAC9C,
|
|
1
|
+
{"version":3,"file":"messages.cjs","names":["version"],"sources":["../../src/kit/messages.ts"],"sourcesContent":["import { version } from \"../../package.json\"\n\nconst div = (content: string) =>\n\t`<div style=\"word-spacing: initial; white-space: pre; line-height: initial; font-family: monospace; color: #ffffff; mix-blend-mode: difference; padding: 1rem; font-size: 1rem;\">${content}</div>`\n\nconst a = (href: string, label?: string) =>\n\t`<a href=\"${href}\" style=\"text-decoration: underline;\">${label || href}<a>`\n\nconst header =\n\t` _____ ___ _____ _ __ __ \\n / ___// (_)_______ / ___/(_)___ ___ __ __/ /___ _/ /_____ _____\\n \\\\__ \\\\/ / / ___/ _ \\\\\\\\__ \\\\/ / __ \\`__ \\\\/ / / / / __ \\`/ __/ __ \\\\/ ___/\\n ___/ / / / /__/ __/__/ / / / / / / / /_/ / / /_/ / /_/ /_/ / / \\n/____/_/_/\\\\___/\\\\___/____/_/_/ /_/ /_/\\\\__,_/_/\\\\__,_/\\\\__/\\\\____/_/ \\n / /_ __ __ / __ \\\\_____(_)________ ___ (_)____\\n / __ \\\\/ / / / / /_/ / ___/ / ___/ __ \\`__ \\\\/ / ___/\\n / /_/ / /_/ / / ____/ / / (__ ) / / / / / / /__ \\n /_.___/\\\\__, / /_/ /_/ /_/____/_/ /_/ /_/_/\\\\___/ \\n /____/ v${version}\\n\\n`\n\nconst footer = \"\\n\\n\\n\\n - The Prismic team\"\n\nexport const sliceSimulatorAccessedDirectly = div(\n`${header}\n\n\n\nYou're seeing this page because you're accessing Slice simulator\ndirectly, e.g:\n\n - ${a(\"http://localhost:3000/slice-simulator\")}\n\n\n\nThe Slice simulator can only be accessed through Slice Machine or\nyour repository.\n\n\n\nIf you believe this is an error, please reach out to us:\n\n - ${a(\"https://github.com/prismicio/slice-simulator/issues/new/choose\")}\n\n\n\n${footer}`,\n)\n"],"mappings":";;AAEA,MAAM,OAAO,YACZ,mLAAmL,QAAQ;AAE5L,MAAM,KAAK,MAAc,UACxB,YAAY,KAAK,wCAAwC,SAAS,KAAK;AAOxE,MAAa,iCAAiC,IAC9C,GAAG,6qBAL2qBA,gBAAAA,QAAQ,MAK5qB;;;;;;;MAOJ,EAAE,uCAAuC,EAAE;;;;;;;;;;;MAW3C,EAAE,gEAAgE,EAAE;;;;;;;;mEAK1E"}
|
package/dist/kit/messages.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.cts","names":[],"sources":["../../src/kit/messages.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"messages.d.cts","names":[],"sources":["../../src/kit/messages.ts"],"mappings":";qBAaa"}
|
package/dist/kit/messages.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","names":[],"sources":["../../src/kit/messages.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"messages.d.ts","names":[],"sources":["../../src/kit/messages.ts"],"mappings":";qBAaa"}
|
package/dist/kit/messages.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.js","names":[],"sources":["../../src/kit/messages.ts"],"sourcesContent":["import { version } from \"../../package.json\"\n\nconst div = (content: string) =>\n\t`<div style=\"word-spacing: initial; white-space: pre; line-height: initial; font-family: monospace; color: #ffffff; mix-blend-mode: difference; padding: 1rem; font-size: 1rem;\">${content}</div>`\n\nconst a = (href: string, label?: string) =>\n\t`<a href=\"${href}\" style=\"text-decoration: underline;\">${label || href}<a>`\n\nconst header =\n\t` _____ ___ _____ _ __ __ \\n / ___// (_)_______ / ___/(_)___ ___ __ __/ /___ _/ /_____ _____\\n \\\\__ \\\\/ / / ___/ _ \\\\\\\\__ \\\\/ / __ \\`__ \\\\/ / / / / __ \\`/ __/ __ \\\\/ ___/\\n ___/ / / / /__/ __/__/ / / / / / / / /_/ / / /_/ / /_/ /_/ / / \\n/____/_/_/\\\\___/\\\\___/____/_/_/ /_/ /_/\\\\__,_/_/\\\\__,_/\\\\__/\\\\____/_/ \\n / /_ __ __ / __ \\\\_____(_)________ ___ (_)____\\n / __ \\\\/ / / / / /_/ / ___/ / ___/ __ \\`__ \\\\/ / ___/\\n / /_/ / /_/ / / ____/ / / (__ ) / / / / / / /__ \\n /_.___/\\\\__, / /_/ /_/ /_/____/_/ /_/ /_/_/\\\\___/ \\n /____/ v${version}\\n\\n`\n\nconst footer = \"\\n\\n\\n\\n - The Prismic team\"\n\nexport const sliceSimulatorAccessedDirectly = div(\n`${header}\n\n\n\nYou're seeing this page because you're accessing Slice simulator\ndirectly, e.g:\n\n - ${a(\"http://localhost:3000/slice-simulator\")}\n\n\n\nThe Slice simulator can only be accessed through Slice Machine or\nyour repository.\n\n\n\nIf you believe this is an error, please reach out to us:\n\n - ${a(\"https://github.com/prismicio/slice-simulator/issues/new/choose\")}\n\n\n\n${footer}`,\n)\n"],"mappings":";;AAEA,MAAM,OAAO,YACZ,mLAAmL,QAAQ;AAE5L,MAAM,KAAK,MAAc,UACxB,YAAY,KAAK,wCAAwC,SAAS,KAAK;AAOxE,MAAa,iCAAiC,IAC9C,
|
|
1
|
+
{"version":3,"file":"messages.js","names":[],"sources":["../../src/kit/messages.ts"],"sourcesContent":["import { version } from \"../../package.json\"\n\nconst div = (content: string) =>\n\t`<div style=\"word-spacing: initial; white-space: pre; line-height: initial; font-family: monospace; color: #ffffff; mix-blend-mode: difference; padding: 1rem; font-size: 1rem;\">${content}</div>`\n\nconst a = (href: string, label?: string) =>\n\t`<a href=\"${href}\" style=\"text-decoration: underline;\">${label || href}<a>`\n\nconst header =\n\t` _____ ___ _____ _ __ __ \\n / ___// (_)_______ / ___/(_)___ ___ __ __/ /___ _/ /_____ _____\\n \\\\__ \\\\/ / / ___/ _ \\\\\\\\__ \\\\/ / __ \\`__ \\\\/ / / / / __ \\`/ __/ __ \\\\/ ___/\\n ___/ / / / /__/ __/__/ / / / / / / / /_/ / / /_/ / /_/ /_/ / / \\n/____/_/_/\\\\___/\\\\___/____/_/_/ /_/ /_/\\\\__,_/_/\\\\__,_/\\\\__/\\\\____/_/ \\n / /_ __ __ / __ \\\\_____(_)________ ___ (_)____\\n / __ \\\\/ / / / / /_/ / ___/ / ___/ __ \\`__ \\\\/ / ___/\\n / /_/ / /_/ / / ____/ / / (__ ) / / / / / / /__ \\n /_.___/\\\\__, / /_/ /_/ /_/____/_/ /_/ /_/_/\\\\___/ \\n /____/ v${version}\\n\\n`\n\nconst footer = \"\\n\\n\\n\\n - The Prismic team\"\n\nexport const sliceSimulatorAccessedDirectly = div(\n`${header}\n\n\n\nYou're seeing this page because you're accessing Slice simulator\ndirectly, e.g:\n\n - ${a(\"http://localhost:3000/slice-simulator\")}\n\n\n\nThe Slice simulator can only be accessed through Slice Machine or\nyour repository.\n\n\n\nIf you believe this is an error, please reach out to us:\n\n - ${a(\"https://github.com/prismicio/slice-simulator/issues/new/choose\")}\n\n\n\n${footer}`,\n)\n"],"mappings":";;AAEA,MAAM,OAAO,YACZ,mLAAmL,QAAQ;AAE5L,MAAM,KAAK,MAAc,UACxB,YAAY,KAAK,wCAAwC,SAAS,KAAK;AAOxE,MAAa,iCAAiC,IAC9C,GAAG,6qBAL2qB,QAAQ,MAK5qB;;;;;;;MAOJ,EAAE,uCAAuC,EAAE;;;;;;;;;;;MAW3C,EAAE,gEAAgE,EAAE;;;;;;;;mEAK1E"}
|
package/dist/kit/types.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","names":[],"sources":["../../src/kit/types.ts"],"sourcesContent":["import type { SliceZone } from \"@prismicio/client\"\n\nimport type { ActiveSlice } from \"../types\"\nimport type { SimulatorManager } from \"./SimulatorManager\"\n\nexport enum StateEventType {\n\tSlices = \"slices\",\n\tActiveSlice = \"activeSlice\",\n\tMessage = \"message\",\n}\n\nexport type StateEvents = {\n\t[StateEventType.Slices]: SliceZone\n\t[StateEventType.ActiveSlice]: ActiveSlice | null\n\t[StateEventType.Message]: string\n}\n\nexport interface SliceSimulatorProps {\n\tzIndex?: number\n\tbackground?: string\n}\n\nexport interface SliceSimulatorState {\n\tmanager: SimulatorManager\n\tslices: SliceZone\n\tmessage: string\n}\n\nexport type SliceSimulatorOptions = SliceSimulatorProps & SliceSimulatorState\n"],"mappings":";AAKA,IAAY,iBAAL,yBAAA,gBAAA;
|
|
1
|
+
{"version":3,"file":"types.cjs","names":[],"sources":["../../src/kit/types.ts"],"sourcesContent":["import type { SliceZone } from \"@prismicio/client\"\n\nimport type { ActiveSlice } from \"../types\"\nimport type { SimulatorManager } from \"./SimulatorManager\"\n\nexport enum StateEventType {\n\tSlices = \"slices\",\n\tActiveSlice = \"activeSlice\",\n\tMessage = \"message\",\n}\n\nexport type StateEvents = {\n\t[StateEventType.Slices]: SliceZone\n\t[StateEventType.ActiveSlice]: ActiveSlice | null\n\t[StateEventType.Message]: string\n}\n\nexport interface SliceSimulatorProps {\n\tzIndex?: number\n\tbackground?: string\n}\n\nexport interface SliceSimulatorState {\n\tmanager: SimulatorManager\n\tslices: SliceZone\n\tmessage: string\n}\n\nexport type SliceSimulatorOptions = SliceSimulatorProps & SliceSimulatorState\n"],"mappings":";AAKA,IAAY,iBAAL,yBAAA,gBAAA;CACN,eAAA,YAAA;CACA,eAAA,iBAAA;CACA,eAAA,aAAA;;AACD,EAAA,CAAA,CAAA"}
|
package/dist/kit/types.d.cts
CHANGED
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
import { ActiveSlice } from "../types.cjs";
|
|
2
2
|
import { SimulatorManager } from "./SimulatorManager.cjs";
|
|
3
3
|
import { SliceZone } from "@prismicio/client";
|
|
4
|
-
|
|
5
4
|
//#region src/kit/types.d.ts
|
|
6
|
-
declare enum StateEventType {
|
|
5
|
+
export declare enum StateEventType {
|
|
7
6
|
Slices = "slices",
|
|
8
7
|
ActiveSlice = "activeSlice",
|
|
9
8
|
Message = "message"
|
|
10
9
|
}
|
|
11
|
-
type StateEvents = {
|
|
10
|
+
export type StateEvents = {
|
|
12
11
|
[StateEventType.Slices]: SliceZone;
|
|
13
12
|
[StateEventType.ActiveSlice]: ActiveSlice | null;
|
|
14
13
|
[StateEventType.Message]: string;
|
|
15
14
|
};
|
|
16
|
-
interface SliceSimulatorProps {
|
|
15
|
+
export interface SliceSimulatorProps {
|
|
17
16
|
zIndex?: number;
|
|
18
17
|
background?: string;
|
|
19
18
|
}
|
|
20
|
-
interface SliceSimulatorState {
|
|
19
|
+
export interface SliceSimulatorState {
|
|
21
20
|
manager: SimulatorManager;
|
|
22
21
|
slices: SliceZone;
|
|
23
22
|
message: string;
|
|
24
23
|
}
|
|
25
|
-
type SliceSimulatorOptions = SliceSimulatorProps & SliceSimulatorState;
|
|
24
|
+
export type SliceSimulatorOptions = SliceSimulatorProps & SliceSimulatorState;
|
|
26
25
|
//#endregion
|
|
27
|
-
export { SliceSimulatorOptions, SliceSimulatorProps, SliceSimulatorState, StateEventType, StateEvents };
|
|
28
26
|
//# sourceMappingURL=types.d.cts.map
|
package/dist/kit/types.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","names":[],"sources":["../../src/kit/types.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../../src/kit/types.ts"],"mappings":";;;;oBAKY;EACX;EACA;EACA;;YAGW;GACV,eAAe,SAAS;GACxB,eAAe,cAAc;GAC7B,eAAe;;iBAGA;EAChB;EACA;;iBAGgB;EAChB,SAAS;EACT,QAAQ;EACR;;YAGW,wBAAwB,sBAAsB"}
|