-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Halt interactions in storybook inspector
- Loading branch information
Showing
8 changed files
with
864 additions
and
742 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,6 @@ | |
"yarn": "1.22.11" | ||
}, | ||
"dependencies": { | ||
"@effection/core": "2.2.0" | ||
"@effection/core": "^2.2.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { instrument } from "@storybook/instrumenter"; | ||
import { addInteractionWrapper, globals, setInteractorScope } from "@interactors/globals"; | ||
|
||
// NOTE: Dummy call to initialize instrumenter. See: https://github.com/storybookjs/storybook/blob/next/lib/instrumenter/src/instrumenter.ts#L512 | ||
instrument({}); | ||
|
||
let isRoot = true; | ||
|
||
addInteractionWrapper((interaction, next) => { | ||
if (!isRoot) { | ||
return next; | ||
} | ||
return async () => { | ||
const cancel = (event) => { | ||
if (!event.newPhase || event.newPhase == "aborted" || event.newPhase == "errored") { | ||
__STORYBOOK_ADDONS_CHANNEL__.off("forceRemount", cancel); | ||
__STORYBOOK_ADDONS_CHANNEL__.off("storyRenderPhaseChanged", cancel); | ||
interaction.catchHalt(); | ||
interaction.halt(); | ||
isRoot = true; | ||
} | ||
}; | ||
__STORYBOOK_ADDONS_CHANNEL__.on("forceRemount", cancel); | ||
__STORYBOOK_ADDONS_CHANNEL__.on("storyRenderPhaseChanged", cancel); | ||
try { | ||
return await global.window.__STORYBOOK_ADDON_INTERACTIONS_INSTRUMENTER__.track( | ||
interaction.options.code(), | ||
next, | ||
[], | ||
{ | ||
intercept: () => !(isRoot = false), | ||
} | ||
); | ||
} finally { | ||
isRoot = true; | ||
__STORYBOOK_ADDONS_CHANNEL__.off("forceRemount", cancel); | ||
__STORYBOOK_ADDONS_CHANNEL__.off("storyRenderPhaseChanged", cancel); | ||
} | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.