react-inlinesvg 4.0.2 → 4.0.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,9 +1,9 @@
1
- import { ReactNode } from 'react';
1
+ import { JSX } from 'react';
2
2
 
3
3
  interface Props {
4
- children: ReactNode;
4
+ children: JSX.Element;
5
5
  name?: string;
6
6
  }
7
- declare function CacheProvider({ children, name }: Props): ReactNode;
7
+ declare function CacheProvider({ children, name }: Props): JSX.Element;
8
8
 
9
9
  export { CacheProvider as default };
@@ -1,9 +1,9 @@
1
- import { ReactNode } from 'react';
1
+ import { JSX } from 'react';
2
2
 
3
3
  interface Props {
4
- children: ReactNode;
4
+ children: JSX.Element;
5
5
  name?: string;
6
6
  }
7
- declare function CacheProvider({ children, name }: Props): ReactNode;
7
+ declare function CacheProvider({ children, name }: Props): JSX.Element;
8
8
 
9
9
  export { CacheProvider as default };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/provider.tsx","../src/helpers.ts"],"sourcesContent":["import { ReactNode } from 'react';\n\nimport { canUseDOM } from './helpers';\n\ninterface Props {\n children: ReactNode;\n name?: string;\n}\n\nexport default function CacheProvider({ children, name }: Props) {\n if (canUseDOM()) {\n window.REACT_INLINESVG_CACHE_NAME = name;\n window.REACT_INLINESVG_PERSISTENT_CACHE = true;\n }\n\n return children;\n}\n","import type { PlainObject } from './types';\n\nexport function canUseDOM(): boolean {\n return !!(typeof window !== 'undefined' && window.document && window.document.createElement);\n}\n\nexport function isSupportedEnvironment(): boolean {\n return supportsInlineSVG() && typeof window !== 'undefined' && window !== null;\n}\n\nexport async function request(url: string, options?: RequestInit) {\n const response = await fetch(url, options);\n const contentType = response.headers.get('content-type');\n const [fileType] = (contentType || '').split(/ ?; ?/);\n\n if (response.status > 299) {\n throw new Error('Not found');\n }\n\n if (!['image/svg+xml', 'text/plain'].some(d => fileType.includes(d))) {\n throw new Error(`Content type isn't valid: ${fileType}`);\n }\n\n return response.text();\n}\n\nexport function sleep(seconds = 1) {\n return new Promise(resolve => {\n setTimeout(resolve, seconds * 1000);\n });\n}\n\nexport function supportsInlineSVG(): boolean {\n /* istanbul ignore next */\n if (!document) {\n return false;\n }\n\n const div = document.createElement('div');\n\n div.innerHTML = '<svg />';\n const svg = div.firstChild as SVGSVGElement;\n\n return !!svg && svg.namespaceURI === 'http://www.w3.org/2000/svg';\n}\n\nfunction randomCharacter(character: string) {\n return character[Math.floor(Math.random() * character.length)];\n}\n\nexport function randomString(length: number): string {\n const letters = 'abcdefghijklmnopqrstuvwxyz';\n const numbers = '1234567890';\n const charset = `${letters}${letters.toUpperCase()}${numbers}`;\n\n let R = '';\n\n for (let index = 0; index < length; index++) {\n R += randomCharacter(charset);\n }\n\n return R;\n}\n\n/**\n * Remove properties from an object\n */\nexport function omit<T extends PlainObject, K extends keyof T>(\n input: T,\n ...filter: K[]\n): Omit<T, K> {\n const output: any = {};\n\n for (const key in input) {\n /* istanbul ignore else */\n if ({}.hasOwnProperty.call(input, key)) {\n if (!filter.includes(key as unknown as K)) {\n output[key] = input[key];\n }\n }\n }\n\n return output as Omit<T, K>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,SAAS,YAAqB;AACnC,SAAO,CAAC,EAAE,OAAO,WAAW,eAAe,OAAO,YAAY,OAAO,SAAS;AAChF;;;ADKe,SAAR,cAA+B,EAAE,UAAU,KAAK,GAAU;AAC/D,MAAI,UAAU,GAAG;AACf,WAAO,6BAA6B;AACpC,WAAO,mCAAmC;AAAA,EAC5C;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../src/provider.tsx","../src/helpers.ts"],"sourcesContent":["import { JSX } from 'react';\n\nimport { canUseDOM } from './helpers';\n\ninterface Props {\n children: JSX.Element;\n name?: string;\n}\n\nexport default function CacheProvider({ children, name }: Props) {\n if (canUseDOM()) {\n window.REACT_INLINESVG_CACHE_NAME = name;\n window.REACT_INLINESVG_PERSISTENT_CACHE = true;\n }\n\n return children;\n}\n","import type { PlainObject } from './types';\n\nexport function canUseDOM(): boolean {\n return !!(typeof window !== 'undefined' && window.document && window.document.createElement);\n}\n\nexport function isSupportedEnvironment(): boolean {\n return supportsInlineSVG() && typeof window !== 'undefined' && window !== null;\n}\n\nexport async function request(url: string, options?: RequestInit) {\n const response = await fetch(url, options);\n const contentType = response.headers.get('content-type');\n const [fileType] = (contentType || '').split(/ ?; ?/);\n\n if (response.status > 299) {\n throw new Error('Not found');\n }\n\n if (!['image/svg+xml', 'text/plain'].some(d => fileType.includes(d))) {\n throw new Error(`Content type isn't valid: ${fileType}`);\n }\n\n return response.text();\n}\n\nexport function sleep(seconds = 1) {\n return new Promise(resolve => {\n setTimeout(resolve, seconds * 1000);\n });\n}\n\nexport function supportsInlineSVG(): boolean {\n /* istanbul ignore next */\n if (!document) {\n return false;\n }\n\n const div = document.createElement('div');\n\n div.innerHTML = '<svg />';\n const svg = div.firstChild as SVGSVGElement;\n\n return !!svg && svg.namespaceURI === 'http://www.w3.org/2000/svg';\n}\n\nfunction randomCharacter(character: string) {\n return character[Math.floor(Math.random() * character.length)];\n}\n\nexport function randomString(length: number): string {\n const letters = 'abcdefghijklmnopqrstuvwxyz';\n const numbers = '1234567890';\n const charset = `${letters}${letters.toUpperCase()}${numbers}`;\n\n let R = '';\n\n for (let index = 0; index < length; index++) {\n R += randomCharacter(charset);\n }\n\n return R;\n}\n\n/**\n * Remove properties from an object\n */\nexport function omit<T extends PlainObject, K extends keyof T>(\n input: T,\n ...filter: K[]\n): Omit<T, K> {\n const output: any = {};\n\n for (const key in input) {\n /* istanbul ignore else */\n if ({}.hasOwnProperty.call(input, key)) {\n if (!filter.includes(key as unknown as K)) {\n output[key] = input[key];\n }\n }\n }\n\n return output as Omit<T, K>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,SAAS,YAAqB;AACnC,SAAO,CAAC,EAAE,OAAO,WAAW,eAAe,OAAO,YAAY,OAAO,SAAS;AAChF;;;ADKe,SAAR,cAA+B,EAAE,UAAU,KAAK,GAAU;AAC/D,MAAI,UAAU,GAAG;AACf,WAAO,6BAA6B;AACpC,WAAO,mCAAmC;AAAA,EAC5C;AAEA,SAAO;AACT;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/helpers.ts","../src/provider.tsx"],"sourcesContent":["import type { PlainObject } from './types';\n\nexport function canUseDOM(): boolean {\n return !!(typeof window !== 'undefined' && window.document && window.document.createElement);\n}\n\nexport function isSupportedEnvironment(): boolean {\n return supportsInlineSVG() && typeof window !== 'undefined' && window !== null;\n}\n\nexport async function request(url: string, options?: RequestInit) {\n const response = await fetch(url, options);\n const contentType = response.headers.get('content-type');\n const [fileType] = (contentType || '').split(/ ?; ?/);\n\n if (response.status > 299) {\n throw new Error('Not found');\n }\n\n if (!['image/svg+xml', 'text/plain'].some(d => fileType.includes(d))) {\n throw new Error(`Content type isn't valid: ${fileType}`);\n }\n\n return response.text();\n}\n\nexport function sleep(seconds = 1) {\n return new Promise(resolve => {\n setTimeout(resolve, seconds * 1000);\n });\n}\n\nexport function supportsInlineSVG(): boolean {\n /* istanbul ignore next */\n if (!document) {\n return false;\n }\n\n const div = document.createElement('div');\n\n div.innerHTML = '<svg />';\n const svg = div.firstChild as SVGSVGElement;\n\n return !!svg && svg.namespaceURI === 'http://www.w3.org/2000/svg';\n}\n\nfunction randomCharacter(character: string) {\n return character[Math.floor(Math.random() * character.length)];\n}\n\nexport function randomString(length: number): string {\n const letters = 'abcdefghijklmnopqrstuvwxyz';\n const numbers = '1234567890';\n const charset = `${letters}${letters.toUpperCase()}${numbers}`;\n\n let R = '';\n\n for (let index = 0; index < length; index++) {\n R += randomCharacter(charset);\n }\n\n return R;\n}\n\n/**\n * Remove properties from an object\n */\nexport function omit<T extends PlainObject, K extends keyof T>(\n input: T,\n ...filter: K[]\n): Omit<T, K> {\n const output: any = {};\n\n for (const key in input) {\n /* istanbul ignore else */\n if ({}.hasOwnProperty.call(input, key)) {\n if (!filter.includes(key as unknown as K)) {\n output[key] = input[key];\n }\n }\n }\n\n return output as Omit<T, K>;\n}\n","import { ReactNode } from 'react';\n\nimport { canUseDOM } from './helpers';\n\ninterface Props {\n children: ReactNode;\n name?: string;\n}\n\nexport default function CacheProvider({ children, name }: Props) {\n if (canUseDOM()) {\n window.REACT_INLINESVG_CACHE_NAME = name;\n window.REACT_INLINESVG_PERSISTENT_CACHE = true;\n }\n\n return children;\n}\n"],"mappings":";AAEO,SAAS,YAAqB;AACnC,SAAO,CAAC,EAAE,OAAO,WAAW,eAAe,OAAO,YAAY,OAAO,SAAS;AAChF;;;ACKe,SAAR,cAA+B,EAAE,UAAU,KAAK,GAAU;AAC/D,MAAI,UAAU,GAAG;AACf,WAAO,6BAA6B;AACpC,WAAO,mCAAmC;AAAA,EAC5C;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../src/helpers.ts","../src/provider.tsx"],"sourcesContent":["import type { PlainObject } from './types';\n\nexport function canUseDOM(): boolean {\n return !!(typeof window !== 'undefined' && window.document && window.document.createElement);\n}\n\nexport function isSupportedEnvironment(): boolean {\n return supportsInlineSVG() && typeof window !== 'undefined' && window !== null;\n}\n\nexport async function request(url: string, options?: RequestInit) {\n const response = await fetch(url, options);\n const contentType = response.headers.get('content-type');\n const [fileType] = (contentType || '').split(/ ?; ?/);\n\n if (response.status > 299) {\n throw new Error('Not found');\n }\n\n if (!['image/svg+xml', 'text/plain'].some(d => fileType.includes(d))) {\n throw new Error(`Content type isn't valid: ${fileType}`);\n }\n\n return response.text();\n}\n\nexport function sleep(seconds = 1) {\n return new Promise(resolve => {\n setTimeout(resolve, seconds * 1000);\n });\n}\n\nexport function supportsInlineSVG(): boolean {\n /* istanbul ignore next */\n if (!document) {\n return false;\n }\n\n const div = document.createElement('div');\n\n div.innerHTML = '<svg />';\n const svg = div.firstChild as SVGSVGElement;\n\n return !!svg && svg.namespaceURI === 'http://www.w3.org/2000/svg';\n}\n\nfunction randomCharacter(character: string) {\n return character[Math.floor(Math.random() * character.length)];\n}\n\nexport function randomString(length: number): string {\n const letters = 'abcdefghijklmnopqrstuvwxyz';\n const numbers = '1234567890';\n const charset = `${letters}${letters.toUpperCase()}${numbers}`;\n\n let R = '';\n\n for (let index = 0; index < length; index++) {\n R += randomCharacter(charset);\n }\n\n return R;\n}\n\n/**\n * Remove properties from an object\n */\nexport function omit<T extends PlainObject, K extends keyof T>(\n input: T,\n ...filter: K[]\n): Omit<T, K> {\n const output: any = {};\n\n for (const key in input) {\n /* istanbul ignore else */\n if ({}.hasOwnProperty.call(input, key)) {\n if (!filter.includes(key as unknown as K)) {\n output[key] = input[key];\n }\n }\n }\n\n return output as Omit<T, K>;\n}\n","import { JSX } from 'react';\n\nimport { canUseDOM } from './helpers';\n\ninterface Props {\n children: JSX.Element;\n name?: string;\n}\n\nexport default function CacheProvider({ children, name }: Props) {\n if (canUseDOM()) {\n window.REACT_INLINESVG_CACHE_NAME = name;\n window.REACT_INLINESVG_PERSISTENT_CACHE = true;\n }\n\n return children;\n}\n"],"mappings":";AAEO,SAAS,YAAqB;AACnC,SAAO,CAAC,EAAE,OAAO,WAAW,eAAe,OAAO,YAAY,OAAO,SAAS;AAChF;;;ACKe,SAAR,cAA+B,EAAE,UAAU,KAAK,GAAU;AAC/D,MAAI,UAAU,GAAG;AACf,WAAO,6BAA6B;AACpC,WAAO,mCAAmC;AAAA,EAC5C;AAEA,SAAO;AACT;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-inlinesvg",
3
- "version": "4.0.2",
3
+ "version": "4.0.3",
4
4
  "description": "An SVG loader for React",
5
5
  "author": "Gil Barbara <gilbarbara@gmail.com>",
6
6
  "contributors": [
@@ -54,27 +54,27 @@
54
54
  "react-from-dom": "^0.6.2"
55
55
  },
56
56
  "devDependencies": {
57
- "@gilbarbara/eslint-config": "^0.5.2",
58
- "@gilbarbara/helpers": "^0.8.2",
57
+ "@gilbarbara/eslint-config": "^0.5.3",
58
+ "@gilbarbara/helpers": "^0.8.4",
59
59
  "@gilbarbara/prettier-config": "^1.0.0",
60
- "@gilbarbara/tsconfig": "^0.1.1",
60
+ "@gilbarbara/tsconfig": "^0.2.3",
61
61
  "@size-limit/preset-small-lib": "^8.2.6",
62
- "@testing-library/jest-dom": "^5.17.0",
62
+ "@testing-library/jest-dom": "^6.1.2",
63
63
  "@testing-library/react": "^14.0.0",
64
64
  "@types/exenv": "^1.2.0",
65
65
  "@types/fetch-mock": "^7.3.5",
66
- "@types/jest": "^29.5.3",
67
- "@types/node": "^20.4.9",
66
+ "@types/jest": "^29.5.4",
67
+ "@types/node": "^20.5.6",
68
68
  "@types/node-fetch": "^2.6.4",
69
- "@types/react": "^18.2.20",
69
+ "@types/react": "^18.2.21",
70
70
  "@types/react-dom": "^18.2.7",
71
71
  "browser-cache-mock": "^0.1.7",
72
72
  "cross-fetch": "^4.0.0",
73
73
  "del-cli": "^5.0.0",
74
74
  "http-server": "^14.1.1",
75
75
  "husky": "^8.0.3",
76
- "jest": "^29.6.2",
77
- "jest-environment-jsdom": "^29.6.2",
76
+ "jest": "^29.6.4",
77
+ "jest-environment-jsdom": "^29.6.4",
78
78
  "jest-extended": "^4.0.1",
79
79
  "jest-fetch-mock": "^3.0.3",
80
80
  "jest-serializer-html": "^7.1.0",
@@ -87,21 +87,22 @@
87
87
  "ts-jest": "^29.1.1",
88
88
  "ts-node": "^10.9.1",
89
89
  "tsup": "^7.2.0",
90
- "typescript": "^5.1.6"
90
+ "typescript": "^5.2.2"
91
91
  },
92
92
  "scripts": {
93
- "build": "npm run clean && tsup",
93
+ "build": "pnpm run clean && tsup",
94
94
  "watch": "tsup --watch",
95
95
  "clean": "del dist/*",
96
96
  "start": "http-server test/__fixtures__ -p 1337 --cors",
97
+ "lint": "eslint --ext .ts,.tsx src test",
97
98
  "test": "start-server-and-test start http://127.0.0.1:1337 test:coverage",
98
99
  "test:coverage": "jest --coverage --bail",
99
100
  "test:watch": "jest --watchAll --verbose",
100
- "lint": "eslint --ext .ts,.tsx src test",
101
- "format": "prettier \"**/*.{js,jsx,json,yml,yaml,css,less,scss,ts,tsx,md,graphql,mdx}\" --write",
102
- "validate": "npm run lint && npm run test && npm run build && npm run size",
101
+ "typecheck": "tsc --noEmit",
103
102
  "size": "size-limit",
104
- "prepublishOnly": "npm run validate",
103
+ "validate": "pnpm run lint && pnpm run typecheck && pnpm run test && pnpm run build && pnpm run size",
104
+ "format": "prettier \"**/*.{js,jsx,json,yml,yaml,css,less,scss,ts,tsx,md,graphql,mdx}\" --write",
105
+ "prepublishOnly": "pnpm run validate",
105
106
  "prepare": "husky install"
106
107
  },
107
108
  "tsup": {
package/src/provider.tsx CHANGED
@@ -1,9 +1,9 @@
1
- import { ReactNode } from 'react';
1
+ import { JSX } from 'react';
2
2
 
3
3
  import { canUseDOM } from './helpers';
4
4
 
5
5
  interface Props {
6
- children: ReactNode;
6
+ children: JSX.Element;
7
7
  name?: string;
8
8
  }
9
9