revas 1.0.3 → 2.0.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 (84) hide show
  1. package/README.md +61 -1
  2. package/dist/chunk-JPUKLNW3.js +1710 -0
  3. package/dist/chunk-JPUKLNW3.js.map +1 -0
  4. package/dist/revas-common.cjs +1768 -0
  5. package/dist/revas-common.cjs.map +1 -0
  6. package/dist/revas-common.d.cts +363 -0
  7. package/dist/revas-common.d.ts +363 -0
  8. package/dist/revas-common.js +3 -0
  9. package/dist/revas-common.js.map +1 -0
  10. package/dist/revas.cjs +1881 -0
  11. package/dist/revas.cjs.map +1 -0
  12. package/dist/revas.d.cts +13 -0
  13. package/dist/revas.d.ts +13 -0
  14. package/dist/revas.js +108 -1978
  15. package/dist/revas.js.map +1 -1
  16. package/package.json +56 -46
  17. package/common.d.ts +0 -1
  18. package/common.js +0 -1
  19. package/dist/revas.common.js +0 -1872
  20. package/dist/revas.common.js.map +0 -1
  21. package/dist/revas.es.js +0 -1943
  22. package/dist/revas.es.js.map +0 -1
  23. package/dist/types/develop/App.d.ts +0 -8
  24. package/dist/types/develop/Intro/About.d.ts +0 -2
  25. package/dist/types/develop/Intro/Animation.d.ts +0 -2
  26. package/dist/types/develop/Intro/Component.d.ts +0 -2
  27. package/dist/types/develop/Intro/Entry.d.ts +0 -6
  28. package/dist/types/develop/Intro/Gesture.d.ts +0 -2
  29. package/dist/types/develop/Intro/Interactable.d.ts +0 -10
  30. package/dist/types/develop/Intro/Navbar.d.ts +0 -6
  31. package/dist/types/develop/Intro/Panel.d.ts +0 -14
  32. package/dist/types/develop/Intro/Style.d.ts +0 -2
  33. package/dist/types/develop/Intro/index.d.ts +0 -2
  34. package/dist/types/develop/Music/Player.d.ts +0 -79
  35. package/dist/types/develop/Music/data.d.ts +0 -8
  36. package/dist/types/develop/Music/index.d.ts +0 -23
  37. package/dist/types/develop/Music/styles.d.ts +0 -19
  38. package/dist/types/develop/Timeline/data.d.ts +0 -5
  39. package/dist/types/develop/Timeline/index.d.ts +0 -11
  40. package/dist/types/develop/common/back.d.ts +0 -2
  41. package/dist/types/develop/common/simple-router.d.ts +0 -44
  42. package/dist/types/develop/serviceWorker.d.ts +0 -7
  43. package/dist/types/index.d.ts +0 -1
  44. package/dist/types/revas/common.d.ts +0 -24
  45. package/dist/types/revas/components/Context.d.ts +0 -12
  46. package/dist/types/revas/components/Image.d.ts +0 -20
  47. package/dist/types/revas/components/LinearGradient.d.ts +0 -38
  48. package/dist/types/revas/components/ListView.d.ts +0 -22
  49. package/dist/types/revas/components/ScrollView.d.ts +0 -43
  50. package/dist/types/revas/components/Text.d.ts +0 -16
  51. package/dist/types/revas/components/Touchable.d.ts +0 -34
  52. package/dist/types/revas/components/View.d.ts +0 -3
  53. package/dist/types/revas/components/common/Scroller.d.ts +0 -35
  54. package/dist/types/revas/components/common/drawImage.d.ts +0 -3
  55. package/dist/types/revas/components/common/drawText.d.ts +0 -17
  56. package/dist/types/revas/components/common/imageLoader.d.ts +0 -2
  57. package/dist/types/revas/core/Animated.d.ts +0 -59
  58. package/dist/types/revas/core/Canvas.d.ts +0 -17
  59. package/dist/types/revas/core/Container.d.ts +0 -18
  60. package/dist/types/revas/core/Node.d.ts +0 -46
  61. package/dist/types/revas/core/css-layout/index.d.ts +0 -9
  62. package/dist/types/revas/core/draw.d.ts +0 -4
  63. package/dist/types/revas/core/offscreen.d.ts +0 -11
  64. package/dist/types/revas/core/reconciler.d.ts +0 -5
  65. package/dist/types/revas/core/touch.d.ts +0 -3
  66. package/dist/types/revas/core/utils.d.ts +0 -22
  67. package/dist/types/revas/core/yoga-layout/index.d.ts +0 -3
  68. package/dist/types/revas/core/yoga-layout/init.d.ts +0 -3
  69. package/dist/types/revas/core/yoga-layout/style.d.ts +0 -3
  70. package/dist/types/revas/index.d.ts +0 -2
  71. package/dist/types/revas/web/index.d.ts +0 -1
  72. package/dist/types/revas/web/render.d.ts +0 -7
  73. package/doc/API.md +0 -241
  74. package/doc/README-zh.md +0 -266
  75. package/public/favicon.ico +0 -0
  76. package/public/index.html +0 -64
  77. package/public/logo192.png +0 -0
  78. package/public/logo512.png +0 -0
  79. package/public/manifest.json +0 -25
  80. package/public/robots.txt +0 -2
  81. package/public/stats.min.js +0 -5
  82. package/public/touch-emulator.js +0 -363
  83. package/rollup.config.ts +0 -44
  84. package/tsconfig.json +0 -30
