Skip to content

Commit

Permalink
Merge pull request #6890 from alibaba/release/next
Browse files Browse the repository at this point in the history
Release 3.4.9
  • Loading branch information
ClarkXia authored May 30, 2024
2 parents 4865124 + 8ebd64e commit 18c7e3e
Show file tree
Hide file tree
Showing 37 changed files with 228 additions and 102 deletions.
9 changes: 9 additions & 0 deletions packages/ice/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 3.4.9

### Patch Changes

- 4c9456fc: feat: export useAsyncData for component Await
- b808156b: feat: support open specified route and list all routes
- Updated dependencies [4c9456fc]
- @ice/runtime@1.4.8

## 3.4.8

### Patch Changes
Expand Down
2 changes: 2 additions & 0 deletions packages/ice/bin/ice-cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
.option('--https [https]', 'enable https', false)
.option('--force', 'force remove cache directory', false)
.option('--speedup', 'speed up build time based on Rust tools', false)
.option('--open <open>', 'open browser on startup with specific route', true)
.option('--list', 'list all available pages', false)
.action(async ({ rootDir, ...commandArgs }, ctx) => {
renamePlatformToTarget(commandArgs);
process.env.NODE_ENV = 'development';
Expand Down
4 changes: 2 additions & 2 deletions packages/ice/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ice/app",
"version": "3.4.8",
"version": "3.4.9",
"description": "provide scripts and configuration used by web framework ice",
"type": "module",
"main": "./esm/index.js",
Expand Down Expand Up @@ -49,7 +49,7 @@
"dependencies": {
"@ice/bundles": "0.2.6",
"@ice/route-manifest": "1.2.2",
"@ice/runtime": "^1.4.7",
"@ice/runtime": "^1.4.8",
"@ice/shared-config": "1.2.7",
"@ice/webpack-config": "1.1.14",
"@ice/rspack-config": "1.1.7",
Expand Down
7 changes: 7 additions & 0 deletions packages/ice/src/bundler/config/getUrls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,11 @@ const getUrls = ({
return urls;
};

export const getUrlInfo = (routePaths: string[]) => {
return {
devPath: (routePaths[0] || '').replace(/^[/\\]/, ''),
routePaths: routePaths.map((routePath) => (routePath || '').replace(/^[/\\]/, '')),
};
};

export default getUrls;
6 changes: 2 additions & 4 deletions packages/ice/src/bundler/rspack/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Configuration as DevServerConfiguration } from '@rspack/dev-server
import getDefaultServerConfig from '../config/defaultServerConfig.js';
import getMiddlewares from '../config/middlewares.js';
import { logger } from '../../utils/logger.js';
import getUrls from '../config/getUrls.js';
import getUrls, { getUrlInfo } from '../config/getUrls.js';
import { WEB } from '../../constant.js';
import type { BuildOptions } from '../types.js';
import formatStats from './formatStats.js';
Expand Down Expand Up @@ -80,9 +80,7 @@ const start = async ({
isSuccessful,
isFirstCompile,
urls,
devUrlInfo: {
devPath: (routePaths[0] || '').replace(/^[/\\]/, ''),
},
devUrlInfo: getUrlInfo(routePaths),
messages: message,
taskConfigs,
...hooksAPI,
Expand Down
6 changes: 2 additions & 4 deletions packages/ice/src/bundler/webpack/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { logger } from '../../utils/logger.js';
import { WEB } from '../../constant.js';
import getMiddlewares from '../config/middlewares.js';
import getDefaultServerConfig from '../config/defaultServerConfig.js';
import getUrls from '../config/getUrls.js';
import getUrls, { getUrlInfo } from '../config/getUrls.js';
import type { BundlerOptions, Context } from '../types.js';

const { merge } = lodash;
Expand Down Expand Up @@ -88,9 +88,7 @@ export async function startDevServer(
isSuccessful,
isFirstCompile,
urls,
devUrlInfo: {
devPath: (routePaths[0] || '').replace(/^[/\\]/, ''),
},
devUrlInfo: getUrlInfo(routePaths),
messages,
taskConfigs,
...hooksAPI,
Expand Down
4 changes: 4 additions & 0 deletions packages/ice/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,10 @@ const cliOption = [
name: 'open',
commands: ['start'],
},
{
name: 'list',
commands: ['start'],
},
{
name: 'speedup',
commands: ['start', 'build'],
Expand Down
1 change: 1 addition & 0 deletions packages/ice/src/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const RUNTIME_EXPORTS = [
'useNavigate',
'useNavigation',
'useRevalidator',
'useAsyncValue',
],
source: '@ice/runtime/router',
},
Expand Down
18 changes: 12 additions & 6 deletions packages/ice/src/plugins/web/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,28 @@ const plugin: Plugin = () => ({
});

onHook('after.start.compile', async ({ isSuccessful, isFirstCompile, urls, devUrlInfo }) => {
const { port, open } = commandArgs;
const { devPath } = devUrlInfo;
const { port, open, list } = commandArgs;
const { devPath, routePaths } = devUrlInfo;
if (isSuccessful && isFirstCompile) {
let logoutMessage = '\n';
logoutMessage += chalk.green(' Starting the development server at:');
if (process.env.CLOUDIDE_ENV) {
logoutMessage += `\n - IDE server: https://${process.env.WORKSPACE_UUID}-${port}.${process.env.WORKSPACE_HOST}${devPath}`;
if (list) {
routePaths.forEach((routePath) => {
logoutMessage += `\n - Route(${routePath || 'index'}) : ${chalk.underline.white(`${urls.lanUrlForTerminal}${routePath}`)}`;
});
} else {
logoutMessage += `\n
if (process.env.CLOUDIDE_ENV) {
logoutMessage += `\n - IDE server: https://${process.env.WORKSPACE_UUID}-${port}.${process.env.WORKSPACE_HOST}${devPath}`;
} else {
logoutMessage += `\n
- Local : ${chalk.underline.white(`${urls.localUrlForBrowser}${devPath}`)}
- Network: ${chalk.underline.white(`${urls.lanUrlForTerminal}${devPath}`)}`;
}
}
logger.log(`${logoutMessage}\n`);

if (open) {
openBrowser(`${urls.localUrlForBrowser}${devPath}`);
openBrowser(`${urls.localUrlForBrowser}${typeof open === 'string' ? open.replace(/^[/\\]/, '') : devPath}`);
}
}
});
Expand Down
1 change: 1 addition & 0 deletions packages/ice/src/types/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ interface AfterCommandCompileOptions {

interface DevServerInfo {
devPath: string;
routePaths: string[];
}

export interface HookLifecycle {
Expand Down
6 changes: 6 additions & 0 deletions packages/jsx-runtime/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @ice/jsx-runtime

## 0.3.0

### Minor Changes

- bccc7db1: fix: use jsx-dev-runtime when development

## 0.2.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/jsx-runtime/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ice/jsx-runtime",
"version": "0.2.2",
"version": "0.3.0",
"description": "JSX runtime for ice.",
"files": [
"esm",
Expand Down
19 changes: 15 additions & 4 deletions packages/jsx-runtime/src/dev.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
import { jsx, Fragment, jsxs } from './index.js';
// @ts-ignore
import { jsxDEV as _jsxDEV, Fragment } from 'react/jsx-dev-runtime';
import { hijackElementProps } from './style.js';

export { Fragment };
export function jsxDEV(
/**
* @param {*} type
* @param {object} props
* @param {string} key
* @param {boolean} isStaticChildren
* @param {object} source
* @param {any} self
*/
function jsxDEV(
type: any,
props: object,
key: string,
isStaticChildren: boolean,
source: object,
self: any,
) {
return isStaticChildren ? jsxs(type, props, key, source, self) : jsx(type, props, key, source, self);
return _jsxDEV(type, hijackElementProps(props), key, isStaticChildren, source, self);
}

export { jsxDEV, Fragment };
51 changes: 1 addition & 50 deletions packages/jsx-runtime/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,50 +1 @@
// @ts-ignore
import { jsx as _jsx, jsxs as _jsxs, Fragment } from 'react/jsx-runtime';
// @ts-ignore
import { convertUnit } from 'style-unit';

const STYLE = 'style';

/**
* https://github.com/reactjs/rfcs/pull/107
* @param {*} type
* @param {object} props
* @param {string} maybeKey
* @param {object} source
* @param {any} self
*/
export function jsx(type: any, props: object, maybeKey: string, source: object, self: any) {
return _jsx(type, hijackElementProps(props), maybeKey, source, self);
}

// Same as jsx method, special case jsxs internally to take advantage of static children.
// // for now we can ship identical prod functions.
export function jsxs(type: any, props: object, maybeKey: string, source: object, self: any) {
return _jsxs(type, hijackElementProps(props), maybeKey, source, self);
}

function isObject(obj: any): obj is object {
return typeof obj === 'object';
}

// Support rpx unit.
export function hijackElementProps(props: { style?: object } | object): object {
if (props && STYLE in props) {
const { style } = props;
if (isObject(style)) {
const result = Object.assign({}, props);
const convertedStyle = {};
for (const prop in style) {
// @ts-ignore
convertedStyle[prop] = typeof style[prop] === 'string' ? convertUnit(style[prop]) : style[prop];
}
result['style'] = convertedStyle;
return result;
}
}
return props;
}

export {
Fragment,
};
export * from './prod.js';
28 changes: 27 additions & 1 deletion packages/jsx-runtime/src/prod.ts
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
export { jsx, jsxs, Fragment } from './index.js';
// @ts-ignore
import { jsx as _jsx, jsxs as _jsxs, Fragment } from 'react/jsx-runtime';
import { hijackElementProps } from './style.js';

/**
* https://github.com/reactjs/rfcs/pull/107
* @param {*} type
* @param {object} props
* @param {string} maybeKey
* @param {object} source
* @param {any} self
*/
function jsx(type: any, props: object, maybeKey: string, source: object, self: any) {
return _jsx(type, hijackElementProps(props), maybeKey, source, self);
}

// Same as jsx method, special case jsxs internally to take advantage of static children.
// // for now we can ship identical prod functions.
function jsxs(type: any, props: object, maybeKey: string, source: object, self: any) {
return _jsxs(type, hijackElementProps(props), maybeKey, source, self);
}

export {
Fragment,
jsx,
jsxs,
};
26 changes: 26 additions & 0 deletions packages/jsx-runtime/src/style.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// @ts-ignore
import { convertUnit } from 'style-unit';

const STYLE = 'style';

function isObject(obj: any): obj is object {
return typeof obj === 'object';
}

// Support rpx unit.
export function hijackElementProps(props: { style?: object } | object): object {
if (props && STYLE in props) {
const { style } = props;
if (isObject(style)) {
const result = Object.assign({}, props);
const convertedStyle = {};
for (const prop in style) {
// @ts-ignore
convertedStyle[prop] = typeof style[prop] === 'string' ? convertUnit(style[prop]) : style[prop];
}
result['style'] = convertedStyle;
return result;
}
}
return props;
}
4 changes: 2 additions & 2 deletions packages/jsx-runtime/tests/hijackElememt.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, it, describe } from 'vitest';
import { hijackElementProps } from '../src/';
import { hijackElementProps } from '../src/style';

describe('hijack element', () => {
it('hijackElementProps basic', () => {
Expand All @@ -19,4 +19,4 @@ describe('hijack element', () => {
},
});
});
});
});
11 changes: 11 additions & 0 deletions packages/plugin-i18n/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# @ice/plugin-i18n

## 5.0.1

### Patch Changes

- Updated dependencies [bccc7db1]
- Updated dependencies [4c9456fc]
- Updated dependencies [b808156b]
- @ice/jsx-runtime@0.3.0
- @ice/runtime@1.4.8
- @ice/app@3.4.9

## 5.0.0

### Patch Changes
Expand Down
8 changes: 4 additions & 4 deletions packages/plugin-i18n/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ice/plugin-i18n",
"version": "5.0.0",
"version": "5.0.1",
"description": "I18n plugin for ice.js 3.",
"files": [
"es2017",
Expand Down Expand Up @@ -39,7 +39,7 @@
"plugin"
],
"dependencies": {
"@ice/jsx-runtime": "^0.2.2",
"@ice/jsx-runtime": "^0.3.0",
"@swc/helpers": "^0.5.1",
"accept-language-parser": "^1.5.0",
"universal-cookie": "^4.0.4",
Expand All @@ -56,8 +56,8 @@
"webpack-dev-server": "4.15.0"
},
"peerDependencies": {
"@ice/app": "^3.4.8",
"@ice/runtime": "^1.4.7"
"@ice/app": "^3.4.9",
"@ice/runtime": "^1.4.8"
},
"publishConfig": {
"access": "public"
Expand Down
6 changes: 6 additions & 0 deletions packages/plugin-intl/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @ice/plugin-intl

## 1.0.1

### Patch Changes

- d06826ef: feat: support get locale messages for global

## 1.0.0

- Initial release
Loading

0 comments on commit 18c7e3e

Please sign in to comment.