[
  {
    "path": ".editorconfig",
    "content": "# http://editorconfig.org\n\nroot = true\n\n[*]\ncharset = utf-8\nindent_style = space\nindent_size = 2\nend_of_line = lf\ninsert_final_newline = true\ntrim_trailing_whitespace = true\n\n[*.md]\ninsert_final_newline = false\ntrim_trailing_whitespace = false\n\n[*.sh]\nindent_size = 4\n"
  },
  {
    "path": ".github/FUNDING.yml",
    "content": "github: jeerbl\n"
  },
  {
    "path": ".github/workflows/codeql-analysis.yml",
    "content": "# For most projects, this workflow file will not need changing; you simply need\n# to commit it to your repository.\n#\n# You may wish to alter this file to override the set of languages analyzed,\n# or to provide custom queries or build logic.\n#\n# ******** NOTE ********\n# We have attempted to detect the languages in your repository. Please check\n# the `language` matrix defined below to confirm you have the correct set of\n# supported CodeQL languages.\n#\nname: \"CodeQL\"\n\non:\n  push:\n    branches: [ \"master\" ]\n  pull_request:\n    # The branches below must be a subset of the branches above\n    branches: [ \"master\" ]\n  schedule:\n    - cron: '28 6 * * 0'\n\njobs:\n  analyze:\n    name: Analyze\n    runs-on: ubuntu-latest\n    permissions:\n      actions: read\n      contents: read\n      security-events: write\n\n    strategy:\n      fail-fast: false\n      matrix:\n        language: [ 'javascript' ]\n        # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]\n        # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support\n\n    steps:\n    - name: Checkout repository\n      uses: actions/checkout@v3\n\n    # Initializes the CodeQL tools for scanning.\n    - name: Initialize CodeQL\n      uses: github/codeql-action/init@v2\n      with:\n        languages: ${{ matrix.language }}\n        # If you wish to specify custom queries, you can do so here or in a config file.\n        # By default, queries listed here will override any specified in a config file.\n        # Prefix the list here with \"+\" to use these queries and those in the config file.\n        \n        # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs\n        # queries: security-extended,security-and-quality\n\n        \n    # Autobuild attempts to build any compiled languages  (C/C++, C#, or Java).\n    # If this step fails, then you should remove it and run the build manually (see below)\n    - name: Autobuild\n      uses: github/codeql-action/autobuild@v2\n\n    # ℹ️ Command-line programs to run using the OS shell.\n    # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun\n\n    #   If the Autobuild fails above, remove it and uncomment the following three lines. \n    #   modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.\n\n    # - run: |\n    #   echo \"Run, Build Application using script\"\n    #   ./location_of_script_within_repo/buildscript.sh\n\n    - name: Perform CodeQL Analysis\n      uses: github/codeql-action/analyze@v2\n"
  },
  {
    "path": ".github/workflows/codeql.yml",
    "content": "# For most projects, this workflow file will not need changing; you simply need\n# to commit it to your repository.\n#\n# You may wish to alter this file to override the set of languages analyzed,\n# or to provide custom queries or build logic.\n#\n# ******** NOTE ********\n# We have attempted to detect the languages in your repository. Please check\n# the `language` matrix defined below to confirm you have the correct set of\n# supported CodeQL languages.\n#\nname: \"CodeQL\"\n\non:\n  push:\n    branches: [ \"master\" ]\n  pull_request:\n    # The branches below must be a subset of the branches above\n    branches: [ \"master\" ]\n  schedule:\n    - cron: '42 20 * * 4'\n\njobs:\n  analyze:\n    name: Analyze\n    runs-on: ubuntu-latest\n    permissions:\n      actions: read\n      contents: read\n      security-events: write\n\n    strategy:\n      fail-fast: false\n      matrix:\n        language: [ 'javascript' ]\n        # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]\n        # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support\n\n    steps:\n    - name: Checkout repository\n      uses: actions/checkout@v3\n\n    # Initializes the CodeQL tools for scanning.\n    - name: Initialize CodeQL\n      uses: github/codeql-action/init@v2\n      with:\n        languages: ${{ matrix.language }}\n        # If you wish to specify custom queries, you can do so here or in a config file.\n        # By default, queries listed here will override any specified in a config file.\n        # Prefix the list here with \"+\" to use these queries and those in the config file.\n        \n        # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs\n        # queries: security-extended,security-and-quality\n\n        \n    # Autobuild attempts to build any compiled languages  (C/C++, C#, or Java).\n    # If this step fails, then you should remove it and run the build manually (see below)\n    - name: Autobuild\n      uses: github/codeql-action/autobuild@v2\n\n    # ℹ️ Command-line programs to run using the OS shell.\n    # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun\n\n    #   If the Autobuild fails above, remove it and uncomment the following three lines. \n    #   modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.\n\n    # - run: |\n    #   echo \"Run, Build Application using script\"\n    #   ./location_of_script_within_repo/buildscript.sh\n\n    - name: Perform CodeQL Analysis\n      uses: github/codeql-action/analyze@v2\n"
  },
  {
    "path": ".github/workflows/dependency-review.yml",
    "content": "# Dependency Review Action\n#\n# This Action will scan dependency manifest files that change as part of a Pull Request, surfacing known-vulnerable versions of the packages declared or updated in the PR. Once installed, if the workflow run is marked as required, PRs introducing known-vulnerable packages will be blocked from merging.\n#\n# Source repository: https://github.com/actions/dependency-review-action\n# Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement\nname: 'Dependency Review'\non: [pull_request]\n\npermissions:\n  contents: read\n\njobs:\n  dependency-review:\n    runs-on: ubuntu-latest\n    steps:\n      - name: 'Checkout Repository'\n        uses: actions/checkout@v3\n      - name: 'Dependency Review'\n        uses: actions/dependency-review-action@v2\n"
  },
  {
    "path": ".github/workflows/nodejs-test.yml",
    "content": "name: NodeJS\n\non:\n  push:\n    branches: [ \"master\" ]\n  pull_request:\n    branches: [ \"master\" ]\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n\n    strategy:\n      matrix:\n        node-version: [16.x]\n\n    steps:\n    - uses: actions/checkout@v3\n\n    - name: Use Node.js ${{ matrix.node-version }}\n      uses: actions/setup-node@v3\n      with:\n        node-version: ${{ matrix.node-version }}\n\n    - name: Build\n      run: |\n        npm install\n        npm test\n"
  },
  {
    "path": ".github/workflows/ossar.yml",
    "content": "# This workflow uses actions that are not certified by GitHub.\n# They are provided by a third-party and are governed by\n# separate terms of service, privacy policy, and support\n# documentation.\n\n# This workflow integrates a collection of open source static analysis tools\n# with GitHub code scanning. For documentation, or to provide feedback, visit\n# https://github.com/github/ossar-action\nname: OSSAR\n\non:\n  push:\n    branches: [ \"master\" ]\n  pull_request:\n    # The branches below must be a subset of the branches above\n    branches: [ \"master\" ]\n  schedule:\n    - cron: '32 5 * * 3'\n\npermissions:\n  contents: read\n\njobs:\n  OSSAR-Scan:\n    # OSSAR runs on windows-latest.\n    # ubuntu-latest and macos-latest support coming soon\n    permissions:\n      contents: read # for actions/checkout to fetch code\n      security-events: write # for github/codeql-action/upload-sarif to upload SARIF results\n    runs-on: windows-latest\n\n    steps:\n    - name: Checkout repository\n      uses: actions/checkout@v3\n\n    # Ensure a compatible version of dotnet is installed.\n    # The [Microsoft Security Code Analysis CLI](https://aka.ms/mscadocs) is built with dotnet v3.1.201.\n    # A version greater than or equal to v3.1.201 of dotnet must be installed on the agent in order to run this action.\n    # GitHub hosted runners already have a compatible version of dotnet installed and this step may be skipped.\n    # For self-hosted runners, ensure dotnet version 3.1.201 or later is installed by including this action:\n    # - name: Install .NET\n    #   uses: actions/setup-dotnet@v2\n    #   with:\n    #     dotnet-version: '3.1.x'\n\n      # Run open source static analysis tools\n    - name: Run OSSAR\n      uses: github/ossar-action@v1\n      id: ossar\n\n      # Upload results to the Security tab\n    - name: Upload OSSAR results\n      uses: github/codeql-action/upload-sarif@v2\n      with:\n        sarif_file: ${{ steps.ossar.outputs.sarifFile }}\n"
  },
  {
    "path": ".github/workflows/stale.yml",
    "content": "name: Mark stale issues and pull requests\n\non:\n  schedule:\n  - cron: \"30 1 * * *\"\n\njobs:\n  stale:\n\n    runs-on: ubuntu-latest\n\n    steps:\n    - uses: actions/stale@v1\n      with:\n        repo-token: ${{ secrets.GITHUB_TOKEN }}\n        stale-issue-message: 'Stale issue message'\n        stale-pr-message: 'Stale pull request message'\n        stale-issue-label: 'no-issue-activity'\n        stale-pr-label: 'no-pr-activity'\n"
  },
  {
    "path": ".gitignore",
    "content": ".DS_Store\nnode_modules/\ntest/dist/\ntest-embed/dist/\nnpm-debug.log\n"
  },
  {
    "path": ".npmignore",
    "content": "test/*\ntest-embed/*\n"
  },
  {
    "path": ".snyk",
    "content": "# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.\nversion: v1.14.1\nignore: {}\n# patches apply the minimum changes required to fix a vulnerability\npatch:\n  SNYK-JS-LODASH-567746:\n    - '@vusion/webfonts-generator > svg2ttf > lodash':\n        patched: '2020-05-01T05:58:26.942Z'\n"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2017 Jerome Brunel\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# webfonts-loader\n\n[![npm](https://img.shields.io/npm/v/webfonts-loader.svg)](https://www.npmjs.com/package/webfonts-loader)\n[![npm](https://img.shields.io/npm/dm/webfonts-loader.svg)](https://www.npmjs.com/package/webfonts-loader)\n[![GitHub Action](https://img.shields.io/github/actions/workflow/status/jeerbl/webfonts-loader/nodejs-test.yml)](https://github.com/jeerbl/webfonts-loader/actions/workflows/nodejs-test.yml)\n[![license](https://img.shields.io/github/license/jeerbl/webfonts-loader.svg)](https://github.com/jeerbl/webfonts-loader/blob/master/LICENSE)\n\nA Webpack loader that generates fonts from your SVG icons and allows you to use your icons in your HTML.\n\n`webfonts-loader` uses the [`webfonts-generator`](https://github.com/vusion/webfonts-generator) plugin to create fonts in any format. It also generates CSS files so that you can use your icons directly in your HTML, using CSS classes.\n\n## Installation\n\n```\nnpm install webfonts-loader\n```\n\n## Usage\n\nAn example of usage can be found in the `test/` directory of this repository.\n\n### Webpack rule\n\nAdd this rule to your Webpack config:\n\n```javascript\n{\n  test: /\\.font\\.js/,\n  use: [\n    MiniCssExtractPlugin.loader,\n    {\n      loader: 'css-loader',\n      options: {\n        url: false\n      }\n    },\n    'webfonts-loader'\n  ]\n}\n```\n\nSo that each font configuration file will be loaded using this rule.\n\n#### Loader options\n\nYou can provide `options` objects to configure the loader behaviour:\n\n```javascript\n{\n  test: /\\.font\\.js/,\n  use: [\n    MiniCssExtractPlugin.loader,\n    {\n      loader: 'css-loader',\n      options: {\n        url: false\n      }\n    },\n    {\n      loader: 'webfonts-loader',\n      options: { ... }\n    }\n  ]\n}\n```\n\nAvailable options are:\n\n##### `publicPath`, String\n\nThis is the URL prefix for generated links (e.g. `/static/` or `https://cdn.project.net/`). Should typically match Webpack's `config.output.publicPath`.\n\n##### Any font config option\n\nIf you pass `types`, `fileName` or any other font config option, it will be used as a default (unless overriden in font config file).\n\n### The font configuration file\n\n#### Description\n\nThe config file allows you to specify parameters for the loader to use. Here is an example configuration file:\n\n```javascript\n// myfont.font.js\nmodule.exports = {\n  'files': [\n    './myfont/*.svg'\n  ],\n  'fontName': 'myfonticons',\n  'classPrefix': 'myfonticon-',\n  'baseSelector': '.myfonticon',\n  'types': ['eot', 'woff2', 'woff', 'ttf', 'svg'],\n  'fileName': 'app.[fontname].[hash].[ext]'\n};\n```\n\nThen you have to require the configuration file:\n\n```javascript\n// entry.js\nrequire('./myfont.font');\n```\n\nThe loader will then generate:\n\n* CSS with the base and class prefix\n* Font files for the SVG icons\n\n#### All font configuration options\n\n##### `baseSelector`, String\n\nThe base CSS selector, under which each icon class is to be created.\nSee [webfonts-generator#templateOptions](https://github.com/vusion/webfonts-generator#templateoptions)\n\n##### `classPrefix`, String\n\nThe prefix to be used with each icon class.\nSee [webfonts-generator#templateOptions](https://github.com/vusion/webfonts-generator#templateoptions)\n\n##### `cssContext`, Function\n\nAdd parameters or helpers to your template.\nSee [webfonts-generator#cssContext](https://github.com/vusion/webfonts-generator#cssContext)\n\n##### `htmlContext`, Function\n\nAdd parameters or helpers to your template.\nSee [webfonts-generator#htmlContext](https://github.com/vusion/webfonts-generator#htmlContext)\n\n##### `cssTemplate`, String\n\nSee [webfonts-generator#cssTemplate](https://github.com/vusion/webfonts-generator#csstemplate)\n\n##### `cssDest`, String\n\nSee [webfonts-generator#cssDest](https://github.com/vusion/webfonts-generator#csstemplate)\n\n##### `embed`, Boolean\n\nIf true the font is encoded in base64 and embedded inside the `@font-face` declaration, otherwise font files are written to disk.\nDefault: `false`\n\n##### `scssFile`, Boolean\n\nIf true, the build process will export a .scss file in the same path as the .css file.\nDefault: `false`\n\n##### `hashLength`, Number\n\nOptional. The length of hash in `fileName`.\nMin: 8\nMax: 32\nDefault: 20\n\n##### `fileName`, String\n\nThe generated font file names. These elements can be used:\n\n* `[fontname]`: the value of the `fontName` parameter\n* `[ext]`: the extension of the font file being generated (`eot`, ...)\n* `[hash]`: the hash of the current compilation\n* `[chunkhash]`: the hash of the SVG files\n\nThis option can be also configured globally in the webpack loader options.\n\n##### `emitCodepoints`, Array (with shorthand versions of Boolean, String and Object)\n\nOptional. The generated codepoints file names.\n\nExamples:\n\n* `emitCodepoints: true`: emits a javascript file named `[fontname].codepoints.js` in the `web` (default) format\n* `emitCodepoints: '[fontname].codepoints.fonts.js'`: emits a javascript file named `[fontname].codepoints.fonts.js` in the `commonjs` format\n* `emitCodepoints: { fileName: '[fontname].codepoints.json', type: 'json'] }`: emits a file named `[fontname].codepoints.json` in the `json` format\n* `emitCodepoints: [{ fileName: '[fontname].codepoints.json', type: 'json'] }, { fileName: '[fontname].codepoints.js', type: 'web'] }, { fileName: '[fontname].codepoints.inc.js', type: 'web'] }]`: emits three files with their respective names and types\n\nThese are the existing formats:\n\n* `web`: (default): generates a file containing the array of codepoints in a format suitable for inclusion in html pages.\n\nExample (for a font named myfonticons):\n```javascript\nif (typeof webfontIconCodepoints === 'undefined') {\n  webfontIconCodepoints = {};\n}\nwebfontIconCodepoints[\"myfonticons\"] = {\"alert\":61697,\"arrow-down\":61698,\"arrow-left\":61699};\n```\n\n* `commonjs`: generates a file containing the array of codepoints in the commonjs format, for use with `require`.\n```javascript\nmodule.exports = {\"alert\":61697,\"arrow-down\":61698,\"arrow-left\":61699}\n```\n\n* `json`: generates a file containing the array of codepoints in the JSON format.\n```javascript\n{\"alert\":61697,\"arrow-down\":61698,\"arrow-left\":61699,\"arrow-right\":61700,\"arrow-small-down\":61701}\n```\n\nThese elements can be used in the filename:\n\n* `[fontname]`: the value of the `fontName` parameter\n* `[chunkhash]`: the hash of the SVG files\n\nThis option can be also configured globally in the webpack loader options.\n\n##### `files`, Array\n\nSee [webfonts-generator#files](https://github.com/vusion/webfonts-generator#files)\n\n##### `fontName`, String\n\nSee [webfonts-generator#fontname](https://github.com/vusion/webfonts-generator#fontname)\n\n##### `formatOptions`, Object\n\nSee [webfonts-generator#formatoptions](https://github.com/vusion/webfonts-generator#formatoptions)\n\n##### `rename`, Function\n\nSee [webfonts-generator#rename](https://github.com/vusion/webfonts-generator#rename)\n\n##### `types`, Array<String>\n\nSee [webfonts-generator#types](https://github.com/vusion/webfonts-generator#types)\n\n##### `dest`, String\n\nSee [webfonts-generator#dest](https://github.com/vusion/webfonts-generator#dest)\n\n##### `html`, Boolean\n\nSee [webfonts-generator#html](https://github.com/vusion/webfonts-generator#html)\n\n##### `htmlDest`, String\n\nSee [webfonts-generator#htmldest](https://github.com/vusion/webfonts-generator#htmldest)\n\n##### `ligature`, Boolean\n\nSee [webfonts-generator#ligature](https://github.com/vusion/webfonts-generator#ligature)\n\n##### `cssFontsUrl`, String (before cssFontsPath)\n\nSee [webfonts-generator#cssfontspath](https://github.com/vusion/webfonts-generator#cssfontspath)\n\n##### `htmlTemplate`, String\n#### Example\n```\n...\nhtmlTemplate: path.resolve(__dirname, 'src/html.hbs'),\n...\n```\n\nSee [webfonts-generator#htmltemplate](https://github.com/vusion/webfonts-generator#htmltemplate)\n\n##### `startCodepoint`, Number\n\nSee [webfonts-generator#startcodepoint](https://github.com/vusion/webfonts-generator#startcodepoint)\n"
  },
  {
    "path": "emit-codepoints.js",
    "content": "var loaderUtils = require('loader-utils');\n\nvar hashFiles = require('./utils').hashFiles;\n\nmodule.exports = {\n  createArrayCodepointFiles (codepointFiles, elem) {\n    const defaultElem = { fileName: '[fontname].codepoints.js', type: 'web' };\n    if (typeof (elem) === 'boolean') {\n      codepointFiles.push(Object.assign({}, defaultElem));\n    } else if (typeof (elem) === 'string') {\n      codepointFiles.push(Object.assign({}, defaultElem, { fileName: elem }));\n    } else if (Array.isArray(elem)) {\n      elem.forEach(e => this.createArrayCodepointFiles(codepointFiles, e));\n    } else if (typeof (elem) === 'object') {\n      codepointFiles.push(Object.assign({}, defaultElem, elem));\n    }\n  },\n  emitFiles (loaderContext, emitCodepointsOptions, generatorOptions, options) {\n    var codepointFiles = [];\n    this.createArrayCodepointFiles(codepointFiles, emitCodepointsOptions);\n    codepointFiles.forEach(emitOption => {\n      var codepointsContent = JSON.stringify(generatorOptions.codepoints);\n      switch (emitOption.type) {\n        case 'commonjs': {\n          codepointsContent = 'module.exports = ' + codepointsContent + ';';\n          break;\n        }\n        case 'web': {\n          codepointsContent = [\n            'if (typeof webfontIconCodepoints === \\'undefined\\') {',\n            '  webfontIconCodepoints = {};',\n            '}',\n            'webfontIconCodepoints[' + JSON.stringify(generatorOptions.fontName) + '] = ' + codepointsContent + ';'\n          ].join('\\n');\n          break;\n        }\n        case 'json': {\n          break;\n        }\n      }\n\n      var codepointsFilename = emitOption.fileName;\n      var chunkHash = codepointsFilename.indexOf('[chunkhash]') !== -1\n        ? hashFiles(generatorOptions.files, options.hashLength) : '';\n\n      codepointsFilename = codepointsFilename\n        .replace('[chunkhash]', chunkHash)\n        .replace('[fontname]', generatorOptions.fontName);\n\n      codepointsFilename = loaderUtils.interpolateName(loaderContext,\n        codepointsFilename,\n        {\n          context: loaderContext.rootContext || loaderContext.options.context || loaderContext.context,\n          content: codepointsContent\n        }\n      );\n      loaderContext.emitFile(codepointsFilename, codepointsContent);\n    });\n  }\n};\n"
  },
  {
    "path": "index.js",
    "content": "var loaderUtils = require('loader-utils');\nvar webfontsGenerator = require('@vusion/webfonts-generator');\nvar path = require('path');\nvar glob = require('glob');\nvar url = require('url');\nvar hashFiles = require('./utils').hashFiles;\n\nvar NativeModule = require('module');\n\nvar mimeTypes = {\n  'eot': 'application/vnd.ms-fontobject',\n  'svg': 'image/svg+xml',\n  'ttf': 'application/x-font-ttf',\n  'woff': 'application/font-woff',\n  'woff2': 'font/woff2'\n};\n\nfunction getFilesAndDeps (patterns, context) {\n  var files = [];\n  var filesDeps = [];\n  var directoryDeps = [];\n\n  function addFile (file) {\n    filesDeps.push(file);\n    files.push(path.resolve(context, file));\n  }\n\n  function addByGlob (globExp) {\n    var globOptions = {\n      cwd: context\n    };\n\n    var foundFiles = glob.sync(globExp, globOptions);\n    files = files.concat(foundFiles.map(file => {\n      return path.resolve(context, file);\n    }));\n\n    var globDirs = glob.sync(path.dirname(globExp) + '/', globOptions);\n    directoryDeps = directoryDeps.concat(globDirs.map(file => {\n      return path.resolve(context, file);\n    }));\n  }\n\n  // Re-work the files array.\n  patterns.forEach(function (pattern) {\n    if (glob.hasMagic(pattern)) {\n      addByGlob(pattern);\n    } else {\n      addFile(pattern);\n    }\n  });\n\n  return {\n    files: files,\n    dependencies: {\n      directories: directoryDeps,\n      files: filesDeps\n    }\n  };\n}\n\n// Futureproof webpack option parsing\nfunction wpGetOptions (context) {\n  if (typeof context.query === 'string') return loaderUtils.getOptions(context);\n  return context.query;\n}\n\nmodule.exports = function (content) {\n  this.cacheable();\n\n  var options = wpGetOptions(this) || {};\n  var rawFontConfig;\n  try {\n    rawFontConfig = JSON.parse(content);\n  } catch (ex) {\n    var module = new NativeModule(this.resourcePath);\n\n    module.paths = NativeModule._nodeModulePaths(this.context);\n    module.filename = this.resourcePath;\n    module._compile(content, this.resourcePath);\n\n    rawFontConfig = module.exports;\n  }\n  var fontConfig = Object.assign({}, options, rawFontConfig);\n\n  var filesAndDeps = getFilesAndDeps(fontConfig.files, this.context);\n  filesAndDeps.dependencies.files.forEach(this.addDependency.bind(this));\n  filesAndDeps.dependencies.directories.forEach(this.addContextDependency.bind(this));\n  fontConfig.files = filesAndDeps.files;\n\n  // With everything set up, let's make an ACTUAL config.\n  var formats = fontConfig.types || ['eot', 'woff2', 'woff', 'ttf', 'svg'];\n  if (formats.constructor !== Array) {\n    formats = [formats];\n  }\n\n  var generatorOptions = {\n    files: fontConfig.files,\n    fontName: fontConfig.fontName,\n    types: formats,\n    order: formats,\n    fontHeight: fontConfig.fontHeight || 1000, // Fixes conversion issues with small svgs,\n    codepoints: fontConfig.codepoints || {},\n    templateOptions: {\n      baseSelector: fontConfig.baseSelector || '.icon',\n      classPrefix: 'classPrefix' in fontConfig ? fontConfig.classPrefix : 'icon-'\n    },\n    scssFile: fontConfig.scssFile || false,\n    dest: fontConfig.dest || '',\n    html: fontConfig.html || false,\n    htmlDest: fontConfig.htmlDest || undefined,\n    cssDest: fontConfig.cssDest ? path.resolve(this.context, fontConfig.cssDest, fontConfig.fontName.toLowerCase() + '.css') : undefined,\n    cssFontsUrl: fontConfig.cssFontsUrl || '',\n    embed: fontConfig.embed || false,\n    formatOptions: fontConfig.formatOptions || {},\n    writeFiles: false\n  };\n\n  if ('startCodepoint' in fontConfig) generatorOptions.startCodepoint = fontConfig.startCodepoint;\n  if ('ligature' in fontConfig) generatorOptions.ligature = fontConfig.ligature;\n  if ('htmlTemplate' in fontConfig) generatorOptions.htmlTemplate = fontConfig.htmlTemplate;\n\n  // This originally was in the object notation itself.\n  // Unfortunately that actually broke my editor's syntax-highlighting...\n  // ... what a shame.\n  if (typeof fontConfig.rename === 'function') {\n    generatorOptions.rename = fontConfig.rename;\n  } else {\n    generatorOptions.rename = function (f) {\n      return path.basename(f, '.svg');\n    };\n  }\n\n  if (fontConfig.cssContext) {\n    generatorOptions.cssContext = fontConfig.cssContext;\n  }\n\n  if (fontConfig.htmlContext) {\n    generatorOptions.htmlContext = fontConfig.htmlContext;\n  }\n\n  if (fontConfig.cssTemplate) {\n    generatorOptions.cssTemplate = path.resolve(this.context, fontConfig.cssTemplate);\n  }\n\n  if (fontConfig.cssFontsUrl) {\n    generatorOptions.cssFontsUrl = path.resolve(this.context, fontConfig.cssFontsUrl);\n  }\n\n  if (fontConfig.htmlTemplate) {\n    generatorOptions.htmlTemplate = path.resolve(this.context, fontConfig.htmlTemplate);\n  }\n\n  if (fontConfig.htmlDest) {\n    generatorOptions.htmlDest = path.resolve(this.context, fontConfig.htmlDest);\n  }\n\n  if (fontConfig.dest) {\n    if (fontConfig.dest.endsWith('/')) {\n      generatorOptions.dest = fontConfig.dest;\n    } else {\n      generatorOptions.dest = `${fontConfig.dest}/`;\n    }\n  }\n\n  // Spit out SCSS file to same path as CSS file to easily use mixins (scssFile must be true)\n  if (fontConfig.cssDest && fontConfig.scssFile) {\n    generatorOptions.cssDest = path.resolve(this.context, fontConfig.cssDest, fontConfig.fontName.toLowerCase() + '.scss');\n  }\n\n  // svgicons2svgfont stuff\n  var keys = [\n    'fixedWidth',\n    'centerHorizontally',\n    'normalize',\n    'fontHeight',\n    'round',\n    'descent'\n  ];\n  for (var x in keys) {\n    if (typeof fontConfig[keys[x]] !== 'undefined') {\n      generatorOptions[keys[x]] = fontConfig[keys[x]];\n    }\n  }\n\n  var cb = this.async();\n\n  var publicPath;\n  if (typeof options.publicPath === 'string') {\n    if (options.publicPath === '' || options.publicPath.endsWith('/')) {\n      publicPath = options.publicPath;\n    } else {\n      publicPath = `${options.publicPath}/`;\n    }\n  } else {\n    if (typeof options.publicPath === 'function') {\n      publicPath = options.publicPath(this.resourcePath, this.rootContext);\n    } else {\n      publicPath = this._compilation.outputOptions.publicPath || '/';\n    }\n  }\n\n  var embed = !!generatorOptions.embed;\n\n  if (generatorOptions.cssTemplate) {\n    this.addDependency(generatorOptions.cssTemplate);\n  }\n\n  if (generatorOptions.cssFontsUrl) {\n    this.addDependency(generatorOptions.cssFontsUrl);\n  }\n\n  webfontsGenerator(generatorOptions, (err, res) => {\n    if (err) {\n      return cb(err);\n    }\n    var urls = {};\n    for (var i in formats) {\n      var format = formats[i];\n      var filename = fontConfig.fileName || options.fileName || '[chunkhash]-[fontname].[ext]';\n      var chunkHash = filename.indexOf('[chunkhash]') !== -1\n        ? hashFiles(generatorOptions.files, options.hashLength) : '';\n\n      filename = generatorOptions.dest.concat(filename);\n      filename = filename\n        .replace('[chunkhash]', chunkHash)\n        .replace('[fontname]', generatorOptions.fontName)\n        .replace('[ext]', format);\n\n      if (!embed) {\n        var formatFilename = loaderUtils.interpolateName(this,\n          filename,\n          {\n            context: this.rootContext || this.options.context || this.context,\n            content: res[format]\n          }\n        );\n        urls[format] = url.resolve(publicPath, formatFilename.replace(/\\\\/g, '/'));\n        this.emitFile(formatFilename, res[format]);\n      } else {\n        urls[format] = 'data:' +\n        mimeTypes[format] +\n        ';charset=utf-8;base64,' +\n        (Buffer.from(res[format]).toString('base64'));\n      }\n    }\n    var emitCodepointsOptions = fontConfig.emitCodepoints || options.emitCodepoints || null;\n    if (emitCodepointsOptions) {\n      var emitCodepoints = require('./emit-codepoints');\n      emitCodepoints.emitFiles(this, emitCodepointsOptions, generatorOptions, options);\n    }\n\n    if (generatorOptions.html) {\n      var htmlDest = generatorOptions.htmlDest ? generatorOptions.htmlDest : generatorOptions.fontName + '.html';\n      htmlDest = generatorOptions.dest.concat(htmlDest);\n      htmlDest = loaderUtils.interpolateName(this,\n        htmlDest,\n        {\n          context: this.rootContext || this.options.context || this.context\n        }\n      );\n\n      var relativeUrls = {};\n      for (var key in urls) {\n        relativeUrls[key] = path.relative(url.resolve(publicPath, path.dirname(htmlDest.replace(/\\\\/g, '/'))), urls[key]);\n      }\n\n      var htmlContent = res.generateHtml(relativeUrls);\n      this.emitFile(htmlDest, htmlContent);\n    }\n\n    cb(null, res.generateCss(urls));\n  });\n};\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"webfonts-loader\",\n  \"version\": \"8.1.1\",\n  \"description\": \"A WebPack loader to automatically generate font files and CSS to make your own icon font\",\n  \"repository\": \"jeerbl/webfonts-loader\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"test\": \"semistandard && ./runTest.sh && ./runTestEmbed.sh\",\n    \"snyk-protect\": \"snyk protect\",\n    \"prepare\": \"npm run snyk-protect\"\n  },\n  \"keywords\": [\n    \"font\",\n    \"webfont\",\n    \"iconfont\",\n    \"web\",\n    \"icon\",\n    \"generator\",\n    \"webpack\",\n    \"loader\"\n  ],\n  \"author\": \"Jérôme\",\n  \"funding\": {\n    \"url\": \"https://github.com/sponsors/jeerbl\"\n  },\n  \"license\": \"MIT\",\n  \"dependencies\": {\n    \"@vusion/webfonts-generator\": \"^0.8.0\",\n    \"glob\": \"^7.1.6\",\n    \"loader-utils\": \"^2.0.0\"\n  },\n  \"devDependencies\": {\n    \"semistandard\": \"^13.0.1\",\n    \"snyk\": \"^1.461.0\"\n  },\n  \"semistandard\": {\n    \"ignore\": [\n      \"**/node_modules/\"\n    ]\n  },\n  \"snyk\": true\n}\n"
  },
  {
    "path": "runTest.sh",
    "content": "#!/bin/sh\n\ncd test && npm install && npm test\n"
  },
  {
    "path": "runTestEmbed.sh",
    "content": "#!/bin/sh\n\ncd test-embed && npm install && npm test\n"
  },
  {
    "path": "test/ava.js",
    "content": "var test = require('ava');\nvar glob = require('glob').sync;\nvar hashFiles = require('../utils').hashFiles;\n\ntest('check consistency of files hash without hash length option', function (t) {\n  var files = glob('./test/test-svg/*.svg');\n  var expected = 'da39a3ee5e6b4b0d3255';\n\n  t.is(hashFiles(files), expected);\n});\n\ntest('check consistency of files hash with min hash length option', function (t) {\n  var files = glob('./test/test-svg/*.svg');\n  var expected = 'da39a3ee';\n  var minHashLength = 8;\n\n  t.is(hashFiles(files, minHashLength), expected);\n});\n\ntest('check consistency of files hash with max hash length option', function (t) {\n  var files = glob('./test/test-svg/*.svg');\n  var expected = 'da39a3ee5e6b4b0d3255bfef95601890';\n  var maxHashLength = 32;\n\n  t.is(hashFiles(files, maxHashLength), expected);\n});\n"
  },
  {
    "path": "test/entry.js",
    "content": "require('./myfont.font');\n"
  },
  {
    "path": "test/myfont.font.js",
    "content": "module.exports = {\n  'files': [\n    './test-svg/*.svg'\n  ],\n  'fontName': 'myfonticons',\n  'classPrefix': 'myfonticon-',\n  'baseSelector': '.myfonticon',\n  'types': ['eot', 'woff2', 'woff', 'ttf', 'svg'],\n  'fixedWidth': true,\n  'fileName': 'app.[fontname].[chunkhash].[ext]'\n};\n"
  },
  {
    "path": "test/package.json",
    "content": "{\n  \"name\": \"webfonts-loader-test\",\n  \"private\": true,\n  \"main\": \"entry.js\",\n  \"scripts\": {\n    \"test\": \"rimraf ./dist && ava -v ./ava.js && webpack --mode production\"\n  },\n  \"devDependencies\": {\n    \"ava\": \"^5.1.0\",\n    \"css-loader\": \"^5.1.0\",\n    \"mini-css-extract-plugin\": \"^1.3.9\",\n    \"rimraf\": \"^3.0.2\",\n    \"style-loader\": \"^2.0.0\",\n    \"webpack\": \"^5.76.0\",\n    \"webpack-cli\": \"^4.5.0\",\n    \"webpack-dev-server\": \"^3.11.2\"\n  },\n  \"standard\": {\n    \"ignore\": [\n      \"./dist\"\n    ]\n  }\n}\n"
  },
  {
    "path": "test/webpack.config.js",
    "content": "const path = require('path');\n\nconst MiniCssExtractPlugin = require('mini-css-extract-plugin');\n\nmodule.exports = {\n  entry: [\n    './entry.js'\n  ],\n  output: {\n    path: path.resolve(__dirname, 'dist'),\n    publicPath: '/',\n    filename: 'app.bundle.js'\n  },\n  performance: {\n    hints: false\n  },\n  module: {\n    rules: [\n      {\n        test: /\\.font\\.js/,\n        use: [\n          MiniCssExtractPlugin.loader,\n          {\n            loader: 'css-loader',\n            options: {\n              url: false\n            }\n          },\n          require.resolve('../') // Replace this line with require('webfonts-loader')\n        ]\n      }\n    ]\n  },\n  plugins: [\n    new MiniCssExtractPlugin({\n      filename: 'app.bundle.[contenthash].css'\n    })\n  ],\n  devServer: {\n    compress: true,\n    historyApiFallback: true,\n    host: 'localhost',\n    hot: true,\n    https: true,\n    inline: true,\n    port: '8080'\n  }\n};\n"
  },
  {
    "path": "test-embed/ava.js",
    "content": "var test = require('ava');\nvar glob = require('glob').sync;\nvar hashFiles = require('../utils').hashFiles;\n\ntest('check consistency of files hash without hash length option', function (t) {\n  var files = glob('./test/test-svg/*.svg');\n  var expected = 'da39a3ee5e6b4b0d3255';\n\n  t.is(hashFiles(files), expected);\n});\n\ntest('check consistency of files hash with min hash length option', function (t) {\n  var files = glob('./test/test-svg/*.svg');\n  var expected = 'da39a3ee';\n  var minHashLength = 8;\n\n  t.is(hashFiles(files, minHashLength), expected);\n});\n\ntest('check consistency of files hash with max hash length option', function (t) {\n  var files = glob('./test/test-svg/*.svg');\n  var expected = 'da39a3ee5e6b4b0d3255bfef95601890';\n  var maxHashLength = 32;\n\n  t.is(hashFiles(files, maxHashLength), expected);\n});\n"
  },
  {
    "path": "test-embed/entry.js",
    "content": "require('./myfont.font');\n"
  },
  {
    "path": "test-embed/myfont.font.json",
    "content": "{\n  \"files\": [\n    \"./test-svg/*.svg\"\n  ],\n  \"fontName\": \"myfonticons\",\n  \"classPrefix\": \"myfonticon-\",\n  \"baseSelector\": \".myfonticon\",\n  \"types\": [\"eot\", \"woff2\", \"woff\", \"ttf\", \"svg\"],\n  \"fixedWidth\": true,\n  \"embed\": true,\n  \"fileName\": \"app.[fontname].[chunkhash].[ext]\"\n}\n"
  },
  {
    "path": "test-embed/package.json",
    "content": "{\n  \"name\": \"webfonts-loader-test\",\n  \"private\": true,\n  \"main\": \"entry.js\",\n  \"scripts\": {\n    \"test\": \"rimraf ./dist && ava -v ./ava.js && webpack --mode production\"\n  },\n  \"devDependencies\": {\n    \"ava\": \"^5.1.0\",\n    \"css-loader\": \"^5.1.0\",\n    \"rimraf\": \"^3.0.2\",\n    \"style-loader\": \"^2.0.0\",\n    \"webpack\": \"^4.46.0\",\n    \"webpack-cli\": \"^3.3.12\",\n    \"webpack-dev-server\": \"^3.11.2\"\n  },\n  \"standard\": {\n    \"ignore\": [\n      \"./dist\"\n    ]\n  }\n}\n"
  },
  {
    "path": "test-embed/webpack.config.js",
    "content": "const path = require('path');\n\nmodule.exports = {\n  entry: [\n    './entry.js'\n  ],\n  output: {\n    path: path.resolve(__dirname, 'dist'),\n    publicPath: '/',\n    filename: 'app.bundle.js'\n  },\n  performance: {\n    hints: false\n  },\n  module: {\n    rules: [\n      {\n        test: /\\.font\\.json/,\n        type: 'javascript/auto',\n        use: [\n          'style-loader',\n          'css-loader',\n          require.resolve('../') // Replace this line with require('webfonts-loader')\n        ]\n      }\n    ]\n  },\n  devServer: {\n    compress: true,\n    historyApiFallback: true,\n    host: 'localhost',\n    hot: true,\n    https: true,\n    inline: true,\n    port: '8080'\n  }\n};\n"
  },
  {
    "path": "utils.js",
    "content": "var crypto = require('crypto');\nvar fs = require('fs');\n\nmodule.exports = {\n  hashFiles: function (files, hashLength) {\n    // FIXME: For compatibility with the hash-files package, this\n    // function just sorts by filename and hashes the concatenation of\n    // the file contents. This algorithm will not detect certain\n    // changes where files are renamed or chunks are moved across\n    // file boundaries (https://github.com/mac-/hash-files/issues/4).\n\n    hashLength = hashLength && +hashLength >= 8 && +hashLength <= 32 ? +hashLength : 20;\n    var hash = crypto.createHash('sha1');\n    Array.from(new Set(files)).sort().forEach(function (file) {\n      hash.update(fs.readFileSync(file));\n    });\n    return hash.digest('hex').slice(0, hashLength);\n  }\n};\n"
  }
]