Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev'
Browse files Browse the repository at this point in the history
# Conflicts:
#	dash-renderer/package-lock.json
  • Loading branch information
Marc-André Rivet committed Oct 29, 2019
2 parents 74b4c2e + a0fa4a4 commit 4446ea8
Show file tree
Hide file tree
Showing 42 changed files with 1,005 additions and 135 deletions.
21 changes: 21 additions & 0 deletions @plotly/dash-component-plugins/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Plotly

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
16 changes: 16 additions & 0 deletions @plotly/dash-component-plugins/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "@plotly/dash-component-plugins",
"version": "1.0.1",
"description": "Plugins for Dash Components",
"repository": {
"type": "git",
"url": "[email protected]:plotly/dash.git"
},
"bugs": {
"url": "https://github.com/plotly/dash/issues"
},
"homepage": "https://github.com/plotly/dash",
"main": "src/index.js",
"author": "Marc-André Rivet",
"license": "MIT"
}
31 changes: 31 additions & 0 deletions @plotly/dash-component-plugins/src/asyncImport.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { lazy } from 'react';

export const asyncDecorator = (target, promise) => {
let resolve;
const isReady = new Promise(r => {
resolve = r;
});

const state = {
isReady,
get: lazy(() => {
return Promise.resolve(promise()).then(res => {
setTimeout(async () => {
await resolve(true);
state.isReady = true;
}, 0);

return res;
});
}),
};

Object.defineProperty(target, '_dashprivate_isLazyComponentReady', {
get: () => state.isReady,
});

return state.get;
};

export const isReady = target => target &&
target._dashprivate_isLazyComponentReady;
3 changes: 3 additions & 0 deletions @plotly/dash-component-plugins/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { asyncDecorator, isReady } from './dynamicImport';

export { asyncDecorator, isReady };
21 changes: 21 additions & 0 deletions @plotly/webpack-dash-dynamic-import/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Plotly

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
16 changes: 16 additions & 0 deletions @plotly/webpack-dash-dynamic-import/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "@plotly/webpack-dash-dynamic-import",
"version": "1.1.1",
"description": "Webpack Plugin for Dynamic Import in Dash",
"repository": {
"type": "git",
"url": "[email protected]:plotly/dash.git"
},
"bugs": {
"url": "https://github.com/plotly/dash/issues"
},
"homepage": "https://github.com/plotly/dash",
"main": "src/index.js",
"author": "Marc-André Rivet",
"license": "MIT"
}
76 changes: 76 additions & 0 deletions @plotly/webpack-dash-dynamic-import/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
const fs = require('fs');

function getFingerprint() {
const package = fs.readFileSync('./package.json');
const packageJson = JSON.parse(package);

const timestamp = Math.round(Date.now() / 1000);
const version = packageJson.version.replace(/[.]/g, '_');

return `"v${version}m${timestamp}"`;
}

const resolveImportSource = () => `\
const getCurrentScript = function() {
let script = document.currentScript;
if (!script) {
/* Shim for IE11 and below */
/* Do not take into account async scripts and inline scripts */
const scripts = Array.from(document.getElementsByTagName('script')).filter(function(s) { return !s.async && !s.text && !s.textContent; });
script = scripts.slice(-1)[0];
}
return script;
};
const isLocalScript = function(script) {
return /\\\/_dash-component-suites\\\//.test(script.src);
};
Object.defineProperty(__webpack_require__, 'p', {
get: (function () {
let script = getCurrentScript();
var url = script.src.split('/').slice(0, -1).join('/') + '/';
return function() {
return url;
};
})()
});
const __jsonpScriptSrc__ = jsonpScriptSrc;
jsonpScriptSrc = function(chunkId) {
let script = getCurrentScript();
let isLocal = isLocalScript(script);
let src = __jsonpScriptSrc__(chunkId);
if(!isLocal) {
return src;
}
const srcFragments = src.split('/');
const fileFragments = srcFragments.slice(-1)[0].split('.');
fileFragments.splice(1, 0, ${getFingerprint()});
srcFragments.splice(-1, 1, fileFragments.join('.'))
return srcFragments.join('/');
};
`

class WebpackDashDynamicImport {
apply(compiler) {
compiler.hooks.compilation.tap('WebpackDashDynamicImport', compilation => {
compilation.mainTemplate.hooks.requireExtensions.tap('WebpackDashDynamicImport > RequireExtensions', (source, chunk, hash) => {
return [
source,
resolveImportSource()
]
});
});
}
}

