Skip to content

Commit dd3bfbe

Browse files
committed
Shortens the names of host dispatcher methods to save bytes
1 parent 9007fdc commit dd3bfbe

9 files changed

+109
-101
lines changed

packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1925,21 +1925,21 @@ function getDocumentFromRoot(root: HoistableRoot): Document {
19251925
const previousDispatcher =
19261926
ReactDOMSharedInternals.d; /* ReactDOMCurrentDispatcher */
19271927
ReactDOMSharedInternals.d /* ReactDOMCurrentDispatcher */ = {
1928-
flushSyncWork: disableLegacyMode
1928+
f /* flushSyncWork */: disableLegacyMode
19291929
? flushSyncWork
1930-
: previousDispatcher.flushSyncWork,
1931-
prefetchDNS,
1932-
preconnect,
1933-
preload,
1934-
preloadModule,
1935-
preinitStyle,
1936-
preinitScript,
1937-
preinitModuleScript,
1930+
: previousDispatcher.f /* flushSyncWork */,
1931+
D /* prefetchDNS */: prefetchDNS,
1932+
C /* preconnect */: preconnect,
1933+
L /* preload */: preload,
1934+
m /* preloadModule */: preloadModule,
1935+
X /* preinitScript */: preinitScript,
1936+
S /* preinitStyle */: preinitStyle,
1937+
M /* preinitModuleScript */: preinitModuleScript,
19381938
};
19391939

19401940
function flushSyncWork() {
19411941
if (disableLegacyMode) {
1942-
const previousWasRendering = previousDispatcher.flushSyncWork();
1942+
const previousWasRendering = previousDispatcher.f(); /* flushSyncWork */
19431943
const wasRendering = flushSyncWorkOnAllRoots();
19441944
// Since multiple dispatchers can flush sync work during a single flushSync call
19451945
// we need to return true if any of them were rendering.
@@ -1990,17 +1990,17 @@ function preconnectAs(
19901990
}
19911991

19921992
function prefetchDNS(href: string) {
1993-
previousDispatcher.prefetchDNS(href);
1993+
previousDispatcher.D(/* prefetchDNS */ href);
19941994
preconnectAs('dns-prefetch', href, null);
19951995
}
19961996

19971997
function preconnect(href: string, crossOrigin?: ?CrossOriginEnum) {
1998-
previousDispatcher.preconnect(href, crossOrigin);
1998+
previousDispatcher.C(/* preconnect */ href, crossOrigin);
19991999
preconnectAs('preconnect', href, crossOrigin);
20002000
}
20012001

20022002
function preload(href: string, as: string, options?: ?PreloadImplOptions) {
2003-
previousDispatcher.preload(href, as, options);
2003+
previousDispatcher.L(/* preload */ href, as, options);
20042004
const ownerDocument = getGlobalDocument();
20052005
if (ownerDocument && href && as) {
20062006
let preloadSelector = `link[rel="preload"][as="${escapeSelectorAttributeValueInsideDoubleQuotes(
@@ -2078,7 +2078,7 @@ function preload(href: string, as: string, options?: ?PreloadImplOptions) {
20782078
}
20792079

20802080
function preloadModule(href: string, options?: ?PreloadModuleImplOptions) {
2081-
previousDispatcher.preloadModule(href, options);
2081+
previousDispatcher.m(/* preloadModule */ href, options);
20822082
const ownerDocument = getGlobalDocument();
20832083
if (ownerDocument && href) {
20842084
const as =
@@ -2139,7 +2139,7 @@ function preinitStyle(
21392139
precedence: ?string,
21402140
options?: ?PreinitStyleOptions,
21412141
) {
2142-
previousDispatcher.preinitStyle(href, precedence, options);
2142+
previousDispatcher.S(/* preinitStyle */ href, precedence, options);
21432143

21442144
const ownerDocument = getGlobalDocument();
21452145
if (ownerDocument && href) {
@@ -2213,7 +2213,7 @@ function preinitStyle(
22132213
}
22142214

22152215
function preinitScript(src: string, options?: ?PreinitScriptOptions) {
2216-
previousDispatcher.preinitScript(src, options);
2216+
previousDispatcher.X(/* preinitScript */ src, options);
22172217

22182218
const ownerDocument = getGlobalDocument();
22192219
if (ownerDocument && src) {
@@ -2269,7 +2269,7 @@ function preinitModuleScript(
22692269
src: string,
22702270
options?: ?PreinitModuleScriptOptions,
22712271
) {
2272-
previousDispatcher.preinitModuleScript(src, options);
2272+
previousDispatcher.M(/* preinitModuleScript */ src, options);
22732273

22742274
const ownerDocument = getGlobalDocument();
22752275
if (ownerDocument && src) {

packages/react-dom-bindings/src/server/ReactDOMFlightServerHostDispatcher.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ import ReactDOMSharedInternals from 'shared/ReactDOMSharedInternals';
2727
const previousDispatcher =
2828
ReactDOMSharedInternals.d; /* ReactDOMCurrentDispatcher */
2929
ReactDOMSharedInternals.d /* ReactDOMCurrentDispatcher */ = {
30-
flushSyncWork: previousDispatcher.flushSyncWork,
31-
prefetchDNS,
32-
preconnect,
33-
preload,
34-
preloadModule,
35-
preinitStyle,
36-
preinitScript,
37-
preinitModuleScript,
30+
f /* flushSyncWork */: previousDispatcher.f /* flushSyncWork */,
31+
D /* prefetchDNS */: prefetchDNS,
32+
C /* preconnect */: preconnect,
33+
L /* preload */: preload,
34+
m /* preloadModule */: preloadModule,
35+
X /* preinitScript */: preinitScript,
36+
S /* preinitStyle */: preinitStyle,
37+
M /* preinitModuleScript */: preinitModuleScript,
3838
};
3939

4040
function prefetchDNS(href: string) {
@@ -50,7 +50,7 @@ function prefetchDNS(href: string) {
5050
hints.add(key);
5151
emitHint(request, 'D', href);
5252
} else {
53-
previousDispatcher.prefetchDNS(href);
53+
previousDispatcher.D(/* prefetchDNS */ href);
5454
}
5555
}
5656
}
@@ -73,7 +73,7 @@ function preconnect(href: string, crossOrigin?: ?CrossOriginEnum) {
7373
emitHint(request, 'C', href);
7474
}
7575
} else {
76-
previousDispatcher.preconnect(href, crossOrigin);
76+
previousDispatcher.C(/* preconnect */ href, crossOrigin);
7777
}
7878
}
7979
}
@@ -106,7 +106,7 @@ function preload(href: string, as: string, options?: ?PreloadImplOptions) {
106106
emitHint(request, 'L', [href, as]);
107107
}
108108
} else {
109-
previousDispatcher.preload(href, as, options);
109+
previousDispatcher.L(/* preload */ href, as, options);
110110
}
111111
}
112112
}
@@ -130,7 +130,7 @@ function preloadModule(href: string, options?: ?PreloadModuleImplOptions) {
130130
return emitHint(request, 'm', href);
131131
}
132132
} else {
133-
previousDispatcher.preloadModule(href, options);
133+
previousDispatcher.m(/* preloadModule */ href, options);
134134
}
135135
}
136136
}
@@ -164,7 +164,7 @@ function preinitStyle(
164164
return emitHint(request, 'S', href);
165165
}
166166
} else {
167-
previousDispatcher.preinitStyle(href, precedence, options);
167+
previousDispatcher.S(/* preinitStyle */ href, precedence, options);
168168
}
169169
}
170170
}
@@ -188,7 +188,7 @@ function preinitScript(src: string, options?: ?PreinitScriptOptions) {
188188
return emitHint(request, 'X', src);
189189
}
190190
} else {
191-
previousDispatcher.preinitScript(src, options);
191+
previousDispatcher.X(/* preinitScript */ src, options);
192192
}
193193
}
194194
}
@@ -215,7 +215,7 @@ function preinitModuleScript(
215215
return emitHint(request, 'M', src);
216216
}
217217
} else {
218-
previousDispatcher.preinitModuleScript(src, options);
218+
previousDispatcher.M(/* preinitModuleScript */ src, options);
219219
}
220220
}
221221
}

packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ import ReactDOMSharedInternals from 'shared/ReactDOMSharedInternals';
8787
const previousDispatcher =
8888
ReactDOMSharedInternals.d; /* ReactDOMCurrentDispatcher */
8989
ReactDOMSharedInternals.d /* ReactDOMCurrentDispatcher */ = {
90-
flushSyncWork: previousDispatcher.flushSyncWork,
91-
prefetchDNS,
92-
preconnect,
93-
preload,
94-
preloadModule,
95-
preinitScript,
96-
preinitStyle,
97-
preinitModuleScript,
90+
f /* flushSyncWork */: previousDispatcher.f /* flushSyncWork */,
91+
D /* prefetchDNS */: prefetchDNS,
92+
C /* preconnect */: preconnect,
93+
L /* preload */: preload,
94+
m /* preloadModule */: preloadModule,
95+
X /* preinitScript */: preinitScript,
96+
S /* preinitStyle */: preinitStyle,
97+
M /* preinitModuleScript */: preinitModuleScript,
9898
};
9999

100100
// We make every property of the descriptor optional because it is not a contract that
@@ -5266,7 +5266,7 @@ function prefetchDNS(href: string) {
52665266
// the resources for this call in either case we opt to do nothing. We can consider making this a warning
52675267
// but there may be times where calling a function outside of render is intentional (i.e. to warm up data
52685268
// fetching) and we don't want to warn in those cases.
5269-
previousDispatcher.prefetchDNS(href);
5269+
previousDispatcher.D(/* prefetchDNS */ href);
52705270
return;
52715271
}
52725272
const resumableState = getResumableState(request);
@@ -5319,7 +5319,7 @@ function preconnect(href: string, crossOrigin: ?CrossOriginEnum) {
53195319
// the resources for this call in either case we opt to do nothing. We can consider making this a warning
53205320
// but there may be times where calling a function outside of render is intentional (i.e. to warm up data
53215321
// fetching) and we don't want to warn in those cases.
5322-
previousDispatcher.preconnect(href, crossOrigin);
5322+
previousDispatcher.C(/* preconnect */ href, crossOrigin);
53235323
return;
53245324
}
53255325
const resumableState = getResumableState(request);
@@ -5380,7 +5380,7 @@ function preload(href: string, as: string, options?: ?PreloadImplOptions) {
53805380
// the resources for this call in either case we opt to do nothing. We can consider making this a warning
53815381
// but there may be times where calling a function outside of render is intentional (i.e. to warm up data
53825382
// fetching) and we don't want to warn in those cases.
5383-
previousDispatcher.preload(href, as, options);
5383+
previousDispatcher.L(/* preload */ href, as, options);
53845384
return;
53855385
}
53865386
const resumableState = getResumableState(request);
@@ -5581,7 +5581,7 @@ function preloadModule(
55815581
// the resources for this call in either case we opt to do nothing. We can consider making this a warning
55825582
// but there may be times where calling a function outside of render is intentional (i.e. to warm up data
55835583
// fetching) and we don't want to warn in those cases.
5584-
previousDispatcher.preloadModule(href, options);
5584+
previousDispatcher.m(/* preloadModule */ href, options);
55855585
return;
55865586
}
55875587
const resumableState = getResumableState(request);
@@ -5655,7 +5655,7 @@ function preinitStyle(
56555655
// the resources for this call in either case we opt to do nothing. We can consider making this a warning
56565656
// but there may be times where calling a function outside of render is intentional (i.e. to warm up data
56575657
// fetching) and we don't want to warn in those cases.
5658-
previousDispatcher.preinitStyle(href, precedence, options);
5658+
previousDispatcher.S(/* preinitStyle */ href, precedence, options);
56595659
return;
56605660
}
56615661
const resumableState = getResumableState(request);
@@ -5740,7 +5740,7 @@ function preinitScript(src: string, options?: ?PreinitScriptOptions): void {
57405740
// the resources for this call in either case we opt to do nothing. We can consider making this a warning
57415741
// but there may be times where calling a function outside of render is intentional (i.e. to warm up data
57425742
// fetching) and we don't want to warn in those cases.
5743-
previousDispatcher.preinitScript(src, options);
5743+
previousDispatcher.X(/* preinitScript */ src, options);
57445744
return;
57455745
}
57465746
const resumableState = getResumableState(request);
@@ -5803,7 +5803,7 @@ function preinitModuleScript(
58035803
// the resources for this call in either case we opt to do nothing. We can consider making this a warning
58045804
// but there may be times where calling a function outside of render is intentional (i.e. to warm up data
58055805
// fetching) and we don't want to warn in those cases.
5806-
previousDispatcher.preinitModuleScript(src, options);
5806+
previousDispatcher.M(/* preinitModuleScript */ src, options);
58075807
return;
58085808
}
58095809
const resumableState = getResumableState(request);

packages/react-dom-bindings/src/shared/ReactFlightClientConfigDOM.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@ export function dispatchHint<Code: HintCode>(
2525
case 'D': {
2626
const refined = refineModel(code, model);
2727
const href = refined;
28-
dispatcher.prefetchDNS(href);
28+
dispatcher.D(/* prefetchDNS */ href);
2929
return;
3030
}
3131
case 'C': {
3232
const refined = refineModel(code, model);
3333
if (typeof refined === 'string') {
3434
const href = refined;
35-
dispatcher.preconnect(href);
35+
dispatcher.C(/* preconnect */ href);
3636
} else {
3737
const href = refined[0];
3838
const crossOrigin = refined[1];
39-
dispatcher.preconnect(href, crossOrigin);
39+
dispatcher.C(/* preconnect */ href, crossOrigin);
4040
}
4141
return;
4242
}
@@ -46,58 +46,58 @@ export function dispatchHint<Code: HintCode>(
4646
const as = refined[1];
4747
if (refined.length === 3) {
4848
const options = refined[2];
49-
dispatcher.preload(href, as, options);
49+
dispatcher.L(/* preload */ href, as, options);
5050
} else {
51-
dispatcher.preload(href, as);
51+
dispatcher.L(/* preload */ href, as);
5252
}
5353
return;
5454
}
5555
case 'm': {
5656
const refined = refineModel(code, model);
5757
if (typeof refined === 'string') {
5858
const href = refined;
59-
dispatcher.preloadModule(href);
59+
dispatcher.m(/* preloadModule */ href);
6060
} else {
6161
const href = refined[0];
6262
const options = refined[1];
63-
dispatcher.preloadModule(href, options);
63+
dispatcher.m(/* preloadModule */ href, options);
6464
}
6565
return;
6666
}
67-
case 'S': {
67+
case 'X': {
6868
const refined = refineModel(code, model);
6969
if (typeof refined === 'string') {
7070
const href = refined;
71-
dispatcher.preinitStyle(href);
71+
dispatcher.X(/* preinitScript */ href);
7272
} else {
7373
const href = refined[0];
74-
const precedence = refined[1] === 0 ? undefined : refined[1];
75-
const options = refined.length === 3 ? refined[2] : undefined;
76-
dispatcher.preinitStyle(href, precedence, options);
74+
const options = refined[1];
75+
dispatcher.X(/* preinitScript */ href, options);
7776
}
7877
return;
7978
}
80-
case 'X': {
79+
case 'S': {
8180
const refined = refineModel(code, model);
8281
if (typeof refined === 'string') {
8382
const href = refined;
84-
dispatcher.preinitScript(href);
83+
dispatcher.S(/* preinitStyle */ href);
8584
} else {
8685
const href = refined[0];
87-
const options = refined[1];
88-
dispatcher.preinitScript(href, options);
86+
const precedence = refined[1] === 0 ? undefined : refined[1];
87+
const options = refined.length === 3 ? refined[2] : undefined;
88+
dispatcher.S(/* preinitStyle */ href, precedence, options);
8989
}
9090
return;
9191
}
9292
case 'M': {
9393
const refined = refineModel(code, model);
9494
if (typeof refined === 'string') {
9595
const href = refined;
96-
dispatcher.preinitModuleScript(href);
96+
dispatcher.M(/* preinitModuleScript */ href);
9797
} else {
9898
const href = refined[0];
9999
const options = refined[1];
100-
dispatcher.preinitModuleScript(href, options);
100+
dispatcher.M(/* preinitModuleScript */ href, options);
101101
}
102102
return;
103103
}
@@ -116,7 +116,7 @@ export function preinitModuleForSSR(
116116
crossOrigin: ?string,
117117
) {
118118
ReactDOMSharedInternals.d /* ReactDOMCurrentDispatcher */
119-
.preinitModuleScript(href, {
119+
.M(/* preinitModuleScript */ href, {
120120
crossOrigin: getCrossOriginString(crossOrigin),
121121
nonce,
122122
});
@@ -128,7 +128,7 @@ export function preinitScriptForSSR(
128128
crossOrigin: ?string,
129129
) {
130130
ReactDOMSharedInternals.d /* ReactDOMCurrentDispatcher */
131-
.preinitScript(href, {
131+
.X(/* preinitScript */ href, {
132132
crossOrigin: getCrossOriginString(crossOrigin),
133133
nonce,
134134
});

packages/react-dom/src/ReactDOMSharedInternals.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ export type ReactDOMInternalsDev = ReactDOMInternals & {
3030
function noop() {}
3131

3232
const DefaultDispatcher: HostDispatcher = {
33-
flushSyncWork: noop,
34-
prefetchDNS: noop,
35-
preconnect: noop,
36-
preload: noop,
37-
preloadModule: noop,
38-
preinitScript: noop,
39-
preinitStyle: noop,
40-
preinitModuleScript: noop,
33+
f /* flushSyncWork */: noop,
34+
D /* prefetchDNS */: noop,
35+
C /* preconnect */: noop,
36+
L /* preload */: noop,
37+
m /* preloadModule */: noop,
38+
X /* preinitScript */: noop,
39+
S /* preinitStyle */: noop,
40+
M /* preinitModuleScript */: noop,
4141
};
4242

4343
const Internals: ReactDOMInternals = {

0 commit comments

Comments
 (0)