-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into docs/add-codeline-hig…
…hlight
- Loading branch information
Showing
52 changed files
with
593 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"installation": { "title": "Installation" }, | ||
"Await": { "title": "<Await/>" } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"installation": { "title": "설치하기" }, | ||
"Await": { "title": "<Await/>" } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Installation | ||
|
||
@suspensive/react-await package lives in npm. To install the latest stable version, run the following command | ||
|
||
[![npm version](https://img.shields.io/npm/v/@suspensive/react-await?color=000&labelColor=000&logo=npm&label=)](https://www.npmjs.com/package/@suspensive/react-await) | ||
|
||
```shell npm2yarn | ||
npm install @suspensive/react-await | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# 설치하기 | ||
|
||
@suspensive/react-await는 npm에 있습니다. 최신 안정버전을 설치하기 위해 아래 커맨드를 실행하세요 | ||
|
||
[![npm version](https://img.shields.io/npm/v/@suspensive/react-await?color=000&labelColor=000&logo=npm&label=)](https://www.npmjs.com/package/@suspensive/react-await) | ||
|
||
```shell npm2yarn | ||
npm install @suspensive/react-await | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** @type {import('eslint').Linter.Config} */ | ||
module.exports = { | ||
root: true, | ||
extends: ['@suspensive/eslint-config/react-ts'], | ||
ignorePatterns: ['*.js*', 'dist', 'coverage'], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# @suspensive/react-await | ||
|
||
## 0.0.1 | ||
|
||
### Patch Changes | ||
|
||
- 7e01577: fix(react): remove `<Await/>` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Suspensive | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# 라이브러리 소개 | ||
|
||
[![npm version](https://img.shields.io/npm/v/@suspensive/react-await?color=000&labelColor=000&logo=npm&label=)](https://www.npmjs.com/package/@suspensive/react-await) | ||
[![npm](https://img.shields.io/npm/dm/@suspensive/react-await?color=000&labelColor=000)](https://www.npmjs.com/package/@suspensive/react-await) | ||
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/@suspensive/react-await?color=000&labelColor=000)](https://www.npmjs.com/package/@suspensive/react-await) | ||
|
||
## 설치하기 | ||
|
||
@suspensive/react-await 는 npm에 있습니다. 최신 안정버전을 설치하기 위해 아래 커맨드를 실행하세요 | ||
|
||
```shell npm2yarn | ||
npm install @suspensive/react-await | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Introduction | ||
|
||
[![npm version](https://img.shields.io/npm/v/@suspensive/react-await?color=000&labelColor=000&logo=npm&label=)](https://www.npmjs.com/package/@suspensive/react-await) | ||
[![npm](https://img.shields.io/npm/dm/@suspensive/react-await?color=000&labelColor=000)](https://www.npmjs.com/package/@suspensive/react-await) | ||
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/@suspensive/react-await?color=000&labelColor=000)](https://www.npmjs.com/package/@suspensive/react-await) | ||
|
||
## Installation | ||
|
||
@suspensive/react-await lives in npm. To install the latest stable version, run the following command | ||
|
||
```shell npm2yarn | ||
npm install @suspensive/react-await | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
{ | ||
"name": "@suspensive/react-await", | ||
"version": "0.0.1", | ||
"description": "Useful interfaces for React Suspense", | ||
"keywords": [ | ||
"suspensive", | ||
"react" | ||
], | ||
"homepage": "https://suspensive.org", | ||
"bugs": "https://github.com/suspensive/react/issues", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/suspensive/react.git", | ||
"directory": "packages/react" | ||
}, | ||
"funding": { | ||
"type": "github", | ||
"url": "https://github.com/sponsors/manudeli" | ||
}, | ||
"license": "MIT", | ||
"author": { | ||
"name": "Jonghyeon Ko", | ||
"email": "[email protected]" | ||
}, | ||
"sideEffects": false, | ||
"type": "module", | ||
"exports": { | ||
".": { | ||
"import": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/index.js" | ||
}, | ||
"require": { | ||
"types": "./dist/index.d.cts", | ||
"default": "./dist/index.cjs" | ||
} | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"main": "dist/index.cjs", | ||
"types": "dist/index.d.ts", | ||
"files": [ | ||
"dist", | ||
"src" | ||
], | ||
"scripts": { | ||
"build": "tsup", | ||
"build:watch": "tsup --watch", | ||
"clean": "rimraf ./dist && rimraf ./coverage", | ||
"lint": "eslint \"**/*.ts*\"", | ||
"lint:attw": "attw --pack", | ||
"lint:pub": "publint --strict", | ||
"prepack": "pnpm build", | ||
"test": "vitest run --coverage", | ||
"test:watch": "vitest --ui --coverage.enabled=true", | ||
"type:check": "tsc --noEmit" | ||
}, | ||
"dependencies": { | ||
"use-sync-external-store": "^1.2.0" | ||
}, | ||
"devDependencies": { | ||
"@suspensive/react": "workspace:*", | ||
"@suspensive/tsup": "workspace:*", | ||
"@suspensive/vitest": "workspace:*", | ||
"@types/node": "^18.16.2", | ||
"@types/react": "^18.2.0", | ||
"@types/react-dom": "^18.2.1", | ||
"@types/use-sync-external-store": "^0.0.4", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0" | ||
}, | ||
"peerDependencies": { | ||
"react": "^16.8 || ^17 || ^18" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
...ges/react/src/experimental/Await.spec.tsx → packages/react-await/src/Await.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/react/src/experimental/Await.tsx → packages/react-await/src/Await.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type { Tuple } from './Tuple' |
53 changes: 53 additions & 0 deletions
53
packages/react-await/src/utils/hasResetKeysChanged.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { hasResetKeysChanged } from '.' | ||
|
||
const primitive = 0 | ||
const reference1 = { test: 0 } | ||
const reference2 = { test: 0 } | ||
|
||
describe('hasResetKeysChanged', () => { | ||
it('should return true if the two arrays have different lengths.', () => { | ||
const array1 = Array.from({ length: 1 }).map((_, index) => primitive + index) | ||
const array2 = Array.from({ length: 2 }).map((_, index) => primitive + index) | ||
|
||
expect(hasResetKeysChanged(array1, array2)).toBe(true) | ||
}) | ||
|
||
it('should return false if the two arrays have same lengths and same primitive element in each index of arrays.', () => { | ||
const array1 = Array.from({ length: 1 }).map((_, index) => primitive + index) | ||
const array2 = Array.from({ length: 1 }).map((_, index) => primitive + index) | ||
|
||
expect(hasResetKeysChanged(array1, array2)).toBe(false) | ||
}) | ||
|
||
it('should return true if the two arrays have same lengths but at least one primitive element is different in each index of arrays.', () => { | ||
const array1 = [primitive, primitive + 1] | ||
const array2 = [primitive, primitive] | ||
|
||
expect(hasResetKeysChanged(array1, array2)).toBe(true) | ||
}) | ||
|
||
it('should return true if the two arrays have same lengths and have all same primitive elements but order is different', () => { | ||
const array1 = [primitive, primitive + 1] | ||
const array2 = [primitive + 1, primitive] | ||
|
||
expect(hasResetKeysChanged(array1, array2)).toBe(true) | ||
}) | ||
|
||
it('should return true when two arrays have each references elements in index of array have different references', () => { | ||
const array1 = [reference1, { test: 2 }] | ||
const array2 = [reference1, { test: 2 }] | ||
|
||
expect(hasResetKeysChanged(array1, array2)).toBe(true) | ||
}) | ||
|
||
it('should return false when two arrays have each references elements in index of array have same references', () => { | ||
const array1 = [reference1, reference2] | ||
const array2 = [reference1, reference2] | ||
|
||
expect(hasResetKeysChanged(array1, array2)).toBe(false) | ||
}) | ||
|
||
it('should return false when no arrays as parameters. because of default value', () => { | ||
expect(hasResetKeysChanged()).toBe(false) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const hasResetKeysChanged = (a: unknown[] = [], b: unknown[] = []) => | ||
a.length !== b.length || a.some((item, index) => !Object.is(item, b[index])) |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
packages/react/src/utils/hashKey.ts → packages/react-await/src/utils/hashKey.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { hasResetKeysChanged } from './hasResetKeysChanged' | ||
export { hashKey } from './hashKey' |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type { ReactNode } from 'react' | ||
|
||
const suspendIsNeed = { current: true } | ||
type SuspendProps = { during: number; toShow?: ReactNode } | ||
export const Suspend = ({ during, toShow }: SuspendProps) => { | ||
if (suspendIsNeed.current) { | ||
throw new Promise((resolve) => | ||
setTimeout(() => { | ||
suspendIsNeed.current = false | ||
resolve('resolved') | ||
}, during) | ||
) | ||
} | ||
return <>{toShow}</> | ||
} | ||
Suspend.reset = () => { | ||
suspendIsNeed.current = true | ||
} | ||
|
||
export const delay = (ms: number) => new Promise((resolve) => setTimeout(() => resolve('done'), ms)) | ||
|
||
export const TEXT = 'TEXT' as const | ||
export const ERROR_MESSAGE = 'ERROR_MESSAGE' as const | ||
export const FALLBACK = 'FALLBACK' as const | ||
export const MS_100 = 100 as const |
Oops, something went wrong.