@yuneta/gobj-ui 7.27.28 → 7.27.29
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 +71 -0
- package/dist/gobj-ui.cjs.js +722 -57
- package/dist/gobj-ui.es.js +723 -59
- package/index.js +1 -0
- package/package.json +2 -2
- package/src/c_yui_update_watch.css +45 -0
- package/src/c_yui_update_watch.js +722 -0
- package/src/c_yui_update_watch.wiring.test.js +315 -0
- package/src/shell_modals.js +8 -0
- package/src/vite_plugin_yuneta_html.test.js +34 -1
- package/src/yui_build_stamp.js +125 -0
- package/src/yui_build_stamp.test.js +56 -0
- package/vite-plugin-yuneta-html.js +60 -2
package/README.md
CHANGED
|
@@ -3739,6 +3739,72 @@ a.close(); // still shown: b holds it
|
|
|
3739
3739
|
b.close(); // gone
|
|
3740
3740
|
```
|
|
3741
3741
|
|
|
3742
|
+
### A new build is deployed — `C_YUI_UPDATE_WATCH`
|
|
3743
|
+
|
|
3744
|
+
Every route of these apps is a hash, and neither a login nor a logout reloads
|
|
3745
|
+
the page: a tab opened before a deploy runs the old bundle until somebody
|
|
3746
|
+
reloads it by hand. It is wrong in two ways. A fix seems "not to work". And
|
|
3747
|
+
the deploy removed the old lazy chunks, so the old page breaks the first time
|
|
3748
|
+
it opens a view it had not loaded yet.
|
|
3749
|
+
|
|
3750
|
+
`C_YUI_UPDATE_WATCH` (7.27.29) compares the build of the page with the build
|
|
3751
|
+
the server hands out now, and when they differ it shows a bar: *A new version
|
|
3752
|
+
is available · 2.0.42 · Reload · ✕*. It never reloads by itself. Create it
|
|
3753
|
+
once, OUTSIDE the shell, so it also covers the login:
|
|
3754
|
+
|
|
3755
|
+
```js
|
|
3756
|
+
import {register_c_yui_update_watch} from "@yuneta/gobj-ui/src/c_yui_update_watch.js";
|
|
3757
|
+
|
|
3758
|
+
register_c_yui_update_watch();
|
|
3759
|
+
// ... after gobj_create_yuno():
|
|
3760
|
+
gobj_start(gobj_create_service("__update_watch__", "C_YUI_UPDATE_WATCH", {}, yuno));
|
|
3761
|
+
|
|
3762
|
+
// in the app's EV_ON_OPEN: a backend deploy often comes with a SPA deploy
|
|
3763
|
+
let update_watch = gobj_find_service("__update_watch__", true);
|
|
3764
|
+
if(update_watch) {
|
|
3765
|
+
gobj_send_event(update_watch, "EV_CHECK_BUILD", {}, gobj);
|
|
3766
|
+
}
|
|
3767
|
+
```
|
|
3768
|
+
|
|
3769
|
+
- **What identifies a build** is the `<meta name="yuneta-build">` that
|
|
3770
|
+
`yunetaHtmlPlugin` writes into `index.html` at build time (see *index.html*
|
|
3771
|
+
below): a hash of the names of the bundle's files, which carry the hash of
|
|
3772
|
+
their content. The same code built twice has the same stamp, so the deploy
|
|
3773
|
+
round's rebuilds announce nothing. The deployed stamp is read from the page
|
|
3774
|
+
itself, fetched again with `cache: "no-store"`. A page with no stamp
|
|
3775
|
+
(`vite dev`) watches nothing. A served page with no stamp (an error page, a
|
|
3776
|
+
hotel wifi's login) is not taken as a new build.
|
|
3777
|
+
- **When it asks**: at start; when the tab is shown again, or the window gets
|
|
3778
|
+
the focus (at most once per `min_interval_ms`, 60 s); when the browser is
|
|
3779
|
+
online again; when a lazy chunk fails to load (`vite:preloadError`); every
|
|
3780
|
+
`period_ms` (1 h); and when the app sends `EV_CHECK_BUILD`. The periodic
|
|
3781
|
+
check is for a screen that is always in view and never gets the focus. It
|
|
3782
|
+
is a deliberate exception to *no polling*, approved for every SPA.
|
|
3783
|
+
- **The bar**: in the shell's notification layer, above the dialogs, and in
|
|
3784
|
+
`document.body` when there is no shell. It follows the shell across a logout.
|
|
3785
|
+
The ✕ hides it for that build only, and a later deploy shows it again. A
|
|
3786
|
+
rollback to the running build takes it away.
|
|
3787
|
+
- **Attributes**: `min_interval_ms`, `period_ms` (0 = off), `with_bar`
|
|
3788
|
+
(false: no bar, the app listens to `EV_NEW_BUILD`), `$parent`, and
|
|
3789
|
+
`before_reload`, a function that can veto the reload when there are unsaved
|
|
3790
|
+
edits:
|
|
3791
|
+
|
|
3792
|
+
```js
|
|
3793
|
+
gobj_create_service("__update_watch__", "C_YUI_UPDATE_WATCH", {
|
|
3794
|
+
before_reload: () => !form_is_dirty() ||
|
|
3795
|
+
yui_shell_confirm_yesno(shell, "all changes will be lost")
|
|
3796
|
+
}, yuno);
|
|
3797
|
+
```
|
|
3798
|
+
|
|
3799
|
+
- **Output events** (optional subscribers, `subscriber` attr):
|
|
3800
|
+
`EV_NEW_BUILD {running, deployed, version}` and
|
|
3801
|
+
`EV_BUILD_CURRENT {running}`.
|
|
3802
|
+
- **Consumer i18n keys**: `new version available`, `reload`, `close`.
|
|
3803
|
+
- **The deploy scripts** upload with `rsync --delete-after --delay-updates`:
|
|
3804
|
+
the new files appear together at the end, and the old ones are removed only
|
|
3805
|
+
after them, so a page loaded during the upload never gets an `index.html`
|
|
3806
|
+
whose chunks are not there yet.
|
|
3807
|
+
|
|
3742
3808
|
### Modals — `yui_shell_show_modal` and the `before_close` veto
|
|
3743
3809
|
|
|
3744
3810
|
`yui_shell_show_modal(shell, $box, opts)` is the standard popup: pass
|
|
@@ -4350,6 +4416,11 @@ export default { plugins: [ yunetaHtmlPlugin({ defaultTitle: "My App" }) ] };
|
|
|
4350
4416
|
`style-src 'self' 'unsafe-inline'`, and `blob:`/`data:` where workers,
|
|
4351
4417
|
images, media and fonts need them.
|
|
4352
4418
|
- Every text from `config.json` is escaped where it lands in the markup.
|
|
4419
|
+
- **The build stamp** (7.27.29, build only): the plugin adds
|
|
4420
|
+
`<meta name="yuneta-build" content="<stamp>" data-version="<version>">` to
|
|
4421
|
+
the emitted `index.html`. `<stamp>` is a sha256 (16 hex characters) of the
|
|
4422
|
+
sorted names of the bundle's files, source maps excluded. `<version>` is the
|
|
4423
|
+
app's `package.json` version. `C_YUI_UPDATE_WATCH` reads it.
|
|
4353
4424
|
|
|
4354
4425
|
### Releasing
|
|
4355
4426
|
|