package/dist/revas.cjs ADDED
@@ -0,0 +1,1881 @@
1
+ 'use strict';
2
+
3
+ var React6 = require('react');
4
+ var bezier = require('bezier-easing');
5
+ var ReactReconciler = require('react-reconciler');
6
+ var constants = require('react-reconciler/constants');
7
+ var Yoga = require('yoga-layout');
8
+
9
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
+
11
+ function _interopNamespace(e) {
12
+ if (e && e.__esModule) return e;
13
+ var n = Object.create(null);
14
+ if (e) {
15
+ Object.keys(e).forEach(function (k) {
16
+ if (k !== 'default') {
17
+ var d = Object.getOwnPropertyDescriptor(e, k);
18
+ Object.defineProperty(n, k, d.get ? d : {
19
+ enumerable: true,
20
+ get: function () { return e[k]; }
21
+ });
22
+ }
23
+ });
24
+ }
25
+ n.default = e;
26
+ return Object.freeze(n);
27
+ }
28
+
29
+ var React6__namespace = /*#__PURE__*/_interopNamespace(React6);
30
+ var bezier__default = /*#__PURE__*/_interopDefault(bezier);
31
+ var ReactReconciler__default = /*#__PURE__*/_interopDefault(ReactReconciler);
32
+ var Yoga__default = /*#__PURE__*/_interopDefault(Yoga);
33
+
34
+ // src/revas/components/View.ts
35
+ function View(props) {
36
+ return React6__namespace.createElement("View", props);
37
+ }
38
+
39
+ // src/revas/core/utils.ts
40
+ function noop() {
41
+ }
42
+ var EMPTY_OBJECT = Object.freeze({});
43
+ var EMPTY_ARRAY = Object.freeze([]);
44
+ function flatten(array) {
45
+ const flattend = [];
46
+ (function flat(array2) {
47
+ array2.forEach(function(el) {
48
+ if (Array.isArray(el)) {
49
+ flat(el);
50
+ } else {
51
+ flattend.push(el);
52
+ }
53
+ });
54
+ })(array);
55
+ return flattend;
56
+ }
57
+ var now = typeof performance === "object" && typeof performance.now === "function" ? () => performance.now() : () => Date.now();
58
+ function observeAnimatedValue(value, observer, defaultValue) {
59
+ if (value === void 0) {
60
+ return defaultValue;
61
+ }
62
+ if (value && value.getValue) {
63
+ return value.getValue(observer);
64
+ }
65
+ return value;
66
+ }
67
+ function applyAnimated(style, callback) {
68
+ if (style.animated) {
69
+ for (const key in style) {
70
+ style[key] = observeAnimatedValue(style[key], callback);
71
+ }
72
+ }
73
+ return style;
74
+ }
75
+ function getMergedStyleFromNode(node, callback) {
76
+ const {
77
+ props: { style = EMPTY_ARRAY }
78
+ } = node;
79
+ return applyAnimated(Object.assign({}, ...flatten([style])), callback);
80
+ }
81
+ function getFrameFromNode(node) {
82
+ const { frame } = node;
83
+ return frame;
84
+ }
85
+ function sortByZIndexAscending(a, b) {
86
+ const styleA = getMergedStyleFromNode(a);
87
+ const styleB = getMergedStyleFromNode(b);
88
+ return (styleA.zIndex || 0) - (styleB.zIndex || 0);
89
+ }
90
+ function clamp(n, min, max) {
91
+ return Math.min(Math.max(n, min), max);
92
+ }
93
+ var ASTRAL_RANGE = /\ud83c[\udffb-\udfff](?=\ud83c[\udffb-\udfff])|(?:[^\ud800-\udfff][\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0]?|[\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0]|\ud83c[\udffb-\udfff])?)*/g;
94
+ var WORD_RANGE = /\w+|\ud83c[\udffb-\udfff](?=\ud83c[\udffb-\udfff])|(?:[^\ud800-\udfff][\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0]?|[\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0]|\ud83c[\udffb-\udfff])?)*/g;
95
+ function getChars(str) {
96
+ return str.match(ASTRAL_RANGE) || EMPTY_ARRAY;
97
+ }
98
+ function getWords(str) {
99
+ return str.match(WORD_RANGE) || EMPTY_ARRAY;
100
+ }
101
+ function setShadow(canvas, color, x = 0, y = 0, blur = 0) {
102
+ if (color && (x || y || blur)) {
103
+ const { context: ctx } = canvas;
104
+ const { shadowBlur, shadowColor, shadowOffsetX, shadowOffsetY } = ctx;
105
+ ctx.shadowBlur = blur;
106
+ ctx.shadowColor = color;
107
+ ctx.shadowOffsetX = x;
108
+ ctx.shadowOffsetY = y;
109
+ return function resetShadow() {
110
+ ctx.shadowBlur = shadowBlur;
111
+ ctx.shadowColor = shadowColor;
112
+ ctx.shadowOffsetX = shadowOffsetX;
113
+ ctx.shadowOffsetY = shadowOffsetY;
114
+ };
115
+ }
116
+ return noop;
117
+ }
118
+ function pushOpacity(canvas, opacity) {
119
+ if (opacity !== null && opacity < 1 && opacity >= 0) {
120
+ const cachedOpacity = canvas.context.globalAlpha || 1;
121
+ canvas.context.globalAlpha = cachedOpacity * opacity;
122
+ return function popOpacity() {
123
+ canvas.context.globalAlpha = cachedOpacity;
124
+ };
125
+ }
126
+ return noop;
127
+ }
128
+ var adapter = {
129
+ createImage: () => new Image()
130
+ };
131
+
132
+ // src/revas/components/common/drawText.ts
133
+ var DEFAULT_MEASURE = [[], 0];
134
+ function measureLines(canvas, chars, boxWidth, numberOfLines) {
135
+ const lines = [];
136
+ let width = 0;
137
+ let text = "";
138
+ let cursor = -1;
139
+ function pushLine(charWidth = 0, char = "", force = false) {
140
+ if (force || text) {
141
+ lines.push({ width, text });
142
+ }
143
+ if (cursor < chars.length && numberOfLines > 0 && lines.length >= numberOfLines) {
144
+ const lastLine = lines[lines.length - 1];
145
+ lastLine.text = `${lastLine.text.slice(0, -2)}...`;
146
+ lastLine.width = canvas.context.measureText(lastLine.text).width;
147
+ cursor = chars.length + 1;
148
+ } else {
149
+ width = charWidth;
150
+ text = char.trim();
151
+ }
152
+ }
153
+ while (cursor++ <= chars.length) {
154
+ if (chars.length > cursor) {
155
+ const char = chars[cursor];
156
+ if (char === "\n") {
157
+ pushLine(0, "", true);
158
+ } else {
159
+ const charWidth = canvas.context.measureText(char).width;
160
+ if (charWidth + width > boxWidth) {
161
+ pushLine(charWidth, char);
162
+ } else {
163
+ width += charWidth;
164
+ text += char;
165
+ }
166
+ }
167
+ } else {
168
+ pushLine();
169
+ }
170
+ }
171
+ return lines;
172
+ }
173
+ function splitContent(content, wordBreak) {
174
+ switch (wordBreak) {
175
+ case "break-all":
176
+ return getChars(content);
177
+ case "keep-all":
178
+ return [content];
179
+ default:
180
+ return getWords(content);
181
+ }
182
+ }
183
+ function applyTextStyle(canvas, options) {
184
+ const { fontStyle, fontWeight, fontSize, fontFamily, textBaseline, color } = options.textStyle;
185
+ canvas.context.font = `${fontStyle} ${fontWeight} ${fontSize}px ${fontFamily}`;
186
+ canvas.context.fillStyle = color;
187
+ canvas.context.textBaseline = textBaseline;
188
+ }
189
+ function measureText(canvas, options) {
190
+ const lines = measureLines(
191
+ canvas,
192
+ splitContent(options.content, options.textStyle.wordBreak),
193
+ options.frame.width,
194
+ options.numberOfLines
195
+ );
196
+ return [lines, options.textStyle.lineHeight * lines.length];
197
+ }
198
+ function drawText(canvas, options, lines) {
199
+ const { textStyle: style, frame } = options;
200
+ const resetShadow = setShadow(
201
+ canvas,
202
+ style.textShadowColor,
203
+ style.textShadowOffsetX,
204
+ style.textShadowOffsetY,
205
+ style.textShadowBlur
206
+ );
207
+ for (let i = 0; i < lines.length; i++) {
208
+ const line = lines[i];
209
+ let { x } = frame;
210
+ switch (style.textAlign) {
211
+ case "center":
212
+ x = x + frame.width / 2 - line.width / 2;
213
+ break;
214
+ case "right":
215
+ x = x + frame.width - line.width;
216
+ break;
217
+ }
218
+ canvas.context.fillText(line.text, x, style.lineHeight * (i + 0.5) + frame.y);
219
+ }
220
+ resetShadow();
221
+ }
222
+
223
+ // src/revas/components/Text.ts
224
+ var Text = class extends React6__namespace.Component {
225
+ state = { height: 0 };
226
+ _measured = DEFAULT_MEASURE;
227
+ _drawed;
228
+ drawText = (canvas, node) => {
229
+ const content = getTextFromNode(node);
230
+ if (content) {
231
+ const options = {
232
+ numberOfLines: node.props.numberOfLines || 0,
233
+ textStyle: getTextStyleFromNode(node),
234
+ frame: getFrameFromNode(node),
235
+ content
236
+ };
237
+ applyTextStyle(canvas, options);
238
+ if (textPropsChanged(options, this._drawed)) {
239
+ this._measured = measureText(canvas, options);
240
+ this._drawed = options;
241
+ }
242
+ const [lines, height] = this._measured;
243
+ drawText(canvas, options, lines);
244
+ if (height !== this.state.height) {
245
+ Promise.resolve().then(() => {
246
+ if (this._drawed) {
247
+ this.setState({ height });
248
+ }
249
+ });
250
+ }
251
+ }
252
+ };
253
+ render() {
254
+ const { children, numberOfLines, ...others } = this.props;
255
+ return React6__namespace.createElement(
256
+ "View",
257
+ others,
258
+ React6__namespace.createElement("Text", {
259
+ content: children,
260
+ customDrawer: this.drawText,
261
+ textStyle: others.style,
262
+ style: this.state,
263
+ numberOfLines,
264
+ $ready: Boolean(this._drawed)
265
+ })
266
+ );
267
+ }
268
+ };
269
+ var TEXT_STYLES_LIST = [
270
+ "fontStyle",
271
+ "fontWeight",
272
+ "fontSize",
273
+ "fontFamily",
274
+ "textBaseline",
275
+ "wordBreak",
276
+ "lineHeight"
277
+ ];
278
+ var DEFAULT_TEXTSTYLE = {
279
+ fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue'",
280
+ fontWeight: "normal",
281
+ fontSize: 14,
282
+ color: "#000",
283
+ fontStyle: "normal",
284
+ textBaseline: "middle"
285
+ };
286
+ function textStyleChanged(left, right) {
287
+ for (let i = 0; i < TEXT_STYLES_LIST.length; i++) {
288
+ const item = TEXT_STYLES_LIST[i];
289
+ if (left[item] !== right[item]) {
290
+ return true;
291
+ }
292
+ }
293
+ return false;
294
+ }
295
+ function textPropsChanged(left, right) {
296
+ if (!right) {
297
+ return true;
298
+ }
299
+ if (left.content !== right.content) {
300
+ return true;
301
+ }
302
+ if (left.numberOfLines !== right.numberOfLines) {
303
+ return true;
304
+ }
305
+ if (left.frame.width !== right.frame.width) {
306
+ return true;
307
+ }
308
+ return textStyleChanged(left.textStyle, right.textStyle);
309
+ }
310
+ function getTextFromNode(node) {
311
+ const frame = getFrameFromNode(node);
312
+ if (frame.width > 0) {
313
+ const { content } = node.props;
314
+ if (typeof content === "string") {
315
+ return content;
316
+ } else if (Array.isArray(content)) {
317
+ return content.join("");
318
+ }
319
+ }
320
+ return "";
321
+ }
322
+ function getTextStyleFromNode(node) {
323
+ const style = Object.assign({}, DEFAULT_TEXTSTYLE, ...flatten([node.props.textStyle]));
324
+ style.lineHeight = style.lineHeight || style.fontSize * 1.1;
325
+ return applyAnimated(style);
326
+ }
327
+
328
+ // src/revas/components/common/imageLoader.ts
329
+ var CachedImage = class {
330
+ constructor(src) {
331
+ this.src = src;
332
+ if (!this.image) {
333
+ throw new Error("Revas: createImage must be initialized");
334
+ }
335
+ this.image.onload = this.onload;
336
+ this.image.onerror = this.onerror;
337
+ this.image.src = src;
338
+ }
339
+ image = adapter.createImage();
340
+ targets = [];
341
+ _ready = false;
342
+ get empty() {
343
+ return this.targets.length === 0;
344
+ }
345
+ onload = () => {
346
+ this._ready = true;
347
+ this.targets.forEach((target) => target(this.image));
348
+ };
349
+ onerror = () => {
350
+ };
351
+ add(target) {
352
+ if (this.targets.indexOf(target) < 0) {
353
+ this.targets.push(target);
354
+ if (this._ready) {
355
+ target(this.image);
356
+ }
357
+ }
358
+ }
359
+ remove(target) {
360
+ const index = this.targets.indexOf(target);
361
+ this.targets.splice(index, 1);
362
+ }
363
+ };
364
+ var cache = /* @__PURE__ */ new Map();
365
+ function get(src, target) {
366
+ if (!cache.has(src)) {
367
+ cache.set(src, new CachedImage(src));
368
+ }
369
+ const cached = cache.get(src);
370
+ target && cached.add(target);
371
+ return cached.image;
372
+ }
373
+ function remove(src, target) {
374
+ if (cache.has(src)) {
375
+ const cached = cache.get(src);
376
+ cached.remove(target);
377
+ if (cached.empty) {
378
+ cache.delete(src);
379
+ }
380
+ }
381
+ }
382
+
383
+ // src/revas/components/common/drawImage.ts
384
+ function drawImage(canvas, node, flags) {
385
+ const image = get(node.props.src);
386
+ if (image.height <= 0) {
387
+ return;
388
+ }
389
+ const frame = getFrameFromNode(node);
390
+ const { width, height, x, y } = frame;
391
+ if (width <= 0 || height <= 0) {
392
+ return;
393
+ }
394
+ const style = getMergedStyleFromNode(node);
395
+ const actualSize = {
396
+ width: image.width,
397
+ height: image.height
398
+ };
399
+ const focusPoint = style.focusPoint || {
400
+ x: actualSize.width * 0.5,
401
+ y: actualSize.height * 0.5
402
+ };
403
+ const hasClip = flags.hasRadius && !flags.hasClip;
404
+ if (hasClip) {
405
+ canvas.context.save();
406
+ canvas.context.clip();
407
+ }
408
+ if (style.resizeMode === "contain") {
409
+ const scale = Math.min(width / actualSize.width, height / actualSize.height) || 1;
410
+ const scaledSize = {
411
+ width: actualSize.width * scale,
412
+ height: actualSize.height * scale
413
+ };
414
+ const sw = Math.round(actualSize.width);
415
+ const sh = Math.round(actualSize.height);
416
+ const dw = Math.round(scaledSize.width);
417
+ const dh = Math.round(scaledSize.height);
418
+ const dx = Math.round((width - scaledSize.width) / 2 + x);
419
+ const dy = Math.round((height - scaledSize.height) / 2 + y);
420
+ canvas.context.drawImage(image, 0, 0, sw, sh, dx, dy, dw, dh);
421
+ } else {
422
+ const scale = Math.max(width / actualSize.width, height / actualSize.height) || 1;
423
+ const scaledSize = {
424
+ width: actualSize.width * scale,
425
+ height: actualSize.height * scale
426
+ };
427
+ const sx = Math.round(clamp(width * 0.5 - focusPoint.x * scale, width - scaledSize.width, 0)) * (-1 / scale);
428
+ const sy = Math.round(clamp(height * 0.5 - focusPoint.y * scale, height - scaledSize.height, 0)) * (-1 / scale);
429
+ const sw = Math.round(actualSize.width - sx * 2);
430
+ const sh = Math.round(actualSize.height - sy * 2);
431
+ const dw = Math.round(width);
432
+ const dh = Math.round(height);
433
+ const dx = Math.round(x);
434
+ const dy = Math.round(y);
435
+ canvas.context.drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh);
436
+ }
437
+ if (hasClip) {
438
+ canvas.context.restore();
439
+ }
440
+ }
441
+
442
+ // src/revas/components/Image.ts
443
+ var DEFAULT_STYLE = { path: true };
444
+ function ImageView(props) {
445
+ const { src, style } = props;
446
+ const [ready, setReady] = React6__namespace.useState(false);
447
+ React6__namespace.useEffect(() => {
448
+ if (src) {
449
+ const onReady = () => setReady(true);
450
+ get(src, onReady);
451
+ return () => remove(src, onReady);
452
+ }
453
+ }, [src]);
454
+ return React6__namespace.createElement("Image", {
455
+ customDrawer: ready ? drawImage : void 0,
456
+ ...props,
457
+ style: [DEFAULT_STYLE, style],
458
+ $ready: ready
459
+ });
460
+ }
461
+ var AnimatedNode = class {
462
+ interpolate(inRange, outRange, ease2 = Easing.linear) {
463
+ return new AnimatedInterpolate(this, inRange, outRange, ease2);
464
+ }
465
+ };
466
+ var AnimatedValue = class extends AnimatedNode {
467
+ constructor(_value) {
468
+ super();
469
+ this._value = _value;
470
+ }
471
+ // TODO: tempor
472
+ _observer;
473
+ setValue(value) {
474
+ this._value = value;
475
+ if (this._observer) {
476
+ const observer = this._observer;
477
+ this._observer = void 0;
478
+ observer();
479
+ }
480
+ }
481
+ getValue(observer) {
482
+ if (observer) {
483
+ this._observer = observer;
484
+ }
485
+ return this._value;
486
+ }
487
+ };
488
+ var AnimatedInterpolate = class extends AnimatedNode {
489
+ constructor(source, inRange, outRange, ease2) {
490
+ super();
491
+ this.source = source;
492
+ this.inRange = inRange;
493
+ this.outRange = outRange;
494
+ this.ease = ease2;
495
+ }
496
+ // TODO: Check inRange is asc
497
+ getValue(observer) {
498
+ const value = this.source.getValue(observer);
499
+ const len = this.inRange.length;
500
+ let i = 1;
501
+ for (; i < len; i++) {
502
+ const x1 = this.inRange[i];
503
+ if (value < x1 || i === len - 1) {
504
+ const x0 = this.inRange[i - 1];
505
+ const y0 = this.outRange[i - 1];
506
+ const y1 = this.outRange[i];
507
+ const percent = (value - x0) / (x1 - x0);
508
+ const result = (y1 - y0) * this.ease(percent) + y0;
509
+ return result;
510
+ }
511
+ }
512
+ return 0;
513
+ }
514
+ };
515
+ var AnimatedTiming = class {
516
+ constructor(value, config) {
517
+ this.value = value;
518
+ this.config = config;
519
+ }
520
+ _startTime = 0;
521
+ _startValue = 0;
522
+ _onEnd;
523
+ _next = 0;
524
+ get _ease() {
525
+ return this.config.ease || Easing.linear;
526
+ }
527
+ start(onEnd) {
528
+ this._startTime = Date.now();
529
+ this._startValue = this.value.getValue();
530
+ this._onEnd = onEnd;
531
+ this._next = requestAnimationFrame(this._loop);
532
+ return this;
533
+ }
534
+ stop() {
535
+ cancelAnimationFrame(this._next);
536
+ return this;
537
+ }
538
+ promise() {
539
+ return new Promise((resolve) => this._onEnd = resolve);
540
+ }
541
+ _loop = () => {
542
+ const duration = Date.now() - this._startTime;
543
+ if (duration < this.config.duration) {
544
+ const percent = duration / this.config.duration;
545
+ const inc = this._ease(percent) * (this.config.to - this._startValue);
546
+ this.value.setValue(this._startValue + inc);
547
+ this._next = requestAnimationFrame(this._loop);
548
+ } else {
549
+ this.value.setValue(this.config.to);
550
+ this._onEnd && requestAnimationFrame(this._onEnd);
551
+ }
552
+ };
553
+ };
554
+ function timing(value, config) {
555
+ return new AnimatedTiming(value, config);
556
+ }
557
+ var ease;
558
+ function getEase() {
559
+ if (!ease) {
560
+ ease = bezier__default.default(0.42, 0, 1, 1);
561
+ }
562
+ return ease;
563
+ }
564
+ var Easing = {
565
+ linear(t) {
566
+ return t;
567
+ },
568
+ ease(t) {
569
+ return getEase()(t);
570
+ },
571
+ /**
572
+ * Runs an easing function forwards.
573
+ */
574
+ in(easing = getEase()) {
575
+ return easing;
576
+ },
577
+ /**
578
+ * Runs an easing function backwards.
579
+ */
580
+ out(easing = getEase()) {
581
+ return (t) => 1 - easing(1 - t);
582
+ },
583
+ /**
584
+ * Makes any easing function symmetrical. The easing function will run
585
+ * forwards for half of the duration, then backwards for the rest of the
586
+ * duration.
587
+ */
588
+ inOut(easing = getEase()) {
589
+ return (t) => {
590
+ if (t < 0.5) {
591
+ return easing(t * 2) / 2;
592
+ }
593
+ return 1 - easing((1 - t) * 2) / 2;
594
+ };
595
+ },
596
+ bounce(t) {
597
+ if (t < 1 / 2.75) {
598
+ return 7.5625 * t * t;
599
+ }
600
+ if (t < 2 / 2.75) {
601
+ const t22 = t - 1.5 / 2.75;
602
+ return 7.5625 * t22 * t22 + 0.75;
603
+ }
604
+ if (t < 2.5 / 2.75) {
605
+ const t22 = t - 2.25 / 2.75;
606
+ return 7.5625 * t22 * t22 + 0.9375;
607
+ }
608
+ const t2 = t - 2.625 / 2.75;
609
+ return 7.5625 * t2 * t2 + 0.984375;
610
+ },
611
+ elastic(bounciness = 1) {
612
+ const p = bounciness * Math.PI;
613
+ return (t) => 1 - Math.pow(Math.cos(t * Math.PI / 2), 3) * Math.cos(t * p);
614
+ }
615
+ };
616
+
617
+ // src/revas/components/Touchable.ts
618
+ var Touchable = class extends React6__namespace.Component {
619
+ static defaultProps = {
620
+ activeOpacity: 0.7
621
+ };
622
+ _style = {
623
+ opacity: new AnimatedValue(1),
624
+ animated: true
625
+ };
626
+ _start;
627
+ _tid = "";
628
+ _onTouchStart = (e) => {
629
+ this._tid = Object.keys(e.touches)[0];
630
+ this._start = e.touches[this._tid];
631
+ this._style.opacity.setValue(this.props.activeOpacity);
632
+ this.props.onPressIn && this.props.onPressIn();
633
+ };
634
+ _onTouchEnd = (e) => {
635
+ if (this._start && e.touches[this._tid]) {
636
+ if (Math.abs(this._start.x - e.touches[this._tid].x) < 3 && Math.abs(this._start.y - e.touches[this._tid].y) < 3) {
637
+ this.props.onPress && this.props.onPress();
638
+ }
639
+ }
640
+ this._style.opacity.setValue(1);
641
+ this.props.onPressOut && this.props.onPressOut();
642
+ };
643
+ render() {
644
+ return React6__namespace.createElement("Touchable", {
645
+ onTouchStart: this._onTouchStart,
646
+ onTouchEnd: this._onTouchEnd,
647
+ ...this.props,
648
+ style: [
649
+ this.props.style,
650
+ this._style
651
+ ]
652
+ });
653
+ }
654
+ };
655
+
656
+ // src/revas/components/common/Scroller.ts
657
+ var Handler = class {
658
+ offset = 0;
659
+ velocity = 0;
660
+ max = -1;
661
+ paging = 0;
662
+ _last = -1;
663
+ capture(value) {
664
+ if (this._last < 0) {
665
+ this._last = value;
666
+ }
667
+ }
668
+ onMove(value, duration) {
669
+ if (this._last >= 0 && duration > 0) {
670
+ const move = this._last - value;
671
+ this.velocity = move / duration;
672
+ this._last = value;
673
+ this.change(move);
674
+ }
675
+ }
676
+ onEnd() {
677
+ if (this._last >= 0) {
678
+ this._last = -1;
679
+ }
680
+ }
681
+ afterEnd(duration) {
682
+ if (this._last < 0) {
683
+ const absv = Math.abs(this.velocity);
684
+ if (this.paging > 0 && absv <= 0.5 && this.offset < this.max) {
685
+ const distance = Math.round(this.offset / this.paging + this.velocity) * this.paging - this.offset;
686
+ this.velocity = clamp(distance / 2e3 + friction(this.velocity, duration, 0.01), -0.5, 0.5);
687
+ if (Math.abs(distance) > 0.5 || absv > 0.05) {
688
+ const move = this.velocity * duration;
689
+ this.change(move);
690
+ return true;
691
+ } else {
692
+ this.change(distance);
693
+ }
694
+ } else if (absv > 0.05) {
695
+ this.velocity = friction(this.velocity, duration, 2e-3);
696
+ const move = this.velocity * duration;
697
+ this.change(move);
698
+ return true;
699
+ } else {
700
+ this.velocity = 0;
701
+ }
702
+ }
703
+ return false;
704
+ }
705
+ change(move) {
706
+ const _offset = clamp(this.offset + move, 0, this.max > 0 ? this.max : 0);
707
+ if (_offset !== this.offset) {
708
+ this.offset = _offset;
709
+ } else if (this._last < 0) {
710
+ this.velocity = 0;
711
+ }
712
+ }
713
+ };
714
+ var Scroller = class {
715
+ constructor(listener) {
716
+ this.listener = listener;
717
+ }
718
+ _timestamp = 0;
719
+ _x = new Handler();
720
+ _y = new Handler();
721
+ _tid = "";
722
+ _timer;
723
+ horizontal = false;
724
+ set maxX(value) {
725
+ this._x.max = value;
726
+ }
727
+ get maxX() {
728
+ return this._x.max;
729
+ }
730
+ set maxY(value) {
731
+ this._y.max = value;
732
+ }
733
+ get maxY() {
734
+ return this._y.max;
735
+ }
736
+ set pagingX(value) {
737
+ this._x.paging = value;
738
+ }
739
+ set pagingY(value) {
740
+ this._y.paging = value;
741
+ }
742
+ _sign(e) {
743
+ e.scroll = { ...e.scroll, x: true, y: true };
744
+ const stopPropagation = e.scroll.stopPropagation || noop;
745
+ if (this.horizontal) {
746
+ if (this._x.velocity > 0) {
747
+ e.scroll.y = false;
748
+ stopPropagation();
749
+ }
750
+ if (this._x.offset > 0 && this._x.offset < this._x.max) {
751
+ e.scroll.x = false;
752
+ }
753
+ } else {
754
+ if (this._y.velocity > 0) {
755
+ e.scroll.x = false;
756
+ stopPropagation();
757
+ }
758
+ if (this._y.offset > 0 && this._y.offset < this._y.max) {
759
+ e.scroll.y = false;
760
+ }
761
+ }
762
+ e.stopPropagation = () => {
763
+ this.touchEnd();
764
+ stopPropagation();
765
+ };
766
+ }
767
+ _check(e) {
768
+ if (this.horizontal && e.scroll && e.scroll.x === false) {
769
+ return this.touchEnd();
770
+ }
771
+ if (!this.horizontal && e.scroll && e.scroll.y === false) {
772
+ return this.touchEnd();
773
+ }
774
+ return true;
775
+ }
776
+ touchStart = (e) => {
777
+ if (!this._tid) {
778
+ this._tid = Object.keys(e.touches)[0];
779
+ this._timestamp = e.timestamp;
780
+ const { x, y } = e.touches[this._tid];
781
+ this.horizontal ? this._x.capture(x) : this._y.capture(y);
782
+ this.emit("start");
783
+ }
784
+ };
785
+ touchMove = (e) => {
786
+ if (this._tid && e.touches[this._tid] && this._check(e)) {
787
+ const { x, y } = e.touches[this._tid];
788
+ const duration = e.timestamp - this._timestamp;
789
+ this._timestamp = e.timestamp;
790
+ this.horizontal ? this._x.onMove(x, duration) : this._y.onMove(y, duration);
791
+ this.emit("scroll");
792
+ this._sign(e);
793
+ }
794
+ };
795
+ touchEnd = () => {
796
+ if (this._tid) {
797
+ this._tid = "";
798
+ this._timestamp = Date.now();
799
+ this._x.onEnd();
800
+ this._y.onEnd();
801
+ this._timer = requestAnimationFrame(this.afterEnd);
802
+ }
803
+ };
804
+ afterEnd = () => {
805
+ const timestamp = Date.now();
806
+ const duration = timestamp - this._timestamp;
807
+ this._timestamp = timestamp;
808
+ if (this.horizontal ? this._x.afterEnd(duration) : this._y.afterEnd(duration)) {
809
+ this.emit("scroll");
810
+ this._timer = requestAnimationFrame(this.afterEnd);
811
+ } else {
812
+ this.emit("end");
813
+ }
814
+ };
815
+ emit(type) {
816
+ this.listener({
817
+ type,
818
+ x: this._x.offset,
819
+ vx: this._x.velocity,
820
+ y: this._y.offset,
821
+ vy: this._y.velocity,
822
+ timestamp: this._timestamp,
823
+ tid: this._tid
824
+ });
825
+ }
826
+ cancel() {
827
+ cancelAnimationFrame(this._timer);
828
+ this._tid = "";
829
+ this._timestamp = Date.now();
830
+ this._x.onEnd();
831
+ this._y.onEnd();
832
+ }
833
+ };
834
+ function friction(v, duration, factor) {
835
+ return v - Math.min(duration * factor, 1) * v;
836
+ }
837
+
838
+ // src/revas/components/ScrollView.ts
839
+ var ScrollView = class extends React6__namespace.Component {
840
+ _height = -1;
841
+ _contentHeight = -1;
842
+ _width = -1;
843
+ _contentWidth = -1;
844
+ _innerStyle = {
845
+ translateX: new AnimatedValue(0),
846
+ translateY: new AnimatedValue(0),
847
+ position: "absolute",
848
+ animated: true
849
+ };
850
+ _offset = { x: 0, y: 0 };
851
+ _scroller = new Scroller((e) => {
852
+ const { x = 0, y = 0 } = this._offset;
853
+ this.props.horizontal ? this._innerStyle.translateX.setValue(x - e.x) : this._innerStyle.translateY.setValue(y - e.y);
854
+ switch (e.type) {
855
+ case "scroll":
856
+ return this.props.onScroll && this.props.onScroll(e);
857
+ case "start":
858
+ return this.props.onScrollStart && this.props.onScrollStart(e);
859
+ case "end":
860
+ return this.props.onScrollEnd && this.props.onScrollEnd(e);
861
+ }
862
+ });
863
+ componentWillUnmount() {
864
+ this._scroller.cancel();
865
+ }
866
+ _onLayout = (frame) => {
867
+ if (this._width !== frame.width || this._height !== frame.height) {
868
+ this._height = frame.height;
869
+ this._width = frame.width;
870
+ this._checkLayout();
871
+ if (this.props.paging) {
872
+ if (this.props.horizontal) {
873
+ this._scroller.pagingX = this.props.paging === true ? frame.width : this.props.paging;
874
+ } else {
875
+ this._scroller.pagingY = this.props.paging === true ? frame.height : this.props.paging;
876
+ }
877
+ }
878
+ }
879
+ this.props.onLayout && this.props.onLayout(frame);
880
+ };
881
+ _onContentLayout = (frame) => {
882
+ const { x = 0, y = 0 } = this._offset;
883
+ const width = frame.width + x;
884
+ const height = frame.height + y;
885
+ if (this._contentWidth !== width || this._contentHeight !== height) {
886
+ this._contentHeight = height;
887
+ this._contentWidth = width;
888
+ this._checkLayout();
889
+ }
890
+ };
891
+ _checkLayout = () => {
892
+ const maxX = this._contentWidth - this._width;
893
+ const maxY = this._contentHeight - this._height;
894
+ if (maxX > 0 && maxX !== this._scroller.maxX || maxY > 0 && maxY !== this._scroller.maxY) {
895
+ this._scroller.maxX = maxX;
896
+ this._scroller.maxY = maxY;
897
+ this._scroller.emit("none");
898
+ }
899
+ };
900
+ render() {
901
+ const { children, horizontal, offset, ...others } = this.props;
902
+ this._scroller.horizontal = horizontal;
903
+ if (offset) {
904
+ this._offset = offset;
905
+ this._scroller.emit("none");
906
+ }
907
+ return React6__namespace.createElement(
908
+ "Scrollable",
909
+ { ...others, onLayout: this._onLayout },
910
+ React6__namespace.createElement("ScrollContent", {
911
+ onTouchStart: this._scroller.touchStart,
912
+ onTouchMove: this._scroller.touchMove,
913
+ onTouchEnd: this._scroller.touchEnd,
914
+ onLayout: this._onContentLayout,
915
+ style: [
916
+ this._innerStyle,
917
+ {
918
+ flexDirection: horizontal ? "row" : "column",
919
+ [horizontal ? "height" : "width"]: "100%"
920
+ }
921
+ ],
922
+ children
923
+ })
924
+ );
925
+ }
926
+ };
927
+ var ListView = class extends React6__namespace.Component {
928
+ state = {
929
+ start: 0,
930
+ end: 1
931
+ };
932
+ _height = 0;
933
+ componentDidMount() {
934
+ this.checkVisible(0);
935
+ }
936
+ checkVisible = (y) => {
937
+ if (this._height > 0) {
938
+ const { itemHeight } = this.props;
939
+ const { start: _start, end: _end } = this.state;
940
+ const start = Math.max(0, Math.floor((y - 10) / itemHeight));
941
+ const end = Math.floor((y + this._height + 10) / itemHeight);
942
+ if (start !== _start || end !== _end) {
943
+ this.setState({ start, end });
944
+ }
945
+ }
946
+ };
947
+ _onScroll = (e) => {
948
+ this.checkVisible(e.y);
949
+ this.props.onScroll && this.props.onScroll(e);
950
+ };
951
+ _onLayout = (frame) => {
952
+ if (this._height !== frame.height) {
953
+ this._height = frame.height;
954
+ }
955
+ };
956
+ renderItem = (item, i) => {
957
+ const { data, renderItem } = this.props;
958
+ const index = i + this.state.start;
959
+ return React6__namespace.createElement(React6__namespace.Fragment, { key: index }, renderItem(item, index, data));
960
+ };
961
+ render() {
962
+ const { data, itemHeight } = this.props;
963
+ const { start, end } = this.state;
964
+ return React6__namespace.createElement(
965
+ ScrollView,
966
+ {
967
+ ...this.props,
968
+ onScroll: this._onScroll,
969
+ onLayout: this._onLayout,
970
+ offset: { y: start * itemHeight }
971
+ },
972
+ data.slice(start, end + 1).map(this.renderItem)
973
+ );
974
+ }
975
+ };
976
+ var DEFAULT_STYLE2 = { path: true };
977
+ function LinearGradient(props) {
978
+ return React6__namespace.createElement("LinearGradient", {
979
+ ...props,
980
+ style: [DEFAULT_STYLE2, props.style],
981
+ customDrawer: drawGradient
982
+ });
983
+ }
984
+ function drawGradient(canvas, node) {
985
+ const { colors } = node.props;
986
+ if (colors && colors.length > 0) {
987
+ const { start = { x: 0, y: 0 }, end = { x: 1, y: 0 } } = node.props;
988
+ const frame = getFrameFromNode(node);
989
+ const grad = canvas.context.createLinearGradient(
990
+ start.x * frame.width + frame.x,
991
+ start.y * frame.height + frame.y,
992
+ end.x * frame.width + frame.x,
993
+ end.y * frame.height + frame.y
994
+ );
995
+ for (let i = 0; i < colors.length; i++) {
996
+ grad.addColorStop(i / (colors.length - 1), colors[i]);
997
+ }
998
+ canvas.context.fillStyle = grad;
999
+ canvas.context.fill();
1000
+ }
1001
+ }
1002
+
1003
+ // src/revas/core/Node.ts
1004
+ var Frame = class {
1005
+ constructor(x = 0, y = 0, width = 0, height = 0) {
1006
+ this.x = x;
1007
+ this.y = y;
1008
+ this.width = width;
1009
+ this.height = height;
1010
+ }
1011
+ };
1012
+ var Node = class {
1013
+ constructor(type, props) {
1014
+ this.type = type;
1015
+ this.props = props;
1016
+ }
1017
+ children = [];
1018
+ frame = new Frame();
1019
+ parent;
1020
+ get $ready() {
1021
+ if (this.props.$ready === false) {
1022
+ return false;
1023
+ }
1024
+ for (let i = 0; i < this.children.length; i++) {
1025
+ const child = this.children[i];
1026
+ if (child.$ready === false) {
1027
+ return false;
1028
+ }
1029
+ }
1030
+ return true;
1031
+ }
1032
+ };
1033
+
1034
+ // src/revas/core/reconciler.ts
1035
+ var isDev = process.env.NODE_ENV !== "production";
1036
+ var currentUpdatePriority = constants.DefaultEventPriority;
1037
+ function checkAndRemove(parent, child) {
1038
+ const index = parent.children.indexOf(child);
1039
+ if (index >= 0) {
1040
+ parent.children.splice(index, 1);
1041
+ }
1042
+ }
1043
+ function appendChild(parent, child) {
1044
+ checkAndRemove(parent, child);
1045
+ parent.children.push(child);
1046
+ child.parent = parent;
1047
+ }
1048
+ var RevasReconciler = ReactReconciler__default.default({
1049
+ supportsMutation: true,
1050
+ supportsPersistence: false,
1051
+ supportsHydration: false,
1052
+ isPrimaryRenderer: false,
1053
+ // Timing
1054
+ now,
1055
+ scheduleTimeout: setTimeout,
1056
+ cancelTimeout: clearTimeout,
1057
+ noTimeout: -1,
1058
+ supportsMicrotasks: true,
1059
+ scheduleMicrotask: typeof queueMicrotask === "function" ? queueMicrotask : setTimeout,
1060
+ // Update priority (required for React 19)
1061
+ getCurrentEventPriority: () => constants.DefaultEventPriority,
1062
+ setCurrentUpdatePriority: (priority) => {
1063
+ currentUpdatePriority = priority;
1064
+ },
1065
+ getCurrentUpdatePriority: () => currentUpdatePriority,
1066
+ resolveUpdatePriority: () => currentUpdatePriority || constants.DefaultEventPriority,
1067
+ // Suspense commit control (required for React 19)
1068
+ maySuspendCommit: () => false,
1069
+ preloadInstance: () => true,
1070
+ startSuspendingCommit: noop,
1071
+ suspendInstance: noop,
1072
+ waitForCommitToBeReady: () => null,
1073
+ // Transitions (required for React 19)
1074
+ NotPendingTransition: null,
1075
+ HostTransitionContext: {
1076
+ $$typeof: /* @__PURE__ */ Symbol.for("react.context"),
1077
+ _currentValue: null,
1078
+ _currentValue2: null
1079
+ },
1080
+ resetFormInstance: noop,
1081
+ // Event tracking (required for React 19)
1082
+ trackSchedulerEvent: noop,
1083
+ resolveEventType: () => null,
1084
+ resolveEventTimeStamp: () => -1.1,
1085
+ shouldAttemptEagerTransition: () => false,
1086
+ // Instance creation
1087
+ createInstance(type, props) {
1088
+ return new Node(type, props);
1089
+ },
1090
+ createTextInstance() {
1091
+ throw new Error("Revas: string cannot be child out of <Text/>");
1092
+ },
1093
+ // Tree operations
1094
+ appendChild,
1095
+ appendInitialChild: appendChild,
1096
+ appendChildToContainer(container, instance) {
1097
+ if (instance.type !== "Root") {
1098
+ throw new Error(`wrong root instance type: ${instance.type}`);
1099
+ }
1100
+ container.setRoot(instance);
1101
+ },
1102
+ removeChild(parent, child) {
1103
+ checkAndRemove(parent, child);
1104
+ child.parent = void 0;
1105
+ },
1106
+ removeChildFromContainer(container) {
1107
+ container.setRoot();
1108
+ },
1109
+ insertBefore(parent, child, before) {
1110
+ checkAndRemove(parent, child);
1111
+ const beforeIndex = parent.children.indexOf(before);
1112
+ parent.children.splice(beforeIndex, 0, child);
1113
+ child.parent = parent;
1114
+ },
1115
+ insertInContainerBefore() {
1116
+ throw new Error("shouldn't be here: insertInContainerBefore");
1117
+ },
1118
+ clearContainer() {
1119
+ },
1120
+ // Finalization
1121
+ finalizeInitialChildren() {
1122
+ return false;
1123
+ },
1124
+ // Public instance
1125
+ getPublicInstance(instance) {
1126
+ return instance;
1127
+ },
1128
+ // Updates
1129
+ prepareUpdate() {
1130
+ return true;
1131
+ },
1132
+ commitUpdate(instance, _updatePayload, _type, oldProps, newProps) {
1133
+ const mergedProps = { ...oldProps };
1134
+ for (const key in newProps) {
1135
+ if (newProps[key] !== void 0) {
1136
+ mergedProps[key] = newProps[key];
1137
+ }
1138
+ }
1139
+ instance.props = mergedProps;
1140
+ },
1141
+ commitMount: noop,
1142
+ // Commit phase
1143
+ prepareForCommit() {
1144
+ return null;
1145
+ },
1146
+ resetAfterCommit(container) {
1147
+ container.draw(true);
1148
+ },
1149
+ resetTextContent: noop,
1150
+ // Context
1151
+ getRootHostContext() {
1152
+ return {};
1153
+ },
1154
+ getChildHostContext(parentHostContext) {
1155
+ return parentHostContext;
1156
+ },
1157
+ shouldSetTextContent() {
1158
+ return false;
1159
+ },
1160
+ // Visibility (required for React 19 Offscreen)
1161
+ hideInstance: noop,
1162
+ hideTextInstance: noop,
1163
+ unhideInstance: noop,
1164
+ unhideTextInstance: noop,
1165
+ // Required stubs for React 19
1166
+ getInstanceFromNode() {
1167
+ return null;
1168
+ },
1169
+ beforeActiveInstanceBlur: noop,
1170
+ afterActiveInstanceBlur: noop,
1171
+ preparePortalMount: noop,
1172
+ prepareScopeUpdate: noop,
1173
+ getInstanceFromScope() {
1174
+ return null;
1175
+ },
1176
+ detachDeletedInstance: noop
1177
+ });
1178
+ RevasReconciler.injectIntoDevTools({
1179
+ bundleType: isDev ? 1 : 0,
1180
+ version: React6.version,
1181
+ rendererPackageName: "revas",
1182
+ findHostInstanceByFiber: RevasReconciler.findHostInstance
1183
+ });
1184
+ var reconciler_default = RevasReconciler;
1185
+ var AppContext = React6.createContext({
1186
+ clientWidth: 0,
1187
+ clientHeight: 0,
1188
+ deviceRatio: 1
1189
+ });
1190
+ function withContext(comp) {
1191
+ comp.contextType = AppContext;
1192
+ return comp;
1193
+ }
1194
+ function Root(props) {
1195
+ return React6.createElement(AppContext.Provider, { value: props }, React6.createElement("Root", props));
1196
+ }
1197
+ function funcName(key) {
1198
+ return `set${key[0].toUpperCase()}${key.substr(1)}`;
1199
+ }
1200
+ function checkAndRun(yoga, key, ...values) {
1201
+ if (yoga[key]) {
1202
+ yoga[key](...values);
1203
+ } else {
1204
+ throw new Error(`Revas: No Such Style Func - ${key}`);
1205
+ }
1206
+ }
1207
+ function parseValue(func, value) {
1208
+ if (typeof value === "number") {
1209
+ return [func, value];
1210
+ } else if (value === "auto") {
1211
+ return [`${func}Auto`];
1212
+ } else if (value.endsWith("%")) {
1213
+ return [`${func}Percent`, Number(value.slice(0, -1))];
1214
+ } else {
1215
+ throw new Error(`Revas: No Such Style Value - ${value}`);
1216
+ }
1217
+ }
1218
+ function parseEnum(func, enums, value) {
1219
+ if (enums[value] !== void 0) {
1220
+ return [func, enums[value]];
1221
+ } else {
1222
+ throw new Error(`Revas: No Such Style Value - ${value}`);
1223
+ }
1224
+ }
1225
+ function parseEdge(func, edge, value) {
1226
+ if (typeof value === "number") {
1227
+ return [func, edge, value];
1228
+ } else if (value === "auto") {
1229
+ return [`${func}Auto`, edge];
1230
+ } else if (value.endsWith("%")) {
1231
+ return [`${func}Percent`, edge, Number(value.slice(0, -1))];
1232
+ } else {
1233
+ throw new Error(`Revas: No Such Style Value - ${value}`);
1234
+ }
1235
+ }
1236
+ var ALIGN_ENUM = {
1237
+ auto: Yoga.Align.Auto,
1238
+ baseline: Yoga.Align.Baseline,
1239
+ center: Yoga.Align.Center,
1240
+ "flex-end": Yoga.Align.FlexEnd,
1241
+ "flex-start": Yoga.Align.FlexStart,
1242
+ "space-around": Yoga.Align.SpaceAround,
1243
+ "space-between": Yoga.Align.SpaceBetween,
1244
+ stretch: Yoga.Align.Stretch
1245
+ };
1246
+ var STYLE_MAP = {};
1247
+ var AVAILABLE = {
1248
+ VALUE: [
1249
+ "flex",
1250
+ "width",
1251
+ "height",
1252
+ "minWidth",
1253
+ "maxWidth",
1254
+ "minHeight",
1255
+ "maxHeight",
1256
+ "flexGrow",
1257
+ "flexShrink",
1258
+ "aspectRatio"
1259
+ ],
1260
+ ENUM: [
1261
+ {
1262
+ key: "justifyContent",
1263
+ enum: {
1264
+ center: Yoga.Justify.Center,
1265
+ "flex-end": Yoga.Justify.FlexEnd,
1266
+ "flex-start": Yoga.Justify.FlexStart,
1267
+ "space-around": Yoga.Justify.SpaceAround,
1268
+ "space-between": Yoga.Justify.SpaceBetween,
1269
+ "space-evenly": Yoga.Justify.SpaceEvenly
1270
+ }
1271
+ },
1272
+ { key: "alignItems", enum: ALIGN_ENUM },
1273
+ { key: "alignSelf", enum: ALIGN_ENUM },
1274
+ { key: "alignContent", enum: ALIGN_ENUM },
1275
+ {
1276
+ key: "flexWrap",
1277
+ enum: {
1278
+ "no-wrap": Yoga.Wrap.NoWrap,
1279
+ wrap: Yoga.Wrap.Wrap,
1280
+ "wrap-reverse": Yoga.Wrap.WrapReverse
1281
+ }
1282
+ },
1283
+ {
1284
+ key: "flexDirection",
1285
+ enum: {
1286
+ column: Yoga.FlexDirection.Column,
1287
+ "column-reverse": Yoga.FlexDirection.ColumnReverse,
1288
+ row: Yoga.FlexDirection.Row,
1289
+ "row-reverse": Yoga.FlexDirection.RowReverse
1290
+ }
1291
+ },
1292
+ {
1293
+ key: "position",
1294
+ remap: "positionType",
1295
+ enum: {
1296
+ relative: Yoga.PositionType.Relative,
1297
+ absolute: Yoga.PositionType.Absolute,
1298
+ static: Yoga.PositionType.Static
1299
+ }
1300
+ }
1301
+ ],
1302
+ EDGE: [
1303
+ { key: "padding", remap: "padding", edge: Yoga.Edge.All },
1304
+ { key: "paddingLeft", remap: "padding", edge: Yoga.Edge.Left },
1305
+ { key: "paddingRight", remap: "padding", edge: Yoga.Edge.Right },
1306
+ { key: "paddingTop", remap: "padding", edge: Yoga.Edge.Top },
1307
+ { key: "paddingBottom", remap: "padding", edge: Yoga.Edge.Bottom },
1308
+ { key: "left", remap: "position", edge: Yoga.Edge.Left },
1309
+ { key: "right", remap: "position", edge: Yoga.Edge.Right },
1310
+ { key: "top", remap: "position", edge: Yoga.Edge.Top },
1311
+ { key: "bottom", remap: "position", edge: Yoga.Edge.Bottom },
1312
+ { key: "margin", remap: "margin", edge: Yoga.Edge.All },
1313
+ { key: "marginLeft", remap: "margin", edge: Yoga.Edge.Left },
1314
+ { key: "marginRight", remap: "margin", edge: Yoga.Edge.Right },
1315
+ { key: "marginTop", remap: "margin", edge: Yoga.Edge.Top },
1316
+ { key: "marginBottom", remap: "margin", edge: Yoga.Edge.Bottom },
1317
+ { key: "borderWidth", remap: "border", edge: Yoga.Edge.All },
1318
+ { key: "borderLeftWidth", remap: "border", edge: Yoga.Edge.Left },
1319
+ { key: "borderRightWidth", remap: "border", edge: Yoga.Edge.Right },
1320
+ { key: "borderTopWidth", remap: "border", edge: Yoga.Edge.Top },
1321
+ { key: "borderBottomWidth", remap: "border", edge: Yoga.Edge.Bottom }
1322
+ ]
1323
+ };
1324
+ AVAILABLE.VALUE.forEach((key) => {
1325
+ const func = funcName(key);
1326
+ STYLE_MAP[key] = (value) => parseValue(func, value);
1327
+ });
1328
+ AVAILABLE.ENUM.forEach((item) => {
1329
+ const func = funcName(item.remap || item.key);
1330
+ const enums = item.enum;
1331
+ STYLE_MAP[item.key] = (value) => parseEnum(func, enums, value);
1332
+ });
1333
+ AVAILABLE.EDGE.forEach((item) => {
1334
+ const func = funcName(item.remap);
1335
+ const { edge } = item;
1336
+ STYLE_MAP[item.key] = (value) => parseEdge(func, edge, value);
1337
+ });
1338
+ var cache2 = /* @__PURE__ */ new WeakMap();
1339
+ function _apply(yoga, style) {
1340
+ if (style) {
1341
+ if (!cache2.has(style)) {
1342
+ const _styles = [];
1343
+ for (const key in style) {
1344
+ const func = STYLE_MAP[key];
1345
+ func && _styles.push(func(style[key]));
1346
+ }
1347
+ cache2.set(style, _styles);
1348
+ }
1349
+ const styles = cache2.get(style);
1350
+ for (let i = 0; i < styles.length; i++) {
1351
+ checkAndRun(yoga, ...styles[i]);
1352
+ }
1353
+ }
1354
+ }
1355
+ function apply(yoga, style) {
1356
+ if (style) {
1357
+ flatten([style]).forEach((s) => _apply(yoga, s));
1358
+ }
1359
+ }
1360
+
1361
+ // src/revas/core/yoga-layout/index.ts
1362
+ function _updateLayout(node) {
1363
+ const yoga = Yoga__default.default.Node.create();
1364
+ const children = [];
1365
+ apply(yoga, node.props.style);
1366
+ for (let i = 0; i < node.children.length; i++) {
1367
+ const child = node.children[i];
1368
+ const [f, y] = _updateLayout(child);
1369
+ const index = children.push(f);
1370
+ yoga.insertChild(y, index - 1);
1371
+ }
1372
+ function process2(x = 0, y = 0) {
1373
+ const layout = yoga.getComputedLayout();
1374
+ node.frame = new Frame(x + layout.left, y + layout.top, layout.width, layout.height);
1375
+ node.props.onLayout && node.props.onLayout(node.frame);
1376
+ for (let i = 0; i < children.length; i++) {
1377
+ children[i](node.frame.x, node.frame.y);
1378
+ }
1379
+ yoga.free();
1380
+ }
1381
+ return [process2, yoga];
1382
+ }
1383
+ function updateLayout(root) {
1384
+ const [process2, yoga] = _updateLayout(root);
1385
+ const { clientWidth, clientHeight, RTL } = root.props;
1386
+ yoga.calculateLayout(clientWidth, clientHeight, RTL ? Yoga.Direction.RTL : Yoga.Direction.LTR);
1387
+ return process2;
1388
+ }
1389
+
1390
+ // src/revas/core/offscreen.ts
1391
+ var MAX_SIZE = 30;
1392
+ var cache3 = /* @__PURE__ */ new Map();
1393
+ var ids = [];
1394
+ function getCache(id) {
1395
+ return cache3.get(id);
1396
+ }
1397
+ function createCache(style, w, h, id) {
1398
+ if (ids.length >= MAX_SIZE) {
1399
+ const expiredId = ids.shift();
1400
+ const { canvas } = cache3.get(expiredId);
1401
+ const cached = {
1402
+ canvas: adapter.resetOffscreenCanvas(canvas, w, h),
1403
+ id,
1404
+ style
1405
+ };
1406
+ cache3.delete(expiredId);
1407
+ cache3.set(cached.id, cached);
1408
+ ids.push(cached.id);
1409
+ return cached;
1410
+ } else {
1411
+ const cached = {
1412
+ canvas: adapter.createOffscreenCanvas(w, h),
1413
+ id,
1414
+ style
1415
+ };
1416
+ cache3.set(cached.id, cached);
1417
+ ids.push(cached.id);
1418
+ return cached;
1419
+ }
1420
+ }
1421
+ var idCache = /* @__PURE__ */ new WeakMap();
1422
+ var __ID = 0;
1423
+ function autoCacheId(node) {
1424
+ if (idCache.has(node)) {
1425
+ return idCache.get(node);
1426
+ } else {
1427
+ const id = `$$auto_id-${__ID++}`;
1428
+ idCache.set(node, id);
1429
+ return id;
1430
+ }
1431
+ }
1432
+ function clearCache() {
1433
+ cache3.clear();
1434
+ ids.length = 0;
1435
+ }
1436
+
1437
+ // src/revas/core/draw.ts
1438
+ function getRadius(style) {
1439
+ return {
1440
+ tl: style.borderTopLeftRadius || style.borderRadius || 0,
1441
+ tr: style.borderTopRightRadius || style.borderRadius || 0,
1442
+ bl: style.borderBottomLeftRadius || style.borderRadius || 0,
1443
+ br: style.borderBottomRightRadius || style.borderRadius || 0
1444
+ };
1445
+ }
1446
+ function drawNode(canvas, node, container) {
1447
+ const style = getMergedStyleFromNode(node, container.draw);
1448
+ const frame = getFrameFromNode(node);
1449
+ if (style.opacity <= 0) {
1450
+ return;
1451
+ }
1452
+ const hasTransform = style.translateX || style.translateY || style.rotate || style.scaleX || style.scaleY || style.scale;
1453
+ const hasClip = style.overflow === "hidden";
1454
+ if (hasClip) {
1455
+ canvas.context.save();
1456
+ } else if (hasTransform) {
1457
+ canvas.transform.save();
1458
+ }
1459
+ const popOpacity = pushOpacity(canvas, style.opacity);
1460
+ if (style.translateX || style.translateY) {
1461
+ canvas.transform.translate(style.translateX || 0, style.translateY || 0);
1462
+ }
1463
+ if (style.rotate || style.scaleX || style.scaleY || style.scale) {
1464
+ const originX = frame.x + frame.width / 2;
1465
+ const originY = frame.y + frame.height / 2;
1466
+ canvas.transform.translate(originX, originY);
1467
+ if (style.rotate) {
1468
+ canvas.transform.rotate(style.rotate);
1469
+ }
1470
+ if (style.scaleX || style.scaleY || style.scale) {
1471
+ canvas.transform.scale(style.scaleX || style.scale, style.scaleY || style.scale);
1472
+ }
1473
+ canvas.transform.translate(-originX, -originY);
1474
+ }
1475
+ if (node.props.cache && adapter.createOffscreenCanvas && frame.height > 0 && frame.width > 0) {
1476
+ drawCache(canvas, node, container, style, frame, hasClip);
1477
+ } else {
1478
+ drawContent(canvas, node, container, style, frame, hasClip);
1479
+ }
1480
+ popOpacity();
1481
+ if (hasClip) {
1482
+ canvas.context.restore();
1483
+ } else if (hasTransform) {
1484
+ canvas.transform.restore();
1485
+ }
1486
+ }
1487
+ function drawCache(canvas, node, container, style, frame, hasClip) {
1488
+ const cachedId = node.props.cache === true ? autoCacheId(node) : node.props.cache;
1489
+ let cached = getCache(cachedId);
1490
+ const { shadowBlur = 0, shadowOffsetX = 0, shadowOffsetY = 0 } = cached ? cached.style : style;
1491
+ const spread = shadowBlur * 2;
1492
+ const x = frame.x + shadowOffsetX - shadowBlur;
1493
+ const y = frame.y + shadowOffsetY - shadowBlur;
1494
+ const w = frame.width + spread;
1495
+ const h = frame.height + spread;
1496
+ if (!cached) {
1497
+ if (!node.$ready && !node.props.forceCache) {
1498
+ return drawContent(canvas, node, container, style, frame, hasClip);
1499
+ }
1500
+ cached = createCache(style, w, h, cachedId);
1501
+ cached.canvas.transform.translate(-x, -y);
1502
+ drawContent(cached.canvas, node, container, style, frame, hasClip);
1503
+ cached.canvas.transform.translate(x, y);
1504
+ }
1505
+ canvas.context.drawImage(cached.canvas.element, x, y, w, h);
1506
+ }
1507
+ function drawContent(canvas, node, container, style, frame, hasClip) {
1508
+ const hasBG = style.backgroundColor && style.backgroundColor !== "transparent";
1509
+ const hasBorder = style.borderColor && style.borderWidth > 0;
1510
+ const hasRadius = style.borderRadius || style.borderTopLeftRadius || style.borderTopRightRadius || style.borderBottomLeftRadius || style.borderBottomRightRadius;
1511
+ const useFrame = hasBG || hasBorder || hasClip || style.path;
1512
+ const usePath = hasRadius || hasClip || style.path;
1513
+ if (useFrame) {
1514
+ const { context: ctx } = canvas;
1515
+ if (usePath) {
1516
+ ctx.beginPath();
1517
+ if (hasRadius) {
1518
+ const radius = getRadius(style);
1519
+ ctx.moveTo(frame.x + radius.tl, frame.y);
1520
+ ctx.arcTo(frame.x + frame.width, frame.y, frame.x + frame.width, frame.y + frame.height, radius.tr);
1521
+ ctx.arcTo(frame.x + frame.width, frame.y + frame.height, frame.x, frame.y + frame.height, radius.br);
1522
+ ctx.arcTo(frame.x, frame.y + frame.height, frame.x, frame.y, radius.bl);
1523
+ ctx.arcTo(frame.x, frame.y, frame.x + frame.width, frame.y, radius.tl);
1524
+ } else {
1525
+ ctx.rect(frame.x, frame.y, frame.width, frame.height);
1526
+ }
1527
+ ctx.closePath();
1528
+ if (hasClip) {
1529
+ ctx.clip();
1530
+ }
1531
+ }
1532
+ if (hasBG || hasBorder) {
1533
+ const resetShadow = setShadow(
1534
+ canvas,
1535
+ style.shadowColor,
1536
+ style.shadowOffsetX,
1537
+ style.shadowOffsetY,
1538
+ style.shadowBlur
1539
+ );
1540
+ if (hasBG) {
1541
+ ctx.fillStyle = style.backgroundColor;
1542
+ if (usePath) {
1543
+ ctx.fill();
1544
+ } else {
1545
+ ctx.fillRect(frame.x, frame.y, frame.width, frame.height);
1546
+ }
1547
+ }
1548
+ if (hasBorder) {
1549
+ ctx.lineWidth = style.borderWidth;
1550
+ ctx.strokeStyle = style.borderColor;
1551
+ if (usePath) {
1552
+ ctx.stroke();
1553
+ } else {
1554
+ ctx.strokeRect(frame.x, frame.y, frame.width, frame.height);
1555
+ }
1556
+ }
1557
+ resetShadow();
1558
+ }
1559
+ }
1560
+ if (node.props.customDrawer) {
1561
+ node.props.customDrawer(canvas, node, { hasRadius, hasClip });
1562
+ }
1563
+ node.children.slice().sort(sortByZIndexAscending).forEach(function drawChild(child) {
1564
+ drawNode(canvas, child, container);
1565
+ });
1566
+ }
1567
+
1568
+ // src/revas/core/touch.ts
1569
+ function scaled(x, c, s = 1) {
1570
+ if (!s && s === 1) return x;
1571
+ return ((s - 1) * c + x) / s;
1572
+ }
1573
+ function findNodeByPoint(node, x, y) {
1574
+ if (node.props.pointerEvents === "none") return;
1575
+ const children = node.children.slice().sort(sortByZIndexAscending).reverse();
1576
+ const style = getMergedStyleFromNode(node);
1577
+ const frame = getFrameFromNode(node);
1578
+ const scaleX = style.scaleX || style.scale;
1579
+ const scaleY = style.scaleY || style.scale;
1580
+ const originX = frame.width / 2 + frame.x;
1581
+ const originY = frame.height / 2 + frame.y;
1582
+ x -= style.translateX || 0;
1583
+ y -= style.translateY || 0;
1584
+ x = scaled(x, originX, scaleX);
1585
+ y = scaled(y, originY, scaleY);
1586
+ if (frame.x < x && frame.y < y && x <= frame.x + frame.width && y <= frame.y + frame.height) {
1587
+ for (let i = 0; i < children.length; i++) {
1588
+ const target = findNodeByPoint(children[i], x, y);
1589
+ if (target) return target;
1590
+ }
1591
+ if (node.props.pointerEvents === "box-none") return;
1592
+ return node;
1593
+ }
1594
+ }
1595
+ var eventNodeHolder = {};
1596
+ function getNodeByTouch(root, type, touch) {
1597
+ if (type === "touchstart") {
1598
+ const target = findNodeByPoint(root, touch.x, touch.y);
1599
+ eventNodeHolder[touch.identifier] = target || root;
1600
+ return eventNodeHolder[touch.identifier];
1601
+ } else if (type === "touchmove") {
1602
+ return eventNodeHolder[touch.identifier] || root;
1603
+ } else if (type === "touchend") {
1604
+ const target = eventNodeHolder[touch.identifier];
1605
+ delete eventNodeHolder[touch.identifier];
1606
+ return target || root;
1607
+ }
1608
+ return root;
1609
+ }
1610
+ var LISTENER_MAP = {
1611
+ touchstart: "onTouchStart",
1612
+ touchmove: "onTouchMove",
1613
+ touchend: "onTouchEnd"
1614
+ };
1615
+ function emitTouch(node, e) {
1616
+ const funcName2 = LISTENER_MAP[e.type];
1617
+ if (funcName2) {
1618
+ while (node) {
1619
+ if (node.props[funcName2] && node.props.pointerEvents !== "box-none" && node.props[funcName2](e) === false) return;
1620
+ node = node.parent;
1621
+ }
1622
+ }
1623
+ }
1624
+
1625
+ // src/revas/core/Container.ts
1626
+ var Container = class {
1627
+ _ready = true;
1628
+ // Now always ready since Yoga is sync
1629
+ _next = false;
1630
+ _reflow = false;
1631
+ _root;
1632
+ get canvas() {
1633
+ return this._root?.props.canvas;
1634
+ }
1635
+ get width() {
1636
+ return this._root?.props.clientWidth || 0;
1637
+ }
1638
+ get height() {
1639
+ return this._root?.props.clientHeight || 0;
1640
+ }
1641
+ get scale() {
1642
+ return this._root?.props.deviceRatio || 1;
1643
+ }
1644
+ setRoot(root) {
1645
+ this._root = root;
1646
+ }
1647
+ handleTouch = (evt) => {
1648
+ const { _root } = this;
1649
+ if (_root) {
1650
+ const emitted = /* @__PURE__ */ new WeakSet();
1651
+ Object.values(evt.touches).forEach((touch) => {
1652
+ const node = getNodeByTouch(_root, evt.type, touch);
1653
+ if (node.parent && !emitted.has(node)) {
1654
+ emitted.add(node);
1655
+ emitTouch(node, evt);
1656
+ }
1657
+ });
1658
+ }
1659
+ };
1660
+ draw = (reflow = false) => {
1661
+ this._reflow = this._reflow || reflow;
1662
+ if (!this._ready) {
1663
+ this._next = true;
1664
+ return;
1665
+ }
1666
+ this._ready = false;
1667
+ const { _root, canvas } = this;
1668
+ if (canvas) {
1669
+ if (this._reflow) {
1670
+ updateLayout(_root)();
1671
+ this._reflow = false;
1672
+ }
1673
+ canvas.context.clearRect(0, 0, this.width, this.height);
1674
+ drawNode(canvas, _root, this);
1675
+ requestAnimationFrame(this.ready);
1676
+ }
1677
+ };
1678
+ ready = () => {
1679
+ this._ready = true;
1680
+ if (this._next) {
1681
+ this._next = false;
1682
+ this.draw();
1683
+ }
1684
+ };
1685
+ };
1686
+
1687
+ // src/revas/core/Canvas.ts
1688
+ var RevasCanvas = class {
1689
+ transform;
1690
+ constructor(context) {
1691
+ this.transform = new Transform(context);
1692
+ }
1693
+ get context() {
1694
+ return this.transform.context;
1695
+ }
1696
+ get element() {
1697
+ return this.context.canvas;
1698
+ }
1699
+ };
1700
+ var Transform = class {
1701
+ constructor(context) {
1702
+ this.context = context;
1703
+ this._canGetTransform = Boolean(context.getTransform);
1704
+ }
1705
+ _stack = [];
1706
+ _canGetTransform = false;
1707
+ save() {
1708
+ if (this._canGetTransform) {
1709
+ this._stack.push(this.context.getTransform());
1710
+ } else {
1711
+ this.context.save();
1712
+ }
1713
+ }
1714
+ restore() {
1715
+ if (this._canGetTransform) {
1716
+ if (this._stack.length > 0) {
1717
+ this.context.setTransform(this._stack.pop());
1718
+ }
1719
+ } else {
1720
+ this.context.restore();
1721
+ }
1722
+ }
1723
+ translate(x, y) {
1724
+ this.context.translate(x, y);
1725
+ }
1726
+ rotate(rad) {
1727
+ this.context.rotate(rad);
1728
+ }
1729
+ scale(sx, sy) {
1730
+ this.context.scale(sx, sy);
1731
+ }
1732
+ };
1733
+ function getNodePosition(node) {
1734
+ let top = 0;
1735
+ let left = 0;
1736
+ while (node) {
1737
+ top += node.offsetTop;
1738
+ left += node.offsetLeft;
1739
+ node = node.offsetParent;
1740
+ }
1741
+ return [top, left];
1742
+ }
1743
+ function createRevasTouchEvent(e) {
1744
+ e.preventDefault();
1745
+ e.stopPropagation();
1746
+ const touches = {};
1747
+ const type = e.type === "touchcancel" ? "touchend" : e.type;
1748
+ Object.keys(e.changedTouches).forEach((key) => {
1749
+ const touch = e.changedTouches[key];
1750
+ if (touch && touch.target) {
1751
+ const [offsetTop, offsetLeft] = getNodePosition(touch.target);
1752
+ touches[touch.identifier] = {
1753
+ identifier: touch.identifier,
1754
+ x: touch.clientX - offsetLeft,
1755
+ y: touch.clientY - offsetTop
1756
+ };
1757
+ }
1758
+ });
1759
+ return { type, touches, timestamp: e.timeStamp || Date.now() };
1760
+ }
1761
+ function createCanvas(parent, scale) {
1762
+ const canvas = document.createElement("canvas");
1763
+ canvas.setAttribute("style", "width: 100%; height: 100%;");
1764
+ parent.appendChild(canvas);
1765
+ canvas.width = canvas.clientWidth * scale;
1766
+ canvas.height = canvas.clientHeight * scale;
1767
+ return canvas;
1768
+ }
1769
+ function createRoot(app, dom, canvas) {
1770
+ return React6.createElement(
1771
+ Root,
1772
+ {
1773
+ clientWidth: dom.clientWidth,
1774
+ clientHeight: dom.clientHeight,
1775
+ deviceRatio: window.devicePixelRatio,
1776
+ canvas
1777
+ },
1778
+ app
1779
+ );
1780
+ }
1781
+ function initTouch(dom, handler) {
1782
+ dom.addEventListener("touchstart", handler, false);
1783
+ dom.addEventListener("touchmove", handler, false);
1784
+ dom.addEventListener("touchend", handler, false);
1785
+ dom.addEventListener("touchcancel", handler, false);
1786
+ return () => {
1787
+ dom.removeEventListener("touchstart", handler, false);
1788
+ dom.removeEventListener("touchmove", handler, false);
1789
+ dom.removeEventListener("touchend", handler, false);
1790
+ dom.removeEventListener("touchcancel", handler, false);
1791
+ };
1792
+ }
1793
+ function render(app, parent, parentComponent, callback = noop) {
1794
+ const scale = window.devicePixelRatio;
1795
+ const dom = createCanvas(parent, scale);
1796
+ const canvas = new RevasCanvas(dom.getContext("2d"));
1797
+ const container = new Container();
1798
+ const destroyTouch = initTouch(dom, (e) => container.handleTouch(createRevasTouchEvent(e)));
1799
+ const fiber = reconciler_default.createContainer(
1800
+ container,
1801
+ 0,
1802
+ // tag: LegacyRoot = 0, ConcurrentRoot = 1
1803
+ null,
1804
+ // hydrationCallbacks
1805
+ false,
1806
+ // isStrictMode
1807
+ null,
1808
+ // concurrentUpdatesByDefaultOverride
1809
+ "",
1810
+ // identifierPrefix
1811
+ console.error,
1812
+ // onUncaughtError
1813
+ console.error,
1814
+ // onCaughtError
1815
+ console.error,
1816
+ // onRecoverableError
1817
+ null
1818
+ // transitionCallbacks
1819
+ );
1820
+ canvas.transform.scale(scale, scale);
1821
+ reconciler_default.updateContainer(createRoot(app, dom, canvas), fiber, parentComponent, callback);
1822
+ return {
1823
+ get $() {
1824
+ return dom;
1825
+ },
1826
+ update(next = app, callback2 = noop) {
1827
+ dom.width = dom.clientWidth * scale;
1828
+ dom.height = dom.clientHeight * scale;
1829
+ clearCache();
1830
+ canvas.transform.scale(scale, scale);
1831
+ reconciler_default.updateContainer(createRoot(next, dom, canvas), fiber, parentComponent, callback2);
1832
+ },
1833
+ unmount(callback2 = noop) {
1834
+ reconciler_default.updateContainer(null, fiber, null, callback2);
1835
+ destroyTouch();
1836
+ clearCache();
1837
+ dom.remove();
1838
+ }
1839
+ };
1840
+ }
1841
+
1842
+ exports.AnimatedInterpolate = AnimatedInterpolate;
1843
+ exports.AnimatedNode = AnimatedNode;
1844
+ exports.AnimatedTiming = AnimatedTiming;
1845
+ exports.AnimatedValue = AnimatedValue;
1846
+ exports.AppContext = AppContext;
1847
+ exports.Container = Container;
1848
+ exports.EMPTY_ARRAY = EMPTY_ARRAY;
1849
+ exports.EMPTY_OBJECT = EMPTY_OBJECT;
1850
+ exports.Easing = Easing;
1851
+ exports.Frame = Frame;
1852
+ exports.Image = ImageView;
1853
+ exports.LinearGradient = LinearGradient;
1854
+ exports.ListView = ListView;
1855
+ exports.Node = Node;
1856
+ exports.RevasCanvas = RevasCanvas;
1857
+ exports.Root = Root;
1858
+ exports.ScrollView = ScrollView;
1859
+ exports.Text = Text;
1860
+ exports.Touchable = Touchable;
1861
+ exports.Transform = Transform;
1862
+ exports.View = View;
1863
+ exports.adapter = adapter;
1864
+ exports.applyAnimated = applyAnimated;
1865
+ exports.clamp = clamp;
1866
+ exports.flatten = flatten;
1867
+ exports.getChars = getChars;
1868
+ exports.getFrameFromNode = getFrameFromNode;
1869
+ exports.getMergedStyleFromNode = getMergedStyleFromNode;
1870
+ exports.getWords = getWords;
1871
+ exports.noop = noop;
1872
+ exports.now = now;
1873
+ exports.pushOpacity = pushOpacity;
1874
+ exports.render = render;
1875
+ exports.renderer = reconciler_default;
1876
+ exports.setShadow = setShadow;
1877
+ exports.sortByZIndexAscending = sortByZIndexAscending;
1878
+ exports.timing = timing;
1879
+ exports.withContext = withContext;
1880
+ //# sourceMappingURL=revas.cjs.map
1881
+ //# sourceMappingURL=revas.cjs.map