flet-box 1.0.3 → 1.0.5

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 (172) hide show
  1. package/README.md +10 -0
  2. package/bin/cli.js +15 -0
  3. package/bin/commands/checkApi.js +761 -0
  4. package/bin/commands/create.js +77 -5
  5. package/bin/utils/dtsProps.js +191 -0
  6. package/bin/utils/moduleExports.js +165 -0
  7. package/bin/utils/neutralise.js +64 -0
  8. package/bin/utils/templates.js +366 -27
  9. package/docs/CONTRIBUTING.md +156 -0
  10. package/docs/README.md +68 -0
  11. package/docs/arquitectura.md +164 -0
  12. package/docs/cli/README.md +542 -0
  13. package/docs/guides/README.md +33 -0
  14. package/docs/guides/app-templates.md +197 -0
  15. package/docs/guides/compatibility.md +95 -0
  16. package/docs/guides/embedding.md +284 -0
  17. package/docs/guides/first-app.md +208 -0
  18. package/docs/guides/frontend-services.md +171 -0
  19. package/docs/guides/minification-and-protection.md +260 -0
  20. package/docs/guides/mobile-and-platforms.md +439 -0
  21. package/docs/guides/online-updates.md +196 -0
  22. package/docs/guides/router.md +282 -0
  23. package/docs/guides/state.md +283 -0
  24. package/docs/guides/syntax-philosophy.md +150 -0
  25. package/docs/guides/utilities.md +241 -0
  26. package/docs/guides/widget-structure.md +163 -0
  27. package/docs/server/README.md +68 -0
  28. package/docs/server/START_HERE.md +121 -0
  29. package/docs/server/api.md +225 -0
  30. package/docs/server/data-services.md +300 -0
  31. package/docs/server/deployment.md +113 -0
  32. package/docs/server/security.md +196 -0
  33. package/docs/services/README.md +79 -0
  34. package/docs/services/RamStore.md +84 -0
  35. package/docs/services/Session.md +84 -0
  36. package/docs/services/Storage.md +88 -0
  37. package/docs/services/http.md +86 -0
  38. package/docs/tools/README.md +138 -0
  39. package/docs/tools/animation.md +87 -0
  40. package/docs/tools/async-ids-log.md +80 -0
  41. package/docs/tools/device.md +132 -0
  42. package/docs/tools/introspection.md +67 -0
  43. package/docs/tools/lists.md +96 -0
  44. package/docs/tools/markdown.md +79 -0
  45. package/docs/tools/reactivity.md +288 -0
  46. package/docs/tools/state.md +103 -0
  47. package/docs/tools/styling.md +92 -0
  48. package/docs/tools/text-and-time.md +89 -0
  49. package/docs/tools/theme.md +102 -0
  50. package/docs/tools/validation.md +75 -0
  51. package/docs/tools/visual-effects.md +84 -0
  52. package/docs/widget/Accordion.md +144 -0
  53. package/docs/widget/AdMob.md +144 -0
  54. package/docs/widget/AdSense.md +133 -0
  55. package/docs/widget/AdaptiveScaffold.md +105 -0
  56. package/docs/widget/AlertDialog.md +103 -0
  57. package/docs/widget/AnimatedBox.md +130 -0
  58. package/docs/widget/AnimatedText.md +123 -0
  59. package/docs/widget/AppBar.md +118 -0
  60. package/docs/widget/Audio.md +135 -0
  61. package/docs/widget/Avatar.md +119 -0
  62. package/docs/widget/Badge.md +128 -0
  63. package/docs/widget/BottomNavigation.md +116 -0
  64. package/docs/widget/BottomSheet.md +125 -0
  65. package/docs/widget/Button.md +137 -0
  66. package/docs/widget/COMMON_PROPS.md +150 -0
  67. package/docs/widget/Card.md +125 -0
  68. package/docs/widget/Carousel.md +151 -0
  69. package/docs/widget/Chart.md +151 -0
  70. package/docs/widget/Checkbox.md +118 -0
  71. package/docs/widget/Chip.md +126 -0
  72. package/docs/widget/CircularBar.md +168 -0
  73. package/docs/widget/CircularChart.md +164 -0
  74. package/docs/widget/CodeViewer.md +130 -0
  75. package/docs/widget/CollapsibleSideBar.md +112 -0
  76. package/docs/widget/Column.md +129 -0
  77. package/docs/widget/Container.md +136 -0
  78. package/docs/widget/DataTable.md +150 -0
  79. package/docs/widget/Divider.md +109 -0
  80. package/docs/widget/DraggBox.md +129 -0
  81. package/docs/widget/Drawer.md +135 -0
  82. package/docs/widget/DrawerItem.md +98 -0
  83. package/docs/widget/Dropdown.md +139 -0
  84. package/docs/widget/DroppBox.md +152 -0
  85. package/docs/widget/FloatingActionButton.md +120 -0
  86. package/docs/widget/GridView.md +140 -0
  87. package/docs/widget/Icon.md +117 -0
  88. package/docs/widget/Image.md +125 -0
  89. package/docs/widget/Input.md +151 -0
  90. package/docs/widget/Inspector.md +92 -0
  91. package/docs/widget/InstallButton.md +128 -0
  92. package/docs/widget/ListTile.md +132 -0
  93. package/docs/widget/ListView.md +138 -0
  94. package/docs/widget/Markdown.md +175 -0
  95. package/docs/widget/MatrixRain.md +122 -0
  96. package/docs/widget/Modal.md +129 -0
  97. package/docs/widget/Pagination.md +135 -0
  98. package/docs/widget/ParallaxBox.md +128 -0
  99. package/docs/widget/ProgressBar.md +130 -0
  100. package/docs/widget/QRCode.md +117 -0
  101. package/docs/widget/README.md +188 -0
  102. package/docs/widget/Radio.md +123 -0
  103. package/docs/widget/Rating.md +131 -0
  104. package/docs/widget/Row.md +131 -0
  105. package/docs/widget/START_HERE.md +146 -0
  106. package/docs/widget/Scaffold.md +152 -0
  107. package/docs/widget/Skeleton.md +130 -0
  108. package/docs/widget/Slider.md +146 -0
  109. package/docs/widget/SnackBar.md +102 -0
  110. package/docs/widget/Stack.md +128 -0
  111. package/docs/widget/Stepper.md +145 -0
  112. package/docs/widget/Switch.md +118 -0
  113. package/docs/widget/Tabs.md +124 -0
  114. package/docs/widget/Text.md +133 -0
  115. package/docs/widget/Tooltip.md +145 -0
  116. package/docs/widget/TreeView.md +176 -0
  117. package/docs/widget/Video.md +127 -0
  118. package/docs/widget/_template.md +61 -0
  119. package/package.json +4 -2
  120. package/src/animations/AnimatedBox.js +32 -1
  121. package/src/animations/AnimatedText.js +7 -3
  122. package/src/animations/MatrixRain.js +37 -12
  123. package/src/animations/ParallaxBox.js +16 -3
  124. package/src/animations/animate.js +187 -58
  125. package/src/animations/index.js +1 -0
  126. package/src/core/runApp.js +13 -1
  127. package/src/create-index.sh +1 -1
  128. package/src/index.d.ts +227 -91
  129. package/src/index.js +1 -0
  130. package/src/navigations/AdaptiveScaffold.js +11 -2
  131. package/src/navigations/AppBar.js +8 -2
  132. package/src/navigations/BottomNavigation.js +24 -5
  133. package/src/navigations/DrawerItem.js +16 -3
  134. package/src/navigations/Scaffold.js +8 -1
  135. package/src/navigations/Tabs.js +40 -8
  136. package/src/tools/dimensions.js +11 -3
  137. package/src/tools/useState.js +139 -101
  138. package/src/utils/getWidgetProps.js +5 -3
  139. package/src/widget-factory/assignProps.js +30 -11
  140. package/src/widget-factory/processProps.js +17 -5
  141. package/src/widget-factory/reactiveValue.js +172 -0
  142. package/src/widget-factory/translateProps.js +777 -901
  143. package/src/widget-factory/warnings.js +15 -0
  144. package/src/widget-factory/widgetFactory.js +27 -0
  145. package/src/widgets/Accordion.js +6 -5
  146. package/src/widgets/AlertDialog.js +7 -5
  147. package/src/widgets/Audio.js +30 -8
  148. package/src/widgets/BottomSheet.js +24 -1
  149. package/src/widgets/Chart.js +4 -1
  150. package/src/widgets/Checkbox.js +16 -8
  151. package/src/widgets/CircularBar.js +12 -1
  152. package/src/widgets/CircularChart.js +4 -1
  153. package/src/widgets/CodeViewer.js +26 -8
  154. package/src/widgets/DataTable.js +11 -2
  155. package/src/widgets/Dropdown.js +5 -1
  156. package/src/widgets/FloatingActionButton.js +4 -7
  157. package/src/widgets/Image.js +7 -2
  158. package/src/widgets/Input.js +119 -6
  159. package/src/widgets/Inspector.js +16 -10
  160. package/src/widgets/ListView.js +80 -30
  161. package/src/widgets/Markdown.js +53 -8
  162. package/src/widgets/Modal.js +24 -1
  163. package/src/widgets/Pagination.js +6 -3
  164. package/src/widgets/ProgressBar.js +16 -13
  165. package/src/widgets/QRCode.js +9 -2
  166. package/src/widgets/Radio.js +11 -8
  167. package/src/widgets/Slider.js +26 -4
  168. package/src/widgets/SnackBar.js +20 -2
  169. package/src/widgets/Stack.js +36 -3
  170. package/src/widgets/Stepper.js +4 -3
  171. package/src/widgets/Switch.js +8 -5
  172. package/src/widgets/TreeView.js +3 -2
