Comparing version 9.0.69 to 9.0.70
{ | ||
"name": "zoid", | ||
"version": "9.0.69", | ||
"version": "9.0.70", | ||
"description": "Cross domain components.", | ||
@@ -58,3 +58,3 @@ "main": "index.js", | ||
"devDependencies": { | ||
"flow-bin": "0.135.0", | ||
"flow-bin": "0.155.0", | ||
"grumbler-scripts": "^3", | ||
@@ -61,0 +61,0 @@ "jsx-pragmatic": "^2", |
@@ -149,3 +149,3 @@ /* @flow */ | ||
function normalizeOptions<P, X>(options : ComponentOptionsType<P, X>) : NormalizedComponentOptionsType<P, X> { | ||
let { | ||
const { | ||
tag, | ||
@@ -155,3 +155,3 @@ url, | ||
bridgeUrl, | ||
props: propsDef = {}, | ||
props = {}, | ||
dimensions = {}, | ||
@@ -173,4 +173,8 @@ autoResize = getDefaultAutoResize(), | ||
// $FlowFixMe | ||
propsDef = { ...getBuiltInProps(), ...propsDef }; | ||
// $FlowFixMe[incompatible-type] | ||
// $FlowFixMe[cannot-spread-inexact] | ||
const propsDef : PropsDefinitionType<P, X> = { | ||
...getBuiltInProps(), | ||
...props | ||
}; | ||
@@ -435,2 +439,4 @@ if (!containerTemplate) { | ||
export type ZoidProps<P> = PropsType<P>; | ||
export function create<P, X>(options : ComponentOptionsType<P, X>) : ZoidComponent<P, X> { | ||
@@ -437,0 +443,0 @@ setupPostRobot(); |
@@ -35,7 +35,6 @@ /* @flow */ | ||
// eslint-disable-next-line flowtype/require-exact-type | ||
export type PropsInputType<P> = { | ||
export type PropsInputType<P> = {| | ||
timeout? : timeoutPropType, | ||
window? : windowPropType, | ||
cspNonce? : cspNoncePropType, | ||
cspNonce? : ?cspNoncePropType, | ||
@@ -50,7 +49,8 @@ onDisplay? : onDisplayPropType, | ||
onError? : onErrorPropType, | ||
onProps? : onPropsPropType<P> | ||
} & P; | ||
onProps? : onPropsPropType<P>, | ||
// eslint-disable-next-line flowtype/require-exact-type | ||
export type PropsType<P> = { | ||
...P | ||
|}; | ||
export type PropsType<P> = {| | ||
timeout? : timeoutPropType, | ||
@@ -72,6 +72,8 @@ window? : ?windowPropType, | ||
onError : onErrorPropType, | ||
onProps : onPropsPropType<P> | ||
} & P; | ||
onProps : onPropsPropType<P>, | ||
...P | ||
|}; | ||
type PropDefinitionType<T, P, S : string, X> = {| | ||
export type PropDefinitionType<T, P, S : string, X> = {| | ||
type : S, | ||
@@ -120,6 +122,7 @@ alias? : string, | ||
queryParam? : boolean | string | ({| value : T |}) => (string | ZalgoPromise<string>), | ||
queryValue? : ({| value : T |}) => (ZalgoPromise<string> | string), | ||
// eslint-disable-next-line no-undef | ||
queryValue? : <R>({| value : T |}) => (ZalgoPromise<R> | R | string), | ||
sendToChild? : boolean, | ||
allowDelegate? : boolean, | ||
validate? : ({| value : T, props : PropsInputType<P> |}) => void, | ||
validate? : ({| value : T, props : PropsType<P> |}) => void, | ||
sameDomain? : boolean, | ||
@@ -136,7 +139,13 @@ serialization? : $Values<typeof PROP_SERIALIZATION> | ||
export type MixedPropDefinitionType<P, X> = BooleanPropDefinitionType<*, P, X> | StringPropDefinitionType<*, P, X> | NumberPropDefinitionType<*, P, X> | FunctionPropDefinitionType<*, P, X> | ObjectPropDefinitionType<*, P, X> | ArrayPropDefinitionType<*, P, X>; | ||
export type MixedPropDefinitionType<P, X> = | ||
BooleanPropDefinitionType<*, P, X> | | ||
StringPropDefinitionType<*, P, X> | | ||
NumberPropDefinitionType<*, P, X> | | ||
FunctionPropDefinitionType<*, P, X> | | ||
ObjectPropDefinitionType<*, P, X> | | ||
ArrayPropDefinitionType<*, P, X>; | ||
export type UserPropsDefinitionType<P, X> = { | ||
export type UserPropsDefinitionType<P, X> = {| | ||
[string] : MixedPropDefinitionType<P, X> | ||
}; | ||
|}; | ||
@@ -174,3 +183,4 @@ export type BuiltInPropsDefinitionType<P, X> = {| | ||
const defaultNoop = () => noop; | ||
const decorateOnce = ({ value }) => once(value); | ||
// eslint-disable-next-line flowtype/require-exact-type | ||
const decorateOnce = <F : Function>({ value } : { value : F }) : F => once(value); | ||
@@ -355,1 +365,34 @@ export function getBuiltInProps<P, X>() : BuiltInPropsDefinitionType<P, X> { | ||
} | ||
type PropCallback<P, X, R> = | ||
((string, BooleanPropDefinitionType<boolean, P, X>, boolean) => R) & | ||
((string, StringPropDefinitionType<string, P, X>, string) => R) & | ||
((string, NumberPropDefinitionType<number, P, X>, number) => R) & | ||
((string, FunctionPropDefinitionType<Function, P, X>, Function) => R) & | ||
((string, ArrayPropDefinitionType<$ReadOnlyArray<*> | $ReadOnlyArray<*>, P, X>, $ReadOnlyArray<*> | $ReadOnlyArray<*>) => R) & | ||
((string, ObjectPropDefinitionType<Object, P, X>, Object) => R); | ||
export function eachProp<P, X>(props : PropsType<P>, propsDef : PropsDefinitionType<P, X>, handler : PropCallback<P, X, void>) { | ||
for (const key of Object.keys(props)) { | ||
const propDef = propsDef[key]; | ||
const value = props[key]; | ||
if (!propDef) { | ||
continue; | ||
} | ||
// $FlowFixMe[incompatible-call] | ||
handler(key, propDef, value); | ||
} | ||
} | ||
export function mapProps<P, X, T>(props : PropsType<P>, propsDef : PropsDefinitionType<P, X>, handler : PropCallback<P, X, T>) : $ReadOnlyArray<T> { | ||
const results = []; | ||
eachProp(props, propsDef, (key, propDef, value) => { | ||
// $FlowFixMe[incompatible-call] | ||
const result = handler(key, propDef, value); | ||
results.push(result); | ||
}); | ||
return results; | ||
} |
@@ -70,15 +70,24 @@ /* @flow */ | ||
constructor: [ ElementRef, NgZone, function angularConstructor(elementRef, zone) { | ||
// $FlowFixMe[object-this-reference] | ||
this._props = {}; | ||
// $FlowFixMe[object-this-reference] | ||
this.elementRef = elementRef; | ||
// $FlowFixMe[object-this-reference] | ||
this.zone = zone; | ||
} ], | ||
ngOnInit () { | ||
// $FlowFixMe[object-this-reference] | ||
const targetElement = this.elementRef.nativeElement; | ||
// $FlowFixMe[object-this-reference] | ||
this.parent = init(getProps(this)); | ||
// $FlowFixMe[object-this-reference] | ||
this.parent.render(targetElement, CONTEXT.IFRAME); | ||
}, | ||
ngDoCheck() { | ||
// $FlowFixMe[object-this-reference] | ||
if (this.parent && !equals(this._props, this.props)) { | ||
// $FlowFixMe[object-this-reference] | ||
this._props = { ...this.props }; | ||
// $FlowFixMe[object-this-reference] | ||
this.parent.updateProps(getProps(this)); | ||
@@ -85,0 +94,0 @@ } |
@@ -52,4 +52,7 @@ /* @flow */ | ||
mounted() { | ||
// $FlowFixMe[object-this-reference] | ||
const el = this.$el; | ||
// $FlowFixMe[object-this-reference] | ||
this.parent = init({ ...propsToCamelCase(this.$attrs) }); | ||
// $FlowFixMe[object-this-reference] | ||
this.parent.render(el, CONTEXT.IFRAME); | ||
@@ -56,0 +59,0 @@ }, |
@@ -5,3 +5,3 @@ /* @flow */ | ||
export type { ZoidComponent, ZoidComponentInstance } from './component'; | ||
export type { ZoidComponent, ZoidComponentInstance, ZoidProps } from './component'; | ||
export type { RenderOptionsType } from './parent'; | ||
@@ -8,0 +8,0 @@ |
@@ -13,2 +13,3 @@ /* @flow */ | ||
return ZalgoPromise.try(() => { | ||
// $FlowFixMe[object-this-reference] | ||
if (this.source && this.source !== window) { | ||
@@ -15,0 +16,0 @@ throw new Error(`Can not call get on proxy object from a remote window`); |
@@ -26,3 +26,3 @@ /* @flow */ | ||
uid : string, | ||
props : PropsInputType<P>, | ||
props : PropsType<P>, | ||
tag : string, | ||
@@ -174,3 +174,3 @@ context : $Values<typeof CONTEXT>, | ||
const event = overrides.event ? overrides.event : eventEmitter(); | ||
const props = overrides.props ? overrides.props : getDefaultProps(); | ||
const props : PropsType<P> = overrides.props ? overrides.props : getDefaultProps(); | ||
@@ -711,3 +711,2 @@ let currentProxyWin : ?ProxyWindow; | ||
const renderTemplate = (renderer : (RenderOptionsType<P>) => ?HTMLElement, { context, uid, container, doc, frame, prerenderFrame } : {| context : $Values<typeof CONTEXT>, uid : string, container? : HTMLElement, doc : Document, frame? : ?HTMLIFrameElement, prerenderFrame? : ?HTMLIFrameElement |}) : ?HTMLElement => { | ||
// $FlowFixMe | ||
return renderer({ | ||
@@ -714,0 +713,0 @@ container, context, uid, doc, frame, prerenderFrame, |
@@ -6,3 +6,3 @@ /* @flow */ | ||
import type { PropsInputType, PropsType, PropsDefinitionType, MixedPropDefinitionType } from '../component/props'; | ||
import { eachProp, mapProps, type PropsInputType, type PropsType, type PropsDefinitionType } from '../component/props'; | ||
import { PROP_SERIALIZATION } from '../constants'; | ||
@@ -12,12 +12,11 @@ | ||
/* Normalize Props | ||
--------------- | ||
function getDefaultInputProps<P>() : P { | ||
// $FlowFixMe[incompatible-type] | ||
const defaultInputProps : P = {}; | ||
return defaultInputProps; | ||
} | ||
Turn props into normalized values, using defaults, function options, etc. | ||
*/ | ||
export function extendProps<P, X>(propsDef : PropsDefinitionType<P, X>, props : PropsType<P>, inputProps : PropsInputType<P>, helpers : ParentHelpers<P>, isUpdate : boolean = false) { | ||
export function extendProps<P, X>(propsDef : PropsDefinitionType<P, X>, props : PropsType<P>, inputProps : PropsInputType<P>, helpers : ParentHelpers<P>, isUpdate : boolean = false) { // eslint-disable-line complexity | ||
// $FlowFixMe | ||
inputProps = inputProps || {}; | ||
inputProps = inputProps || getDefaultInputProps(); | ||
extend(props, inputProps); | ||
@@ -77,12 +76,10 @@ | ||
// $FlowFixMe | ||
for (const key of Object.keys(props)) { | ||
const propDef = propsDef[key]; | ||
const value = props[key]; | ||
eachProp(props, propsDef, (key, propDef, value) => { | ||
if (!propDef) { | ||
continue; | ||
return; | ||
} | ||
if (__DEBUG__ && isDefined(value) && propDef.validate) { | ||
// $FlowFixMe[incompatible-call] | ||
// $FlowFixMe[incompatible-exact] | ||
propDef.validate({ value, props }); | ||
@@ -92,5 +89,8 @@ } | ||
if (isDefined(value) && propDef.decorate) { | ||
props[key] = propDef.decorate({ value, props, state, close, focus, event, onError }); | ||
// $FlowFixMe[incompatible-call] | ||
const decoratedValue = propDef.decorate({ value, props, state, close, focus, event, onError }); | ||
// $FlowFixMe[incompatible-type] | ||
props[key] = decoratedValue; | ||
} | ||
} | ||
}); | ||
@@ -107,26 +107,2 @@ for (const key of Object.keys(propsDef)) { | ||
// $FlowFixMe | ||
function getQueryParam<P, X>(prop : MixedPropDefinitionType<P, X>, key : string, value : string) : ZalgoPromise<string> { | ||
return ZalgoPromise.try(() => { | ||
if (typeof prop.queryParam === 'function') { | ||
return prop.queryParam({ value }); | ||
} else if (typeof prop.queryParam === 'string') { | ||
return prop.queryParam; | ||
} else { | ||
return key; | ||
} | ||
}); | ||
} | ||
// $FlowFixMe | ||
function getQueryValue<P, X>(prop : MixedPropDefinitionType<P, X>, key : string, value : string) : ZalgoPromise<string> { | ||
return ZalgoPromise.try(() => { | ||
if (typeof prop.queryValue === 'function' && isDefined(value)) { | ||
return prop.queryValue({ value }); | ||
} else { | ||
return value; | ||
} | ||
}); | ||
} | ||
export function propsToQuery<P, X>(propsDef : PropsDefinitionType<P, X>, props : (PropsType<P>)) : ZalgoPromise<{ [string] : string | boolean }> { | ||
@@ -136,17 +112,5 @@ | ||
// $FlowFixMe | ||
const keys = Object.keys(props); | ||
return ZalgoPromise.all(keys.map(key => { | ||
const prop = propsDef[key]; | ||
if (!prop) { | ||
return; // eslint-disable-line array-callback-return | ||
} | ||
return ZalgoPromise.all(mapProps(props, propsDef, (key, propDef, value) => { | ||
return ZalgoPromise.resolve().then(() => { | ||
const value = props[key]; | ||
if (value === null || typeof value === 'undefined') { | ||
@@ -156,19 +120,32 @@ return; | ||
if (!prop.queryParam) { | ||
if (!propDef.queryParam) { | ||
return; | ||
} | ||
return value; | ||
return ZalgoPromise.hash({ | ||
}).then(value => { | ||
queryParam: ZalgoPromise.try(() => { | ||
if (typeof propDef.queryParam === 'function') { | ||
// $FlowFixMe[incompatible-call] | ||
return propDef.queryParam({ value }); | ||
} else if (typeof propDef.queryParam === 'string') { | ||
return propDef.queryParam; | ||
} else { | ||
return key; | ||
} | ||
}), | ||
queryValue: ZalgoPromise.try(() => { | ||
if (typeof propDef.queryValue === 'function' && isDefined(value)) { | ||
// $FlowFixMe[incompatible-call] | ||
// $FlowFixMe[incompatible-return] | ||
return propDef.queryValue({ value }); | ||
} else { | ||
// $FlowFixMe[incompatible-return] | ||
return value; | ||
} | ||
}) | ||
if (value === null || typeof value === 'undefined') { | ||
return; | ||
} | ||
}).then(({ queryParam, queryValue }) => { | ||
return ZalgoPromise.all([ | ||
getQueryParam(prop, key, value), | ||
getQueryValue(prop, key, value) | ||
]).then(([ queryParam, queryValue ]) => { | ||
let result; | ||
@@ -182,7 +159,7 @@ | ||
if (prop.serialization === PROP_SERIALIZATION.JSON) { | ||
if (propDef.serialization === PROP_SERIALIZATION.JSON) { | ||
result = JSON.stringify(queryValue); | ||
} else if (prop.serialization === PROP_SERIALIZATION.BASE64) { | ||
} else if (propDef.serialization === PROP_SERIALIZATION.BASE64) { | ||
result = base64encode(JSON.stringify(queryValue)); | ||
} else if (prop.serialization === PROP_SERIALIZATION.DOTIFY || !prop.serialization) { | ||
} else if (propDef.serialization === PROP_SERIALIZATION.DOTIFY || !propDef.serialization) { | ||
result = dotify(queryValue, key); | ||
@@ -189,0 +166,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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3151077
22732