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

hadron-app-registry

Package Overview
Dependencies
Maintainers
0
Versions
522
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hadron-app-registry - npm Package Compare versions

Comparing version 0.0.0-next-bc37cfc07b82d66ae76a8abc7104e13cc84c22eb to 0.0.0-next-be3d5f97c142a1a62831cbb6b70edb79ac62ed02

96

dist/app-registry.d.ts

@@ -1,6 +0,5 @@

import type { Store as RefluxStore } from 'reflux';
import type { Store as ReduxStore } from 'redux';
import EventEmitter from 'eventemitter3';
import type { ReactReduxContext } from 'react-redux';
export type Store = (ReduxStore | Partial<RefluxStore>) & {
export type Store = any & {
onActivated?: (appRegistry: AppRegistry) => void;

@@ -11,10 +10,33 @@ };

export interface Plugin {
/**
* Redux or reflux store that will be automatically passed to a
* corresponding provider
*/
store: Store;
/**
* Optional, only relevant for plugins using redux stores in cases where
* exposed plugin methods need access to plugin store in react tree where
* another redux store is mounted
*/
context?: typeof ReactReduxContext;
/**
* Optional, only relevant for plugins still using reflux
*/
actions?: RefluxActions;
/**
* Will be called to clean up plugin subscriptions when it is deactivated by
* app registry scope
*/
deactivate: () => void;
}
/**
* Is a registry for all user interface components, stores, and actions
* in the application.
*/
export declare class AppRegistry {
_emitter: EventEmitter;
plugins: Record<string, Plugin>;
/**
* Instantiate the registry.
*/
constructor();

@@ -26,13 +48,83 @@ static get AppRegistry(): typeof AppRegistry;

deactivate(): void;
/**
* Adds a listener for the event name to the underlying event emitter.
*
* @param {String} eventName - The event name.
* @param {Function} listener - The listener.
*
* @returns {AppRegistry} The chainable app registry.
*/
addListener(eventName: string, listener: (...args: any[]) => void): this;
/**
* Emits an event for the name with the provided arguments.
*
* @param {String} eventName - The event name.
* @param {...Object} args - The arguments.
*
* @returns {Boolean} If the event had listeners.
*/
emit(eventName: string, ...args: any[]): boolean;
/**
* Return all the event names.
*
* @returns {Array} The event names.
*/
eventNames(): string[];
/**
* Gets a count of listeners for the event name.
*
* @param {String} eventName - The event name.
*
* @returns {Number} The listener count.
*/
listenerCount(eventName: string): number;
/**
* Get all the listeners for the event.
*
* @param {String} eventName - The event name.
*
* @returns {Array} The listeners for the event.
*/
listeners(eventName: string): ((...args: any[]) => void)[];
/**
* Adds a listener for the event name to the underlying event emitter.
*
* @param {String} eventName - The event name.
* @param {Function} listener - The listener.
*
* @returns {AppRegistry} The chainable app registry.
*/
on(eventName: string, listener: (...args: any[]) => void): this;
/**
* Adds a listener for the event name to the underlying event emitter
* to handle an event only once.
*
* @param {String} eventName - The event name.
* @param {Function} listener - The listener.
*
* @returns {AppRegistry} The chainable app registry.
*/
once(eventName: string, listener: (...args: any[]) => void): this;
/**
* Removes a listener for the event.
*
* @param {String} eventName - The event name.
* @param {Function} listener - The listener.
*
* @returns {AppRegistry} The chainable app registry.
*/
removeListener(eventName: string, listener: (...args: any[]) => void): this;
/**
* Removes all the listeners for the event name.
*
* @param {String} eventName - The event name.
*
* @returns {AppRegistry} The chainable app registry.
*/
removeAllListeners(eventName: string): this;
}
/**
* Create a global app registry and prevent modification.
*/
export declare const globalAppRegistry: Readonly<AppRegistry>;
//# sourceMappingURL=app-registry.d.ts.map

@@ -14,3 +14,10 @@ "use strict";

exports.isReduxStore = isReduxStore;
/**
* Is a registry for all user interface components, stores, and actions
* in the application.
*/
class AppRegistry {
/**
* Instantiate the registry.
*/
constructor() {

@@ -20,2 +27,3 @@ this._emitter = new eventemitter3_1.default();

}
// Helper until this module is 'proper' fake ESM
static get AppRegistry() {

@@ -44,17 +52,60 @@ return AppRegistry;

}
/**
* Adds a listener for the event name to the underlying event emitter.
*
* @param {String} eventName - The event name.
* @param {Function} listener - The listener.
*
* @returns {AppRegistry} The chainable app registry.
*/
addListener(eventName, listener) {
return this.on(eventName, listener);
}
/**
* Emits an event for the name with the provided arguments.
*
* @param {String} eventName - The event name.
* @param {...Object} args - The arguments.
*
* @returns {Boolean} If the event had listeners.
*/
emit(eventName, ...args) {
return this._emitter.emit(eventName, ...args);
}
/**
* Return all the event names.
*
* @returns {Array} The event names.
*/
eventNames() {
return this._emitter.eventNames();
}
/**
* Gets a count of listeners for the event name.
*
* @param {String} eventName - The event name.
*
* @returns {Number} The listener count.
*/
listenerCount(eventName) {
return this._emitter.listeners(eventName).length;
}
/**
* Get all the listeners for the event.
*
* @param {String} eventName - The event name.
*
* @returns {Array} The listeners for the event.
*/
listeners(eventName) {
return this._emitter.listeners(eventName);
}
/**
* Adds a listener for the event name to the underlying event emitter.
*
* @param {String} eventName - The event name.
* @param {Function} listener - The listener.
*
* @returns {AppRegistry} The chainable app registry.
*/
on(eventName, listener) {

@@ -64,2 +115,11 @@ this._emitter.on(eventName, listener);

}
/**
* Adds a listener for the event name to the underlying event emitter
* to handle an event only once.
*
* @param {String} eventName - The event name.
* @param {Function} listener - The listener.
*
* @returns {AppRegistry} The chainable app registry.
*/
once(eventName, listener) {

@@ -69,2 +129,10 @@ this._emitter.once(eventName, listener);

}
/**
* Removes a listener for the event.
*
* @param {String} eventName - The event name.
* @param {Function} listener - The listener.
*
* @returns {AppRegistry} The chainable app registry.
*/
removeListener(eventName, listener) {

@@ -74,2 +142,9 @@ this._emitter.removeListener(eventName, listener);

}
/**
* Removes all the listeners for the event name.
*
* @param {String} eventName - The event name.
*
* @returns {AppRegistry} The chainable app registry.
*/
removeAllListeners(eventName) {

@@ -81,3 +156,6 @@ this._emitter.removeAllListeners(eventName);

exports.AppRegistry = AppRegistry;
/**
* Create a global app registry and prevent modification.
*/
exports.globalAppRegistry = Object.freeze(new AppRegistry());
//# sourceMappingURL=app-registry.js.map

@@ -6,3 +6,4 @@ import { AppRegistry, globalAppRegistry } from './app-registry';

export { registerHadronPlugin, createActivateHelpers, createServiceLocator, createServiceProvider, } from './register-plugin';
export type { Plugin as HadronPlugin } from './app-registry';
export default AppRegistry;
//# sourceMappingURL=index.d.ts.map
import React from 'react';
import { AppRegistry } from './app-registry';
/**
* @internal exported for the mock plugin helper implementation
*/
export declare const GlobalAppRegistryContext: React.Context<Readonly<AppRegistry>>;

@@ -7,6 +10,27 @@ type AppRegistryProviderProps = {

deactivateOnUnmount?: never;
children: React.ReactNode;
children?: React.ReactNode;
scopeName?: string;
} | {
/**
* localAppRegistry to be set in React context. By default will be created
* when this component renders. Can be used to preserve appRegistry state even
* if AppRegistryProvider is unmounted
*
* @example
* function CollectionTab({ id }) {
* return (
* <AppRegistryProvider
* appRegistry={getRegistryForTabId(id)}
* deactivateOnUnmount={false}
* >
* ...
* </AppRegistryProvider>
* )
* }
*/
localAppRegistry: AppRegistry;
/**
* Deactivates all active plugins and remove all event listeners from the app
* registry when provider unmounts. Default is `true`
*/
deactivateOnUnmount?: boolean;

@@ -20,2 +44,3 @@ children: React.ReactNode;

}): JSX.Element;
export declare function useIsTopLevelProvider(): boolean;
export declare function AppRegistryProvider({ children, ...props }: AppRegistryProviderProps): JSX.Element;

@@ -22,0 +47,0 @@ export declare function useGlobalAppRegistry(): AppRegistry;

@@ -26,5 +26,8 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.useLocalAppRegistry = exports.useGlobalAppRegistry = exports.AppRegistryProvider = exports.GlobalAppRegistryProvider = exports.GlobalAppRegistryContext = void 0;
exports.useLocalAppRegistry = exports.useGlobalAppRegistry = exports.AppRegistryProvider = exports.useIsTopLevelProvider = exports.GlobalAppRegistryProvider = exports.GlobalAppRegistryContext = void 0;
const react_1 = __importStar(require("react"));
const app_registry_1 = require("./app-registry");
/**
* @internal exported for the mock plugin helper implementation
*/
exports.GlobalAppRegistryContext = (0, react_1.createContext)(app_registry_1.globalAppRegistry);

@@ -37,2 +40,6 @@ const LocalAppRegistryContext = (0, react_1.createContext)(null);

exports.GlobalAppRegistryProvider = GlobalAppRegistryProvider;
function useIsTopLevelProvider() {
return (0, react_1.useContext)(LocalAppRegistryContext) === null;
}
exports.useIsTopLevelProvider = useIsTopLevelProvider;
function AppRegistryProvider({ children, ...props }) {

@@ -42,3 +49,3 @@ const initialPropsRef = (0, react_1.useRef)(props);

const globalAppRegistry = useGlobalAppRegistry();
const isTopLevelProvider = (0, react_1.useContext)(LocalAppRegistryContext) === null;
const isTopLevelProvider = useIsTopLevelProvider();
const [localAppRegistry] = (0, react_1.useState)(() => {

@@ -49,2 +56,7 @@ return (initialLocalAppRegistry ??

(0, react_1.useEffect)(() => {
// For cases where localAppRegistry was provided by the parent, we allow
// parent to also take control over the cleanup lifecycle by disabling
// deactivate call with the `deactivateOnUnmount` prop. Otherwise if
// localAppRegistry was created by the provider, it will always clean up on
// unmount
const shouldDeactivate = initialLocalAppRegistry

@@ -51,0 +63,0 @@ ? deactivateOnUnmount

@@ -8,3 +8,14 @@ import React from 'react';

constructor();
/**
* A signal for the abort controller that will be aborted when the cleanup
* method is called. Helpful to be able to abort or check whether or not
* plugin is still active in async tasks triggered during plugin activate
* phase
*/
get signal(): AbortSignal;
/**
* Helper method to subscribe to events on a generic event emitter. Events
* will be added to the cleanup set and will be cleaned up when `cleanup` is
* called
*/
on: (emitter: {

@@ -14,3 +25,10 @@ on(evt: string, fn: (...args: any) => any): any;

}, evt: string, fn: (...args: any) => any) => void;
/**
* Add an arbitrary callback to the cleanup set
*/
addCleanup: (fn?: () => void) => void;
/**
* Call all the cleanup callbacks. This includes any events listeners set up
* with an `on` helper and everything that was added with `addCleanup`
*/
cleanup: () => void;

@@ -27,6 +45,12 @@ }

};
export type HadronPluginConfig<T, S extends Record<string, () => unknown>> = {
export type HadronPluginConfig<T, S extends Record<string, () => unknown>, A extends Plugin> = {
name: string;
component: React.ComponentType<T>;
activate: (initialProps: T, services: Registries & Services<S>, helpers: ActivateHelpers) => Plugin;
/**
* Plugin activation method, will receive any props passed to the component,
* and global and local app registry instances to subscribe to any relevant
* events. Should return plugin store and an optional deactivate method to
* clean up subscriptions or any other store-related state
*/
activate: (initialProps: T, services: Registries & Services<S>, helpers: ActivateHelpers) => A;
};

@@ -39,11 +63,110 @@ type MockOptions = {

};
/**
* Helper method to "create" a service locator function for a particular
* service. This method guarantees that service locators are used only in
* appropriate context. Every service locator function in the application should
* be created with this method.
*/
export declare function createServiceLocator<T extends (this: any, ...args: any[]) => any>(fn: T, name?: string): T;
/**
* Optional service provider creation method. In some cases service providers
* need access to other service locators to facilitate service injections. In
* these cases service provider can be wrapped with the createServiceProvider
* function to allow usage of serviceLocator functions in providers outside of
* the usual hadron plugin "activate" lifecycle.
*/
export declare function createServiceProvider<T extends React.FunctionComponent<any>>(fn: T): T;
export type HadronPluginComponent<T, S extends Record<string, () => unknown>> = React.FunctionComponent<T> & {
export type HadronPluginComponent<T, S extends Record<string, () => unknown>, A extends Plugin> = React.FunctionComponent<T> & {
displayName: string;
useActivate(props: T): void;
withMockServices(mocks: Partial<Registries & Services<S>>, options?: Partial<Pick<MockOptions, 'disableChildPluginRendering'>>): React.FunctionComponent<T>;
/**
* Hook that will activate plugin in the current rendering scope without
* actually rendering it. Useful to set up plugins that are rendered
* conditionally and have to subscribe to event listeners earlier than the
* first render in their lifecycle
*
* @example
* const Plugin = registerHadronPlugin(...);
*
* function Component() {
* Plugin.useActivate();
* const [pluginVisible] = useState(false);
*
* // This Plugin component will already have its store set up and listening
* // to the events even before rendering
* return (pluginVisible && <Plugin />)
* }
*/
useActivate(props: T): A;
/**
* Convenience method for testing: allows to override services and app
* registries available in the plugin context
*
* @example
* const PluginWithLogger = registerHadronPlugin({ ... }, { logger: loggerLocator });
*
* const MockPlugin = PluginWithLogger.withMockServices({ logger: Sinon.stub() });
*
* @param mocks Overrides for the services locator values and registries
* passed to the plugin in runtime. When `globalAppRegistry`
* override is passed, it will be also used for the
* localAppRegistry override unless `localAppRegistry` is also
* explicitly passed as a mock service.
*/
withMockServices(mocks: Partial<Registries & Services<S>>, options?: Partial<Pick<MockOptions, 'disableChildPluginRendering'>>): HadronPluginComponent<T, S, A>;
};
export declare function registerHadronPlugin<T, S extends Record<string, () => unknown>>(config: HadronPluginConfig<T, S>, services?: S): HadronPluginComponent<T, S>;
/**
* Creates a hadron plugin that will be automatically activated on first render
* and cleaned up when localAppRegistry unmounts
*
* @param config Hadron plugin configuration
* @param services Map of service locator functions that plugin depends on
*
* @returns Hadron plugin component
*
* @example
* const CreateCollectionPlugin = registerHadronPlugin({
* name: 'CreateCollection',
* component: CreateCollectionModal,
* activate(opts, { globalAppRegistry }) {
* const store = configureStore(...);
* const openCreateCollectionModal = (ns) => {
* store.dispatch(openModal(ns));
* }
* globalAppRegistry.on('create-collection', openCreateCollectionModal);
* return {
* store,
* deactivate() {
* globalAppRegistry.removeEventListener(
* 'create-collection',
* openCreateCollectionModal
* );
* }
* }
* }
* });
*
* @example
* // app.js
* import CompassLogging from '@mongodb-js/compass-logging';
* import { LoggingProvider } from '@mongodb-js/compass-logging/provider';
*
* ReactDOM.render(
* <LoggingProvider service={CompassLogging}>
* <PluginWithLogger />
* </LoggingProvider>
* )
*
* // plugin.js
* import { logging } from '@mongodb-js/compass-logging/provider'
*
* const PluginWithLogger = registerHadronPlugin({
* name: 'LoggingPlugin',
* component: () => null,
* activate(opts, { logging }) {
* logging.log('Plugin activated!');
* }
* }, { logging })
*/
export declare function registerHadronPlugin<T, S extends Record<string, () => unknown>, A extends Plugin>(config: HadronPluginConfig<T, S, A>, services?: S): HadronPluginComponent<T, S, A>;
export {};
//# sourceMappingURL=register-plugin.d.ts.map

@@ -35,2 +35,7 @@ "use strict";

this.deactivateController = new AbortController();
/**
* Helper method to subscribe to events on a generic event emitter. Events
* will be added to the cleanup set and will be cleaned up when `cleanup` is
* called
*/
this.on = (emitter, evt, fn) => {

@@ -43,2 +48,5 @@ const voidFn = (...args) => void fn(...args);

};
/**
* Add an arbitrary callback to the cleanup set
*/
this.addCleanup = (fn) => {

@@ -49,2 +57,6 @@ if (fn) {

};
/**
* Call all the cleanup callbacks. This includes any events listeners set up
* with an `on` helper and everything that was added with `addCleanup`
*/
this.cleanup = () => {

@@ -59,2 +71,8 @@ for (const fn of this.cleanupFns.values()) {

}
/**
* A signal for the abort controller that will be aborted when the cleanup
* method is called. Helpful to be able to abort or check whether or not
* plugin is still active in async tasks triggered during plugin activate
* phase
*/
get signal() {

@@ -77,5 +95,16 @@ return this.deactivateController.signal;

}, []);
return react_1.default.cloneElement(children, { store, actions, ...actions, ...state });
return react_1.default.cloneElement(
// There is a ton of issues with cloning children like that,
// this is a legacy piece of code that we know works in our cases and so we
// can ignore ts errors instead of handling all corner-cases
children,
// There is no single pattern to how reflux is used by plugins, sometime
// store is passed directly, sometimes only state, sometimes actions are
// passed as a single prop, sometimes spreaded, sometimes all the approaches
// are mixed and used like that in the plugins. Reflux is legacy that we
// prefer to not spend time cleaning up so we're just trying to cover all
// the cases here as much as possible
{ store, actions, ...actions, ...state });
}
const defaultMockOptions = {
const DEFAULT_MOCK_OPTIONS = {
pluginName: '$$root',

@@ -86,8 +115,14 @@ mockedEnvironment: false,

};
const MockOptionsContext = react_1.default.createContext(defaultMockOptions);
const useMockOption = (key) => {
return (0, react_1.useContext)(MockOptionsContext)[key];
const MockOptionsContext = react_1.default.createContext(null);
const useMockOption = (key, defaultMockOptions = DEFAULT_MOCK_OPTIONS) => {
return (0, react_1.useContext)(MockOptionsContext)?.[key] ?? defaultMockOptions[key];
};
let serviceLocationInProgress = false;
const kLocator = Symbol('CompassServiceLocatorFunction');
/**
* Helper method to "create" a service locator function for a particular
* service. This method guarantees that service locators are used only in
* appropriate context. Every service locator function in the application should
* be created with this method.
*/
function createServiceLocator(fn, name = fn.name) {

@@ -103,2 +138,9 @@ return Object.assign(function (...args) {

exports.createServiceLocator = createServiceLocator;
/**
* Optional service provider creation method. In some cases service providers
* need access to other service locators to facilitate service injections. In
* these cases service provider can be wrapped with the createServiceProvider
* function to allow usage of serviceLocator functions in providers outside of
* the usual hadron plugin "activate" lifecycle.
*/
function createServiceProvider(fn) {

@@ -124,6 +166,6 @@ const displayName = `ServiceProvider(${fn.displayName ?? fn.name})`;

}
function useHadronPluginActivate(config, services, props) {
function useHadronPluginActivate(config, services, props, mockOptions) {
const registryName = `${config.name}.Plugin`;
const isMockedEnvironment = useMockOption('mockedEnvironment');
const mockServices = useMockOption('mockServices');
const isMockedEnvironment = useMockOption('mockedEnvironment', mockOptions);
const mockServices = useMockOption('mockServices', mockOptions);
const globalAppRegistry = (0, react_context_1.useGlobalAppRegistry)();

@@ -174,2 +216,55 @@ const localAppRegistry = (0, react_context_1.useLocalAppRegistry)();

}
/**
* Creates a hadron plugin that will be automatically activated on first render
* and cleaned up when localAppRegistry unmounts
*
* @param config Hadron plugin configuration
* @param services Map of service locator functions that plugin depends on
*
* @returns Hadron plugin component
*
* @example
* const CreateCollectionPlugin = registerHadronPlugin({
* name: 'CreateCollection',
* component: CreateCollectionModal,
* activate(opts, { globalAppRegistry }) {
* const store = configureStore(...);
* const openCreateCollectionModal = (ns) => {
* store.dispatch(openModal(ns));
* }
* globalAppRegistry.on('create-collection', openCreateCollectionModal);
* return {
* store,
* deactivate() {
* globalAppRegistry.removeEventListener(
* 'create-collection',
* openCreateCollectionModal
* );
* }
* }
* }
* });
*
* @example
* // app.js
* import CompassLogging from '@mongodb-js/compass-logging';
* import { LoggingProvider } from '@mongodb-js/compass-logging/provider';
*
* ReactDOM.render(
* <LoggingProvider service={CompassLogging}>
* <PluginWithLogger />
* </LoggingProvider>
* )
*
* // plugin.js
* import { logging } from '@mongodb-js/compass-logging/provider'
*
* const PluginWithLogger = registerHadronPlugin({
* name: 'LoggingPlugin',
* component: () => null,
* activate(opts, { logging }) {
* logging.log('Plugin activated!');
* }
* }, { logging })
*/
function registerHadronPlugin(config, services) {

@@ -181,2 +276,6 @@ const Component = config.component;

const disableRendering = useMockOption('disableChildPluginRendering');
// This can only be true in test environment when parent plugin is setup
// with mock services. We allow parent to render, but any other plugin
// that would try to render afterwards will just return `null` avoiding
// the need for providing services for child plugins
if (isMockedEnvironment &&

@@ -187,2 +286,6 @@ mockedPluginName !== config.name &&

}
// We don't actually use this hook conditionally, even though eslint rule
// thinks so: values returned by `useMock*` hooks are constant in React
// runtime
// eslint-disable-next-line react-hooks/rules-of-hooks
const { store, actions, context } = useHadronPluginActivate(config, services, props);

@@ -199,8 +302,17 @@ if ((0, app_registry_1.isReduxStore)(store)) {

useActivate: (props) => {
useHadronPluginActivate(config, services, props);
return useHadronPluginActivate(config, services, props);
},
withMockServices(mocks = {}, options) {
const { globalAppRegistry = new app_registry_1.AppRegistry(), localAppRegistry = globalAppRegistry, ...mockServices } = mocks;
const {
// In case globalAppRegistry mock is not provided, we use the one
// created in scope so that plugins don't leak their events and
// registered metadata on the globalAppRegistry
globalAppRegistry = new app_registry_1.AppRegistry(),
// If localAppRegistry is not explicitly provided, use the passed mock
// for global app registry instead
localAppRegistry = globalAppRegistry, ...mockServices } = mocks;
// These services will be passed to the plugin `activate` method second
// argument
const mockOptions = {
...defaultMockOptions,
...DEFAULT_MOCK_OPTIONS,
mockedEnvironment: true,

@@ -211,8 +323,23 @@ pluginName: config.name,

};
return function MockPluginWithContext(props) {
return (react_1.default.createElement(MockOptionsContext.Provider, { value: mockOptions },
react_1.default.createElement(react_context_1.GlobalAppRegistryContext.Provider, { value: globalAppRegistry },
react_1.default.createElement(react_context_1.AppRegistryProvider, { localAppRegistry: localAppRegistry },
react_1.default.createElement(Plugin, { ...props })))));
};
function MockPluginWithContext(props) {
const isTopLevelProvider = (0, react_context_1.useIsTopLevelProvider)();
const hasCustomAppRegistries = !!mockServices.localAppRegistry || !!mockServices.globalAppRegistry;
// Only render these providers if there are no providers for app
// registry set up higher in the rendering tree or if user explicitly
// passed some mocks here. In other cases we're probably be interferring
// with some custom providers setup by the test code
const shouldRenderRegistryProviders = isTopLevelProvider || hasCustomAppRegistries;
return (react_1.default.createElement(MockOptionsContext.Provider, { value: mockOptions }, shouldRenderRegistryProviders ? (react_1.default.createElement(react_context_1.GlobalAppRegistryContext.Provider, { value: globalAppRegistry },
react_1.default.createElement(react_context_1.AppRegistryProvider, { localAppRegistry: localAppRegistry },
react_1.default.createElement(Plugin, { ...props })))) : (react_1.default.createElement(Plugin, { ...props }))));
}
return Object.assign(MockPluginWithContext, {
displayName: config.name,
useActivate: (props) => {
return useHadronPluginActivate(config, services, props, mockOptions);
},
withMockServices() {
return MockPluginWithContext;
},
});
},

@@ -219,0 +346,0 @@ });

14

package.json

@@ -10,3 +10,3 @@ {

"homepage": "https://github.com/mongodb-js/compass",
"version": "0.0.0-next-bc37cfc07b82d66ae76a8abc7104e13cc84c22eb",
"version": "0.0.0-next-be3d5f97c142a1a62831cbb6b70edb79ac62ed02",
"repository": {

@@ -54,7 +54,7 @@ "type": "git",

"devDependencies": {
"@mongodb-js/eslint-config-compass": "0.0.0-next-bc37cfc07b82d66ae76a8abc7104e13cc84c22eb",
"@mongodb-js/mocha-config-compass": "0.0.0-next-bc37cfc07b82d66ae76a8abc7104e13cc84c22eb",
"@mongodb-js/prettier-config-compass": "0.0.0-next-bc37cfc07b82d66ae76a8abc7104e13cc84c22eb",
"@mongodb-js/tsconfig-compass": "0.0.0-next-bc37cfc07b82d66ae76a8abc7104e13cc84c22eb",
"@testing-library/react": "^12.1.5",
"@mongodb-js/eslint-config-compass": "0.0.0-next-be3d5f97c142a1a62831cbb6b70edb79ac62ed02",
"@mongodb-js/mocha-config-compass": "0.0.0-next-be3d5f97c142a1a62831cbb6b70edb79ac62ed02",
"@mongodb-js/prettier-config-compass": "0.0.0-next-be3d5f97c142a1a62831cbb6b70edb79ac62ed02",
"@mongodb-js/testing-library-compass": "0.0.0-next-be3d5f97c142a1a62831cbb6b70edb79ac62ed02",
"@mongodb-js/tsconfig-compass": "0.0.0-next-be3d5f97c142a1a62831cbb6b70edb79ac62ed02",
"@types/chai": "^4.2.21",

@@ -72,3 +72,3 @@ "@types/mocha": "^9.0.0",

},
"gitHead": "bc37cfc07b82d66ae76a8abc7104e13cc84c22eb"
"gitHead": "be3d5f97c142a1a62831cbb6b70edb79ac62ed02"
}

@@ -166,3 +166,8 @@ # hadron-app-registry

```tsx
import { render, cleanup, screen, waitFor } from '@testing-library/react';
import {
render,
cleanup,
screen,
waitFor,
} from '@mongodb-js/testing-library-compass';

@@ -169,0 +174,0 @@ const PluginWithMockServices = WorkspacesPlugin.withMockServices(

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

import type { Store as RefluxStore } from 'reflux';
import type { Store as ReduxStore } from 'redux';

@@ -6,3 +5,7 @@ import EventEmitter from 'eventemitter3';

export type Store = (ReduxStore | Partial<RefluxStore>) & {
// This type is very generic on purpose so that registerPlugin function generic
// type can derive it automatically based on the passed activate function. This
// is helpful when using useActivate hook to get the stricter type of returned
// activate store elsewhere in the code
export type Store = any & {
onActivated?: (appRegistry: AppRegistry) => void;

@@ -9,0 +12,0 @@ };

@@ -20,2 +20,3 @@ import { AppRegistry, globalAppRegistry } from './app-registry';

} from './register-plugin';
export type { Plugin as HadronPlugin } from './app-registry';
export default AppRegistry;

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

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