@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 +81 -6
- package/dist/gobj-ui.cjs.js +737 -63
- package/dist/gobj-ui.es.js +738 -65
- package/index.js +1 -0
- package/package.json +2 -2
- package/src/c_yui_gclass.js +2 -2
- package/src/c_yui_gobj_tree_js.js +13 -5
- 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/gclass_traces.wiring.test.js +6 -0
- package/src/gobj_tree_remote.wiring.test.js +14 -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
|
@@ -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
|
|
3423
|
-
|
|
3424
|
-
the
|
|
3425
|
-
|
|
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
|
-
`
|
|
3433
|
-
`
|
|
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
|
|