@antv/g-webgpu 0.5.6 → 1.1.0

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.
Files changed (168) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +0 -53
  3. package/dist/index.umd.min.js +16 -0
  4. package/es/ContextRegisterPlugin.d.ts +7 -0
  5. package/es/ContextRegisterPlugin.js +28 -0
  6. package/es/WebGLContextService.d.ts +18 -0
  7. package/es/WebGLContextService.js +99 -0
  8. package/es/index.d.ts +10 -7
  9. package/es/index.js +34 -8
  10. package/lib/ContextRegisterPlugin.d.ts +7 -0
  11. package/lib/ContextRegisterPlugin.js +37 -0
  12. package/lib/WebGLContextService.d.ts +18 -0
  13. package/lib/WebGLContextService.js +107 -0
  14. package/lib/index.d.ts +10 -0
  15. package/lib/index.js +47 -43
  16. package/package.json +37 -31
  17. package/CHANGELOG.md +0 -89
  18. package/es/Kernel.d.ts +0 -21
  19. package/es/Kernel.js +0 -331
  20. package/es/Kernel.js.map +0 -1
  21. package/es/Renderer.d.ts +0 -24
  22. package/es/Renderer.js +0 -341
  23. package/es/Renderer.js.map +0 -1
  24. package/es/Scene.d.ts +0 -11
  25. package/es/Scene.js +0 -54
  26. package/es/Scene.js.map +0 -1
  27. package/es/View.d.ts +0 -20
  28. package/es/View.js +0 -86
  29. package/es/View.js.map +0 -1
  30. package/es/World.d.ts +0 -49
  31. package/es/World.js +0 -283
  32. package/es/World.js.map +0 -1
  33. package/es/camera/Camera.d.ts +0 -252
  34. package/es/camera/Camera.js +0 -831
  35. package/es/camera/Camera.js.map +0 -1
  36. package/es/camera/Landmark.d.ts +0 -28
  37. package/es/camera/Landmark.js +0 -86
  38. package/es/camera/Landmark.js.map +0 -1
  39. package/es/geometry/Box.d.ts +0 -11
  40. package/es/geometry/Box.js +0 -180
  41. package/es/geometry/Box.js.map +0 -1
  42. package/es/geometry/Merged.d.ts +0 -8
  43. package/es/geometry/Merged.js +0 -91
  44. package/es/geometry/Merged.js.map +0 -1
  45. package/es/geometry/Plane.d.ts +0 -10
  46. package/es/geometry/Plane.js +0 -112
  47. package/es/geometry/Plane.js.map +0 -1
  48. package/es/geometry/Sphere.d.ts +0 -9
  49. package/es/geometry/Sphere.js +0 -121
  50. package/es/geometry/Sphere.js.map +0 -1
  51. package/es/geometry/index.d.ts +0 -19
  52. package/es/geometry/index.js +0 -59
  53. package/es/geometry/index.js.map +0 -1
  54. package/es/glsl.d.js +0 -2
  55. package/es/glsl.d.js.map +0 -1
  56. package/es/index.js.map +0 -1
  57. package/es/material/basic/index.d.ts +0 -10
  58. package/es/material/basic/index.js +0 -108
  59. package/es/material/basic/index.js.map +0 -1
  60. package/es/material/index.d.ts +0 -16
  61. package/es/material/index.js +0 -60
  62. package/es/material/index.js.map +0 -1
  63. package/es/renderable/Renderable.d.ts +0 -41
  64. package/es/renderable/Renderable.js +0 -169
  65. package/es/renderable/Renderable.js.map +0 -1
  66. package/es/renderable/grid/index.d.ts +0 -17
  67. package/es/renderable/grid/index.js +0 -133
  68. package/es/renderable/grid/index.js.map +0 -1
  69. package/es/renderable/line/index.d.ts +0 -23
  70. package/es/renderable/line/index.js +0 -231
  71. package/es/renderable/line/index.js.map +0 -1
  72. package/es/renderable/point/index.d.ts +0 -29
  73. package/es/renderable/point/index.js +0 -241
  74. package/es/renderable/point/index.js.map +0 -1
  75. package/es/texture/Cache.d.ts +0 -6
  76. package/es/texture/Cache.js +0 -28
  77. package/es/texture/Cache.js.map +0 -1
  78. package/es/texture/Texture2D.d.ts +0 -13
  79. package/es/texture/Texture2D.js +0 -126
  80. package/es/texture/Texture2D.js.map +0 -1
  81. package/es/utils/canvas.d.ts +0 -1
  82. package/es/utils/canvas.js +0 -8
  83. package/es/utils/canvas.js.map +0 -1
  84. package/es/utils/is-array.d.ts +0 -2
  85. package/es/utils/is-array.js +0 -5
  86. package/es/utils/is-array.js.map +0 -1
  87. package/es/utils/is-number.d.ts +0 -1
  88. package/es/utils/is-number.js +0 -4
  89. package/es/utils/is-number.js.map +0 -1
  90. package/es/utils/is-type.d.ts +0 -2
  91. package/es/utils/is-type.js +0 -8
  92. package/es/utils/is-type.js.map +0 -1
  93. package/es/utils/is-typedarray.d.ts +0 -27
  94. package/es/utils/is-typedarray.js +0 -99
  95. package/es/utils/is-typedarray.js.map +0 -1
  96. package/es/utils/math.d.ts +0 -3
  97. package/es/utils/math.js +0 -24
  98. package/es/utils/math.js.map +0 -1
  99. package/es/utils/picking.d.ts +0 -1
  100. package/es/utils/picking.js +0 -4
  101. package/es/utils/picking.js.map +0 -1
  102. package/es/utils/polyline-normals.d.ts +0 -6
  103. package/es/utils/polyline-normals.js +0 -129
  104. package/es/utils/polyline-normals.js.map +0 -1
  105. package/es/utils/typedarray.d.ts +0 -1
  106. package/es/utils/typedarray.js +0 -29
  107. package/es/utils/typedarray.js.map +0 -1
  108. package/lib/Kernel.js +0 -352
  109. package/lib/Kernel.js.map +0 -1
  110. package/lib/Renderer.js +0 -354
  111. package/lib/Renderer.js.map +0 -1
  112. package/lib/Scene.js +0 -64
  113. package/lib/Scene.js.map +0 -1
  114. package/lib/View.js +0 -99
  115. package/lib/View.js.map +0 -1
  116. package/lib/World.js +0 -313
  117. package/lib/World.js.map +0 -1
  118. package/lib/camera/Camera.js +0 -900
  119. package/lib/camera/Camera.js.map +0 -1
  120. package/lib/camera/Landmark.js +0 -95
  121. package/lib/camera/Landmark.js.map +0 -1
  122. package/lib/geometry/Box.js +0 -205
  123. package/lib/geometry/Box.js.map +0 -1
  124. package/lib/geometry/Merged.js +0 -110
  125. package/lib/geometry/Merged.js.map +0 -1
  126. package/lib/geometry/Plane.js +0 -127
  127. package/lib/geometry/Plane.js.map +0 -1
  128. package/lib/geometry/Sphere.js +0 -136
  129. package/lib/geometry/Sphere.js.map +0 -1
  130. package/lib/geometry/index.js +0 -71
  131. package/lib/geometry/index.js.map +0 -1
  132. package/lib/glsl.d.js +0 -2
  133. package/lib/glsl.d.js.map +0 -1
  134. package/lib/index.js.map +0 -1
  135. package/lib/material/basic/index.js +0 -125
  136. package/lib/material/basic/index.js.map +0 -1
  137. package/lib/material/index.js +0 -72
  138. package/lib/material/index.js.map +0 -1
  139. package/lib/renderable/Renderable.js +0 -178
  140. package/lib/renderable/Renderable.js.map +0 -1
  141. package/lib/renderable/grid/index.js +0 -148
  142. package/lib/renderable/grid/index.js.map +0 -1
  143. package/lib/renderable/line/index.js +0 -248
  144. package/lib/renderable/line/index.js.map +0 -1
  145. package/lib/renderable/point/index.js +0 -259
  146. package/lib/renderable/point/index.js.map +0 -1
  147. package/lib/texture/Cache.js +0 -38
  148. package/lib/texture/Cache.js.map +0 -1
  149. package/lib/texture/Texture2D.js +0 -142
  150. package/lib/texture/Texture2D.js.map +0 -1
  151. package/lib/utils/canvas.js +0 -15
  152. package/lib/utils/canvas.js.map +0 -1
  153. package/lib/utils/is-array.js +0 -17
  154. package/lib/utils/is-array.js.map +0 -1
  155. package/lib/utils/is-number.js +0 -11
  156. package/lib/utils/is-number.js.map +0 -1
  157. package/lib/utils/is-type.js +0 -15
  158. package/lib/utils/is-type.js.map +0 -1
  159. package/lib/utils/is-typedarray.js +0 -109
  160. package/lib/utils/is-typedarray.js.map +0 -1
  161. package/lib/utils/math.js +0 -35
  162. package/lib/utils/math.js.map +0 -1
  163. package/lib/utils/picking.js +0 -11
  164. package/lib/utils/picking.js.map +0 -1
  165. package/lib/utils/polyline-normals.js +0 -137
  166. package/lib/utils/polyline-normals.js.map +0 -1
  167. package/lib/utils/typedarray.js +0 -36
  168. package/lib/utils/typedarray.js.map +0 -1
