Skip to content

Commit 6926c47

Browse files
authored
Merge pull request #6513 from alibaba/release/next
Release 3.3.2
2 parents 97cecb7 + fbeaf93 commit 6926c47

File tree

97 files changed

+596
-271
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+596
-271
lines changed

examples/with-store/src/pages/index.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Link } from 'ice';
1+
import { Link, definePageConfig } from 'ice';
22
import pageStore from './store';
33
import logo from './ice.png';
44
import appStore from '@/store';
@@ -26,5 +26,8 @@ function Home() {
2626
);
2727
}
2828

29+
export const pageConfig = definePageConfig(() => ({
30+
title: 'Home Page',
31+
}));
2932

3033
export default Home;

examples/with-store/src/store.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import { createStore } from 'ice';
22
import user from './models/user';
3-
3+
console.log('app store depend on window', window);
44
export default createStore({ user });

packages/appear/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @ice/appear
22

3+
## 0.2.1
4+
5+
### Patch Changes
6+
7+
- b8b1d5e4: fix: sourceMap url in prod files but not publish with sourceMap file
8+
39
## 0.2.0
410

511
### Minor Changes

packages/appear/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "@ice/appear",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"description": "",
55
"main": "./esm/index.js",
66
"types": "./esm/index.d.ts",
77
"scripts": {
8-
"watch": "tsc -w",
8+
"watch": "tsc -w --sourceMap",
99
"build": "tsc",
1010
"prepublishOnly": "npm run build"
1111
},

packages/bundles/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 0.1.16
4+
5+
### Patch Changes
6+
7+
- b8b1d5e4: fix: sourceMap url in prod files but not publish with sourceMap file
8+
39
## 0.1.15
410

511
### Patch Changes

packages/bundles/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ice/bundles",
3-
"version": "0.1.15",
3+
"version": "0.1.16",
44
"license": "MIT",
55
"author": "ICE",
66
"description": "Basic dependencies for ice.",
@@ -9,7 +9,7 @@
99
"compiled"
1010
],
1111
"scripts": {
12-
"watch": "tsc -w",
12+
"watch": "tsc -w --sourceMap",
1313
"build": "tsx scripts/build.ts && tsc"
1414
},
1515
"main": "./esm/index.js",

packages/cache-canvas/CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# @ice/cache-canvas
22

3+
## 0.0.13
4+
5+
### Patch Changes
6+
7+
- 1e4b20af: fix: The base64 of canvans may be too large, and the syncCall will block the thread.
8+
- b8b1d5e4: fix: sourceMap url in prod files but not publish with sourceMap file
9+
- a04cc002: fix: fix style not match when hydrate
10+
311
## 0.0.12
412

513
### Patch Changes

packages/cache-canvas/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "@ice/cache-canvas",
3-
"version": "0.0.12",
3+
"version": "0.0.13",
44
"description": "",
55
"main": "./esm/index.js",
66
"types": "./esm/index.d.ts",
77
"scripts": {
8-
"watch": "tsc -w",
8+
"watch": "tsc -w --sourceMap",
99
"build": "tsc",
1010
"prepublishOnly": "npm run build"
1111
},

packages/cache-canvas/src/index.tsx