package/docs/README.md ADDED
@@ -0,0 +1,68 @@
1
+ # The FletBox Book
2
+
3
+ FletBox is a tiny UI framework: you describe your screen with plain JavaScript *widgets*, and FletBox turns them into real HTML that updates itself. No build config, no dependencies — just `import { Text, Button } from "flet-box"`.
4
+
5
+ This documentation is one continuous book. Start at **Chapter 0** and follow the "Continue reading" links at the bottom of every page; each page teaches you something real and links to the next.
6
+
7
+ ## The reading path
8
+
9
+ | # | Chapter | What you learn | Level |
10
+ | --- | --- | --- | --- |
11
+ | 0 | [Your first FletBox app, step by step](guides/first-app.md) | Your first running app in 20 minutes | Beginner |
12
+ | — | [Start here](widget/START_HERE.md) | How the widget book works | Beginner |
13
+ | 1–8 | [The widget book](widget/README.md) | Every widget: layout, input, data, chat, media, navigation | Beginner → Intermediate |
14
+ | 9 | [State, Router & Services](guides/state.md) | Shared state, navigation routes, storage, and HTTP | Intermediate |
15
+ | 10 | [Tools & Utilities](tools/README.md) | The helper functions that ship with the framework | Intermediate |
16
+ | 11 | [The CLI](cli/README.md) | Create, run, and build projects with `flet-box` | Intermediate |
17
+ | A | [Appendices](guides/minification-and-protection.md) | Minification, mobile, compatibility, embedding, online updates (OTA) | Advanced |
18
+
19
+ > **Levels.** *Beginner:* start here and read in order. *Intermediate:* continue in order — you are comfortable with widgets. *Advanced:* for when you ship, skip on a first read.
20
+
21
+ ## The path, linked end to end
22
+
23
+ Every page points to its **Previous** and **Next**. The chain is:
24
+
25
+ ```
26
+ Front cover (this page)
27
+ → Chapter 0 · first-app.md
28
+ → Start here · widget/START_HERE.md
29
+ → The widget book · widget/README.md (Chapters 1–8)
30
+ → State · guides/state.md
31
+ → Router · guides/router.md
32
+ → Frontend services · guides/frontend-services.md
33
+ → RamStore · services/RamStore.md
34
+ → Session · services/Session.md
35
+ → Storage · services/Storage.md
36
+ → HTTP client · services/http.md
37
+ → Tools index · tools/README.md
38
+ → Styling helpers · tools/styling.md
39
+ → Lists, arrays & data · tools/lists.md
40
+ → Text & time · tools/text-and-time.md
41
+ → State, memo & refs · tools/state.md
42
+ → Reactivity · tools/reactivity.md
43
+ → Async, ids & logging · tools/async-ids-log.md
44
+ → Device & environment · tools/device.md
45
+ → Themes · tools/theme.md
46
+ → Markdown, code & HTML · tools/markdown.md
47
+ → Visual effects · tools/visual-effects.md
48
+ → Widget introspection · tools/introspection.md
49
+ → Input validation · tools/validation.md
50
+ → Animation helpers · tools/animation.md
51
+ → Utilities guide · guides/utilities.md
52
+ → The CLI · cli/README.md
53
+ → Appendices (minification → mobile → compatibility → embedding → online updates)
54
+ → The end of the book
55
+ ```
56
+
57
+ ## How this book is written
58
+
59
+ - **Everything is real.** Every function, prop, and method documented here exists in the runtime. Pages were checked against `src/index.js` and `src/index.d.ts`.
60
+ - **You can copy the examples.** They are small, complete, and runnable.
61
+ - **Every page links to the next.** Follow the numbers and you cover the whole framework once.
62
+ - **Three layers, one API.** A public feature is complete when three pieces agree: the runtime implementation, the export in `src/index.js`, and the type in `src/index.d.ts`. This book documents that same surface.
63
+
64
+ ## Reference (not part of the book)
65
+
66
+ - [Server toolkit](server/README.md) — Express/SQLite/Redis backend helpers (separate toolkit).
67
+ - [Architecture](arquitectura.md) — how the framework is built inside.
68
+ - [Contributing](CONTRIBUTING.md) — for people who add code or docs to FletBox.
@@ -0,0 +1,164 @@
1
+ # Architecture
2
+
3
+ This document describes how FletBox is organized internally. It expands on the
4
+ [Architecture](../README.md#architecture) section of the README and is meant as a
5
+ map for contributors who want to understand the framework before changing it.
6
+
7
+ FletBox is a lightweight, declarative UI framework for vanilla JavaScript. It has
8
+ no external runtime dependencies and **no Virtual DOM**: every widget produces a
9
+ real `HTMLElement` that is attached to the document. Reactivity is achieved with a
10
+ key-based state store and subscribers, not with a diffing tree.
11
+
12
+ ## Layers
13
+
14
+ The project is organized into layers, from the public surface down to the runtime
15
+ internals:
16
+
17
+ ```text
18
+ Public API (src/index.js)
19
+ │
20
+ ├── Runtime (src/core) runApp, App, PWA
21
+ ├── Widget factory (src/widget-factory) the heart
22
+ ├── Widgets (src/widgets) ready-to-use building blocks
23
+ ├── State (src/tools/useState) key store + subscribers
24
+ ├── Router (src/navigations) routes, params, history
25
+ └── Services & utilities (src/services, src/tools, src/utils)
26
+ ```
27
+
28
+ ### 1. Public layer
29
+
30
+ - Entry point: [src/index.js](../src/index.js)
31
+
32
+ This barrel module re-exports the entire public API: widgets, utilities, services,
33
+ the router, and the runtime (`runApp`, `App`, `useState`, and friends). Consumers
34
+ should import everything from the package root rather than reaching into internal
35
+ paths.
36
+
37
+ ### 2. Framework runtime
38
+
39
+ Key files:
40
+
41
+ - [src/core/runApp.js](../src/core/runApp.js)
42
+ - [src/core/App.js](../src/core/App.js)
43
+ - [src/core/pwa.js](../src/core/pwa.js)
44
+
45
+ `runApp(App, rootId)` is the bootstrap. It:
46
+
47
+ 1. resolves (or safely creates) the root container — it never wipes `document.body`;
48
+ 2. applies and watches the system theme (`light`/`dark`);
49
+ 3. optionally initializes the router when a `routes` map is supplied;
50
+ 4. renders the app and re-renders on theme or global-state changes.
51
+
52
+ Re-rendering replaces the previous main container. Before removing it, the runtime
53
+ walks the old subtree and fires each element's unmount handlers and cleanup hooks,
54
+ so listeners and observers do not leak across renders. `runApp` returns a
55
+ `{ destroy }` handle to tear the app down explicitly.
56
+
57
+ ### 3. Widget factory (the heart)
58
+
59
+ - Entry point: [src/widget-factory/widgetFactory.js](../src/widget-factory/widgetFactory.js)
60
+
61
+ This is the core of the framework. It defines how a widget description becomes a
62
+ real `HTMLElement` carrying props, style, events, children, lifecycle, reactivity,
63
+ and update behavior.
64
+
65
+ Relevant submodules:
66
+
67
+ - [createWidget.js](../src/widget-factory/createWidget.js) — creates the base element.
68
+ - [processProps.js](../src/widget-factory/processProps.js) — normalizes and translates props (including alias dialects).
69
+ - [assignProps.js](../src/widget-factory/assignProps.js) — applies processed props to the element.
70
+ - [reactivity.js](../src/widget-factory/reactivity.js) — connects the element to state subscribers.
71
+ - [addChildren.js](../src/widget-factory/addChildren.js) — appends child widgets/elements.
72
+ - [effects.js](../src/widget-factory/effects.js) — runs post-render effects.
73
+ - [lifecycle.js](../src/widget-factory/lifecycle.js) — mount/unmount tracking.
74
+
75
+ The widget build pipeline runs roughly in this order:
76
+
77
+ ```text
78
+ WidgetFactory(tag, props)
79
+ → normalize
80
+ → createWidget
81
+ → makeParentable
82
+ → addLifecycle
83
+ → processProps
84
+ → assignProps
85
+ → stackPosition
86
+ → addChildren
87
+ → applyEffects
88
+ → makeReactive
89
+ ```
90
+
91
+ > The widget factory is the most sensitive part of the codebase. Changes here
92
+ > affect every widget; treat the pipeline as stable and prefer additive changes.
93
+
94
+ ### 4. Lifecycle
95
+
96
+ - [src/widget-factory/lifecycle.js](../src/widget-factory/lifecycle.js)
97
+
98
+ Mount/unmount state is tracked with a global `MutationObserver` on `document.body`
99
+ plus a registry of live widgets. A widget exposes `onMount(fn)` / `onUnmount(fn)`
100
+ and an internal `_cleanup` hook. When a widget disconnects from the DOM its unmount
101
+ handlers fire and it is pruned from the registry, which keeps the observer from
102
+ growing without bound. Widgets that are created before being attached are
103
+ re-registered when they are finally appended.
104
+
105
+ ### 5. State
106
+
107
+ - [src/tools/useState.js](../src/tools/useState.js)
108
+
109
+ State is a key-based store held in RAM with a set of subscribers per key:
110
+
111
+ ```javascript
112
+ const [count, setCount] = useState("count", 0);
113
+ ```
114
+
115
+ Reading a key inside a widget connects that widget to the key; calling the setter
116
+ notifies subscribers so only the connected widgets update. A global render hook lets
117
+ the runtime re-render when broad state changes.
118
+
119
+ ### 6. Router
120
+
121
+ - [src/navigations/Router.js](../src/navigations/Router.js)
122
+
123
+ `initRouter(routes)` maps paths to screens, supporting static routes, parameterized
124
+ routes (`/user/:id`), query strings, and browser-history navigation:
125
+
126
+ ```javascript
127
+ initRouter({
128
+ "/": Home,
129
+ "/about": About,
130
+ "/user/:id": User,
131
+ });
132
+ ```
133
+
134
+ ### 7. Services and utilities
135
+
136
+ Key folders:
137
+
138
+ - [src/services](../src/services) — local storage, session, HTTP client, in-RAM store.
139
+ - [src/tools](../src/tools) — `useState`, `memo`, `ref`, `device`, `dimensions`, and other helpers.
140
+ - [src/utils](../src/utils) — text, date, color, grid, margin, padding, animation, theme, and markdown utilities.
141
+
142
+ ## Prop aliases
143
+
144
+ Many props accept multiple spellings (for example `bgColor` and `backgroundColor`).
145
+ These are **intentional multi-dialect aliases**, not duplicates: they let developers
146
+ write in the dialect they prefer. Alias handling lives in the prop-translation step
147
+ of the widget factory and should be extended, never deduplicated.
148
+
149
+ ## Production builds
150
+
151
+ Development-only warnings are gated behind a `FLETBOX_DEV` flag. Production bundles
152
+ are built with esbuild using `--define:FLETBOX_DEV=false`, which collapses the gate
153
+ and strips dev warnings from the shipped output. See
154
+ [Minification and protection](guides/minification-and-protection.md).
155
+
156
+ ## Related documentation
157
+
158
+ - [Start here](widget/START_HERE.md)
159
+ - [Build your first FletBox app](guides/app-templates.md)
160
+ - [State](guides/state.md)
161
+ - [Routing](guides/router.md)
162
+ - [Utilities](guides/utilities.md)
163
+ - [Frontend services](guides/frontend-services.md)
164
+ - [Contributing](CONTRIBUTING.md)