react-inlinesvg 4.1.1 → 4.1.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.
- package/dist/provider.d.mts +3 -3
- package/dist/provider.d.ts +3 -3
- package/dist/provider.js.map +1 -1
- package/dist/provider.mjs.map +1 -1
- package/package.json +16 -14
- package/src/provider.tsx +2 -2
package/dist/provider.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
|
|
3
3
|
interface Props {
|
|
4
|
-
children:
|
|
4
|
+
children: ReactNode;
|
|
5
5
|
name?: string;
|
|
6
6
|
}
|
|
7
|
-
declare function CacheProvider({ children, name }: Props):
|
|
7
|
+
declare function CacheProvider({ children, name }: Props): ReactNode;
|
|
8
8
|
|
|
9
9
|
export { CacheProvider as default };
|
package/dist/provider.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
|
|
3
3
|
interface Props {
|
|
4
|
-
children:
|
|
4
|
+
children: ReactNode;
|
|
5
5
|
name?: string;
|
|
6
6
|
}
|
|
7
|
-
declare function CacheProvider({ children, name }: Props):
|
|
7
|
+
declare function CacheProvider({ children, name }: Props): ReactNode;
|
|
8
8
|
|
|
9
9
|
export { CacheProvider as default };
|
|
10
10
|
export = CacheProvider
|
package/dist/provider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/provider.tsx","../src/modules/helpers.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../src/provider.tsx","../src/modules/helpers.ts"],"sourcesContent":["import { ReactNode } from 'react';\n\nimport { canUseDOM } from './modules/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 /* c8 ignore next 3 */\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 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":[]}
|
package/dist/provider.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/modules/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 /* c8 ignore next 3 */\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 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 {
|
|
1
|
+
{"version":3,"sources":["../src/modules/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 /* c8 ignore next 3 */\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 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 './modules/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":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-inlinesvg",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.3",
|
|
4
4
|
"description": "An SVG loader for React",
|
|
5
5
|
"author": "Gil Barbara <gilbarbara@gmail.com>",
|
|
6
6
|
"contributors": [
|
|
@@ -51,25 +51,26 @@
|
|
|
51
51
|
"react": "16.8 - 18"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"react-from-dom": "^0.
|
|
54
|
+
"react-from-dom": "^0.7.2"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@
|
|
57
|
+
"@arethetypeswrong/cli": "^0.15.0",
|
|
58
|
+
"@gilbarbara/eslint-config": "^0.7.4",
|
|
58
59
|
"@gilbarbara/prettier-config": "^1.0.0",
|
|
59
60
|
"@gilbarbara/tsconfig": "^0.2.3",
|
|
60
61
|
"@size-limit/preset-small-lib": "^11.0.2",
|
|
61
|
-
"@testing-library/jest-dom": "^6.2
|
|
62
|
-
"@testing-library/react": "^14.1
|
|
63
|
-
"@types/node": "^20.11.
|
|
64
|
-
"@types/react": "^18.2.
|
|
65
|
-
"@types/react-dom": "^18.2.
|
|
62
|
+
"@testing-library/jest-dom": "^6.4.2",
|
|
63
|
+
"@testing-library/react": "^14.2.1",
|
|
64
|
+
"@types/node": "^20.11.21",
|
|
65
|
+
"@types/react": "^18.2.60",
|
|
66
|
+
"@types/react-dom": "^18.2.19",
|
|
66
67
|
"@vitejs/plugin-react": "^4.2.1",
|
|
67
|
-
"@vitest/coverage-v8": "^1.
|
|
68
|
+
"@vitest/coverage-v8": "^1.3.1",
|
|
68
69
|
"browser-cache-mock": "^0.1.7",
|
|
69
70
|
"del-cli": "^5.1.0",
|
|
70
71
|
"fix-tsup-cjs": "^1.2.0",
|
|
71
72
|
"http-server": "^14.1.1",
|
|
72
|
-
"husky": "^
|
|
73
|
+
"husky": "^9.0.11",
|
|
73
74
|
"jest-extended": "^4.0.2",
|
|
74
75
|
"jsdom": "^24.0.0",
|
|
75
76
|
"react": "^18.2.0",
|
|
@@ -78,9 +79,9 @@
|
|
|
78
79
|
"size-limit": "^11.0.2",
|
|
79
80
|
"start-server-and-test": "^2.0.3",
|
|
80
81
|
"ts-node": "^10.9.2",
|
|
81
|
-
"tsup": "^8.0.
|
|
82
|
+
"tsup": "^8.0.2",
|
|
82
83
|
"typescript": "^5.3.3",
|
|
83
|
-
"vitest": "^1.
|
|
84
|
+
"vitest": "^1.3.1",
|
|
84
85
|
"vitest-fetch-mock": "^0.2.2"
|
|
85
86
|
},
|
|
86
87
|
"scripts": {
|
|
@@ -93,11 +94,12 @@
|
|
|
93
94
|
"test:coverage": "vitest run --coverage",
|
|
94
95
|
"test:watch": "vitest watch",
|
|
95
96
|
"typecheck": "tsc -p test/tsconfig.json",
|
|
97
|
+
"typevalidation": "attw -P",
|
|
96
98
|
"size": "size-limit",
|
|
97
|
-
"validate": "pnpm run lint && pnpm run typecheck && pnpm run test && pnpm run build && pnpm run size",
|
|
99
|
+
"validate": "pnpm run lint && pnpm run typecheck && pnpm run test && pnpm run build && pnpm run size && npm run typevalidation",
|
|
98
100
|
"format": "prettier \"**/*.{js,jsx,json,yml,yaml,css,less,scss,ts,tsx,md,graphql,mdx}\" --write",
|
|
99
101
|
"prepublishOnly": "pnpm run validate",
|
|
100
|
-
"prepare": "husky
|
|
102
|
+
"prepare": "husky"
|
|
101
103
|
},
|
|
102
104
|
"tsup": {
|
|
103
105
|
"banner": {
|