Chat Logs

  1. * phaleth joined #primate
  2. phalethno flash!
  3. phalethnot even on epiphany
  4. phaleth16 files changed
  5. bluephaleth: hi. how did you do that?
  6. blueI'm working on markdowndb btw
  7. blueI think markdown as a traditional frontend. really makes no sense. it doesn't get props, and it doesn't have logic
  8. blueinstead, we're going to have a store-like interface around it that queries the data in real time in dev, and in prod inlines everything
  9. bluethe inline part is hard, because that possibly requires access to app, and dbs don't partake in the app lifecycle
  10. bluephaleth: dreamreal: https://dpaste.com/3QSFU543W
  11. bluethen on `BlogPost.get("primate-39"), you're gonna get { html, toc, path, body, frontmatter }
  12. bluethe only tricky part is to have this operation loads from the fs in dev, and from memory, as part of the bundle, in prod
  13. blueload*
  14. bluebut markdowndb is the key to unlock full cms capabilities
  15. phalethblue: hi
  16. phalethcan you check the last PR on primate repo?
  17. phalethI'm looking for a post-build handler or something like that
  18. phaleth*latest PR
  19. phalethwhy is it called db if it's not overridable?
  20. blueI'll check it phaleth
  21. bluewhat do you mean with no overridable?
  22. bluenot(
  23. bluenot*
  24. phalethmarkdown files are static I guess
  25. bluethe problem is we want different behaviour during dev and prod. in dev it's acceptable to load / transform the mds on the fly, in prod it isn't
  26. blueplus, primate/website has different addons like transforming snippets which makes everything more complicated
  27. blueI wish I had a good solution for it, I currently don't
  28. phalethso the db is like a cache for md files?
  29. phalethmight was well just transform them to html and let the site be static
  30. phalethbtw, the PR I opened is getting towards that, just need to figure out a build step, I could slap something together after build, but I'm wondering if there is something primate specific
  31. bluethere is `app.done`. I don't like it, but you can use it
  32. bluehttps://github.com/primate-run/primate/blob/master/packages/native/src/private/module.ts#L29
  33. bluethat's essentially a postbuild
  34. bluethe thing is that I want something in between "fully static, separate HTMLs" and "load/transform mds in dev mode"
  35. blueI do like the fact the current solution bundles everything into one server.js
  36. blueforcing you to otherwise always do --target=static could be a regression
  37. blue(or copy the .mds to production and load them on demand)
  38. bluealso we reason about the mds in some routes
  39. bluehttps://github.com/primate-run/primate/blob/master/apps/website/routes/llms.txt.ts
  40. bluehttps://github.com/primate-run/primate/blob/master/apps/website/routes/llms-full.txt.ts
  41. bluethese two would be a catastrophe without caching
  42. phalethcaching server side you mean?
  43. blueyes
  44. blueobviously in a world of --target=static, you just build llms.txt into llms.txt.html once and you're done
  45. phalethjust take a look at the response time here, it's not so bad https://grafana.repopack.app/public-dashboards/ce90d22ed104477ea945d2c35aa8d3d7
  46. blueit's not bad right now because it's all precompiled in memory
  47. phalethif the website gets busy then you can bother yourself with that, but then SSG and running the site on nginx would solve all those problems
  48. phalethyeah, and memory is fast
  49. blueyes but @primate/markdown is just for apps/website, I'm trying to rethink it as a general cms-like solution
  50. blueisn't just*
  51. phalethdid you see the response time? :)
  52. phaleththere is not much to gain
  53. blue9 ms?
  54. phalethyeah, deno is kinda slow, but still acceptable
  55. blueno let's optimise it to 0.5 ms </sumner>
  56. phalethheh, then that means it's nginx
  57. blueyeah I was joking, 9 ms is totally acceptable for now
  58. blueso my point is
  59. blueapps/website is actually not the issue here. it'll get --target=static and be happy with its htmls. especially with your colourscheme work
  60. bluethe issue here are other apps. I have this small apps where I keep notes, like obsidian, and the 'load from fs' is fully acceptable for it at least in dev mode
  61. bluesmall app*
  62. blueso essentially this is a caching problem
  63. blueyou don't want to run the expensive md > html pipeline on every request
  64. blueyou ideally only want to run it when the source has changed
  65. bluefor the fs, you could do a small `stats` check I suppose and compare against what you last saw
  66. phalethok, so then it's a store, it's not a db
  67. blueyes it is a store, it'll be exposed as markdown.store
  68. blueand you'll have programmatic access to the frontmatter and also partitioning
  69. blue(say if you have i18n)
  70. phaleththe github experience https://images4.imagebam.com/6a/e8/8a/ME1D55XF_o.png
  71. blueoh wow, that looks like garbage
  72. blueI think what we need is
  73. phalethyeah
  74. blue@primate/markdown.store becomes the new way to use markdown, and --target=static is how we solve the caching problem for apps/website
  75. blueI still don't know how to tell --target=static though how it should generate pages based on a parameterised route
  76. bluebut yeah, all of this still doesn't solve my major conundrum during dev which is that apps/website takes way too long to start up, and recreate the bundle
  77. phalethyeah, primate website takes a while to startup in dev mode
  78. bluemaybe, markdown.store runs all the pipeline on startup (or if you don't care, you can pass in lazy: true).
  79. bluein dev mode I'd generally go lazy, I think
  80. blueand the website would start up immediately
  81. blueso every docs page is converted on the fly, and then cached until stats has changed
  82. blueand in production, --target=static takes over, so laziness isn't relevant, everything gets produced during build
  83. bluemaybe I don't even need lazy: true and it's always lazy, and always cached
  84. blueI think this is a good compromise
  85. bluebut this requires markdown stores and --target=static to arrive in the same commit
  86. blueotherwise we can't meaningfully deploy the website, it'll be slow on first requests and you'd need to copy .md files and the snippets directly and what not
  87. phalethcool, looking forward to static target
  88. blueya
  89. phalethI have a FileRef to a text file, now I need to replace contents inside the file behind the FileRef, how to do that with rcompat?
  90. phalethnpm install replace
  91. phalethomg
  92. phalethwrite method exists
  93. blueyes
  94. blueif it's an object you want to write you also have writeJSON
  95. bluethat will write it out as a JSON string you can later load with #json
  96. phalethit's a JS file
  97. phalethplain text
  98. bluecool, then just #write
  99. phalethwrite works, I just don't know how to read the file
  100. bluetext()
  101. phalethah, ok
  102. bluedo you want to read it, or import it?
  103. phalethnice, that worked
  104. bluecool
  105. phalethblue: any clue why is the browser getting the unminified file? https://images4.imagebam.com/61/fe/8d/ME1D57VH_o.png
  106. phalethI've just pushed the changes, but why is that JS file served unminified and with the correct filename containing the hash is a total mystery
  107. bluephaleth: where is that file located, in static?
  108. blueit looks like esbuild chunked it
  109. blueit should be minified though
  110. blueoh, it's in static
  111. blueare the js/css minified?
  112. phalethyeah, I guess that file being in static dir is the problem, so I'm gonna run it through the bundler even for dev
  113. bluewhat I'm wondering aobut is how come this didn't land in app.js. it should
  114. phalethno, it should not, that's actually the goal
  115. blueoh, ok
  116. blueshould still be minified
  117. phalethit's supposed to be it's own chunk
  118. phalethyeah, everything is minifed, it's just that one file originaly from static dir is served verbatim
  119. bluehow did you achieve chunking?
  120. phalethI'll just make it a ts file and make it part of the build for dev
  121. phalethmagic :D
  122. bluelol
  123. phalethtake a look at app.html on the PR
  124. blueoh
  125. blue<script src="scheme-storage.js"></script>
  126. phalethlooks like I can have a client dir as part of the project
  127. bluehm, I still believe primate scans the static dir for js/css and incorporates it
  128. phalethok, then I should move that to client dir
  129. bluewhat does that client dir do?
  130. blueI'm discovering things about primate I never knew existed :P
  131. bluethat's fairly wonderous, given I've written nearly 100% of it myself, haha
  132. phalethI hope if I put the file in client dir it will end up in build/client
  133. blueI don't know what that hope is based on
  134. blueis that documented?
  135. phalethit's a flat out hope
  136. blueoh
  137. blueprobably not gonna work
  138. phalethI don't tend to look into documentation
  139. blueya
  140. bluesame
  141. bluedocs are for idiots
  142. phalethso what should I use instead of the static dir?
  143. bluewell generally speaking, %head% is your friend
  144. blueyou shouldn't hard-encode scripts into <head>
  145. bluelet me see what's the way to latch onto %head%
  146. blue .replace("%head%", render_head(this.#assets, head));
  147. bluelet's see how #assets is populated
  148. phalethI can get FileRef to app.html
  149. blueok, AppServe#publish does that
  150. phalethbut you know the app.html ends up being in server.js when in the post build phase
  151. phalethnot sure if the %head% thing is still in place there, but let me see
  152. blueya
  153. bluehmpf, I don't see anyone calling publish really
  154. blueis this mechanism even in use anymore
  155. blueI think esbuild completely replaced it
  156. phalethah ok, the %head% is still there
  157. phalethyeah, so that means esbuild has put the scheme-storage-blahblah.js into head and that's why it's served verbatim
  158. phalethbut I need to chunk it out, so how to tell AppServe.publish or whatever to not include that?
  159. blueso I think publish is dead code
  160. bluelook at ServeApp#start
  161. bluethat generates the assets
  162. phalethyeah, but that's in core
  163. blue Object.entries(this.#serve_assets.client)
  164. bluelet me see who populates that
  165. phalethor not? I was hoping there would be a handler I could hook up to from within Website.ts
  166. phalethisn't there onServe?
  167. phalethI think I've deleted that one
  168. bluethere is, yes
  169. phalethI have no clue what to do
  170. bluewhat are you trying to achieve
  171. phalethexactly what's on that picture, but the response for scheme-storage-blahblah.js should be minified as you see in the text editor above
  172. bluepull it into the bundle then
  173. blueplace the file in static, esbuild will pull it in
  174. bluedon't worry about the rest of the stuff
  175. phalethno, the bundle is too big and that's why there is a flash
  176. phaletheven currently, there is a flash
  177. blueyes but in --target=static, the bundle won't contain much
  178. phalethnah, it will always be tens of KBs at least and that's enough to flash
  179. phalethalso this tiny JS is loaded before css
  180. phalethand that huge bundle should not be loaded before css and should not stop css for loading either
  181. bluebut in the future, that bundles should be basically only scheme-storage,js
  182. bluebundle*
  183. phalethbut since there is at least the content hash, I'm fine with what's currently on that PR
  184. blueeverything else falls away, the components, the fetch navigation, etc.
  185. blueyou can simulate it now by turning off CSR
  186. bluesvelte({ csr: false })
  187. phalethwell, that'd mean full reloads on navigation
  188. bluewait, that's what we *want* to do with target static, no?
  189. phalethI think the proposal says something different, but hold on that thought now
  190. phalethI'll log into github and mark the PR as ready
  191. phalethand let you test that change
  192. phalethon brave
  193. blueyeah the proposal is a bit more contrived
  194. bluesomething like, there's a JSON file for the mds or smth
  195. phalethyeah, but don't worry about that
  196. phalethfirst please check if whatever I did works in brave
  197. phaleththe file is like 1.27 kBs unminifield vs 717 Bs minified
  198. phalethwhich is not much
  199. phalethno need to rewrite primate cause of that :D
  200. phalethcause if that works then full page reloads are fine
  201. blueya
  202. blueyeah, this markdown redo is overdue anyway
  203. blueand --target=static, too
  204. phalethfor primate website I'm gonna work on making the JS bundle size smaller, but first I need to make sure everything happens client side
  205. phalethand this light/dark thing is being tricky
  206. blueya
  207. phalethwhat does FileRef.debase do? gives you the filename?
  208. phalethor I think it's more like fs.debase
  209. phalethah, it expects args
  210. bluegive /tmp/a/b being the 'base', and tmp/a/b/c/d.js being the fileRef, it allows you get c/d.js,
  211. bluegiven*
  212. phalethah, ok, seems like it always returns the subpath with starting forwardslash
  213. blueya, that's unfortunate, I wanted to fix that annoying forward slash
  214. blueotherwise just do .slice(1)
  215. phaleththis this.#serve_assets.client that you've mentioned is being populated out of nowhere and only during production not serve but build I guess
  216. * jreicher joined #primate