Skip to content

Commit

Permalink
Merge pull request #26285 from 43081j/qs-part-1
Browse files Browse the repository at this point in the history
Dependencies: Remove `qs` from `@storybook/manager-api` & `@storybook/channels`
  • Loading branch information
ndelangen committed Mar 7, 2024
2 parents 1fac5e1 + e467a0e commit e87d043
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
1 change: 0 additions & 1 deletion code/lib/channels/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"@storybook/client-logger": "workspace:*",
"@storybook/core-events": "workspace:*",
"@storybook/global": "^5.0.0",
"qs": "^6.10.0",
"telejson": "^7.2.0",
"tiny-invariant": "^1.3.1"
},
Expand Down
5 changes: 2 additions & 3 deletions code/lib/channels/src/postmessage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { global } from '@storybook/global';
import * as EVENTS from '@storybook/core-events';
import { logger, pretty } from '@storybook/client-logger';
import { isJSON, parse, stringify } from 'telejson';
import qs from 'qs';
import invariant from 'tiny-invariant';
import type {
ChannelTransport,
Expand Down Expand Up @@ -102,13 +101,13 @@ export class PostMessageTransport implements ChannelTransport {

const frames = this.getFrames(target);

const query = qs.parse(location?.search || '', { ignoreQueryPrefix: true });
const query = new URLSearchParams(location?.search || '');

const data = stringify(
{
key: KEY,
event,
refId: query.refId,
refId: query.get('refId'),
},
stringifyOptions
);
Expand Down
1 change: 0 additions & 1 deletion code/lib/manager-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
"@types/qs": "^6",
"@types/semver": "^7.3.4",
"flush-promises": "^1.0.2",
"qs": "^6.10.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"semver": "^7.3.7",
Expand Down
13 changes: 6 additions & 7 deletions code/lib/manager-api/src/tests/url.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { describe, beforeEach, it, expect, vi } from 'vitest';
import qs from 'qs';

import { SET_CURRENT_STORY, GLOBALS_UPDATED, UPDATE_QUERY_PARAMS } from '@storybook/core-events';

Expand All @@ -15,7 +14,7 @@ describe('initial state', () => {
describe('config query parameters', () => {
it('handles full parameter', () => {
const navigate = vi.fn();
const location = { search: qs.stringify({ full: '1' }) };
const location = { search: new URLSearchParams({ full: '1' }).toString() };

const {
state: { layout },
Expand All @@ -30,7 +29,7 @@ describe('initial state', () => {

it('handles nav parameter', () => {
const navigate = vi.fn();
const location = { search: qs.stringify({ nav: '0' }) };
const location = { search: new URLSearchParams({ nav: '0' }).toString() };

const {
state: { layout },
Expand All @@ -41,7 +40,7 @@ describe('initial state', () => {

it('handles shortcuts parameter', () => {
const navigate = vi.fn();
const location = { search: qs.stringify({ shortcuts: '0' }) };
const location = { search: new URLSearchParams({ shortcuts: '0' }).toString() };

const {
state: { ui },
Expand All @@ -52,7 +51,7 @@ describe('initial state', () => {

it('handles panel parameter, bottom', () => {
const navigate = vi.fn();
const location = { search: qs.stringify({ panel: 'bottom' }) };
const location = { search: new URLSearchParams({ panel: 'bottom' }).toString() };

const {
state: { layout },
Expand All @@ -63,7 +62,7 @@ describe('initial state', () => {

it('handles panel parameter, right', () => {
const navigate = vi.fn();
const location = { search: qs.stringify({ panel: 'right' }) };
const location = { search: new URLSearchParams({ panel: 'right' }).toString() };

const {
state: { layout },
Expand All @@ -74,7 +73,7 @@ describe('initial state', () => {

it('handles panel parameter, 0', () => {
const navigate = vi.fn();
const location = { search: qs.stringify({ panel: '0' }) };
const location = { search: new URLSearchParams({ panel: '0' }).toString() };

const {
state: { layout },
Expand Down
2 changes: 0 additions & 2 deletions code/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5588,7 +5588,6 @@ __metadata:
"@storybook/client-logger": "workspace:*"
"@storybook/core-events": "workspace:*"
"@storybook/global": "npm:^5.0.0"
qs: "npm:^6.10.0"
telejson: "npm:^7.2.0"
tiny-invariant: "npm:^1.3.1"
typescript: "npm:^5.3.2"
Expand Down Expand Up @@ -6109,7 +6108,6 @@ __metadata:
flush-promises: "npm:^1.0.2"
lodash: "npm:^4.17.21"
memoizerific: "npm:^1.11.3"
qs: "npm:^6.10.0"
react: "npm:^18.2.0"
react-dom: "npm:^18.2.0"
semver: "npm:^7.3.7"
Expand Down

0 comments on commit e87d043

Please sign in to comment.