Skip to content

Commit 4446ea8

Browse files
author
Marc-André Rivet
committed
Merge remote-tracking branch 'origin/dev'
# Conflicts: # dash-renderer/package-lock.json
2 parents 74b4c2e + a0fa4a4 commit 4446ea8

Some content is hidden

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

42 files changed

+1005
-135
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Plotly
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "@plotly/dash-component-plugins",
3+
"version": "1.0.1",
4+
"description": "Plugins for Dash Components",
5+
"repository": {
6+
"type": "git",
7+
"url": "[email protected]:plotly/dash.git"
8+
},
9+
"bugs": {
10+
"url": "https://github.com/plotly/dash/issues"
11+
},
12+
"homepage": "https://github.com/plotly/dash",
13+
"main": "src/index.js",
14+
"author": "Marc-André Rivet",
15+
"license": "MIT"
16+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { lazy } from 'react';
2+
3+
export const asyncDecorator = (target, promise) => {
4+
let resolve;
5+
const isReady = new Promise(r => {
6+
resolve = r;
7+
});
8+
9+
const state = {
10+
isReady,
11+
get: lazy(() => {
12+
return Promise.resolve(promise()).then(res => {
13+
setTimeout(async () => {
14+
await resolve(true);
15+
state.isReady = true;
16+
}, 0);
17+
18+
return res;
19+
});
20+
}),
21+
};
22+
23+
Object.defineProperty(target, '_dashprivate_isLazyComponentReady', {
24+
get: () => state.isReady,
25+
});
26+
27+
return state.get;
28+
};
29+
30+
export const isReady = target => target &&
31+
target._dashprivate_isLazyComponentReady;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { asyncDecorator, isReady } from './dynamicImport';
2+
3+
export { asyncDecorator, isReady };
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Plotly
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "@plotly/webpack-dash-dynamic-import",
3+
"version": "1.1.1",
4+
"description": "Webpack Plugin for Dynamic Import in Dash",
5+
"repository": {
6+
"type": "git",
7+
"url": "[email protected]:plotly/dash.git"
8+
},
9+
"bugs": {
10+
"url": "https://github.com/plotly/dash/issues"
11+
},
12+
"homepage": "https://github.com/plotly/dash",
13+
"main": "src/index.js",
14+
"author": "Marc-André Rivet",
15+
"license": "MIT"
16+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
const fs = require('fs');
2+
3+
function getFingerprint() {
4+
const package = fs.readFileSync('./package.json');
5+
const packageJson = JSON.parse(package);
6+
7+
const timestamp = Math.round(Date.now() / 1000);
8+
const version = packageJson.version.replace(/[.]/g, '_');
9+
10+
return `"v${version}m${timestamp}"`;
11+
}
12+
13+
const resolveImportSource = () => `\
14+
const getCurrentScript = function() {
15+
let script = document.currentScript;
16+
if (!script) {
17+
/* Shim for IE11 and below */
18+
/* Do not take into account async scripts and inline scripts */
19+
const scripts = Array.from(document.getElementsByTagName('script')).filter(function(s) { return !s.async && !s.text && !s.textContent; });
20+
script = scripts.slice(-1)[0];
21+
}
22+
23+
return script;
24+
};
25+
26+
const isLocalScript = function(script) {
27+
return /\\\/_dash-component-suites\\\//.test(script.src);
28+
};
29+
30+
Object.defineProperty(__webpack_require__, 'p', {
31+
get: (function () {
32+
let script = getCurrentScript();
33+
34+
var url = script.src.split('/').slice(0, -1).join('/') + '/';
35+
36+
return function() {
37+
return url;
38+
};
39+
})()
40+
});
41+
42+
const __jsonpScriptSrc__ = jsonpScriptSrc;
43+
jsonpScriptSrc = function(chunkId) {
44+
let script = getCurrentScript();
45+
let isLocal = isLocalScript(script);
46+
47+
let src = __jsonpScriptSrc__(chunkId);
48+
49+
if(!isLocal) {
50+
return src;
51+
}
52+
53+
const srcFragments = src.split('/');
54+
const fileFragments = srcFragments.slice(-1)[0].split('.');
55+
56+
fileFragments.splice(1, 0, ${getFingerprint()});
57+
srcFragments.splice(-1, 1, fileFragments.join('.'))
58+
59+
return srcFragments.join('/');
60+
};
61+
`
62+
63+
class WebpackDashDynamicImport {
64+
apply(compiler) {
65+
compiler.hooks.compilation.tap('WebpackDashDynamicImport', compilation => {
66+
compilation.mainTemplate.hooks.requireExtensions.tap('WebpackDashDynamicImport > RequireExtensions', (source, chunk, hash) => {
67+
return [
68+
source,
69+
resolveImportSource()
70+
]
71+
});
72+
});
73+
}
74+
}
75+
76+
module.exports = WebpackDashDynamicImport;

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22
All notable changes to `dash` will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## [1.5.0] - 2019-10-29
6+
### Added
7+
- [#964](https://github.com/plotly/dash/pull/964) Adds support for preventing updates in clientside functions.
8+
- Reject all updates with `throw window.dash_clientside.PreventUpdate;`
9+
- Reject a single output by returning `window.dash_clientside.no_update`
10+
- [#899](https://github.com/plotly/dash/pull/899) Add support for async dependencies and components
11+
- [#973](https://github.com/plotly/dash/pull/973) Adds support for resource caching and adds a fallback caching mechanism through etag
12+
13+
### Fixed
14+
- [#974](https://github.com/plotly/dash/pull/974) Fix and improve a percy snapshot behavior issue we found in dash-docs testing. It adds a flag `wait_for_callbacks` to ensure that, in the context of a dash app testing, the percy snapshot action will happen only after all callbacks get fired.
15+
516
## [1.4.1] - 2019-10-17
617
### Fixed
718
- [#969](https://github.com/plotly/dash/pull/969) Fix warnings emitted by react devtools coming from our own devtools components.

dash-renderer/.babelrc

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

dash-renderer/babel.config.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module.exports = {
2+
presets: [['@babel/preset-env', {
3+
useBuiltIns: 'usage',
4+
corejs: 3
5+
}], '@babel/preset-react'],
6+
env: {
7+
test: {
8+
plugins: [
9+
'@babel/plugin-transform-modules-commonjs'
10+
]
11+
}
12+
}
13+
};

0 commit comments

Comments
 (0)