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

zoid

Package Overview
Dependencies
Maintainers
2
Versions
147
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zoid - npm Package Compare versions

Comparing version 9.0.70 to 9.0.71

2

package.json
{
"name": "zoid",
"version": "9.0.70",
"version": "9.0.71",
"description": "Cross domain components.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -7,7 +7,7 @@ /* @flow */

import { isWindow, getDomain, type CrossDomainWindowType } from 'cross-domain-utils/src';
import { noop, isElement, cleanup, memoize, identity } from 'belter/src';
import { noop, isElement, cleanup, memoize, identity, extend } from 'belter/src';
import { getChildPayload, childComponent, type ChildComponent } from '../child';
import { type RenderOptionsType, type ParentHelpers, parentComponent } from '../parent/parent';
import { CONTEXT, POST_MESSAGE, WILDCARD, DEFAULT_DIMENSIONS } from '../constants';
import { CONTEXT, POST_MESSAGE, WILDCARD, DEFAULT_DIMENSIONS, METHOD } from '../constants';
import { react, angular, vue, angular2 } from '../drivers';

@@ -50,2 +50,3 @@ import { getGlobal, destroyGlobal } from '../lib';

bridgeUrl? : string,
method? : $Values<typeof METHOD>,

@@ -93,2 +94,3 @@ props? : UserPropsDefinitionType<P, X>,

bridgeUrl : ?string,
method : ?$Values<typeof METHOD>,

@@ -122,3 +124,3 @@ propsDef : PropsDefinitionType<P, X>,

render : (container? : string | HTMLElement, context? : $Values<typeof CONTEXT>) => ZalgoPromise<void>,
renderTo : (target : CrossDomainWindowType, container? : string, context? : $Values<typeof CONTEXT>) => ZalgoPromise<void>
renderTo : (target : CrossDomainWindowType, container? : string | HTMLElement, context? : $Values<typeof CONTEXT>) => ZalgoPromise<void>
|};

@@ -169,3 +171,4 @@

logger = { info: noop },
exports: xports = getDefaultExports()
exports: xports = getDefaultExports(),
method
} = options;

@@ -193,2 +196,3 @@

bridgeUrl,
method,
propsDef,

@@ -265,3 +269,5 @@ dimensions: { width, height },

return {
parent: parentComponent(options, overrides, source)
parent: parentComponent({
options, overrides, parentWin: source
})
};

@@ -340,3 +346,6 @@ });

const parent = parentComponent(options);
const parent = parentComponent({
options
});
parent.init();

@@ -356,2 +365,6 @@

