-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
5,255 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# EditorConfig is awesome: https://EditorConfig.org | ||
# install EditorConfig for VS Code extension | ||
# top-most EditorConfig file | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 2 | ||
indent_style = space | ||
insert_final_newline = true | ||
max_line_length = 80 | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
max_line_length = 0 | ||
trim_trailing_whitespace = 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 @@ | ||
**/node_modules |
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,67 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"es6": true, | ||
"node": true, | ||
"jest": true | ||
}, | ||
"extends": [ | ||
"airbnb", | ||
"prettier", | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/eslint-recommended", | ||
"plugin:@typescript-eslint/recommended" | ||
], | ||
"globals": { | ||
"Atomics": "readonly", | ||
"SharedArrayBuffer": "readonly" | ||
}, | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaVersion": 2019, | ||
"sourceType": "module" | ||
}, | ||
"plugins": [ | ||
"prettier", | ||
"@typescript-eslint" | ||
], | ||
"rules": { | ||
"no-useless-constructor": 0, | ||
"class-methods-use-this": 0, | ||
"no-underscore-dangle": 0, | ||
"@typescript-eslint/no-non-null-assertion": 0, | ||
"@typescript-eslint/interface-name-prefix": 0, | ||
"@typescript-eslint/explicit-function-return-type": 0, | ||
"max-classes-per-file": 0, | ||
"no-await-in-loop": "off", | ||
"no-restricted-syntax": "off", | ||
"import/no-extraneous-dependencies": [ | ||
"error", | ||
{ | ||
"devDependencies": true | ||
} | ||
], | ||
"import/prefer-default-export": "off", | ||
"prettier/prettier": [ | ||
"error" | ||
], | ||
"import/extensions": [ | ||
"error", | ||
"ignorePackages", | ||
{ | ||
"js": "never", | ||
"ts": "never" | ||
} | ||
] | ||
}, | ||
"settings": { | ||
"import/resolver": { | ||
"node": { | ||
"extensions": [ | ||
".js", | ||
".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,26 @@ | ||
name: Node CI | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [16.x, 18.x, 20.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: yarn install, build, and test | ||
run: | | ||
yarn install | ||
yarn build | ||
yarn test | ||
env: | ||
CI: true |
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,24 @@ | ||
name: Publish Package to npmjs | ||
on: | ||
release: | ||
types: [created] | ||
jobs: | ||
publish-npm: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
id-token: write | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18.x' | ||
registry-url: 'https://registry.npmjs.org' | ||
- run: yarn | ||
- run: yarn build | ||
- run: yarn test | ||
- run: npm publish --provenance | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}} | ||
CI: true | ||
|
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 @@ | ||
example |
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 @@ | ||
{ | ||
"singleQuote": true, | ||
"trailingComma": "es5" | ||
} |
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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# use-travel | ||
A React hook for state time travel with undo, redo, and reset functionalities. | ||
|
||
TODO |
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 @@ | ||
declare var __DEV__: boolean |
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 * from './src'; |
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,86 @@ | ||
{ | ||
"name": "use-travel", | ||
"version": "0.0.1", | ||
"description": "A React hook for state time travel with undo, redo, and reset functionalities.", | ||
"main": "dist/index.cjs.js", | ||
"unpkg": "dist/index.umd.js", | ||
"types": "dist/index.d.ts", | ||
"umd:main": "dist/index.umd.js", | ||
"module": "dist/index.esm.js", | ||
"jsnext:main": "dist/index.esm.js", | ||
"react-native": "dist/index.esm.js", | ||
"typings": "dist/index.d.ts", | ||
"source": "src/index.ts", | ||
"sideEffects": false, | ||
"files": [ | ||
"dist" | ||
], | ||
"scripts": { | ||
"test": "jest", | ||
"clean": "rimraf dist", | ||
"build": "yarn clean && tsc --skipLibCheck && yarn build:prod", | ||
"build:prod": "NODE_ENV=production rollup --config --bundleConfigAsCjs", | ||
"commit": "yarn git-cz" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/unadlib/use-travel.git" | ||
}, | ||
"author": "unadlib", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/unadlib/use-travel/issues" | ||
}, | ||
"homepage": "https://github.com/unadlib/use-travel#readme", | ||
"keywords": [ | ||
"use-undo", | ||
"undo", | ||
"redo", | ||
"time travel", | ||
"mutative" | ||
], | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "^24.0.1", | ||
"@rollup/plugin-node-resolve": "^15.0.1", | ||
"@rollup/plugin-replace": "^5.0.2", | ||
"@types/jest": "^29.5.0", | ||
"@types/node": "^18.15.5", | ||
"@typescript-eslint/eslint-plugin": "^5.56.0", | ||
"@typescript-eslint/parser": "^5.56.0", | ||
"commitizen": "^4.3.0", | ||
"eslint": "^8.36.0", | ||
"eslint-config-airbnb": "^19.0.4", | ||
"eslint-config-prettier": "^8.8.0", | ||
"eslint-plugin-import": "^2.27.5", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"jest": "^29.5.0", | ||
"jest-environment-jsdom": "^29.5.0", | ||
"mutative": "^1.0.3", | ||
"prettier": "^2.8.6", | ||
"rimraf": "^4.4.0", | ||
"rollup": "^3.20.0", | ||
"rollup-plugin-terser": "^7.0.0", | ||
"ts-jest": "^29.1.0", | ||
"ts-node": "^10.9.1", | ||
"tslib": "^2.5.0", | ||
"typedoc": "^0.23.28", | ||
"typedoc-plugin-markdown": "^3.14.0", | ||
"typescript": "^5.0.2", | ||
"yargs": "^17.7.1" | ||
}, | ||
"config": { | ||
"commitizen": { | ||
"path": "cz-conventional-changelog" | ||
} | ||
}, | ||
"jest": { | ||
"preset": "ts-jest", | ||
"testEnvironment": "jsdom", | ||
"globals": { | ||
"__DEV__": false | ||
} | ||
}, | ||
"peerDependencies": { | ||
"mutative": "^1.0.3" | ||
} | ||
} |
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,48 @@ | ||
import resolve from '@rollup/plugin-node-resolve'; | ||
import commonjs from '@rollup/plugin-commonjs'; | ||
import replace from '@rollup/plugin-replace'; | ||
import { terser } from 'rollup-plugin-terser'; | ||
import pkg from './package.json'; | ||
|
||
const input = './dist/index.js'; | ||
|
||
export default { | ||
input, | ||
output: [ | ||
{ | ||
format: 'cjs', | ||
exports: 'auto', | ||
file: 'dist/index.cjs.js', | ||
sourcemap: true, | ||
exports: 'named', | ||
}, | ||
{ | ||
format: 'es', | ||
file: 'dist/index.esm.js', | ||
sourcemap: true, | ||
}, | ||
{ | ||
format: 'umd', | ||
name: pkg.name | ||
.split('-') | ||
.map(([s, ...rest]) => [s.toUpperCase(), ...rest].join('')) | ||
.join(''), | ||
file: pkg.unpkg, | ||
sourcemap: true, | ||
globals: { | ||
mutative: 'Mutative', | ||
}, | ||
exports: 'named', | ||
}, | ||
], | ||
plugins: [ | ||
resolve(), | ||
commonjs(), | ||
replace({ | ||
__DEV__: 'false', | ||
preventAssignment: true, | ||
}), | ||
terser(), | ||
], | ||
external: ['mutative'], | ||
}; |
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,3 @@ | ||
export const useTravel = (state: any) => { | ||
// | ||
}; |
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,3 @@ | ||
test('base', () => { | ||
// test code | ||
}); |
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,73 @@ | ||
{ | ||
"compilerOptions": { | ||
/* Basic Options */ | ||
// "incremental": true, /* Enable incremental compilation */ | ||
"target": "es2015" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */, | ||
"module": "es2015" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */, | ||
"lib": [ | ||
"ES2019", | ||
"DOM" | ||
] /* Specify library files to be included in the compilation. */, | ||
// "allowJs": true, /* Allow javascript files to be compiled. */ | ||
// "checkJs": true, /* Report errors in .js files. */ | ||
// "jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ | ||
"declaration": true /* Generates corresponding '.d.ts' file. */, | ||
"declarationMap": true /* Generates a sourcemap for each corresponding '.d.ts' file. */, | ||
// "sourceMap": true, /* Generates corresponding '.map' file. */ | ||
// "outFile": "./", /* Concatenate and emit output to single file. */ | ||
"outDir": "./dist" /* Redirect output structure to the directory. */, | ||
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ | ||
// "composite": true, /* Enable project compilation */ | ||
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ | ||
// "removeComments": true, /* Do not emit comments to output. */ | ||
// "noEmit": true, /* Do not emit outputs. */ | ||
"importHelpers": true /* Import emit helpers from 'tslib'. */, | ||
"downlevelIteration": true /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */, | ||
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ | ||
|
||
/* Strict Type-Checking Options */ | ||
"strict": true /* Enable all strict type-checking options. */, | ||
"noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */, | ||
// "strictNullChecks": true, /* Enable strict null checks. */ | ||
// "strictFunctionTypes": true, /* Enable strict checking of function types. */ | ||
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ | ||
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ | ||
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ | ||
"alwaysStrict": true /* Parse in strict mode and emit "use strict" for each source file. */, | ||
|
||
/* Additional Checks */ | ||
// "noUnusedLocals": true, /* Report errors on unused locals. */ | ||
// "noUnusedParameters": true, /* Report errors on unused parameters. */ | ||
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ | ||
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ | ||
|
||
/* Module Resolution Options */ | ||
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ | ||
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ | ||
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ | ||
"rootDirs": [ | ||
"node_modules/@types" | ||
] /* List of root folders whose combined content represents the structure of the project at runtime. */, | ||
// "types": [ | ||
// ], /* Type declaration files to be included in compilation. */ | ||
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ | ||
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, | ||
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ | ||
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ | ||
|
||
/* Source Map Options */ | ||
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ | ||
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ | ||
"inlineSourceMap": true /* Emit a single file with source maps instead of having a separate file. */, | ||
"inlineSources": true /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */, | ||
|
||
/* Experimental Options */ | ||
"experimentalDecorators": true /* Enables experimental support for ES7 decorators. */, | ||
"emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */, | ||
"useDefineForClassFields": false, | ||
|
||
/* Advanced Options */ | ||
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ | ||
}, | ||
"include": ["src/*", "global.d.ts"] | ||
} |
Oops, something went wrong.