flet-box 1.0.6 → 1.0.8

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 (162) hide show
  1. package/README.md +28 -1
  2. package/bin/cli.js +90 -11
  3. package/bin/commands/auditFix.js +682 -0
  4. package/bin/commands/checkApi.js +20 -6
  5. package/bin/commands/checkUi.js +1369 -0
  6. package/bin/commands/create.js +86 -12
  7. package/bin/commands/createBundle.js +75 -1
  8. package/bin/commands/images.js +349 -0
  9. package/bin/commands/pruneAssets.js +170 -0
  10. package/bin/commands/release.js +34 -1
  11. package/bin/commands/runCloudflare.js +47 -9
  12. package/bin/commands/runServer.js +91 -25
  13. package/bin/commands/toPng.js +346 -0
  14. package/bin/commands/unpack.js +1173 -0
  15. package/bin/ota/loader.js +90 -0
  16. package/bin/utils/appSources.js +101 -0
  17. package/bin/utils/bundleConfig.js +166 -0
  18. package/bin/utils/dtsProps.js +147 -0
  19. package/bin/utils/imageTools.js +271 -0
  20. package/bin/utils/images/bmp.js +99 -0
  21. package/bin/utils/images/gif.js +244 -0
  22. package/bin/utils/images/index.js +163 -0
  23. package/bin/utils/images/jpeg.js +643 -0
  24. package/bin/utils/images/png.js +486 -0
  25. package/bin/utils/images/unsupported.js +29 -0
  26. package/bin/utils/neutralise.js +109 -6
  27. package/bin/utils/pwaShell.js +137 -0
  28. package/bin/utils/templates.js +1653 -471
  29. package/docs/README.md +2 -0
  30. package/docs/cli/README.md +144 -1
  31. package/docs/guides/README.md +2 -0
  32. package/docs/guides/clean-ui.md +211 -0
  33. package/docs/guides/minification-and-protection.md +1 -1
  34. package/docs/guides/online-updates.md +105 -9
  35. package/docs/tools/README.md +1 -1
  36. package/docs/tools/animation.md +1 -1
  37. package/docs/tools/markdown.md +3 -3
  38. package/docs/tools/theme.md +41 -1
  39. package/docs/widget/Accordion.md +4 -0
  40. package/docs/widget/AdMob.md +5 -1
  41. package/docs/widget/AdSense.md +4 -0
  42. package/docs/widget/AnimatedBox.md +7 -3
  43. package/docs/widget/AnimatedText.md +4 -0
  44. package/docs/widget/Audio.md +5 -1
  45. package/docs/widget/Avatar.md +15 -3
  46. package/docs/widget/Badge.md +4 -0
  47. package/docs/widget/Button.md +4 -0
  48. package/docs/widget/COMMON_PROPS.md +52 -0
  49. package/docs/widget/Card.md +4 -0
  50. package/docs/widget/Carousel.md +4 -0
  51. package/docs/widget/Chart.md +4 -0
  52. package/docs/widget/Checkbox.md +4 -0
  53. package/docs/widget/Chip.md +4 -0
  54. package/docs/widget/CircularBar.md +4 -0
  55. package/docs/widget/CircularChart.md +4 -0
  56. package/docs/widget/CodeViewer.md +4 -0
  57. package/docs/widget/Column.md +4 -0
  58. package/docs/widget/Container.md +4 -0
  59. package/docs/widget/DataTable.md +4 -0
  60. package/docs/widget/Divider.md +4 -0
  61. package/docs/widget/DraggBox.md +6 -2
  62. package/docs/widget/Dropdown.md +6 -0
  63. package/docs/widget/DroppBox.md +5 -1
  64. package/docs/widget/FloatingActionButton.md +4 -0
  65. package/docs/widget/GridView.md +4 -0
  66. package/docs/widget/Icon.md +4 -0
  67. package/docs/widget/Image.md +14 -3
  68. package/docs/widget/Input.md +4 -0
  69. package/docs/widget/Inspector.md +2 -2
  70. package/docs/widget/InstallButton.md +4 -0
  71. package/docs/widget/ListTile.md +4 -0
  72. package/docs/widget/ListView.md +4 -0
  73. package/docs/widget/Maps.md +191 -0
  74. package/docs/widget/Markdown.md +4 -0
  75. package/docs/widget/MatrixRain.md +4 -0
  76. package/docs/widget/Pagination.md +4 -0
  77. package/docs/widget/ParallaxBox.md +4 -0
  78. package/docs/widget/ProgressBar.md +4 -0
  79. package/docs/widget/QRCode.md +4 -0
  80. package/docs/widget/README.md +12 -10
  81. package/docs/widget/Radio.md +5 -1
  82. package/docs/widget/Rating.md +4 -0
  83. package/docs/widget/Row.md +4 -0
  84. package/docs/widget/Skeleton.md +4 -0
  85. package/docs/widget/Slider.md +4 -0
  86. package/docs/widget/Stack.md +4 -0
  87. package/docs/widget/Stepper.md +4 -0
  88. package/docs/widget/Switch.md +4 -0
  89. package/docs/widget/Tabs.md +5 -5
  90. package/docs/widget/Text.md +4 -0
  91. package/docs/widget/Tooltip.md +14 -13
  92. package/docs/widget/TreeView.md +4 -0
  93. package/docs/widget/Video.md +6 -2
  94. package/package.json +2 -2
  95. package/src/animations/AnimatedBox.js +4 -1
  96. package/src/animations/MatrixRain.js +3 -3
  97. package/src/core/hmr-client.js +129 -34
  98. package/src/index.d.ts +195 -7
  99. package/src/index.js +2 -0
  100. package/src/navigations/AppBar.js +22 -16
  101. package/src/navigations/BottomNavigation.js +8 -13
  102. package/src/navigations/CollapsibleSideBar.js +30 -8
  103. package/src/navigations/Drawer.js +25 -15
  104. package/src/navigations/DrawerItem.js +3 -1
  105. package/src/navigations/Scaffold.js +26 -12
  106. package/src/navigations/Tabs.js +104 -59
  107. package/src/tools/color.js +54 -0
  108. package/src/tools/index.js +9 -1
  109. package/src/tools/scale.js +41 -0
  110. package/src/tools/shadow.js +20 -0
  111. package/src/utils/index.js +1 -0
  112. package/src/utils/readableInk.js +19 -0
  113. package/src/utils/syntaxHighlight.js +78 -10
  114. package/src/utils/themes.js +217 -54
  115. package/src/utils/units.js +33 -11
  116. package/src/widget-factory/effects.js +56 -5
  117. package/src/widget-factory/processProps.js +10 -1
  118. package/src/widget-factory/remTool.js +15 -29
  119. package/src/widget-factory/stackPosition.js +18 -3
  120. package/src/widget-factory/translateProps.js +60 -1
  121. package/src/widgets/Accordion.js +20 -23
  122. package/src/widgets/AdMob.js +7 -2
  123. package/src/widgets/Avatar.js +236 -133
  124. package/src/widgets/Badge.js +3 -2
  125. package/src/widgets/BottomSheet.js +14 -13
  126. package/src/widgets/Button.js +69 -30
  127. package/src/widgets/Card.js +6 -2
  128. package/src/widgets/Carousel.js +12 -10
  129. package/src/widgets/Chart.js +28 -5
  130. package/src/widgets/Checkbox.js +76 -18
  131. package/src/widgets/Chip.js +31 -10
  132. package/src/widgets/CircularBar.js +7 -7
  133. package/src/widgets/CircularChart.js +26 -8
  134. package/src/widgets/CodeViewer.js +93 -20
  135. package/src/widgets/Container.js +13 -0
  136. package/src/widgets/DataTable.js +17 -11
  137. package/src/widgets/DraggBox.js +2 -1
  138. package/src/widgets/Dropdown.js +59 -14
  139. package/src/widgets/DroppBox.js +4 -2
  140. package/src/widgets/FloatingActionButton.js +13 -7
  141. package/src/widgets/Icon.js +3 -1
  142. package/src/widgets/Image.js +102 -3
  143. package/src/widgets/Input.js +30 -23
  144. package/src/widgets/Inspector.js +54 -1
  145. package/src/widgets/InstallButton.js +6 -4
  146. package/src/widgets/ListTile.js +4 -3
  147. package/src/widgets/ListView.js +30 -12
  148. package/src/widgets/Maps.js +1495 -0
  149. package/src/widgets/Markdown.js +37 -26
  150. package/src/widgets/Modal.js +14 -11
  151. package/src/widgets/Pagination.js +16 -11
  152. package/src/widgets/ProgressBar.js +6 -4
  153. package/src/widgets/Radio.js +73 -15
  154. package/src/widgets/Rating.js +24 -6
  155. package/src/widgets/Skeleton.js +31 -31
  156. package/src/widgets/Slider.js +29 -18
  157. package/src/widgets/SnackBar.js +35 -39
  158. package/src/widgets/Stepper.js +13 -9
  159. package/src/widgets/Switch.js +59 -18
  160. package/src/widgets/Tooltip.js +24 -12
  161. package/src/widgets/TreeView.js +27 -15
  162. package/src/widgets/index.js +1 -0
