@symbo.ls/scratch 3.1.1 → 3.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,11 @@
1
1
  'use strict'
2
2
 
3
- import { isArray, isString } from '@domql/utils'
3
+ import { isArray, isNotProduction, isString } from '@domql/utils'
4
4
  import { getActiveConfig } from '../factory'
5
5
 
6
- const ENV = process.env.NODE_ENV || 'development'
7
- const isDev = ENV === 'development' || ENV === 'testing'
6
+ const isDev = isNotProduction()
8
7
 
9
- export const generateSprite = (icons) => {
8
+ export const generateSprite = icons => {
10
9
  const CONFIG = getActiveConfig()
11
10
 
12
11
  let sprite = ''
@@ -20,7 +19,7 @@ export const generateSprite = (icons) => {
20
19
  return sprite
21
20
  }
22
21
 
23
- const parseRootAttributes = (htmlString) => {
22
+ const parseRootAttributes = htmlString => {
24
23
  const val = htmlString.default || htmlString
25
24
  if (!isString(val)) {
26
25
  if (isDev) console.warn('parseRootAttributes:', val, 'is not a string')
@@ -33,7 +32,9 @@ const parseRootAttributes = (htmlString) => {
33
32
  }
34
33
 
35
34
  const attrString = match[1]
36
- const attrs = attrString.match(/(\S+)=["']?((?:.(?!["']?\s+(?:\S+)=|\s*\/?[>"']))+.)["']?/gm)
35
+ const attrs = attrString.match(
36
+ /(\S+)=["']?((?:.(?!["']?\s+(?:\S+)=|\s*\/?[>"']))+.)["']?/gm
37
+ )
37
38
  return attrs.reduce((acc, attr) => {
38
39
  const [key, value] = attr.split('=')
39
40
  acc[key] = value.replace(/['"]/g, '')
@@ -49,7 +50,9 @@ const replaceIdsAndUrls = (code, key) => {
49
50
  if (isArray(matches)) {
50
51
  matches.forEach(() => {
51
52
  const randomKey = Math.floor(Math.random() * 100000)
52
- replacedCode = code.replace(idRegex, `id="${key}-${randomKey}"`).replace(urlRegex, `url(#${key}-${randomKey})`)
53
+ replacedCode = code
54
+ .replace(idRegex, `id="${key}-${randomKey}"`)
55
+ .replace(urlRegex, `url(#${key}-${randomKey})`)
53
56
  })
54
57
  }
55
58
  return replacedCode
@@ -64,7 +67,8 @@ export const convertSvgToSymbol = (key, code) => {
64
67
 
65
68
  const replacedCode = replaceIdsAndUrls(code, key)
66
69
 
67
- let symbol = replacedCode.replace('<svg',
70
+ let symbol = replacedCode.replace(
71
+ '<svg',
68
72
  `<symbol id="${key}" xmlns="${xmlns}" viewBox="${viewBox}"`
69
73
  )
70
74