Skip to content

Commit 5536e77

Browse files
committed
Remove ImmutableJS
1 parent d41077e commit 5536e77

33 files changed

+375
-309
lines changed

@types/index.d.ts

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { OrderedSet, Set } from 'immutable';
21
import React from 'react';
2+
import type { Set } from '../sources/client/src/vo/set';
33

44
import { BaseEntityRecords, Context } from '@wordpress/core-data';
55

@@ -19,7 +19,7 @@ declare namespace EntitiesSearch {
1919
fields: EntitiesSearch.SearchQueryFields;
2020
[p: string]: unknown;
2121
}>
22-
> {}
22+
> { }
2323

2424
interface SearchEntityFields
2525
extends Readonly<{
@@ -28,7 +28,7 @@ declare namespace EntitiesSearch {
2828
url: string;
2929
type: string;
3030
subtype: string;
31-
}> {}
31+
}> { }
3232

3333
type ControlOption<V extends any> = Readonly<{
3434
value: V;
@@ -37,39 +37,39 @@ declare namespace EntitiesSearch {
3737

3838
type SingularControl<V> = {
3939
[K in keyof BaseControl<V>]: K extends 'value'
40-
? V
41-
: K extends 'onChange'
42-
? (value: V) => void
43-
: BaseControl<V>[K];
40+
? V
41+
: K extends 'onChange'
42+
? (value: V) => void
43+
: BaseControl<V>[K];
4444
};
4545

4646
interface BaseControl<V>
4747
extends Readonly<{
48-
value: OrderedSet<V>;
49-
options: OrderedSet<ControlOption<V>>;
48+
value: Set<V>;
49+
options: Set<ControlOption<V>>;
5050
onChange(values: BaseControl<V>['value']): void;
51-
}> {}
51+
}> { }
5252

5353
/*
5454
* Hooks
5555
*/
5656
type ViewablePostType = Readonly<{
5757
[K in keyof PostType<'edit'>]: K extends 'viewable'
58-
? true
59-
: PostType<'edit'>[K];
58+
? true
59+
: PostType<'edit'>[K];
6060
}>;
6161

6262
// TODO Need Type Test.
6363
type ViewableTaxonomy = Readonly<{
6464
[K in keyof Taxonomy<'edit'>]: K extends 'visibility'
65-
? BaseEntityRecords.TaxonomyVisibility & {
66-
publicly_queryable: true;
67-
}
68-
: Taxonomy<'edit'>[K];
65+
? BaseEntityRecords.TaxonomyVisibility & {
66+
publicly_queryable: true;
67+
}
68+
: Taxonomy<'edit'>[K];
6969
}>;
7070

7171
type EntitiesRecords<Entity> = Readonly<{
72-
records(): OrderedSet<Entity>;
72+
records(): Set<Entity>;
7373
isResolving(): boolean;
7474
errored(): boolean;
7575
succeed(): boolean;
@@ -88,45 +88,45 @@ declare namespace EntitiesSearch {
8888
interface EntitiesState<
8989
E,
9090
K,
91-
OptionSet = OrderedSet<EntitiesSearch.ControlOption<E>>
91+
OptionSet = Set<EntitiesSearch.ControlOption<E>>
9292
> extends Readonly<{
93-
entities: BaseControl<E>['value'];
94-
kind: BaseControl<K>['value'];
95-
contextualEntitiesOptions: OptionSet;
96-
currentEntitiesOptions: OptionSet;
97-
selectedEntitiesOptions: OptionSet;
98-
}> {}
93+
entities: BaseControl<E>['value'];
94+
kind: BaseControl<K>['value'];
95+
contextualEntitiesOptions: OptionSet;
96+
currentEntitiesOptions: OptionSet;
97+
selectedEntitiesOptions: OptionSet;
98+
}> { }
9999

100100
type StoreAction<E, K> =
101101
| {
102-
type: 'UPDATE_ENTITIES';
103-
entities: EntitiesState<E, K>['entities'];
104-
}
102+
type: 'UPDATE_ENTITIES';
103+
entities: EntitiesState<E, K>['entities'];
104+
}
105105
| {
106-
type: 'UPDATE_KIND';
107-
kind: EntitiesState<E, K>['kind'];
108-
}
106+
type: 'UPDATE_KIND';
107+
kind: EntitiesState<E, K>['kind'];
108+
}
109109
| {
110-
type: 'UPDATE_CURRENT_ENTITIES_OPTIONS';
111-
currentEntitiesOptions: EntitiesState<
112-
E,
113-
K
114-
>['currentEntitiesOptions'];
115-
}
110+
type: 'UPDATE_CURRENT_ENTITIES_OPTIONS';
111+
currentEntitiesOptions: EntitiesState<
112+
E,
113+
K
114+
>['currentEntitiesOptions'];
115+
}
116116
| {
117-
type: 'UPDATE_CONTEXTUAL_ENTITIES_OPTIONS';
118-
contextualEntitiesOptions: EntitiesState<
119-
E,
120-
K
121-
>['contextualEntitiesOptions'];
122-
}
117+
type: 'UPDATE_CONTEXTUAL_ENTITIES_OPTIONS';
118+
contextualEntitiesOptions: EntitiesState<
119+
E,
120+
K
121+
>['contextualEntitiesOptions'];
122+
}
123123
| {
124-
type: 'UPDATE_SELECTED_ENTITIES_OPTIONS';
125-
selectedEntitiesOptions: EntitiesState<
126-
E,
127-
K
128-
>['selectedEntitiesOptions'];
129-
};
124+
type: 'UPDATE_SELECTED_ENTITIES_OPTIONS';
125+
selectedEntitiesOptions: EntitiesState<
126+
E,
127+
K
128+
>['selectedEntitiesOptions'];
129+
};
130130

