Interaction tracking follow up (#13509)
* Merged interaction-tracking package into react-scheduler * Add tracking API to FB+www builds * Added Rollup plugin to strip no-side-effect imports from Rollup bundles * Re-bundle tracking and scheduling APIs on SECRET_INTERNALS object for UMD build (and provide lazy forwarding methods) * Added some additional tests and fixtures * Fixed broken UMD fixture in master (#13512)
Brian Vaughn committed
Sep 1, 2018 at 12:00 UTC
46950a3dfc9e14b5b91ee5823df11883f5d2466e
71 files changed
+1351
-837
.eslintrc.js
+1
@@ -84,5 +84,6 @@ module.exports = {
84
spyOnDevAndProd: true,
85
spyOnProd: true,
86
__PROFILE__: true,
87
+ __UMD__: true,
88
},
89
};
fixtures/packaging/browserify/dev/package.json
+2
-1
@@ -4,7 +4,8 @@
4
"dependencies": {
5
"browserify": "^13.3.0",
6
"react": "link:../../../../build/node_modules/react",
7
- "react-dom": "link:../../../../build/node_modules/react-dom"
7
+ "react-dom": "link:../../../../build/node_modules/react-dom",
8
+ "react-scheduler": "link:../../../../build/node_modules/react-scheduler"
9
},
10
"scripts": {
11
"build": "rm -f output.js && browserify ./input.js -o output.js"
fixtures/packaging/browserify/dev/yarn.lock
+19
-78
@@ -25,10 +25,6 @@ array-reduce@~0.0.0:
25
version "0.0.0"
26
resolved "https://registry.yarnpkg.com/array-reduce/-/array-reduce-0.0.0.tgz#173899d3ffd1c7d9383e4479525dbe278cab5f2b"
27
28
-asap@~2.0.3:
29
- version "2.0.6"
30
- resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46"
31
-
28
asn1.js@^4.0.0:
29
version "4.9.1"
30
resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-4.9.1.tgz#48ba240b45a9280e94748990ba597d216617fd40"
@@ -254,10 +250,6 @@ convert-source-map@~1.1.0:
250
version "1.1.3"
251
resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.1.3.tgz#4829c877e9fe49b3161f3bf3673888e204699860"
252
257
-core-js@^1.0.0:
258
- version "1.2.7"
259
- resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636"
260
-
253
core-util-is@~1.0.0:
254
version "1.0.2"
255
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
@@ -365,12 +357,6 @@ elliptic@^6.0.0:
357
minimalistic-assert "^1.0.0"
358
minimalistic-crypto-utils "^1.0.0"
359
368
-encoding@^0.1.11:
369
- version "0.1.12"
370
- resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb"
371
- dependencies:
372
- iconv-lite "~0.4.13"
373
-
360
events@~1.1.0:
361
version "1.1.1"
362
resolved "https://registry.yarnpkg.com/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924"
@@ -382,18 +368,6 @@ evp_bytestokey@^1.0.0, evp_bytestokey@^1.0.3:
368
md5.js "^1.3.4"
369
safe-buffer "^5.1.1"
370
385
-fbjs@^0.8.16:
386
- version "0.8.16"
387
- resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.16.tgz#5e67432f550dc41b572bf55847b8aca64e5337db"
388
- dependencies:
389
- core-js "^1.0.0"
390
- isomorphic-fetch "^2.1.1"
391
- loose-envify "^1.0.0"
392
- object-assign "^4.1.0"
393
- promise "^7.1.1"
394
- setimmediate "^1.0.5"
395
- ua-parser-js "^0.7.9"
396
-
371
fs.realpath@^1.0.0:
372
version "1.0.0"
373
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
@@ -455,10 +429,6 @@ https-browserify@~0.0.0:
429
version "0.0.1"
430
resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-0.0.1.tgz#3f91365cabe60b77ed0ebba24b454e3e09d95a82"
431
458
-iconv-lite@~0.4.13:
459
- version "0.4.19"
460
- resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b"
461
-
432
ieee754@^1.1.4:
433
version "1.1.8"
434
resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.8.tgz#be33d40ac10ef1926701f6f08a2d86fbfd1ad3e4"
@@ -505,10 +475,6 @@ is-buffer@^1.1.0:
475
version "1.1.5"
476
resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.5.tgz#1f3b26ef613b214b88cbca23cc6c01d87961eecc"
477
508
-is-stream@^1.0.1:
509
- version "1.1.0"
510
- resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44"
511
-
478
isarray@^1.0.0, isarray@~1.0.0:
479
version "1.0.0"
480
resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
@@ -517,16 +483,9 @@ isarray@~0.0.1:
483
version "0.0.1"
484
resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf"
485
520
-isomorphic-fetch@^2.1.1:
521
- version "2.2.1"
522
- resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz#611ae1acf14f5e81f729507472819fe9733558a9"
523
- dependencies:
524
- node-fetch "^1.0.1"
525
- whatwg-fetch ">=0.10.0"
526
-
527
-js-tokens@^3.0.0:
528
- version "3.0.2"
529
- resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
486
+"js-tokens@^3.0.0 || ^4.0.0":
487
+ version "4.0.0"
488
+ resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
489
490
json-stable-stringify@~0.0.0:
491
version "0.0.1"
@@ -560,11 +519,11 @@ lodash.memoize@~3.0.3:
519
version "3.0.4"
520
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-3.0.4.tgz#2dcbd2c287cbc0a55cc42328bd0c736150d53e3f"
521
563
-loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.3.1:
564
- version "1.3.1"
565
- resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848"
522
+loose-envify@^1.1.0, loose-envify@^1.3.1:
523
+ version "1.4.0"
524
+ resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
525
dependencies:
567
- js-tokens "^3.0.0"
526
+ js-tokens "^3.0.0 || ^4.0.0"
527
528
md5.js@^1.3.4:
529
version "1.3.4"
@@ -618,14 +577,7 @@ module-deps@^4.0.8:
577
through2 "^2.0.0"
578
xtend "^4.0.0"
579
621
-node-fetch@^1.0.1:
622
- version "1.7.3"
623
- resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef"
624
- dependencies:
625
- encoding "^0.1.11"
626
- is-stream "^1.0.1"
627
-
628
-object-assign@^4.1.0, object-assign@^4.1.1:
580
+object-assign@^4.1.1:
581
version "4.1.1"
582
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
583
@@ -693,17 +645,10 @@ process@~0.11.0:
645
version "0.11.10"
646
resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182"
647
696
-promise@^7.1.1:
697
- version "7.3.1"
698
- resolved "https://registry.yarnpkg.com/promise/-/promise-7.3.1.tgz#064b72602b18f90f29192b8b1bc418ffd1ebd3bf"
648
+prop-types@^15.6.2:
649
+ version "15.6.2"
650
+ resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.2.tgz#05d5ca77b4453e985d60fc7ff8c859094a497102"
651
dependencies:
700
- asap "~2.0.3"
701
-
702
-prop-types@^15.6.0:
703
- version "15.6.0"
704
- resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.0.tgz#ceaf083022fc46b4a35f69e13ef75aed0d639856"
705
- dependencies:
706
- fbjs "^0.8.16"
652
loose-envify "^1.3.1"
653
object-assign "^4.1.1"
654
@@ -743,6 +688,14 @@ randombytes@^2.0.0, randombytes@^2.0.1:
688
version "0.0.0"
689
uid ""
690
691
+react-scheduler@^0.1.0-alpha-1:
692
+ version "0.1.0"
693
+ resolved "https://registry.yarnpkg.com/react-scheduler/-/react-scheduler-0.1.0.tgz#d16c0ee90d2895ff1941e0d681293dbe4f4b4f38"
694
+
695
+"react-scheduler@link:../../../../build/node_modules/react-scheduler":
696
+ version "0.0.0"
697
+ uid ""
698
+
699
"react@link:../../../../build/node_modules/react":
700
version "0.0.0"
701
uid ""
@@ -797,10 +750,6 @@ safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@~5.1.0,
750
version "5.1.1"
751
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853"
752
800
-setimmediate@^1.0.5:
801
- version "1.0.5"
802
- resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285"
803
-
753
sha.js@^2.4.0, sha.js@^2.4.8, sha.js@~2.4.4:
754
version "2.4.9"
755
resolved "https://registry.yarnpkg.com/sha.js/-/sha.js-2.4.9.tgz#98f64880474b74f4a38b8da9d3c0f2d104633e7d"
@@ -910,10 +859,6 @@ typedarray@~0.0.5:
859
version "0.0.6"
860
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
861
913
-ua-parser-js@^0.7.9:
914
- version "0.7.17"
915
- resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.17.tgz#e9ec5f9498b9ec910e7ae3ac626a805c4d09ecac"
916
-
862
umd@^3.0.0:
863
version "3.0.1"
864
resolved "https://registry.yarnpkg.com/umd/-/umd-3.0.1.tgz#8ae556e11011f63c2596708a8837259f01b3d60e"
@@ -941,10 +886,6 @@ vm-browserify@~0.0.1:
886
dependencies:
887
indexof "0.0.1"
888
944
-whatwg-fetch@>=0.10.0:
945
- version "2.0.3"
946
- resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz#9c84ec2dcf68187ff00bc64e1274b442176e1c84"
947
-
889
wrappy@1:
890
version "1.0.2"
891
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
fixtures/packaging/browserify/prod/package.json
+2
-1
@@ -4,7 +4,8 @@
4
"dependencies": {
5
"browserify": "^13.3.0",
6
"react": "link:../../../../build/node_modules/react",
7
- "react-dom": "link:../../../../build/node_modules/react-dom"
7
+ "react-dom": "link:../../../../build/node_modules/react-dom",
8
+ "react-scheduler": "link:../../../../build/node_modules/react-scheduler"
9
},
10
"scripts": {
11
"build": "rm -f output.js && browserify ./input.js -g [envify --NODE_ENV 'production'] -o output.js"
fixtures/packaging/browserify/prod/yarn.lock
+19
-78
@@ -25,10 +25,6 @@ array-reduce@~0.0.0:
25
version "0.0.0"
26
resolved "https://registry.yarnpkg.com/array-reduce/-/array-reduce-0.0.0.tgz#173899d3ffd1c7d9383e4479525dbe278cab5f2b"
27
28
-asap@~2.0.3:
29
- version "2.0.6"
30
- resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46"
31
-
28
asn1.js@^4.0.0:
29
version "4.9.1"
30
resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-4.9.1.tgz#48ba240b45a9280e94748990ba597d216617fd40"
@@ -254,10 +250,6 @@ convert-source-map@~1.1.0:
250
version "1.1.3"
251
resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.1.3.tgz#4829c877e9fe49b3161f3bf3673888e204699860"
252
257
-core-js@^1.0.0:
258
- version "1.2.7"
259
- resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636"
260
-
253
core-util-is@~1.0.0:
254
version "1.0.2"
255
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
@@ -365,12 +357,6 @@ elliptic@^6.0.0:
357
minimalistic-assert "^1.0.0"
358
minimalistic-crypto-utils "^1.0.0"
359
368
-encoding@^0.1.11:
369
- version "0.1.12"
370
- resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb"
371
- dependencies:
372
- iconv-lite "~0.4.13"
373
-
360
envify@^4.0.0:
361
version "4.1.0"
362
resolved "https://registry.yarnpkg.com/envify/-/envify-4.1.0.tgz#f39ad3db9d6801b4e6b478b61028d3f0b6819f7e"
@@ -393,18 +379,6 @@ evp_bytestokey@^1.0.0, evp_bytestokey@^1.0.3:
379
md5.js "^1.3.4"
380
safe-buffer "^5.1.1"
381
396
-fbjs@^0.8.16:
397
- version "0.8.16"
398
- resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.16.tgz#5e67432f550dc41b572bf55847b8aca64e5337db"
399
- dependencies:
400
- core-js "^1.0.0"
401
- isomorphic-fetch "^2.1.1"
402
- loose-envify "^1.0.0"
403
- object-assign "^4.1.0"
404
- promise "^7.1.1"
405
- setimmediate "^1.0.5"
406
- ua-parser-js "^0.7.9"
407
-
382
fs.realpath@^1.0.0:
383
version "1.0.0"
384
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
@@ -466,10 +440,6 @@ https-browserify@~0.0.0:
440
version "0.0.1"
441
resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-0.0.1.tgz#3f91365cabe60b77ed0ebba24b454e3e09d95a82"
442
469
-iconv-lite@~0.4.13:
470
- version "0.4.19"
471
- resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b"
472
-
443
ieee754@^1.1.4:
444
version "1.1.8"
445
resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.8.tgz#be33d40ac10ef1926701f6f08a2d86fbfd1ad3e4"
@@ -516,10 +486,6 @@ is-buffer@^1.1.0:
486
version "1.1.5"
487
resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.5.tgz#1f3b26ef613b214b88cbca23cc6c01d87961eecc"
488
519
-is-stream@^1.0.1:
520
- version "1.1.0"
521
- resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44"
522
-
489
isarray@^1.0.0, isarray@~1.0.0:
490
version "1.0.0"
491
resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
@@ -528,16 +494,9 @@ isarray@~0.0.1:
494
version "0.0.1"
495
resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf"
496
531
-isomorphic-fetch@^2.1.1:
532
- version "2.2.1"
533
- resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz#611ae1acf14f5e81f729507472819fe9733558a9"
534
- dependencies:
535
- node-fetch "^1.0.1"
536
- whatwg-fetch ">=0.10.0"
537
-
538
-js-tokens@^3.0.0:
539
- version "3.0.2"
540
- resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
497
+"js-tokens@^3.0.0 || ^4.0.0":
498
+ version "4.0.0"
499
+ resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
500
501
json-stable-stringify@~0.0.0:
502
version "0.0.1"
@@ -571,11 +530,11 @@ lodash.memoize@~3.0.3:
530
version "3.0.4"
531
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-3.0.4.tgz#2dcbd2c287cbc0a55cc42328bd0c736150d53e3f"
532
574
-loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.3.1:
575
- version "1.3.1"
576
- resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848"
533
+loose-envify@^1.1.0, loose-envify@^1.3.1:
534
+ version "1.4.0"
535
+ resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
536
dependencies:
578
- js-tokens "^3.0.0"
537
+ js-tokens "^3.0.0 || ^4.0.0"
538
539
md5.js@^1.3.4:
540
version "1.3.4"
@@ -629,14 +588,7 @@ module-deps@^4.0.8:
588
through2 "^2.0.0"
589
xtend "^4.0.0"
590
632
-node-fetch@^1.0.1:
633
- version "1.7.3"
634
- resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef"
635
- dependencies:
636
- encoding "^0.1.11"
637
- is-stream "^1.0.1"
638
-
639
-object-assign@^4.1.0, object-assign@^4.1.1:
591
+object-assign@^4.1.1:
592
version "4.1.1"
593
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
594
@@ -704,17 +656,10 @@ process@~0.11.0:
656
version "0.11.10"
657
resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182"
658
707
-promise@^7.1.1:
708
- version "7.3.1"
709
- resolved "https://registry.yarnpkg.com/promise/-/promise-7.3.1.tgz#064b72602b18f90f29192b8b1bc418ffd1ebd3bf"
659
+prop-types@^15.6.2:
660
+ version "15.6.2"
661
+ resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.2.tgz#05d5ca77b4453e985d60fc7ff8c859094a497102"
662
dependencies:
711
- asap "~2.0.3"
712
-
713
-prop-types@^15.6.0:
714
- version "15.6.0"
715
- resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.0.tgz#ceaf083022fc46b4a35f69e13ef75aed0d639856"
716
- dependencies:
717
- fbjs "^0.8.16"
663
loose-envify "^1.3.1"
664
object-assign "^4.1.1"
665
@@ -754,6 +699,14 @@ randombytes@^2.0.0, randombytes@^2.0.1:
699
version "0.0.0"
700
uid ""
701
702
+react-scheduler@^0.1.0-alpha-1:
703
+ version "0.1.0"
704
+ resolved "https://registry.yarnpkg.com/react-scheduler/-/react-scheduler-0.1.0.tgz#d16c0ee90d2895ff1941e0d681293dbe4f4b4f38"
705
+
706
+"react-scheduler@link:../../../../build/node_modules/react-scheduler":
707
+ version "0.0.0"
708
+ uid ""
709
+
710
"react@link:../../../../build/node_modules/react":
711
version "0.0.0"
712
uid ""
@@ -808,10 +761,6 @@ safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@~5.1.0,
761
version "5.1.1"
762
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853"
763
811
-setimmediate@^1.0.5:
812
- version "1.0.5"
813
- resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285"
814
-
764
sha.js@^2.4.0, sha.js@^2.4.8, sha.js@~2.4.4:
765
version "2.4.9"
766
resolved "https://registry.yarnpkg.com/sha.js/-/sha.js-2.4.9.tgz#98f64880474b74f4a38b8da9d3c0f2d104633e7d"
@@ -921,10 +870,6 @@ typedarray@~0.0.5:
870
version "0.0.6"
871
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
872
924
-ua-parser-js@^0.7.9:
925
- version "0.7.17"
926
- resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.17.tgz#e9ec5f9498b9ec910e7ae3ac626a805c4d09ecac"
927
-
873
umd@^3.0.0:
874
version "3.0.1"
875
resolved "https://registry.yarnpkg.com/umd/-/umd-3.0.1.tgz#8ae556e11011f63c2596708a8837259f01b3d60e"
@@ -952,10 +897,6 @@ vm-browserify@~0.0.1:
897
dependencies:
898
indexof "0.0.1"
899
955
-whatwg-fetch@>=0.10.0:
956
- version "2.0.3"
957
- resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz#9c84ec2dcf68187ff00bc64e1274b442176e1c84"
958
-
900
wrappy@1:
901
version "1.0.2"
902
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
fixtures/packaging/brunch/dev/package.json
+2
-1
@@ -5,7 +5,8 @@
5
"brunch": "^2.9.1",
6
"javascript-brunch": "^2.0.0",
7
"react": "link:../../../../build/node_modules/react",
8
- "react-dom": "link:../../../../build/node_modules/react-dom"
8
+ "react-dom": "link:../../../../build/node_modules/react-dom",
9
+ "react-scheduler": "link:../../../../build/node_modules/react-scheduler"
10
},
11
"scripts": {
12
"build": "rm -rf public && brunch build"
fixtures/packaging/brunch/dev/yarn.lock
+13
-68
@@ -78,10 +78,6 @@ array-unique@^0.2.1:
78
version "0.2.1"
79
resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53"
80
81
-asap@~2.0.3:
82
- version "2.0.6"
83
- resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46"
84
-
81
asn1.js@^4.0.0:
82
version "4.9.1"
83
resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-4.9.1.tgz#48ba240b45a9280e94748990ba597d216617fd40"
@@ -413,10 +409,6 @@ cookie@0.3.1:
409
version "0.3.1"
410
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb"
411
416
-core-js@^1.0.0:
417
- version "1.2.7"
418
- resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636"
419
-
412
core-util-is@1.0.2, core-util-is@~1.0.0:
413
version "1.0.2"
414
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
@@ -604,12 +596,6 @@ encodeurl@~1.0.1:
596
version "1.0.1"
597
resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.1.tgz#79e3d58655346909fe6f0f45a5de68103b294d20"
598
607
-encoding@^0.1.11:
608
- version "0.1.12"
609
- resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb"
610
- dependencies:
611
- iconv-lite "~0.4.13"
612
-
599
es-abstract@^1.6.1:
600
version "1.9.0"
601
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.9.0.tgz#690829a07cae36b222e7fd9b75c0d0573eb25227"
@@ -726,18 +712,6 @@ fast-levenshtein@^1.1.3:
712
version "1.1.4"
713
resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-1.1.4.tgz#e6a754cc8f15e58987aa9cbd27af66fd6f4e5af9"
714
729
-fbjs@^0.8.16:
730
- version "0.8.16"
731
- resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.16.tgz#5e67432f550dc41b572bf55847b8aca64e5337db"
732
- dependencies:
733
- core-js "^1.0.0"
734
- isomorphic-fetch "^2.1.1"
735
- loose-envify "^1.0.0"
736
- object-assign "^4.1.0"
737
- promise "^7.1.1"
738
- setimmediate "^1.0.5"
739
- ua-parser-js "^0.7.9"
740
-
715
fcache@~0.3:
716
version "0.3.0"
717
resolved "https://registry.yarnpkg.com/fcache/-/fcache-0.3.0.tgz#d45f2f908642b91b798e88195ec47881a51c3d44"
@@ -1027,7 +1001,7 @@ https-browserify@~0.0.1:
1001
version "0.0.1"
1002
resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-0.0.1.tgz#3f91365cabe60b77ed0ebba24b454e3e09d95a82"
1003
1030
-iconv-lite@0.4.19, iconv-lite@~0.4.13:
1004
+iconv-lite@0.4.19:
1005
version "0.4.19"
1006
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b"
1007
@@ -1152,10 +1126,6 @@ is-regex@^1.0.4:
1126
dependencies:
1127
has "^1.0.1"
1128
1155
-is-stream@^1.0.1:
1156
- version "1.1.0"
1157
- resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44"
1158
-
1129
is-symbol@^1.0.1:
1130
version "1.0.1"
1131
resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572"
@@ -1182,13 +1152,6 @@ isobject@^2.0.0:
1152
dependencies:
1153
isarray "1.0.0"
1154
1185
-isomorphic-fetch@^2.1.1:
1186
- version "2.2.1"
1187
- resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz#611ae1acf14f5e81f729507472819fe9733558a9"
1188
- dependencies:
1189
- node-fetch "^1.0.1"
1190
- whatwg-fetch ">=0.10.0"
1191
-
1155
isstream@~0.1.2:
1156
version "0.1.2"
1157
resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a"
@@ -1264,7 +1227,7 @@ loggy@~0.3.0:
1227
ansicolors "~0.3.2"
1228
growl "~1.8.1"
1229
1267
-loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.3.1:
1230
+loose-envify@^1.1.0, loose-envify@^1.3.1:
1231
version "1.3.1"
1232
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848"
1233
dependencies:
@@ -1423,13 +1386,6 @@ node-browser-modules@^0.1.0:
1386
util "~0.10.3"
1387
vm-browserify "~0.0.4"
1388
1426
-node-fetch@^1.0.1:
1427
- version "1.7.3"
1428
- resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef"
1429
- dependencies:
1430
- encoding "^0.1.11"
1431
- is-stream "^1.0.1"
1432
-
1389
node-pre-gyp@^0.6.36:
1390
version "0.6.38"
1391
resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.6.38.tgz#e92a20f83416415bb4086f6d1fb78b3da73d113d"
@@ -1605,17 +1561,10 @@ promise.prototype.finally@^2:
1561
es-abstract "^1.6.1"
1562
function-bind "^1.1.0"
1563
1608
-promise@^7.1.1:
1609
- version "7.3.1"
1610
- resolved "https://registry.yarnpkg.com/promise/-/promise-7.3.1.tgz#064b72602b18f90f29192b8b1bc418ffd1ebd3bf"
1611
- dependencies:
1612
- asap "~2.0.3"
1613
-
1614
-prop-types@^15.6.0:
1615
- version "15.6.0"
1616
- resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.0.tgz#ceaf083022fc46b4a35f69e13ef75aed0d639856"
1564
+prop-types@^15.6.2:
1565
+ version "15.6.2"
1566
+ resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.2.tgz#05d5ca77b4453e985d60fc7ff8c859094a497102"
1567
dependencies:
1618
- fbjs "^0.8.16"
1568
loose-envify "^1.3.1"
1569
object-assign "^4.1.1"
1570
@@ -1708,6 +1657,14 @@ rc@^1.1.7:
1657
version "0.0.0"
1658
uid ""
1659
1660
+react-scheduler@^0.1.0-alpha-1:
1661
+ version "0.1.0"
1662
+ resolved "https://registry.yarnpkg.com/react-scheduler/-/react-scheduler-0.1.0.tgz#d16c0ee90d2895ff1941e0d681293dbe4f4b4f38"
1663
+
1664
+"react-scheduler@link:../../../../build/node_modules/react-scheduler":
1665
+ version "0.0.0"
1666
+ uid ""
1667
+
1668
"react@link:../../../../build/node_modules/react":
1669
version "0.0.0"
1670
uid ""
@@ -1870,10 +1827,6 @@ set-immediate-shim@^1.0.1:
1827
version "1.0.1"
1828
resolved "https://registry.yarnpkg.com/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz#4b2b1b27eb808a9f8dcc481a58e5e56f599f3f61"
1829
1873
-setimmediate@^1.0.5:
1874
- version "1.0.5"
1875
- resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285"
1876
-
1830
setprototypeof@1.0.3:
1831
version "1.0.3"
1832
resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.0.3.tgz#66567e37043eeb4f04d91bd658c0cbefb55b8e04"
@@ -2053,10 +2006,6 @@ type-is@~1.6.15:
2006
media-typer "0.3.0"
2007
mime-types "~2.1.15"
2008
2056
-ua-parser-js@^0.7.9:
2057
- version "0.7.17"
2058
- resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.17.tgz#e9ec5f9498b9ec910e7ae3ac626a805c4d09ecac"
2059
-
2009
uid-number@^0.0.6:
2010
version "0.0.6"
2011
resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81"
@@ -2118,10 +2067,6 @@ vm-browserify@~0.0.4:
2067
dependencies:
2068
indexof "0.0.1"
2069
2121
-whatwg-fetch@>=0.10.0:
2122
- version "2.0.3"
2123
- resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz#9c84ec2dcf68187ff00bc64e1274b442176e1c84"
2124
-
2070
which@^1.2.12:
2071
version "1.3.0"
2072
resolved "https://registry.yarnpkg.com/which/-/which-1.3.0.tgz#ff04bdfc010ee547d780bec38e1ac1c2777d253a"
fixtures/packaging/brunch/prod/package.json
+2
-1
@@ -5,7 +5,8 @@
5
"brunch": "^2.9.1",
6
"javascript-brunch": "^2.0.0",
7
"react": "link:../../../../build/node_modules/react",
8
- "react-dom": "link:../../../../build/node_modules/react-dom"
8
+ "react-dom": "link:../../../../build/node_modules/react-dom",
9
+ "react-scheduler": "link:../../../../build/node_modules/react-scheduler"
10
},
11
"scripts": {
12
"build": "rm -rf public && brunch build -p"
fixtures/packaging/brunch/prod/yarn.lock
+13
-68
@@ -78,10 +78,6 @@ array-unique@^0.2.1:
78
version "0.2.1"
79
resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53"
80
81
-asap@~2.0.3:
82
- version "2.0.6"
83
- resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46"
84
-
81
asn1.js@^4.0.0:
82
version "4.9.1"
83
resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-4.9.1.tgz#48ba240b45a9280e94748990ba597d216617fd40"
@@ -413,10 +409,6 @@ cookie@0.3.1:
409
version "0.3.1"
410
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb"
411
416
-core-js@^1.0.0:
417
- version "1.2.7"
418
- resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636"
419
-
412
core-util-is@1.0.2, core-util-is@~1.0.0:
413
version "1.0.2"
414
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
@@ -604,12 +596,6 @@ encodeurl@~1.0.1:
596
version "1.0.1"
597
resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.1.tgz#79e3d58655346909fe6f0f45a5de68103b294d20"
598
607
-encoding@^0.1.11:
608
- version "0.1.12"
609
- resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb"
610
- dependencies:
611
- iconv-lite "~0.4.13"
612
-
599
es-abstract@^1.6.1:
600
version "1.9.0"
601
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.9.0.tgz#690829a07cae36b222e7fd9b75c0d0573eb25227"
@@ -726,18 +712,6 @@ fast-levenshtein@^1.1.3:
712
version "1.1.4"
713
resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-1.1.4.tgz#e6a754cc8f15e58987aa9cbd27af66fd6f4e5af9"
714
729
-fbjs@^0.8.16:
730
- version "0.8.16"
731
- resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.16.tgz#5e67432f550dc41b572bf55847b8aca64e5337db"
732
- dependencies:
733
- core-js "^1.0.0"
734
- isomorphic-fetch "^2.1.1"
735
- loose-envify "^1.0.0"
736
- object-assign "^4.1.0"
737
- promise "^7.1.1"
738
- setimmediate "^1.0.5"
739
- ua-parser-js "^0.7.9"
740
-
715
fcache@~0.3:
716
version "0.3.0"
717
resolved "https://registry.yarnpkg.com/fcache/-/fcache-0.3.0.tgz#d45f2f908642b91b798e88195ec47881a51c3d44"
@@ -1027,7 +1001,7 @@ https-browserify@~0.0.1:
1001
version "0.0.1"
1002
resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-0.0.1.tgz#3f91365cabe60b77ed0ebba24b454e3e09d95a82"
1003
1030
-iconv-lite@0.4.19, iconv-lite@~0.4.13:
1004
+iconv-lite@0.4.19:
1005
version "0.4.19"
1006
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b"
1007
@@ -1152,10 +1126,6 @@ is-regex@^1.0.4:
1126
dependencies:
1127
has "^1.0.1"
1128
1155
-is-stream@^1.0.1:
1156
- version "1.1.0"
1157
- resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44"
1158
-
1129
is-symbol@^1.0.1:
1130
version "1.0.1"
1131
resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572"
@@ -1182,13 +1152,6 @@ isobject@^2.0.0:
1152
dependencies:
1153
isarray "1.0.0"
1154
1185
-isomorphic-fetch@^2.1.1:
1186
- version "2.2.1"
1187
- resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz#611ae1acf14f5e81f729507472819fe9733558a9"
1188
- dependencies:
1189
- node-fetch "^1.0.1"
1190
- whatwg-fetch ">=0.10.0"
1191
-
1155
isstream@~0.1.2:
1156
version "0.1.2"
1157
resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a"
@@ -1264,7 +1227,7 @@ loggy@~0.3.0:
1227
ansicolors "~0.3.2"
1228
growl "~1.8.1"
1229
1267
-loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.3.1:
1230
+loose-envify@^1.1.0, loose-envify@^1.3.1:
1231
version "1.3.1"
1232
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848"
1233
dependencies:
@@ -1423,13 +1386,6 @@ node-browser-modules@^0.1.0:
1386
util "~0.10.3"
1387
vm-browserify "~0.0.4"
1388
1426
-node-fetch@^1.0.1:
1427
- version "1.7.3"
1428
- resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef"
1429
- dependencies:
1430
- encoding "^0.1.11"
1431
- is-stream "^1.0.1"
1432
-
1389
node-pre-gyp@^0.6.36:
1390
version "0.6.38"
1391
resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.6.38.tgz#e92a20f83416415bb4086f6d1fb78b3da73d113d"
@@ -1605,17 +1561,10 @@ promise.prototype.finally@^2:
1561
es-abstract "^1.6.1"
1562
function-bind "^1.1.0"
1563
1608
-promise@^7.1.1:
1609
- version "7.3.1"
1610
- resolved "https://registry.yarnpkg.com/promise/-/promise-7.3.1.tgz#064b72602b18f90f29192b8b1bc418ffd1ebd3bf"
1611
- dependencies:
1612
- asap "~2.0.3"
1613
-
1614
-prop-types@^15.6.0:
1615
- version "15.6.0"
1616
- resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.0.tgz#ceaf083022fc46b4a35f69e13ef75aed0d639856"
1564
+prop-types@^15.6.2:
1565
+ version "15.6.2"
1566
+ resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.2.tgz#05d5ca77b4453e985d60fc7ff8c859094a497102"
1567
dependencies:
1618
- fbjs "^0.8.16"
1568
loose-envify "^1.3.1"
1569
object-assign "^4.1.1"
1570
@@ -1708,6 +1657,14 @@ rc@^1.1.7:
1657
version "0.0.0"
1658
uid ""
1659
1660
+react-scheduler@^0.1.0-alpha-1:
1661
+ version "0.1.0"
1662
+ resolved "https://registry.yarnpkg.com/react-scheduler/-/react-scheduler-0.1.0.tgz#d16c0ee90d2895ff1941e0d681293dbe4f4b4f38"
1663
+
1664
+"react-scheduler@link:../../../../build/node_modules/react-scheduler":
1665
+ version "0.0.0"
1666
+ uid ""
1667
+
1668
"react@link:../../../../build/node_modules/react":
1669
version "0.0.0"
1670
uid ""
@@ -1870,10 +1827,6 @@ set-immediate-shim@^1.0.1:
1827
version "1.0.1"
1828
resolved "https://registry.yarnpkg.com/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz#4b2b1b27eb808a9f8dcc481a58e5e56f599f3f61"
1829
1873
-setimmediate@^1.0.5:
1874
- version "1.0.5"
1875
- resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285"
1876
-
1830
setprototypeof@1.0.3:
1831
version "1.0.3"
1832
resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.0.3.tgz#66567e37043eeb4f04d91bd658c0cbefb55b8e04"
@@ -2053,10 +2006,6 @@ type-is@~1.6.15:
2006
media-typer "0.3.0"
2007
mime-types "~2.1.15"
2008
2056
-ua-parser-js@^0.7.9:
2057
- version "0.7.17"
2058
- resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.17.tgz#e9ec5f9498b9ec910e7ae3ac626a805c4d09ecac"
2059
-
2009
uid-number@^0.0.6:
2010
version "0.0.6"
2011
resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81"
@@ -2118,10 +2067,6 @@ vm-browserify@~0.0.4:
2067
dependencies:
2068
indexof "0.0.1"
2069
2121
-whatwg-fetch@>=0.10.0:
2122
- version "2.0.3"
2123
- resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz#9c84ec2dcf68187ff00bc64e1274b442176e1c84"
2124
-
2070
which@^1.2.12:
2071
version "1.3.0"
2072
resolved "https://registry.yarnpkg.com/which/-/which-1.3.0.tgz#ff04bdfc010ee547d780bec38e1ac1c2777d253a"
fixtures/packaging/rjs/dev/config.js
+1
@@ -6,5 +6,6 @@ module.exports = {
6
paths: {
7
react: '../../../../build/dist/react.development',
8
'react-dom': '../../../../build/dist/react-dom.development',
9
+ 'react-scheduler': '../../../../build/dist/react-scheduler.development',
10
},
11
};
fixtures/packaging/rjs/prod/config.js
+1
@@ -6,5 +6,6 @@ module.exports = {
6
paths: {
7
react: '../../../../build/dist/react.production.min',
8
'react-dom': '../../../../build/dist/react-dom.production.min',
9
+ 'react-scheduler': '../../../../build/dist/react-scheduler.development',
10
},
11
};
fixtures/packaging/systemjs-builder/dev/config.js
+1
@@ -2,5 +2,6 @@ System.config({
2
paths: {
3
react: '../../../../build/dist/react.development.js',
4
'react-dom': '../../../../build/dist/react-dom.development.js',
5
+ 'react-scheduler': '../../../../build/dist/react-scheduler.development',
6
},
7
});
fixtures/packaging/systemjs-builder/prod/config.js
+1
@@ -2,5 +2,6 @@ System.config({
2
paths: {
3
react: '../../../../build/dist/react.production.min.js',
4
'react-dom': '../../../../build/dist/react-dom.production.min.js',
5
+ 'react-scheduler': '../../../../build/dist/react-scheduler.development',
6
},
7
});
fixtures/schedule/index.html
+5
-1
@@ -92,7 +92,11 @@
92
<script src="../../build/dist/react-scheduler.development.js"></script>
93
<script src="https://unpkg.com/babel-standalone@6/babel.js"></script>
94
<script type="text/babel">
95
-const {scheduleWork, cancelWork, now} = ReactScheduler;
95
+const {
96
+ unstable_scheduleWork: scheduleWork,
97
+ unstable_cancelWork: cancelWork,
98
+ unstable_now: now
99
+} = ReactScheduler;
100
function displayTestResult(testNumber) {
101
const expectationNode = document.getElementById('test-' + testNumber + '-expected');
102
const resultNode = document.getElementById('test-' + testNumber);
fixtures/tracking/index.html
new
+72
@@ -0,0 +1,72 @@
1
+<!DOCTYPE html>
2
+<html style="width: 100%; height: 100%;">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Test tracking UMD</title>
6
+ <style>
7
+ body {
8
+ font-family: sans-serif;
9
+ }
10
+ ol {
11
+ display: inline-flex;
12
+ flex-direction: column;
13
+ align-items: flex-start;
14
+ }
15
+ li {
16
+ background-color: #F7F7F7;
17
+ border: solid #CCC 0.125rem;
18
+ margin-bottom: 0.5rem;
19
+ border-radius: 0.25rem;
20
+ padding: 0.5rem;
21
+ }
22
+ li:after {
23
+ content: attr(data-value);
24
+ margin-left: 0.25rem;
25
+ }
26
+ .correct {
27
+ border-color: #0C0;
28
+ border-style: solid;
29
+ background: #EFE;
30
+ }
31
+ .incorrect {
32
+ border-color: #F00;
33
+ border-style: dashed;
34
+ background-color: #FEE;
35
+ }
36
+ </style>
37
+ </head>
38
+ <body>
39
+ <h1>Test tracking UMD</h1>
40
+ <p>
41
+ This fixture tests that the new tracking API is accessible via UMD build using the UMD shim.
42
+ It does not exhaustively test API functionality, only that the forwarded methods can be called.
43
+ </p>
44
+ <p>
45
+ Before running the tests below, check the console to make sure there are no errors.
46
+ </p>
47
+ <h3>
48
+ Tests
49
+ <button onClick="runAllTests()">Run all tests</button>
50
+ </h3>
51
+ <ol>
52
+ <li id="checkSchedulerAPI" data-value="...">
53
+ <strong>Test scheduler API</strong>
54
+ </li>
55
+ <li id="checkSchedulerTrackingAPI" data-value="...">
56
+ <strong>Test tracking API</strong>
57
+ </li>
58
+ <li id="checkSchedulerTrackingSubscriptionsAPI" data-value="...">
59
+ <strong>Test tracking subscriptions API</strong>
60
+ </li>
61
+ <li id="checkEndToEndIntegration" data-value="...">
62
+ <strong>Test end-to-end integration</strong>
63
+ </li>
64
+ </ol>
65
+ <!-- Load the tracking API before react to test that it's lazily evaluated -->
66
+ <script src="../../build/node_modules/react-scheduler/umd/react-scheduler.js"></script>
67
+ <script src="../../build/node_modules/react-scheduler/umd/react-scheduler-tracking.js"></script>
68
+ <script src="../../build/node_modules/react/umd/react.development.js"></script>
69
+ <script src="../../build/node_modules/react-dom/umd/react-dom.development.js"></script>
70
+ <script src="./script.js"></script>
71
+ </body>
72
+</html>
fixtures/tracking/script.js
new
+208
@@ -0,0 +1,208 @@
1
+function runTest(listItem, callback) {
2
+ try {
3
+ callback();
4
+ listItem.className = 'correct';
5
+ listItem.setAttribute('data-value', 'All checks pass');
6
+ } catch (error) {
7
+ listItem.className = 'incorrect';
8
+ listItem.setAttribute('data-value', error);
9
+ }
10
+}
11
+
12
+function runAllTests() {
13
+ try {
14
+ checkSchedulerAPI();
15
+ } finally {
16
+ try {
17
+ checkSchedulerTrackingAPI();
18
+ } finally {
19
+ try {
20
+ checkSchedulerTrackingSubscriptionsAPI();
21
+ } finally {
22
+ checkEndToEndIntegration();
23
+ }
24
+ }
25
+ }
26
+}
27
+
28
+function checkSchedulerAPI() {
29
+ runTest(document.getElementById('checkSchedulerAPI'), () => {
30
+ if (
31
+ typeof ReactScheduler === 'undefined' ||
32
+ typeof ReactScheduler.unstable_now !== 'function' ||
33
+ typeof ReactScheduler.unstable_scheduleWork !== 'function' ||
34
+ typeof ReactScheduler.unstable_cancelScheduledWork !== 'function'
35
+ ) {
36
+ throw 'API is not defined';
37
+ }
38
+
39
+ if (ReactScheduler.unstable_now() !== performance.now()) {
40
+ throw 'API does not work';
41
+ }
42
+
43
+ // There is no real way to verify that the two APIs are connected.
44
+ });
45
+}
46
+
47
+function checkSchedulerTrackingAPI() {
48
+ runTest(document.getElementById('checkSchedulerTrackingAPI'), () => {
49
+ if (
50
+ typeof ReactSchedulerTracking === 'undefined' ||
51
+ typeof ReactSchedulerTracking.__getInteractionsRef !== 'function' ||
52
+ typeof ReactSchedulerTracking.__getSubscriberRef !== 'function' ||
53
+ typeof ReactSchedulerTracking.unstable_clear !== 'function' ||
54
+ typeof ReactSchedulerTracking.unstable_getCurrent !== 'function' ||
55
+ typeof ReactSchedulerTracking.unstable_getThreadID !== 'function' ||
56
+ typeof ReactSchedulerTracking.unstable_track !== 'function' ||
57
+ typeof ReactSchedulerTracking.unstable_wrap !== 'function'
58
+ ) {
59
+ throw 'API is not defined';
60
+ }
61
+
62
+ try {
63
+ let interactionsSet;
64
+ ReactSchedulerTracking.unstable_track('test', 123, () => {
65
+ interactionsSet = ReactSchedulerTracking.__getInteractionsRef().current;
66
+ });
67
+ if (interactionsSet.size !== 1) {
68
+ throw null;
69
+ }
70
+ const interaction = Array.from(interactionsSet)[0];
71
+ if (interaction.name !== 'test' || interaction.timestamp !== 123) {
72
+ throw null;
73
+ }
74
+ } catch (error) {
75
+ throw 'API does not work';
76
+ }
77
+
78
+ const ForwardedSchedulerTracking =
79
+ React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
80
+ .SchedulerTracking;
81
+
82
+ if (
83
+ ReactSchedulerTracking.unstable_getThreadID() ===
84
+ ForwardedSchedulerTracking.unstable_getThreadID()
85
+ ) {
86
+ throw 'API forwarding is broken';
87
+ }
88
+ });
89
+}
90
+
91
+function checkSchedulerTrackingSubscriptionsAPI() {
92
+ runTest(
93
+ document.getElementById('checkSchedulerTrackingSubscriptionsAPI'),
94
+ () => {
95
+ if (
96
+ typeof ReactSchedulerTracking === 'undefined' ||
97
+ typeof ReactSchedulerTracking.unstable_subscribe !== 'function' ||
98
+ typeof ReactSchedulerTracking.unstable_unsubscribe !== 'function'
99
+ ) {
100
+ throw 'API is not defined';
101
+ }
102
+
103
+ const onInteractionScheduledWorkCompletedCalls = [];
104
+ const onInteractionTrackedCalls = [];
105
+ const onWorkCanceledCalls = [];
106
+ const onWorkScheduledCalls = [];
107
+ const onWorkStartedCalls = [];
108
+ const onWorkStoppedCalls = [];
109
+ const subscriber = {
110
+ onInteractionScheduledWorkCompleted: (...args) =>
111
+ onInteractionScheduledWorkCompletedCalls.push(args),
112
+ onInteractionTracked: (...args) => onInteractionTrackedCalls.push(args),
113
+ onWorkCanceled: (...args) => onWorkCanceledCalls.push(args),
114
+ onWorkScheduled: (...args) => onWorkScheduledCalls.push(args),
115
+ onWorkStarted: (...args) => onWorkStartedCalls.push(args),
116
+ onWorkStopped: (...args) => onWorkStoppedCalls.push(args),
117
+ };
118
+
119
+ try {
120
+ ReactSchedulerTracking.unstable_subscribe(subscriber);
121
+ ReactSchedulerTracking.unstable_track('foo', 123, () => {});
122
+ ReactSchedulerTracking.unstable_unsubscribe(subscriber);
123
+ if (onInteractionTrackedCalls.length !== 1) {
124
+ throw null;
125
+ }
126
+ const interaction = onInteractionTrackedCalls[0][0];
127
+ if (interaction.name !== 'foo' || interaction.timestamp !== 123) {
128
+ throw null;
129
+ }
130
+ ReactSchedulerTracking.unstable_track('bar', 456, () => {});
131
+ if (onInteractionTrackedCalls.length !== 1) {
132
+ throw null;
133
+ }
134
+ } catch (error) {
135
+ throw 'API does not forward methods';
136
+ }
137
+
138
+ const ForwardedSchedulerTracking =
139
+ React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
140
+ .SchedulerTracking;
141
+
142
+ try {
143
+ ForwardedSchedulerTracking.unstable_subscribe(subscriber);
144
+ ReactSchedulerTracking.unstable_track('foo', 123, () => {});
145
+ ForwardedSchedulerTracking.unstable_track('bar', 456, () => {});
146
+ ReactSchedulerTracking.unstable_unsubscribe(subscriber);
147
+ if (onInteractionTrackedCalls.length !== 3) {
148
+ throw null;
149
+ }
150
+ const interactionFoo = onInteractionTrackedCalls[1][0];
151
+ const interactionBar = onInteractionTrackedCalls[2][0];
152
+ if (
153
+ interactionFoo.name !== 'foo' ||
154
+ interactionFoo.timestamp !== 123 ||
155
+ interactionBar.name !== 'bar' ||
156
+ interactionBar.timestamp !== 456
157
+ ) {
158
+ throw null;
159
+ }
160
+ ForwardedSchedulerTracking.unstable_track('baz', 789, () => {});
161
+ if (onInteractionTrackedCalls.length !== 3) {
162
+ throw null;
163
+ }
164
+ } catch (error) {
165
+ throw 'API forwarding is broken';
166
+ }
167
+ }
168
+ );
169
+}
170
+
171
+function checkEndToEndIntegration() {
172
+ runTest(document.getElementById('checkEndToEndIntegration'), () => {
173
+ try {
174
+ const onRenderCalls = [];
175
+ const onRender = (...args) => onRenderCalls.push(args);
176
+ const container = document.createElement('div');
177
+
178
+ ReactSchedulerTracking.unstable_track('render', 123, () => {
179
+ ReactDOM.render(
180
+ React.createElement(
181
+ React.unstable_Profiler,
182
+ {id: 'profiler', onRender},
183
+ React.createElement('div', null, 'hi')
184
+ ),
185
+ container
186
+ );
187
+ });
188
+
189
+ if (container.textContent !== 'hi') {
190
+ throw null;
191
+ }
192
+
193
+ if (onRenderCalls.length !== 1) {
194
+ throw null;
195
+ }
196
+ const call = onRenderCalls[0];
197
+ if (call.length !== 7) {
198
+ throw null;
199
+ }
200
+ const interaction = Array.from(call[6])[0];
201
+ if (interaction.name !== 'render' || interaction.timestamp !== 123) {
202
+ throw null;
203
+ }
204
+ } catch (error) {
205
+ throw 'End to end integration is broken';
206
+ }
207
+ });
208
+}
fixtures/unstable-async/suspense/package.json
+1
-1
@@ -10,10 +10,10 @@
10
"dependencies": {
11
"clipboard": "^1.7.1",
12
"github-fork-ribbon-css": "^0.2.1",
13
- "interaction-tracking": "../../../build/node_modules/interaction-tracking",
13
"react": "../../../build/node_modules/react",
14
"react-dom": "../../../build/node_modules/react-dom",
15
"react-draggable": "^3.0.5",
16
+ "react-scheduler": "../../../build/node_modules/react-scheduler",
17
"simple-cache-provider": "../../../build/node_modules/simple-cache-provider"
18
},
19
"scripts": {
fixtures/unstable-async/suspense/src/components/App.js
+4
-1
@@ -1,5 +1,8 @@
1
-import {track, wrap} from 'interaction-tracking';
1
import React, {Placeholder, PureComponent} from 'react';
2
+import {
3
+ unstable_track as track,
4
+ unstable_wrap as wrap,
5
+} from 'react-scheduler/tracking';
6
import {createResource} from 'simple-cache-provider';
7
import {cache} from '../cache';
8
import Spinner from './Spinner';
fixtures/unstable-async/suspense/src/index.js
+1
-1
@@ -1,6 +1,6 @@
1
-import {track} from 'interaction-tracking';
1
import React, {Fragment, PureComponent} from 'react';
2
import {unstable_createRoot, render} from 'react-dom';
3
+import {unstable_track as track} from 'react-scheduler/tracking';
4
import {cache} from './cache';
5
import {
6
setFakeRequestTime,
fixtures/unstable-async/suspense/yarn.lock
+24
-6
@@ -3482,9 +3482,6 @@ inquirer@3.3.0, inquirer@^3.0.6:
3482
strip-ansi "^4.0.0"
3483
through "^2.3.6"
3484
3485
-interaction-tracking@../../../build/node_modules/interaction-tracking:
3486
- version "0.0.1"
3487
-
3485
internal-ip@1.2.0:
3486
version "1.2.0"
3487
resolved "https://registry.yarnpkg.com/internal-ip/-/internal-ip-1.2.0.tgz#ae9fbf93b984878785d50a8de1b356956058cf5c"
@@ -4102,6 +4099,10 @@ js-tokens@^3.0.0, js-tokens@^3.0.2:
4099
version "3.0.2"
4100
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
4101
4102
+"js-tokens@^3.0.0 || ^4.0.0":
4103
+ version "4.0.0"
4104
+ resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
4105
+
4106
js-yaml@^3.4.3, js-yaml@^3.7.0, js-yaml@^3.9.1:
4107
version "3.10.0"
4108
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.10.0.tgz#2e78441646bd4682e963f22b6e92823c309c62dc"
@@ -4389,12 +4390,18 @@ longest@^1.0.1:
4390
version "1.0.1"
4391
resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097"
4392
4392
-loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.3.1:
4393
+loose-envify@^1.0.0, loose-envify@^1.3.1:
4394
version "1.3.1"
4395
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848"
4396
dependencies:
4397
js-tokens "^3.0.0"
4398
4399
+loose-envify@^1.1.0:
4400
+ version "1.4.0"
4401
+ resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
4402
+ dependencies:
4403
+ js-tokens "^3.0.0 || ^4.0.0"
4404
+
4405
loud-rejection@^1.0.0:
4406
version "1.6.0"
4407
resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f"
@@ -5720,11 +5727,12 @@ react-dev-utils@^5.0.1:
5727
text-table "0.2.0"
5728
5729
react-dom@../../../build/node_modules/react-dom:
5723
- version "16.4.1"
5730
+ version "16.4.3-alpha.0"
5731
dependencies:
5732
loose-envify "^1.1.0"
5733
object-assign "^4.1.1"
5734
prop-types "^15.6.2"
5735
+ react-scheduler "^0.1.0-alpha-1"
5736
5737
react-draggable@^3.0.5:
5738
version "3.0.5"
@@ -5737,6 +5745,15 @@ react-error-overlay@^4.0.0:
5745
version "4.0.0"
5746
resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-4.0.0.tgz#d198408a85b4070937a98667f500c832f86bd5d4"
5747
5748
+react-scheduler@../../../build/node_modules/react-scheduler:
5749
+ version "0.1.0-alpha-1"
5750
+ dependencies:
5751
+ object-assign "^4.1.1"
5752
+
5753
+react-scheduler@^0.1.0-alpha-1:
5754
+ version "0.1.0"
5755
+ resolved "https://registry.yarnpkg.com/react-scheduler/-/react-scheduler-0.1.0.tgz#d16c0ee90d2895ff1941e0d681293dbe4f4b4f38"
5756
+
5757
react-scripts@^1.1.4:
5758
version "1.1.4"
5759
resolved "https://registry.yarnpkg.com/react-scripts/-/react-scripts-1.1.4.tgz#d5c230e707918d6dd2d06f303b10f5222d017c88"
@@ -5783,11 +5800,12 @@ react-scripts@^1.1.4:
5800
fsevents "^1.1.3"
5801
5802
react@../../../build/node_modules/react:
5786
- version "16.4.1"
5803
+ version "16.4.3-alpha.0"
5804
dependencies:
5805
loose-envify "^1.1.0"
5806
object-assign "^4.1.1"
5807
prop-types "^15.6.2"
5808
+ react-scheduler "^0.1.0-alpha-1"
5809
5810
read-pkg-up@^1.0.1:
5811
version "1.0.1"
packages/interaction-tracking/README.md
packages/interaction-tracking/index.js
deleted
-12
@@ -1,12 +0,0 @@
1
-/**
2
- * Copyright (c) 2013-present, Facebook, Inc.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @flow
8
- */
9
-
10
-'use strict';
11
-
12
-export * from './src/InteractionTracking';
packages/interaction-tracking/npm/index.js
deleted
-7
@@ -1,7 +0,0 @@
1
-'use strict';
2
-
3
-if (process.env.NODE_ENV === 'production') {
4
- module.exports = require('./cjs/interaction-tracking.production.min.js');
5
-} else {
6
- module.exports = require('./cjs/interaction-tracking.development.js');
7
-}
packages/interaction-tracking/package.json
deleted
-24
@@ -1,24 +0,0 @@
1
-{
2
- "name": "interaction-tracking",
3
- "description": "utility for tracking interaction events",
4
- "version": "0.0.1",
5
- "license": "MIT",
6
- "files": [
7
- "LICENSE",
8
- "README.md",
9
- "index.js",
10
- "subscriptions.js",
11
- "cjs/",
12
- "umd/"
13
- ],
14
- "keywords": [
15
- "interaction",
16
- "tracking",
17
- "react"
18
- ],
19
- "repository": "https://github.com/facebook/react",
20
- "bugs": {
21
- "url": "https://github.com/facebook/react/issues"
22
- },
23
- "homepage": "https://reactjs.org/"
24
-}
packages/react-art/package.json
+2
-1
@@ -22,7 +22,8 @@
22
"create-react-class": "^15.6.2",
23
"loose-envify": "^1.1.0",
24
"object-assign": "^4.1.1",
25
- "prop-types": "^15.6.2"
25
+ "prop-types": "^15.6.2",
26
+ "react-scheduler": "^0.1.0-alpha-1"
27
},
28
"peerDependencies": {
29
"react": "^16.0.0"
packages/react-art/src/ReactARTHostConfig.js
+5
-6
@@ -5,7 +5,11 @@
5
* LICENSE file in the root directory of this source tree.
6
*/
7
8
-import * as ReactScheduler from 'shared/ReactScheduler';
8
+export {
9
+ unstable_now as now,
10
+ unstable_scheduleWork as scheduleDeferredCallback,
11
+ unstable_cancelScheduledWork as cancelDeferredCallback,
12
+} from 'react-scheduler';
13
import Transform from 'art/core/transform';
14
import Mode from 'art/modes/current';
15
import invariant from 'shared/invariant';
@@ -329,9 +333,6 @@ export function getChildHostContext() {
333
return NO_CONTEXT;
334
}
335
332
-export const scheduleDeferredCallback = ReactScheduler.scheduleWork;
333
-export const cancelDeferredCallback = ReactScheduler.cancelScheduledWork;
334
-
336
export const scheduleTimeout = setTimeout;
337
export const cancelTimeout = clearTimeout;
338
export const noTimeout = -1;
@@ -342,8 +343,6 @@ export function shouldSetTextContent(type, props) {
343
);
344
}
345
345
-export const now = ReactScheduler.now;
346
-
346
// The ART renderer is secondary to the React DOM renderer.
347
export const isPrimaryRenderer = false;
348
packages/react-dom/package.json
+2
-1
@@ -15,7 +15,8 @@
15
"dependencies": {
16
"loose-envify": "^1.1.0",
17
"object-assign": "^4.1.1",
18
- "prop-types": "^15.6.2"
18
+ "prop-types": "^15.6.2",
19
+ "react-scheduler": "^0.1.0-alpha-1"
20
},
21
"peerDependencies": {
22
"react": "^16.0.0"
packages/react-dom/src/client/ReactDOMHostConfig.js
+4
-4
@@ -61,10 +61,10 @@ export type TimeoutHandle = TimeoutID;
61
export type NoTimeout = -1;
62
63
export {
64
- now,
65
- scheduleWork as scheduleDeferredCallback,
66
- cancelScheduledWork as cancelDeferredCallback,
67
-} from 'shared/ReactScheduler';
64
+ unstable_now as now,
65
+ unstable_scheduleWork as scheduleDeferredCallback,
66
+ unstable_cancelScheduledWork as cancelDeferredCallback,
67
+} from 'react-scheduler';
68
69
let SUPPRESS_HYDRATION_WARNING;
70
if (__DEV__) {
packages/react-native-renderer/package.json
+2
-1
@@ -5,7 +5,8 @@
5
"repository": "facebook/react",
6
"dependencies": {
7
"object-assign": "^4.1.1",
8
- "prop-types": "^15.6.2"
8
+ "prop-types": "^15.6.2",
9
+ "react-scheduler": "^0.1.0-alpha-1"
10
},
11
"peerDependencies": {
12
"react": "^16.0.0"
packages/react-reconciler/package.json
+2
-1
@@ -27,7 +27,8 @@
27
"dependencies": {
28
"loose-envify": "^1.1.0",
29
"object-assign": "^4.1.1",
30
- "prop-types": "^15.6.2"
30
+ "prop-types": "^15.6.2",
31
+ "react-scheduler": "^0.1.0-alpha-1"
32
},
33
"browserify": {
34
"transform": [
packages/react-reconciler/src/ReactFiberCommitWork.js
+2
-2
@@ -20,7 +20,7 @@ import type {ExpirationTime} from './ReactFiberExpirationTime';
20
import type {CapturedValue, CapturedError} from './ReactCapturedValue';
21
22
import {
23
- enableInteractionTracking,
23
+ enableSchedulerTracking,
24
enableProfilerTimer,
25
enableSuspense,
26
} from 'shared/ReactFeatureFlags';
@@ -845,7 +845,7 @@ function commitWork(
845
if (enableProfilerTimer) {
846
const onRender = finishedWork.memoizedProps.onRender;
847
848
- if (enableInteractionTracking) {
848
+ if (enableSchedulerTracking) {
849
onRender(
850
finishedWork.memoizedProps.id,
851
current === null ? 'mount' : 'update',
packages/react-reconciler/src/ReactFiberRoot.js
+10
-10
@@ -10,13 +10,13 @@
10
import type {Fiber} from './ReactFiber';
11
import type {ExpirationTime} from './ReactFiberExpirationTime';
12
import type {TimeoutHandle, NoTimeout} from './ReactFiberHostConfig';
13
-import type {Interaction} from 'interaction-tracking/src/InteractionTracking';
13
+import type {Interaction} from 'react-scheduler/src/Tracking';
14
15
import {noTimeout} from './ReactFiberHostConfig';
16
import {createHostRootFiber} from './ReactFiber';
17
import {NoWork} from './ReactFiberExpirationTime';
18
-import {enableInteractionTracking} from 'shared/ReactFeatureFlags';
19
-import {getThreadID} from 'interaction-tracking';
18
+import {enableSchedulerTracking} from 'shared/ReactFeatureFlags';
19
+import {unstable_getThreadID} from 'react-scheduler/tracking';
20
21
// TODO: This should be lifted into the renderer.
22
export type Batch = {
@@ -82,7 +82,7 @@ type BaseFiberRootProperties = {|
82
// The following attributes are only used by interaction tracking builds.
83
// They enable interactions to be associated with their async work,
84
// And expose interaction metadata to the React DevTools Profiler plugin.
85
-// Note that these attributes are only defined when the enableInteractionTracking flag is enabled.
85
+// Note that these attributes are only defined when the enableSchedulerTracking flag is enabled.
86
type ProfilingOnlyFiberRootProperties = {|
87
interactionThreadID: number,
88
memoizedInteractions: Set<Interaction>,
@@ -91,9 +91,9 @@ type ProfilingOnlyFiberRootProperties = {|
91
92
// Exported FiberRoot type includes all properties,
93
// To avoid requiring potentially error-prone :any casts throughout the project.
94
-// Profiling properties are only safe to access in profiling builds (when enableInteractionTracking is true).
94
+// Profiling properties are only safe to access in profiling builds (when enableSchedulerTracking is true).
95
// The types are defined separately within this file to ensure they stay in sync.
96
-// (We don't have to use an inline :any cast when enableInteractionTracking is disabled.)
96
+// (We don't have to use an inline :any cast when enableSchedulerTracking is disabled.)
97
export type FiberRoot = {
98
...BaseFiberRootProperties,
99
...ProfilingOnlyFiberRootProperties,
@@ -109,7 +109,7 @@ export function createFiberRoot(
109
const uninitializedFiber = createHostRootFiber(isAsync);
110
111
let root;
112
- if (enableInteractionTracking) {
112
+ if (enableSchedulerTracking) {
113
root = ({
114
current: uninitializedFiber,
115
containerInfo: containerInfo,
@@ -134,7 +134,7 @@ export function createFiberRoot(
134
firstBatch: null,
135
nextScheduledRoot: null,
136
137
- interactionThreadID: getThreadID(),
137
+ interactionThreadID: unstable_getThreadID(),
138
memoizedInteractions: new Set(),
139
pendingInteractionMap: new Map(),
140
}: FiberRoot);
@@ -168,8 +168,8 @@ export function createFiberRoot(
168
uninitializedFiber.stateNode = root;
169
170
// The reason for the way the Flow types are structured in this file,
171
- // Is to avoid needing :any casts everywhere interaction-tracking fields are used.
172
- // Unfortunately that requires an :any cast for non-interaction-tracking capable builds.
171
+ // Is to avoid needing :any casts everywhere interaction tracking fields are used.
172
+ // Unfortunately that requires an :any cast for non-interaction tracking capable builds.
173
// $FlowFixMe Remove this :any cast and replace it with something better.
174
return ((root: any): FiberRoot);
175
}
packages/react-reconciler/src/ReactFiberScheduler.js
+41
-27
@@ -10,9 +10,16 @@
10
import type {Fiber} from './ReactFiber';
11
import type {Batch, FiberRoot} from './ReactFiberRoot';
12
import type {ExpirationTime} from './ReactFiberExpirationTime';
13
-import type {Interaction} from 'interaction-tracking/src/InteractionTracking';
13
+import type {
14
+ Interaction,
15
+ InteractionsRef,
16
+ SubscriberRef,
17
+} from 'react-scheduler/src/Tracking';
18
15
-import {__interactionsRef, __subscriberRef} from 'interaction-tracking';
19
+import {
20
+ __getInteractionsRef,
21
+ __getSubscriberRef,
22
+} from 'react-scheduler/tracking';
23
import {
24
invokeGuardedCallback,
25
hasCaughtError,
@@ -44,7 +51,7 @@ import {
51
HostPortal,
52
} from 'shared/ReactWorkTags';
53
import {
47
- enableInteractionTracking,
54
+ enableSchedulerTracking,
55
enableProfilerTimer,
56
enableUserTimingAPI,
57
replayFailedUnitOfWorkWithInvokeGuardedCallback,
@@ -162,6 +169,13 @@ export type Thenable = {
169
170
const {ReactCurrentOwner} = ReactSharedInternals;
171
172
+let interactionsRef: InteractionsRef = (null: any);
173
+let subscriberRef: SubscriberRef = (null: any);
174
+if (enableSchedulerTracking) {
175
+ interactionsRef = __getInteractionsRef();
176
+ subscriberRef = __getSubscriberRef();
177
+}
178
+
179
let didWarnAboutStateTransition;
180
let didWarnSetStateChildContext;
181
let warnAboutUpdateOnUnmounted;
@@ -553,14 +567,14 @@ function commitRoot(root: FiberRoot, finishedWork: Fiber): void {
567
markCommittedPriorityLevels(root, earliestRemainingTimeBeforeCommit);
568
569
let prevInteractions: Set<Interaction> = (null: any);
556
- let committedInteractions: Array<Interaction> = enableInteractionTracking
570
+ let committedInteractions: Array<Interaction> = enableSchedulerTracking
571
? []
572
: (null: any);
559
- if (enableInteractionTracking) {
573
+ if (enableSchedulerTracking) {
574
// Restore any pending interactions at this point,
575
// So that cascading work triggered during the render phase will be accounted for.
562
- prevInteractions = __interactionsRef.current;
563
- __interactionsRef.current = root.memoizedInteractions;
576
+ prevInteractions = interactionsRef.current;
577
+ interactionsRef.current = root.memoizedInteractions;
578
579
// We are potentially finished with the current batch of interactions.
580
// So we should clear them out of the pending interaction map.
@@ -754,13 +768,13 @@ function commitRoot(root: FiberRoot, finishedWork: Fiber): void {
768
}
769
onCommit(root, earliestRemainingTimeAfterCommit);
770
757
- if (enableInteractionTracking) {
758
- __interactionsRef.current = prevInteractions;
771
+ if (enableSchedulerTracking) {
772
+ interactionsRef.current = prevInteractions;
773
774
let subscriber;
775
776
try {
763
- subscriber = __subscriberRef.current;
777
+ subscriber = subscriberRef.current;
778
if (subscriber !== null && root.memoizedInteractions.size > 0) {
779
const threadID = computeThreadID(
780
committedExpirationTime,
@@ -1162,11 +1176,11 @@ function renderRoot(
1176
const expirationTime = root.nextExpirationTimeToWorkOn;
1177
1178
let prevInteractions: Set<Interaction> = (null: any);
1165
- if (enableInteractionTracking) {
1179
+ if (enableSchedulerTracking) {
1180
// We're about to start new tracked work.
1181
// Restore pending interactions so cascading work triggered during the render phase will be accounted for.
1168
- prevInteractions = __interactionsRef.current;
1169
- __interactionsRef.current = root.memoizedInteractions;
1182
+ prevInteractions = interactionsRef.current;
1183
+ interactionsRef.current = root.memoizedInteractions;
1184
}
1185
1186
// Check if we're starting from a fresh stack, or if we're resuming from
@@ -1187,7 +1201,7 @@ function renderRoot(
1201
);
1202
root.pendingCommitExpirationTime = NoWork;
1203
1190
- if (enableInteractionTracking) {
1204
+ if (enableSchedulerTracking) {
1205
// Determine which interactions this batch of work currently includes,
1206
// So that we can accurately attribute time spent working on it,
1207
// And so that cascading work triggered during the render phase will be associated with it.
@@ -1209,7 +1223,7 @@ function renderRoot(
1223
root.memoizedInteractions = interactions;
1224
1225
if (interactions.size > 0) {
1212
- const subscriber = __subscriberRef.current;
1226
+ const subscriber = subscriberRef.current;
1227
if (subscriber !== null) {
1228
const threadID = computeThreadID(
1229
expirationTime,
@@ -1218,7 +1232,7 @@ function renderRoot(
1232
try {
1233
subscriber.onWorkStarted(interactions, threadID);
1234
} catch (error) {
1221
- // Work thrown by a interaction-tracking subscriber should be rethrown,
1235
+ // Work thrown by an interaction tracking subscriber should be rethrown,
1236
// But only once it's safe (to avoid leaveing the scheduler in an invalid state).
1237
// Store the error for now and we'll re-throw in finishRendering().
1238
if (!hasUnhandledError) {
@@ -1292,9 +1306,9 @@ function renderRoot(
1306
break;
1307
} while (true);
1308
1295
- if (enableInteractionTracking) {
1309
+ if (enableSchedulerTracking) {
1310
// Tracked work is done for now; restore the previous interactions.
1297
- __interactionsRef.current = prevInteractions;
1311
+ interactionsRef.current = prevInteractions;
1312
}
1313
1314
// We're done performing work. Time to clean up.
@@ -1601,15 +1615,15 @@ function retrySuspendedRoot(
1615
scheduleWorkToRoot(fiber, retryTime);
1616
const rootExpirationTime = root.expirationTime;
1617
if (rootExpirationTime !== NoWork) {
1604
- if (enableInteractionTracking) {
1618
+ if (enableSchedulerTracking) {
1619
// Restore previous interactions so that new work is associated with them.
1606
- let prevInteractions = __interactionsRef.current;
1607
- __interactionsRef.current = root.memoizedInteractions;
1620
+ let prevInteractions = interactionsRef.current;
1621
+ interactionsRef.current = root.memoizedInteractions;
1622
// Because suspense timeouts do not decrement the interaction count,
1623
// Continued suspense work should also not increment the count.
1624
storeInteractionsForExpirationTime(root, rootExpirationTime, false);
1625
requestWork(root, rootExpirationTime);
1612
- __interactionsRef.current = prevInteractions;
1626
+ interactionsRef.current = prevInteractions;
1627
} else {
1628
requestWork(root, rootExpirationTime);
1629
}
@@ -1672,11 +1686,11 @@ function storeInteractionsForExpirationTime(
1686
expirationTime: ExpirationTime,
1687
updateInteractionCounts: boolean,
1688
): void {
1675
- if (!enableInteractionTracking) {
1689
+ if (!enableSchedulerTracking) {
1690
return;
1691
}
1692
1679
- const interactions = __interactionsRef.current;
1693
+ const interactions = interactionsRef.current;
1694
if (interactions.size > 0) {
1695
const pendingInteractions = root.pendingInteractionMap.get(expirationTime);
1696
if (pendingInteractions != null) {
@@ -1699,7 +1713,7 @@ function storeInteractionsForExpirationTime(
1713
}
1714
}
1715
1702
- const subscriber = __subscriberRef.current;
1716
+ const subscriber = subscriberRef.current;
1717
if (subscriber !== null) {
1718
const threadID = computeThreadID(
1719
expirationTime,
@@ -1731,7 +1745,7 @@ function scheduleWork(fiber: Fiber, expirationTime: ExpirationTime) {
1745
return;
1746
}
1747
1734
- if (enableInteractionTracking) {
1748
+ if (enableSchedulerTracking) {
1749
storeInteractionsForExpirationTime(root, expirationTime, true);
1750
}
1751
@@ -1922,7 +1936,7 @@ function onTimeout(root, finishedWork, suspendedExpirationTime) {
1936
recomputeCurrentRendererTime();
1937
currentSchedulerTime = currentRendererTime;
1938
1925
- if (enableInteractionTracking) {
1939
+ if (enableSchedulerTracking) {
1940
// Don't update pending interaction counts for suspense timeouts,
1941
// Because we know we still need to do more work in this case.
1942
suspenseDidTimeout = true;
packages/react-scheduler/npm/tracking.js
new
+7
@@ -0,0 +1,7 @@
1
+'use strict';
2
+
3
+if (process.env.NODE_ENV === 'production') {
4
+ module.exports = require('./cjs/react-scheduler-tracking.production.min.js');
5
+} else {
6
+ module.exports = require('./cjs/react-scheduler-tracking.development.js');
7
+}
packages/react-scheduler/npm/umd/react-scheduler-tracking.js
new
+95
@@ -0,0 +1,95 @@
1
+/**
2
+ * @license React
3
+ *
4
+ * Copyright (c) 2013-present, Facebook, Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+
10
+'use strict';
11
+
12
+(function(global, factory) {
13
+ typeof exports === 'object' && typeof module !== 'undefined'
14
+ ? (module.exports = factory(require('react')))
15
+ : typeof define === 'function' && define.amd // eslint-disable-line no-undef
16
+ ? define(['react'], factory) // eslint-disable-line no-undef
17
+ : (global.ReactSchedulerTracking = factory(global));
18
+})(this, function(global) {
19
+ function __getInteractionsRef() {
20
+ return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracking.__getInteractionsRef.apply(
21
+ this,
22
+ arguments
23
+ );
24
+ }
25
+
26
+ function __getSubscriberRef() {
27
+ return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracking.__getSubscriberRef.apply(
28
+ this,
29
+ arguments
30
+ );
31
+ }
32
+
33
+ function unstable_clear() {
34
+ return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracking.unstable_clear.apply(
35
+ this,
36
+ arguments
37
+ );
38
+ }
39
+
40
+ function unstable_getCurrent() {
41
+ return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracking.unstable_getCurrent.apply(
42
+ this,
43
+ arguments
44
+ );
45
+ }
46
+
47
+ function unstable_getThreadID() {
48
+ return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracking.unstable_getThreadID.apply(
49
+ this,
50
+ arguments
51
+ );
52
+ }
53
+
54
+ function unstable_subscribe() {
55
+ // eslint-disable-next-line max-len
56
+ return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracking.unstable_subscribe.apply(
57
+ this,
58
+ arguments
59
+ );
60
+ }
61
+
62
+ function unstable_track() {
63
+ return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracking.unstable_track.apply(
64
+ this,
65
+ arguments
66
+ );
67
+ }
68
+
69
+ function unstable_unsubscribe() {
70
+ // eslint-disable-next-line max-len
71
+ return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracking.unstable_unsubscribe.apply(
72
+ this,
73
+ arguments
74
+ );
75
+ }
76
+
77
+ function unstable_wrap() {
78
+ return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracking.unstable_wrap.apply(
79
+ this,
80
+ arguments
81
+ );
82
+ }
83
+
84
+ return Object.freeze({
85
+ __getInteractionsRef: __getInteractionsRef,
86
+ __getSubscriberRef: __getSubscriberRef,
87
+ unstable_clear: unstable_clear,
88
+ unstable_getCurrent: unstable_getCurrent,
89
+ unstable_getThreadID: unstable_getThreadID,
90
+ unstable_subscribe: unstable_subscribe,
91
+ unstable_track: unstable_track,
92
+ unstable_unsubscribe: unstable_unsubscribe,
93
+ unstable_wrap: unstable_wrap,
94
+ });
95
+});
packages/react-scheduler/npm/umd/react-scheduler.js
new
+45
@@ -0,0 +1,45 @@
1
+/**
2
+ * @license React
3
+ *
4
+ * Copyright (c) 2013-present, Facebook, Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+
10
+'use strict';
11
+
12
+(function(global, factory) {
13
+ typeof exports === 'object' && typeof module !== 'undefined'
14
+ ? (module.exports = factory(require('react')))
15
+ : typeof define === 'function' && define.amd // eslint-disable-line no-undef
16
+ ? define(['react'], factory) // eslint-disable-line no-undef
17
+ : (global.ReactScheduler = factory(global));
18
+})(this, function(global) {
19
+ function unstable_now() {
20
+ return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_now.apply(
21
+ this,
22
+ arguments
23
+ );
24
+ }
25
+
26
+ function unstable_scheduleWork() {
27
+ return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_scheduleWork.apply(
28
+ this,
29
+ arguments
30
+ );
31
+ }
32
+
33
+ function unstable_cancelScheduledWork() {
34
+ return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_cancelScheduledWork.apply(
35
+ this,
36
+ arguments
37
+ );
38
+ }
39
+
40
+ return Object.freeze({
41
+ unstable_now: unstable_now,
42
+ unstable_scheduleWork: unstable_scheduleWork,
43
+ unstable_cancelScheduledWork: unstable_cancelScheduledWork,
44
+ });
45
+});
packages/react-scheduler/package.json
+1
@@ -20,6 +20,7 @@
20
"LICENSE",
21
"README.md",
22
"index.js",
23
+ "tracking.js",
24
"cjs/",
25
"umd/"
26
]
packages/react-scheduler/src/ReactScheduler.js
+5
-1
@@ -465,4 +465,8 @@ if (!canUseDOM) {
465
};
466
}
467
468
-export {now, scheduleWork, cancelScheduledWork};
468
+export {
469
+ now as unstable_now,
470
+ scheduleWork as unstable_scheduleWork,
471
+ cancelScheduledWork as unstable_cancelScheduledWork,
472
+};
packages/react-scheduler/src/Tracking.js
renamed
+36
-21
@@ -7,7 +7,7 @@
7
* @flow
8
*/
9
10
-import {enableInteractionTracking} from 'shared/ReactFeatureFlags';
10
+import {enableSchedulerTracking} from 'shared/ReactFeatureFlags';
11
12
export type Interaction = {|
13
__count: number,
@@ -70,7 +70,7 @@ let interactionsRef: InteractionsRef = (null: any);
70
// Listener(s) to notify when interactions begin and end.
71
let subscriberRef: SubscriberRef = (null: any);
72
73
-if (enableInteractionTracking) {
73
+if (enableSchedulerTracking) {
74
interactionsRef = {
75
current: new Set(),
76
};
@@ -81,10 +81,16 @@ if (enableInteractionTracking) {
81
82
// These values are exported for libraries with advanced use cases (i.e. React).
83
// They should not typically be accessed directly.
84
-export {interactionsRef as __interactionsRef, subscriberRef as __subscriberRef};
84
+export function __getInteractionsRef(): InteractionsRef {
85
+ return interactionsRef;
86
+}
87
+
88
+export function __getSubscriberRef(): SubscriberRef {
89
+ return subscriberRef;
90
+}
91
86
-export function clear(callback: Function): any {
87
- if (!enableInteractionTracking) {
92
+export function unstable_clear(callback: Function): any {
93
+ if (!enableSchedulerTracking) {
94
return callback();
95
}
96
@@ -98,25 +104,25 @@ export function clear(callback: Function): any {
104
}
105
}
106
101
-export function getCurrent(): Set<Interaction> | null {
102
- if (!enableInteractionTracking) {
107
+export function unstable_getCurrent(): Set<Interaction> | null {
108
+ if (!enableSchedulerTracking) {
109
return null;
110
} else {
111
return interactionsRef.current;
112
}
113
}
114
109
-export function getThreadID(): number {
115
+export function unstable_getThreadID(): number {
116
return ++threadIDCounter;
117
}
118
113
-export function track(
119
+export function unstable_track(
120
name: string,
121
timestamp: number,
122
callback: Function,
123
threadID: number = DEFAULT_THREAD_ID,
124
): any {
119
- if (!enableInteractionTracking) {
125
+ if (!enableSchedulerTracking) {
126
return callback();
127
}
128
@@ -174,11 +180,11 @@ export function track(
180
return returnValue;
181
}
182
177
-export function wrap(
183
+export function unstable_wrap(
184
callback: Function,
185
threadID: number = DEFAULT_THREAD_ID,
186
): Function {
181
- if (!enableInteractionTracking) {
187
+ if (!enableSchedulerTracking) {
188
return callback;
189
}
190
@@ -195,6 +201,8 @@ export function wrap(
201
interaction.__count++;
202
});
203
204
+ let hasRun = false;
205
+
206
function wrapped() {
207
const prevInteractions = interactionsRef.current;
208
interactionsRef.current = wrappedInteractions;
@@ -222,16 +230,23 @@ export function wrap(
230
231
return returnValue;
232
} finally {
225
- // Update pending async counts for all wrapped interactions.
226
- // If this was the last scheduled async work for any of them,
227
- // Mark them as completed.
228
- wrappedInteractions.forEach(interaction => {
229
- interaction.__count--;
233
+ if (!hasRun) {
234
+ // We only expect a wrapped function to be executed once,
235
+ // But in the event that it's executed more than once–
236
+ // Only decrement the outstanding interaction counts once.
237
+ hasRun = true;
238
+
239
+ // Update pending async counts for all wrapped interactions.
240
+ // If this was the last scheduled async work for any of them,
241
+ // Mark them as completed.
242
+ wrappedInteractions.forEach(interaction => {
243
+ interaction.__count--;
244
231
- if (subscriber !== null && interaction.__count === 0) {
232
- subscriber.onInteractionScheduledWorkCompleted(interaction);
233
- }
234
- });
245
+ if (subscriber !== null && interaction.__count === 0) {
246
+ subscriber.onInteractionScheduledWorkCompleted(interaction);
247
+ }
248
+ });
249
+ }
250
}
251
}
252
packages/react-scheduler/src/TrackingSubscriptions.js
renamed
+25
-19
@@ -7,25 +7,42 @@
7
* @flow
8
*/
9
10
-import type {Interaction, Subscriber} from './InteractionTracking';
10
+import type {Interaction, Subscriber, SubscriberRef} from './Tracking';
11
12
-import {enableInteractionTracking} from 'shared/ReactFeatureFlags';
13
-import {__subscriberRef} from 'interaction-tracking';
12
+import {enableSchedulerTracking} from 'shared/ReactFeatureFlags';
13
+import {__getSubscriberRef} from 'react-scheduler/tracking';
14
15
+let subscriberRef: SubscriberRef = (null: any);
16
let subscribers: Set<Subscriber> = (null: any);
16
-if (enableInteractionTracking) {
17
+if (enableSchedulerTracking) {
18
+ subscriberRef = __getSubscriberRef();
19
subscribers = new Set();
20
}
21
20
-export function subscribe(subscriber: Subscriber): void {
21
- if (enableInteractionTracking) {
22
+export function unstable_subscribe(subscriber: Subscriber): void {
23
+ if (enableSchedulerTracking) {
24
subscribers.add(subscriber);
25
+
26
+ if (subscribers.size === 1) {
27
+ subscriberRef.current = {
28
+ onInteractionScheduledWorkCompleted,
29
+ onInteractionTracked,
30
+ onWorkCanceled,
31
+ onWorkScheduled,
32
+ onWorkStarted,
33
+ onWorkStopped,
34
+ };
35
+ }
36
}
37
}
38
26
-export function unsubscribe(subscriber: Subscriber): void {
27
- if (enableInteractionTracking) {
39
+export function unstable_unsubscribe(subscriber: Subscriber): void {
40
+ if (enableSchedulerTracking) {
41
subscribers.delete(subscriber);
42
+
43
+ if (subscribers.size === 0) {
44
+ subscriberRef.current = null;
45
+ }
46
}
47
}
48
@@ -154,14 +171,3 @@ function onWorkCanceled(
171
throw caughtError;
172
}
173
}
157
-
158
-if (enableInteractionTracking) {
159
- __subscriberRef.current = {
160
- onInteractionScheduledWorkCompleted,
161
- onInteractionTracked,
162
- onWorkCanceled,
163
- onWorkScheduled,
164
- onWorkStarted,
165
- onWorkStopped,
166
- };
167
-}
packages/react-scheduler/src/__tests__/ReactScheduler-test.js
+25
-16
@@ -99,7 +99,7 @@ describe('ReactScheduler', () => {
99
100
describe('scheduleWork', () => {
101
it('calls the callback within the frame when not blocked', () => {
102
- const {scheduleWork} = ReactScheduler;
102
+ const {unstable_scheduleWork: scheduleWork} = ReactScheduler;
103
const cb = jest.fn();
104
scheduleWork(cb);
105
advanceOneFrame({timeLeftInFrame: 15});
@@ -111,7 +111,7 @@ describe('ReactScheduler', () => {
111
112
describe('with multiple callbacks', () => {
113
it('accepts multiple callbacks and calls within frame when not blocked', () => {
114
- const {scheduleWork} = ReactScheduler;
114
+ const {unstable_scheduleWork: scheduleWork} = ReactScheduler;
115
const callbackLog = [];
116
const callbackA = jest.fn(() => callbackLog.push('A'));
117
const callbackB = jest.fn(() => callbackLog.push('B'));
@@ -137,7 +137,7 @@ describe('ReactScheduler', () => {
137
});
138
139
it("accepts callbacks betweeen animationFrame and postMessage and doesn't stall", () => {
140
- const {scheduleWork} = ReactScheduler;
140
+ const {unstable_scheduleWork: scheduleWork} = ReactScheduler;
141
const callbackLog = [];
142
const callbackA = jest.fn(() => callbackLog.push('A'));
143
const callbackB = jest.fn(() => callbackLog.push('B'));
@@ -167,7 +167,7 @@ describe('ReactScheduler', () => {
167
'schedules callbacks in correct order and' +
168
'keeps calling them if there is time',
169
() => {
170
- const {scheduleWork} = ReactScheduler;
170
+ const {unstable_scheduleWork: scheduleWork} = ReactScheduler;
171
const callbackLog = [];
172
const callbackA = jest.fn(() => {
173
callbackLog.push('A');
@@ -194,7 +194,7 @@ describe('ReactScheduler', () => {
194
);
195
196
it('schedules callbacks in correct order when callbacks have many nested scheduleWork calls', () => {
197
- const {scheduleWork} = ReactScheduler;
197
+ const {unstable_scheduleWork: scheduleWork} = ReactScheduler;
198
const callbackLog = [];
199
const callbackA = jest.fn(() => {
200
callbackLog.push('A');
@@ -229,7 +229,7 @@ describe('ReactScheduler', () => {
229
});
230
231
it('schedules callbacks in correct order when they use scheduleWork to schedule themselves', () => {
232
- const {scheduleWork} = ReactScheduler;
232
+ const {unstable_scheduleWork: scheduleWork} = ReactScheduler;
233
const callbackLog = [];
234
let callbackAIterations = 0;
235
const callbackA = jest.fn(() => {
@@ -260,7 +260,7 @@ describe('ReactScheduler', () => {
260
261
describe('when there is no more time left in the frame', () => {
262
it('calls any callback which has timed out, waits for others', () => {
263
- const {scheduleWork} = ReactScheduler;
263
+ const {unstable_scheduleWork: scheduleWork} = ReactScheduler;
264
startOfLatestFrame = 1000000000000;
265
currentTime = startOfLatestFrame - 10;
266
const callbackLog = [];
@@ -295,7 +295,7 @@ describe('ReactScheduler', () => {
295
296
describe('when there is some time left in the frame', () => {
297
it('calls timed out callbacks and then any more pending callbacks, defers others if time runs out', () => {
298
- const {scheduleWork} = ReactScheduler;
298
+ const {unstable_scheduleWork: scheduleWork} = ReactScheduler;
299
startOfLatestFrame = 1000000000000;
300
currentTime = startOfLatestFrame - 10;
301
const callbackLog = [];
@@ -343,7 +343,10 @@ describe('ReactScheduler', () => {
343
344
describe('cancelScheduledWork', () => {
345
it('cancels the scheduled callback', () => {
346
- const {scheduleWork, cancelScheduledWork} = ReactScheduler;
346
+ const {
347
+ unstable_scheduleWork: scheduleWork,
348
+ unstable_cancelScheduledWork: cancelScheduledWork,
349
+ } = ReactScheduler;
350
const cb = jest.fn();
351
const callbackId = scheduleWork(cb);
352
expect(cb).toHaveBeenCalledTimes(0);
@@ -354,7 +357,10 @@ describe('ReactScheduler', () => {
357
358
describe('with multiple callbacks', () => {
359
it('when called more than once', () => {
357
- const {scheduleWork, cancelScheduledWork} = ReactScheduler;
360
+ const {
361
+ unstable_scheduleWork: scheduleWork,
362
+ unstable_cancelScheduledWork: cancelScheduledWork,
363
+ } = ReactScheduler;
364
const callbackLog = [];
365
const callbackA = jest.fn(() => callbackLog.push('A'));
366
const callbackB = jest.fn(() => callbackLog.push('B'));
@@ -375,7 +381,10 @@ describe('ReactScheduler', () => {
381
});
382
383
it('when one callback cancels the next one', () => {
378
- const {scheduleWork, cancelScheduledWork} = ReactScheduler;
384
+ const {
385
+ unstable_scheduleWork: scheduleWork,
386
+ unstable_cancelScheduledWork: cancelScheduledWork,
387
+ } = ReactScheduler;
388
const callbackLog = [];
389
let callbackBId;
390
const callbackA = jest.fn(() => {
@@ -412,7 +421,7 @@ describe('ReactScheduler', () => {
421
*
422
*/
423
it('still calls all callbacks within same frame', () => {
415
- const {scheduleWork} = ReactScheduler;
424
+ const {unstable_scheduleWork: scheduleWork} = ReactScheduler;
425
const callbackLog = [];
426
const callbackA = jest.fn(() => callbackLog.push('A'));
427
const callbackB = jest.fn(() => {
@@ -458,7 +467,7 @@ describe('ReactScheduler', () => {
467
*
468
*/
469
it('and with some timed out callbacks, still calls all callbacks within same frame', () => {
461
- const {scheduleWork} = ReactScheduler;
470
+ const {unstable_scheduleWork: scheduleWork} = ReactScheduler;
471
const callbackLog = [];
472
const callbackA = jest.fn(() => {
473
callbackLog.push('A');
@@ -504,7 +513,7 @@ describe('ReactScheduler', () => {
513
*
514
*/
515
it('still calls all callbacks within same frame', () => {
507
- const {scheduleWork} = ReactScheduler;
516
+ const {unstable_scheduleWork: scheduleWork} = ReactScheduler;
517
const callbackLog = [];
518
const callbackA = jest.fn(() => {
519
callbackLog.push('A');
@@ -565,7 +574,7 @@ describe('ReactScheduler', () => {
574
*
575
*/
576
it('and with all timed out callbacks, still calls all callbacks within same frame', () => {
568
- const {scheduleWork} = ReactScheduler;
577
+ const {unstable_scheduleWork: scheduleWork} = ReactScheduler;
578
const callbackLog = [];
579
const callbackA = jest.fn(() => {
580
callbackLog.push('A');
@@ -646,7 +655,7 @@ describe('ReactScheduler', () => {
655
*
656
*/
657
it('still calls all callbacks within same frame', () => {
649
- const {scheduleWork} = ReactScheduler;
658
+ const {unstable_scheduleWork: scheduleWork} = ReactScheduler;
659
startOfLatestFrame = 1000000000000;
660
currentTime = startOfLatestFrame - 10;
661
catchPostMessageErrors = true;
packages/react-scheduler/src/__tests__/Tracking-test.internal.js
renamed
+81
-75
@@ -8,14 +8,14 @@
8
*/
9
'use strict';
10
11
-describe('InteractionTracking', () => {
12
- let InteractionTracking;
11
+describe('Tracking', () => {
12
+ let SchedulerTracking;
13
let ReactFeatureFlags;
14
15
let advanceTimeBy;
16
let currentTime;
17
18
- function loadModules({enableInteractionTracking}) {
18
+ function loadModules({enableSchedulerTracking}) {
19
jest.resetModules();
20
jest.useFakeTimers();
21
@@ -27,36 +27,36 @@ describe('InteractionTracking', () => {
27
};
28
29
ReactFeatureFlags = require('shared/ReactFeatureFlags');
30
- ReactFeatureFlags.enableInteractionTracking = enableInteractionTracking;
30
+ ReactFeatureFlags.enableSchedulerTracking = enableSchedulerTracking;
31
32
- InteractionTracking = require('interaction-tracking');
32
+ SchedulerTracking = require('react-scheduler/tracking');
33
}
34
35
- describe('enableInteractionTracking enabled', () => {
36
- beforeEach(() => loadModules({enableInteractionTracking: true}));
35
+ describe('enableSchedulerTracking enabled', () => {
36
+ beforeEach(() => loadModules({enableSchedulerTracking: true}));
37
38
it('should return the value of a tracked function', () => {
39
expect(
40
- InteractionTracking.track('arbitrary', currentTime, () => 123),
40
+ SchedulerTracking.unstable_track('arbitrary', currentTime, () => 123),
41
).toBe(123);
42
});
43
44
it('should return the value of a clear function', () => {
45
- expect(InteractionTracking.clear(() => 123)).toBe(123);
45
+ expect(SchedulerTracking.unstable_clear(() => 123)).toBe(123);
46
});
47
48
it('should return the value of a wrapped function', () => {
49
let wrapped;
50
- InteractionTracking.track('arbitrary', currentTime, () => {
51
- wrapped = InteractionTracking.wrap(() => 123);
50
+ SchedulerTracking.unstable_track('arbitrary', currentTime, () => {
51
+ wrapped = SchedulerTracking.unstable_wrap(() => 123);
52
});
53
expect(wrapped()).toBe(123);
54
});
55
56
it('should pass arguments through to a wrapped function', done => {
57
let wrapped;
58
- InteractionTracking.track('arbitrary', currentTime, () => {
59
- wrapped = InteractionTracking.wrap((param1, param2) => {
58
+ SchedulerTracking.unstable_track('arbitrary', currentTime, () => {
59
+ wrapped = SchedulerTracking.unstable_wrap((param1, param2) => {
60
expect(param1).toBe('foo');
61
expect(param2).toBe('bar');
62
done();
@@ -66,14 +66,14 @@ describe('InteractionTracking', () => {
66
});
67
68
it('should return an empty set when outside of a tracked event', () => {
69
- expect(InteractionTracking.getCurrent()).toContainNoInteractions();
69
+ expect(SchedulerTracking.unstable_getCurrent()).toContainNoInteractions();
70
});
71
72
it('should report the tracked interaction from within the track callback', done => {
73
advanceTimeBy(100);
74
75
- InteractionTracking.track('some event', currentTime, () => {
76
- const interactions = InteractionTracking.getCurrent();
75
+ SchedulerTracking.unstable_track('some event', currentTime, () => {
76
+ const interactions = SchedulerTracking.unstable_getCurrent();
77
expect(interactions).toMatchInteractions([
78
{name: 'some event', timestamp: 100},
79
]);
@@ -86,7 +86,7 @@ describe('InteractionTracking', () => {
86
let wrappedIndirection;
87
88
function indirection() {
89
- const interactions = InteractionTracking.getCurrent();
89
+ const interactions = SchedulerTracking.unstable_getCurrent();
90
expect(interactions).toMatchInteractions([
91
{name: 'some event', timestamp: 100},
92
]);
@@ -96,8 +96,8 @@ describe('InteractionTracking', () => {
96
97
advanceTimeBy(100);
98
99
- InteractionTracking.track('some event', currentTime, () => {
100
- wrappedIndirection = InteractionTracking.wrap(indirection);
99
+ SchedulerTracking.unstable_track('some event', currentTime, () => {
100
+ wrappedIndirection = SchedulerTracking.unstable_wrap(indirection);
101
});
102
103
advanceTimeBy(50);
@@ -108,24 +108,26 @@ describe('InteractionTracking', () => {
108
it('should clear the interaction stack for tracked callbacks', () => {
109
let innerTestReached = false;
110
111
- InteractionTracking.track('outer event', currentTime, () => {
112
- expect(InteractionTracking.getCurrent()).toMatchInteractions([
111
+ SchedulerTracking.unstable_track('outer event', currentTime, () => {
112
+ expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([
113
{name: 'outer event'},
114
]);
115
116
- InteractionTracking.clear(() => {
117
- expect(InteractionTracking.getCurrent()).toMatchInteractions([]);
116
+ SchedulerTracking.unstable_clear(() => {
117
+ expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions(
118
+ [],
119
+ );
120
119
- InteractionTracking.track('inner event', currentTime, () => {
120
- expect(InteractionTracking.getCurrent()).toMatchInteractions([
121
- {name: 'inner event'},
122
- ]);
121
+ SchedulerTracking.unstable_track('inner event', currentTime, () => {
122
+ expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions(
123
+ [{name: 'inner event'}],
124
+ );
125
126
innerTestReached = true;
127
});
128
});
129
128
- expect(InteractionTracking.getCurrent()).toMatchInteractions([
130
+ expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([
131
{name: 'outer event'},
132
]);
133
});
@@ -138,29 +140,31 @@ describe('InteractionTracking', () => {
140
let wrappedIndirection;
141
142
const indirection = jest.fn(() => {
141
- expect(InteractionTracking.getCurrent()).toMatchInteractions([
143
+ expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([
144
{name: 'outer event'},
145
]);
146
145
- InteractionTracking.clear(() => {
146
- expect(InteractionTracking.getCurrent()).toMatchInteractions([]);
147
+ SchedulerTracking.unstable_clear(() => {
148
+ expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions(
149
+ [],
150
+ );
151
148
- InteractionTracking.track('inner event', currentTime, () => {
149
- expect(InteractionTracking.getCurrent()).toMatchInteractions([
150
- {name: 'inner event'},
151
- ]);
152
+ SchedulerTracking.unstable_track('inner event', currentTime, () => {
153
+ expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions(
154
+ [{name: 'inner event'}],
155
+ );
156
157
innerTestReached = true;
158
});
159
});
160
157
- expect(InteractionTracking.getCurrent()).toMatchInteractions([
161
+ expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([
162
{name: 'outer event'},
163
]);
164
});
165
162
- InteractionTracking.track('outer event', currentTime, () => {
163
- wrappedIndirection = InteractionTracking.wrap(indirection);
166
+ SchedulerTracking.unstable_track('outer event', currentTime, () => {
167
+ wrappedIndirection = SchedulerTracking.unstable_wrap(indirection);
168
});
169
170
wrappedIndirection();
@@ -175,7 +179,7 @@ describe('InteractionTracking', () => {
179
let outerIndirectionTracked = false;
180
181
function innerIndirection() {
178
- const interactions = InteractionTracking.getCurrent();
182
+ const interactions = SchedulerTracking.unstable_getCurrent();
183
expect(interactions).toMatchInteractions([
184
{name: 'outer event', timestamp: 100},
185
{name: 'inner event', timestamp: 150},
@@ -185,7 +189,7 @@ describe('InteractionTracking', () => {
189
}
190
191
function outerIndirection() {
188
- const interactions = InteractionTracking.getCurrent();
192
+ const interactions = SchedulerTracking.unstable_getCurrent();
193
expect(interactions).toMatchInteractions([
194
{name: 'outer event', timestamp: 100},
195
]);
@@ -193,16 +197,16 @@ describe('InteractionTracking', () => {
197
outerIndirectionTracked = true;
198
}
199
196
- InteractionTracking.track('outer event', currentTime, () => {
200
+ SchedulerTracking.unstable_track('outer event', currentTime, () => {
201
// Verify the current tracked event
198
- let interactions = InteractionTracking.getCurrent();
202
+ let interactions = SchedulerTracking.unstable_getCurrent();
203
expect(interactions).toMatchInteractions([
204
{name: 'outer event', timestamp: 100},
205
]);
206
207
advanceTimeBy(50);
208
205
- const wrapperOuterIndirection = InteractionTracking.wrap(
209
+ const wrapperOuterIndirection = SchedulerTracking.unstable_wrap(
210
outerIndirection,
211
);
212
@@ -210,8 +214,8 @@ describe('InteractionTracking', () => {
214
let innerEventTracked = false;
215
216
// Verify that a nested event is properly tracked
213
- InteractionTracking.track('inner event', currentTime, () => {
214
- interactions = InteractionTracking.getCurrent();
217
+ SchedulerTracking.unstable_track('inner event', currentTime, () => {
218
+ interactions = SchedulerTracking.unstable_getCurrent();
219
expect(interactions).toMatchInteractions([
220
{name: 'outer event', timestamp: 100},
221
{name: 'inner event', timestamp: 150},
@@ -221,7 +225,9 @@ describe('InteractionTracking', () => {
225
wrapperOuterIndirection();
226
expect(outerIndirectionTracked).toBe(true);
227
224
- wrapperInnerIndirection = InteractionTracking.wrap(innerIndirection);
228
+ wrapperInnerIndirection = SchedulerTracking.unstable_wrap(
229
+ innerIndirection,
230
+ );
231
232
innerEventTracked = true;
233
});
@@ -229,7 +235,7 @@ describe('InteractionTracking', () => {
235
expect(innerEventTracked).toBe(true);
236
237
// Verify that the original event is restored
232
- interactions = InteractionTracking.getCurrent();
238
+ interactions = SchedulerTracking.unstable_getCurrent();
239
expect(interactions).toMatchInteractions([
240
{name: 'outer event', timestamp: 100},
241
]);
@@ -246,14 +252,14 @@ describe('InteractionTracking', () => {
252
it('should reset state appropriately when an error occurs in a track callback', done => {
253
advanceTimeBy(100);
254
249
- InteractionTracking.track('outer event', currentTime, () => {
255
+ SchedulerTracking.unstable_track('outer event', currentTime, () => {
256
expect(() => {
251
- InteractionTracking.track('inner event', currentTime, () => {
257
+ SchedulerTracking.unstable_track('inner event', currentTime, () => {
258
throw Error('intentional');
259
});
260
}).toThrow();
261
256
- expect(InteractionTracking.getCurrent()).toMatchInteractions([
262
+ expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([
263
{name: 'outer event', timestamp: 100},
264
]);
265
@@ -264,18 +270,18 @@ describe('InteractionTracking', () => {
270
it('should reset state appropriately when an error occurs in a wrapped callback', done => {
271
advanceTimeBy(100);
272
267
- InteractionTracking.track('outer event', currentTime, () => {
273
+ SchedulerTracking.unstable_track('outer event', currentTime, () => {
274
let wrappedCallback;
275
270
- InteractionTracking.track('inner event', currentTime, () => {
271
- wrappedCallback = InteractionTracking.wrap(() => {
276
+ SchedulerTracking.unstable_track('inner event', currentTime, () => {
277
+ wrappedCallback = SchedulerTracking.unstable_wrap(() => {
278
throw Error('intentional');
279
});
280
});
281
282
expect(wrappedCallback).toThrow();
283
278
- expect(InteractionTracking.getCurrent()).toMatchInteractions([
284
+ expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([
285
{name: 'outer event', timestamp: 100},
286
]);
287
@@ -286,30 +292,30 @@ describe('InteractionTracking', () => {
292
293
describe('advanced integration', () => {
294
it('should return a unique threadID per request', () => {
289
- expect(InteractionTracking.getThreadID()).not.toBe(
290
- InteractionTracking.getThreadID(),
295
+ expect(SchedulerTracking.unstable_getThreadID()).not.toBe(
296
+ SchedulerTracking.unstable_getThreadID(),
297
);
298
});
299
300
it('should expose the current set of interactions to be externally manipulated', () => {
295
- InteractionTracking.track('outer event', currentTime, () => {
296
- expect(InteractionTracking.__interactionsRef.current).toBe(
297
- InteractionTracking.getCurrent(),
301
+ SchedulerTracking.unstable_track('outer event', currentTime, () => {
302
+ expect(SchedulerTracking.__getInteractionsRef().current).toBe(
303
+ SchedulerTracking.unstable_getCurrent(),
304
);
305
300
- InteractionTracking.__interactionsRef.current = new Set([
306
+ SchedulerTracking.__getInteractionsRef().current = new Set([
307
{name: 'override event'},
308
]);
309
304
- expect(InteractionTracking.getCurrent()).toMatchInteractions([
310
+ expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([
311
{name: 'override event'},
312
]);
313
});
314
});
315
316
it('should expose a subscriber ref to be externally manipulated', () => {
311
- InteractionTracking.track('outer event', currentTime, () => {
312
- expect(InteractionTracking.__subscriberRef).toEqual({
317
+ SchedulerTracking.unstable_track('outer event', currentTime, () => {
318
+ expect(SchedulerTracking.__getSubscriberRef()).toEqual({
319
current: null,
320
});
321
});
@@ -317,42 +323,42 @@ describe('InteractionTracking', () => {
323
});
324
});
325
320
- describe('enableInteractionTracking disabled', () => {
321
- beforeEach(() => loadModules({enableInteractionTracking: false}));
326
+ describe('enableSchedulerTracking disabled', () => {
327
+ beforeEach(() => loadModules({enableSchedulerTracking: false}));
328
329
it('should return the value of a tracked function', () => {
330
expect(
325
- InteractionTracking.track('arbitrary', currentTime, () => 123),
331
+ SchedulerTracking.unstable_track('arbitrary', currentTime, () => 123),
332
).toBe(123);
333
});
334
335
it('should return the value of a wrapped function', () => {
336
let wrapped;
331
- InteractionTracking.track('arbitrary', currentTime, () => {
332
- wrapped = InteractionTracking.wrap(() => 123);
337
+ SchedulerTracking.unstable_track('arbitrary', currentTime, () => {
338
+ wrapped = SchedulerTracking.unstable_wrap(() => 123);
339
});
340
expect(wrapped()).toBe(123);
341
});
342
343
it('should return null for tracked interactions', () => {
338
- expect(InteractionTracking.getCurrent()).toBe(null);
344
+ expect(SchedulerTracking.unstable_getCurrent()).toBe(null);
345
});
346
347
it('should execute tracked callbacks', done => {
342
- InteractionTracking.track('some event', currentTime, () => {
343
- expect(InteractionTracking.getCurrent()).toBe(null);
348
+ SchedulerTracking.unstable_track('some event', currentTime, () => {
349
+ expect(SchedulerTracking.unstable_getCurrent()).toBe(null);
350
351
done();
352
});
353
});
354
355
it('should return the value of a clear function', () => {
350
- expect(InteractionTracking.clear(() => 123)).toBe(123);
356
+ expect(SchedulerTracking.unstable_clear(() => 123)).toBe(123);
357
});
358
359
it('should execute wrapped callbacks', done => {
354
- const wrappedCallback = InteractionTracking.wrap(() => {
355
- expect(InteractionTracking.getCurrent()).toBe(null);
360
+ const wrappedCallback = SchedulerTracking.unstable_wrap(() => {
361
+ expect(SchedulerTracking.unstable_getCurrent()).toBe(null);
362
363
done();
364
});
@@ -362,7 +368,7 @@ describe('InteractionTracking', () => {
368
369
describe('advanced integration', () => {
370
it('should not create unnecessary objects', () => {
365
- expect(InteractionTracking.__interactionsRef).toBe(null);
371
+ expect(SchedulerTracking.__getInteractionsRef()).toBe(null);
372
});
373
});
374
});
packages/react-scheduler/src/__tests__/Tracking-test.js
new
+51
@@ -0,0 +1,51 @@
1
+/**
2
+ * Copyright (c) 2013-present, Facebook, Inc.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @jest-environment node
8
+ */
9
+'use strict';
10
+
11
+describe('Tracking', () => {
12
+ let SchedulerTracking;
13
+
14
+ beforeEach(() => {
15
+ jest.resetModules();
16
+
17
+ SchedulerTracking = require('react-scheduler/tracking');
18
+ });
19
+
20
+ it('should return the value of a tracked function', () => {
21
+ expect(SchedulerTracking.unstable_track('arbitrary', 0, () => 123)).toBe(
22
+ 123,
23
+ );
24
+ });
25
+
26
+ it('should return the value of a wrapped function', () => {
27
+ let wrapped;
28
+ SchedulerTracking.unstable_track('arbitrary', 0, () => {
29
+ wrapped = SchedulerTracking.unstable_wrap(() => 123);
30
+ });
31
+ expect(wrapped()).toBe(123);
32
+ });
33
+
34
+ it('should execute tracked callbacks', done => {
35
+ SchedulerTracking.unstable_track('some event', 0, () => {
36
+ done();
37
+ });
38
+ });
39
+
40
+ it('should return the value of a clear function', () => {
41
+ expect(SchedulerTracking.unstable_clear(() => 123)).toBe(123);
42
+ });
43
+
44
+ it('should execute wrapped callbacks', done => {
45
+ const wrappedCallback = SchedulerTracking.unstable_wrap(() => {
46
+ done();
47
+ });
48
+
49
+ wrappedCallback();
50
+ });
51
+});
packages/react-scheduler/src/__tests__/TrackingSubscriptions-test.internal.js
renamed
+126
-61
@@ -8,9 +8,8 @@
8
*/
9
'use strict';
10
11
-describe('InteractionTracking', () => {
12
- let InteractionTracking;
13
- let InteractionTrackingSubscriptions;
11
+describe('TrackingSubscriptions', () => {
12
+ let SchedulerTracking;
13
let ReactFeatureFlags;
14
15
let currentTime;
@@ -34,17 +33,16 @@ describe('InteractionTracking', () => {
33
const secondEvent = {id: 1, name: 'second', timestamp: 0};
34
const threadID = 123;
35
37
- function loadModules({enableInteractionTracking}) {
36
+ function loadModules({enableSchedulerTracking, autoSubscribe = true}) {
37
jest.resetModules();
38
jest.useFakeTimers();
39
40
currentTime = 0;
41
42
ReactFeatureFlags = require('shared/ReactFeatureFlags');
44
- ReactFeatureFlags.enableInteractionTracking = enableInteractionTracking;
43
+ ReactFeatureFlags.enableSchedulerTracking = enableSchedulerTracking;
44
46
- InteractionTracking = require('interaction-tracking');
47
- InteractionTrackingSubscriptions = require('interaction-tracking/subscriptions');
45
+ SchedulerTracking = require('react-scheduler/tracking');
46
47
throwInOnInteractionScheduledWorkCompleted = false;
48
throwInOnInteractionTracked = false;
@@ -102,22 +100,38 @@ describe('InteractionTracking', () => {
100
onWorkStopped: jest.fn(),
101
};
102
105
- InteractionTrackingSubscriptions.subscribe(firstSubscriber);
106
- InteractionTrackingSubscriptions.subscribe(secondSubscriber);
103
+ if (autoSubscribe) {
104
+ SchedulerTracking.unstable_subscribe(firstSubscriber);
105
+ SchedulerTracking.unstable_subscribe(secondSubscriber);
106
+ }
107
}
108
109
describe('enabled', () => {
110
- beforeEach(() => loadModules({enableInteractionTracking: true}));
110
+ beforeEach(() => loadModules({enableSchedulerTracking: true}));
111
+
112
+ it('should lazily subscribe to tracking and unsubscribe again if there are no external subscribers', () => {
113
+ loadModules({enableSchedulerTracking: true, autoSubscribe: false});
114
+
115
+ expect(SchedulerTracking.__getSubscriberRef().current).toBe(null);
116
+ SchedulerTracking.unstable_subscribe(firstSubscriber);
117
+ expect(SchedulerTracking.__getSubscriberRef().current).toBeDefined();
118
+ SchedulerTracking.unstable_subscribe(secondSubscriber);
119
+ expect(SchedulerTracking.__getSubscriberRef().current).toBeDefined();
120
+ SchedulerTracking.unstable_unsubscribe(secondSubscriber);
121
+ expect(SchedulerTracking.__getSubscriberRef().current).toBeDefined();
122
+ SchedulerTracking.unstable_unsubscribe(firstSubscriber);
123
+ expect(SchedulerTracking.__getSubscriberRef().current).toBe(null);
124
+ });
125
126
describe('error handling', () => {
127
it('should cover onInteractionTracked/onWorkStarted within', done => {
114
- InteractionTracking.track(firstEvent.name, currentTime, () => {
128
+ SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => {
129
const mock = jest.fn();
130
131
// It should call the callback before re-throwing
132
throwInOnInteractionTracked = true;
133
expect(() =>
120
- InteractionTracking.track(
134
+ SchedulerTracking.unstable_track(
135
secondEvent.name,
136
currentTime,
137
mock,
@@ -129,7 +143,7 @@ describe('InteractionTracking', () => {
143
144
throwInOnWorkStarted = true;
145
expect(() =>
132
- InteractionTracking.track(
146
+ SchedulerTracking.unstable_track(
147
secondEvent.name,
148
currentTime,
149
mock,
@@ -139,7 +153,7 @@ describe('InteractionTracking', () => {
153
expect(mock).toHaveBeenCalledTimes(2);
154
155
// It should restore the previous/outer interactions
142
- expect(InteractionTracking.getCurrent()).toMatchInteractions([
156
+ expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([
157
firstEvent,
158
]);
159
@@ -154,20 +168,26 @@ describe('InteractionTracking', () => {
168
});
169
170
it('should cover onWorkStopped within track', done => {
157
- InteractionTracking.track(firstEvent.name, currentTime, () => {
171
+ SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => {
172
let innerInteraction;
173
const mock = jest.fn(() => {
160
- innerInteraction = Array.from(InteractionTracking.getCurrent())[1];
174
+ innerInteraction = Array.from(
175
+ SchedulerTracking.unstable_getCurrent(),
176
+ )[1];
177
});
178
179
throwInOnWorkStopped = true;
180
expect(() =>
165
- InteractionTracking.track(secondEvent.name, currentTime, mock),
181
+ SchedulerTracking.unstable_track(
182
+ secondEvent.name,
183
+ currentTime,
184
+ mock,
185
+ ),
186
).toThrow('Expected error onWorkStopped');
187
throwInOnWorkStopped = false;
188
189
// It should restore the previous/outer interactions
170
- expect(InteractionTracking.getCurrent()).toMatchInteractions([
190
+ expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([
191
firstEvent,
192
]);
193
@@ -182,17 +202,21 @@ describe('InteractionTracking', () => {
202
});
203
204
it('should cover onInteractionScheduledWorkCompleted within track', done => {
185
- InteractionTracking.track(firstEvent.name, currentTime, () => {
205
+ SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => {
206
const mock = jest.fn();
207
208
throwInOnInteractionScheduledWorkCompleted = true;
209
expect(() =>
190
- InteractionTracking.track(secondEvent.name, currentTime, mock),
210
+ SchedulerTracking.unstable_track(
211
+ secondEvent.name,
212
+ currentTime,
213
+ mock,
214
+ ),
215
).toThrow('Expected error onInteractionScheduledWorkCompleted');
216
throwInOnInteractionScheduledWorkCompleted = false;
217
218
// It should restore the previous/outer interactions
195
- expect(InteractionTracking.getCurrent()).toMatchInteractions([
219
+ expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([
220
firstEvent,
221
]);
222
@@ -210,7 +234,7 @@ describe('InteractionTracking', () => {
234
expect(onWorkStopped).not.toHaveBeenCalled();
235
236
expect(() => {
213
- InteractionTracking.track(firstEvent.name, currentTime, () => {
237
+ SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => {
238
throw Error('Expected error callback');
239
});
240
}).toThrow('Expected error callback');
@@ -222,12 +246,14 @@ describe('InteractionTracking', () => {
246
});
247
248
it('should cover onWorkScheduled within wrap', done => {
225
- InteractionTracking.track(firstEvent.name, currentTime, () => {
226
- const interaction = Array.from(InteractionTracking.getCurrent())[0];
249
+ SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => {
250
+ const interaction = Array.from(
251
+ SchedulerTracking.unstable_getCurrent(),
252
+ )[0];
253
const beforeCount = interaction.__count;
254
255
throwInOnWorkScheduled = true;
230
- expect(() => InteractionTracking.wrap(() => {})).toThrow(
256
+ expect(() => SchedulerTracking.unstable_wrap(() => {})).toThrow(
257
'Expected error onWorkScheduled',
258
);
259
@@ -244,9 +270,9 @@ describe('InteractionTracking', () => {
270
it('should cover onWorkStarted within wrap', () => {
271
const mock = jest.fn();
272
let interaction, wrapped;
247
- InteractionTracking.track(firstEvent.name, currentTime, () => {
248
- interaction = Array.from(InteractionTracking.getCurrent())[0];
249
- wrapped = InteractionTracking.wrap(mock);
273
+ SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => {
274
+ interaction = Array.from(SchedulerTracking.unstable_getCurrent())[0];
275
+ wrapped = SchedulerTracking.unstable_wrap(mock);
276
});
277
expect(interaction.__count).toBe(1);
278
@@ -264,24 +290,30 @@ describe('InteractionTracking', () => {
290
});
291
292
it('should cover onWorkStopped within wrap', done => {
267
- InteractionTracking.track(firstEvent.name, currentTime, () => {
293
+ SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => {
294
const outerInteraction = Array.from(
269
- InteractionTracking.getCurrent(),
295
+ SchedulerTracking.unstable_getCurrent(),
296
)[0];
297
expect(outerInteraction.__count).toBe(1);
298
299
let wrapped;
300
let innerInteraction;
301
276
- InteractionTracking.track(secondEvent.name, currentTime, () => {
277
- innerInteraction = Array.from(InteractionTracking.getCurrent())[1];
278
- expect(outerInteraction.__count).toBe(1);
279
- expect(innerInteraction.__count).toBe(1);
280
-
281
- wrapped = InteractionTracking.wrap(jest.fn());
282
- expect(outerInteraction.__count).toBe(2);
283
- expect(innerInteraction.__count).toBe(2);
284
- });
302
+ SchedulerTracking.unstable_track(
303
+ secondEvent.name,
304
+ currentTime,
305
+ () => {
306
+ innerInteraction = Array.from(
307
+ SchedulerTracking.unstable_getCurrent(),
308
+ )[1];
309
+ expect(outerInteraction.__count).toBe(1);
310
+ expect(innerInteraction.__count).toBe(1);
311
+
312
+ wrapped = SchedulerTracking.unstable_wrap(jest.fn());
313
+ expect(outerInteraction.__count).toBe(2);
314
+ expect(innerInteraction.__count).toBe(2);
315
+ },
316
+ );
317
318
expect(outerInteraction.__count).toBe(2);
319
expect(innerInteraction.__count).toBe(1);
@@ -291,7 +323,7 @@ describe('InteractionTracking', () => {
323
throwInOnWorkStopped = false;
324
325
// It should restore the previous interactions
294
- expect(InteractionTracking.getCurrent()).toMatchInteractions([
326
+ expect(SchedulerTracking.unstable_getCurrent()).toMatchInteractions([
327
outerInteraction,
328
]);
329
@@ -311,9 +343,9 @@ describe('InteractionTracking', () => {
343
344
let wrapped;
345
let interaction;
314
- InteractionTracking.track(firstEvent.name, currentTime, () => {
315
- interaction = Array.from(InteractionTracking.getCurrent())[0];
316
- wrapped = InteractionTracking.wrap(() => {
346
+ SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => {
347
+ interaction = Array.from(SchedulerTracking.unstable_getCurrent())[0];
348
+ wrapped = SchedulerTracking.unstable_wrap(() => {
349
throw Error('Expected error wrap');
350
});
351
});
@@ -332,9 +364,9 @@ describe('InteractionTracking', () => {
364
365
it('should cover onWorkCanceled within wrap', () => {
366
let interaction, wrapped;
335
- InteractionTracking.track(firstEvent.name, currentTime, () => {
336
- interaction = Array.from(InteractionTracking.getCurrent())[0];
337
- wrapped = InteractionTracking.wrap(jest.fn());
367
+ SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => {
368
+ interaction = Array.from(SchedulerTracking.unstable_getCurrent())[0];
369
+ wrapped = SchedulerTracking.unstable_wrap(jest.fn());
370
});
371
expect(interaction.__count).toBe(1);
372
@@ -358,7 +390,7 @@ describe('InteractionTracking', () => {
390
expect(onInteractionTracked).not.toHaveBeenCalled();
391
expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
392
361
- InteractionTracking.track(
393
+ SchedulerTracking.unstable_track(
394
firstEvent.name,
395
currentTime,
396
() => {
@@ -374,7 +406,7 @@ describe('InteractionTracking', () => {
406
);
407
expect(onWorkStopped).not.toHaveBeenCalled();
408
377
- InteractionTracking.track(
409
+ SchedulerTracking.unstable_track(
410
secondEvent.name,
411
currentTime,
412
() => {
@@ -426,19 +458,19 @@ describe('InteractionTracking', () => {
458
const unwrapped = jest.fn();
459
let wrapped;
460
429
- InteractionTracking.track(firstEvent.name, currentTime, () => {
461
+ SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => {
462
expect(onInteractionTracked).toHaveBeenCalledTimes(1);
463
expect(onInteractionTracked).toHaveBeenLastNotifiedOfInteraction(
464
firstEvent,
465
);
466
435
- InteractionTracking.track(secondEvent.name, currentTime, () => {
467
+ SchedulerTracking.unstable_track(secondEvent.name, currentTime, () => {
468
expect(onInteractionTracked).toHaveBeenCalledTimes(2);
469
expect(onInteractionTracked).toHaveBeenLastNotifiedOfInteraction(
470
secondEvent,
471
);
472
441
- wrapped = InteractionTracking.wrap(unwrapped, threadID);
473
+ wrapped = SchedulerTracking.unstable_wrap(unwrapped, threadID);
474
expect(onWorkScheduled).toHaveBeenCalledTimes(1);
475
expect(onWorkScheduled).toHaveBeenLastNotifiedOfWork(
476
new Set([firstEvent, secondEvent]),
@@ -478,10 +510,10 @@ describe('InteractionTracking', () => {
510
const fnOne = jest.fn();
511
const fnTwo = jest.fn();
512
let wrappedOne, wrappedTwo;
481
- InteractionTracking.track(firstEvent.name, currentTime, () => {
482
- wrappedOne = InteractionTracking.wrap(fnOne, threadID);
483
- InteractionTracking.track(secondEvent.name, currentTime, () => {
484
- wrappedTwo = InteractionTracking.wrap(fnTwo, threadID);
513
+ SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => {
514
+ wrappedOne = SchedulerTracking.unstable_wrap(fnOne, threadID);
515
+ SchedulerTracking.unstable_track(secondEvent.name, currentTime, () => {
516
+ wrappedTwo = SchedulerTracking.unstable_wrap(fnTwo, threadID);
517
});
518
});
519
@@ -521,12 +553,38 @@ describe('InteractionTracking', () => {
553
554
it('should not end an interaction twice if wrap is used to schedule follow up work within another wrap', () => {
555
const fnOne = jest.fn(() => {
524
- wrappedTwo = InteractionTracking.wrap(fnTwo, threadID);
556
+ wrappedTwo = SchedulerTracking.unstable_wrap(fnTwo, threadID);
557
});
558
const fnTwo = jest.fn();
559
let wrappedOne, wrappedTwo;
528
- InteractionTracking.track(firstEvent.name, currentTime, () => {
529
- wrappedOne = InteractionTracking.wrap(fnOne, threadID);
560
+ SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => {
561
+ wrappedOne = SchedulerTracking.unstable_wrap(fnOne, threadID);
562
+ });
563
+
564
+ expect(onInteractionTracked).toHaveBeenCalledTimes(1);
565
+ expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
566
+
567
+ wrappedOne();
568
+
569
+ expect(onInteractionTracked).toHaveBeenCalledTimes(1);
570
+ expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
571
+
572
+ wrappedTwo();
573
+
574
+ expect(onInteractionTracked).toHaveBeenCalledTimes(1);
575
+ expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1);
576
+ expect(
577
+ onInteractionScheduledWorkCompleted,
578
+ ).toHaveBeenLastNotifiedOfInteraction(firstEvent);
579
+ });
580
+
581
+ it('should not decrement the interaction count twice if a wrapped function is run twice', () => {
582
+ const unwrappedOne = jest.fn();
583
+ const unwrappedTwo = jest.fn();
584
+ let wrappedOne, wrappedTwo;
585
+ SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => {
586
+ wrappedOne = SchedulerTracking.unstable_wrap(unwrappedOne, threadID);
587
+ wrappedTwo = SchedulerTracking.unstable_wrap(unwrappedTwo, threadID);
588
});
589
590
expect(onInteractionTracked).toHaveBeenCalledTimes(1);
@@ -534,6 +592,13 @@ describe('InteractionTracking', () => {
592
593
wrappedOne();
594
595
+ expect(unwrappedOne).toHaveBeenCalledTimes(1);
596
+ expect(onInteractionTracked).toHaveBeenCalledTimes(1);
597
+ expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
598
+
599
+ wrappedOne();
600
+
601
+ expect(unwrappedOne).toHaveBeenCalledTimes(2);
602
expect(onInteractionTracked).toHaveBeenCalledTimes(1);
603
expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
604
@@ -547,15 +612,15 @@ describe('InteractionTracking', () => {
612
});
613
614
it('should unsubscribe', () => {
550
- InteractionTrackingSubscriptions.unsubscribe(firstSubscriber);
551
- InteractionTracking.track(firstEvent.name, currentTime, () => {});
615
+ SchedulerTracking.unstable_unsubscribe(firstSubscriber);
616
+ SchedulerTracking.unstable_track(firstEvent.name, currentTime, () => {});
617
618
expect(onInteractionTracked).not.toHaveBeenCalled();
619
});
620
});
621
622
describe('disabled', () => {
558
- beforeEach(() => loadModules({enableInteractionTracking: false}));
623
+ beforeEach(() => loadModules({enableSchedulerTracking: false}));
624
625
// TODO
626
});
packages/react-scheduler/tracking.js
renamed
+2
-1
@@ -9,4 +9,5 @@
9
10
'use strict';
11
12
-export * from './src/InteractionTrackingSubscriptions';
12
+export * from './src/Tracking';
13
+export * from './src/TrackingSubscriptions';
packages/react-test-renderer/package.json
+2
-1
@@ -17,7 +17,8 @@
17
"dependencies": {
18
"object-assign": "^4.1.1",
19
"prop-types": "^15.6.2",
20
- "react-is": "^16.4.3-alpha.0"
20
+ "react-is": "^16.4.3-alpha.0",
21
+ "react-scheduler": "^0.1.0-alpha-1"
22
},
23
"peerDependencies": {
24
"react": "^16.0.0"
packages/react/package.json
+2
-1
@@ -23,7 +23,8 @@
23
"dependencies": {
24
"loose-envify": "^1.1.0",
25
"object-assign": "^4.1.1",
26
- "prop-types": "^15.6.2"
26
+ "prop-types": "^15.6.2",
27
+ "react-scheduler": "^0.1.0-alpha-1"
28
},
29
"browserify": {
30
"transform": [
packages/react/src/ReactSharedInternals.js
+42
@@ -6,6 +6,22 @@
6
*/
7
8
import assign from 'object-assign';
9
+import {
10
+ unstable_cancelScheduledWork,
11
+ unstable_now,
12
+ unstable_scheduleWork,
13
+} from 'react-scheduler';
14
+import {
15
+ __getInteractionsRef,
16
+ __getSubscriberRef,
17
+ unstable_clear,
18
+ unstable_getCurrent,
19
+ unstable_getThreadID,
20
+ unstable_subscribe,
21
+ unstable_track,
22
+ unstable_unsubscribe,
23
+ unstable_wrap,
24
+} from 'react-scheduler/tracking';
25
import ReactCurrentOwner from './ReactCurrentOwner';
26
import ReactDebugCurrentFrame from './ReactDebugCurrentFrame';
27
@@ -15,6 +31,32 @@ const ReactSharedInternals = {
31
assign,
32
};
33
34
+if (__UMD__) {
35
+ // Re-export the react-scheduler API(s) for UMD bundles.
36
+ // This avoids introducing a dependency on a new UMD global in a minor update,
37
+ // Since that would be a breaking change (e.g. for all existing CodeSandboxes).
38
+ // This re-export is only required for UMD bundles;
39
+ // CJS bundles use the shared NPM package.
40
+ Object.assign(ReactSharedInternals, {
41
+ Scheduler: {
42
+ unstable_cancelScheduledWork,
43
+ unstable_now,
44
+ unstable_scheduleWork,
45
+ },
46
+ SchedulerTracking: {
47
+ __getInteractionsRef,
48
+ __getSubscriberRef,
49
+ unstable_clear,
50
+ unstable_getCurrent,
51
+ unstable_getThreadID,
52
+ unstable_subscribe,
53
+ unstable_track,
54
+ unstable_unsubscribe,
55
+ unstable_wrap,
56
+ },
57
+ });
58
+}
59
+
60
if (__DEV__) {
61
Object.assign(ReactSharedInternals, {
62
// These should not be included in production.
packages/react/src/__tests__/ReactProfiler-test.internal.js
+165
-153
@@ -10,20 +10,19 @@
10
11
'use strict';
12
13
-let InteractionTracking;
14
-let InteractionTrackingSubscriptions;
13
let React;
14
let ReactFeatureFlags;
15
let ReactNoop;
16
let ReactTestRenderer;
17
let advanceTimeBy;
18
+let SchedulerTracking;
19
let mockNow;
20
let AdvanceTime;
21
22
function loadModules({
23
enableProfilerTimer = true,
24
enableSuspense = false,
26
- enableInteractionTracking = true,
25
+ enableSchedulerTracking = true,
26
replayFailedUnitOfWorkWithInvokeGuardedCallback = false,
27
useNoopRenderer = false,
28
} = {}) {
@@ -38,13 +37,12 @@ function loadModules({
37
ReactFeatureFlags.debugRenderPhaseSideEffectsForStrictMode = false;
38
ReactFeatureFlags.enableProfilerTimer = enableProfilerTimer;
39
ReactFeatureFlags.enableGetDerivedStateFromCatch = true;
41
- ReactFeatureFlags.enableInteractionTracking = enableInteractionTracking;
40
+ ReactFeatureFlags.enableSchedulerTracking = enableSchedulerTracking;
41
ReactFeatureFlags.enableSuspense = enableSuspense;
42
ReactFeatureFlags.replayFailedUnitOfWorkWithInvokeGuardedCallback = replayFailedUnitOfWorkWithInvokeGuardedCallback;
43
45
- InteractionTracking = require('interaction-tracking');
46
- InteractionTrackingSubscriptions = require('interaction-tracking/subscriptions');
44
React = require('react');
45
+ SchedulerTracking = require('react-scheduler/tracking');
46
47
if (useNoopRenderer) {
48
ReactNoop = require('react-noop-renderer');
@@ -84,17 +82,17 @@ const mockDevToolsForTest = () => {
82
83
describe('Profiler', () => {
84
describe('works in profiling and non-profiling bundles', () => {
87
- [true, false].forEach(enableInteractionTracking => {
85
+ [true, false].forEach(enableSchedulerTracking => {
86
[true, false].forEach(enableProfilerTimer => {
89
- describe(`enableInteractionTracking:${
90
- enableInteractionTracking ? 'enabled' : 'disabled'
87
+ describe(`enableSchedulerTracking:${
88
+ enableSchedulerTracking ? 'enabled' : 'disabled'
89
} enableProfilerTimer:${
90
enableProfilerTimer ? 'enabled' : 'disabled'
91
}`, () => {
92
beforeEach(() => {
93
jest.resetModules();
94
97
- loadModules({enableInteractionTracking, enableProfilerTimer});
95
+ loadModules({enableSchedulerTracking, enableProfilerTimer});
96
});
97
98
// This will throw in production too,
@@ -167,12 +165,12 @@ describe('Profiler', () => {
165
});
166
});
167
170
- [true, false].forEach(enableInteractionTracking => {
168
+ [true, false].forEach(enableSchedulerTracking => {
169
describe('onRender callback', () => {
170
beforeEach(() => {
171
jest.resetModules();
172
175
- loadModules({enableInteractionTracking});
173
+ loadModules({enableSchedulerTracking});
174
});
175
176
it('is not invoked until the commit phase', () => {
@@ -233,7 +231,7 @@ describe('Profiler', () => {
231
232
let [call] = callback.mock.calls;
233
236
- expect(call).toHaveLength(enableInteractionTracking ? 7 : 6);
234
+ expect(call).toHaveLength(enableSchedulerTracking ? 7 : 6);
235
expect(call[0]).toBe('test');
236
expect(call[1]).toBe('mount');
237
expect(call[2]).toBe(10); // actual time
@@ -241,7 +239,7 @@ describe('Profiler', () => {
239
expect(call[4]).toBe(5); // start time
240
expect(call[5]).toBe(15); // commit time
241
expect(call[6]).toEqual(
244
- enableInteractionTracking ? new Set() : undefined,
242
+ enableSchedulerTracking ? new Set() : undefined,
243
); // interaction events
244
245
callback.mockReset();
@@ -258,7 +256,7 @@ describe('Profiler', () => {
256
257
[call] = callback.mock.calls;
258
261
- expect(call).toHaveLength(enableInteractionTracking ? 7 : 6);
259
+ expect(call).toHaveLength(enableSchedulerTracking ? 7 : 6);
260
expect(call[0]).toBe('test');
261
expect(call[1]).toBe('update');
262
expect(call[2]).toBe(10); // actual time
@@ -266,7 +264,7 @@ describe('Profiler', () => {
264
expect(call[4]).toBe(35); // start time
265
expect(call[5]).toBe(45); // commit time
266
expect(call[6]).toEqual(
269
- enableInteractionTracking ? new Set() : undefined,
267
+ enableSchedulerTracking ? new Set() : undefined,
268
); // interaction events
269
270
callback.mockReset();
@@ -283,7 +281,7 @@ describe('Profiler', () => {
281
282
[call] = callback.mock.calls;
283
286
- expect(call).toHaveLength(enableInteractionTracking ? 7 : 6);
284
+ expect(call).toHaveLength(enableSchedulerTracking ? 7 : 6);
285
expect(call[0]).toBe('test');
286
expect(call[1]).toBe('update');
287
expect(call[2]).toBe(4); // actual time
@@ -291,7 +289,7 @@ describe('Profiler', () => {
289
expect(call[4]).toBe(65); // start time
290
expect(call[5]).toBe(69); // commit time
291
expect(call[6]).toEqual(
294
- enableInteractionTracking ? new Set() : undefined,
292
+ enableSchedulerTracking ? new Set() : undefined,
293
); // interaction events
294
});
295
@@ -1176,7 +1174,7 @@ describe('Profiler', () => {
1174
jest.resetModules();
1175
1176
loadModules({
1179
- enableInteractionTracking: true,
1177
+ enableSchedulerTracking: true,
1178
});
1179
1180
throwInOnInteractionScheduledWorkCompleted = false;
@@ -1208,7 +1206,7 @@ describe('Profiler', () => {
1206
});
1207
1208
// Verify interaction subscriber methods are called as expected.
1211
- InteractionTrackingSubscriptions.subscribe({
1209
+ SchedulerTracking.unstable_subscribe({
1210
onInteractionScheduledWorkCompleted,
1211
onInteractionTracked,
1212
onWorkCanceled,
@@ -1230,7 +1228,7 @@ describe('Profiler', () => {
1228
// Errors that happen inside of a subscriber should throw,
1229
throwInOnWorkScheduled = true;
1230
expect(() => {
1233
- InteractionTracking.track('event', mockNow(), () => {
1231
+ SchedulerTracking.unstable_track('event', mockNow(), () => {
1232
renderer = ReactTestRenderer.create(<Component>fail</Component>, {
1233
unstable_isAsync: true,
1234
});
@@ -1256,7 +1254,7 @@ describe('Profiler', () => {
1254
}
1255
1256
let renderer;
1259
- InteractionTracking.track('event', mockNow(), () => {
1257
+ SchedulerTracking.unstable_track('event', mockNow(), () => {
1258
renderer = ReactTestRenderer.create(<Component>text</Component>, {
1259
unstable_isAsync: true,
1260
});
@@ -1285,7 +1283,7 @@ describe('Profiler', () => {
1283
}
1284
1285
let renderer;
1288
- InteractionTracking.track('event', mockNow(), () => {
1286
+ SchedulerTracking.unstable_track('event', mockNow(), () => {
1287
renderer = ReactTestRenderer.create(<Component>text</Component>, {
1288
unstable_isAsync: true,
1289
});
@@ -1327,8 +1325,8 @@ describe('Profiler', () => {
1325
};
1326
1327
let renderer;
1330
- InteractionTracking.track(eventOne.name, mockNow(), () => {
1331
- InteractionTracking.track(eventTwo.name, mockNow(), () => {
1328
+ SchedulerTracking.unstable_track(eventOne.name, mockNow(), () => {
1329
+ SchedulerTracking.unstable_track(eventTwo.name, mockNow(), () => {
1330
renderer = ReactTestRenderer.create(<Component>text</Component>, {
1331
unstable_isAsync: true,
1332
});
@@ -1382,16 +1380,20 @@ describe('Profiler', () => {
1380
1381
const onRender = jest.fn();
1382
let renderer;
1385
- InteractionTracking.track(interactionCreation.name, mockNow(), () => {
1386
- renderer = ReactTestRenderer.create(
1387
- <React.unstable_Profiler id="test-profiler" onRender={onRender}>
1388
- <Example />
1389
- </React.unstable_Profiler>,
1390
- {
1391
- unstable_isAsync: true,
1392
- },
1393
- );
1394
- });
1383
+ SchedulerTracking.unstable_track(
1384
+ interactionCreation.name,
1385
+ mockNow(),
1386
+ () => {
1387
+ renderer = ReactTestRenderer.create(
1388
+ <React.unstable_Profiler id="test-profiler" onRender={onRender}>
1389
+ <Example />
1390
+ </React.unstable_Profiler>,
1391
+ {
1392
+ unstable_isAsync: true,
1393
+ },
1394
+ );
1395
+ },
1396
+ );
1397
1398
expect(onInteractionTracked).toHaveBeenCalledTimes(1);
1399
expect(onInteractionTracked).toHaveBeenLastNotifiedOfInteraction(
@@ -1399,7 +1401,7 @@ describe('Profiler', () => {
1401
);
1402
expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
1403
1402
- // The interaction-tracking package will notify of work started for the default thread,
1404
+ // The react-scheduler/tracking package will notify of work started for the default thread,
1405
// But React shouldn't notify until it's been flushed.
1406
expect(getWorkForReactThreads(onWorkStarted)).toHaveLength(0);
1407
expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(0);
@@ -1419,7 +1421,7 @@ describe('Profiler', () => {
1421
let call = onRender.mock.calls[0];
1422
expect(call[0]).toEqual('test-profiler');
1423
expect(call[5]).toEqual(mockNow());
1422
- if (ReactFeatureFlags.enableInteractionTracking) {
1424
+ if (ReactFeatureFlags.enableSchedulerTracking) {
1425
expect(call[6]).toMatchInteractions([interactionCreation]);
1426
}
1427
@@ -1451,13 +1453,13 @@ describe('Profiler', () => {
1453
name: 'initial event',
1454
timestamp: mockNow(),
1455
};
1454
- InteractionTracking.track(interactionOne.name, mockNow(), () => {
1456
+ SchedulerTracking.unstable_track(interactionOne.name, mockNow(), () => {
1457
instance.setState({count: 1});
1458
1459
// Update state again to verify our tracked interaction isn't registered twice
1460
instance.setState({count: 2});
1461
1460
- // The interaction-tracking package will notify of work started for the default thread,
1462
+ // The react-scheduler/tracking package will notify of work started for the default thread,
1463
// But React shouldn't notify until it's been flushed.
1464
expect(getWorkForReactThreads(onWorkStarted)).toHaveLength(0);
1465
expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(0);
@@ -1491,7 +1493,7 @@ describe('Profiler', () => {
1493
call = onRender.mock.calls[0];
1494
expect(call[0]).toEqual('test-profiler');
1495
expect(call[5]).toEqual(mockNow());
1494
- if (ReactFeatureFlags.enableInteractionTracking) {
1496
+ if (ReactFeatureFlags.enableSchedulerTracking) {
1497
expect(call[6]).toMatchInteractions([interactionOne]);
1498
}
1499
@@ -1524,7 +1526,7 @@ describe('Profiler', () => {
1526
call = onRender.mock.calls[0];
1527
expect(call[0]).toEqual('test-profiler');
1528
expect(call[5]).toEqual(mockNow());
1527
- if (ReactFeatureFlags.enableInteractionTracking) {
1529
+ if (ReactFeatureFlags.enableSchedulerTracking) {
1530
expect(call[6]).toMatchInteractions([]);
1531
}
1532
@@ -1546,7 +1548,7 @@ describe('Profiler', () => {
1548
name: 'root update event',
1549
timestamp: mockNow(),
1550
};
1549
- InteractionTracking.track(interactionTwo.name, mockNow(), () => {
1551
+ SchedulerTracking.unstable_track(interactionTwo.name, mockNow(), () => {
1552
renderer.update(
1553
<React.unstable_Profiler id="test-profiler" onRender={onRender}>
1554
<Example />
@@ -1560,7 +1562,7 @@ describe('Profiler', () => {
1562
);
1563
expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(2);
1564
1563
- // The interaction-tracking package will notify of work started for the default thread,
1565
+ // The react-scheduler/tracking package will notify of work started for the default thread,
1566
// But React shouldn't notify until it's been flushed.
1567
expect(getWorkForReactThreads(onWorkStarted)).toHaveLength(0);
1568
expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(0);
@@ -1580,7 +1582,7 @@ describe('Profiler', () => {
1582
call = onRender.mock.calls[0];
1583
expect(call[0]).toEqual('test-profiler');
1584
expect(call[5]).toEqual(mockNow());
1583
- if (ReactFeatureFlags.enableInteractionTracking) {
1585
+ if (ReactFeatureFlags.enableSchedulerTracking) {
1586
expect(call[6]).toMatchInteractions([interactionTwo]);
1587
}
1588
@@ -1647,109 +1649,119 @@ describe('Profiler', () => {
1649
timestamp: mockNow(),
1650
};
1651
1650
- InteractionTracking.track(interactionLowPri.name, mockNow(), () => {
1651
- // Render a partially update, but don't finish.
1652
- first.setState({count: 1});
1653
-
1654
- expect(onWorkScheduled).toHaveBeenCalled();
1655
- expect(onWorkScheduled.mock.calls[0][0]).toMatchInteractions([
1656
- interactionLowPri,
1657
- ]);
1658
-
1659
- expect(renderer).toFlushThrough(['FirstComponent']);
1660
- expect(onRender).not.toHaveBeenCalled();
1661
-
1662
- expect(onInteractionTracked).toHaveBeenCalledTimes(1);
1663
- expect(onInteractionTracked).toHaveBeenLastNotifiedOfInteraction(
1664
- interactionLowPri,
1665
- );
1666
- expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
1667
- expect(getWorkForReactThreads(onWorkStarted)).toHaveLength(1);
1668
- expect(getWorkForReactThreads(onWorkStarted)[0][0]).toMatchInteractions(
1669
- [interactionLowPri],
1670
- );
1671
- expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(0);
1652
+ SchedulerTracking.unstable_track(
1653
+ interactionLowPri.name,
1654
+ mockNow(),
1655
+ () => {
1656
+ // Render a partially update, but don't finish.
1657
+ first.setState({count: 1});
1658
1673
- advanceTimeBy(100);
1659
+ expect(onWorkScheduled).toHaveBeenCalled();
1660
+ expect(onWorkScheduled.mock.calls[0][0]).toMatchInteractions([
1661
+ interactionLowPri,
1662
+ ]);
1663
1675
- const interactionHighPri = {
1676
- id: 1,
1677
- name: 'highPri',
1678
- timestamp: mockNow(),
1679
- };
1664
+ expect(renderer).toFlushThrough(['FirstComponent']);
1665
+ expect(onRender).not.toHaveBeenCalled();
1666
1681
- // Interrupt with higher priority work.
1682
- // This simulates a total of 37ms of actual render time.
1683
- renderer.unstable_flushSync(() => {
1684
- InteractionTracking.track(interactionHighPri.name, mockNow(), () => {
1685
- second.setState({count: 1});
1667
+ expect(onInteractionTracked).toHaveBeenCalledTimes(1);
1668
+ expect(onInteractionTracked).toHaveBeenLastNotifiedOfInteraction(
1669
+ interactionLowPri,
1670
+ );
1671
+ expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
1672
+ expect(getWorkForReactThreads(onWorkStarted)).toHaveLength(1);
1673
+ expect(
1674
+ getWorkForReactThreads(onWorkStarted)[0][0],
1675
+ ).toMatchInteractions([interactionLowPri]);
1676
+ expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(0);
1677
+
1678
+ advanceTimeBy(100);
1679
+
1680
+ const interactionHighPri = {
1681
+ id: 1,
1682
+ name: 'highPri',
1683
+ timestamp: mockNow(),
1684
+ };
1685
1687
- expect(onInteractionTracked).toHaveBeenCalledTimes(2);
1688
- expect(onInteractionTracked).toHaveBeenLastNotifiedOfInteraction(
1689
- interactionHighPri,
1686
+ // Interrupt with higher priority work.
1687
+ // This simulates a total of 37ms of actual render time.
1688
+ renderer.unstable_flushSync(() => {
1689
+ SchedulerTracking.unstable_track(
1690
+ interactionHighPri.name,
1691
+ mockNow(),
1692
+ () => {
1693
+ second.setState({count: 1});
1694
+
1695
+ expect(onInteractionTracked).toHaveBeenCalledTimes(2);
1696
+ expect(
1697
+ onInteractionTracked,
1698
+ ).toHaveBeenLastNotifiedOfInteraction(interactionHighPri);
1699
+ expect(
1700
+ onInteractionScheduledWorkCompleted,
1701
+ ).not.toHaveBeenCalled();
1702
+
1703
+ expect(getWorkForReactThreads(onWorkStarted)).toHaveLength(1);
1704
+ expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(0);
1705
+ },
1706
);
1691
- expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
1692
-
1693
- expect(getWorkForReactThreads(onWorkStarted)).toHaveLength(1);
1694
- expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(0);
1707
});
1696
- });
1697
- expect(ReactTestRenderer).toClearYields(['SecondComponent']);
1698
-
1699
- expect(onInteractionTracked).toHaveBeenCalledTimes(2);
1700
- expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1);
1701
- expect(
1702
- onInteractionScheduledWorkCompleted,
1703
- ).toHaveBeenLastNotifiedOfInteraction(interactionHighPri);
1704
-
1705
- // Verify the high priority update was associated with the high priority event.
1706
- expect(onRender).toHaveBeenCalledTimes(1);
1707
- let call = onRender.mock.calls[0];
1708
- expect(call[0]).toEqual('test');
1709
- expect(call[5]).toEqual(mockNow());
1710
- expect(call[6]).toMatchInteractions(
1711
- ReactFeatureFlags.enableInteractionTracking
1712
- ? [interactionLowPri, interactionHighPri]
1713
- : [],
1714
- );
1708
+ expect(ReactTestRenderer).toClearYields(['SecondComponent']);
1709
+
1710
+ expect(onInteractionTracked).toHaveBeenCalledTimes(2);
1711
+ expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1);
1712
+ expect(
1713
+ onInteractionScheduledWorkCompleted,
1714
+ ).toHaveBeenLastNotifiedOfInteraction(interactionHighPri);
1715
+
1716
+ // Verify the high priority update was associated with the high priority event.
1717
+ expect(onRender).toHaveBeenCalledTimes(1);
1718
+ let call = onRender.mock.calls[0];
1719
+ expect(call[0]).toEqual('test');
1720
+ expect(call[5]).toEqual(mockNow());
1721
+ expect(call[6]).toMatchInteractions(
1722
+ ReactFeatureFlags.enableSchedulerTracking
1723
+ ? [interactionLowPri, interactionHighPri]
1724
+ : [],
1725
+ );
1726
1716
- onRender.mockClear();
1727
+ onRender.mockClear();
1728
1718
- advanceTimeBy(100);
1729
+ advanceTimeBy(100);
1730
1720
- // Resume the original low priority update, with rebased state.
1721
- // Verify the low priority update was retained.
1722
- renderer.unstable_flushAll(['FirstComponent']);
1723
- expect(onRender).toHaveBeenCalledTimes(1);
1724
- call = onRender.mock.calls[0];
1725
- expect(call[0]).toEqual('test');
1726
- expect(call[5]).toEqual(mockNow());
1727
- expect(call[6]).toMatchInteractions(
1728
- ReactFeatureFlags.enableInteractionTracking
1729
- ? [interactionLowPri]
1730
- : [],
1731
- );
1732
-
1733
- expect(onInteractionTracked).toHaveBeenCalledTimes(2);
1734
- expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1);
1731
+ // Resume the original low priority update, with rebased state.
1732
+ // Verify the low priority update was retained.
1733
+ renderer.unstable_flushAll(['FirstComponent']);
1734
+ expect(onRender).toHaveBeenCalledTimes(1);
1735
+ call = onRender.mock.calls[0];
1736
+ expect(call[0]).toEqual('test');
1737
+ expect(call[5]).toEqual(mockNow());
1738
+ expect(call[6]).toMatchInteractions(
1739
+ ReactFeatureFlags.enableSchedulerTracking
1740
+ ? [interactionLowPri]
1741
+ : [],
1742
+ );
1743
1736
- // Work might be started multiple times before being completed.
1737
- // This is okay; it's part of the interaction-tracking subscriber contract.
1738
- expect(getWorkForReactThreads(onWorkStarted)).toHaveLength(3);
1739
- expect(getWorkForReactThreads(onWorkStarted)[1][0]).toMatchInteractions(
1740
- [interactionLowPri, interactionHighPri],
1741
- );
1742
- expect(getWorkForReactThreads(onWorkStarted)[2][0]).toMatchInteractions(
1743
- [interactionLowPri],
1744
- );
1745
- expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(2);
1746
- expect(getWorkForReactThreads(onWorkStopped)[0][0]).toMatchInteractions(
1747
- [interactionLowPri, interactionHighPri],
1748
- );
1749
- expect(getWorkForReactThreads(onWorkStopped)[1][0]).toMatchInteractions(
1750
- [interactionLowPri],
1751
- );
1752
- });
1744
+ expect(onInteractionTracked).toHaveBeenCalledTimes(2);
1745
+ expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1);
1746
+
1747
+ // Work might be started multiple times before being completed.
1748
+ // This is okay; it's part of the react-scheduler/tracking contract.
1749
+ expect(getWorkForReactThreads(onWorkStarted)).toHaveLength(3);
1750
+ expect(
1751
+ getWorkForReactThreads(onWorkStarted)[1][0],
1752
+ ).toMatchInteractions([interactionLowPri, interactionHighPri]);
1753
+ expect(
1754
+ getWorkForReactThreads(onWorkStarted)[2][0],
1755
+ ).toMatchInteractions([interactionLowPri]);
1756
+ expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(2);
1757
+ expect(
1758
+ getWorkForReactThreads(onWorkStopped)[0][0],
1759
+ ).toMatchInteractions([interactionLowPri, interactionHighPri]);
1760
+ expect(
1761
+ getWorkForReactThreads(onWorkStopped)[1][0],
1762
+ ).toMatchInteractions([interactionLowPri]);
1763
+ },
1764
+ );
1765
1766
expect(onInteractionTracked).toHaveBeenCalledTimes(2);
1767
expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(2);
@@ -1793,7 +1805,7 @@ describe('Profiler', () => {
1805
const onRender = jest.fn();
1806
let firstCommitTime = mockNow();
1807
let renderer;
1796
- InteractionTracking.track(interactionOne.name, mockNow(), () => {
1808
+ SchedulerTracking.unstable_track(interactionOne.name, mockNow(), () => {
1809
renderer = ReactTestRenderer.create(
1810
<React.unstable_Profiler id="test" onRender={onRender}>
1811
<Example />
@@ -1837,13 +1849,13 @@ describe('Profiler', () => {
1849
expect(call[0]).toEqual('test');
1850
expect(call[5]).toEqual(firstCommitTime);
1851
expect(call[6]).toMatchInteractions(
1840
- ReactFeatureFlags.enableInteractionTracking ? [interactionOne] : [],
1852
+ ReactFeatureFlags.enableSchedulerTracking ? [interactionOne] : [],
1853
);
1854
call = onRender.mock.calls[1];
1855
expect(call[0]).toEqual('test');
1856
expect(call[5]).toEqual(mockNow());
1857
expect(call[6]).toMatchInteractions(
1846
- ReactFeatureFlags.enableInteractionTracking ? [interactionOne] : [],
1858
+ ReactFeatureFlags.enableSchedulerTracking ? [interactionOne] : [],
1859
);
1860
1861
onRender.mockClear();
@@ -1855,7 +1867,7 @@ describe('Profiler', () => {
1867
};
1868
1869
// Cause an tracked, async update
1858
- InteractionTracking.track(interactionTwo.name, mockNow(), () => {
1870
+ SchedulerTracking.unstable_track(interactionTwo.name, mockNow(), () => {
1871
instance.setState({count: 2});
1872
});
1873
expect(onRender).not.toHaveBeenCalled();
@@ -1900,13 +1912,13 @@ describe('Profiler', () => {
1912
expect(call[0]).toEqual('test');
1913
expect(call[5]).toEqual(firstCommitTime);
1914
expect(call[6]).toMatchInteractions(
1903
- ReactFeatureFlags.enableInteractionTracking ? [interactionTwo] : [],
1915
+ ReactFeatureFlags.enableSchedulerTracking ? [interactionTwo] : [],
1916
);
1917
call = onRender.mock.calls[1];
1918
expect(call[0]).toEqual('test');
1919
expect(call[5]).toEqual(mockNow());
1920
expect(call[6]).toMatchInteractions(
1909
- ReactFeatureFlags.enableInteractionTracking ? [interactionTwo] : [],
1921
+ ReactFeatureFlags.enableSchedulerTracking ? [interactionTwo] : [],
1922
);
1923
1924
onRender.mockClear();
@@ -1921,7 +1933,7 @@ describe('Profiler', () => {
1933
function callback() {
1934
instance.setState({count: 6});
1935
}
1924
- InteractionTracking.track(interactionThree.name, mockNow(), () => {
1936
+ SchedulerTracking.unstable_track(interactionThree.name, mockNow(), () => {
1937
instance.setState({count: 5}, callback);
1938
});
1939
expect(onRender).not.toHaveBeenCalled();
@@ -1965,13 +1977,13 @@ describe('Profiler', () => {
1977
expect(call[0]).toEqual('test');
1978
expect(call[5]).toEqual(firstCommitTime);
1979
expect(call[6]).toMatchInteractions(
1968
- ReactFeatureFlags.enableInteractionTracking ? [interactionThree] : [],
1980
+ ReactFeatureFlags.enableSchedulerTracking ? [interactionThree] : [],
1981
);
1982
call = onRender.mock.calls[1];
1983
expect(call[0]).toEqual('test');
1984
expect(call[5]).toEqual(mockNow());
1985
expect(call[6]).toMatchInteractions(
1974
- ReactFeatureFlags.enableInteractionTracking ? [interactionThree] : [],
1986
+ ReactFeatureFlags.enableSchedulerTracking ? [interactionThree] : [],
1987
);
1988
});
1989
@@ -2014,7 +2026,7 @@ describe('Profiler', () => {
2026
timestamp: mockNow(),
2027
};
2028
2017
- InteractionTracking.track(interaction.name, mockNow(), () => {
2029
+ SchedulerTracking.unstable_track(interaction.name, mockNow(), () => {
2030
parentInstance.setState({count: 1});
2031
});
2032
@@ -2032,7 +2044,7 @@ describe('Profiler', () => {
2044
let call = onRender.mock.calls[0];
2045
expect(call[0]).toEqual('test-profiler');
2046
expect(call[6]).toMatchInteractions(
2035
- ReactFeatureFlags.enableInteractionTracking ? [interaction] : [],
2047
+ ReactFeatureFlags.enableSchedulerTracking ? [interaction] : [],
2048
);
2049
2050
expect(onInteractionTracked).toHaveBeenCalledTimes(1);
@@ -2056,11 +2068,11 @@ describe('Profiler', () => {
2068
loadModules({
2069
useNoopRenderer: true,
2070
enableSuspense: true,
2059
- enableInteractionTracking: true,
2071
+ enableSchedulerTracking: true,
2072
});
2073
2074
// Re-register since we've reloaded modules
2063
- InteractionTrackingSubscriptions.subscribe({
2075
+ SchedulerTracking.unstable_subscribe({
2076
onInteractionScheduledWorkCompleted,
2077
onInteractionTracked,
2078
onWorkCanceled,
@@ -2127,7 +2139,7 @@ describe('Profiler', () => {
2139
};
2140
2141
const onRender = jest.fn();
2130
- InteractionTracking.track(interaction.name, mockNow(), () => {
2142
+ SchedulerTracking.unstable_track(interaction.name, mockNow(), () => {
2143
ReactNoop.render(
2144
<React.unstable_Profiler id="test-profiler" onRender={onRender}>
2145
<React.Placeholder fallback={<Text text="Loading..." />}>
@@ -2172,7 +2184,7 @@ describe('Profiler', () => {
2184
let call = onRender.mock.calls[0];
2185
expect(call[0]).toEqual('test-profiler');
2186
expect(call[6]).toMatchInteractions(
2175
- ReactFeatureFlags.enableInteractionTracking ? [interaction] : [],
2187
+ ReactFeatureFlags.enableSchedulerTracking ? [interaction] : [],
2188
);
2189
2190
expect(onInteractionTracked).toHaveBeenCalledTimes(1);
@@ -2187,7 +2199,7 @@ describe('Profiler', () => {
2199
call = onRender.mock.calls[1];
2200
expect(call[0]).toEqual('test-profiler');
2201
expect(call[6]).toMatchInteractions(
2190
- ReactFeatureFlags.enableInteractionTracking ? [interaction] : [],
2202
+ ReactFeatureFlags.enableSchedulerTracking ? [interaction] : [],
2203
);
2204
2205
expect(onInteractionTracked).toHaveBeenCalledTimes(1);
packages/react/src/__tests__/ReactProfilerDevToolsIntegration-test.internal.js
+4
-4
@@ -14,7 +14,7 @@ describe('ReactProfiler DevTools integration', () => {
14
let React;
15
let ReactFeatureFlags;
16
let ReactTestRenderer;
17
- let InteractionTracking;
17
+ let SchedulerTracking;
18
let AdvanceTime;
19
let advanceTimeBy;
20
let hook;
@@ -38,10 +38,10 @@ describe('ReactProfiler DevTools integration', () => {
38
39
ReactFeatureFlags = require('shared/ReactFeatureFlags');
40
ReactFeatureFlags.enableProfilerTimer = true;
41
- ReactFeatureFlags.enableInteractionTracking = true;
41
+ ReactFeatureFlags.enableSchedulerTracking = true;
42
+ SchedulerTracking = require('react-scheduler/tracking');
43
React = require('react');
44
ReactTestRenderer = require('react-test-renderer');
44
- InteractionTracking = require('interaction-tracking');
45
46
ReactTestRenderer.unstable_setNowImplementation(mockNow);
47
advanceTimeBy = amount => {
@@ -180,7 +180,7 @@ describe('ReactProfiler DevTools integration', () => {
180
const eventTime = mockNow();
181
182
// Render with an interaction
183
- InteractionTracking.track('some event', eventTime, () => {
183
+ SchedulerTracking.unstable_track('some event', eventTime, () => {
184
rendered.update(<div />);
185
});
186
packages/react/src/__tests__/__snapshots__/ReactProfiler-test.internal.js.snap
+16
-16
@@ -1,6 +1,6 @@
1
// Jest Snapshot v1, https://goo.gl/fbAQLP
2
3
-exports[`Profiler works in profiling and non-profiling bundles enableInteractionTracking:disabled enableProfilerTimer:disabled should render children 1`] = `
3
+exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:disabled enableProfilerTimer:disabled should render children 1`] = `
4
<div>
5
<span>
6
outside span
@@ -14,11 +14,11 @@ exports[`Profiler works in profiling and non-profiling bundles enableInteraction
14
</div>
15
`;
16
17
-exports[`Profiler works in profiling and non-profiling bundles enableInteractionTracking:disabled enableProfilerTimer:disabled should support an empty Profiler (with no children) 1`] = `null`;
17
+exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:disabled enableProfilerTimer:disabled should support an empty Profiler (with no children) 1`] = `null`;
18
19
-exports[`Profiler works in profiling and non-profiling bundles enableInteractionTracking:disabled enableProfilerTimer:disabled should support an empty Profiler (with no children) 2`] = `<div />`;
19
+exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:disabled enableProfilerTimer:disabled should support an empty Profiler (with no children) 2`] = `<div />`;
20
21
-exports[`Profiler works in profiling and non-profiling bundles enableInteractionTracking:disabled enableProfilerTimer:disabled should support nested Profilers 1`] = `
21
+exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:disabled enableProfilerTimer:disabled should support nested Profilers 1`] = `
22
Array [
23
<div>
24
outer functional component
@@ -32,7 +32,7 @@ Array [
32
]
33
`;
34
35
-exports[`Profiler works in profiling and non-profiling bundles enableInteractionTracking:disabled enableProfilerTimer:enabled should render children 1`] = `
35
+exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:disabled enableProfilerTimer:enabled should render children 1`] = `
36
<div>
37
<span>
38
outside span
@@ -46,11 +46,11 @@ exports[`Profiler works in profiling and non-profiling bundles enableInteraction
46
</div>
47
`;
48
49
-exports[`Profiler works in profiling and non-profiling bundles enableInteractionTracking:disabled enableProfilerTimer:enabled should support an empty Profiler (with no children) 1`] = `null`;
49
+exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:disabled enableProfilerTimer:enabled should support an empty Profiler (with no children) 1`] = `null`;
50
51
-exports[`Profiler works in profiling and non-profiling bundles enableInteractionTracking:disabled enableProfilerTimer:enabled should support an empty Profiler (with no children) 2`] = `<div />`;
51
+exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:disabled enableProfilerTimer:enabled should support an empty Profiler (with no children) 2`] = `<div />`;
52
53
-exports[`Profiler works in profiling and non-profiling bundles enableInteractionTracking:disabled enableProfilerTimer:enabled should support nested Profilers 1`] = `
53
+exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:disabled enableProfilerTimer:enabled should support nested Profilers 1`] = `
54
Array [
55
<div>
56
outer functional component
@@ -64,7 +64,7 @@ Array [
64
]
65
`;
66
67
-exports[`Profiler works in profiling and non-profiling bundles enableInteractionTracking:enabled enableProfilerTimer:disabled should render children 1`] = `
67
+exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:enabled enableProfilerTimer:disabled should render children 1`] = `
68
<div>
69
<span>
70
outside span
@@ -78,11 +78,11 @@ exports[`Profiler works in profiling and non-profiling bundles enableInteraction
78
</div>
79
`;
80
81
-exports[`Profiler works in profiling and non-profiling bundles enableInteractionTracking:enabled enableProfilerTimer:disabled should support an empty Profiler (with no children) 1`] = `null`;
81
+exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:enabled enableProfilerTimer:disabled should support an empty Profiler (with no children) 1`] = `null`;
82
83
-exports[`Profiler works in profiling and non-profiling bundles enableInteractionTracking:enabled enableProfilerTimer:disabled should support an empty Profiler (with no children) 2`] = `<div />`;
83
+exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:enabled enableProfilerTimer:disabled should support an empty Profiler (with no children) 2`] = `<div />`;
84
85
-exports[`Profiler works in profiling and non-profiling bundles enableInteractionTracking:enabled enableProfilerTimer:disabled should support nested Profilers 1`] = `
85
+exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:enabled enableProfilerTimer:disabled should support nested Profilers 1`] = `
86
Array [
87
<div>
88
outer functional component
@@ -96,7 +96,7 @@ Array [
96
]
97
`;
98
99
-exports[`Profiler works in profiling and non-profiling bundles enableInteractionTracking:enabled enableProfilerTimer:enabled should render children 1`] = `
99
+exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:enabled enableProfilerTimer:enabled should render children 1`] = `
100
<div>
101
<span>
102
outside span
@@ -110,11 +110,11 @@ exports[`Profiler works in profiling and non-profiling bundles enableInteraction
110
</div>
111
`;
112
113
-exports[`Profiler works in profiling and non-profiling bundles enableInteractionTracking:enabled enableProfilerTimer:enabled should support an empty Profiler (with no children) 1`] = `null`;
113
+exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:enabled enableProfilerTimer:enabled should support an empty Profiler (with no children) 1`] = `null`;
114
115
-exports[`Profiler works in profiling and non-profiling bundles enableInteractionTracking:enabled enableProfilerTimer:enabled should support an empty Profiler (with no children) 2`] = `<div />`;
115
+exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:enabled enableProfilerTimer:enabled should support an empty Profiler (with no children) 2`] = `<div />`;
116
117
-exports[`Profiler works in profiling and non-profiling bundles enableInteractionTracking:enabled enableProfilerTimer:enabled should support nested Profilers 1`] = `
117
+exports[`Profiler works in profiling and non-profiling bundles enableSchedulerTracking:enabled enableProfilerTimer:enabled should support nested Profilers 1`] = `
118
Array [
119
<div>
120
outer functional component
packages/shared/ReactFeatureFlags.js
+1
-1
@@ -40,7 +40,7 @@ export const warnAboutLegacyContextAPI = false;
40
export const enableProfilerTimer = __PROFILE__;
41
42
// Track which interactions trigger each commit.
43
-export const enableInteractionTracking = __PROFILE__;
43
+export const enableSchedulerTracking = __PROFILE__;
44
45
// Only used in www builds.
46
export function addUserTimingListener() {
packages/shared/ReactScheduler.js
deleted
-17
@@ -1,17 +0,0 @@
1
-/**
2
- * Copyright (c) 2013-present, Facebook, Inc.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @flow
8
- */
9
-
10
-'use strict';
11
-import {
12
- now,
13
- scheduleWork,
14
- cancelScheduledWork,
15
-} from 'react-scheduler/src/ReactScheduler';
16
-
17
-export {now, scheduleWork, cancelScheduledWork};
packages/shared/forks/ReactFeatureFlags.native-fabric-fb.js
+1
-1
@@ -21,7 +21,7 @@ export const warnAboutDeprecatedLifecycles = false;
21
export const warnAboutLegacyContextAPI = __DEV__;
22
export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
23
export const enableProfilerTimer = __PROFILE__;
24
-export const enableInteractionTracking = false;
24
+export const enableSchedulerTracking = __PROFILE__;
25
26
// Only used in www builds.
27
export function addUserTimingListener() {
packages/shared/forks/ReactFeatureFlags.native-fabric-oss.js
+1
-1
@@ -21,7 +21,7 @@ export const warnAboutDeprecatedLifecycles = false;
21
export const warnAboutLegacyContextAPI = false;
22
export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
23
export const enableProfilerTimer = __PROFILE__;
24
-export const enableInteractionTracking = false;
24
+export const enableSchedulerTracking = __PROFILE__;
25
26
// Only used in www builds.
27
export function addUserTimingListener() {
packages/shared/forks/ReactFeatureFlags.native-fb.js
+1
-1
@@ -26,7 +26,7 @@ export const {
26
export const enableUserTimingAPI = __DEV__;
27
export const warnAboutLegacyContextAPI = __DEV__;
28
export const enableProfilerTimer = __PROFILE__;
29
-export const enableInteractionTracking = false;
29
+export const enableSchedulerTracking = __PROFILE__;
30
31
// Only used in www builds.
32
export function addUserTimingListener() {
packages/shared/forks/ReactFeatureFlags.native-oss.js
+1
-1
@@ -21,7 +21,7 @@ export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
21
export const warnAboutDeprecatedLifecycles = false;
22
export const warnAboutLegacyContextAPI = false;
23
export const enableProfilerTimer = __PROFILE__;
24
-export const enableInteractionTracking = false;
24
+export const enableSchedulerTracking = __PROFILE__;
25
26
// Only used in www builds.
27
export function addUserTimingListener() {
packages/shared/forks/ReactFeatureFlags.persistent.js
+1
-1
@@ -21,7 +21,7 @@ export const warnAboutDeprecatedLifecycles = false;
21
export const warnAboutLegacyContextAPI = false;
22
export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
23
export const enableProfilerTimer = __PROFILE__;
24
-export const enableInteractionTracking = false;
24
+export const enableSchedulerTracking = __PROFILE__;
25
26
// Only used in www builds.
27
export function addUserTimingListener() {
packages/shared/forks/ReactFeatureFlags.test-renderer.js
+1
-1
@@ -21,7 +21,7 @@ export const warnAboutDeprecatedLifecycles = false;
21
export const warnAboutLegacyContextAPI = false;
22
export const replayFailedUnitOfWorkWithInvokeGuardedCallback = false;
23
export const enableProfilerTimer = false;
24
-export const enableInteractionTracking = false;
24
+export const enableSchedulerTracking = false;
25
26
// Only used in www builds.
27
export function addUserTimingListener() {
packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
+1
-1
@@ -21,7 +21,7 @@ export const warnAboutDeprecatedLifecycles = false;
21
export const warnAboutLegacyContextAPI = false;
22
export const replayFailedUnitOfWorkWithInvokeGuardedCallback = false;
23
export const enableProfilerTimer = false;
24
-export const enableInteractionTracking = false;
24
+export const enableSchedulerTracking = false;
25
26
// Only used in www builds.
27
export function addUserTimingListener() {
packages/shared/forks/ReactFeatureFlags.www.js
+1
-1
@@ -32,7 +32,7 @@ export const warnAboutLegacyContextAPI = __DEV__;
32
export let enableUserTimingAPI = __DEV__;
33
34
export const enableProfilerTimer = __PROFILE__;
35
-export const enableInteractionTracking = __PROFILE__;
35
+export const enableSchedulerTracking = __PROFILE__;
36
37
let refCount = 0;
38
export function addUserTimingListener() {
packages/shared/forks/ReactScheduler.umd.js
new
+20
@@ -0,0 +1,20 @@
1
+/**
2
+ * Copyright (c) 2013-present, Facebook, Inc.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow
8
+ */
9
+
10
+import React from 'react';
11
+
12
+const ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
13
+
14
+const {
15
+ unstable_cancelScheduledWork,
16
+ unstable_now,
17
+ unstable_scheduleWork,
18
+} = ReactInternals.Scheduler;
19
+
20
+export {unstable_cancelScheduledWork, unstable_now, unstable_scheduleWork};
packages/shared/forks/ReactScheduler.www.js
+6
-2
@@ -6,6 +6,10 @@
6
*/
7
8
'use strict';
9
-const {now, scheduleWork, cancelScheduledWork} = require('customSchedule');
9
+const {
10
+ unstable_now,
11
+ unstable_scheduleWork,
12
+ unstable_cancelScheduledWork,
13
+} = require('customSchedule');
14
11
-export {now, scheduleWork, cancelScheduledWork};
15
+export {unstable_now, unstable_scheduleWork, unstable_cancelScheduledWork};
packages/shared/forks/ReactSchedulerTracking.umd.js
new
+36
@@ -0,0 +1,36 @@
1
+/**
2
+ * Copyright (c) 2013-present, Facebook, Inc.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow
8
+ */
9
+
10
+import React from 'react';
11
+
12
+const ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
13
+
14
+const {
15
+ __getInteractionsRef,
16
+ __getSubscriberRef,
17
+ unstable_clear,
18
+ unstable_getCurrent,
19
+ unstable_getThreadID,
20
+ unstable_subscribe,
21
+ unstable_track,
22
+ unstable_unsubscribe,
23
+ unstable_wrap,
24
+} = ReactInternals.SchedulerTracking;
25
+
26
+export {
27
+ __getInteractionsRef,
28
+ __getSubscriberRef,
29
+ unstable_clear,
30
+ unstable_getCurrent,
31
+ unstable_getThreadID,
32
+ unstable_subscribe,
33
+ unstable_track,
34
+ unstable_unsubscribe,
35
+ unstable_wrap,
36
+};
scripts/flow/environment.js
+1
@@ -10,6 +10,7 @@
10
/* eslint-disable */
11
12
declare var __PROFILE__: boolean;
13
+declare var __UMD__: boolean;
14
15
declare var __REACT_DEVTOOLS_GLOBAL_HOOK__: any; /*?{
16
inject: ?((stuff: Object) => void)
scripts/jest/setupEnvironment.js
+1
@@ -6,6 +6,7 @@ if (NODE_ENV !== 'development' && NODE_ENV !== 'production') {
6
}
7
global.__DEV__ = NODE_ENV === 'development';
8
global.__PROFILE__ = NODE_ENV === 'development';
9
+global.__UMD__ = false;
10
11
if (typeof window !== 'undefined') {
12
global.requestAnimationFrame = function(callback) {
scripts/rollup/build.js
+9
-2
@@ -18,6 +18,7 @@ const Stats = require('./stats');
18
const Sync = require('./sync');
19
const sizes = require('./plugins/sizes-plugin');
20
const useForks = require('./plugins/use-forks-plugin');
21
+const stripUnusedImports = require('./plugins/strip-unused-imports');
22
const extractErrorCodes = require('../error-codes/extract-errors');
23
const Packaging = require('./packaging');
24
const {asyncCopyTo, asyncRimRaf} = require('./utils');
@@ -272,7 +273,8 @@ function getPlugins(
273
bundleType,
274
globalName,
275
moduleType,
275
- modulesToStub
276
+ modulesToStub,
277
+ pureExternalModules
278
) {
279
const findAndRecordErrorCodes = extractErrorCodes(errorCodeOpts);
280
const forks = Modules.getForks(bundleType, entry, moduleType);
@@ -323,6 +325,7 @@ function getPlugins(
325
replace({
326
__DEV__: isProduction ? 'false' : 'true',
327
__PROFILE__: isProfiling || !isProduction ? 'true' : 'false',
328
+ __UMD__: isUMDBundle ? 'true' : 'false',
329
'process.env.NODE_ENV': isProduction ? "'production'" : "'development'",
330
}),
331
// We still need CommonJS for external deps like object-assign.
@@ -349,6 +352,9 @@ function getPlugins(
352
renaming: !shouldStayReadable,
353
})
354
),
355
+ // HACK to work around the fact that Rollup isn't removing unused, pure-module imports.
356
+ // Note that this plugin must be called after closure applies DCE.
357
+ isProduction && stripUnusedImports(pureExternalModules),
358
// Add the whitespace back if necessary.
359
shouldStayReadable && prettier({parser: 'babylon'}),
360
// License and haste headers, top-level `if` blocks.
@@ -468,7 +474,8 @@ async function createBundle(bundle, bundleType) {
474
bundleType,
475
bundle.global,
476
bundle.moduleType,
471
- bundle.modulesToStub
477
+ bundle.modulesToStub,
478
+ pureExternalModules
479
),
480
// We can't use getters in www.
481
legacy:
scripts/rollup/bundles.js
+20
-32
@@ -60,8 +60,10 @@ const bundles = [
60
UMD_PROD,
61
NODE_DEV,
62
NODE_PROD,
63
+ NODE_PROFILING,
64
FB_WWW_DEV,
65
FB_WWW_PROD,
66
+ FB_WWW_PROFILING,
67
],
68
moduleType: ISOMORPHIC,
69
entry: 'react',
@@ -85,7 +87,7 @@ const bundles = [
87
moduleType: RENDERER,
88
entry: 'react-dom',
89
global: 'ReactDOM',
88
- externals: ['interaction-tracking', 'react'],
90
+ externals: ['react'],
91
},
92
93
//******* Test Utils *******/
@@ -129,7 +131,7 @@ const bundles = [
131
moduleType: NON_FIBER_RENDERER,
132
entry: 'react-dom/server.browser',
133
global: 'ReactDOMServer',
132
- externals: ['interaction-tracking', 'react'],
134
+ externals: ['react'],
135
},
136
137
{
@@ -137,7 +139,7 @@ const bundles = [
139
bundleTypes: [NODE_DEV, NODE_PROD],
140
moduleType: NON_FIBER_RENDERER,
141
entry: 'react-dom/server.node',
140
- externals: ['interaction-tracking', 'react', 'stream'],
142
+ externals: ['react', 'stream'],
143
},
144
145
/******* React ART *******/
@@ -179,7 +181,6 @@ const bundles = [
181
'deepDiffer',
182
'deepFreezeAndThrowOnMutationInDev',
183
'flattenStyle',
182
- 'interaction-tracking',
184
'ReactNativeViewConfigRegistry',
185
],
186
},
@@ -200,7 +201,6 @@ const bundles = [
201
'deepDiffer',
202
'deepFreezeAndThrowOnMutationInDev',
203
'flattenStyle',
203
- 'interaction-tracking',
204
'ReactNativeViewConfigRegistry',
205
],
206
},
@@ -223,7 +223,6 @@ const bundles = [
223
'deepDiffer',
224
'deepFreezeAndThrowOnMutationInDev',
225
'flattenStyle',
226
- 'interaction-tracking',
226
'ReactNativeViewConfigRegistry',
227
],
228
},
@@ -245,7 +244,6 @@ const bundles = [
244
'deepDiffer',
245
'deepFreezeAndThrowOnMutationInDev',
246
'flattenStyle',
248
- 'interaction-tracking',
247
'ReactNativeViewConfigRegistry',
248
],
249
},
@@ -257,7 +255,7 @@ const bundles = [
255
moduleType: RENDERER,
256
entry: 'react-test-renderer',
257
global: 'ReactTestRenderer',
260
- externals: ['interaction-tracking', 'react'],
258
+ externals: ['react'],
259
},
260
261
{
@@ -322,7 +320,7 @@ const bundles = [
320
moduleType: RECONCILER,
321
entry: 'react-reconciler',
322
global: 'ReactReconciler',
325
- externals: ['interaction-tracking', 'react'],
323
+ externals: ['react'],
324
},
325
326
/******* React Persistent Reconciler *******/
@@ -332,7 +330,7 @@ const bundles = [
330
moduleType: RECONCILER,
331
entry: 'react-reconciler/persistent',
332
global: 'ReactPersistentReconciler',
335
- externals: ['interaction-tracking', 'react'],
333
+ externals: ['react'],
334
},
335
336
/******* Reflection *******/
@@ -385,38 +383,28 @@ const bundles = [
383
/******* React Scheduler (experimental) *******/
384
{
385
label: 'react-scheduler',
388
- bundleTypes: [
389
- UMD_DEV,
390
- UMD_PROD,
391
- NODE_DEV,
392
- NODE_PROD,
393
- FB_WWW_DEV,
394
- FB_WWW_PROD,
395
- ],
386
+ bundleTypes: [NODE_DEV, NODE_PROD, FB_WWW_DEV, FB_WWW_PROD],
387
moduleType: ISOMORPHIC,
388
entry: 'react-scheduler',
389
global: 'ReactScheduler',
390
externals: [],
391
},
392
402
- /******* interaction-tracking (experimental) *******/
393
{
404
- label: 'interaction-tracking',
405
- bundleTypes: [NODE_DEV, NODE_PROD, UMD_DEV, UMD_PROD],
394
+ label: 'react-scheduler-tracking',
395
+ bundleTypes: [
396
+ FB_WWW_DEV,
397
+ FB_WWW_PROD,
398
+ FB_WWW_PROFILING,
399
+ NODE_DEV,
400
+ NODE_PROD,
401
+ NODE_PROFILING,
402
+ ],
403
moduleType: ISOMORPHIC,
407
- entry: 'interaction-tracking',
408
- global: 'InteractionTracking',
404
+ entry: 'react-scheduler/tracking',
405
+ global: 'ReactSchedulerTracking',
406
externals: [],
407
},
411
-
412
- {
413
- label: 'interaction-tracking-subscriptions',
414
- bundleTypes: [NODE_DEV, NODE_PROD, UMD_DEV, UMD_PROD],
415
- moduleType: ISOMORPHIC,
416
- entry: 'interaction-tracking/subscriptions',
417
- global: 'InteractionTrackingSubscriptions',
418
- externals: ['interaction-tracking'],
419
- },
408
];
409
410
// Based on deep-freeze by substack (public domain)
scripts/rollup/forks.js
+30
-1
@@ -114,13 +114,42 @@ const forks = Object.freeze({
114
return null;
115
},
116
117
- 'shared/ReactScheduler': (bundleType, entry) => {
117
+ 'react-scheduler': (bundleType, entry, dependencies) => {
118
switch (bundleType) {
119
case FB_WWW_DEV:
120
case FB_WWW_PROD:
121
case FB_WWW_PROFILING:
122
return 'shared/forks/ReactScheduler.www.js';
123
+ case UMD_DEV:
124
+ case UMD_PROD:
125
+ if (dependencies.indexOf('react') === -1) {
126
+ // It's only safe to use this fork for modules that depend on React,
127
+ // because they read the re-exported API from the SECRET_INTERNALS object.
128
+ return null;
129
+ }
130
+ // Optimization: for UMDs, use the API that is already a part of the React
131
+ // package instead of requiring it to be loaded via a separate <script> tag
132
+ return 'shared/forks/ReactScheduler.umd.js';
133
+ default:
134
+ // For CJS bundles, use the shared NPM package.
135
+ return null;
136
+ }
137
+ },
138
+
139
+ 'react-scheduler/tracking': (bundleType, entry, dependencies) => {
140
+ switch (bundleType) {
141
+ case UMD_DEV:
142
+ case UMD_PROD:
143
+ if (dependencies.indexOf('react') === -1) {
144
+ // It's only safe to use this fork for modules that depend on React,
145
+ // because they read the re-exported API from the SECRET_INTERNALS object.
146
+ return null;
147
+ }
148
+ // Optimization: for UMDs, use the API that is already a part of the React
149
+ // package instead of requiring it to be loaded via a separate <script> tag
150
+ return 'shared/forks/ReactSchedulerTracking.umd.js';
151
default:
152
+ // For CJS bundles, use the shared NPM package.
153
return null;
154
}
155
},
scripts/rollup/modules.js
+4
-3
@@ -14,15 +14,16 @@ const HAS_NO_SIDE_EFFECTS_ON_IMPORT = false;
14
const importSideEffects = Object.freeze({
15
'prop-types/checkPropTypes': HAS_NO_SIDE_EFFECTS_ON_IMPORT,
16
deepFreezeAndThrowOnMutationInDev: HAS_NO_SIDE_EFFECTS_ON_IMPORT,
17
- 'interaction-tracking': HAS_NO_SIDE_EFFECTS_ON_IMPORT,
17
+ 'react-scheduler': HAS_NO_SIDE_EFFECTS_ON_IMPORT,
18
+ 'react-scheduler/tracking': HAS_NO_SIDE_EFFECTS_ON_IMPORT,
19
});
20
21
// Bundles exporting globals that other modules rely on.
22
const knownGlobals = Object.freeze({
23
react: 'React',
24
'react-dom': 'ReactDOM',
24
- 'interaction-tracking': 'InteractionTracking',
25
- 'interaction-tracking/subscriptions': 'InteractionTrackingSubscriptions',
25
+ 'react-scheduler': 'ReactScheduler',
26
+ 'react-scheduler/tracking': 'ReactSchedulerTracking',
27
});
28
29
// Given ['react'] in bundle externals, returns { 'react': 'React' }.
scripts/rollup/plugins/strip-unused-imports.js
new
+23
@@ -0,0 +1,23 @@
1
+/**
2
+ * Copyright (c) 2013-present, Facebook, Inc.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+'use strict';
8
+
9
+module.exports = function sizes(pureExternalModules) {
10
+ return {
11
+ name: 'scripts/rollup/plugins/strip-unused-imports',
12
+ transformBundle(code) {
13
+ pureExternalModules.forEach(module => {
14
+ const regExp = new RegExp(
15
+ `(?<!= *)require\\(["']${module}["']\\)[,;]`,
16
+ 'g'
17
+ );
18
+ code = code.replace(regExp, '');
19
+ });
20
+ return {code};
21
+ },
22
+ };
23
+};