lecodes-cli 0.1.5 → 0.1.7

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 (81) hide show
  1. package/dist/index.js +300 -149
  2. package/package.json +5 -3
  3. package/runtime/sdk/animate/animate.ts +238 -0
  4. package/runtime/sdk/animate/bezier.ts +138 -0
  5. package/runtime/sdk/animate/easings.ts +126 -0
  6. package/runtime/sdk/core/color.ts +66 -0
  7. package/runtime/sdk/core/events.ts +38 -0
  8. package/runtime/sdk/core/registry.ts +23 -0
  9. package/runtime/sdk/g2/Camera2D.ts +73 -0
  10. package/runtime/sdk/g2/Node2D.ts +104 -0
  11. package/runtime/sdk/g2/Scene2D.ts +73 -0
  12. package/runtime/sdk/g2/Sprite.ts +164 -0
  13. package/runtime/sdk/g2/Texture2D.ts +37 -0
  14. package/runtime/sdk/g2/Tilemap.ts +41 -0
  15. package/runtime/sdk/g2/loop.ts +22 -0
  16. package/runtime/sdk/gl/Body.ts +101 -0
  17. package/runtime/sdk/gl/Camera.ts +40 -0
  18. package/runtime/sdk/gl/Geometry.ts +218 -0
  19. package/runtime/sdk/gl/Light.ts +37 -0
  20. package/runtime/sdk/gl/Material.ts +124 -0
  21. package/runtime/sdk/gl/Mesh.ts +123 -0
  22. package/runtime/sdk/gl/Node.ts +307 -0
  23. package/runtime/sdk/gl/Noise.ts +30 -0
  24. package/runtime/sdk/gl/Particles.ts +185 -0
  25. package/runtime/sdk/gl/Plane.ts +53 -0
  26. package/runtime/sdk/gl/Ray.ts +16 -0
  27. package/runtime/sdk/gl/Scene.ts +179 -0
  28. package/runtime/sdk/gl/Texture.ts +35 -0
  29. package/runtime/sdk/gl/controls.ts +95 -0
  30. package/runtime/sdk/gl/state.ts +6 -0
  31. package/runtime/sdk/gl/touch.ts +56 -0
  32. package/runtime/sdk/inject.ts +72 -0
  33. package/runtime/sdk/math/Mathf.ts +118 -0
  34. package/runtime/sdk/math/mat4.ts +278 -0
  35. package/runtime/sdk/math/quat.ts +232 -0
  36. package/runtime/sdk/math/vec.ts +255 -0
  37. package/runtime/sdk/plugins/qr.ts +36 -0
  38. package/runtime/sdk/runtime/device.ts +33 -0
  39. package/runtime/sdk/runtime/fetch.ts +71 -0
  40. package/runtime/sdk/runtime/files.ts +23 -0
  41. package/runtime/sdk/runtime/input.ts +12 -0
  42. package/runtime/sdk/runtime/media.ts +111 -0
  43. package/runtime/sdk/runtime/misc.ts +12 -0
  44. package/runtime/sdk/runtime/net.ts +36 -0
  45. package/runtime/sdk/runtime/storage.ts +13 -0
  46. package/runtime/sdk/runtime/touch.ts +44 -0
  47. package/runtime/sdk/ui/UI.ts +19 -0
  48. package/runtime/sdk/ui/UIButton.ts +84 -0
  49. package/runtime/sdk/ui/UIContainer.ts +100 -0
  50. package/runtime/sdk/ui/UIImage.ts +68 -0
  51. package/runtime/sdk/ui/UIInput.ts +78 -0
  52. package/runtime/sdk/ui/UINode.ts +342 -0
  53. package/runtime/sdk/ui/UIScreen.ts +122 -0
  54. package/runtime/sdk/ui/UIScrollable.ts +70 -0
  55. package/runtime/sdk/ui/UISpacer.ts +14 -0
  56. package/runtime/sdk/ui/UIText.ts +40 -0
  57. package/runtime/sdk/ui/UIVideo.ts +38 -0
  58. package/runtime/sdk/ui/UIVirtualizedList.ts +222 -0
  59. package/runtime/sdk/ui/UIWidget.ts +97 -0
  60. package/runtime/sdk/ui/fonts.ts +10 -0
  61. package/runtime/sdk/ui/router.ts +73 -0
  62. package/runtime/gl-matrix/common.js +0 -54
  63. package/runtime/gl-matrix/header.js +0 -12
  64. package/runtime/gl-matrix/index.js +0 -11
  65. package/runtime/gl-matrix/mat2.js +0 -425
  66. package/runtime/gl-matrix/mat2d.js +0 -476
  67. package/runtime/gl-matrix/mat3.js +0 -765
  68. package/runtime/gl-matrix/mat4.js +0 -1947
  69. package/runtime/gl-matrix/quat.js +0 -737
  70. package/runtime/gl-matrix/quat2.js +0 -822
  71. package/runtime/gl-matrix/vec2.js +0 -620
  72. package/runtime/gl-matrix/vec3.js +0 -791
  73. package/runtime/gl-matrix/vec4.js +0 -652
  74. package/runtime/worker/animate.js +0 -304
  75. package/runtime/worker/chunk-4ZN32GYS.js +0 -34
  76. package/runtime/worker/chunk-G5ZA3LKB.js +0 -52
  77. package/runtime/worker/chunk-MI3UXE5H.js +0 -1395
  78. package/runtime/worker/creator.js +0 -930
  79. package/runtime/worker/globals.js +0 -208
  80. package/runtime/worker/ui.js +0 -763
  81. package/runtime/worker/utils.js +0 -16
