Skip to content

Commit d1a518c

Browse files
Filmbostock
andauthored
Adopt type=module (#123)
* Adopt type=module follow changes in d3-format: * type=module * add exports * remove zip * license: ISC * update dependencies **TESTS NOT WORKING** * fix LICENSE * Update README * remove Sublime project * add eslint.json * related d3/d3#3502; extract copyrights from LICENSE * update dependencies * remove duplicate .eslintrc * cleaner imports; fix tests * cleaner imports; fix tests * cleaner imports; fix tests * cleaner imports; fix tests Co-authored-by: Mike Bostock <[email protected]>
1 parent abe6511 commit d1a518c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+3005
-3468
lines changed

.eslintrc.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
"ecmaVersion": 8
66
},
77
"env": {
8-
"es6": true,
9-
"node": true,
10-
"browser": true
8+
"es6": true
119
},
1210
"rules": {
1311
"no-cond-assign": 0

.github/eslint.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "eslint-compact",
5+
"pattern": [
6+
{
7+
"regexp": "^(.+):\\sline\\s(\\d+),\\scol\\s(\\d+),\\s(Error|Warning|Info)\\s-\\s(.+)\\s\\((.+)\\)$",
8+
"file": 1,
9+
"line": 2,
10+
"column": 3,
11+
"severity": 4,
12+
"message": 5,
13+
"code": 6
14+
}
15+
]
16+
}
17+
]
18+
}

.github/workflows/node.js.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
2+
3+
name: Node.js CI
4+
5+
on:
6+
push:
7+
branches: [ main ]
8+
pull_request:
9+
branches: [ main ]
10+
11+
jobs:
12+
build:
13+
14+
runs-on: ubuntu-latest
15+
16+
strategy:
17+
matrix:
18+
node-version: [14.x]
19+
20+
steps:
21+
- uses: actions/checkout@v2
22+
- name: Use Node.js ${{ matrix.node-version }}
23+
uses: actions/setup-node@v1
24+
with:
25+
node-version: ${{ matrix.node-version }}
26+
- run: yarn --frozen-lockfile
27+
- run: |
28+
echo ::add-matcher::.github/eslint.json
29+
yarn run eslint src test --format=compact
30+
- run: yarn test

LICENSE

Lines changed: 13 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,13 @@
1-
Copyright (c) 2010-2015, Michael Bostock
2-
All rights reserved.
3-
4-
Redistribution and use in source and binary forms, with or without
5-
modification, are permitted provided that the following conditions are met:
6-
7-
* Redistributions of source code must retain the above copyright notice, this
8-
list of conditions and the following disclaimer.
9-
10-
* Redistributions in binary form must reproduce the above copyright notice,
11-
this list of conditions and the following disclaimer in the documentation
12-
and/or other materials provided with the distribution.
13-
14-
* The name Michael Bostock may not be used to endorse or promote products
15-
derived from this software without specific prior written permission.
16-
17-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20-
DISCLAIMED. IN NO EVENT SHALL MICHAEL BOSTOCK BE LIABLE FOR ANY DIRECT,
21-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
22-
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24-
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26-
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27-
28-
TERMS OF USE - EASING EQUATIONS
29-
30-
Open source under the BSD License.
31-
32-
Copyright 2001 Robert Penner
33-
All rights reserved.
34-
35-
Redistribution and use in source and binary forms, with or without modification,
36-
are permitted provided that the following conditions are met:
37-
38-
- Redistributions of source code must retain the above copyright notice, this
39-
list of conditions and the following disclaimer.
40-
41-
- Redistributions in binary form must reproduce the above copyright notice,
42-
this list of conditions and the following disclaimer in the documentation
43-
and/or other materials provided with the distribution.
44-
45-
- Neither the name of the author nor the names of contributors may be used to
46-
endorse or promote products derived from this software without specific prior
47-
written permission.
48-
49-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
50-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
51-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
52-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
53-
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
54-
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
55-
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
56-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
57-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
58-
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1+
Copyright 2010-2021 Mike Bostock
2+
3+
Permission to use, copy, modify, and/or distribute this software for any purpose
4+
with or without fee is hereby granted, provided that the above copyright notice
5+
and this permission notice appear in all copies.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
9+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
11+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
12+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
13+
THIS SOFTWARE.

