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.
- package/README.md +28 -1
- package/bin/cli.js +90 -11
- package/bin/commands/auditFix.js +682 -0
- package/bin/commands/checkApi.js +20 -6
- package/bin/commands/checkUi.js +1369 -0
- package/bin/commands/create.js +86 -12
- package/bin/commands/createBundle.js +75 -1
- package/bin/commands/images.js +349 -0
- package/bin/commands/pruneAssets.js +170 -0
- package/bin/commands/release.js +34 -1
- package/bin/commands/runCloudflare.js +47 -9
- package/bin/commands/runServer.js +91 -25
- package/bin/commands/toPng.js +346 -0
- package/bin/commands/unpack.js +1173 -0
- package/bin/ota/loader.js +90 -0
- package/bin/utils/appSources.js +101 -0
- package/bin/utils/bundleConfig.js +166 -0
- package/bin/utils/dtsProps.js +147 -0
- package/bin/utils/imageTools.js +271 -0
- package/bin/utils/images/bmp.js +99 -0
- package/bin/utils/images/gif.js +244 -0
- package/bin/utils/images/index.js +163 -0
- package/bin/utils/images/jpeg.js +643 -0
- package/bin/utils/images/png.js +486 -0
- package/bin/utils/images/unsupported.js +29 -0
- package/bin/utils/neutralise.js +109 -6
- package/bin/utils/pwaShell.js +137 -0
- package/bin/utils/templates.js +1653 -471
- package/docs/README.md +2 -0
- package/docs/cli/README.md +144 -1
- package/docs/guides/README.md +2 -0
- package/docs/guides/clean-ui.md +211 -0
- package/docs/guides/minification-and-protection.md +1 -1
- package/docs/guides/online-updates.md +105 -9
- package/docs/tools/README.md +1 -1
- package/docs/tools/animation.md +1 -1
- package/docs/tools/markdown.md +3 -3
- package/docs/tools/theme.md +41 -1
- package/docs/widget/Accordion.md +4 -0
- package/docs/widget/AdMob.md +5 -1
- package/docs/widget/AdSense.md +4 -0
- package/docs/widget/AnimatedBox.md +7 -3
- package/docs/widget/AnimatedText.md +4 -0
- package/docs/widget/Audio.md +5 -1
- package/docs/widget/Avatar.md +15 -3
- package/docs/widget/Badge.md +4 -0
- package/docs/widget/Button.md +4 -0
- package/docs/widget/COMMON_PROPS.md +52 -0
- package/docs/widget/Card.md +4 -0
- package/docs/widget/Carousel.md +4 -0
- package/docs/widget/Chart.md +4 -0
- package/docs/widget/Checkbox.md +4 -0
- package/docs/widget/Chip.md +4 -0
- package/docs/widget/CircularBar.md +4 -0
- package/docs/widget/CircularChart.md +4 -0
- package/docs/widget/CodeViewer.md +4 -0
- package/docs/widget/Column.md +4 -0
- package/docs/widget/Container.md +4 -0
- package/docs/widget/DataTable.md +4 -0
- package/docs/widget/Divider.md +4 -0
- package/docs/widget/DraggBox.md +6 -2
- package/docs/widget/Dropdown.md +6 -0
- package/docs/widget/DroppBox.md +5 -1
- package/docs/widget/FloatingActionButton.md +4 -0
- package/docs/widget/GridView.md +4 -0
- package/docs/widget/Icon.md +4 -0
- package/docs/widget/Image.md +14 -3
- package/docs/widget/Input.md +4 -0
- package/docs/widget/Inspector.md +2 -2
- package/docs/widget/InstallButton.md +4 -0
- package/docs/widget/ListTile.md +4 -0
- package/docs/widget/ListView.md +4 -0
- package/docs/widget/Maps.md +191 -0
- package/docs/widget/Markdown.md +4 -0
- package/docs/widget/MatrixRain.md +4 -0
- package/docs/widget/Pagination.md +4 -0
- package/docs/widget/ParallaxBox.md +4 -0
- package/docs/widget/ProgressBar.md +4 -0
- package/docs/widget/QRCode.md +4 -0
- package/docs/widget/README.md +12 -10
- package/docs/widget/Radio.md +5 -1
- package/docs/widget/Rating.md +4 -0
- package/docs/widget/Row.md +4 -0
- package/docs/widget/Skeleton.md +4 -0
- package/docs/widget/Slider.md +4 -0
- package/docs/widget/Stack.md +4 -0
- package/docs/widget/Stepper.md +4 -0
- package/docs/widget/Switch.md +4 -0
- package/docs/widget/Tabs.md +5 -5
- package/docs/widget/Text.md +4 -0
- package/docs/widget/Tooltip.md +14 -13
- package/docs/widget/TreeView.md +4 -0
- package/docs/widget/Video.md +6 -2
- package/package.json +2 -2
- package/src/animations/AnimatedBox.js +4 -1
- package/src/animations/MatrixRain.js +3 -3
- package/src/core/hmr-client.js +129 -34
- package/src/index.d.ts +195 -7
- package/src/index.js +2 -0
- package/src/navigations/AppBar.js +22 -16
- package/src/navigations/BottomNavigation.js +8 -13
- package/src/navigations/CollapsibleSideBar.js +30 -8
- package/src/navigations/Drawer.js +25 -15
- package/src/navigations/DrawerItem.js +3 -1
- package/src/navigations/Scaffold.js +26 -12
- package/src/navigations/Tabs.js +104 -59
- package/src/tools/color.js +54 -0
- package/src/tools/index.js +9 -1
- package/src/tools/scale.js +41 -0
- package/src/tools/shadow.js +20 -0
- package/src/utils/index.js +1 -0
- package/src/utils/readableInk.js +19 -0
- package/src/utils/syntaxHighlight.js +78 -10
- package/src/utils/themes.js +217 -54
- package/src/utils/units.js +33 -11
- package/src/widget-factory/effects.js +56 -5
- package/src/widget-factory/processProps.js +10 -1
- package/src/widget-factory/remTool.js +15 -29
- package/src/widget-factory/stackPosition.js +18 -3
- package/src/widget-factory/translateProps.js +60 -1
- package/src/widgets/Accordion.js +20 -23
- package/src/widgets/AdMob.js +7 -2
- package/src/widgets/Avatar.js +236 -133
- package/src/widgets/Badge.js +3 -2
- package/src/widgets/BottomSheet.js +14 -13
- package/src/widgets/Button.js +69 -30
- package/src/widgets/Card.js +6 -2
- package/src/widgets/Carousel.js +12 -10
- package/src/widgets/Chart.js +28 -5
- package/src/widgets/Checkbox.js +76 -18
- package/src/widgets/Chip.js +31 -10
- package/src/widgets/CircularBar.js +7 -7
- package/src/widgets/CircularChart.js +26 -8
- package/src/widgets/CodeViewer.js +93 -20
- package/src/widgets/Container.js +13 -0
- package/src/widgets/DataTable.js +17 -11
- package/src/widgets/DraggBox.js +2 -1
- package/src/widgets/Dropdown.js +59 -14
- package/src/widgets/DroppBox.js +4 -2
- package/src/widgets/FloatingActionButton.js +13 -7
- package/src/widgets/Icon.js +3 -1
- package/src/widgets/Image.js +102 -3
- package/src/widgets/Input.js +30 -23
- package/src/widgets/Inspector.js +54 -1
- package/src/widgets/InstallButton.js +6 -4
- package/src/widgets/ListTile.js +4 -3
- package/src/widgets/ListView.js +30 -12
- package/src/widgets/Maps.js +1495 -0
- package/src/widgets/Markdown.js +37 -26
- package/src/widgets/Modal.js +14 -11
- package/src/widgets/Pagination.js +16 -11
- package/src/widgets/ProgressBar.js +6 -4
- package/src/widgets/Radio.js +73 -15
- package/src/widgets/Rating.js +24 -6
- package/src/widgets/Skeleton.js +31 -31
- package/src/widgets/Slider.js +29 -18
- package/src/widgets/SnackBar.js +35 -39
- package/src/widgets/Stepper.js +13 -9
- package/src/widgets/Switch.js +59 -18
- package/src/widgets/Tooltip.js +24 -12
- package/src/widgets/TreeView.js +27 -15
- package/src/widgets/index.js +1 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file bin/utils/pwaShell.js
|
|
3
|
+
* @description Two build-time corrections that make a bundle deployable as a PWA
|
|
4
|
+
* on a static host, which is where every generated app actually ends up
|
|
5
|
+
* (GitHub Pages, S3, any bucket under `/repo/`).
|
|
6
|
+
*
|
|
7
|
+
* Neither can be left to the app author to remember, because both fail silently
|
|
8
|
+
* on the developer's own machine and only show up once deployed:
|
|
9
|
+
*
|
|
10
|
+
* 1. `writeSpaFallback` — a single-page app has routes the host does not know.
|
|
11
|
+
* GitHub Pages has no rewrite rule, so a refresh on `/repo/menu` is answered
|
|
12
|
+
* with Pages' own "Page not found": the app looks broken exactly on the
|
|
13
|
+
* entry point a shared link or a reload produces. `404.html` is the portable
|
|
14
|
+
* remedy: every static host serves that file for a missing path, so copying
|
|
15
|
+
* the built shell over it hands the deep link to the router instead.
|
|
16
|
+
*
|
|
17
|
+
* 2. `normaliseManifest` — a generated `manifest.json` says `"start_url": "/"`
|
|
18
|
+
* and `"scope": "/"`. Resolved against the manifest's own URL that is the
|
|
19
|
+
* host root, i.e. `https://user.github.io/`, which is outside the app's
|
|
20
|
+
* directory and outside its service worker's scope. Chrome then refuses to
|
|
21
|
+
* offer the install at all: the site renders, works offline, and never shows
|
|
22
|
+
* "Add to Home Screen". Icons have the quieter version of the same bug — a
|
|
23
|
+
* copied logo declared as `192x192` that is really 512 px wide.
|
|
24
|
+
*
|
|
25
|
+
* Both only touch the bundle output. The project's own `manifest.json` and
|
|
26
|
+
* `index.html` stay host-agnostic so the same folder still runs on `:8000`.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
import fs from "fs";
|
|
30
|
+
import path from "path";
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Read the intrinsic size of a PNG from its IHDR chunk.
|
|
34
|
+
*
|
|
35
|
+
* @param {string} filePath - Absolute path to the candidate icon.
|
|
36
|
+
* @returns {{width: number, height: number}|null} Nothing for a non-PNG file.
|
|
37
|
+
*/
|
|
38
|
+
export const pngDimensions = (filePath) => {
|
|
39
|
+
const header = Buffer.alloc(24);
|
|
40
|
+
let handle;
|
|
41
|
+
try {
|
|
42
|
+
handle = fs.openSync(filePath, "r");
|
|
43
|
+
if (fs.readSync(handle, header, 0, 24, 0) !== 24) return null;
|
|
44
|
+
} catch {
|
|
45
|
+
return null;
|
|
46
|
+
} finally {
|
|
47
|
+
if (handle !== undefined) fs.closeSync(handle);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const isPng =
|
|
51
|
+
header[0] === 0x89 &&
|
|
52
|
+
header.subarray(12, 16).toString("ascii") === "IHDR";
|
|
53
|
+
if (!isPng) return null;
|
|
54
|
+
return { width: header.readUInt32BE(16), height: header.readUInt32BE(20) };
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Make the bundled `manifest.json` launch and stay inside the app it ships with.
|
|
59
|
+
*
|
|
60
|
+
* `start_url` and `scope` are resolved against the manifest URL, so `"/"` means
|
|
61
|
+
* the host root. Rewriting only that value (and an empty string) to `"./"` keeps
|
|
62
|
+
* a root-hosted app identical to what it was while pulling a sub-path app back
|
|
63
|
+
* inside its own directory; any other value is a deliberate base path and is left
|
|
64
|
+
* alone. Each icon's declared `sizes` is corrected to the pixels the file really
|
|
65
|
+
* has, which is also what makes the 192 px requirement provable to the browser.
|
|
66
|
+
*
|
|
67
|
+
* @param {string} targetDir - Absolute path of the bundle directory.
|
|
68
|
+
* @returns {string[]} Human-readable description of each correction made.
|
|
69
|
+
*/
|
|
70
|
+
export const normaliseManifest = (targetDir) => {
|
|
71
|
+
const manifestPath = path.join(targetDir, "manifest.json");
|
|
72
|
+
if (!fs.existsSync(manifestPath)) return [];
|
|
73
|
+
|
|
74
|
+
let raw;
|
|
75
|
+
try {
|
|
76
|
+
raw = fs.readFileSync(manifestPath, "utf8");
|
|
77
|
+
} catch {
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
let manifest;
|
|
82
|
+
try {
|
|
83
|
+
manifest = JSON.parse(raw);
|
|
84
|
+
} catch {
|
|
85
|
+
return [];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const changes = [];
|
|
89
|
+
|
|
90
|
+
// "/" escapes the app on a sub-path host; "" is the same mistake written
|
|
91
|
+
// differently. Anything else was typed on purpose.
|
|
92
|
+
for (const field of ["start_url", "scope"]) {
|
|
93
|
+
if (manifest[field] === "/" || manifest[field] === "") {
|
|
94
|
+
manifest[field] = "./";
|
|
95
|
+
changes.push(`${field}: "/" → "./"`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (Array.isArray(manifest.icons)) {
|
|
100
|
+
for (const icon of manifest.icons) {
|
|
101
|
+
if (!icon || typeof icon.src !== "string") continue;
|
|
102
|
+
// Strip any query/hash and the leading "./" before hitting the disk; the
|
|
103
|
+
// bundle keeps icons relative to its own directory.
|
|
104
|
+
const clean = icon.src.split(/[?#]/)[0].replace(/^\.\//, "");
|
|
105
|
+
const size = pngDimensions(path.join(targetDir, clean));
|
|
106
|
+
if (!size) continue;
|
|
107
|
+
const actual = `${size.width}x${size.height}`;
|
|
108
|
+
if (icon.sizes !== actual) {
|
|
109
|
+
const declared = icon.sizes;
|
|
110
|
+
icon.sizes = actual;
|
|
111
|
+
changes.push(`${clean}: sizes now ${actual} (was ${declared})`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (changes.length) {
|
|
117
|
+
fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2) + "\n");
|
|
118
|
+
}
|
|
119
|
+
return changes;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Copy the finished shell to `404.html` so unknown paths serve the app.
|
|
124
|
+
*
|
|
125
|
+
* Called last, after the OTA loader is wired and the share tags are absolute, so
|
|
126
|
+
* the fallback document is byte-identical to `index.html` and boots the same
|
|
127
|
+
* bundle. Idempotent: rebuilding the project always rewrites it.
|
|
128
|
+
*
|
|
129
|
+
* @param {string} targetDir - Absolute path of the bundle directory.
|
|
130
|
+
* @returns {boolean} False when there is no `index.html` to copy.
|
|
131
|
+
*/
|
|
132
|
+
export const writeSpaFallback = (targetDir) => {
|
|
133
|
+
const index = path.join(targetDir, "index.html");
|
|
134
|
+
if (!fs.existsSync(index)) return false;
|
|
135
|
+
fs.copyFileSync(index, path.join(targetDir, "404.html"));
|
|
136
|
+
return true;
|
|
137
|
+
};
|