@@ -1,29 +0,0 @@
1
- import { BufferData } from '@antv/g-webgpu-core';
2
- import { Renderable } from '../Renderable';
3
- interface IPointConfig {
4
- id: number;
5
- shape: 'circle' | 'triangle' | 'square' | 'pentagon' | 'hexagon' | 'octogon' | 'hexagram' | 'rhombus' | 'vesica';
6
- position: [number, number];
7
- size: [number, number];
8
- color: [number, number, number, number];
9
- opacity: number;
10
- strokeWidth: number;
11
- strokeOpacity: number;
12
- strokeColor: [number, number, number, number];
13
- }
14
- /**
15
- * Use SDF to draw 2D point with stroke.
16
- */
17
- export declare class Point extends Renderable<Partial<IPointConfig> | Array<Partial<IPointConfig>>> {
18
- private readonly materialSystem;
19
- private readonly geometrySystem;
20
- private readonly shaderModuleService;
21
- protected onAttributeChanged({ name, data, }: {
22
- name: string;
23
- data: BufferData;
24
- }): void;
25
- protected onEntityCreated(): void;
26
- private buildAttribute;
27
- private buildAttributes;
28
- }
29
- export {};
@@ -1,241 +0,0 @@
1
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
- import _initializerDefineProperty from "@babel/runtime/helpers/initializerDefineProperty";
4
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
5
- import _createClass from "@babel/runtime/helpers/createClass";
6
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
7
- import _inherits from "@babel/runtime/helpers/inherits";
8
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
9
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
10
- import _applyDecoratedDescriptor from "@babel/runtime/helpers/applyDecoratedDescriptor";
11
- import _initializerWarningHelper from "@babel/runtime/helpers/initializerWarningHelper";
12
-
13
- var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _class, _class2, _descriptor, _descriptor2, _descriptor3, _temp;
14
-
15
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
16
-
17
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
18
-
19
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
20
-
21
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
22
-
23
- import { gl, IDENTIFIER } from '@antv/g-webgpu-core';
24
- import { inject, injectable, named } from 'inversify';
25
- import { encodePickingColor } from '../../utils/picking';
26
- import { Renderable } from '../Renderable';
27
-
28
- /* babel-plugin-inline-import './shaders/webgl.point.frag.glsl' */
29
- var pointFrag = "uniform float u_blur : 0.05;\nuniform float u_opacity : 0.7;\nuniform float u_stroke_width : 0.01;\nuniform vec4 u_stroke_color : [0, 0, 0, 0];\nuniform float u_stroke_opacity : 1;\n\nvarying vec4 v_color;\nvarying vec4 v_data;\nvarying float v_radius;\n\n#pragma include \"sdf2d\"\n#pragma include \"picking\"\n\nvoid main() {\n int shape = int(floor(v_data.w + 0.5));\n\n float antialiasblur = v_data.z;\n float antialiased_blur = -max(u_blur, antialiasblur);\n float r = v_radius / (v_radius + u_stroke_width);\n\n float outer_df;\n float inner_df;\n // 'circle', 'triangle', 'square', 'pentagon', 'hexagon', 'octogon', 'hexagram', 'rhombus', 'vesica'\n // if (shape == 0) {\n outer_df = sdCircle(v_data.xy, 1.0);\n inner_df = sdCircle(v_data.xy, r);\n // } else if (shape == 1) {\n // outer_df = sdEquilateralTriangle(1.1 * v_data.xy);\n // inner_df = sdEquilateralTriangle(1.1 / r * v_data.xy);\n // } else if (shape == 2) {\n // outer_df = sdBox(v_data.xy, vec2(1.));\n // inner_df = sdBox(v_data.xy, vec2(r));\n // } else if (shape == 3) {\n // outer_df = sdPentagon(v_data.xy, 0.8);\n // inner_df = sdPentagon(v_data.xy, r * 0.8);\n // } else if (shape == 4) {\n // outer_df = sdHexagon(v_data.xy, 0.8);\n // inner_df = sdHexagon(v_data.xy, r * 0.8);\n // } else if (shape == 5) {\n // outer_df = sdOctogon(v_data.xy, 1.0);\n // inner_df = sdOctogon(v_data.xy, r);\n // } else if (shape == 6) {\n // outer_df = sdHexagram(v_data.xy, 0.52);\n // inner_df = sdHexagram(v_data.xy, r * 0.52);\n // } else if (shape == 7) {\n // outer_df = sdRhombus(v_data.xy, vec2(1.0));\n // inner_df = sdRhombus(v_data.xy, vec2(r));\n // } else if (shape == 8) {\n // outer_df = sdVesica(v_data.xy, 1.1, 0.8);\n // inner_df = sdVesica(v_data.xy, r * 1.1, r * 0.8);\n // }\n\n float opacity_t = smoothstep(0.0, antialiased_blur, outer_df);\n\n float color_t = u_stroke_width < 0.01 ? 0.0 : smoothstep(\n antialiased_blur,\n 0.0,\n inner_df\n );\n vec4 strokeColor = u_stroke_color == vec4(0) ? v_color : u_stroke_color;\n\n gl_FragColor = mix(vec4(v_color.rgb, v_color.a * u_opacity), strokeColor * u_stroke_opacity, color_t);\n gl_FragColor.a = gl_FragColor.a * opacity_t;\n\n gl_FragColor = filterColor(gl_FragColor);\n}";
30
-
31
- /* babel-plugin-inline-import './shaders/webgl.point.vert.glsl' */
32
- var pointVert = "attribute vec2 position;\nattribute vec4 color;\nattribute float shape;\nattribute vec2 offset;\nattribute float size;\n\nuniform mat4 projectionMatrix;\nuniform mat4 modelViewMatrix;\n\nuniform float u_stroke_width : 0.01;\nuniform float u_device_pixel_ratio;\nuniform vec2 u_viewport;\n\nvarying vec4 v_color;\nvarying vec4 v_data;\nvarying float v_radius;\n\n#pragma include \"picking\"\n\nvoid main() {\n v_color = color;\n v_radius = size;\n\n lowp float antialiasblur = 1.0 / u_device_pixel_ratio * (size + u_stroke_width);\n\n // construct point coords\n v_data = vec4(position, antialiasblur, shape);\n\n gl_Position = projectionMatrix * modelViewMatrix\n * vec4(position * size + offset, 0.0, 1.0);\n\n setPickingColor(a_PickingColor);\n}";
33
- var pointShapes = ['circle', 'triangle', 'square', 'pentagon', 'hexagon', 'octogon', 'hexagram', 'rhombus', 'vesica'];
34
- export
35
- /**
36
- * Use SDF to draw 2D point with stroke.
37
- */
38
- var Point = (_dec = injectable(), _dec2 = inject(IDENTIFIER.Systems), _dec3 = named(IDENTIFIER.MaterialSystem), _dec4 = inject(IDENTIFIER.Systems), _dec5 = named(IDENTIFIER.GeometrySystem), _dec6 = inject(IDENTIFIER.ShaderModuleService), _dec(_class = (_class2 = (_temp = /*#__PURE__*/function (_Renderable) {
39
- _inherits(Point, _Renderable);
40
-
41
- var _super = _createSuper(Point);
42
-
43
- function Point() {
44
- var _this;
45
-
46
- _classCallCheck(this, Point);
47
-
48
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
49
- args[_key] = arguments[_key];
50
- }
51
-
52
- _this = _super.call.apply(_super, [this].concat(args));
53
-
54
- _initializerDefineProperty(_this, "materialSystem", _descriptor, _assertThisInitialized(_this));
55
-
56
- _initializerDefineProperty(_this, "geometrySystem", _descriptor2, _assertThisInitialized(_this));
57
-
58
- _initializerDefineProperty(_this, "shaderModuleService", _descriptor3, _assertThisInitialized(_this));
59
-
60
- return _this;
61
- }
62
-
63
- _createClass(Point, [{
64
- key: "onAttributeChanged",
65
- value: function onAttributeChanged(_ref) {
66
- var name = _ref.name,
67
- data = _ref.data;
68
- var mesh = this.getMeshComponent();
69
-
70
- if (mesh && mesh.material) {
71
- if (name === 'strokeWidth') {
72
- mesh.material.setUniform('u_stroke_width', data);
73
- } else if (name === 'strokeColor') {
74
- mesh.material.setUniform('u_stroke_color', data);
75
- } else if (name === 'strokeOpacity') {
76
- mesh.material.setUniform('u_stroke_opacity', data);
77
- } else if (name === 'opacity') {
78
- mesh.material.setUniform('u_opacity', data);
79
- } else if (name === 'blur') {
80
- mesh.material.setUniform('u_blur', data);
81
- }
82
- }
83
- }
84
- }, {
85
- key: "onEntityCreated",
86
- value: function onEntityCreated() {
87
- this.shaderModuleService.registerModule('grid', {
88
- vs: pointVert,
89
- fs: pointFrag
90
- });
91
-
92
- var _this$shaderModuleSer = this.shaderModuleService.getModule('grid'),
93
- vs = _this$shaderModuleSer.vs,
94
- fs = _this$shaderModuleSer.fs,
95
- extractedUniforms = _this$shaderModuleSer.uniforms;
96
-
97
- var material = this.materialSystem.createShaderMaterial({
98
- vertexShader: vs,
99
- fragmentShader: fs,
100
- cull: {
101
- enable: false
102
- },
103
- depth: {
104
- enable: false
105
- },
106
- blend: {
107
- enable: true,
108
- func: {
109
- srcRGB: gl.SRC_ALPHA,
110
- dstRGB: gl.ONE_MINUS_SRC_ALPHA,
111
- srcAlpha: 1,
112
- dstAlpha: 1
113
- }
114
- }
115
- }); // TODO: support define stroke-relative props per point
116
-
117
- material.setUniform(_objectSpread({
118
- u_device_pixel_ratio: window.devicePixelRatio
119
- }, extractedUniforms));
120
- var attributes = this.buildAttributes();
121
- var geometry = this.geometrySystem.createInstancedBufferGeometry({
122
- maxInstancedCount: attributes.instancedOffsets.length / 2,
123
- vertexCount: 6
124
- });
125
- geometry.setIndex([0, 2, 1, 0, 3, 2]);
126
- geometry.setAttribute('position', Float32Array.from(attributes.positions), {
127
- arrayStride: 4 * 2,
128
- stepMode: 'vertex',
129
- attributes: [{
130
- shaderLocation: 0,
131
- offset: 0,
132
- format: 'float2'
133
- }]
134
- });
135
- geometry.setAttribute('offset', Float32Array.from(attributes.instancedOffsets), {
136
- arrayStride: 4 * 2,
137
- stepMode: 'instance',
138
- attributes: [{
139
- shaderLocation: 1,
140
- offset: 0,
141
- format: 'float2'
142
- }]
143
- });
144
- geometry.setAttribute('color', Float32Array.from(attributes.instancedColors), {
145
- arrayStride: 4 * 4,
146
- stepMode: 'instance',
147
- attributes: [{
148
- shaderLocation: 2,
149
- offset: 0,
150
- format: 'float4'
151
- }]
152
- });
153
- geometry.setAttribute('size', Float32Array.from(attributes.instancedSizes), {
154
- arrayStride: 4,
155
- stepMode: 'instance',
156
- attributes: [{
157
- shaderLocation: 3,
158
- offset: 0,
159
- format: 'float'
160
- }]
161
- });
162
- geometry.setAttribute('shape', Float32Array.from(attributes.instancedShapes), {
163
- arrayStride: 4,
164
- stepMode: 'instance',
165
- attributes: [{
166
- shaderLocation: 4,
167
- offset: 0,
168
- format: 'float'
169
- }]
170
- });
171
- geometry.setAttribute('a_PickingColor', Float32Array.from(attributes.instancedPickingColors), {
172
- arrayStride: 4 * 3,
173
- stepMode: 'instance',
174
- attributes: [{
175
- shaderLocation: 6,
176
- offset: 0,
177
- format: 'float3'
178
- }]
179
- });
180
- this.setMaterial(material);
181
- this.setGeometry(geometry);
182
- }
183
- }, {
184
- key: "buildAttribute",
185
- value: function buildAttribute(config, attributes, index) {
186
- var _attributes$instanced, _attributes$instanced2, _attributes$instanced3, _attributes$instanced4;
187
-
188
- (_attributes$instanced = attributes.instancedPickingColors).push.apply(_attributes$instanced, _toConsumableArray(encodePickingColor(config.id || index)));
189
-
190
- attributes.instancedShapes.push(pointShapes.indexOf(config.shape || 'circle'));
191
-
192
- (_attributes$instanced2 = attributes.instancedColors).push.apply(_attributes$instanced2, _toConsumableArray(config.color || [1, 0, 0, 1]));
193
-
194
- (_attributes$instanced3 = attributes.instancedOffsets).push.apply(_attributes$instanced3, _toConsumableArray(config.position || [0, 0]));
195
-
196
- (_attributes$instanced4 = attributes.instancedSizes).push.apply(_attributes$instanced4, _toConsumableArray(config.size || [0.2, 0.2]));
197
- }
198
- }, {
199
- key: "buildAttributes",
200
- value: function buildAttributes() {
201
- var _this2 = this;
202
-
203
- var attributes = {
204
- positions: [1, 1, 1, -1, -1, -1, -1, 1],
205
- instancedOffsets: [],
206
- instancedColors: [],
207
- instancedSizes: [],
208
- instancedShapes: [],
209
- instancedPickingColors: []
210
- };
211
-
212
- if (Array.isArray(this.config)) {
213
- this.config.forEach(function (config, i) {
214
- _this2.buildAttribute(config, attributes, i);
215
- });
216
- } else {
217
- this.buildAttribute(this.config, attributes, 0);
218
- }
219
-
220
- return attributes;
221
- }
222
- }]);
223
-
224
- return Point;
225
- }(Renderable), _temp), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "materialSystem", [_dec2, _dec3], {
226
- configurable: true,
227
- enumerable: true,
228
- writable: true,
229
- initializer: null
230
- }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "geometrySystem", [_dec4, _dec5], {
231
- configurable: true,
232
- enumerable: true,
233
- writable: true,
234
- initializer: null
235
- }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "shaderModuleService", [_dec6], {
236
- configurable: true,
237
- enumerable: true,
238
- writable: true,
239
- initializer: null
240
- })), _class2)) || _class);
241
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/renderable/point/index.ts"],"names":["gl","IDENTIFIER","inject","injectable","named","encodePickingColor","Renderable","pointShapes","Point","Systems","MaterialSystem","GeometrySystem","ShaderModuleService","name","data","mesh","getMeshComponent","material","setUniform","shaderModuleService","registerModule","vs","pointVert","fs","pointFrag","getModule","extractedUniforms","uniforms","materialSystem","createShaderMaterial","vertexShader","fragmentShader","cull","enable","depth","blend","func","srcRGB","SRC_ALPHA","dstRGB","ONE_MINUS_SRC_ALPHA","srcAlpha","dstAlpha","u_device_pixel_ratio","window","devicePixelRatio","attributes","buildAttributes","geometry","geometrySystem","createInstancedBufferGeometry","maxInstancedCount","instancedOffsets","length","vertexCount","setIndex","setAttribute","Float32Array","from","positions","arrayStride","stepMode","shaderLocation","offset","format","instancedColors","instancedSizes","instancedShapes","instancedPickingColors","setMaterial","setGeometry","config","index","push","id","indexOf","shape","color","position","size","Array","isArray","forEach","i","buildAttribute"],"mappings":";;;;;;;;;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aAAKA,MAAL,CAAYW,OAAZ,CAAoB,UAACX,MAAD,EAASY,CAAT,EAAe;AACjC,UAAA,MAAI,CAACC,cAAL,CAAoBb,MAApB,EAA4BzB,UAA5B,EAAwCqC,CAAxC;AACD,SAFD;AAGD,OAJD,MAIO;AACL,aAAKC,cAAL,CAAoB,KAAKb,MAAzB,EAAiCzB,UAAjC,EAA6C,CAA7C;AACD;;AAED,aAAOA,UAAP;AACD;AAvNH;;AAAA;AAAA,EAA2BxC,UAA3B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["import {\n BufferData,\n GeometrySystem,\n gl,\n IDENTIFIER,\n IShaderModuleService,\n MaterialSystem,\n} from '@antv/g-webgpu-core';\nimport { inject, injectable, named } from 'inversify';\nimport { encodePickingColor } from '../../utils/picking';\nimport { Renderable } from '../Renderable';\nimport pointFrag from './shaders/webgl.point.frag.glsl';\nimport pointVert from './shaders/webgl.point.vert.glsl';\n\nconst pointShapes = [\n 'circle',\n 'triangle',\n 'square',\n 'pentagon',\n 'hexagon',\n 'octogon',\n 'hexagram',\n 'rhombus',\n 'vesica',\n];\n\ninterface IPointConfig {\n id: number;\n shape:\n | 'circle'\n | 'triangle'\n | 'square'\n | 'pentagon'\n | 'hexagon'\n | 'octogon'\n | 'hexagram'\n | 'rhombus'\n | 'vesica';\n position: [number, number];\n size: [number, number];\n color: [number, number, number, number]; // sRGB\n opacity: number;\n strokeWidth: number;\n strokeOpacity: number;\n strokeColor: [number, number, number, number]; // sRGB\n}\n\ninterface IInstanceAttributes {\n positions: number[];\n instancedOffsets: number[];\n instancedColors: number[];\n instancedSizes: number[];\n instancedShapes: number[];\n instancedPickingColors: number[];\n}\n\n/**\n * Use SDF to draw 2D point with stroke.\n */\n@injectable()\nexport class Point extends Renderable<\n Partial<IPointConfig> | Array<Partial<IPointConfig>>\n> {\n @inject(IDENTIFIER.Systems)\n @named(IDENTIFIER.MaterialSystem)\n private readonly materialSystem: MaterialSystem;\n\n @inject(IDENTIFIER.Systems)\n @named(IDENTIFIER.GeometrySystem)\n private readonly geometrySystem: GeometrySystem;\n\n @inject(IDENTIFIER.ShaderModuleService)\n private readonly shaderModuleService: IShaderModuleService;\n\n protected onAttributeChanged({\n name,\n data,\n }: {\n name: string;\n data: BufferData;\n }) {\n const mesh = this.getMeshComponent();\n if (mesh && mesh.material) {\n if (name === 'strokeWidth') {\n mesh.material.setUniform('u_stroke_width', data);\n } else if (name === 'strokeColor') {\n mesh.material.setUniform('u_stroke_color', data);\n } else if (name === 'strokeOpacity') {\n mesh.material.setUniform('u_stroke_opacity', data);\n } else if (name === 'opacity') {\n mesh.material.setUniform('u_opacity', data);\n } else if (name === 'blur') {\n mesh.material.setUniform('u_blur', data);\n }\n }\n }\n\n protected onEntityCreated() {\n this.shaderModuleService.registerModule('grid', {\n vs: pointVert,\n fs: pointFrag,\n });\n const {\n vs,\n fs,\n uniforms: extractedUniforms,\n } = this.shaderModuleService.getModule('grid');\n\n const material = this.materialSystem.createShaderMaterial({\n vertexShader: vs!,\n fragmentShader: fs!,\n cull: {\n enable: false,\n },\n depth: {\n enable: false,\n },\n blend: {\n enable: true,\n func: {\n srcRGB: gl.SRC_ALPHA,\n dstRGB: gl.ONE_MINUS_SRC_ALPHA,\n srcAlpha: 1,\n dstAlpha: 1,\n },\n },\n });\n\n // TODO: support define stroke-relative props per point\n material.setUniform({\n u_device_pixel_ratio: window.devicePixelRatio,\n ...extractedUniforms,\n });\n\n const attributes = this.buildAttributes();\n\n const geometry = this.geometrySystem.createInstancedBufferGeometry({\n maxInstancedCount: attributes.instancedOffsets.length / 2,\n vertexCount: 6,\n });\n\n geometry.setIndex([0, 2, 1, 0, 3, 2]);\n\n geometry.setAttribute('position', Float32Array.from(attributes.positions), {\n arrayStride: 4 * 2,\n stepMode: 'vertex',\n attributes: [\n {\n shaderLocation: 0,\n offset: 0,\n format: 'float2',\n },\n ],\n });\n\n geometry.setAttribute(\n 'offset',\n Float32Array.from(attributes.instancedOffsets),\n {\n arrayStride: 4 * 2,\n stepMode: 'instance',\n attributes: [\n {\n shaderLocation: 1,\n offset: 0,\n format: 'float2',\n },\n ],\n },\n );\n\n geometry.setAttribute(\n 'color',\n Float32Array.from(attributes.instancedColors),\n {\n arrayStride: 4 * 4,\n stepMode: 'instance',\n attributes: [\n {\n shaderLocation: 2,\n offset: 0,\n format: 'float4',\n },\n ],\n },\n );\n\n geometry.setAttribute(\n 'size',\n Float32Array.from(attributes.instancedSizes),\n {\n arrayStride: 4,\n stepMode: 'instance',\n attributes: [\n {\n shaderLocation: 3,\n offset: 0,\n format: 'float',\n },\n ],\n },\n );\n\n geometry.setAttribute(\n 'shape',\n Float32Array.from(attributes.instancedShapes),\n {\n arrayStride: 4,\n stepMode: 'instance',\n attributes: [\n {\n shaderLocation: 4,\n offset: 0,\n format: 'float',\n },\n ],\n },\n );\n\n geometry.setAttribute(\n 'a_PickingColor',\n Float32Array.from(attributes.instancedPickingColors),\n {\n arrayStride: 4 * 3,\n stepMode: 'instance',\n attributes: [\n {\n shaderLocation: 6,\n offset: 0,\n format: 'float3',\n },\n ],\n },\n );\n\n this.setMaterial(material);\n this.setGeometry(geometry);\n }\n\n private buildAttribute(\n config: Partial<IPointConfig>,\n attributes: IInstanceAttributes,\n index: number,\n ) {\n attributes.instancedPickingColors.push(\n ...encodePickingColor(config.id || index),\n );\n\n attributes.instancedShapes.push(\n pointShapes.indexOf(config.shape || 'circle'),\n );\n attributes.instancedColors.push(...(config.color || [1, 0, 0, 1]));\n attributes.instancedOffsets.push(...(config.position || [0, 0]));\n attributes.instancedSizes.push(...(config.size || [0.2, 0.2]));\n }\n\n private buildAttributes() {\n const attributes: IInstanceAttributes = {\n positions: [1, 1, 1, -1, -1, -1, -1, 1],\n instancedOffsets: [],\n instancedColors: [],\n instancedSizes: [],\n instancedShapes: [],\n instancedPickingColors: [],\n };\n\n if (Array.isArray(this.config)) {\n this.config.forEach((config, i) => {\n this.buildAttribute(config, attributes, i);\n });\n } else {\n this.buildAttribute(this.config, attributes, 0);\n }\n\n return attributes;\n }\n}\n"],"file":"index.js"}
@@ -1,6 +0,0 @@
1
- import { ITexture2D } from '@antv/g-webgpu-core';
2
- export declare class TextureCache {
3
- private cache;
4
- get(name: string): ITexture2D;
5
- set(name: string, texture: ITexture2D): void;
6
- }
@@ -1,28 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
-
4
- var _dec, _class, _temp;
5
-
6
- import { injectable } from 'inversify';
7
- export var TextureCache = (_dec = injectable(), _dec(_class = (_temp = /*#__PURE__*/function () {
8
- function TextureCache() {
9
- _classCallCheck(this, TextureCache);
10
-
11
- this.cache = {};
12
- }
13
-
14
- _createClass(TextureCache, [{
15
- key: "get",
16
- value: function get(name) {
17
- return this.cache[name];
18
- }
19
- }, {
20
- key: "set",
21
- value: function set(name, texture) {
22
- this.cache[name] = texture;
23
- }
24
- }]);
25
-
26
- return TextureCache;
27
- }(), _temp)) || _class);
28
- //# sourceMappingURL=Cache.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/texture/Cache.ts"],"names":["injectable","TextureCache","cache","name","texture"],"mappings":";;;;;AACA,SAASA,UAAT,QAA2B,WAA3B;AAGA,WAAaC,YAAb,WADCD,UAAU,EACX;AAAA;AAAA;;AAAA,SACUE,KADV,GAC8C,EAD9C;AAAA;;AAAA;AAAA;AAAA,wBAGaC,IAHb,EAG2B;AACvB,aAAO,KAAKD,KAAL,CAAWC,IAAX,CAAP;AACD;AALH;AAAA;AAAA,wBAOaA,IAPb,EAO2BC,OAP3B,EAOgD;AAC5C,WAAKF,KAAL,CAAWC,IAAX,IAAmBC,OAAnB;AACD;AATH;;AAAA;AAAA","sourcesContent":["import { ITexture2D } from '@antv/g-webgpu-core';\nimport { injectable } from 'inversify';\n\n@injectable()\nexport class TextureCache {\n private cache: Record<string, ITexture2D> = {};\n\n public get(name: string) {\n return this.cache[name];\n }\n\n public set(name: string, texture: ITexture2D) {\n this.cache[name] = texture;\n }\n}\n"],"file":"Cache.js"}
@@ -1,13 +0,0 @@
1
- import { ITexture2D, ITexture2DInitializationOptions } from '@antv/g-webgpu-core';
2
- export declare class Texture2D {
3
- private readonly textureCache;
4
- private readonly engine;
5
- private config;
6
- private loaded;
7
- private texture;
8
- setConfig(config: ITexture2DInitializationOptions & {
9
- url: string;
10
- }): void;
11
- isLoaded(): boolean;
12
- load(): Promise<ITexture2D>;
13
- }
@@ -1,126 +0,0 @@
1
- import _regeneratorRuntime from "@babel/runtime/regenerator";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
4
- import _initializerDefineProperty from "@babel/runtime/helpers/initializerDefineProperty";
5
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
6
- import _createClass from "@babel/runtime/helpers/createClass";
7
- import _applyDecoratedDescriptor from "@babel/runtime/helpers/applyDecoratedDescriptor";
8
- import _initializerWarningHelper from "@babel/runtime/helpers/initializerWarningHelper";
9
-
10
- var _dec, _dec2, _dec3, _class, _class2, _descriptor, _descriptor2, _temp;
11
-
12
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
13
-
14
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
15
-
16
- import { IDENTIFIER } from '@antv/g-webgpu-core';
17
- import { inject, injectable } from 'inversify';
18
- import { TextureCache } from './Cache';
19
- export var Texture2D = (_dec = injectable(), _dec2 = inject(TextureCache), _dec3 = inject(IDENTIFIER.RenderEngine), _dec(_class = (_class2 = (_temp = /*#__PURE__*/function () {
20
- function Texture2D() {
21
- _classCallCheck(this, Texture2D);
22
-
23
- _initializerDefineProperty(this, "textureCache", _descriptor, this);
24
-
25
- _initializerDefineProperty(this, "engine", _descriptor2, this);
26
-
27
- this.config = void 0;
28
- this.loaded = false;
29
- this.texture = void 0;
30
- }
31
-
32
- _createClass(Texture2D, [{
33
- key: "setConfig",
34
- value: function setConfig(config) {
35
- this.config = config;
36
- }
37
- }, {
38
- key: "isLoaded",
39
- value: function isLoaded() {
40
- return this.loaded;
41
- } // public update(config: ITexture2DInitializationOptions) {
42
- // if (this.loaded && this.texture) {
43
- // const t = this.texture.get();
44
- // }
45
- // }
46
-
47
- }, {
48
- key: "load",
49
- value: function () {
50
- var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
51
- var _this = this;
52
-
53
- return _regeneratorRuntime.wrap(function _callee$(_context) {
54
- while (1) {
55
- switch (_context.prev = _context.next) {
56
- case 0:
57
- if (!this.config.url) {
58
- _context.next = 4;
59
- break;
60
- }
61
-
62
- return _context.abrupt("return", new Promise(function (resolve, reject) {
63
- var existed = _this.textureCache.get(_this.config.url);
64
-
65
- if (existed) {
66
- resolve(existed);
67
- } else {
68
- var image = new Image();
69
- image.crossOrigin = 'Anonymous';
70
- image.src = _this.config.url;
71
-
72
- image.onload = function () {
73
- var texture = _this.engine.createTexture2D(_objectSpread(_objectSpread({}, _this.config), {}, {
74
- data: image,
75
- width: image.width,
76
- height: image.height,
77
- flipY: true
78
- }));
79
-
80
- _this.textureCache.set(_this.config.url, texture);
81
-
82
- _this.texture = texture;
83
- _this.loaded = true;
84
- resolve(texture);
85
- };
86
-
87
- image.onerror = function () {
88
- reject();
89
- };
90
- }
91
- }));
92
-
93
- case 4:
94
- this.loaded = true;
95
- this.texture = this.engine.createTexture2D(this.config);
96
- return _context.abrupt("return", this.texture);
97
-
98
- case 7:
99
- case "end":
100
- return _context.stop();
101
- }
102
- }
103
- }, _callee, this);
104
- }));
105
-
106
- function load() {
107
- return _load.apply(this, arguments);
108
- }
109
-
110
- return load;
111
- }()
112
- }]);
113
-
114
- return Texture2D;
115
- }(), _temp), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "textureCache", [_dec2], {
116
- configurable: true,
117
- enumerable: true,
118
- writable: true,
119
- initializer: null
120
- }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "engine", [_dec3], {
121
- configurable: true,
122
- enumerable: true,
123
- writable: true,
124
- initializer: null
125
- })), _class2)) || _class);
126
- //# sourceMappingURL=Texture2D.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/texture/Texture2D.ts"],"names":["IDENTIFIER","inject","injectable","TextureCache","Texture2D","RenderEngine","config","loaded","texture","url","Promise","resolve","reject","existed","textureCache","get","image","Image","crossOrigin","src","onload","engine","createTexture2D","data","width","height","flipY","set","onerror"],"mappings":";;;;;;;;;;;;;;;AAAA,SAGEA,UAHF,QAUO,qBAVP;AAWA,SAASC,MAAT,EAAiBC,UAAjB,QAAmC,WAAnC;AACA,SAASC,YAAT,QAA6B,SAA7B;AAGA,WAAaC,SAAb,WADCF,UAAU,EACX,UACGD,MAAM,CAACE,YAAD,CADT,UAIGF,MAAM,CAACD,UAAU,CAACK,YAAZ,CAJT;AAAA;AAAA;;AAAA;;AAAA;;AAAA,SAOUC,MAPV;AAAA,SAQUC,MARV,GAQmB,KARnB;AAAA,SASUC,OATV;AAAA;;AAAA;AAAA;AAAA,8BAWmBF,MAXnB,EAW8E;AAC1E,WAAKA,MAAL,GAAcA,MAAd;AACD;AAbH;AAAA;AAAA,+BAeoB;AAChB,aAAO,KAAKC,MAAZ;AACD,KAjBH,CAmBE;AACA;AACA;AACA;AACA;;AAv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AAd;AACA,qBAAKC,OAAL,GAAe,KAAKa,MAAL,CAAYC,eAAZ,CAA4B,KAAKhB,MAAjC,CAAf;AAvDN,iDAwDa,KAAKE,OAxDlB;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["import {\n IClearOptions,\n IConfigService,\n IDENTIFIER,\n IRendererService,\n IShaderModuleService,\n ISystem,\n ITexture2D,\n ITexture2DInitializationOptions,\n IView,\n} from '@antv/g-webgpu-core';\nimport { inject, injectable } from 'inversify';\nimport { TextureCache } from './Cache';\n\n@injectable()\nexport class Texture2D {\n @inject(TextureCache)\n private readonly textureCache: TextureCache;\n\n @inject(IDENTIFIER.RenderEngine)\n private readonly engine: IRendererService;\n\n private config: ITexture2DInitializationOptions & { url: string };\n private loaded = false;\n private texture: ITexture2D;\n\n public setConfig(config: ITexture2DInitializationOptions & { url: string }) {\n this.config = config;\n }\n\n public isLoaded() {\n return this.loaded;\n }\n\n // public update(config: ITexture2DInitializationOptions) {\n // if (this.loaded && this.texture) {\n // const t = this.texture.get();\n // }\n // }\n\n public async load() {\n if (this.config.url) {\n return new Promise<ITexture2D>((resolve, reject) => {\n const existed = this.textureCache.get(this.config.url);\n if (existed) {\n resolve(existed);\n } else {\n const image = new Image();\n image.crossOrigin = 'Anonymous';\n image.src = this.config.url;\n image.onload = () => {\n const texture = this.engine.createTexture2D({\n ...this.config,\n data: image,\n width: image.width,\n height: image.height,\n flipY: true,\n });\n this.textureCache.set(this.config.url, texture);\n this.texture = texture;\n this.loaded = true;\n resolve(texture);\n };\n image.onerror = () => {\n reject();\n };\n }\n });\n } else {\n this.loaded = true;\n this.texture = this.engine.createTexture2D(this.config);\n return this.texture;\n }\n }\n}\n"],"file":"Texture2D.js"}
@@ -1 +0,0 @@
1
- export declare function createCanvas(): HTMLCanvasElement;
@@ -1,8 +0,0 @@
1
- export function createCanvas() {
2
- if (typeof document !== 'undefined') {
3
- return document.createElement('canvas');
4
- } else {
5
- throw new Error('Cannot create a canvas in this context');
6
- }
7
- }
8
- //# sourceMappingURL=canvas.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/canvas.ts"],"names":["createCanvas","document","createElement","Error"],"mappings":"AAAA,OAAO,SAASA,YAAT,GAAwB;AAC7B,MAAI,OAAOC,QAAP,KAAoB,WAAxB,EAAqC;AACnC,WAAOA,QAAQ,CAACC,aAAT,CAAuB,QAAvB,CAAP;AACD,GAFD,MAEO;AACL,UAAM,IAAIC,KAAJ,CAAU,wCAAV,CAAN;AACD;AACF","sourcesContent":["export function createCanvas() {\n if (typeof document !== 'undefined') {\n return document.createElement('canvas');\n } else {\n throw new Error('Cannot create a canvas in this context');\n }\n}\n"],"file":"canvas.js"}
@@ -1,2 +0,0 @@
1
- declare const _default: (value: any) => value is any[];
2
- export default _default;
@@ -1,5 +0,0 @@
1
- import isType from './is-type';
2
- export default (function (value) {
3
- return Array.isArray ? Array.isArray(value) : isType(value, 'Array');
4
- });
5
- //# sourceMappingURL=is-array.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/is-array.ts"],"names":["isType","value","Array","isArray"],"mappings":"AAAA,OAAOA,MAAP,MAAmB,WAAnB;AAEA,gBAAe,UAACC,KAAD,EAAgC;AAC7C,SAAOC,KAAK,CAACC,OAAN,GAAgBD,KAAK,CAACC,OAAN,CAAcF,KAAd,CAAhB,GAAuCD,MAAM,CAACC,KAAD,EAAQ,OAAR,CAApD;AACD,CAFD","sourcesContent":["import isType from './is-type';\n\nexport default (value: any): value is any[] => {\n return Array.isArray ? Array.isArray(value) : isType(value, 'Array');\n}\n\n"],"file":"is-array.js"}
@@ -1 +0,0 @@
1
- export declare function isNumber(value: any): boolean;
@@ -1,4 +0,0 @@
1
- export function isNumber(value) {
2
- return typeof value === 'number';
3
- }
4
- //# sourceMappingURL=is-number.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/is-number.ts"],"names":["isNumber","value"],"mappings":"AAAA,OAAO,SAASA,QAAT,CAAkBC,KAAlB,EAA8B;AACnC,SAAO,OAAOA,KAAP,KAAiB,QAAxB;AACD","sourcesContent":["export function isNumber(value: any) {\n return typeof value === 'number';\n}\n "],"file":"is-number.js"}
@@ -1,2 +0,0 @@
1
- declare const isType: (value: any, type: string) => boolean;
2
- export default isType;
@@ -1,8 +0,0 @@
1
- var toString = {}.toString;
2
-
3
- var isType = function isType(value, type) {
4
- return toString.call(value) === '[object ' + type + ']';
5
- };
6
-
7
- export default isType;
8
- //# sourceMappingURL=is-type.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/is-type.ts"],"names":["toString","isType","value","type","call"],"mappings":"AAAA,IAAMA,QAAQ,GAAG,GAAGA,QAApB;;AAEA,IAAMC,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD,EAAaC,IAAb;AAAA,SAAuCH,QAAQ,CAACI,IAAT,CAAcF,KAAd,MAAyB,aAAaC,IAAb,GAAoB,GAApF;AAAA,CAAf;;AAEA,eAAeF,MAAf","sourcesContent":["const toString = {}.toString;\n\nconst isType = (value: any, type: string): boolean => toString.call(value) === '[object ' + type + ']';\n\nexport default isType;"],"file":"is-type.js"}
@@ -1,27 +0,0 @@
1
- /**
2
- * The base implementation of `_.isTypedArray` without Node.js optimizations.
3
- *
4
- * @private
5
- * @param {*} value The value to check.
6
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
7
- */
8
- declare function baseIsTypedArray(value: any): boolean;
9
- /**
10
- * Checks if `value` is classified as a typed array.
11
- *
12
- * @static
13
- * @memberOf _
14
- * @since 3.0.0
15
- * @category Lang
16
- * @param {*} value The value to check.
17
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
18
- * @example
19
- *
20
- * _.isTypedArray(new Uint8Array);
21
- * // => true
22
- *
23
- * _.isTypedArray([]);
24
- * // => false
25
- */
26
- export declare const isTypedArray: typeof baseIsTypedArray;
27
- export {};