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

@goji/core

Package Overview
Dependencies
Maintainers
2
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@goji/core - npm Package Compare versions

Comparing version 0.5.10 to 0.5.11

coverage/lcov-report/src/createPageConfig.tsx.html

5

dist/cjs/adaptor/wechat.js

@@ -153,3 +153,6 @@ "use strict";

};
Component(Object.assign(Object.assign({}, pageConfig), eventHandler));
Component(Object.assign(Object.assign({}, pageConfig), { pageLifetimes: {
hide: pageLifecycles.onHide,
show: pageLifecycles.onShow,
}, methods: Object.assign({}, eventHandler) }));
}

@@ -156,0 +159,0 @@ }

18

dist/cjs/components/eventProxy.d.ts

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

import React, { PureComponent } from 'react';
import React from 'react';
export interface EventProxyContextType {

@@ -6,2 +6,5 @@ handleEvent(name: string, callback: Function): void;

export declare const EventProxyContext: React.Context<EventProxyContextType | undefined>;
export interface EventProxy {
emitEvent(name: string, data?: any): void;
}
/**

@@ -13,11 +16,4 @@ * EventProxyProvider is the gateway to communicate between reconciler container and React elements

*/
export declare class EventProxyProvider extends PureComponent {
private events;
constructor(props: any);
state: {
context: EventProxyContextType;
};
private handleEvent;
emitEvent(name: string, data?: any): void;
render(): JSX.Element;
}
export declare const EventProxyProvider: React.ForwardRefExoticComponent<{
children?: React.ReactNode;
} & React.RefAttributes<EventProxy>>;

@@ -14,31 +14,22 @@ "use strict";

*/
class EventProxyProvider extends react_1.PureComponent {
constructor(props) {
super(props);
this.events = new events_1.EventEmitter();
this.state = {
context: {
handleEvent: this.handleEvent.bind(this),
},
};
}
handleEvent(name, callback) {
this.events.on(name, callback);
return () => {
this.events.removeListener(name, callback);
};
}
emitEvent(name, data) {
reconciler_1.batchedUpdates(() => {
this.events.emit(name, data);
});
}
render() {
const { children } = this.props;
const { context } = this.state;
const { Provider } = exports.EventProxyContext;
return react_1.default.createElement(Provider, { value: context }, children);
}
}
exports.EventProxyProvider = EventProxyProvider;
exports.EventProxyProvider = react_1.forwardRef(function EventProxyProvider({ children }, ref) {
const events = react_1.useMemo(() => new events_1.EventEmitter(), []);
react_1.useImperativeHandle(ref, () => ({
emitEvent: (name, data) => {
reconciler_1.batchedUpdates(() => {
events.emit(name, data);
});
},
}), [events]);
const context = react_1.useMemo(() => ({
handleEvent: (name, callback) => {
events.on(name, callback);
return () => {
events.removeListener(name, callback);
};
},
}), [events]);
const { Provider } = exports.EventProxyContext;
return react_1.default.createElement(Provider, { value: context }, children);
});
//# sourceMappingURL=eventProxy.js.map
import React from 'react';
export declare const createRootElement: (children: React.ReactNode) => JSX.Element;
import { EventProxy } from './eventProxy';
export declare const GojiProvider: ({ children, eventProxyRef, }: React.PropsWithChildren<{
eventProxyRef: React.RefObject<EventProxy>;
}>) => JSX.Element;
export { EventProxyContext } from './eventProxy';

@@ -7,5 +7,3 @@ "use strict";

const eventProxy_1 = require("./eventProxy");
// should use function instead of component because we have to make sure
// `EventProxy` is the root element
exports.createRootElement = (children) => (react_1.default.createElement(eventProxy_1.EventProxyProvider, null,
exports.GojiProvider = ({ children, eventProxyRef, }) => (react_1.default.createElement(eventProxy_1.EventProxyProvider, { ref: eventProxyRef },
react_1.default.createElement(provider_1.UniversalHooksProvider, null, children)));

@@ -12,0 +10,0 @@ var eventProxy_2 = require("./eventProxy");

@@ -13,2 +13,3 @@ import { FiberRoot } from 'react-reconciler';

export declare class Container extends BasedContainer {
private eventProxyRef;
rootDOM: Array<ElementInstance | TextInstance>;

@@ -24,3 +25,2 @@ portalRootDOM: Array<ElementInstance | TextInstance>;

unregisterEventHandler(handlerKey: string): void;
private getPublicRootInstance;
private getRootDom;

@@ -27,0 +27,0 @@ emitLifecycleEvent<T extends LifecycleName>(eventName: T, eventData?: any): void;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = require("react");
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importStar(require("react"));
const react_is_1 = require("react-is");

@@ -42,2 +43,3 @@ const render_1 = require("./render");

super(...arguments);
this.eventProxyRef = react_1.createRef();
this.rootDOM = [];

@@ -77,9 +79,16 @@ this.portalRootDOM = [];

const rootInst = new instance_1.ElementInstance('goji_root', {}, [...this.rootDOM, ...this.portalRootDOM], this);
// FIXME: the auto-generated id update every time and cause `verifyDiff` failed
rootInst.id = -1;
rootInst.tag = undefined;
const [children_, updates] = rootInst.pure('');
const [newData, diff] = rootInst.pure('');
if (process.env.NODE_ENV !== 'production') {
// eslint-disable-next-line global-require
const { verifyDiff } = require('./utils/diff');
verifyDiff(this, newData, diff);
}
const startTime = new Date().getTime();
if (!hasChildrenUpdate && Object.keys(updates).length === 0) {
if (!hasChildrenUpdate && Object.keys(diff).length === 0) {
return;
}
this.adaptorInstance.updateData(hasChildrenUpdate ? children_ : updates, () => {
this.adaptorInstance.updateData(hasChildrenUpdate ? newData : diff, () => {
// @ts-ignore

@@ -92,3 +101,3 @@ if (process.env.NODE_ENV !== 'production') {

console.log(`context => property count:${Object.keys(this.adaptorInstance).length}`);
console.log(`updates`, updates, children_);
console.log(`updates`, diff, newData);
}

@@ -104,10 +113,2 @@ events_1.gojiEvents.triggerOnSetData();

}
getPublicRootInstance() {
const container = this.fiberRootContainer;
const containerFiber = container.current;
if (!containerFiber.child) {
return null;
}
return containerFiber.child.stateNode;
}
getRootDom(child) {

@@ -120,9 +121,9 @@ if (child instanceof instance_1.ElementInstance && child.props.$$type === react_is_1.Portal) {

emitLifecycleEvent(eventName, eventData) {
const publicRootInstance = this.getPublicRootInstance();
if (publicRootInstance) {
publicRootInstance.emitEvent(eventName, eventData);
const eventProxy = this.eventProxyRef.current;
if (eventProxy) {
eventProxy.emitEvent(eventName, eventData);
}
}
render(element) {
render_1.renderIntoContainer(components_1.createRootElement(element), this);
render_1.renderIntoContainer(react_1.default.createElement(components_1.GojiProvider, { eventProxyRef: this.eventProxyRef }, element), this);
}

@@ -129,0 +130,0 @@ }

@@ -150,3 +150,6 @@ import React, { cloneElement, useState } from 'react';

};
Component(Object.assign(Object.assign({}, pageConfig), eventHandler));
Component(Object.assign(Object.assign({}, pageConfig), { pageLifetimes: {
hide: pageLifecycles.onHide,
show: pageLifecycles.onShow,
}, methods: Object.assign({}, eventHandler) }));
}

@@ -153,0 +156,0 @@ }

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

import React, { PureComponent } from 'react';
import React from 'react';
export interface EventProxyContextType {

@@ -6,2 +6,5 @@ handleEvent(name: string, callback: Function): void;

export declare const EventProxyContext: React.Context<EventProxyContextType | undefined>;
export interface EventProxy {
emitEvent(name: string, data?: any): void;
}
/**

@@ -13,11 +16,4 @@ * EventProxyProvider is the gateway to communicate between reconciler container and React elements

*/
export declare class EventProxyProvider extends PureComponent {
private events;
constructor(props: any);
state: {
context: EventProxyContextType;
};
private handleEvent;
emitEvent(name: string, data?: any): void;
render(): JSX.Element;
}
export declare const EventProxyProvider: React.ForwardRefExoticComponent<{
children?: React.ReactNode;
} & React.RefAttributes<EventProxy>>;

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

import React, { PureComponent, createContext } from 'react';
import React, { createContext, forwardRef, useMemo, useImperativeHandle, } from 'react';
import { EventEmitter } from 'events';

@@ -11,30 +11,22 @@ import { batchedUpdates } from '../reconciler';

*/
export class EventProxyProvider extends PureComponent {
constructor(props) {
super(props);
this.events = new EventEmitter();
this.state = {
context: {
handleEvent: this.handleEvent.bind(this),
},
};
}
handleEvent(name, callback) {
this.events.on(name, callback);
return () => {
this.events.removeListener(name, callback);
};
}
emitEvent(name, data) {
batchedUpdates(() => {
this.events.emit(name, data);
});
}
render() {
const { children } = this.props;
const { context } = this.state;
const { Provider } = EventProxyContext;
return React.createElement(Provider, { value: context }, children);
}
}
export const EventProxyProvider = forwardRef(function EventProxyProvider({ children }, ref) {
const events = useMemo(() => new EventEmitter(), []);
useImperativeHandle(ref, () => ({
emitEvent: (name, data) => {
batchedUpdates(() => {
events.emit(name, data);
});
},
}), [events]);
const context = useMemo(() => ({
handleEvent: (name, callback) => {
events.on(name, callback);
return () => {
events.removeListener(name, callback);
};
},
}), [events]);
const { Provider } = EventProxyContext;
return React.createElement(Provider, { value: context }, children);
});
//# sourceMappingURL=eventProxy.js.map
import React from 'react';
export declare const createRootElement: (children: React.ReactNode) => JSX.Element;
import { EventProxy } from './eventProxy';
export declare const GojiProvider: ({ children, eventProxyRef, }: React.PropsWithChildren<{
eventProxyRef: React.RefObject<EventProxy>;
}>) => JSX.Element;
export { EventProxyContext } from './eventProxy';
import React from 'react';
import { UniversalHooksProvider } from '../lifecycles/universal/provider';
import { EventProxyProvider } from './eventProxy';
// should use function instead of component because we have to make sure
// `EventProxy` is the root element
export const createRootElement = (children) => (React.createElement(EventProxyProvider, null,
export const GojiProvider = ({ children, eventProxyRef, }) => (React.createElement(EventProxyProvider, { ref: eventProxyRef },
React.createElement(UniversalHooksProvider, null, children)));
export { EventProxyContext } from './eventProxy';
//# sourceMappingURL=index.js.map

@@ -13,2 +13,3 @@ import { FiberRoot } from 'react-reconciler';

export declare class Container extends BasedContainer {
private eventProxyRef;
rootDOM: Array<ElementInstance | TextInstance>;

@@ -24,3 +25,2 @@ portalRootDOM: Array<ElementInstance | TextInstance>;

unregisterEventHandler(handlerKey: string): void;
private getPublicRootInstance;
private getRootDom;

@@ -27,0 +27,0 @@ emitLifecycleEvent<T extends LifecycleName>(eventName: T, eventData?: any): void;

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

import { cloneElement } from 'react';
import React, { cloneElement, createRef } from 'react';
import { Portal } from 'react-is';

@@ -6,3 +6,3 @@ import { renderIntoContainer } from './render';

import { gojiEvents } from './events';
import { createRootElement } from './components';
import { GojiProvider } from './components';
const getGlobalVariable = () => {

@@ -40,2 +40,3 @@ /* eslint-disable no-undef */

super(...arguments);
this.eventProxyRef = createRef();
this.rootDOM = [];

@@ -75,9 +76,16 @@ this.portalRootDOM = [];

const rootInst = new ElementInstance('goji_root', {}, [...this.rootDOM, ...this.portalRootDOM], this);
// FIXME: the auto-generated id update every time and cause `verifyDiff` failed
rootInst.id = -1;
rootInst.tag = undefined;
const [children_, updates] = rootInst.pure('');
const [newData, diff] = rootInst.pure('');
if (process.env.NODE_ENV !== 'production') {
// eslint-disable-next-line global-require
const { verifyDiff } = require('./utils/diff');
verifyDiff(this, newData, diff);
}
const startTime = new Date().getTime();
if (!hasChildrenUpdate && Object.keys(updates).length === 0) {
if (!hasChildrenUpdate && Object.keys(diff).length === 0) {
return;
}
this.adaptorInstance.updateData(hasChildrenUpdate ? children_ : updates, () => {
this.adaptorInstance.updateData(hasChildrenUpdate ? newData : diff, () => {
// @ts-ignore

@@ -90,3 +98,3 @@ if (process.env.NODE_ENV !== 'production') {

console.log(`context => property count:${Object.keys(this.adaptorInstance).length}`);
console.log(`updates`, updates, children_);
console.log(`updates`, diff, newData);
}

@@ -102,10 +110,2 @@ gojiEvents.triggerOnSetData();

}
getPublicRootInstance() {
const container = this.fiberRootContainer;
const containerFiber = container.current;
if (!containerFiber.child) {
return null;
}
return containerFiber.child.stateNode;
}
getRootDom(child) {

@@ -118,11 +118,11 @@ if (child instanceof ElementInstance && child.props.$$type === Portal) {

emitLifecycleEvent(eventName, eventData) {
const publicRootInstance = this.getPublicRootInstance();
if (publicRootInstance) {
publicRootInstance.emitEvent(eventName, eventData);
const eventProxy = this.eventProxyRef.current;
if (eventProxy) {
eventProxy.emitEvent(eventName, eventData);
}
}
render(element) {
renderIntoContainer(createRootElement(element), this);
renderIntoContainer(React.createElement(GojiProvider, { eventProxyRef: this.eventProxyRef }, element), this);
}
}
//# sourceMappingURL=container.js.map
{
"name": "@goji/core",
"version": "0.5.10",
"version": "0.5.11",
"description": "Goji Core",

@@ -81,3 +81,3 @@ "main": "dist/cjs/index.js",

},
"gitHead": "d2731e21e0754887f29dfc73bca2554b42d5855d"
"gitHead": "a43a6ffee93f43cbdde7e85e286fbaa55666ffe6"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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

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

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

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