function mapImageResources(rootDir, subDir, type, resourceName) {
    var pathMap = {};
    shell.ls(path.join(rootDir, subDir, type + '-*'))
    .forEach(function (drawableFolder) {
        var imagePath = path.join(subDir, path.basename(drawableFolder), resourceName);
        pathMap[imagePath] = null;
    });
    return pathMap;
}

function mapImageResources ( rootDir , subDir , type , resourceName ) { var pathMap = { } ; shell . ls ( path . join ( rootDir , subDir , type + '-*' ) ) . forEach ( function ( drawableFolder ) { var imagePath = path . join ( subDir , path . basename ( drawableFolder ) , resourceName ) ; pathMap [ imagePath ] = null ; } ) ; return pathMap ; }

Gets a map containing resources of a specified name from all drawable folders in a directory.

Gets a map containing resources of a specified name from all drawable folders in a directory .


function findAndroidLaunchModePreference(platformConfig) {
    var launchMode = platformConfig.getPreference('AndroidLaunchMode');
    if (!launchMode) {
        // Return a default value
        return 'singleTop';
    }

    var expectedValues = ['standard', 'singleTop', 'singleTask', 'singleInstance'];
    var valid = expectedValues.indexOf(launchMode) >= 0;
    if (!valid) {
        // Note: warn, but leave the launch mode as developer wanted, in case the list of options changes in the future
        events.emit('warn', 'Unrecognized value for AndroidLaunchMode preference: ' +
            launchMode + '. Expected values are: ' + expectedValues.join(', '));
    }

    return launchMode;
}

Gets and validates 'AndroidLaunchMode' prepference from config.xml. Returns
preference value and warns if it doesn't seems to be valid

@param   {ConfigParser}  platformConfig  A configParser instance for
platform.

@return  {String}                  Preference's value from config.xml or
default value, if there is no such preference. The default value is
'singleTop'

Gets and validates AndroidLaunchMode prepference from config . xml . Returns preference value and warns if it doesn t seems to be valid


function AndroidManifest(path) {
    this.path = path;
    this.doc = xml.parseElementtreeSync(path);
    if (this.doc.getroot().tag !== 'manifest') {
        throw new Error('AndroidManifest at ' + path + ' has incorrect root node name (expected "manifest")');
    }
}


function expectUnmetRequirements (expected) {
    const actual = unmetRequirementsCollector.store;
    expect(actual).toEqual(jasmine.arrayWithExactContents(expected));
}

function expectUnmetRequirements ( expected ) { const actual = unmetRequirementsCollector . store ; expect ( actual ) . toEqual ( jasmine . arrayWithExactContents ( expected ) ) ; }

Checks the warnings that were printed by the CLI to ensure that the code is listing the correct reasons for failure. Checks against the global warnings object which is reset before each test

Checks the warnings that were printed by the CLI to ensure that the code is listing the correct reasons for failure . Checks against the global warnings object which is reset before each test


function findVersion (versions, version) {
    var cleanedVersion = semver.clean(version);
    for (var i = 0; i < versions.length; i++) {
        if (semver.clean(versions[i]) === cleanedVersion) {
            return versions[i];
        }
    }
    return null;
}

function findVersion ( versions , version ) { var cleanedVersion = semver . clean ( version ) ; for ( var i = 0 ; i < versions . length ; i ++ ) { if ( semver . clean ( versions [ i ] ) === cleanedVersion ) { return versions [ i ] ; } } return null ; }

return the version if it is in the versions array return null if the version doesn't exist in the array

return the version if it is in the versions array return null if the version doesn t exist in the array


function listUnmetRequirements (name, failedRequirements) {
    events.emit('warn', 'Unmet project requirements for latest version of ' + name + ':');

    failedRequirements.forEach(function (req) {
        events.emit('warn', '    ' + req.dependency + ' (' + req.installed + ' in project, ' + req.required + ' required)');
    });
}

emits warnings to users of failed dependnecy requirements in their projects


function(folderName, task) {
    var defer = Q.defer();

    var vn = (task.name || folderName);

    if (!task.id || !check.isUUID(task.id)) {
        defer.reject(createError(vn + ': id is a required guid'));
    };

    if (!task.name || !check.isAlphanumeric(task.name)) {
        defer.reject(createError(vn + ': name is a required alphanumeric string'));
    }

    if (!task.friendlyName || !check.isLength(task.friendlyName, 1, 40)) {
        defer.reject(createError(vn + ': friendlyName is a required string <= 40 chars'));
    }

    if (!task.instanceNameFormat) {
        defer.reject(createError(vn + ': instanceNameFormat is required'));
    }

    // resolve if not already rejected
    defer.resolve();
    return defer.promise;
}

Validates the structure of a task.json file.

Validates the structure of a task . json file .


