diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 378e8f849..60ecd5e0c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,7 +7,8 @@ jobs: runs-on: ubuntu-latest outputs: kernel: ${{ steps.filter.outputs.kernel }} - tornado-e2e: ${{ steps.filter.outputs.tornado-e2e }} + # tornado-e2e: ${{ steps.filter.outputs.tornado-e2e }} + tornado-e2e: true # This step does not detect changes in the `streamlit` submodule that is needed to trigger the test-tornado-e2e job (https://github.com/dorny/paths-filter/issues/143), so skip checking and make it always return true as a workaround. mountable: ${{ steps.filter.outputs.mountable }} sharing-editor: ${{ steps.filter.outputs.sharing-editor }} sharing-common: ${{ steps.filter.outputs.sharing-common }} @@ -21,10 +22,10 @@ jobs: kernel: - 'packages/kernel/**/*' # - '!packages/kernel/py/**/*' # Not supported by paths-filter now: https://github.com/dorny/paths-filter/issues/106 - tornado-e2e: - - 'packages/kernel/py/tornado' - - 'packages/kernel/py/e2etests/**/*' - - 'streamlit/**/*' + # tornado-e2e: # We run this job anytime. See above. + # - 'packages/kernel/py/tornado' + # - 'packages/kernel/py/e2etests/**/*' + # - 'streamlit/**/*' mountable: - 'packages/mountable/**/*' sharing-editor: @@ -107,6 +108,13 @@ jobs: - name: Create virtualenv run: python -m venv .venv + - name: Install dependencies + shell: bash + run: | + . .venv/bin/activate + cd packages/kernel/py/e2etests + poetry install + # Set up the /streamlit submodule ## Set up apt packages. Ref: https://github.com/streamlit/streamlit/wiki/Contributing#ubuntu - name: Install Streamlit build dependencies @@ -117,26 +125,26 @@ jobs: cd streamlit make mini-init - - name: Install dependencies - shell: bash - run: poetry install - working-directory: packages/kernel/py/e2etests - - name: Run linter and code formatter to the test code module - working-directory: packages/kernel/py/e2etests run: | + . .venv/bin/activate + cd packages/kernel/py/e2etests poetry run black . --check poetry run isort . --check poetry run flake8 - name: Run mypy - working-directory: packages/kernel/py/e2etests - run: poetry run mypy . + run: | + . .venv/bin/activate + cd packages/kernel/py/e2etests + poetry run mypy . - name: Run pytest shell: bash - run: poetry run python -m pytest -v tests - working-directory: packages/kernel/py/e2etests + run: | + . .venv/bin/activate + cd packages/kernel/py/e2etests + poetry run python -m pytest -v tests test-mountable: needs: changes diff --git a/Makefile b/Makefile index 8bc3b0c07..e0a49628c 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ kernel := packages/kernel/dist/* pyarrow_wheel := packages/kernel/py/stlite-pyarrow/dist/stlite_pyarrow-0.1.0-py3-none-any.whl tornado_wheel := packages/kernel/py/tornado/dist/tornado-6.2-py3-none-any.whl streamlit_proto := streamlit/frontend/src/autogen -streamlit_wheel := packages/kernel/py/streamlit/lib/dist/streamlit-1.17.0-py2.py3-none-any.whl +streamlit_wheel := packages/kernel/py/streamlit/lib/dist/streamlit-1.18.1-py2.py3-none-any.whl .PHONY: all all: init mountable sharing sharing-editor @@ -124,4 +124,4 @@ $(streamlit_wheel): $(VENV) $(streamlit_proto) streamlit/lib/streamlit/**/*.py s cd streamlit && \ $(MAKE) distribution mkdir -p `dirname $(streamlit_wheel)` - cp streamlit/lib/dist/streamlit-1.17.0-py2.py3-none-any.whl $(streamlit_wheel) + cp streamlit/lib/dist/streamlit-1.18.1-py2.py3-none-any.whl $(streamlit_wheel) diff --git a/packages/common-react/package.json b/packages/common-react/package.json index 1269938f9..54ebc2e77 100644 --- a/packages/common-react/package.json +++ b/packages/common-react/package.json @@ -14,17 +14,17 @@ "check:prettier": "prettier --check ." }, "dependencies": { - "streamlit-browser": "^1.12.0" + "streamlit-browser": "^1.18.1" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^5.46.1", - "@typescript-eslint/parser": "^5.46.1", - "eslint": "^8.21.0", - "eslint-plugin-react": "^7.31.11", + "@typescript-eslint/eslint-plugin": "^5.49.0", + "@typescript-eslint/parser": "^5.49.0", + "eslint": "^8.33.0", + "eslint-plugin-react": "^7.32.1", "react": "^17.0.2", "react-dom": "^17.0.2", "react-toastify": "^9.1.1", - "typescript": "^4.6.4" + "typescript": "^4.9.4" }, "peerDependencies": { "react": "^17.0.2", diff --git a/packages/common-react/src/toastify-components/theme.ts b/packages/common-react/src/toastify-components/theme.ts index 9c5c6d700..86a9a69be 100644 --- a/packages/common-react/src/toastify-components/theme.ts +++ b/packages/common-react/src/toastify-components/theme.ts @@ -1,16 +1,28 @@ -import { LocalStore } from "streamlit-browser/src/lib/storageUtils"; +import { + LocalStore, + localStorageAvailable, +} from "streamlit-browser/src/lib/storageUtils"; import { darkTheme } from "streamlit-browser/src/theme/themeConfigs"; -export function isDarkTheme() { +function isSystemDarkTheme(): boolean { + // Detect the system color mode. Ref: https://stackoverflow.com/a/57795495/13103190 + return ( + window.matchMedia && + window.matchMedia("(prefers-color-scheme: dark)").matches + ); +} + +export function isDarkTheme(): boolean { + if (!localStorageAvailable()) { + return isSystemDarkTheme(); + } + // Ref: https://github.com/streamlit/streamlit/blob/1.12.0/frontend/src/theme/utils.ts#L544 const cachedThemeStr = window.localStorage.getItem(LocalStore.ACTIVE_THEME); if (!cachedThemeStr) { - // Detect the system color mode Ref: https://stackoverflow.com/a/57795495/13103190 - return ( - window.matchMedia && - window.matchMedia("(prefers-color-scheme: dark)").matches - ); + return isSystemDarkTheme(); } + const { name } = JSON.parse(cachedThemeStr); return name === darkTheme.name; diff --git a/packages/common/package.json b/packages/common/package.json index 41fde927e..d7aa7a766 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -19,10 +19,10 @@ "check:prettier": "prettier --check ." }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^5.33.0", - "@typescript-eslint/parser": "^5.33.0", - "eslint": "^8.21.0", - "typescript": "^4.6.4", + "@typescript-eslint/eslint-plugin": "^5.49.0", + "@typescript-eslint/parser": "^5.49.0", + "eslint": "^8.33.0", + "typescript": "^4.9.4", "vitest": "^0.21.1" } } diff --git a/packages/desktop/bin/dump_artifacts.ts b/packages/desktop/bin/dump_artifacts.ts index 98ff8b115..820212b42 100755 --- a/packages/desktop/bin/dump_artifacts.ts +++ b/packages/desktop/bin/dump_artifacts.ts @@ -100,7 +100,7 @@ async function createSitePackagesSnapshot( pyodide, path.join( stliteKernelPyDir, - "streamlit/lib/dist/streamlit-1.17.0-py2.py3-none-any.whl" + "streamlit/lib/dist/streamlit-1.18.1-py2.py3-none-any.whl" ) ); } else { diff --git a/packages/desktop/craco.config.js b/packages/desktop/craco.config.js index 86db01d53..a0070e280 100644 --- a/packages/desktop/craco.config.js +++ b/packages/desktop/craco.config.js @@ -3,17 +3,7 @@ const HtmlWebpackPlugin = require("html-webpack-plugin"); module.exports = { babel: { - plugins: [ - "@emotion", - // Stlite: This specific syntax plugin is needed since the syntax was started being used in the upstream codebase (https://github.com/streamlit/streamlit/pull/5913/files#diff-845917f3a07167e741db444532fae1e083d5b9f84ac8e8e38d3a34818a311ad8R242). - // With the browserslist setting in the upstream project, this plugin is automatically chosen by @babel/preset-env and the syntax is transpiled nicely, - // however, this `desktop` package has a different browserslist optimized for the Electron runtime - // and it leads to an error maybe because of CRA's bug. - // So we had to specify this single plugin here explicitly. - // See https://github.com/whitphx/stlite/issues/471 for the details. - // TODO: When CRA is updated to v5, the bug should be gone away so this config can be removed. - "@babel/plugin-proposal-logical-assignment-operators", - ], + plugins: ["@emotion"], loaderOptions: { cacheDirectory: true, }, @@ -37,8 +27,9 @@ module.exports = { "script-src 'wasm-unsafe-eval' 'unsafe-eval'", // style-src is necessary because of emotion. In dev, style-loader with injectType=styleTag is also the reason. "style-src 'self' 'unsafe-inline'", - // The worker is inlined as blob: https://github.com/whitphx/stlite/blob/v0.7.1/packages/stlite-kernel/src/kernel.ts#L16 - "worker-src blob:", + // - 'self': The stlite kernel worker is bundled as a separate file via Webpack 5's worker feature. + // - blob: : Some third party libraries such as Mapbox used in st.map() create workers from blob. + "worker-src 'self' blob:", // For