weifuwu 0.27.19 β†’ 0.27.21

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/dist/index.d.ts CHANGED
@@ -66,4 +66,4 @@ export { loadModule, clearModuleCache } from './ssr/compile.ts';
66
66
  export { cssContext, cssRouter, clearCSSCache } from './ssr/css.ts';
67
67
  export type { CssAsset } from './ssr/css.ts';
68
68
  export { assetRouter, assetScripts } from './ssr/assets.ts';
69
- export { wfuwAssets } from './ssr/ui/assets.ts';
69
+ export { wfuwAssets, wfuwVersion } from './ssr/ui/assets.ts';
package/dist/index.js CHANGED
@@ -3664,6 +3664,15 @@ import { readFileSync as readFileSync3 } from "node:fs";
3664
3664
  import { resolve as resolve7, dirname } from "node:path";
3665
3665
  import { fileURLToPath } from "node:url";
3666
3666
  var __dirname = dirname(fileURLToPath(import.meta.url));
3667
+ var wfuwVersion = (() => {
3668
+ try {
3669
+ const js = readFileSync3(resolve7(__dirname, "weifuwu-ui.js"), "utf-8");
3670
+ const m = js.match(/WFU_VERSION = '([^']+)'/);
3671
+ return m ? m[1] : "0.0.0";
3672
+ } catch {
3673
+ return "0.0.0";
3674
+ }
3675
+ })();
3667
3676
  function wfuwAssets() {
3668
3677
  const router = new Router();
3669
3678
  const jsPath = resolve7(__dirname, "weifuwu-ui.js");
@@ -3786,5 +3795,6 @@ export {
3786
3795
  validate,
3787
3796
  view,
3788
3797
  wfuwAssets,
3798
+ wfuwVersion,
3789
3799
  withTestDb
3790
3800
  };
@@ -1,2 +1,4 @@
1
1
  import { Router } from '../../core/router.ts';
2
+ /** Current weifuwu version, extracted from weifuwu-ui.js header. */
3
+ export declare const wfuwVersion: string;
2
4
  export declare function wfuwAssets(): Router;
@@ -1,4 +1,6 @@
1
1
  {
2
+ "theme": { "dark": "πŸŒ™" },
3
+ "lang": { "zh": "δΈ­ζ–‡", "en": "EN" },
2
4
  "title": "Build APIs & UI, Zero Build Step",
3
5
  "cta": "Try Me",
4
6
  "docs": "Documentation",
@@ -1,4 +1,6 @@
1
1
  {
2
+ "theme": { "dark": "πŸŒ™" },
3
+ "lang": { "zh": "δΈ­ζ–‡", "en": "EN" },
2
4
  "title": "ι›ΆηΌ–θ―‘ζž„ε»Ί API ε’Œ UI",
3
5
  "cta": "体ιͺŒδΈ€δΈ‹",
4
6
  "docs": "ζ–‡ζ‘£",
@@ -1,4 +1,4 @@
1
- import { html, raw } from 'weifuwu'
1
+ import { html, raw, wfuwVersion } from 'weifuwu'
2
2
 
3
3
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
4
  export default function (body: string, ctx: any) {
@@ -16,8 +16,8 @@ export default function (body: string, ctx: any) {
16
16
  <meta charset="utf-8" />
17
17
  <meta name="viewport" content="width=device-width, initial-scale=1" />
18
18
  <title>weifuwu</title>
19
- <link rel="stylesheet" href="/__wfw/css/weifuwu-ui.css" />
20
- <script src="/__wfw/js/weifuwu-ui.js"></script>
19
+ <link rel="stylesheet" href="/__wfw/css/weifuwu-ui.css?v=${wfuwVersion}" />
20
+ <script src="/__wfw/js/weifuwu-ui.js?v=${wfuwVersion}"></script>
21
21
  <script id="__wfw-i18n" type="application/json">
22
22
  ${raw(JSON.stringify(messages))}
23
23
  </script>
@@ -3,33 +3,28 @@ import { html, raw } from 'weifuwu'
3
3
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
4
  export default function (ctx: any) {
5
5
  const t = ctx.i18n?.t || ((k: string) => k)
6
- const theme = ctx.theme?.value || 'system'
7
- const locale = ctx.i18n?.locale || 'en'
8
6
 
9
7
  return html`<div wu-data='${raw(JSON.stringify({ open: false }))}'>
10
- <!-- Navbar -->
11
8
  <nav class="wu-flex wu-items-center wu-justify-between wu-p-4 wu-border-bottom">
12
9
  <strong class="wu-text-lg">weifuwu</strong>
13
10
  <div class="wu-flex wu-gap-sm wu-items-center">
14
- <button wu-theme="dark" class="wu-btn wu-btn-sm">πŸŒ™</button>
15
- <button wu-lang="zh-CN" class="wu-btn wu-btn-sm">δΈ­ζ–‡</button>
11
+ <button wu-theme="dark" class="wu-btn wu-btn-sm" wu-text-key="theme.dark">πŸŒ™</button>
12
+ <button wu-lang="zh-CN" class="wu-btn wu-btn-sm" wu-text-key="lang.zh">δΈ­ζ–‡</button>
16
13
  </div>
17
14
  </nav>
18
15
 
19
- <!-- Hero -->
20
16
  <section class="wu-p-4" style="max-width: 640px; margin: 80px auto; text-align: center;">
21
- <h1 class="wu-text-2xl" style="margin-bottom: 8px;">${t('title')}</h1>
17
+ <h1 class="wu-text-2xl" style="margin-bottom: 8px;" wu-text-key="title">${t('title')}</h1>
22
18
  <p class="wu-text-secondary wu-text-md" style="margin-bottom: 32px;">
23
19
  Pure Node.js, no build step
24
20
  </p>
25
21
 
26
22
  <div class="wu-flex wu-justify-center wu-gap-md">
27
- <button class="wu-btn wu-btn-primary" wu-on="click: open = !open">${t('cta')}</button>
28
- <a href="https://weifuwu.dev" class="wu-btn" target="_blank"> ${t('docs')} </a>
23
+ <button class="wu-btn wu-btn-primary" wu-on="click: open = !open" wu-text-key="cta">${t('cta')}</button>
24
+ <a href="https://weifuwu.dev" class="wu-btn" target="_blank" wu-text-key="docs">${t('docs')}</a>
29
25
  </div>
30
26
 
31
- <!-- Demo: toggled content -->
32
- <div wu-show="open" class="wu-card" style="margin-top: 24px; text-align: left;">
27
+ <div wu-show="open" class="wu-card" style="margin-top: 24px; text-align: left;" wu-text-key="demo">
33
28
  ${t('demo')}
34
29
  </div>
35
30
  </section>
@@ -11,6 +11,7 @@
11
11
  * @license MIT
12
12
  * @version 0.1.0
13
13
  */
14
+ const WFU_VERSION = '0.27.20';
14
15
  (function () {
15
16
  'use strict'
16
17
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weifuwu",
3
3
  "type": "module",
4
- "version": "0.27.19",
4
+ "version": "0.27.21",
5
5
  "description": "Web-standard HTTP microframework for Node.js β€” (req, ctx) => Response",
6
6
  "exports": {
7
7
  ".": "./dist/index.js"