@vesk/runtime 0.2.9 → 0.2.11
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 +69 -2
- package/dist/hmr-client.d.ts +323 -0
- package/dist/hmr-client.d.ts.map +1 -1
- package/dist/hmr-client.js +3869 -197
- package/dist/md.d.ts +7 -3
- package/dist/md.d.ts.map +1 -1
- package/dist/md.js +228 -38
- package/dist/request.d.ts +28 -0
- package/dist/request.d.ts.map +1 -1
- package/dist/request.js +70 -0
- package/dist/resource.d.ts +5 -0
- package/dist/resource.d.ts.map +1 -1
- package/dist/resource.js +71 -3
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +7 -3
- package/package.json +2 -2
package/dist/md.d.ts
CHANGED
|
@@ -55,7 +55,7 @@ export interface MdHtmlWarning {
|
|
|
55
55
|
/** Short sample of the source snippet (bounded). */
|
|
56
56
|
sample: string;
|
|
57
57
|
}
|
|
58
|
-
export declare const MD_BASE_CSS = "\n.vesk-md { color:
|
|
58
|
+
export declare const MD_BASE_CSS = "\n.vesk-md { color: inherit; font-size: 16px; line-height: 1.7; word-wrap: break-word; }\n.vesk-md h1,.vesk-md h2,.vesk-md h3,.vesk-md h4,.vesk-md h5,.vesk-md h6 { margin: 1.4em 0 .6em; font-weight: 650; line-height: 1.25; }\n.vesk-md h1 { font-size: 2em; }\n.vesk-md h2 { font-size: 1.5em; }\n.vesk-md h3 { font-size: 1.25em; } .vesk-md h4 { font-size: 1em; }\n.vesk-md p { margin: .8em 0; }\n.vesk-md a { color: color-mix(in srgb, currentColor 50%, #0969da); text-decoration: none; } .vesk-md a:hover { text-decoration: underline; }\n.vesk-md img { max-width: 100%; border-radius: 6px; }\n.vesk-md hr { border: 0; height: 1px; background: color-mix(in srgb, currentColor 18%, transparent); margin: 1.6em 0; }\n.vesk-md blockquote { margin: .8em 0; padding: .2em 1em; color: color-mix(in srgb, currentColor 62%, transparent); border-left: .25em solid color-mix(in srgb, currentColor 18%, transparent); }\n.vesk-md ul,.vesk-md ol { margin: .8em 0; padding-left: 2em; }\n.vesk-md ul { list-style: disc; } .vesk-md ul ul { list-style: circle; } .vesk-md ul ul ul { list-style: square; }\n.vesk-md ol { list-style: decimal; } .vesk-md ol ol { list-style: lower-alpha; }\n.vesk-md li { margin: .25em 0; }\n.vesk-md li.md-task { list-style: none; margin-left: -1.4em; display: flex; gap: .5em; align-items: baseline; }\n.vesk-md code:not(pre code) { background: color-mix(in srgb, currentColor 12%, transparent); padding: .15em .35em; border-radius: 5px; font-family: ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; font-size: 85%; }\n.vesk-md .md-table-wrap { overflow-x: auto; margin: .8em 0; }\n.vesk-md table.md-table { border-collapse: collapse; width: max-content; max-width: 100%; font-size: .95em; }\n.vesk-md .md-table th,.vesk-md .md-table td { border: 1px solid color-mix(in srgb, currentColor 18%, transparent); padding: 6px 13px; }\n.vesk-md .md-table th { background: color-mix(in srgb, currentColor 8%, transparent); font-weight: 650; }\n.vesk-md .md-table tr:nth-child(2n) td { background: color-mix(in srgb, currentColor 5%, transparent); }\n.vesk-md .md-code { --md-code-bg: color-mix(in srgb, currentColor 6%, transparent); margin: 1em 0; border-radius: 8px; overflow: hidden; background: var(--md-code-bg); border: 1px solid color-mix(in srgb, currentColor 15%, transparent); }\n.vesk-md .md-code-bar { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px; background: var(--md-code-bg); border-bottom: 1px solid color-mix(in srgb, currentColor 15%, transparent); }\n.vesk-md .md-code-lang { font-family: ui-monospace,monospace; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: color-mix(in srgb, currentColor 60%, transparent); }\n.vesk-md .md-copy { all: unset; cursor: pointer; font: 11px ui-monospace,monospace; color: color-mix(in srgb, currentColor 60%, transparent); padding: 2px 8px; border-radius: 6px; }\n.vesk-md .md-copy:hover { color: inherit; background: color-mix(in srgb, currentColor 10%, transparent); }\n.vesk-md .md-copy.md-copied { color: color-mix(in srgb, currentColor 70%, transparent); }\n.vesk-md .md-code pre { margin: 0; overflow-x: auto; padding: 14px 16px; }\n.vesk-md .md-code code { font-family: ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; font-size: 13.5px; line-height: 1.55; color: var(--md-code-fg,inherit); background: none; padding: 0; }\n.vesk-md code[md-lines] { counter-reset: ln; display: block; }\n.vesk-md code[md-lines] .tok-line { display: block; counter-increment: ln; padding-left: 3.2em; position: relative; }\n.vesk-md code[md-lines] .tok-line::before { content: counter(ln); position: absolute; left: 0; width: 2.4em; text-align: right; color: color-mix(in srgb, currentColor 50%, transparent); user-select: none; }\n.tok-kw { color: color-mix(in srgb, currentColor 85%, transparent); } .tok-lit { color: color-mix(in srgb, currentColor 80%, transparent); } .tok-str { color: color-mix(in srgb, currentColor 72%, transparent); }\n.tok-num { color: color-mix(in srgb, currentColor 80%, transparent); } .tok-com { color: color-mix(in srgb, currentColor 52%, transparent); font-style: italic; }\n.tok-fn { color: color-mix(in srgb, currentColor 72%, transparent); } .tok-attr { color: color-mix(in srgb, currentColor 72%, transparent); } .tok-prop { color: color-mix(in srgb, currentColor 72%, transparent); }\n.tok-sel { color: color-mix(in srgb, currentColor 74%, transparent); } .tok-add { color: color-mix(in srgb, currentColor 86%, transparent); background: color-mix(in srgb, currentColor 10%, transparent); display: inline-block; width: 100%; }\n.tok-del { color: color-mix(in srgb, currentColor 86%, transparent); background: color-mix(in srgb, currentColor 10%, transparent); display: inline-block; width: 100%; }\n.vesk-md-light { color: #24292f; --md-code-bg: #f6f8fa; --md-code-fg: #1f2328; --md-link: #0969da; }\n.vesk-md-light a { color: #0969da; }\n.vesk-md-light hr { background: #d0d7de; }\n.vesk-md-light blockquote { color: #57606a; border-left-color: #d0d7de; }\n.vesk-md-light code:not(pre code) { background: rgba(175,184,193,.2); }\n.vesk-md-light .md-table th,.vesk-md-light .md-table td { border-color: #d0d7de; }\n.vesk-md-light .md-table th { background: #f6f8fa; }\n.vesk-md-light .md-table tr:nth-child(2n) td { background: #f6f8fa80; }\n.vesk-md-light .md-code { border-color: #d1d9e0; }\n.vesk-md-light .md-code-bar { border-bottom-color: #d1d9e0; }\n.vesk-md-light .md-code-lang { color: #59636e; }\n.vesk-md-light .md-copy { color: #59636e; }\n.vesk-md-light .md-copy:hover { color: #1f2328; background: #eaeef2; }\n.vesk-md-light .md-copy.md-copied { color: #1a7f37; }\n.vesk-md-light code[md-lines] .tok-line::before { color: #8c959f; }\n.vesk-md-light .tok-kw { color: #cf222e; } .vesk-md-light .tok-lit { color: #0550ae; } .vesk-md-light .tok-str { color: #0a3069; }\n.vesk-md-light .tok-num { color: #0550ae; } .vesk-md-light .tok-com { color: #59636e; font-style: italic; }\n.vesk-md-light .tok-fn { color: #8250df; } .vesk-md-light .tok-attr { color: #0550ae; } .vesk-md-light .tok-prop { color: #0550ae; }\n.vesk-md-light .tok-sel { color: #116329; } .vesk-md-light .tok-add { color: #116329; background: #dafbe1; }\n.vesk-md-light .tok-del { color: #cf222e; background: #ffebe9; }\n.vesk-md-dark { --md-code-bg: #0d1117; --md-code-fg: #c9d1d9; color: #f0f6fc; --md-link: #4493f8; }\n.vesk-md-dark a { color: #4493f8; }\n.vesk-md-dark hr { background: #30363d; }\n.vesk-md-dark blockquote { color: #8b949e; border-left-color: #30363d; }\n.vesk-md-dark code:not(pre code) { background: rgba(110,118,129,.4); }\n.vesk-md-dark .md-table th,.vesk-md-dark .md-table td { border-color: #30363d; }\n.vesk-md-dark .md-table th { background: #161b22; }\n.vesk-md-dark .md-table tr:nth-child(2n) td { background: #161b2280; }\n.vesk-md-dark .md-code { border-color: #30363d; }\n.vesk-md-dark .md-code-bar { border-bottom-color: #30363d; }\n.vesk-md-dark .md-code-lang { color: #8b949e; }\n.vesk-md-dark .md-copy { color: #8b949e; }\n.vesk-md-dark .md-copy:hover { color: #c9d1d9; background: #30363d; }\n.vesk-md-dark .md-copy.md-copied { color: #3fb950; }\n.vesk-md-dark code[md-lines] .tok-line::before { color: #484f58; }\n.vesk-md-dark .tok-kw { color: #ff7b72; } .vesk-md-dark .tok-lit { color: #79c0ff; }\n.vesk-md-dark .tok-str { color: #a5d6ff; } .vesk-md-dark .tok-num { color: #f2cc60; }\n.vesk-md-dark .tok-com { color: #8b949e; font-style: italic; }\n.vesk-md-dark .tok-fn { color: #d2a8ff; } .vesk-md-dark .tok-attr { color: #79c0ff; }\n.vesk-md-dark .tok-prop { color: #79c0ff; } .vesk-md-dark .tok-sel { color: #7ee787; }\n.vesk-md-dark .tok-add { color: #aff5b4; background: rgba(46,160,67,.15); }\n.vesk-md-dark .tok-del { color: #ffdcd7; background: rgba(248,81,73,.15); }\n";
|
|
59
59
|
/**
|
|
60
60
|
* Renders markdown to HTML with default (legacy) options — output shape is
|
|
61
61
|
* stable for existing consumers. Pass options for advanced features:
|
|
@@ -85,7 +85,9 @@ export declare function setMdConsoleWarnings(enabled: boolean): void;
|
|
|
85
85
|
/** Drains the collected passthrough samples (for build-time summaries). */
|
|
86
86
|
export declare function drainMdHtmlWarnings(): MdHtmlWarning[];
|
|
87
87
|
export interface MdProps {
|
|
88
|
-
/** Markdown source — a plain string
|
|
88
|
+
/** Markdown source — a plain string, a tracked cell (reactive on client), a
|
|
89
|
+
* streamed resource (useFetch.stream — re-renders per chunk), or an
|
|
90
|
+
* absolute public markdown path (runtime-loaded from the app's public dir). */
|
|
89
91
|
content?: string | {
|
|
90
92
|
get: () => string;
|
|
91
93
|
};
|
|
@@ -93,7 +95,9 @@ export interface MdProps {
|
|
|
93
95
|
codeBg?: string;
|
|
94
96
|
/** Default code text color. Fence-level fg= wins. */
|
|
95
97
|
codeFg?: string;
|
|
96
|
-
/** Code theme preset: 'light'
|
|
98
|
+
/** Code theme preset: 'light' or 'dark'. When omitted, <Md> is
|
|
99
|
+
* backgroundless and inherits the page's background/theme (transparent
|
|
100
|
+
* wrapper, neutral currentColor-based surfaces). Per-fence bg=/fg= still win. */
|
|
97
101
|
theme?: 'light' | 'dark';
|
|
98
102
|
class?: string;
|
|
99
103
|
className?: string;
|
package/dist/md.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"md.d.ts","sourceRoot":"","sources":["../src/md.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"md.d.ts","sourceRoot":"","sources":["../src/md.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAwC/D,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAW5C;AAwcD,4EAA4E;AAC5E,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAgB/C;AAID,UAAU,MAAM;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACd;AA6ND;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CA6HhE;AAyWD,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3B,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,eAAe,CAAC,EAAE,aAAa,EAAE,CAAC;CAClC;AAkZD,MAAM,WAAW,eAAe;IAC/B,wEAAwE;IACxE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,uFAAuF;IACvF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,uFAAuF;IACvF,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,0EAA0E;IAC1E,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,mDAAmD;IACnD,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,OAAO,CAAC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AM,MAAM,CAAA;KAAE,CAAC;IACzC,0FAA0F;IAC1F,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qDAAqD;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;sFAEkF;IAClF,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yFAAyF;IACzF,GAAG,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACvB,kEAAkE;IAClE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,8EAA8E;IAC9E,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,0EAA0E;IAC1E,IAAI,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;IAC3B,6EAA6E;IAC7E,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACrB;AAuMD;;;;;;GAMG;AACH,wBAAgB,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,IAAI,GAAG,MAAM,CAwE3G"}
|
package/dist/md.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { effect } from '@vesk/runtime/src/ripple-blocks';
|
|
2
|
+
import { tracked, get, set } from '@vesk/runtime/src/ripple-runtime';
|
|
3
|
+
import { getSsrData, setSsrData } from '@vesk/runtime/src/resource';
|
|
2
4
|
// =============================================================
|
|
3
5
|
// Markdown rendering for <Md content={...} />.
|
|
4
6
|
//
|
|
@@ -11,9 +13,10 @@ import { effect } from '@vesk/runtime/src/ripple-blocks';
|
|
|
11
13
|
// chrome, heading anchors, autolinks, hard breaks) and can be tuned
|
|
12
14
|
// via props (css / lineNumbers / copy / highlight / ids / autolink).
|
|
13
15
|
//
|
|
14
|
-
// `content` accepts a plain string
|
|
15
|
-
//
|
|
16
|
-
//
|
|
16
|
+
// `content` accepts a plain string, a tracked cell, a useFetch.stream()
|
|
17
|
+
// resource, or an absolute public markdown path (runtime-loaded) —
|
|
18
|
+
// cells/resources are unwrapped for rendering and, on the client,
|
|
19
|
+
// subscribed so the rendered markdown updates reactively.
|
|
17
20
|
// =============================================================
|
|
18
21
|
/** Unwraps tracked cells passed as props (compiler emits the cell itself). */
|
|
19
22
|
function unwrapMaybeCell(v) {
|
|
@@ -2020,44 +2023,72 @@ function renderBlocks(blocks, ctx) {
|
|
|
2020
2023
|
}
|
|
2021
2024
|
// ── Base stylesheet (opt-in via <Md css>) ────────────────────
|
|
2022
2025
|
export const MD_BASE_CSS = `
|
|
2023
|
-
.vesk-md { color:
|
|
2026
|
+
.vesk-md { color: inherit; font-size: 16px; line-height: 1.7; word-wrap: break-word; }
|
|
2024
2027
|
.vesk-md h1,.vesk-md h2,.vesk-md h3,.vesk-md h4,.vesk-md h5,.vesk-md h6 { margin: 1.4em 0 .6em; font-weight: 650; line-height: 1.25; }
|
|
2025
2028
|
.vesk-md h1 { font-size: 2em; }
|
|
2026
2029
|
.vesk-md h2 { font-size: 1.5em; }
|
|
2027
2030
|
.vesk-md h3 { font-size: 1.25em; } .vesk-md h4 { font-size: 1em; }
|
|
2028
2031
|
.vesk-md p { margin: .8em 0; }
|
|
2029
|
-
.vesk-md a { color: #0969da; text-decoration: none; } .vesk-md a:hover { text-decoration: underline; }
|
|
2032
|
+
.vesk-md a { color: color-mix(in srgb, currentColor 50%, #0969da); text-decoration: none; } .vesk-md a:hover { text-decoration: underline; }
|
|
2030
2033
|
.vesk-md img { max-width: 100%; border-radius: 6px; }
|
|
2031
|
-
.vesk-md hr { border: 0; height: 1px; background:
|
|
2032
|
-
.vesk-md blockquote { margin: .8em 0; padding: .2em 1em; color:
|
|
2034
|
+
.vesk-md hr { border: 0; height: 1px; background: color-mix(in srgb, currentColor 18%, transparent); margin: 1.6em 0; }
|
|
2035
|
+
.vesk-md blockquote { margin: .8em 0; padding: .2em 1em; color: color-mix(in srgb, currentColor 62%, transparent); border-left: .25em solid color-mix(in srgb, currentColor 18%, transparent); }
|
|
2033
2036
|
.vesk-md ul,.vesk-md ol { margin: .8em 0; padding-left: 2em; }
|
|
2034
2037
|
.vesk-md ul { list-style: disc; } .vesk-md ul ul { list-style: circle; } .vesk-md ul ul ul { list-style: square; }
|
|
2035
2038
|
.vesk-md ol { list-style: decimal; } .vesk-md ol ol { list-style: lower-alpha; }
|
|
2036
2039
|
.vesk-md li { margin: .25em 0; }
|
|
2037
2040
|
.vesk-md li.md-task { list-style: none; margin-left: -1.4em; display: flex; gap: .5em; align-items: baseline; }
|
|
2038
|
-
.vesk-md code:not(pre code) { background:
|
|
2041
|
+
.vesk-md code:not(pre code) { background: color-mix(in srgb, currentColor 12%, transparent); padding: .15em .35em; border-radius: 5px; font-family: ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; font-size: 85%; }
|
|
2039
2042
|
.vesk-md .md-table-wrap { overflow-x: auto; margin: .8em 0; }
|
|
2040
2043
|
.vesk-md table.md-table { border-collapse: collapse; width: max-content; max-width: 100%; font-size: .95em; }
|
|
2041
|
-
.vesk-md .md-table th,.vesk-md .md-table td { border: 1px solid
|
|
2042
|
-
.vesk-md .md-table th { background:
|
|
2043
|
-
.vesk-md .md-table tr:nth-child(2n) td { background:
|
|
2044
|
-
.vesk-md .md-code { --md-code-bg:
|
|
2045
|
-
.vesk-md .md-code-bar { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px; background: var(--md-code-bg); border-bottom: 1px solid
|
|
2046
|
-
.vesk-md .md-code-lang { font-family: ui-monospace,monospace; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color:
|
|
2047
|
-
.vesk-md .md-copy { all: unset; cursor: pointer; font: 11px ui-monospace,monospace; color:
|
|
2048
|
-
.vesk-md .md-copy:hover { color:
|
|
2049
|
-
.vesk-md .md-copy.md-copied { color:
|
|
2044
|
+
.vesk-md .md-table th,.vesk-md .md-table td { border: 1px solid color-mix(in srgb, currentColor 18%, transparent); padding: 6px 13px; }
|
|
2045
|
+
.vesk-md .md-table th { background: color-mix(in srgb, currentColor 8%, transparent); font-weight: 650; }
|
|
2046
|
+
.vesk-md .md-table tr:nth-child(2n) td { background: color-mix(in srgb, currentColor 5%, transparent); }
|
|
2047
|
+
.vesk-md .md-code { --md-code-bg: color-mix(in srgb, currentColor 6%, transparent); margin: 1em 0; border-radius: 8px; overflow: hidden; background: var(--md-code-bg); border: 1px solid color-mix(in srgb, currentColor 15%, transparent); }
|
|
2048
|
+
.vesk-md .md-code-bar { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px; background: var(--md-code-bg); border-bottom: 1px solid color-mix(in srgb, currentColor 15%, transparent); }
|
|
2049
|
+
.vesk-md .md-code-lang { font-family: ui-monospace,monospace; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: color-mix(in srgb, currentColor 60%, transparent); }
|
|
2050
|
+
.vesk-md .md-copy { all: unset; cursor: pointer; font: 11px ui-monospace,monospace; color: color-mix(in srgb, currentColor 60%, transparent); padding: 2px 8px; border-radius: 6px; }
|
|
2051
|
+
.vesk-md .md-copy:hover { color: inherit; background: color-mix(in srgb, currentColor 10%, transparent); }
|
|
2052
|
+
.vesk-md .md-copy.md-copied { color: color-mix(in srgb, currentColor 70%, transparent); }
|
|
2050
2053
|
.vesk-md .md-code pre { margin: 0; overflow-x: auto; padding: 14px 16px; }
|
|
2051
|
-
.vesk-md .md-code code { font-family: ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; font-size: 13.5px; line-height: 1.55; color: var(--md-code-fg
|
|
2054
|
+
.vesk-md .md-code code { font-family: ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; font-size: 13.5px; line-height: 1.55; color: var(--md-code-fg,inherit); background: none; padding: 0; }
|
|
2052
2055
|
.vesk-md code[md-lines] { counter-reset: ln; display: block; }
|
|
2053
2056
|
.vesk-md code[md-lines] .tok-line { display: block; counter-increment: ln; padding-left: 3.2em; position: relative; }
|
|
2054
|
-
.vesk-md code[md-lines] .tok-line::before { content: counter(ln); position: absolute; left: 0; width: 2.4em; text-align: right; color:
|
|
2055
|
-
.tok-kw { color:
|
|
2056
|
-
.tok-num { color:
|
|
2057
|
-
.tok-fn { color:
|
|
2058
|
-
.tok-sel { color:
|
|
2059
|
-
.tok-del { color:
|
|
2060
|
-
.vesk-md-
|
|
2057
|
+
.vesk-md code[md-lines] .tok-line::before { content: counter(ln); position: absolute; left: 0; width: 2.4em; text-align: right; color: color-mix(in srgb, currentColor 50%, transparent); user-select: none; }
|
|
2058
|
+
.tok-kw { color: color-mix(in srgb, currentColor 85%, transparent); } .tok-lit { color: color-mix(in srgb, currentColor 80%, transparent); } .tok-str { color: color-mix(in srgb, currentColor 72%, transparent); }
|
|
2059
|
+
.tok-num { color: color-mix(in srgb, currentColor 80%, transparent); } .tok-com { color: color-mix(in srgb, currentColor 52%, transparent); font-style: italic; }
|
|
2060
|
+
.tok-fn { color: color-mix(in srgb, currentColor 72%, transparent); } .tok-attr { color: color-mix(in srgb, currentColor 72%, transparent); } .tok-prop { color: color-mix(in srgb, currentColor 72%, transparent); }
|
|
2061
|
+
.tok-sel { color: color-mix(in srgb, currentColor 74%, transparent); } .tok-add { color: color-mix(in srgb, currentColor 86%, transparent); background: color-mix(in srgb, currentColor 10%, transparent); display: inline-block; width: 100%; }
|
|
2062
|
+
.tok-del { color: color-mix(in srgb, currentColor 86%, transparent); background: color-mix(in srgb, currentColor 10%, transparent); display: inline-block; width: 100%; }
|
|
2063
|
+
.vesk-md-light { color: #24292f; --md-code-bg: #f6f8fa; --md-code-fg: #1f2328; --md-link: #0969da; }
|
|
2064
|
+
.vesk-md-light a { color: #0969da; }
|
|
2065
|
+
.vesk-md-light hr { background: #d0d7de; }
|
|
2066
|
+
.vesk-md-light blockquote { color: #57606a; border-left-color: #d0d7de; }
|
|
2067
|
+
.vesk-md-light code:not(pre code) { background: rgba(175,184,193,.2); }
|
|
2068
|
+
.vesk-md-light .md-table th,.vesk-md-light .md-table td { border-color: #d0d7de; }
|
|
2069
|
+
.vesk-md-light .md-table th { background: #f6f8fa; }
|
|
2070
|
+
.vesk-md-light .md-table tr:nth-child(2n) td { background: #f6f8fa80; }
|
|
2071
|
+
.vesk-md-light .md-code { border-color: #d1d9e0; }
|
|
2072
|
+
.vesk-md-light .md-code-bar { border-bottom-color: #d1d9e0; }
|
|
2073
|
+
.vesk-md-light .md-code-lang { color: #59636e; }
|
|
2074
|
+
.vesk-md-light .md-copy { color: #59636e; }
|
|
2075
|
+
.vesk-md-light .md-copy:hover { color: #1f2328; background: #eaeef2; }
|
|
2076
|
+
.vesk-md-light .md-copy.md-copied { color: #1a7f37; }
|
|
2077
|
+
.vesk-md-light code[md-lines] .tok-line::before { color: #8c959f; }
|
|
2078
|
+
.vesk-md-light .tok-kw { color: #cf222e; } .vesk-md-light .tok-lit { color: #0550ae; } .vesk-md-light .tok-str { color: #0a3069; }
|
|
2079
|
+
.vesk-md-light .tok-num { color: #0550ae; } .vesk-md-light .tok-com { color: #59636e; font-style: italic; }
|
|
2080
|
+
.vesk-md-light .tok-fn { color: #8250df; } .vesk-md-light .tok-attr { color: #0550ae; } .vesk-md-light .tok-prop { color: #0550ae; }
|
|
2081
|
+
.vesk-md-light .tok-sel { color: #116329; } .vesk-md-light .tok-add { color: #116329; background: #dafbe1; }
|
|
2082
|
+
.vesk-md-light .tok-del { color: #cf222e; background: #ffebe9; }
|
|
2083
|
+
.vesk-md-dark { --md-code-bg: #0d1117; --md-code-fg: #c9d1d9; color: #f0f6fc; --md-link: #4493f8; }
|
|
2084
|
+
.vesk-md-dark a { color: #4493f8; }
|
|
2085
|
+
.vesk-md-dark hr { background: #30363d; }
|
|
2086
|
+
.vesk-md-dark blockquote { color: #8b949e; border-left-color: #30363d; }
|
|
2087
|
+
.vesk-md-dark code:not(pre code) { background: rgba(110,118,129,.4); }
|
|
2088
|
+
.vesk-md-dark .md-table th,.vesk-md-dark .md-table td { border-color: #30363d; }
|
|
2089
|
+
.vesk-md-dark .md-table th { background: #161b22; }
|
|
2090
|
+
.vesk-md-dark .md-table tr:nth-child(2n) td { background: #161b2280; }
|
|
2091
|
+
.vesk-md-dark .md-code { border-color: #30363d; }
|
|
2061
2092
|
.vesk-md-dark .md-code-bar { border-bottom-color: #30363d; }
|
|
2062
2093
|
.vesk-md-dark .md-code-lang { color: #8b949e; }
|
|
2063
2094
|
.vesk-md-dark .md-copy { color: #8b949e; }
|
|
@@ -2177,6 +2208,126 @@ function wireCopyHandlers(root) {
|
|
|
2177
2208
|
function mdIsSSR() {
|
|
2178
2209
|
return typeof document === 'undefined';
|
|
2179
2210
|
}
|
|
2211
|
+
// =============================================================
|
|
2212
|
+
// Runtime markdown-file loading (public/*.md) + streaming support
|
|
2213
|
+
//
|
|
2214
|
+
// When `content` resolves to an absolute public markdown path
|
|
2215
|
+
// (e.g. "/docs/guide.md"), <Md> loads the FILE at runtime:
|
|
2216
|
+
// - server: adapter-installed `__vsk_md_read_file` hook reads it,
|
|
2217
|
+
// constrained to the public dir + `.md` suffixes (returns null
|
|
2218
|
+
// outside those bounds), and the content is stashed in
|
|
2219
|
+
// `__vsk_ssr_data` for hydration so there is no flash.
|
|
2220
|
+
// - client: `fetch(path)` with a per-path cache cell; while loading
|
|
2221
|
+
// (or if the file does not exist) the path itself is rendered as
|
|
2222
|
+
// literal markdown text.
|
|
2223
|
+
// `content` may also be a streaming-resource result (useFetch.stream),
|
|
2224
|
+
// whose `.into` cell is subscribed so chunks re-render progressively.
|
|
2225
|
+
// =============================================================
|
|
2226
|
+
/** Tokenizer endsWith (no regex, mirrors compiler rule). */
|
|
2227
|
+
function stringEndsWith(s, suffix) {
|
|
2228
|
+
if (suffix.length > s.length)
|
|
2229
|
+
return false;
|
|
2230
|
+
for (let i = 0; i < suffix.length; i++) {
|
|
2231
|
+
if (s[s.length - suffix.length + i] !== suffix[i])
|
|
2232
|
+
return false;
|
|
2233
|
+
}
|
|
2234
|
+
return true;
|
|
2235
|
+
}
|
|
2236
|
+
function isPublicMarkdownPath(v) {
|
|
2237
|
+
if (typeof v !== 'string')
|
|
2238
|
+
return false;
|
|
2239
|
+
const s = v;
|
|
2240
|
+
if (s.length < 2 || s.charCodeAt(0) !== 47)
|
|
2241
|
+
return false; // '/'
|
|
2242
|
+
if (s.charCodeAt(1) === 47)
|
|
2243
|
+
return false; // '//'
|
|
2244
|
+
for (let i = 0; i < s.length; i++) {
|
|
2245
|
+
const c = s.charCodeAt(i);
|
|
2246
|
+
if (c === 63 || c === 35 || c === 92)
|
|
2247
|
+
return false; // ? # \
|
|
2248
|
+
}
|
|
2249
|
+
const lower = s.toLowerCase();
|
|
2250
|
+
return stringEndsWith(lower, '.md') || stringEndsWith(lower, '.markdown');
|
|
2251
|
+
}
|
|
2252
|
+
const mdPathCache = new Map();
|
|
2253
|
+
const mdPathCells = new Map();
|
|
2254
|
+
const mdPathInflight = new Set();
|
|
2255
|
+
function getMdPathCell(path) {
|
|
2256
|
+
let cell = mdPathCells.get(path);
|
|
2257
|
+
if (!cell) {
|
|
2258
|
+
cell = tracked(undefined);
|
|
2259
|
+
mdPathCells.set(path, cell);
|
|
2260
|
+
}
|
|
2261
|
+
return cell;
|
|
2262
|
+
}
|
|
2263
|
+
function ensureMdPathLoaded(path) {
|
|
2264
|
+
if (mdPathCache.has(path) || mdPathInflight.has(path))
|
|
2265
|
+
return;
|
|
2266
|
+
const ssr = getSsrData('md:' + path);
|
|
2267
|
+
if (typeof ssr === 'string') {
|
|
2268
|
+
mdPathCache.set(path, ssr);
|
|
2269
|
+
return;
|
|
2270
|
+
}
|
|
2271
|
+
mdPathInflight.add(path);
|
|
2272
|
+
fetch(path)
|
|
2273
|
+
.then((r) => (r.ok ? r.text() : Promise.reject(r)))
|
|
2274
|
+
.then((text) => {
|
|
2275
|
+
mdPathCache.set(path, text);
|
|
2276
|
+
set(getMdPathCell(path), text);
|
|
2277
|
+
})
|
|
2278
|
+
.catch(() => {
|
|
2279
|
+
mdPathCache.set(path, null);
|
|
2280
|
+
set(getMdPathCell(path), null);
|
|
2281
|
+
})
|
|
2282
|
+
.finally(() => {
|
|
2283
|
+
mdPathInflight.delete(path);
|
|
2284
|
+
});
|
|
2285
|
+
}
|
|
2286
|
+
function readServerMdPath(path) {
|
|
2287
|
+
const hook = globalThis.__vsk_md_read_file;
|
|
2288
|
+
if (typeof hook !== 'function')
|
|
2289
|
+
return null;
|
|
2290
|
+
try {
|
|
2291
|
+
const out = hook(path);
|
|
2292
|
+
if (typeof out === 'string')
|
|
2293
|
+
return out;
|
|
2294
|
+
}
|
|
2295
|
+
catch {
|
|
2296
|
+
/* read errors fall through to literal rendering */
|
|
2297
|
+
}
|
|
2298
|
+
return null;
|
|
2299
|
+
}
|
|
2300
|
+
/**
|
|
2301
|
+
* Resolves a raw content value to the markdown SOURCE that should be
|
|
2302
|
+
* rendered. Non-path values pass through; public markdown paths are read
|
|
2303
|
+
* on the server (SSR) or resolved from cache while loading on the client.
|
|
2304
|
+
*/
|
|
2305
|
+
function resolveMdSource(value) {
|
|
2306
|
+
const s = String(value ?? '');
|
|
2307
|
+
if (!isPublicMarkdownPath(s))
|
|
2308
|
+
return s;
|
|
2309
|
+
if (mdIsSSR()) {
|
|
2310
|
+
const content = readServerMdPath(s);
|
|
2311
|
+
if (content !== null) {
|
|
2312
|
+
setSsrData('md:' + s, content);
|
|
2313
|
+
return content;
|
|
2314
|
+
}
|
|
2315
|
+
return s;
|
|
2316
|
+
}
|
|
2317
|
+
ensureMdPathLoaded(s);
|
|
2318
|
+
const cached = mdPathCache.get(s);
|
|
2319
|
+
return cached === undefined || cached === null ? s : cached;
|
|
2320
|
+
}
|
|
2321
|
+
/** Extracts the streaming target cell from a useFetch.stream() resource. */
|
|
2322
|
+
function streamCellFrom(rawContent) {
|
|
2323
|
+
if (rawContent === null || typeof rawContent !== 'object')
|
|
2324
|
+
return null;
|
|
2325
|
+
const into = rawContent.into;
|
|
2326
|
+
if (into !== null && typeof into === 'object' && typeof into.get === 'function') {
|
|
2327
|
+
return into;
|
|
2328
|
+
}
|
|
2329
|
+
return null;
|
|
2330
|
+
}
|
|
2180
2331
|
function buildHtml(content, props) {
|
|
2181
2332
|
// Per-instance props override the process-wide policy from vesk.config.ts.
|
|
2182
2333
|
const global = getMdPolicy();
|
|
@@ -2223,10 +2374,14 @@ function buildHtml(content, props) {
|
|
|
2223
2374
|
*/
|
|
2224
2375
|
export function Md(props, _registry, hydrate) {
|
|
2225
2376
|
const rawContent = props.content;
|
|
2226
|
-
const
|
|
2227
|
-
const
|
|
2377
|
+
const streamTarget = streamCellFrom(rawContent);
|
|
2378
|
+
const contentCell = streamTarget ?? rawContent;
|
|
2379
|
+
const content = String(unwrapMaybeCell(contentCell) ?? '');
|
|
2380
|
+
const html = buildHtml(resolveMdSource(content), props);
|
|
2228
2381
|
const classNameRaw = props.className != null ? String(props.className) : props.class != null ? String(props.class) : '';
|
|
2229
|
-
|
|
2382
|
+
// No theme → inherit/transparent (no theme class). Explicit theme applies
|
|
2383
|
+
// the matching preset: 'light' → .vesk-md-light, 'dark' → .vesk-md-dark.
|
|
2384
|
+
const themeClass = props.theme === 'dark' ? ' vesk-md-dark' : props.theme === 'light' ? ' vesk-md-light' : '';
|
|
2230
2385
|
const className = `vesk-md${themeClass}${classNameRaw ? ' ' + classNameRaw : ''}`;
|
|
2231
2386
|
const style = props.style != null ? String(props.style) : '';
|
|
2232
2387
|
// Component-level code defaults; fence-level bg=/fg= emit the same
|
|
@@ -2239,9 +2394,11 @@ export function Md(props, _registry, hydrate) {
|
|
|
2239
2394
|
if (propFg && propFg !== 'none')
|
|
2240
2395
|
wrapperParts.push(`--md-code-fg:${propFg}`);
|
|
2241
2396
|
const wrapperStyle = wrapperParts.length > 0 ? escapeHtml(wrapperParts.join(';')) : '';
|
|
2242
|
-
// A tracked `content` cell
|
|
2243
|
-
// client (per-keystroke live
|
|
2244
|
-
|
|
2397
|
+
// A tracked `content` cell (or a streaming resource's `into` cell)
|
|
2398
|
+
// re-renders the markdown reactively on the client (per-keystroke live
|
|
2399
|
+
// editing and progressive stream chunks work without any extra wiring).
|
|
2400
|
+
const reactive = isCell(contentCell);
|
|
2401
|
+
const pathMode = isPublicMarkdownPath(content);
|
|
2245
2402
|
if (mdIsSSR()) {
|
|
2246
2403
|
const attrs = className ? ` class="${escapeHtml(className)}"` : '';
|
|
2247
2404
|
const styleAttr = style || wrapperStyle ? ` style="${[wrapperStyle, style.split('"').join('"')].filter(Boolean).join(';')}"` : '';
|
|
@@ -2254,12 +2411,25 @@ export function Md(props, _registry, hydrate) {
|
|
|
2254
2411
|
if (existing)
|
|
2255
2412
|
el = existing;
|
|
2256
2413
|
}
|
|
2257
|
-
|
|
2414
|
+
const claimed = !!el.parentNode;
|
|
2415
|
+
if (pathMode && claimed) {
|
|
2416
|
+
// Retention: the SSR render already shows this path's rendered
|
|
2417
|
+
// file (or the literal path). Only overwrite when the client has
|
|
2418
|
+
// authoritative content (hydrated ssr data / cache); otherwise
|
|
2419
|
+
// trust the markup until the client load resolves.
|
|
2420
|
+
el.setAttribute('data-vsk-md-ssr', '1');
|
|
2421
|
+
if (mdPathCache.has(content))
|
|
2422
|
+
el.innerHTML = html;
|
|
2423
|
+
}
|
|
2424
|
+
else {
|
|
2425
|
+
el.innerHTML = html;
|
|
2426
|
+
}
|
|
2258
2427
|
el.className = className;
|
|
2259
2428
|
el.style.cssText = [wrapperStyle, style].filter(Boolean).join(';');
|
|
2260
2429
|
wireCopyHandlers(el);
|
|
2261
|
-
if (reactive)
|
|
2262
|
-
subscribeContent(el,
|
|
2430
|
+
if (reactive || pathMode) {
|
|
2431
|
+
subscribeContent(el, contentCell, props, pathMode && claimed ? { trustInitialSsr: true, initialValue: content } : undefined);
|
|
2432
|
+
}
|
|
2263
2433
|
// When the element came from SSR it is already in the document —
|
|
2264
2434
|
// return an empty fragment. When the walker handed us a FRESH
|
|
2265
2435
|
// element (dynamic branch that had no SSR markup), hand the element
|
|
@@ -2273,14 +2443,34 @@ export function Md(props, _registry, hydrate) {
|
|
|
2273
2443
|
div.className = className;
|
|
2274
2444
|
div.style.cssText = [wrapperStyle, style].filter(Boolean).join(';');
|
|
2275
2445
|
wireCopyHandlers(div);
|
|
2276
|
-
if (reactive)
|
|
2277
|
-
subscribeContent(div,
|
|
2446
|
+
if (reactive || pathMode)
|
|
2447
|
+
subscribeContent(div, contentCell, props);
|
|
2278
2448
|
return div;
|
|
2279
2449
|
}
|
|
2280
|
-
function subscribeContent(el, rawContent, props) {
|
|
2450
|
+
function subscribeContent(el, rawContent, props, opts) {
|
|
2451
|
+
const trust = opts?.trustInitialSsr === true;
|
|
2452
|
+
const initial = opts?.initialValue;
|
|
2453
|
+
let ran = false;
|
|
2281
2454
|
effect(() => {
|
|
2282
2455
|
const value = String(unwrapMaybeCell(rawContent) ?? '');
|
|
2283
|
-
|
|
2456
|
+
if (isPublicMarkdownPath(value)) {
|
|
2457
|
+
const known = getSsrData('md:' + value) !== undefined || mdPathCache.has(value);
|
|
2458
|
+
ensureMdPathLoaded(value);
|
|
2459
|
+
const cell = getMdPathCell(value);
|
|
2460
|
+
get(cell);
|
|
2461
|
+
if (trust && !ran && value === initial && !known) {
|
|
2462
|
+
// Keep the SSR-rendered file visible while the client load is
|
|
2463
|
+
// in flight (or the path stays a literal on not-found).
|
|
2464
|
+
ran = true;
|
|
2465
|
+
return;
|
|
2466
|
+
}
|
|
2467
|
+
ran = true;
|
|
2468
|
+
el.innerHTML = buildHtml(resolveMdSource(value), props);
|
|
2469
|
+
wireCopyHandlers(el);
|
|
2470
|
+
return;
|
|
2471
|
+
}
|
|
2472
|
+
ran = true;
|
|
2473
|
+
el.innerHTML = buildHtml(resolveMdSource(value), props);
|
|
2284
2474
|
wireCopyHandlers(el);
|
|
2285
2475
|
});
|
|
2286
2476
|
}
|
package/dist/request.d.ts
CHANGED
|
@@ -104,6 +104,32 @@ export declare class VeskRequest extends ServerRequest {
|
|
|
104
104
|
_parsedUrl: URL | null;
|
|
105
105
|
__security?: Record<string, unknown>;
|
|
106
106
|
constructor(input: string | URL, init?: RequestInit);
|
|
107
|
+
/**
|
|
108
|
+
* The request's host header (honoring `x-forwarded-host` when
|
|
109
|
+
* setTrustProxy() is enabled). Falls back to the parsed URL host.
|
|
110
|
+
*/
|
|
111
|
+
get host(): string;
|
|
112
|
+
/** Absolute origin (`protocol://host`) — the base for resolving relative URLs. */
|
|
113
|
+
get origin(): string;
|
|
114
|
+
/**
|
|
115
|
+
* Resolves a possibly-relative URL against this request's own origin.
|
|
116
|
+
* Absolute URLs (scheme or protocol-relative `//`) pass through untouched.
|
|
117
|
+
* Used by the runtime SSR fetcher (`resolveFetchUrl`) to make in-app
|
|
118
|
+
* fetches (e.g. `/api/...`) work during server rendering.
|
|
119
|
+
*/
|
|
120
|
+
resolveUrl(url: string): string;
|
|
121
|
+
/** locals map accessors so <VeskRequest> can double as the middleware ctx. */
|
|
122
|
+
set(key: string, value: unknown): void;
|
|
123
|
+
get(key: string): unknown;
|
|
124
|
+
/**
|
|
125
|
+
* Wraps an inbound platform `Request` (from dev/prod/platform handlers)
|
|
126
|
+
* into a VeskRequest carrying the same method, headers and cookie store.
|
|
127
|
+
* Params/locals can be seeded so useParams()/useRequest() work in renders.
|
|
128
|
+
*/
|
|
129
|
+
static from(request: Request, init?: {
|
|
130
|
+
params?: Record<string, string>;
|
|
131
|
+
locals?: Record<string, unknown>;
|
|
132
|
+
}): VeskRequest;
|
|
107
133
|
get parsedUrl(): URL;
|
|
108
134
|
get query(): Record<string, string>;
|
|
109
135
|
set query(v: Record<string, string>);
|
|
@@ -163,6 +189,8 @@ declare class _VeskResponse extends ServerResponse {
|
|
|
163
189
|
static rewrite(url: string): _VeskResponse;
|
|
164
190
|
static next(): _VeskResponse;
|
|
165
191
|
static html(html: string, init?: ResponseInit): _VeskResponse;
|
|
192
|
+
/** Chunked streaming response over a `ReadableStream` body (SSE, file streams, …). */
|
|
193
|
+
static stream(readable: ReadableStream, init?: ResponseInit): _VeskResponse;
|
|
166
194
|
}
|
|
167
195
|
export declare const VeskResponse: typeof _VeskResponse & ((body?: unknown, init?: ResponseInit) => VeskResponseInstance);
|
|
168
196
|
export declare function applyRequestSecurity(request: VeskRequest, response: VeskResponseInstance): void;
|
package/dist/request.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAAA,UAAU,cAAc;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACrB;AAWD,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,GAAG,IAAI,CAI3D;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,GAAG,IAAI,CAI3D;AAED,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAM9F;AAED,wBAAgB,SAAS,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAGlD;AAED,wBAAgB,UAAU,IAAI,cAAc,GAAG,IAAI,CAElD;AA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C,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAI5F;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAI3G;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAIxI;AAED,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAIhH"}
|
package/dist/request.js
CHANGED
|
@@ -307,6 +307,22 @@ export class VeskRequest extends ServerRequest {
|
|
|
307
307
|
this._body = null;
|
|
308
308
|
this._bodyPromise = null;
|
|
309
309
|
this._parsedUrl = null;
|
|
310
|
+
const cookieHeader = this.headers?.get('cookie') || '';
|
|
311
|
+
if (cookieHeader) {
|
|
312
|
+
for (const part of cookieHeader.split(';')) {
|
|
313
|
+
const eq = part.indexOf('=');
|
|
314
|
+
if (eq > 0) {
|
|
315
|
+
const name = part.slice(0, eq).trim();
|
|
316
|
+
const val = part.slice(eq + 1).trim();
|
|
317
|
+
try {
|
|
318
|
+
this._cookies[name] = decodeURIComponent(val);
|
|
319
|
+
}
|
|
320
|
+
catch {
|
|
321
|
+
this._cookies[name] = val;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
310
326
|
Object.defineProperty(this, 'body', {
|
|
311
327
|
get: () => {
|
|
312
328
|
if (!this._bodyPromise) {
|
|
@@ -318,6 +334,56 @@ export class VeskRequest extends ServerRequest {
|
|
|
318
334
|
enumerable: true,
|
|
319
335
|
});
|
|
320
336
|
}
|
|
337
|
+
/**
|
|
338
|
+
* The request's host header (honoring `x-forwarded-host` when
|
|
339
|
+
* setTrustProxy() is enabled). Falls back to the parsed URL host.
|
|
340
|
+
*/
|
|
341
|
+
get host() {
|
|
342
|
+
const trust = this._security.trustProxy === true;
|
|
343
|
+
const fwd = trust ? this.headers?.get('x-forwarded-host') : undefined;
|
|
344
|
+
const header = typeof fwd === 'string' && fwd ? fwd : (this.headers?.get('host') || '');
|
|
345
|
+
if (header)
|
|
346
|
+
return header;
|
|
347
|
+
return this.parsedUrl.host || 'localhost';
|
|
348
|
+
}
|
|
349
|
+
/** Absolute origin (`protocol://host`) — the base for resolving relative URLs. */
|
|
350
|
+
get origin() {
|
|
351
|
+
return `${this.protocol}://${this.host}`;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Resolves a possibly-relative URL against this request's own origin.
|
|
355
|
+
* Absolute URLs (scheme or protocol-relative `//`) pass through untouched.
|
|
356
|
+
* Used by the runtime SSR fetcher (`resolveFetchUrl`) to make in-app
|
|
357
|
+
* fetches (e.g. `/api/...`) work during server rendering.
|
|
358
|
+
*/
|
|
359
|
+
resolveUrl(url) {
|
|
360
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(url) || url.startsWith('//'))
|
|
361
|
+
return url;
|
|
362
|
+
return new URL(url, this.origin).href;
|
|
363
|
+
}
|
|
364
|
+
/** locals map accessors so <VeskRequest> can double as the middleware ctx. */
|
|
365
|
+
set(key, value) {
|
|
366
|
+
this._locals[key] = value;
|
|
367
|
+
}
|
|
368
|
+
get(key) {
|
|
369
|
+
return this._locals[key];
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Wraps an inbound platform `Request` (from dev/prod/platform handlers)
|
|
373
|
+
* into a VeskRequest carrying the same method, headers and cookie store.
|
|
374
|
+
* Params/locals can be seeded so useParams()/useRequest() work in renders.
|
|
375
|
+
*/
|
|
376
|
+
static from(request, init) {
|
|
377
|
+
const vreq = new VeskRequest(request instanceof Request ? request.url : String(request), {
|
|
378
|
+
method: request.method,
|
|
379
|
+
headers: request.headers,
|
|
380
|
+
});
|
|
381
|
+
if (init?.params)
|
|
382
|
+
vreq._params = { ...init.params };
|
|
383
|
+
if (init?.locals)
|
|
384
|
+
vreq._locals = { ...init.locals };
|
|
385
|
+
return vreq;
|
|
386
|
+
}
|
|
321
387
|
get parsedUrl() {
|
|
322
388
|
if (!this._parsedUrl) {
|
|
323
389
|
this._parsedUrl = new URL(this.url);
|
|
@@ -534,6 +600,10 @@ class _VeskResponse extends ServerResponse {
|
|
|
534
600
|
headers: { 'Content-Type': 'text/html; charset=utf-8', ...init?.headers },
|
|
535
601
|
});
|
|
536
602
|
}
|
|
603
|
+
/** Chunked streaming response over a `ReadableStream` body (SSE, file streams, …). */
|
|
604
|
+
static stream(readable, init) {
|
|
605
|
+
return new _VeskResponse(readable, init);
|
|
606
|
+
}
|
|
537
607
|
}
|
|
538
608
|
export const VeskResponse = new Proxy(_VeskResponse, {
|
|
539
609
|
apply(target, _thisArg, args) {
|
package/dist/resource.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ export interface SsrDataSink {
|
|
|
35
35
|
clear(): void;
|
|
36
36
|
}
|
|
37
37
|
export declare function setSsrSink(sink: SsrDataSink | null): void;
|
|
38
|
+
export declare function getSsrData(key: string): unknown;
|
|
38
39
|
export declare function setSsrData(key: string, value: unknown): void;
|
|
39
40
|
export declare function clearSsrData(): void;
|
|
40
41
|
export declare function mutate(key: string, data?: unknown): void;
|
|
@@ -44,6 +45,10 @@ export declare namespace useFetch {
|
|
|
44
45
|
var text: <T = string>(url: string, options?: Omit<UseFetchOptions<T>, "body">) => Resource<T>;
|
|
45
46
|
var json: <T = unknown>(url: string, options?: Omit<UseFetchOptions<T>, "body">) => Resource<T>;
|
|
46
47
|
var arrayBuffer: <T = ArrayBuffer>(url: string, options?: Omit<UseFetchOptions<T>, "body">) => Resource<T>;
|
|
48
|
+
var stream: (urlOrFn: string | (() => string), options?: Omit<UseFetchOptions<string>, "body"> & {
|
|
49
|
+
into?: Tracked<string>;
|
|
50
|
+
onChunk?: (chunk: string, total: string) => void;
|
|
51
|
+
}) => Resource<string>;
|
|
47
52
|
}
|
|
48
53
|
export declare function resolveSsrResources(): Promise<Record<string, unknown>>;
|
|
49
54
|
//# sourceMappingURL=resource.d.ts.map
|
package/dist/resource.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAQhE,MAAM,WAAW,QAAQ,CAAC,CAAC,CAAE,SAAQ,WAAW,CAAC,CAAC,CAAC;IAClD,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,CAAC,GAAG,SAAS,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,IAAI,CAAC;CAClB;AAED,MAAM,WAAW,eAAe,CAAC,CAAC,CAAE,SAAQ,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC;IACpE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,gGAAgG;IAChG,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,qBAAa,SAAU,SAAQ,KAAK;IACnC,MAAM,EAAE,MAAM,CAAC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