Skip to content

Commit 888ed56

Browse files
committed
Add type definitions
1 parent 90f0be1 commit 888ed56

9 files changed

+803
-16
lines changed

.eslintrc.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
root: true,
3+
extends: '@react-native-community',
4+
};

.npmignore

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
img
2+
example
3+
e2e
4+
test
5+
circle.yml
6+
.npmignore
7+
8+
# OSX
9+
#
10+
.DS_Store
11+
12+
# Xcode
13+
#
14+
build/
15+
*.pbxuser
16+
!default.pbxuser
17+
*.mode1v3
18+
!default.mode1v3
19+
*.mode2v3
20+
!default.mode2v3
21+
*.perspectivev3
22+
!default.perspectivev3
23+
xcuserdata
24+
*.xccheckout
25+
*.moved-aside
26+
DerivedData
27+
*.hmap
28+
*.ipa
29+
*.xcuserstate
30+
project.xcworkspace
31+
32+
# Android/IJ
33+
#
34+
.idea
35+
.gradle
36+
local.properties
37+
*.iml
38+
local.properties
39+
.idea/workspace.xml
40+
.idea/libraries
41+
build
42+
captures
43+
44+
# node.js
45+
#
46+
node_modules/
47+
npm-debug.log
48+
49+
# BUCK
50+
buck-out/
51+
\.buckd/
52+
android/app/libs
53+
android/keystores/debug.keystore

dist/index.d.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export interface BlurhashProps {
2+
blurhash: string;
3+
width: number;
4+
height: number;
5+
punch: number;
6+
}
7+
declare const Blurhash: any;
8+
export default Blurhash;

dist/index.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"use strict";
2+
var __importDefault = (this && this.__importDefault) || function (mod) {
3+
return (mod && mod.__esModule) ? mod : { "default": mod };
4+
};
5+
Object.defineProperty(exports, "__esModule", { value: true });
6+
const react_1 = __importDefault(require("react"));
7+
const react_native_1 = require("react-native");
8+
class BlurhashView extends react_1.default.Component {
9+
constructor(props) {
10+
super(props);
11+
}
12+
render() {
13+
return (<Blurhash {...this.props}/>);
14+
}
15+
}
16+
// requireNativeComponent automatically resolves 'BlurhashView' to 'BlurhashViewManager'
17+
const Blurhash = react_native_1.requireNativeComponent('BlurhashView');
18+
exports.default = Blurhash;

index.js

-4
This file was deleted.

index.tsx

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from 'react';
2+
import { requireNativeComponent } from 'react-native';
3+
4+
5+
export interface BlurhashProps {
6+
blurhash: string;
7+
width: number;
8+
height: number;
9+
punch: number;
10+
}
11+
12+
class BlurhashView extends React.Component<BlurhashProps> {
13+
constructor(props: BlurhashProps) {
14+
super(props);
15+
}
16+
17+
render() {
18+
return (<Blurhash {...this.props} />);
19+
}
20+
}
21+
22+
23+
// requireNativeComponent automatically resolves 'BlurhashView' to 'BlurhashViewManager'
24+
const Blurhash = requireNativeComponent<BlurhashProps>('BlurhashView');
25+
export default Blurhash;

package.json

+15-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,21 @@
33
"title": "React Native Blurhash",
44
"version": "1.0.0",
55
"description": "BlurHash is a compact representation of a placeholder for an image. This is a Native UI Module for React Native to wrap the Blurhash implementations and make them usable in React Native.",
6-
"main": "index.js",
6+
"main": "dist/index.js",
7+
"types": "dist/index.d.ts",
78
"files": [
89
"README.md",
9-
"android",
10-
"index.js",
11-
"ios",
10+
"android/src",
11+
"android/build.gradle",
12+
"ios/Blurhash.xcodeproj/project.pbxproj",
13+
"ios/BlurhashBridge.h",
14+
"ios/BlurhashDecode.swift",
15+
"ios/BlurhashEncode.swift",
16+
"ios/BlurhashView.swift",
17+
"ios/BlurhashViewManager.m",
18+
"ios/BlurhashViewManager.swift",
19+
"ios/UIImage+Color.swift",
20+
"dist",
1221
"react-native-blurhash.podspec"
1322
],
1423
"scripts": {
@@ -34,6 +43,8 @@
3443
"react-native": ">=0.60.0-rc.0 <1.0.x"
3544
},
3645
"devDependencies": {
46+
"@types/react": "^16.9.36",
47+
"@types/react-native": "^0.62.13",
3748
"@typescript-eslint/eslint-plugin": "^3.2.0",
3849
"@typescript-eslint/parser": "^3.2.0",
3950
"eslint": "^7.2.0",

tsconfig.json

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"compilerOptions": {
3+
/* Basic Options */
4+
"target": "esnext" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */,
5+
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
6+
"lib": [
7+
"es6",
8+
"DOM"
9+
] /* Specify library files to be included in the compilation. */,
10+
"allowJs": true /* Allow javascript files to be compiled. */,
11+
// "checkJs": true, /* Report errors in .js files. */
12+
"jsx": "react-native" /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */,
13+
"declaration": true /* Generates corresponding '.d.ts' file. */,
14+
// "sourceMap": true, /* Generates corresponding '.map' file. */
15+
// "outFile": "./", /* Concatenate and emit output to single file. */
16+
"outDir": "./dist" /* Redirect output structure to the directory. */,
17+
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
18+
// "removeComments": true, /* Do not emit comments to output. */
19+
"noEmit": true /* Do not emit outputs. */,
20+
// "incremental": true, /* Enable incremental compilation */
21+
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
22+
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
23+
"isolatedModules": true /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */,
24+
/* Strict Type-Checking Options */
25+
"strict": true /* Enable all strict type-checking options. */,
26+
"noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */,
27+
// "strictNullChecks": true, /* Enable strict null checks. */
28+
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
29+
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
30+
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
31+
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
32+
/* Additional Checks */
33+
// "noUnusedLocals": true, /* Report errors on unused locals. */
34+
// "noUnusedParameters": true, /* Report errors on unused parameters. */
35+
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
36+
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
37+
/* Module Resolution Options */
38+
"moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
39+
"baseUrl": "./" /* Base directory to resolve non-absolute module names. */,
40+
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
41+
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
42+
// "typeRoots": [], /* List of folders to include type definitions from. */
43+
// "types": [], /* Type declaration files to be included in compilation. */
44+
"allowSyntheticDefaultImports": true /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */,
45+
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
46+
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
47+
/* Source Map Options */
48+
// "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
49+
// "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */
50+
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
51+
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
52+
/* Experimental Options */
53+
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
54+
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
55+
},
56+
"files": [
57+
"index.tsx"
58+
],
59+
"include": [
60+
"index.tsx"
61+
],
62+
}

0 commit comments

Comments
 (0)