Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade to React 19, yarn 4, Cesium 1.126.0 and TS #693

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 51 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,74 +1,100 @@
name: ci

on:
push:
branches:
- main
pull_request:

jobs:
ci:
name: CI
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v3
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Checkout
uses: actions/checkout@v3
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)

- name: Enable Corepack
run: corepack enable

# Yarn 4 uses .yarn/cache instead of a global cache directory
- name: Cache Yarn dependencies
uses: actions/cache@v4
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
path: |
.yarn/cache
.yarn/unplugged
.yarn/install-state.gz
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install
run: yarn install --frozen-lockfile

- name: Install dependencies
run: yarn install --immutable

- name: Lint
run: yarn run lint

- name: Test
run: yarn run test

- name: Codecov
uses: codecov/codecov-action@v3
Comment on lines 46 to 47
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Update codecov action version.

The codecov action version is outdated.

-        uses: codecov/codecov-action@v3
+        uses: codecov/codecov-action@v4
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Codecov
uses: codecov/codecov-action@v3
- name: Codecov
- uses: codecov/codecov-action@v3
+ uses: codecov/codecov-action@v4
🧰 Tools
🪛 actionlint (1.7.4)

47-47: the runner of "codecov/codecov-action@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


- name: Build
run: yarn run build

- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/**/*

docs:
name: Build docs
runs-on: ubuntu-latest
needs: ci
if: ${{ github.event_name == 'push' }}
steps:
- uses: actions/setup-node@v3
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Checkout
uses: actions/checkout@v3
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)

- name: Enable Corepack
run: corepack enable

- name: Cache Yarn dependencies
uses: actions/cache@v4
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
path: |
.yarn/cache
.yarn/unplugged
.yarn/install-state.gz
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install
run: yarn install --frozen-lockfile

- name: Install dependencies
run: yarn install --immutable

- name: Install Docs
run: (cd docs && yarn install --frozen-lockfile)
run: (cd docs && yarn install --immutable)

- name: Build docs
run: yarn run docs:build

- name: Deploy docs
uses: peaceiris/actions-gh-pages@v3
Comment on lines 95 to 96
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Update gh-pages action version.

The gh-pages action version is outdated.

-        uses: peaceiris/actions-gh-pages@v3
+        uses: peaceiris/actions-gh-pages@v4
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Deploy docs
uses: peaceiris/actions-gh-pages@v3
- name: Deploy docs
- uses: peaceiris/actions-gh-pages@v3
+ uses: peaceiris/actions-gh-pages@v4
🧰 Tools
🪛 actionlint (1.7.4)

96-96: the runner of "peaceiris/actions-gh-pages@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/build
cname: resium.reearth.io
cname: resium.reearth.io
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,12 @@ node_modules
/examples/build
/example/package-lock.json
/example/yarn.lock

