OSSInsight charts and visualizations will be developed under widget specification.
A widget implementation contains several config or code fragments:
- Metadata: Defines human-readable information for the widget. Including dynamic SEO info generator.
- Datasource: Defines how a widget fetch required data.
- Visualization: Defines how a widget rendering fetched data to browser chart or static image.
- Parameters: Defines dynamic parameters the widget takes to provide flexibilities.
Widget should provide a package.json
file. Several fields will be used as widget metadata info:
name
: The unique name of the widget. All official widgets name should have@ossinsight/widget-
prefix. And the name should be a valid npm package name.version
: Required field by npm, not vital.description
(Optional): Describe what the widget does. If no dynamic SEO description provided, this field will be taken as fallback text.keywords
(Optional): Will be used to classify widget. For example:Repository
,Collection
,PRs
,Stars
, ...author
: Default toOSSInsight
for official widgets.
Widget should provide a metadata.ts
for generate dynamic metadata for SEO.
This file should provide a default exported function, takes
WidgetVisualizerContext
as argument and returns partial of
Next.js metadata object.
Widget must provide a datasource.json
to define how the widget fetch required data.
See Datasource Schema v1 for documentations.
Widget must provide a visualization.ts
to define how the widget renders data into chart or static images. The file
should export:
default
: A function to returns renderer config.type
: Indicates which renderer the widget uses.
The renderer function body should be platform independent and framework independent.
The first argument is the fetched data from datasource. If the datasource.json
provides multiple datasource, the
argument will be an array.
A widget could accept several dynamic parameters during data-fetching and rendering. All available parameters should be
defined in params.json
.
See Parameters Schema v1 for documentations.
The package @ossinsight/widgets-core
provides all widget logic codes during client side
render and server side rendering.
- src/datasource: All types of datasource fetchers will be placed in this folder.
- src/parameters
- src/render
Utils for widgets. Auto installed for all widgets.
Type definitions for widgets. Auto installed for all widgets.
ESLint plugin for validate widget folders.
Use pnpm create to create a widget folder conveniently.
A tool to preview a widget locally without OSSInsight source code and dependencies.