Skip to content

Commit

Permalink
Merge pull request #6513 from alibaba/release/next
Browse files Browse the repository at this point in the history
Release 3.3.2
  • Loading branch information
ClarkXia authored Sep 14, 2023
2 parents 97cecb7 + fbeaf93 commit 6926c47
Show file tree
Hide file tree
Showing 97 changed files with 596 additions and 271 deletions.
5 changes: 4 additions & 1 deletion examples/with-store/src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Link } from 'ice';
import { Link, definePageConfig } from 'ice';
import pageStore from './store';
import logo from './ice.png';
import appStore from '@/store';
Expand Down Expand Up @@ -26,5 +26,8 @@ function Home() {
);
}

export const pageConfig = definePageConfig(() => ({
title: 'Home Page',
}));

export default Home;
2 changes: 1 addition & 1 deletion examples/with-store/src/store.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createStore } from 'ice';
import user from './models/user';

console.log('app store depend on window', window);
export default createStore({ user });
6 changes: 6 additions & 0 deletions packages/appear/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @ice/appear

## 0.2.1

### Patch Changes

- b8b1d5e4: fix: sourceMap url in prod files but not publish with sourceMap file

## 0.2.0

### Minor Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/appear/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "@ice/appear",
"version": "0.2.0",
"version": "0.2.1",
"description": "",
"main": "./esm/index.js",
"types": "./esm/index.d.ts",
"scripts": {
"watch": "tsc -w",
"watch": "tsc -w --sourceMap",
"build": "tsc",
"prepublishOnly": "npm run build"
},
Expand Down
6 changes: 6 additions & 0 deletions packages/bundles/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 0.1.16

### Patch Changes

- b8b1d5e4: fix: sourceMap url in prod files but not publish with sourceMap file

## 0.1.15

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/bundles/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ice/bundles",
"version": "0.1.15",
"version": "0.1.16",
"license": "MIT",
"author": "ICE",
"description": "Basic dependencies for ice.",
Expand All @@ -9,7 +9,7 @@
"compiled"
],
"scripts": {
"watch": "tsc -w",
"watch": "tsc -w --sourceMap",
"build": "tsx scripts/build.ts && tsc"
},
"main": "./esm/index.js",
Expand Down
8 changes: 8 additions & 0 deletions packages/cache-canvas/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @ice/cache-canvas

## 0.0.13

### Patch Changes

- 1e4b20af: fix: The base64 of canvans may be too large, and the syncCall will block the thread.
- b8b1d5e4: fix: sourceMap url in prod files but not publish with sourceMap file
- a04cc002: fix: fix style not match when hydrate

