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

@wixc3/app-core

Package Overview
Dependencies
Maintainers
0
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wixc3/app-core - npm Package Compare versions

Comparing version 4.4.0 to 4.5.0

45

dist/define-app-types.d.ts

@@ -74,3 +74,3 @@ import type React from 'react';

}
export interface IReactApp<T = unknown> {
export interface IReactApp<MANIFEST_EXTRA_DATA = unknown, ROUTE_EXTRA_DATA = unknown> {
/**

@@ -83,3 +83,3 @@ * Should be isomorphic, should return the same result on the server and in a web worker

prepareApp: (options: IPrepareAppOptions) => Promise<{
manifest: IAppManifest<T>;
manifest: IAppManifest<MANIFEST_EXTRA_DATA, ROUTE_EXTRA_DATA>;
dispose: () => void;

@@ -94,3 +94,3 @@ }>;

*/
getNewPageInfo?: (options: IGetNewPageInfoOptions<T>) => {
getNewPageInfo?: (options: IGetNewPageInfoOptions<MANIFEST_EXTRA_DATA, ROUTE_EXTRA_DATA>) => {
isValid: boolean;

@@ -101,3 +101,3 @@ errorMessage?: string;

newPageSourceCode: string;
newPageRoute?: RouteInfo<T>;
newPageRoute?: RouteInfo<ROUTE_EXTRA_DATA>;
routingPattern?: RoutingPattern;

@@ -110,3 +110,3 @@ };

*/
getMovePageInfo?: (options: IMovePageInfoOptions<T>) => {
getMovePageInfo?: (options: IMovePageInfoOptions<MANIFEST_EXTRA_DATA, ROUTE_EXTRA_DATA>) => {
isValid: boolean;

@@ -116,3 +116,3 @@ errorMessage?: string;

pageModule: string;
newPageRoute?: RouteInfo<T>;
newPageRoute?: RouteInfo<ROUTE_EXTRA_DATA>;
routingPattern?: RoutingPattern;

@@ -135,3 +135,3 @@ };

hasGetStaticRoutes?: (options: ICallServerMethodOptions, forRouteAtFilePath: string) => Promise<boolean>;
App: React.ComponentType<IReactAppProps<T>>;
App: React.ComponentType<IReactAppProps<MANIFEST_EXTRA_DATA, ROUTE_EXTRA_DATA>>;
/**

@@ -142,10 +142,11 @@ * Renders the App into an HTML element

*/
render: (targetElement: HTMLElement, props: IReactAppProps<T>) => Promise<() => void>;
render: (targetElement: HTMLElement, props: IReactAppProps<MANIFEST_EXTRA_DATA, ROUTE_EXTRA_DATA>) => Promise<() => void>;
}
export interface IAppManifest<T = unknown> {
routes: RouteInfo<T>[];
homeRoute?: RouteInfo<T>;
errorRoutes?: RouteInfo<T>[];
export interface IAppManifest<MANIFEST_EXTRA_DATA = unknown, ROUTE_EXTRA_DATA = undefined> {
extraData: MANIFEST_EXTRA_DATA;
routes: RouteInfo<ROUTE_EXTRA_DATA>[];
homeRoute?: RouteInfo<ROUTE_EXTRA_DATA>;
errorRoutes?: RouteInfo<ROUTE_EXTRA_DATA>[];
}
export interface RouteInfo<T = unknown> {
export interface RouteInfo<ROUTE_EXTRA_DATA = unknown> {
pageModule: string;

@@ -176,3 +177,3 @@ pageExportName?: string;

*/
extraData: T;
extraData: ROUTE_EXTRA_DATA;
path: Array<StaticRoutePart | DynamicRoutePart>;

@@ -194,4 +195,4 @@ /**

}
export interface IReactAppProps<T = unknown> {
manifest: IAppManifest<T>;
export interface IReactAppProps<MANIFEST_EXTRA_DATA = unknown, ROUTE_EXTRA_DATA = unknown> {
manifest: IAppManifest<MANIFEST_EXTRA_DATA, ROUTE_EXTRA_DATA>;
importModule: DynamicImport;

@@ -212,3 +213,3 @@ uri: string;

export interface IPrepareAppOptions {
onManifestUpdate: (appProps: IAppManifest<any>) => void;
onManifestUpdate: (appProps: IAppManifest<any, any>) => void;
fsApi: FSApi;

@@ -220,9 +221,9 @@ }

}
export interface IGetNewPageInfoOptions<T> {
export interface IGetNewPageInfoOptions<MANIFEST_EXTRA_DATA = unknown, ROUTE_EXTRA_DATA = unknown> {
fsApi: FSApi;
requestedURI: string;
manifest: IAppManifest<T>;
manifest: IAppManifest<MANIFEST_EXTRA_DATA, ROUTE_EXTRA_DATA>;
}
export type RoutingPattern = 'file' | 'folder(route)' | 'folder(index)';
export interface IMovePageInfoOptions<T> extends IGetNewPageInfoOptions<T> {
export interface IMovePageInfoOptions<MANIFEST_EXTRA_DATA = unknown, ROUTE_EXTRA_DATA = unknown> extends IGetNewPageInfoOptions<MANIFEST_EXTRA_DATA, ROUTE_EXTRA_DATA> {
movedFilePath: string;

@@ -235,7 +236,7 @@ }

export interface IResults<T> {
status: 'ready' | 'invalid' | 'disposed';
status: 'ready' | 'invalid' | 'disposed' | 'loading';
results: T | null;
errorMessage?: string;
}
export type OmitReactApp<T extends IReactApp<D>, D> = Omit<T, 'render' | 'setupStage' | 'setProps'>;
export type OmitReactApp<T extends IReactApp<any, any>> = Omit<T, 'render' | 'setupStage' | 'setProps'>;
//# sourceMappingURL=define-app-types.d.ts.map
import { IReactApp, OmitReactApp } from './define-app-types';
export declare function defineApp<T>(input: OmitReactApp<IReactApp<T>, T>): IReactApp<T>;
export declare function defineApp<MANIFEST_EXTRA_DATA = unknown, ROUTE_EXTRA_DATA = undefined>(input: OmitReactApp<IReactApp<MANIFEST_EXTRA_DATA, ROUTE_EXTRA_DATA>>): IReactApp<MANIFEST_EXTRA_DATA, ROUTE_EXTRA_DATA>;
//# sourceMappingURL=define-app.d.ts.map
import type { IAppManifest, IReactApp } from '@wixc3/app-core';
import { IDirectoryContents } from '@file-services/types';
export interface AppDefDriverOptions<T> {
app: IReactApp<T>;
export interface AppDefDriverOptions<MANIFEST_EXTRA_DATA = unknown, ROUTE_EXTRA_DATAU = unknown> {
app: IReactApp<MANIFEST_EXTRA_DATA, ROUTE_EXTRA_DATAU>;
initialFiles: IDirectoryContents;

@@ -16,3 +16,3 @@ evaluatedNodeModules: Record<string, unknown>;

}
export declare class AppDefDriver<T> {
export declare class AppDefDriver<MANIFEST_EXTRA_DATA = unknown, ROUTE_EXTRA_DATA = unknown> {
private options;

@@ -22,2 +22,3 @@ private fs;

private dirListeners;
private manifestListeners;
private fileListeners;

@@ -27,6 +28,6 @@ private exportsListeners;

private disposeApp?;
constructor(options: AppDefDriverOptions<T>);
init(): Promise<IAppManifest<T>>;
constructor(options: AppDefDriverOptions<MANIFEST_EXTRA_DATA, ROUTE_EXTRA_DATA>);
init(): Promise<IAppManifest<MANIFEST_EXTRA_DATA, ROUTE_EXTRA_DATA>>;
addOrUpdateFile(filePath: string, contents: string): void;
getManifest(): IAppManifest<T> | null;
getManifest(): IAppManifest<MANIFEST_EXTRA_DATA, ROUTE_EXTRA_DATA> | null;
getNewPageInfo(requestedURI: string): {

@@ -38,3 +39,3 @@ isValid: boolean;

newPageSourceCode: string;
newPageRoute?: import("@wixc3/app-core").RouteInfo<T> | undefined;
newPageRoute?: import("@wixc3/app-core").RouteInfo<ROUTE_EXTRA_DATA> | undefined;
routingPattern?: import("@wixc3/app-core").RoutingPattern;

@@ -47,13 +48,17 @@ };

pageModule: string;
newPageRoute?: import("@wixc3/app-core").RouteInfo<T> | undefined;
newPageRoute?: import("@wixc3/app-core").RouteInfo<ROUTE_EXTRA_DATA> | undefined;
routingPattern?: import("@wixc3/app-core").RoutingPattern;
};
render({ uri }?: {
addManifestListener(cb: (manifest: IAppManifest<MANIFEST_EXTRA_DATA, ROUTE_EXTRA_DATA>) => void): void;
removeManifestListener(cb: (manifest: IAppManifest<MANIFEST_EXTRA_DATA, ROUTE_EXTRA_DATA>) => void): void;
private dispatchManifestUpdate;
render({ uri, testAutoRerenderOnManifestUpdate, }?: {
uri?: string;
testAutoRerenderOnManifestUpdate?: boolean;
}): Promise<{
dispose(): void;
dispose: () => void;
container: HTMLDivElement;
rerender({ uri }?: {
rerender: ({ uri }?: {
uri?: string;
}): Promise<() => void>;
}) => Promise<() => void>;
}>;

@@ -60,0 +65,0 @@ dispose(): void;

@@ -15,2 +15,3 @@ "use strict";

this.dirListeners = [];
this.manifestListeners = new Set();
this.fileListeners = {};

@@ -94,3 +95,3 @@ this.exportsListeners = {};

results: module || null,
errorMessage
errorMessage,
}),

@@ -136,2 +137,3 @@ dispose() {

this.lastManifest = manifest;
this.dispatchManifestUpdate();
},

@@ -197,5 +199,16 @@ });

}
async render({ uri = '/' } = {}) {
addManifestListener(cb) {
this.manifestListeners.add(cb);
}
removeManifestListener(cb) {
this.manifestListeners.delete(cb);
}
dispatchManifestUpdate() {
for (const listener of this.manifestListeners) {
listener(this.lastManifest);
}
}
async render({ uri = '/', testAutoRerenderOnManifestUpdate, } = {}) {
const { app } = this.options;
const { fsApi, importModule, lastManifest } = this;
const { fsApi, importModule } = this;
if (!app.callServerMethod) {

@@ -209,8 +222,10 @@ throw new Error('app.callServerMethod is not defined');

fsApi,
importModule
importModule,
}, filePath, methodName, args);
},
importModule: this.importModule,
manifest: lastManifest,
onCaughtError() { },
manifest: this.lastManifest,
onCaughtError() {
/**/
},
setUri(_uri) {

@@ -222,11 +237,21 @@ // ToDo: implement

const unmount = await app.render(container, createProps(uri));
let lastUri = uri;
const rerender = ({ uri = '/' } = {}) => {
lastUri = uri;
return app.render(container, createProps(uri));
};
const manifestListener = () => {
void rerender({ uri: lastUri });
};
if (testAutoRerenderOnManifestUpdate !== false) {
this.addManifestListener(manifestListener);
}
return {
dispose() {
dispose: () => {
unmount();
container.remove();
this.removeManifestListener(manifestListener);
},
container,
rerender({ uri = '/' } = {}) {
return app.render(container, createProps(uri));
}
rerender,
};

@@ -233,0 +258,0 @@ }

{
"name": "@wixc3/app-core",
"description": "Common types and helpers for building applications",
"version": "4.4.0",
"version": "4.5.0",
"main": "dist/index.js",

@@ -6,0 +6,0 @@ "exports": {

@@ -90,3 +90,3 @@ import type React from 'react';

export interface IReactApp<T = unknown> {
export interface IReactApp<MANIFEST_EXTRA_DATA = unknown, ROUTE_EXTRA_DATA = unknown> {
/**

@@ -99,3 +99,3 @@ * Should be isomorphic, should return the same result on the server and in a web worker

prepareApp: (options: IPrepareAppOptions) => Promise<{
manifest: IAppManifest<T>;
manifest: IAppManifest<MANIFEST_EXTRA_DATA, ROUTE_EXTRA_DATA>;
dispose: () => void;

@@ -111,3 +111,3 @@ }>;

*/
getNewPageInfo?: (options: IGetNewPageInfoOptions<T>) => {
getNewPageInfo?: (options: IGetNewPageInfoOptions<MANIFEST_EXTRA_DATA, ROUTE_EXTRA_DATA>) => {
isValid: boolean;

@@ -118,3 +118,3 @@ errorMessage?: string;

newPageSourceCode: string;
newPageRoute?: RouteInfo<T>;
newPageRoute?: RouteInfo<ROUTE_EXTRA_DATA>;
routingPattern?: RoutingPattern;

@@ -128,3 +128,3 @@ };

*/
getMovePageInfo?: (options: IMovePageInfoOptions<T>) => {
getMovePageInfo?: (options: IMovePageInfoOptions<MANIFEST_EXTRA_DATA, ROUTE_EXTRA_DATA>) => {
isValid: boolean;

@@ -134,3 +134,3 @@ errorMessage?: string;

pageModule: string;
newPageRoute?: RouteInfo<T>;
newPageRoute?: RouteInfo<ROUTE_EXTRA_DATA>;
routingPattern?: RoutingPattern;

@@ -160,4 +160,3 @@ };

App: React.ComponentType<IReactAppProps<T>>;
App: React.ComponentType<IReactAppProps<MANIFEST_EXTRA_DATA, ROUTE_EXTRA_DATA>>;
/**

@@ -168,11 +167,15 @@ * Renders the App into an HTML element

*/
render: (targetElement: HTMLElement, props: IReactAppProps<T>) => Promise<() => void>;
render: (
targetElement: HTMLElement,
props: IReactAppProps<MANIFEST_EXTRA_DATA, ROUTE_EXTRA_DATA>,
) => Promise<() => void>;
}
export interface IAppManifest<T = unknown> {
routes: RouteInfo<T>[];
homeRoute?: RouteInfo<T>;
errorRoutes?: RouteInfo<T>[];
export interface IAppManifest<MANIFEST_EXTRA_DATA = unknown, ROUTE_EXTRA_DATA = undefined> {
extraData: MANIFEST_EXTRA_DATA;
routes: RouteInfo<ROUTE_EXTRA_DATA>[];
homeRoute?: RouteInfo<ROUTE_EXTRA_DATA>;
errorRoutes?: RouteInfo<ROUTE_EXTRA_DATA>[];
}
export interface RouteInfo<T = unknown> {
export interface RouteInfo<ROUTE_EXTRA_DATA = unknown> {
pageModule: string;

@@ -194,3 +197,2 @@ pageExportName?: string;

/**

@@ -207,3 +209,3 @@ * a list of export names of the page that should be editable

*/
extraData: T;
extraData: ROUTE_EXTRA_DATA;
path: Array<StaticRoutePart | DynamicRoutePart>;

@@ -228,4 +230,4 @@ /**

export interface IReactAppProps<T = unknown> {
manifest: IAppManifest<T>;
export interface IReactAppProps<MANIFEST_EXTRA_DATA = unknown, ROUTE_EXTRA_DATA = unknown> {
manifest: IAppManifest<MANIFEST_EXTRA_DATA, ROUTE_EXTRA_DATA>;
importModule: DynamicImport;

@@ -250,3 +252,3 @@ uri: string;

// eslint-disable-next-line @typescript-eslint/no-explicit-any
onManifestUpdate: (appProps: IAppManifest<any>) => void;
onManifestUpdate: (appProps: IAppManifest<any, any>) => void;
fsApi: FSApi;

@@ -258,6 +260,6 @@ }

}
export interface IGetNewPageInfoOptions<T> {
export interface IGetNewPageInfoOptions<MANIFEST_EXTRA_DATA = unknown, ROUTE_EXTRA_DATA = unknown> {
fsApi: FSApi;
requestedURI: string;
manifest: IAppManifest<T>;
manifest: IAppManifest<MANIFEST_EXTRA_DATA, ROUTE_EXTRA_DATA>;
}

@@ -267,3 +269,4 @@

export interface IMovePageInfoOptions<T> extends IGetNewPageInfoOptions<T> {
export interface IMovePageInfoOptions<MANIFEST_EXTRA_DATA = unknown, ROUTE_EXTRA_DATA = unknown>
extends IGetNewPageInfoOptions<MANIFEST_EXTRA_DATA, ROUTE_EXTRA_DATA> {
movedFilePath: string;

@@ -277,3 +280,3 @@ }

export interface IResults<T> {
status: 'ready' | 'invalid' | 'disposed';
status: 'ready' | 'invalid' | 'disposed' | 'loading';
results: T | null;

@@ -283,2 +286,3 @@ errorMessage?: string;

export type OmitReactApp<T extends IReactApp<D>, D> = Omit<T, 'render' | 'setupStage' | 'setProps'>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type OmitReactApp<T extends IReactApp<any, any>> = Omit<T, 'render' | 'setupStage' | 'setProps'>;

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

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