Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

piral

Package Overview
Dependencies
Maintainers
1
Versions
1021
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

piral - npm Package Compare versions

Comparing version 0.3.1 to 0.4.0-pre.417

54

lib/render.d.ts
import * as React from 'react';
import { RouteComponentProps } from 'react-router-dom';
import { LocalizationMessages } from 'piral-core';
import { LocalizationMessages, PiletRequester } from 'piral-core';
import { PiralAttachment } from './api';
export interface PiralOptions {
/**
* Sets the selector of the element to render into.
* @default '#app'
*/
selector?: string | Element;
gateway?: string;
/**
* Sets the function to request the pilets. By default the
* pilets are requested via the standardized GraphQL resource.
*/
requestPilets?: PiletRequester;
/**
* Sets the URL of the portal gateway to the backend.
* @default document.location.origin,
*/
gatewayUrl?: string;
/**
* Sets the URL of the GraphQL subscription or prevents
* creating a subscription.
* @default gatewayUrl,
*/
subscriptionUrl?: false | string;
/**
* Sets additional routes (pages) to be available.
* @default {}
*/
routes?: Record<string, React.ComponentType<RouteComponentProps>>;
/**
* Sets additional trackers to be available.
* @default []
*/
trackers?: Array<React.ComponentType<RouteComponentProps>>;
/**
* Sets the default translations to be available.
* @default {}
*/
translations?: LocalizationMessages;
/**
* Overrides the defaults and sets some custom components.
* @default {}
*/
components?: Record<string, React.ComponentType<any>>;
/**
* Attaches a single static module to the application.
*/
attach?: PiralAttachment;
}
/**
* Sets up a new Piral instance and renders it using the provided options.
* Can be used as simple as calling the function directly without any
* arguments.
* @param options The options to use when setting up the Piral instance.
* @example
```tsx
import { renderInstance } from 'piral';
renderInstance();
export * from 'piral';
```
*/
export declare function renderInstance(options?: PiralOptions): void;

@@ -12,15 +12,39 @@ "use strict";

const components_1 = require("./components");
/**
* Sets up a new Piral instance and renders it using the provided options.
* Can be used as simple as calling the function directly without any
* arguments.
* @param options The options to use when setting up the Piral instance.
* @example
```tsx
import { renderInstance } from 'piral';
renderInstance();
export * from 'piral';
```
*/
function renderInstance(options = {}) {
const { routes = {}, trackers = [], selector = '#app', gateway, translations, components, attach } = options;
const defaultRequestPilets = () => {
const source = client.executeQuery(urql_1.createRequest(`
query initialData {
pilets {
hash
link
name
version
author
dependencies
}
}
`));
return piral_ext_1.pipeToPromise(source).then(({ pilets }) => pilets);
};
const { routes = {}, trackers = [], selector = '#app', requestPilets = defaultRequestPilets, gatewayUrl: gateway, subscriptionUrl, translations, components, attach, } = options;
const origin = utils_1.getGateway(gateway);
const client = piral_ext_1.setupGqlClient({
url: origin,
subscriptionUrl,
});
const Piral = piral_core_1.createInstance({
availableModules: utils_1.getAvailableModules(attach),
requestModules() {
return fetch(`${origin}/api/v1/pilet`)
.then(res => res.json())
.then(res => res.items);
},
availablePilets: utils_1.getAvailablePilets(attach),
requestPilets,
components,

@@ -27,0 +51,0 @@ Loader: components_1.Loader,

2

lib/utils/options.d.ts

@@ -5,2 +5,2 @@ import { ArbiterModule } from 'react-arbiter';

export declare function getGateway(url?: string): string;
export declare function getAvailableModules(setup?: PiralAttachment): ArbiterModule<import("piral-core").PiralApi<import("../api").PiExtApi>>[];
export declare function getAvailablePilets(setup?: PiralAttachment): ArbiterModule<import("piral-core").PiralApi<import("../api").PiExtApi>>[];

@@ -25,3 +25,3 @@ "use strict";

exports.getGateway = getGateway;
function getAvailableModules(setup) {
function getAvailablePilets(setup) {
const debugModules = (process.env.DEBUG_PILETS || '').split(',');

@@ -45,3 +45,3 @@ const availableModules = [];

}
exports.getAvailableModules = getAvailableModules;
exports.getAvailablePilets = getAvailablePilets;
//# sourceMappingURL=options.js.map
{
"name": "piral",
"version": "0.3.1",
"version": "0.4.0-pre.417",
"description": "The all-in-one piral package.",

@@ -44,4 +44,4 @@ "keywords": [

"graphql": "^14.3.0",
"piral-core": "^0.3.1",
"piral-ext": "^0.3.1",
"piral-core": "^0.4.0-pre.417",
"piral-ext": "^0.4.0-pre.417",
"promise-polyfill": "^8.1.0",

@@ -60,3 +60,3 @@ "react": "^16.8.1",

},
"gitHead": "f6a79e18f7cf5ec03dbb43df83a0244efed20374"
"gitHead": "1f32708b106a5930455c774221134ee6786ef155"
}

@@ -22,3 +22,3 @@ import { isfunc, ArbiterModule } from 'react-arbiter';

export function getAvailableModules(setup?: PiralAttachment) {
export function getAvailablePilets(setup?: PiralAttachment) {
const debugModules = (process.env.DEBUG_PILETS || '').split(',');

@@ -25,0 +25,0 @@ const availableModules: Array<ArbiterModule<PiletApi>> = [];

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc