GT2/GT2-iOS/node_modules/react-native-safe-module/package.json

119 lines
9.8 KiB
JSON

{
"_args": [
[
{
"raw": "react-native-safe-module@^1.1.0",
"scope": null,
"escapedName": "react-native-safe-module",
"name": "react-native-safe-module",
"rawSpec": "^1.1.0",
"spec": ">=1.1.0 <2.0.0",
"type": "range"
},
"/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/lottie-react-native"
]
],
"_from": "react-native-safe-module@>=1.1.0 <2.0.0",
"_id": "react-native-safe-module@1.2.0",
"_inCache": true,
"_location": "/react-native-safe-module",
"_nodeVersion": "6.9.1",
"_npmOperationalInternal": {
"host": "packages-18-east.internal.npmjs.com",
"tmp": "tmp/react-native-safe-module-1.2.0.tgz_1493710209901_0.4773560962639749"
},
"_npmUser": {
"name": "intelligibabble",
"email": "leland.m.richardson@gmail.com"
},
"_npmVersion": "3.10.8",
"_phantomChildren": {},
"_requested": {
"raw": "react-native-safe-module@^1.1.0",
"scope": null,
"escapedName": "react-native-safe-module",
"name": "react-native-safe-module",
"rawSpec": "^1.1.0",
"spec": ">=1.1.0 <2.0.0",
"type": "range"
},
"_requiredBy": [
"/lottie-react-native"
],
"_resolved": "https://registry.npmjs.org/react-native-safe-module/-/react-native-safe-module-1.2.0.tgz",
"_shasum": "a23824ca24edc2901913694a76646475113d570d",
"_shrinkwrap": null,
"_spec": "react-native-safe-module@^1.1.0",
"_where": "/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/lottie-react-native",
"author": {
"name": "Leland Richardson",
"email": "leland.m.richardson@gmail.com"
},
"bugs": {
"url": "https://github.com/lelandrichardson/react-native-safe-module/issues"
},
"dependencies": {
"dedent": "^0.6.0"
},
"description": "A safe way to consume React Native NativeModules",
"devDependencies": {
"babel-cli": "^6.14.0",
"babel-core": "^6.14.0",
"babel-preset-react-native": "^1.9.0",
"chai": "^3.5.0",
"eslint": "^3.5.0",
"eslint-config-airbnb": "^11.0.0",
"eslint-plugin-import": "^1.14.0",
"eslint-plugin-jsx-a11y": "^2.2.1",
"eslint-plugin-react": "^6.2.0",
"mocha": "^3.0.2",
"react": "^15.2.0",
"react-native": "^0.30.0",
"react-native-mock": "^0.2.6",
"sinon": "^1.17.5",
"sinon-chai": "^2.8.0"
},
"directories": {},
"dist": {
"shasum": "a23824ca24edc2901913694a76646475113d570d",
"tarball": "https://registry.npmjs.org/react-native-safe-module/-/react-native-safe-module-1.2.0.tgz"
},
"gitHead": "0d4eb529d9229ff43ff0647c9c88410a06832ca7",
"homepage": "https://github.com/lelandrichardson/react-native-safe-module#readme",
"keywords": [
"react-native",
"react",
"native-modules",
"code-push"
],
"license": "MIT",
"main": "lib/index.js",
"maintainers": [
{
"name": "intelligibabble",
"email": "leland.m.richardson@gmail.com"
}
],
"name": "react-native-safe-module",
"optionalDependencies": {},
"peerDependencies": {
"react-native": "*"
},
"readme": "# react-native-safe-module\n\nA safe way to consume React Native NativeModules\n\n\n[![npm Version](https://img.shields.io/npm/v/react-native-safe-module.svg)](https://www.npmjs.com/package/react-native-safe-module) [![License](https://img.shields.io/npm/l/react-native-safe-module.svg)](https://www.npmjs.com/package/react-native-safe-module) [![Build Status](https://travis-ci.org/lelandrichardson/react-native-safe-module.svg)](https://travis-ci.org/airbnb/react-native-safe-module)\n\n\n## Motivation\n\nReact Native enables a new aspect of mobile development: \"Code Push\".\nCode Push provides developers a way to push updates to their JS code base\nto mobile clients without going through the app store.\n\nSince you can code push to older versions of the native client app, this \ntype of deployment creates a new point of failure though: JavaScript\ncode that is incompatible with the native version of the app it's running\non.\n\nReact Native JS interacts with the Native code entirely through \"Native Modules\",\nwhich are injected at run-time onto the `ReactNative.NativeModules`\nnamespace. As a result, having code that interacts with these modules\ndirectly can result in run-time errors. This library allows you to more\nsafely interact with native modules, and provide version-specific overrides\nfor the module, as well as mocks to use in the case that the method or module\nis entirely absent. The result is more robust code that can be code pushed\nto more users, as well as code that can be tested in an environment without\na host app (e.g, Node).\n\n\n\n## Installation\n\n```bash\nnpm i --save react-native-safe-module\n```\n\n## Usage\n\nImporting `SafeModule` is as simple as:\n\n```js\nimport SafeModule from 'react-native-safe-module';\n```\n\n### Basic Usage\n\nIf you were using a Native Module before, such as `NativeModules.FooModule`\nlike this:\n\n```js\nimport { NativeModules } from 'react-native';\nconst { FooModule } = NativeModules;\n\n// ...\n\nFooModule.doSomething().then(...)\n\n```\n\nYou can instead do:\n\n```js\nimport SafeModule from 'react-native-safe-module';\nconst FooModule = SafeModule.create({\n moduleName: 'FooModule',\n mock: {\n doSomething: () => Promise.resolve(...),\n },\n});\n\n// ...\n\nFooModule.doSomething().then(...)\n```\n\n\n### Version-Specific Overrides\n\nBy default, `SafeModule` assumes that you are exporting a constant `VERSION`\nwith each Native Module that can be used to identify which version of the\nnative module it is. If you would like to specify the version a different\nway, you are able to add a `getVersion` option to the SafeModule configuration\nwhich is a function expected to return the correct version of the module.\n\nOften times you may need to make a breaking change to the API of your Native Module,\nbut it can be made backwards compatible with SafeModule very easily.\n\nFor example, imagine we have a `Scrolling` module with a `scrollTo(...)`\nmethod. \n\nIn version \"7\" of the module, the method signature of `scrollTo`\nlooked something like `scrollTo(x: number, y: number, animated: true)`.\n\nIn the latest version of the module, we have changed the method signature\nto look something like: `scrollTo(options: {x: number, y: number, animated: true})`.\n\nThis is a breaking change, but we can make it backwards compatible with SafeModule:\n\n```js\n// Scrolling.js\nimport SafeModule from 'react-native-safe-module';\n\nmodule.exports = SafeModule.create({\n moduleName: 'MyCustomScrollingModule',\n mock: {\n scrollTo: () => { /* do nothing */},\n },\n overrides: {\n 7: {\n // overrides are defined as higher-order functions which are first\n // called with the real module's method, and are expected to return\n // a new function with the current API.\n scrollTo: oldScrollTo => options => {\n return oldScrollTo(options.x, options.y, !!options.animated);\n },\n },\n },\n});\n```\n\n\n### Module Name Changes\n\nSometimes we want to change the name of a Native Module. In this case,\nwe need to support both versions of the name. SafeModule allows you to\nspecify `moduleName` as an array of names. It will use the first name\nit finds.\n\nFor example, consider the case where we have a module named `FooExperimentalModule`,\nand we want to change the name of it to be just `FooModule`.\n\n```js\n// FooModule.js\nimport SafeModule from 'react-native-safe-module';\n\nmodule.exports = SafeModule.create({\n moduleName: ['FooModule', 'FooExperimentalModule'],\n mock: {\n ...\n },\n});\n```\n\nIn this case, `SafeModule` will look for `FooModule` first, and then\n`FooExperimentalModule` if it is not found. Finally, it will fall back\nto the `mock` implementation if none is found.\n\n\n\n\n## API\n\n### `SafeModule.create(options)`\n\n*Parameters:*\n\n - `options.moduleName`: (**required**, `string | Array<string>`) the name,\n or array of names, to look for the module at on the `NativeModules` namespace.\n - `options.mock`: (**required**, `mixed`) The mock implementation of the native module.\n - `options.getVersion`: (`(module) => string|number`) Optional. A function that returns \n the version of the native module. Only needed if you are specifying overrides and not\n exporting a `VERSION` property on your native module. Defaults to `x => x.VERSION`.\n - `options.overrides`: (`{[version: string]: mixed`) Optional. A map of version numbers to\n overridden implementations of the corresponding property/method. If an overridden property\n or method is a function, it will be called during `SafeModule.create(...)` with two arguments,\n the original value of that property on the original module, and the original module itself. The\n return value of this function will be put on the return value of `SafeModule.create(...)`.\n - `options.isEventEmitter`: (`bool`) Optional. A flag indicating that the native module\n is expected to be an `EventEmitter`. Puts the `EventEmitter` instance on the `emitter` \n property of the resulting module. Defaults to `false`.\n\n\n\n\n## TODO\n\n- [ ] Implement `onInit` lifecycle method\n- [ ] Implement `onNoModuleFound` lifecycle method\n- [ ] Implement `onVersionFound` lifecycle method\n- [ ] Implement `onOverrideUsed` lifecycle method\n- [ ] Implement `onOverrideCalled` lifecycle method\n",
"readmeFilename": "README.md",
"repository": {
"type": "git",
"url": "git+https://github.com/lelandrichardson/react-native-safe-module.git"
},
"scripts": {
"build": "rm -rf lib && babel -d lib src",
"lint": "eslint ./src ./test",
"prepublish": "npm run --silent build",
"test": "npm run --silent lint && npm run --silent test:all",
"test:all": "npm run --silent test:base -- --recursive test/",
"test:base": "mocha --require ./test/_setup.js --require react-native-mock/mock.js --compilers js:babel-core/register",
"test:watch": "npm run --silent test:base -- --recursive test/ --watch"
},
"version": "1.2.0"
}