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

piral-base

Package Overview
Dependencies
Maintainers
1
Versions
878
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

piral-base - npm Package Compare versions

Comparing version 0.10.0 to 0.11.0-pre.891

6

lib/aggregate.d.ts

@@ -1,2 +0,2 @@

import { GenericPilet, GenericPiletApiCreator } from './types';
import { Pilet, PiletApiCreator } from './types';
/**

@@ -8,3 +8,3 @@ * Sets up the evaluated pilets to become integrated pilets.

*/
export declare function createPilets<TApi>(createApi: GenericPiletApiCreator<TApi>, pilets: Array<GenericPilet<TApi>>): Promise<GenericPilet<TApi>[]>;
export declare function createPilets(createApi: PiletApiCreator, pilets: Array<Pilet>): Promise<Pilet[]>;
/**

@@ -16,2 +16,2 @@ * Sets up an evaluated pilet to become an integrated pilet.

*/
export declare function createPilet<TApi>(createApi: GenericPiletApiCreator<TApi>, pilet: GenericPilet<TApi>): Promise<GenericPilet<TApi>>;
export declare function createPilet(createApi: PiletApiCreator, pilet: Pilet): Promise<Pilet>;
import { LoadPiletsOptions, PiletsLoading } from './types';
export declare function startLoadingPilets<TApi>(options: LoadPiletsOptions<TApi>): {
connect(notifier: PiletsLoading<TApi>): void;
disconnect(notifier: PiletsLoading<TApi>): void;
export declare function startLoadingPilets(options: LoadPiletsOptions): {
connect(notifier: PiletsLoading): void;
disconnect(notifier: PiletsLoading): void;
};

@@ -1,2 +0,2 @@

import { GenericPiletApp, AvailableDependencies } from './types';
import { PiletApp, AvailableDependencies } from './types';
/**

@@ -10,3 +10,3 @@ * Compiles the given content from a generic dependency.

*/
export declare function evalDependency<TApi>(name: string, content: string, link?: string, dependencies?: AvailableDependencies): GenericPiletApp<TApi>;
export declare function evalDependency(name: string, content: string, link?: string, dependencies?: AvailableDependencies): PiletApp;
/**

@@ -20,2 +20,2 @@ * Compiles the given content from a module with a dependency resolution.

*/
export declare function compileDependency<TApi>(name: string, content: string, link?: string, dependencies?: AvailableDependencies): Promise<GenericPiletApp<TApi>>;
export declare function compileDependency(name: string, content: string, link?: string, dependencies?: AvailableDependencies): Promise<PiletApp>;
import { defaultFetchDependency } from './fetch';
import { PiletMetadata, GenericPilet, PiletDependencyGetter, PiletFetcher, PiletDependencyFetcher, AvailableDependencies } from './types';
import { PiletMetadata, Pilet, PiletDependencyGetter, PiletRequester, PiletDependencyFetcher, AvailableDependencies } from './types';
/**

@@ -11,3 +11,3 @@ * Loads the given raw pilet content by resolving its dependencies and

*/
export declare function loadPilet<TApi>(meta: PiletMetadata, getDependencies: PiletDependencyGetter, fetchDependency?: typeof defaultFetchDependency): Promise<GenericPilet<TApi>>;
export declare function loadPilet(meta: PiletMetadata, getDependencies: PiletDependencyGetter, fetchDependency?: typeof defaultFetchDependency): Promise<Pilet>;
/**

@@ -18,3 +18,3 @@ * Loads the pilets metadata and puts them in the cache, if provided.

*/
export declare function loadMetadata(fetchPilets: PiletFetcher): Promise<any[]>;
export declare function loadMetadata(fetchPilets: PiletRequester): Promise<any[]>;
/**

@@ -27,2 +27,2 @@ * Loads the pilets by first getting them, then evaluating the raw content.

*/
export declare function loadPilets<TApi>(fetchPilets: PiletFetcher, fetchDependency?: PiletDependencyFetcher, globalDependencies?: AvailableDependencies, getLocalDependencies?: PiletDependencyGetter): Promise<Array<GenericPilet<TApi>>>;
export declare function loadPilets(fetchPilets: PiletRequester, fetchDependency?: PiletDependencyFetcher, globalDependencies?: AvailableDependencies, getLocalDependencies?: PiletDependencyGetter): Promise<Array<Pilet>>;

@@ -1,2 +0,2 @@

import { GenericPilet } from './types';
import { Pilet, PiletApi } from './types';
/**

@@ -8,2 +8,2 @@ * Sets up the given pilet by calling the exported `setup` function

*/
export declare function setupPilet<TApi>(app: GenericPilet<TApi>, api: TApi): void | Promise<void>;
export declare function setupPilet(app: Pilet, api: PiletApi): void | Promise<void>;

@@ -7,3 +7,3 @@ import { LoadPiletsOptions, PiletsLoaded, PiletLoadingStrategy } from './types';

*/
export declare function createProgressiveStrategy<TApi>(async: boolean): PiletLoadingStrategy<TApi>;
export declare function createProgressiveStrategy(async: boolean): PiletLoadingStrategy;
/**

@@ -14,3 +14,3 @@ * This strategy starts rendering when the pilets metadata has been received.

*/
export declare function blazingStrategy<TApi>(options: LoadPiletsOptions<TApi>, cb: PiletsLoaded<TApi>): PromiseLike<void>;
export declare function blazingStrategy(options: LoadPiletsOptions, cb: PiletsLoaded): PromiseLike<void>;
/**

@@ -21,3 +21,3 @@ * The async strategy picked when no strategy is declared and async is set to

*/
export declare function asyncStrategy<TApi>(options: LoadPiletsOptions<TApi>, cb: PiletsLoaded<TApi>): PromiseLike<void>;
export declare function asyncStrategy(options: LoadPiletsOptions, cb: PiletsLoaded): PromiseLike<void>;
/**

@@ -27,3 +27,3 @@ * The standard strategy that is used if no strategy is declared and async is

*/
export declare function standardStrategy<TApi>(options: LoadPiletsOptions<TApi>, cb: PiletsLoaded<TApi>): PromiseLike<void>;
export declare function standardStrategy(options: LoadPiletsOptions, cb: PiletsLoaded): PromiseLike<void>;
/**

@@ -34,2 +34,2 @@ * The strategy that could be used for special purposes, e.g., SSR or specific

*/
export declare function syncStrategy<TApi>(options: LoadPiletsOptions<TApi>, cb: PiletsLoaded<TApi>): PromiseLike<void>;
export declare function syncStrategy(options: LoadPiletsOptions, cb: PiletsLoaded): PromiseLike<void>;

@@ -0,1 +1,4 @@

/**
* Describes the metadata transported by a pilet.
*/
export interface PiletMetadata {

@@ -36,8 +39,58 @@ /**

}
export interface GenericPiletApp<TApi> {
/**
* Defines the API accessible from pilets.
*/
export interface PiletApi extends EventEmitter {
/**
* Gets the metadata of the current pilet.
*/
meta: PiletMetadata;
}
/**
* The map of known Piral app shell events.
*/
export interface PiralEventMap {
[custom: string]: any;
}
/**
* Listener for Piral app shell events.
*/
export interface Listener<T> {
/**
* Receives an event of type T.
*/
(arg: T): void;
}
/**
* The emitter for Piral app shell events.
*/
export interface EventEmitter {
/**
* Attaches a new event listener.
* @param type The type of the event to listen for.
* @param callback The callback to trigger.
*/
on<K extends keyof PiralEventMap>(type: K, callback: Listener<PiralEventMap[K]>): EventEmitter;
/**
* Detaches an existing event listener.
* @param type The type of the event to listen for.
* @param callback The callback to trigger.
*/
off<K extends keyof PiralEventMap>(type: K, callback: Listener<PiralEventMap[K]>): EventEmitter;
/**
* Emits a new event with the given type.
* @param type The type of the event to emit.
* @param arg The payload of the event.
*/
emit<K extends keyof PiralEventMap>(type: K, arg: PiralEventMap[K]): EventEmitter;
}
/**
* The pilet app, i.e., the functional exports.
*/
export interface PiletApp {
/**
* Integrates the evaluated pilet into the application.
* @param api The API to access the application.
*/
setup(api: TApi): void | Promise<void>;
setup(api: PiletApi): void | Promise<void>;
/**

@@ -47,8 +100,17 @@ * Optional function for cleanup.

*/
teardown?(api: TApi): void;
teardown?(api: PiletApi): void;
}
export interface GenericPiletExports<TApi> {
exports: GenericPiletApp<TApi> | undefined;
/**
* Defines the exports of a pilet.
*/
export interface PiletExports {
exports: PiletApp | undefined;
}
export declare type GenericPilet<TApi> = GenericPiletApp<TApi> & PiletMetadata;
/**
* An evaluated pilet, i.e., a full pilet: functionality and metadata.
*/
export declare type Pilet = PiletApp & PiletMetadata;
/**
* The callback to fetch a JS content from an URL.
*/
export interface PiletDependencyFetcher {

@@ -62,3 +124,6 @@ /**

}
export interface GenericPiletApiCreator<TApi> {
/**
* The creator function for the pilet API.
*/
export interface PiletApiCreator {
/**

@@ -69,4 +134,7 @@ * Creates an API for the given raw pilet.

*/
(target: PiletMetadata): TApi;
(target: PiletMetadata): PiletApi;
}
/**
* The callback to get the shared dependencies for a specific pilet.
*/
export interface PiletDependencyGetter {

@@ -82,3 +150,6 @@ /**

}
export interface PiletFetcher {
/**
* The interface describing a function capable of fetching pilets.
*/
export interface PiletRequester {
/**

@@ -89,15 +160,30 @@ * Gets the raw pilets (e.g., from a server) asynchronously.

}
/**
* The record containing all available dependencies.
*/
export interface AvailableDependencies {
[name: string]: any;
}
export interface PiletsLoaded<TApi> {
(error: Error | undefined, pilets: Array<GenericPilet<TApi>>): void;
/**
* The callback to be used when pilets have been loaded.
*/
export interface PiletsLoaded {
(error: Error | undefined, pilets: Array<Pilet>): void;
}
export interface PiletsLoading<TApi> {
(error: Error | undefined, pilets: Array<GenericPilet<TApi>>, loaded: boolean): void;
/**
* The callback to be used when pilets are loading.
*/
export interface PiletsLoading {
(error: Error | undefined, pilets: Array<Pilet>, loaded: boolean): void;
}
export interface PiletLoadingStrategy<TApi> {
(options: LoadPiletsOptions<TApi>, pilets: PiletsLoaded<TApi>): PromiseLike<void>;
/**
* The strategy for loading pilets.
*/
export interface PiletLoadingStrategy {
(options: LoadPiletsOptions, pilets: PiletsLoaded): PromiseLike<void>;
}
export interface LoadPiletsOptions<TApi> {
/**
* The options for loading pilets.
*/
export interface LoadPiletsOptions {
/**

@@ -107,7 +193,7 @@ * The callback function for creating an API object.

*/
createApi: GenericPiletApiCreator<TApi>;
createApi: PiletApiCreator;
/**
* The callback for fetching the dynamic pilets.
*/
fetchPilets: PiletFetcher;
fetchPilets: PiletRequester;
/**

@@ -117,3 +203,3 @@ * Optionally, some already existing evaluated pilets, e.g.,

*/
pilets?: Array<GenericPilet<TApi>>;
pilets?: Array<Pilet>;
/**

@@ -136,3 +222,3 @@ * The callback for defining how a dependency will be fetched.

*/
strategy?: PiletLoadingStrategy<TApi>;
strategy?: PiletLoadingStrategy;
}
{
"name": "piral-base",
"version": "0.10.0",
"version": "0.11.0-pre.891",
"description": "The base library for creating a Piral instance.",

@@ -39,3 +39,3 @@ "keywords": [

},
"gitHead": "7c5a6e46f285d94749c3d9f4778aab8483435d63"
"gitHead": "986aaf2b3e2977d7b2718defc713d72d9d87bc8d"
}
import { isfunc } from './utils';
import { setupPilet } from './setup';
import { GenericPilet, GenericPiletApiCreator } from './types';
import { Pilet, PiletApiCreator } from './types';
function checkCreateApi<TApi>(createApi: GenericPiletApiCreator<TApi>) {
function checkCreateApi(createApi: PiletApiCreator) {
if (!isfunc(createApi)) {

@@ -20,3 +20,3 @@ console.warn('Invalid `createApi` function. Skipping pilet installation.');

*/
export function createPilets<TApi>(createApi: GenericPiletApiCreator<TApi>, pilets: Array<GenericPilet<TApi>>) {
export function createPilets(createApi: PiletApiCreator, pilets: Array<Pilet>) {
const promises = [];

@@ -40,3 +40,3 @@

*/
export function createPilet<TApi>(createApi: GenericPiletApiCreator<TApi>, pilet: GenericPilet<TApi>) {
export function createPilet(createApi: PiletApiCreator, pilet: Pilet) {
const promises = [];

@@ -43,0 +43,0 @@

import { isfunc } from './utils';
import { standardStrategy } from './strategies';
import { LoadPiletsOptions, GenericPilet, PiletsLoading } from './types';
import { LoadPiletsOptions, Pilet, PiletsLoading } from './types';
export function startLoadingPilets<TApi>(options: LoadPiletsOptions<TApi>) {
export function startLoadingPilets(options: LoadPiletsOptions) {
const state = {

@@ -11,6 +11,6 @@ loaded: false,

};
const notifiers: Array<PiletsLoading<TApi>> = [];
const call = (notifier: PiletsLoading<TApi>) => notifier(state.error, state.pilets, state.loaded);
const notifiers: Array<PiletsLoading> = [];
const call = (notifier: PiletsLoading) => notifier(state.error, state.pilets, state.loaded);
const notify = () => notifiers.forEach(call);
const setPilets = (error: Error, pilets: Array<GenericPilet<TApi>>) => {
const setPilets = (error: Error, pilets: Array<Pilet>) => {
state.error = error;

@@ -27,3 +27,3 @@ state.pilets = pilets;

return {
connect(notifier: PiletsLoading<TApi>) {
connect(notifier: PiletsLoading) {
if (isfunc(notifier)) {

@@ -34,3 +34,3 @@ notifiers.push(notifier);

},
disconnect(notifier: PiletsLoading<TApi>) {
disconnect(notifier: PiletsLoading) {
const index = notifiers.indexOf(notifier);

@@ -37,0 +37,0 @@ index !== -1 && notifiers.splice(index, 1);

@@ -1,2 +0,2 @@

import { GenericPiletApp, AvailableDependencies, GenericPiletExports } from './types';
import { PiletApp, AvailableDependencies, PiletExports } from './types';

@@ -15,3 +15,3 @@ function requireModule(name: string, dependencies: AvailableDependencies) {

function checkPiletApp<TApi>(app?: GenericPiletApp<TApi>): GenericPiletApp<TApi> {
function checkPiletApp(app?: PiletApp): PiletApp {
if (!app) {

@@ -38,11 +38,6 @@ console.error('Invalid module found.', name);

*/
export function evalDependency<TApi>(
name: string,
content: string,
link = '',
dependencies: AvailableDependencies = {},
) {
export function evalDependency(name: string, content: string, link = '', dependencies: AvailableDependencies = {}) {
const mod = {
exports: {},
} as GenericPiletExports<TApi>;
} as PiletExports;
const require = (moduleName: string) => requireModule(moduleName, dependencies);

@@ -69,3 +64,3 @@

*/
export function compileDependency<TApi>(
export function compileDependency(
name: string,

@@ -75,5 +70,5 @@ content: string,

dependencies: AvailableDependencies = {},
): Promise<GenericPiletApp<TApi>> {
const app = evalDependency<TApi>(name, content, link, dependencies);
): Promise<PiletApp> {
const app = evalDependency(name, content, link, dependencies);
return Promise.resolve(app).then(checkPiletApp);
}

@@ -6,5 +6,5 @@ import { isfunc, createEmptyModule, getDependencyResolver } from './utils';

PiletMetadata,
GenericPilet,
Pilet,
PiletDependencyGetter,
PiletFetcher,
PiletRequester,
PiletDependencyFetcher,

@@ -14,3 +14,3 @@ AvailableDependencies,

function loadFromContent<TApi>(
function loadFromContent(
meta: PiletMetadata,

@@ -20,7 +20,7 @@ content: string,

link?: string,
): Promise<GenericPilet<TApi>> {
): Promise<Pilet> {
const dependencies = {
...(getDependencies(meta) || {}),
};
return compileDependency<TApi>(meta.name, content, link, dependencies).then(app => ({
return compileDependency(meta.name, content, link, dependencies).then(app => ({
...app,

@@ -31,3 +31,3 @@ ...meta,

function checkFetchPilets(fetchPilets: PiletFetcher) {
function checkFetchPilets(fetchPilets: PiletRequester) {
if (!isfunc(fetchPilets)) {

@@ -49,7 +49,7 @@ console.error('Could not get the pilets. Provide a valid `fetchPilets` function.');

*/
export function loadPilet<TApi>(
export function loadPilet(
meta: PiletMetadata,
getDependencies: PiletDependencyGetter,
fetchDependency = defaultFetchDependency,
): Promise<GenericPilet<TApi>> {
): Promise<Pilet> {
const { link, content } = meta;

@@ -59,3 +59,3 @@ const retrieve = link ? fetchDependency(link) : content ? Promise.resolve(content) : undefined;

if (retrieve) {
return retrieve.then(content => loadFromContent<TApi>(meta, content, getDependencies, link));
return retrieve.then(content => loadFromContent(meta, content, getDependencies, link));
} else {

@@ -73,3 +73,3 @@ console.warn('Empty pilet found!', meta.name);

*/
export function loadMetadata(fetchPilets: PiletFetcher) {
export function loadMetadata(fetchPilets: PiletRequester) {
if (checkFetchPilets(fetchPilets)) {

@@ -89,13 +89,13 @@ return fetchPilets();

*/
export function loadPilets<TApi>(
fetchPilets: PiletFetcher,
export function loadPilets(
fetchPilets: PiletRequester,
fetchDependency?: PiletDependencyFetcher,
globalDependencies?: AvailableDependencies,
getLocalDependencies?: PiletDependencyGetter,
): Promise<Array<GenericPilet<TApi>>> {
): Promise<Array<Pilet>> {
const getDependencies = getDependencyResolver(globalDependencies, getLocalDependencies);
return loadMetadata(fetchPilets).then(pilets =>
Promise.all(pilets.map(m => loadPilet<TApi>(m, getDependencies, fetchDependency))),
Promise.all(pilets.map(m => loadPilet(m, getDependencies, fetchDependency))),
);
}

@@ -1,2 +0,2 @@

import { GenericPilet } from './types';
import { Pilet, PiletApi } from './types';

@@ -9,3 +9,3 @@ /**

*/
export function setupPilet<TApi>(app: GenericPilet<TApi>, api: TApi) {
export function setupPilet(app: Pilet, api: PiletApi) {
try {

@@ -12,0 +12,0 @@ return app.setup(api);

import { getDependencyResolver } from './utils';
import { loadPilet, loadPilets, loadMetadata } from './load';
import { createPilets, createPilet } from './aggregate';
import { LoadPiletsOptions, PiletsLoaded, GenericPilet, GenericPiletApiCreator, PiletLoadingStrategy } from './types';
import { LoadPiletsOptions, PiletsLoaded, Pilet, PiletApiCreator, PiletLoadingStrategy } from './types';
function evalAll<TApi>(
createApi: GenericPiletApiCreator<TApi>,
oldModules: Array<GenericPilet<TApi>>,
newModules: Array<GenericPilet<TApi>>,
) {
function evalAll(createApi: PiletApiCreator, oldModules: Array<Pilet>, newModules: Array<Pilet>) {
for (const oldModule of oldModules) {

@@ -27,3 +23,3 @@ const [newModule] = newModules.filter(m => m.name === oldModule.name);

*/
export function createProgressiveStrategy<TApi>(async: boolean): PiletLoadingStrategy<TApi> {
export function createProgressiveStrategy(async: boolean): PiletLoadingStrategy {
return (options, cb) => {

@@ -41,3 +37,3 @@ const { fetchPilets, fetchDependency, dependencies, getDependencies, createApi, pilets = [] } = options;

const promises = metadata.map(m =>
loadPilet<TApi>(m, getDep, fetchDependency).then(mod => {
loadPilet(m, getDep, fetchDependency).then(mod => {
const available = pilets.filter(m => m.name === mod.name).length === 0;

@@ -74,4 +70,4 @@

*/
export function blazingStrategy<TApi>(options: LoadPiletsOptions<TApi>, cb: PiletsLoaded<TApi>): PromiseLike<void> {
const strategy = createProgressiveStrategy<TApi>(true);
export function blazingStrategy(options: LoadPiletsOptions, cb: PiletsLoaded): PromiseLike<void> {
const strategy = createProgressiveStrategy(true);
return strategy(options, cb);

@@ -85,3 +81,3 @@ }

*/
export function asyncStrategy<TApi>(options: LoadPiletsOptions<TApi>, cb: PiletsLoaded<TApi>): PromiseLike<void> {
export function asyncStrategy(options: LoadPiletsOptions, cb: PiletsLoaded): PromiseLike<void> {
standardStrategy(options, cb);

@@ -95,3 +91,3 @@ return Promise.resolve();

*/
export function standardStrategy<TApi>(options: LoadPiletsOptions<TApi>, cb: PiletsLoaded<TApi>): PromiseLike<void> {
export function standardStrategy(options: LoadPiletsOptions, cb: PiletsLoaded): PromiseLike<void> {
const { fetchPilets, fetchDependency, dependencies, getDependencies, createApi, pilets = [] } = options;

@@ -109,3 +105,3 @@ return loadPilets(fetchPilets, fetchDependency, dependencies, getDependencies)

*/
export function syncStrategy<TApi>(options: LoadPiletsOptions<TApi>, cb: PiletsLoaded<TApi>): PromiseLike<void> {
export function syncStrategy(options: LoadPiletsOptions, cb: PiletsLoaded): PromiseLike<void> {
const { createApi, pilets = [] } = options;

@@ -112,0 +108,0 @@ return evalAll(createApi, pilets, []).then(

@@ -0,1 +1,4 @@

/**
* Describes the metadata transported by a pilet.
*/
export interface PiletMetadata {

@@ -37,8 +40,62 @@ /**

export interface GenericPiletApp<TApi> {
/**
* Defines the API accessible from pilets.
*/
export interface PiletApi extends EventEmitter {
/**
* Gets the metadata of the current pilet.
*/
meta: PiletMetadata;
}
/**
* The map of known Piral app shell events.
*/
export interface PiralEventMap {
[custom: string]: any;
}
/**
* Listener for Piral app shell events.
*/
export interface Listener<T> {
/**
* Receives an event of type T.
*/
(arg: T): void;
}
/**
* The emitter for Piral app shell events.
*/
export interface EventEmitter {
/**
* Attaches a new event listener.
* @param type The type of the event to listen for.
* @param callback The callback to trigger.
*/
on<K extends keyof PiralEventMap>(type: K, callback: Listener<PiralEventMap[K]>): EventEmitter;
/**
* Detaches an existing event listener.
* @param type The type of the event to listen for.
* @param callback The callback to trigger.
*/
off<K extends keyof PiralEventMap>(type: K, callback: Listener<PiralEventMap[K]>): EventEmitter;
/**
* Emits a new event with the given type.
* @param type The type of the event to emit.
* @param arg The payload of the event.
*/
emit<K extends keyof PiralEventMap>(type: K, arg: PiralEventMap[K]): EventEmitter;
}
/**
* The pilet app, i.e., the functional exports.
*/
export interface PiletApp {
/**
* Integrates the evaluated pilet into the application.
* @param api The API to access the application.
*/
setup(api: TApi): void | Promise<void>;
setup(api: PiletApi): void | Promise<void>;
/**

@@ -48,11 +105,20 @@ * Optional function for cleanup.

*/
teardown?(api: TApi): void;
teardown?(api: PiletApi): void;
}
export interface GenericPiletExports<TApi> {
exports: GenericPiletApp<TApi> | undefined;
/**
* Defines the exports of a pilet.
*/
export interface PiletExports {
exports: PiletApp | undefined;
}
export type GenericPilet<TApi> = GenericPiletApp<TApi> & PiletMetadata;
/**
* An evaluated pilet, i.e., a full pilet: functionality and metadata.
*/
export type Pilet = PiletApp & PiletMetadata;
/**
* The callback to fetch a JS content from an URL.
*/
export interface PiletDependencyFetcher {

@@ -67,3 +133,6 @@ /**

export interface GenericPiletApiCreator<TApi> {
/**
* The creator function for the pilet API.
*/
export interface PiletApiCreator {
/**

@@ -74,5 +143,8 @@ * Creates an API for the given raw pilet.

*/
(target: PiletMetadata): TApi;
(target: PiletMetadata): PiletApi;
}
/**
* The callback to get the shared dependencies for a specific pilet.
*/
export interface PiletDependencyGetter {

@@ -89,3 +161,6 @@ /**

export interface PiletFetcher {
/**
* The interface describing a function capable of fetching pilets.
*/
export interface PiletRequester {
/**

@@ -97,2 +172,5 @@ * Gets the raw pilets (e.g., from a server) asynchronously.

/**
* The record containing all available dependencies.
*/
export interface AvailableDependencies {

@@ -102,15 +180,27 @@ [name: string]: any;

export interface PiletsLoaded<TApi> {
(error: Error | undefined, pilets: Array<GenericPilet<TApi>>): void;
/**
* The callback to be used when pilets have been loaded.
*/
export interface PiletsLoaded {
(error: Error | undefined, pilets: Array<Pilet>): void;
}
export interface PiletsLoading<TApi> {
(error: Error | undefined, pilets: Array<GenericPilet<TApi>>, loaded: boolean): void;
/**
* The callback to be used when pilets are loading.
*/
export interface PiletsLoading {
(error: Error | undefined, pilets: Array<Pilet>, loaded: boolean): void;
}
export interface PiletLoadingStrategy<TApi> {
(options: LoadPiletsOptions<TApi>, pilets: PiletsLoaded<TApi>): PromiseLike<void>;
/**
* The strategy for loading pilets.
*/
export interface PiletLoadingStrategy {
(options: LoadPiletsOptions, pilets: PiletsLoaded): PromiseLike<void>;
}
export interface LoadPiletsOptions<TApi> {
/**
* The options for loading pilets.
*/
export interface LoadPiletsOptions {
/**

@@ -120,7 +210,7 @@ * The callback function for creating an API object.

*/
createApi: GenericPiletApiCreator<TApi>;
createApi: PiletApiCreator;
/**
* The callback for fetching the dynamic pilets.
*/
fetchPilets: PiletFetcher;
fetchPilets: PiletRequester;
/**

@@ -130,3 +220,3 @@ * Optionally, some already existing evaluated pilets, e.g.,

*/
pilets?: Array<GenericPilet<TApi>>;
pilets?: Array<Pilet>;
/**

@@ -149,3 +239,3 @@ * The callback for defining how a dependency will be fetched.

*/
strategy?: PiletLoadingStrategy<TApi>;
strategy?: PiletLoadingStrategy;
}

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

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