From d9524e893cb34f23155a4ebd3f1424a947333898 Mon Sep 17 00:00:00 2001 From: Kevin Strider Date: Mon, 23 May 2022 09:43:57 -0700 Subject: [PATCH] node-apis.mdx (Creating Plugins - Using Node.js APIs) Summary: Restyle of page, including changes to spelling, grammar, links, and structure (where relevant). Reviewed By: mweststrate Differential Revision: D36596005 fbshipit-source-id: 9ae71f426fad792af6e13f949581e26f8366baa4 --- docs/extending/node-apis.mdx | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/docs/extending/node-apis.mdx b/docs/extending/node-apis.mdx index 7fba780ab..9cc0d62e3 100644 --- a/docs/extending/node-apis.mdx +++ b/docs/extending/node-apis.mdx @@ -3,16 +3,15 @@ id: node-apis title: Using Node.js APIs --- -Flipper plugins should be designed to work inside browsers as well, as Flipper isn't guaranteed to be always running on top of Electron. -For that reason it should be avoided to use Node.js APIs directly (e.g. modules like `fs`, `child_process`, `path`), -or packages that depend on those. +Flipper plugins should be designed to work inside browsers as Flipper isn't guaranteed to always run on top of Electron. +For that reason, you should avoid using Node.js APIs directly (with, for example, modules like `fs`, `child_process`, `path`), or packages that depend on the plugins. -The most important Node APIs can be found by using `getFlipperLib()` (exposed by the `flipper-plugin` package). Please note that these APIs are all promisified. +The most important Node APIs can be found by using `getFlipperLib()` (exposed by the `flipper-plugin` package). Please note that these APIs are all promisified: -* `fs`: Use `getFlipperLib().remoteServerContext.fs` instead. -* `child_process`: Use `getFlipperLib().remoteServerContext.childProcess.exec`. Note that this API is intended for short lived processes only. -* `path`: Use `import {path} from 'flipper-plugin'` instead. -* `os`: Use `getFlipperLib().environmentInfo.os` instead. - * For system specific directories like home, desktop, etc, use `getFlipperLib().paths.homePath` and alike. +* `fs` - use `getFlipperLib().remoteServerContext.fs` instead. +* `child_process` - use `getFlipperLib().remoteServerContext.childProcess.exec`. Note that this API is intended for short lived processes only. +* `path` - use `import {path} from 'flipper-plugin'` instead. +* `os` - use `getFlipperLib().environmentInfo.os` instead. + * For system-specific directories such as 'home' and 'desktop', use `getFlipperLib().paths.homePath` and similar. -In the future, these APIs might be subject to further security / permission restrictions to sandbox plugins better. +In the future, these APIs may be subject to further security / permission restrictions to better sandbox plugins.