package/README.md CHANGED
@@ -101,11 +101,38 @@ flet-box check-api # scan src/ for invented widgets/props
101
101
  flet-box check-api --props Button # print the real props of one widget
102
102
  flet-box check-api --list # print every public export
103
103
  flet-box check-api --emit-api # (re)generate .fletbox/api/cheatsheet.md
104
+
105
+ # Read one widget from every surface at once (offline)
106
+ flet-box unpack Text # each prop, where it goes, and what is dead
107
+ flet-box unpack Text --example # a paste-ready call, built only from verified props
108
+ flet-box unpack Modal --diff # where types, engine, docs and code disagree
109
+ flet-box unpack --all --md # every widget, as .fletbox/api/api.json + api.md
110
+
111
+ # Repair (writes files; run `npm run check` afterwards to confirm)
112
+ flet-box audit-fix # fix imports and prop typos in one pass
113
+ flet-box audit-fix --only imports # just the import wiring
114
+ flet-box audit-fix --only props # just `chilldren` → `children`
104
115
  ```
105
116
 
106
117
  In a generated app these are also `npm run check` (and `npm run check -- --props Button`),
107
118
  because `flet-box create` writes `scripts/check-app.mjs` plus the `AGENTS.md` contract
108
- that points any AI assistant at the real API.
119
+ that points any AI assistant at the real API. `npm run fix` runs `audit-fix`.
120
+
121
+ `audit-fix` only rewrites a name when exactly one real name is close enough to be
122
+ certain — a wrong "fix" that happens to be a valid prop changes the UI silently and
123
+ silences the gate, which is worse than the error it replaced. Anything ambiguous is
124
+ printed under *Left for you to decide* and the file is not touched.
125
+
126
+ `flet-box unpack` answers the question the types alone cannot: a prop can be declared,
127
+ documented and still reach nothing. It cross-checks the four places a prop lives —
128
+ `src/index.d.ts`, the `ALL_PROPS` translation table, the widget's own source, its doc
129
+ page — and labels each disagreement: **DEAD** (typed, read by nothing), **INVENTED**
130
+ (read by the widget, declared nowhere), **UNDOCUMENTED** (the engine routes it, the
131
+ interface hides it), **DOC-ONLY** and **CODE-ONLY** (the page and the code each promise
132
+ something the other never heard of). `--example` uses only that verified set, so what it
133
+ prints is the whole API you can safely paste; `unpack --all --json` writes the same facts
134
+ as `.fletbox/api/api.json` for the AI agent inside an app, which is the surface it should
135
+ invent against.
109
136
 
110
137
  ## Android and iOS
111
138
 
package/bin/cli.js CHANGED
@@ -14,6 +14,12 @@ import fs from "fs";
14
14
  import path from "path";
15
15
  import { createProject } from "./commands/create.js";
16
16
  import { checkApi } from "./commands/checkApi.js";
17
+ import { checkUi } from "./commands/checkUi.js";
18
+ import { auditFix } from "./commands/auditFix.js";
19
+ import { toPng } from "./commands/toPng.js";
20
+ import { images } from "./commands/images.js";
21
+ import { pruneAssets } from "./commands/pruneAssets.js";
22
+ import { unpack } from "./commands/unpack.js";
17
23
  import { packageManager } from "./commands/package.js";
18
24
  import { createBundle } from "./commands/createBundle.js";
19
25
  import { buildAndroid } from "./commands/buildAndroid.js";
@@ -63,6 +69,7 @@ ${cmd("create --adaptive", "responsive (mobile + desktop)")}
63
69
  ${cmd("create --blank", "empty project")}
64
70
  ${cmd("create --full", "AppBar+Drawer+BottomNav")}
65
71
  ${cmd("create --sidebar", "desktop (Sidebar+AppBar)")}
72
+ ${cmd("create --template <name>", "same four by name: basic|adaptive|blank|full|sidebar")}
66
73
  ${cmd("create --repo <user/repo>", "set GitHub repo for OTA updates")}
67
74
  ${cmd("screen <name|num>", "Create screen(s) (1-10)")}
68
75
  ${cmd("component <name|num>", "Create component(s) (1-10)")}
@@ -76,6 +83,27 @@ ${cmd(" └─ --props <Widget>", "print one widget's real props")}
76
83
  ${cmd(" └─ --list", "list every widget")}
77
84
  ${cmd(" └─ --emit-api", "write .fletbox/api/cheatsheet.md")}
78
85
  ${cmd(" └─ alias", "check | checkApi | doctor")}
86
+ ${cmd("unpack <Widget>", "Everything one widget really accepts, and what works")}
87
+ ${cmd(" └─ --example", "paste-ready call using only verified props")}
88
+ ${cmd(" └─ --diff", "what the docs or types claim that the code ignores")}
89
+ ${cmd(" └─ unpack --all", "every widget; --json / --md write .fletbox/api/")}
90
+ ${cmd("check-ui", "Clean-UI gate: tokens, 8-based scale, tap targets, WCAG contrast")}
91
+ ${cmd(" └─ --tokens", "print the measured contrast of every color token")}
92
+ ${cmd(" └─ --strict", "fail on contrast warnings too")}
93
+ ${cmd(" └─ alias", "ui | checkUi")}
94
+ ${cmd("audit-fix", "Rewrite broken imports, missing imports and misspelled props")}
95
+ ${cmd(" └─ --only imports|props", "run one repair instead of both")}
96
+ ${cmd(" └─ alias", "fix-imports | fix-path-imports | auditFix")}
97
+ ${cmd("to-png [dir]", "Convert JPEG/BMP/GIF images to PNG, no dependencies")}
98
+ ${cmd(" └─ --replace", "remove each source after its PNG was written and read back")}
99
+ ${cmd(" └─ --out <dir> | --force | --flat | --dry-run", "where to write, and what to touch")}
100
+ ${cmd(" └─ alias", "topng | convert-images")}
101
+ ${cmd("images [dir]", "Shrink JPG/PNG photos to a byte budget with the platform WebP encoder")}
102
+ ${cmd(" └─ --budget <KB> | --width <px>", "what 'small enough' means (default 40KB)")}
103
+ ${cmd(" └─ --install", "install the encoder this machine is missing")}
104
+ ${cmd(" └─ alias", "optimize-images | imgs")}
105
+ ${cmd("prune-assets [dir]", "Delete images the app never references (dry run unless --apply)")}
106
+ ${cmd(" └─ alias", "prune")}
79
107
  ${cmd("build android", "Build Android debug APK")}
80
108
  ${cmd("build android --release", "Build unsigned release APK/AAB to sign yourself")}
81
109
  ${cmd("build ios", "Build iOS Simulator app (macOS + Xcode)")}
@@ -86,7 +114,7 @@ ${cmd(" └─ --livereload", "hot reload on the device")}
86
114
  ${cmd("run", "Static file server")}
87
115
  ${cmd("run --hot", "Dev server with hot reload")}
88
116
  ${cmd("run-spa", "SPA + hot reload")}
89
- ${cmd("cloudflare", "Serve demo on a public Cloudflare HTTPS tunnel")}
117
+ ${cmd("cloudflare [dir]", "Build the bundle, then tunnel it: public HTTPS demo link")}
90
118
  ${cmd(" └─ alias", "cf | demo | tunnel")}
91
119
  ${cmd("run-bundle [dir]", "Build & serve the bundle (single app.js)")}
92
120
  ${cmd("pkg", "Open the package manager")}
@@ -110,6 +138,8 @@ ${section("✨", "EXAMPLES")}
110
138
  ${c("gray", "cd my-app && flet-box run-spa")}
111
139
  ${c("gray", "flet-box run-bundle # build & preview production")}
112
140
  ${c("gray", "flet-box cloudflare # public HTTPS demo link in console")}
141
+ ${c("gray", "flet-box unpack Text --example # what Text really accepts, as code")}
142
+ ${c("gray", "flet-box unpack --all --json # dump the verified API for your AI agent")}
113
143
  ${c("gray", "flet-box kill-server 8000 # kill the parasite server")}
114
144
 
115
145
  ${divider("", "#3730a3")}
@@ -165,6 +195,16 @@ const parseFlags = () => {
165
195
  return flags;
166
196
  };
167
197
 
198
+ /**
199
+ * The bundle directory a command works on: the second argument when it is a
200
+ * plain name, `www` otherwise. Flags never reach here, so `flet-box cloudflare
201
+ * --port 9000` cannot mistake `--port` for a target.
202
+ *
203
+ * @returns {string}
204
+ */
205
+ const bundleTarget = () =>
206
+ args[1] && /^[a-zA-Z0-9_][a-zA-Z0-9_-]*$/.test(args[1]) ? args[1] : "www";
207
+
168
208
  /**
169
209
  * Guards commands that must run inside a FletBox project directory.
170
210
  * Exits with a descriptive error when `src/app.js` is not found in the
@@ -207,7 +247,7 @@ async function main() {
207
247
  console.log(
208
248
  c(
209
249
  "gray",
210
- "Usage: flet-box create <project-name> [--adaptive|--blank|--full|--sidebar|--repo user/repo]",
250
+ "Usage: flet-box create <project-name> [--adaptive|--blank|--full|--sidebar|--template <name>|--repo user/repo]",
211
251
  ),
212
252
  );
213
253
  process.exit(1);
@@ -274,6 +314,52 @@ async function main() {
274
314
  break;
275
315
  }
276
316
 
317
+ case "unpack": {
318
+ const { exitCode } = await unpack(args.slice(1));
319
+ if (exitCode) process.exit(exitCode);
320
+ break;
321
+ }
322
+
323
+ case "check-ui":
324
+ case "checkUi":
325
+ case "ui": {
326
+ const { exitCode } = await checkUi(args.slice(1));
327
+ if (exitCode) process.exit(exitCode);
328
+ break;
329
+ }
330
+
331
+ case "audit-fix":
332
+ case "auditFix":
333
+ case "fix-imports":
334
+ case "fix-path-imports": {
335
+ const { exitCode } = await auditFix(args.slice(1));
336
+ if (exitCode) process.exit(exitCode);
337
+ break;
338
+ }
339
+
340
+ case "to-png":
341
+ case "topng":
342
+ case "convert-images": {
343
+ const { exitCode } = await toPng(args.slice(1));
344
+ if (exitCode) process.exit(exitCode);
345
+ break;
346
+ }
347
+
348
+ case "images":
349
+ case "optimize-images":
350
+ case "imgs": {
351
+ const { exitCode } = await images(args.slice(1));
352
+ if (exitCode) process.exit(exitCode);
353
+ break;
354
+ }
355
+
356
+ case "prune-assets":
357
+ case "prune": {
358
+ const { exitCode } = await pruneAssets(args.slice(1));
359
+ if (exitCode) process.exit(exitCode);
360
+ break;
361
+ }
362
+
277
363
  case "build":
278
364
  if (args[1] === "android") {
279
365
  buildAndroid(args.slice(2));
@@ -337,16 +423,8 @@ async function main() {
337
423
  case "runBundle":
338
424
  case "preview": {
339
425
  ensureProject();
340
- // Accept an explicit target directory as the second argument, but reject
341
- // anything that looks like a flag (starts with "-") to avoid misparses.
342
- const targetDir =
343
- args[1] &&
344
- /^[a-zA-Z0-9_][a-zA-Z0-9_-]*$/.test(args[1]) &&
345
- !args[1].startsWith("-")
346
- ? args[1]
347
- : "www";
348
426
  await (await import("./commands/runBundle.js")).runBundle({
349
- target: targetDir,
427
+ target: bundleTarget(),
350
428
  port: flags.port,
351
429
  askPort: !flags.portExplicit,
352
430
  logRequests: flags.logRequests,
@@ -373,6 +451,7 @@ async function main() {
373
451
  case "tunnel":
374
452
  ensureProject();
375
453
  await (await import("./commands/runCloudflare.js")).runCloudflareDemo({
454
+ target: bundleTarget(),
376
455
  port: flags.port,
377
456
  logRequests: flags.logRequests,
378
457
  });