const clone = ({ decorate = identity } = {}) => {
return init(decorate(props));
};
const render = (target, container, context) => {

@@ -371,2 +384,6 @@ return ZalgoPromise.try(() => {

if (target !== window && typeof container !== 'string') {
throw new Error(`Must pass string element when rendering to another window`);
}
return getDefaultContext(props, context);

@@ -376,3 +393,12 @@

container = getDefaultContainer(finalContext, container);
return parent.render(target, container, finalContext);
return parent.render({
target,
container,
context: finalContext,
rerender: () => {
const newInstance = clone();
extend(instance, newInstance);
return newInstance.renderTo(target, container, context);
}
});

@@ -386,6 +412,2 @@ }).catch(err => {

const clone = ({ decorate = identity } = {}) => {
return init(decorate(props));
};
instance = {

@@ -392,0 +414,0 @@ ...parent.getExports(),

@@ -8,3 +8,3 @@ /* @flow */

import { PROP_SERIALIZATION } from '../constants';
import { PROP_SERIALIZATION, PROP_TYPE } from '../constants';

@@ -76,3 +76,3 @@ export type EventHandlerType<T> = (T) => void | ZalgoPromise<void>;

export type PropDefinitionType<T, P, S : string, X> = {|
export type PropDefinitionType<T, P, S : $Values<typeof PROP_TYPE>, X> = {|
type : S,

@@ -121,4 +121,7 @@ alias? : string,

queryParam? : boolean | string | ({| value : T |}) => (string | ZalgoPromise<string>),
bodyParam? : boolean | string | ({| value : T |}) => (string | ZalgoPromise<string>),
// eslint-disable-next-line no-undef
queryValue? : <R>({| value : T |}) => (ZalgoPromise<R> | R | string),
// eslint-disable-next-line no-undef
bodyValue? : <R>({| value : T |}) => (ZalgoPromise<R> | R | string),
sendToChild? : boolean,

@@ -125,0 +128,0 @@ allowDelegate? : boolean,

@@ -58,1 +58,6 @@ /* @flow */

};
export const METHOD = {
GET: ('get' : 'get'),
POST: ('post' : 'post')
};

@@ -11,6 +11,6 @@ /* @flow */

noop, onResize, extendUrl, appendChild, cleanup, base64encode, isRegex,
once, stringifyError, destroyElement, getElementSafe, showElement, hideElement, iframe, memoize,
once, stringifyError, destroyElement, getElementSafe, showElement, hideElement, iframe, memoize, isElementClosed,
awaitFrameWindow, popup, normalizeDimension, watchElementForClose, isShadowElement, insertShadowSlot } from 'belter/src';
import { ZOID, POST_MESSAGE, CONTEXT, EVENT,
import { ZOID, POST_MESSAGE, CONTEXT, EVENT, METHOD,
INITIAL_PROPS, WINDOW_REFERENCES } from '../constants';

@@ -23,3 +23,3 @@ import { getGlobal, getProxyObject, type ProxyObject } from '../lib';

import { propsToQuery, extendProps } from './props';
import { serializeProps, extendProps } from './props';

@@ -96,2 +96,14 @@ export type RenderOptionsType<P> = {|

type Rerender = () => ZalgoPromise<void>;
type RenderContainerOptions = {|
context : $Values<typeof CONTEXT>,
uid : string,
proxyFrame : ?ProxyObject<HTMLIFrameElement>,
proxyPrerenderFrame : ?ProxyObject<HTMLIFrameElement>,
rerender : Rerender
|};
type ResolveInitPromise = () => ZalgoPromise<void>;
type RejectInitPromise = (mixed) => ZalgoPromise<void>;
type GetProxyContainer = (container : string | HTMLElement) => ZalgoPromise<ProxyObject<HTMLElement>>;

@@ -102,3 +114,3 @@ type Show = () => ZalgoPromise<void>;

type OnError = (mixed) => ZalgoPromise<void>;
type RenderContainer = (proxyContainer : ProxyObject<HTMLElement>, {| context : $Values<typeof CONTEXT>, uid : string, proxyFrame : ?ProxyObject<HTMLIFrameElement>, proxyPrerenderFrame : ?ProxyObject<HTMLIFrameElement> |}) => ZalgoPromise<?ProxyObject<HTMLElement>>;
type RenderContainer = (proxyContainer : ProxyObject<HTMLElement>, RenderContainerOptions) => ZalgoPromise<?ProxyObject<HTMLElement>>;
type SetProxyWin = (ProxyWindow) => ZalgoPromise<void>;

@@ -133,3 +145,5 @@ type GetProxyWindow = () => ZalgoPromise<ProxyWindow>;

getInternalState : GetInternalState,
setInternalState : SetInternalState
setInternalState : SetInternalState,
resolveInitPromise : ResolveInitPromise,
rejectInitPromise : RejectInitPromise
|};

@@ -152,5 +166,12 @@

type RenderOptions = {|
target : CrossDomainWindowType,
container : string | HTMLElement,
context : $Values<typeof CONTEXT>,
rerender : Rerender
|};
type ParentComponent<P, X> = {|
init : () => void,
render : (CrossDomainWindowType, string | HTMLElement, $Values<typeof CONTEXT>) => ZalgoPromise<void>,
render : (RenderOptions) => ZalgoPromise<void>,
setProps : (newProps : PropsInputType<P>, isUpdate? : boolean) => void,

@@ -168,3 +189,9 @@ destroy : (err? : mixed) => ZalgoPromise<void>,

export function parentComponent<P, X>(options : NormalizedComponentOptionsType<P, X>, overrides? : ParentDelegateOverrides<P> = getDefaultOverrides(), parentWin : CrossDomainWindowType = window) : ParentComponent<P, X> {
type ParentOptions<P, X> = {|
options : NormalizedComponentOptionsType<P, X>,
overrides? : ParentDelegateOverrides<P>,
parentWin? : CrossDomainWindowType
|};
export function parentComponent<P, X>({ options, overrides = getDefaultOverrides(), parentWin = window } : ParentOptions<P, X>) : ParentComponent<P, X> {
const { propsDef, containerTemplate, prerenderTemplate, tag, name, attributes, dimensions, autoResize, url, domain: domainMatch, validate, exports: xports } = options;

@@ -203,2 +230,22 @@

const resolveInitPromise = () => {
return ZalgoPromise.try(() => {
if (overrides.resolveInitPromise) {
return overrides.resolveInitPromise();
}
return initPromise.resolve();
});
};
const rejectInitPromise = (err : mixed) => {
return ZalgoPromise.try(() => {
if (overrides.rejectInitPromise) {
return overrides.rejectInitPromise(err);
}
return initPromise.reject(err);
});
};
const getPropsForChild = (domain : string | RegExp) : ZalgoPromise<PropsType<P>> => {

@@ -238,3 +285,3 @@ const result = {};

} else {
return initPromise.reject(err).then(() => {
return rejectInitPromise(err).then(() => {
setTimeout(() => {

@@ -375,4 +422,12 @@ throw err;

const buildQuery = () : ZalgoPromise<{| [string] : string | boolean |}> => {
return serializeProps(propsDef, props, METHOD.GET);
};
const buildBody = () : ZalgoPromise<{| [string] : string | boolean |}> => {
return serializeProps(propsDef, props, METHOD.POST);
};
const buildUrl = () : ZalgoPromise<string> => {
return propsToQuery(propsDef, props).then(query => {
return buildQuery().then(query => {
return extendUrl(normalizeMockUrl(getUrl()), { query });

@@ -510,3 +565,3 @@ });

childComponent = childExports;
initPromise.resolve();
resolveInitPromise();
clean.register(() => childExports.close.fireAndForget().catch(noop));

@@ -599,3 +654,5 @@ });

proxyWin.setWindow(win, { send });
return proxyWin;
return proxyWin.setName(windowName).then(() => {
return proxyWin;
});
});

@@ -630,6 +687,8 @@ };

}).then(isClosed => {
if (isClosed) {
return close(new Error(`Detected ${ context } close`));
} else if (!cancelled) {
return watchForClose(proxyWin, context);
if (!cancelled) {
if (isClosed) {
return close(new Error(`Detected ${ context } close`));
} else {
return watchForClose(proxyWin, context);
}
}

@@ -774,8 +833,6 @@ });

};
const renderContainer : RenderContainer = (proxyContainer : ProxyObject<HTMLElement>, { proxyFrame, proxyPrerenderFrame, context, uid, rerender } : RenderContainerOptions) : ZalgoPromise<?ProxyObject<HTMLElement>> => {
const renderContainer : RenderContainer = (proxyContainer : ProxyObject<HTMLElement>, { proxyFrame, proxyPrerenderFrame, context, uid } :
{| context : $Values<typeof CONTEXT>, uid : string, proxyFrame : ?ProxyObject<HTMLIFrameElement>, proxyPrerenderFrame : ?ProxyObject<HTMLIFrameElement> |}) : ZalgoPromise<?ProxyObject<HTMLElement>> => {
if (renderContainerOverride) {
return renderContainerOverride(proxyContainer, { proxyFrame, proxyPrerenderFrame, context, uid });
return renderContainerOverride(proxyContainer, { proxyFrame, proxyPrerenderFrame, context, uid, rerender });
}

@@ -797,3 +854,13 @@

appendChild(container, innerContainer);
const containerWatcher = watchElementForClose(innerContainer, () => close(new Error(`Detected container element removed from DOM`)));
const containerWatcher = watchElementForClose(innerContainer, () => {
const removeError = new Error(`Detected container element removed from DOM`);
return ZalgoPromise.delay(1).then(() => {
if (isElementClosed(innerContainer)) {
close(removeError);
} else {
clean.all(removeError);
return rerender().then(resolveInitPromise, rejectInitPromise);
}
});
});

@@ -889,3 +956,3 @@ clean.register(() => containerWatcher.cancel());

const childOverridesPromise = send(target, `${ POST_MESSAGE.DELEGATE }_${ name }`, {
overrides: { props: delegateProps, event, close, onError, getInternalState, setInternalState }
overrides: { props: delegateProps, event, close, onError, getInternalState, setInternalState, resolveInitPromise, rejectInitPromise }
}).then(({ data: { parent } }) => {

@@ -958,3 +1025,3 @@ const parentComp : ParentComponent<P, X> = parent;

const render = (target : CrossDomainWindowType, container : string | HTMLElement, context : $Values<typeof CONTEXT>) : ZalgoPromise<void> => {
const render = ({ target, container, context, rerender } : RenderOptions) : ZalgoPromise<void> => {
return ZalgoPromise.try(() => {

@@ -978,2 +1045,3 @@ const uid = `${ ZOID }-${ tag }-${ uniqueID() }`;

const buildUrlPromise = buildUrl();
const buildBodyPromise = buildBody();
const onRenderPromise = event.trigger(EVENT.RENDER);

@@ -992,3 +1060,3 @@

const renderContainerPromise = ZalgoPromise.hash({ proxyContainer: getProxyContainerPromise, proxyFrame: openFramePromise, proxyPrerenderFrame: openPrerenderFramePromise }).then(({ proxyContainer, proxyFrame, proxyPrerenderFrame }) => {
return renderContainer(proxyContainer, { context, uid, proxyFrame, proxyPrerenderFrame });
return renderContainer(proxyContainer, { context, uid, proxyFrame, proxyPrerenderFrame, rerender });
}).then(proxyContainer => {

@@ -1023,6 +1091,19 @@ return proxyContainer;

const loadUrlPromise = ZalgoPromise.hash({ proxyWin: openPromise, builtUrl: buildUrlPromise, windowName: setWindowNamePromise, prerender: prerenderPromise }).then(({ proxyWin, builtUrl }) => {
return proxyWin.setLocation(builtUrl);
const getMethodPromise = ZalgoPromise.hash({ body: buildBodyPromise }).then(({ body }) => {
if (options.method) {
return options.method;
}
if (Object.keys(body).length) {
return METHOD.POST;
}
return METHOD.GET;
});
const loadUrlPromise = ZalgoPromise.hash({ proxyWin: openPromise, windowUrl: buildUrlPromise, body: buildBodyPromise, method: getMethodPromise, windowName: setWindowNamePromise, prerender: prerenderPromise }).then(({ proxyWin, windowUrl, body, method }) => {
return proxyWin.setLocation(windowUrl, { method, body });
});
const watchForClosePromise = openPromise.then(proxyWin => {

@@ -1029,0 +1110,0 @@ watchForClose(proxyWin, context);

@@ -7,3 +7,3 @@ /* @flow */

import { eachProp, mapProps, type PropsInputType, type PropsType, type PropsDefinitionType } from '../component/props';
import { PROP_SERIALIZATION } from '../constants';
import { PROP_SERIALIZATION, METHOD } from '../constants';

@@ -104,3 +104,3 @@ import type { ParentHelpers } from './index';

export function propsToQuery<P, X>(propsDef : PropsDefinitionType<P, X>, props : (PropsType<P>)) : ZalgoPromise<{ [string] : string | boolean }> {
export function serializeProps<P, X>(propsDef : PropsDefinitionType<P, X>, props : (PropsType<P>), method : $Values<typeof METHOD>) : ZalgoPromise<{ [string] : string | boolean }> {

@@ -116,3 +116,13 @@ const params = {};

if (!propDef.queryParam) {
const getParam = {
[ METHOD.GET ]: propDef.queryParam,
[ METHOD.POST ]: propDef.bodyParam
}[method];
const getValue = {
[ METHOD.GET ]: propDef.queryValue,
[ METHOD.POST ]: propDef.bodyValue
}[method];
if (!getParam) {
return;

@@ -123,8 +133,8 @@ }

queryParam: ZalgoPromise.try(() => {
if (typeof propDef.queryParam === 'function') {
finalParam: ZalgoPromise.try(() => {
if (typeof getParam === 'function') {
// $FlowFixMe[incompatible-call]
return propDef.queryParam({ value });
} else if (typeof propDef.queryParam === 'string') {
return propDef.queryParam;
return getParam({ value });
} else if (typeof getParam === 'string') {
return getParam;
} else {

@@ -135,7 +145,7 @@ return key;

queryValue: ZalgoPromise.try(() => {
if (typeof propDef.queryValue === 'function' && isDefined(value)) {
finalValue: ZalgoPromise.try(() => {
if (typeof getValue === 'function' && isDefined(value)) {
// $FlowFixMe[incompatible-call]
// $FlowFixMe[incompatible-return]
return propDef.queryValue({ value });
return getValue({ value });
} else {

@@ -147,18 +157,18 @@ // $FlowFixMe[incompatible-return]

}).then(({ queryParam, queryValue }) => {
}).then(({ finalParam, finalValue }) => {
let result;
if (typeof queryValue === 'boolean') {
result = queryValue.toString();
} else if (typeof queryValue === 'string') {
result = queryValue.toString();
} else if (typeof queryValue === 'object' && queryValue !== null) {
if (typeof finalValue === 'boolean') {
result = finalValue.toString();
} else if (typeof finalValue === 'string') {
result = finalValue.toString();
} else if (typeof finalValue === 'object' && finalValue !== null) {
if (propDef.serialization === PROP_SERIALIZATION.JSON) {
result = JSON.stringify(queryValue);
result = JSON.stringify(finalValue);
} else if (propDef.serialization === PROP_SERIALIZATION.BASE64) {
result = base64encode(JSON.stringify(queryValue));
result = base64encode(JSON.stringify(finalValue));
} else if (propDef.serialization === PROP_SERIALIZATION.DOTIFY || !propDef.serialization) {
result = dotify(queryValue, key);
result = dotify(finalValue, key);

@@ -172,7 +182,7 @@ for (const dotkey of Object.keys(result)) {

} else if (typeof queryValue === 'number') {
result = queryValue.toString();
} else if (typeof finalValue === 'number') {
result = finalValue.toString();
}
params[queryParam] = result;
params[finalParam] = result;
});

@@ -179,0 +189,0 @@ });

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

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 too big to display

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 too big to display

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 too big to display

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

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