vendor.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. /**
  20. * AUTO-GENERATED FILE. DO NOT MODIFY.
  21. */
  22. /*
  23. * Licensed to the Apache Software Foundation (ASF) under one
  24. * or more contributor license agreements. See the NOTICE file
  25. * distributed with this work for additional information
  26. * regarding copyright ownership. The ASF licenses this file
  27. * to you under the Apache License, Version 2.0 (the
  28. * "License"); you may not use this file except in compliance
  29. * with the License. You may obtain a copy of the License at
  30. *
  31. * http://www.apache.org/licenses/LICENSE-2.0
  32. *
  33. * Unless required by applicable law or agreed to in writing,
  34. * software distributed under the License is distributed on an
  35. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  36. * KIND, either express or implied. See the License for the
  37. * specific language governing permissions and limitations
  38. * under the License.
  39. */
  40. import { assert } from 'zrender/lib/core/util.js';
  41. import { error } from './log.js';
  42. import { UNDEFINED_STR } from './types.js';
  43. import { MAX_SAFE_INTEGER } from './number.js';
  44. /* global Int8Array, Int16Array, Int32Array, Uint8Array, Uint16Array, Uint32Array,
  45. Uint8ClampedArray, Float32Array, Float64Array */
  46. export var Int8ArrayCtor = typeof Int8Array !== UNDEFINED_STR ? Int8Array : undefined;
  47. export var Int16ArrayCtor = typeof Int16Array !== UNDEFINED_STR ? Int16Array : undefined;
  48. export var Int32ArrayCtor = typeof Int32Array !== UNDEFINED_STR ? Int32Array : undefined;
  49. export var Uint8ArrayCtor = typeof Uint8Array !== UNDEFINED_STR ? Uint8Array : undefined;
  50. export var Uint16ArrayCtor = typeof Uint16Array !== UNDEFINED_STR ? Uint16Array : undefined;
  51. export var Uint32ArrayCtor = typeof Uint32Array !== UNDEFINED_STR ? Uint32Array : undefined;
  52. export var Uint8ClampedArrayCtor = typeof Uint8ClampedArray !== UNDEFINED_STR ? Uint8ClampedArray : undefined;
  53. export var Float32ArrayCtor = typeof Float32Array !== UNDEFINED_STR ? Float32Array : undefined;
  54. export var Float64ArrayCtor = typeof Float64Array !== UNDEFINED_STR ? Float64Array : undefined;
  55. export function createFloat32Array(capacity) {
  56. return tryEnsureTypedArray({
  57. ctor: Float32ArrayCtor
  58. }, capacity).arr;
  59. }
  60. export function tryEnsureTypedArray(tyArr,
  61. // Can add more types if needed.
  62. // NOTICE: Callers need to manage data length themselves.
  63. // Do not consider `capacity` as the data length.
  64. capacity) {
  65. if (process.env.NODE_ENV !== 'production') {
  66. assert(capacity != null && isFinite(capacity) && capacity >= 0 && tyArr.hasOwnProperty('ctor'));
  67. }
  68. var existingArr = tyArr.arr;
  69. var ctor = tyArr.ctor;
  70. if (capacity > MAX_SAFE_INTEGER) {
  71. capacity = MAX_SAFE_INTEGER;
  72. }
  73. if (!existingArr || tyArr.typed && existingArr.length < capacity) {
  74. var nextArr = void 0;
  75. if (ctor) {
  76. try {
  77. // A large contiguous memory allocation may cause OOM.
  78. nextArr = new ctor(capacity);
  79. tyArr.typed = true;
  80. existingArr && nextArr.set(existingArr);
  81. } catch (e) {
  82. if (process.env.NODE_ENV !== 'production') {
  83. error(e);
  84. }
  85. }
  86. }
  87. if (!nextArr) {
  88. nextArr = [];
  89. tyArr.typed = false;
  90. if (existingArr) {
  91. for (var i = 0, len = existingArr.length; i < len; i++) {
  92. nextArr[i] = existingArr[i];
  93. }
  94. }
  95. }
  96. tyArr.arr = nextArr;
  97. }
  98. return tyArr;
  99. }