Skip to content

Commit

Permalink
Rename schedule to scheduler (facebook#13683)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon authored and jetoneza committed Jan 23, 2019
1 parent 0cfa4bc commit f84b1e0
Show file tree
Hide file tree
Showing 52 changed files with 213 additions and 209 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html style="width: 100%; height: 100%;">
<head>
<meta charset="utf-8">
<title>Schedule Test Page</title>
<title>Scheduler Test Page</title>
<style>
.correct {
border: solid green 2px;
Expand All @@ -13,7 +13,7 @@
</style>
</head>
<body>
<h1>Schedule Fixture</h1>
<h1>Scheduler Fixture</h1>
<p>
This fixture is for manual testing purposes, and the patterns used in
implementing it should not be used as a model. This is mainly for anyone
Expand Down Expand Up @@ -89,14 +89,15 @@ <h2>Tests:</h2>
<div> If the counter advanced while you were away from this tab, it's correct.</div>
</li>
</ol>
<script src="../../build/dist/schedule.development.js"></script>
<script src="../../build/dist/react.development.js"></script>
<script src="../../build/node_modules/scheduler/umd/scheduler.development.js"></script>
<script src="https://unpkg.com/babel-standalone@6/babel.js"></script>
<script type="text/babel">
const {
unstable_scheduleWork: scheduleWork,
unstable_cancelWork: cancelWork,
unstable_now: now
} = Schedule;
} = Scheduler;
function displayTestResult(testNumber) {
const expectationNode = document.getElementById('test-' + testNumber + '-expected');
const resultNode = document.getElementById('test-' + testNumber);
Expand Down
4 changes: 2 additions & 2 deletions fixtures/tracing/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ <h3>
</li>
</ol>
<!-- Load the tracing API before react to test that it's lazily evaluated -->
<script src="../../build/node_modules/schedule/umd/schedule.development.js"></script>
<script src="../../build/node_modules/schedule/umd/schedule-tracing.development.js"></script>
<script src="../../build/node_modules/scheduler/umd/scheduler.development.js"></script>
<script src="../../build/node_modules/scheduler/umd/scheduler-tracing.development.js"></script>
<script src="../../build/node_modules/react/umd/react.development.js"></script>
<script src="../../build/node_modules/react-dom/umd/react-dom.development.js"></script>
<script src="./script.js"></script>
Expand Down
52 changes: 26 additions & 26 deletions fixtures/tracing/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ function runAllTests() {
function checkSchedulerAPI() {
runTest(document.getElementById('checkSchedulerAPI'), () => {
if (
typeof Schedule === 'undefined' ||
typeof Schedule.unstable_now !== 'function' ||
typeof Schedule.unstable_scheduleWork !== 'function' ||
typeof Schedule.unstable_cancelScheduledWork !== 'function'
typeof Scheduler === 'undefined' ||
typeof Scheduler.unstable_now !== 'function' ||
typeof Scheduler.unstable_scheduleWork !== 'function' ||
typeof Scheduler.unstable_cancelScheduledWork !== 'function'
) {
throw 'API is not defined';
}

if (Schedule.unstable_now() !== performance.now()) {
if (Scheduler.unstable_now() !== performance.now()) {
throw 'API does not work';
}

Expand All @@ -47,20 +47,20 @@ function checkSchedulerAPI() {
function checkSchedulerTracingAPI() {
runTest(document.getElementById('checkSchedulerTracingAPI'), () => {
if (
typeof ScheduleTracing === 'undefined' ||
typeof ScheduleTracing.unstable_clear !== 'function' ||
typeof ScheduleTracing.unstable_getCurrent !== 'function' ||
typeof ScheduleTracing.unstable_getThreadID !== 'function' ||
typeof ScheduleTracing.unstable_trace !== 'function' ||
typeof ScheduleTracing.unstable_wrap !== 'function'
typeof SchedulerTracing === 'undefined' ||
typeof SchedulerTracing.unstable_clear !== 'function' ||
typeof SchedulerTracing.unstable_getCurrent !== 'function' ||
typeof SchedulerTracing.unstable_getThreadID !== 'function' ||
typeof SchedulerTracing.unstable_trace !== 'function' ||
typeof SchedulerTracing.unstable_wrap !== 'function'
) {
throw 'API is not defined';
}

try {
let interactionsSet;
ScheduleTracing.unstable_trace('test', 123, () => {
interactionsSet = ScheduleTracing.unstable_getCurrent();
SchedulerTracing.unstable_trace('test', 123, () => {
interactionsSet = SchedulerTracing.unstable_getCurrent();
});
if (interactionsSet.size !== 1) {
throw null;
Expand All @@ -74,10 +74,10 @@ function checkSchedulerTracingAPI() {
}

const ForwardedSchedulerTracing =
React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing;
React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracing;

if (
ScheduleTracing.unstable_getThreadID() ===
SchedulerTracing.unstable_getThreadID() ===
ForwardedSchedulerTracing.unstable_getThreadID()
) {
throw 'API forwarding is broken';
Expand All @@ -90,9 +90,9 @@ function checkSchedulerTracingSubscriptionsAPI() {
document.getElementById('checkSchedulerTracingSubscriptionsAPI'),
() => {
if (
typeof ScheduleTracing === 'undefined' ||
typeof ScheduleTracing.unstable_subscribe !== 'function' ||
typeof ScheduleTracing.unstable_unsubscribe !== 'function'
typeof SchedulerTracing === 'undefined' ||
typeof SchedulerTracing.unstable_subscribe !== 'function' ||
typeof SchedulerTracing.unstable_unsubscribe !== 'function'
) {
throw 'API is not defined';
}
Expand All @@ -114,17 +114,17 @@ function checkSchedulerTracingSubscriptionsAPI() {
};

try {
ScheduleTracing.unstable_subscribe(subscriber);
ScheduleTracing.unstable_trace('foo', 123, () => {});
ScheduleTracing.unstable_unsubscribe(subscriber);
SchedulerTracing.unstable_subscribe(subscriber);
SchedulerTracing.unstable_trace('foo', 123, () => {});
SchedulerTracing.unstable_unsubscribe(subscriber);
if (onInteractionTracedCalls.length !== 1) {
throw null;
}
const interaction = onInteractionTracedCalls[0][0];
if (interaction.name !== 'foo' || interaction.timestamp !== 123) {
throw null;
}
ScheduleTracing.unstable_trace('bar', 456, () => {});
SchedulerTracing.unstable_trace('bar', 456, () => {});
if (onInteractionTracedCalls.length !== 1) {
throw null;
}
Expand All @@ -134,13 +134,13 @@ function checkSchedulerTracingSubscriptionsAPI() {

const ForwardedSchedulerTracing =
React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
.ScheduleTracing;
.SchedulerTracing;

try {
ForwardedSchedulerTracing.unstable_subscribe(subscriber);
ScheduleTracing.unstable_trace('foo', 123, () => {});
SchedulerTracing.unstable_trace('foo', 123, () => {});
ForwardedSchedulerTracing.unstable_trace('bar', 456, () => {});
ScheduleTracing.unstable_unsubscribe(subscriber);
SchedulerTracing.unstable_unsubscribe(subscriber);
if (onInteractionTracedCalls.length !== 3) {
throw null;
}
Expand Down Expand Up @@ -172,7 +172,7 @@ function checkEndToEndIntegration() {
const onRender = (...args) => onRenderCalls.push(args);
const container = document.createElement('div');

ScheduleTracing.unstable_trace('render', 123, () => {
SchedulerTracing.unstable_trace('render', 123, () => {
ReactDOM.render(
React.createElement(
React.unstable_Profiler,
Expand Down
7 changes: 5 additions & 2 deletions fixtures/unstable-async/suspense/src/components/App.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import React, {Placeholder, PureComponent} from 'react';
import {unstable_scheduleWork} from 'schedule';
import {unstable_trace as trace, unstable_wrap as wrap} from 'schedule/tracing';
import {unstable_scheduleWork} from 'scheduler';
import {
unstable_trace as trace,
unstable_wrap as wrap,
} from 'scheduler/tracing';
import {createResource} from 'simple-cache-provider';
import {cache} from '../cache';
import Spinner from './Spinner';
Expand Down
2 changes: 1 addition & 1 deletion fixtures/unstable-async/suspense/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {Fragment, PureComponent} from 'react';
import {unstable_createRoot, render} from 'react-dom';
import {unstable_trace as trace} from 'schedule/tracing';
import {unstable_trace as trace} from 'scheduler/tracing';
import {cache} from './cache';
import {
setFakeRequestTime,
Expand Down
2 changes: 1 addition & 1 deletion fixtures/unstable-async/time-slicing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ There are also known bugs and inefficiencies in master so **don't use this fixtu
# 1: Build react from source
cd /path/to/react
yarn
yarn build dom-client,core,simple-cache-provider,schedule --type=NODE
yarn build dom-client,core,simple-cache-provider,scheduler --type=NODE

# 2: Install fixture dependencies
cd fixtures/unstable-async/time-slicing/
Expand Down
2 changes: 1 addition & 1 deletion fixtures/unstable-async/time-slicing/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {PureComponent} from 'react';
import {flushSync, render} from 'react-dom';
import {unstable_scheduleWork} from 'schedule';
import {unstable_scheduleWork} from 'scheduler';
import _ from 'lodash';
import Charts from './Charts';
import Clock from './Clock';
Expand Down
2 changes: 1 addition & 1 deletion packages/react-art/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1",
"prop-types": "^15.6.2",
"schedule": "^0.5.0"
"scheduler": "^0.9.0"
},
"peerDependencies": {
"react": "^16.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/react-art/src/ReactARTHostConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export {
unstable_now as now,
unstable_scheduleWork as scheduleDeferredCallback,
unstable_cancelScheduledWork as cancelDeferredCallback,
} from 'schedule';
} from 'scheduler';
import Transform from 'art/core/transform';
import Mode from 'art/modes/current';
import invariant from 'shared/invariant';
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1",
"prop-types": "^15.6.2",
"schedule": "^0.5.0"
"scheduler": "^0.9.0"
},
"peerDependencies": {
"react": "^16.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/client/ReactDOMHostConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export {
unstable_now as now,
unstable_scheduleWork as scheduleDeferredCallback,
unstable_cancelScheduledWork as cancelDeferredCallback,
} from 'schedule';
} from 'scheduler';

let SUPPRESS_HYDRATION_WARNING;
if (__DEV__) {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-renderer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dependencies": {
"object-assign": "^4.1.1",
"prop-types": "^15.6.2",
"schedule": "^0.5.0"
"scheduler": "^0.9.0"
},
"peerDependencies": {
"react": "^16.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1",
"prop-types": "^15.6.2",
"schedule": "^0.5.0"
"scheduler": "^0.9.0"
},
"browserify": {
"transform": [
Expand Down
4 changes: 2 additions & 2 deletions packages/react-reconciler/src/ReactFiberRoot.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
import type {Fiber} from './ReactFiber';
import type {ExpirationTime} from './ReactFiberExpirationTime';
import type {TimeoutHandle, NoTimeout} from './ReactFiberHostConfig';
import type {Interaction} from 'schedule/src/Tracing';
import type {Interaction} from 'scheduler/src/Tracing';

import {noTimeout} from './ReactFiberHostConfig';
import {createHostRootFiber} from './ReactFiber';
import {NoWork} from './ReactFiberExpirationTime';
import {enableSchedulerTracing} from 'shared/ReactFeatureFlags';
import {unstable_getThreadID} from 'schedule/tracing';
import {unstable_getThreadID} from 'scheduler/tracing';

/* eslint-disable no-use-before-define */
// TODO: This should be lifted into the renderer.
Expand Down
4 changes: 2 additions & 2 deletions packages/react-reconciler/src/ReactFiberScheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import type {Fiber} from './ReactFiber';
import type {Batch, FiberRoot} from './ReactFiberRoot';
import type {ExpirationTime} from './ReactFiberExpirationTime';
import type {Interaction} from 'schedule/src/Tracing';
import type {Interaction} from 'scheduler/src/Tracing';

import {__interactionsRef, __subscriberRef} from 'schedule/tracing';
import {__interactionsRef, __subscriberRef} from 'scheduler/tracing';
import {
invokeGuardedCallback,
hasCaughtError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('ReactTracing', () => {
const ReactFeatureFlags = require('shared/ReactFeatureFlags');
ReactFeatureFlags.enableSchedulerTracing = false;

require('schedule/tracing');
require('scheduler/tracing');

ReactFeatureFlags.enableSchedulerTracing = true;

Expand Down
2 changes: 1 addition & 1 deletion packages/react-test-renderer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"object-assign": "^4.1.1",
"prop-types": "^15.6.2",
"react-is": "^16.5.2",
"schedule": "^0.5.0"
"scheduler": "^0.9.0"
},
"peerDependencies": {
"react": "^16.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1",
"prop-types": "^15.6.2",
"schedule": "^0.5.0"
"scheduler": "^0.9.0"
},
"browserify": {
"transform": [
Expand Down
8 changes: 4 additions & 4 deletions packages/react/src/ReactSharedInternals.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
unstable_cancelScheduledWork,
unstable_now,
unstable_scheduleWork,
} from 'schedule';
} from 'scheduler';
import {
__interactionsRef,
__subscriberRef,
Expand All @@ -21,7 +21,7 @@ import {
unstable_trace,
unstable_unsubscribe,
unstable_wrap,
} from 'schedule/tracing';
} from 'scheduler/tracing';
import ReactCurrentOwner from './ReactCurrentOwner';
import ReactDebugCurrentFrame from './ReactDebugCurrentFrame';

Expand All @@ -38,12 +38,12 @@ if (__UMD__) {
// This re-export is only required for UMD bundles;
// CJS bundles use the shared NPM package.
Object.assign(ReactSharedInternals, {
Schedule: {
Scheduler: {
unstable_cancelScheduledWork,
unstable_now,
unstable_scheduleWork,
},
ScheduleTracing: {
SchedulerTracing: {
__interactionsRef,
__subscriberRef,
unstable_clear,
Expand Down
10 changes: 5 additions & 5 deletions packages/react/src/__tests__/ReactProfiler-test.internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function loadModules({
ReactFeatureFlags.replayFailedUnitOfWorkWithInvokeGuardedCallback = replayFailedUnitOfWorkWithInvokeGuardedCallback;

React = require('react');
SchedulerTracing = require('schedule/tracing');
SchedulerTracing = require('scheduler/tracing');

if (useNoopRenderer) {
ReactNoop = require('react-noop-renderer');
Expand Down Expand Up @@ -1460,7 +1460,7 @@ describe('Profiler', () => {
);
expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();

// The schedule/tracing package will notify of work started for the default thread,
// The scheduler/tracing package will notify of work started for the default thread,
// But React shouldn't notify until it's been flushed.
expect(getWorkForReactThreads(onWorkStarted)).toHaveLength(0);
expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(0);
Expand Down Expand Up @@ -1518,7 +1518,7 @@ describe('Profiler', () => {
// Update state again to verify our traced interaction isn't registered twice
instance.setState({count: 2});

// The schedule/tracing package will notify of work started for the default thread,
// The scheduler/tracing package will notify of work started for the default thread,
// But React shouldn't notify until it's been flushed.
expect(getWorkForReactThreads(onWorkStarted)).toHaveLength(0);
expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(0);
Expand Down Expand Up @@ -1621,7 +1621,7 @@ describe('Profiler', () => {
);
expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(2);

// The schedule/tracing package will notify of work started for the default thread,
// The scheduler/tracing package will notify of work started for the default thread,
// But React shouldn't notify until it's been flushed.
expect(getWorkForReactThreads(onWorkStarted)).toHaveLength(0);
expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(0);
Expand Down Expand Up @@ -1799,7 +1799,7 @@ describe('Profiler', () => {
expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1);

// Work might be started multiple times before being completed.
// This is okay; it's part of the schedule/tracing contract.
// This is okay; it's part of the scheduler/tracing contract.
expect(getWorkForReactThreads(onWorkStarted)).toHaveLength(3);
expect(getWorkForReactThreads(onWorkStarted)[1][0]).toMatchInteractions(
[interactionLowPri, interactionHighPri],
Expand Down

0 comments on commit f84b1e0

Please sign in to comment.