131131
/*
132132
* Components
@@ -135,7 +135,7 @@ declare namespace EntitiesSearch {
135135
extends Readonly<{
136136
id?: string;
137137
onChange(phrase: string | React.ChangeEvent<HTMLInputElement>);
138-
}> {}
138+
}> { }
139139

140140
interface CompositeEntitiesKinds<E, K>
141141
extends Readonly<{
@@ -155,5 +155,5 @@ declare namespace EntitiesSearch {
155155
phrase: Parameters<SearchControl<E, K>['search']>[0]
156156
) => ReturnType<SearchControl<E, K>['search']>
157157
): React.ReactNode;
158-
}> {}
158+
}> { }
159159
}

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
"@wordpress/core-data": "~6.12.0",
3939
"@wordpress/i18n": "~4.24.0",
4040
"classnames": "^2.3.2",
41-
"immutable": "~4.3.0",
4241
"react": "~18.2.0"
4342
},
4443
"scripts": {

sources/client/src/api/search-entities.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import EntitiesSearch from '@types';
2-
import { OrderedSet } from 'immutable';
32

3+
import { Set } from '../vo/set';
44
import { fetch } from './fetch';
55

66
export async function searchEntities<E>(
77
type: string,
8-
subtype: OrderedSet<string>,
8+
subtype: Set<string>,
99
phrase: string,
1010
queryArguments?: EntitiesSearch.QueryArguments<string>
11-
): Promise<OrderedSet<E>> {
11+
): Promise<Set<E>> {
1212
const {
1313
exclude,
1414
include,
@@ -26,7 +26,7 @@ export async function searchEntities<E>(
2626
include: include?.toArray() ?? [],
2727
...restArguments,
2828
},
29-
type: type,
29+
type,
3030
search: phrase,
3131
subtype: subtype.toArray(),
3232
_fields: serializeFields(fields),
@@ -37,7 +37,7 @@ export async function searchEntities<E>(
3737
path: `?rest_route=/wp/v2/search&${params.toString()}`,
3838
});
3939

40-
return OrderedSet(entities);
40+
return new Set(entities);
4141
}
4242

4343
function serializeFields(fields: EntitiesSearch.SearchQueryFields): string {

0 commit comments

Comments
 (0)