module.exports = WebpackDashDynamicImport;
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
All notable changes to `dash` will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [1.5.0] - 2019-10-29
### Added
- [#964](https://github.com/plotly/dash/pull/964) Adds support for preventing updates in clientside functions.
- Reject all updates with `throw window.dash_clientside.PreventUpdate;`
- Reject a single output by returning `window.dash_clientside.no_update`
- [#899](https://github.com/plotly/dash/pull/899) Add support for async dependencies and components
- [#973](https://github.com/plotly/dash/pull/973) Adds support for resource caching and adds a fallback caching mechanism through etag

### Fixed
- [#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.

## [1.4.1] - 2019-10-17
### Fixed
- [#969](https://github.com/plotly/dash/pull/969) Fix warnings emitted by react devtools coming from our own devtools components.
Expand Down
6 changes: 0 additions & 6 deletions dash-renderer/.babelrc

This file was deleted.

13 changes: 13 additions & 0 deletions dash-renderer/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
presets: [['@babel/preset-env', {
useBuiltIns: 'usage',
corejs: 3
}], '@babel/preset-react'],
env: {
test: {
plugins: [
'@babel/plugin-transform-modules-commonjs'
]
}
}
};
6 changes: 3 additions & 3 deletions dash-renderer/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ module.exports = {
// transform: null,

// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// transformIgnorePatterns: [
// "/node_modules/"
// ],
transformIgnorePatterns: [
"/node_modules/(?!@plotly).+\\.js"
],

// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
// unmockedModulePathPatterns: undefined,
Expand Down
6 changes: 4 additions & 2 deletions dash-renderer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dash-renderer",
"version": "1.1.2",
"version": "1.2.0",
"description": "render dash components in react",
"main": "dash_renderer/dash_renderer.min.js",
"scripts": {
Expand Down Expand Up @@ -36,8 +36,10 @@
},
"devDependencies": {
"@babel/core": "^7.6.0",
"@babel/plugin-transform-modules-commonjs": "^7.6.0",
"@babel/preset-env": "^7.6.0",
"@babel/preset-react": "^7.0.0",
"@plotly/dash-component-plugins": "^1.0.1",
"@svgr/webpack": "^4.1.0",
"babel-eslint": "^10.0.3",
"babel-loader": "^8.0.6",
Expand All @@ -57,9 +59,9 @@
"prettier-stylelint": "^0.4.2",
"raw-loader": "^3.1.0",
"style-loader": "^1.0.0",
"webpack-dev-server": "^3.1.11",
"webpack": "^4.39.3",
"webpack-cli": "^3.3.8",
"webpack-dev-server": "^3.1.11",
"webpack-serve": "^3.1.1",
"whatwg-fetch": "^2.0.2"
}
Expand Down
2 changes: 2 additions & 0 deletions dash-renderer/src/APIController.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
computePaths,
hydrateInitialOutputs,
setLayout,
setAppIsReady,
} from './actions/index';
import {applyPersistence} from './persistence';
import apiThunk from './actions/api';
Expand Down Expand Up @@ -54,6 +55,7 @@ class UnconnectedContainer extends Component {
dispatch
);
dispatch(setLayout(finalLayout));
dispatch(setAppIsReady());
} else if (isNil(paths)) {
dispatch(computePaths({subTree: layout, startingPath: []}));
}
Expand Down
5 changes: 1 addition & 4 deletions dash-renderer/src/TreeContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,11 @@ import {
type,
} from 'ramda';
import {notifyObservers, updateProps} from './actions';
import isSimpleComponent from './isSimpleComponent';
import {recordUiEdit} from './persistence';
import ComponentErrorBoundary from './components/error/ComponentErrorBoundary.react';
import checkPropTypes from 'check-prop-types';

const SIMPLE_COMPONENT_TYPES = ['String', 'Number', 'Null', 'Boolean'];
const isSimpleComponent = component =>
includes(type(component), SIMPLE_COMPONENT_TYPES);

function validateComponent(componentDefinition) {
if (type(componentDefinition) === 'Array') {
throw new Error(
Expand Down
1 change: 1 addition & 0 deletions dash-renderer/src/actions/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const actionList = {
SET_CONFIG: 'SET_CONFIG',
ON_ERROR: 'ON_ERROR',
SET_HOOKS: 'SET_HOOKS',
SET_APP_READY: 'SET_APP_READY',
};

export const getAction = action => {
Expand Down
Loading

0 comments on commit 4446ea8

Please sign in to comment.