README.md

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,36 @@ To compute intermediate state, transitions leverage a variety of [built-in inter
1616

1717
## Installing
1818

19-
If you use NPM, `npm install d3-transition`. Otherwise, download the [latest release](https://github.com/d3/d3-transition/releases/latest). You can also load directly from [d3js.org](https://d3js.org), either as a [standalone library](https://d3js.org/d3-transition.v2.min.js) or as part of [D3](https://github.com/d3/d3). AMD, CommonJS, and vanilla environments are supported. In vanilla, a `d3` global is exported:
19+
If you use npm, `npm install d3-transition`. You can also download the [latest release on GitHub](https://github.com/d3/d3-transition/releases/latest). For vanilla HTML in modern browsers, import d3-transition from Skypack:
2020

2121
```html
22-
<script src="https://d3js.org/d3-color.v2.min.js"></script>
23-
<script src="https://d3js.org/d3-dispatch.v2.min.js"></script>
24-
<script src="https://d3js.org/d3-ease.v2.min.js"></script>
25-
<script src="https://d3js.org/d3-interpolate.v2.min.js"></script>
26-
<script src="https://d3js.org/d3-selection.v2.min.js"></script>
27-
<script src="https://d3js.org/d3-timer.v2.min.js"></script>
28-
<script src="https://d3js.org/d3-transition.v2.min.js"></script>
22+
<script type="module">
23+
24+
import {transition} from "https://cdn.skypack.dev/d3-transition@3";
25+
26+
const t = transition();
27+
28+
</script>
29+
```
30+
31+
For legacy environments, you can load d3-transition’s UMD bundle from an npm-based CDN such as jsDelivr; a `d3` global is exported:
32+
33+
```html
34+
<script src="https://cdn.jsdelivr.net/npm/d3-color@3"></script>
35+
<script src="https://cdn.jsdelivr.net/npm/d3-dispatch@3"></script>
36+
<script src="https://cdn.jsdelivr.net/npm/d3-ease@3"></script>
37+
<script src="https://cdn.jsdelivr.net/npm/d3-interpolate@3"></script>
38+
<script src="https://cdn.jsdelivr.net/npm/d3-selection@3"></script>
39+
<script src="https://cdn.jsdelivr.net/npm/d3-timer@3"></script>
40+
<script src="https://cdn.jsdelivr.net/npm/d3-transition@3"></script>
2941
<script>
3042
31-
var transition = d3.transition();
43+
const t = d3.transition();
3244
3345
</script>
3446
```
3547

36-
[Try d3-transition in your browser.](https://tonicdev.com/npm/d3-transition)
48+
[Try d3-transition in your browser.](https://observablehq.com/collection/@d3/d3-transition)
3749

3850
## API Reference
3951

@@ -296,7 +308,7 @@ For each selected element, sets the [text content](http://www.w3.org/TR/DOM-Leve
296308
To interpolate text rather than to set it on start, use [*transition*.textTween](#transition_textTween) or append a replacement element and cross-fade opacity. Text is not interpolated by default because it is usually undesirable.
297309

298310
<a name="transition_textTween" href="#transition_textTween">#</a> <i>transition</i>.<b>textTween</b>(<i>factory</i>) · [Source](https://github.com/d3/d3-transition/blob/master/src/transition/textTween.js), [Examples](https://observablehq.com/@d3/transition-texttween)
299-
311+
300312
If *factory* is specified and not null, assigns the text [tween](#transition_tween) to the specified interpolator *factory*. An interpolator factory is a function that returns an [interpolator](https://github.com/d3/d3-interpolate); when the transition starts, the *factory* is evaluated for each selected element, in order, being passed the current datum `d` and index `i`, with the `this` context as the current DOM element. The returned interpolator will then be invoked for each frame of the transition, in order, being passed the [eased](#transition_ease) time *t*, typically in the range [0, 1]. Lastly, the return value of the interpolator will be used to set the text. The interpolator must return a string.
301313

302314
For example, to interpolate the text with integers from 0 to 100:

d3-transition.sublime-project

Lines changed: 0 additions & 17 deletions
This file was deleted.

package.json

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,61 @@
22
"name": "d3-transition",
33
"version": "2.0.0",
44
"description": "Animated transitions for D3 selections.",
5+
"homepage": "https://d3js.org/d3-transition/",
6+
"repository": {
7+
"type": "git",
8+
"url": "https://github.com/d3/d3-transition.git"
9+
},
510
"keywords": [
611
"d3",
712
"d3-module",
813
"dom",
914
"transition",
1015
"animation"
1116
],
12-
"homepage": "https://d3js.org/d3-transition/",
13-
"license": "BSD-3-Clause",
17+
"license": "ISC",
1418
"author": {
1519
"name": "Mike Bostock",
1620
"url": "https://bost.ocks.org/mike"
1721
},
18-
"main": "dist/d3-transition.js",
19-
"unpkg": "dist/d3-transition.min.js",
20-
"jsdelivr": "dist/d3-transition.min.js",
21-
"module": "src/index.js",
22-
"repository": {
23-
"type": "git",
24-
"url": "https://github.com/d3/d3-transition.git"
25-
},
22+
"type": "module",
2623
"files": [
2724
"dist/**/*.js",
2825
"src/**/*.js"
2926
],
30-
"scripts": {
31-
"pretest": "rollup -c",
32-
"test": "tape 'test/**/*-test.js' && eslint src",
33-
"prepublishOnly": "rm -rf dist && yarn test",
34-
"postpublish": "git push && git push --tags && cd ../d3.github.com && git pull && cp ../${npm_package_name}/dist/${npm_package_name}.js ${npm_package_name}.v${npm_package_version%%.*}.js && cp ../${npm_package_name}/dist/${npm_package_name}.min.js ${npm_package_name}.v${npm_package_version%%.*}.min.js && git add ${npm_package_name}.v${npm_package_version%%.*}.js ${npm_package_name}.v${npm_package_version%%.*}.min.js && git commit -m \"${npm_package_name} ${npm_package_version}\" && git push && cd - && zip -j dist/${npm_package_name}.zip -- LICENSE README.md dist/${npm_package_name}.js dist/${npm_package_name}.min.js"
27+
"module": "src/index.js",
28+
"main": "src/index.js",
29+
"jsdelivr": "dist/d3-transition.min.js",
30+
"unpkg": "dist/d3-transition.min.js",
31+
"exports": {
32+
"umd": "./dist/d3-transition.min.js",
33+
"default": "./src/index.js"
3534
},
3635
"sideEffects": true,
3736
"dependencies": {
38-
"d3-color": "1 - 2",
39-
"d3-dispatch": "1 - 2",
40-
"d3-ease": "1 - 2",
41-
"d3-interpolate": "1 - 2",
42-
"d3-timer": "1 - 2"
37+
"d3-color": "1 - 3",
38+
"d3-dispatch": "1 - 3",
39+
"d3-ease": "1 - 3",
40+
"d3-interpolate": "1 - 3",
41+
"d3-timer": "1 - 3"
42+
},
43+
"devDependencies": {
44+
"d3-selection": "2 - 3",
45+
"eslint": "7",
46+
"jsdom": "16",
47+
"mocha": "9",
48+
"rollup": "2",
49+
"rollup-plugin-terser": "7"
50+
},
51+
"scripts": {
52+
"test": "mocha 'test/**/*-test.js' && eslint src test",
53+
"prepublishOnly": "rm -rf dist && yarn test && rollup -c",
54+
"postpublish": "git push && git push --tags && cd ../d3.github.com && git pull && cp ../${npm_package_name}/dist/${npm_package_name}.js ${npm_package_name}.v${npm_package_version%%.*}.js && cp ../${npm_package_name}/dist/${npm_package_name}.min.js ${npm_package_name}.v${npm_package_version%%.*}.min.js && git add ${npm_package_name}.v${npm_package_version%%.*}.js ${npm_package_name}.v${npm_package_version%%.*}.min.js && git commit -m \"${npm_package_name} ${npm_package_version}\" && git push && cd -"
55+
},
56+
"engines": {
57+
"node": ">=12"
4358
},
4459
"peerDependencies": {
4560
"d3-selection": "2"
46-
},
47-
"devDependencies": {
48-
"d3-selection": "2",
49-
"eslint": "6",
50-
"jsdom": "15",
51-
"rollup": "1",
52-
"rollup-plugin-terser": "5",
53-
"tape": "4"
5461
}
5562
}

rollup.config.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1+
import {readFileSync} from "fs";
12
import {terser} from "rollup-plugin-terser";
23
import * as meta from "./package.json";
34

5+
// Extract copyrights from the LICENSE.
6+
const copyright = readFileSync("./LICENSE", "utf-8")
7+
.split(/\n/g)
8+
.filter(line => /^Copyright\s+/.test(line))
9+
.map(line => line.replace(/^Copyright\s+/, ""))
10+
.join(", ");
11+
412
const config = {
513
input: "src/index.js",
614
external: Object.keys(meta.dependencies || {}).filter(key => /^d3-/.test(key)),
@@ -10,7 +18,7 @@ const config = {
1018
format: "umd",
1119
indent: false,
1220
extend: true,
13-
banner: `// ${meta.homepage} v${meta.version} Copyright ${(new Date).getFullYear()} ${meta.author.name}`,
21+
banner: `// ${meta.homepage} v${meta.version} Copyright ${copyright}`,
1422
globals: Object.assign({}, ...Object.keys({...meta.dependencies, ...meta.peerDependencies}).filter(key => /^d3-/.test(key)).map(key => ({[key]: "d3"})))
1523
},
1624
plugins: [],

test/.eslintrc

Lines changed: 0 additions & 15 deletions
This file was deleted.

test/.eslintrc.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": "eslint:recommended",
3+
"parserOptions": {
4+
"sourceType": "module",
5+
"ecmaVersion": 8
6+
},
7+
"env": {
8+
"mocha": true,
9+
"node": true,
10+
"es6": true,
11+
"browser": true
12+
}
13+
}

0 commit comments

Comments
 (0)