+6-27
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ declare global {
2525
_windvane_backControl: Function | null;
2626
__megability_bridge__: {
2727
syncCall: Function;
28+
asyncCall: Function;
2829
};
2930
}
3031
}
@@ -74,7 +75,7 @@ export const CacheCanvas = forwardRef((props: CacheCanvasProps, ref) => {
7475
}
7576
// Cache base64 string when canvas rendered.
7677
if (renderedCanvas && strBase64) {
77-
Storage.setItem(cacheKey, strBase64, {
78+
return Storage.setItem(cacheKey, strBase64, {
7879
bizID,
7980
});
8081
}
@@ -88,27 +89,6 @@ export const CacheCanvas = forwardRef((props: CacheCanvasProps, ref) => {
8889
setMounted(true);
8990
}, []);
9091

91-
useEffect(() => {
92-
if (window.WindVane) {
93-
window.WindVane.call('WebAppInterface', 'enableHookNativeBack', {});
94-
window._windvane_backControl = () => {
95-
cacheCanvasFunc();
96-
// Windvane must return a string value of true for it to work properly.
97-
return 'false';
98-
};
99-
}
100-
document.addEventListener('wvBackClickEvent', cacheCanvasFunc, false);
101-
window.addEventListener('beforeunload', cacheCanvasFunc);
102-
103-
return () => {
104-
window.removeEventListener('beforeunload', cacheCanvasFunc);
105-
window.removeEventListener('wvBackClickEvent', cacheCanvasFunc);
106-
if (window._windvane_backControl) {
107-
window._windvane_backControl = null;
108-
}
109-
};
110-
}, [cacheCanvasFunc]);
111-
11292
useEffect(() => {
11393
if (mounted && typeof init === 'function') {
11494
const res = init();
@@ -139,10 +119,9 @@ export const CacheCanvas = forwardRef((props: CacheCanvasProps, ref) => {
139119
{
140120
(typeof fallback === 'function') && (<div
141121
id={`fallback-${id}`}
142-
style={isNode || Storage.getItem(cacheKey, { bizID }) ? { display: 'none' } : { display: 'block' }}
143122
>
144123
{
145-
fallback()
124+
(isNode || !Storage.getItem(cacheKey, { bizID })) && fallback()
146125
}
147126
</div>)
148127
}
@@ -175,9 +154,9 @@ export const CacheCanvas = forwardRef((props: CacheCanvasProps, ref) => {
175154
if (base64Data) {
176155
const img = document.getElementById('canvas-img-${id}');
177156
img && (img.src = base64Data);
178-
fallback && (fallback.style.display = 'none');
179-
} else {
180-
fallback && (fallback.style.display = 'block');
157+
if (fallback && fallback.childNodes[0]) {
158+
fallback.removeChild(fallback.childNodes[0]);
159+
}
181160
}
182161
`,
183162
}}

packages/cache-canvas/src/storage.tsx

+21-12
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,33 @@ export const Storage = {
1414
});
1515

1616
if (canIUse) {
17-
const res = window.__megability_bridge__.syncCall('userKVStorage', 'setItem', {
18-
key,
19-
value,
20-
bizID,
17+
return new Promise((resolve, reject) => {
18+
// The base64 of canvans may be too large, and the syncCall will block the thread.
19+
window.__megability_bridge__.asyncCall('userKVStorage', 'setItem', {
20+
key,
21+
value,
22+
bizID,
23+
}, (res) => {
24+
if (res && res.statusCode <= 100) {
25+
resolve(res);
26+
} else {
27+
reject();
28+
}
29+
});
2130
});
22-
if (res && res.statusCode === 0) {
23-
return;
24-
}
2531
}
2632
}
2733

28-
if (typeof window !== 'undefined' && window.localStorage) {
29-
return localStorage.setItem(key, value);
30-
}
31-
32-
return (cache[key] = value);
34+
return new Promise((resolve, reject) => {
35+
if (typeof window !== 'undefined' && typeof localStorage !== 'undefined') {
36+
resolve(localStorage.setItem(key, value));
37+
} else {
38+
reject(new Error('localStorage is undefined.'));
39+
}
40+
});
3341
} catch (e) {
3442
console.error('Storage setItem error:', e);
43+
return Promise.reject(e);
3544
}
3645
},
3746
getItem: (key, { bizID = '' }) => {

packages/create-ice/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 1.9.1
4+
5+
### Patch Changes
6+
7+
- b8b1d5e4: fix: sourceMap url in prod files but not publish with sourceMap file
8+
39
## 1.9.0
410

511
### Minor Changes

packages/create-ice/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "create-ice",
3-
"version": "1.9.0",
3+
"version": "1.9.1",
44
"description": "npm init ice",
55
"type": "module",
66
"main": "./esm/index.mjs",
@@ -20,7 +20,7 @@
2020
"npm": ">=3.0.0"
2121
},
2222
"scripts": {
23-
"watch": "tsc -w",
23+
"watch": "tsc -w --sourceMap",
2424
"build": "tsc"
2525
},
2626
"dependencies": {

packages/ice/CHANGELOG.md

+21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
# Changelog
22

3+
## 3.3.2
4+
5+
### Patch Changes
6+
7+
- b8b1d5e4: fix: sourceMap url in prod files but not publish with sourceMap file
8+
- 06829a4e: fix: params urls for hook before.start.run
9+
- 7194c75c: fix: throw error when server compile failed
10+
- 68f19eae: fix: should not import runtime module and routes when csr
11+
- cec448c3: fix: browsers compatibility of dataLoader
12+
- 64442269: fix: redirect import of definePageConfig
13+
- Updated dependencies [b8b1d5e4]
14+
- Updated dependencies [68f19eae]
15+
- Updated dependencies [64442269]
16+
- Updated dependencies [b7488105]
17+
- @ice/route-manifest@1.2.2
18+
- @ice/webpack-config@1.1.2
19+
- @ice/rspack-config@1.0.3
20+
- @ice/shared-config@1.0.3
21+
- @ice/bundles@0.1.16
22+
- @ice/runtime@1.2.9
23+
324
## 3.3.1
425

526
### Patch Changes

packages/ice/package.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ice/app",
3-
"version": "3.3.1",
3+
"version": "3.3.2",
44
"description": "provide scripts and configuration used by web framework ice",
55
"type": "module",
66
"main": "./esm/index.js",
@@ -27,7 +27,7 @@
2727
"npm": ">=3.0.0"
2828
},
2929
"scripts": {
30-
"watch": "tsc -w",
30+
"watch": "tsc -w --sourceMap",
3131
"build": "tsc",
3232
"postinstall": "node ./scripts/postinstall.mjs"
3333
},
@@ -37,12 +37,12 @@
3737
"bugs": "https://github.com/alibaba/ice/issues",
3838
"homepage": "https://v3.ice.work",
3939
"dependencies": {
40-
"@ice/bundles": "0.1.15",
41-
"@ice/route-manifest": "1.2.1",
42-
"@ice/runtime": "^1.2.8",
43-
"@ice/shared-config": "1.0.2",
44-
"@ice/webpack-config": "1.1.1",
45-
"@ice/rspack-config": "1.0.2",
40+
"@ice/bundles": "0.1.16",
41+
"@ice/route-manifest": "1.2.2",
42+
"@ice/runtime": "^1.2.9",
43+
"@ice/shared-config": "1.0.3",
44+
"@ice/webpack-config": "1.1.2",
45+
"@ice/rspack-config": "1.0.3",
4646
"@swc/helpers": "0.5.1",
4747
"@types/express": "^4.17.14",
4848
"address": "^1.1.2",

packages/ice/src/bundler/rspack/build.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ import formatStats from './formatStats.js';
66

77
async function build(options: BuildOptions) {
88
const { compiler, context, hooksAPI, taskConfigs, rspackConfigs, appConfig, routeManifest } = options;
9-
const { rootDir, extendsPluginAPI, applyHook, userConfig } = context;
9+
const { rootDir, extendsPluginAPI, applyHook, userConfig, commandArgs } = context;
10+
await applyHook('before.build.run', {
11+
commandArgs,
12+
taskConfigs,
13+
rspackConfigs,
14+
...hooksAPI,
15+
});
1016
const { stats, isSuccessful, messages } = await new Promise<CompileResults>((resolve, reject) => {
1117
let messages: { errors: string[]; warnings: string[] };
1218
compiler.run(async (_, stats: MultiStats) => {
@@ -41,7 +47,10 @@ async function build(options: BuildOptions) {
4147

4248
if (isSuccessful) {
4349
const outputDir = rspackConfigs[0].output.path;
44-
const { serverEntry } = await extendsPluginAPI.serverCompileTask.get() || {};
50+
const { serverEntry, error } = await extendsPluginAPI.serverCompileTask.get() || {};
51+
if (error) {
52+
throw new Error('Build failed, please check the error message.');
53+
}
4554
const outputPaths = await getOutputPaths({
4655
rootDir,
4756
serverEntry,

packages/ice/src/bundler/rspack/index.ts

+1-7
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,14 @@ async function bundler(
1010
context: Context,
1111
options: BundlerOptions,
1212
) {
13-
const { command, applyHook, commandArgs } = context;
13+
const { command } = context;
1414
const {
1515
taskConfigs,
1616
hooksAPI,
1717
routeManifest,
1818
appConfig,
1919
} = options;
2020
const rspackConfigs = await getConfig(context, options);
21-
await applyHook(`before.${command}.run`, {
22-
commandArgs,
23-
taskConfigs,
24-
rspackConfigs,
25-
...hooksAPI,
26-
});
2721

2822
let compiler: MultiCompiler;
2923
let devServer: RspackDevServer;

packages/ice/src/bundler/rspack/start.ts

+7
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ const start = async ({
4545
appConfig,
4646
devServerConfig,
4747
});
48+
await applyHook('before.start.run', {
49+
commandArgs,
50+
taskConfigs,
51+
rspackConfigs,
52+
urls,
53+
...hooksAPI,
54+
});
4855

4956
const { RspackDevServer } = await import('@ice/bundles/esm/dev-server.js');
5057
const devServer = new RspackDevServer(devServerConfig, compiler);

0 commit comments

Comments
 (0)