gitoria

notes

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit90c73ed390c73ed3notes mobile: back link gapmre90c73ed3/lib/util.hl

1.6 KB

  1. // lib/util.hl — SMALL SHARED HELPERS (notes mission 002, code order): the environment, the table folder, lists and the
  2. // id checks. Each lives here once; the topic files import them.
  3. import { env } from 'hl:proc'
  4. // an environment variable (or `.env` beside project.hl), trimmed; unset or blank → fallback
  5. static envOr = (name, fallback) => {
  6. v = env(name)
  7. return v != null && v.trim() != '' ? v.trim() : fallback
  8. }
  9. // NOTES_STORAGE = the table directory (default ./storage/mpackdb, relative to project.hl)
  10. static storageDir = envOr('NOTES_STORAGE', './storage/mpackdb')
  11. static countOfList = (list) => {
  12. if (list == null) { return 0 }
  13. n = list.length
  14. return n == null ? 0 : n
  15. }
  16. static firstOf = (list) => { return countOfList(list) > 0 ? list[0] : null }
  17. // only lowercase hex (ident's one-time codes are 48 hex)
  18. static isHex = (s, max) => {
  19. if (s == null || hlTypeName(s) != 'String' || s.length == 0 || s.length > max) { return false }
  20. let i = 0
  21. while (i < s.length) {
  22. let c = s.charCodeAt(i)
  23. if (!((c >= 48 && c <= 57) || (c >= 97 && c <= 102))) { return false }
  24. i = i + 1
  25. }
  26. return true
  27. }
  28. // an identity id as ident answers it: its public SHORT ID since ident#23 (5 characters like `a68sz`: 2-9 and a-z),
  29. // before that the old per-app id (32 hex) — lower case letters and digits, at most 64 (mission 039; isHex refused `a68sz`)
  30. static isIdentId = (s) => {
  31. if (s == null || hlTypeName(s) != 'String' || s.length == 0 || s.length > 64) { return false }
  32. let i = 0
  33. while (i < s.length) {
  34. let c = s.charCodeAt(i)
  35. if (!((c >= 48 && c <= 57) || (c >= 97 && c <= 122))) { return false }
  36. i = i + 1
  37. }
  38. return true
  39. }

Branches

Latest commits

  • 90c73ed3notes mobile: back link gapmre
  • 72bd4f83notes mobile: list header on the gutter, delete confirmation as a question + two equal buttons, Delete note under the editor edgemre
  • ba1e73f8notes: a sent edit is done once the server's version is not older, so a second writer's text shows in the first tab; gate: two writers both waysmre
  • c69ef9ebsync components.hybriel 134b4e3: MdEditor builds an editor put into the page at once, redraws a surface put in anew (F5, hybriel#211)mre
  • 2eb783f5sync components 9a: shared Icon (icons/icons.hl), md-editor toolbar icons + single focus ring (components f4-icons ba96735)mre
  • 4dd46dadsync-components: copy icons/icons.hl + README (F4); testsmre
  • c92e4a0ftests/e2e-outside.mjs: real-Chrome E2E, a note pushed from another device while open, then typingmre
  • 0516b4ccmd-editor.hl: verbatim copy of components f3-mdvalue (an older text handed back is kept)mre
  • 38cc11ecmd-editor.hl: verbatim copy of components f3-mdvalue (an outside value change is shown by the editor)mre
  • 3e7e79f5reports/H1-hydrate.mdmre
  • d98775e8tests/browser.mjs: wait for hydration before the clicks after a goto('/') (tables new note, phone sidebar)mre
  • 1f3198b6tests/cdp.mjs: HL_CPU_THROTTLE=<rate> optional CPU throttling for gate runsmre
  • 39cf9fdfre-vendor Hybriel 5406d146 (hl:web batches 9+10: #72 emits while the socket is closed delivered after reconnect, browser boot linear, faster list appends; contains int 6–14 + m406)mre
  • db07aa84tests: short-id-switch ports from env (NOTES_SWITCH_IDENT_PORT/_PORT), defaults unchangedmre
  • ef9f9feere-vendor Hybriel 6f8a0689 (int 6–11: streaming cursors, #203 index heal + close() fix, fd403 listDir/cursor fds, hl:time browser side, hl:web batches 5+6)mre
  • 5485467cdocker-compose: nofile 65536 (Hybriel int 6+ boot opened >1024 files in the tracker)mre
  • 86ea4a85deploy: backup copies index files first and *.mpack data last (hot-copy skew, hybriel #203)mre
  • edeab20fnotes mission 015: mission, report, LOG, STATUSmre
  • 542a0383notes mission 015: e2e-chrome E2E_HOST (own cookie jar in the shared Chrome)mre
  • 8b30f510notes mission 015: main-menu from layouts 0bcc629, current = true kept (route marks only /), server-HTML marker checksmre