Skip to content

Commit

Permalink
Merge pull request #6396 from alibaba/release/next
Browse files Browse the repository at this point in the history
Release 3.2.8
  • Loading branch information
ClarkXia authored Jul 20, 2023
2 parents ae705c0 + 9878e74 commit 19bdfb1
Show file tree
Hide file tree
Showing 54 changed files with 1,196 additions and 180 deletions.
2 changes: 2 additions & 0 deletions examples/cavans-project/.browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
defaults
ios_saf 9
10 changes: 10 additions & 0 deletions examples/cavans-project/ice.config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from '@ice/app';
import canvasPlugin from '@ice/plugin-canvas';

export default defineConfig(() => ({
plugins: [
canvasPlugin(),
],
ssr: true,
ssg: false,
}));
25 changes: 25 additions & 0 deletions examples/cavans-project/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "@examples/canvas-project",
"version": "1.0.0",
"private": true,
"scripts": {
"start": "ice start",
"build": "ice build"
},
"description": "",
"author": "",
"license": "MIT",
"dependencies": {
"@ice/app": "workspace:*",
"@ice/plugin-canvas": "workspace:*",
"@ice/runtime": "workspace:*",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"@ice/cache-canvas": "workspace:*"
},
"devDependencies": {
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"webpack": "^5.86.0"
}
}
3 changes: 3 additions & 0 deletions examples/cavans-project/src/app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { defineAppConfig } from 'ice';

export default defineAppConfig(() => ({}));
7 changes: 7 additions & 0 deletions examples/cavans-project/src/components/bar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function Bar() {
return (
<div>
bar
</div>
);
}
22 changes: 22 additions & 0 deletions examples/cavans-project/src/document.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Meta, Title, Links, Main, Scripts } from 'ice';

function Document() {
return (
<html>
<head>
<meta charSet="utf-8" />
<meta name="description" content="ICE Demo" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<Meta />
<Title />
<Links />
</head>
<body>
<Main />
<Scripts />
</body>
</html>
);
}

export default Document;
65 changes: 65 additions & 0 deletions examples/cavans-project/src/pages/home.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { definePageConfig, CacheCanvas } from 'ice';
import { useRef } from 'react';
import styles from './index.module.css';

export type RefCacheCanvas = {
cacheCanvasToStorage: () => void;
};

const GAME_CANVAS_ID = 'canvas-id';

export default function Home() {
const childRef = useRef<RefCacheCanvas>();
const initFunc = () => {
return new Promise((resolve) => {
const canvas: HTMLCanvasElement | null = document.getElementById(GAME_CANVAS_ID) as HTMLCanvasElement;
if (canvas && typeof canvas.getContext === 'function') {
let ctx: CanvasRenderingContext2D | null = canvas.getContext('2d');

ctx?.fillRect(25, 25, 100, 100);
ctx?.clearRect(45, 45, 60, 60);
ctx?.strokeRect(50, 50, 50, 50);
}

setTimeout(() => {
console.log('canvas paint ready!');
resolve(true);
}, 5000);
});
};
return (
<>
<h2 className={styles.title}>Home Page</h2>
<CacheCanvas
ref={childRef}
id={GAME_CANVAS_ID}
init={initFunc}
fallback={() => <div>fallback</div>}
/>
<button
style={{ display: 'block' }}
onClick={() => {
console.log('active cache!');
childRef.current?.cacheCanvasToStorage();
}}
>cache canvas</button>
</>
);
}

export const pageConfig = definePageConfig(() => {
return {
title: 'Home',
meta: [
{
name: 'theme-color',
content: '#000',
},
{
name: 'title-color',
content: '#f00',
},
],
auth: ['admin'],
};
});
Binary file added examples/cavans-project/src/pages/ice.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions examples/cavans-project/src/pages/index.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.title {
color: red;
}
3 changes: 3 additions & 0 deletions examples/cavans-project/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface AppData {
title: string;
}
1 change: 1 addition & 0 deletions examples/cavans-project/src/typings.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="@ice/app/types" />
32 changes: 32 additions & 0 deletions examples/cavans-project/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"compileOnSave": false,
"buildOnSave": false,
"compilerOptions": {
"baseUrl": ".",
"outDir": "build",
"module": "esnext",
"target": "es6",
"jsx": "react-jsx",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"lib": ["es6", "dom"],
"sourceMap": true,
"allowJs": true,
"rootDir": "./",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": false,
"importHelpers": true,
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true,
"skipLibCheck": true,
"paths": {
"@/*": ["./src/*"],
"ice": [".ice"]
}
},
"include": ["src", ".ice", "ice.config.*"],
"exclude": ["build", "public"]
}
2 changes: 1 addition & 1 deletion examples/single-route/optimization.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { defineConfig } from '@ice/app';
export default defineConfig(() => ({
publicPath: '/',
optimization: {
router: true,
disableRouter: true,
},
}));
7 changes: 7 additions & 0 deletions examples/single-route/src/pages/home.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const home = () => {
return (
<>home</>
);
};

export default home;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rimraf": "^3.0.2",
"stylelint": "^14.10.0",
"stylelint": "^15.10.1",
"tsx": "^3.12.1",
"typescript": "^4.7.4",
"vitest": "^0.15.2"
Expand Down
7 changes: 7 additions & 0 deletions packages/cache-canvas/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @ice/cache-canvas

## 0.0.9

### Patch Changes

- 018238f9: feat: support cache of 2d cavans
46 changes: 46 additions & 0 deletions packages/cache-canvas/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# @ice/cache-canvas

React component for supporting canvas for cache.

## Usage

```bash
npm i @ice/cache-canvas -S
```

```jsx
import MainGame from './game'; // eva.js 的封装

const GAME_CANVAS = 'game-canvas';

export default (props) => {
useEffect(() => {
const gameEl = document.getElementById(GAME_CANVAS);
new MainGame(gameEl, getGameHeight());
}, []);

const init = () => {
return new Promise((resolve) => {
const canvas: HTMLCanvasElement | null = document.getElementById(GAME_CANVAS_ID) as HTMLCanvasElement;
if (canvas && typeof canvas.getContext === 'function') {
let ctx: CanvasRenderingContext2D | null = canvas.getContext('2d');

ctx?.fillRect(25, 25, 100, 100);
ctx?.clearRect(45, 45, 60, 60);
ctx?.strokeRect(50, 50, 50, 50);
}

setTimeout(() => {
console.log('canvas paint ready!');
resolve(true);
}, 5000);
});
}

return (
<>
<CanvasCache id={GAME_CANVAS} useCache={false} init={init} />
</>
);
};
```
29 changes: 29 additions & 0 deletions packages/cache-canvas/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "@ice/cache-canvas",
"version": "0.0.9",
"description": "",
"main": "./esm/index.js",
"types": "./esm/index.d.ts",
"scripts": {
"watch": "tsc -w",
"build": "tsc",
"prepublishOnly": "npm run build"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"react": "^18.0.0",
"react-dom": "^18.0.0"
},
"dependencies": {
"universal-env": "^3.3.3"
},
"peerDependencies": {
"react": "^18",
"react-dom": "^18"
},
"publishConfig": {
"access": "public"
}
}
Loading

0 comments on commit 19bdfb1

Please sign in to comment.