# yarn 4
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
56 changes: 30 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,40 +40,44 @@
},
"peerDependencies": {
"cesium": "1.x",
"react": ">=18.2.0",
"react-dom": ">=18.2.0"
"react": ">=18.2.0 <20",
"react-dom": ">=18.2.0 <20"
},
"devDependencies": {
"@storybook/addon-essentials": "8.0.5",
"@storybook/addon-storysource": "8.0.5",
"@storybook/addons": "7.6.17",
"@storybook/builder-vite": "8.0.5",
"@storybook/react": "8.0.5",
"@storybook/react-vite": "8.0.5",
"@storybook/theming": "8.0.5",
"@testing-library/jest-dom": "6.4.2",
"@testing-library/react": "14.2.2",
"@types/node": "20.12.2",
"@types/react": "18.2.73",
"@vitejs/plugin-react": "4.2.1",
"c8": "9.1.0",
"cesium": "1.116.0",
"@storybook/addon-essentials": "8.5.3",
"@storybook/addon-storysource": "8.5.3",
"@storybook/addons": "7.6.20",
"@storybook/builder-vite": "8.5.3",
"@storybook/react": "8.5.3",
"@storybook/react-vite": "8.5.3",
"@storybook/theming": "8.5.3",
"@testing-library/dom": "10.4.0",
"@testing-library/jest-dom": "6.6.3",
"@testing-library/react": "16.2.0",
"@types/jsdom": "21.1.7",
"@types/node": "22.13.1",
"@types/react": "19.0.8",
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "4.3.4",
"c8": "10.1.3",
"cesium": "1.126.0",
"eslint": "8.57.0",
"eslint-config-reearth": "0.3.0",
"globby": "14.0.1",
"jsdom": "24.0.0",
"npm-run-all2": "5.0.0",
"jsdom": "26.0.0",
"npm-run-all2": "7.0.2",
"prettier": "3.2.5",
"react": "18.2.0",
"react-dom": "18.2.0",
"storybook": "8.0.5",
"react": "19.0.0",
"react-dom": "19.0.0",
"storybook": "8.5.3",
"ts-expect": "1.3.0",
"ts-node": "10.9.2",
"typescript": "5.4.3",
"vite": "5.2.7",
"vite-plugin-cesium": "1.2.22",
"vite-plugin-dts": "3.8.1",
"vitest": "1.4.0",
"vite": "6.1.0",
"vite-plugin-cesium": "1.2.23",
"vite-plugin-dts": "4.5.0",
"vitest": "3.0.5",
"web-streams-polyfill": "4.0.0"
}
},
"packageManager": "[email protected]"
}
1 change: 1 addition & 0 deletions src/Billboard/Billboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const cesiumProps = [
"horizontalOrigin",
"image",
"pixelOffset",
"splitDirection",
"pixelOffsetScaleByDistance",
"position",
"rotation",
Expand Down
1 change: 1 addition & 0 deletions src/BillboardGraphics/BillboardGraphics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const cesiumProps = [
"pixelOffset",
"rotation",
"alignedAxis",
"splitDirection",
"width",
"height",
"color",
Expand Down
2 changes: 2 additions & 0 deletions src/Cesium3DTileset/Cesium3DTileset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const cesiumProps = [
"immediatelyLoadDesiredLevelOfDetail",
"loadSiblings",
"clippingPlanes",
"clippingPolygons",
"classificationType",
"ellipsoid",
"lightColor",
Expand Down Expand Up @@ -118,6 +119,7 @@ const cesiumReadonlyProps = [
"cullWithChildrenBounds",
"debugHeatmapTilePropertyName",
"enableDebugWireframe",
"environmentMapOptions",
"modelUpAxis",
"modelForwardAxis",
"projectTo2D",
Expand Down
8 changes: 8 additions & 0 deletions src/CesiumWidget/CesiumWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ const cesiumReadonlyProps = [
"creditViewport",
"shadows",
"terrainShadows",
"ellipsoid",
"dataSources",
"allowDataSourcesToSuspendAnimation",
"trackedEntity",
"trackedEntityChanged",
"clockTrackedDataSource",
"shouldAnimate",
"automaticallyTrackDataSourceClocks",
"terrain",
"requestRenderMode",
"maximumRenderTimeChange",
Expand Down
1 change: 1 addition & 0 deletions src/Entity/Entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ const cesiumProps = [
"label",
"model",
"name",
"trackingReferenceFrame",
"orientation",
"path",
"plane",
Expand Down
4 changes: 4 additions & 0 deletions src/Fog/Fog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ const cesiumProps = [
"enabled",
"minimumBrightness",
"screenSpaceErrorFactor",
"heightScalar",
"maxHeight",
"visualDensityScalar",
"heightFalloff",
"renderable",
] as const;

Expand Down
1 change: 1 addition & 0 deletions src/Globe/Globe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const cesiumProps = [
"backFaceCulling",
"baseColor",
"clippingPlanes",
"clippingPolygons",
"depthTestAgainstTerrain",
"enableLighting",
"lightingFadeInDistance",
Expand Down
3 changes: 3 additions & 0 deletions src/Model/Model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const cesiumProps = [
"maximumScale",
"minimumPixelSize",
"modelMatrix",
"clippingPolygons",
"outlineColor",
"scale",
"shadows",
Expand All @@ -66,6 +67,8 @@ const cesiumReadonlyProps = [
"releaseGltfJson",
"cull",
"opaquePass",
"enableVerticalExaggeration",
"environmentMapOptions",
"upAxis",
"forwardAxis",
"content",
Expand Down
2 changes: 2 additions & 0 deletions src/ModelGraphics/ModelGraphics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ const cesiumProps = [
"runAnimations",
"clampAnimations",
"nodeTransformations",
"environmentMapOptions",
"enableVerticalExaggeration",
"shadows",
"heightReference",
"distanceDisplayCondition",
Expand Down
1 change: 1 addition & 0 deletions src/PointGraphics/PointGraphics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const cesiumProps = [
"scaleByDistance",
"translucencyByDistance",
"heightReference",
"splitDirection",
"distanceDisplayCondition",
"disableDepthTestDistance",
] as const;
Expand Down
1 change: 1 addition & 0 deletions src/PointPrimitive/PointPrimitive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const cesiumProps = [
"distanceDisplayCondition",
"id",
"outlineColor",
"splitDirection",
"outlineWidth",
"pixelSize",
"position",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ const cesiumProps = [
"enableTilt",
"enableTranslate",
"enableZoom",
"zoomFactor",
"maximumTiltAngle",
"inertiaSpin",
"inertiaTranslate",
"inertiaZoom",
Expand Down
1 change: 1 addition & 0 deletions src/Viewer/Viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const cesiumProps = [
"resolutionScale",
"allowDataSourcesToSuspendAnimation",
"trackedEntity",
"ellipsoid",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

LGTM! Added ellipsoid support consistently with CesiumWidget.

The addition of ellipsoid property aligns with the similar change in CesiumWidget, maintaining consistency across components.

Let's verify the ellipsoid property is consistently implemented across components:


🏁 Script executed:

#!/bin/bash
# Search for ellipsoid property usage across components
rg -l 'ellipsoid.*cesiumProps' src/

Length of output: 37


Let's gather more context to verify that the ellipsoid property has been added consistently. We need to inspect the context around the cesiumProps array in both Viewer.ts and CesiumWidget.ts to confirm the ellipsoid entry is present. Please run the following verification shell script:

This script will print out the surrounding lines of the cesiumProps arrays in both files so we can verify that the ellipsoid property is included consistently.


🏁 Script executed:

#!/bin/bash
echo "=== Viewer.ts: cesiumProps context ==="
rg -C 5 'cesiumProps' src/Viewer/Viewer.ts

echo "=== CesiumWidget.ts: cesiumProps context ==="
rg -C 5 'cesiumProps' src/CesiumWidget.ts

Length of output: 1103


Let's gather more context by inspecting the full definition of cesiumProps in Viewer.ts and searching for similar definitions elsewhere (which should include the cesiumProps implementation in CesiumWidget if available).

Please run the following verification shell script:


🏁 Script executed:

#!/bin/bash
echo "=== Full definition of cesiumProps in Viewer.ts ==="
sed -n '/const cesiumProps = \[/,/\]/p' src/Viewer/Viewer.ts

echo "=== Searching for all cesiumProps definitions in the repository ==="
rg -l 'const cesiumProps = \[' .

Length of output: 2903


Let's verify if the ellipsoid property is consistently included in the CesiumWidget component. Please run the following script to inspect the full definition of cesiumProps in CesiumWidget.ts:


🏁 Script executed:

#!/bin/bash
echo "=== Full definition of cesiumProps in CesiumWidget.ts ==="
sed -n '/const cesiumProps = \[/,/\]/p' src/CesiumWidget/CesiumWidget.ts

Length of output: 357


Ellipsoid Property Inconsistency Found

  • The cesiumProps array in Viewer.ts now includes "ellipsoid", which is correct for adding support.
  • However, the cesiumProps array in CesiumWidget.ts does not include "ellipsoid", which contradicts the review comment’s claim of consistency.

It appears that while the Viewer was updated to support the ellipsoid property, the same was not applied to CesiumWidget. Please confirm whether ellipsoid support is intended in both components. If consistency across components is required, then CesiumWidget.ts should be updated accordingly.

"selectedEntity",
"shadows",
"useBrowserRecommendedResolution",
Expand Down
2 changes: 1 addition & 1 deletion src/core/CameraOperation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const createCameraOperation = <P>(
/* eslint-disable react-hooks/rules-of-hooks */
const component: FC<P & CameraOperationProps> = props => {
const ctx = useCesium();
const prevProps = useRef<P>();
const prevProps = useRef<P | undefined>(undefined);
const first = useRef(false);

useEffect(() => {
Expand Down
11 changes: 8 additions & 3 deletions src/core/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,15 @@ export const createCesiumComponent = <Element, Props extends {}, State = any>({
defaultProps,
...options
}: CesiumComponentOptions<Element, Props, State>): CesiumComponentType<Element, Props> => {
const component: ForwardRefRenderFunction<CesiumComponentRef<Element>, Props> = (props, ref) => {
const component: ForwardRefRenderFunction<CesiumComponentRef<Element>, PropsWithoutRef<Props>> = (
props,
ref,
) => {
const mergedProps = {
...defaultProps,
...props,
};
} as Props;

// eslint-disable-next-line react-hooks/rules-of-hooks
const [provided, mounted, wrapperRef] = useCesiumComponent<Element, Props, State>(
options,
Expand All @@ -66,6 +70,7 @@ export const createCesiumComponent = <Element, Props extends {}, State = any>({
? (mergedProps as PropsWithChildren<Props>).children
: null
: null;

const wrappedChildren = renderContainer ? (
<div
data-testid="resium-container"
Expand All @@ -87,5 +92,5 @@ export const createCesiumComponent = <Element, Props extends {}, State = any>({

component.displayName = options.name;

return forwardRef(component);
return forwardRef<CesiumComponentRef<Element>, Props>(component);
};
Loading
Loading