From 9968c31e44d4ec2f1f5d94939b85457e9368e56e Mon Sep 17 00:00:00 2001 From: zealotchen Date: Tue, 20 Aug 2024 11:50:17 +0800 Subject: [PATCH 1/3] feat(react): add animation stop --- packages/hippy-react/package.json | 2 +- packages/hippy-react/src/modules/animation.ts | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/hippy-react/package.json b/packages/hippy-react/package.json index 0ff13777bc8..ed7702b378c 100644 --- a/packages/hippy-react/package.json +++ b/packages/hippy-react/package.json @@ -1,6 +1,6 @@ { "name": "@hippy/react", - "version": "unspecified", + "version": "2.16.2-rc.0", "description": "Hippy react framework", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/hippy-react/src/modules/animation.ts b/packages/hippy-react/src/modules/animation.ts index 66af92df4a4..41282ef3231 100644 --- a/packages/hippy-react/src/modules/animation.ts +++ b/packages/hippy-react/src/modules/animation.ts @@ -265,6 +265,13 @@ class Animation implements Animation { Bridge.callNative('AnimationModule', 'pauseAnimation', this.animationId); } + /** + * Stop the running animation + */ + public stop() { + Bridge.callNative('AnimationModule', 'stopAnimation', this.animationId); + } + /** * Resume execution of paused animation */ From 2288a8fbcf636a320b0686cd660e4c16d1c2dc62 Mon Sep 17 00:00:00 2001 From: zealotchen Date: Tue, 29 Oct 2024 17:38:36 +0800 Subject: [PATCH 2/3] feat(web): fix image local path --- .../scripts/hippy-webpack.web-renderer.js | 16 ++++++++++++++ .../hippy-web-renderer/src/component/image.ts | 22 ++++++++++++------- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/examples/hippy-react-demo/scripts/hippy-webpack.web-renderer.js b/examples/hippy-react-demo/scripts/hippy-webpack.web-renderer.js index d15bec933fd..8b8d09d914c 100644 --- a/examples/hippy-react-demo/scripts/hippy-webpack.web-renderer.js +++ b/examples/hippy-react-demo/scripts/hippy-webpack.web-renderer.js @@ -1,3 +1,4 @@ +const fs = require('fs'); const path = require('path'); const webpack = require('webpack'); const HtmlWebpackPlugin = require('html-webpack-plugin'); @@ -78,5 +79,20 @@ module.exports = { resolve: { extensions: ['.js', '.jsx', '.json'], modules: [path.resolve(__dirname, '../node_modules')], + alias: (() => { + const aliases = {}; + // If @hippy/web-renderer was built exist in packages directory then make an alias + // Remove the section if you don't use it + const webRendererPath = path.resolve(__dirname, '../../../packages/hippy-web-renderer/dist'); + if (fs.existsSync(path.resolve(webRendererPath, 'index.js'))) { + console.warn(`* Using the @hippy/web-renderer in ${webRendererPath} as @hippy/web-renderer alias`); + aliases['@hippy/web-renderer'] = webRendererPath; + } else { + console.warn('* Using the @hippy/web-renderer defined in package.json'); + } + + + return aliases; + })(), }, }; diff --git a/packages/hippy-web-renderer/src/component/image.ts b/packages/hippy-web-renderer/src/component/image.ts index afd6437cbed..e3585dcb6df 100644 --- a/packages/hippy-web-renderer/src/component/image.ts +++ b/packages/hippy-web-renderer/src/component/image.ts @@ -63,6 +63,13 @@ export class Image extends HippyWebView { return { boxSizing: 'border-box', zIndex: 0 }; } + public replaceHpfile(value: string) { + if (value && /^(hpfile):\/\//.test(value) && value.indexOf('assets') > -1) { + return value.replace('hpfile://./', ''); + } + return value ?? ''; + } + public set tintColor(value) { this.props[NodeProps.TINY_COLOR] = value; if (value !== undefined && value !== 0) { @@ -108,17 +115,14 @@ export class Image extends HippyWebView { public get src() { const value = this.props[NodeProps.SOURCE]; - if (value && /^(hpfile):\/\//.test(value) && value.indexOf('assets') > -1) { - return value.replace('hpfile://./', ''); - } - - return value ?? ''; + return this.replaceHpfile(value); } public set src(value: string) { if (value && this.src === value) { return; } + value = this.replaceHpfile(value); this.props[NodeProps.SOURCE] = value ?? ''; if (value && value !== this.props[NodeProps.DEFAULT_SOURCE]) { @@ -145,10 +149,12 @@ export class Image extends HippyWebView { } public get defaultSource() { - return this.props[NodeProps.DEFAULT_SOURCE]; + const value = this.props[NodeProps.DEFAULT_SOURCE]; + return this.replaceHpfile(value); } public set defaultSource(value: string) { + value = this.replaceHpfile(value); this.props[NodeProps.DEFAULT_SOURCE] = value; if (!this.isLoadSuccess) { this.renderImgDom!.src = value; @@ -190,12 +196,12 @@ export class Image extends HippyWebView { private handleLoad(_event: Event, loadUrl?: string) { this.isLoadSuccess = false; if ((!loadUrl && this.renderImgDom?.src === this.src) || loadUrl === this.src) { - this.onLoad(null); + this.onLoad({}); if (this.renderImgDom?.src !== this.src) { this.renderImgDom!.src = this.src; } } - this.onLoadEnd(null); + this.onLoadEnd({}); } private buildTintDomContainer() { From ea4ab0118cb7f50e49c9528e12fe1720ac00bbfe Mon Sep 17 00:00:00 2001 From: zealotchen Date: Tue, 29 Oct 2024 17:41:44 +0800 Subject: [PATCH 3/3] feat(web): remove unused code --- packages/hippy-react/package.json | 2 +- packages/hippy-react/src/modules/animation.ts | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/packages/hippy-react/package.json b/packages/hippy-react/package.json index ed7702b378c..0ff13777bc8 100644 --- a/packages/hippy-react/package.json +++ b/packages/hippy-react/package.json @@ -1,6 +1,6 @@ { "name": "@hippy/react", - "version": "2.16.2-rc.0", + "version": "unspecified", "description": "Hippy react framework", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/hippy-react/src/modules/animation.ts b/packages/hippy-react/src/modules/animation.ts index 41282ef3231..66af92df4a4 100644 --- a/packages/hippy-react/src/modules/animation.ts +++ b/packages/hippy-react/src/modules/animation.ts @@ -265,13 +265,6 @@ class Animation implements Animation { Bridge.callNative('AnimationModule', 'pauseAnimation', this.animationId); } - /** - * Stop the running animation - */ - public stop() { - Bridge.callNative('AnimationModule', 'stopAnimation', this.animationId); - } - /** * Resume execution of paused animation */