Skip to content
This repository has been archived by the owner on Nov 17, 2022. It is now read-only.

Commit

Permalink
Merge pull request #365 from ice-lab/release-next
Browse files Browse the repository at this point in the history
Release next
  • Loading branch information
ClarkXia authored Aug 12, 2022
2 parents 691bc6d + cbbd9be commit f5755a0
Show file tree
Hide file tree
Showing 207 changed files with 14,092 additions and 10,967 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/auto-publisher.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Install pnpm
run: npm i pnpm -g
- run: npm run setup
- run: npm run publish:beta
- run: npm run publish:release
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
ACCESS_KEY_ID: ${{ secrets.ACCESS_KEY_ID }}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ coverage
*.swp
*.dia~
*.temp.json
*.swc

# Packages
packages/*/lib/
packages/*/esm/

# temp folder .ice
examples/*/.ice
examples/*/.swc

build
dist
Expand Down
5 changes: 4 additions & 1 deletion examples/basic-project/ice.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import auth from '@ice/plugin-auth';

export default defineConfig({
publicPath: '/',
syntaxFeatures: {
exportDefaultFrom: true,
},
define: {
HAHA: JSON.stringify(true),
'process.env.HAHA': JSON.stringify(true),
},
transform: (code, id) => {
if (id.includes('src/pages')) {
console.log('transform page:', id);
// console.log('transform page:', id);
}
return code;
},
Expand Down
1 change: 1 addition & 0 deletions examples/basic-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@ice/plugin-auth": "workspace:*",
"@ice/plugin-rax-compat": "workspace:*",
"@ice/runtime": "workspace:*",
"@uni/env": "^1.1.0",
"ahooks": "^3.3.8",
"react": "^18.0.0",
"react-dom": "^18.0.0"
Expand Down
21 changes: 21 additions & 0 deletions examples/basic-project/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { defineAppConfig } from 'ice';
import { defineAuthConfig } from '@ice/plugin-auth/esm/types';
import { isWeb, isNode } from '@uni/env';
import type { GetAppData } from 'ice';

if (process.env.ICE_CORE_ERROR_BOUNDARY === 'true') {
console.error('__REMOVED__');
Expand All @@ -10,6 +12,14 @@ console.warn('__WARN__');
console.error('__ERROR__');
console.log('process.env.HAHA', process.env.HAHA);

if (isWeb) {
console.error('__IS_WEB__');
}

if (isNode) {
console.error('__IS_NODE__');
}

export const auth = defineAuthConfig(() => {
// fetch auth data
return {
Expand All @@ -24,3 +34,14 @@ export default defineAppConfig({
rootId: 'app',
},
});

export const getAppData: GetAppData = () => {
return new Promise((resolve) => {
resolve({
title: 'gogogogo',
auth: {
admin: true,
},
});
});
};
10 changes: 9 additions & 1 deletion examples/basic-project/src/document.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Meta, Title, Links, Main, Scripts } from 'ice';
import { Meta, Title, Links, Main, Scripts, useAppData } from 'ice';
import type { AppData } from 'ice';

function Document() {
const appData = useAppData<AppData>();

return (
<html>
<head>
Expand All @@ -10,6 +13,11 @@ function Document() {
<Meta />
<Title />
<Links />
<script
dangerouslySetInnerHTML={{
__html: `console.log('${appData?.title}')`,
}}
/>
</head>
<body>
<Main />
Expand Down
2 changes: 2 additions & 0 deletions examples/basic-project/src/pages/about.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Link, useData, useConfig } from 'ice';
import { isWeb } from '@uni/env';
// @ts-expect-error
import url from './ice.png';

Expand All @@ -18,6 +19,7 @@ export default function About() {
<Link to="/">home</Link>
<img src={url} height="40" width="40" />
<span className="mark">new</span>
<div>isWeb: { isWeb ? 'true' : 'false' }</div>
</>
);
}
Expand Down
15 changes: 9 additions & 6 deletions examples/basic-project/src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
import { Suspense, lazy } from 'react';
import { Link, useData, useConfig } from 'ice';
import { Link, useData, useAppData, useConfig } from 'ice';
// not recommended but works
import { useAppContext } from '@ice/runtime';
import { useRequest } from 'ahooks';
import type { AppData } from 'ice';
import styles from './index.module.css';

const Bar = lazy(() => import('../components/bar'));

export default function Home(props) {
console.log('render Home', props);

const appContext = useAppContext();
console.log('get AppContext', appContext);

const appData = useAppData<AppData>();
const data = useData();
const config = useConfig();

console.log('render Home', 'data', data, 'config', config);
if (typeof window !== 'undefined') {
console.log('render Home', props);
console.log('get AppData', appData);
console.log('get AppContext', appContext);
console.log('render Home', 'data', data, 'config', config);
}

const { data: foo } = useRequest(() => fetch('/api/foo').then(res => res.json()));
const { data: users } = useRequest(() => fetch('/api/users').then(res => res.json()));
Expand Down
6 changes: 6 additions & 0 deletions examples/hash-router/ice.config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { defineConfig } from '@ice/app';

export default defineConfig({
ssr: false,
ssg: false,
});
19 changes: 19 additions & 0 deletions examples/hash-router/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "hash-router-demo",
"version": "1.0.0",
"scripts": {
"start": "ice start",
"build": "ice build"
},
"dependencies": {
"@ice/app": "workspace:*",
"@ice/runtime": "workspace:*",
"react": "^18.0.0",
"react-dom": "^18.0.0"
},
"devDependencies": {
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"regenerator-runtime": "^0.13.9"
}
}
7 changes: 7 additions & 0 deletions examples/hash-router/src/app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineAppConfig } from 'ice';

export default defineAppConfig({
router: {
type: 'hash',
},
});
22 changes: 22 additions & 0 deletions examples/hash-router/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="Hash Router Demo" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<Meta />
<Title />
<Links />
</head>
<body>
<Main />
<Scripts />
</body>
</html>
);
}

export default Document;
10 changes: 10 additions & 0 deletions examples/hash-router/src/pages/about.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Link } from 'ice';

export default function Home() {
return (
<>
<h2>About Page</h2>
<Link to="/">Home</Link>
</>
);
}
10 changes: 10 additions & 0 deletions examples/hash-router/src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Link } from 'ice';