@@ -1,304 +0,0 @@
1
- // ../worker/src/animate/bezier.ts
2
- var a = (a1, a2) => 1 - 3 * a2 + 3 * a1;
3
- var b = (a1, a2) => 3 * a2 - 6 * a1;
4
- var c = (a1) => 3 * a1;
5
- var calcBezier = (t, a1, a2) => ((a(a1, a2) * t + b(a1, a2)) * t + c(a1)) * t;
6
- var getSlope = (t, a1, a2) => 3 * a(a1, a2) * t * t + 2 * b(a1, a2) * t + c(a1);
7
- var subdivisionPrecision = 1e-7;
8
- var subdivisionMaxIterations = 10;
9
- function binarySubdivide(aX, aA, aB, mX1, mX2) {
10
- let currentX;
11
- let currentT;
12
- let i = 0;
13
- do {
14
- currentT = aA + (aB - aA) / 2;
15
- currentX = calcBezier(currentT, mX1, mX2) - aX;
16
- if (currentX > 0) {
17
- aB = currentT;
18
- } else {
19
- aA = currentT;
20
- }
21
- } while (Math.abs(currentX) > subdivisionPrecision && ++i < subdivisionMaxIterations);
22
- return currentT;
23
- }
24
- var newtonIterations = 8;
25
- var newtonMinSlope = 1e-3;
26
- function newtonRaphsonIterate(aX, aGuessT, mX1, mX2) {
27
- for (let i = 0; i < newtonIterations; ++i) {
28
- const currentSlope = getSlope(aGuessT, mX1, mX2);
29
- if (currentSlope === 0) {
30
- return aGuessT;
31
- }
32
- const currentX = calcBezier(aGuessT, mX1, mX2) - aX;
33
- aGuessT -= currentX / currentSlope;
34
- }
35
- return aGuessT;
36
- }
37
- var kSplineTableSize = 11;
38
- var kSampleStepSize = 1 / (kSplineTableSize - 1);
39
- var linear = (p) => p;
40
- function cubicBezier(mX1, mY1, mX2, mY2) {
41
- if (mX1 === mY1 && mX2 === mY2) return linear;
42
- const sampleValues = new Float32Array(kSplineTableSize);
43
- for (let i = 0; i < kSplineTableSize; ++i) {
44
- sampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2);
45
- }
46
- function getTForX(aX) {
47
- let intervalStart = 0;
48
- let currentSample = 1;
49
- const lastSample = kSplineTableSize - 1;
50
- for (; currentSample !== lastSample && sampleValues[currentSample] <= aX; ++currentSample) {
51
- intervalStart += kSampleStepSize;
52
- }
53
- --currentSample;
54
- const dist = (aX - sampleValues[currentSample]) / (sampleValues[currentSample + 1] - sampleValues[currentSample]);
55
- const guessForT = intervalStart + dist * kSampleStepSize;
56
- const initialSlope = getSlope(guessForT, mX1, mX2);
57
- if (initialSlope >= newtonMinSlope) {
58
- return newtonRaphsonIterate(aX, guessForT, mX1, mX2);
59
- } else if (initialSlope === 0) {
60
- return guessForT;
61
- } else {
62
- return binarySubdivide(
63
- aX,
64
- intervalStart,
65
- intervalStart + kSampleStepSize,
66
- mX1,
67
- mX2
68
- );
69
- }
70
- }
71
- return (t) => t === 0 || t === 1 ? t : calcBezier(getTForX(t), mY1, mY2);
72
- }
73
-
74
- // ../worker/src/animate/easings.ts
75
- var BOUNCE_FIRST_THRESHOLD = 4 / 11;
76
- var BOUNCE_SECOND_THRESHOLD = 8 / 11;
77
- var BOUNCE_THIRD_THRESHOLD = 9 / 10;
78
- var ca = 4356 / 361;
79
- var cb = 35442 / 1805;
80
- var cc = 16061 / 1805;
81
- function easeIn(p) {
82
- return p * p;
83
- }
84
- function easeOut(p) {
85
- return 1 - easeIn(1 - p);
86
- }
87
- function easeInOut(p) {
88
- return p <= 0.5 ? easeIn(2 * p) / 2 : (2 - easeIn(2 * (1 - p))) / 2;
89
- }
90
-
91
- // ../worker/src/animate/animate.ts
92
- var animate = (options) => {
93
- let onRawUpdate;
94
- if (typeof options.to === "number") {
95
- const { onUpdate, from, to } = options;
96
- onRawUpdate = (t) => onUpdate(from + (to - from) * t);
97
- } else if (options.to === "string") {
98
- const { onUpdate, from, to } = options;
99
- onRawUpdate = (t) => onUpdate(from);
100
- } else if (options.to.length === 2) {
101
- const { onUpdate, from, to } = options;
102
- const tempVec = new Float32Array(3);
103
- onRawUpdate = (t) => onUpdate(lerp2(tempVec, from, to, t));
104
- } else if (options.to.length === 3) {
105
- const { onUpdate, from, to } = options;
106
- const tempVec = new Float32Array(3);
107
- onRawUpdate = (t) => onUpdate(lerp(tempVec, from, to, t));
108
- } else if (options.to.length === 4) {
109
- const { onUpdate, from, to } = options;
110
- const tempQuat = new Float32Array(4);
111
- onRawUpdate = (t) => onUpdate(slerp(tempQuat, from, to, t));
112
- } else {
113
- onRawUpdate = () => {
114
- };
115
- }
116
- const animationId = _creatorUtils.animate((val) => {
117
- const _val = options.easing ? options.easing(val) : val;
118
- onRawUpdate(_val);
119
- if (val === 1 && options.onComplete) {
120
- options.onComplete();
121
- }
122
- }, options.duration);
123
- return animationId;
124
- };
125
- var stopAnimation = (id) => _creatorUtils.stopAnimation(id);
126
- var pauseAnimation = (id) => _creatorUtils.pauseAnimation(id);
127
- var resumeAnimation = (id) => _creatorUtils.resumeAnimation(id);
128
- var animateMat4 = (options) => {
129
- const fromPosition = new Float32Array(3);
130
- const fromQuaternion = new Float32Array(4);
131
- const fromScale = new Float32Array(3);
132
- const toPosition = new Float32Array(3);
133
- const toQuaternion = new Float32Array(4);
134
- const toScale = new Float32Array(3);
135
- decompose(fromQuaternion, fromPosition, fromScale, options.from);
136
- decompose(toQuaternion, toPosition, toScale, options.to);
137
- const tempPosition = new Float32Array(3);
138
- const tempQuat = new Float32Array(4);
139
- const tempScale = new Float32Array(3);
140
- const tempMat = new Float32Array(16);
141
- const onUpdate = options.onUpdate;
142
- const onRawUpdate = (t) => {
143
- lerp(tempPosition, fromPosition, toPosition, t);
144
- slerp(tempQuat, fromQuaternion, toQuaternion, t);
145
- lerp(tempScale, fromScale, toScale, t);
146
- onUpdate(fromRotationTranslationScale(tempMat, tempQuat, tempPosition, tempScale));
147
- };
148
- const animationId = _creatorUtils.animate((val) => {
149
- const _val = options.easing ? options.easing(val) : val;
150
- onRawUpdate(_val);
151
- if (val === 1 && options.onComplete) {
152
- options.onComplete();
153
- }
154
- }, options.duration);
155
- return animationId;
156
- };
157
- var EPSILON = 1e-6;
158
- function slerp(out, a2, b2, t) {
159
- const ax = a2[0], ay = a2[1], az = a2[2], aw = a2[3];
160
- let bx = b2[0], by = b2[1], bz = b2[2], bw = b2[3];
161
- let omega, cosom, sinom, scale0, scale1;
162
- cosom = ax * bx + ay * by + az * bz + aw * bw;
163
- if (cosom < 0) {
164
- cosom = -cosom;
165
- bx = -bx;
166
- by = -by;
167
- bz = -bz;
168
- bw = -bw;
169
- }
170
- if (1 - cosom > EPSILON) {
171
- omega = Math.acos(cosom);
172
- sinom = Math.sin(omega);
173
- scale0 = Math.sin((1 - t) * omega) / sinom;
174
- scale1 = Math.sin(t * omega) / sinom;
175
- } else {
176
- scale0 = 1 - t;
177
- scale1 = t;
178
- }
179
- out[0] = scale0 * ax + scale1 * bx;
180
- out[1] = scale0 * ay + scale1 * by;
181
- out[2] = scale0 * az + scale1 * bz;
182
- out[3] = scale0 * aw + scale1 * bw;
183
- return out;
184
- }
185
- function lerp(out, a2, b2, t) {
186
- const ax = a2[0];
187
- const ay = a2[1];
188
- const az = a2[2];
189
- out[0] = ax + t * (b2[0] - ax);
190
- out[1] = ay + t * (b2[1] - ay);
191
- out[2] = az + t * (b2[2] - az);
192
- return out;
193
- }
194
- function lerp2(out, a2, b2, t) {
195
- const ax = a2[0];
196
- const ay = a2[1];
197
- const az = a2[2];
198
- out[0] = ax + t * (b2[0] - ax);
199
- out[1] = ay + t * (b2[1] - ay);
200
- return out;
201
- }
202
- function fromRotationTranslationScale(out, q, v, s) {
203
- const x = q[0], y = q[1], z = q[2], w = q[3];
204
- const x2 = x + x;
205
- const y2 = y + y;
206
- const z2 = z + z;
207
- const xx = x * x2;
208
- const xy = x * y2;
209
- const xz = x * z2;
210
- const yy = y * y2;
211
- const yz = y * z2;
212
- const zz = z * z2;
213
- const wx = w * x2;
214
- const wy = w * y2;
215
- const wz = w * z2;
216
- const sx = s[0];
217
- const sy = s[1];
218
- const sz = s[2];
219
- out[0] = (1 - (yy + zz)) * sx;
220
- out[1] = (xy + wz) * sx;
221
- out[2] = (xz - wy) * sx;
222
- out[3] = 0;
223
- out[4] = (xy - wz) * sy;
224
- out[5] = (1 - (xx + zz)) * sy;
225
- out[6] = (yz + wx) * sy;
226
- out[7] = 0;
227
- out[8] = (xz + wy) * sz;
228
- out[9] = (yz - wx) * sz;
229
- out[10] = (1 - (xx + yy)) * sz;
230
- out[11] = 0;
231
- out[12] = v[0];
232
- out[13] = v[1];
233
- out[14] = v[2];
234
- out[15] = 1;
235
- return out;
236
- }
237
- function decompose(out_r, out_t, out_s, mat) {
238
- out_t[0] = mat[12];
239
- out_t[1] = mat[13];
240
- out_t[2] = mat[14];
241
- const m11 = mat[0];
242
- const m12 = mat[1];
243
- const m13 = mat[2];
244
- const m21 = mat[4];
245
- const m22 = mat[5];
246
- const m23 = mat[6];
247
- const m31 = mat[8];
248
- const m32 = mat[9];
249
- const m33 = mat[10];
250
- out_s[0] = Math.hypot(m11, m12, m13);
251
- out_s[1] = Math.hypot(m21, m22, m23);
252
- out_s[2] = Math.hypot(m31, m32, m33);
253
- const is1 = 1 / out_s[0];
254
- const is2 = 1 / out_s[1];
255
- const is3 = 1 / out_s[2];
256
- const sm11 = m11 * is1;
257
- const sm12 = m12 * is2;
258
- const sm13 = m13 * is3;
259
- const sm21 = m21 * is1;
260
- const sm22 = m22 * is2;
261
- const sm23 = m23 * is3;
262
- const sm31 = m31 * is1;
263
- const sm32 = m32 * is2;
264
- const sm33 = m33 * is3;
265
- const trace = sm11 + sm22 + sm33;
266
- let S = 0;
267
- if (trace > 0) {
268
- S = Math.sqrt(trace + 1) * 2;
269
- out_r[3] = 0.25 * S;
270
- out_r[0] = (sm23 - sm32) / S;
271
- out_r[1] = (sm31 - sm13) / S;
272
- out_r[2] = (sm12 - sm21) / S;
273
- } else if (sm11 > sm22 && sm11 > sm33) {
274
- S = Math.sqrt(1 + sm11 - sm22 - sm33) * 2;
275
- out_r[3] = (sm23 - sm32) / S;
276
- out_r[0] = 0.25 * S;
277
- out_r[1] = (sm12 + sm21) / S;
278
- out_r[2] = (sm31 + sm13) / S;
279
- } else if (sm22 > sm33) {
280
- S = Math.sqrt(1 + sm22 - sm11 - sm33) * 2;
281
- out_r[3] = (sm31 - sm13) / S;
282
- out_r[0] = (sm12 + sm21) / S;
283
- out_r[1] = 0.25 * S;
284
- out_r[2] = (sm23 + sm32) / S;
285
- } else {
286
- S = Math.sqrt(1 + sm33 - sm11 - sm22) * 2;
287
- out_r[3] = (sm12 - sm21) / S;
288
- out_r[0] = (sm31 + sm13) / S;
289
- out_r[1] = (sm23 + sm32) / S;
290
- out_r[2] = 0.25 * S;
291
- }
292
- return out_r;
293
- }
294
- export {
295
- animate,
296
- animateMat4,
297
- cubicBezier,
298
- easeIn,
299
- easeInOut,
300
- easeOut,
301
- pauseAnimation,
302
- resumeAnimation,
303
- stopAnimation
304
- };
@@ -1,34 +0,0 @@
1
- // ../worker/src/TouchEvent.ts
2
- var ClickEvent = class {
3
- type = "click";
4
- pointerId;
5
- clientX;
6
- clientY;
7
- target;
8
- constructor(clientX, clientY, pointerId) {
9
- this.pointerId = pointerId;
10
- this.clientX = clientX;
11
- this.clientY = clientY;
12
- }
13
- };
14
- var TouchStartEvent = class {
15
- type = "touchstart";
16
- pointerId;
17
- clientX;
18
- clientY;
19
- target;
20
- _trackHandler;
21
- constructor(clientX, clientY, pointerId) {
22
- this.pointerId = pointerId;
23
- this.clientX = clientX;
24
- this.clientY = clientY;
25
- }
26
- track(e) {
27
- this._trackHandler = e;
28
- }
29
- };
30
-
31
- export {
32
- ClickEvent,
33
- TouchStartEvent
34
- };
@@ -1,52 +0,0 @@
1
- // ../worker/src/utils/QRScanner.ts
2
- var QRScanner = class {
3
- _onData;
4
- constructor(onData) {
5
- this._onData = onData;
6
- }
7
- async open() {
8
- await new Promise((res, rej) => {
9
- _creator.requestCamera(res, rej);
10
- });
11
- await new Promise((res, rej) => {
12
- _creatorUtils.openScanner(res, rej, this._onData);
13
- });
14
- }
15
- close() {
16
- _creatorUtils.closeScanner();
17
- }
18
- };
19
-
20
- // ../worker/src/utils/CameraViewer.ts
21
- var CameraViewer = class {
22
- static async open(facingMode) {
23
- await new Promise((res, rej) => {
24
- _creator.requestCamera(res, rej);
25
- });
26
- await new Promise((res, rej) => {
27
- _creatorUtils.cameraOpen(facingMode ?? "back", res, rej);
28
- });
29
- }
30
- static setFacingMode(facingMode) {
31
- _creatorUtils.cameraSetFacingMode(facingMode);
32
- }
33
- static takePhoto() {
34
- return new Promise((res, rej) => {
35
- _creatorUtils.cameraTakePhoto((bufferId, name, size) => {
36
- res(new File(bufferId, name, size));
37
- }, rej);
38
- });
39
- }
40
- static close() {
41
- _creatorUtils.cameraClose();
42
- }
43
- };
44
-
45
- // ../worker/src/utils.ts
46
- var inputKey = (keyCode) => _creatorUtils.inputKey(keyCode);
47
-
48
- export {
49
- QRScanner,
50
- CameraViewer,
51
- inputKey
52
- };