|
2 | 2 |
|
3 | 3 | import { MatrixArray } from '../core/matrix'; |
4 | 4 | import Transformable, { TransformProp } from '../core/Transformable'; |
5 | | -import { RADIAN_TO_DEGREE, retrieve2, logError, isFunction } from '../core/util'; |
| 5 | +import { RADIAN_TO_DEGREE, retrieve2, logError } from '../core/util'; |
6 | 6 | import Displayable from '../graphic/Displayable'; |
7 | 7 | import { GradientObject } from '../graphic/Gradient'; |
8 | 8 | import { LinearGradientObject } from '../graphic/LinearGradient'; |
9 | 9 | import Path from '../graphic/Path'; |
10 | 10 | import { ImagePatternObject, PatternObject, SVGPatternObject } from '../graphic/Pattern'; |
11 | 11 | import { RadialGradientObject } from '../graphic/RadialGradient'; |
12 | 12 | import { parse } from '../tool/color'; |
13 | | -import env from '../core/env'; |
14 | 13 |
|
15 | 14 | const mathRound = Math.round; |
16 | 15 |
|
@@ -173,14 +172,14 @@ export function getSRTTransformString( |
173 | 172 | } |
174 | 173 |
|
175 | 174 | export const encodeBase64 = (function () { |
176 | | - if (env.hasGlobalWindow && isFunction(window.btoa)) { |
| 175 | + if (typeof Buffer !== 'undefined' && typeof Buffer.from === 'function') { |
177 | 176 | return function (str: string) { |
178 | | - return window.btoa(unescape(encodeURIComponent(str))); |
| 177 | + return Buffer.from(str).toString('base64'); |
179 | 178 | }; |
180 | 179 | } |
181 | | - if (typeof Buffer !== 'undefined') { |
| 180 | + if (typeof btoa === 'function' && typeof unescape === 'function' && typeof encodeURIComponent === 'function') { |
182 | 181 | return function (str: string) { |
183 | | - return Buffer.from(str).toString('base64'); |
| 182 | + return btoa(unescape(encodeURIComponent(str))); |
184 | 183 | }; |
185 | 184 | } |
186 | 185 | return function (str: string): string { |
|
0 commit comments