@yuneta/gobj-ui 7.27.27 → 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 CHANGED
@@ -3419,18 +3419,22 @@ child and publishes `EV_SET_GCLASS_TRACE {gclass, levels, set}` to it, which
3419
3419
  goes out as `EV_SET_TRACE_LEVEL {scope: "gclass"}`.
3420
3420
 
3421
3421
  Note what the C runtime does with them: a gclass or yuno level is saved by the
3422
- yuno (`trace_levels`) and **survives a restart**; a gobj level is saved too but
3423
- only the gclass and global scopes are re-applied at start up, so it **ends with
3424
- the yuno**. The blocks say so. The traces go to the yuno's log, not to the
3425
- Developer window.
3422
+ yuno (`trace_levels`) and **survives a restart**. A gobj level survives too
3423
+ when the gobj is a named **service** (SDK 7.27.3+: it is saved under its service
3424
+ name, the only name `set_user_gobj_traces()` can find at start up); any other
3425
+ gobj's level **ends with the yuno**. The card says which of the two its gobj
3426
+ is, and the gclass viewer that the gclass' levels survive. The traces go to the
3427
+ yuno's log, not to the Developer window.
3426
3428
 
3427
3429
  Consumer i18n keys (every app that mounts the tree): `traces of this gobj`,
3428
3430
  `kernel levels`, `this gobj`, `the whole yuno`, `all of the gclass`,
3429
3431
  `on for the whole yuno`, `on for all of the gclass`, `traces of the yuno`,
3430
3432
  `remove the traces of this gobj`, `remove the traces of the gclass`,
3431
3433
  `remove the traces of the yuno`, `the yuno's traces survive a restart`,
3432
- `gclass traces survive a restart, gobj traces end with the yuno` (plus
3433
- `yuno`, `level`, `loading` and `gclass`, which every app has).
3434
+ `the traces of a service survive a restart`,
3435
+ `the traces of a gobj that is not a service end with the yuno`,
3436
+ `the traces of a gclass survive a restart` (plus `yuno`, `level`, `loading`
3437
+ and `gclass`, which every app has).
3434
3438
 
3435
3439
  ### The gclass viewer — `yui_gclass_view.js`
3436
3440
 
@@ -3735,6 +3739,72 @@ a.close(); // still shown: b holds it
3735
3739
  b.close(); // gone
3736
3740
  ```
3737
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
+
3738
3808
  ### Modals — `yui_shell_show_modal` and the `before_close` veto
3739
3809
 
3740
3810
  `yui_shell_show_modal(shell, $box, opts)` is the standard popup: pass
@@ -4346,6 +4416,11 @@ export default { plugins: [ yunetaHtmlPlugin({ defaultTitle: "My App" }) ] };
4346
4416
  `style-src 'self' 'unsafe-inline'`, and `blob:`/`data:` where workers,
4347
4417
  images, media and fonts need them.
4348
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.
4349
4424
 
4350
4425
  ### Releasing
4351
4426