@threadlabs/markupkit 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/README.md +62 -2
- package/components/breadcrumbs.html +9 -0
- package/components/nav.html +51 -0
- package/components/pager.html +13 -0
- package/dist/application.d.ts +31 -0
- package/dist/application.d.ts.map +1 -0
- package/dist/application.js +488 -0
- package/dist/application.js.map +1 -0
- package/dist/browser.d.ts +13 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +151 -0
- package/dist/browser.js.map +1 -0
- package/dist/build.d.ts +5 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +351 -0
- package/dist/build.js.map +1 -0
- package/dist/bundle-worker.d.ts +2 -0
- package/dist/bundle-worker.d.ts.map +1 -0
- package/dist/bundle-worker.js +48 -0
- package/dist/bundle-worker.js.map +1 -0
- package/dist/bundle.d.ts +23 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +34 -0
- package/dist/bundle.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +68 -0
- package/dist/cli.js.map +1 -0
- package/dist/client.d.ts +40 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +447 -0
- package/dist/client.js.map +1 -0
- package/dist/component-module.d.ts +20 -0
- package/dist/component-module.d.ts.map +1 -0
- package/dist/component-module.js +82 -0
- package/dist/component-module.js.map +1 -0
- package/dist/config.d.ts +36 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +111 -0
- package/dist/config.js.map +1 -0
- package/dist/csp.d.ts +23 -0
- package/dist/csp.d.ts.map +1 -0
- package/dist/csp.js +91 -0
- package/dist/csp.js.map +1 -0
- package/dist/description.d.ts +45 -0
- package/dist/description.d.ts.map +1 -0
- package/dist/description.js +28 -0
- package/dist/description.js.map +1 -0
- package/dist/document.d.ts +48 -0
- package/dist/document.d.ts.map +1 -0
- package/dist/document.js +65 -0
- package/dist/document.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/links.d.ts +8 -0
- package/dist/links.d.ts.map +1 -0
- package/dist/links.js +90 -0
- package/dist/links.js.map +1 -0
- package/dist/private-api.d.ts +12 -0
- package/dist/private-api.d.ts.map +1 -0
- package/dist/private-api.js +158 -0
- package/dist/private-api.js.map +1 -0
- package/dist/private-client.d.ts +11 -0
- package/dist/private-client.d.ts.map +1 -0
- package/dist/private-client.js +18 -0
- package/dist/private-client.js.map +1 -0
- package/dist/private-readers.d.ts +26 -0
- package/dist/private-readers.d.ts.map +1 -0
- package/dist/private-readers.js +107 -0
- package/dist/private-readers.js.map +1 -0
- package/dist/provider-preparation.d.ts +20 -0
- package/dist/provider-preparation.d.ts.map +1 -0
- package/dist/provider-preparation.js +82 -0
- package/dist/provider-preparation.js.map +1 -0
- package/dist/providers.d.ts +14 -0
- package/dist/providers.d.ts.map +1 -0
- package/dist/providers.js +127 -0
- package/dist/providers.js.map +1 -0
- package/dist/read-channel.d.ts +30 -0
- package/dist/read-channel.d.ts.map +1 -0
- package/dist/read-channel.js +65 -0
- package/dist/read-channel.js.map +1 -0
- package/dist/resource.d.ts +31 -0
- package/dist/resource.d.ts.map +1 -0
- package/dist/resource.js +117 -0
- package/dist/resource.js.map +1 -0
- package/dist/routes.d.ts +90 -0
- package/dist/routes.d.ts.map +1 -0
- package/dist/routes.js +536 -0
- package/dist/routes.js.map +1 -0
- package/dist/serve.d.ts +4 -0
- package/dist/serve.d.ts.map +1 -0
- package/dist/serve.js +221 -0
- package/dist/serve.js.map +1 -0
- package/dist/server.d.ts +211 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +734 -0
- package/dist/server.js.map +1 -0
- package/dist/types.d.ts +504 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +80 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Next Web Working Group
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,63 @@
|
|
|
1
|
-
|
|
1
|
+
<picture>
|
|
2
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/threadlabs-studio/markupkit/main/website/public/logo-dark.svg">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/threadlabs-studio/markupkit/main/website/public/logo.svg" alt="MarkupKit logo" width="80" height="80">
|
|
4
|
+
</picture>
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
# MarkupKit
|
|
7
|
+
|
|
8
|
+
Build with HTML again.
|
|
9
|
+
|
|
10
|
+
The HTML, CSS, and JavaScript you know, with components, routing, and server rendering powered by
|
|
11
|
+
the next generation of HTML. MarkupKit also provides shared layouts and typed data for your application.
|
|
12
|
+
|
|
13
|
+
MarkupKit is a Threadlabs product, built on [HTML Next](https://github.com/nextwebwg/html-next),
|
|
14
|
+
the implementation of the Next Web Working Group's declarative components proposal.
|
|
15
|
+
[Markupress](https://github.com/threadlabs-studio/markupress) builds documentation on MarkupKit;
|
|
16
|
+
MarkupKit owns the application platform and Markupress owns the documentation experience.
|
|
17
|
+
|
|
18
|
+
MarkupKit (`@threadlabs/markupkit`) builds applications with HTML Next components. It provides routes,
|
|
19
|
+
layouts, server loaders, endpoints, middleware, browser delivery, and development tools. A build
|
|
20
|
+
prerenders pages for any static host and writes a request server for pages that render on each
|
|
21
|
+
request, which `markupkit start` runs on Node and Deno and Bun run through its `fetch`.
|
|
22
|
+
[The server-rendering design](./docs/server-rendering.md) records how requests are answered.
|
|
23
|
+
|
|
24
|
+
Use Node `>=22.22.2 <23 || >=24.15 <25`. Install `@threadlabs/markupkit` and add its commands to your
|
|
25
|
+
`package.json` scripts:
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"scripts": {
|
|
30
|
+
"dev": "markupkit dev",
|
|
31
|
+
"build": "markupkit build",
|
|
32
|
+
"preview": "markupkit preview",
|
|
33
|
+
"start": "markupkit start"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Then run `pnpm dev`, `pnpm build`, `pnpm preview`, or `pnpm start` (`npm run dev` and the others work too).
|
|
39
|
+
|
|
40
|
+
**Guide:** [MarkupKit](https://threadlabs-studio.github.io/markupkit/) covers pages and routing,
|
|
41
|
+
loading data, endpoints and middleware, navigation, moving between pages, deployment, and
|
|
42
|
+
configuration. Its source is
|
|
43
|
+
[`website/docs`](./website/docs/) in this repository, built with Markupress.
|
|
44
|
+
[The client-navigation design](./docs/client-navigation.md) records how pages swap in place.
|
|
45
|
+
|
|
46
|
+
## Proof applications
|
|
47
|
+
|
|
48
|
+
From this repository, after building:
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
node dist/cli.js build examples/basic
|
|
52
|
+
node dist/cli.js preview examples/basic
|
|
53
|
+
pnpm build:docs-proof
|
|
54
|
+
node dist/cli.js preview .context/markupkit-docs-proof
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The basic application exercises routes, loaders, state, and component modules without documentation
|
|
58
|
+
features. The docs proof converts this repository's Markdown guides and generates a component
|
|
59
|
+
reference, code display, heading anchors, search navigation, a theme, and an interactive example.
|
|
60
|
+
Its Markdown dependency and theme live in the consumer, outside the platform runtime and published
|
|
61
|
+
package. Its input is trusted, checked-in author content; it does not sanitize arbitrary Markdown.
|
|
62
|
+
|
|
63
|
+
MarkupKit is MIT-licensed.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<template component="mk-breadcrumbs">
|
|
2
|
+
<defs>
|
|
3
|
+
<prop name="items" type="list(object({ href: string, label: string, current: string, depth: number, pageName: string, group?: string, ... }))" required>Pages from the top of the trail to the current page.</prop>
|
|
4
|
+
<prop name="label" type="string" default="Breadcrumb">Accessible navigation name.</prop>
|
|
5
|
+
</defs>
|
|
6
|
+
<nav from:aria-label="$label">
|
|
7
|
+
<ol><li $each="item of $items"><a from:href="$item.href" from:aria-current="$item.current">{$item.label}</a></li></ol>
|
|
8
|
+
</nav>
|
|
9
|
+
</template>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<template component="mk-nav-items">
|
|
2
|
+
<defs>
|
|
3
|
+
<prop name="items" type="list(object({ label: string, current: string, depth: number, href?: string, group?: string, open?: boolean, children?: list(object({ label: string, ... })), ... }))" required>Navigation items, each with its nested items.</prop>
|
|
4
|
+
</defs>
|
|
5
|
+
<ul><template $each="item, index of $items">
|
|
6
|
+
<li $if="$item.group and $item.group != $items[$index - 1].group" data-group from:data-depth="$item.depth">{$item.group}</li>
|
|
7
|
+
<li from:data-depth="$item.depth">
|
|
8
|
+
<template $match><details $when="$item.children" from:open="$item.open">
|
|
9
|
+
<summary><template $match><a $when="$item.href" from:href="$item.href" from:aria-current="$item.current">{$item.label}</a><span $else>{$item.label}</span></template></summary>
|
|
10
|
+
<mk-nav-items from:items="$item.children"></mk-nav-items>
|
|
11
|
+
</details>
|
|
12
|
+
<a $else from:href="$item.href" from:aria-current="$item.current">{$item.label}</a></template>
|
|
13
|
+
</li>
|
|
14
|
+
</template></ul>
|
|
15
|
+
</template>
|
|
16
|
+
<!-- The first three levels of items render inline, each as <mk-nav-items> renders a level, so a tree up to
|
|
17
|
+
three levels deep is one instance and the page carries its items once. Each deeper level is an <mk-nav-items>. -->
|
|
18
|
+
<template component="mk-nav">
|
|
19
|
+
<defs>
|
|
20
|
+
<prop name="items" type="list(object({ label: string, current: string, depth: number, href?: string, group?: string, open?: boolean, children?: list(object({ label: string, ... })), ... }))" required>Ordered page links: navigation() items, or navigationTree() nodes.</prop>
|
|
21
|
+
<prop name="label" type="string" default="Navigation">Accessible navigation name.</prop>
|
|
22
|
+
</defs>
|
|
23
|
+
<nav from:aria-label="$label"><ul><template $each="a, i of $items">
|
|
24
|
+
<li $if="$a.group and $a.group != $items[$i - 1].group" data-group from:data-depth="$a.depth">{$a.group}</li>
|
|
25
|
+
<li from:data-depth="$a.depth">
|
|
26
|
+
<template $match><details $when="$a.children" from:open="$a.open">
|
|
27
|
+
<summary><template $match><a $when="$a.href" from:href="$a.href" from:aria-current="$a.current">{$a.label}</a><span $else>{$a.label}</span></template></summary>
|
|
28
|
+
<ul><template $each="b, j of $a.children">
|
|
29
|
+
<li $if="$b.group and $b.group != $a.children[$j - 1].group" data-group from:data-depth="$b.depth">{$b.group}</li>
|
|
30
|
+
<li from:data-depth="$b.depth">
|
|
31
|
+
<template $match><details $when="$b.children" from:open="$b.open">
|
|
32
|
+
<summary><template $match><a $when="$b.href" from:href="$b.href" from:aria-current="$b.current">{$b.label}</a><span $else>{$b.label}</span></template></summary>
|
|
33
|
+
<ul><template $each="c, k of $b.children">
|
|
34
|
+
<li $if="$c.group and $c.group != $b.children[$k - 1].group" data-group from:data-depth="$c.depth">{$c.group}</li>
|
|
35
|
+
<li from:data-depth="$c.depth">
|
|
36
|
+
<template $match><details $when="$c.children" from:open="$c.open">
|
|
37
|
+
<summary><template $match><a $when="$c.href" from:href="$c.href" from:aria-current="$c.current">{$c.label}</a><span $else>{$c.label}</span></template></summary>
|
|
38
|
+
<mk-nav-items from:items="$c.children"></mk-nav-items>
|
|
39
|
+
</details>
|
|
40
|
+
<a $else from:href="$c.href" from:aria-current="$c.current">{$c.label}</a></template>
|
|
41
|
+
</li>
|
|
42
|
+
</template></ul>
|
|
43
|
+
</details>
|
|
44
|
+
<a $else from:href="$b.href" from:aria-current="$b.current">{$b.label}</a></template>
|
|
45
|
+
</li>
|
|
46
|
+
</template></ul>
|
|
47
|
+
</details>
|
|
48
|
+
<a $else from:href="$a.href" from:aria-current="$a.current">{$a.label}</a></template>
|
|
49
|
+
</li>
|
|
50
|
+
</template></ul></nav>
|
|
51
|
+
</template>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<template component="mk-pager">
|
|
2
|
+
<defs>
|
|
3
|
+
<prop name="previous" type="object({ href: string, label: string, current: string, depth: number, pageName: string, group?: string, ... })">The page before this one.</prop>
|
|
4
|
+
<prop name="next" type="object({ href: string, label: string, current: string, depth: number, pageName: string, group?: string, ... })">The page after this one.</prop>
|
|
5
|
+
<prop name="label" type="string" default="Pages">Accessible navigation name.</prop>
|
|
6
|
+
<prop name="previousText" type="string" default="Previous">Text before the previous page's label.</prop>
|
|
7
|
+
<prop name="nextText" type="string" default="Next">Text before the next page's label.</prop>
|
|
8
|
+
</defs>
|
|
9
|
+
<nav from:aria-label="$label">
|
|
10
|
+
<a $if="$previous" rel="prev" from:href="$previous.href"><small>{$previousText}</small> {$previous.label}</a>
|
|
11
|
+
<a $if="$next" rel="next" from:href="$next.href"><small>{$nextText}</small> {$next.label}</a>
|
|
12
|
+
</nav>
|
|
13
|
+
</template>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type ComponentDefinition } from "@nextwebwg/html-next";
|
|
2
|
+
import { type ViteDevServer } from "vite";
|
|
3
|
+
import { type PageAssets } from "./document.js";
|
|
4
|
+
import { type RenderLayer } from "./server.js";
|
|
5
|
+
import type { Application, ApplicationOptions, ContentSecurityPolicyOptions, RenderedPolicy, ApplicationRoute, BrowserDefinition, RenderedHead, RenderedPage } from "./types.js";
|
|
6
|
+
export declare function headScripts(options: ApplicationOptions, root: string): Promise<readonly string[]>;
|
|
7
|
+
export declare function notFoundPage(scripts: readonly string[], policy?: RenderedPolicy): {
|
|
8
|
+
head: RenderedHead;
|
|
9
|
+
body: string;
|
|
10
|
+
html: string;
|
|
11
|
+
};
|
|
12
|
+
/** A route's components, ready to render: its layers, every component they use, and their browser delivery. */
|
|
13
|
+
export interface RouteGraph {
|
|
14
|
+
readonly layers: readonly RenderLayer[];
|
|
15
|
+
readonly definitions: readonly ComponentDefinition[];
|
|
16
|
+
readonly components: readonly BrowserDefinition[];
|
|
17
|
+
}
|
|
18
|
+
/** The application, plus what a build reads from it: each route's component graph and the concrete page URLs. */
|
|
19
|
+
export declare function createApplicationInternals(input?: ApplicationOptions, moduleServer?: ViteDevServer, assets?: (page: RenderedPage) => PageAssets, policy?: ContentSecurityPolicyOptions | false): Promise<{
|
|
20
|
+
application: Application;
|
|
21
|
+
graph: (route: ApplicationRoute) => Promise<RouteGraph>;
|
|
22
|
+
catalog: () => Promise<ReadonlyMap<string, ApplicationRoute>>;
|
|
23
|
+
policy: () => Promise<RenderedPolicy | undefined>;
|
|
24
|
+
redirects: Map<string, string>;
|
|
25
|
+
}>;
|
|
26
|
+
/**
|
|
27
|
+
* assets supplies a serving adapter's browser modules and stylesheets for fetch(), and policy the csp
|
|
28
|
+
* option it applies in place of the configured one, as the development server adds what Vite needs.
|
|
29
|
+
*/
|
|
30
|
+
export declare function createApplication(input?: ApplicationOptions, moduleServer?: ViteDevServer, assets?: (page: RenderedPage) => PageAssets, policy?: ContentSecurityPolicyOptions | false): Promise<Application>;
|
|
31
|
+
//# sourceMappingURL=application.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../src/application.ts"],"names":[],"mappings":"AAKA,OAAO,EAA0D,KAAK,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAGxH,OAAO,EAA0C,KAAK,aAAa,EAAE,MAAM,MAAM,CAAC;AAIlF,OAAO,EAA4C,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAM1F,OAAO,EAA2K,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AACxN,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,4BAA4B,EAAiB,cAAc,EAAE,gBAAgB,EAAE,iBAAiB,EAA0D,YAAY,EAAE,YAAY,EACvM,MAAM,YAAY,CAAC;AAoB/C,wBAAsB,WAAW,CAAC,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC,CAYvG;AAGD,wBAAgB,YAAY,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,MAAM,CAAC,EAAE,cAAc;;;;EAI/E;AAED,+GAA+G;AAC/G,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,CAAC;IACxC,QAAQ,CAAC,WAAW,EAAE,SAAS,mBAAmB,EAAE,CAAC;IACrD,QAAQ,CAAC,UAAU,EAAE,SAAS,iBAAiB,EAAE,CAAC;CACnD;AAED,iHAAiH;AACjH,wBAAsB,0BAA0B,CAAC,KAAK,GAAE,kBAAuB,EAAE,YAAY,CAAC,EAAE,aAAa,EAC3G,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,UAAU,EAAE,MAAM,CAAC,EAAE,4BAA4B,GAAG,KAAK;;mBAgF9D,gBAAgB,KAAG,OAAO,CAAC,UAAU,CAAC;;;;GAyPnE;AA+CD;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,KAAK,GAAE,kBAAuB,EAAE,YAAY,CAAC,EAAE,aAAa,EAClG,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,UAAU,EAAE,MAAM,CAAC,EAAE,4BAA4B,GAAG,KAAK,GAAG,OAAO,CAAC,WAAW,CAAC,CAElH"}
|