2.2.27 • Published 9 days ago

@riboseinc/paneron-extension-kit v2.2.27

Weekly downloads
162
License
MIT
Repository
github
Last release
9 days ago

= Paneron extension kit

== Extension development

Paneron extensions are written in TypeScript based on React, and can make use of Blueprint 3 UI components.

An extension is essentially a React component that is given as props some functions that simplify interaction with underlying data repository.

=== Setup

. Create a new repository using Paneron extension template repository (https://github.com/paneron/extension-template-basic).

. For testing purposes, obtain Paneron source code (clone https://github.com/paneron/paneron) and build the project locally.

. Create a directory named paneron-extension-dev somewhere on your machine.

==== Iteration

After you make changes:

. Rebuild your extension from its repository root: +

source,sh

$ yarn build

. Copy the contents of dist/ into paneron-extension-dev/@riboseinc/paneron-extension-<your-extension-name>.

. Launch your local build of Paneron using a command like this, from within Paneron repository root: +

source,sh

$ env PANERON_PLUGIN_DIR=/path/to/your/paneron-extension-dev/directory yarn dev

==== Release

An extension must be released as a separate NPM package, specifying entry as plugin.js (see template extension for example packaging).

When ready & tested, release your extension on NPM:

source,sh

$ npm publish

NOTE: Currently, only extensions released under @riboseinc NPM scope are supported. Plugin name must be prefixed with paneron-extension- (e.g., @riboseinc/paneron-extension-foo-registry).

=== Rules of Paneron extensions

There are some extra constraints placed upon extension component code, mostly due to limitations of extension mechanism at this point in time.

. An extension must not have any dependencies specified in package.json. Anything you want to import should be provided by Paneron (see below what is). (You can use devDependencies, though.)

. An extension cannot call browser window’s native functions. If you need setTimeout(), use setTimeout prop passed to your top-level extension component.

. An extension cannot import and use React’s tools (e.g., hooks like useState()). Instead, React instance passed via the React prop must be used.

If these rules are not observed, you may end up getting a confusing blank screen after opening a repository using your extension and “DevTools was disconnected from the page” in console.

Here’s how using a useState() hook might look like:

source,tsx

// This is only to enable JSX support. import React from 'react';

const MyRepositoryView: React.FC = function (props) { const value, setValue = props.React.useState(null); return <div style={{ padding: '1rem' }}>Welcome to repository {props.title}!;

};

As usual, for a more complete example check out the basic extension template repository.

==== Modules you can import

Here are the modules you can import:

  • "@blueprintjs/core"
  • "@blueprintjs/datetime"
  • "@blueprintjs/icons"
  • "@blueprintjs/select"
  • "@emotion/core"
  • "@riboseinc/paneron-extension-kit"
  • "@riboseinc/paneron-registry-kit"
  • "electron-log"
  • "js-yaml"
  • "react" (but note quirks above)
  • "react-window"
  • "throttle-debounce"

Again, you must not have anything in your dependencies, but you may want to add what you use from the above to your devDependencies for TypeScript development convenience.

=== Using Emotion for styling components

Taking the above example, here is how it could be written using Emotion:

source,tsx

/* @jsx jsx /

import { css, jsx } from '@emotion/core';

const MyRepositoryView: React.FC = function (props) { const value, setValue = props.React.useState(null); return <div css={csspadding: 1rem;}>Welcome to repository {props.title}!;

};

NOTE

If using React fragment shorthand syntax (<>…</>), keep the React import and add @jsxFrag pragma:

source,tsx

/ @jsx jsx */ / @jsxFrag React.Fragment */

import React from 'react';

import { css, jsx } from '@emotion/core';

const MyRepositoryView: React.FC = function (props) { const value, setValue = props.React.useState(null); return <>

<div css={css`padding: 1rem;`}>Welcome to repository {props.title}!</div>

</>;

};

====

2.2.26

9 days ago

2.2.27

9 days ago

2.2.25

9 days ago

2.2.24

11 days ago

2.2.23

12 days ago

2.2.22

14 days ago

2.2.21

21 days ago

2.2.20

2 months ago

2.2.18

2 months ago

2.2.17

5 months ago

2.2.16

5 months ago

2.2.1

9 months ago

2.2.0

9 months ago

2.2.15

6 months ago

2.2.3

8 months ago

2.2.2

9 months ago

2.2.13

6 months ago

2.2.5

8 months ago

2.2.14

6 months ago

2.2.4

8 months ago

2.2.11

6 months ago

2.2.7

7 months ago

2.2.12

6 months ago

2.2.6

8 months ago

2.2.10

6 months ago

2.1.1

10 months ago

2.2.9

7 months ago

2.2.8

7 months ago

2.1.0

11 months ago

2.0.7

1 year ago

2.0.8

12 months ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.5

1 year ago

2.0.4

1 year ago

2.0.6

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

2.0.0-alpha23

2 years ago

2.0.0-alpha24

2 years ago

2.0.0-alpha21

3 years ago

2.0.0-alpha22

3 years ago

2.0.0-alpha20

3 years ago

2.0.0-alpha19

3 years ago

2.0.0-alpha17

3 years ago

2.0.0-alpha18

3 years ago

2.0.0-alpha16

3 years ago

2.0.0-alpha14

3 years ago

2.0.0-alpha15

3 years ago

2.0.0-alpha13

3 years ago

2.0.0-alpha12

3 years ago

2.0.0-alpha11

3 years ago

2.0.0-alpha10

3 years ago

2.0.0-alpha9

3 years ago

2.0.0-alpha8

3 years ago

2.0.0-alpha7

3 years ago

2.0.0-alpha6

3 years ago

2.0.0-alpha5

3 years ago

2.0.0-alpha4

3 years ago

2.0.0-alpha3

3 years ago

2.0.0-alpha2

3 years ago

2.0.0-alpha1

3 years ago

2.0.0-dev31

3 years ago

2.0.0-dev30

3 years ago

2.0.0-dev29

3 years ago

2.0.0-dev27

3 years ago

2.0.0-dev26

3 years ago

2.0.0-dev28

3 years ago

2.0.0-dev21

3 years ago

2.0.0-dev20

3 years ago

2.0.0-dev23

3 years ago

2.0.0-dev22

3 years ago

2.0.0-dev14

3 years ago

2.0.0-dev13

3 years ago

2.0.0-dev16

3 years ago

2.0.0-dev15

3 years ago

2.0.0-dev18

3 years ago

2.0.0-dev17

3 years ago

2.0.0-dev19

3 years ago

2.0.0-dev25

3 years ago

2.0.0-dev24

3 years ago

2.0.0-dev12

3 years ago

2.0.0-dev11

3 years ago

2.0.0-dev10

3 years ago

2.0.0-dev9

3 years ago

1.0.2

3 years ago

2.0.0-dev8

3 years ago

2.0.0-dev7

3 years ago

2.0.0-dev6

3 years ago

2.0.0-dev5

3 years ago

2.0.0-dev4

3 years ago

2.0.0-dev3

3 years ago

2.0.0-dev2

3 years ago

2.0.0-dev1

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

1.0.0-alpha13

3 years ago

1.0.0-alpha12

4 years ago

1.0.0-alpha10

4 years ago

1.0.0-alpha9

4 years ago

1.0.0-alpha8

4 years ago

1.0.0-alpha7

4 years ago

1.0.0-alpha6

4 years ago

1.0.0-alpha5

4 years ago

1.0.0-alpha4

4 years ago

1.0.0-alpha3

4 years ago

1.0.0-alpha2

4 years ago

1.0.0-alpha1

4 years ago