Skip to content

Commit 0199e65

Browse files
authored
Merge branch 'main' into support-esm
2 parents 024022a + 1b4d3af commit 0199e65

File tree

12 files changed

+683
-317
lines changed

12 files changed

+683
-317
lines changed

.circleci/comment.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const Octokit = require('@octokit/rest');
2+
const fs = require('fs');
23

34
const octokit = new Octokit({
45
auth: `token ${process.env.GITHUB_TOKEN}`
@@ -64,6 +65,7 @@ async function run() {
6465
}
6566

6667
if (pr != null) {
68+
let diffs = fs.readFileSync('/tmp/dist/ts-diff.txt');
6769
await octokit.issues.createComment({
6870
owner: 'adobe',
6971
repo: 'react-spectrum',
@@ -75,5 +77,14 @@ async function run() {
7577
* [View the storybook-16](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/storybook-16/index.html)
7678
* [View the documentation](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/docs/index.html)`
7779
});
80+
if (diffs.length > 0) {
81+
await octokit.issues.createComment({
82+
owner: 'adobe',
83+
repo: 'react-spectrum',
84+
issue_number: pr,
85+
body: `## API Changes
86+
${diffs}
87+
`});
88+
}
7889
}
7990
}

.circleci/config.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,57 @@ jobs:
216216
name: lint
217217
command: yarn lint
218218

219+
ts-build-branch:
220+
executor: rsp-large
221+
steps:
222+
- restore_cache:
223+
key: react-spectrum-{{ .Environment.CACHE_VERSION }}-{{ .Environment.CIRCLE_SHA1 }}
224+
225+
- run:
226+
name: build branch apis
227+
command: yarn build:api-branch
228+
229+
- persist_to_workspace:
230+
root: dist
231+
paths:
232+
- 'branch-api/'
233+
234+
ts-build-fork-point:
235+
executor: rsp-large
236+
steps:
237+
- restore_cache:
238+
key: react-spectrum-{{ .Environment.CACHE_VERSION }}-{{ .Environment.CIRCLE_SHA1 }}
239+
240+
- run:
241+
name: build fork-point apis
242+
command: |
243+
yarn build:api-branch --githash="origin/main" --output="base-api" && yarn build:api-branch && yarn compare:apis
244+
245+
- persist_to_workspace:
246+
root: dist
247+
paths:
248+
- 'base-api/'
249+
250+
ts-diff:
251+
executor: rsp-large
252+
steps:
253+
- restore_cache:
254+
key: react-spectrum-{{ .Environment.CACHE_VERSION }}-{{ .Environment.CIRCLE_SHA1 }}
255+
256+
- attach_workspace:
257+
at: /tmp/dist
258+
259+
- run:
260+
name: compare api
261+
command: |
262+
mkdir -p dist
263+
yarn --silent compare:apis --isCI --branch-api-dir="/tmp/dist/branch-api" --base-api-dir="/tmp/dist/base-api" | tee dist/ts-diff.txt
264+
265+
- persist_to_workspace:
266+
root: dist
267+
paths:
268+
- 'ts-diff.txt'
269+
219270
storybook:
220271
executor: rsp-large
221272
steps:
@@ -349,6 +400,9 @@ jobs:
349400
- restore_cache:
350401
key: react-spectrum-{{ .Environment.CACHE_VERSION }}-{{ .Environment.CIRCLE_SHA1 }}
351402

403+
- attach_workspace:
404+
at: /tmp/dist
405+
352406
- run:
353407
name: comment on pr
354408
command: |
@@ -398,6 +452,25 @@ workflows:
398452
- lint:
399453
requires:
400454
- install
455+
- ts-build-fork-point:
456+
requires:
457+
- install
458+
filters:
459+
branches:
460+
ignore: main
461+
- ts-build-branch:
462+
requires:
463+
- install
464+
filters:
465+
branches:
466+
ignore: main
467+
- ts-diff:
468+
requires:
469+
- ts-build-fork-point
470+
- ts-build-branch
471+
filters:
472+
branches:
473+
ignore: main
401474
- storybook:
402475
requires:
403476
- install
@@ -450,6 +523,7 @@ workflows:
450523
branches:
451524
ignore: main
452525
requires:
526+
- ts-diff
453527
- deploy
454528
- comment:
455529
name: comment-verdaccio

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
"build:api-published": "node scripts/buildPublishedAPI.js",
4141
"build:api-branch": "node scripts/buildBranchAPI.js",
4242
"compare:apis": "node scripts/compareAPIs.js",
43-
"check-apis": "yarn build:api-published && yarn build:api-branch && yarn compare:apis",
43+
"check-apis": "yarn build:api-branch --githash=\"origin/main\" --output=\"base-api\" && yarn build:api-branch && yarn compare:apis",
44+
"check-published-apis": "yarn build:api-published && yarn build:api-branch && yarn compare:apis",
4445
"bumpVersions": "node scripts/bumpVersions.js",
4546
"supportESM": "node scripts/supportESM.js"
4647
},
@@ -106,6 +107,7 @@
106107
"core-js": "^3.0.0",
107108
"cross-env": "^7.0.2",
108109
"cross-spawn": "^7.0.3",
110+
"diff": "^5.1.0",
109111
"delta-e": "^0.0.8",
110112
"eslint": "^7.10.0",
111113
"eslint-plugin-import": "^2.22.1",
@@ -127,7 +129,6 @@
127129
"jest-junit": "^12.0.0",
128130
"jest-matchmedia-mock": "^1.0.0",
129131
"jsdom": "^16.7.0",
130-
"json-diff-ts": "^1.1.0",
131132
"lerna": "^3.13.2",
132133
"lfcdn": "^0.4.2",
133134
"md5": "^2.2.1",

packages/@react-aria/dnd/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function mapModality(modality: string) {
6262
modality = 'virtual';
6363
}
6464

65-
if (modality === 'virtual' && 'ontouchstart' in window) {
65+
if (modality === 'virtual' && (typeof window !== 'undefined' && 'ontouchstart' in window)) {
6666
modality = 'touch';
6767
}
6868

packages/@react-spectrum/contextualhelp/src/ContextualHelp.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212

1313
import {ActionButton} from '@react-spectrum/button';
14-
import {classNames, SlotProvider} from '@react-spectrum/utils';
14+
import {classNames, ClearSlots, SlotProvider} from '@react-spectrum/utils';
1515
import {Dialog, DialogTrigger} from '@react-spectrum/dialog';
1616
import {FocusableRef} from '@react-types/shared';
1717
import HelpOutline from '@spectrum-icons/workflow/HelpOutline';
@@ -52,11 +52,13 @@ function ContextualHelp(props: SpectrumContextualHelpProps, ref: FocusableRef<HT
5252
isQuiet>
5353
{icon}
5454
</ActionButton>
55-
<SlotProvider slots={slots}>
56-
<Dialog UNSAFE_className={classNames(helpStyles, 'react-spectrum-ContextualHelp-dialog')}>
57-
{children}
58-
</Dialog>
59-
</SlotProvider>
55+
<ClearSlots>
56+
<SlotProvider slots={slots}>
57+
<Dialog UNSAFE_className={classNames(helpStyles, 'react-spectrum-ContextualHelp-dialog')}>
58+
{children}
59+
</Dialog>
60+
</SlotProvider>
61+
</ClearSlots>
6062
</DialogTrigger>
6163
);
6264
}

packages/@react-stately/collections/src/Section.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Section.getCollectionNode = function* getCollectionNode<T>(props: SectionProps<T
2222
let {children, title, items} = props;
2323
yield {
2424
type: 'section',
25+
props: props,
2526
hasChildNodes: true,
2627
rendered: title,
2728
'aria-label': props['aria-label'],

packages/dev/docs/src/types.js

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ export function Type({type}) {
6262
case 'unknown':
6363
case 'never':
6464
return <Keyword {...type} />;
65+
case 'this':
66+
return <Keyword {...type} />;
67+
case 'symbol':
68+
return <Symbol {...type} />;
6569
case 'identifier':
6670
return <Identifier {...type} />;
6771
case 'string':
@@ -88,6 +92,8 @@ export function Type({type}) {
8892
return <IntersectionType {...type} />;
8993
case 'application':
9094
return <TypeApplication {...type} />;
95+
case 'typeOperator':
96+
return <TypeOperator {...type} />;
9197
case 'function':
9298
return <FunctionType {...type} />;
9399
case 'parameter':
@@ -122,12 +128,24 @@ export function Type({type}) {
122128
}
123129
case 'conditional':
124130
return <ConditionalType {...type} />;
131+
case 'indexedAccess':
132+
return <IndexedAccess {...type} />;
133+
case 'keyof':
134+
return <Keyof {...type} />;
125135
default:
126136
console.log('no render component for TYPE', type);
127137
return null;
128138
}
129139
}
130140

141+
function TypeOperator({operator, value}) {
142+
return <span><span className="token hljs-literal">{operator}</span>{' '}<Type type={value} /></span>;
143+
}
144+
145+
function IndexedAccess({objectType, indexType}) {
146+
return <span><Type type={objectType} />[<Type type={indexType} />]</span>;
147+
}
148+
131149
function StringLiteral({value}) {
132150
return <span className="token hljs-string">{`'${value.replace(/'/, '\\\'')}'`}</span>;
133151
}
@@ -140,6 +158,14 @@ function BooleanLiteral({value}) {
140158
return <span className="token hljs-literal">{'' + value}</span>;
141159
}
142160

161+
function Symbol() {
162+
return <span className="token hljs-literal">symbol</span>;
163+
}
164+
165+
function Keyof({keyof}) {
166+
return <span><Keyword type="keyof" />{' '}<Type type={keyof} /></span>;
167+
}
168+
143169
function Keyword({type}) {
144170
let link = getDoc(type);
145171
if (link) {
@@ -523,21 +549,6 @@ function ObjectType({properties, exact}) {
523549
let optional = property.optional;
524550
let value = property.value;
525551

526-
// Special handling for methods
527-
if (value && value.type === 'function' && !optional && token === 'method') {
528-
return (
529-
<div key={property.key} style={{paddingLeft: '1.5em'}}>
530-
<span className="token hljs-function">{k}</span>
531-
<span className="token punctuation">(</span>
532-
<JoinList elements={value.parameters} joiner=", " />
533-
<span className="token punctuation">)</span>
534-
<span className="token punctuation">{': '}</span>
535-
<Type type={value.return} />
536-
{i < arr.length - 1 ? ',' : ''}
537-
</div>
538-
);
539-
}
540-
541552
let punc = optional ? '?: ' : ': ';
542553
return (
543554
<div key={property.key} style={{paddingLeft: '1.5em'}}>

packages/dev/parcel-transformer-docs/DocsTransformer.js

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,13 +333,28 @@ module.exports = new Transformer({
333333
});
334334
}
335335

336+
if (path.isTSTypeOperator()) {
337+
return Object.assign(node, {
338+
type: 'typeOperator',
339+
operator: path.node.operator,
340+
value: processExport(path.get('typeAnnotation'))
341+
});
342+
}
343+
344+
if (path.isTSThisType()) {
345+
return Object.assign(node, {
346+
type: 'this'
347+
});
348+
}
349+
336350
if (path.isTSPropertySignature()) {
337351
let name = t.isStringLiteral(path.node.key) ? path.node.key.value : path.node.key.name;
338352
let docs = getJSDocs(path);
353+
let value = processExport(path.get('typeAnnotation.typeAnnotation'));
339354
return Object.assign(node, addDocs({
340355
type: 'property',
341356
name,
342-
value: processExport(path.get('typeAnnotation.typeAnnotation')),
357+
value,
343358
optional: path.node.optional || false
344359
}, docs));
345360
}
@@ -398,6 +413,10 @@ module.exports = new Transformer({
398413
return bindings;
399414
}
400415

416+
if (path.isTSSymbolKeyword()) {
417+
return Object.assign(node, {type: 'symbol'});
418+
}
419+
401420
if (path.isTSBooleanKeyword()) {
402421
return Object.assign(node, {type: 'boolean'});
403422
}
@@ -508,6 +527,19 @@ module.exports = new Transformer({
508527
});
509528
}
510529

530+
if (path.isTSModuleDeclaration()) {
531+
// TODO: decide how we want to display something from a Global namespace
532+
return node;
533+
}
534+
535+
if (path.isTSIndexedAccessType()) {
536+
return Object.assign(node, {
537+
type: 'indexedAccess',
538+
objectType: processExport(path.get('objectType')),
539+
indexType: processExport(path.get('indexType'))
540+
});
541+
}
542+
511543
console.log('UNKNOWN TYPE', path.node.type);
512544
}
513545

0 commit comments

Comments
 (0)