diff --git a/AppScope/app.json5 b/AppScope/app.json5 new file mode 100644 index 0000000..6e57827 --- /dev/null +++ b/AppScope/app.json5 @@ -0,0 +1,11 @@ +{ + "app": { + "bundleName": "com.openharmony.imageknife", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "distributedNotificationEnabled": true + } +} diff --git a/AppScope/resources/base/element/string.json b/AppScope/resources/base/element/string.json new file mode 100644 index 0000000..dd151a3 --- /dev/null +++ b/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ImageKnife" + } + ] +} diff --git a/AppScope/resources/base/media/app_icon.png b/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000..ce307a8 Binary files /dev/null and b/AppScope/resources/base/media/app_icon.png differ diff --git a/CHANGELOG.md b/CHANGELOG.md index 96ce6db..ce587a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +## 1.0.3 +- 适配OpenHarmony API9 Stage模型。 ## 1.0.2 - 支持用户自定义扩展变换接口。 diff --git a/OAT.xml b/OAT.xml index 3ffe033..77d2187 100644 --- a/OAT.xml +++ b/OAT.xml @@ -6,11 +6,13 @@ + + diff --git a/README.md b/README.md index 8b65cfb..744621a 100644 --- a/README.md +++ b/README.md @@ -25,24 +25,21 @@ OpenHarmony npm环境配置等更多内容,参考安装教程 [如何安装Ope ## 使用说明 -1.首先初始化全局ImageKnife实例,在app.ets中调用ImageKnife.with()进行初始化。 +1.首先初始化全局ImageKnife实例,在AbilityStage.ts中调用ImageKnife.with(this.context)进行初始化 ```typescript +import AbilityStage from "@ohos.application.AbilityStage" import {ImageKnife} from '@ohos/imageknife' -export default { - data: { - imageKnife: {} // ImageKnife全局占位符 - }, - onCreate() { - this.data.imageKnife = ImageKnife.with();// ImageKnife占位符全局初始化赋值 - } + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + globalThis.ImageKnife = ImageKnife.with(this.context); + } } ``` 2.参考[推荐使用](###'推荐使用')或[自定义实现](###'自定义实现') - - #### 推荐使用: 使用ImageKnifeOption作为入参,配合自定义组件ImageKnifeComponent使用。 @@ -82,7 +79,7 @@ struct Index { ```typescript export default class PixelMapPack{ - pixelMap:PixelMap; + pixelMap:PixelMap; } ``` @@ -113,7 +110,7 @@ Image(this.imageKnifePixelMapPack.pixelMap) ```typescript //配置参数 let requestOptin = new RequestOption(); - //加载本地图片 + //加载本地图片 requestOptin.load($r('app.media.jpgSample')) .addListener((err,data) => { //加载成功/失败回调监听 @@ -127,26 +124,26 @@ let requestOptin = new RequestOption(); .placeholder( $r('app.media.icon_loading'), (data)=>{ // 占位图回调监听 }) - .errorholder( $r('app.media.icon_failed'), (data)=>{ + .errorholder( $r('app.media.icon_failed'), (data)=>{ // 失败占位图回调监听 }) .thumbnail(0.3, (data) => { // 缩略图加载成功回调 }) - // 一定要把控件大小传给RequestOption,图片变换必须 + // 一定要把控件大小传给RequestOption,图片变换必须 .setImageViewSize({width:200, height:200}) - // 设置缓存策略 - .diskCacheStrategy(new AUTOMATIC()) - .addProgressListener((percentValue: string) => { + // 设置缓存策略 + .diskCacheStrategy(new AUTOMATIC()) + .addProgressListener((percentValue: string) => { // 图片网络加载进度条百分比回调 }) - .addRetryListener((error: any) => { - // 加载失败重试监听 图片加载失败时优先展示重试图层,点击重试图层,会重新进行一次加载流程 + .addRetryListener((error: any) => { + // 加载失败重试监听 图片加载失败时优先展示重试图层,点击重试图层,会重新进行一次加载流程 }) - // 左上圆角10pixel像素点 - .roundedCorners({top:10}) + // 左上圆角10pixel像素点 + .roundedCorners({top:10}) // 启动加载流程,执行结果将会返回到上面的回调接口中 - ImageKnife.call(requestOptin); + globalThis.ImageKnife.call(requestOptin); ``` ##### 步骤4: @@ -212,10 +209,12 @@ let requestOptin = new RequestOption(); | request.roundedCorners() | RoundedCornersTransformation | 圆角剪裁 | | request.sepiaFilter() | SepiaFilterTransformation | 乌墨色滤波器 | | request.sketchFilter() | SketchFilterTransformation | 素描滤波器 | +| request.mask() | MaskTransformation | 遮罩 | +| request.swirlFilter() | SwirlFilterTransformation | 扭曲滤波器 | ## 兼容性 -支持 OpenHarmony API version 8 及以上版本。 +支持 OpenHarmony API version 9 及以上版本。 ## 目录结构 @@ -223,69 +222,71 @@ let requestOptin = new RequestOption(); /imageknife/src/ - main/ets/components - cache # 缓存相关内容 - - diskstrategy # 缓存策略 - - key # 缓存key生成策略 - - Base64.ets # Base64算法 - - CustomMap.ets # 自定义Map封装 - - DiskCacheEntry.ets# 磁盘缓存entry - - DiskLruCache.ets # 磁盘LRU缓存策略 - - FileReader.ets # 文件读取相关 - - FileUtils.ets # 文件工具类 - - LruCache.ets # 内存LRU缓存策略 - - Md5.ets # MD5算法 - + - diskstrategy # 缓存策略 + - key # 缓存key生成策略 + - Base64.ets # Base64算法 + - CustomMap.ets # 自定义Map封装 + - DiskCacheEntry.ets# 磁盘缓存entry + - DiskLruCache.ets # 磁盘LRU缓存策略 + - FileReader.ets # 文件读取相关 + - FileUtils.ets # 文件工具类 + - LruCache.ets # 内存LRU缓存策略 + - Md5.ets # MD5算法 + - imageknife # imageknife主要内容 - - compress # 压缩相关 - - constants # 常量相关 - - entry # 部分数据结构 - - holder # 占位图相关解析 - - interface # 接口相关 - - networkmanage # 网络相关 - - pngj # pngj相关 - - requestmanage # imageknife请求相关 - - resourcemanage # 本地资源解析相关 - - transform # 图片变换相关 - - utils # 工具类相关 - - ImageKnife.ets # imageknife门面,app持久化类 - - ImageKnifeData.ets # 数据封装 - - ImageKnifeComponent.ets # 自定义控件封装 - - ImageKnifeOption.ets # 用户传参数封装 - - PixelMapPack.ets # PixelMap封装 - - RequestOption.ets # 用户设置参数封装 - + - compress # 压缩相关 + - constants # 常量相关 + - entry # 部分数据结构 + - holder # 占位图相关解析 + - interface # 接口相关 + - networkmanage # 网络相关 + - pngj # pngj相关 + - requestmanage # imageknife请求相关 + - resourcemanage # 本地资源解析相关 + - transform # 图片变换相关 + - utils # 工具类相关 + - ImageKnife.ets # imageknife门面,app持久化类 + - ImageKnifeData.ets # 数据封装 + - ImageKnifeComponent.ets # 自定义控件封装 + - ImageKnifeOption.ets # 用户传参数封装 + - PixelMapPack.ets # PixelMap封装 + - RequestOption.ets # 用户设置参数封装 + /entry/src/ -- main/ets/MainAbility +- main/ets/MainAbility - pages # 测试page页面列表 - - basicTestFeatureAbilityPage.ets # 测试元能力 - - basicTestFileIOPage.ets # 测试fileio - - basicTestMediaImage.ets # 测试媒体image - - basicTestResourceManagerPage.ets # 测试本地资源解析 - - compressPage.ets # 压缩页面 - - frescoImageTestCasePage.ets # 测试属性动画组件切换 - - frescoLayerTestCasePage.ets # 测试ImageKnifeComponent组件切换配合属性动画 - - frescoRetryTestCasePage.ets # 测试ImageKnifeComponent加载失败重试 - - index.ets # 测试页面入口 - - indexFresco.ets # 二级测试页面入口 - - loadNetworkTestCasePage.ets # 网络加载测试 - - loadResourceTestCasePage.ets # 本地加载测试 - - showErrorholderTestCasePage.ets # 加载失败占位图测试 - - storageTestDiskLruCache.ets # 磁盘缓存测试 - - storageTestLruCache.ets # 内存缓存测试 - - testAllCacheInfoPage.ets # 所有缓存信息获取测试 - - testAllTypeImageKnifeComponentPage.ets # 所有类型图片加载测试 - - testAllTypeNativeImagePage.ets # 所有类型本地图片加载测试 - - testGifDontAnimatePage.ets # gif加载静态图片测试 - - testImageKnifeOptionChangedPage.ets # ImageKnifeOption数据切换测试 - - testImageKnifeOptionChangedPage2.ets # ImageKnifeOption数据切换测试 - - testMultiThreadWorkerPage2.ets # 多线程测试 - - testPlaceholderPage.ets # 加载占位图测试 - - testPreloadPage.ets # 预加载测试 - - testResourceManagerPage.ets # 解析本地资源测试 - - transformPixelMapPage.ets # 所有类型变换测试 - - transformTestCasePage.ets # 所有类型变换配合ImageKnifeComponent测试 - + - basicTestFeatureAbilityPage.ets # 测试元能力 + - basicTestFileIOPage.ets # 测试fileio + - basicTestMediaImage.ets # 测试媒体image + - basicTestResourceManagerPage.ets # 测试本地资源解析 + - compressPage.ets # 压缩页面 + - cropImagePage.ets # 裁剪页面 + - cropImagePage2.ets # 手势裁剪页面 + - frescoImageTestCasePage.ets # 测试属性动画组件切换 + - frescoLayerTestCasePage.ets # 测试ImageKnifeComponent组件切换配合属性动画 + - frescoRetryTestCasePage.ets # 测试ImageKnifeComponent加载失败重试 + - index.ets # 测试页面入口 + - indexFresco.ets # 二级测试页面入口 + - loadNetworkTestCasePage.ets # 网络加载测试 + - loadResourceTestCasePage.ets # 本地加载测试 + - showErrorholderTestCasePage.ets # 加载失败占位图测试 + - storageTestDiskLruCache.ets # 磁盘缓存测试 + - storageTestLruCache.ets # 内存缓存测试 + - testAllCacheInfoPage.ets # 所有缓存信息获取测试 + - testAllTypeImageKnifeComponentPage.ets # 所有类型图片加载测试 + - testAllTypeNativeImagePage.ets # 所有类型本地图片加载测试 + - testGifDontAnimatePage.ets # gif加载静态图片测试 + - testImageKnifeOptionChangedPage.ets # ImageKnifeOption数据切换测试 + - testImageKnifeOptionChangedPage2.ets # ImageKnifeOption数据切换测试 + - testMultiThreadWorkerPage2.ets # 多线程测试 + - testPlaceholderPage.ets # 加载占位图测试 + - testPreloadPage.ets # 预加载测试 + - testResourceManagerPage.ets # 解析本地资源测试 + - transformPixelMapPage.ets # 所有类型变换测试 + - transformTestCasePage.ets # 所有类型变换配合ImageKnifeComponent测试 + - workers # 测试worker多线程 - - worker1.js # worker多线程测试 + - worker1.js # worker多线程测试 ``` ## 贡献代码 diff --git a/build-profile.json5 b/build-profile.json5 index d787b0e..1021077 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -1,21 +1,7 @@ { "app": { - "signingConfigs": [ - { - "name": "default", - "material": { - "certpath": "C:\\Users\\zwx1045834\\.ohos\\config\\openharmony\\auto_ohos.cer", - "storePassword": "000000184CD86AF7B78D3E3B6C36B9221705137AC28BD8A341A757477E5DC27D95E6A0DFD5EB51AE", - "keyAlias": "debugKey", - "keyPassword": "00000018DAB1AB9C9DF6E7C4D35BE8EAF4323EFA49131AB39C65BA5C44DE6D3879C6B31AA70D1E14", - "profile": "C:\\Users\\zwx1045834\\.ohos\\config\\openharmony\\auto_ohos_default_com.example.imageknifegiteepro.p7b", - "signAlg": "SHA256withECDSA", - "storeFile": "C:\\Users\\zwx1045834\\.ohos\\config\\openharmony\\auto_ohos.p12" - } - } - ], - "compileSdkVersion": 8, - "compatibleSdkVersion": 8, + "compileSdkVersion": 9, + "compatibleSdkVersion": 9, "products": [ { "name": "default", @@ -39,6 +25,10 @@ { "name": "imageknife", "srcPath": "./imageknife" + }, + { + "name": "disklrucache", + "srcPath": "./disklrucache" } ] } \ No newline at end of file diff --git a/disklrucache/.gitignore b/disklrucache/.gitignore new file mode 100644 index 0000000..4f9a973 --- /dev/null +++ b/disklrucache/.gitignore @@ -0,0 +1,3 @@ +/node_modules +/.preview +/build \ No newline at end of file diff --git a/disklrucache/build-profile.json5 b/disklrucache/build-profile.json5 new file mode 100644 index 0000000..35dff6d --- /dev/null +++ b/disklrucache/build-profile.json5 @@ -0,0 +1,5 @@ +{ + "apiType": "stageMode", + "buildOption": { + } +} diff --git a/disklrucache/hvigorfile.js b/disklrucache/hvigorfile.js new file mode 100644 index 0000000..42ed4b4 --- /dev/null +++ b/disklrucache/hvigorfile.js @@ -0,0 +1,3 @@ +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +module.exports = require('@ohos/hvigor-ohos-plugin').harTasks + diff --git a/disklrucache/index.ets b/disklrucache/index.ets new file mode 100644 index 0000000..d2d2c2f --- /dev/null +++ b/disklrucache/index.ets @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http:// www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * disklrucache + */ +export * from './src/main/ets/components/disklrucache/DiskLruCache' +export * from './src/main/ets/components/disklrucache/DiskCacheEntry' diff --git a/disklrucache/package.json b/disklrucache/package.json new file mode 100644 index 0000000..492598e --- /dev/null +++ b/disklrucache/package.json @@ -0,0 +1,18 @@ +{ + "license":"ISC", + "types":"", + "devDependencies":{ + "@types/spark-md5":"^3.0.2" + }, + "name":"@ohos/disklrucache", + "description":"a npm package which contains arkUI2.0 page", + "ohos":{ + "org":"" + }, + "main":"index.ets", + "repository":{}, + "version":"1.0.0", + "dependencies":{ + "spark-md5":"^3.0.2" + } +} \ No newline at end of file diff --git a/disklrucache/src/main/ets/components/disklrucache/CustomMap.ts b/disklrucache/src/main/ets/components/disklrucache/CustomMap.ts new file mode 100644 index 0000000..6e8b05a --- /dev/null +++ b/disklrucache/src/main/ets/components/disklrucache/CustomMap.ts @@ -0,0 +1,115 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http:// www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export class CustomMap { + map: Map = new Map() + + /** + * 获取键对应的值 + * + * @param key 键值 + */ + get(key: K): V | undefined { + if (key == null) { + throw new Error('key is null,checking the parameter'); + } + return this.map.get(key) + } + + /** + * 是否含有key的缓存 + * + * @param key 键值 + */ + hasKey(key: K) { + if (key == null) { + throw new Error('key is null,checking the parameter'); + } + return this.map.has(key) + } + + /** + * 添加键值对 + * + * @param key 键值 + * @param value 键对应的值 + */ + put(key: K, value: V): V | undefined { + if (key == null || value == null) { + throw new Error('key or value is invalid,checking the parameter'); + } + let pre = this.map.get(key) + if (this.hasKey(key)) { + this.map.delete(key) + } + this.map.set(key, value); + return pre + } + + /** + * 去除键值,(去除键数据中的键名及对应的值) + * + * @param key 键值 + */ + remove(key: K): boolean { + if (key == null) { + throw new Error('key is null,checking the parameter'); + } + return this.map.delete(key) + } + + /** + * 获取最先存储的数据的key + */ + getFirstKey(): K { // keys()可以遍历后需要优化put()方法,暂时仅获取index=0的key + return this.map.keys().next().value + } + + /** + * 判断键值元素是否为空 + */ + isEmpty(): boolean { + return this.map.size == 0; + } + + /** + * 获取键值元素大小 + */ + size(): number { + return this.map.size; + } + + /** + * 遍历Map,执行处理函数. 回调函数 function(key,value,index){..} + * + * @param fn 遍历回调方法 + */ + each(fn) { + this.map.forEach(fn) + } + + /** + * 清除键值对 + */ + clear() { + this.map.clear() + } + + /** + * 遍历key + */ + keys(): IterableIterator { + return this.map.keys() + } +} \ No newline at end of file diff --git a/imageknife/src/main/ets/components/cache/DiskCacheEntry.ets b/disklrucache/src/main/ets/components/disklrucache/DiskCacheEntry.ts similarity index 56% rename from imageknife/src/main/ets/components/cache/DiskCacheEntry.ets rename to disklrucache/src/main/ets/components/disklrucache/DiskCacheEntry.ts index ece37d8..ad2625d 100644 --- a/imageknife/src/main/ets/components/cache/DiskCacheEntry.ets +++ b/disklrucache/src/main/ets/components/disklrucache/DiskCacheEntry.ts @@ -13,35 +13,34 @@ * limitations under the License. */ export class DiskCacheEntry { + // 缓存的key + key: string = '' - // 缓存的key - key: string= '' + // 缓存文件大小 + length: number = 0 - // 缓存文件大小 - length: number= 0 + constructor(key: string, length?: number) { + this.key = key + this.length = length + } - constructor(key: string, length?: number) { - this.key = key - this.length = length - } + setKey(key: string) { + this.key = key + } - setKey(key: string) { - this.key = key - } + getKey(): string { + return this.key + } - getkey(): string{ - return this.key - } + setLength(length: number) { + this.length = length + } - setLength(length: number) { - this.length = length - } + getLength(): number { + return this.length + } - getLength(): number{ - return this.length - } - - toString(): string{ - return this.key + ' - ' + this.length - } + toString(): string { + return this.key + ' - ' + this.length + } } \ No newline at end of file diff --git a/disklrucache/src/main/ets/components/disklrucache/DiskLruCache.ts b/disklrucache/src/main/ets/components/disklrucache/DiskLruCache.ts new file mode 100644 index 0000000..f36800c --- /dev/null +++ b/disklrucache/src/main/ets/components/disklrucache/DiskLruCache.ts @@ -0,0 +1,444 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import fileio from '@ohos.fileio' +import { CustomMap } from './CustomMap' +import { FileUtils } from './FileUtils' +import { FileReader } from './FileReader' +import { DiskCacheEntry } from './DiskCacheEntry' +import SparkMD5 from "spark-md5" + + +export class DiskLruCache { + // 默认缓存数据最大值 + private static readonly DEFAULT_MAX_SIZE: number = 30 * 1024 * 1024 + + // 缓存journal文件名称 + private static readonly journal: string = 'journal' + + // 缓存journal备份文件名称 + private static readonly journalTemp: string = 'journal_temp' + + // 备份文件save标识符 + private static readonly SAVE: string = 'save' + + // 备份文件read标识符 + private static readonly READ: string = 'read' + + // 备份文件remove标识符 + private static readonly REMOVE: string = 'remove' + + // 缓存文件路径地址 + private path: string = '' + + // 缓存journal文件路径 + private journalPath: string = '' + + // 缓存journal备份文件路径 + private journalPathTemp: string = '' + + // 缓存数据最大值 + private maxSize: number = DiskLruCache.DEFAULT_MAX_SIZE + + // 当前缓存数据值 + private size: number = 0 + + // 缓存数据集合 + private cacheMap: CustomMap = new CustomMap() + + private constructor(path: string, maxSize: number) { + this.path = path + this.maxSize = maxSize + this.journalPath = path + DiskLruCache.journal + this.journalPathTemp = path + DiskLruCache.journalTemp + } + + /** + * 打开path中的缓存,如果不存在缓存,则创建新缓存 + * + * @param path 缓存文件路径地址 + * @param maxSize 缓存数据最大值,默认值为3M + */ + public static create(path: string, maxSize?: number): DiskLruCache { + if (!!!path) { + throw new Error('DiskLruCache create path is empty, checking the parameter'); + } + if (!!!maxSize) { + maxSize = DiskLruCache.DEFAULT_MAX_SIZE + } + if (maxSize <= 0) { + throw new Error("DiskLruCache create maxSize <= 0, checking the parameter"); + } + if (!FileUtils.getInstance().existFolder(path)) { + FileUtils.getInstance().createFolder(path, true) + } + if (path.endsWith(FileUtils.SEPARATOR)) { + path = path + } else { + path = path + FileUtils.SEPARATOR + } + let journalPath = path + DiskLruCache.journal + let journalPathTemp = path + DiskLruCache.journalTemp + + // 判断日志文件是否存在,如果没有初始化创建 + if (FileUtils.getInstance().exist(journalPath)) { + let stat = fileio.statSync(journalPath) + if (stat.size > 0) { + FileUtils.getInstance().createFile(journalPathTemp) + FileUtils.getInstance().copyFile(journalPath, journalPathTemp) + let diskLruCache: DiskLruCache = new DiskLruCache(path, maxSize) + diskLruCache.readJournal(journalPathTemp) + diskLruCache.resetJournalFile() + return diskLruCache + } else { + return new DiskLruCache(path, maxSize) + } + } else { + FileUtils.getInstance().createFile(journalPath) + return new DiskLruCache(path, maxSize) + } + } + + /** + * 处理journal文件数据 + * + * @param line 日志行字符串 + */ + private dealWithJournal(line: string) { + let filePath = '' + try { + let lineData = line.split(' ') + if (lineData.length > 1) { + if (lineData[0] != DiskLruCache.REMOVE) { + filePath = this.path + lineData[1] + let fileStat = fileio.statSync(filePath) + if (fileStat.isFile() && fileStat.size > 0) { + this.size = this.size + fileStat.size + FileUtils.getInstance().writeData(this.journalPath, line + FileReader.LF) + this.putCacheMap(lineData[1], fileStat.size) + } + } else { + if (this.cacheMap.hasKey(lineData[1])) { + let cacheEntry: DiskCacheEntry = this.cacheMap.get(lineData[1]) + this.size = this.size - cacheEntry.getLength() + this.cacheMap.remove(lineData[1]) + } + } + } + } catch (e) { + console.error('DiskLruCache - dealWithJournal e ' + e) + } + } + + /** + * 设置disk缓存最大数据值 + * + * @param max 缓存数据最大值 + */ + setMaxSize(max: number) { + this.maxSize = max + this.trimToSize() + } + + /** + * 存储disk缓存数据 + * + * @param key 键值 + * @param content 文件内容 + */ + set(key: string, content: ArrayBuffer) { + if (!!!key) { + throw new Error('key is null, checking the parameter') + } + if (content == null || content.byteLength == 0) { + throw new Error('content is null, checking the parameter') + } + let fileSize = content.byteLength + key = SparkMD5.hash(key) + this.size = this.size + fileSize + this.putCacheMap(key, fileSize) + FileUtils.getInstance().writeData(this.journalPath, DiskLruCache.SAVE + ' ' + key + FileReader.LF) + this.trimToSize() + let tempPath = this.path + key + FileUtils.getInstance().writeNewFile(tempPath, content) + } + + /** + * 异步存储disk缓存数据 + * + * @param key 键值 + * @param content 文件内容 + */ + async setAsync(key: string, content: ArrayBuffer): Promise { + if (!!!key) { + throw new Error('key is null, checking the parameter') + } + if (content == null || content.byteLength == 0) { + throw new Error('content is null, checking the parameter') + } + let fileSize = content.byteLength + key = SparkMD5.hash(key) + this.size = this.size + fileSize + console.log('setAsync fileSize ='+ fileSize +' all size ='+this.size + ' max size ='+this.maxSize); + this.putCacheMap(key, fileSize) + await FileUtils.getInstance().writeDataAsync(this.journalPath, DiskLruCache.SAVE + ' ' + key + FileReader.LF) + this.trimToSize() + let tempPath = this.path + key + await FileUtils.getInstance().writeNewFileAsync(tempPath, content) + } + + /** + * 存储disk缓存数据 + * + * @param key key 键值 + * @param path 文件路径 + */ + setFileByPath(key: string, path: string) { + if (!!!key) { + throw new Error('key is null, checking the parameter') + } + if (!!!path || !FileUtils.getInstance().exist(path)) { + throw new Error('path is null or no exist file, checking the parameter') + } + let fileSize = FileUtils.getInstance().getFileSize(path) + if (fileSize == -1) { + throw new Error('path getFileSize error ') + } + key = SparkMD5.hash(key) + this.size = this.size + fileSize + this.putCacheMap(key, fileSize) + FileUtils.getInstance().writeData(this.journalPath, DiskLruCache.SAVE + ' ' + key + FileReader.LF) + this.trimToSize() + fileSize = FileUtils.getInstance().getFileSize(path) + FileUtils.getInstance().copyFile(path, this.path + key) + } + + /** + * 异步存储disk缓存数据 + * + * @param key key 键值 + * @param path 文件路径 + */ + async setFileByPathAsync(key: string, path: string): Promise { + if (!!!key) { + throw new Error('key is null, checking the parameter') + } + if (!!!path || !FileUtils.getInstance().exist(path)) { + throw new Error('path is null or no exist file, checking the parameter') + } + let fileSize = FileUtils.getInstance().getFileSize(path) + if (fileSize == -1) { + throw new Error('path getFileSize error ') + } + key = SparkMD5.hash(key) + this.size = this.size + fileSize + this.putCacheMap(key, fileSize) + await FileUtils.getInstance().writeDataAsync(this.journalPath, DiskLruCache.SAVE + ' ' + key + FileReader.LF) + this.trimToSize() + fileSize = FileUtils.getInstance().getFileSize(path) + await FileUtils.getInstance().copyFileAsync(path, this.path + key) + } + + /** + * 获取key缓存数据 + * + * @param key key 键值 + */ + get(key: string): ArrayBuffer { + if (!!!key) { + throw new Error('key is null,checking the parameter'); + } + key = SparkMD5.hash(key) + let path = this.path + key; + if (FileUtils.getInstance().exist(path)) { + let ab: ArrayBuffer = FileUtils.getInstance().readFile(path) + this.putCacheMap(key, ab.byteLength) + FileUtils.getInstance().writeData(this.journalPath, DiskLruCache.READ + ' ' + key + FileReader.LF) + return ab + } else { + return null; + } + } + + /** + * 异步获取key缓存数据 + * + * @param key 键值 + */ + async getAsync(key: string): Promise { + if (!!!key) { + throw new Error('key is null,checking the parameter'); + } + key = SparkMD5.hash(key) + let path = this.path + key; + if (FileUtils.getInstance().exist(path)) { + let ab: ArrayBuffer = await FileUtils.getInstance().readFileAsync(path) + this.putCacheMap(key, ab.byteLength) + await FileUtils.getInstance().writeDataAsync(this.journalPath, DiskLruCache.READ + ' ' + key + FileReader.LF) + return ab + } else { + return null; + } + } + + /** + * 获取key缓存数据绝对路径 + * + * @param key 键值 + */ + getFileToPath(key: string): string { + if (!!!key) { + throw new Error('key is null,checking the parameter'); + } + key = SparkMD5.hash(key); + let path = this.path + key; + if (FileUtils.getInstance().exist(path)) { + FileUtils.getInstance().writeData(this.journalPath, DiskLruCache.READ + ' ' + key + FileReader.LF); + return path + } else { + return null + } + } + + /** + * 异步获取key缓存数据绝对路径 + * + * @param key 键值 + */ + async getFileToPathAsync(key: string): Promise { + if (!!!key) { + throw new Error('key is null,checking the parameter'); + } + key = SparkMD5.hash(key); + let path = this.path + key; + if (FileUtils.getInstance().exist(path)) { + await FileUtils.getInstance().writeDataAsync(this.journalPath, DiskLruCache.READ + ' ' + key + FileReader.LF); + return path + } else { + return null + } + } + + /** + * 删除key缓存数据 + * + * @param key 键值 + */ + deleteCacheDataByKey(key: string): DiskCacheEntry { + if (!!!key) { + throw new Error('key is null,checking the parameter'); + } + key = SparkMD5.hash(key) + let path = this.path + key; + if (FileUtils.getInstance().exist(path)) { + let ab = FileUtils.getInstance().readFile(path) + this.size = this.size - ab.byteLength + this.cacheMap.remove(key) + FileUtils.getInstance().writeData(this.journalPath, DiskLruCache.REMOVE + ' ' + key + FileReader.LF) + FileUtils.getInstance().deleteFile(path) + } + return this.cacheMap.get(key) + } + + /** + *遍历当前的磁盘缓存数据 + * + * @param fn 遍历后方法回调 + */ + foreachDiskLruCache(fn) { + this.cacheMap.each(fn) + } + + /** + * 清除所有disk缓存数据 + */ + cleanCacheData() { + this.cacheMap.each((value, key) => { + FileUtils.getInstance().deleteFile(this.path + key) + }) + FileUtils.getInstance().deleteFile(this.journalPath) + this.cacheMap.clear() + this.size = 0 + } + + /** + * 重置journal文件数据 + */ + private resetJournalFile() { + FileUtils.getInstance().clearFile(this.journalPath) + for (let key of this.cacheMap.keys()) { + FileUtils.getInstance().writeData(this.journalPath, DiskLruCache.SAVE + ' ' + key + FileReader.LF) + } + } + + /** + * 读取journal文件的缓存数据 + * + * @param path 日志缓存文件路径地址 + */ + private readJournal(path: string) { + let fileReader = new FileReader(path) + let line: string = '' + while (!fileReader.isEnd()) { + line = fileReader.readLine() + line = line.replace(FileReader.LF, '').replace(FileReader.CR, '') + this.dealWithJournal(line) + } + fileReader.close() + FileUtils.getInstance().deleteFile(this.journalPathTemp) + this.trimToSize() + } + + /** + * 缓存数据map集合 + * + * @param key 键值 + * @param length 缓存文件大小 + */ + private putCacheMap(key: string, length?: number) { + if (length > 0) { + console.log('key = '+key) + console.log('value length= '+ length) + this.cacheMap.put(key, new DiskCacheEntry(key, length)) + } else { + this.cacheMap.put(key, new DiskCacheEntry(key)) + } + } + + /** + * 根据LRU算法删除多余缓存数据 + */ + private trimToSize() { + + while (this.size > this.maxSize) { + let tempKey: string = this.cacheMap.getFirstKey() + let fileSize = FileUtils.getInstance().getFileSize(this.path + tempKey) + if (fileSize > 0) { + this.size = this.size - fileSize + } + console.log('trimToSize fileSize ='+ fileSize +' all size ='+this.size + ' max size ='+this.maxSize); + FileUtils.getInstance().deleteFile(this.path + tempKey) + this.cacheMap.remove(tempKey) + FileUtils.getInstance().writeData(this.journalPath, DiskLruCache.REMOVE + ' ' + tempKey + FileReader.LF) + } + } + + getPath(){ + return this.path; + } + + getCacheMap(){ + return this.cacheMap; + } +} \ No newline at end of file diff --git a/disklrucache/src/main/ets/components/disklrucache/FileReader.ts b/disklrucache/src/main/ets/components/disklrucache/FileReader.ts new file mode 100644 index 0000000..42b2ddf --- /dev/null +++ b/disklrucache/src/main/ets/components/disklrucache/FileReader.ts @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import fileio from '@ohos.fileio' + +export class FileReader { + // 换行符 + static readonly LF: string = '\n' + + // CR符 + static readonly CR: string = '\r' + + // 文件大小 + fileLength: number = 0 + + // 读取的长度 + length: number = 0 + + // 读写stream + stream: any = null + + // 缓存buf + buf: ArrayBuffer = new ArrayBuffer(1) + + /** + * 读取文件行 + * + * @param path 文件路径 + */ + constructor(path: string) { + if (!path || Object.keys(path).length == 0) { + return + } + try { + this.stream = fileio.createStreamSync(path, 'r+'); + let stat = fileio.statSync(path) + this.fileLength = stat.size + } catch (e) { + } + } + + /** + * 循环读取文件数据 + */ + readLine(): string { + let line = '' + while (this.length <= this.fileLength) { + this.stream.readSync(this.buf, { position: this.length }) + this.length++ + let temp = String.fromCharCode.apply(null, new Uint8Array(this.buf)); + line = line + temp + if (temp == FileReader.LF || temp == FileReader.CR) { + return line + } + } + return line + } + + /** + * 判断文件是否结束 + */ + isEnd() { + return this.fileLength <= 0 || this.length == this.fileLength + } + + /** + * 关闭stream + */ + close() { + this.stream.closeSync() + } +} \ No newline at end of file diff --git a/disklrucache/src/main/ets/components/disklrucache/FileUtils.ts b/disklrucache/src/main/ets/components/disklrucache/FileUtils.ts new file mode 100644 index 0000000..1038004 --- /dev/null +++ b/disklrucache/src/main/ets/components/disklrucache/FileUtils.ts @@ -0,0 +1,240 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import fileio from '@ohos.fileio' + +export class FileUtils { + private static sInstance: FileUtils + static readonly SEPARATOR: string = '/' + base64Str: string = '' + + /** + * 单例实现FileUtils类 + */ + public static getInstance(): FileUtils { + if (!this.sInstance) { + this.sInstance = new FileUtils(); + } + return this.sInstance; + } + + private constructor() { + } + + /** + * 新建文件 + * + * @param path 文件绝对路径及文件名 + * @return number 文件句柄id + */ + createFile(path: string): number { + return fileio.openSync(path, 0o100, 0o664) + } + + /** + * 删除文件 + * + * @param path 文件绝对路径及文件名 + */ + deleteFile(path: string): void { + fileio.unlinkSync(path); + } + + /** + * 拷贝文件 + * + * @param src 文件绝对路径及文件名 + * @param dest 拷贝到对应的路径 + */ + copyFile(src: string, dest: string) { + fileio.copyFileSync(src, dest); + } + + /** + * 异步拷贝文件 + * + * @param src 文件绝对路径及文件名 + * @param dest 拷贝到对应的路径 + */ + async copyFileAsync(src: string, dest: string): Promise { + await fileio.copyFile(src, dest); + } + + /** + * 清空已有文件数据 + * + * @param path 文件绝对路径 + */ + clearFile(path: string): number { + return fileio.openSync(path, 0o1000) + } + + /** + * 向path写入数据 + * + * @param path 文件绝对路径 + * @param content 文件内容 + */ + writeData(path: string, content: ArrayBuffer | string) { + let fd = fileio.openSync(path, 0o102, 0o664) + let stat = fileio.statSync(path) + fileio.writeSync(fd, content, { position: stat.size }) + fileio.closeSync(fd) + } + + /** + * 异步向path写入数据 + * + * @param path 文件绝对路径 + * @param content 文件内容 + */ + async writeDataAsync(path: string, content: ArrayBuffer | string): Promise { + let fd = await fileio.open(path, 0o102, 0o664) + let stat = await fileio.stat(path) + await fileio.write(fd, content, { position: stat.size }) + await fileio.close(fd) + } + + /** + * 判断path文件是否存在 + * + * @param path 文件绝对路径 + */ + exist(path: string): boolean { + try { + let stat = fileio.statSync(path) + return stat.isFile() + } catch (e) { + console.error("FileUtils exist e " + e) + return false + } + } + + /** + * 向path写入数据 + * + * @param path 文件绝对路径 + * @param data 文件内容 + */ + writeNewFile(path: string, data: ArrayBuffer) { + this.createFile(path) + this.writeFile(path, data) + } + + /** + * 向path写入数据 + * + * @param path 文件绝对路径 + * @param data 文件内容 + */ + async writeNewFileAsync(path: string, data: ArrayBuffer): Promise { + await fileio.open(path, 0o100, 0o664) + let fd = await fileio.open(path, 0o102, 0o664) + await fileio.ftruncate(fd) + await fileio.write(fd, data) + await fileio.fsync(fd) + await fileio.close(fd) + } + + /** + * 获取path的文件大小 + * + * @param path 文件绝对路径 + */ + getFileSize(path: string): number { + try { + let stat = fileio.statSync(path) + return stat.size + } catch (e) { + console.error("FileUtils getFileSize e " + e) + return -1 + } + } + + /** + * 读取路径path的文件 + * + * @param path 文件绝对路径 + */ + readFile(path: string): ArrayBuffer { + let fd = fileio.openSync(path, 0o2); + let length = fileio.statSync(path).size + let buf = new ArrayBuffer(length); + fileio.readSync(fd, buf) + return buf + } + + /** + * 读取路径path的文件 + * + * @param path 文件绝对路径 + */ + async readFileAsync(path: string): Promise { + let stat = await fileio.stat(path); + let fd = await fileio.open(path, 0o2); + let length = stat.size; + let buf = new ArrayBuffer(length); + await fileio.read(fd, buf); + return buf + } + + /** + * 创建文件夹 + * + * @param path 文件夹绝对路径,只有是权限范围内的路径,可以生成 + * @param recursive + */ + createFolder(path: string, recursive?: boolean) { + if (recursive) { + if (!this.existFolder(path)) { + let lastInterval = path.lastIndexOf(FileUtils.SEPARATOR) + if (lastInterval == 0) { + return + } + let newPath = path.substring(0, lastInterval) + this.createFolder(newPath, true) + if (!this.existFolder(path)) { + fileio.mkdirSync(path) + } + } + } else { + if (!this.existFolder(path)) { + fileio.mkdirSync(path) + } + } + } + + /** + * 判断文件夹是否存在 + * + * @param path 文件夹绝对路径 + */ + existFolder(path: string): boolean { + try { + let stat = fileio.statSync(path) + return stat.isDirectory() + } catch (e) { + console.error("FileUtils folder exist e " + e) + return false + } + } + + private writeFile(path: string, content: ArrayBuffer | string) { + let fd = fileio.openSync(path, 0o102, 0o664) + fileio.ftruncateSync(fd) + fileio.writeSync(fd, content) + fileio.fsyncSync(fd) + fileio.closeSync(fd) + } +} \ No newline at end of file diff --git a/disklrucache/src/main/module.json5 b/disklrucache/src/main/module.json5 new file mode 100644 index 0000000..f2c566d --- /dev/null +++ b/disklrucache/src/main/module.json5 @@ -0,0 +1,11 @@ +{ + "module": { + "name": "disklrucache", + "type": "har", + "deviceTypes": [ + "default", + "tablet" + ], + "uiSyntax": "ets" + } +} diff --git a/disklrucache/src/main/resources/base/element/string.json b/disklrucache/src/main/resources/base/element/string.json new file mode 100644 index 0000000..1e76de0 --- /dev/null +++ b/disklrucache/src/main/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from npm package" + } + ] +} diff --git a/entry/build-profile.json5 b/entry/build-profile.json5 index ae58d1d..44145e0 100644 --- a/entry/build-profile.json5 +++ b/entry/build-profile.json5 @@ -1,6 +1,11 @@ { - "apiType": 'faMode', + "apiType": 'stageMode', "buildOption": { + "sourceOption": { + "workers": [ + "./src/main/ets/pages/workers/worker1.js", + ] + } }, "targets": [ { diff --git a/entry/hvigorfile.js b/entry/hvigorfile.js index bcec4c9..d7720ee 100644 --- a/entry/hvigorfile.js +++ b/entry/hvigorfile.js @@ -1,2 +1,2 @@ // Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. -module.exports = require('@ohos/hvigor-ohos-plugin').legacyHapTasks +module.exports = require('@ohos/hvigor-ohos-plugin').hapTasks diff --git a/entry/package-lock.json b/entry/package-lock.json deleted file mode 100644 index 91c2411..0000000 --- a/entry/package-lock.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "entry", - "version": "1.0.0", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "@ohos/imageknife": { - "version": "file:../imageknife", - "requires": { - "pako": "^1.0.5" - }, - "dependencies": { - "pako": { - "version": "1.0.11", - "resolved": "http://mirrors.tools.huawei.com/npm/pako/-/pako-1.0.11.tgz", - "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==" - } - } - } - } -} diff --git a/entry/package.json b/entry/package.json index bce3fa8..de0a391 100644 --- a/entry/package.json +++ b/entry/package.json @@ -1,14 +1,16 @@ { - "license": "Apache License 2.0", - "devDependencies": {}, - "name": "entry", - "ohos": { - "org": "huawei", - "directoryLevel": "module", - "buildTool": "hvigor" + "license":"ISC", + "devDependencies":{}, + "name":"entry", + "ohos":{ + "org":"huawei", + "directoryLevel":"module", + "buildTool":"hvigor" }, - "version": "1.0.0", - "dependencies": { - "@ohos/imageknife": "file:../imageknife" + "description":"example description", + "repository":{}, + "version":"1.0.0", + "dependencies":{ + "@ohos/imageknife":"file:../imageknife" } -} +} \ No newline at end of file diff --git a/entry/src/main/config.json b/entry/src/main/config.json deleted file mode 100644 index 6d3d97f..0000000 --- a/entry/src/main/config.json +++ /dev/null @@ -1,140 +0,0 @@ -{ - "app": { - "vendor": "openharmony", - "bundleName": "cn.openharmony.imageknife", - "version": { - "code": 1000000, - "name": "1.0.0" - } - }, - "deviceConfig": { - "default": { - "network": { - "cleartextTraffic": true - } - } - }, - "module": { - "mainAbility": ".MainAbility", - "deviceType": [ - "phone", - "tablet" - ], - "abilities": [ - { - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ], - "orientation": "unspecified", - "visible": true, - "srcPath": "MainAbility", - "name": ".MainAbility", - "srcLanguage": "ets", - "icon": "$media:icon", - "description": "$string:ImageKnife_OHOS", - "formsEnabled": false, - "label": "$string:ImageKnife_OHOS", - "type": "page", - "launchType": "standard" - } - ], - "distro": { - "moduleType": "entry", - "installationFree": false, - "deliveryWithInstall": true, - "moduleName": "entry" - }, - "package": "cn.openharmony.entry", - "srcPath": "", - "name": ".entry", - "reqPermissions": [ - { - "name": "ohos.permission.READ_USER_STORAGE" - }, - { - "name": "ohos.permission.INTERNET", - "reason": "Api call", - "usedScene": { - "ability": [ - "cn.openharmony.imageknife.MainAbility" - ], - "when": "always" - } - }, - { - "name": "ohos.permission.KEEP_BACKGROUND_RUNNING" - }, - { - "name": "ohos.permission.READ_MEDIA", - "reason": "location background", - "usedScene": { - "when": "always", - "ability": [ - "cn.openharmony.imageknife.MainAbility" - ] - } - }, - { - "name": "ohos.permission.WRITE_MEDIA", - "reason": "location background", - "usedScene": { - "when": "always", - "ability": [ - "cn.openharmony.imageknife.MainAbility" - ] - } - } - ], - "js": [ - { - "mode": { - "syntax": "ets", - "type": "pageAbility" - }, - "pages": [ - "pages/index", - "pages/indexFresco", - "pages/frescoLayerTestCasePage", - "pages/frescoImageTestCasePage", - "pages/frescoRetryTestCasePage", - "pages/basicTestFeatureAbilityPage", - "pages/basicTestFileIOPage", - "pages/basicTestMediaImage", - "pages/basicTestResourceManagerPage", - "pages/storageTestLruCache", - "pages/storageTestDiskLruCache", - "pages/transformTestCasePage", - "pages/pngjTestCasePage", - "pages/testAllTypeImageKnifeComponentPage", - "pages/testAllTypeNativeImagePage", - "pages/loadResourceTestCasePage", - "pages/loadNetworkTestCasePage", - "pages/showErrorholderTestCasePage", - "pages/transformPixelMapPage", - "pages/testGifDontAnimatePage", - "pages/testPreloadPage", - "pages/testImageKnifeOptionChangedPage", - "pages/testImageKnifeOptionChangedPage2", - "pages/compressPage", - "pages/testAllCacheInfoPage", - "pages/testResourceManagerPage", - "pages/testMultiThreadWorkerPage2", - "pages/testImageKnifeOptionChangedPage", - "pages/cropImagePage" - ], - "name": ".MainAbility", - "window": { - "designWidth": 720, - "autoDesignWidth": false - } - } - ] - } -} \ No newline at end of file diff --git a/entry/src/main/ets/MainAbility/app.ets b/entry/src/main/ets/Application/AbilityStage.ts similarity index 70% rename from entry/src/main/ets/MainAbility/app.ets rename to entry/src/main/ets/Application/AbilityStage.ts index b2d066b..2395462 100644 --- a/entry/src/main/ets/MainAbility/app.ets +++ b/entry/src/main/ets/Application/AbilityStage.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -12,18 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import app from '@system.app'; - +import AbilityStage from "@ohos.application.AbilityStage" import {ImageKnife} from '@ohos/imageknife' -export default { - data: { - imageKnife: {} // ImageKnife - }, - onCreate() { - this.data.imageKnife = ImageKnife.with(); - }, - onDestroy() { - - }, -} +export default class MyAbilityStage extends AbilityStage { + onCreate() { + globalThis.ImageKnife = ImageKnife.with(this.context); + } +} \ No newline at end of file diff --git a/entry/src/main/ets/Application/MyAbilityStage.ts b/entry/src/main/ets/Application/MyAbilityStage.ts new file mode 100644 index 0000000..32dfe93 --- /dev/null +++ b/entry/src/main/ets/Application/MyAbilityStage.ts @@ -0,0 +1,7 @@ +import AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/entry/src/main/ets/MainAbility/MainAbility.ts b/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000..67c59e7 --- /dev/null +++ b/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import Ability from '@ohos.application.Ability' +import {ImageKnife} from '@ohos/imageknife' +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + + +// this.context.resourceManager.getMedia() +// globalThis.ImageKnifeContext = this.context; +// globalThis.ImageKnife = ImageKnife.with(this.context); +// this.context.filesDir + + console.log('globalThis.ImageKnife 1 ='+typeof globalThis.ImageKnife) + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + + windowStage.setUIContent(this.context, "pages/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/entry/src/main/ets/MainAbility/pages/basicTestMediaImage.ets b/entry/src/main/ets/MainAbility/pages/basicTestMediaImage.ets deleted file mode 100644 index 06128a6..0000000 --- a/entry/src/main/ets/MainAbility/pages/basicTestMediaImage.ets +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import featureAbility from '@ohos.ability.featureAbility'; -import {FileUtils} from '@ohos/imageknife' -import {FileTypeUtil} from '@ohos/imageknife' -import resourceManager from '@ohos.resourceManager'; -import {Base64} from '@ohos/imageknife' -import {PixelMapPack} from '@ohos/imageknife' -import {ParseImageUtil} from '@ohos/imageknife' - -@Entry -@Component -struct BasicTestMediaImage { - @State pixelMapPack:PixelMapPack= new PixelMapPack(); - build() { - Scroll() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Flex({direction:FlexDirection.Row}){ - Button('本地资源jpg') - .onClick(()=>{ - resourceManager.getResourceManager() - .then(result => { - result.getMedia($r('app.media.jpgSample').id) - .then(data => { - let arrayBuffer = this.typedArrayToBuffer(data); - let parseImageUtil = new ParseImageUtil(); - parseImageUtil.parseImage(arrayBuffer,(pxielmap)=>{ - let jpgPack = new PixelMapPack(); - jpgPack.pixelMap = pxielmap; - this.pixelMapPack = jpgPack; - },(err)=>{}) - }) - .catch(err => { - console.log('basicTestMediaImage - 本地加载资源err' + JSON.stringify(err)); - }) - }) - - }).margin({left:15}).backgroundColor(Color.Blue) - Button('本地资源png') - .onClick(()=>{ - resourceManager.getResourceManager() - .then(result => { - result.getMedia($r('app.media.pngSample').id) - .then(data => { - let arrayBuffer = this.typedArrayToBuffer(data); - let parseImageUtil = new ParseImageUtil(); - parseImageUtil.parseImage(arrayBuffer,(pxielmap)=>{ - let pngPack = new PixelMapPack(); - pngPack.pixelMap = pxielmap; - this.pixelMapPack = pngPack; - },(err)=>{}) - }) - .catch(err => { - console.log('basicTestMediaImage - 本地加载资源err' + JSON.stringify(err)); - }) - }) - - }).margin({left:15}).backgroundColor(Color.Blue) - Button('本地资源bmp') - .onClick(()=>{ - resourceManager.getResourceManager() - .then(result => { - result.getMedia($r('app.media.bmpSample').id) - .then(data => { - let arrayBuffer = this.typedArrayToBuffer(data); - let parseImageUtil = new ParseImageUtil(); - parseImageUtil.parseImage(arrayBuffer,(pxielmap)=>{ - let bmpPack = new PixelMapPack(); - bmpPack.pixelMap = pxielmap; - this.pixelMapPack = bmpPack; - },(err)=>{}) - }) - .catch(err => { - console.log('basicTestMediaImage - 本地加载资源err' + JSON.stringify(err)); - }) - }) - - }).margin({left:15}).backgroundColor(Color.Blue) - Button('本地资源webp') - .onClick(()=>{ - resourceManager.getResourceManager() - .then(result => { - result.getMedia($r('app.media.jpgSample').id) - .then(data => { - let arrayBuffer = this.typedArrayToBuffer(data); - let parseImageUtil = new ParseImageUtil(); - parseImageUtil.parseImage(arrayBuffer,(pxielmap)=>{ - let webpPack = new PixelMapPack(); - webpPack.pixelMap = pxielmap; - this.pixelMapPack = webpPack; - },(err)=>{}) - }) - .catch(err => { - console.log('basicTestMediaImage - 本地加载资源err' + JSON.stringify(err)); - }) - }) - - }).margin({left:15}).backgroundColor(Color.Blue) - Button('本地资源gif') - .onClick(()=>{ - resourceManager.getResourceManager() - .then(result => { - result.getMedia($r('app.media.gifSample').id) - .then(data => { - let arrayBuffer = this.typedArrayToBuffer(data); - let parseImageUtil = new ParseImageUtil(); - parseImageUtil.parseImage(arrayBuffer,(pxielmap)=>{ - let gifPack = new PixelMapPack(); - gifPack.pixelMap = pxielmap; - this.pixelMapPack = gifPack; - },(err)=>{}) - }) - .catch(err => { - console.log('basicTestMediaImage - 本地加载资源err' + JSON.stringify(err)); - }) - }) - - }).margin({left:15}).backgroundColor(Color.Blue) - } - .margin({top:15}) - Image(this.pixelMapPack.pixelMap) - .width(300) - .height(300) - .backgroundColor(Color.Pink) - } - } - .width('100%') - .height('100%') - } - - typedArrayToBuffer(array: Uint8Array): ArrayBuffer { - return array.buffer.slice(array.byteOffset, array.byteLength + array.byteOffset) - } -} diff --git a/entry/src/main/ets/MainAbility/pages/basicTestFeatureAbilityPage.ets b/entry/src/main/ets/pages/basicTestFeatureAbilityPage.ets similarity index 63% rename from entry/src/main/ets/MainAbility/pages/basicTestFeatureAbilityPage.ets rename to entry/src/main/ets/pages/basicTestFeatureAbilityPage.ets index 3caf286..22d1e5e 100644 --- a/entry/src/main/ets/MainAbility/pages/basicTestFeatureAbilityPage.ets +++ b/entry/src/main/ets/pages/basicTestFeatureAbilityPage.ets @@ -12,12 +12,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import featureAbility from '@ohos.ability.featureAbility'; + @Entry @Component struct BasicTestFeatureAbilityPage { - @Watch("watchPathChange") @State filePath:string= "查看featureAbility路径"; + @Watch("watchPathChange") @State filePath: string = "查看featureAbility路径"; watchPathChange() { console.log("watchPathChange"); @@ -28,30 +28,19 @@ struct BasicTestFeatureAbilityPage { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Text(this.filePath).fontSize(20) Button("featureAbility.getContext().getFilesDir()") - .margin({top:20}) - .onClick(()=>{ - featureAbility.getContext() - .getFilesDir() - .then((data) => { + .margin({ top: 20 }) + .onClick(() => { + let data = globalThis.ImageKnife.getImageKnifeContext().filesDir; console.log("ImageKnife filesPath = " + data) this.filePath = data }) - .catch((error) => { - console.error('ImageKnife Failed to obtain the filesPath directory. Cause:' + error.message); - }) - }) Button("featureAbility.getContext().getCacheDir()") - .margin({top:20}) - .onClick(()=>{ - featureAbility.getContext().getCacheDir() - .then((data) => { + .margin({ top: 20 }) + .onClick(() => { + let data = globalThis.ImageKnife.getImageKnifeContext().cacheDir; console.log("ImageKnife cachesPath = " + data) this.filePath = data }) - .catch((error) => { - console.error('ImageKnife Failed to obtain the cachesPath directory. Cause:' + error.message); - }) - }) } } .width('100%') diff --git a/entry/src/main/ets/MainAbility/pages/basicTestFileIOPage.ets b/entry/src/main/ets/pages/basicTestFileIOPage.ets similarity index 62% rename from entry/src/main/ets/MainAbility/pages/basicTestFileIOPage.ets rename to entry/src/main/ets/pages/basicTestFileIOPage.ets index 3e9c7e4..dd5e3b1 100644 --- a/entry/src/main/ets/MainAbility/pages/basicTestFileIOPage.ets +++ b/entry/src/main/ets/pages/basicTestFileIOPage.ets @@ -12,14 +12,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import featureAbility from '@ohos.ability.featureAbility'; + import { FileUtils } from '@ohos/imageknife' import resourceManager from '@ohos.resourceManager'; @Entry @Component -struct BasicTestFileIOPage { - @Watch('watchPathChange') @State filePath: string= '查看featureAbility路径'; +struct basicTestFileIOPage { + @State filePath: string = '查看featureAbility路径'; appFilePath = ''; appCachePath = ''; @State imageFile: string = '' @@ -39,34 +39,27 @@ struct BasicTestFileIOPage { Button('featureAbility.getContext().getFilesDir()') .margin({ top: 10 }) .onClick(() => { - featureAbility.getContext() - .getFilesDir() - .then((data) => { - console.log('ImageKnife filesPath = ' + data) - this.filePath = data - this.appFilePath = data; - }) - .catch((error) => { - console.error('ImageKnife Failed to obtain the filesPath directory. Cause:' + error.message); - }) + + let data = globalThis.ImageKnife.getImageKnifeContext().filesDir; + console.log('ImageKnife filesPath = ' + data) + this.filePath = data + this.appFilePath = data; + }) Button('featureAbility.getContext().getCacheDir()') .margin({ top: 10 }) .onClick(() => { - featureAbility.getContext() - .getCacheDir() - .then((data) => { - console.log('ImageKnife cachesPath = ' + data) - this.filePath = data - this.appCachePath = data - }) - .catch((error) => { - console.error('ImageKnife Failed to obtain the cachesPath directory. Cause:' + error.message); - }) + + let data = globalThis.ImageKnife.getImageKnifeContext().cacheDir; + console.log('ImageKnife cachesPath = ' + data) + this.filePath = data + this.appFilePath = data; + }) Button('files目录创建Folder1和Folder2 验证statSync mkdirSync') .margin({ top: 10 }) .onClick(() => { + console.log('files目录创建Folder1和Folder2 验证statSync mkdirSync') FileUtils.getInstance() .createFolder(this.appFilePath + '/Folder1'); FileUtils.getInstance() @@ -75,59 +68,64 @@ struct BasicTestFileIOPage { Button('将media资源存入Folder1 验证writeSync mkdirSync createStreamSync') .margin({ top: 10 }) .onClick(() => { - resourceManager.getResourceManager() - .then(result => { - result.getMedia($r('app.media.gifSample').id,) - .then(data => { - console.log('basicTestFileIOPage - 本地加载资源 解析后数据data = ' + data) - let arrayBuffer = this.typedArrayToBuffer(data); - FileUtils.getInstance().writeFile(this.appFilePath + '/Folder1/jpgSample.gif', arrayBuffer) - this.imageFile = 'file://' + this.appFilePath + '/Folder1/jpgSample.gif' - }) - .catch(err => { - console.log('basicTestFileIOPage - 本地加载资源err' + JSON.stringify(err)); - }) + console.log('将media资源存入Folder1 验证writeSync mkdirSync createStreamSync') + globalThis.ImageKnife.getImageKnifeContext().resourceManager + .getMedia($r('app.media.gifSample').id) + .then(data => { + console.log('result.getMedia') + console.log('basicTestFileIOPage - 本地加载资源 解析后数据data length= ' + data.byteLength) + let arrayBuffer = this.typedArrayToBuffer(data); + FileUtils.getInstance().writeFile(this.appFilePath + '/Folder1/jpgSample.gif', arrayBuffer) + this.imageFile = 'file://' + this.appFilePath + '/Folder1/jpgSample.gif' + console.log('Folder1 imaeFile =' + this.imageFile) + }) + .catch(err => { + console.log('basicTestFileIOPage - 本地加载资源err' + JSON.stringify(err)); }) }) Button('copy:Folder1至Folder2, 验证copyFileSync') .margin({ top: 10 }) .onClick(() => { + console.log('copy:Folder1至Folder2, 验证copyFileSync') let filePath1 = this.appFilePath + '/Folder1/jpgSample.gif'; let filePath2 = this.appFilePath + '/Folder2/jpgSample.gif'; + FileUtils.getInstance().createFolder(this.appFilePath + '/Folder1') FileUtils.getInstance().createFolder(this.appFilePath + '/Folder2') FileUtils.getInstance().copyFile(filePath1, filePath2); this.imageFile = 'file://' + this.appFilePath + '/Folder2/jpgSample.gif' + console.log('Folder2 imaeFile =' + this.imageFile) }) Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Button('显示空PixelMap') .margin({ left: 10 }) .onClick(() => { - this.normalPixelMap=true; + this.normalPixelMap = true; this.normalResource = false; }) Button('显示RES') .margin({ left: 10 }) .onClick(() => { - this.normalPixelMap=false; + this.normalPixelMap = false; this.normalResource = true; }) Button('显示String') .margin({ left: 10 }) .onClick(() => { - this.normalPixelMap=false; + this.normalPixelMap = false; this.normalResource = false; }) } - Image(this.normalPixelMap?this.imagePixelMap:(this.normalResource? this.imageRes:this.imageFile)) + Image(this.normalPixelMap ? this.imagePixelMap : (this.normalResource ? this.imageRes : this.imageFile)) .width(200) .height(200) .backgroundColor(Color.Pink) } + .width('100%') + .height('100%') } - .width('100%') - .height('100%') + } typedArrayToBuffer(array: Uint8Array): ArrayBuffer { diff --git a/entry/src/main/ets/pages/basicTestMediaImage.ets b/entry/src/main/ets/pages/basicTestMediaImage.ets new file mode 100644 index 0000000..176e0ef --- /dev/null +++ b/entry/src/main/ets/pages/basicTestMediaImage.ets @@ -0,0 +1,133 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import featureAbility from '@ohos.ability.featureAbility'; +import { FileUtils } from '@ohos/imageknife' +import { FileTypeUtil } from '@ohos/imageknife' +import resourceManager from '@ohos.resourceManager'; +import { Base64 } from '@ohos/imageknife' +import { PixelMapPack } from '@ohos/imageknife' +import { ParseImageUtil } from '@ohos/imageknife' + +@Entry +@Component +struct BasicTestMediaImage { + @State pixelMapPack: PixelMapPack = new PixelMapPack(); + + build() { + Scroll() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Flex({ direction: FlexDirection.Row }) { + Button('本地资源jpg') + .onClick(() => { + globalThis.ImageKnife.getImageKnifeContext().resourceManager.getMedia($r('app.media.jpgSample').id) + .then(data => { + let arrayBuffer = this.typedArrayToBuffer(data); + let parseImageUtil = new ParseImageUtil(); + parseImageUtil.parseImage(arrayBuffer, (pxielmap) => { + let jpgPack = new PixelMapPack(); + jpgPack.pixelMap = pxielmap; + this.pixelMapPack = jpgPack; + }, (err) => { + }) + }) + .catch(err => { + console.log('basicTestMediaImage - 本地加载资源err' + JSON.stringify(err)); + }) + }).margin({ left: 15 }).backgroundColor(Color.Blue) + Button('本地资源png') + .onClick(() => { + globalThis.ImageKnife.getImageKnifeContext().resourceManager.getMedia($r('app.media.pngSample').id) + .then(data => { + let arrayBuffer = this.typedArrayToBuffer(data); + let parseImageUtil = new ParseImageUtil(); + parseImageUtil.parseImage(arrayBuffer, (pxielmap) => { + let pngPack = new PixelMapPack(); + pngPack.pixelMap = pxielmap; + this.pixelMapPack = pngPack; + }, (err) => { + }) + }) + .catch(err => { + console.log('basicTestMediaImage - 本地加载资源err' + JSON.stringify(err)); + }) + }).margin({ left: 15 }).backgroundColor(Color.Blue) + Button('本地资源bmp') + .onClick(() => { + globalThis.ImageKnife.getImageKnifeContext().resourceManager.getMedia($r('app.media.bmpSample').id) + .then(data => { + let arrayBuffer = this.typedArrayToBuffer(data); + let parseImageUtil = new ParseImageUtil(); + parseImageUtil.parseImage(arrayBuffer, (pxielmap) => { + let bmpPack = new PixelMapPack(); + bmpPack.pixelMap = pxielmap; + this.pixelMapPack = bmpPack; + }, (err) => { + }) + }) + .catch(err => { + console.log('basicTestMediaImage - 本地加载资源err' + JSON.stringify(err)); + }) + }).margin({ left: 15 }).backgroundColor(Color.Blue) + Button('本地资源webp') + .onClick(() => { + globalThis.ImageKnife.getImageKnifeContext().resourceManager.getMedia($r('app.media.jpgSample').id) + .then(data => { + let arrayBuffer = this.typedArrayToBuffer(data); + let parseImageUtil = new ParseImageUtil(); + parseImageUtil.parseImage(arrayBuffer, (pxielmap) => { + let webpPack = new PixelMapPack(); + webpPack.pixelMap = pxielmap; + this.pixelMapPack = webpPack; + }, (err) => { + }) + }) + .catch(err => { + console.log('basicTestMediaImage - 本地加载资源err' + JSON.stringify(err)); + }) + }).margin({ left: 15 }).backgroundColor(Color.Blue) + Button('本地资源gif') + .onClick(() => { + globalThis.ImageKnife.getImageKnifeContext().resourceManager.getMedia($r('app.media.gifSample').id) + .then(data => { + let arrayBuffer = this.typedArrayToBuffer(data); + let parseImageUtil = new ParseImageUtil(); + parseImageUtil.parseImage(arrayBuffer, (pxielmap) => { + let gifPack = new PixelMapPack(); + gifPack.pixelMap = pxielmap; + this.pixelMapPack = gifPack; + }, (err) => { + }) + }) + .catch(err => { + console.log('basicTestMediaImage - 本地加载资源err' + JSON.stringify(err)); + }) + }).margin({ left: 15 }).backgroundColor(Color.Blue) + } + .margin({ top: 15 }) + + Image(this.pixelMapPack.pixelMap) + .width(300) + .height(300) + .backgroundColor(Color.Pink) + } + } + .width('100%') + .height('100%') + } + + typedArrayToBuffer(array: Uint8Array): ArrayBuffer { + return array.buffer.slice(array.byteOffset, array.byteLength + array.byteOffset) + } +} diff --git a/entry/src/main/ets/MainAbility/pages/basicTestResourceManagerPage.ets b/entry/src/main/ets/pages/basicTestResourceManagerPage.ets similarity index 86% rename from entry/src/main/ets/MainAbility/pages/basicTestResourceManagerPage.ets rename to entry/src/main/ets/pages/basicTestResourceManagerPage.ets index 3670561..ce86ac9 100644 --- a/entry/src/main/ets/MainAbility/pages/basicTestResourceManagerPage.ets +++ b/entry/src/main/ets/pages/basicTestResourceManagerPage.ets @@ -31,10 +31,8 @@ struct BasicTestResourceManagerPage { Button('getMedia解析一张jpg图片') .margin({ top: 10 }) .onClick(() => { - resourceManager.getResourceManager() - .then(result => { - result.getMedia($r('app.media.jpgSample') - .id,) + globalThis.ImageKnife.getImageKnifeContext().resourceManager.getMedia($r('app.media.jpgSample') + .id,) .then(data => { console.log('basicTestFileIOPage - 本地加载资源 解析后数据data = ' + data) let arrayBuffer = this.typedArrayToBuffer(data); @@ -45,17 +43,14 @@ struct BasicTestResourceManagerPage { .catch(err => { console.log('basicTestFileIOPage - 本地加载资源err' + JSON.stringify(err)); }) - }) }) Button('getMediaBase64解析一张png图片') .margin({ top: 10 }) .onClick(() => { - resourceManager.getResourceManager() - .then(result => { - result.getMediaBase64($r('app.media.pngSample') - .id) + globalThis.ImageKnife.getImageKnifeContext().resourceManager.getMediaBase64($r('app.media.pngSample') + .id) .then(data => { - console.log('ParseResClientBase64 - 本地加载资源 解析后数据data = ' + data) + console.log('ParseResClientBase64 - 本地加载资源 解析后数据data') let matchReg = ';base64,'; var firstIndex = data.indexOf(matchReg); data = data.substring(firstIndex + matchReg.length, data.length) @@ -69,7 +64,6 @@ struct BasicTestResourceManagerPage { .catch(err => { console.log('basicTestFileIOPage - 本地加载资源err' + JSON.stringify(err)); }) - }) }) } diff --git a/entry/src/main/ets/MainAbility/pages/compressPage.ets b/entry/src/main/ets/pages/compressPage.ets similarity index 98% rename from entry/src/main/ets/MainAbility/pages/compressPage.ets rename to entry/src/main/ets/pages/compressPage.ets index 9f32a0c..dc00e72 100644 --- a/entry/src/main/ets/MainAbility/pages/compressPage.ets +++ b/entry/src/main/ets/pages/compressPage.ets @@ -97,7 +97,7 @@ struct CompressPage { data.push($r('app.media.jpgSample')) console.info("asasd start compress") - ImageKnife.with() + globalThis.ImageKnife .compressBuilder() .load(data) .ignoreBy(100) @@ -137,7 +137,8 @@ struct CompressPage { } } console.info("asasd start compress") - ImageKnife.with() + + globalThis.ImageKnife .compressBuilder() .load(data) .ignoreBy(100) diff --git a/entry/src/main/ets/MainAbility/pages/cropImagePage.ets b/entry/src/main/ets/pages/cropImagePage.ets similarity index 100% rename from entry/src/main/ets/MainAbility/pages/cropImagePage.ets rename to entry/src/main/ets/pages/cropImagePage.ets diff --git a/entry/src/main/ets/pages/cropImagePage2.ets b/entry/src/main/ets/pages/cropImagePage2.ets new file mode 100644 index 0000000..2359aed --- /dev/null +++ b/entry/src/main/ets/pages/cropImagePage2.ets @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { CropImage } from '@ohos/imageknife' +import { CropOptions } from '@ohos/imageknife' +import { Crop } from '@ohos/imageknife' +import { RecourseProvider } from '@ohos/imageknife' +import { PixelMapPack } from '@ohos/imageknife' +import { PixelMapCrop } from '@ohos/imageknife' +import { CropCallback } from '@ohos/imageknife' +import { FileUtils } from '@ohos/imageknife' + + +@Component +@Entry +export struct CropImagePage2 { + @State options1: PixelMapCrop.Options = new PixelMapCrop.Options(); + @State cropTap: boolean = false; + @State pack: PixelMapPack = new PixelMapPack(); + @State width: number = 0; + @State height: number = 0; + @State _rotate: number = 0; + @State _scale: number = 1; + private _resource: Resource = $r('app.media.bmpNet'); + + build() { + Column() { + + Button('点击解析图片') + .onClick(() => { + globalThis.ImageKnife.getImageKnifeContext().resourceManager.getMedia($r('app.media.bmpNet').id) + .then(data => { + let arrayBuffer = FileUtils.getInstance().uint8ArrayToBuffer(data); + let optionx = new PixelMapCrop.Options(); + optionx.setWidth(600) + .setHeight(400) + .setCropFunction((err, pixelmap, sx, sy) => { + console.log('PMC setCropFunction callback') + if (err) { + console.error('PMC crop err =' + err) + } else { + let pack1 = new PixelMapPack(); + pack1.pixelMap = pixelmap; + this.pack = pack1; + this.width = sx * px2vp(1); + this.height = sy * px2vp(1); + } + + + }) + optionx.loadBuffer(arrayBuffer, () => { + this.options1 = optionx; + }) + }) + + + }) + + PixelMapCrop({ options: this.options1, cropTap: this.cropTap }) + + Button('点击裁剪图片') + .onClick(() => { + this.cropTap = !this.cropTap; + }) + + + Image(this.pack.pixelMap) + .width(this.width) + .height(this.height) + .objectFit(ImageFit.Contain) + .rotate({ + z: 1, + centerX: this.width / 2, + centerY: this.height / 2, + angle: this._rotate + }) + .scale({ x: this._scale, y: this._scale, z: 1.0 }) + .gesture(GestureGroup(GestureMode.Parallel, + RotationGesture({ fingers: 2 }).onActionUpdate(event => { + this._rotate = event.angle; + }), PinchGesture({ fingers: 2 }).onActionUpdate(event => { + this._scale = event.scale; + }))) + + + } + .backgroundColor(Color.Brown) + .width('100%') + .height('100%') + + } +} \ No newline at end of file diff --git a/entry/src/main/ets/MainAbility/pages/frescoImageTestCasePage.ets b/entry/src/main/ets/pages/frescoImageTestCasePage.ets similarity index 99% rename from entry/src/main/ets/MainAbility/pages/frescoImageTestCasePage.ets rename to entry/src/main/ets/pages/frescoImageTestCasePage.ets index ed85957..444fc91 100644 --- a/entry/src/main/ets/MainAbility/pages/frescoImageTestCasePage.ets +++ b/entry/src/main/ets/pages/frescoImageTestCasePage.ets @@ -22,8 +22,6 @@ import {RoundedCornersTransformation} from '@ohos/imageknife' struct FrescoImageTestCasePage { @State progresshint:string = "输出加载百分比回调信息" - - @State imageKnifeOption1: ImageKnifeOption = { loadSrc: "https://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83ericA1Mv66TwicuYOtbDMBcUhv1aa9RJBeAn9uURfcZD0AUGrJebAn1g2AjN0vb2E1XTET7fTuLBNmA/132", diff --git a/entry/src/main/ets/MainAbility/pages/frescoLayerTestCasePage.ets b/entry/src/main/ets/pages/frescoLayerTestCasePage.ets similarity index 100% rename from entry/src/main/ets/MainAbility/pages/frescoLayerTestCasePage.ets rename to entry/src/main/ets/pages/frescoLayerTestCasePage.ets diff --git a/entry/src/main/ets/MainAbility/pages/frescoRetryTestCasePage.ets b/entry/src/main/ets/pages/frescoRetryTestCasePage.ets similarity index 100% rename from entry/src/main/ets/MainAbility/pages/frescoRetryTestCasePage.ets rename to entry/src/main/ets/pages/frescoRetryTestCasePage.ets diff --git a/entry/src/main/ets/MainAbility/pages/index.ets b/entry/src/main/ets/pages/index.ets similarity index 89% rename from entry/src/main/ets/MainAbility/pages/index.ets rename to entry/src/main/ets/pages/index.ets index e966fb1..13825ca 100644 --- a/entry/src/main/ets/MainAbility/pages/index.ets +++ b/entry/src/main/ets/pages/index.ets @@ -1,5 +1,5 @@ /* - * Copyright (C) 1521 Huawei Device Co., Ltd. + * Copyright (C) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,13 +13,14 @@ * limitations under the License. */ import router from '@system.router'; -import {Pngj} from '@ohos/imageknife' + @Entry @Component -struct Index { - @State hint1:string = '启用网络模拟加载替换网络加载' +struct IndexFunctionDemo { + @State hint1: string = '启用网络模拟加载替换网络加载' + build() { Scroll() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { @@ -148,12 +149,20 @@ struct Index { console.log("pages/pngjTestCasePage 页面跳转") router.push({ uri: "pages/pngjTestCasePage" }); }).margin({ top: 15 }) - Button("测试图片的裁剪") - .onClick(() => { - console.log("pages/cropImagePage 页面跳转") - router.push({ uri: "pages/cropImagePage" }); - }).margin({ top: 15 }) + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Button("测试图片的裁剪") + .onClick(() => { + console.log("pages/cropImagePage 页面跳转") + router.push({ uri: "pages/cropImagePage" }); + }).margin({ top: 15 }) + Button("测试图片的裁剪2") + .onClick(() => { + console.log("pages/cropImagePage2 页面跳转") + router.push({ uri: "pages/cropImagePage2" }); + }).margin({ top: 15 }) + }.width('100%') + .height(60).backgroundColor(Color.Pink) } } .width('100%') @@ -164,12 +173,6 @@ struct Index { } onBackPress() { - let cache = ImageKnife.getMemoryCache(); - cache.print() + } -} -var ImageKnife; -var defaultTemp = globalThis.exports.default -if (defaultTemp != undefined) { - ImageKnife = defaultTemp.data.imageKnife; } \ No newline at end of file diff --git a/entry/src/main/ets/MainAbility/pages/indexFresco.ets b/entry/src/main/ets/pages/indexFresco.ets similarity index 79% rename from entry/src/main/ets/MainAbility/pages/indexFresco.ets rename to entry/src/main/ets/pages/indexFresco.ets index b130c16..61a345d 100644 --- a/entry/src/main/ets/MainAbility/pages/indexFresco.ets +++ b/entry/src/main/ets/pages/indexFresco.ets @@ -22,27 +22,19 @@ struct IndexFresco { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Button("测试控件隐藏与展示和动画") .onClick(() => { - router.push({ uri: "pages/frescoLayerTestCasePage" }); - }).margin({ top: 15 }) + router.push({ uri: "pages/frescoLayerTestCasePage" }); + }).margin({ top: 15 }) Button("测试自定义控件FrescoImage的加载百分比") .onClick(() => { - router.push({ uri: "pages/frescoImageTestCasePage" }); - }).margin({ top: 15 }) + router.push({ uri: "pages/frescoImageTestCasePage" }); + }).margin({ top: 15 }) Button("测试自定义控件FrescoImage重试Retry") .onClick(() => { - router.push({ uri: "pages/frescoRetryTestCasePage" }); - }).margin({ top: 15 }) - - - + router.push({ uri: "pages/frescoRetryTestCasePage" }); + }).margin({ top: 15 }) } } .width('100%') .height('100%') } - - - - -} - +} \ No newline at end of file diff --git a/entry/src/main/ets/MainAbility/pages/loadNetworkTestCasePage.ets b/entry/src/main/ets/pages/loadNetworkTestCasePage.ets similarity index 100% rename from entry/src/main/ets/MainAbility/pages/loadNetworkTestCasePage.ets rename to entry/src/main/ets/pages/loadNetworkTestCasePage.ets diff --git a/entry/src/main/ets/MainAbility/pages/loadResourceTestCasePage.ets b/entry/src/main/ets/pages/loadResourceTestCasePage.ets similarity index 100% rename from entry/src/main/ets/MainAbility/pages/loadResourceTestCasePage.ets rename to entry/src/main/ets/pages/loadResourceTestCasePage.ets diff --git a/entry/src/main/ets/MainAbility/pages/pngjTestCasePage.ets b/entry/src/main/ets/pages/pngjTestCasePage.ets similarity index 84% rename from entry/src/main/ets/MainAbility/pages/pngjTestCasePage.ets rename to entry/src/main/ets/pages/pngjTestCasePage.ets index 4fa289e..3114fff 100644 --- a/entry/src/main/ets/MainAbility/pages/pngjTestCasePage.ets +++ b/entry/src/main/ets/pages/pngjTestCasePage.ets @@ -13,20 +13,23 @@ * limitations under the License. */ import router from '@system.router'; -import {Pngj} from '@ohos/imageknife' +import { Pngj } from '@ohos/imageknife' import resourceManager from '@ohos.resourceManager'; -import {FileUtils} from '@ohos/imageknife' +import { FileUtils } from '@ohos/imageknife' import featureability from '@ohos.ability.featureAbility' import ArkWorker from '@ohos.worker' + @Entry @Component struct PngjTestCasePage { - pngSource: ArrayBuffer = new ArrayBuffer(0); + pngSource: ArrayBuffer = new ArrayBuffer(0); rootFolder: string = ''; @State hint1: string = 'readPngImageInfo内容展示' @State hint2: string = 'readPngImage内容展示' @State hint3: string = 'writePngWithString内容展示' @State hint4: string = 'writePngWithString内容展示' + @State hint5: string = '测试readMetadata' + @State hint6: string = '测试writeMetadata' build() { Scroll() { @@ -36,25 +39,15 @@ struct PngjTestCasePage { Button('点击获取Png图片buffer').fontSize(20) .onClick(() => { - featureability.getContext() - .getFilesDir() - .then((data) => { - this.rootFolder = data; - }) - .catch((err) => { - console.log('点击获取Png图片buffer 路径获取失败 err:' + err) - }) + this.rootFolder = globalThis.ImageKnife.getImageKnifeContext().filesDir; - resourceManager.getResourceManager() - .then(result => { - result.getMedia($r('app.media.Tomato').id) - .then(data => { - this.pngSource = FileUtils.getInstance().uint8ArrayToBuffer(data); - }) - .catch(err => { - console.log('点击获取Png图片buffer err=' + err) - }) + globalThis.ImageKnife.getImageKnifeContext().resourceManager.getMedia($r('app.media.Tomato').id) + .then(data => { + this.pngSource = FileUtils.getInstance().uint8ArrayToBuffer(data); + }) + .catch(err => { + console.log('点击获取Png图片buffer err=' + err) }) }) @@ -103,6 +96,7 @@ struct PngjTestCasePage { }).margin({ top: 5, left: 10 }) }.width('100%') .height(60).backgroundColor(Color.Pink) + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Button('测试readPngImageInfo') .onClick(() => { @@ -114,7 +108,10 @@ struct PngjTestCasePage { Button('测试readPngImageAsync') .onClick(() => { let pngj = new Pngj(); - let worker = new ArkWorker.Worker('workers/worker1.js', { type: 'classic', name: 'readPngImageAsync'}) + let worker = new ArkWorker.Worker('entry/ets/pages/workers/worker1.js', { + type: 'classic', + name: 'readPngImageAsync' + }) pngj.readPngImageAsync(worker, this.pngSource, (sender, value) => { this.pngSource = sender this.hint2 = 'img with=' + value.width + ' img height=' + value.height @@ -124,7 +121,10 @@ struct PngjTestCasePage { Button('测试writePngWithStringAsync') .onClick(() => { let pngj = new Pngj(); - let worker = new ArkWorker.Worker('workers/worker1.js', { type: 'classic', name: 'writePngWithStringAsync'}) + let worker = new ArkWorker.Worker('entry/ets/pages/workers/worker1.js', { + type: 'classic', + name: 'writePngWithStringAsync' + }) pngj.writePngWithStringAsync(worker, 'hello world', this.pngSource, (sender, value) => { this.pngSource = sender FileUtils.getInstance().createFileProcess( @@ -138,7 +138,10 @@ struct PngjTestCasePage { Button('测试writePngAsync') .onClick(() => { let pngj = new Pngj(); - let worker = new ArkWorker.Worker('workers/worker1.js', { type: 'classic', name: 'writePngAsync'}) + let worker = new ArkWorker.Worker('entry/ets/pages/workers/worker1.js', { + type: 'classic', + name: 'writePngAsync' + }) pngj.writePngAsync(worker, this.pngSource, (sender, value) => { this.pngSource = sender FileUtils.getInstance().createFileProcess( @@ -165,9 +168,9 @@ struct PngjTestCasePage { .width('100%') .height(120) } + .width('100%') + .height('100%') } - .width('100%') - .height('100%') } typedArrayToBuffer(array: Uint8Array): ArrayBuffer { diff --git a/entry/src/main/ets/MainAbility/pages/showErrorholderTestCasePage.ets b/entry/src/main/ets/pages/showErrorholderTestCasePage.ets similarity index 100% rename from entry/src/main/ets/MainAbility/pages/showErrorholderTestCasePage.ets rename to entry/src/main/ets/pages/showErrorholderTestCasePage.ets diff --git a/entry/src/main/ets/MainAbility/pages/storageTestDiskLruCache.ets b/entry/src/main/ets/pages/storageTestDiskLruCache.ets similarity index 93% rename from entry/src/main/ets/MainAbility/pages/storageTestDiskLruCache.ets rename to entry/src/main/ets/pages/storageTestDiskLruCache.ets index 3719cef..c4b274d 100644 --- a/entry/src/main/ets/MainAbility/pages/storageTestDiskLruCache.ets +++ b/entry/src/main/ets/pages/storageTestDiskLruCache.ets @@ -53,12 +53,12 @@ struct StorageTestDiskLruCache { .backgroundColor(Color.Blue) Button("替换ImageKnife默认DiskLruCache并设置大小1M") .onClick(() => { - DiskImageKnife.replaceDiskLruCache(1 * 1024 * 1024) + globalThis.ImageKnife.replaceDiskLruCache(1 * 1024 * 1024) }).margin({top:15, bottom:15}) Button("替换ImageKnife默认DiskLruCache并设置大小30M") .onClick(() => { - DiskImageKnife.replaceDiskLruCache(30 * 1024 * 1024) + globalThis.ImageKnife.replaceDiskLruCache(30 * 1024 * 1024) }).margin({top:15, bottom:15}) Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { @@ -170,19 +170,24 @@ struct StorageTestDiskLruCache { request.addAllCacheInfoCallback(this.imageKnifeOption.allCacheInfoCallback) } - DiskImageKnife.call(request); + globalThis.ImageKnife.call(request); } imageKnifeChangeSource(data:ImageKnifeData) { this.imageKnifeSpecialFixed(data); - //查看mImageKnife中的DiskLruCache - let disk = DiskImageKnife.getDiskMemoryCache(); - let showDisk = '' - disk.foreachDiskLruCache((value, key, map) => { - showDisk += "key=" + key + "&value=" + value; - }) - this.logText = "日志结果:" + showDisk; + + // 由于异步写入,可能读取disklrucache的时候还没删成功,为了保证成功删除这里使用了延时 + setTimeout(() => { + //查看mImageKnife中的DiskLruCache + let disk = globalThis.ImageKnife.getDiskMemoryCache(); + let showDisk = '' + disk.foreachDiskLruCache((value, key, map) => { + showDisk += "key=" + key + "&value=" + value; + }) + this.logText = "日志结果:" + showDisk; + }, 2000) + } imageKnifeSpecialFixed(data:ImageKnifeData) { @@ -226,7 +231,7 @@ struct StorageTestDiskLruCache { console.log("ImageKnife占位图输出=String 拥有上一个图片类型 上一个是SVG") this.normalPixelMap = false; this.normalResource = false; - let firstIndex = (data.imageKnifeValue as string).indexOf(DiskImageKnife.getSvgAndGifFolder()); + let firstIndex = (data.imageKnifeValue as string).indexOf(globalThis.ImageKnife.getSvgAndGifFolder()); console.log("firstIndex=" + firstIndex); let suffix = (data.imageKnifeValue as string).substring(firstIndex, (data.imageKnifeValue as string).length) console.log("suffix =" + suffix); @@ -238,7 +243,7 @@ struct StorageTestDiskLruCache { this.normalPixelMap = false; this.normalResource = false; - let firstIndex = (data.imageKnifeValue as string).indexOf(DiskImageKnife.getSvgAndGifFolder()); + let firstIndex = (data.imageKnifeValue as string).indexOf(globalThis.ImageKnife.getSvgAndGifFolder()); console.log("firstIndex=" + firstIndex); let suffix = (data.imageKnifeValue as string).substring(firstIndex, (data.imageKnifeValue as string).length) console.log("suffix =" + suffix); @@ -280,7 +285,7 @@ struct StorageTestDiskLruCache { console.log("ImageKnife占位图输出=String 没有上一个图片类型") this.normalPixelMap = false; this.normalResource = false; - let firstIndex = (data.imageKnifeValue as string).indexOf(DiskImageKnife.getSvgAndGifFolder()); + let firstIndex = (data.imageKnifeValue as string).indexOf(globalThis.ImageKnife.getSvgAndGifFolder()); console.log("firstIndex=" + firstIndex); let suffix = (data.imageKnifeValue as string).substring(firstIndex, (data.imageKnifeValue as string).length) console.log("suffix =" + suffix); @@ -318,4 +323,3 @@ struct StorageTestDiskLruCache { } } -var DiskImageKnife = globalThis.exports.default.data.imageKnife \ No newline at end of file diff --git a/entry/src/main/ets/MainAbility/pages/storageTestLruCache.ets b/entry/src/main/ets/pages/storageTestLruCache.ets similarity index 96% rename from entry/src/main/ets/MainAbility/pages/storageTestLruCache.ets rename to entry/src/main/ets/pages/storageTestLruCache.ets index 8837ad5..5f37d73 100644 --- a/entry/src/main/ets/MainAbility/pages/storageTestLruCache.ets +++ b/entry/src/main/ets/pages/storageTestLruCache.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import featureAbility from '@ohos.ability.featureAbility'; + import {LruCache} from '@ohos/imageknife' function getRandomInt(min, max) { diff --git a/entry/src/main/ets/MainAbility/pages/testAllCacheInfoPage.ets b/entry/src/main/ets/pages/testAllCacheInfoPage.ets similarity index 99% rename from entry/src/main/ets/MainAbility/pages/testAllCacheInfoPage.ets rename to entry/src/main/ets/pages/testAllCacheInfoPage.ets index b474d96..70a6c4b 100644 --- a/entry/src/main/ets/MainAbility/pages/testAllCacheInfoPage.ets +++ b/entry/src/main/ets/pages/testAllCacheInfoPage.ets @@ -207,4 +207,4 @@ struct TestAllCacheInfoPage { } -var ImageKnife = globalThis.exports.default.data.imageKnife \ No newline at end of file +var ImageKnife = globalThis.ImageKnife \ No newline at end of file diff --git a/entry/src/main/ets/MainAbility/pages/testAllTypeImageKnifeComponentPage.ets b/entry/src/main/ets/pages/testAllTypeImageKnifeComponentPage.ets similarity index 100% rename from entry/src/main/ets/MainAbility/pages/testAllTypeImageKnifeComponentPage.ets rename to entry/src/main/ets/pages/testAllTypeImageKnifeComponentPage.ets diff --git a/entry/src/main/ets/MainAbility/pages/testAllTypeNativeImagePage.ets b/entry/src/main/ets/pages/testAllTypeNativeImagePage.ets similarity index 100% rename from entry/src/main/ets/MainAbility/pages/testAllTypeNativeImagePage.ets rename to entry/src/main/ets/pages/testAllTypeNativeImagePage.ets diff --git a/entry/src/main/ets/MainAbility/pages/testGifDontAnimatePage.ets b/entry/src/main/ets/pages/testGifDontAnimatePage.ets similarity index 84% rename from entry/src/main/ets/MainAbility/pages/testGifDontAnimatePage.ets rename to entry/src/main/ets/pages/testGifDontAnimatePage.ets index a6a1c2f..2cc5593 100644 --- a/entry/src/main/ets/MainAbility/pages/testGifDontAnimatePage.ets +++ b/entry/src/main/ets/pages/testGifDontAnimatePage.ets @@ -31,17 +31,17 @@ struct TestGifDontAnimatePage { build() { Scroll() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Flex({direction:FlexDirection.Row}){ + Column() { + Flex({ direction: FlexDirection.Row }) { Button('本地资源gif') - .onClick(()=>{ - this.imageKnifeOption1 = { - loadSrc: $r('app.media.gifSample'), - size: { width: 300, height: 300 }, - placeholderSrc: $r('app.media.icon_loading'), - errorholderSrc: $r('app.media.icon_failed'), - margin:{left:15,top:15,right:15,bottom:15} - } + .onClick(() => { + this.imageKnifeOption1 = { + loadSrc: $r('app.media.gifSample'), + size: { width: 300, height: 300 }, + placeholderSrc: $r('app.media.icon_loading'), + errorholderSrc: $r('app.media.icon_failed'), + margin: { left: 15, top: 15, right: 15, bottom: 15 } + } }).margin({left:15}).backgroundColor(Color.Grey) Button('本地资源gif静态') @@ -95,5 +95,4 @@ struct TestGifDontAnimatePage { } } - -var ImageKnife = globalThis.exports.default.data.imageKnife \ No newline at end of file +var ImageKnife = globalThis.ImageKnife \ No newline at end of file diff --git a/entry/src/main/ets/MainAbility/pages/testImageKnifeOptionChangedPage.ets b/entry/src/main/ets/pages/testImageKnifeOptionChangedPage.ets similarity index 100% rename from entry/src/main/ets/MainAbility/pages/testImageKnifeOptionChangedPage.ets rename to entry/src/main/ets/pages/testImageKnifeOptionChangedPage.ets diff --git a/entry/src/main/ets/MainAbility/pages/testImageKnifeOptionChangedPage2.ets b/entry/src/main/ets/pages/testImageKnifeOptionChangedPage2.ets similarity index 98% rename from entry/src/main/ets/MainAbility/pages/testImageKnifeOptionChangedPage2.ets rename to entry/src/main/ets/pages/testImageKnifeOptionChangedPage2.ets index 7edb12a..34957ac 100644 --- a/entry/src/main/ets/MainAbility/pages/testImageKnifeOptionChangedPage2.ets +++ b/entry/src/main/ets/pages/testImageKnifeOptionChangedPage2.ets @@ -105,4 +105,3 @@ struct TestImageKnifeOptionChangedPage2 { } -var ImageKnife = globalThis.exports.default.data.imageKnife \ No newline at end of file diff --git a/entry/src/main/ets/MainAbility/pages/testMultiThreadWorkerPage2.ets b/entry/src/main/ets/pages/testMultiThreadWorkerPage2.ets similarity index 94% rename from entry/src/main/ets/MainAbility/pages/testMultiThreadWorkerPage2.ets rename to entry/src/main/ets/pages/testMultiThreadWorkerPage2.ets index c0a93c2..73b628a 100644 --- a/entry/src/main/ets/MainAbility/pages/testMultiThreadWorkerPage2.ets +++ b/entry/src/main/ets/pages/testMultiThreadWorkerPage2.ets @@ -23,7 +23,10 @@ struct TestMultiThreadWorkerPage2 { Button("创建Worker向子线程发送携带Arraybuffer数据") .margin({ top: 20 }) .onClick(() => { - let worker = new ArkWorker.Worker("workers/worker1.js", { type: "classic", name: "zhangsan" }) + let worker = new ArkWorker.Worker("entry/ets/pages/workers/worker1.js", { + type: "classic", + name: "zhangsan" + }) worker.onerror = function (data) { console.info("worker:: receive onerror " + data.lineno + ", msg = " + data.message + ", filename = " + data.filename + ", colno = " + data.colno); } diff --git a/entry/src/main/ets/MainAbility/pages/testPreloadPage.ets b/entry/src/main/ets/pages/testPreloadPage.ets similarity index 88% rename from entry/src/main/ets/MainAbility/pages/testPreloadPage.ets rename to entry/src/main/ets/pages/testPreloadPage.ets index 99e9bdc..319fcdc 100644 --- a/entry/src/main/ets/MainAbility/pages/testPreloadPage.ets +++ b/entry/src/main/ets/pages/testPreloadPage.ets @@ -15,7 +15,7 @@ import {ImageKnifeComponent} from '@ohos/imageknife' import {ImageKnifeOption} from '@ohos/imageknife' import {RequestOption} from '@ohos/imageknife' -import {RotateImageTransformation} from '@ohos/imageknife' + @Entry @Component @@ -72,18 +72,18 @@ struct TestPreloadPage { build() { Scroll() { - Flex({ direction: FlexDirection.Column }) { - Flex({ direction: FlexDirection.Column }) { + Column() { + Column() { Flex({ direction: FlexDirection.Row }) { Button('预加载本地资源gif') .onClick(() => { - let request = new RequestOption(); - request.load($r('app.media.gifSample')) - .setImageViewSize({ width: 300, height: 300 }) - .addListener((err, data) => { - if (err && err.length > 0) { - console.log('预加载本地资源gif 出现错误! err=' + err) - } else { + let request = new RequestOption(); + request.load($r('app.media.gifSample')) + .setImageViewSize({ width: 300, height: 300 }) + .addListener((err, data) => { + if (err && err.length > 0) { + console.log('预加载本地资源gif 出现错误! err=' + err) + } else { console.log('预加载本地资源gif成功! imageKnifedata=' + JSON.stringify(data)) } return false; @@ -216,17 +216,17 @@ struct TestPreloadPage { } - Flex({ direction: FlexDirection.Column }) { + Column() { Flex({ direction: FlexDirection.Row }) { Button('预加载本地资源svg') .onClick(() => { - let request = new RequestOption(); - request.load($r('app.media.svgSample')) - .setImageViewSize({ width: 300, height: 300 }) - .addListener((err, data) => { - if (err && err.length > 0) { - console.log('预加载本地资源svg 出现错误! err=' + err) - } else { + let request = new RequestOption(); + request.load($r('app.media.svgSample')) + .setImageViewSize({ width: 300, height: 300 }) + .addListener((err, data) => { + if (err && err.length > 0) { + console.log('预加载本地资源svg 出现错误! err=' + err) + } else { console.log('预加载本地资源svg成功! imageKnifedata=' + JSON.stringify(data)) } return false; @@ -296,17 +296,17 @@ struct TestPreloadPage { } - Flex({ direction: FlexDirection.Column }) { + Column() { Flex({ direction: FlexDirection.Row }) { Button('预加载本地资源webp') .onClick(() => { - let request = new RequestOption(); - request.load($r('app.media.jpgSample')) - .setImageViewSize({ width: 300, height: 300 }) - .addListener((err, data) => { - if (err && err.length > 0) { - console.log('预加载本地资源webp 出现错误! err=' + err) - } else { + let request = new RequestOption(); + request.load($r('app.media.jpgSample')) + .setImageViewSize({ width: 300, height: 300 }) + .addListener((err, data) => { + if (err && err.length > 0) { + console.log('预加载本地资源webp 出现错误! err=' + err) + } else { console.log('预加载本地资源webp成功! imageKnifedata=' + JSON.stringify(data)) } return false; @@ -374,17 +374,17 @@ struct TestPreloadPage { } - Flex({ direction: FlexDirection.Column }) { + Column() { Flex({ direction: FlexDirection.Row }) { Button('预加载本地资源bmp') .onClick(() => { - let request = new RequestOption(); - request.load($r('app.media.bmpSample')) - .setImageViewSize({ width: 300, height: 300 }) - .addListener((err, data) => { - if (err && err.length > 0) { - console.log('预加载本地资源bmp 出现错误! err=' + err) - } else { + let request = new RequestOption(); + request.load($r('app.media.bmpSample')) + .setImageViewSize({ width: 300, height: 300 }) + .addListener((err, data) => { + if (err && err.length > 0) { + console.log('预加载本地资源bmp 出现错误! err=' + err) + } else { console.log('预加载本地资源bmp成功! imageKnifedata=' + JSON.stringify(data)) } return false; @@ -452,17 +452,17 @@ struct TestPreloadPage { } - Flex({ direction: FlexDirection.Column }) { + Column() { Flex({ direction: FlexDirection.Row }) { Button('预加载本地资源png') .onClick(() => { - let request = new RequestOption(); - request.load($r('app.media.pngSample')) - .setImageViewSize({ width: 300, height: 300 }) - .addListener((err, data) => { - if (err && err.length > 0) { - console.log('预加载本地资源png 出现错误! err=' + err) - } else { + let request = new RequestOption(); + request.load($r('app.media.pngSample')) + .setImageViewSize({ width: 300, height: 300 }) + .addListener((err, data) => { + if (err && err.length > 0) { + console.log('预加载本地资源png 出现错误! err=' + err) + } else { console.log('预加载本地资源png成功! imageKnifedata=' + JSON.stringify(data)) } return false; @@ -530,17 +530,17 @@ struct TestPreloadPage { } - Flex({ direction: FlexDirection.Column }) { + Column() { Flex({ direction: FlexDirection.Row }) { Button('预加载本地资源jpg') .onClick(() => { - let request = new RequestOption(); - request.load($r('app.media.jpgSample')) - .setImageViewSize({ width: 300, height: 300 }) - .addListener((err, data) => { - if (err && err.length > 0) { - console.log('预加载本地资源jpg 出现错误! err=' + err) - } else { + let request = new RequestOption(); + request.load($r('app.media.jpgSample')) + .setImageViewSize({ width: 300, height: 300 }) + .addListener((err, data) => { + if (err && err.length > 0) { + console.log('预加载本地资源jpg 出现错误! err=' + err) + } else { console.log('预加载本地资源jpg成功! imageKnifedata=' + JSON.stringify(data)) } return false; @@ -608,9 +608,11 @@ struct TestPreloadPage { } } + } .width('100%') .height('100%') + } aboutToAppear() { @@ -619,4 +621,4 @@ struct TestPreloadPage { } -var ImageKnife = globalThis.exports.default.data.imageKnife \ No newline at end of file +var ImageKnife = globalThis.ImageKnife \ No newline at end of file diff --git a/entry/src/main/ets/MainAbility/pages/testResourceManagerPage.ets b/entry/src/main/ets/pages/testResourceManagerPage.ets similarity index 90% rename from entry/src/main/ets/MainAbility/pages/testResourceManagerPage.ets rename to entry/src/main/ets/pages/testResourceManagerPage.ets index e70cb69..7e1eef6 100644 --- a/entry/src/main/ets/MainAbility/pages/testResourceManagerPage.ets +++ b/entry/src/main/ets/pages/testResourceManagerPage.ets @@ -36,9 +36,7 @@ struct TestResourceManagerPage { .height(300) Button("点击执行ResourceManager的Base64") .onClick(()=>{ - resourceManager.getResourceManager() - .then(result => { - result.getMediaBase64($r('app.media.jpgSample').id) + globalThis.ImageKnife.getImageKnifeContext().resourceManager.getMediaBase64($r('app.media.jpgSample').id) .then(data => { console.log("jpgSample data=" + data) let matchUseLess = ";base64,"; @@ -55,15 +53,11 @@ struct TestResourceManagerPage { this.imageKnifeData = newImageKnifeData; }) - - }) }) Button("点击执行ResourceManager的非Base64") .margin({top:25}) .onClick(()=>{ - resourceManager.getResourceManager() - .then(result => { - result.getMedia($r('app.media.pngSample').id) + globalThis.ImageKnife.getImageKnifeContext().resourceManager.getMedia($r('app.media.pngSample').id) .then(data => { console.log("arrayBuffer data=" + data) let fileTypeUtil = new FileTypeUtil(); @@ -73,8 +67,6 @@ struct TestResourceManagerPage { newImageKnifeData.imageKnifeType = typeValue this.imageKnifeData = newImageKnifeData; }) - - }) }) } } diff --git a/entry/src/main/ets/MainAbility/pages/transformPixelMapPage.ets b/entry/src/main/ets/pages/transformPixelMapPage.ets similarity index 96% rename from entry/src/main/ets/MainAbility/pages/transformPixelMapPage.ets rename to entry/src/main/ets/pages/transformPixelMapPage.ets index f60ec97..f87d5e3 100644 --- a/entry/src/main/ets/MainAbility/pages/transformPixelMapPage.ets +++ b/entry/src/main/ets/pages/transformPixelMapPage.ets @@ -12,17 +12,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {RequestOption} from '@ohos/imageknife' -import {CropCircleWithBorderTransformation} from '@ohos/imageknife/src/main/ets/components/imageknife/transform/CropCircleWithBorderTransformation' -import {RotateImageTransformation} from '@ohos/imageknife' -import {CropSquareTransformation} from '@ohos/imageknife' -import {CropTransformation} from '@ohos/imageknife' -import {CropType} from '@ohos/imageknife' -import {GrayscaleTransformation} from '@ohos/imageknife' -import {BrightnessFilterTransformation} from '@ohos/imageknife' -import {ContrastFilterTransformation} from '@ohos/imageknife' -import {InvertFilterTransformation} from '@ohos/imageknife' -import {SepiaFilterTransformation} from '@ohos/imageknife' +import { RequestOption } from '@ohos/imageknife' +import { CropCircleTransformation } from '@ohos/imageknife' +import { RoundedCornersTransformation } from '@ohos/imageknife' +import { + CropCircleWithBorderTransformation +} from '@ohos/imageknife/src/main/ets/components/imageknife/transform/CropCircleWithBorderTransformation' +import { RotateImageTransformation } from '@ohos/imageknife' +import { CropSquareTransformation } from '@ohos/imageknife' +import { CropTransformation } from '@ohos/imageknife' +import { CropType } from '@ohos/imageknife' +import { GrayscaleTransformation } from '@ohos/imageknife' +import { BrightnessFilterTransformation } from '@ohos/imageknife' +import { ContrastFilterTransformation } from '@ohos/imageknife' +import { InvertFilterTransformation } from '@ohos/imageknife' +import { SepiaFilterTransformation } from '@ohos/imageknife' import {SketchFilterTransformation} from '@ohos/imageknife' import {BlurTransformation} from '@ohos/imageknife' import {PixelationFilterTransformation} from '@ohos/imageknife' @@ -874,4 +878,4 @@ struct TransformPixelMapPage { } } -var ImageKnife = globalThis.exports.default.data.imageKnife \ No newline at end of file +var ImageKnife = globalThis.ImageKnife \ No newline at end of file diff --git a/entry/src/main/ets/MainAbility/pages/transformTestCasePage.ets b/entry/src/main/ets/pages/transformTestCasePage.ets similarity index 100% rename from entry/src/main/ets/MainAbility/pages/transformTestCasePage.ets rename to entry/src/main/ets/pages/transformTestCasePage.ets diff --git a/entry/src/main/ets/MainAbility/workers/worker1.js b/entry/src/main/ets/pages/workers/worker1.js similarity index 99% rename from entry/src/main/ets/MainAbility/workers/worker1.js rename to entry/src/main/ets/pages/workers/worker1.js index 76dc412..de2649a 100644 --- a/entry/src/main/ets/MainAbility/workers/worker1.js +++ b/entry/src/main/ets/pages/workers/worker1.js @@ -13,9 +13,16 @@ * limitations under the License. */ import arkWorker from '@ohos.worker'; + import {handler} from '@ohos/imageknife/src/main/ets/components/imageknife/pngj/PngWork' arkWorker.parentPort.onmessage = handler + + + + + + diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5 new file mode 100644 index 0000000..ddb2873 --- /dev/null +++ b/entry/src/main/module.json5 @@ -0,0 +1,40 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:entry_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "requestPermissions": [{"name": "ohos.permission.INTERNET"}], + "uiSyntax": "ets", + "abilities": [ + { + "name": "MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:test_color", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json index e847707..a4cd007 100644 --- a/entry/src/main/resources/base/element/string.json +++ b/entry/src/main/resources/base/element/string.json @@ -1,5 +1,18 @@ { "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "ImageKnife" + }, + { "name": "ImageKnife_OHOS", "value": "ImageKnife_OHOS" diff --git a/entry/src/main/resources/base/profile/main_pages.json b/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000..51c0ef6 --- /dev/null +++ b/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,33 @@ +{ + "src": [ + "pages/index", + "pages/indexFresco", + "pages/frescoLayerTestCasePage", + "pages/frescoImageTestCasePage", + "pages/frescoRetryTestCasePage", + "pages/basicTestFeatureAbilityPage", + "pages/basicTestFileIOPage", + "pages/basicTestMediaImage", + "pages/basicTestResourceManagerPage", + "pages/storageTestLruCache", + "pages/storageTestDiskLruCache", + "pages/transformTestCasePage", + "pages/pngjTestCasePage", + "pages/testAllTypeImageKnifeComponentPage", + "pages/testAllTypeNativeImagePage", + "pages/loadResourceTestCasePage", + "pages/loadNetworkTestCasePage", + "pages/showErrorholderTestCasePage", + "pages/transformPixelMapPage", + "pages/testGifDontAnimatePage", + "pages/testPreloadPage", + "pages/testImageKnifeOptionChangedPage", + "pages/testImageKnifeOptionChangedPage2", + "pages/compressPage", + "pages/testAllCacheInfoPage", + "pages/testResourceManagerPage", + "pages/testMultiThreadWorkerPage2", + "pages/cropImagePage", + "pages/cropImagePage2" + ] +} diff --git a/entry/src/ohosTest/config.json b/entry/src/ohosTest/config.json deleted file mode 100644 index b97e860..0000000 --- a/entry/src/ohosTest/config.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "app": { - "bundleName": "com.example.imageknifegiteepro", - "vendor": "example", - "version": { - "code": 1000000, - "name": "1.0.0" - } - }, - "deviceConfig": {}, - "module": { - "package": "com.example.entry_test", - "name": ".entry_test", - "mainAbility": ".TestAbility", - "srcPath": "", - "deviceType": [ - "phone", - "tablet" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry_test", - "moduleType": "feature", - "installationFree": false - }, - "abilities": [ - { - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ], - "orientation": "unspecified", - "visible": true, - "srcPath": "TestAbility", - "name": ".TestAbility", - "srcLanguage": "ets", - "icon": "$media:icon", - "description": "$string:description_TestAbility", - "formsEnabled": false, - "label": "$string:entry_TestAbility", - "type": "page", - "launchType": "standard" - } - ], - "js": [ - { - "mode": { - "syntax": "ets", - "type": "pageAbility" - }, - "pages": [ - "pages/index" - ], - "name": ".TestAbility", - "window": { - "designWidth": 720, - "autoDesignWidth": false - } - } - ] - } -} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/Application/TestAbilityStage.ts b/entry/src/ohosTest/ets/Application/TestAbilityStage.ts new file mode 100644 index 0000000..b2461b2 --- /dev/null +++ b/entry/src/ohosTest/ets/Application/TestAbilityStage.ts @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import AbilityStage from "@ohos.application.AbilityStage" + +export default class TestAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] TestAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/TestAbility/TestAbility.ts b/entry/src/ohosTest/ets/TestAbility/TestAbility.ts new file mode 100644 index 0000000..2263496 --- /dev/null +++ b/entry/src/ohosTest/ets/TestAbility/TestAbility.ts @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import Ability from '@ohos.application.Ability' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from 'hypium/index' +import testsuite from '../test/List.test' + +export default class TestAbility extends Ability { + onCreate(want, launchParam) { + console.log('TestAbility onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + } + + onDestroy() { + console.log('TestAbility onDestroy') + } + + onWindowStageCreate(windowStage) { + console.log('TestAbility onWindowStageCreate') + windowStage.setUIContent(this.context, 'TestAbility/pages/index', null) + + globalThis.abilityContext = this.context; + } + + onWindowStageDestroy() { + console.log('TestAbility onWindowStageDestroy') + } + + onForeground() { + console.log('TestAbility onForeground') + } + + onBackground() { + console.log('TestAbility onBackground') + } +}; \ No newline at end of file diff --git a/entry/src/ohosTest/ets/TestAbility/app.ets b/entry/src/ohosTest/ets/TestAbility/app.ets deleted file mode 100644 index bc4d7e2..0000000 --- a/entry/src/ohosTest/ets/TestAbility/app.ets +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' -import { Hypium } from 'hypium/index' -import testsuite from '../test/List.test' - -export default { - onCreate() { - console.info('Application onCreate') - var abilityDelegator: any - abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() - var abilityDelegatorArguments: any - abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() - console.info('start run testcase!!!') - Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) - }, - onDestroy() { - console.info('Application onDestroy') - }, -} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/TestAbility/pages/index.ets b/entry/src/ohosTest/ets/TestAbility/pages/index.ets index df4ccb0..cc488e6 100644 --- a/entry/src/ohosTest/ets/TestAbility/pages/index.ets +++ b/entry/src/ohosTest/ets/TestAbility/pages/index.ets @@ -1,18 +1,18 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, + * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ -import router from '@system.router'; +import router from '@ohos.router'; @Entry @Component @@ -20,7 +20,6 @@ struct Index { aboutToAppear() { console.info('TestAbility index aboutToAppear') } - @State message: string = 'Hello World' build() { Row() { diff --git a/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts b/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts index d1fb5ea..8b40caa 100644 --- a/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts +++ b/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -1,13 +1,13 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, + * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -20,25 +20,24 @@ var abilityDelegatorArguments = undefined function translateParamsToString(parameters) { const keySet = new Set([ - '-s class', '-s notClass', '-s suite', '-s itName', - '-s level', '-s testType', '-s size', '-s timeout', - '-s package' + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout' ]) let targetParams = ''; for (const key in parameters) { if (keySet.has(key)) { - targetParams += ' ' + key + ' ' + parameters[key] + targetParams = `${targetParams} ${key} ${parameters[key]}` } } return targetParams.trim() } async function onAbilityCreateCallback() { - console.log('onAbilityCreateCallback'); + console.log("onAbilityCreateCallback"); } async function addAbilityMonitorCallback(err: any) { - console.info('addAbilityMonitorCallback : ' + JSON.stringify(err)) + console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) } export default class OpenHarmonyTestRunner implements TestRunner { @@ -46,21 +45,20 @@ export default class OpenHarmonyTestRunner implements TestRunner { } onPrepare() { - console.info('OpenHarmonyTestRunner OnPrepare') + console.info("OpenHarmonyTestRunner OnPrepare ") } - onRun() { + async onRun() { console.log('OpenHarmonyTestRunner onRun run') abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() - + var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility' let lMonitor = { abilityName: testAbilityName, onAbilityCreate: onAbilityCreateCallback, }; - var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) - var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) console.info('cmd : '+cmd) abilityDelegator.executeShellCommand(cmd, @@ -69,9 +67,6 @@ export default class OpenHarmonyTestRunner implements TestRunner { console.info('executeShellCommand : data : ' + d.stdResult); console.info('executeShellCommand : data : ' + d.exitCode); }) - console.info('OpenHarmonyTestRunner onRun call abilityDelegator.getAppContext') - var context = abilityDelegator.getAppContext() - console.info('getAppContext : ' + JSON.stringify(context)) console.info('OpenHarmonyTestRunner onRun end') } }; \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/Ability.test.ets b/entry/src/ohosTest/ets/test/Ability.test.ets index eb9e0b6..22f7b08 100644 --- a/entry/src/ohosTest/ets/test/Ability.test.ets +++ b/entry/src/ohosTest/ets/test/Ability.test.ets @@ -1,13 +1,13 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, + * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. diff --git a/entry/src/ohosTest/ets/test/List.test.ets b/entry/src/ohosTest/ets/test/List.test.ets index 760f2aa..d3c6829 100644 --- a/entry/src/ohosTest/ets/test/List.test.ets +++ b/entry/src/ohosTest/ets/test/List.test.ets @@ -1,13 +1,13 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, + * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. diff --git a/entry/src/ohosTest/module.json5 b/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000..4cf8a1f --- /dev/null +++ b/entry/src/ohosTest/module.json5 @@ -0,0 +1,37 @@ +{ + "module": { + "name": "entry_test", + "type": "feature", + "srcEntrance": "./ets/TestAbility/TestAbility.ts", + "description": "$string:entry_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "TestAbility", + "srcEntrance": "./ets/TestAbility/TestAbility.ts", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "visible": true, + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/entry/src/ohosTest/resources/base/element/color.json b/entry/src/ohosTest/resources/base/element/color.json new file mode 100644 index 0000000..1bbc9aa --- /dev/null +++ b/entry/src/ohosTest/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "white", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/entry/src/ohosTest/resources/base/element/string.json b/entry/src/ohosTest/resources/base/element/string.json index a0901cf..8407800 100644 --- a/entry/src/ohosTest/resources/base/element/string.json +++ b/entry/src/ohosTest/resources/base/element/string.json @@ -1,12 +1,16 @@ { "string": [ { - "name": "description_TestAbility", - "value": "eTS_Empty Ability" + "name": "entry_test_desc", + "value": "i am an entry for tv" }, { - "name": "entry_TestAbility", - "value": "entry_TestAbility" + "name": "TestAbility_desc", + "value": "the tv entry test ability" + }, + { + "name": "TestAbility_label", + "value": "tvBase" } ] } \ No newline at end of file diff --git a/entry/src/ohosTest/resources/base/profile/test_pages.json b/entry/src/ohosTest/resources/base/profile/test_pages.json new file mode 100644 index 0000000..fcef82b --- /dev/null +++ b/entry/src/ohosTest/resources/base/profile/test_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "TestAbility/pages/index" + ] +} diff --git a/hvigorfile.js b/hvigorfile.js index cff9f0d..5f2735e 100644 --- a/hvigorfile.js +++ b/hvigorfile.js @@ -1,2 +1,2 @@ // Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. -module.exports = require('@ohos/hvigor-ohos-plugin').legacyAppTasks \ No newline at end of file +module.exports = require('@ohos/hvigor-ohos-plugin').appTasks \ No newline at end of file diff --git a/imageknife/build-profile.json5 b/imageknife/build-profile.json5 index 107d8c7..35dff6d 100644 --- a/imageknife/build-profile.json5 +++ b/imageknife/build-profile.json5 @@ -1,5 +1,5 @@ { - "apiType": "faMode", + "apiType": "stageMode", "buildOption": { } } diff --git a/imageknife/hvigorfile.js b/imageknife/hvigorfile.js index 3a7c40c..42ed4b4 100644 --- a/imageknife/hvigorfile.js +++ b/imageknife/hvigorfile.js @@ -1,3 +1,3 @@ // Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. -module.exports = require('@ohos/hvigor-ohos-plugin').legacyHarTasks +module.exports = require('@ohos/hvigor-ohos-plugin').harTasks diff --git a/imageknife/index.ets b/imageknife/index.ets index 035217e..7dcb522 100644 --- a/imageknife/index.ets +++ b/imageknife/index.ets @@ -22,7 +22,6 @@ export * from './src/main/ets/components/cache/FileUtils' export * from './src/main/ets/components/cache/Md5' export * from './src/main/ets/components/cache/Base64' export * from './src/main/ets/components/cache/LruCache' -export * from './src/main/ets/components/cache/DiskLruCache' export * from './src/main/ets/components/cache/diskstrategy/enum/ALL' export * from './src/main/ets/components/cache/diskstrategy/enum/AUTOMATIC' export * from './src/main/ets/components/cache/diskstrategy/enum/DATA' @@ -48,6 +47,8 @@ export * from './src/main/ets/components/imageknife/compress/provider/RecoursePr export * from './src/main/ets/components/imageknife/crop/Crop' export * from './src/main/ets/components/imageknife/crop/CropImage' export * from './src/main/ets/components/imageknife/crop/CropOptions' +export {default as PixelMapCrop} from './src/main/ets/components/imageknife/crop/PixelMapCrop' +export * from './src/main/ets/components/imageknife/crop/CropCallback' /** * transform @@ -82,6 +83,8 @@ export * from './src/main/ets/components/imageknife/pngj/Pngj' export {handler} from './src/main/ets/components/imageknife/pngj/PngWork' export * from './src/main/ets/components/imageknife/pngj/UPNG' + + /** * ImageKnife */ diff --git a/imageknife/package-lock.json b/imageknife/package-lock.json deleted file mode 100644 index c6a681a..0000000 --- a/imageknife/package-lock.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "@ohos/imageknife", - "version": "1.0.2", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "pako": { - "version": "1.0.11", - "resolved": "http://mirrors.tools.huawei.com/npm/pako/-/pako-1.0.11.tgz", - "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==" - } - } -} diff --git a/imageknife/package.json b/imageknife/package.json index 342ebdb..332c2ad 100644 --- a/imageknife/package.json +++ b/imageknife/package.json @@ -1,27 +1,29 @@ { - "types": "", - "keywords": [ + "types":"", + "keywords":[ "OpenHarmony", "ImageKnife", "glide" ], - "author": "ohos_tpc", - "description": "专门为OpenHarmony打造的一款图像加载缓存库,致力于更高效、更轻便、更简单", - "ohos": { - "org": "opensource" + "author":"ohos_tpc", + "description":"专门为OpenHarmony打造的一款图像加载缓存库,致力于更高效、更轻便、更简单", + "ohos":{ + "org":"opensource" }, - "main": "index.ets", - "repository": "https://gitee.com/openharmony-tpc/ImageKnife", - "version": "1.0.2", - "dependencies": { - "pako": "^1.0.5" + "main":"index.ets", + "repository":"https://gitee.com/openharmony-tpc/ImageKnife", + "version":"1.0.2", + "dependencies":{ + "pako":"^1.0.5", + "@ohos/disklrucache":"file:../disklrucache", + "crc-32":"^1.2.0" }, - "tags": [ + "tags":[ "OpenHarmony", "ImageKnife", "glide" ], - "license": "Apache License 2.0", - "devDependencies": {}, - "name": "@ohos/imageknife" -} + "license":"Apache License 2.0", + "devDependencies":{}, + "name":"@ohos/imageknife" +} \ No newline at end of file diff --git a/imageknife/src/main/config.json b/imageknife/src/main/config.json deleted file mode 100644 index 7e6421e..0000000 --- a/imageknife/src/main/config.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "app": { - "bundleName": "cn.openharmony.imageknife", - "vendor": "openharmony", - "version": { - "code": 1000000, - "name": "1.0.0" - } - }, - "deviceConfig": {}, - "module": { - "package": "cn.openharmony.imageknife", - "deviceType": [ - "phone", - "tablet" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "imageknife", - "moduleType": "har" - }, - "uiSyntax": "ets" - } -} diff --git a/imageknife/src/main/ets/components/cache/DiskLruCache.ets b/imageknife/src/main/ets/components/cache/DiskLruCache.ets deleted file mode 100644 index 35594a4..0000000 --- a/imageknife/src/main/ets/components/cache/DiskLruCache.ets +++ /dev/null @@ -1,318 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import {CustomMap} from './CustomMap' -import {FileUtils} from './FileUtils' -import {FileReader} from './FileReader' -import {DiskCacheEntry} from './DiskCacheEntry' -import fileio from '@ohos.fileio'; -import featureability from '@ohos.ability.featureAbility' -import {Md5} from './Md5' - -export class DiskLruCache { - - // 缓存数据集合 - cacheMap: CustomMap = new CustomMap() - fileUtils: FileUtils = FileUtils.getInstance() - diskCacheFolder: string = 'ImageKnifeDiskCache' - - // 缓存文件路劲地址 - dirPath: string= '' - - // 缓存数据最大值 - maxSize: number = 30 * 1024 * 1024 - - // 当前缓存数据值 - size: number = 0 - - // 缓存journal文件名称 - - journal: string = 'journal' - - // 缓存journal备份文件名称 - journalTemp: string = 'journal_temp' - - // 缓存journal文件路径 - journalPath: string = '' - - // 缓存journal备份文件路径 - journalPathTemp: string = '' - - constructor(maxSize: number, direction?: string) { - if (maxSize > 0) { - this.maxSize = maxSize - } - if (!this.isNull(direction)) { - if (direction.endsWith('/')) { - this.dirPath = direction - } else { - this.dirPath = direction + '/' - } - } else { - featureability.getContext() - .getFilesDir() - .then((data) => { - console.log('DiskLruCache - FileDir= ' + data) - let dirPathFolder = data + '/' + this.diskCacheFolder - this.dirPath = dirPathFolder; - FileUtils.getInstance() - .createFolder(dirPathFolder) - this.init() - }) - .catch((error) => { - console.log('DiskLruCache FileDir Error Cause:' + error.message); - }) - } - } - - /** - * 初始化缓存文件 - */ - private init() { - if (this.dirPath.endsWith('/')) { - this.dirPath = this.dirPath - } else { - this.dirPath = this.dirPath + '/' - } - this.journalPath = this.dirPath + this.journal - this.journalPathTemp = this.dirPath + this.journalTemp - try { - var stat = fileio.statSync(this.journalPath) - if (stat.isFile() && stat.size > 0) { - this.fileUtils.createFile(this.journalPathTemp) - this.fileUtils.copyFile(this.journalPath, this.journalPathTemp) - this.readJournal(this.journalPathTemp) - this.resetJournalFile() - } else { - this.fileUtils.createFile(this.journalPath) - } - } catch (e) { - console.log('DiskLruCache - init e ' + e) - this.fileUtils.createFile(this.journalPath) - } - } - - /** - * 重置journal文件数据 - */ - resetJournalFile(){ - this.fileUtils.clearFile(this.journalPath) - for(let key of this.cacheMap.keys()){ - this.fileUtils.writeData(this.journalPath, 'save ' + key + '\n') - } - } - - /** - * 读取journal文件的缓存数据 - */ - readJournal(path: string) { - var fileReader = new FileReader(path) - var line: string = '' - while (!fileReader.isEnd()) { - line = fileReader.readLine() - line = line.replace('\n', '').replace('\r', '') - this.dealwithJournal(line) - } - this.fileUtils.deleteFile(this.journalPathTemp) - this.trimToSize() - } - - /** - * 处理journal文件数据 - */ - dealwithJournal(line: string) { - var picPath = '' - try { - var datas = line.split(' ') - if (datas.length > 1) { - if (datas[0] != 'remove') { - picPath = this.dirPath + datas[1] - var picstat = fileio.statSync(picPath) - if (picstat.isFile() && picstat.size > 0) { - this.size = this.size + picstat.size - this.fileUtils.writeData(this.journalPath, line + '\n') - this.putCacheMap(datas[1], picstat.size) - } - } else { - if (this.cacheMap.hasKey(datas[1])) { - var cacheEntry: DiskCacheEntry = this.cacheMap.get(datas[1]) - this.size = this.size - cacheEntry.getLength() - this.cacheMap.remove(datas[1]) - } - } - } - } catch (e) { - console.log('DiskLruCache - dealwithJournal e = ' + e) - } - } - - /** - * 设置disk缓存最大数据值 - */ - setMaxSize(max: number) { - this.maxSize = max - this.trimToSize() - } - - /** - * 缓存数据map集合 - */ - private putCacheMap(key: string, length?: number) { - if (this.cacheMap.hasKey(key)) { - this.cacheMap.remove(key) - } - if (length > 0) { - this.cacheMap.put(key, new DiskCacheEntry(key, length)) - } else { - this.cacheMap.put(key, new DiskCacheEntry(key)) - } - } - - /** - * 存储disk缓存数据 - */ - putCacheData(key: string, content?: ArrayBuffer, path?: string) { - if (key == null) { - throw new Error('key is null,checking the parameter'); - } - var fileSize = 0 - var isvalid: boolean = false - key = Md5.hashStr(key) - if (content != null && content.byteLength > 0) { - isvalid = true - var tempPath = this.dirPath + key - fileSize = content.byteLength - this.fileUtils.writePic(tempPath, content) - } - if (!this.isNull(path) && this.fileUtils.exist(path)) { - isvalid = true - fileSize = this.fileUtils.getFileSize(path) - this.fileUtils.copyFile(path, this.dirPath + key) - } - if (isvalid) { - this.size = this.size + fileSize - this.putCacheMap(key, fileSize) - this.fileUtils.writeData(this.journalPath, 'save ' + key + '\n') - this.trimToSize() - } else { - throw ('putCacheData() key or content or path is invalid') - } - - } - - /** - * 根据LRU算法删除多余缓存数据 - */ - private trimToSize() { - while (this.size > this.maxSize) { - var tempkey: string = this.cacheMap.getFirstKey() - var fileSize = this.fileUtils.getFileSize(this.dirPath + tempkey) - if (fileSize > 0) { - this.size = this.size - fileSize - } - this.fileUtils.deleteFile(this.dirPath + tempkey) - this.cacheMap.remove(tempkey) - this.fileUtils.writeData(this.journalPath, 'remove ' + tempkey + '\n') - } - } - - /** - * 获取key缓存数据 - */ - getCacheDataByKey(key: string): ArrayBuffer{ - if (key == null) { - throw new Error('key is null,checking the parameter'); - } - key = Md5.hashStr(key) - var path = this.dirPath + key; - if (this.fileUtils.exist(path)) { - var ab: ArrayBuffer = this.fileUtils.readFilePic(path) - this.putCacheMap(key, ab.byteLength) - this.fileUtils.writeData(this.journalPath, 'read ' + key + '\n') - return ab - } else { - return null; - } - } - - /** - * 获取key缓存数据绝对路径 - */ - getCacheFileByKey(key: string): string{ - if (key == null) { - throw new Error('key is null,checking the parameter'); - } - key = Md5.hashStr(key) - if (this.dirPath.endsWith('/')) { - this.dirPath = this.dirPath - } else { - this.dirPath = this.dirPath + '/' - } - var path = this.dirPath + key; - if (this.fileUtils.exist(path)) { - this.fileUtils.writeData(this.journalPath, 'read ' + key + '\n') - return path - } else { - return null - } - } - - /** - * 删除key缓存数据 - */ - deleteCacheDataBykey(key: string): DiskCacheEntry{ - if (key == null) { - throw new Error('key is null,checking the parameter'); - } - key = Md5.hashStr(key) - var path = this.dirPath + key; - if (this.fileUtils.exist(path)) { - var ab = this.fileUtils.readFilePic(path) - this.size = this.size - ab.byteLength - this.cacheMap.remove(key) - this.fileUtils.writeData(this.journalPath, 'remove ' + key + '\n') - this.fileUtils.deleteFile(path) - } - return this.cacheMap.get(key) - } - - /** - * 清除所有disk缓存数据 - */ - cleanCacheData() { - var length = this.cacheMap.size() - for (var index = 0; index < length; index++) { - this.fileUtils.deleteFile(this.dirPath + this.cacheMap[index]) - } - this.fileUtils.deleteFile(this.journalPath) - this.cacheMap.clear() - this.size = 0 - } - - /** - * 空字符串判断 - */ - private isNull(str: string): boolean{ - if (!str || Object.keys(str).length == 0) { - return true - } else { - return false - } - } - - foreachDiskLruCache(fn){ - this.cacheMap.each(fn) - } - -} \ No newline at end of file diff --git a/imageknife/src/main/ets/components/cache/FileUtils.ets b/imageknife/src/main/ets/components/cache/FileUtils.ets index 7430bcb..c5754d3 100644 --- a/imageknife/src/main/ets/components/cache/FileUtils.ets +++ b/imageknife/src/main/ets/components/cache/FileUtils.ets @@ -179,26 +179,6 @@ export class FileUtils { } } - /** - * 读取media的资源文件 - */ - readMediaPic() { - resmgr.getResourceManager() - .then(result => { - result.getMediaBase64($r('app.media.icon') - .id) - .then(data => { - console.error("FileUtils - readPic data = " + data) - data = data.replace("data:image/png;base64,", "") - console.error("FileUtils - readPic this.data = " + data) - this.base64Str = data - console.error("FileUtils - readPic this.base64Str = " + this.base64Str) - }) - .catch(err => { - console.log("FileUtils - readPic err" + JSON.stringify(err)); - }) - }) - } /** * stream式读取 diff --git a/imageknife/src/main/ets/components/cache/diskstrategy/enum/ALL.ets b/imageknife/src/main/ets/components/cache/diskstrategy/enum/ALL.ets index 8086159..ca7b950 100644 --- a/imageknife/src/main/ets/components/cache/diskstrategy/enum/ALL.ets +++ b/imageknife/src/main/ets/components/cache/diskstrategy/enum/ALL.ets @@ -12,9 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import{DiskStrategy} from '../../diskstrategy/DiskStrategy' -import{DataSrc} from '../../diskstrategy/DataSrc' -import{EncodeStrategy} from '../../diskstrategy/EncodeStrategy' +import { DiskStrategy } from '../../diskstrategy/DiskStrategy' +import { DataSrc } from '../../diskstrategy/DataSrc' +import { EncodeStrategy } from '../../diskstrategy/EncodeStrategy' export class ALL implements DiskStrategy { getName(): string{ diff --git a/imageknife/src/main/ets/components/imageknife/ImageKnife.ets b/imageknife/src/main/ets/components/imageknife/ImageKnife.ets index 198b5ee..b8a7341 100644 --- a/imageknife/src/main/ets/components/imageknife/ImageKnife.ets +++ b/imageknife/src/main/ets/components/imageknife/ImageKnife.ets @@ -13,8 +13,8 @@ * limitations under the License. */ -import {DiskLruCache} from "../cache/DiskLruCache" -import {LruCache} from "../cache/LruCache" +import { DiskLruCache } from "@ohos/disklrucache" +import { LruCache } from "../cache/LruCache" import {EngineKeyFactories} from "../cache/key/EngineKeyFactories" import {RequestOption} from "../imageknife/RequestOption" import {AsyncCallback} from "../imageknife/interface/asynccallback" @@ -35,6 +35,8 @@ import featureAbility from '@ohos.ability.featureAbility'; import {CompressBuilder} from "../imageknife/compress/CompressBuilder" export class ImageKnife { + static readonly SEPARATOR: string = '/' + private imageKnifeContext; private memoryCache: LruCache; private diskMemoryCache: DiskLruCache; private dataFetch: IDataFetch; @@ -46,17 +48,47 @@ export class ImageKnife { private runningRequest: Array; private pendingRequest: Array; private fileTypeUtil: FileTypeUtil; // 通用文件格式辨别 + private diskCacheFolder: string = "ImageKnifeDiskCache" private svgAndGifFolder: string = "svgAndGifFolder"; // svg和gif的文件路径地址 private svgAndGifCommitFile: string = "svgAndGifCommitFile" // svg和gif提交记录 - private defaultListener:AsyncCallback; // 全局监听器 + private defaultListener: AsyncCallback; // 全局监听器 + + private constructor(imgCtx) { + this.imageKnifeContext = imgCtx; + + // 构造方法传入size 为保存文件个数 + this.memoryCache = new LruCache(100); + + // 创建disk缓存 传入的size 为多少比特 比如20KB 传入20*1024 + this.diskMemoryCache = DiskLruCache.create(this.imageKnifeContext.filesDir + ImageKnife.SEPARATOR + this.diskCacheFolder, 30 * 1024 * 1024); + + // 创建网络下载能力 + this.dataFetch = new DownloadClient(); + + // 创建本地数据解析能力 + this.resourceFetch = new ParseResClient(); + + // 初始化本地 文件保存 + this.filesPath = this.imageKnifeContext.filesDir; + this.initSvgAndGifEnvironment(); + + this.runningRequest = new Array(); + this.pendingRequest = new Array(); + + // 通用文件格式识别初始化 + this.fileTypeUtil = new FileTypeUtil(); + } getMemoryCache(): LruCache{ return this.memoryCache; } - setMemoryCache(lrucache: LruCache){ - this.memoryCache = lrucache; + public static with(context): ImageKnife{ + if (!this.sInstance) { + this.sInstance = new ImageKnife(context); + } + return this.sInstance; } getDiskMemoryCache(): DiskLruCache{ @@ -81,46 +113,18 @@ export class ImageKnife { this.svgAndGifFolder = folderPath; } - getDefaultListener(){ + getImageKnifeContext() { + return this.imageKnifeContext; + } + + setMemoryCache(lrucache: LruCache) { + this.memoryCache = lrucache; + } + + getDefaultListener() { return this.defaultListener; } - setDefaultListener(newDefaultListener:AsyncCallback){ - this.defaultListener = newDefaultListener; - } - - private constructor() { - - // 构造方法传入size 为保存文件个数 - this.memoryCache = new LruCache(100); - - // 创建disk缓存 传入的size 为多少比特 比如20KB 传入20*1024 - this.diskMemoryCache = new DiskLruCache(30 * 1024 * 1024); - - // 创建网络下载能力 - this.dataFetch = new DownloadClient(); - - // 创建本地数据解析能力 - this.resourceFetch = new ParseResClient(); - - // 初始化本地 文件保存 - featureAbility.getContext() - .getFilesDir() - .then((data) => { - this.filesPath = data - this.initSvgAndGifEnvironment(); - }) - .catch((error) => { - console.error('ImageKnife Failed to obtain the filesPath directory. Cause:' + error.message); - }) - - this.runningRequest = new Array(); - this.pendingRequest = new Array(); - - // 通用文件格式识别初始化 - this.fileTypeUtil = new FileTypeUtil(); - } - private initSvgAndGifEnvironment() { let folderExist = FileUtils.getInstance().existFolder(this.filesPath + "/" + this.svgAndGifFolder) let fileExist = @@ -149,11 +153,8 @@ export class ImageKnife { private static sInstance: ImageKnife; - public static with(): ImageKnife{ - if (!this.sInstance) { - this.sInstance = new ImageKnife(); - } - return this.sInstance; + setDefaultListener(newDefaultListener: AsyncCallback) { + this.defaultListener = newDefaultListener; } public compressBuilder(): CompressBuilder{ @@ -178,15 +179,15 @@ export class ImageKnife { } // 替代原来的DiskLruCache - public replaceDiskLruCache(size:number){ - this.diskMemoryCache = new DiskLruCache(size); + public replaceDiskLruCache(size:number) { + // this.diskMemoryCache = DiskLruCache.create(this.imageKnifeContext.filesDir+ImageKnife.SEPARATOR+this.diskCacheFolder, size); - if(this.diskMemoryCache.cacheMap.size() <= 0) { - this.diskMemoryCache = new DiskLruCache(size); - }else{ - let newDiskLruCache = new DiskLruCache(size); + if (this.diskMemoryCache.getCacheMap().size() <= 0) { + this.diskMemoryCache = DiskLruCache.create(this.imageKnifeContext.filesDir + ImageKnife.SEPARATOR + this.diskCacheFolder, size); + } else { + let newDiskLruCache = DiskLruCache.create(this.imageKnifeContext.filesDir + ImageKnife.SEPARATOR + this.diskCacheFolder, size); this.diskMemoryCache.foreachDiskLruCache(function (value, key, map) { - newDiskLruCache.putCacheData(key, value, null); + newDiskLruCache.set(key, value); }) this.diskMemoryCache = newDiskLruCache; } diff --git a/imageknife/src/main/ets/components/imageknife/ImageKnifeComponent.ets b/imageknife/src/main/ets/components/imageknife/ImageKnifeComponent.ets index a017127..eff9d39 100644 --- a/imageknife/src/main/ets/components/imageknife/ImageKnifeComponent.ets +++ b/imageknife/src/main/ets/components/imageknife/ImageKnifeComponent.ets @@ -178,23 +178,11 @@ export struct ImageKnifeComponent { } // imageknife 第一次启动和数据刷新后重新发送请求 imageKnifeExecute() { - - if(ImageKnife){ - }else{ - ImageKnife = globalThis.exports.default.data.imageKnife; - } - - if(ImageKnife){ - }else{ - console.log('ImageKnife Singleton Initialization Not Completed!') - } - let request = new RequestOption(); this.configNecessary(request); this.configCacheStrategy(request); this.configDisplay(request); - - ImageKnife.call(request); + globalThis.ImageKnife.call(request); } imageKnifeChangeSource(data:ImageKnifeData) { @@ -341,8 +329,7 @@ export struct ImageKnifeComponent { } } -var ImageKnife; -var defaultTemp = globalThis.exports.default -if (defaultTemp != undefined) { - ImageKnife = defaultTemp.data.imageKnife; -} + + + + diff --git a/imageknife/src/main/ets/components/imageknife/RequestOption.ets b/imageknife/src/main/ets/components/imageknife/RequestOption.ets index 7eeb2cc..f443e7b 100644 --- a/imageknife/src/main/ets/components/imageknife/RequestOption.ets +++ b/imageknife/src/main/ets/components/imageknife/RequestOption.ets @@ -369,19 +369,8 @@ export class RequestOption { break; } } - - if(ImageKnife){ - }else{ - ImageKnife = globalThis.exports.default.data.imageKnife; - } - - if(ImageKnife){ - }else{ - console.log('ImageKnife Singleton Initialization Not Completed!') - } - // 加载成功之后 - ImageKnife.removeRunning(this); + globalThis.ImageKnife.removeRunning(this); } loadError(err) { @@ -396,25 +385,9 @@ export class RequestOption { this.errorholderFunc(this.errorholderData) } } - // 加载失败之后 - if(ImageKnife){ - }else{ - ImageKnife = globalThis.exports.default.data.imageKnife; - } - - if(ImageKnife){ - }else{ - console.log('ImageKnife Singleton Initialization Not Completed!') - } - - ImageKnife.removeRunning(this); + globalThis.ImageKnife.removeRunning(this); } } -var ImageKnife; -var defaultTemp = globalThis.exports.default -if (defaultTemp != undefined) { - ImageKnife = defaultTemp.data.imageKnife; -} diff --git a/imageknife/src/main/ets/components/imageknife/compress/CompressBuilder.ets b/imageknife/src/main/ets/components/imageknife/compress/CompressBuilder.ets index 08e7796..7f4ea19 100644 --- a/imageknife/src/main/ets/components/imageknife/compress/CompressBuilder.ets +++ b/imageknife/src/main/ets/components/imageknife/compress/CompressBuilder.ets @@ -20,8 +20,8 @@ import fileio from '@ohos.fileio'; import {CompressAdapter} from '../compress/provider/CompressAdapter' import {DataStringPathProvider} from '../compress/provider/DataStringPathProvider' import {RecourseProvider} from '../compress/provider/RecourseProvider' -import featureability from '@ohos.ability.featureAbility' -import {Engine} from '../compress/Engine' +import { Engine } from '../compress/Engine' +import { ImageKnife } from '../ImageKnife' export class CompressBuilder { private _mTargetDir: string; @@ -106,10 +106,11 @@ export class CompressBuilder { public async get():Promise { if (!this._mTargetDir) { - let path = await featureability.getContext().getFilesDir(); + let context = globalThis.ImageKnife.getImageKnifeContext(); + let path = context.filesDir; var timestamp = (new Date()).valueOf(); this._outFilePath = path + "/compress/" + timestamp + (Math.random() * 100).toFixed(0) + ".jpg"; - let result =await this.startAsyncCompress(); + let result = await this.startAsyncCompress(); return result; } else { let result =await this.startAsyncCompress(); @@ -200,15 +201,9 @@ export class CompressBuilder { } private getImageCacheFile() { - featureability.getContext() - .getFilesDir() - .then(path => { - var timestamp = (new Date()).valueOf(); - this._outFilePath = path + "/compress/" + timestamp + (Math.random() * 100).toFixed(0) + ".jpg"; - this.startCompress(); - }) - .catch(error => { - throw new Error("getImageCacheFile happened error:" + JSON.stringify(error)); - }) + let context = globalThis.ImageKnife.getImageKnifeContext(); + var timestamp = (new Date()).valueOf(); + this._outFilePath = context.filesDir + "/compress/" + timestamp + (Math.random() * 100).toFixed(0) + ".jpg"; + this.startCompress(); } } \ No newline at end of file diff --git a/imageknife/src/main/ets/components/imageknife/compress/Engine.ets b/imageknife/src/main/ets/components/imageknife/compress/Engine.ets index 432216b..a6038e2 100644 --- a/imageknife/src/main/ets/components/imageknife/compress/Engine.ets +++ b/imageknife/src/main/ets/components/imageknife/compress/Engine.ets @@ -70,7 +70,6 @@ export class Engine { } compress() { - console.info("asasd compress()") if (this.mCompressAdapter instanceof DataStringPathProvider) { // file this.mCompressAdapter.openInternal((buffer) => { @@ -90,7 +89,7 @@ export class Engine { var height = info.size.height; var width = info.size.width; var computeSize = this.computeSize(width, height); - console.info("asasd compress computeSize:" + computeSize); + console.info("Engine compress computeSize:" + computeSize); let options = { editable: true, sampleSize: computeSize, diff --git a/imageknife/src/main/ets/components/imageknife/compress/provider/RecourseProvider.ets b/imageknife/src/main/ets/components/imageknife/compress/provider/RecourseProvider.ets index eb0cc03..d84bef4 100644 --- a/imageknife/src/main/ets/components/imageknife/compress/provider/RecourseProvider.ets +++ b/imageknife/src/main/ets/components/imageknife/compress/provider/RecourseProvider.ets @@ -14,7 +14,6 @@ */ import {CompressAdapter, PixelMapFormat} from "../provider/CompressAdapter" -import resmgr from '@ohos.resourceManager' import {CompressDataListener} from "../listener/CompressDataListener" import {FileTypeUtil} from '../../../imageknife/utils/FileTypeUtil' @@ -43,20 +42,18 @@ export class RecourseProvider extends CompressAdapter { if (!this._mResourceData) { throw Error("compress resource is empty"); } - resmgr.getResourceManager() - .then(result => { - result.getMedia(this._mResourceData - .id) - .then(data => { - let buffer = this.uint8ArrayToBuffer(data); - let fileTypeUtil = new FileTypeUtil() - this._mPixelMapHeader = fileTypeUtil.getFileType(buffer); - callback(buffer); + globalThis.ImageKnife.getImageKnifeContext().resourceManager + .getMedia(this._mResourceData.id) + .then(data => { + let buffer = this.uint8ArrayToBuffer(data); + let fileTypeUtil = new FileTypeUtil() + this._mPixelMapHeader = fileTypeUtil.getFileType(buffer); + callback(buffer); }) - .catch(err => { + .catch(err => { console.log("RecourseProvider openInternal err" + JSON.stringify(err)); }) - }) + } getPixelMapFormat(): PixelMapFormat{ diff --git a/imageknife/src/main/ets/components/imageknife/crop/Crop.ets b/imageknife/src/main/ets/components/imageknife/crop/Crop.ets index c171b4c..bcc8bc5 100644 --- a/imageknife/src/main/ets/components/imageknife/crop/Crop.ets +++ b/imageknife/src/main/ets/components/imageknife/crop/Crop.ets @@ -13,13 +13,12 @@ * limitations under the License. */ -import {AsyncTransform} from "../transform/AsyncTransform" +import { CropCallback } from './CropCallback' import image from "@ohos.multimedia.image" -import {TransformUtils} from "../transform/TransformUtils" export namespace Crop { - export function crop(buf: ArrayBuffer, x: number, y: number, cropWidth: number, cropHeight: number, func?: AsyncTransform, colorRatio?: number) { + export function crop(buf: ArrayBuffer, x: number, y: number, cropWidth: number, cropHeight: number, func?: CropCallback, colorRatio?: number) { if (!buf || buf.byteLength <= 0) { console.log("Crop buf is empty"); if (func) { @@ -28,7 +27,7 @@ export namespace Crop { return; } var imageSource = image.createImageSource(buf as any); - TransformUtils.getPixelMapSize(imageSource, (error, size: { + getPixelMapSize(imageSource, (error, size: { width: number, height: number }) => { @@ -72,7 +71,7 @@ export namespace Crop { }) } - async function colorRatioPixelMap(data: any, width: number, height: number, colorRatio: number, func?: AsyncTransform) { + async function colorRatioPixelMap(data: any, width: number, height: number, colorRatio: number, func?: CropCallback) { if (!data) { func("colorRatio pixelMap is null", null); return; @@ -94,4 +93,23 @@ export namespace Crop { await writePromise; func("", data); } + + + function getPixelMapSize(imageSource: any, func: CropCallback<{ + width: number, + height: number + }>) { + if (!imageSource) { + return; + } + imageSource.getImageInfo((err, value) => { + if (err) { + func(err, null) + return; + } + var pWidth = value.size.width; + var pHeight = value.size.height; + func('', { width: pWidth, height: pHeight }); + }) + } } \ No newline at end of file diff --git a/imageknife/src/main/ets/components/imageknife/crop/CropCallback.ets b/imageknife/src/main/ets/components/imageknife/crop/CropCallback.ets new file mode 100644 index 0000000..1f428e5 --- /dev/null +++ b/imageknife/src/main/ets/components/imageknife/crop/CropCallback.ets @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export interface CropCallback { + (err, data: T) +} \ No newline at end of file diff --git a/imageknife/src/main/ets/components/imageknife/crop/PixelMapCrop.ets b/imageknife/src/main/ets/components/imageknife/crop/PixelMapCrop.ets new file mode 100644 index 0000000..2a691e5 --- /dev/null +++ b/imageknife/src/main/ets/components/imageknife/crop/PixelMapCrop.ets @@ -0,0 +1,903 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import image from "@ohos.multimedia.image" +import { Crop } from './Crop' +import { CropCallback } from './CropCallback' + +@Component +struct PixelMapCrop { + @Watch('watchOptions') @State options: PixelMapCrop.Options = new PixelMapCrop.Options(); + @Watch('watchCropTap') @Prop cropTap: boolean; + @State bWidth: number = 0; + @State bHeight: number = 0; + @State cWidth: number = 0; + @State cHeight: number = 0; + downX: number = 0; + downY: number = 0; + moveX: number = 0; + moveY: number = 0; + lastMoveX: number = 0; + lastMoveY: number = 0; + // 裁剪4个角区域 下标0和1左上点 下标2和3右下点 + leftTopArea: number[] = [0, 0, 0, 0] + leftBottomArea: number[] = [0, 0, 0, 0] + rightTopArea: number[] = [0, 0, 0, 0] + rightBottomArea: number[] = [0, 0, 0, 0] + // 4个边框区域 + leftLineArea: number[] = [0, 0, 0, 0] + topLineArea: number[] = [0, 0, 0, 0] + rightLineArea: number[] = [0, 0, 0, 0] + bottomLineArea: number[] = [0, 0, 0, 0] + //四个角的点 + topLeftPoint: number[] = [0, 0] + topRightPoint: number[] = [0, 0] + bottomLeftPoint: number[] = [0, 0] + bottomRightPoint: number[] = [0, 0] + //角宽 + connerWidth: number = 4 + //边框线宽 + lineWidth: number = 2 + //内部预览细线 + gridLineWidth: number = 1 + MIN_LENGTH = this.connerWidth * 2 * 4 + isValidTouch = false; + isTopLeftAreaTouch = false; + isTopRightAreaTouch = false; + isBottomLeftAreaTouch = false; + isBottomRightAreaTouch = false; + isTopLineAreaTouch = false; + isLeftLineAreaTouch = false; + isRightLineAreaTouch = false; + isBottomLineAreaTouch = false; + isMoveTouch = false; + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private contextGesture: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + watchOptions() { + this.readyCrop(); + } + + watchCropTap() { + console.log('PMC watchCropTap callback') + if (this.options.cropAction) { + console.log('PMC cropAction start') + this.options.cropAction(this.topLeftPoint, this.bottomRightPoint, this.options.pixelScale); + } + } + + readyCrop() { + if (!this.options.width || !this.options.height || !this.options.pixelBuffer || !this.options.pixelMap) { + throw new Error('PixelMapCrop Options width must not be null & height must not be null & pixelMap must not be null & pixelBuffer must not be null ') + return + } + + this.bWidth = px2vp(this.options.width); + this.bHeight = px2vp(this.options.height); + + this.cWidth = px2vp(this.options.pixelWidth) + this.cHeight = px2vp(this.options.pixelHeight) + + + this.context.drawImage(this.options.pixelMap, 0, 0) + + + this.cropDefault(); + + this.buildCropBoxConnerArea() + + this.buildCropBoxLineArea() + + + this.drawCropBox(); + } + + + //获取裁剪 初始位置 + cropDefault() { + // 左上角 初始坐标 + this.topLeftPoint = [this.cWidth / 4.0 - this.connerWidth / 2.0, this.cHeight / 4.0 - this.connerWidth / 2.0] + + // 右上角 初始坐标 + this.topRightPoint = [this.cWidth / 4.0 * 3.0 + this.connerWidth / 2.0, this.cHeight / 4.0 - this.connerWidth / 2.0] + + // 左下角 初始坐标 + this.bottomLeftPoint = [this.cWidth / 4.0 - this.connerWidth / 2.0, this.cHeight / 4.0 * 3.0 + this.connerWidth / 2.0] + + // 右下角 初始坐标 + this.bottomRightPoint = [this.cWidth / 4.0 * 3.0 + this.connerWidth / 2.0, this.cHeight / 4.0 * 3.0 + this.connerWidth / 2.0] + } + + buildCropBoxConnerArea() { + // 左上角 初始区域 + this.leftTopArea = [this.topLeftPoint[0], this.topLeftPoint[1], this.topLeftPoint[0] + this.MIN_LENGTH / 2, this.topLeftPoint[1] + this.MIN_LENGTH / 2] + // 右上角 初始区域 + this.rightTopArea = [this.topRightPoint[0] - this.MIN_LENGTH / 2, this.topRightPoint[1], this.topRightPoint[0], this.topRightPoint[1] + this.MIN_LENGTH / 2] + // 左下角 初始区域 + this.leftBottomArea = [this.bottomLeftPoint[0], this.bottomLeftPoint[1] - this.MIN_LENGTH / 2, this.bottomLeftPoint[0] + this.MIN_LENGTH / 2, this.bottomLeftPoint[1]] + // 右下角 初始区域 + this.rightBottomArea = [this.bottomRightPoint[0] - this.MIN_LENGTH / 2, this.bottomRightPoint[1] - this.MIN_LENGTH / 2, this.bottomRightPoint[0], this.bottomRightPoint[1]] + } + + buildCropBoxLineArea() { + // 左线 + this.leftLineArea = [this.topLeftPoint[0], this.topLeftPoint[1] + this.MIN_LENGTH / 2, this.bottomLeftPoint[0] + this.MIN_LENGTH / 2, this.bottomLeftPoint[1] - this.MIN_LENGTH / 2] + // 上线 + this.topLineArea = [this.topLeftPoint[0] + this.MIN_LENGTH / 2, this.topLeftPoint[1], this.topRightPoint[0] - this.MIN_LENGTH / 2, this.topRightPoint[1] + this.MIN_LENGTH / 2] + // 右线 + this.rightLineArea = [this.topRightPoint[0] - this.MIN_LENGTH / 2, this.topRightPoint[1] + this.MIN_LENGTH / 2, this.bottomRightPoint[0], this.bottomRightPoint[1] - this.MIN_LENGTH / 2] + // 下线 + this.bottomLineArea = [this.bottomLeftPoint[0] + this.MIN_LENGTH / 2, this.bottomLeftPoint[1] - this.MIN_LENGTH / 2, this.bottomRightPoint[0] - this.MIN_LENGTH / 2, this.bottomRightPoint[1]] + } + + + // 绘制裁剪框 + drawCropBox() { + this.contextGesture.clearRect(0, 0, this.cWidth, this.cHeight) + // 绘制 裁剪框内部 透明底色 外部非透明底色 + this.drawTransparentBackground(); + // 绘制网格线 + if (this.options.hasGuideLine) { + this.drawGridLine() + } + // 绘制裁剪框边框线 + this.drawConnerLine() + // 绘制裁剪框边框 + this.drawConner() + } + + drawTransparentBackground() { + + this.contextGesture.fillStyle = 'rgba(0,0,0,0.8)' + this.contextGesture.moveTo(this.topLeftPoint[0], this.topLeftPoint[1]) + this.contextGesture.lineTo(this.topRightPoint[0], this.topRightPoint[1]) + this.contextGesture.lineTo(this.bottomRightPoint[0], this.bottomRightPoint[1]) + this.contextGesture.lineTo(this.bottomLeftPoint[0], this.bottomLeftPoint[1]) + this.contextGesture.closePath(); + + this.contextGesture.moveTo(0, 0) + this.contextGesture.lineTo(0, this.cHeight) + this.contextGesture.lineTo(this.cWidth, this.cHeight) + this.contextGesture.lineTo(this.cWidth, 0) + this.contextGesture.closePath(); + + this.contextGesture.fill(); + } + + drawGridLine() { + + this.contextGesture.lineWidth = this.gridLineWidth * px2vp(1) + this.contextGesture.lineCap = 'square' + this.contextGesture.strokeStyle = '#ffffff' + + let contentW = this.topRightPoint[0] - this.topLeftPoint[0] + let stepW = contentW / 3.0; + + let contentH = this.bottomLeftPoint[1] - this.topLeftPoint[1] + let stepH = contentH / 3.0; + + // 竖线1 + this.contextGesture.beginPath() + this.contextGesture.moveTo(this.topLeftPoint[0] + stepW * 1.0, this.topLeftPoint[1]) + this.contextGesture.lineTo(this.bottomLeftPoint[0] + stepW * 1.0, this.bottomLeftPoint[1]) + this.contextGesture.stroke() + + // 竖线2 + this.contextGesture.beginPath() + this.contextGesture.moveTo(this.topLeftPoint[0] + stepW * 2.0, this.topLeftPoint[1]) + this.contextGesture.lineTo(this.bottomLeftPoint[0] + stepW * 2.0, this.bottomLeftPoint[1]) + this.contextGesture.stroke() + + //横线1 + this.contextGesture.beginPath() + this.contextGesture.moveTo(this.topLeftPoint[0], this.topLeftPoint[1] + stepH * 1.0) + this.contextGesture.lineTo(this.topRightPoint[0], this.topRightPoint[1] + stepH * 1.0) + this.contextGesture.stroke() + //横线2 + this.contextGesture.beginPath() + this.contextGesture.moveTo(this.topLeftPoint[0], this.topLeftPoint[1] + stepH * 2.0) + this.contextGesture.lineTo(this.topRightPoint[0], this.topRightPoint[1] + stepH * 2.0) + this.contextGesture.stroke() + } + + // 边框 + drawConnerLine() { + this.contextGesture.lineWidth = this.lineWidth + this.contextGesture.lineCap = 'square' + this.contextGesture.strokeStyle = '#aaaaaa' + // 上框 + this.contextGesture.beginPath() + this.contextGesture.moveTo(this.topLeftPoint[0], this.topLeftPoint[1]) + this.contextGesture.lineTo(this.topRightPoint[0], this.topRightPoint[1]) + this.contextGesture.stroke() + // 左框 + this.contextGesture.beginPath() + this.contextGesture.moveTo(this.topLeftPoint[0], this.topLeftPoint[1]) + this.contextGesture.lineTo(this.bottomLeftPoint[0], this.bottomLeftPoint[1]) + this.contextGesture.stroke() + // 右框 + console.log('PMC this.topRightPoint=' + this.topRightPoint + ' this.bottomRightPoint=' + this.bottomRightPoint) + this.contextGesture.beginPath() + this.contextGesture.moveTo(this.topRightPoint[0], this.topRightPoint[1]) + this.contextGesture.lineTo(this.bottomRightPoint[0], this.bottomRightPoint[1]) + this.contextGesture.stroke() + // 下框 + this.contextGesture.beginPath() + this.contextGesture.moveTo(this.bottomLeftPoint[0], this.bottomLeftPoint[1]) + this.contextGesture.lineTo(this.bottomRightPoint[0], this.bottomRightPoint[1]) + this.contextGesture.stroke() + } + // 边框角 + drawConner() { + this.contextGesture.lineWidth = this.connerWidth + this.contextGesture.lineCap = 'square' + this.contextGesture.strokeStyle = '#ffffff' + + // 左上角 + this.contextGesture.beginPath() + this.contextGesture.moveTo(this.topLeftPoint[0], this.topLeftPoint[1]) + this.contextGesture.lineTo(this.topLeftPoint[0], this.topLeftPoint[1] + this.MIN_LENGTH / 2.0) + this.contextGesture.stroke() + + this.contextGesture.beginPath() + this.contextGesture.moveTo(this.topLeftPoint[0], this.topLeftPoint[1]) + this.contextGesture.lineTo(this.topLeftPoint[0] + this.MIN_LENGTH / 2.0, this.topLeftPoint[1]) + this.contextGesture.stroke() + + // 右上角 + this.contextGesture.beginPath() + this.contextGesture.moveTo(this.topRightPoint[0], this.topRightPoint[1]) + this.contextGesture.lineTo(this.topRightPoint[0], this.topRightPoint[1] + this.MIN_LENGTH / 2.0) + this.contextGesture.stroke() + + this.contextGesture.beginPath() + this.contextGesture.moveTo(this.topRightPoint[0], this.topRightPoint[1]) + this.contextGesture.lineTo(this.topRightPoint[0] - this.MIN_LENGTH / 2.0, this.topRightPoint[1]) + this.contextGesture.stroke() + + // 左下角 + this.contextGesture.beginPath() + this.contextGesture.moveTo(this.bottomLeftPoint[0], this.bottomLeftPoint[1]) + this.contextGesture.lineTo(this.bottomLeftPoint[0], this.bottomLeftPoint[1] - this.MIN_LENGTH / 2.0) + this.contextGesture.stroke() + + this.contextGesture.beginPath() + this.contextGesture.moveTo(this.bottomLeftPoint[0], this.bottomLeftPoint[1]) + this.contextGesture.lineTo(this.bottomLeftPoint[0] + this.MIN_LENGTH / 2.0, this.bottomLeftPoint[1]) + this.contextGesture.stroke() + + + // 右下角 + this.contextGesture.beginPath() + this.contextGesture.moveTo(this.bottomRightPoint[0], this.bottomRightPoint[1]) + this.contextGesture.lineTo(this.bottomRightPoint[0], this.bottomRightPoint[1] - this.MIN_LENGTH / 2.0) + this.contextGesture.stroke() + + this.contextGesture.beginPath() + this.contextGesture.moveTo(this.bottomRightPoint[0], this.bottomRightPoint[1]) + this.contextGesture.lineTo(this.bottomRightPoint[0] - this.MIN_LENGTH / 2.0, this.bottomRightPoint[1]) + this.contextGesture.stroke() + } + + build() { + Stack() { + Canvas(this.context) + .width(this.cWidth) + .height(this.cHeight) + .onReady(() => { + }).backgroundColor(Color.Yellow) + + Canvas(this.contextGesture) + .width(this.cWidth) + .height(this.cHeight) + // .backgroundColor('#33000000') + .onReady(() => { + }) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + // 手指按下 + this.downX = event.touches[0].x; + this.downY = event.touches[0].y; + + this.lastMoveX = event.touches[0].x; + this.lastMoveY = event.touches[0].y; + + this.belongRegion() + + } + if (event.type === TouchType.Up) { + // 手指放开 + this.downX = 0; + this.downY = 0; + + this.moveX = 0; + this.moveY = 0; + + this.resetTouch(); + + } + if (event.type === TouchType.Move) { + // 手指移动 + this.moveX = event.touches[0].x; + this.moveY = event.touches[0].y; + // 每次移动的delta数据 + let dx = this.moveX - this.lastMoveX; + let dy = this.moveY - this.lastMoveY; + + console.log('PMC this.isTopLeftAreaTouch =' + this.isTopLeftAreaTouch + ' this.isTopRightAreaTouch =' + this.isTopRightAreaTouch + + ' this.isBottomLeftAreaTouch=' + this.isBottomLeftAreaTouch + ' isBottomRightAreaTouch' + this.isBottomRightAreaTouch + + ' dx =' + dx + ' dy =' + dy) + + this.touchLeftTopArea(dx, dy) + this.touchRightTopArea(dx, dy) + this.touchLeftBottomArea(dx, dy) + this.touchRightBottomArea(dx, dy) + + + this.touchTopLineArea(dx, dy) + this.touchLeftLineArea(dx, dy) + this.touchRightLineArea(dx, dy) + this.touchBottomLineArea(dx, dy) + + this.touchMoveCropBox(dx, dy); + + this.lastMoveX = event.touches[0].x + this.lastMoveY = event.touches[0].y + + } + + }) + + } + .width(this.bWidth) + .height(this.bHeight) + .padding({ + left: (this.bWidth - this.cWidth) / 2.0, + top: (this.bHeight - this.cHeight) / 2.0, + right: (this.bWidth - this.cWidth) / 2.0, + bottom: (this.bHeight - this.cHeight) / 2.0 + }) + .backgroundColor(Color.Pink) + } + + touchLeftTopArea(dx: number, dy: number) { + if (this.isTopLeftAreaTouch) { + let boarderLeft = this.topLeftPoint[0] + dx + + if (boarderLeft < 0) { + dx = 0 - this.topLeftPoint[0]; + } + + let boarderTop = this.topLeftPoint[1] + dy + if (boarderTop < 0) { + dy = 0 - this.topLeftPoint[1] + } + + let boarderRight = this.topLeftPoint[0] + dx + if (boarderRight > this.topRightPoint[0] - this.MIN_LENGTH) { + dx = this.topRightPoint[0] - this.MIN_LENGTH - this.topLeftPoint[0] + } + + let boarderBottom = this.topLeftPoint[1] + dy + if (boarderBottom > this.bottomLeftPoint[1] - this.MIN_LENGTH) { + dy = this.bottomLeftPoint[1] - this.MIN_LENGTH - this.topLeftPoint[1] + } + + + this.topLeftPoint[0] = this.topLeftPoint[0] + dx; + this.topLeftPoint[1] = this.topLeftPoint[1] + dy; + + this.topRightPoint[1] = this.topRightPoint[1] + dy; + + this.bottomLeftPoint[0] = this.bottomLeftPoint[0] + dx; + + this.buildCropBoxConnerArea(); + this.buildCropBoxLineArea(); + this.drawCropBox(); + + } + } + + touchRightTopArea(dx: number, dy: number) { + if (this.isTopRightAreaTouch) { + let boarderLeft = this.topRightPoint[0] + dx + + if (boarderLeft < this.topLeftPoint[0] + this.MIN_LENGTH) { + dx = this.topLeftPoint[0] + this.MIN_LENGTH - this.topRightPoint[0]; + } + + let boarderTop = this.topRightPoint[1] + dy + if (boarderTop < 0) { + dy = 0 - this.topRightPoint[1] + } + + let boarderRight = this.topRightPoint[0] + dx + if (boarderRight > this.cWidth) { + dx = this.cWidth - this.topRightPoint[0] + } + + let boarderBottom = this.topRightPoint[1] + dy + if (boarderBottom > this.bottomRightPoint[1] - this.MIN_LENGTH) { + dy = this.bottomRightPoint[1] - this.MIN_LENGTH - this.topLeftPoint[1] + } + + + this.topRightPoint[0] = this.topRightPoint[0] + dx; + this.topRightPoint[1] = this.topRightPoint[1] + dy; + + this.topLeftPoint[1] = this.topLeftPoint[1] + dy; + this.bottomRightPoint[0] = this.bottomRightPoint[0] + dx; + + this.buildCropBoxConnerArea(); + this.buildCropBoxLineArea(); + this.drawCropBox(); + + } + } + + touchLeftBottomArea(dx: number, dy: number) { + if (this.isBottomLeftAreaTouch) { + let boarderLeft = this.bottomLeftPoint[0] + dx + + if (boarderLeft < 0) { + dx = 0 - this.bottomLeftPoint[0]; + } + + let boarderTop = this.bottomLeftPoint[1] + dy + if (boarderTop < this.topLeftPoint[1] + this.MIN_LENGTH) { + dy = this.topLeftPoint[1] + this.MIN_LENGTH - this.bottomLeftPoint[1] + } + + let boarderRight = this.bottomLeftPoint[0] + dx + if (boarderRight > this.bottomRightPoint[0] - this.MIN_LENGTH) { + dx = this.bottomRightPoint[0] - this.MIN_LENGTH - this.bottomLeftPoint[0] + } + + let boarderBottom = this.bottomLeftPoint[1] + dy + if (boarderBottom > this.cHeight) { + dy = this.cHeight - this.bottomLeftPoint[1] + } + + + this.bottomLeftPoint[0] = this.bottomLeftPoint[0] + dx; + this.bottomLeftPoint[1] = this.bottomLeftPoint[1] + dy; + + this.topLeftPoint[0] = this.topLeftPoint[0] + dx; + this.bottomRightPoint[1] = this.bottomRightPoint[1] + dy; + + this.buildCropBoxConnerArea(); + this.buildCropBoxLineArea(); + this.drawCropBox(); + + } + } + + touchRightBottomArea(dx: number, dy: number) { + if (this.isBottomRightAreaTouch) { + let boarderLeft = this.bottomRightPoint[0] + dx + + if (boarderLeft < this.bottomLeftPoint[0] + this.MIN_LENGTH) { + dx = this.bottomLeftPoint[0] + this.MIN_LENGTH - this.bottomRightPoint[0]; + } + + let boarderTop = this.bottomRightPoint[1] + dy + if (boarderTop < this.topRightPoint[1] + this.MIN_LENGTH) { + dy = this.topRightPoint[1] + this.MIN_LENGTH - this.bottomRightPoint[1] + } + + let boarderRight = this.bottomRightPoint[0] + dx + if (boarderRight > this.cWidth) { + dx = this.cWidth - this.bottomRightPoint[0] + } + + let boarderBottom = this.bottomRightPoint[1] + dy + if (boarderBottom > this.cHeight) { + dy = this.cHeight - this.bottomRightPoint[1] + } + + + this.bottomRightPoint[0] = this.bottomRightPoint[0] + dx; + this.bottomRightPoint[1] = this.bottomRightPoint[1] + dy; + + this.bottomLeftPoint[1] = this.bottomLeftPoint[1] + dy; + this.topRightPoint[0] = this.topRightPoint[0] + dx; + + this.buildCropBoxConnerArea(); + this.buildCropBoxLineArea(); + this.drawCropBox(); + + } + } + + touchTopLineArea(dx: number, dy: number) { + + if (this.isTopLineAreaTouch) { + + + let boarderTop = this.topLeftPoint[1] + dy + if (boarderTop < 0) { + dy = 0 - this.topLeftPoint[1] + } + + let boarderBottom = this.topLeftPoint[1] + dy + if (boarderBottom > this.bottomLeftPoint[1] - this.MIN_LENGTH) { + dy = this.bottomLeftPoint[1] - this.MIN_LENGTH - this.topLeftPoint[1] + } + + + this.topLeftPoint[1] = this.topLeftPoint[1] + dy; + + this.topRightPoint[1] = this.topRightPoint[1] + dy; + + + this.buildCropBoxConnerArea(); + this.buildCropBoxLineArea(); + this.drawCropBox(); + + } + } + + touchBottomLineArea(dx: number, dy: number) { + + if (this.isBottomLineAreaTouch) { + + let boarderTop = this.bottomLeftPoint[1] + dy + if (boarderTop < this.topLeftPoint[1] + this.MIN_LENGTH) { + dy = this.topLeftPoint[1] + this.MIN_LENGTH - this.bottomLeftPoint[1] + } + + let boarderBottom = this.bottomLeftPoint[1] + dy + if (boarderBottom > this.cHeight) { + dy = this.cHeight - this.bottomLeftPoint[1] + } + + this.bottomLeftPoint[1] = this.bottomLeftPoint[1] + dy; + this.bottomRightPoint[1] = this.bottomRightPoint[1] + dy; + + this.buildCropBoxConnerArea(); + this.buildCropBoxLineArea(); + this.drawCropBox(); + + } + } + + touchLeftLineArea(dx: number, dy: number) { + + if (this.isLeftLineAreaTouch) { + let boarderLeft = this.topLeftPoint[0] + dx + if (boarderLeft < 0) { + dx = 0 - this.topLeftPoint[0]; + } + + let boarderRight = this.topLeftPoint[0] + dx + if (boarderRight > this.topRightPoint[0] - this.MIN_LENGTH) { + dx = this.topRightPoint[0] - this.MIN_LENGTH - this.topLeftPoint[0] + } + + this.topLeftPoint[0] = this.topLeftPoint[0] + dx; + this.bottomLeftPoint[0] = this.bottomLeftPoint[0] + dx; + + + this.buildCropBoxConnerArea(); + this.buildCropBoxLineArea(); + this.drawCropBox(); + } + } + + touchRightLineArea(dx: number, dy: number) { + if (this.isRightLineAreaTouch) { + + let boarderLeft = this.topRightPoint[0] + dx + if (boarderLeft < this.topLeftPoint[0] + this.MIN_LENGTH) { + dx = this.topLeftPoint[0] + this.MIN_LENGTH - this.topRightPoint[0]; + } + + let boarderRight = this.topRightPoint[0] + dx + if (boarderRight > this.cWidth) { + dx = this.cWidth - this.topRightPoint[0] + } + + this.topRightPoint[0] = this.topRightPoint[0] + dx; + this.bottomRightPoint[0] = this.bottomRightPoint[0] + dx; + + this.buildCropBoxConnerArea(); + this.buildCropBoxLineArea(); + this.drawCropBox(); + } + } + + touchMoveCropBox(dx: number, dy: number) { + if (this.isMoveTouch) { + let boarderLeft = this.topLeftPoint[0] + dx + if (boarderLeft < 0) { + dx = 0 - this.topLeftPoint[0]; + } + + let boarderTop = this.topLeftPoint[1] + dy + if (boarderTop < 0) { + dy = 0 - this.topLeftPoint[1] + } + + let boarderRight = this.bottomRightPoint[0] + dx + if (boarderRight > this.cWidth) { + dx = this.cWidth - this.bottomRightPoint[0] + } + + let boarderBottom = this.bottomRightPoint[1] + dy + if (boarderBottom > this.cHeight) { + dy = this.cHeight - this.bottomRightPoint[1] + } + + this.topLeftPoint[0] = this.topLeftPoint[0] + dx; + this.topLeftPoint[1] = this.topLeftPoint[1] + dy; + + this.topRightPoint[0] = this.topRightPoint[0] + dx; + this.topRightPoint[1] = this.topRightPoint[1] + dy; + + this.bottomLeftPoint[0] = this.bottomLeftPoint[0] + dx; + this.bottomLeftPoint[1] = this.bottomLeftPoint[1] + dy; + + this.bottomRightPoint[0] = this.bottomRightPoint[0] + dx; + this.bottomRightPoint[1] = this.bottomRightPoint[1] + dy; + + + this.buildCropBoxConnerArea(); + this.buildCropBoxLineArea(); + this.drawCropBox(); + + } + } + + + // 判断用户手指按下的点的位置 + belongRegion() { + this.resetTouch(); + // 首先判断是否落在裁剪框默认范围内 + this.isBelongCropBox(); + console.log('PMC this.isValidTouch=' + this.isValidTouch) + console.log('PMC downx =' + this.downX + ' downy =' + this.downY + 'this.leftTopArea =' + this.leftTopArea + ' this.leftBottomArea=' + this.leftBottomArea + + ' this.rightTopArea=' + this.rightTopArea + ' this.rightBottomArea=' + this.rightBottomArea); + // 其次判断是否落在裁剪框4个角位置范围 + if (this.isValidTouch) { + console.log('PMC C1') + this.isTopLeftAreaTouch = this.connerBelonged(this.leftTopArea) + console.log('PMC C2') + this.isBottomLeftAreaTouch = this.connerBelonged(this.leftBottomArea) + console.log('PMC C3') + this.isTopRightAreaTouch = this.connerBelonged(this.rightTopArea) + console.log('PMC C4') + this.isBottomRightAreaTouch = this.connerBelonged(this.rightBottomArea) + console.log('PMC result this.isTopLeftAreaTouch =' + this.isTopLeftAreaTouch + ' this.isTopRightAreaTouch =' + this.isTopRightAreaTouch + + ' this.isBottomLeftAreaTouch=' + this.isBottomLeftAreaTouch + ' isBottomRightAreaTouch' + this.isBottomRightAreaTouch) + + // 再判断是否落在裁剪框4个边框范围 + if (!this.isTopLeftAreaTouch && !this.isBottomLeftAreaTouch && !this.isTopRightAreaTouch && !this.isBottomRightAreaTouch) { + console.log('PMC L1') + this.isTopLineAreaTouch = this.lineBelonged(this.topLineArea) + console.log('PMC L2') + this.isLeftLineAreaTouch = this.lineBelonged(this.leftLineArea) + console.log('PMC L3') + this.isRightLineAreaTouch = this.lineBelonged(this.rightLineArea) + console.log('PMC L4') + this.isBottomLineAreaTouch = this.lineBelonged(this.bottomLineArea) + + console.log('PMC result this.isTopLineAreaTouch =' + this.isTopLineAreaTouch + ' this.isLeftLineAreaTouch =' + this.isLeftLineAreaTouch + + ' this.isRightLineAreaTouch=' + this.isRightLineAreaTouch + ' isBottomLineAreaTouch' + this.isBottomLineAreaTouch) + + } + if (!this.isTopLeftAreaTouch && !this.isBottomLeftAreaTouch && !this.isTopRightAreaTouch && !this.isBottomRightAreaTouch + && !this.isTopLineAreaTouch && !this.isLeftLineAreaTouch && !this.isRightLineAreaTouch && !this.isBottomLineAreaTouch + ) { + this.belongMoveTouch(); + } + } + + // 最后的其他位置都是整体平移整个裁剪框 + } + + resetTouch() { + this.isValidTouch = false; + + this.isTopLeftAreaTouch = false; + this.isTopRightAreaTouch = false; + this.isBottomLeftAreaTouch = false; + this.isBottomRightAreaTouch = false; + + this.isTopLineAreaTouch = false; + this.isLeftLineAreaTouch = false; + this.isRightLineAreaTouch = false; + this.isBottomLineAreaTouch = false; + + this.isMoveTouch = false; + } + + isBelongCropBox() { + + let x0 = this.topLeftPoint[0]; + let y0 = this.topLeftPoint[1]; + + let x1 = this.bottomRightPoint[0]; + let y1 = this.bottomRightPoint[1]; + + if (this.downX >= x0 && this.downX <= x1 && this.downY >= y0 && this.downY <= y1) { + this.isValidTouch = true; + } else { + this.isValidTouch = false; + } + + } + + belongMoveTouch() { + + let x0 = this.topLeftPoint[0] + this.MIN_LENGTH / 2; + let y0 = this.topLeftPoint[1] + this.MIN_LENGTH / 2; + + let x1 = this.bottomRightPoint[0] - this.MIN_LENGTH / 2; + let y1 = this.bottomRightPoint[1] - this.MIN_LENGTH / 2; + + if (this.downX > x0 && this.downX < x1 && this.downY > y0 && this.downY < y1) { + this.isMoveTouch = true; + } else { + this.isMoveTouch = false; + } + + } + + lineBelonged(area: number[]) { + + let x0 = area[0]; + let y0 = area[1]; + + let x1 = area[2]; + let y1 = area[3]; + + if (this.downX > x0 && this.downX < x1 && this.downY > y0 && this.downY < y1) { + return true; + } + return false; + } + + connerBelonged(area: number[]): boolean { + + let x0 = area[0]; + let y0 = area[1]; + + let x1 = area[2]; + let y1 = area[3]; + console.log('PMC downx=' + this.downX + ' downY' + this.downY + ' x0=' + x0 + ' y0=' + y0 + ' x1=' + x1 + ' y1=' + y1) + if (this.downX >= x0 && this.downX <= x1 && this.downY >= y0 && this.downY <= y1) { + console.log('PMC conner is belonged!') + return true + } + return false; + } +} + +namespace PixelMapCrop { + + + export class Options { + width: number; + height: number; + pixelMap: PixelMap; + + // 是否需要绘制线 + hasGuideLine: boolean; + pixelBuffer: ArrayBuffer; + // 展示pixel宽度 + pixelWidth: number; + // 展示pixel高度 + pixelHeight: number; + // 缩放scale:center-inside类型缩放的比例 + pixelScale: number; + + // 用户裁剪后的回调 + cropFunction: Function; + + // 本地裁剪框 回调 + cropAction: Function; + + constructor() { + + } + + // 裁剪动作 + setCropFunction(crop: (error, pixelmap, sx, sy) => void) { + this.cropFunction = crop; + + this.cropAction = (topLeftPoint, bottomRightPoint, scaleInside) => { + let dx = vp2px(1) * topLeftPoint[0] * 1.0 / scaleInside; + let dy = vp2px(1) * topLeftPoint[1] * 1.0 / scaleInside; + let sx = vp2px(1) * (bottomRightPoint[0] - topLeftPoint[0]) * 1.0 / scaleInside; + let sy = vp2px(1) * (bottomRightPoint[1] - topLeftPoint[1]) * 1.0 / scaleInside; + Crop.crop(this.pixelBuffer, dx, dy, sx, sy, (error, pixelmap) => { + this.cropFunction(error, pixelmap, sx, sy) + }, 1); + } + + return this; + } + + setWidth(imageWidth: number) { + this.width = imageWidth; + return this; + } + + setHeight(imageHeight: number) { + this.height = imageHeight; + return this; + } + + setGuideLine(guideLine: boolean) { + this.hasGuideLine = guideLine; + } + + getGuideLine() { + return this.hasGuideLine; + } + + async loadBuffer(buffer: ArrayBuffer, readyCrop: Function) { + if (!buffer || buffer.byteLength <= 0) { + console.log('PixelMapCrop "loadBuffer" method buf is empty'); + return; + } + + //数据赋值 + this.pixelBuffer = buffer; + + let imageSource = image.createImageSource(buffer as any); + imageSource.getImageInfo().then((imageInfo) => { + //获取宽高 + + let scaleInside = 1; + + if (this.width && this.height) { + //center_inside 模式判断 + let scaleW = imageInfo.size.width / (this.width * 1.0) + let scaleH = imageInfo.size.height / (this.height * 1.0) + if (scaleH > 1 || scaleW > 1) { + scaleInside = 1.0 / Math.max(scaleW, scaleH) + } + + } else { + this.width = imageInfo.size.width; + this.height = imageInfo.size.height; + } + this.pixelScale = scaleInside; + this.pixelWidth = imageInfo.size.width * scaleInside; + this.pixelHeight = imageInfo.size.height * scaleInside; + + let options = { + editable: true, + rotate: 0, + desiredSize: { + width: imageInfo.size.width * scaleInside, + height: imageInfo.size.height * scaleInside, + } + } + imageSource.createPixelMap(options).then((pixelmap) => { + this.pixelMap = pixelmap; + if (readyCrop) { + readyCrop(); + } + }) + + }); + + } + } +} + +export default PixelMapCrop; diff --git a/imageknife/src/main/ets/components/imageknife/networkmanage/DownloadClient.ets b/imageknife/src/main/ets/components/imageknife/networkmanage/DownloadClient.ets index f4713c6..765d98d 100644 --- a/imageknife/src/main/ets/components/imageknife/networkmanage/DownloadClient.ets +++ b/imageknife/src/main/ets/components/imageknife/networkmanage/DownloadClient.ets @@ -13,122 +13,107 @@ * limitations under the License. */ -import {IDataFetch} from "../networkmanage/IDataFetch" -import {RequestOption} from "../RequestOption" -import {Md5} from "../../cache/Md5" -import{FileUtils} from "../../cache/FileUtils" - +import { IDataFetch } from "../networkmanage/IDataFetch" +import { RequestOption } from "../RequestOption" +import { Md5 } from "../../cache/Md5" +import { FileUtils } from "../../cache/FileUtils" import loadRequest from '@ohos.request'; export class DownloadClient implements IDataFetch { loadData(request: RequestOption, onCompleteFunction, onErrorFunction) { - let requestUrl = request.loadSrc as string; - if (requestUrl.startsWith("http") || requestUrl.startsWith("https")) { - let filename = Md5.hashStr(request.generateDataKey); - let downloadFolder = request.getFilesPath() + "/" + request.networkCacheFolder; - let allpath = request.getFilesPath() + "/" + request.networkCacheFolder + "/" + filename + ".img"; + let filename = Md5.hashStr(request.generateDataKey); + let downloadFolder = request.getFilesPath() + "/" + request.networkCacheFolder; + let allpath = request.getFilesPath() + "/" + request.networkCacheFolder + "/" + filename + ".img"; - if (!FileUtils.getInstance().existFolder(downloadFolder)) { - FileUtils.getInstance().createFolder(downloadFolder) - } + if (!FileUtils.getInstance().existFolder(downloadFolder)) { + FileUtils.getInstance().createFolder(downloadFolder) + } - if (FileUtils.getInstance().exist(allpath)) { - FileUtils.getInstance().deleteFile(allpath) - } + if (FileUtils.getInstance().exist(allpath)) { + FileUtils.getInstance().deleteFile(allpath) + } - let desc = filename + ".img"; + let desc = filename + ".img"; + var downloadConfig = { + url: (request.loadSrc as string), + filePath: allpath, + }; - var downloadConfig = { - url: (request.loadSrc as string), - filePath: allpath, - header: {}, - enableMetered: true, - enableRoaming: true, - description: desc, - networkType: 1, - title: filename, - }; + let loadTask = null; + loadRequest.download(globalThis.ImageKnife.getImageKnifeContext(), downloadConfig).then(downloadTask => { + if (downloadTask) { + loadTask = downloadTask; - let loadTask = null; - loadRequest.download(downloadConfig, (err, downloadTask) =>{ - if(err){ - onErrorFunction(err) - }else { - if (downloadTask) { - loadTask = downloadTask; + loadTask.on('progress', (receivedSize, totalSize) => { + let percent = Math.round(((receivedSize * 1.0) / (totalSize * 1.0)) * 100) + "%" + if (request.progressFunc) { + request.progressFunc(percent); + } + }); - loadTask.on('progress', (err, receivedSize, totalSize) => { - let percent = Math.round(((receivedSize * 1.0) / (totalSize * 1.0)) * 100) + "%" - if (request.progressFunc) { - request.progressFunc(percent); - } - }); + loadTask.on('complete', () => { + let downloadPath = allpath; + request.downloadFilePath = downloadPath; + let arraybuffer = FileUtils.getInstance().readFilePic(downloadPath) + onCompleteFunction(arraybuffer); + FileUtils.getInstance().deleteFile(downloadPath); - loadTask.on('complete', () => { - let downloadPath = allpath; - request.downloadFilePath = downloadPath; - let arraybuffer = FileUtils.getInstance().readFilePic(downloadPath) - onCompleteFunction(arraybuffer); - FileUtils.getInstance().deleteFile(downloadPath); + loadTask.off('complete', () => { - loadTask.off('complete', () => { - loadTask = null; - }) + }) - loadTask.off('pause', () => { - }) + loadTask.off('pause', () => { + }) - loadTask.off('remove', () => { - }) + loadTask.off('remove', () => { + }) - loadTask.off('progress', () => { - }) + loadTask.off('progress', () => { + }) - loadTask.off('fail', () => { - }) - }) - - loadTask.on('pause', () => { - }) - - loadTask.on('remove', () => { - }) - - loadTask.on('fail', (err) => { - onErrorFunction('DownloadClient Download task fail err =' + err) - if (loadTask) { - loadTask.remove().then(result => { - loadTask.off('complete', () => { - }) - - loadTask.off('pause', () => { - }) - - loadTask.off('remove', () => { - }) - - loadTask.off('progress', () => { - }) - - loadTask.off('fail', () => { - }) - loadTask = null - }).catch(err => { - loadTask = null; - console.log('DownloadClient Download task fail err =' + err); - }) - } - }) - - } else { - onErrorFunction('DownloadClient downloadTask dismiss!') - } - } + loadTask.off('fail', () => { + }) + loadTask = null; }) - } else { - onErrorFunction("DownloadClient 暂不支持除http之外的uri加载") - } + loadTask.on('pause', () => { + }) + + loadTask.on('remove', () => { + }) + + loadTask.on('fail', (err) => { + onErrorFunction('DownloadClient Download task fail err =' + err) + if (loadTask) { + loadTask.remove().then(result => { + loadTask.off('complete', () => { + }) + + loadTask.off('pause', () => { + }) + + loadTask.off('remove', () => { + }) + + loadTask.off('progress', () => { + }) + + loadTask.off('fail', () => { + }) + loadTask = null + }).catch(err => { + loadTask = null; + console.log('DownloadClient Download task fail err =' + err); + }) + } + }) + + } else { + onErrorFunction('DownloadClient downloadTask dismiss!') + } + }).catch((err) => { + onErrorFunction(err) + }) } } \ No newline at end of file diff --git a/imageknife/src/main/ets/components/imageknife/pngj/Pngj.ets b/imageknife/src/main/ets/components/imageknife/pngj/Pngj.ets index 05ac328..1b726c5 100644 --- a/imageknife/src/main/ets/components/imageknife/pngj/Pngj.ets +++ b/imageknife/src/main/ets/components/imageknife/pngj/Pngj.ets @@ -16,7 +16,6 @@ import {UPNG} from '../pngj/UPNG'; import {PngCallback} from '../pngj/PngCallback'; import image from '@ohos.multimedia.image'; import resourceManager from '@ohos.resourceManager'; -import featureability from '@ohos.ability.featureAbility' import ArkWorker from '@ohos.worker' export class Pngj { @@ -60,17 +59,16 @@ export class Pngj { callback(pngBuffer, newPng); } - readPngImageAsync(worker:ArkWorker.Worker, pngBuffer: ArrayBuffer, callback:PngCallback){ - - worker.onerror = function(data){ + readPngImageAsync(worker: any, pngBuffer: ArrayBuffer, callback: PngCallback) { + worker.onerror = function (data) { } - worker.onmessageerror = function(e){ + worker.onmessageerror = function (e) { } - worker.onexit = function(){ + worker.onexit = function () { } @@ -85,24 +83,20 @@ export class Pngj { } worker.terminate(); } - - var obj = { type: 'readPngImageAsync', data:pngBuffer} + var obj = { type: 'readPngImageAsync', data: pngBuffer } worker.postMessage(obj, [pngBuffer]) - } - - writePngWithStringAsync(worker:ArkWorker.Worker,addInfo:string, pngBuffer:ArrayBuffer, callback:PngCallback) { - - worker.onerror = function(data){ + writePngWithStringAsync(worker: any, addInfo: string, pngBuffer: ArrayBuffer, callback: PngCallback) { + worker.onerror = function (data) { } - worker.onmessageerror = function(e){ + worker.onmessageerror = function (e) { } - worker.onexit = function(){ + worker.onexit = function () { } @@ -123,18 +117,16 @@ export class Pngj { } - - writePngAsync(worker:ArkWorker.Worker,pngBuffer:ArrayBuffer, callback:PngCallback) { - - worker.onerror = function(data){ + writePngAsync(worker: any, pngBuffer: ArrayBuffer, callback: PngCallback) { + worker.onerror = function (data) { } - worker.onmessageerror = function(e){ + worker.onmessageerror = function (e) { } - worker.onexit = function(){ + worker.onexit = function () { } diff --git a/imageknife/src/main/ets/components/imageknife/requestmanage/DiskCacheProxy.ets b/imageknife/src/main/ets/components/imageknife/requestmanage/DiskCacheProxy.ets index 4da069b..38ba6ea 100644 --- a/imageknife/src/main/ets/components/imageknife/requestmanage/DiskCacheProxy.ets +++ b/imageknife/src/main/ets/components/imageknife/requestmanage/DiskCacheProxy.ets @@ -13,8 +13,8 @@ * limitations under the License. */ -import {ICache} from "../requestmanage/ICache" -import {DiskLruCache} from "../../cache/DiskLruCache" +import { ICache } from "../requestmanage/ICache" +import { DiskLruCache } from "@ohos/disklrucache" export class DiskCacheProxy implements ICache { private mDiskLruCache: DiskLruCache; @@ -29,7 +29,7 @@ export class DiskCacheProxy implements ICache { } getCachePath():string{ - let folderPath = this.mDiskLruCache.dirPath + let folderPath = this.mDiskLruCache.getPath(); if (folderPath.endsWith('/')) { return folderPath; } else { @@ -38,11 +38,11 @@ export class DiskCacheProxy implements ICache { } getValue(key: string): ArrayBuffer{ - return this.mDiskLruCache.getCacheDataByKey(key); + return this.mDiskLruCache.get(key); } - putValue(key: string, value: ArrayBuffer) { - this.mDiskLruCache.putCacheData(key, value, null) + async putValue(key: string, value: ArrayBuffer) { + await this.mDiskLruCache.setAsync(key, value) } removeValue(key: string): ArrayBuffer{ diff --git a/imageknife/src/main/ets/components/imageknife/requestmanage/MemoryCacheProxy.ets b/imageknife/src/main/ets/components/imageknife/requestmanage/MemoryCacheProxy.ets index 691404d..7752c2e 100644 --- a/imageknife/src/main/ets/components/imageknife/requestmanage/MemoryCacheProxy.ets +++ b/imageknife/src/main/ets/components/imageknife/requestmanage/MemoryCacheProxy.ets @@ -29,7 +29,6 @@ export class MemoryCacheProxy implements ICache { } getValue(key: K): V{ - console.log("Level1MemoryCache getValue come in!"); return this.mLruCache.get(key); } diff --git a/imageknife/src/main/ets/components/imageknife/requestmanage/RequstManager.ets b/imageknife/src/main/ets/components/imageknife/requestmanage/RequstManager.ets index a3573d8..c55fc47 100644 --- a/imageknife/src/main/ets/components/imageknife/requestmanage/RequstManager.ets +++ b/imageknife/src/main/ets/components/imageknife/requestmanage/RequstManager.ets @@ -13,9 +13,9 @@ * limitations under the License. */ -import {RequestOption} from "../../imageknife/RequestOption" -import {DiskLruCache} from "../../cache/DiskLruCache" -import {LruCache} from "../../cache/LruCache" +import { RequestOption } from "../../imageknife/RequestOption" +import { DiskLruCache } from "@ohos/disklrucache" +import { LruCache } from "../../cache/LruCache" import {FileUtils} from "../../cache/FileUtils" import {Md5} from "../../cache/Md5" import{MemoryCacheProxy} from "../requestmanage/MemoryCacheProxy" @@ -485,8 +485,8 @@ export class RequestManager { new Promise((resolve, reject) => { resolve(source) }) - .then((arraybuffer: ArrayBuffer) => { - this.mDiskCacheProxy.putValue(this.options.generateDataKey, arraybuffer) + .then(async (arraybuffer: ArrayBuffer) => { + await this.mDiskCacheProxy.putValue(this.options.generateDataKey, arraybuffer) }) .catch((err) => { console.log("save diskLruCache error=" + err); @@ -541,18 +541,18 @@ export class RequestManager { return imageKnifeData; } - private saveCacheAndDisk(value: PixelMap, filetype:string, onComplete, source:ArrayBuffer){ + private saveCacheAndDisk(value: PixelMap, filetype:string, onComplete, source:ArrayBuffer) { let imageKnifeData = this.createImageKnifeData(ImageKnifeData.PIXELMAP, value, filetype); this.mMemoryCacheProxy.putValue(this.options.generateCacheKey, imageKnifeData); - let save2DiskCache = (arraybuffer) => { - this.mDiskCacheProxy.putValue(this.options.generateDataKey, arraybuffer) - } + let save2DiskCache = async (arraybuffer) => { + await this.mDiskCacheProxy.putValue(this.options.generateDataKey, arraybuffer) + } let runSave2Disk = (resolve, reject) => { resolve(source); - } + } let promise = new Promise(runSave2Disk); - promise.then(save2DiskCache); - onComplete(imageKnifeData); + promise.then(save2DiskCache); + onComplete(imageKnifeData); } thumbnailProcess(source:ArrayBuffer, filetype:string, onComplete, onError){ diff --git a/imageknife/src/main/ets/components/imageknife/resourcemanage/ParseResClient.ets b/imageknife/src/main/ets/components/imageknife/resourcemanage/ParseResClient.ets index ab6b314..ddcd37c 100644 --- a/imageknife/src/main/ets/components/imageknife/resourcemanage/ParseResClient.ets +++ b/imageknife/src/main/ets/components/imageknife/resourcemanage/ParseResClient.ets @@ -23,16 +23,14 @@ export class ParseResClient implements IResourceFetch { let resId = res.id; let resType = res.type; if (resType == ResourceTypeEts.MEDIA) { - resourceManager.getResourceManager() - .then(result => { - result.getMedia(resId) - .then(data => { - let arrayBuffer = this.typedArrayToBuffer(data); - onCompleteFunction(arrayBuffer) - }) - .catch(err => { - onErrorFunction(err) - }) + globalThis.ImageKnife.getImageKnifeContext().resourceManager + .getMedia(resId) + .then(data => { + let arrayBuffer = this.typedArrayToBuffer(data); + onCompleteFunction(arrayBuffer) + }) + .catch(err => { + onErrorFunction(err) }) } else if (resType == ResourceTypeEts.RAWFILE) { diff --git a/imageknife/src/main/ets/components/imageknife/resourcemanage/ParseResClientBase64.ets b/imageknife/src/main/ets/components/imageknife/resourcemanage/ParseResClientBase64.ets index 2ff7d02..fb75c14 100644 --- a/imageknife/src/main/ets/components/imageknife/resourcemanage/ParseResClientBase64.ets +++ b/imageknife/src/main/ets/components/imageknife/resourcemanage/ParseResClientBase64.ets @@ -24,21 +24,19 @@ export class ParseResClientBase64 implements IResourceFetch { let resId = res.id; let resType = res.type; if (resType == ResourceTypeEts.MEDIA) { - resourceManager.getResourceManager() - .then(result => { - result.getMediaBase64(resId) - .then(data => { - let matchReg = ';base64,'; - var firstIndex = data.indexOf(matchReg) - data = data.substring(firstIndex + matchReg.length, data.length) - let arrayBuffer = Base64.getInstance() - .decode(data); - onCompleteFunction(arrayBuffer) - }) - .catch(err => { - onErrorFunction(err) - }) + globalThis.ImageKnife.getImageKnifeContext().resourceManager + .getMediaBase64(resId) + .then(data => { + let matchReg = ';base64,'; + var firstIndex = data.indexOf(matchReg) + data = data.substring(firstIndex + matchReg.length, data.length) + let arrayBuffer = Base64.getInstance() + .decode(data); + onCompleteFunction(arrayBuffer) }) + .catch(err => { + onErrorFunction(err) + }) } else if (resType == ResourceTypeEts.RAWFILE) { onErrorFunction('ParseResClientBase64 本地资源是rawfile暂时无法解析出错') diff --git a/imageknife/src/main/ets/components/imageknife/transform/BlurTransformation.ets b/imageknife/src/main/ets/components/imageknife/transform/BlurTransformation.ets index 118b7f5..5a84076 100644 --- a/imageknife/src/main/ets/components/imageknife/transform/BlurTransformation.ets +++ b/imageknife/src/main/ets/components/imageknife/transform/BlurTransformation.ets @@ -13,13 +13,13 @@ * limitations under the License. */ -import {BaseTransform} from "../transform/BaseTransform.ets" -import {AsyncTransform} from "../transform/AsyncTransform.ets" -import {Constants} from "../constants/Constants.ets" -import {RequestOption} from "../../imageknife/RequestOption.ets" -import {TransformUtils} from "../transform/TransformUtils.ets" +import { BaseTransform } from "../transform/BaseTransform" +import { AsyncTransform } from "../transform/AsyncTransform" +import { Constants } from "../constants/Constants" +import { RequestOption } from "../../imageknife/RequestOption" +import { TransformUtils } from "../transform/TransformUtils" import image from "@ohos.multimedia.image" -import {fastBlur} from "../utils/FastBlur" +import { fastBlur } from "../utils/FastBlur" export class BlurTransformation implements BaseTransform { diff --git a/imageknife/src/main/ets/components/imageknife/transform/BrightnessFilterTransformation.ets b/imageknife/src/main/ets/components/imageknife/transform/BrightnessFilterTransformation.ets index bbd837d..6afc66b 100644 --- a/imageknife/src/main/ets/components/imageknife/transform/BrightnessFilterTransformation.ets +++ b/imageknife/src/main/ets/components/imageknife/transform/BrightnessFilterTransformation.ets @@ -13,10 +13,10 @@ * limitations under the License. */ -import {BaseTransform} from "../transform/BaseTransform.ets" -import {AsyncTransform} from "../transform/AsyncTransform.ets" -import {Constants} from "../constants/Constants.ets" -import {RequestOption} from "../../imageknife/RequestOption.ets" +import { BaseTransform } from "../transform/BaseTransform" +import { AsyncTransform } from "../transform/AsyncTransform" +import { Constants } from "../constants/Constants" +import { RequestOption } from "../../imageknife/RequestOption" import image from "@ohos.multimedia.image" @@ -24,7 +24,7 @@ import image from "@ohos.multimedia.image" * brightness value ranges from -1.0 to 1.0, with 0.0 as the normal level */ export class BrightnessFilterTransformation implements BaseTransform { - private _mBrightness: number= 0.0; + private _mBrightness: number = 0.0; constructor(brightness: number) { this._mBrightness = brightness; diff --git a/imageknife/src/main/ets/components/imageknife/transform/ContrastFilterTransformation.ets b/imageknife/src/main/ets/components/imageknife/transform/ContrastFilterTransformation.ets index 2eb7800..33956ce 100644 --- a/imageknife/src/main/ets/components/imageknife/transform/ContrastFilterTransformation.ets +++ b/imageknife/src/main/ets/components/imageknife/transform/ContrastFilterTransformation.ets @@ -13,10 +13,10 @@ * limitations under the License. */ -import {BaseTransform} from "../transform/BaseTransform.ets" -import {AsyncTransform} from "../transform/AsyncTransform.ets" -import {Constants} from "../constants/Constants.ets" -import {RequestOption} from "../../imageknife/RequestOption.ets" +import { BaseTransform } from "../transform/BaseTransform" +import { AsyncTransform } from "../transform/AsyncTransform" +import { Constants } from "../constants/Constants" +import { RequestOption } from "../../imageknife/RequestOption" import image from "@ohos.multimedia.image" diff --git a/imageknife/src/main/ets/components/imageknife/transform/CropCircleTransformation.ets b/imageknife/src/main/ets/components/imageknife/transform/CropCircleTransformation.ets index 6bec794..6d64065 100644 --- a/imageknife/src/main/ets/components/imageknife/transform/CropCircleTransformation.ets +++ b/imageknife/src/main/ets/components/imageknife/transform/CropCircleTransformation.ets @@ -13,18 +13,18 @@ * limitations under the License. */ -import {BaseTransform} from "../transform/BaseTransform.ets" -import {AsyncTransform} from "../transform/AsyncTransform.ets" -import {Constants} from "../constants/Constants.ets" -import {RequestOption} from "../../imageknife/RequestOption.ets" -import {TransformUtils} from "../transform/TransformUtils.ets" +import { BaseTransform } from "../transform/BaseTransform" +import { AsyncTransform } from "../transform/AsyncTransform" +import { Constants } from "../constants/Constants" +import { RequestOption } from "../../imageknife/RequestOption" +import { TransformUtils } from "../transform/TransformUtils" import image from "@ohos.multimedia.image" export class CropCircleTransformation implements BaseTransform { - private static TAG: string= "CropCircleTransformation"; - private mCenterX: number= 0; - private mCenterY: number= 0; - private mRadius: number= 0; + private static TAG: string = "CropCircleTransformation"; + private mCenterX: number = 0; + private mCenterY: number = 0; + private mRadius: number = 0; getName() { return CropCircleTransformation.TAG + ";mCenterX:" + this.mCenterX diff --git a/imageknife/src/main/ets/components/imageknife/transform/CropCircleWithBorderTransformation.ets b/imageknife/src/main/ets/components/imageknife/transform/CropCircleWithBorderTransformation.ets index 7024890..86495f1 100644 --- a/imageknife/src/main/ets/components/imageknife/transform/CropCircleWithBorderTransformation.ets +++ b/imageknife/src/main/ets/components/imageknife/transform/CropCircleWithBorderTransformation.ets @@ -13,21 +13,21 @@ * limitations under the License. */ -import {BaseTransform} from "../transform/BaseTransform.ets" -import {AsyncTransform} from "../transform/AsyncTransform.ets" -import {Constants} from "../constants/Constants.ets" -import {RequestOption} from "../../imageknife/RequestOption.ets" -import {TransformUtils} from "../transform/TransformUtils.ets" +import { BaseTransform } from "../transform/BaseTransform" +import { AsyncTransform } from "../transform/AsyncTransform" +import { Constants } from "../constants/Constants" +import { RequestOption } from "../../imageknife/RequestOption" +import { TransformUtils } from "../transform/TransformUtils" import image from "@ohos.multimedia.image" export class CropCircleWithBorderTransformation implements BaseTransform { - private static TAG: string= "CropCircleTransformation"; - private mBorderSize: number= 5; - private mCenterX: number= 0; - private mCenterY: number= 0; - private mRadius: number= 0; - private mRColor: number= 0; - private mGColor: number= 0; + private static TAG: string = "CropCircleTransformation"; + private mBorderSize: number = 5; + private mCenterX: number = 0; + private mCenterY: number = 0; + private mRadius: number = 0; + private mRColor: number = 0; + private mGColor: number = 0; private mBColor: number= 0; constructor(border_size: number, value: { diff --git a/imageknife/src/main/ets/components/imageknife/transform/CropSquareTransformation.ets b/imageknife/src/main/ets/components/imageknife/transform/CropSquareTransformation.ets index 8c3f3e8..63b7b21 100644 --- a/imageknife/src/main/ets/components/imageknife/transform/CropSquareTransformation.ets +++ b/imageknife/src/main/ets/components/imageknife/transform/CropSquareTransformation.ets @@ -13,15 +13,15 @@ * limitations under the License. */ -import {BaseTransform} from "../transform/BaseTransform.ets" -import {AsyncTransform} from "../transform/AsyncTransform.ets" -import {Constants} from "../constants/Constants.ets" -import {RequestOption} from "../../imageknife/RequestOption.ets" +import { BaseTransform } from "../transform/BaseTransform" +import { AsyncTransform } from "../transform/AsyncTransform" +import { Constants } from "../constants/Constants" +import { RequestOption } from "../../imageknife/RequestOption" import image from "@ohos.multimedia.image" export class CropSquareTransformation implements BaseTransform { - private static TAG: string= "CropSquareTransformation"; + private static TAG: string = "CropSquareTransformation"; getName() { return CropSquareTransformation.TAG + ";CropSquareTransformation:" + this; diff --git a/imageknife/src/main/ets/components/imageknife/transform/CropTransformation.ets b/imageknife/src/main/ets/components/imageknife/transform/CropTransformation.ets index fef3a54..f06cc09 100644 --- a/imageknife/src/main/ets/components/imageknife/transform/CropTransformation.ets +++ b/imageknife/src/main/ets/components/imageknife/transform/CropTransformation.ets @@ -13,18 +13,18 @@ * limitations under the License. */ -import {BaseTransform} from "../transform/BaseTransform.ets" -import {AsyncTransform} from "../transform/AsyncTransform.ets" -import {Constants} from "../constants/Constants.ets" -import {RequestOption} from "../../imageknife/RequestOption.ets" -import {TransformUtils} from "../transform/TransformUtils.ets" +import { BaseTransform } from "../transform/BaseTransform" +import { AsyncTransform } from "../transform/AsyncTransform" +import { Constants } from "../constants/Constants" +import { RequestOption } from "../../imageknife/RequestOption" +import { TransformUtils } from "../transform/TransformUtils" import image from "@ohos.multimedia.image" export class CropTransformation implements BaseTransform { - private static TAG: string= "CropCircleTransformation"; + private static TAG: string = "CropCircleTransformation"; private mWidth: number; private mHeight: number; - private mCropType: CropType= CropType.CENTER; + private mCropType: CropType = CropType.CENTER; constructor(width: number, height: number, cropType?: CropType) { this.mWidth = width; diff --git a/imageknife/src/main/ets/components/imageknife/transform/GrayscaleTransformation.ets b/imageknife/src/main/ets/components/imageknife/transform/GrayscaleTransformation.ets index 02a437d..d146073 100644 --- a/imageknife/src/main/ets/components/imageknife/transform/GrayscaleTransformation.ets +++ b/imageknife/src/main/ets/components/imageknife/transform/GrayscaleTransformation.ets @@ -13,11 +13,11 @@ * limitations under the License. */ -import {BaseTransform} from "../transform/BaseTransform.ets" -import {AsyncTransform} from "../transform/AsyncTransform.ets" -import {Constants} from "../constants/Constants.ets" -import {RequestOption} from "../../imageknife/RequestOption.ets" -import {TransformUtils} from "../transform/TransformUtils.ets" +import { BaseTransform } from "../transform/BaseTransform" +import { AsyncTransform } from "../transform/AsyncTransform" +import { Constants } from "../constants/Constants" +import { RequestOption } from "../../imageknife/RequestOption" +import { TransformUtils } from "../transform/TransformUtils" import image from "@ohos.multimedia.image" export class GrayscaleTransformation implements BaseTransform { diff --git a/imageknife/src/main/ets/components/imageknife/transform/InvertFilterTransformation.ets b/imageknife/src/main/ets/components/imageknife/transform/InvertFilterTransformation.ets index 462121e..ccaeaca 100644 --- a/imageknife/src/main/ets/components/imageknife/transform/InvertFilterTransformation.ets +++ b/imageknife/src/main/ets/components/imageknife/transform/InvertFilterTransformation.ets @@ -13,10 +13,10 @@ * limitations under the License. */ -import {BaseTransform} from "../transform/BaseTransform.ets" -import {AsyncTransform} from "../transform/AsyncTransform.ets" -import {Constants} from "../constants/Constants.ets" -import {RequestOption} from "../../imageknife/RequestOption.ets" +import { BaseTransform } from "../transform/BaseTransform" +import { AsyncTransform } from "../transform/AsyncTransform" +import { Constants } from "../constants/Constants" +import { RequestOption } from "../../imageknife/RequestOption" import image from "@ohos.multimedia.image" /** diff --git a/imageknife/src/main/ets/components/imageknife/transform/MaskTransformation.ets b/imageknife/src/main/ets/components/imageknife/transform/MaskTransformation.ets index 273efb3..4bf6ec0 100644 --- a/imageknife/src/main/ets/components/imageknife/transform/MaskTransformation.ets +++ b/imageknife/src/main/ets/components/imageknife/transform/MaskTransformation.ets @@ -13,11 +13,11 @@ * limitations under the License. */ -import {BaseTransform} from "../transform/BaseTransform.ets" -import {AsyncTransform} from "../transform/AsyncTransform.ets" -import {Constants} from "../constants/Constants.ets" -import {RequestOption} from "../../imageknife/RequestOption.ets" -import {MaskUtils} from "../utils/MaskUtils.ets" +import { BaseTransform } from "../transform/BaseTransform" +import { AsyncTransform } from "../transform/AsyncTransform" +import { Constants } from "../constants/Constants" +import { RequestOption } from "../../imageknife/RequestOption" +import { MaskUtils } from "../utils/MaskUtils" import image from "@ohos.multimedia.image" import resmgr from "@ohos.resourceManager" diff --git a/imageknife/src/main/ets/components/imageknife/transform/PixelationFilterTransformation.ets b/imageknife/src/main/ets/components/imageknife/transform/PixelationFilterTransformation.ets index 9e55bc5..6ea204f 100644 --- a/imageknife/src/main/ets/components/imageknife/transform/PixelationFilterTransformation.ets +++ b/imageknife/src/main/ets/components/imageknife/transform/PixelationFilterTransformation.ets @@ -13,20 +13,20 @@ * limitations under the License. */ -import {BaseTransform} from "../transform/BaseTransform.ets" -import {AsyncTransform} from "../transform/AsyncTransform.ets" -import {Constants} from "../constants/Constants.ets" -import {RequestOption} from "../../imageknife/RequestOption.ets" -import {TransformUtils} from "../transform/TransformUtils.ets" +import { BaseTransform } from "../transform/BaseTransform" +import { AsyncTransform } from "../transform/AsyncTransform" +import { Constants } from "../constants/Constants" +import { RequestOption } from "../../imageknife/RequestOption" +import { TransformUtils } from "../transform/TransformUtils" import image from "@ohos.multimedia.image" -import {pixelUtils} from "../utils/PixelUtils" +import { pixelUtils } from "../utils/PixelUtils" /** * Applies a Pixelation effect to the image. * The pixel with a default of 10.0. */ export class PixelationFilterTransformation implements BaseTransform { - private _mPixel: number= 10.0; + private _mPixel: number = 10.0; constructor(pixel?: number) { if (pixel) { diff --git a/imageknife/src/main/ets/components/imageknife/transform/RotateImageTransformation.ets b/imageknife/src/main/ets/components/imageknife/transform/RotateImageTransformation.ets index ddb9c9a..3034c55 100644 --- a/imageknife/src/main/ets/components/imageknife/transform/RotateImageTransformation.ets +++ b/imageknife/src/main/ets/components/imageknife/transform/RotateImageTransformation.ets @@ -12,11 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {BaseTransform} from "../transform/BaseTransform.ets" -import {AsyncTransform} from "../transform/AsyncTransform.ets" -import {Constants} from "../constants/Constants.ets" -import {RequestOption} from "../../imageknife/RequestOption.ets" -import {TransformUtils} from "../transform/TransformUtils.ets" +import { BaseTransform } from "../transform/BaseTransform" +import { AsyncTransform } from "../transform/AsyncTransform" +import { Constants } from "../constants/Constants" +import { RequestOption } from "../../imageknife/RequestOption" +import { TransformUtils } from "../transform/TransformUtils" import image from "@ohos.multimedia.image" diff --git a/imageknife/src/main/ets/components/imageknife/transform/RoundedCornersTransformation.ets b/imageknife/src/main/ets/components/imageknife/transform/RoundedCornersTransformation.ets index 9220f5e..da5fcb3 100644 --- a/imageknife/src/main/ets/components/imageknife/transform/RoundedCornersTransformation.ets +++ b/imageknife/src/main/ets/components/imageknife/transform/RoundedCornersTransformation.ets @@ -12,20 +12,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {BaseTransform} from "../transform/BaseTransform.ets" -import {AsyncTransform} from "../transform/AsyncTransform.ets" -import {ArcPoint} from "../entry/ArcPoint.ets" -import {Constants} from "../constants/Constants.ets" -import {RequestOption} from "../../imageknife/RequestOption.ets" -import {TransformUtils} from "../transform/TransformUtils.ets" +import { BaseTransform } from "../transform/BaseTransform" +import { AsyncTransform } from "../transform/AsyncTransform" +import { ArcPoint } from "../entry/ArcPoint" +import { Constants } from "../constants/Constants" +import { RequestOption } from "../../imageknife/RequestOption" +import { TransformUtils } from "../transform/TransformUtils" import image from "@ohos.multimedia.image" export class RoundedCornersTransformation implements BaseTransform { - private mTop_left: number= 0; - private mTop_right: number= 0; - private mBottom_left: number= 0; - private mBottom_right: number= 0; + private mTop_left: number = 0; + private mTop_right: number = 0; + private mBottom_left: number = 0; + private mBottom_right: number = 0; private mTransform_pixelMap: any; private mPoint: ArcPoint[]; diff --git a/imageknife/src/main/ets/components/imageknife/transform/SepiaFilterTransformation.ets b/imageknife/src/main/ets/components/imageknife/transform/SepiaFilterTransformation.ets index de3d9e9..bca60c4 100644 --- a/imageknife/src/main/ets/components/imageknife/transform/SepiaFilterTransformation.ets +++ b/imageknife/src/main/ets/components/imageknife/transform/SepiaFilterTransformation.ets @@ -13,10 +13,10 @@ * limitations under the License. */ -import {BaseTransform} from "../transform/BaseTransform.ets" -import {AsyncTransform} from "../transform/AsyncTransform.ets" -import {Constants} from "../constants/Constants.ets" -import {RequestOption} from "../../imageknife/RequestOption.ets" +import { BaseTransform } from "../transform/BaseTransform" +import { AsyncTransform } from "../transform/AsyncTransform" +import { Constants } from "../constants/Constants" +import { RequestOption } from "../../imageknife/RequestOption" import image from "@ohos.multimedia.image" /** diff --git a/imageknife/src/main/ets/components/imageknife/transform/SketchFilterTransformation.ets b/imageknife/src/main/ets/components/imageknife/transform/SketchFilterTransformation.ets index d074c80..e6c004d 100644 --- a/imageknife/src/main/ets/components/imageknife/transform/SketchFilterTransformation.ets +++ b/imageknife/src/main/ets/components/imageknife/transform/SketchFilterTransformation.ets @@ -13,13 +13,13 @@ * limitations under the License. */ -import {BaseTransform} from '../transform/BaseTransform.ets' -import {AsyncTransform} from '../transform/AsyncTransform.ets' -import {Constants} from '../constants/Constants.ets' -import {RequestOption} from '../../imageknife/RequestOption.ets' -import {TransformUtils} from '../transform/TransformUtils.ets' +import { BaseTransform } from '../transform/BaseTransform' +import { AsyncTransform } from '../transform/AsyncTransform' +import { Constants } from '../constants/Constants' +import { RequestOption } from '../../imageknife/RequestOption' +import { TransformUtils } from '../transform/TransformUtils' import image from '@ohos.multimedia.image' -import {CalculatePixelUtils} from '../utils/CalculatePixelUtils' +import { CalculatePixelUtils } from '../utils/CalculatePixelUtils' export class SketchFilterTransformation implements BaseTransform { getName() { diff --git a/imageknife/src/main/ets/components/imageknife/transform/SwirlFilterTransformation.ets b/imageknife/src/main/ets/components/imageknife/transform/SwirlFilterTransformation.ets index 4dad54e..fd6aeea 100644 --- a/imageknife/src/main/ets/components/imageknife/transform/SwirlFilterTransformation.ets +++ b/imageknife/src/main/ets/components/imageknife/transform/SwirlFilterTransformation.ets @@ -13,15 +13,15 @@ * limitations under the License. */ -import {BaseTransform} from '../transform/BaseTransform.ets' -import {AsyncTransform} from '../transform/AsyncTransform.ets' -import {Constants} from '../constants/Constants.ets' -import {RequestOption} from '../../imageknife/RequestOption.ets' -import {TransformUtils} from '../transform/TransformUtils.ets' +import { BaseTransform } from '../transform/BaseTransform' +import { AsyncTransform } from '../transform/AsyncTransform' +import { Constants } from '../constants/Constants' +import { RequestOption } from '../../imageknife/RequestOption' +import { TransformUtils } from '../transform/TransformUtils' import image from '@ohos.multimedia.image' -import {PixelEntry} from '../entry/PixelEntry' -import {ColorUtils} from '../utils/ColorUtils' -import {CalculatePixelUtils} from '../utils/CalculatePixelUtils' +import { PixelEntry } from '../entry/PixelEntry' +import { ColorUtils } from '../utils/ColorUtils' +import { CalculatePixelUtils } from '../utils/CalculatePixelUtils' export class SwirlFilterTransformation implements BaseTransform { private _degree: number; diff --git a/imageknife/src/main/ets/components/imageknife/utils/ColorUtils.ets b/imageknife/src/main/ets/components/imageknife/utils/ColorUtils.ets index 4254369..472d342 100644 --- a/imageknife/src/main/ets/components/imageknife/utils/ColorUtils.ets +++ b/imageknife/src/main/ets/components/imageknife/utils/ColorUtils.ets @@ -12,7 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import resmgr from '@ohos.resourceManager' import {DataCallBack} from "../interface/DataCallBack" export namespace ColorUtils { @@ -22,22 +21,19 @@ export namespace ColorUtils { * ColorUtils.parseColor("color_name",callback) */ export function parseColor(c: string, callback: DataCallBack) { - resmgr.getResourceManager() - .then(result => { + var reColor = 'sys.color.' + c; - result.getString($r(reColor) - .id, (err, color) => { - if (!err) { - var cos = JSON.stringify(color); - callback.callback(cos) - } else { - callback.callback(err.message) - } - }); - }) - .catch((error) => { - callback.callback(error.message) - }) + globalThis.ImageKnife.getImageKnifeContext().resourceManager.getString($r(reColor) + .id, (err, color) => { + if (!err) { + var cos = JSON.stringify(color); + callback.callback(cos) + } else { + callback.callback(err.message) + } + }); + + } export function red(color: number): number { diff --git a/imageknife/src/main/module.json5 b/imageknife/src/main/module.json5 new file mode 100644 index 0000000..1fe0fbe --- /dev/null +++ b/imageknife/src/main/module.json5 @@ -0,0 +1,11 @@ +{ + "module": { + "name": "imageknife", + "type": "har", + "deviceTypes": [ + "default", + "tablet" + ], + "uiSyntax": "ets" + } +} diff --git a/imageknife/src/main/resources/base/element/string.json b/imageknife/src/main/resources/base/element/string.json new file mode 100644 index 0000000..1e76de0 --- /dev/null +++ b/imageknife/src/main/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from npm package" + } + ] +} diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index 336d297..0000000 --- a/package-lock.json +++ /dev/null @@ -1,1657 +0,0 @@ -{ - "name": "imageknifegiteepro", - "version": "1.0.0", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "@ohos/hvigor": { - "version": "1.0.6", - "resolved": "https://cmc.centralrepo.rnd.huawei.com/artifactory/api/npm/product_npm/@ohos/hvigor/-/@ohos/hvigor-1.0.6.tgz", - "integrity": "sha512-jjp7vpvUOMW1Nf7TdyhOtonwWHoSyBJLUiZTQqIx/GJV4UJyIqsiURUOqFwncQ4L7PDdeHuWly4uEelknYeWhg==", - "requires": { - "@ohos/hvigor-base": "1.0.6", - "interpret": "1.4.0", - "liftoff": "4.0.0", - "mute-stdout": "1.0.0", - "pretty-hrtime": "1.0.0", - "v8flags": "3.2.0", - "yargs": "7.1.0" - } - }, - "@ohos/hvigor-base": { - "version": "1.0.6", - "resolved": "https://cmc.centralrepo.rnd.huawei.com/artifactory/api/npm/product_npm/@ohos/hvigor-base/-/@ohos/hvigor-base-1.0.6.tgz", - "integrity": "sha512-cRDnWICTxmpNiFb9clIioqP5Oik1seLCICztXVhZqultrHuxwTheCRUZrHwlpyWdkSB2Al+FFBqmSwzIgZX4IQ==", - "requires": { - "json5": "2.2.0", - "log4js": "6.4.1", - "undertaker": "1.2.1" - } - }, - "@ohos/hvigor-ohos-plugin": { - "version": "1.0.6", - "resolved": "https://cmc.centralrepo.rnd.huawei.com/artifactory/api/npm/product_npm/@ohos/hvigor-ohos-plugin/-/@ohos/hvigor-ohos-plugin-1.0.6.tgz", - "integrity": "sha512-MAAi8uJxMzODUoSSNfBr+fU4HQ20dfQtkje9I+X4asc7qY2kAplW/q9f5XS8IOvv8zhC8OcSgsAXOAJuLMstOQ==", - "requires": { - "@ohos/hvigor-base": "1.0.6", - "@ohos/sdkmanager-common": "1.1.3", - "ajv": "8.10.0", - "archiver": "5.3.0", - "execa": "5.1.1", - "fs-extra": "10.0.0", - "glob": "7.2.0", - "iconv-lite": "0.6.3", - "json5": "2.2.0", - "lodash": "4.17.21", - "pretty-hrtime": "1.0.3", - "resolve-package-path": "4.0.3" - }, - "dependencies": { - "fs-extra": { - "version": "10.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/fs-extra/-/fs-extra-10.0.0.tgz", - "integrity": "sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==", - "requires": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - } - }, - "pretty-hrtime": { - "version": "1.0.3", - "resolved": "http://mirrors.tools.huawei.com/npm/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz", - "integrity": "sha1-t+PqQkNaTJsnWdmeDyAesZWALuE=" - } - } - }, - "@ohos/sdkmanager-common": { - "version": "1.1.3", - "resolved": "https://cmc.centralrepo.rnd.huawei.com/artifactory/api/npm/product_npm/@ohos/sdkmanager-common/-/@ohos/sdkmanager-common-1.1.3.tgz", - "integrity": "sha512-d2uhVauDDJZIUvyyaWWoavG4N/jLyfF5IH5kEXKV6R8HNf3606H1zDQzA+UZtOfwwJFXhD9djRjnVFNB8xc7aw==" - }, - "ajv": { - "version": "8.10.0", - "resolved": "http://mirrors.tools.huawei.com/npm/ajv/-/ajv-8.10.0.tgz", - "integrity": "sha512-bzqAEZOjkrUMl2afH8dknrq5KEk2SrwdBROR+vH1EKVQTqaUbJVPdc/gEdggTMM0Se+s+Ja4ju4TlNcStKl2Hw==", - "requires": { - "fast-deep-equal": "^3.1.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2", - "uri-js": "^4.2.2" - } - }, - "ansi-regex": { - "version": "2.1.1", - "resolved": "http://mirrors.tools.huawei.com/npm/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" - }, - "archiver": { - "version": "5.3.0", - "resolved": "http://mirrors.tools.huawei.com/npm/archiver/-/archiver-5.3.0.tgz", - "integrity": "sha512-iUw+oDwK0fgNpvveEsdQ0Ase6IIKztBJU2U0E9MzszMfmVVUyv1QJhS2ITW9ZCqx8dktAxVAjWWkKehuZE8OPg==", - "requires": { - "archiver-utils": "^2.1.0", - "async": "^3.2.0", - "buffer-crc32": "^0.2.1", - "readable-stream": "^3.6.0", - "readdir-glob": "^1.0.0", - "tar-stream": "^2.2.0", - "zip-stream": "^4.1.0" - } - }, - "archiver-utils": { - "version": "2.1.0", - "resolved": "http://mirrors.tools.huawei.com/npm/archiver-utils/-/archiver-utils-2.1.0.tgz", - "integrity": "sha512-bEL/yUb/fNNiNTuUz979Z0Yg5L+LzLxGJz8x79lYmR54fmTIb6ob/hNQgkQnIUDWIFjZVQwl9Xs356I6BAMHfw==", - "requires": { - "glob": "^7.1.4", - "graceful-fs": "^4.2.0", - "lazystream": "^1.0.0", - "lodash.defaults": "^4.2.0", - "lodash.difference": "^4.5.0", - "lodash.flatten": "^4.4.0", - "lodash.isplainobject": "^4.0.6", - "lodash.union": "^4.6.0", - "normalize-path": "^3.0.0", - "readable-stream": "^2.0.0" - }, - "dependencies": { - "readable-stream": { - "version": "2.3.7", - "resolved": "http://mirrors.tools.huawei.com/npm/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - } - } - }, - "arr-filter": { - "version": "1.1.2", - "resolved": "http://mirrors.tools.huawei.com/npm/arr-filter/-/arr-filter-1.1.2.tgz", - "integrity": "sha1-Q/3d0JHo7xGqTEXZzcGOLf8XEe4=", - "requires": { - "make-iterator": "^1.0.0" - } - }, - "arr-flatten": { - "version": "1.1.0", - "resolved": "http://mirrors.tools.huawei.com/npm/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==" - }, - "arr-map": { - "version": "2.0.2", - "resolved": "http://mirrors.tools.huawei.com/npm/arr-map/-/arr-map-2.0.2.tgz", - "integrity": "sha1-Onc0X/wc814qkYJWAfnljy4kysQ=", - "requires": { - "make-iterator": "^1.0.0" - } - }, - "array-each": { - "version": "1.0.1", - "resolved": "http://mirrors.tools.huawei.com/npm/array-each/-/array-each-1.0.1.tgz", - "integrity": "sha1-p5SvDAWrF1KEbudTofIRoFugxE8=" - }, - "array-initial": { - "version": "1.1.0", - "resolved": "http://mirrors.tools.huawei.com/npm/array-initial/-/array-initial-1.1.0.tgz", - "integrity": "sha1-L6dLJnOTccOUe9enrcc74zSz15U=", - "requires": { - "array-slice": "^1.0.0", - "is-number": "^4.0.0" - } - }, - "array-last": { - "version": "1.3.0", - "resolved": "http://mirrors.tools.huawei.com/npm/array-last/-/array-last-1.3.0.tgz", - "integrity": "sha512-eOCut5rXlI6aCOS7Z7kCplKRKyiFQ6dHFBem4PwlwKeNFk2/XxTrhRh5T9PyaEWGy/NHTZWbY+nsZlNFJu9rYg==", - "requires": { - "is-number": "^4.0.0" - } - }, - "array-slice": { - "version": "1.1.0", - "resolved": "http://mirrors.tools.huawei.com/npm/array-slice/-/array-slice-1.1.0.tgz", - "integrity": "sha512-B1qMD3RBP7O8o0H2KbrXDyB0IccejMF15+87Lvlor12ONPRHP6gTjXMNkt/d3ZuOGbAe66hFmaCfECI24Ufp6w==" - }, - "async": { - "version": "3.2.3", - "resolved": "http://mirrors.tools.huawei.com/npm/async/-/async-3.2.3.tgz", - "integrity": "sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g==" - }, - "async-done": { - "version": "1.3.2", - "resolved": "http://mirrors.tools.huawei.com/npm/async-done/-/async-done-1.3.2.tgz", - "integrity": "sha512-uYkTP8dw2og1tu1nmza1n1CMW0qb8gWWlwqMmLb7MhBVs4BXrFziT6HXUd+/RlRA/i4H9AkofYloUbs1fwMqlw==", - "requires": { - "end-of-stream": "^1.1.0", - "once": "^1.3.2", - "process-nextick-args": "^2.0.0", - "stream-exhaust": "^1.0.1" - } - }, - "async-settle": { - "version": "1.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/async-settle/-/async-settle-1.0.0.tgz", - "integrity": "sha1-HQqRS7Aldb7IqPOnTlCA9yssDGs=", - "requires": { - "async-done": "^1.2.2" - } - }, - "bach": { - "version": "1.2.0", - "resolved": "http://mirrors.tools.huawei.com/npm/bach/-/bach-1.2.0.tgz", - "integrity": "sha1-Szzpa/JxNPeaG0FKUcFONMO9mIA=", - "requires": { - "arr-filter": "^1.1.1", - "arr-flatten": "^1.0.1", - "arr-map": "^2.0.0", - "array-each": "^1.0.0", - "array-initial": "^1.0.0", - "array-last": "^1.1.1", - "async-done": "^1.2.2", - "async-settle": "^1.0.0", - "now-and-later": "^2.0.0" - } - }, - "balanced-match": { - "version": "1.0.2", - "resolved": "http://mirrors.tools.huawei.com/npm/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" - }, - "base64-js": { - "version": "1.5.1", - "resolved": "http://mirrors.tools.huawei.com/npm/base64-js/-/base64-js-1.5.1.tgz", - "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==" - }, - "bl": { - "version": "4.1.0", - "resolved": "http://mirrors.tools.huawei.com/npm/bl/-/bl-4.1.0.tgz", - "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", - "requires": { - "buffer": "^5.5.0", - "inherits": "^2.0.4", - "readable-stream": "^3.4.0" - } - }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "http://mirrors.tools.huawei.com/npm/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "braces": { - "version": "3.0.2", - "resolved": "http://mirrors.tools.huawei.com/npm/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", - "requires": { - "fill-range": "^7.0.1" - } - }, - "buffer": { - "version": "5.7.1", - "resolved": "http://mirrors.tools.huawei.com/npm/buffer/-/buffer-5.7.1.tgz", - "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", - "requires": { - "base64-js": "^1.3.1", - "ieee754": "^1.1.13" - } - }, - "buffer-crc32": { - "version": "0.2.13", - "resolved": "http://mirrors.tools.huawei.com/npm/buffer-crc32/-/buffer-crc32-0.2.13.tgz", - "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=" - }, - "call-bind": { - "version": "1.0.2", - "resolved": "http://mirrors.tools.huawei.com/npm/call-bind/-/call-bind-1.0.2.tgz", - "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", - "requires": { - "function-bind": "^1.1.1", - "get-intrinsic": "^1.0.2" - } - }, - "camelcase": { - "version": "3.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/camelcase/-/camelcase-3.0.0.tgz", - "integrity": "sha1-MvxLn82vhF/N9+c7uXysImHwqwo=" - }, - "cliui": { - "version": "3.2.0", - "resolved": "http://mirrors.tools.huawei.com/npm/cliui/-/cliui-3.2.0.tgz", - "integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=", - "requires": { - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1", - "wrap-ansi": "^2.0.0" - } - }, - "code-point-at": { - "version": "1.1.0", - "resolved": "http://mirrors.tools.huawei.com/npm/code-point-at/-/code-point-at-1.1.0.tgz", - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" - }, - "collection-map": { - "version": "1.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/collection-map/-/collection-map-1.0.0.tgz", - "integrity": "sha1-rqDwb40mx4DCt1SUOFVEsiVa8Yw=", - "requires": { - "arr-map": "^2.0.2", - "for-own": "^1.0.0", - "make-iterator": "^1.0.0" - } - }, - "compress-commons": { - "version": "4.1.1", - "resolved": "http://mirrors.tools.huawei.com/npm/compress-commons/-/compress-commons-4.1.1.tgz", - "integrity": "sha512-QLdDLCKNV2dtoTorqgxngQCMA+gWXkM/Nwu7FpeBhk/RdkzimqC3jueb/FDmaZeXh+uby1jkBqE3xArsLBE5wQ==", - "requires": { - "buffer-crc32": "^0.2.13", - "crc32-stream": "^4.0.2", - "normalize-path": "^3.0.0", - "readable-stream": "^3.6.0" - } - }, - "concat-map": { - "version": "0.0.1", - "resolved": "http://mirrors.tools.huawei.com/npm/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" - }, - "core-util-is": { - "version": "1.0.3", - "resolved": "http://mirrors.tools.huawei.com/npm/core-util-is/-/core-util-is-1.0.3.tgz", - "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" - }, - "crc-32": { - "version": "1.2.1", - "resolved": "http://mirrors.tools.huawei.com/npm/crc-32/-/crc-32-1.2.1.tgz", - "integrity": "sha512-Dn/xm/1vFFgs3nfrpEVScHoIslO9NZRITWGz/1E/St6u4xw99vfZzVkW0OSnzx2h9egej9xwMCEut6sqwokM/w==", - "requires": { - "exit-on-epipe": "~1.0.1", - "printj": "~1.3.1" - } - }, - "crc32-stream": { - "version": "4.0.2", - "resolved": "http://mirrors.tools.huawei.com/npm/crc32-stream/-/crc32-stream-4.0.2.tgz", - "integrity": "sha512-DxFZ/Hk473b/muq1VJ///PMNLj0ZMnzye9thBpmjpJKCc5eMgB95aK8zCGrGfQ90cWo561Te6HK9D+j4KPdM6w==", - "requires": { - "crc-32": "^1.2.0", - "readable-stream": "^3.4.0" - } - }, - "cross-spawn": { - "version": "7.0.3", - "resolved": "http://mirrors.tools.huawei.com/npm/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", - "requires": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - }, - "dependencies": { - "which": { - "version": "2.0.2", - "resolved": "http://mirrors.tools.huawei.com/npm/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "requires": { - "isexe": "^2.0.0" - } - } - } - }, - "d": { - "version": "1.0.1", - "resolved": "http://mirrors.tools.huawei.com/npm/d/-/d-1.0.1.tgz", - "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==", - "requires": { - "es5-ext": "^0.10.50", - "type": "^1.0.1" - } - }, - "date-format": { - "version": "4.0.6", - "resolved": "http://mirrors.tools.huawei.com/npm/date-format/-/date-format-4.0.6.tgz", - "integrity": "sha512-B9vvg5rHuQ8cbUXE/RMWMyX2YA5TecT3jKF5fLtGNlzPlU7zblSPmAm2OImDbWL+LDOQ6pUm+4LOFz+ywS41Zw==" - }, - "debug": { - "version": "4.3.4", - "resolved": "http://mirrors.tools.huawei.com/npm/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "requires": { - "ms": "2.1.2" - } - }, - "decamelize": { - "version": "1.2.0", - "resolved": "http://mirrors.tools.huawei.com/npm/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=" - }, - "default-resolution": { - "version": "2.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/default-resolution/-/default-resolution-2.0.0.tgz", - "integrity": "sha1-vLgrqnKtebQmp2cy8aga1t8m1oQ=" - }, - "define-properties": { - "version": "1.1.3", - "resolved": "http://mirrors.tools.huawei.com/npm/define-properties/-/define-properties-1.1.3.tgz", - "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", - "requires": { - "object-keys": "^1.0.12" - } - }, - "detect-file": { - "version": "1.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/detect-file/-/detect-file-1.0.0.tgz", - "integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=" - }, - "end-of-stream": { - "version": "1.4.4", - "resolved": "http://mirrors.tools.huawei.com/npm/end-of-stream/-/end-of-stream-1.4.4.tgz", - "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", - "requires": { - "once": "^1.4.0" - } - }, - "error-ex": { - "version": "1.3.2", - "resolved": "http://mirrors.tools.huawei.com/npm/error-ex/-/error-ex-1.3.2.tgz", - "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", - "requires": { - "is-arrayish": "^0.2.1" - } - }, - "es5-ext": { - "version": "0.10.59", - "resolved": "http://mirrors.tools.huawei.com/npm/es5-ext/-/es5-ext-0.10.59.tgz", - "integrity": "sha512-cOgyhW0tIJyQY1Kfw6Kr0viu9ZlUctVchRMZ7R0HiH3dxTSp5zJDLecwxUqPUrGKMsgBI1wd1FL+d9Jxfi4cLw==", - "requires": { - "es6-iterator": "^2.0.3", - "es6-symbol": "^3.1.3", - "next-tick": "^1.1.0" - } - }, - "es6-iterator": { - "version": "2.0.3", - "resolved": "http://mirrors.tools.huawei.com/npm/es6-iterator/-/es6-iterator-2.0.3.tgz", - "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=", - "requires": { - "d": "1", - "es5-ext": "^0.10.35", - "es6-symbol": "^3.1.1" - } - }, - "es6-symbol": { - "version": "3.1.3", - "resolved": "http://mirrors.tools.huawei.com/npm/es6-symbol/-/es6-symbol-3.1.3.tgz", - "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==", - "requires": { - "d": "^1.0.1", - "ext": "^1.1.2" - } - }, - "es6-weak-map": { - "version": "2.0.3", - "resolved": "http://mirrors.tools.huawei.com/npm/es6-weak-map/-/es6-weak-map-2.0.3.tgz", - "integrity": "sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==", - "requires": { - "d": "1", - "es5-ext": "^0.10.46", - "es6-iterator": "^2.0.3", - "es6-symbol": "^3.1.1" - } - }, - "execa": { - "version": "5.1.1", - "resolved": "http://mirrors.tools.huawei.com/npm/execa/-/execa-5.1.1.tgz", - "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", - "requires": { - "cross-spawn": "^7.0.3", - "get-stream": "^6.0.0", - "human-signals": "^2.1.0", - "is-stream": "^2.0.0", - "merge-stream": "^2.0.0", - "npm-run-path": "^4.0.1", - "onetime": "^5.1.2", - "signal-exit": "^3.0.3", - "strip-final-newline": "^2.0.0" - } - }, - "exit-on-epipe": { - "version": "1.0.1", - "resolved": "http://mirrors.tools.huawei.com/npm/exit-on-epipe/-/exit-on-epipe-1.0.1.tgz", - "integrity": "sha512-h2z5mrROTxce56S+pnvAV890uu7ls7f1kEvVGJbw1OlFH3/mlJ5bkXu0KRyW94v37zzHPiUd55iLn3DA7TjWpw==" - }, - "expand-tilde": { - "version": "2.0.2", - "resolved": "http://mirrors.tools.huawei.com/npm/expand-tilde/-/expand-tilde-2.0.2.tgz", - "integrity": "sha1-l+gBqgUt8CRU3kawK/YhZCzchQI=", - "requires": { - "homedir-polyfill": "^1.0.1" - } - }, - "ext": { - "version": "1.6.0", - "resolved": "http://mirrors.tools.huawei.com/npm/ext/-/ext-1.6.0.tgz", - "integrity": "sha512-sdBImtzkq2HpkdRLtlLWDa6w4DX22ijZLKx8BMPUuKe1c5lbN6xwQDQCxSfxBQnHZ13ls/FH0MQZx/q/gr6FQg==", - "requires": { - "type": "^2.5.0" - }, - "dependencies": { - "type": { - "version": "2.6.0", - "resolved": "http://mirrors.tools.huawei.com/npm/type/-/type-2.6.0.tgz", - "integrity": "sha512-eiDBDOmkih5pMbo9OqsqPRGMljLodLcwd5XD5JbtNB0o89xZAwynY9EdCDsJU7LtcVCClu9DvM7/0Ep1hYX3EQ==" - } - } - }, - "extend": { - "version": "3.0.2", - "resolved": "http://mirrors.tools.huawei.com/npm/extend/-/extend-3.0.2.tgz", - "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" - }, - "fast-deep-equal": { - "version": "3.1.3", - "resolved": "http://mirrors.tools.huawei.com/npm/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" - }, - "fill-range": { - "version": "7.0.1", - "resolved": "http://mirrors.tools.huawei.com/npm/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", - "requires": { - "to-regex-range": "^5.0.1" - } - }, - "find-up": { - "version": "1.1.2", - "resolved": "http://mirrors.tools.huawei.com/npm/find-up/-/find-up-1.1.2.tgz", - "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", - "requires": { - "path-exists": "^2.0.0", - "pinkie-promise": "^2.0.0" - } - }, - "findup-sync": { - "version": "5.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/findup-sync/-/findup-sync-5.0.0.tgz", - "integrity": "sha512-MzwXju70AuyflbgeOhzvQWAvvQdo1XL0A9bVvlXsYcFEBM87WR4OakL4OfZq+QRmr+duJubio+UtNQCPsVESzQ==", - "requires": { - "detect-file": "^1.0.0", - "is-glob": "^4.0.3", - "micromatch": "^4.0.4", - "resolve-dir": "^1.0.1" - } - }, - "fined": { - "version": "2.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/fined/-/fined-2.0.0.tgz", - "integrity": "sha512-OFRzsL6ZMHz5s0JrsEr+TpdGNCtrVtnuG3x1yzGNiQHT0yaDnXAj8V/lWcpJVrnoDpcwXcASxAZYbuXda2Y82A==", - "requires": { - "expand-tilde": "^2.0.2", - "is-plain-object": "^5.0.0", - "object.defaults": "^1.1.0", - "object.pick": "^1.3.0", - "parse-filepath": "^1.0.2" - } - }, - "flagged-respawn": { - "version": "2.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/flagged-respawn/-/flagged-respawn-2.0.0.tgz", - "integrity": "sha512-Gq/a6YCi8zexmGHMuJwahTGzXlAZAOsbCVKduWXC6TlLCjjFRlExMJc4GC2NYPYZ0r/brw9P7CpRgQmlPVeOoA==" - }, - "flatted": { - "version": "3.2.5", - "resolved": "http://mirrors.tools.huawei.com/npm/flatted/-/flatted-3.2.5.tgz", - "integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==" - }, - "for-in": { - "version": "1.0.2", - "resolved": "http://mirrors.tools.huawei.com/npm/for-in/-/for-in-1.0.2.tgz", - "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=" - }, - "for-own": { - "version": "1.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/for-own/-/for-own-1.0.0.tgz", - "integrity": "sha1-xjMy9BXO3EsE2/5wz4NklMU8tEs=", - "requires": { - "for-in": "^1.0.1" - } - }, - "fs-constants": { - "version": "1.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/fs-constants/-/fs-constants-1.0.0.tgz", - "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" - }, - "fs-extra": { - "version": "10.0.1", - "resolved": "http://mirrors.tools.huawei.com/npm/fs-extra/-/fs-extra-10.0.1.tgz", - "integrity": "sha512-NbdoVMZso2Lsrn/QwLXOy6rm0ufY2zEOKCDzJR/0kBsb0E6qed0P3iYK+Ath3BfvXEeu4JhEtXLgILx5psUfag==", - "requires": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - } - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" - }, - "function-bind": { - "version": "1.1.1", - "resolved": "http://mirrors.tools.huawei.com/npm/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" - }, - "get-caller-file": { - "version": "1.0.3", - "resolved": "http://mirrors.tools.huawei.com/npm/get-caller-file/-/get-caller-file-1.0.3.tgz", - "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==" - }, - "get-intrinsic": { - "version": "1.1.1", - "resolved": "http://mirrors.tools.huawei.com/npm/get-intrinsic/-/get-intrinsic-1.1.1.tgz", - "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", - "requires": { - "function-bind": "^1.1.1", - "has": "^1.0.3", - "has-symbols": "^1.0.1" - } - }, - "get-stream": { - "version": "6.0.1", - "resolved": "http://mirrors.tools.huawei.com/npm/get-stream/-/get-stream-6.0.1.tgz", - "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==" - }, - "glob": { - "version": "7.2.0", - "resolved": "http://mirrors.tools.huawei.com/npm/glob/-/glob-7.2.0.tgz", - "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "global-modules": { - "version": "1.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/global-modules/-/global-modules-1.0.0.tgz", - "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==", - "requires": { - "global-prefix": "^1.0.1", - "is-windows": "^1.0.1", - "resolve-dir": "^1.0.0" - } - }, - "global-prefix": { - "version": "1.0.2", - "resolved": "http://mirrors.tools.huawei.com/npm/global-prefix/-/global-prefix-1.0.2.tgz", - "integrity": "sha1-2/dDxsFJklk8ZVVoy2btMsASLr4=", - "requires": { - "expand-tilde": "^2.0.2", - "homedir-polyfill": "^1.0.1", - "ini": "^1.3.4", - "is-windows": "^1.0.1", - "which": "^1.2.14" - } - }, - "graceful-fs": { - "version": "4.2.9", - "resolved": "http://mirrors.tools.huawei.com/npm/graceful-fs/-/graceful-fs-4.2.9.tgz", - "integrity": "sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ==" - }, - "has": { - "version": "1.0.3", - "resolved": "http://mirrors.tools.huawei.com/npm/has/-/has-1.0.3.tgz", - "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "requires": { - "function-bind": "^1.1.1" - } - }, - "has-symbols": { - "version": "1.0.3", - "resolved": "http://mirrors.tools.huawei.com/npm/has-symbols/-/has-symbols-1.0.3.tgz", - "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==" - }, - "homedir-polyfill": { - "version": "1.0.3", - "resolved": "http://mirrors.tools.huawei.com/npm/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz", - "integrity": "sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==", - "requires": { - "parse-passwd": "^1.0.0" - } - }, - "hosted-git-info": { - "version": "2.8.9", - "resolved": "http://mirrors.tools.huawei.com/npm/hosted-git-info/-/hosted-git-info-2.8.9.tgz", - "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==" - }, - "human-signals": { - "version": "2.1.0", - "resolved": "http://mirrors.tools.huawei.com/npm/human-signals/-/human-signals-2.1.0.tgz", - "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==" - }, - "hypium": { - "version": "1.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/hypium/-/hypium-1.0.0.tgz", - "integrity": "sha512-nl+RQVv2AU/5FvFRhsXyWO5wh+2huhdqRZ3bszBWZzW+kpNI3AT4ydvVRYIfaQbYwV4UlX/rSc7BtFjLAezhow==" - }, - "iconv-lite": { - "version": "0.6.3", - "resolved": "http://mirrors.tools.huawei.com/npm/iconv-lite/-/iconv-lite-0.6.3.tgz", - "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", - "requires": { - "safer-buffer": ">= 2.1.2 < 3.0.0" - } - }, - "ieee754": { - "version": "1.2.1", - "resolved": "http://mirrors.tools.huawei.com/npm/ieee754/-/ieee754-1.2.1.tgz", - "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==" - }, - "inflight": { - "version": "1.0.6", - "resolved": "http://mirrors.tools.huawei.com/npm/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.4", - "resolved": "http://mirrors.tools.huawei.com/npm/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" - }, - "ini": { - "version": "1.3.8", - "resolved": "http://mirrors.tools.huawei.com/npm/ini/-/ini-1.3.8.tgz", - "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==" - }, - "interpret": { - "version": "1.4.0", - "resolved": "http://mirrors.tools.huawei.com/npm/interpret/-/interpret-1.4.0.tgz", - "integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==" - }, - "invert-kv": { - "version": "1.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/invert-kv/-/invert-kv-1.0.0.tgz", - "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=" - }, - "is-absolute": { - "version": "1.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/is-absolute/-/is-absolute-1.0.0.tgz", - "integrity": "sha512-dOWoqflvcydARa360Gvv18DZ/gRuHKi2NU/wU5X1ZFzdYfH29nkiNZsF3mp4OJ3H4yo9Mx8A/uAGNzpzPN3yBA==", - "requires": { - "is-relative": "^1.0.0", - "is-windows": "^1.0.1" - } - }, - "is-arrayish": { - "version": "0.2.1", - "resolved": "http://mirrors.tools.huawei.com/npm/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=" - }, - "is-core-module": { - "version": "2.8.1", - "resolved": "http://mirrors.tools.huawei.com/npm/is-core-module/-/is-core-module-2.8.1.tgz", - "integrity": "sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA==", - "requires": { - "has": "^1.0.3" - } - }, - "is-extglob": { - "version": "2.1.1", - "resolved": "http://mirrors.tools.huawei.com/npm/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=" - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "requires": { - "number-is-nan": "^1.0.0" - } - }, - "is-glob": { - "version": "4.0.3", - "resolved": "http://mirrors.tools.huawei.com/npm/is-glob/-/is-glob-4.0.3.tgz", - "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "requires": { - "is-extglob": "^2.1.1" - } - }, - "is-number": { - "version": "4.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/is-number/-/is-number-4.0.0.tgz", - "integrity": "sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==" - }, - "is-plain-object": { - "version": "5.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/is-plain-object/-/is-plain-object-5.0.0.tgz", - "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==" - }, - "is-relative": { - "version": "1.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/is-relative/-/is-relative-1.0.0.tgz", - "integrity": "sha512-Kw/ReK0iqwKeu0MITLFuj0jbPAmEiOsIwyIXvvbfa6QfmN9pkD1M+8pdk7Rl/dTKbH34/XBFMbgD4iMJhLQbGA==", - "requires": { - "is-unc-path": "^1.0.0" - } - }, - "is-stream": { - "version": "2.0.1", - "resolved": "http://mirrors.tools.huawei.com/npm/is-stream/-/is-stream-2.0.1.tgz", - "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==" - }, - "is-unc-path": { - "version": "1.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/is-unc-path/-/is-unc-path-1.0.0.tgz", - "integrity": "sha512-mrGpVd0fs7WWLfVsStvgF6iEJnbjDFZh9/emhRDcGWTduTfNHd9CHeUwH3gYIjdbwo4On6hunkztwOaAw0yllQ==", - "requires": { - "unc-path-regex": "^0.1.2" - } - }, - "is-utf8": { - "version": "0.2.1", - "resolved": "http://mirrors.tools.huawei.com/npm/is-utf8/-/is-utf8-0.2.1.tgz", - "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=" - }, - "is-windows": { - "version": "1.0.2", - "resolved": "http://mirrors.tools.huawei.com/npm/is-windows/-/is-windows-1.0.2.tgz", - "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==" - }, - "isarray": { - "version": "1.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" - }, - "isexe": { - "version": "2.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" - }, - "isobject": { - "version": "3.0.1", - "resolved": "http://mirrors.tools.huawei.com/npm/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=" - }, - "json-schema-traverse": { - "version": "1.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" - }, - "json5": { - "version": "2.2.0", - "resolved": "http://mirrors.tools.huawei.com/npm/json5/-/json5-2.2.0.tgz", - "integrity": "sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==", - "requires": { - "minimist": "^1.2.5" - } - }, - "jsonfile": { - "version": "6.1.0", - "resolved": "http://mirrors.tools.huawei.com/npm/jsonfile/-/jsonfile-6.1.0.tgz", - "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", - "requires": { - "graceful-fs": "^4.1.6", - "universalify": "^2.0.0" - } - }, - "kind-of": { - "version": "6.0.3", - "resolved": "http://mirrors.tools.huawei.com/npm/kind-of/-/kind-of-6.0.3.tgz", - "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==" - }, - "last-run": { - "version": "1.1.1", - "resolved": "http://mirrors.tools.huawei.com/npm/last-run/-/last-run-1.1.1.tgz", - "integrity": "sha1-RblpQsF7HHnHchmCWbqUO+v4yls=", - "requires": { - "default-resolution": "^2.0.0", - "es6-weak-map": "^2.0.1" - } - }, - "lazystream": { - "version": "1.0.1", - "resolved": "http://mirrors.tools.huawei.com/npm/lazystream/-/lazystream-1.0.1.tgz", - "integrity": "sha512-b94GiNHQNy6JNTrt5w6zNyffMrNkXZb3KTkCZJb2V1xaEGCk093vkZ2jk3tpaeP33/OiXC+WvK9AxUebnf5nbw==", - "requires": { - "readable-stream": "^2.0.5" - }, - "dependencies": { - "readable-stream": { - "version": "2.3.7", - "resolved": "http://mirrors.tools.huawei.com/npm/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - } - } - }, - "lcid": { - "version": "1.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/lcid/-/lcid-1.0.0.tgz", - "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", - "requires": { - "invert-kv": "^1.0.0" - } - }, - "liftoff": { - "version": "4.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/liftoff/-/liftoff-4.0.0.tgz", - "integrity": "sha512-rMGwYF8q7g2XhG2ulBmmJgWv25qBsqRbDn5gH0+wnuyeFt7QBJlHJmtg5qEdn4pN6WVAUMgXnIxytMFRX9c1aA==", - "requires": { - "extend": "^3.0.2", - "findup-sync": "^5.0.0", - "fined": "^2.0.0", - "flagged-respawn": "^2.0.0", - "is-plain-object": "^5.0.0", - "object.map": "^1.0.1", - "rechoir": "^0.8.0", - "resolve": "^1.20.0" - } - }, - "load-json-file": { - "version": "1.1.0", - "resolved": "http://mirrors.tools.huawei.com/npm/load-json-file/-/load-json-file-1.1.0.tgz", - "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", - "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^2.2.0", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0", - "strip-bom": "^2.0.0" - } - }, - "lodash": { - "version": "4.17.21", - "resolved": "http://mirrors.tools.huawei.com/npm/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" - }, - "lodash.defaults": { - "version": "4.2.0", - "resolved": "http://mirrors.tools.huawei.com/npm/lodash.defaults/-/lodash.defaults-4.2.0.tgz", - "integrity": "sha1-0JF4cW/+pN3p5ft7N/bwgCJ0WAw=" - }, - "lodash.difference": { - "version": "4.5.0", - "resolved": "http://mirrors.tools.huawei.com/npm/lodash.difference/-/lodash.difference-4.5.0.tgz", - "integrity": "sha1-nMtOUF1Ia5FlE0V3KIWi3yf9AXw=" - }, - "lodash.flatten": { - "version": "4.4.0", - "resolved": "http://mirrors.tools.huawei.com/npm/lodash.flatten/-/lodash.flatten-4.4.0.tgz", - "integrity": "sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8=" - }, - "lodash.isplainobject": { - "version": "4.0.6", - "resolved": "http://mirrors.tools.huawei.com/npm/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", - "integrity": "sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=" - }, - "lodash.union": { - "version": "4.6.0", - "resolved": "http://mirrors.tools.huawei.com/npm/lodash.union/-/lodash.union-4.6.0.tgz", - "integrity": "sha1-SLtQiECfFvGCFmZkHETdGqrjzYg=" - }, - "log4js": { - "version": "6.4.1", - "resolved": "http://mirrors.tools.huawei.com/npm/log4js/-/log4js-6.4.1.tgz", - "integrity": "sha512-iUiYnXqAmNKiIZ1XSAitQ4TmNs8CdZYTAWINARF3LjnsLN8tY5m0vRwd6uuWj/yNY0YHxeZodnbmxKFUOM2rMg==", - "requires": { - "date-format": "^4.0.3", - "debug": "^4.3.3", - "flatted": "^3.2.4", - "rfdc": "^1.3.0", - "streamroller": "^3.0.2" - } - }, - "make-iterator": { - "version": "1.0.1", - "resolved": "http://mirrors.tools.huawei.com/npm/make-iterator/-/make-iterator-1.0.1.tgz", - "integrity": "sha512-pxiuXh0iVEq7VM7KMIhs5gxsfxCux2URptUQaXo4iZZJxBAzTPOLE2BumO5dbfVYq/hBJFBR/a1mFDmOx5AGmw==", - "requires": { - "kind-of": "^6.0.2" - } - }, - "map-cache": { - "version": "0.2.2", - "resolved": "http://mirrors.tools.huawei.com/npm/map-cache/-/map-cache-0.2.2.tgz", - "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=" - }, - "merge-stream": { - "version": "2.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/merge-stream/-/merge-stream-2.0.0.tgz", - "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==" - }, - "micromatch": { - "version": "4.0.4", - "resolved": "http://mirrors.tools.huawei.com/npm/micromatch/-/micromatch-4.0.4.tgz", - "integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==", - "requires": { - "braces": "^3.0.1", - "picomatch": "^2.2.3" - } - }, - "mimic-fn": { - "version": "2.1.0", - "resolved": "http://mirrors.tools.huawei.com/npm/mimic-fn/-/mimic-fn-2.1.0.tgz", - "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==" - }, - "minimatch": { - "version": "3.1.2", - "resolved": "http://mirrors.tools.huawei.com/npm/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "minimist": { - "version": "1.2.6", - "resolved": "http://mirrors.tools.huawei.com/npm/minimist/-/minimist-1.2.6.tgz", - "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==" - }, - "ms": { - "version": "2.1.2", - "resolved": "http://mirrors.tools.huawei.com/npm/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" - }, - "mute-stdout": { - "version": "1.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/mute-stdout/-/mute-stdout-1.0.0.tgz", - "integrity": "sha1-WzLqB+tDyd7WEwQ0z5JvRrKn/U0=" - }, - "next-tick": { - "version": "1.1.0", - "resolved": "http://mirrors.tools.huawei.com/npm/next-tick/-/next-tick-1.1.0.tgz", - "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==" - }, - "normalize-package-data": { - "version": "2.5.0", - "resolved": "http://mirrors.tools.huawei.com/npm/normalize-package-data/-/normalize-package-data-2.5.0.tgz", - "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", - "requires": { - "hosted-git-info": "^2.1.4", - "resolve": "^1.10.0", - "semver": "2 || 3 || 4 || 5", - "validate-npm-package-license": "^3.0.1" - } - }, - "normalize-path": { - "version": "3.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==" - }, - "now-and-later": { - "version": "2.0.1", - "resolved": "http://mirrors.tools.huawei.com/npm/now-and-later/-/now-and-later-2.0.1.tgz", - "integrity": "sha512-KGvQ0cB70AQfg107Xvs/Fbu+dGmZoTRJp2TaPwcwQm3/7PteUyN2BCgk8KBMPGBUXZdVwyWS8fDCGFygBm19UQ==", - "requires": { - "once": "^1.3.2" - } - }, - "npm-run-path": { - "version": "4.0.1", - "resolved": "http://mirrors.tools.huawei.com/npm/npm-run-path/-/npm-run-path-4.0.1.tgz", - "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", - "requires": { - "path-key": "^3.0.0" - } - }, - "number-is-nan": { - "version": "1.0.1", - "resolved": "http://mirrors.tools.huawei.com/npm/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" - }, - "object-keys": { - "version": "1.1.1", - "resolved": "http://mirrors.tools.huawei.com/npm/object-keys/-/object-keys-1.1.1.tgz", - "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==" - }, - "object.assign": { - "version": "4.1.2", - "resolved": "http://mirrors.tools.huawei.com/npm/object.assign/-/object.assign-4.1.2.tgz", - "integrity": "sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==", - "requires": { - "call-bind": "^1.0.0", - "define-properties": "^1.1.3", - "has-symbols": "^1.0.1", - "object-keys": "^1.1.1" - } - }, - "object.defaults": { - "version": "1.1.0", - "resolved": "http://mirrors.tools.huawei.com/npm/object.defaults/-/object.defaults-1.1.0.tgz", - "integrity": "sha1-On+GgzS0B96gbaFtiNXNKeQ1/s8=", - "requires": { - "array-each": "^1.0.1", - "array-slice": "^1.0.0", - "for-own": "^1.0.0", - "isobject": "^3.0.0" - } - }, - "object.map": { - "version": "1.0.1", - "resolved": "http://mirrors.tools.huawei.com/npm/object.map/-/object.map-1.0.1.tgz", - "integrity": "sha1-z4Plncj8wK1fQlDh94s7gb2AHTc=", - "requires": { - "for-own": "^1.0.0", - "make-iterator": "^1.0.0" - } - }, - "object.pick": { - "version": "1.3.0", - "resolved": "http://mirrors.tools.huawei.com/npm/object.pick/-/object.pick-1.3.0.tgz", - "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", - "requires": { - "isobject": "^3.0.1" - } - }, - "object.reduce": { - "version": "1.0.1", - "resolved": "http://mirrors.tools.huawei.com/npm/object.reduce/-/object.reduce-1.0.1.tgz", - "integrity": "sha1-b+NI8qx/oPlcpiEiZZkJaCW7A60=", - "requires": { - "for-own": "^1.0.0", - "make-iterator": "^1.0.0" - } - }, - "once": { - "version": "1.4.0", - "resolved": "http://mirrors.tools.huawei.com/npm/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "requires": { - "wrappy": "1" - } - }, - "onetime": { - "version": "5.1.2", - "resolved": "http://mirrors.tools.huawei.com/npm/onetime/-/onetime-5.1.2.tgz", - "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", - "requires": { - "mimic-fn": "^2.1.0" - } - }, - "os-locale": { - "version": "1.4.0", - "resolved": "http://mirrors.tools.huawei.com/npm/os-locale/-/os-locale-1.4.0.tgz", - "integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=", - "requires": { - "lcid": "^1.0.0" - } - }, - "parse-filepath": { - "version": "1.0.2", - "resolved": "http://mirrors.tools.huawei.com/npm/parse-filepath/-/parse-filepath-1.0.2.tgz", - "integrity": "sha1-pjISf1Oq89FYdvWHLz/6x2PWyJE=", - "requires": { - "is-absolute": "^1.0.0", - "map-cache": "^0.2.0", - "path-root": "^0.1.1" - } - }, - "parse-json": { - "version": "2.2.0", - "resolved": "http://mirrors.tools.huawei.com/npm/parse-json/-/parse-json-2.2.0.tgz", - "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", - "requires": { - "error-ex": "^1.2.0" - } - }, - "parse-passwd": { - "version": "1.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/parse-passwd/-/parse-passwd-1.0.0.tgz", - "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=" - }, - "path-exists": { - "version": "2.1.0", - "resolved": "http://mirrors.tools.huawei.com/npm/path-exists/-/path-exists-2.1.0.tgz", - "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", - "requires": { - "pinkie-promise": "^2.0.0" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "http://mirrors.tools.huawei.com/npm/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" - }, - "path-key": { - "version": "3.1.1", - "resolved": "http://mirrors.tools.huawei.com/npm/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==" - }, - "path-parse": { - "version": "1.0.7", - "resolved": "http://mirrors.tools.huawei.com/npm/path-parse/-/path-parse-1.0.7.tgz", - "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" - }, - "path-root": { - "version": "0.1.1", - "resolved": "http://mirrors.tools.huawei.com/npm/path-root/-/path-root-0.1.1.tgz", - "integrity": "sha1-mkpoFMrBwM1zNgqV8yCDyOpHRbc=", - "requires": { - "path-root-regex": "^0.1.0" - } - }, - "path-root-regex": { - "version": "0.1.2", - "resolved": "http://mirrors.tools.huawei.com/npm/path-root-regex/-/path-root-regex-0.1.2.tgz", - "integrity": "sha1-v8zcjfWxLcUsi0PsONGNcsBLqW0=" - }, - "path-type": { - "version": "1.1.0", - "resolved": "http://mirrors.tools.huawei.com/npm/path-type/-/path-type-1.1.0.tgz", - "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", - "requires": { - "graceful-fs": "^4.1.2", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0" - } - }, - "picomatch": { - "version": "2.3.1", - "resolved": "http://mirrors.tools.huawei.com/npm/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==" - }, - "pify": { - "version": "2.3.0", - "resolved": "http://mirrors.tools.huawei.com/npm/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" - }, - "pinkie": { - "version": "2.0.4", - "resolved": "http://mirrors.tools.huawei.com/npm/pinkie/-/pinkie-2.0.4.tgz", - "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=" - }, - "pinkie-promise": { - "version": "2.0.1", - "resolved": "http://mirrors.tools.huawei.com/npm/pinkie-promise/-/pinkie-promise-2.0.1.tgz", - "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", - "requires": { - "pinkie": "^2.0.0" - } - }, - "pretty-hrtime": { - "version": "1.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/pretty-hrtime/-/pretty-hrtime-1.0.0.tgz", - "integrity": "sha1-9ualItPmBwRSK/Db5oVu0g515Nw=" - }, - "printj": { - "version": "1.3.1", - "resolved": "http://mirrors.tools.huawei.com/npm/printj/-/printj-1.3.1.tgz", - "integrity": "sha512-GA3TdL8szPK4AQ2YnOe/b+Y1jUFwmmGMMK/qbY7VcE3Z7FU8JstbKiKRzO6CIiAKPhTO8m01NoQ0V5f3jc4OGg==" - }, - "process-nextick-args": { - "version": "2.0.1", - "resolved": "http://mirrors.tools.huawei.com/npm/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" - }, - "punycode": { - "version": "2.1.1", - "resolved": "http://mirrors.tools.huawei.com/npm/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" - }, - "read-pkg": { - "version": "1.1.0", - "resolved": "http://mirrors.tools.huawei.com/npm/read-pkg/-/read-pkg-1.1.0.tgz", - "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", - "requires": { - "load-json-file": "^1.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^1.0.0" - } - }, - "read-pkg-up": { - "version": "1.0.1", - "resolved": "http://mirrors.tools.huawei.com/npm/read-pkg-up/-/read-pkg-up-1.0.1.tgz", - "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", - "requires": { - "find-up": "^1.0.0", - "read-pkg": "^1.0.0" - } - }, - "readable-stream": { - "version": "3.6.0", - "resolved": "http://mirrors.tools.huawei.com/npm/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "requires": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - } - }, - "readdir-glob": { - "version": "1.1.1", - "resolved": "http://mirrors.tools.huawei.com/npm/readdir-glob/-/readdir-glob-1.1.1.tgz", - "integrity": "sha512-91/k1EzZwDx6HbERR+zucygRFfiPl2zkIYZtv3Jjr6Mn7SkKcVct8aVO+sSRiGMc6fLf72du3d92/uY63YPdEA==", - "requires": { - "minimatch": "^3.0.4" - } - }, - "rechoir": { - "version": "0.8.0", - "resolved": "http://mirrors.tools.huawei.com/npm/rechoir/-/rechoir-0.8.0.tgz", - "integrity": "sha512-/vxpCXddiX8NGfGO/mTafwjq4aFa/71pvamip0++IQk3zG8cbCj0fifNPrjjF1XMXUne91jL9OoxmdykoEtifQ==", - "requires": { - "resolve": "^1.20.0" - } - }, - "require-directory": { - "version": "2.1.1", - "resolved": "http://mirrors.tools.huawei.com/npm/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=" - }, - "require-from-string": { - "version": "2.0.2", - "resolved": "http://mirrors.tools.huawei.com/npm/require-from-string/-/require-from-string-2.0.2.tgz", - "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==" - }, - "require-main-filename": { - "version": "1.0.1", - "resolved": "http://mirrors.tools.huawei.com/npm/require-main-filename/-/require-main-filename-1.0.1.tgz", - "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=" - }, - "resolve": { - "version": "1.22.0", - "resolved": "http://mirrors.tools.huawei.com/npm/resolve/-/resolve-1.22.0.tgz", - "integrity": "sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==", - "requires": { - "is-core-module": "^2.8.1", - "path-parse": "^1.0.7", - "supports-preserve-symlinks-flag": "^1.0.0" - } - }, - "resolve-dir": { - "version": "1.0.1", - "resolved": "http://mirrors.tools.huawei.com/npm/resolve-dir/-/resolve-dir-1.0.1.tgz", - "integrity": "sha1-eaQGRMNivoLybv/nOcm7U4IEb0M=", - "requires": { - "expand-tilde": "^2.0.0", - "global-modules": "^1.0.0" - } - }, - "resolve-package-path": { - "version": "4.0.3", - "resolved": "http://mirrors.tools.huawei.com/npm/resolve-package-path/-/resolve-package-path-4.0.3.tgz", - "integrity": "sha512-SRpNAPW4kewOaNUt8VPqhJ0UMxawMwzJD8V7m1cJfdSTK9ieZwS6K7Dabsm4bmLFM96Z5Y/UznrpG5kt1im8yA==", - "requires": { - "path-root": "^0.1.1" - } - }, - "rfdc": { - "version": "1.3.0", - "resolved": "http://mirrors.tools.huawei.com/npm/rfdc/-/rfdc-1.3.0.tgz", - "integrity": "sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA==" - }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "http://mirrors.tools.huawei.com/npm/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - }, - "safer-buffer": { - "version": "2.1.2", - "resolved": "http://mirrors.tools.huawei.com/npm/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" - }, - "semver": { - "version": "5.7.1", - "resolved": "http://mirrors.tools.huawei.com/npm/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" - }, - "set-blocking": { - "version": "2.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" - }, - "shebang-command": { - "version": "2.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "requires": { - "shebang-regex": "^3.0.0" - } - }, - "shebang-regex": { - "version": "3.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==" - }, - "signal-exit": { - "version": "3.0.7", - "resolved": "http://mirrors.tools.huawei.com/npm/signal-exit/-/signal-exit-3.0.7.tgz", - "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" - }, - "spdx-correct": { - "version": "3.1.1", - "resolved": "http://mirrors.tools.huawei.com/npm/spdx-correct/-/spdx-correct-3.1.1.tgz", - "integrity": "sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w==", - "requires": { - "spdx-expression-parse": "^3.0.0", - "spdx-license-ids": "^3.0.0" - } - }, - "spdx-exceptions": { - "version": "2.3.0", - "resolved": "http://mirrors.tools.huawei.com/npm/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz", - "integrity": "sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A==" - }, - "spdx-expression-parse": { - "version": "3.0.1", - "resolved": "http://mirrors.tools.huawei.com/npm/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz", - "integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==", - "requires": { - "spdx-exceptions": "^2.1.0", - "spdx-license-ids": "^3.0.0" - } - }, - "spdx-license-ids": { - "version": "3.0.11", - "resolved": "http://mirrors.tools.huawei.com/npm/spdx-license-ids/-/spdx-license-ids-3.0.11.tgz", - "integrity": "sha512-Ctl2BrFiM0X3MANYgj3CkygxhRmr9mi6xhejbdO960nF6EDJApTYpn0BQnDKlnNBULKiCN1n3w9EBkHK8ZWg+g==" - }, - "stream-exhaust": { - "version": "1.0.2", - "resolved": "http://mirrors.tools.huawei.com/npm/stream-exhaust/-/stream-exhaust-1.0.2.tgz", - "integrity": "sha512-b/qaq/GlBK5xaq1yrK9/zFcyRSTNxmcZwFLGSTG0mXgZl/4Z6GgiyYOXOvY7N3eEvFRAG1bkDRz5EPGSvPYQlw==" - }, - "streamroller": { - "version": "3.0.6", - "resolved": "http://mirrors.tools.huawei.com/npm/streamroller/-/streamroller-3.0.6.tgz", - "integrity": "sha512-Qz32plKq/MZywYyhEatxyYc8vs994Gz0Hu2MSYXXLD233UyPeIeRBZARIIGwFer4Mdb8r3Y2UqKkgyDghM6QCg==", - "requires": { - "date-format": "^4.0.6", - "debug": "^4.3.4", - "fs-extra": "^10.0.1" - } - }, - "string-width": { - "version": "1.0.2", - "resolved": "http://mirrors.tools.huawei.com/npm/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "http://mirrors.tools.huawei.com/npm/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "requires": { - "safe-buffer": "~5.1.0" - } - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "http://mirrors.tools.huawei.com/npm/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "requires": { - "ansi-regex": "^2.0.0" - } - }, - "strip-bom": { - "version": "2.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/strip-bom/-/strip-bom-2.0.0.tgz", - "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", - "requires": { - "is-utf8": "^0.2.0" - } - }, - "strip-final-newline": { - "version": "2.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/strip-final-newline/-/strip-final-newline-2.0.0.tgz", - "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==" - }, - "supports-preserve-symlinks-flag": { - "version": "1.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", - "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==" - }, - "tar-stream": { - "version": "2.2.0", - "resolved": "http://mirrors.tools.huawei.com/npm/tar-stream/-/tar-stream-2.2.0.tgz", - "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", - "requires": { - "bl": "^4.0.3", - "end-of-stream": "^1.4.1", - "fs-constants": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^3.1.1" - } - }, - "to-regex-range": { - "version": "5.0.1", - "resolved": "http://mirrors.tools.huawei.com/npm/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "requires": { - "is-number": "^7.0.0" - }, - "dependencies": { - "is-number": { - "version": "7.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" - } - } - }, - "type": { - "version": "1.2.0", - "resolved": "http://mirrors.tools.huawei.com/npm/type/-/type-1.2.0.tgz", - "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==" - }, - "unc-path-regex": { - "version": "0.1.2", - "resolved": "http://mirrors.tools.huawei.com/npm/unc-path-regex/-/unc-path-regex-0.1.2.tgz", - "integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo=" - }, - "undertaker": { - "version": "1.2.1", - "resolved": "http://mirrors.tools.huawei.com/npm/undertaker/-/undertaker-1.2.1.tgz", - "integrity": "sha512-71WxIzDkgYk9ZS+spIB8iZXchFhAdEo2YU8xYqBYJ39DIUIqziK78ftm26eecoIY49X0J2MLhG4hr18Yp6/CMA==", - "requires": { - "arr-flatten": "^1.0.1", - "arr-map": "^2.0.0", - "bach": "^1.0.0", - "collection-map": "^1.0.0", - "es6-weak-map": "^2.0.1", - "last-run": "^1.1.0", - "object.defaults": "^1.0.0", - "object.reduce": "^1.0.0", - "undertaker-registry": "^1.0.0" - } - }, - "undertaker-registry": { - "version": "1.0.1", - "resolved": "http://mirrors.tools.huawei.com/npm/undertaker-registry/-/undertaker-registry-1.0.1.tgz", - "integrity": "sha1-XkvaMI5KiirlhPm5pDWaSZglzFA=" - }, - "universalify": { - "version": "2.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/universalify/-/universalify-2.0.0.tgz", - "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==" - }, - "uri-js": { - "version": "4.4.1", - "resolved": "http://mirrors.tools.huawei.com/npm/uri-js/-/uri-js-4.4.1.tgz", - "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", - "requires": { - "punycode": "^2.1.0" - } - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "http://mirrors.tools.huawei.com/npm/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" - }, - "v8flags": { - "version": "3.2.0", - "resolved": "http://mirrors.tools.huawei.com/npm/v8flags/-/v8flags-3.2.0.tgz", - "integrity": "sha512-mH8etigqMfiGWdeXpaaqGfs6BndypxusHHcv2qSHyZkGEznCd/qAXCWWRzeowtL54147cktFOC4P5y+kl8d8Jg==", - "requires": { - "homedir-polyfill": "^1.0.1" - } - }, - "validate-npm-package-license": { - "version": "3.0.4", - "resolved": "http://mirrors.tools.huawei.com/npm/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", - "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", - "requires": { - "spdx-correct": "^3.0.0", - "spdx-expression-parse": "^3.0.0" - } - }, - "which": { - "version": "1.3.1", - "resolved": "http://mirrors.tools.huawei.com/npm/which/-/which-1.3.1.tgz", - "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", - "requires": { - "isexe": "^2.0.0" - } - }, - "which-module": { - "version": "1.0.0", - "resolved": "http://mirrors.tools.huawei.com/npm/which-module/-/which-module-1.0.0.tgz", - "integrity": "sha1-u6Y8qGGUiZT/MHc2CJ47lgJsKk8=" - }, - "wrap-ansi": { - "version": "2.1.0", - "resolved": "http://mirrors.tools.huawei.com/npm/wrap-ansi/-/wrap-ansi-2.1.0.tgz", - "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", - "requires": { - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1" - } - }, - "wrappy": { - "version": "1.0.2", - "resolved": "http://mirrors.tools.huawei.com/npm/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" - }, - "y18n": { - "version": "3.2.2", - "resolved": "http://mirrors.tools.huawei.com/npm/y18n/-/y18n-3.2.2.tgz", - "integrity": "sha512-uGZHXkHnhF0XeeAPgnKfPv1bgKAYyVvmNL1xlKsPYZPaIHxGti2hHqvOCQv71XMsLxu1QjergkqogUnms5D3YQ==" - }, - "yargs": { - "version": "7.1.0", - "resolved": "http://mirrors.tools.huawei.com/npm/yargs/-/yargs-7.1.0.tgz", - "integrity": "sha1-a6MY6xaWFyf10oT46gA+jWFU0Mg=", - "requires": { - "camelcase": "^3.0.0", - "cliui": "^3.2.0", - "decamelize": "^1.1.1", - "get-caller-file": "^1.0.1", - "os-locale": "^1.4.0", - "read-pkg-up": "^1.0.1", - "require-directory": "^2.1.1", - "require-main-filename": "^1.0.1", - "set-blocking": "^2.0.0", - "string-width": "^1.0.2", - "which-module": "^1.0.0", - "y18n": "^3.2.1", - "yargs-parser": "^5.0.0" - } - }, - "yargs-parser": { - "version": "5.0.1", - "resolved": "http://mirrors.tools.huawei.com/npm/yargs-parser/-/yargs-parser-5.0.1.tgz", - "integrity": "sha512-wpav5XYiddjXxirPoCTUPbqM0PXvJ9hiBMvuJgInvo4/lAOTZzUprArw17q2O1P2+GHhbBr18/iQwjL5Z9BqfA==", - "requires": { - "camelcase": "^3.0.0", - "object.assign": "^4.1.0" - } - }, - "zip-stream": { - "version": "4.1.0", - "resolved": "http://mirrors.tools.huawei.com/npm/zip-stream/-/zip-stream-4.1.0.tgz", - "integrity": "sha512-zshzwQW7gG7hjpBlgeQP9RuyPGNxvJdzR8SUM3QhxCnLjWN2E7j3dOvpeDcQoETfHx0urRS7EtmVToql7YpU4A==", - "requires": { - "archiver-utils": "^2.1.0", - "compress-commons": "^4.1.0", - "readable-stream": "^3.6.0" - } - } - } -} diff --git a/package.json b/package.json index 35bc6d0..376389e 100644 --- a/package.json +++ b/package.json @@ -1,18 +1,19 @@ { - "license": "ISC", - "devDependencies": {}, - "name": "imageknifegiteepro", - "ohos": { - "org": "huawei", - "directoryLevel": "project", - "buildTool": "hvigor" + "license":"ISC", + "devDependencies":{}, + "name":"imageknife", + "ohos":{ + "org":"huawei", + "directoryLevel":"project", + "buildTool":"hvigor" }, - "description": "example description", - "repository": {}, - "version": "1.0.0", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "1.0.6", - "hypium": "^1.0.0", - "@ohos/hvigor": "1.0.6" + "description":"example description", + "repository":{}, + "version":"1.0.0", + "dependencies":{ + "@ohos/hypium":"1.0.1", + "@ohos/hvigor-ohos-plugin":"1.1.6", + "hypium":"^1.0.0", + "@ohos/hvigor":"1.1.6" } -} +} \ No newline at end of file