@yuneta/gobj-ui 7.27.28 → 7.27.30
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 +91 -2
- package/dist/gobj-ui.cjs.js +800 -69
- package/dist/gobj-ui.es.js +800 -71
- package/index.js +1 -0
- package/package.json +3 -3
- package/src/c_yui_gclass.js +32 -0
- package/src/c_yui_gobj_tree_js.js +66 -22
- package/src/c_yui_node.js +6 -22
- package/src/c_yui_update_watch.css +45 -0
- package/src/c_yui_update_watch.js +769 -0
- package/src/c_yui_update_watch.wiring.test.js +390 -0
- package/src/gclass_language.wiring.test.js +141 -0
- package/src/gobj_tree_camera.wiring.test.js +81 -7
- package/src/gobj_tree_remote.wiring.test.js +102 -2
- package/src/shell_modals.js +8 -0
- package/src/shell_view_shown.wiring.test.js +71 -1
- 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
|
@@ -609,8 +609,11 @@ active child is the one already hanging in its body.
|
|
|
609
609
|
**A content shown again is told so** (7.27.21+). A node keeps the content it
|
|
610
610
|
built, as the shell keeps a `keep_alive` view, so a content that reads its data
|
|
611
611
|
only when it is created declares `EV_VIEW_SHOWN` and reads it again there: the
|
|
612
|
-
node sends it when it comes back to that content
|
|
613
|
-
|
|
612
|
+
node sends it, with kw `{route}`, when it comes back to that content. That also
|
|
613
|
+
covers the whole tree shown again by the shell, because every node on the path
|
|
614
|
+
comes back with the shell's route change, so the node itself does not declare
|
|
615
|
+
`EV_VIEW_SHOWN` and the shell does not tell the tree a second time (7.27.30+).
|
|
616
|
+
Once per showing (SHELL.md §4).
|
|
614
617
|
|
|
615
618
|
**The tree is a contract, not runtime state.** Once published, a node's path
|
|
616
619
|
is a url a client may have bookmarked, scripted, or been sold as another door
|
|
@@ -3739,6 +3742,87 @@ a.close(); // still shown: b holds it
|
|
|
3739
3742
|
b.close(); // gone
|
|
3740
3743
|
```
|
|
3741
3744
|
|
|
3745
|
+
### A new build is deployed — `C_YUI_UPDATE_WATCH`
|
|
3746
|
+
|
|
3747
|
+
Every route of these apps is a hash, and neither a login nor a logout reloads
|
|
3748
|
+
the page: a tab opened before a deploy runs the old bundle until somebody
|
|
3749
|
+
reloads it by hand. It is wrong in two ways. A fix seems "not to work". And
|
|
3750
|
+
the deploy removed the old lazy chunks, so the old page breaks the first time
|
|
3751
|
+
it opens a view it had not loaded yet.
|
|
3752
|
+
|
|
3753
|
+
`C_YUI_UPDATE_WATCH` (7.27.29) compares the build of the page with the build
|
|
3754
|
+
the server hands out now, and when they differ it shows a bar: *A new version
|
|
3755
|
+
is available · 2.0.42 · Reload · ✕*. It never reloads by itself. Create it
|
|
3756
|
+
once, OUTSIDE the shell, so it also covers the login:
|
|
3757
|
+
|
|
3758
|
+
```js
|
|
3759
|
+
import {register_c_yui_update_watch} from "@yuneta/gobj-ui/src/c_yui_update_watch.js";
|
|
3760
|
+
|
|
3761
|
+
register_c_yui_update_watch();
|
|
3762
|
+
// ... after gobj_create_yuno():
|
|
3763
|
+
gobj_start(gobj_create_service("__update_watch__", "C_YUI_UPDATE_WATCH", {}, yuno));
|
|
3764
|
+
|
|
3765
|
+
// in the app's EV_ON_OPEN: a backend deploy often comes with a SPA deploy
|
|
3766
|
+
let update_watch = gobj_find_service("__update_watch__", true);
|
|
3767
|
+
if(update_watch) {
|
|
3768
|
+
gobj_send_event(update_watch, "EV_CHECK_BUILD", {}, gobj);
|
|
3769
|
+
}
|
|
3770
|
+
```
|
|
3771
|
+
|
|
3772
|
+
- **What identifies a build** is the `<meta name="yuneta-build">` that
|
|
3773
|
+
`yunetaHtmlPlugin` writes into `index.html` at build time (see *index.html*
|
|
3774
|
+
below): a hash of the names of the bundle's files, which carry the hash of
|
|
3775
|
+
their content. The same code built twice has the same stamp, so the deploy
|
|
3776
|
+
round's rebuilds announce nothing. The deployed stamp is read from the page
|
|
3777
|
+
itself, fetched again with `cache: "no-store"`. A page with no stamp
|
|
3778
|
+
(`vite dev`) watches nothing. A served page with no stamp (an error page, a
|
|
3779
|
+
hotel wifi's login) is not taken as a new build.
|
|
3780
|
+
- **When it asks**: at start; when the tab is shown again, or the window gets
|
|
3781
|
+
the focus (at most once per `min_interval_ms`, 60 s); when the browser is
|
|
3782
|
+
online again; when a lazy chunk fails to load (`vite:preloadError`); every
|
|
3783
|
+
`period_ms` (1 h); and when the app sends `EV_CHECK_BUILD`. The periodic
|
|
3784
|
+
check is for a screen that is always in view and never gets the focus. It
|
|
3785
|
+
is a deliberate exception to *no polling*, approved for every SPA.
|
|
3786
|
+
- **The bar**: in the shell's notification layer, above the dialogs, and in
|
|
3787
|
+
`document.body` when there is no shell. It follows the shell across a logout.
|
|
3788
|
+
The ✕ hides it for that build only, and a later deploy shows it again. A
|
|
3789
|
+
rollback to the running build takes it away.
|
|
3790
|
+
- **Its language** follows the live shell's `EV_LANGUAGE_CHANGED`
|
|
3791
|
+
(`yui_shell_language_changed()`). On the login there is no shell to publish
|
|
3792
|
+
it, so the app's login language switch calls
|
|
3793
|
+
**`yui_update_watch_language_changed()`** after switching its i18next
|
|
3794
|
+
(7.27.30+). It sends `EV_LANGUAGE_CHANGED` to every live watch, so the bar
|
|
3795
|
+
is re-translated through the watch's FSM. With a shell up too, the second
|
|
3796
|
+
refresh is harmless:
|
|
3797
|
+
|
|
3798
|
+
```js
|
|
3799
|
+
import {yui_update_watch_language_changed} from "@yuneta/gobj-ui/src/c_yui_update_watch.js";
|
|
3800
|
+
|
|
3801
|
+
// the login's language button, after switching the i18next language:
|
|
3802
|
+
switch_locale(locale);
|
|
3803
|
+
yui_update_watch_language_changed(); // or (gobj), the gobj that switched
|
|
3804
|
+
```
|
|
3805
|
+
- **Attributes**: `min_interval_ms`, `period_ms` (0 = off), `with_bar`
|
|
3806
|
+
(false: no bar, the app listens to `EV_NEW_BUILD`), `$parent`, and
|
|
3807
|
+
`before_reload`, a function that can veto the reload when there are unsaved
|
|
3808
|
+
edits:
|
|
3809
|
+
|
|
3810
|
+
```js
|
|
3811
|
+
gobj_create_service("__update_watch__", "C_YUI_UPDATE_WATCH", {
|
|
3812
|
+
before_reload: () => !form_is_dirty() ||
|
|
3813
|
+
yui_shell_confirm_yesno(shell, "all changes will be lost")
|
|
3814
|
+
}, yuno);
|
|
3815
|
+
```
|
|
3816
|
+
|
|
3817
|
+
- **Output events** (optional subscribers, `subscriber` attr):
|
|
3818
|
+
`EV_NEW_BUILD {running, deployed, version}` and
|
|
3819
|
+
`EV_BUILD_CURRENT {running}`.
|
|
3820
|
+
- **Consumer i18n keys**: `new version available`, `reload`, `close`.
|
|
3821
|
+
- **The deploy scripts** upload with `rsync --delete-after --delay-updates`:
|
|
3822
|
+
the new files appear together at the end, and the old ones are removed only
|
|
3823
|
+
after them, so a page loaded during the upload never gets an `index.html`
|
|
3824
|
+
whose chunks are not there yet.
|
|
3825
|
+
|
|
3742
3826
|
### Modals — `yui_shell_show_modal` and the `before_close` veto
|
|
3743
3827
|
|
|
3744
3828
|
`yui_shell_show_modal(shell, $box, opts)` is the standard popup: pass
|
|
@@ -4350,6 +4434,11 @@ export default { plugins: [ yunetaHtmlPlugin({ defaultTitle: "My App" }) ] };
|
|
|
4350
4434
|
`style-src 'self' 'unsafe-inline'`, and `blob:`/`data:` where workers,
|
|
4351
4435
|
images, media and fonts need them.
|
|
4352
4436
|
- Every text from `config.json` is escaped where it lands in the markup.
|
|
4437
|
+
- **The build stamp** (7.27.29, build only): the plugin adds
|
|
4438
|
+
`<meta name="yuneta-build" content="<stamp>" data-version="<version>">` to
|
|
4439
|
+
the emitted `index.html`. `<stamp>` is a sha256 (16 hex characters) of the
|
|
4440
|
+
sorted names of the bundle's files, source maps excluded. `<version>` is the
|
|
4441
|
+
app's `package.json` version. `C_YUI_UPDATE_WATCH` reads it.
|
|
4353
4442
|
|
|
4354
4443
|
### Releasing
|
|
4355
4444
|
|