Skip to content

Commit

Permalink
Merge branch 'main' into support-esm
Browse files Browse the repository at this point in the history
  • Loading branch information
snowystinger authored Oct 13, 2022
2 parents 024022a + 1b4d3af commit 0199e65
Show file tree
Hide file tree
Showing 12 changed files with 683 additions and 317 deletions.
11 changes: 11 additions & 0 deletions .circleci/comment.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const Octokit = require('@octokit/rest');
const fs = require('fs');

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

if (pr != null) {
let diffs = fs.readFileSync('/tmp/dist/ts-diff.txt');
await octokit.issues.createComment({
owner: 'adobe',
repo: 'react-spectrum',
Expand All @@ -75,5 +77,14 @@ async function run() {
* [View the storybook-16](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/storybook-16/index.html)
* [View the documentation](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/docs/index.html)`
});
if (diffs.length > 0) {
await octokit.issues.createComment({
owner: 'adobe',
repo: 'react-spectrum',
issue_number: pr,
body: `## API Changes
${diffs}
`});
}
}
}
74 changes: 74 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,57 @@ jobs:
name: lint
command: yarn lint

ts-build-branch:
executor: rsp-large
steps:
- restore_cache:
key: react-spectrum-{{ .Environment.CACHE_VERSION }}-{{ .Environment.CIRCLE_SHA1 }}

- run:
name: build branch apis
command: yarn build:api-branch

- persist_to_workspace:
root: dist
paths:
- 'branch-api/'

ts-build-fork-point:
executor: rsp-large
steps:
- restore_cache:
key: react-spectrum-{{ .Environment.CACHE_VERSION }}-{{ .Environment.CIRCLE_SHA1 }}

- run:
name: build fork-point apis
command: |
yarn build:api-branch --githash="origin/main" --output="base-api" && yarn build:api-branch && yarn compare:apis
- persist_to_workspace:
root: dist
paths:
- 'base-api/'

ts-diff:
executor: rsp-large
steps:
- restore_cache:
key: react-spectrum-{{ .Environment.CACHE_VERSION }}-{{ .Environment.CIRCLE_SHA1 }}

- attach_workspace:
at: /tmp/dist

- run:
name: compare api
command: |
mkdir -p dist
yarn --silent compare:apis --isCI --branch-api-dir="/tmp/dist/branch-api" --base-api-dir="/tmp/dist/base-api" | tee dist/ts-diff.txt
- persist_to_workspace:
root: dist
paths:
- 'ts-diff.txt'

storybook:
executor: rsp-large
steps:
Expand Down Expand Up @@ -349,6 +400,9 @@ jobs:
- restore_cache:
key: react-spectrum-{{ .Environment.CACHE_VERSION }}-{{ .Environment.CIRCLE_SHA1 }}

- attach_workspace:
at: /tmp/dist

- run:
name: comment on pr
command: |
Expand Down Expand Up @@ -398,6 +452,25 @@ workflows:
- lint:
requires:
- install
- ts-build-fork-point:
requires:
- install
filters:
branches:
ignore: main
- ts-build-branch:
requires:
- install
filters:
branches:
ignore: main
- ts-diff:
requires:
- ts-build-fork-point
- ts-build-branch
filters:
branches:
ignore: main
- storybook:
requires:
- install
Expand Down Expand Up @@ -450,6 +523,7 @@ workflows:
branches:
ignore: main
requires:
- ts-diff
- deploy
- comment:
name: comment-verdaccio
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"build:api-published": "node scripts/buildPublishedAPI.js",
"build:api-branch": "node scripts/buildBranchAPI.js",
"compare:apis": "node scripts/compareAPIs.js",
"check-apis": "yarn build:api-published && yarn build:api-branch && yarn compare:apis",
"check-apis": "yarn build:api-branch --githash=\"origin/main\" --output=\"base-api\" && yarn build:api-branch && yarn compare:apis",
"check-published-apis": "yarn build:api-published && yarn build:api-branch && yarn compare:apis",
"bumpVersions": "node scripts/bumpVersions.js",
"supportESM": "node scripts/supportESM.js"
},
Expand Down Expand Up @@ -106,6 +107,7 @@
"core-js": "^3.0.0",
"cross-env": "^7.0.2",
"cross-spawn": "^7.0.3",
"diff": "^5.1.0",
"delta-e": "^0.0.8",
"eslint": "^7.10.0",
"eslint-plugin-import": "^2.22.1",
Expand All @@ -127,7 +129,6 @@
"jest-junit": "^12.0.0",
"jest-matchmedia-mock": "^1.0.0",
"jsdom": "^16.7.0",
"json-diff-ts": "^1.1.0",
"lerna": "^3.13.2",
"lfcdn": "^0.4.2",
"md5": "^2.2.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/@react-aria/dnd/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function mapModality(modality: string) {
modality = 'virtual';
}

if (modality === 'virtual' && 'ontouchstart' in window) {
if (modality === 'virtual' && (typeof window !== 'undefined' && 'ontouchstart' in window)) {
modality = 'touch';
}

Expand Down
14 changes: 8 additions & 6 deletions packages/@react-spectrum/contextualhelp/src/ContextualHelp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

import {ActionButton} from '@react-spectrum/button';
import {classNames, SlotProvider} from '@react-spectrum/utils';
import {classNames, ClearSlots, SlotProvider} from '@react-spectrum/utils';
import {Dialog, DialogTrigger} from '@react-spectrum/dialog';
import {FocusableRef} from '@react-types/shared';
import HelpOutline from '@spectrum-icons/workflow/HelpOutline';
Expand Down Expand Up @@ -52,11 +52,13 @@ function ContextualHelp(props: SpectrumContextualHelpProps, ref: FocusableRef<HT
isQuiet>
{icon}
</ActionButton>
<SlotProvider slots={slots}>
<Dialog UNSAFE_className={classNames(helpStyles, 'react-spectrum-ContextualHelp-dialog')}>
{children}
</Dialog>
</SlotProvider>
<ClearSlots>
<SlotProvider slots={slots}>
<Dialog UNSAFE_className={classNames(helpStyles, 'react-spectrum-ContextualHelp-dialog')}>
{children}
</Dialog>
</SlotProvider>
</ClearSlots>
</DialogTrigger>
);
}
Expand Down
1 change: 1 addition & 0 deletions packages/@react-stately/collections/src/Section.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Section.getCollectionNode = function* getCollectionNode<T>(props: SectionProps<T
let {children, title, items} = props;
yield {
type: 'section',
props: props,
hasChildNodes: true,
rendered: title,
'aria-label': props['aria-label'],
Expand Down
41 changes: 26 additions & 15 deletions packages/dev/docs/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ export function Type({type}) {
case 'unknown':
case 'never':
return <Keyword {...type} />;
case 'this':
return <Keyword {...type} />;
case 'symbol':
return <Symbol {...type} />;
case 'identifier':
return <Identifier {...type} />;
case 'string':
Expand All @@ -88,6 +92,8 @@ export function Type({type}) {
return <IntersectionType {...type} />;
case 'application':
return <TypeApplication {...type} />;
case 'typeOperator':
return <TypeOperator {...type} />;
case 'function':
return <FunctionType {...type} />;
case 'parameter':
Expand Down Expand Up @@ -122,12 +128,24 @@ export function Type({type}) {
}
case 'conditional':
return <ConditionalType {...type} />;
case 'indexedAccess':
return <IndexedAccess {...type} />;
case 'keyof':
return <Keyof {...type} />;
default:
console.log('no render component for TYPE', type);
return null;
}
}

function TypeOperator({operator, value}) {
return <span><span className="token hljs-literal">{operator}</span>{' '}<Type type={value} /></span>;
}

function IndexedAccess({objectType, indexType}) {
return <span><Type type={objectType} />[<Type type={indexType} />]</span>;
}

function StringLiteral({value}) {
return <span className="token hljs-string">{`'${value.replace(/'/, '\\\'')}'`}</span>;
}
Expand All @@ -140,6 +158,14 @@ function BooleanLiteral({value}) {
return <span className="token hljs-literal">{'' + value}</span>;
}

function Symbol() {
return <span className="token hljs-literal">symbol</span>;
}

function Keyof({keyof}) {
return <span><Keyword type="keyof" />{' '}<Type type={keyof} /></span>;
}

function Keyword({type}) {
let link = getDoc(type);
if (link) {
Expand Down Expand Up @@ -523,21 +549,6 @@ function ObjectType({properties, exact}) {
let optional = property.optional;
let value = property.value;

// Special handling for methods
if (value && value.type === 'function' && !optional && token === 'method') {
return (
<div key={property.key} style={{paddingLeft: '1.5em'}}>
<span className="token hljs-function">{k}</span>
<span className="token punctuation">(</span>
<JoinList elements={value.parameters} joiner=", " />
<span className="token punctuation">)</span>
<span className="token punctuation">{': '}</span>
<Type type={value.return} />
{i < arr.length - 1 ? ',' : ''}
</div>
);
}

let punc = optional ? '?: ' : ': ';
return (
<div key={property.key} style={{paddingLeft: '1.5em'}}>
Expand Down
34 changes: 33 additions & 1 deletion packages/dev/parcel-transformer-docs/DocsTransformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,13 +333,28 @@ module.exports = new Transformer({
});
}

if (path.isTSTypeOperator()) {
return Object.assign(node, {
type: 'typeOperator',
operator: path.node.operator,
value: processExport(path.get('typeAnnotation'))
});
}

if (path.isTSThisType()) {
return Object.assign(node, {
type: 'this'
});
}

if (path.isTSPropertySignature()) {
let name = t.isStringLiteral(path.node.key) ? path.node.key.value : path.node.key.name;
let docs = getJSDocs(path);
let value = processExport(path.get('typeAnnotation.typeAnnotation'));
return Object.assign(node, addDocs({
type: 'property',
name,
value: processExport(path.get('typeAnnotation.typeAnnotation')),
value,
optional: path.node.optional || false
}, docs));
}
Expand Down Expand Up @@ -398,6 +413,10 @@ module.exports = new Transformer({
return bindings;
}

if (path.isTSSymbolKeyword()) {
return Object.assign(node, {type: 'symbol'});
}

if (path.isTSBooleanKeyword()) {
return Object.assign(node, {type: 'boolean'});
}
Expand Down Expand Up @@ -508,6 +527,19 @@ module.exports = new Transformer({
});
}

if (path.isTSModuleDeclaration()) {
// TODO: decide how we want to display something from a Global namespace
return node;
}

if (path.isTSIndexedAccessType()) {
return Object.assign(node, {
type: 'indexedAccess',
objectType: processExport(path.get('objectType')),
indexType: processExport(path.get('indexType'))
});
}

console.log('UNKNOWN TYPE', path.node.type);
}

Expand Down
Loading

0 comments on commit 0199e65

Please sign in to comment.