@alecsibilia/ui-kit 0.0.0-stage → 0.1.0-alpha.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/CHANGELOG.md +7 -0
- package/LICENSE +201 -0
- package/README.md +233 -2
- package/bin/ui-kit.js +12 -0
- package/dist/alchemy/app.d.ts +34 -0
- package/dist/alchemy/app.js +88 -0
- package/dist/alchemy/index.d.ts +11 -0
- package/dist/alchemy/index.js +11 -0
- package/dist/alchemy/live-rooms.d.ts +21 -0
- package/dist/alchemy/live-rooms.js +31 -0
- package/dist/alchemy/migrations.d.ts +28 -0
- package/dist/alchemy/migrations.js +56 -0
- package/dist/alchemy/stage.d.ts +20 -0
- package/dist/alchemy/stage.js +20 -0
- package/dist/alchemy/wrangler-config.d.ts +76 -0
- package/dist/alchemy/wrangler-config.js +82 -0
- package/dist/build/app-modules.d.ts +11 -0
- package/dist/build/app-modules.js +40 -0
- package/dist/build/check.d.ts +4 -0
- package/dist/build/check.js +170 -0
- package/dist/build/cli.d.ts +1 -0
- package/dist/build/cli.js +79 -0
- package/dist/build/feature.d.ts +8 -0
- package/dist/build/feature.js +24 -0
- package/dist/build/index.d.ts +13 -0
- package/dist/build/index.js +13 -0
- package/dist/build/measure-cpu.d.ts +2 -0
- package/dist/build/measure-cpu.js +196 -0
- package/dist/build/prerender.d.ts +5 -0
- package/dist/build/prerender.js +109 -0
- package/dist/build/preview.d.ts +7 -0
- package/dist/build/preview.js +41 -0
- package/dist/build/seo-files.d.ts +27 -0
- package/dist/build/seo-files.js +24 -0
- package/dist/client/head-swap.d.ts +45 -0
- package/dist/client/head-swap.js +183 -0
- package/dist/client/hydration-pass.d.ts +56 -0
- package/dist/client/hydration-pass.js +186 -0
- package/dist/client/hydration-reset.d.ts +82 -0
- package/dist/client/hydration-reset.js +154 -0
- package/dist/client/index.d.ts +37 -0
- package/dist/client/index.js +65 -0
- package/dist/client/nav-client.d.ts +35 -0
- package/dist/client/nav-client.js +371 -0
- package/dist/live/collab/doc-provider.d.ts +74 -0
- package/dist/live/collab/doc-provider.js +412 -0
- package/dist/live/collab/index.d.ts +51 -0
- package/dist/live/collab/index.jsx +142 -0
- package/dist/live/collab-status.d.ts +25 -0
- package/dist/live/collab-status.js +17 -0
- package/dist/live/cursors/cursor-engine.d.ts +57 -0
- package/dist/live/cursors/cursor-engine.js +243 -0
- package/dist/live/cursors/index.d.ts +46 -0
- package/dist/live/cursors/index.jsx +110 -0
- package/dist/live/declaration.d.ts +113 -0
- package/dist/live/declaration.js +94 -0
- package/dist/live/index.d.ts +8 -0
- package/dist/live/index.js +8 -0
- package/dist/live/protocol.d.ts +224 -0
- package/dist/live/protocol.js +272 -0
- package/dist/live/server/doc-store.d.ts +68 -0
- package/dist/live/server/doc-store.js +187 -0
- package/dist/live/server/index.d.ts +60 -0
- package/dist/live/server/index.js +77 -0
- package/dist/live/server/room-presence.d.ts +24 -0
- package/dist/live/server/room-presence.js +123 -0
- package/dist/live/server/room-sockets.d.ts +65 -0
- package/dist/live/server/room-sockets.js +97 -0
- package/dist/live/server/room.d.ts +20 -0
- package/dist/live/server/room.js +348 -0
- package/dist/live/server/route.d.ts +56 -0
- package/dist/live/server/route.js +159 -0
- package/dist/live/server/types.d.ts +163 -0
- package/dist/live/server/types.js +2 -0
- package/dist/logic/agent-actions.d.ts +133 -0
- package/dist/logic/agent-actions.js +150 -0
- package/dist/logic/command-types.d.ts +53 -0
- package/dist/logic/command-types.js +0 -0
- package/dist/logic/dev.d.ts +9 -0
- package/dist/logic/dev.js +10 -0
- package/dist/logic/draft-rebase.d.ts +59 -0
- package/dist/logic/draft-rebase.js +71 -0
- package/dist/logic/form-state.d.ts +105 -0
- package/dist/logic/form-state.js +93 -0
- package/dist/logic/head.d.ts +145 -0
- package/dist/logic/head.js +140 -0
- package/dist/logic/index.d.ts +27 -0
- package/dist/logic/index.js +25 -0
- package/dist/logic/island-def.d.ts +89 -0
- package/dist/logic/island-def.js +59 -0
- package/dist/logic/kit-commands.d.ts +104 -0
- package/dist/logic/kit-commands.js +72 -0
- package/dist/logic/kit-errors.d.ts +25 -0
- package/dist/logic/kit-errors.js +6 -0
- package/dist/logic/listen.d.ts +99 -0
- package/dist/logic/listen.js +92 -0
- package/dist/logic/mutation-def.d.ts +65 -0
- package/dist/logic/mutation-def.js +43 -0
- package/dist/logic/navigation-data.d.ts +50 -0
- package/dist/logic/navigation-data.js +55 -0
- package/dist/logic/navigation-policy.d.ts +74 -0
- package/dist/logic/navigation-policy.js +127 -0
- package/dist/logic/page-model-def.d.ts +108 -0
- package/dist/logic/page-model-def.js +31 -0
- package/dist/logic/path.d.ts +31 -0
- package/dist/logic/path.js +48 -0
- package/dist/logic/query-def.d.ts +56 -0
- package/dist/logic/query-def.js +37 -0
- package/dist/logic/query-key.d.ts +24 -0
- package/dist/logic/query-key.js +35 -0
- package/dist/logic/query-types.d.ts +28 -0
- package/dist/logic/query-types.js +2 -0
- package/dist/logic/resources.d.ts +163 -0
- package/dist/logic/resources.js +62 -0
- package/dist/logic/result.d.ts +30 -0
- package/dist/logic/result.js +23 -0
- package/dist/logic/route-model.d.ts +139 -0
- package/dist/logic/route-model.js +207 -0
- package/dist/logic/route-params.d.ts +80 -0
- package/dist/logic/route-params.js +114 -0
- package/dist/logic/route-table.d.ts +308 -0
- package/dist/logic/route-table.js +206 -0
- package/dist/logic/seo.d.ts +61 -0
- package/dist/logic/seo.js +101 -0
- package/dist/logic/site.d.ts +12 -0
- package/dist/logic/site.js +0 -0
- package/dist/logic/subscriptions.d.ts +177 -0
- package/dist/logic/subscriptions.js +152 -0
- package/dist/render/index.d.ts +32 -0
- package/dist/render/index.js +52 -0
- package/dist/runtime/island-wake.d.ts +38 -0
- package/dist/runtime/island-wake.js +147 -0
- package/dist/runtime/query-scope.d.ts +224 -0
- package/dist/runtime/query-scope.js +222 -0
- package/dist/runtime/room-hub.d.ts +107 -0
- package/dist/runtime/room-hub.js +307 -0
- package/dist/runtime/subscription-runner.d.ts +71 -0
- package/dist/runtime/subscription-runner.js +240 -0
- package/dist/server/bindings.d.ts +41 -0
- package/dist/server/bindings.js +74 -0
- package/dist/server/browser.d.ts +9 -0
- package/dist/server/browser.js +9 -0
- package/dist/server/edge-cache.d.ts +28 -0
- package/dist/server/edge-cache.js +35 -0
- package/dist/server/errors.d.ts +45 -0
- package/dist/server/errors.js +36 -0
- package/dist/server/form-actions-setup.d.ts +1 -0
- package/dist/server/form-actions-setup.js +15 -0
- package/dist/server/form-actions.d.ts +121 -0
- package/dist/server/form-actions.js +211 -0
- package/dist/server/index.d.ts +36 -0
- package/dist/server/index.js +35 -0
- package/dist/server/inputs.d.ts +45 -0
- package/dist/server/inputs.js +77 -0
- package/dist/server/rate-limit.d.ts +29 -0
- package/dist/server/rate-limit.js +32 -0
- package/dist/server/read-cache.d.ts +74 -0
- package/dist/server/read-cache.js +58 -0
- package/dist/server/request-info.d.ts +17 -0
- package/dist/server/request-info.js +11 -0
- package/dist/server/request.d.ts +52 -0
- package/dist/server/request.js +73 -0
- package/dist/server/response-cookies.d.ts +23 -0
- package/dist/server/response-cookies.js +24 -0
- package/dist/server/run-effect.d.ts +42 -0
- package/dist/server/run-effect.js +92 -0
- package/dist/server/run.d.ts +63 -0
- package/dist/server/run.js +66 -0
- package/dist/server/session.d.ts +125 -0
- package/dist/server/session.js +247 -0
- package/dist/test/fake-bindings.d.ts +32 -0
- package/dist/test/fake-bindings.js +108 -0
- package/dist/test/fake-room.d.ts +66 -0
- package/dist/test/fake-room.js +216 -0
- package/dist/test/index.d.ts +19 -0
- package/dist/test/index.js +44 -0
- package/dist/test/probe.d.ts +11 -0
- package/dist/test/probe.js +11 -0
- package/dist/test/solid-jsx.d.ts +23 -0
- package/dist/test/solid-jsx.js +28 -0
- package/dist/test/solid-preload.d.ts +1 -0
- package/dist/test/solid-preload.js +29 -0
- package/dist/ui/code-editor/index.d.ts +21 -0
- package/dist/ui/code-editor/index.jsx +286 -0
- package/dist/ui/collab-text/index.d.ts +29 -0
- package/dist/ui/collab-text/index.jsx +96 -0
- package/dist/ui/components/controls.d.ts +69 -0
- package/dist/ui/components/controls.jsx +81 -0
- package/dist/ui/components/feedback.d.ts +26 -0
- package/dist/ui/components/feedback.jsx +80 -0
- package/dist/ui/components/layout.d.ts +74 -0
- package/dist/ui/components/layout.jsx +146 -0
- package/dist/ui/components/lists.d.ts +69 -0
- package/dist/ui/components/lists.jsx +133 -0
- package/dist/ui/components/navigation.d.ts +73 -0
- package/dist/ui/components/navigation.jsx +112 -0
- package/dist/ui/components/text.d.ts +34 -0
- package/dist/ui/components/text.jsx +163 -0
- package/dist/ui/index.d.ts +7 -0
- package/dist/ui/index.js +7 -0
- package/dist/ui/jsx-runtime.d.ts +19 -0
- package/dist/ui/jsx-runtime.js +0 -0
- package/dist/ui/list-keys.d.ts +31 -0
- package/dist/ui/list-keys.js +45 -0
- package/dist/ui/styles/base.css +38 -0
- package/dist/ui/styles/components.css +608 -0
- package/dist/ui/styles/tokens.css +27 -0
- package/dist/ui/styles/transitions.css +23 -0
- package/dist/ui/styles/workbench.css +428 -0
- package/dist/ui/styles.css +9 -0
- package/dist/view/agent-actions-view.d.ts +30 -0
- package/dist/view/agent-actions-view.js +27 -0
- package/dist/view/agent-surface.d.ts +42 -0
- package/dist/view/agent-surface.js +123 -0
- package/dist/view/app-scope.d.ts +51 -0
- package/dist/view/app-scope.js +75 -0
- package/dist/view/boundary.d.ts +18 -0
- package/dist/view/boundary.jsx +26 -0
- package/dist/view/command-runner.d.ts +16 -0
- package/dist/view/command-runner.js +245 -0
- package/dist/view/form.d.ts +82 -0
- package/dist/view/form.jsx +109 -0
- package/dist/view/head-view.d.ts +31 -0
- package/dist/view/head-view.js +46 -0
- package/dist/view/index.d.ts +41 -0
- package/dist/view/index.js +40 -0
- package/dist/view/island-root.d.ts +30 -0
- package/dist/view/island-root.js +36 -0
- package/dist/view/island.d.ts +102 -0
- package/dist/view/island.jsx +154 -0
- package/dist/view/match.d.ts +41 -0
- package/dist/view/match.js +111 -0
- package/dist/view/model.d.ts +92 -0
- package/dist/view/model.js +162 -0
- package/dist/view/navigation-head.d.ts +29 -0
- package/dist/view/navigation-head.jsx +38 -0
- package/dist/view/page-model.d.ts +46 -0
- package/dist/view/page-model.js +146 -0
- package/dist/view/query-effects.d.ts +87 -0
- package/dist/view/query-effects.js +147 -0
- package/dist/view/query-ok.d.ts +45 -0
- package/dist/view/query-ok.js +96 -0
- package/dist/view/query.d.ts +115 -0
- package/dist/view/query.jsx +179 -0
- package/dist/view/result-view.d.ts +14 -0
- package/dist/view/result-view.jsx +15 -0
- package/dist/view/route-pages.d.ts +43 -0
- package/dist/view/route-pages.js +59 -0
- package/dist/view/router.d.ts +44 -0
- package/dist/view/router.js +123 -0
- package/dist/vite/dev-middleware.d.ts +12 -0
- package/dist/vite/dev-middleware.js +39 -0
- package/dist/vite/dev-objects.d.ts +25 -0
- package/dist/vite/dev-objects.js +127 -0
- package/dist/vite/dev-platform.d.ts +19 -0
- package/dist/vite/dev-platform.js +77 -0
- package/dist/vite/dev-seo-files.d.ts +11 -0
- package/dist/vite/dev-seo-files.js +40 -0
- package/dist/vite/index.d.ts +53 -0
- package/dist/vite/index.js +148 -0
- package/dist/vite/local-config.d.ts +34 -0
- package/dist/vite/local-config.js +72 -0
- package/dist/vite/worker-build.d.ts +24 -0
- package/dist/vite/worker-build.js +84 -0
- package/dist/worker/create-worker.d.ts +52 -0
- package/dist/worker/create-worker.js +90 -0
- package/dist/worker/index.d.ts +12 -0
- package/dist/worker/index.js +12 -0
- package/dist/worker/page-routes.d.ts +88 -0
- package/dist/worker/page-routes.js +100 -0
- package/dist/worker/page-status.d.ts +41 -0
- package/dist/worker/page-status.js +23 -0
- package/dist/worker/request-prelude.d.ts +69 -0
- package/dist/worker/request-prelude.js +107 -0
- package/dist/worker/security.d.ts +76 -0
- package/dist/worker/security.js +137 -0
- package/dist/worker/server-app.d.ts +54 -0
- package/dist/worker/server-app.js +76 -0
- package/guards/browser-only.js +5 -0
- package/guards/node-only.js +6 -0
- package/guards/server-only.js +5 -0
- package/migrations/0001-sessions.sql +22 -0
- package/package.json +233 -5
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { normalizePathname } from './path.js';
|
|
2
|
+
import { decodeSearch, isStatic, matchPattern, splitUrl, } from './route-params.js';
|
|
3
|
+
export * from './route-params.js';
|
|
4
|
+
/** What an SSR route without `ssr` gets. */
|
|
5
|
+
export const DEFAULT_SSR_MODE = 'whole';
|
|
6
|
+
/** What `navigation` defaults to. */
|
|
7
|
+
export const DEFAULT_NAVIGATION = 'document';
|
|
8
|
+
/** What `speculate` defaults to (public routes). */
|
|
9
|
+
export const DEFAULT_SPECULATION = 'prefetch';
|
|
10
|
+
/**
|
|
11
|
+
* Declares a route's lazy page import: `page: lazyPage(() => import("./x-page.tsx"))`.
|
|
12
|
+
* Identity at runtime. It types the entry as `() => Promise<PageModule>`
|
|
13
|
+
* without TypeScript reading the page's props, so a page can type its
|
|
14
|
+
* props from the table it is listed in (`PageProps<RouteOf<AppRoutes>...>`)
|
|
15
|
+
* without a circular type.
|
|
16
|
+
*/
|
|
17
|
+
export function lazyPage(load) {
|
|
18
|
+
return load;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A route's client-navigation section, or `undefined` for a full-load
|
|
22
|
+
* (`document`) route. A prerendered route never has one in effect (hash
|
|
23
|
+
* CSP; lint `ui-kit/route-navigation` reports writing it).
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* routeSection({ render: "ssr", navigation: { client: "app" } }); // "app"
|
|
28
|
+
* routeSection({ render: "prerender", navigation: { client: "app" } }); // undefined
|
|
29
|
+
* routeSection({ render: "ssr" }); // undefined
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export function routeSection(entry) {
|
|
33
|
+
const nav = entry.navigation;
|
|
34
|
+
if (nav === undefined || nav === 'document' || entry.render !== 'ssr')
|
|
35
|
+
return undefined;
|
|
36
|
+
return nav.client;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The speculation a route gets: its `speculate` (default `prefetch`),
|
|
40
|
+
* `none` for `auth: "required"` routes whatever they say.
|
|
41
|
+
*/
|
|
42
|
+
export function effectiveSpeculation(entry) {
|
|
43
|
+
if (entry.auth === 'required')
|
|
44
|
+
return 'none';
|
|
45
|
+
return entry.speculate ?? DEFAULT_SPECULATION;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The table's matching data (paths, search specs, auth, render mode).
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* const paths = routePathsOf(routes);
|
|
53
|
+
* initRouteModel(paths, currentUrl());
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export function routePathsOf(table) {
|
|
57
|
+
const paths = {};
|
|
58
|
+
for (const [tag, entry] of Object.entries(table)) {
|
|
59
|
+
paths[tag] = {
|
|
60
|
+
path: entry.path === null ? null : normalizePathname(entry.path),
|
|
61
|
+
search: entry.search ?? {},
|
|
62
|
+
auth: entry.auth ?? 'public',
|
|
63
|
+
render: entry.render,
|
|
64
|
+
ssr: entry.ssr ?? DEFAULT_SSR_MODE,
|
|
65
|
+
navigation: routeSection(entry) === undefined
|
|
66
|
+
? DEFAULT_NAVIGATION
|
|
67
|
+
: 'client',
|
|
68
|
+
section: routeSection(entry) ?? null,
|
|
69
|
+
speculate: effectiveSpeculation(entry),
|
|
70
|
+
presence: entry.presence === true,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
return paths;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The route for a URL: its tag, decoded path params and search params.
|
|
77
|
+
* Static paths win over param paths (`/plans/new` before `/plans/:planId`);
|
|
78
|
+
* a path that matches nothing (or has a param that is not valid
|
|
79
|
+
* percent-encoding) is `NotFound`. Pure, server-safe.
|
|
80
|
+
*
|
|
81
|
+
* @param table - The table's `routePathsOf` data.
|
|
82
|
+
* @param url - A path with optional query (`/plans/x?tab=stats`) or a full URL.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* matchRoute(paths, "/plans/voltar-main?tab=stats&x=1");
|
|
87
|
+
* // { _tag: "PlanDetail", params: { planId: "voltar-main" }, search: { tab: "stats" } }
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export function matchRoute(table, url) {
|
|
91
|
+
const source = table;
|
|
92
|
+
const { pathname, query } = splitUrl(url);
|
|
93
|
+
const normalized = normalizePathname(pathname);
|
|
94
|
+
const tags = Object.keys(source).filter((tag) => source[tag].path !== null);
|
|
95
|
+
const ordered = [
|
|
96
|
+
...tags.filter((tag) => isStatic(source[tag].path)),
|
|
97
|
+
...tags.filter((tag) => !isStatic(source[tag].path)),
|
|
98
|
+
];
|
|
99
|
+
for (const tag of ordered) {
|
|
100
|
+
const entry = source[tag];
|
|
101
|
+
const params = matchPattern(normalizePathname(entry.path), normalized);
|
|
102
|
+
if (params) {
|
|
103
|
+
return {
|
|
104
|
+
_tag: tag,
|
|
105
|
+
params,
|
|
106
|
+
search: decodeSearch(entry.search ?? {}, query),
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return { _tag: 'NotFound', params: {}, search: {} };
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* The URL of a route: params percent-encoded into the pattern, search
|
|
114
|
+
* params in spec order, omitted when equal to their fallback (so the
|
|
115
|
+
* default tab's URL is the bare path). `matchRoute(t, hrefFor(t, r))`
|
|
116
|
+
* gives back `r`.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts
|
|
120
|
+
* hrefFor(paths, { _tag: "PlanDetail", params: { planId: "a b" }, search: { tab: "stats" } });
|
|
121
|
+
* // "/plans/a%20b?tab=stats"
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
export function hrefFor(table, route) {
|
|
125
|
+
const source = table;
|
|
126
|
+
const value = route;
|
|
127
|
+
const entry = source[value._tag];
|
|
128
|
+
if (!entry || entry.path === null)
|
|
129
|
+
throw new Error(`No path for route ${value._tag}`);
|
|
130
|
+
const path = normalizePathname(entry.path)
|
|
131
|
+
.split('/')
|
|
132
|
+
.map((segment) => segment.startsWith(':')
|
|
133
|
+
? encodeURIComponent(value.params[segment.slice(1)] ?? '')
|
|
134
|
+
: segment)
|
|
135
|
+
.join('/');
|
|
136
|
+
const spec = entry.search ?? {};
|
|
137
|
+
const query = new URLSearchParams();
|
|
138
|
+
for (const name of Object.keys(spec)) {
|
|
139
|
+
const v = value.search[name];
|
|
140
|
+
if (v !== undefined && v !== spec[name].fallback)
|
|
141
|
+
query.set(name, String(v));
|
|
142
|
+
}
|
|
143
|
+
const qs = query.toString();
|
|
144
|
+
return qs ? `${path}?${qs}` : path;
|
|
145
|
+
}
|
|
146
|
+
/** Whether two routes are the same URL (same tag, params and search). */
|
|
147
|
+
export function sameRoute(table, a, b) {
|
|
148
|
+
if (a._tag !== b._tag)
|
|
149
|
+
return false;
|
|
150
|
+
if (a._tag === 'NotFound')
|
|
151
|
+
return true;
|
|
152
|
+
return (hrefFor(table, a) ===
|
|
153
|
+
hrefFor(table, b));
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* The table entry for a URL, with the matched tag and route (the `NotFound`
|
|
157
|
+
* entry when nothing matches). What the Worker reads before rendering:
|
|
158
|
+
* render mode, `auth`, params.
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```ts
|
|
162
|
+
* const hit = routeEntryFor(routes, "/plans/x?tab=stats");
|
|
163
|
+
* hit.render; // "ssr"
|
|
164
|
+
* hit.auth; // undefined (public)
|
|
165
|
+
* hit.route; // { _tag: "PlanDetail", params: { planId: "x" }, search: { tab: "stats" } }
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
export function routeEntryFor(table, url) {
|
|
169
|
+
const route = matchRoute(routePathsOf(table), url);
|
|
170
|
+
const entry = table[route._tag];
|
|
171
|
+
return {
|
|
172
|
+
...entry,
|
|
173
|
+
auth: entry.auth ?? 'public',
|
|
174
|
+
ssr: entry.ssr ?? DEFAULT_SSR_MODE,
|
|
175
|
+
tag: route._tag,
|
|
176
|
+
route,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Paths whose render mode is `prerender` (what the prerender step writes).
|
|
181
|
+
* A prerendered route cannot have path params (there is no list of values
|
|
182
|
+
* to render at build time).
|
|
183
|
+
*/
|
|
184
|
+
export function prerenderedPathsOf(table) {
|
|
185
|
+
return Object.entries(table)
|
|
186
|
+
.filter(([, entry]) => entry.render === 'prerender' && entry.path !== null)
|
|
187
|
+
.map(([tag, entry]) => {
|
|
188
|
+
const path = normalizePathname(entry.path);
|
|
189
|
+
if (!isStatic(path))
|
|
190
|
+
throw new Error(`Route ${tag} is prerendered but has params (${path})`);
|
|
191
|
+
return path;
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Whether a route shows live page presence (`presence: true` in the table).
|
|
196
|
+
* `NotFound` never does. Pure: a route model's selector can call it.
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```ts
|
|
200
|
+
* routePresence(paths, matchRoute(paths, "/plans/x")); // true when PlanDetail sets `presence: true`
|
|
201
|
+
* ```
|
|
202
|
+
*/
|
|
203
|
+
export function routePresence(table, route) {
|
|
204
|
+
const spec = table[route._tag];
|
|
205
|
+
return spec?.path !== null && spec?.presence === true;
|
|
206
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `sitemap.xml` and `robots.txt` from the route table. Pure: the build
|
|
3
|
+
* (`scripts/seo-files.ts`, written into the static assets) and the dev
|
|
4
|
+
* server produce the same files from the same table.
|
|
5
|
+
*
|
|
6
|
+
* Which URLs go in the sitemap:
|
|
7
|
+
* - every public route with a static path (`/`, `/architecture`), in table order;
|
|
8
|
+
* - every public route with params, once per params set its provider
|
|
9
|
+
* returns (`/plans/:planId` → `{ planId: "voltar-main" }`). A param
|
|
10
|
+
* route without a provider is left out (and listed in `skipped`);
|
|
11
|
+
* - never: `auth: "required"` routes, `NotFound`, and routes whose head
|
|
12
|
+
* says `robots: "noindex"` (or `nofollow` with noindex).
|
|
13
|
+
*
|
|
14
|
+
* `robots.txt` allows everything but the server-function endpoint and the
|
|
15
|
+
* `auth: "required"` pages, and names the sitemap. (Disallow is not
|
|
16
|
+
* noindex: those pages also say `noindex` in their head where it matters.)
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* const plan = await sitemapPlan(routes, site, { PlanDetail: async () => [{ planId: "voltar-main" }] });
|
|
21
|
+
* sitemapXml(plan.urls);
|
|
22
|
+
* robotsTxt(routes, site);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
import { type SiteHead } from './head.ts';
|
|
26
|
+
import type { RouteTable } from './route-table.ts';
|
|
27
|
+
/** Params sets for one param route, read at build time (a list, a D1 export, an API). */
|
|
28
|
+
export type SitemapProvider = () => Promise<readonly Readonly<Record<string, string>>[]>;
|
|
29
|
+
/** Providers by route tag, for routes with `:params`. */
|
|
30
|
+
export type SitemapProviders<T> = {
|
|
31
|
+
readonly [K in keyof T & string]?: SitemapProvider;
|
|
32
|
+
};
|
|
33
|
+
export interface SitemapPlan {
|
|
34
|
+
/** Absolute URLs, in table order, without duplicates. */
|
|
35
|
+
readonly urls: readonly string[];
|
|
36
|
+
/** Public param routes with no provider (they have no URLs to list). */
|
|
37
|
+
readonly skipped: readonly string[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The sitemap's URLs for a route table.
|
|
41
|
+
*
|
|
42
|
+
* @param table - the app's route table
|
|
43
|
+
* @param site - the site head (its `origin` makes the URLs absolute)
|
|
44
|
+
* @param providers - params lists for param routes
|
|
45
|
+
*/
|
|
46
|
+
export declare function sitemapPlan<T extends RouteTable>(table: T, site: SiteHead, providers: SitemapProviders<T>): Promise<SitemapPlan>;
|
|
47
|
+
/** Google reads up to 50,000 URLs (and 50 MB) per sitemap file. */
|
|
48
|
+
export declare const SITEMAP_MAX_URLS = 50000;
|
|
49
|
+
/**
|
|
50
|
+
* A `urlset` sitemap. No `priority` / `changefreq` (Google ignores them)
|
|
51
|
+
* and no `lastmod` (only useful when it is accurate per URL).
|
|
52
|
+
*/
|
|
53
|
+
export declare function sitemapXml(urls: readonly string[]): string;
|
|
54
|
+
/** Where the sitemap lives (a static asset at the site root). */
|
|
55
|
+
export declare const SITEMAP_PATH = "/sitemap.xml";
|
|
56
|
+
/**
|
|
57
|
+
* `robots.txt`: everything allowed but `disallow` (the server-function
|
|
58
|
+
* endpoint by default) and the table's `auth: "required"` pages; names the
|
|
59
|
+
* sitemap by absolute URL.
|
|
60
|
+
*/
|
|
61
|
+
export declare function robotsTxt(table: RouteTable, site: SiteHead, disallow?: readonly string[]): string;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `sitemap.xml` and `robots.txt` from the route table. Pure: the build
|
|
3
|
+
* (`scripts/seo-files.ts`, written into the static assets) and the dev
|
|
4
|
+
* server produce the same files from the same table.
|
|
5
|
+
*
|
|
6
|
+
* Which URLs go in the sitemap:
|
|
7
|
+
* - every public route with a static path (`/`, `/architecture`), in table order;
|
|
8
|
+
* - every public route with params, once per params set its provider
|
|
9
|
+
* returns (`/plans/:planId` → `{ planId: "voltar-main" }`). A param
|
|
10
|
+
* route without a provider is left out (and listed in `skipped`);
|
|
11
|
+
* - never: `auth: "required"` routes, `NotFound`, and routes whose head
|
|
12
|
+
* says `robots: "noindex"` (or `nofollow` with noindex).
|
|
13
|
+
*
|
|
14
|
+
* `robots.txt` allows everything but the server-function endpoint and the
|
|
15
|
+
* `auth: "required"` pages, and names the sitemap. (Disallow is not
|
|
16
|
+
* noindex: those pages also say `noindex` in their head where it matters.)
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* const plan = await sitemapPlan(routes, site, { PlanDetail: async () => [{ planId: "voltar-main" }] });
|
|
21
|
+
* sitemapXml(plan.urls);
|
|
22
|
+
* robotsTxt(routes, site);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
import { absoluteUrl, fillPath, resolveRouteHead, } from './head.js';
|
|
26
|
+
import { normalizePathname } from './path.js';
|
|
27
|
+
const hasParams = (path) => path.includes(':');
|
|
28
|
+
/**
|
|
29
|
+
* The sitemap's URLs for a route table.
|
|
30
|
+
*
|
|
31
|
+
* @param table - the app's route table
|
|
32
|
+
* @param site - the site head (its `origin` makes the URLs absolute)
|
|
33
|
+
* @param providers - params lists for param routes
|
|
34
|
+
*/
|
|
35
|
+
export async function sitemapPlan(table, site, providers) {
|
|
36
|
+
const urls = [];
|
|
37
|
+
const skipped = [];
|
|
38
|
+
for (const [tag, entry] of Object.entries(table)) {
|
|
39
|
+
if (entry.path === null || entry.auth === 'required')
|
|
40
|
+
continue;
|
|
41
|
+
const path = normalizePathname(entry.path);
|
|
42
|
+
const listed = (params) => {
|
|
43
|
+
const head = resolveRouteHead(entry.head, { params, search: {} }, site);
|
|
44
|
+
return head.robots === undefined || !head.robots.includes('noindex');
|
|
45
|
+
};
|
|
46
|
+
if (!hasParams(path)) {
|
|
47
|
+
if (listed({}))
|
|
48
|
+
urls.push(absoluteUrl(site.origin, path));
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const provider = providers[tag];
|
|
52
|
+
if (!provider) {
|
|
53
|
+
skipped.push(tag);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
for (const params of await provider()) {
|
|
57
|
+
if (listed(params))
|
|
58
|
+
urls.push(absoluteUrl(site.origin, fillPath(path, params)));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return { urls: [...new Set(urls)], skipped };
|
|
62
|
+
}
|
|
63
|
+
const xmlEscape = (text) => text
|
|
64
|
+
.replace(/&/g, '&')
|
|
65
|
+
.replace(/</g, '<')
|
|
66
|
+
.replace(/>/g, '>')
|
|
67
|
+
.replace(/"/g, '"')
|
|
68
|
+
.replace(/'/g, ''');
|
|
69
|
+
/** Google reads up to 50,000 URLs (and 50 MB) per sitemap file. */
|
|
70
|
+
export const SITEMAP_MAX_URLS = 50_000;
|
|
71
|
+
/**
|
|
72
|
+
* A `urlset` sitemap. No `priority` / `changefreq` (Google ignores them)
|
|
73
|
+
* and no `lastmod` (only useful when it is accurate per URL).
|
|
74
|
+
*/
|
|
75
|
+
export function sitemapXml(urls) {
|
|
76
|
+
if (urls.length > SITEMAP_MAX_URLS) {
|
|
77
|
+
throw new Error(`sitemap: ${urls.length} URLs is over the ${SITEMAP_MAX_URLS} per-file limit; split it with a sitemap index`);
|
|
78
|
+
}
|
|
79
|
+
const body = urls
|
|
80
|
+
.map((url) => ` <url><loc>${xmlEscape(url)}</loc></url>`)
|
|
81
|
+
.join('\n');
|
|
82
|
+
return `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n${body}\n</urlset>\n`;
|
|
83
|
+
}
|
|
84
|
+
/** Where the sitemap lives (a static asset at the site root). */
|
|
85
|
+
export const SITEMAP_PATH = '/sitemap.xml';
|
|
86
|
+
/**
|
|
87
|
+
* `robots.txt`: everything allowed but `disallow` (the server-function
|
|
88
|
+
* endpoint by default) and the table's `auth: "required"` pages; names the
|
|
89
|
+
* sitemap by absolute URL.
|
|
90
|
+
*/
|
|
91
|
+
export function robotsTxt(table, site, disallow = ['/_server/']) {
|
|
92
|
+
const authPaths = Object.values(table)
|
|
93
|
+
.filter((entry) => entry.path !== null && entry.auth === 'required')
|
|
94
|
+
.map((entry) => normalizePathname(entry.path));
|
|
95
|
+
const lines = [
|
|
96
|
+
'User-agent: *',
|
|
97
|
+
...[...disallow, ...authPaths].map((path) => `Disallow: ${path}`),
|
|
98
|
+
'Allow: /',
|
|
99
|
+
];
|
|
100
|
+
return `${lines.join('\n')}\n\nSitemap: ${absoluteUrl(site.origin, SITEMAP_PATH)}\n`;
|
|
101
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SiteHead } from './head.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Whether pages publish their agent actions (`<AgentActions>`): the page
|
|
4
|
+
* manifest in the head and WebMCP tools in the browser. Draft, off unless
|
|
5
|
+
* the app turns it on.
|
|
6
|
+
*/
|
|
7
|
+
export type AgentSurfaceFlag = 'on' | 'off';
|
|
8
|
+
/** Site-wide settings the kit's head and agent parts read. */
|
|
9
|
+
export interface SiteSettings {
|
|
10
|
+
readonly head: SiteHead;
|
|
11
|
+
readonly agents: AgentSurfaceFlag;
|
|
12
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model subscriptions (Elm / Foldkit `subscriptions`), as plain data.
|
|
3
|
+
* Import-free: a `.model.ts` builds them from its state; the kit starts,
|
|
4
|
+
* stops and diffs them (`subscription-runner.ts`).
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* subscriptions: (model) =>
|
|
8
|
+
* model.mode === "Live" ? [channel("/api/live-feed", decodeFeedFrame, (f) => ({ _tag: "FramePushed", f }))] : [],
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* Identity: a subscription's `key`. Between two lists, same key = keep
|
|
12
|
+
* running (its message mappers are swapped for the newest ones); new key =
|
|
13
|
+
* start; missing key = stop.
|
|
14
|
+
*
|
|
15
|
+
* - Derived keys (no `key` option): kind + parameters (`every:1000`,
|
|
16
|
+
* `channel:/live/feed`). Several subscriptions with the same derived key
|
|
17
|
+
* all run: the runner numbers repeats by position among that key
|
|
18
|
+
* (`every:1000`, `every:1000#2`), like Elm, where two `Time.every 1000`
|
|
19
|
+
* with different Messages both fire. Their order in the list is their
|
|
20
|
+
* identity, so a model that inserts one in front shifts the mapper, not the
|
|
21
|
+
* timer.
|
|
22
|
+
* - Explicit keys (`{ key: "clock" }`) pin identity regardless of position.
|
|
23
|
+
* They still include the parameters (`every:1000:clock`,
|
|
24
|
+
* `channel:<url>:feed`), so a changed URL or interval restarts the
|
|
25
|
+
* subscription instead of silently keeping the old socket / timer. Two
|
|
26
|
+
* subscriptions with the same explicit key are a bug: the runner throws in
|
|
27
|
+
* development and logs (keeping the first) in production.
|
|
28
|
+
*/
|
|
29
|
+
import type { Peer, RoomAccess, RoomRef, RoomServerFrame } from '../live/protocol.ts';
|
|
30
|
+
/** Connection state of a `channel` (sent through `onStatus`). */
|
|
31
|
+
export type ChannelStatus = 'Connecting' | 'Open' | 'Closed';
|
|
32
|
+
/** Where a subscription's key came from (see the identity rules above). */
|
|
33
|
+
export type SubscriptionKeySource = 'derived' | 'explicit';
|
|
34
|
+
/** A timer: `toMessage(now)` every `ms` milliseconds. */
|
|
35
|
+
export interface EverySubscription<Msg> {
|
|
36
|
+
readonly _tag: 'Every';
|
|
37
|
+
readonly key: string;
|
|
38
|
+
readonly keySource: SubscriptionKeySource;
|
|
39
|
+
readonly ms: number;
|
|
40
|
+
readonly toMessage: (now: number) => Msg;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A WebSocket channel (e.g. a Durable Object feed). Each frame is JSON-
|
|
44
|
+
* parsed, run through `decode` (return `undefined` to drop a frame that
|
|
45
|
+
* does not match the schema), and mapped by `toMessage`. Reconnects with
|
|
46
|
+
* backoff while subscribed.
|
|
47
|
+
*/
|
|
48
|
+
export interface ChannelSubscription<Msg> {
|
|
49
|
+
readonly _tag: 'Channel';
|
|
50
|
+
readonly key: string;
|
|
51
|
+
readonly keySource: SubscriptionKeySource;
|
|
52
|
+
/** Absolute `ws(s)://` URL, or a path on this origin (`/api/live-feed`). */
|
|
53
|
+
readonly url: string;
|
|
54
|
+
/** `"json"` (default): frames are `JSON.parse`d before `decode`; `"text"`: raw text. */
|
|
55
|
+
readonly frames: 'json' | 'text';
|
|
56
|
+
/** Decode + map in one step (kit-internal shape). */
|
|
57
|
+
readonly receive: (raw: unknown) => Msg | undefined;
|
|
58
|
+
readonly onStatus?: (status: ChannelStatus) => Msg;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* What a room subscription hears (kit-internal): the shared room socket's
|
|
62
|
+
* status changes and parsed frames, with the connection's latest `welcome`.
|
|
63
|
+
*/
|
|
64
|
+
export type RoomEvent = {
|
|
65
|
+
readonly _tag: 'Status';
|
|
66
|
+
readonly status: 'Connecting' | 'Open' | 'Closed';
|
|
67
|
+
} | {
|
|
68
|
+
readonly _tag: 'Frame';
|
|
69
|
+
readonly frame: RoomServerFrame;
|
|
70
|
+
readonly welcome: Extract<RoomServerFrame, {
|
|
71
|
+
readonly t: 'welcome';
|
|
72
|
+
}> | undefined;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* A live room (`presence(...)`, `roomSaved(...)`): rides the page's one
|
|
76
|
+
* shared socket for that room (`KitScope.rooms()`), however many models
|
|
77
|
+
* and kit parts use it.
|
|
78
|
+
*/
|
|
79
|
+
export interface RoomSubscription<Msg> {
|
|
80
|
+
readonly _tag: 'Room';
|
|
81
|
+
readonly key: string;
|
|
82
|
+
readonly keySource: SubscriptionKeySource;
|
|
83
|
+
/** The room socket path (`RoomRef.path`). */
|
|
84
|
+
readonly path: string;
|
|
85
|
+
/** Event -> Message (kit-internal shape); `undefined` drops it. */
|
|
86
|
+
readonly receive: (event: RoomEvent) => Msg | undefined;
|
|
87
|
+
}
|
|
88
|
+
export type Subscription<Msg> = EverySubscription<Msg> | ChannelSubscription<Msg> | RoomSubscription<Msg>;
|
|
89
|
+
/**
|
|
90
|
+
* Who is in a room, as a model sees it (`presence(room, toMessage)`).
|
|
91
|
+
*
|
|
92
|
+
* - `Connecting`: the socket is (re)connecting; no list yet.
|
|
93
|
+
* - `Here`: the latest list. `peers` dedupes a signed-in user's tabs (each
|
|
94
|
+
* anonymous tab is its own `Guest` peer); `tabs` counts sockets; `self`
|
|
95
|
+
* is this tab's peer id (skip it for "others"); `access` is what the
|
|
96
|
+
* viewer may do with the room's docs.
|
|
97
|
+
* - `Offline`: the socket closed; the kit is reconnecting with backoff.
|
|
98
|
+
*/
|
|
99
|
+
export type RoomPresence = {
|
|
100
|
+
readonly _tag: 'Connecting';
|
|
101
|
+
} | {
|
|
102
|
+
readonly _tag: 'Here';
|
|
103
|
+
readonly self: string;
|
|
104
|
+
readonly peers: readonly Peer[];
|
|
105
|
+
readonly tabs: number;
|
|
106
|
+
readonly access: RoomAccess;
|
|
107
|
+
} | {
|
|
108
|
+
readonly _tag: 'Offline';
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Presence of a live room as Messages, for any model (page model or
|
|
112
|
+
* island model). The page shares one socket per room with every other
|
|
113
|
+
* user of it (another `presence`, `<LiveCursors>`, the collab part).
|
|
114
|
+
* Cursor frames never reach `toMessage` (they are drawn by `<LiveCursors>`
|
|
115
|
+
* and stay out of the Message trace).
|
|
116
|
+
*
|
|
117
|
+
* @param room - A declared room (`roomRef(LIVE_ROOMS, type, key)`).
|
|
118
|
+
* @param toMessage - Presence -> Message. Keep it a plain wrapper; decide in `update`.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```ts
|
|
122
|
+
* subscriptions: (model) => [presence(model.room, (p) => ({ _tag: "PresenceChanged", presence: p }))]
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
export declare function presence<Msg>(room: RoomRef, toMessage: (presence: RoomPresence) => Msg): RoomSubscription<Msg>;
|
|
126
|
+
/** A doc of the room was persisted by its `persist` hook (the room's `saved` frame). */
|
|
127
|
+
export interface RoomDocSaved {
|
|
128
|
+
readonly doc: string;
|
|
129
|
+
/** Epoch ms, room clock. */
|
|
130
|
+
readonly at: number;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* The room's `saved` frames as Messages: a collaborative doc's persisted
|
|
134
|
+
* copy changed, so a model can `Refetch` the query that reads it (the
|
|
135
|
+
* doc's contents never become Messages). Shares the room's one socket.
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* subscriptions: (model) => [roomSaved(planRoom(model.planId), (saved) => ({ _tag: "NotesSaved", doc: saved.doc }))]
|
|
140
|
+
* // update: NotesSaved -> [model, [refetch<typeof planCollabQueries>("planCollab")("notes")]]
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
export declare function roomSaved<Msg>(room: RoomRef, toMessage: (saved: RoomDocSaved) => Msg): RoomSubscription<Msg>;
|
|
144
|
+
/**
|
|
145
|
+
* Sends `toMessage(Date.now())` every `ms` ms while it is in the list.
|
|
146
|
+
* Two `every` with the same `ms` both run (see the identity rules above).
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```ts
|
|
150
|
+
* every(1000, (now) => ({ _tag: "ClockTicked", now }))
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
export declare function every<Msg>(ms: number, toMessage: (now: number) => Msg, options?: {
|
|
154
|
+
readonly key?: string;
|
|
155
|
+
}): EverySubscription<Msg>;
|
|
156
|
+
/**
|
|
157
|
+
* Listens to a WebSocket channel while it is in the list.
|
|
158
|
+
*
|
|
159
|
+
* @param url - `ws(s)://...` or a same-origin path.
|
|
160
|
+
* @param decode - Schema-ish decoder over the frame (parsed JSON, or the raw
|
|
161
|
+
* text with `frames: "text"`); `undefined` drops it.
|
|
162
|
+
* @param toMessage - Decoded frame -> Message.
|
|
163
|
+
* @param options - `onStatus` (connection state -> Message), `frames`, `key`
|
|
164
|
+
* (pins identity; the URL stays part of the key).
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```ts
|
|
168
|
+
* channel("/api/live-feed", decodeLiveFeedFrame, (frame) => ({ _tag: "FramePushed", frame }), {
|
|
169
|
+
* onStatus: (status) => ({ _tag: "ChannelStatusChanged", status }),
|
|
170
|
+
* })
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
export declare function channel<T, Msg, Raw = unknown>(url: string, decode: (raw: Raw) => T | undefined, toMessage: (value: T) => Msg, options?: {
|
|
174
|
+
readonly onStatus?: (status: ChannelStatus) => Msg;
|
|
175
|
+
readonly frames?: 'json' | 'text';
|
|
176
|
+
readonly key?: string;
|
|
177
|
+
}): ChannelSubscription<Msg>;
|