@meursyphus/flitter 0.0.6 → 0.0.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.
package/.eslintrc.cjs ADDED
@@ -0,0 +1,35 @@
1
+ module.exports = {
2
+ root: true,
3
+ parser: "@typescript-eslint/parser",
4
+ extends: [
5
+ "eslint:recommended",
6
+ "plugin:@typescript-eslint/recommended",
7
+ "prettier",
8
+ ],
9
+ plugins: ["@typescript-eslint"],
10
+ ignorePatterns: ["*.cjs"],
11
+ parserOptions: {
12
+ sourceType: "module",
13
+ ecmaVersion: 2020,
14
+ },
15
+ env: {
16
+ browser: true,
17
+ es2017: true,
18
+ node: true,
19
+ },
20
+ rules: {
21
+ "@typescript-eslint/no-explicit-any": "off",
22
+ "no-unused-vars": "off",
23
+ "@typescript-eslint/no-unused-vars": "off",
24
+ "no-case-declarations": "off",
25
+ "@typescript-eslint/consistent-type-imports": "error",
26
+ "@typescript-eslint/no-unused-vars": [
27
+ "error",
28
+ {
29
+ argsIgnorePattern: "^_",
30
+ varsIgnorePattern: "^_",
31
+ caughtErrorsIgnorePattern: "^_",
32
+ },
33
+ ],
34
+ },
35
+ };
package/.prettierrc ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "semi": true,
3
+ "trailingComma": "all",
4
+ "printWidth": 80,
5
+ "tabWidth": 2,
6
+ "useTabs": false,
7
+ "arrowParens": "avoid",
8
+ "endOfLine": "lf"
9
+ }
package/README.md CHANGED
@@ -11,9 +11,11 @@ For more details, visit [here](https://flitter.pages.dev).
11
11
  Getting started with Flitter is straightforward. Follow these steps to install and use Flitter in your React or Svelte projects. (Or you can implement widget component manually to support Flitter.)
12
12
 
13
13
  ### React
14
+
14
15
  ```bash
15
16
  npm i @meursyphus/flitter @meursyphus/flitter-react
16
17
  ```
18
+
17
19
  Example of using Flitter widgets in a React component:
18
20
 
19
21
  ```javascript
@@ -34,6 +36,7 @@ const App = () => {
34
36
  );
35
37
  };
36
38
  ```
39
+
37
40
  ### Svelte
38
41
 
39
42
  ```bash
@@ -67,4 +70,4 @@ npm i @meursyphus/flitter @meursyphus/flitter-svelte
67
70
 
68
71
  Flitter is open-source software freely available under the MIT license.
69
72
 
70
- For more information and documentation, refer to the [Flitter official documentation](https://flitter.pages.dev).
73
+ For more information and documentation, refer to the [Flitter official documentation](https://flitter.pages.dev).
package/dist/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # Flitter
2
+
3
+ Flitter is a framework that deals with SVG. Like React, it uses VDOM to manage state and optimize rendering. Since the library directly calculates the layout, it is much easier to visualize data than using D3. This provides a high level of control and flexibility for data visualization.
4
+
5
+ FlutterJs is a library inspired by Flutter, a cross-platform framework commonly used for mobile app development.
6
+
7
+ For more details, visit [here](https://flitter.pages.dev).
8
+
9
+ ## Getting Started
10
+
11
+ Getting started with Flitter is straightforward. Follow these steps to install and use Flitter in your React or Svelte projects. (Or you can implement widget component manually to support Flitter.)
12
+
13
+ ### React
14
+
15
+ ```bash
16
+ npm i @meursyphus/flitter @meursyphus/flitter-react
17
+ ```
18
+
19
+ Example of using Flitter widgets in a React component:
20
+
21
+ ```javascript
22
+ import { Container, Alignment, Text, TextStyle } from '@meursyphus/flitter';
23
+ import Widget from '@meursyphus/flitter-react';
24
+
25
+ const App = () => {
26
+ return (
27
+ <Widget
28
+ width="600px"
29
+ height="300px"
30
+ widget={Container({
31
+ alignment: Alignment.center,
32
+ color: 'lightblue',
33
+ child: Text("Hello, Flitter!", style: TextStyle({ fontSize: 30, weight: 'bold' }))
34
+ })}
35
+ />
36
+ );
37
+ };
38
+ ```
39
+
40
+ ### Svelte
41
+
42
+ ```bash
43
+ npm i @meursyphus/flitter @meursyphus/flitter-svelte
44
+ ```
45
+
46
+ ```svelte
47
+ <script>
48
+ import { Container, Alignment, Text, TextStyle } from '@meursyphus/flitter';
49
+ import Widget from '@meursyphus/flitter-svelte';
50
+ </script>
51
+
52
+ <Widget
53
+ width="600px"
54
+ height="300px"
55
+ widget={Container({
56
+ alignment: Alignment.center,
57
+ color: 'lightblue',
58
+ child: Text("Hello, Flitter!", style: TextStyle({ fontSize: 30, weight: 'bold' }))
59
+ })}
60
+ />
61
+ ```
62
+
63
+ ## Features
64
+
65
+ - Provides high-resolution, resolution-independent visualizations based on SVG
66
+ - Simplifies SVG manipulation with a component-based approach
67
+ - Allows for quick learning and development with a syntax similar to Flutter
68
+
69
+ ## License
70
+
71
+ Flitter is open-source software freely available under the MIT license.
72
+
73
+ For more information and documentation, refer to the [Flitter official documentation](https://flitter.pages.dev).
@@ -351,7 +351,7 @@ var lerp_default = lerp;
351
351
  // src/utils/getTextSize.ts
352
352
  var OFFSET = 20;
353
353
  var SCALE = 100;
354
- var defaultWidthMapStr = `007LLmW'55;N0500LLLLLLLLLL00NNNLzWW\\\\WQb\\0FWLg\\bWb\\WQ\\WrWWQ000CL5LLFLL0LL**F*gLLLL5F0LF\\FFF5.5N`;
354
+ var defaultWidthMapStr = "007LLmW'55;N0500LLLLLLLLLL00NNNLzWW\\\\WQb\\0FWLg\\bWb\\WQ\\WrWWQ000CL5LLFLL0LL**F*gLLLL5F0LF\\FFF5.5N";
355
355
  var DEFAULT_FONT_SIZE = 12;
356
356
  var DEFAULT_FONT_FAMILY = "sans-serif";
357
357
  var DEFAULT_FONT = `${DEFAULT_FONT_SIZE}px ${DEFAULT_FONT_FAMILY}`;
@@ -12226,9 +12226,7 @@ var RenderView = class extends RenderObject_default {
12226
12226
  width: constraint.maxWidth,
12227
12227
  height: constraint.maxHeight
12228
12228
  });
