mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 07:41:58 +08:00
MIGRATE to use qs
since that's what we use in many other places
This commit is contained in:
parent
5854b575bd
commit
6d2fa3aa64
@ -33,6 +33,7 @@
|
|||||||
"@storybook/core-events": "6.0.0-beta.39",
|
"@storybook/core-events": "6.0.0-beta.39",
|
||||||
"core-js": "^3.0.1",
|
"core-js": "^3.0.1",
|
||||||
"global": "^4.3.2",
|
"global": "^4.3.2",
|
||||||
|
"qs": "^6.6.0",
|
||||||
"telejson": "^4.0.0"
|
"telejson": "^4.0.0"
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
|
@ -3,6 +3,7 @@ import * as EVENTS from '@storybook/core-events';
|
|||||||
import Channel, { ChannelEvent, ChannelHandler } from '@storybook/channels';
|
import Channel, { ChannelEvent, ChannelHandler } from '@storybook/channels';
|
||||||
import { logger, pretty } from '@storybook/client-logger';
|
import { logger, pretty } from '@storybook/client-logger';
|
||||||
import { isJSON, parse, stringify } from 'telejson';
|
import { isJSON, parse, stringify } from 'telejson';
|
||||||
|
import qs from 'qs';
|
||||||
|
|
||||||
interface Config {
|
interface Config {
|
||||||
page: 'manager' | 'preview';
|
page: 'manager' | 'preview';
|
||||||
@ -14,16 +15,6 @@ interface BufferedEvent {
|
|||||||
reject: (reason?: any) => void;
|
reject: (reason?: any) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const getQueryObject = (): Record<string, string & { refId?: string }> => {
|
|
||||||
return (window.document.location.search as string)
|
|
||||||
.substr(1)
|
|
||||||
.split('&')
|
|
||||||
.reduce((acc, s) => {
|
|
||||||
const [k, v] = s.split('=');
|
|
||||||
return Object.assign(acc, { [k]: v || true });
|
|
||||||
}, {});
|
|
||||||
};
|
|
||||||
|
|
||||||
export const KEY = 'storybook-channel';
|
export const KEY = 'storybook-channel';
|
||||||
|
|
||||||
// TODO: we should export a method for opening child windows here and keep track of em.
|
// TODO: we should export a method for opening child windows here and keep track of em.
|
||||||
@ -81,11 +72,13 @@ export class PostmsgTransport {
|
|||||||
|
|
||||||
const frames = this.getFrames(target);
|
const frames = this.getFrames(target);
|
||||||
|
|
||||||
|
const query = qs.parse(location.search, { ignoreQueryPrefix: true });
|
||||||
|
|
||||||
const data = stringify(
|
const data = stringify(
|
||||||
{
|
{
|
||||||
key: KEY,
|
key: KEY,
|
||||||
event,
|
event,
|
||||||
refId: getQueryObject().refId,
|
refId: query.refId,
|
||||||
},
|
},
|
||||||
{ maxDepth: depth, allowFunction }
|
{ maxDepth: depth, allowFunction }
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user