export default function Home() {
return (
<>
<h2>Home</h2>
<Link to="/about">about</Link>
</>
);
}
16 changes: 16 additions & 0 deletions examples/hash-router/src/pages/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Outlet } from 'ice';

export default () => {
return (
<div>
<h1>Layout</h1>
<Outlet />
</div>
);
};

export function getConfig() {
return {
title: 'Hash Router Demo',
};
}
32 changes: 32 additions & 0 deletions examples/hash-router/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": ["node_modules", "build", "public"]
}
2 changes: 2 additions & 0 deletions examples/rax-project/src/document.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* @jsx createElement */
import { createElement } from 'rax';
import { Meta, Title, Links, Main, Scripts } from 'ice';

function Document() {
Expand Down
4 changes: 3 additions & 1 deletion examples/with-antd-mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
"@ice/app": "workspace:*",
"@ice/runtime": "workspace:*",
"antd-mobile": "^5.12.4",
"constate": "^3.3.2"
"constate": "^3.3.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/react": "^18.0.0",
Expand Down
19 changes: 19 additions & 0 deletions examples/with-antd/ice.config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { defineConfig } from '@ice/app';
import antd from '@ice/plugin-antd';
import moment from '@ice/plugin-moment-locales';

export default defineConfig({
plugins: [
antd({
importStyle: true,
dark: true,
compact: true,
theme: {
'blue-base': '#fd8',
},
}),
moment({
locales: ['zh-cn'],
}),
],
});
27 changes: 27 additions & 0 deletions examples/with-antd/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "with-antd",
"version": "1.0.0",
"scripts": {
"start": "ice start",
"build": "ice build"
},
"description": "",
"author": "",
"license": "MIT",
"dependencies": {
"@ice/app": "workspace:*",
"@ice/plugin-antd": "workspace:*",
"@ice/plugin-moment-locales": "workspace:*",
"@ice/runtime": "workspace:*",
"antd": "^4.0.0",
"moment": "^2.29.4",
"react": "^18.0.0",
"react-dom": "^18.0.0"
},
"devDependencies": {
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.2",
"browserslist": "^4.19.3",
"regenerator-runtime": "^0.13.9"
}
}
7 changes: 7 additions & 0 deletions examples/with-antd/src/app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineAppConfig } from 'ice';

export default defineAppConfig({
app: {
rootId: 'app',
},
});
22 changes: 22 additions & 0 deletions examples/with-antd/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 3.0 Demo" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<Meta />
<Title />
<Links />
</head>
<body>
<Main />
<Scripts />
</body>
</html>
);
}

export default Document;
3 changes: 3 additions & 0 deletions examples/with-antd/src/global.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
font-size: 14px;
}
3 changes: 3 additions & 0 deletions examples/with-antd/src/pages/index.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.color {
color: @blue-base;
}
Loading

0 comments on commit f5755a0

Please sign in to comment.