12229
- this.children.forEach(
12230
- (child) => child.layout(constraints_default.loose(this.size))
12231
- );
12229
+ this.children.forEach((child) => child.layout(constraints_default.loose(this.size)));
12232
12230
  }
12233
12231
  paint(context, clipId, matrix4, opacity) {
12234
12232
  if (this.size.width === 0 || this.size.height === 0)
@@ -12670,6 +12668,12 @@ var Scheduler = class {
12670
12668
  this.persistenceCallbacks = [];
12671
12669
  this.postFrameCallbacks = [];
12672
12670
  }
12671
+ consumePostCallbacks() {
12672
+ this.postFrameCallbacks.forEach((callback) => {
12673
+ callback();
12674
+ });
12675
+ this.postFrameCallbacks = [];
12676
+ }
12673
12677
  schedule() {
12674
12678
  switch (this.phase) {
12675
12679
  case 0 /* idle */:
@@ -12686,9 +12690,7 @@ var Scheduler = class {
12686
12690
  callback();
12687
12691
  });
12688
12692
  this.phase = 2 /* postFrameCallbacks */;
12689
- this.postFrameCallbacks.forEach((callback) => {
12690
- callback();
12691
- });
12693
+ this.consumePostCallbacks();
12692
12694
  this.postFrameCallbacks = [];
12693
12695
  this.phase = 0 /* idle */;
12694
12696
  }
@@ -12705,25 +12707,25 @@ var Scheduler_default = Scheduler;
12705
12707
  var RenderFrameDispatcher = class {
12706
12708
  constructor({ onFrame } = {}) {
12707
12709
  __publicField(this, "onFrame");
12710
+ // Actually we don't need to invoke browser to render because browser automatically render its own state periodically
12711
+ // so Here we just call onFrame callback.
12712
+ __publicField(this, "idle", true);
12708
12713
  this.onFrame = onFrame;
12709
12714
  }
12710
12715
  setOnFrame(callback) {
12711
12716
  this.onFrame = () => callback();
12712
12717
  }
12713
- // Actually we dont need to invoke browser to render because browser automatically render its own state periodically
12714
- // so Here we just call onFrame callback.
12715
12718
  dispatch() {
12716
- if (typeof window === "undefined") {
12717
- setTimeout(() => {
12718
- var _a;
12719
- (_a = this.onFrame) == null ? void 0 : _a.call(this);
12720
- }, 0);
12721
- } else {
12722
- window.requestAnimationFrame(() => {
12723
- var _a;
12724
- (_a = this.onFrame) == null ? void 0 : _a.call(this);
12725
- });
12726
- }
12719
+ if (typeof window === "undefined")
12720
+ return;
12721
+ if (!this.idle)
12722
+ return;
12723
+ this.idle = false;
12724
+ window.requestAnimationFrame(() => {
12725
+ var _a;
12726
+ (_a = this.onFrame) == null ? void 0 : _a.call(this);
12727
+ this.idle = true;
12728
+ });
12727
12729
  }
12728
12730
  };
12729
12731
  var RenderFrameDispatcher_default = RenderFrameDispatcher;
@@ -12758,7 +12760,6 @@ var AppRunner = class {
12758
12760
  __publicField(this, "buildOwner");
12759
12761
  __publicField(this, "renderOwner");
12760
12762
  __publicField(this, "scheduler");
12761
- __publicField(this, "renderDispatcher");
12762
12763
  __publicField(this, "didRun", false);
12763
12764
  __publicField(this, "widget");
12764
12765
  this.viewSize = ssrSize;
@@ -12782,13 +12783,12 @@ var AppRunner = class {
12782
12783
  this.buildOwner = buildOwner;
12783
12784
  this.renderOwner = renderOwner;
12784
12785
  this.scheduler = scheduler;
12785
- this.renderDispatcher = renderDispatcher;
12786
12786
  this.renderContext = renderContext;
12787
12787
  }
12788
12788
  runApp(widget) {
12789
12789
  this.widget = widget;
12790
12790
  if (this.viewSize == null)
12791
- return ``;
12791
+ return "";
12792
12792
  this.root = new RenderObjectToWidgetAdapter_default({
12793
12793
  app: widget,
12794
12794
  buildOwner: this.buildOwner,
@@ -12800,6 +12800,7 @@ var AppRunner = class {
12800
12800
  this.root.renderObject.constraints = constraints_default.tight(this.viewSize);
12801
12801
  this.didRun = true;
12802
12802
  this.draw();
12803
+ this.scheduler.consumePostCallbacks();
12803
12804
  return this.renderContext.view.innerHTML;
12804
12805
  }
12805
12806
  setConfig({
@@ -17492,16 +17493,19 @@ var RenderGestureDetector = class extends SingleChildRenderObject_default {
17492
17493
  drag: this.onDragMove,
17493
17494
  dragend: this.onDragEnd
17494
17495
  };
17495
- return TypedObject_default.keys(listeners).reduce((acc, key) => {
17496
- acc[key] = (e) => {
17497
- var _a;
17498
- if (this.bubble[key]) {
17499
- this.dispatchParent(e);
17500
- }
17501
- (_a = listeners[key]) == null ? void 0 : _a.call(listeners, e);
17502
- };
17503
- return acc;
17504
- }, {});
17496
+ return TypedObject_default.keys(listeners).reduce(
17497
+ (acc, key) => {
17498
+ acc[key] = (e) => {
17499
+ var _a;
17500
+ if (this.bubble[key]) {
17501
+ this.dispatchParent(e);
17502
+ }
17503
+ (_a = listeners[key]) == null ? void 0 : _a.call(listeners, e);
17504
+ };
17505
+ return acc;
17506
+ },
17507
+ {}
17508
+ );
17505
17509
  }
17506
17510
  attach(ownerElement) {
17507
17511
  super.attach(ownerElement);
@@ -3328,6 +3328,7 @@ declare class Scheduler {
3328
3328
  private persistenceCallbacks;
3329
3329
  private postFrameCallbacks;
3330
3330
  constructor();
3331
+ consumePostCallbacks(): void;
3331
3332
  schedule(): void;
3332
3333
  private performSchedule;
3333
3334
  addPersistenceCallbacks(callback: () => void): void;
@@ -3345,6 +3346,7 @@ declare class RenderFrameDispatcher {
3345
3346
  onFrame?: () => void;
3346
3347
  });
3347
3348
  setOnFrame(callback: () => void): void;
3349
+ private idle;
3348
3350
  dispatch(): void;
3349
3351
  }
3350
3352
 
@@ -3513,7 +3515,6 @@ declare class AppRunner {
3513
3515
  private buildOwner;
3514
3516
  private renderOwner;
3515
3517
  private scheduler;
3516
- private renderDispatcher;
3517
3518
  constructor({ view, document: _document, window: _window, ssrSize, }: AppRunnerProps);
3518
3519
  private didRun;
3519
3520
  private widget;
@@ -3328,6 +3328,7 @@ declare class Scheduler {
3328
3328
  private persistenceCallbacks;
3329
3329
  private postFrameCallbacks;
3330
3330
  constructor();
3331
+ consumePostCallbacks(): void;
3331
3332
  schedule(): void;
3332
3333
  private performSchedule;
3333
3334
  addPersistenceCallbacks(callback: () => void): void;
@@ -3345,6 +3346,7 @@ declare class RenderFrameDispatcher {
3345
3346
  onFrame?: () => void;
3346
3347
  });
3347
3348
  setOnFrame(callback: () => void): void;
3349
+ private idle;
3348
3350
  dispatch(): void;
3349
3351
  }
3350
3352
 
@@ -3513,7 +3515,6 @@ declare class AppRunner {
3513
3515
  private buildOwner;
3514
3516
  private renderOwner;
3515
3517
  private scheduler;
3516
- private renderDispatcher;
3517
3518
  constructor({ view, document: _document, window: _window, ssrSize, }: AppRunnerProps);
3518
3519
  private didRun;
3519
3520
  private widget;
@@ -867,7 +867,7 @@
867
867
  // src/utils/getTextSize.ts
868
868
  var OFFSET = 20;
869
869
  var SCALE = 100;
870
- var defaultWidthMapStr = `007LLmW'55;N0500LLLLLLLLLL00NNNLzWW\\\\WQb\\0FWLg\\bWb\\WQ\\WrWWQ000CL5LLFLL0LL**F*gLLLL5F0LF\\FFF5.5N`;
870
+ var defaultWidthMapStr = "007LLmW'55;N0500LLLLLLLLLL00NNNLzWW\\\\WQb\\0FWLg\\bWb\\WQ\\WrWWQ000CL5LLFLL0LL**F*gLLLL5F0LF\\FFF5.5N";
871
871
  var DEFAULT_FONT_SIZE = 12;
872
872
  var DEFAULT_FONT_FAMILY = "sans-serif";
873
873
  var DEFAULT_FONT = `${DEFAULT_FONT_SIZE}px ${DEFAULT_FONT_FAMILY}`;
@@ -12940,9 +12940,7 @@
12940
12940
  width: constraint.maxWidth,
12941
12941
  height: constraint.maxHeight
12942
12942
  });
12943
- this.children.forEach(
12944
- (child) => child.layout(constraints_default.loose(this.size))
12945
- );
12943
+ this.children.forEach((child) => child.layout(constraints_default.loose(this.size)));
12946
12944
  }
12947
12945
  paint(context, clipId, matrix4, opacity) {
12948
12946
  if (this.size.width === 0 || this.size.height === 0)
@@ -13384,6 +13382,12 @@
13384
13382
  this.persistenceCallbacks = [];
13385
13383
  this.postFrameCallbacks = [];
13386
13384
  }
13385
+ consumePostCallbacks() {
13386
+ this.postFrameCallbacks.forEach((callback) => {
13387
+ callback();
13388
+ });
13389
+ this.postFrameCallbacks = [];
13390
+ }
13387
13391
  schedule() {
13388
13392
  switch (this.phase) {
13389
13393
  case 0 /* idle */:
@@ -13400,9 +13404,7 @@
13400
13404
  callback();
13401
13405
  });
13402
13406
  this.phase = 2 /* postFrameCallbacks */;
13403
- this.postFrameCallbacks.forEach((callback) => {
13404
- callback();
13405
- });
13407
+ this.consumePostCallbacks();
13406
13408
  this.postFrameCallbacks = [];
13407
13409
  this.phase = 0 /* idle */;
13408
13410
  }
@@ -13419,25 +13421,25 @@
13419
13421
  var RenderFrameDispatcher = class {
13420
13422
  constructor({ onFrame } = {}) {
13421
13423
  __publicField(this, "onFrame");
13424
+ // Actually we don't need to invoke browser to render because browser automatically render its own state periodically
13425
+ // so Here we just call onFrame callback.
13426
+ __publicField(this, "idle", true);
13422
13427
  this.onFrame = onFrame;
13423
13428
  }
13424
13429
  setOnFrame(callback) {
13425
13430
  this.onFrame = () => callback();
13426
13431
  }
13427
- // Actually we dont need to invoke browser to render because browser automatically render its own state periodically
13428
- // so Here we just call onFrame callback.
13429
13432
  dispatch() {
13430
- if (typeof window === "undefined") {
13431
- setTimeout(() => {
13432
- var _a;
13433
- (_a = this.onFrame) == null ? void 0 : _a.call(this);
13434
- }, 0);
13435
- } else {
13436
- window.requestAnimationFrame(() => {
13437
- var _a;
13438
- (_a = this.onFrame) == null ? void 0 : _a.call(this);
13439
- });
13440
- }
13433
+ if (typeof window === "undefined")
13434
+ return;
13435
+ if (!this.idle)
13436
+ return;
13437
+ this.idle = false;
13438
+ window.requestAnimationFrame(() => {
13439
+ var _a;
13440
+ (_a = this.onFrame) == null ? void 0 : _a.call(this);
13441
+ this.idle = true;
13442
+ });
13441
13443
  }
13442
13444
  };
13443
13445
  var RenderFrameDispatcher_default = RenderFrameDispatcher;
@@ -13472,7 +13474,6 @@
13472
13474
  __publicField(this, "buildOwner");
13473
13475
  __publicField(this, "renderOwner");
13474
13476
  __publicField(this, "scheduler");
13475
- __publicField(this, "renderDispatcher");
13476
13477
  __publicField(this, "didRun", false);
13477
13478
  __publicField(this, "widget");
13478
13479
  this.viewSize = ssrSize;
@@ -13496,13 +13497,12 @@
13496
13497
  this.buildOwner = buildOwner;
13497
13498
  this.renderOwner = renderOwner;
13498
13499
  this.scheduler = scheduler;
13499
- this.renderDispatcher = renderDispatcher;
13500
13500
  this.renderContext = renderContext;
13501
13501
  }
13502
13502
  runApp(widget) {
13503
13503
  this.widget = widget;
13504
13504
  if (this.viewSize == null)
13505
- return ``;
13505
+ return "";
13506
13506
  this.root = new RenderObjectToWidgetAdapter_default({
13507
13507
  app: widget,
13508
13508
  buildOwner: this.buildOwner,
@@ -13514,6 +13514,7 @@
13514
13514
  this.root.renderObject.constraints = constraints_default.tight(this.viewSize);
13515
13515
  this.didRun = true;
13516
13516
  this.draw();
13517
+ this.scheduler.consumePostCallbacks();
13517
13518
  return this.renderContext.view.innerHTML;
13518
13519
  }
13519
13520
  setConfig({
@@ -19085,16 +19086,19 @@
19085
19086
  drag: this.onDragMove,
19086
19087
  dragend: this.onDragEnd
19087
19088
  };
19088
- return TypedObject_default.keys(listeners).reduce((acc, key) => {
19089
- acc[key] = (e) => {
19090
- var _a;
19091
- if (this.bubble[key]) {
19092
- this.dispatchParent(e);
19093
- }
19094
- (_a = listeners[key]) == null ? void 0 : _a.call(listeners, e);
19095
- };
19096
- return acc;
19097
- }, {});
19089
+ return TypedObject_default.keys(listeners).reduce(
19090
+ (acc, key) => {
19091
+ acc[key] = (e) => {
19092
+ var _a;
19093
+ if (this.bubble[key]) {
19094
+ this.dispatchParent(e);
19095
+ }
19096
+ (_a = listeners[key]) == null ? void 0 : _a.call(listeners, e);
19097
+ };
19098
+ return acc;
19099
+ },
19100
+ {}
19101
+ );
19098
19102
  }
19099
19103
  attach(ownerElement) {
19100
19104
  super.attach(ownerElement);
@@ -351,7 +351,7 @@ var lerp_default = lerp;
351
351
  // src/utils/getTextSize.ts
352
352
  var OFFSET = 20;
353
353
  var SCALE = 100;
354
- var defaultWidthMapStr = `007LLmW'55;N0500LLLLLLLLLL00NNNLzWW\\\\WQb\\0FWLg\\bWb\\WQ\\WrWWQ000CL5LLFLL0LL**F*gLLLL5F0LF\\FFF5.5N`;
354
+ var defaultWidthMapStr = "007LLmW'55;N0500LLLLLLLLLL00NNNLzWW\\\\WQb\\0FWLg\\bWb\\WQ\\WrWWQ000CL5LLFLL0LL**F*gLLLL5F0LF\\FFF5.5N";
355
355
  var DEFAULT_FONT_SIZE = 12;
356
356
  var DEFAULT_FONT_FAMILY = "sans-serif";
357
357
  var DEFAULT_FONT = `${DEFAULT_FONT_SIZE}px ${DEFAULT_FONT_FAMILY}`;
@@ -12226,9 +12226,7 @@ var RenderView = class extends RenderObject_default {
12226
12226
  width: constraint.maxWidth,
12227
12227
  height: constraint.maxHeight
12228
12228
  });
12229
- this.children.forEach(
12230
- (child) => child.layout(constraints_default.loose(this.size))
12231
- );
12229
+ this.children.forEach((child) => child.layout(constraints_default.loose(this.size)));
12232
12230
  }
12233
12231
  paint(context, clipId, matrix4, opacity) {
12234
12232
  if (this.size.width === 0 || this.size.height === 0)
@@ -12670,6 +12668,12 @@ var Scheduler = class {
12670
12668
  this.persistenceCallbacks = [];
12671
12669
  this.postFrameCallbacks = [];
12672
12670
  }
12671
+ consumePostCallbacks() {
12672
+ this.postFrameCallbacks.forEach((callback) => {
12673
+ callback();
12674
+ });
12675
+ this.postFrameCallbacks = [];
12676
+ }
12673
12677
  schedule() {
12674
12678
  switch (this.phase) {
12675
12679
  case 0 /* idle */:
@@ -12686,9 +12690,7 @@ var Scheduler = class {
12686
12690
  callback();
12687
12691
  });
12688
12692
  this.phase = 2 /* postFrameCallbacks */;
12689
- this.postFrameCallbacks.forEach((callback) => {
12690
- callback();
12691
- });
12693
+ this.consumePostCallbacks();
12692
12694
  this.postFrameCallbacks = [];
12693
12695
  this.phase = 0 /* idle */;
12694
12696
  }
@@ -12705,25 +12707,25 @@ var Scheduler_default = Scheduler;
12705
12707
  var RenderFrameDispatcher = class {
12706
12708
  constructor({ onFrame } = {}) {
12707
12709
  __publicField(this, "onFrame");
12710
+ // Actually we don't need to invoke browser to render because browser automatically render its own state periodically
12711
+ // so Here we just call onFrame callback.
12712
+ __publicField(this, "idle", true);
12708
12713
  this.onFrame = onFrame;
12709
12714
  }
12710
12715
  setOnFrame(callback) {
12711
12716
  this.onFrame = () => callback();
12712
12717
  }
12713
- // Actually we dont need to invoke browser to render because browser automatically render its own state periodically
12714
- // so Here we just call onFrame callback.
12715
12718
  dispatch() {
12716
- if (typeof window === "undefined") {
12717
- setTimeout(() => {
12718
- var _a;
12719
- (_a = this.onFrame) == null ? void 0 : _a.call(this);
12720
- }, 0);
12721
- } else {
12722
- window.requestAnimationFrame(() => {
12723
- var _a;
12724
- (_a = this.onFrame) == null ? void 0 : _a.call(this);
12725
- });
12726
- }
12719
+ if (typeof window === "undefined")
12720
+ return;
12721
+ if (!this.idle)
12722
+ return;
12723
+ this.idle = false;
12724
+ window.requestAnimationFrame(() => {
12725
+ var _a;
12726
+ (_a = this.onFrame) == null ? void 0 : _a.call(this);
12727
+ this.idle = true;
12728
+ });
12727
12729
  }
12728
12730
  };
12729
12731
  var RenderFrameDispatcher_default = RenderFrameDispatcher;
@@ -12758,7 +12760,6 @@ var AppRunner = class {
12758
12760
  __publicField(this, "buildOwner");
12759
12761
  __publicField(this, "renderOwner");
12760
12762
  __publicField(this, "scheduler");
12761
- __publicField(this, "renderDispatcher");
12762
12763
  __publicField(this, "didRun", false);
12763
12764
  __publicField(this, "widget");
12764
12765
  this.viewSize = ssrSize;
@@ -12782,13 +12783,12 @@ var AppRunner = class {
12782
12783
  this.buildOwner = buildOwner;
12783
12784
  this.renderOwner = renderOwner;
12784
12785
  this.scheduler = scheduler;
12785
- this.renderDispatcher = renderDispatcher;
12786
12786
  this.renderContext = renderContext;
12787
12787
  }
12788
12788
  runApp(widget) {
12789
12789
  this.widget = widget;
12790
12790
  if (this.viewSize == null)
12791
- return ``;
12791
+ return "";
12792
12792
  this.root = new RenderObjectToWidgetAdapter_default({
12793
12793
  app: widget,
12794
12794
  buildOwner: this.buildOwner,
@@ -12800,6 +12800,7 @@ var AppRunner = class {
12800
12800
  this.root.renderObject.constraints = constraints_default.tight(this.viewSize);
12801
12801
  this.didRun = true;
12802
12802
  this.draw();
12803
+ this.scheduler.consumePostCallbacks();
12803
12804
  return this.renderContext.view.innerHTML;
12804
12805
  }
12805
12806
  setConfig({
@@ -17492,16 +17493,19 @@ var RenderGestureDetector = class extends SingleChildRenderObject_default {
17492
17493
  drag: this.onDragMove,
17493
17494
  dragend: this.onDragEnd
17494
17495
  };
17495
- return TypedObject_default.keys(listeners).reduce((acc, key) => {
17496
- acc[key] = (e) => {
17497
- var _a;
17498
- if (this.bubble[key]) {
17499
- this.dispatchParent(e);
17500
- }
17501
- (_a = listeners[key]) == null ? void 0 : _a.call(listeners, e);
17502
- };
17503
- return acc;
17504
- }, {});
17496
+ return TypedObject_default.keys(listeners).reduce(
17497
+ (acc, key) => {
17498
+ acc[key] = (e) => {
17499
+ var _a;
17500
+ if (this.bubble[key]) {
17501
+ this.dispatchParent(e);
17502
+ }
17503
+ (_a = listeners[key]) == null ? void 0 : _a.call(listeners, e);
17504
+ };
17505
+ return acc;
17506
+ },
17507
+ {}
17508
+ );
17505
17509
  }
17506
17510
  attach(ownerElement) {
17507
17511
  super.attach(ownerElement);
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@meursyphus/flitter",
3
+ "version": "0.0.7",
4
+ "description": "A declarative, widget-based library built on SVG for simplifying data visualization with a Flutter-like syntax.",
5
+ "keywords": [
6
+ "flitter",
7
+ "data visualization",
8
+ "SVG",
9
+ "widget-based",
10
+ "declarative",
11
+ "flutter"
12
+ ],
13
+ "homepage": "https://flitter.pages.dev",
14
+ "scripts": {
15
+ "test": "echo \"Error: no test specified\" && exit 1",
16
+ "build": "tsup && npm run copy-package && npm run copy-readme && cd dist && npm run fix-package",
17
+ "copy-package": "cp package.json dist/package.json",
18
+ "copy-readme": "cp README.md dist/README.md",
19
+ "fix-package": "npm pkg set main=./index.cjs module=./index.js exports.default=./index.js exports.import=./index.js types=./index.d.ts",
20
+ "lint": "eslint src/**",
21
+ "postbuild": "echo \"Build complete. Please run: \n\ncd dist\nnpm publish\n\"",
22
+ "format": "prettier --write ."
23
+ },
24
+ "devDependencies": {
25
+ "@typescript-eslint/eslint-plugin": "^6.16.0",
26
+ "cp": "^0.2.0",
27
+ "eslint": "^8.56.0",
28
+ "eslint-config-standard-with-typescript": "^43.0.0",
29
+ "eslint-plugin-import": "^2.29.1",
30
+ "eslint-plugin-n": "^16.6.0",
31
+ "eslint-plugin-promise": "^6.1.1",
32
+ "prettier": "^3.2.5",
33
+ "tsup": "^8.0.1",
34
+ "typescript": "^5.3.3"
35
+ },
36
+ "dependencies": {
37
+ "color-rgba": "^3.0.0",
38
+ "popmotion": "^11.0.5",
39
+ "short-unique-id": "^5.0.3"
40
+ },
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "git+https://github.com/meursyphus/flitter.git"
44
+ },
45
+ "author": "meursyphus",
46
+ "license": "MIT",
47
+ "bugs": {
48
+ "url": "https://github.com/meursyphus/flitter/issues"
49
+ },
50
+ "main": "./index.cjs",
51
+ "types": "./index.d.ts",
52
+ "type": "module",
53
+ "publishConfig": {
54
+ "access": "public"
55
+ },
56
+ "module": "./index.js",
57
+ "exports": {
58
+ "default": "./index.js",
59
+ "import": "./index.js"
60
+ }
61
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meursyphus/flitter",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "A declarative, widget-based library built on SVG for simplifying data visualization with a Flutter-like syntax.",
5
5
  "keywords": [
6
6
  "flitter",
@@ -18,7 +18,8 @@
18
18
  "copy-readme": "cp README.md dist/README.md",
19
19
  "fix-package": "npm pkg set main=./index.cjs module=./index.js exports.default=./index.js exports.import=./index.js types=./index.d.ts",
20
20
  "lint": "eslint src/**",
21
- "postbuild": "echo \"Build complete. Please run: \n\ncd dist\nnpm publish\n\""
21
+ "postbuild": "echo \"Build complete. Please run: \n\ncd dist\nnpm publish\n\"",
22
+ "format": "prettier --write ."
22
23
  },
23
24
  "devDependencies": {
24
25
  "@typescript-eslint/eslint-plugin": "^6.16.0",
@@ -28,6 +29,7 @@
28
29
  "eslint-plugin-import": "^2.29.1",
29
30
  "eslint-plugin-n": "^16.6.0",
30
31
  "eslint-plugin-promise": "^6.1.1",
32
+ "prettier": "^3.2.5",
31
33
  "tsup": "^8.0.1",
32
34
  "typescript": "^5.3.3"
33
35
  },
@@ -45,15 +47,10 @@
45
47
  "bugs": {
46
48
  "url": "https://github.com/meursyphus/flitter/issues"
47
49
  },
48
- "main": "./index.cjs",
49
- "types": "./index.d.ts",
50
+ "main": "dist/index.js",
51
+ "types": "dist/index.d.ts",
50
52
  "type": "module",
51
53
  "publishConfig": {
52
54
  "access": "public"
53
- },
54
- "module": "./index.js",
55
- "exports": {
56
- "default": "./index.js",
57
- "import": "./index.js"
58
55
  }
59
56
  }
package/tsconfig.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "baseUrl": ".", // 기준 경로를 현재 디렉토리로 설정
4
+ "paths": {
5
+ "src/*": ["./src/*"] // 'src' 별칭을 src 디렉토리에 매핑
6
+ },
7
+ "target": "ES6",
8
+ "useDefineForClassFields": true,
9
+ "module": "ES2022",
10
+ "moduleResolution": "Node",
11
+ "declaration": true,
12
+ "emitDeclarationOnly": true,
13
+ "forceConsistentCasingInFileNames": true,
14
+ "outDir": "package"
15
+ },
16
+ "include": ["src/index.ts"],
17
+ "exclude": ["node_modules"]
18
+ }
package/tsup.config.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { defineConfig } from "tsup";
2
+
3
+ export default defineConfig({
4
+ entry: ["src/index.ts"],
5
+ splitting: true,
6
+ sourcemap: false,
7
+ clean: true,
8
+ dts: true,
9
+ format: ["iife", "cjs", "esm"],
10
+ });