## 0.0.12

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/cache-canvas/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "@ice/cache-canvas",
"version": "0.0.12",
"version": "0.0.13",
"description": "",
"main": "./esm/index.js",
"types": "./esm/index.d.ts",
"scripts": {
"watch": "tsc -w",
"watch": "tsc -w --sourceMap",
"build": "tsc",
"prepublishOnly": "npm run build"
},
Expand Down
33 changes: 6 additions & 27 deletions packages/cache-canvas/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ declare global {
_windvane_backControl: Function | null;
__megability_bridge__: {
syncCall: Function;
asyncCall: Function;
};
}
}
Expand Down Expand Up @@ -74,7 +75,7 @@ export const CacheCanvas = forwardRef((props: CacheCanvasProps, ref) => {
}
// Cache base64 string when canvas rendered.
if (renderedCanvas && strBase64) {
Storage.setItem(cacheKey, strBase64, {
return Storage.setItem(cacheKey, strBase64, {
bizID,
});
}
Expand All @@ -88,27 +89,6 @@ export const CacheCanvas = forwardRef((props: CacheCanvasProps, ref) => {
setMounted(true);
}, []);

useEffect(() => {
if (window.WindVane) {
window.WindVane.call('WebAppInterface', 'enableHookNativeBack', {});
window._windvane_backControl = () => {
cacheCanvasFunc();
// Windvane must return a string value of true for it to work properly.
return 'false';
};
}
document.addEventListener('wvBackClickEvent', cacheCanvasFunc, false);
window.addEventListener('beforeunload', cacheCanvasFunc);

return () => {
window.removeEventListener('beforeunload', cacheCanvasFunc);
window.removeEventListener('wvBackClickEvent', cacheCanvasFunc);
if (window._windvane_backControl) {
window._windvane_backControl = null;
}
};
}, [cacheCanvasFunc]);

useEffect(() => {
if (mounted && typeof init === 'function') {
const res = init();
Expand Down Expand Up @@ -139,10 +119,9 @@ export const CacheCanvas = forwardRef((props: CacheCanvasProps, ref) => {
{
(typeof fallback === 'function') && (<div
id={`fallback-${id}`}
style={isNode || Storage.getItem(cacheKey, { bizID }) ? { display: 'none' } : { display: 'block' }}
>
{
fallback()
(isNode || !Storage.getItem(cacheKey, { bizID })) && fallback()
}
</div>)
}
Expand Down Expand Up @@ -175,9 +154,9 @@ export const CacheCanvas = forwardRef((props: CacheCanvasProps, ref) => {
if (base64Data) {
const img = document.getElementById('canvas-img-${id}');
img && (img.src = base64Data);
fallback && (fallback.style.display = 'none');
} else {
fallback && (fallback.style.display = 'block');
if (fallback && fallback.childNodes[0]) {
fallback.removeChild(fallback.childNodes[0]);
}
}
`,
}}
Expand Down
33 changes: 21 additions & 12 deletions packages/cache-canvas/src/storage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,33 @@ export const Storage = {
});

if (canIUse) {
const res = window.__megability_bridge__.syncCall('userKVStorage', 'setItem', {
key,
value,
bizID,
return new Promise((resolve, reject) => {
// The base64 of canvans may be too large, and the syncCall will block the thread.
window.__megability_bridge__.asyncCall('userKVStorage', 'setItem', {
key,
value,
bizID,
}, (res) => {
if (res && res.statusCode <= 100) {
resolve(res);
} else {
reject();
}
});
});
if (res && res.statusCode === 0) {
return;
}
}
}

if (typeof window !== 'undefined' && window.localStorage) {
return localStorage.setItem(key, value);
}

return (cache[key] = value);
return new Promise((resolve, reject) => {
if (typeof window !== 'undefined' && typeof localStorage !== 'undefined') {
resolve(localStorage.setItem(key, value));
} else {
reject(new Error('localStorage is undefined.'));
}
});
} catch (e) {
console.error('Storage setItem error:', e);
return Promise.reject(e);
}
},
getItem: (key, { bizID = '' }) => {
Expand Down
6 changes: 6 additions & 0 deletions packages/create-ice/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 1.9.1

### Patch Changes

- b8b1d5e4: fix: sourceMap url in prod files but not publish with sourceMap file

## 1.9.0

### Minor Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/create-ice/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-ice",
"version": "1.9.0",
"version": "1.9.1",
"description": "npm init ice",
"type": "module",
"main": "./esm/index.mjs",
Expand All @@ -20,7 +20,7 @@
"npm": ">=3.0.0"
},
"scripts": {
"watch": "tsc -w",
"watch": "tsc -w --sourceMap",
"build": "tsc"
},
"dependencies": {
Expand Down
21 changes: 21 additions & 0 deletions packages/ice/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Changelog

## 3.3.2

### Patch Changes

- b8b1d5e4: fix: sourceMap url in prod files but not publish with sourceMap file
- 06829a4e: fix: params urls for hook before.start.run
- 7194c75c: fix: throw error when server compile failed
- 68f19eae: fix: should not import runtime module and routes when csr
- cec448c3: fix: browsers compatibility of dataLoader
- 64442269: fix: redirect import of definePageConfig
- Updated dependencies [b8b1d5e4]
- Updated dependencies [68f19eae]
- Updated dependencies [64442269]
- Updated dependencies [b7488105]
- @ice/route-manifest@1.2.2
- @ice/webpack-config@1.1.2
- @ice/rspack-config@1.0.3
- @ice/shared-config@1.0.3
- @ice/bundles@0.1.16
- @ice/runtime@1.2.9

## 3.3.1

### Patch Changes
Expand Down
16 changes: 8 additions & 8 deletions packages/ice/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ice/app",
"version": "3.3.1",
"version": "3.3.2",
"description": "provide scripts and configuration used by web framework ice",
"type": "module",
"main": "./esm/index.js",
Expand All @@ -27,7 +27,7 @@
"npm": ">=3.0.0"
},
"scripts": {
"watch": "tsc -w",
"watch": "tsc -w --sourceMap",
"build": "tsc",
"postinstall": "node ./scripts/postinstall.mjs"
},
Expand All @@ -37,12 +37,12 @@
"bugs": "https://github.com/alibaba/ice/issues",
"homepage": "https://v3.ice.work",
"dependencies": {
"@ice/bundles": "0.1.15",
"@ice/route-manifest": "1.2.1",
"@ice/runtime": "^1.2.8",
"@ice/shared-config": "1.0.2",
"@ice/webpack-config": "1.1.1",
"@ice/rspack-config": "1.0.2",
"@ice/bundles": "0.1.16",
"@ice/route-manifest": "1.2.2",
"@ice/runtime": "^1.2.9",
"@ice/shared-config": "1.0.3",
"@ice/webpack-config": "1.1.2",
"@ice/rspack-config": "1.0.3",
"@swc/helpers": "0.5.1",
"@types/express": "^4.17.14",
"address": "^1.1.2",
Expand Down
13 changes: 11 additions & 2 deletions packages/ice/src/bundler/rspack/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import formatStats from './formatStats.js';

async function build(options: BuildOptions) {
const { compiler, context, hooksAPI, taskConfigs, rspackConfigs, appConfig, routeManifest } = options;
const { rootDir, extendsPluginAPI, applyHook, userConfig } = context;
const { rootDir, extendsPluginAPI, applyHook, userConfig, commandArgs } = context;
await applyHook('before.build.run', {
commandArgs,
taskConfigs,
rspackConfigs,
...hooksAPI,
});
const { stats, isSuccessful, messages } = await new Promise<CompileResults>((resolve, reject) => {
let messages: { errors: string[]; warnings: string[] };
compiler.run(async (_, stats: MultiStats) => {
Expand Down Expand Up @@ -41,7 +47,10 @@ async function build(options: BuildOptions) {

if (isSuccessful) {
const outputDir = rspackConfigs[0].output.path;
const { serverEntry } = await extendsPluginAPI.serverCompileTask.get() || {};
const { serverEntry, error } = await extendsPluginAPI.serverCompileTask.get() || {};
if (error) {
throw new Error('Build failed, please check the error message.');
}
const outputPaths = await getOutputPaths({
rootDir,
serverEntry,
Expand Down
8 changes: 1 addition & 7 deletions packages/ice/src/bundler/rspack/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,14 @@ async function bundler(
context: Context,
options: BundlerOptions,
) {
const { command, applyHook, commandArgs } = context;
const { command } = context;
const {
taskConfigs,
hooksAPI,
routeManifest,
appConfig,
} = options;
const rspackConfigs = await getConfig(context, options);
await applyHook(`before.${command}.run`, {
commandArgs,
taskConfigs,
rspackConfigs,
...hooksAPI,
});

let compiler: MultiCompiler;
let devServer: RspackDevServer;
Expand Down
7 changes: 7 additions & 0 deletions packages/ice/src/bundler/rspack/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ const start = async ({
appConfig,
devServerConfig,
});
await applyHook('before.start.run', {
commandArgs,
taskConfigs,
rspackConfigs,
urls,
...hooksAPI,
});

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

0 comments on commit 6926c47

Please sign in to comment.