Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/antd-plus/CHANGELOG.md
#	packages/antd-plus/package.json
#	packages/painter/CHANGELOG.md
#	packages/painter/package.json
#	packages/pdf-viewer/CHANGELOG.md
#	packages/pdf-viewer/package.json
#	packages/pocket/CHANGELOG.md
#	packages/pocket/package.json
  • Loading branch information
NicoKam committed Nov 7, 2023
2 parents 4122bcc + ac9bfcb commit f1e34ba
Show file tree
Hide file tree
Showing 20 changed files with 174 additions and 45 deletions.
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
MIT LICENSE

Copyright (c) 2020-present orca-team, https://orca.nicokam.work/

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
# Orca-Pocket
# Orca-Team Front-End Pocket Toolkit

A React-biased front-end collection, including UI components, hooks, and common-tools.

[Click here to see our website and documentation.](https://orca.nicokam.work/)

## Introduction

[![npm version](https://badge.fury.io/js/%40orca-fe%2Fpocket.svg)](https://badge.fury.io/js/%40orca-fe%2Fpocket)
[![Build Status](https://travis-ci.com/orca-team/orca-fe-pocket.svg?branch=master)](https://travis-ci.com/orca-team/orca-fe-pocket)

![orca-pocket-readmd.png](./public/assets-readme/orca-pocket-readmd.png)

Visit here for more details:

- [@orca-fe/pocket](https://orca.nicokam.work/components)
- [@orca-fe/hooks](https://orca.nicokam.work/hooks)
- [@orca-fe/tools](https://orca.nicokam.work/tools)
- [@orca-fe/antd-plus](https://orca.nicokam.work/antd-pluses)
- [@orca-fe/transformer](https://orca.nicokam.work/pro-component/transformers)
- [@orca-fe/dnd](https://orca.nicokam.work/pro-component/dnds)
- [@orca-fe/painter](https://orca.nicokam.work/pro-component/painters)
- [@orca-fe/pdf-viewer](https://orca.nicokam.work/pro-component/pdf-viewers)
3 changes: 3 additions & 0 deletions emit-log.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# 取出 log.txt 的文件内容
log=$(cat log.txt|grep 'New tag:')

# 将换行符替换为两个换行符
log=$(echo "$log"|sed 's/\n/\\n\\n/g')

# 如果 log.txt 为空
if [ -z "$log" ]; then
curl "https://oapi.dingtalk.com/robot/send?access_token=${DING_TOKEN}" \
Expand Down
9 changes: 9 additions & 0 deletions packages/antd-plus/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
# @orca-fe/painter

## 0.3.5

### Patch Changes

- Updated dependencies
- @orca-fe/hooks@1.10.0
- @orca-fe/pocket@3.2.6

## 0.3.4

### Patch Changes

- Updated dependencies
- @orca-fe/hooks@1.9.2
- @orca-fe/pocket@3.2.5

## 0.3.3
Expand Down
6 changes: 3 additions & 3 deletions packages/antd-plus/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@orca-fe/antd-plus",
"version": "0.3.4",
"version": "0.3.5",
"description": "Transformer Container",
"keywords": [
"react",
Expand Down Expand Up @@ -36,9 +36,9 @@
"clear": "rimraf lib es"
},
"dependencies": {
"@orca-fe/hooks": "^1.9.1",
"@orca-fe/hooks": "^1.10.0",
"@orca-fe/jss-plugin-auto-prefix": "^0.0.1",
"@orca-fe/pocket": "^3.2.5",
"@orca-fe/pocket": "^3.2.6",
"@orca-fe/simple-jss": "^0.0.3",
"@orca-fe/tools": "^0.10.0",
"ahooks": "^3.7.8",
Expand Down
12 changes: 12 additions & 0 deletions packages/hooks/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# @orca-fe/hooks

## 1.10.0

### Minor Changes

- feat: 增加 throwOnError 选项

## 1.9.2

### Patch Changes

- fix: export UseServiceContext

## 1.9.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@orca-fe/hooks",
"version": "1.9.1",
"version": "1.10.0",
"description": "React Hooks Collections",
"keywords": [
"react",
Expand Down
3 changes: 2 additions & 1 deletion packages/hooks/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import useEffectWithTarget, { useLayoutEffectWithTarget } from './useEffectWithT
import useStaticClick from './useStaticClick';
import useNextTick, { useLayoutNextTick } from './useNextTick';
import usePan from './usePan';
import useService from './useService';
import useService, { UseServiceContext } from './useService';
import useInterval from './useInterval';
import useHotkeyListener from './useHotkeyListener';
import HotkeyManager from './hotkey-manager';
Expand All @@ -38,6 +38,7 @@ export {
useLayoutNextTick,
usePan,
useService,
UseServiceContext,
useInterval,
useGetState,
useMergedRefs,
Expand Down
33 changes: 25 additions & 8 deletions packages/hooks/src/useService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ export interface ContextOptions {

/** 如果请求失败,是否维持之前的结果,默认为 true */
keepSuccessData?: boolean;

/** 如果請求的結果是 Error 則視為拋出異常。 */
throwOnError?: boolean;
}

export const UseServiceContext = React.createContext<ContextOptions>({});
Expand Down Expand Up @@ -138,6 +141,7 @@ export function useService<Args extends any[], ServiceResult = any, Result = Fet
pollingWhenHidden = false,
stateMgr,
onFinish,
throwOnError = true,
} = { ...globalOptions, ...options };

const service = useMemoizedFn(_service);
Expand Down Expand Up @@ -190,6 +194,9 @@ export function useService<Args extends any[], ServiceResult = any, Result = Fet
try {
const res = await service(...args);
let formattedData = formatter(res) as Result | undefined;
if (throwOnError && formattedData instanceof Error) {
throw formattedData;
}
if (keepSuccessData && formattedData == null) {
formattedData = data;
}
Expand Down Expand Up @@ -218,14 +225,24 @@ export function useService<Args extends any[], ServiceResult = any, Result = Fet
return formattedData;
} catch (error: any) {
console.error(error);
_this.loading = false;
setState({
data: undefined,
error,
loading: false,
});
if (typeof onError === 'function') {
onError(error, args);
if (_this.ticket === ticket) {
_this.loading = false;
if (keepSuccessData) {
setState({
error,
loading: false,
});
} else {
setState({
error,
loading: false,
data: undefined,
});
}

if (typeof onError === 'function') {
onError(error, args);
}
}
}
return undefined;
Expand Down
11 changes: 11 additions & 0 deletions packages/painter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
# @orca-fe/painter

## 1.4.40

### Patch Changes

- Updated dependencies
- @orca-fe/hooks@1.10.0
- @orca-fe/pocket@3.2.6
- @orca-fe/transformer@0.3.26

## 1.4.39

### Patch Changes

- Updated dependencies
- @orca-fe/hooks@1.9.2
- @orca-fe/pocket@3.2.5
- @orca-fe/transformer@0.3.25

## 1.4.38

Expand Down
8 changes: 4 additions & 4 deletions packages/painter/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@orca-fe/painter",
"version": "1.4.39",
"version": "1.4.40",
"description": "Konva Painter",
"keywords": [
"react",
Expand Down Expand Up @@ -37,17 +37,17 @@
"clear": "rimraf lib es"
},
"dependencies": {
"@orca-fe/hooks": "^1.9.1",
"@orca-fe/hooks": "^1.10.0",
"@orca-fe/jss-plugin-auto-prefix": "^0.0.1",
"@orca-fe/pocket": "^3.2.5",
"@orca-fe/pocket": "^3.2.6",
"@orca-fe/simple-jss": "^0.0.3",
"@orca-fe/tools": "^0.10.0",
"ahooks": "^3.7.8",
"classnames": "^2.3.2",
"color": "^4.2.3",
"react-colorful": "^5.6.1",
"tslib": "^2.6.0",
"@orca-fe/transformer": "^0.3.24"
"@orca-fe/transformer": "^0.3.26"
},
"peerDependencies": {
"@ant-design/icons": "^4.7.0",
Expand Down
12 changes: 11 additions & 1 deletion packages/pdf-viewer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
# @orca-fe/pdf-viewer

## 1.19.4

### Patch Changes

- Updated dependencies
- @orca-fe/hooks@1.10.0
- @orca-fe/painter@1.4.40
- @orca-fe/pocket@3.2.6

## 1.19.3

### Patch Changes

- Updated dependencies
- @orca-fe/pocket@3.2.5
- @orca-fe/hooks@1.9.2
- @orca-fe/painter@1.4.39
- @orca-fe/pocket@3.2.5

## 1.19.2

Expand Down
8 changes: 4 additions & 4 deletions packages/pdf-viewer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@orca-fe/pdf-viewer",
"version": "1.19.3",
"version": "1.19.4",
"description": "PDF Viewer",
"keywords": [
"react",
Expand Down Expand Up @@ -38,11 +38,11 @@
"clear": "rimraf lib es"
},
"dependencies": {
"@orca-fe/hooks": "^1.9.1",
"@orca-fe/hooks": "^1.10.0",
"@orca-fe/jss-plugin-auto-prefix": "^0.0.1",
"@orca-fe/painter": "^1.4.39",
"@orca-fe/painter": "^1.4.40",
"@orca-fe/pdfjs-dist-browserify": "^3.8.24",
"@orca-fe/pocket": "^3.2.5",
"@orca-fe/pocket": "^3.2.6",
"@orca-fe/simple-jss": "^0.0.3",
"@orca-fe/tools": "^0.10.0",
"ahooks": "^3.7.8",
Expand Down
10 changes: 9 additions & 1 deletion packages/pocket/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
# @orca-fe/pocket

## 3.2.6

### Patch Changes

- Updated dependencies
- @orca-fe/hooks@1.10.0

## 3.2.5

### Patch Changes

- fix: resizable-wrapper add cover to fix iframe event
- Updated dependencies
- @orca-fe/hooks@1.9.2

## 3.2.4

Expand Down
4 changes: 2 additions & 2 deletions packages/pocket/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@orca-fe/pocket",
"version": "3.2.5",
"version": "3.2.6",
"description": "UI components by orca-team",
"keywords": [
"react",
Expand Down Expand Up @@ -39,7 +39,7 @@
"clear": "rimraf lib es"
},
"dependencies": {
"@orca-fe/hooks": "^1.9.1",
"@orca-fe/hooks": "^1.10.0",
"@orca-fe/jss-plugin-auto-prefix": "^0.0.1",
"@orca-fe/tools": "^0.10.0",
"@rc-component/trigger": "^1.13.3",
Expand Down
14 changes: 14 additions & 0 deletions packages/transformer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# @orca-fe/painter

## 0.3.26

### Patch Changes

- Updated dependencies
- @orca-fe/hooks@1.10.0

## 0.3.25

### Patch Changes

- Updated dependencies
- @orca-fe/hooks@1.9.2

## 0.3.24

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/transformer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@orca-fe/transformer",
"version": "0.3.24",
"version": "0.3.26",
"description": "Transformer Container",
"keywords": [
"react",
Expand Down Expand Up @@ -42,7 +42,7 @@
"gl-matrix": "^3.4.3",
"prefix-classnames": "^0.0.7",
"tslib": "^2.6.0",
"@orca-fe/hooks": "^1.9.1",
"@orca-fe/hooks": "^1.10.0",
"@orca-fe/tools": "^0.10.0"
},
"peerDependencies": {
Expand Down
Loading

0 comments on commit f1e34ba

Please sign in to comment.