function (travisYML, newVersion, newCodeName, existingVersions) {
  // Should only add the new version if it is not present in any form
  if (existingVersions.versions.length === 0) return travisYML
  const nodeVersionIndex = getNodeVersionIndex(existingVersions.versions, newVersion, newCodeName)
  const travisYMLLines = travisYML.split('\n')
  // We only need to do something if the new version isn’t present
  if (nodeVersionIndex === -1) {
    let delimiter = ''
    let leadingSpaces = ''
    if (existingVersions.versions && existingVersions.versions.length > 0) {
      if (existingVersions.versions[0].match(/"/)) {
        delimiter = '"'
      }
      if (existingVersions.versions[0].match(/'/)) {
        delimiter = "'"
      }
      leadingSpaces = existingVersions.versions[0].match(/^([ ]*)/)[1]
    }
    // splice the new version back onto the end of the node version list in the original travisYMLLines array,
    // unless it wasn’t an array but an inline definition of a single version, eg: `node_js: 9`
    if (existingVersions.versions.length === 1 && existingVersions.startIndex === existingVersions.endIndex) {
      // A single node version was defined in inline format, now we want to define two versions in array format
      travisYMLLines.splice(existingVersions.startIndex, 1, 'node_js:')
      travisYMLLines.splice(existingVersions.startIndex + 1, 0, `${leadingSpaces}- ${existingVersions.versions[0]}`)
      travisYMLLines.splice(existingVersions.startIndex + 2, 0, `${leadingSpaces}- ${delimiter}${newVersion}${delimiter}`)
    } else {
      // Multiple node versions were defined in array format
      travisYMLLines.splice(existingVersions.endIndex + 1, 0, `${leadingSpaces}- ${delimiter}${newVersion}${delimiter}`)
    }
  }
  return travisYMLLines.join('\n')
}

function
(
travisYML
,
newVersion
,
newCodeName
,
existingVersions
)
{
if
(
existingVersions
.
versions
.
length
===
0
)
return
travisYML
const
nodeVersionIndex
=
getNodeVersionIndex
(
existingVersions
.
versions
,
newVersion
,
newCodeName
)
const
travisYMLLines
=
travisYML
.
split
(
'\n'
)
\n
if
(
nodeVersionIndex
===
1
)
{
let
delimiter
=
''
let
leadingSpaces
=
''
if
(
existingVersions
.
versions
&&
existingVersions
.
versions
.
length
>
0
)
{
if
(
existingVersions
.
versions
[
0
]
.
match
(
/
"
/
)
)
{
delimiter
=
'"'
}
if
(
existingVersions
.
versions
[
0
]
.
match
(
/
'
/
)
)
{
delimiter
=
"'"
}
leadingSpaces
=
existingVersions
.
versions
[
0
]
.
match
(
/
^([ ]*)
/
)
[
1
]
}
if
(
existingVersions
.
versions
.
length
===
1
&&
existingVersions
.
startIndex
===
existingVersions
.
endIndex
)
{
travisYMLLines
.
splice
(
existingVersions
.
startIndex
,
1
,
'node_js:'
)
travisYMLLines
.
splice
(
existingVersions
.
startIndex
+
1
,
0
,
`
${
leadingSpaces
}
${
existingVersions
.
versions
[
0
]
}
`
)
travisYMLLines
.
splice
(
existingVersions
.
startIndex
+
2
,
0
,
`
${
leadingSpaces
}
${
delimiter
}
${
newVersion
}
${
delimiter
}
`
)
}
else
{
travisYMLLines
.
splice
(
existingVersions
.
endIndex
+
1
,
0
,
`
${
leadingSpaces
}
${
delimiter
}
${
newVersion
}
${
delimiter
}
`
)
}
}
}

Stop! YAMLtime! existingVersions is the output of getNodeVersionsFromTravisYML


function (travisYML, newVersion, newCodeName, existingVersions) {
  // Should only remove the old version if it is actually present in any form
  if (existingVersions.versions.length === 0) return travisYML
  const nodeVersionIndex = getNodeVersionIndex(existingVersions.versions, newVersion, newCodeName, true)
  let travisYMLLines = travisYML.split('\n')
  // We only need to do something if the old version is present
  if (nodeVersionIndex !== -1) {
    // If it’s the only version we don’t want to remove it
    if (existingVersions.versions.length !== 1) {
      // Multiple node versions were defined in array format
      // set lines we want to remove to undefined in existingVersion.versions and filter them out afterwards
      const updatedVersionsArray = _.filter(existingVersions.versions.map((version) => {
        return hasNodeVersion(version, newVersion, newCodeName, true) ? undefined : version
      }), Boolean)
      // splice the updated existingversions into travisymllines
      travisYMLLines.splice(existingVersions.startIndex + 1, existingVersions.endIndex - existingVersions.startIndex, updatedVersionsArray)
      // has an array in an array, needs to be flattened
      travisYMLLines = _.flatten(travisYMLLines)
    }
  }
  return travisYMLLines.join('\n')
}

function ( travisYML , newVersion , newCodeName , existingVersions ) { if ( existingVersions . versions . length === 0 ) return travisYML const nodeVersionIndex = getNodeVersionIndex ( existingVersions . versions , newVersion , newCodeName , true ) let travisYMLLines = travisYML . split ( '\n' ) \n if ( nodeVersionIndex !== - 1 ) { if ( existingVersions . versions . length !== 1 ) { const updatedVersionsArray = _ . filter ( existingVersions . versions . map ( ( version ) => { return hasNodeVersion ( version , newVersion , newCodeName , true ) ? undefined : version } ) , Boolean ) travisYMLLines . splice ( existingVersions . startIndex + 1 , existingVersions . endIndex - existingVersions . startIndex , updatedVersionsArray ) travisYMLLines = _ . flatten ( travisYMLLines ) } } }

existingVersions is the output of getNodeVersionsFromTravisYML


function travisTransform (travisYML) {
    try {
      var travisJSON = yaml.safeLoad(travisYML, {
        schema: yaml.FAILSAFE_SCHEMA
      })
    } catch (e) {
      // ignore .travis.yml if it can not be parsed
      return
    }
    // No node versions specified in root level of travis YML
    // There may be node versions defined in the matrix or jobs keys, but those can become
    // far too complex for us to handle, so we don’t
    if (!_.get(travisJSON, 'node_js')) return

    const nodeVersionFromYaml = getNodeVersionsFromTravisYML(travisYML)
    const hasNodeVersion = getNodeVersionIndex(nodeVersionFromYaml.versions, nodeVersion, codeName) !== -1
    if (hasNodeVersion) return

    const updatedTravisYaml = addNodeVersionToTravisYML(travisYML, nodeVersion, codeName, nodeVersionFromYaml)
    return updatedTravisYaml
  }

function travisTransform ( travisYML ) { try { var travisJSON = yaml . safeLoad ( travisYML , { schema : yaml . FAILSAFE_SCHEMA } ) } catch ( e ) { return } if ( ! _ . get ( travisJSON , 'node_js' ) ) return const nodeVersionFromYaml = getNodeVersionsFromTravisYML ( travisYML ) const hasNodeVersion = getNodeVersionIndex ( nodeVersionFromYaml . versions , nodeVersion , codeName ) !== - 1 if ( hasNodeVersion ) return const updatedTravisYaml = addNodeVersionToTravisYML ( travisYML , nodeVersion , codeName , nodeVersionFromYaml ) return updatedTravisYaml }


function isDependencyIgnoredInGroups (groups, packageFilePath, dependencyName) {
  const groupName = getGroupForPackageFile(groups, packageFilePath)
  return groupName && _.includes(groups[groupName].ignore, dependencyName)
}

function isDependencyIgnoredInGroups ( groups , packageFilePath , dependencyName ) { const groupName = getGroupForPackageFile ( groups , packageFilePath ) return groupName && _ . includes ( groups [ groupName ] . ignore , dependencyName ) }

Given a groups array, a package path, and a dependency name, returns whether that dep is ignored for that package in any group

Given a groups array a package path and a dependency name returns whether that dep is ignored for that package in any group


function getDependencyURL ({ repositoryURL, dependency }) {
  // githubURL is an object!
  const githubURL = url.parse(
    githubFromGit(repositoryURL) || ''
  )
  if (dependency && !githubURL.href) {
    return `https://www.npmjs.com/package/${dependency}`
  }
  return githubURL
}

function getDependencyURL ( { repositoryURL , dependency } ) { const githubURL = url . parse ( githubFromGit ( repositoryURL ) || '' ) if ( dependency && ! githubURL . href ) { return ` ${ dependency } ` } return githubURL }

returns a url object if you pass in a GitHub repositoryURL, returns a string with an npm URL if you just pass in a dependency name

returns a url object if you pass in a GitHub repositoryURL returns a string with an npm URL if you just pass in a dependency name


function extractApis(services) {
                            var filterTypes = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1];

                            services = Array.isArray(services) ? services : [services];
                            var apis = services.reduce(function (total, service) {
                                var obj = service.constructor === Object ? service : Object.getPrototypeOf(service);
                                var keys = aggregateApisByType(obj, total, filterTypes);
                                total.push.apply(total, keys);
                                return total;
                            }, []);

                            return apis;
                        }

function extractApis ( services ) { var filterTypes = arguments . length <= 1 || arguments [ 1 ] === undefined ? [ ] : arguments [ 1 ] ; services = Array . isArray ( services ) ? services : [ services ] ; var apis = services . reduce ( function ( total , service ) { var obj = service . constructor === Object ? service : Object . getPrototypeOf ( service ) ; var keys = aggregateApisByType ( obj , total , filterTypes ) ; total . push . apply ( total , keys ) ; return total ; } , [ ] ) ; return apis ; }

extracts lists of methods from each service object.

extracts lists of methods from each service object .


function extractNormalizedFacetValues(results, attribute) {
  var predicate = {name: attribute};
  if (results._state.isConjunctiveFacet(attribute)) {
    var facet = find(results.facets, predicate);
    if (!facet) return [];

    return map(facet.data, function(v, k) {
      return {
        name: k,
        count: v,
        isRefined: results._state.isFacetRefined(attribute, k),
        isExcluded: results._state.isExcludeRefined(attribute, k)
      };
    });
  } else if (results._state.isDisjunctiveFacet(attribute)) {
    var disjunctiveFacet = find(results.disjunctiveFacets, predicate);
    if (!disjunctiveFacet) return [];

    return map(disjunctiveFacet.data, function(v, k) {
      return {
        name: k,
        count: v,
        isRefined: results._state.isDisjunctiveFacetRefined(attribute, k)
      };
    });
  } else if (results._state.isHierarchicalFacet(attribute)) {
    return find(results.hierarchicalFacets, predicate);
  }
}

function extractNormalizedFacetValues ( results , attribute ) { var predicate = { name : attribute } ; if ( results . _state . isConjunctiveFacet ( attribute ) ) { var facet = find ( results . facets , predicate ) ; if ( ! facet ) return [ ] ; return map ( facet . data , function ( v , k ) { return { name : k , count : v , isRefined : results . _state . isFacetRefined ( attribute , k ) , isExcluded : results . _state . isExcludeRefined ( attribute , k ) } ; } ) ; } else if ( results . _state . isDisjunctiveFacet ( attribute ) ) { var disjunctiveFacet = find ( results . disjunctiveFacets , predicate ) ; if ( ! disjunctiveFacet ) return [ ] ; return map ( disjunctiveFacet . data , function ( v , k ) { return { name : k , count : v , isRefined : results . _state . isDisjunctiveFacetRefined ( attribute , k ) } ; } ) ; } else if ( results . _state . isHierarchicalFacet ( attribute ) ) { return find ( results . hierarchicalFacets , predicate ) ; } }

Get the facet values of a specified attribute from a SearchResults object.
@private
@param {SearchResults} results the search results to search in
@param {string} attribute name of the faceted attribute to search for
@return {array|object} facet values. For the hierarchical facets it is an object.

Get the facet values of a specified attribute from a SearchResults object .


function recSort(sortFn, node) {
  if (!node.data || node.data.length === 0) {
    return node;
  }
  var children = map(node.data, partial(recSort, sortFn));
  var sortedChildren = sortFn(children);
  var newNode = merge({}, node, {data: sortedChildren});
  return newNode;
}

function recSort ( sortFn , node ) { if ( ! node . data || node . data . length === 0 ) { return node ; } var children = map ( node . data , partial ( recSort , sortFn ) ) ; var sortedChildren = sortFn ( children ) ; var newNode = merge ( { } , node , { data : sortedChildren } ) ; return newNode ; }

Sort nodes of a hierarchical facet results
@private
@param {HierarchicalFacet} node node to upon which we want to apply the sort


function(attribute, operator, v) {
    var value = valToNumber(v);

    if (this.isNumericRefined(attribute, operator, value)) return this;

    var mod = merge({}, this.numericRefinements);

    mod[attribute] = merge({}, mod[attribute]);

    if (mod[attribute][operator]) {
      // Array copy
      mod[attribute][operator] = mod[attribute][operator].slice();
      // Add the element. Concat can't be used here because value can be an array.
      mod[attribute][operator].push(value);
    } else {
      mod[attribute][operator] = [value];
    }

    return this.setQueryParameters({
      numericRefinements: mod
    });
  }

function ( attribute , operator , v ) { var value = valToNumber ( v ) ; if ( this . isNumericRefined ( attribute , operator , value ) ) return this ; var mod = merge ( { } , this . numericRefinements ) ; mod [ attribute ] = merge ( { } , mod [ attribute ] ) ; if ( mod [ attribute ] [ operator ] ) { mod [ attribute ] [ operator ] = mod [ attribute ] [ operator ] . slice ( ) ; mod [ attribute ] [ operator ] . push ( value ) ; } else { mod [ attribute ] [ operator ] = [ value ] ; } return this . setQueryParameters ( { numericRefinements : mod } ) ; }

Add a numeric filter for a given attribute
When value is an array, they are combined with OR
When value is a single value, it will combined with AND
@method
@param {string} attribute attribute to set the filter on
@param {string} operator operator of the filter (possible values: =, >, >=, <, <=, !=)
@param {number | number[]} value value of the filter
@return {SearchParameters}
@example
// for price = 50 or 40
searchparameter.addNumericRefinement('price', '=', [50, 40]);
@example
// for size = 38 and 40
searchparameter.addNumericRefinement('size', '=', 38);
searchparameter.addNumericRefinement('size', '=', 40);

Add a numeric filter for a given attribute When value is an array they are combined with OR When value is a single value it will combined with AND


function _clearNumericRefinements(attribute) {
    if (isUndefined(attribute)) {
      if (isEmpty(this.numericRefinements)) return this.numericRefinements;
      return {};
    } else if (isString(attribute)) {
      if (isEmpty(this.numericRefinements[attribute])) return this.numericRefinements;
      return omit(this.numericRefinements, attribute);
    } else if (isFunction(attribute)) {
      var hasChanged = false;
      var newNumericRefinements = reduce(this.numericRefinements, function(memo, operators, key) {
        var operatorList = {};

        forEach(operators, function(values, operator) {
          var outValues = [];
          forEach(values, function(value) {
            var predicateResult = attribute({val: value, op: operator}, key, 'numeric');
            if (!predicateResult) outValues.push(value);
          });
          if (!isEmpty(outValues)) {
            if (outValues.length !== values.length) hasChanged = true;
            operatorList[operator] = outValues;
          }
          else hasChanged = true;
        });

        if (!isEmpty(operatorList)) memo[key] = operatorList;

        return memo;
      }, {});

      if (hasChanged) return newNumericRefinements;
      return this.numericRefinements;
    }
  }

function _clearNumericRefinements ( attribute ) { if ( isUndefined ( attribute ) ) { if ( isEmpty ( this . numericRefinements ) ) return this . numericRefinements ; return { } ; } else if ( isString ( attribute ) ) { if ( isEmpty ( this . numericRefinements [ attribute ] ) ) return this . numericRefinements ; return omit ( this . numericRefinements , attribute ) ; } else if ( isFunction ( attribute ) ) { var hasChanged = false ; var newNumericRefinements = reduce ( this . numericRefinements , function ( memo , operators , key ) { var operatorList = { } ; forEach ( operators , function ( values , operator ) { var outValues = [ ] ; forEach ( values , function ( value ) { var predicateResult = attribute ( { val : value , op : operator } , key , 'numeric' ) ; if ( ! predicateResult ) outValues . push ( value ) ; } ) ; if ( ! isEmpty ( outValues ) ) { if ( outValues . length !== values . length ) hasChanged = true ; operatorList [ operator ] = outValues ; } else hasChanged = true ; } ) ; if ( ! isEmpty ( operatorList ) ) memo [ key ] = operatorList ; return memo ; } , { } ) ; if ( hasChanged ) return newNumericRefinements ; return this . numericRefinements ; } }

Clear numeric filters.
@method
@private
@param {string|SearchParameters.clearCallback} [attribute] optional string or function
- If not given, means to clear all the filters.
- If `string`, means to clear all refinements for the `attribute` named filter.
- If `function`, means to clear all the refinements that return truthy values.
@return {Object.<string, OperatorList>}


function addHierarchicalFacet(hierarchicalFacet) {
    if (this.isHierarchicalFacet(hierarchicalFacet.name)) {
      throw new Error(
        'Cannot declare two hierarchical facets with the same name: `' + hierarchicalFacet.name + '`');
    }

    return this.setQueryParameters({
      hierarchicalFacets: this.hierarchicalFacets.concat([hierarchicalFacet])
    });
  }

Add a hierarchical facet to the hierarchicalFacets attribute of the helper
configuration.
@method
@param {object} hierarchicalFacet hierarchical facet to add
@return {SearchParameters}
@throws will throw an error if a hierarchical facet with the same name was already declared

Add a hierarchical facet to the hierarchicalFacets attribute of the helper configuration .


function addFacetRefinement(facet, value) {
    if (!this.isConjunctiveFacet(facet)) {
      throw new Error(facet + ' is not defined in the facets attribute of the helper configuration');
    }
    if (RefinementList.isRefined(this.facetsRefinements, facet, value)) return this;

    return this.setQueryParameters({
      facetsRefinements: RefinementList.addRefinement(this.facetsRefinements, facet, value)
    });
  }

Add a refinement on a "normal" facet
@method
@param {string} facet attribute to apply the faceting on
@param {string} value value of the attribute (will be converted to string)
@return {SearchParameters}


function addExcludeRefinement(facet, value) {
    if (!this.isConjunctiveFacet(facet)) {
      throw new Error(facet + ' is not defined in the facets attribute of the helper configuration');
    }
    if (RefinementList.isRefined(this.facetsExcludes, facet, value)) return this;

    return this.setQueryParameters({
      facetsExcludes: RefinementList.addRefinement(this.facetsExcludes, facet, value)
    });
  }

Exclude a value from a "normal" facet
@method
@param {string} facet attribute to apply the exclusion on
@param {string} value value of the attribute (will be converted to string)
@return {SearchParameters}


function addDisjunctiveFacetRefinement(facet, value) {
    if (!this.isDisjunctiveFacet(facet)) {
      throw new Error(
        facet + ' is not defined in the disjunctiveFacets attribute of the helper configuration');
    }

    if (RefinementList.isRefined(this.disjunctiveFacetsRefinements, facet, value)) return this;

    return this.setQueryParameters({
      disjunctiveFacetsRefinements: RefinementList.addRefinement(
        this.disjunctiveFacetsRefinements, facet, value)
    });
  }

Adds a refinement on a disjunctive facet.
@method
@param {string} facet attribute to apply the faceting on
@param {string} value value of the attribute (will be converted to string)
@return {SearchParameters}

Adds a refinement on a disjunctive facet .


function addTagRefinement(tag) {
    if (this.isTagRefined(tag)) return this;

    var modification = {
      tagRefinements: this.tagRefinements.concat(tag)
    };

    return this.setQueryParameters(modification);
  }

function addTagRefinement ( tag ) { if ( this . isTagRefined ( tag ) ) return this ; var modification = { tagRefinements : this . tagRefinements . concat ( tag ) } ; return this . setQueryParameters ( modification ) ; }

addTagRefinement adds a tag to the list used to filter the results
@param {string} tag tag to be added
@return {SearchParameters}


function removeFacet(facet) {
    if (!this.isConjunctiveFacet(facet)) {
      return this;
    }

    return this.clearRefinements(facet).setQueryParameters({
      facets: filter(this.facets, function(f) {
        return f !== facet;
      })
    });
  }

function removeFacet ( facet ) { if ( ! this . isConjunctiveFacet ( facet ) ) { return this ; } return this . clearRefinements ( facet ) . setQueryParameters ( { facets : filter ( this . facets , function ( f ) { return f !== facet ; } ) } ) ; }

Remove a facet from the facets attribute of the helper configuration, if it
is present.
@method
@param {string} facet facet name to remove
@return {SearchParameters}

Remove a facet from the facets attribute of the helper configuration if it is present .


function removeDisjunctiveFacet(facet) {
    if (!this.isDisjunctiveFacet(facet)) {
      return this;
    }

    return this.clearRefinements(facet).setQueryParameters({
      disjunctiveFacets: filter(this.disjunctiveFacets, function(f) {
        return f !== facet;
      })
    });
  }

function removeDisjunctiveFacet ( facet ) { if ( ! this . isDisjunctiveFacet ( facet ) ) { return this ; } return this . clearRefinements ( facet ) . setQueryParameters ( { disjunctiveFacets : filter ( this . disjunctiveFacets , function ( f ) { return f !== facet ; } ) } ) ; }

Remove a disjunctive facet from the disjunctiveFacets attribute of the
helper configuration, if it is present.
@method
@param {string} facet disjunctive facet name to remove
@return {SearchParameters}

Remove a disjunctive facet from the disjunctiveFacets attribute of the helper configuration if it is present .


function removeHierarchicalFacet(facet) {
    if (!this.isHierarchicalFacet(facet)) {
      return this;
    }

    return this.clearRefinements(facet).setQueryParameters({
      hierarchicalFacets: filter(this.hierarchicalFacets, function(f) {
        return f.name !== facet;
      })
    });
  }

function removeHierarchicalFacet ( facet ) { if ( ! this . isHierarchicalFacet ( facet ) ) { return this ; } return this . clearRefinements ( facet ) . setQueryParameters ( { hierarchicalFacets : filter ( this . hierarchicalFacets , function ( f ) { return f . name !== facet ; } ) } ) ; }

Remove a hierarchical facet from the hierarchicalFacets attribute of the
helper configuration, if it is present.
@method
@param {string} facet hierarchical facet name to remove
@return {SearchParameters}

Remove a hierarchical facet from the hierarchicalFacets attribute of the helper configuration if it is present .


function removeFacetRefinement(facet, value) {
    if (!this.isConjunctiveFacet(facet)) {
      throw new Error(facet + ' is not defined in the facets attribute of the helper configuration');
    }
    if (!RefinementList.isRefined(this.facetsRefinements, facet, value)) return this;

    return this.setQueryParameters({
      facetsRefinements: RefinementList.removeRefinement(this.facetsRefinements, facet, value)
    });
  }

Remove a refinement set on facet. If a value is provided, it will clear the
refinement for the given value, otherwise it will clear all the refinement
values for the faceted attribute.
@method
@param {string} facet name of the attribute used for faceting
@param {string} [value] value used to filter
@return {SearchParameters}

Remove a refinement set on facet . If a value is provided it will clear the refinement for the given value otherwise it will clear all the refinement values for the faceted attribute .


function removeExcludeRefinement(facet, value) {
    if (!this.isConjunctiveFacet(facet)) {
      throw new Error(facet + ' is not defined in the facets attribute of the helper configuration');
    }
    if (!RefinementList.isRefined(this.facetsExcludes, facet, value)) return this;

    return this.setQueryParameters({
      facetsExcludes: RefinementList.removeRefinement(this.facetsExcludes, facet, value)
    });
  }

Remove a negative refinement on a facet
@method
@param {string} facet name of the attribute used for faceting
@param {string} value value used to filter
@return {SearchParameters}


function removeDisjunctiveFacetRefinement(facet, value) {
    if (!this.isDisjunctiveFacet(facet)) {
      throw new Error(
        facet + ' is not defined in the disjunctiveFacets attribute of the helper configuration');
    }
    if (!RefinementList.isRefined(this.disjunctiveFacetsRefinements, facet, value)) return this;

    return this.setQueryParameters({
      disjunctiveFacetsRefinements: RefinementList.removeRefinement(
        this.disjunctiveFacetsRefinements, facet, value)
    });
  }

Remove a refinement on a disjunctive facet
@method
@param {string} facet name of the attribute used for faceting
@param {string} value value used to filter
@return {SearchParameters}


function removeTagRefinement(tag) {
    if (!this.isTagRefined(tag)) return this;

    var modification = {
      tagRefinements: filter(this.tagRefinements, function(t) { return t !== tag; })
    };

    return this.setQueryParameters(modification);
  }

function removeTagRefinement ( tag ) { if ( ! this . isTagRefined ( tag ) ) return this ; var modification = { tagRefinements : filter ( this . tagRefinements , function ( t ) { return t !== tag ; } ) } ; return this . setQueryParameters ( modification ) ; }

Remove a tag from the list of tag refinements
@method
@param {string} tag the tag to remove
@return {SearchParameters}


function toggleFacetRefinement(facet, value) {
    if (this.isHierarchicalFacet(facet)) {
      return this.toggleHierarchicalFacetRefinement(facet, value);
    } else if (this.isConjunctiveFacet(facet)) {
      return this.toggleConjunctiveFacetRefinement(facet, value);
    } else if (this.isDisjunctiveFacet(facet)) {
      return this.toggleDisjunctiveFacetRefinement(facet, value);
    }

    throw new Error('Cannot refine the undeclared facet ' + facet +
      '; it should be added to the helper options facets, disjunctiveFacets or hierarchicalFacets');
  }

Generic toggle refinement method to use with facet, disjunctive facets
and hierarchical facets
@param  {string} facet the facet to refine
@param  {string} value the associated value
@return {SearchParameters}
@throws will throw an error if the facet is not declared in the settings of the helper

Generic toggle refinement method to use with facet disjunctive facets and hierarchical facets


function(facet, path) {
    if (this.isHierarchicalFacetRefined(facet)) {
      throw new Error(facet + ' is already refined.');
    }
    var mod = {};
    mod[facet] = [path];
    return this.setQueryParameters({
      hierarchicalFacetsRefinements: defaults({}, mod, this.hierarchicalFacetsRefinements)
    });
  }

function
(
facet
,
path
)
{
if
(
this
.
isHierarchicalFacetRefined
(
facet
)
)
{
throw
new
Error
(
facet
+
' is already refined.'
)
;
}
var
mod
=
{
}
;
mod
[
facet
]
=
[
path
]
;
return
this
.
setQueryParameters
(
{
hierarchicalFacetsRefinements
:
defaults
(
{
}
,
mod
,
this
.
hierarchicalFacetsRefinements
)
}
)
;
}

Adds a refinement on a hierarchical facet.
@param {string} facet the facet name
@param {string} path the hierarchical facet path
@return {SearchParameter} the new state
@throws Error if the facet is not defined or if the facet is refined

Adds a refinement on a hierarchical facet .


function isFacetRefined(facet, value) {
    if (!this.isConjunctiveFacet(facet)) {
      throw new Error(facet + ' is not defined in the facets attribute of the helper configuration');
    }
    return RefinementList.isRefined(this.facetsRefinements, facet, value);
  }

Returns true if the facet is refined, either for a specific value or in
general.
@method
@param {string} facet name of the attribute for used for faceting
@param {string} value, optional value. If passed will test that this value
is filtering the given facet.
@return {boolean} returns true if refined

Returns true if the facet is refined either for a specific value or in general .


function isExcludeRefined(facet, value) {
    if (!this.isConjunctiveFacet(facet)) {
      throw new Error(facet + ' is not defined in the facets attribute of the helper configuration');
    }
    return RefinementList.isRefined(this.facetsExcludes, facet, value);
  }

Returns true if the facet contains exclusions or if a specific value is
excluded.

@method
@param {string} facet name of the attribute for used for faceting
@param {string} [value] optional value. If passed will test that this value
is filtering the given facet.
@return {boolean} returns true if refined

Returns true if the facet contains exclusions or if a specific value is excluded .


function getRefinedDisjunctiveFacets() {
    // attributes used for numeric filter can also be disjunctive
    var disjunctiveNumericRefinedFacets = intersection(
      keys(this.numericRefinements),
      this.disjunctiveFacets
    );

    return keys(this.disjunctiveFacetsRefinements)
      .concat(disjunctiveNumericRefinedFacets)
      .concat(this.getRefinedHierarchicalFacets());
  }

function getRefinedDisjunctiveFacets ( ) { var disjunctiveNumericRefinedFacets = intersection ( keys ( this . numericRefinements ) , this . disjunctiveFacets ) ; return keys ( this . disjunctiveFacetsRefinements ) . concat ( disjunctiveNumericRefinedFacets ) . concat ( this . getRefinedHierarchicalFacets ( ) ) ; }

Returns the list of all disjunctive facets refined
@method
@param {string} facet name of the attribute used for faceting
@param {value} value value used for filtering
@return {string[]}


function setParameter(parameter, value) {
    if (this[parameter] === value) return this;

    var modification = {};

    modification[parameter] = value;

    return this.setQueryParameters(modification);
  }

function setParameter ( parameter , value ) { if ( this [ parameter ] === value ) return this ; var modification = { } ; modification [ parameter ] = value ; return this . setQueryParameters ( modification ) ; }

Let the user set a specific value for a given parameter. Will return the
same instance if the parameter is invalid or if the value is the same as the
previous one.
@method
@param {string} parameter the parameter name
@param {any} value the value to be set, must be compliant with the definition
of the attribute on the object
@return {SearchParameters} the updated state

Let the user set a specific value for a given parameter . Will return the same instance if the parameter is invalid or if the value is the same as the previous one .


function setQueryParameters(params) {
    if (!params) return this;

    var error = SearchParameters.validate(this, params);

    if (error) {
      throw error;
    }

    var parsedParams = SearchParameters._parseNumbers(params);

    return this.mutateMe(function mergeWith(newInstance) {
      var ks = keys(params);

      forEach(ks, function(k) {
        newInstance[k] = parsedParams[k];
      });

      return newInstance;
    });
  }

function setQueryParameters ( params ) { if ( ! params ) return this ; var error = SearchParameters . validate ( this , params ) ; if ( error ) { throw error ; } var parsedParams = SearchParameters . _parseNumbers ( params ) ; return this . mutateMe ( function mergeWith ( newInstance ) { var ks = keys ( params ) ; forEach ( ks , function ( k ) { newInstance [ k ] = parsedParams [ k ] ; } ) ; return newInstance ; } ) ; }

Let the user set any of the parameters with a plain object.
@method
@param {object} params all the keys and the values to be updated
@return {SearchParameters} a new updated instance

Let the user set any of the parameters with a plain object .


function(facetName) {
    if (!this.isHierarchicalFacet(facetName)) {
      throw new Error(
        'Cannot get the breadcrumb of an unknown hierarchical facet: `' + facetName + '`');
    }

    var refinement = this.getHierarchicalRefinement(facetName)[0];
    if (!refinement) return [];

    var separator = this._getHierarchicalFacetSeparator(
      this.getHierarchicalFacetByName(facetName)
    );
    var path = refinement.split(separator);
    return map(path, trim);
  }

Get the current breadcrumb for a hierarchical facet, as an array
@param  {string} facetName Hierarchical facet name
@return {array.<string>} the path as an array of string

Get the current breadcrumb for a hierarchical facet as an array


function runCommand(cmd, args) {
  var prev = null;
  console.log(chalk.cyanBright(cmd) + " " + args.map(arg => {
    if (arg.startsWith("-"))
      return chalk.gray("\\") + "\n " + chalk.bold(arg);
    return arg;
  }).join(" ") + "\n");
  var proc = child_process.spawnSync(cmd, args, { stdio: "inherit" });
  if (proc.error)
    throw proc.error;
  if (proc.status !== 0)
    throw Error("exited with " + proc.status);
  return proc;
}

function
runCommand
(
cmd
,
args
)
{
var
prev
=
;
console
.
log
(
chalk
.
cyanBright
(
cmd
)
+
" "
+
args
.
map
(
arg
=>
{
if
(
arg
.
startsWith
(
"-"
)
)
return
chalk
.
gray
(
"\\"
)
+
\\
+
"\n "
;
\n
}
)
.
chalk
.
bold
(
arg
)
return
arg
;
+
join
)
;
(
" "
)
"\n"
\n
var
proc
=
child_process
.
spawnSync
(
cmd
,
args
,
{
stdio
:
"inherit"
}
)
;
}

Runs a command using the specified arguments.

Runs a command using the specified arguments .


function compileIntrinsics() {
  var target = path.join(sourceDirectory, "passes", "WasmIntrinsics.cpp");
  runCommand("python", [
    path.join(binaryenDirectory, "scripts", "embedwast.py"),
    path.join(sourceDirectory, "passes", "wasm-intrinsics.wast"),
    target
  ]);
  sourceFiles.push(target);
}

function compileIntrinsics ( ) { var target = path . join ( sourceDirectory , "passes" , "WasmIntrinsics.cpp" ) ; runCommand ( "python" , [ path . join ( binaryenDirectory , "scripts" , "embedwast.py" ) , path . join ( sourceDirectory , "passes" , "wasm-intrinsics.wast" ) , target ] ) ; sourceFiles . push ( target ) ; }

Compiles embedded intrinsics used by the targets below.

Compiles embedded intrinsics used by the targets below .


function compileShared() {
  runCommand("python", [
    path.join(emscriptenDirectory, "em++")
  ].concat(sourceFiles).concat(commonOptions).concat([
    "-o", "shared.bc"
  ]));
}

function compileShared ( ) { runCommand ( "python" , [ path . join ( emscriptenDirectory , "em++" ) ] . concat ( sourceFiles ) . concat ( commonOptions ) . concat ( [ "-o" , "shared.bc" ] ) ) ; }

Compiles shared bitcode used to build the targets below.

Compiles shared bitcode used to build the targets below .


function compileJs(options) {
  runCommand("python", [
    path.join(emscriptenDirectory, "em++"),
    "shared.bc"
  ].concat(commonOptions).concat([
    "--post-js", options.post,
    "--closure", "1",
    "-s", "WASM=0",
    "-s", "EXPORTED_FUNCTIONS=[" + exportedFunctionsArg + "]",
    "-s", "ALLOW_MEMORY_GROWTH=1",
    "-s", "ELIMINATE_DUPLICATE_FUNCTIONS=1",
    "-s", "MODULARIZE_INSTANCE=1",
    "-s", "EXPORT_NAME=\"Binaryen\"",
    "-o", options.out,
    "-Oz"
  ]));
}

function compileJs ( options ) { runCommand ( "python" , [ path . join ( emscriptenDirectory , "em++" ) , "shared.bc" ] . concat ( commonOptions ) . concat ( [ "--post-js" , options . post , "--closure" , "1" , "-s" , "WASM=0" , "-s" , "EXPORTED_FUNCTIONS=[" + exportedFunctionsArg + "]" , "-s" , "ALLOW_MEMORY_GROWTH=1" , "-s" , "ELIMINATE_DUPLICATE_FUNCTIONS=1" , "-s" , "MODULARIZE_INSTANCE=1" , "-s" , "EXPORT_NAME=\"Binaryen\"" , \" , \" , "-o" ] ) ) ; }


function compileWasm(options) {
  run("python", [
    path.join(emscriptenDirectory, "em++"),
    "shared.bc"
  ].concat(commonOptions).concat([
    "--post-js", options.post,
    "--closure", "1",
    "-s", "EXPORTED_FUNCTIONS=[" + exportedFunctionsArg + "]",
    "-s", "ALLOW_MEMORY_GROWTH=1",
    "-s", "BINARYEN=1",
    "-s", "BINARYEN_METHOD=\"native-wasm\"",
    "-s", "MODULARIZE_INSTANCE=1",
    "-s", "EXPORT_NAME=\"Binaryen\"",
    "-o", options.out,
    "-Oz"
  ]));
}

function compileWasm ( options ) { run ( "python" , [ path . join ( emscriptenDirectory , "em++" ) , "shared.bc" ] . concat ( commonOptions ) . concat ( [ "--post-js" , options . post , "--closure" , "1" , "-s" , "EXPORTED_FUNCTIONS=[" + exportedFunctionsArg + "]" , "-s" , "ALLOW_MEMORY_GROWTH=1" , "-s" , "BINARYEN=1" , "-s" , "BINARYEN_METHOD=\"native-wasm\"" , \" , \" , "-s" , "MODULARIZE_INSTANCE=1" , "-s" , "EXPORT_NAME=\"Binaryen\"" , \" ] ) ) ; }


function pluginState () {
    return {
        _sync: {
            signedIn: false,
            userId: null,
            unsubscribe: {},
            pathVariables: {},
            patching: false,
            syncStack: {
                inserts: [],
                updates: {},
                propDeletions: {},
                deletions: [],
                debounceTimer: null,
            },
            fetched: {},
            stopPatchingTimeout: null
        }
    };
}

function pluginState ( ) { return { _sync : { signedIn : false , userId : null , unsubscribe : { } , pathVariables : { } , patching : false , syncStack : { inserts : [ ] , updates : { } , propDeletions : { } , deletions : [ ] , debounceTimer : null , } , fetched : { } , stopPatchingTimeout : null } } ; }

a function returning the state object

@export
@returns {IState} the state object


function helpers(originVal, newVal) {
                    if (isArray(originVal) && isArrayHelper(newVal)) {
                        newVal = newVal.executeOn(originVal);
                    }
                    if (isNumber(originVal) && isIncrementHelper(newVal)) {
                        newVal = newVal.executeOn(originVal);
                    }
                    return newVal; // always return newVal as fallback!!
                }

function helpers ( originVal , newVal ) { if ( isArray ( originVal ) && isArrayHelper ( newVal ) ) { newVal = newVal . executeOn ( originVal ) ; } if ( isNumber ( originVal ) && isIncrementHelper ( newVal ) ) { newVal = newVal . executeOn ( originVal ) ; } return newVal ; }


function makeBatchFromSyncstack(state, getters, Firebase, batchMaxCount) {
    if (batchMaxCount === void 0) { batchMaxCount = 500; }
    // get state & getter variables
    var firestorePath = state._conf.firestorePath;
    var firestorePathComplete = getters.firestorePathComplete;
    var dbRef = getters.dbRef;
    var collectionMode = getters.collectionMode;
    // make batch
    var batch = Firebase.firestore().batch();
    var log = {};
    var count = 0;
    // Add 'updates' to batch
    var updates = grabUntilApiLimit('updates', count, batchMaxCount, state);
    log['updates: '] = updates;
    count = count + updates.length;
    // Add to batch
    updates.forEach(function (item) {
        var id = item.id;
        var docRef = (collectionMode) ? dbRef.doc(id) : dbRef;
        if (state._conf.sync.guard.includes('id'))
            delete item.id;
        // @ts-ignore
        batch.update(docRef, item);
    });
    // Add 'propDeletions' to batch
    var propDeletions = grabUntilApiLimit('propDeletions', count, batchMaxCount, state);
    log['prop deletions: '] = propDeletions;
    count = count + propDeletions.length;
    // Add to batch
    propDeletions.forEach(function (item) {
        var id = item.id;
        var docRef = (collectionMode) ? dbRef.doc(id) : dbRef;
        if (state._conf.sync.guard.includes('id'))
            delete item.id;
        // @ts-ignore
        batch.update(docRef, item);
    });
    // Add 'deletions' to batch
    var deletions = grabUntilApiLimit('deletions', count, batchMaxCount, state);
    log['deletions: '] = deletions;
    count = count + deletions.length;
    // Add to batch
    deletions.forEach(function (id) {
        var docRef = dbRef.doc(id);
        batch.delete(docRef);
    });
    // Add 'inserts' to batch
    var inserts = grabUntilApiLimit('inserts', count, batchMaxCount, state);
    log['inserts: '] = inserts;
    count = count + inserts.length;
    // Add to batch
    inserts.forEach(function (item) {
        var newRef = dbRef.doc(item.id);
        batch.set(newRef, item);
    });
    // log the batch contents
    if (state._conf.logging) {
        console.group('[vuex-easy-firestore] api call batch:');
        console.log("%cFirestore PATH: " + firestorePathComplete + " [" + firestorePath + "]", 'color: grey');
        Object.keys(log).forEach(function (key) {
            console.log(key, log[key]);
        });
        console.groupEnd();
    }
    return batch;
}

function
makeBatchFromSyncstack
(
state
,
getters
,
Firebase
,
batchMaxCount
)
{
if
(
batchMaxCount
===
void
0
)
{
batchMaxCount
=
500
;
}
var
firestorePath
=
state
.
_conf
.
firestorePath
;
var
firestorePathComplete
=
getters
.
firestorePathComplete
;
var
dbRef
=
getters
.
dbRef
;
var
collectionMode
=
getters
.
collectionMode
;
var
batch
=
Firebase
.
firestore
(
)
.
batch
(
)
;
var
log
=
{
}
;
var
count
=
0
;
var
updates
=
grabUntilApiLimit
(
'updates'
,
count
,
batchMaxCount
,
state
)
;
log
[
'updates: '
]
=
updates
;
count
=
count
+
updates
.
length
;
updates
.
forEach
(
function
(
item
)
{
var
id
=
item
.
id
;
var
docRef
=
(
collectionMode
)
dbRef
.
doc
(
id
)
:
dbRef
;
if
(
state
.
_conf
.
sync
.
guard
.
includes
(
'id'
)
)
delete
item
.
id
;
batch
.
update
(
docRef
,
item
)
;
}
)
;
var
propDeletions
=
grabUntilApiLimit
(
'propDeletions'
,
count
,
batchMaxCount
,
state
)
;
log
[
'prop deletions: '
]
=
propDeletions
;
count
=
count
+
propDeletions
.
length
;
propDeletions
.
forEach
(
function
(
item
)
{
var
id
=
item
.
id
;
var
docRef
=
(
collectionMode
)
dbRef
.
doc
(
id
)
:
dbRef
;
if
(
state
.
_conf
.
sync
.
guard
.
includes
(
'id'
)
)
delete
item
.
id
;
batch
.
update
(
docRef
,
item
)
;
}
)
;
var
deletions
=
grabUntilApiLimit
(
'deletions'
,
count
,
batchMaxCount
,
state
)
;
log
[
'deletions: '
]
=
deletions
;
count
=
count
+
deletions
.
length
;
deletions
.
forEach
(
function
(
id
)
{
var
docRef
=
dbRef
.
doc
(
id
)
;
batch
.
delete
(
docRef
)
;
}
)
;
var
inserts
=
grabUntilApiLimit
(
'inserts'
,
count
,
batchMaxCount
,
state
)
;
log
[
'inserts: '
]
=
inserts
;
count
=
count
+
inserts
.
length
;
inserts
.
forEach
(
function
(
item
)
{
var
newRef
=
dbRef
.
doc
(
item
.
id
)
;
batch
.
set
(
newRef
,
item
)
;
}
)
;
if
(
state
.
_conf
.
logging
)
{
console
.
group
(
'[vuex-easy-firestore] api call batch:'
)
;
console
.
log
(
"%cFirestore PATH: "
+
firestorePathComplete
+
" ["
+
firestorePath
+
"]"
,
'color: grey'
)
;
Object
.
keys
(
log
)
.
forEach
(
function
(
key
)
{
console
.
log
(
key
,
log
[
key
]
)
;
}
)
;
console
.
groupEnd
(
)
;
}
return
batch
;
}

Create a Firebase batch from a syncStack to be passed inside the state param.

@export
@param {IPluginState} state The state which should have `_sync.syncStack`, `_sync.userId`, `state._conf.firestorePath`
@param {AnyObject} getters The getters which should have `dbRef`, `storeRef`, `collectionMode` and `firestorePathComplete`
@param {any} Firebase dependency injection for Firebase & Firestore
@param {number} [batchMaxCount=500] The max count of the batch. Defaults to 500 as per Firestore documentation.
@returns {*} A Firebase firestore batch object.

Create a Firebase batch from a syncStack to be passed inside the state param .


function iniModule (userConfig, FirebaseDependency) {
    // prepare state._conf
    var conf = copy(merge({ state: {}, mutations: {}, actions: {}, getters: {} }, defaultConfig, userConfig));
    if (!errorCheck(conf))
        return;
    var userState = conf.state;
    var userMutations = conf.mutations;
    var userActions = conf.actions;
    var userGetters = conf.getters;
    delete conf.state;
    delete conf.mutations;
    delete conf.actions;
    delete conf.getters;
    // prepare rest of state
    var docContainer = {};
    if (conf.statePropName)
        docContainer[conf.statePropName] = {};
    var restOfState = merge(userState, docContainer);
    // if 'doc' mode, set merge initial state onto default values
    if (conf.firestoreRefType === 'doc') {
        var defaultValsInState = (conf.statePropName)
            ? restOfState[conf.statePropName]
            : restOfState;
        conf.sync.defaultValues = copy(merge(defaultValsInState, conf.sync.defaultValues));
    }
    return {
        namespaced: true,
        state: merge(pluginState(), restOfState, { _conf: conf }),
        mutations: merge(userMutations, pluginMutations(merge(userState, { _conf: conf }))),
        actions: merge(userActions, pluginActions(FirebaseDependency)),
        getters: merge(userGetters, pluginGetters(FirebaseDependency))
    };
}

function iniModule ( userConfig , FirebaseDependency ) { var conf = copy ( merge ( { state : { } , mutations : { } , actions : { } , getters : { } } , defaultConfig , userConfig ) ) ; if ( ! errorCheck ( conf ) ) return ; var userState = conf . state ; var userMutations = conf . mutations ; var userActions = conf . actions ; var userGetters = conf . getters ; delete conf . state ; delete conf . mutations ; delete conf . actions ; delete conf . getters ; var docContainer = { } ; if ( conf . statePropName ) docContainer [ conf . statePropName ] = { } ; var restOfState = merge ( userState , docContainer ) ; if ( conf . firestoreRefType === 'doc' ) { var defaultValsInState = ( conf . statePropName ) ? restOfState [ conf . statePropName ] : restOfState ; conf . sync . defaultValues = copy ( merge ( defaultValsInState , conf . sync . defaultValues ) ) ; } return { namespaced : true , state : merge ( pluginState ( ) , restOfState , { _conf : conf } ) , mutations : merge ( userMutations , pluginMutations ( merge ( userState , { _conf : conf } ) ) ) , actions : merge ( userActions , pluginActions ( FirebaseDependency ) ) , getters : merge ( userGetters , pluginGetters ( FirebaseDependency ) ) } ; }

A function that returns a vuex module object with seamless 2-way sync for firestore.

@param {IEasyFirestoreModule} userConfig Takes a config object per module
@param {*} FirebaseDependency The Firebase dependency (non-instanciated), defaults to the Firebase peer dependency if left blank.
@returns {IStore} the module ready to be included in your vuex store

A function that returns a vuex module object with seamless 2 - way sync for firestore .


function setDefaultValues (obj, defaultValues) {
    if (!isWhat.isPlainObject(defaultValues))
        console.error('[vuex-easy-firestore] Trying to merge target:', obj, 'onto a non-object (defaultValues):', defaultValues);
    if (!isWhat.isPlainObject(obj))
        console.error('[vuex-easy-firestore] Trying to merge a non-object:', obj, 'onto the defaultValues:', defaultValues);
    var result = merge({ extensions: [convertTimestamps] }, defaultValues, obj);
    return findAndReplaceAnything.findAndReplace(result, '%convertTimestamp%', null, { onlyPlainObjects: true });
}

Merge an object onto defaultValues

@export
@param {object} obj
@param {object} defaultValues
@returns {AnyObject} the new object


function getId(payloadPiece, conf, path, fullPayload) {
    if (isWhat.isString(payloadPiece))
        return payloadPiece;
    if (isWhat.isPlainObject(payloadPiece)) {
        if ('id' in payloadPiece)
            return payloadPiece.id;
        var keys = Object.keys(payloadPiece);
        if (keys.length === 1)
            return keys[0];
    }
    return '';
}

function getId ( payloadPiece , conf , path , fullPayload ) { if ( isWhat . isString ( payloadPiece ) ) return payloadPiece ; if ( isWhat . isPlainObject ( payloadPiece ) ) { if ( 'id' in payloadPiece ) return payloadPiece . id ; var keys = Object . keys ( payloadPiece ) ; if ( keys . length === 1 ) return keys [ 0 ] ; } return '' ; }

gets an ID from a single piece of payload.

@export
@param {(object | string)} payloadPiece
@param {object} [conf] (optional - for error handling) the vuex-easy-access config
@param {string} [path] (optional - for error handling) the path called
@param {(object | any[] | string)} [fullPayload] (optional - for error handling) the full payload on which each was `getId()` called
@returns {string} the id

gets an ID from a single piece of payload .


function vuexEasyFirestore(easyFirestoreModule, _a) {
    var _b = _a === void 0 ? {
        logging: false,
        preventInitialDocInsertion: false,
        FirebaseDependency: Firebase$2
    } : _a, _c = _b.logging, logging = _c === void 0 ? false : _c, _d = _b.preventInitialDocInsertion, preventInitialDocInsertion = _d === void 0 ? false : _d, _e = _b.FirebaseDependency, FirebaseDependency = _e === void 0 ? Firebase$2 : _e;
    if (FirebaseDependency) {
        setFirebaseDependency(FirebaseDependency);
        setFirebaseDependency$1(FirebaseDependency);
    }
    return function (store) {
        // Get an array of config files
        if (!isWhat.isArray(easyFirestoreModule))
            easyFirestoreModule = [easyFirestoreModule];
        // Create a module for each config file
        easyFirestoreModule.forEach(function (config) {
            config.logging = logging;
            if (config.sync && config.sync.preventInitialDocInsertion === undefined) {
                config.sync.preventInitialDocInsertion = preventInitialDocInsertion;
            }
            var moduleName = vuexEasyAccess.getKeysFromPath(config.moduleName);
            store.registerModule(moduleName, iniModule(config, FirebaseDependency));
        });
    };
}

function vuexEasyFirestore ( easyFirestoreModule , _a ) { var _b = _a === void 0 ? { logging : false , preventInitialDocInsertion : false , FirebaseDependency : Firebase$2 } : _a , _c = _b . logging , logging = _c === void 0 ? false : _c , _d = _b . preventInitialDocInsertion , preventInitialDocInsertion = _d === void 0 ? false : _d , _e = _b . FirebaseDependency , FirebaseDependency = _e === void 0 ? Firebase$2 : _e ; if ( FirebaseDependency ) { setFirebaseDependency ( FirebaseDependency ) ; setFirebaseDependency$1 ( FirebaseDependency ) ; } return function ( store ) { if ( ! isWhat . isArray ( easyFirestoreModule ) ) easyFirestoreModule = [ easyFirestoreModule ] ; easyFirestoreModule . forEach ( function ( config ) { config . logging = logging ; if ( config . sync && config . sync . preventInitialDocInsertion === undefined ) { config . sync . preventInitialDocInsertion = preventInitialDocInsertion ; } var moduleName = vuexEasyAccess . getKeysFromPath ( config . moduleName ) ; store . registerModule ( moduleName , iniModule ( config , FirebaseDependency ) ) ; } ) ; } ; }

Firebase
Create vuex-easy-firestore modules. Add as single plugin to Vuex Store.

@export
@param {(IEasyFirestoreModule | IEasyFirestoreModule[])} easyFirestoreModule A vuex-easy-firestore module (or array of modules) with proper configuration as per the documentation.
@param {{logging?: boolean, FirebaseDependency?: any}} extraConfig An object with `logging` and `FirebaseDependency` props. `logging` enables console logs for debugging. `FirebaseDependency` is the non-instanciated Firebase class you can pass. (defaults to the Firebase peer dependency)
@returns {*}

Firebase Create vuex - easy - firestore modules . Add as single plugin to Vuex Store .


function parseCSV(csvFilePath, attributeFields) {
  return new Promise((resolve, reject) => {
    try {
      csv(csvFilePath, data => resolve(_transformToHierarchy(data, attributeFields))); // lol hello Lisp
    } catch (err) {
      reject(err);
    }
  });
}

function parseCSV ( csvFilePath , attributeFields ) { return new Promise ( ( resolve , reject ) => { try { csv ( csvFilePath , data => resolve ( _transformToHierarchy ( data , attributeFields ) ) ) ; } catch ( err ) { reject ( err ) ; } } ) ; }

parseCSV - Parses a CSV file into a hierarchy structure.

@param {string} csvFilePath     Path to CSV file to be parsed.
@param {array<string>|undefined} attributeFields Set of column names to be used as attributes (optional)

@return {Promise} Returns hierarchy array if resolved, error object if rejected.

parseCSV - Parses a CSV file into a hierarchy structure .


function parseJSON(jsonFilePath) {
  return new Promise((resolve, reject) => {
    try {
      json(jsonFilePath, data => resolve([data]));
    } catch (err) {
      reject(err);
    }
  });
}

function parseJSON ( jsonFilePath ) { return new Promise ( ( resolve , reject ) => { try { json ( jsonFilePath , data => resolve ( [ data ] ) ) ; } catch ( err ) { reject ( err ) ; } } ) ; }

parseJSON - Parses a hierarchical JSON file that requires no further transformation.

@param {string} jsonFilePath Path to JSON file to be parsed.

@return {Promise} Returns hierarchy array if resolved, error object if rejected.

parseJSON - Parses a hierarchical JSON file that requires no further transformation .


function parseFlatJSON(jsonFilePath, attributeFields) {
  return new Promise((resolve, reject) => {
    try {
      json(jsonFilePath, data => resolve(_transformToHierarchy(data, attributeFields)));
    } catch (err) {
      reject(err);
    }
  });
}

function parseFlatJSON ( jsonFilePath , attributeFields ) { return new Promise ( ( resolve , reject ) => { try { json ( jsonFilePath , data => resolve ( _transformToHierarchy ( data , attributeFields ) ) ) ; } catch ( err ) { reject ( err ) ; } } ) ; }

parseFlatJSON - Parses a flat JSON file into a hierarchy structure.

@param {string} jsonFilePath Path to flat JSON file to be parsed.
@param {array<string>|undefined} attributeFields Set of `link` fields to be used as attributes

@return {Promise} Returns hierarchy array if resolved, error object if rejected.

parseFlatJSON - Parses a flat JSON file into a hierarchy structure .


function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
  if (true) {
    for (var typeSpecName in typeSpecs) {
      if (typeSpecs.hasOwnProperty(typeSpecName)) {
        var error;
        // Prop type validation may throw. In case they do, we don't want to
        // fail the render phase where it didn't fail before. So we log it.
        // After these have been cleaned up, we'll let them throw.
        try {
          // This is intentionally an invariant that gets caught. It's the same
          // behavior as without this statement except with a better message.
          if (typeof typeSpecs[typeSpecName] !== 'function') {
            var err = Error(
              (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
              'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
            );
            err.name = 'Invariant Violation';
            throw err;
          }
          error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
        } catch (ex) {
          error = ex;
        }
        if (error && !(error instanceof Error)) {
          printWarning(
            (componentName || 'React class') + ': type specification of ' +
            location + ' `' + typeSpecName + '` is invalid; the type checker ' +
            'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
            'You may have forgotten to pass an argument to the type checker ' +
            'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
            'shape all require an argument).'
          )

        }
        if (error instanceof Error && !(error.message in loggedTypeFailures)) {
          // Only monitor this failure once because there tends to be a lot of the
          // same error.
          loggedTypeFailures[error.message] = true;

          var stack = getStack ? getStack() : '';

          printWarning(
            'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
          );
        }
      }
    }
  }
}

Assert that the values match with the type specs.
Error messages are memorized and will only be shown once.

@param {object} typeSpecs Map of name to a ReactPropType
@param {object} values Runtime values that need to be type-checked
@param {string} location e.g. "prop", "context", "child context"
@param {string} componentName Name of the component for error messages.
@param {?Function} getStack Returns the component stack.
@private

Assert that the values match with the type specs . Error messages are memorized and will only be shown once .


function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) {
  hasError = false;
  caughtError = null;
  invokeGuardedCallbackImpl$1.apply(reporter, arguments);
}

function invokeGuardedCallback ( name , func , context , a , b , c , d , e , f ) { hasError = false ; caughtError = null ; invokeGuardedCallbackImpl$1 . apply ( reporter , arguments ) ; }

Call a function while guarding against errors that happens within it.
Returns an error if it throws, otherwise null.

In production, this is implemented using a try-catch. The reason we don't
use a try-catch directly is so that we can swap out a different
implementation in DEV mode.

@param {String} name of the guard to use for logging or debugging
@param {Function} func The function to invoke
@param {*} context The context to use when calling the function
@param {...*} args Arguments for function

Call a function while guarding against errors that happens within it . Returns an error if it throws otherwise null .


function getClosestInstanceFromNode(node) {
  if (node[internalInstanceKey]) {
    return node[internalInstanceKey];
  }

  while (!node[internalInstanceKey]) {
    if (node.parentNode) {
      node = node.parentNode;
    } else {
      // Top of the tree. This node must not be part of a React tree (or is
      // unmounted, potentially).
      return null;
    }
  }

  var inst = node[internalInstanceKey];
  if (inst.tag === HostComponent || inst.tag === HostText) {
    // In Fiber, this will always be the deepest root.
    return inst;
  }

  return null;
}

function getClosestInstanceFromNode ( node ) { if ( node [ internalInstanceKey ] ) { return node [ internalInstanceKey ] ; } while ( ! node [ internalInstanceKey ] ) { if ( node . parentNode ) { node = node . parentNode ; } else { return null ; } } var inst = node [ internalInstanceKey ] ; if ( inst . tag === HostComponent || inst . tag === HostText ) { return inst ; } return null ; }

Given a DOM node, return the closest ReactDOMComponent or
ReactDOMTextComponent instance ancestor.

Given a DOM node return the closest ReactDOMComponent or ReactDOMTextComponent instance ancestor .


function getInstanceFromNode$1(node) {
  var inst = node[internalInstanceKey];
  if (inst) {
    if (inst.tag === HostComponent || inst.tag === HostText) {
      return inst;
    } else {
      return null;
    }
  }
  return null;
}

function getInstanceFromNode$1 ( node ) { var inst = node [ internalInstanceKey ] ; if ( inst ) { if ( inst . tag === HostComponent || inst . tag === HostText ) { return inst ; } else { return null ; } } return null ; }

Given a DOM node, return the ReactDOMComponent or ReactDOMTextComponent
instance, or null if the node was not rendered by this React.

Given a DOM node return the ReactDOMComponent or ReactDOMTextComponent instance or null if the node was not rendered by this React .


function getNodeFromInstance$1(inst) {
  if (inst.tag === HostComponent || inst.tag === HostText) {
    // In Fiber this, is just the state node right now. We assume it will be
    // a host component or host text.
    return inst.stateNode;
  }

  // Without this first invariant, passing a non-DOM-component triggers the next
  // invariant for a missing parent, which is super confusing.
  invariant(false, 'getNodeFromInstance: Invalid argument.');
}

Given a ReactDOMComponent or ReactDOMTextComponent, return the corresponding
DOM node.

Given a ReactDOMComponent or ReactDOMTextComponent return the corresponding DOM node .


function traverseEnterLeave(from, to, fn, argFrom, argTo) {
  var common = from && to ? getLowestCommonAncestor(from, to) : null;
  var pathFrom = [];
  while (true) {
    if (!from) {
      break;
    }
    if (from === common) {
      break;
    }
    var alternate = from.alternate;
    if (alternate !== null && alternate === common) {
      break;
    }
    pathFrom.push(from);
    from = getParent(from);
  }
  var pathTo = [];
  while (true) {
    if (!to) {
      break;
    }
    if (to === common) {
      break;
    }
    var _alternate = to.alternate;
    if (_alternate !== null && _alternate === common) {
      break;
    }
    pathTo.push(to);
    to = getParent(to);
  }
  for (var i = 0; i < pathFrom.length; i++) {
    fn(pathFrom[i], 'bubbled', argFrom);
  }
  for (var _i = pathTo.length; _i-- > 0;) {
    fn(pathTo[_i], 'captured', argTo);
  }
}

function traverseEnterLeave ( from , to , fn , argFrom , argTo ) { var common = from && to ? getLowestCommonAncestor ( from , to ) : null ; var pathFrom = [ ] ; while ( true ) { if ( ! from ) { break ; } if ( from === common ) { break ; } var alternate = from . alternate ; if ( alternate !== null && alternate === common ) { break ; } pathFrom . push ( from ) ; from = getParent ( from ) ; } var pathTo = [ ] ; while ( true ) { if ( ! to ) { break ; } if ( to === common ) { break ; } var _alternate = to . alternate ; if ( _alternate !== null && _alternate === common ) { break ; } pathTo . push ( to ) ; to = getParent ( to ) ; } for ( var i = 0 ; i < pathFrom . length ; i ++ ) { fn ( pathFrom [ i ] , 'bubbled' , argFrom ) ; } for ( var _i = pathTo . length ; _i -- > 0 ; ) { fn ( pathTo [ _i ] , 'captured' , argTo ) ; } }

Traverses the ID hierarchy and invokes the supplied `cb` on any IDs that
should would receive a `mouseEnter` or `mouseLeave` event.

Does not invoke the callback on the nearest common ancestor because nothing
"entered" or "left" that element.

Traverses the ID hierarchy and invokes the supplied cb on any IDs that should would receive a mouseEnter or mouseLeave event .


function makePrefixMap(styleProp, eventName) {
  var prefixes = {};

  prefixes[styleProp.toLowerCase()] = eventName.toLowerCase();
  prefixes['Webkit' + styleProp] = 'webkit' + eventName;
  prefixes['Moz' + styleProp] = 'moz' + eventName;

  return prefixes;
}

function makePrefixMap ( styleProp , eventName ) { var prefixes = { } ; prefixes [ styleProp . toLowerCase ( ) ] = eventName . toLowerCase ( ) ; prefixes [ 'Webkit' + styleProp ] = 'webkit' + eventName ; prefixes [ 'Moz' + styleProp ] = 'moz' + eventName ; return prefixes ; }

Generate a mapping of standard vendor prefixes using the defined style property and event name.

@param {string} styleProp
@param {string} eventName
@returns {object}

Generate a mapping of standard vendor prefixes using the defined style property and event name .


function () {
    var Interface = this.constructor.Interface;
    for (var propName in Interface) {
      {
        Object.defineProperty(this, propName, getPooledWarningPropertyDefinition(propName, Interface[propName]));
      }
    }
    this.dispatchConfig = null;
    this._targetInst = null;
    this.nativeEvent = null;
    this.isDefaultPrevented = functionThatReturnsFalse;
    this.isPropagationStopped = functionThatReturnsFalse;
    this._dispatchListeners = null;
    this._dispatchInstances = null;
    {
      Object.defineProperty(this, 'nativeEvent', getPooledWarningPropertyDefinition('nativeEvent', null));
      Object.defineProperty(this, 'isDefaultPrevented', getPooledWarningPropertyDefinition('isDefaultPrevented', functionThatReturnsFalse));
      Object.defineProperty(this, 'isPropagationStopped', getPooledWarningPropertyDefinition('isPropagationStopped', functionThatReturnsFalse));
      Object.defineProperty(this, 'preventDefault', getPooledWarningPropertyDefinition('preventDefault', function () {}));
      Object.defineProperty(this, 'stopPropagation', getPooledWarningPropertyDefinition('stopPropagation', function () {}));
    }
  }

function ( ) { var Interface = this . constructor . Interface ; for ( var propName in Interface ) { { Object . defineProperty ( this , propName , getPooledWarningPropertyDefinition ( propName , Interface [ propName ] ) ) ; } } this . dispatchConfig = null ; this . _targetInst = null ; this . nativeEvent = null ; this . isDefaultPrevented = functionThatReturnsFalse ; this . isPropagationStopped = functionThatReturnsFalse ; this . _dispatchListeners = null ; this . _dispatchInstances = null ; { Object . defineProperty ( this , 'nativeEvent' , getPooledWarningPropertyDefinition ( 'nativeEvent' , null ) ) ; Object . defineProperty ( this , 'isDefaultPrevented' , getPooledWarningPropertyDefinition ( 'isDefaultPrevented' , functionThatReturnsFalse ) ) ; Object . defineProperty ( this , 'isPropagationStopped' , getPooledWarningPropertyDefinition ( 'isPropagationStopped' , functionThatReturnsFalse ) ) ; Object . defineProperty ( this , 'preventDefault' , getPooledWarningPropertyDefinition ( 'preventDefault' , function ( ) { } ) ) ; Object . defineProperty ( this , 'stopPropagation' , getPooledWarningPropertyDefinition ( 'stopPropagation' , function ( ) { } ) ) ; } }

`PooledClass` looks for `destructor` on each instance it releases.

PooledClass looks for destructor on each instance it releases .


function getCompositionEventType(topLevelType) {
  switch (topLevelType) {
    case TOP_COMPOSITION_START:
      return eventTypes.compositionStart;
    case TOP_COMPOSITION_END:
      return eventTypes.compositionEnd;
    case TOP_COMPOSITION_UPDATE:
      return eventTypes.compositionUpdate;
  }
}

function getCompositionEventType ( topLevelType ) { switch ( topLevelType ) { case TOP_COMPOSITION_START : return eventTypes . compositionStart ; case TOP_COMPOSITION_END : return eventTypes . compositionEnd ; case TOP_COMPOSITION_UPDATE : return eventTypes . compositionUpdate ; } }

Translate native top level events into event types.

@param {string} topLevelType
@return {object}

Translate native top level events into event types .


function isFallbackCompositionEnd(topLevelType, nativeEvent) {
  switch (topLevelType) {
    case TOP_KEY_UP:
      // Command keys insert or clear IME input.
      return END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1;
    case TOP_KEY_DOWN:
      // Expect IME keyCode on each keydown. If we get any other
      // code we must have exited earlier.
      return nativeEvent.keyCode !== START_KEYCODE;
    case TOP_KEY_PRESS:
    case TOP_MOUSE_DOWN:
    case TOP_BLUR:
      // Events are not possible without cancelling IME.
      return true;
    default:
      return false;
  }
}

function isFallbackCompositionEnd ( topLevelType , nativeEvent ) { switch ( topLevelType ) { case TOP_KEY_UP : return END_KEYCODES . indexOf ( nativeEvent . keyCode ) !== - 1 ; case TOP_KEY_DOWN : return nativeEvent . keyCode !== START_KEYCODE ; case TOP_KEY_PRESS : case TOP_MOUSE_DOWN : case TOP_BLUR : return true ; default : return false ; } }

Does our fallback mode think that this event is the end of composition?

@param {string} topLevelType
@param {object} nativeEvent
@return {boolean}


function getValueForProperty(node, name, expected, propertyInfo) {
  {
    if (propertyInfo.mustUseProperty) {
      var propertyName = propertyInfo.propertyName;

      return node[propertyName];
    } else {
      var attributeName = propertyInfo.attributeName;

      var stringValue = null;

      if (propertyInfo.type === OVERLOADED_BOOLEAN) {
        if (node.hasAttribute(attributeName)) {
          var value = node.getAttribute(attributeName);
          if (value === '') {
            return true;
          }
          if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
            return value;
          }
          if (value === '' + expected) {
            return expected;
          }
          return value;
        }
      } else if (node.hasAttribute(attributeName)) {
        if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
          // We had an attribute but shouldn't have had one, so read it
          // for the error message.
          return node.getAttribute(attributeName);
        }
        if (propertyInfo.type === BOOLEAN) {
          // If this was a boolean, it doesn't matter what the value is
          // the fact that we have it is the same as the expected.
          return expected;
        }
        // Even if this property uses a namespace we use getAttribute
        // because we assume its namespaced name is the same as our config.
        // To use getAttributeNS we need the local name which we don't have
        // in our config atm.
        stringValue = node.getAttribute(attributeName);
      }

      if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
        return stringValue === null ? expected : stringValue;
      } else if (stringValue === '' + expected) {
        return expected;
      } else {
        return stringValue;
      }
    }
  }
}

function getValueForProperty ( node , name , expected , propertyInfo ) { { if ( propertyInfo . mustUseProperty ) { var propertyName = propertyInfo . propertyName ; return node [ propertyName ] ; } else { var attributeName = propertyInfo . attributeName ; var stringValue = null ; if ( propertyInfo . type === OVERLOADED_BOOLEAN ) { if ( node . hasAttribute ( attributeName ) ) { var value = node . getAttribute ( attributeName ) ; if ( value === '' ) { return true ; } if ( shouldRemoveAttribute ( name , expected , propertyInfo , false ) ) { return value ; } if ( value === '' + expected ) { return expected ; } return value ; } } else if ( node . hasAttribute ( attributeName ) ) { if ( shouldRemoveAttribute ( name , expected , propertyInfo , false ) ) { return node . getAttribute ( attributeName ) ; } if ( propertyInfo . type === BOOLEAN ) { return expected ; } stringValue = node . getAttribute ( attributeName ) ; } if ( shouldRemoveAttribute ( name , expected , propertyInfo , false ) ) { return stringValue === null ? expected : stringValue ; } else if ( stringValue === '' + expected ) { return expected ; } else { return stringValue ; } } } }

Get the value for a property on a node. Only used in DEV for SSR validation.
The "expected" argument is used as a hint of what the expected value is.
Some properties have multiple equivalent values.

Get the value for a property on a node . Only used in DEV for SSR validation . The expected argument is used as a hint of what the expected value is . Some properties have multiple equivalent values .


function getTargetInstForInputEventPolyfill(topLevelType, targetInst) {
  if (topLevelType === TOP_SELECTION_CHANGE || topLevelType === TOP_KEY_UP || topLevelType === TOP_KEY_DOWN) {
    // On the selectionchange event, the target is just document which isn't
    // helpful for us so just check activeElement instead.
    //
    // 99% of the time, keydown and keyup aren't necessary. IE8 fails to fire
    // propertychange on the first input event after setting `value` from a
    // script and fires only keydown, keypress, keyup. Catching keyup usually
    // gets it and catching keydown lets us fire an event for the first
    // keystroke if user does a key repeat (it'll be a little delayed: right
    // before the second keystroke). Other input methods (e.g., paste) seem to
    // fire selectionchange normally.
    return getInstIfValueChanged(activeElementInst);
  }
}

function getTargetInstForInputEventPolyfill ( topLevelType , targetInst ) { if ( topLevelType === TOP_SELECTION_CHANGE || topLevelType === TOP_KEY_UP || topLevelType === TOP_KEY_DOWN ) { return getInstIfValueChanged ( activeElementInst ) ; } }


function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
    var isOverEvent = topLevelType === TOP_MOUSE_OVER || topLevelType === TOP_POINTER_OVER;
    var isOutEvent = topLevelType === TOP_MOUSE_OUT || topLevelType === TOP_POINTER_OUT;

    if (isOverEvent && (nativeEvent.relatedTarget || nativeEvent.fromElement)) {
      return null;
    }

    if (!isOutEvent && !isOverEvent) {
      // Must not be a mouse or pointer in or out - ignoring.
      return null;
    }

    var win = void 0;
    if (nativeEventTarget.window === nativeEventTarget) {
      // `nativeEventTarget` is probably a window object.
      win = nativeEventTarget;
    } else {
      // TODO: Figure out why `ownerDocument` is sometimes undefined in IE8.
      var doc = nativeEventTarget.ownerDocument;
      if (doc) {
        win = doc.defaultView || doc.parentWindow;
      } else {
        win = window;
      }
    }

    var from = void 0;
    var to = void 0;
    if (isOutEvent) {
      from = targetInst;
      var related = nativeEvent.relatedTarget || nativeEvent.toElement;
      to = related ? getClosestInstanceFromNode(related) : null;
    } else {
      // Moving to a node from outside the window.
      from = null;
      to = targetInst;
    }

    if (from === to) {
      // Nothing pertains to our managed components.
      return null;
    }

    var eventInterface = void 0,
        leaveEventType = void 0,
        enterEventType = void 0,
        eventTypePrefix = void 0;

    if (topLevelType === TOP_MOUSE_OUT || topLevelType === TOP_MOUSE_OVER) {
      eventInterface = SyntheticMouseEvent;
      leaveEventType = eventTypes$2.mouseLeave;
      enterEventType = eventTypes$2.mouseEnter;
      eventTypePrefix = 'mouse';
    } else if (topLevelType === TOP_POINTER_OUT || topLevelType === TOP_POINTER_OVER) {
      eventInterface = SyntheticPointerEvent;
      leaveEventType = eventTypes$2.pointerLeave;
      enterEventType = eventTypes$2.pointerEnter;
      eventTypePrefix = 'pointer';
    }

    var fromNode = from == null ? win : getNodeFromInstance$1(from);
    var toNode = to == null ? win : getNodeFromInstance$1(to);

    var leave = eventInterface.getPooled(leaveEventType, from, nativeEvent, nativeEventTarget);
    leave.type = eventTypePrefix + 'leave';
    leave.target = fromNode;
    leave.relatedTarget = toNode;

    var enter = eventInterface.getPooled(enterEventType, to, nativeEvent, nativeEventTarget);
    enter.type = eventTypePrefix + 'enter';
    enter.target = toNode;
    enter.relatedTarget = fromNode;

    accumulateEnterLeaveDispatches(leave, enter, from, to);

    return [leave, enter];
  }

function ( topLevelType , targetInst , nativeEvent , nativeEventTarget ) { var isOverEvent = topLevelType === TOP_MOUSE_OVER || topLevelType === TOP_POINTER_OVER ; var isOutEvent = topLevelType === TOP_MOUSE_OUT || topLevelType === TOP_POINTER_OUT ; if ( isOverEvent && ( nativeEvent . relatedTarget || nativeEvent . fromElement ) ) { return null ; } if ( ! isOutEvent && ! isOverEvent ) { return null ; } var win = void 0 ; if ( nativeEventTarget . window === nativeEventTarget ) { win = nativeEventTarget ; } else { var doc = nativeEventTarget . ownerDocument ; if ( doc ) { win = doc . defaultView || doc . parentWindow ; } else { win = window ; } } var from = void 0 ; var to = void 0 ; if ( isOutEvent ) { from = targetInst ; var related = nativeEvent . relatedTarget || nativeEvent . toElement ; to = related ? getClosestInstanceFromNode ( related ) : null ; } else { from = null ; to = targetInst ; } if ( from === to ) { return null ; } var eventInterface = void 0 , leaveEventType = void 0 , enterEventType = void 0 , eventTypePrefix = void 0 ; if ( topLevelType === TOP_MOUSE_OUT || topLevelType === TOP_MOUSE_OVER ) { eventInterface = SyntheticMouseEvent ; leaveEventType = eventTypes$2 . mouseLeave ; enterEventType = eventTypes$2 . mouseEnter ; eventTypePrefix = 'mouse' ; } else if ( topLevelType === TOP_POINTER_OUT || topLevelType === TOP_POINTER_OVER ) { eventInterface = SyntheticPointerEvent ; leaveEventType = eventTypes$2 . pointerLeave ; enterEventType = eventTypes$2 . pointerEnter ; eventTypePrefix = 'pointer' ; } var fromNode = from == null ? win : getNodeFromInstance$1 ( from ) ; var toNode = to == null ? win : getNodeFromInstance$1 ( to ) ; var leave = eventInterface . getPooled ( leaveEventType , from , nativeEvent , nativeEventTarget ) ; leave . type = eventTypePrefix + 'leave' ; leave . target = fromNode ; leave . relatedTarget = toNode ; var enter = eventInterface . getPooled ( enterEventType , to , nativeEvent , nativeEventTarget ) ; enter . type = eventTypePrefix + 'enter' ; enter . target = toNode ; enter . relatedTarget = fromNode ; accumulateEnterLeaveDispatches ( leave , enter , from , to ) ; return [ leave , enter ] ; }

For almost every interaction we care about, there will be both a top-level
`mouseover` and `mouseout` event that occurs. Only use `mouseout` so that
we do not extract duplicate events. However, moving the mouse into the
browser from outside will not fire a `mouseout` event. In this case, we use
the `mouseover` top-level event.

For almost every interaction we care about there will be both a top - level mouseover and mouseout event that occurs . Only use mouseout so that we do not extract duplicate events . However moving the mouse into the browser from outside will not fire a mouseout event . In this case we use the mouseover top - level event .


function listenTo(registrationName, mountAt) {
  var isListening = getListeningForDocument(mountAt);
  var dependencies = registrationNameDependencies[registrationName];

  for (var i = 0; i < dependencies.length; i++) {
    var dependency = dependencies[i];
    if (!(isListening.hasOwnProperty(dependency) && isListening[dependency])) {
      switch (dependency) {
        case TOP_SCROLL:
          trapCapturedEvent(TOP_SCROLL, mountAt);
          break;
        case TOP_FOCUS:
        case TOP_BLUR:
          trapCapturedEvent(TOP_FOCUS, mountAt);
          trapCapturedEvent(TOP_BLUR, mountAt);
          // We set the flag for a single dependency later in this function,
          // but this ensures we mark both as attached rather than just one.
          isListening[TOP_BLUR] = true;
          isListening[TOP_FOCUS] = true;
          break;
        case TOP_CANCEL:
        case TOP_CLOSE:
          if (isEventSupported(getRawEventName(dependency))) {
            trapCapturedEvent(dependency, mountAt);
          }
          break;
        case TOP_INVALID:
        case TOP_SUBMIT:
        case TOP_RESET:
          // We listen to them on the target DOM elements.
          // Some of them bubble so we don't want them to fire twice.
          break;
        default:
          // By default, listen on the top level to all non-media events.
          // Media events don't bubble so adding the listener wouldn't do anything.
          var isMediaEvent = mediaEventTypes.indexOf(dependency) !== -1;
          if (!isMediaEvent) {
            trapBubbledEvent(dependency, mountAt);
          }
          break;
      }
      isListening[dependency] = true;
    }
  }
}

function listenTo ( registrationName , mountAt ) { var isListening = getListeningForDocument ( mountAt ) ; var dependencies = registrationNameDependencies [ registrationName ] ; for ( var i = 0 ; i < dependencies . length ; i ++ ) { var dependency = dependencies [ i ] ; if ( ! ( isListening . hasOwnProperty ( dependency ) && isListening [ dependency ] ) ) { switch ( dependency ) { case TOP_SCROLL : trapCapturedEvent ( TOP_SCROLL , mountAt ) ; break ; case TOP_FOCUS : case TOP_BLUR : trapCapturedEvent ( TOP_FOCUS , mountAt ) ; trapCapturedEvent ( TOP_BLUR , mountAt ) ; isListening [ TOP_BLUR ] = true ; isListening [ TOP_FOCUS ] = true ; break ; case TOP_CANCEL : case TOP_CLOSE : if ( isEventSupported ( getRawEventName ( dependency ) ) ) { trapCapturedEvent ( dependency , mountAt ) ; } break ; case TOP_INVALID : case TOP_SUBMIT : case TOP_RESET : break ; default : var isMediaEvent = mediaEventTypes . indexOf ( dependency ) !== - 1 ; if ( ! isMediaEvent ) { trapBubbledEvent ( dependency , mountAt ) ; } break ; } isListening [ dependency ] = true ; } } }

We listen for bubbled touch events on the document object.

Firefox v8.01 (and possibly others) exhibited strange behavior when
mounting `onmousemove` events at some node that was not the document
element. The symptoms were that if your mouse is not moving over something
contained within that mount point (for example on the background) the
top-level listeners for `onmousemove` won't be called. However, if you
register the `mousemove` on the document object, then it will of course
catch all `mousemove`s. This along with iOS quirks, justifies restricting
top-level listeners to the document object only, at least for these
movement types of events and possibly all events.

@see http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html

Also, `keyup`/`keypress`/`keydown` do not bubble to the window on IE, but
they bubble to document.

@param {string} registrationName Name of listener (e.g. `onClick`).
@param {object} mountAt Container where to mount the listener

We listen for bubbled touch events on the document object .


function getEventTargetDocument(eventTarget) {
  return eventTarget.window === eventTarget ? eventTarget.document : eventTarget.nodeType === DOCUMENT_NODE ? eventTarget : eventTarget.ownerDocument;
}

function getEventTargetDocument ( eventTarget ) { return eventTarget . window === eventTarget ? eventTarget . document : eventTarget . nodeType === DOCUMENT_NODE ? eventTarget : eventTarget . ownerDocument ; }

Get document associated with the event target.

@param {object} nativeEventTarget
@return {Document}

Get document associated with the event target .


function constructSelectEvent(nativeEvent, nativeEventTarget) {
  // Ensure we have the right element, and that the user is not dragging a
  // selection (this matches native `select` event behavior). In HTML5, select
  // fires only on input and textarea thus if there's no focused element we
  // won't dispatch.
  var doc = getEventTargetDocument(nativeEventTarget);

  if (mouseDown || activeElement$1 == null || activeElement$1 !== getActiveElement(doc)) {
    return null;
  }

  // Only fire when selection has actually changed.
  var currentSelection = getSelection(activeElement$1);
  if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) {
    lastSelection = currentSelection;

    var syntheticEvent = SyntheticEvent.getPooled(eventTypes$3.select, activeElementInst$1, nativeEvent, nativeEventTarget);

    syntheticEvent.type = 'select';
    syntheticEvent.target = activeElement$1;

    accumulateTwoPhaseDispatches(syntheticEvent);

    return syntheticEvent;
  }

  return null;
}

function constructSelectEvent ( nativeEvent , nativeEventTarget ) { var doc = getEventTargetDocument ( nativeEventTarget ) ; if ( mouseDown || activeElement$1 == null || activeElement$1 !== getActiveElement ( doc ) ) { return null ; } var currentSelection = getSelection ( activeElement$1 ) ; if ( ! lastSelection || ! shallowEqual ( lastSelection , currentSelection ) ) { lastSelection = currentSelection ; var syntheticEvent = SyntheticEvent . getPooled ( eventTypes$3 . select , activeElementInst$1 , nativeEvent , nativeEventTarget ) ; syntheticEvent . type = 'select' ; syntheticEvent . target = activeElement$1 ; accumulateTwoPhaseDispatches ( syntheticEvent ) ; return syntheticEvent ; } return null ; }

Poll selection to see whether it's changed.

@param {object} nativeEvent
@param {object} nativeEventTarget
@return {?SyntheticEvent}

Poll selection to see whether it s changed .


function (node, text) {
  if (text) {
    var firstChild = node.firstChild;

    if (firstChild && firstChild === node.lastChild && firstChild.nodeType === TEXT_NODE) {
      firstChild.nodeValue = text;
      return;
    }
  }
  node.textContent = text;
}

function ( node , text ) { if ( text ) { var firstChild = node . firstChild ; if ( firstChild && firstChild === node . lastChild && firstChild . nodeType === TEXT_NODE ) { firstChild . nodeValue = text ; return ; } } node . textContent = text ; }

Set the textContent property of a node. For text updates, it's faster
to set the `nodeValue` of the Text node directly instead of using
`.textContent` which will remove the existing node and create a new one.

@param {DOMElement} node
@param {string} text
@internal

Set the textContent property of a node . For text updates it s faster to set the nodeValue of the Text node directly instead of using . textContent which will remove the existing node and create a new one .


function createDangerousStringForStyles(styles) {
  {
    var serialized = '';
    var delimiter = '';
    for (var styleName in styles) {
      if (!styles.hasOwnProperty(styleName)) {
        continue;
      }
      var styleValue = styles[styleName];
      if (styleValue != null) {
        var isCustomProperty = styleName.indexOf('--') === 0;
        serialized += delimiter + hyphenateStyleName(styleName) + ':';
        serialized += dangerousStyleValue(styleName, styleValue, isCustomProperty);

        delimiter = ';';
      }
    }
    return serialized || null;
  }
}

function createDangerousStringForStyles ( styles ) { { var serialized = '' ; var delimiter = '' ; for ( var styleName in styles ) { if ( ! styles . hasOwnProperty ( styleName ) ) { continue ; } var styleValue = styles [ styleName ] ; if ( styleValue != null ) { var isCustomProperty = styleName . indexOf ( '--' ) === 0 ; serialized += delimiter + hyphenateStyleName ( styleName ) + ':' ; serialized += dangerousStyleValue ( styleName , styleValue , isCustomProperty ) ; delimiter = ';' ; } } return serialized || null ; } }

Operations for dealing with CSS properties.

This creates a string that is expected to be equivalent to the style
attribute generated by server-side rendering. It by-passes warnings and
security checks so it's not safe to use this value for anything other than
comparison. It is only used in DEV for SSR validation.

Operations for dealing with CSS properties . This creates a string that is expected to be equivalent to the style attribute generated by server - side rendering . It by - passes warnings and security checks so it s not safe to use this value for anything other than comparison . It is only used in DEV for SSR validation .


function (containerChildSet, workInProgress) {
    // We only have the top Fiber that was created but we need recurse down its
    // children to find all the terminal nodes.
    var node = workInProgress.child;
    while (node !== null) {
      if (node.tag === HostComponent || node.tag === HostText) {
        appendChildToContainerChildSet(containerChildSet, node.stateNode);
      } else if (node.tag === HostPortal) {
        // If we have a portal child, then we don't want to traverse
        // down its children. Instead, we'll get insertions from each child in
        // the portal directly.
      } else if (node.child !== null) {
        node.child.return = node;
        node = node.child;
        continue;
      }
      if (node === workInProgress) {
        return;
      }
      while (node.sibling === null) {
        if (node.return === null || node.return === workInProgress) {
          return;
        }
        node = node.return;
      }
      node.sibling.return = node.return;
      node = node.sibling;
    }
  }

function ( containerChildSet , workInProgress ) { var node = workInProgress . child ; while ( node !== null ) { if ( node . tag === HostComponent || node . tag === HostText ) { appendChildToContainerChildSet ( containerChildSet , node . stateNode ) ; } else if ( node . tag === HostPortal ) { } else if ( node . child !== null ) { node . child . return = node ; node = node . child ; continue ; } if ( node === workInProgress ) { return ; } while ( node . sibling === null ) { if ( node . return === null || node . return === workInProgress ) { return ; } node = node . return ; } node . sibling . return = node . return ; node = node . sibling ; } }

Persistent host tree mode An unfortunate fork of appendAllChildren because we have two different parent types.

Persistent host tree mode An unfortunate fork of appendAllChildren because we have two different parent types .


function safelyCallComponentWillUnmount(current$$1, instance) {
  {
    invokeGuardedCallback(null, callComponentWillUnmountWithTimer, null, current$$1, instance);
    if (hasCaughtError()) {
      var unmountError = clearCaughtError();
      captureCommitPhaseError(current$$1, unmountError);
    }
  }
}

function safelyCallComponentWillUnmount ( current$$1 , instance ) { { invokeGuardedCallback ( null , callComponentWillUnmountWithTimer , null , current$$1 , instance ) ; if ( hasCaughtError ( ) ) { var unmountError = clearCaughtError ( ) ; captureCommitPhaseError ( current$$1 , unmountError ) ; } } }

Capture errors so they don't interrupt unmounting.

Capture errors so they don t interrupt unmounting .


function computeUniqueAsyncExpiration() {
  var currentTime = requestCurrentTime();
  var result = computeAsyncExpiration(currentTime);
  if (result <= lastUniqueAsyncExpiration) {
    // Since we assume the current time monotonically increases, we only hit
    // this branch when computeUniqueAsyncExpiration is fired multiple times
    // within a 200ms window (or whatever the async bucket size is).
    result = lastUniqueAsyncExpiration + 1;
  }
  lastUniqueAsyncExpiration = result;
  return lastUniqueAsyncExpiration;
}

function computeUniqueAsyncExpiration ( ) { var currentTime = requestCurrentTime ( ) ; var result = computeAsyncExpiration ( currentTime ) ; if ( result <= lastUniqueAsyncExpiration ) { result = lastUniqueAsyncExpiration + 1 ; } lastUniqueAsyncExpiration = result ; return lastUniqueAsyncExpiration ; }

Creates a unique async expiration time .


function stringify(content) {
  if (typeof content === 'string' && stringifiedRegexp.test(content)) {
    return content;
  }
  return JSON.stringify(content, null, 2);
}

function stringify ( content ) { if ( typeof content === 'string' && stringifiedRegexp . test ( content ) ) { return content ; } return JSON . stringify ( content , null , 2 ) ; }

If already stringified - return original content
@param {Object|Array} content
@return {string}


function getLoaderOptions(loaderPath, rule) {
  let multiRuleProp;

  if (isWebpack1) {
    multiRuleProp = 'loaders';
  } else if (rule.oneOf) {
    multiRuleProp = 'oneOf';
  } else {
    multiRuleProp = 'use';
  }

  const multiRule = typeof rule === 'object' && Array.isArray(rule[multiRuleProp]) ? rule[multiRuleProp] : null;
  let options;

  if (multiRule) {
    const rules = [].concat(...multiRule.map(r => (r.use || r)));
    options = rules.map(normalizeRule).find(r => loaderPath.includes(r.loader)).options;
  } else {
    options = normalizeRule(rule).options;
  }

  return options;
}

function getLoaderOptions ( loaderPath , rule ) { let multiRuleProp ; if ( isWebpack1 ) { multiRuleProp = 'loaders' ; } else if ( rule . oneOf ) { multiRuleProp = 'oneOf' ; } else { multiRuleProp = 'use' ; } const multiRule = typeof rule === 'object' && Array . isArray ( rule [ multiRuleProp ] ) ? rule [ multiRuleProp ] : null ; let options ; if ( multiRule ) { const rules = [ ] . concat ( ... multiRule . map ( r => ( r . use || r ) ) ) ; options = rules . map ( normalizeRule ) . find ( r => loaderPath . includes ( r . loader ) ) . options ; } else { options = normalizeRule ( rule ) . options ; } return options ; }

webpack 1 compat loader options finder. Returns normalized options.
@param {string} loaderPath
@param {Object|Rule} rule
@return {Object|null}

webpack 1 compat loader options finder . Returns normalized options .


function normalizeRule(rule) {
  if (!rule) {
    throw new Error('Rule should be string or object');
  }

  let data;

  if (typeof rule === 'string') {
    const parts = rule.split('?');
    data = {
      loader: parts[0],
      options: parts[1] ? parseQuery(`?${parts[1]}`) : null
    };
  } else {
    const options = isWebpack1 ? rule.query : rule.options;
    data = {
      loader: rule.loader,
      options: options || null
    };
  }

  return data;
}

function
normalizeRule
(
rule
)
{
if
(
!
rule
)
{
throw
new
Error
(
'Rule should be string or object'
)
;
}
let
data
;
if
(
typeof
rule
===
'string'
)
{
const
parts
=
rule
.
split
(
'?'
)
;
data
=
{
loader
:
parts
[
0
]
,
options
:
parts
[
1
]
parseQuery
(
`
${
parts
[
1
]
}
`
)
:
}
;
}
else
{
const
options
=
isWebpack1
rule
.
query
:
rule
.
options
;
data
=
{
loader
:
rule
.
loader
,
options
:
options
||
}
;
}
return
data
;
}

webpack 1 compat rule normalizer
@param {string|Rule} rule (string - webpack 1, Object - webpack 2)
@return {Object<loader: string, options: Object|null>}


function findParent(node, handle) {
  let current = node
  while (current) {
    if (handle(current)) {
      return current
    }
    current = current.parent
  }
}

function findParent ( node , handle ) { let current = node while ( current ) { if ( handle ( current ) ) { return current } current = current . parent } }