revojs 0.0.46 → 0.0.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/index.d.ts +7 -7
- package/dist/http/index.d.ts +16 -20
- package/dist/index.js +44 -45
- package/dist/presets/bun.js +8 -4
- package/dist/presets/cloudflare.d.ts +1 -1
- package/dist/presets/cloudflare.js +9 -5
- package/dist/presets/runtime-7PuIOxLz.js +61 -0
- package/dist/router/index.d.ts +0 -3
- package/dist/runtime/index.d.ts +18 -16
- package/package.json +1 -1
- package/src/types/index.d.ts +2 -2
package/dist/app/index.d.ts
CHANGED
|
@@ -11,19 +11,19 @@ export type ClientConfig = {
|
|
|
11
11
|
export type ServerConfig = {
|
|
12
12
|
entry: ServerEntry;
|
|
13
13
|
};
|
|
14
|
-
export type DevelopmentConfig
|
|
15
|
-
middleware: Array<Middleware
|
|
14
|
+
export type DevelopmentConfig = {
|
|
15
|
+
middleware: Array<Middleware>;
|
|
16
16
|
};
|
|
17
|
-
export type Config
|
|
17
|
+
export type Config = {
|
|
18
18
|
client: ClientConfig;
|
|
19
19
|
server: false | ServerConfig;
|
|
20
20
|
markdown: Record<string, Template>;
|
|
21
|
-
dev: DevelopmentConfig
|
|
21
|
+
dev: DevelopmentConfig;
|
|
22
22
|
};
|
|
23
|
-
export type App
|
|
24
|
-
config: Config
|
|
23
|
+
export type App = {
|
|
24
|
+
config: Config;
|
|
25
25
|
virtuals: Record<string, (environment: Environment) => string>;
|
|
26
26
|
};
|
|
27
|
-
export declare const createApp: <T>(config?: NestedPartial<Config
|
|
27
|
+
export declare const createApp: <T>(config?: NestedPartial<Config>) => App;
|
|
28
28
|
export declare const SERVER = "ssr";
|
|
29
29
|
export declare const CLIENT = "client";
|
package/dist/http/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Scope } from "../signals";
|
|
1
2
|
export type CookieOptions = {
|
|
2
3
|
domain?: string;
|
|
3
4
|
expires?: Date;
|
|
@@ -12,31 +13,26 @@ export type HttpMethod = "GET" | "HEAD" | "PATCH" | "POST" | "PUT" | "DELETE" |
|
|
|
12
13
|
export type Encoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex";
|
|
13
14
|
export type StatusCode = 100 | 101 | 102 | 103 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226 | 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 444 | 450 | 451 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 506 | 507 | 508 | 509 | 510 | 511 | 521 | 522 | 523 | 525 | 530 | 599;
|
|
14
15
|
export type MimeType = "text/plain" | "text/css" | "text/html" | "text/csv" | "text/javascript" | "application/json" | "application/xml" | "image/jpeg" | "image/png" | "image/gif" | "image/webp" | "image/svg+xml" | "image/bmp" | "image/x-icon" | "font/ttf" | "font/otf" | "font/woff" | "font/woff2" | "audio/mpeg" | "audio/wav" | "audio/ogg" | "audio/mp4" | "video/mp4" | "video/webm" | "video/ogg" | "video/quicktime" | "video/x-msvideo" | "application/zip" | "application/vnd.rar" | "application/x-tar" | "application/gzip" | "application/x-7z-compressed" | "application/pdf" | "application/msword" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" | "application/vnd.ms-excel" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | "application/vnd.ms-powerpoint" | "application/vnd.openxmlformats-officedocument.presentationml.presentation" | "application/vnd.microsoft.portable-executable" | "application/vnd.android.package-archive";
|
|
15
|
-
export type Context<T> = {
|
|
16
|
-
inputs: Record<string, string>;
|
|
17
|
-
variables: T;
|
|
18
|
-
};
|
|
19
16
|
export type Set = {
|
|
20
17
|
status?: StatusCode;
|
|
21
18
|
message?: string;
|
|
22
19
|
headers: Headers;
|
|
23
20
|
};
|
|
24
|
-
export
|
|
21
|
+
export declare class Event extends Scope {
|
|
25
22
|
request: Request;
|
|
26
23
|
response: Set;
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
export type Handle
|
|
30
|
-
export type Middleware
|
|
31
|
-
export declare const
|
|
32
|
-
export declare const
|
|
33
|
-
export declare const
|
|
34
|
-
export declare const
|
|
35
|
-
export declare const
|
|
36
|
-
export declare const
|
|
37
|
-
export declare const
|
|
38
|
-
export declare const
|
|
39
|
-
export declare const
|
|
40
|
-
export declare const
|
|
41
|
-
export declare const setCookie: <T>(event: Event<T>, name: string, value: string, options?: CookieOptions) => void;
|
|
24
|
+
constructor(request: Request);
|
|
25
|
+
}
|
|
26
|
+
export type Handle = (event: Event) => void | Response | Promise<void | Response>;
|
|
27
|
+
export type Middleware = (event: Event, next: Handle) => void | Response | Promise<void | Response>;
|
|
28
|
+
export declare const sendText: (event: Event, text: string) => Response;
|
|
29
|
+
export declare const sendHtml: (event: Event, text: string) => Response;
|
|
30
|
+
export declare const sendJson: <T>(event: Event, value: T) => Response;
|
|
31
|
+
export declare const sendRedirect: (event: Event, path: string) => Response;
|
|
32
|
+
export declare const sendBadRequest: (event: Event, text: string) => Response;
|
|
33
|
+
export declare const sendUnauthorized: (event: Event) => Response;
|
|
34
|
+
export declare const getRequestUrl: (event: Event, base?: string) => URL;
|
|
35
|
+
export declare const getCookies: (event: Event) => Record<string, string>;
|
|
36
|
+
export declare const getSetCookies: (event: Event) => Record<string, string>;
|
|
37
|
+
export declare const setCookie: (event: Event, name: string, value: string, options?: CookieOptions) => void;
|
|
42
38
|
export declare const getMimeType: (file: string) => MimeType;
|
package/dist/index.js
CHANGED
|
@@ -478,12 +478,14 @@ const HOST_CONTEXT = defineContext("HOST_CONTEXT");
|
|
|
478
478
|
|
|
479
479
|
//#endregion
|
|
480
480
|
//#region src/http/index.ts
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
481
|
+
var Event$1 = class extends Scope {
|
|
482
|
+
request;
|
|
483
|
+
response;
|
|
484
|
+
constructor(request) {
|
|
485
|
+
super();
|
|
486
|
+
this.request = request;
|
|
487
|
+
this.response = { headers: new Headers() };
|
|
488
|
+
}
|
|
487
489
|
};
|
|
488
490
|
const sendText = (event, text) => {
|
|
489
491
|
event.response.headers.set("Content-Type", "text/plain");
|
|
@@ -510,8 +512,8 @@ const sendUnauthorized = (event) => {
|
|
|
510
512
|
event.response.status = 401;
|
|
511
513
|
return new Response(null, event.response);
|
|
512
514
|
};
|
|
513
|
-
const getRequestUrl = (event) => {
|
|
514
|
-
return new URL(event
|
|
515
|
+
const getRequestUrl = (event, base) => {
|
|
516
|
+
return new URL(event.request.url, base);
|
|
515
517
|
};
|
|
516
518
|
const getCookies = (event) => {
|
|
517
519
|
const cookies = event.request.headers.get("Cookie")?.split("; ") ?? [];
|
|
@@ -633,8 +635,11 @@ var Radix = class Radix {
|
|
|
633
635
|
|
|
634
636
|
//#endregion
|
|
635
637
|
//#region src/runtime/index.ts
|
|
636
|
-
const useRuntime = (scope
|
|
637
|
-
return scope.getContext(
|
|
638
|
+
const useRuntime = (scope) => {
|
|
639
|
+
return scope.getContext(RUNTIME_CONTEXT);
|
|
640
|
+
};
|
|
641
|
+
const useVariables = (scope) => {
|
|
642
|
+
return scope.getContext(VARIABLE_CONTEXT);
|
|
638
643
|
};
|
|
639
644
|
const defineRoute = (route) => {
|
|
640
645
|
return route;
|
|
@@ -648,22 +653,23 @@ const toPath = (value) => {
|
|
|
648
653
|
const split = route.split(".");
|
|
649
654
|
return split.length === 3 ? [split.at(0), split.at(1)] : [split.at(0)];
|
|
650
655
|
};
|
|
651
|
-
const $fetch = async (scope, input,
|
|
656
|
+
const $fetch = async (scope, input, options) => {
|
|
652
657
|
const { event } = useRuntime(scope);
|
|
653
658
|
let response;
|
|
654
659
|
if (event) {
|
|
655
660
|
const url = new URL(input.toString(), event.request.url);
|
|
656
|
-
|
|
657
|
-
|
|
661
|
+
const next = new Event$1(new Request(url, options));
|
|
662
|
+
next.setContext(VARIABLE_CONTEXT, useVariables(event));
|
|
663
|
+
const previous = new URL(event.request.url);
|
|
664
|
+
if (url.origin === previous.origin) response = await (await import("#virtual/runtime")).runtime.fetch(next);
|
|
665
|
+
}
|
|
666
|
+
response ??= await fetch(input, options);
|
|
658
667
|
if (response.ok === false) throw response;
|
|
659
668
|
switch (response.headers.get("Content-Type")) {
|
|
660
669
|
case "application/json": return response.json();
|
|
661
670
|
default: return response;
|
|
662
671
|
}
|
|
663
672
|
};
|
|
664
|
-
const getVariables = (event) => {
|
|
665
|
-
return event ? event.context.variables : import.meta.env;
|
|
666
|
-
};
|
|
667
673
|
const createRuntime = async () => {
|
|
668
674
|
const radix = new Radix();
|
|
669
675
|
const middlewares = new Array();
|
|
@@ -673,15 +679,7 @@ const createRuntime = async () => {
|
|
|
673
679
|
radix.insert((method ?? "GET").toUpperCase() + name, defineRoute({ fetch: async (event) => {
|
|
674
680
|
const route = await routes[path]?.();
|
|
675
681
|
if (typeof route === "object") return route.fetch(event);
|
|
676
|
-
if (route)
|
|
677
|
-
const scope = new Scope();
|
|
678
|
-
try {
|
|
679
|
-
scope.setContext(RUNTIME_CONTEXT, { event });
|
|
680
|
-
return sendHtml(event, await renderToString(scope, await import("#virtual/client").then((module) => module.client)));
|
|
681
|
-
} finally {
|
|
682
|
-
scope.stop();
|
|
683
|
-
}
|
|
684
|
-
}
|
|
682
|
+
if (route) return sendHtml(event, await renderToString(event, await import("#virtual/client").then((module) => module.client)));
|
|
685
683
|
} }));
|
|
686
684
|
}
|
|
687
685
|
const assets = await import("#virtual/assets").then((module) => module.assets);
|
|
@@ -695,19 +693,19 @@ const createRuntime = async () => {
|
|
|
695
693
|
return {
|
|
696
694
|
radix,
|
|
697
695
|
middlewares,
|
|
698
|
-
fetch: async (
|
|
699
|
-
const url = getRequestUrl(
|
|
700
|
-
const { value: route, inputs } = radix.match(request.method + url.pathname);
|
|
701
|
-
const event = createEvent(request, {
|
|
702
|
-
...context,
|
|
703
|
-
inputs
|
|
704
|
-
});
|
|
696
|
+
fetch: async (event) => {
|
|
697
|
+
const url = getRequestUrl(event);
|
|
698
|
+
const { value: route, inputs } = radix.match(event.request.method + url.pathname);
|
|
705
699
|
try {
|
|
700
|
+
event.setContext(RUNTIME_CONTEXT, {
|
|
701
|
+
event,
|
|
702
|
+
inputs
|
|
703
|
+
});
|
|
706
704
|
if (route) {
|
|
707
705
|
const response = await invoke(event, route.fetch, 0);
|
|
708
706
|
if (response) return response;
|
|
709
707
|
}
|
|
710
|
-
return sendText(event, "
|
|
708
|
+
return sendText(event, "NOT_FOUND");
|
|
711
709
|
} catch (exception) {
|
|
712
710
|
if (exception instanceof Response) return exception;
|
|
713
711
|
throw exception;
|
|
@@ -716,6 +714,7 @@ const createRuntime = async () => {
|
|
|
716
714
|
};
|
|
717
715
|
};
|
|
718
716
|
const RUNTIME_CONTEXT = defineContext("RUNTIME_CONTEXT");
|
|
717
|
+
const VARIABLE_CONTEXT = defineContext("VARIABLE_CONTEXT");
|
|
719
718
|
|
|
720
719
|
//#endregion
|
|
721
720
|
//#region src/router/index.tsx
|
|
@@ -730,7 +729,6 @@ const createRouter = (options) => {
|
|
|
730
729
|
const radix = new Radix();
|
|
731
730
|
const url = createState();
|
|
732
731
|
const route = createState();
|
|
733
|
-
const inputs = createState();
|
|
734
732
|
for (const path in options.routes) {
|
|
735
733
|
const [name] = toPath(path);
|
|
736
734
|
if (name) {
|
|
@@ -739,24 +737,25 @@ const createRouter = (options) => {
|
|
|
739
737
|
}
|
|
740
738
|
}
|
|
741
739
|
const registerRouterContext = async (scope) => {
|
|
742
|
-
const { event } = useRuntime(scope);
|
|
743
740
|
const fetch$1 = async () => {
|
|
741
|
+
const { event } = useRuntime(scope);
|
|
744
742
|
url.value = new URL(event?.request.url ?? window?.location.href);
|
|
745
743
|
const match = radix.match(url.value.pathname);
|
|
746
|
-
|
|
744
|
+
scope.setContext(RUNTIME_CONTEXT, {
|
|
745
|
+
event,
|
|
746
|
+
inputs: match.inputs
|
|
747
|
+
});
|
|
747
748
|
const Page$1 = await match.value?.();
|
|
748
|
-
if (Page$1) route.value = /* @__PURE__ */ h(Page$1,
|
|
749
|
+
if (Page$1) route.value = /* @__PURE__ */ h(Page$1, null);
|
|
749
750
|
};
|
|
750
751
|
if (isClient()) useEvent(scope, window, "popstate", () => navigator.dispatchEvent(new NavigateEvent()));
|
|
751
|
-
if (event) inputs.value = event.context.inputs;
|
|
752
752
|
await fetch$1().then(() => useEvent(scope, navigator, "navigate", fetch$1));
|
|
753
753
|
scope.setContext(ROUTER_CONTEXT, {
|
|
754
754
|
options,
|
|
755
755
|
navigator,
|
|
756
756
|
url,
|
|
757
757
|
radix,
|
|
758
|
-
route
|
|
759
|
-
inputs
|
|
758
|
+
route
|
|
760
759
|
});
|
|
761
760
|
return useRouter(scope);
|
|
762
761
|
};
|
|
@@ -766,7 +765,7 @@ const createRouter = (options) => {
|
|
|
766
765
|
};
|
|
767
766
|
};
|
|
768
767
|
const useRouter = (scope, context) => {
|
|
769
|
-
const { url, route,
|
|
768
|
+
const { url, route, navigator } = scope.getContext(context ?? ROUTER_CONTEXT);
|
|
770
769
|
const navigate = (path) => {
|
|
771
770
|
if (isClient()) {
|
|
772
771
|
if (window.location.pathname != path) window.history.pushState(window.history.state, "", path);
|
|
@@ -780,7 +779,6 @@ const useRouter = (scope, context) => {
|
|
|
780
779
|
return {
|
|
781
780
|
url,
|
|
782
781
|
route,
|
|
783
|
-
inputs,
|
|
784
782
|
navigator,
|
|
785
783
|
navigate,
|
|
786
784
|
anchorNavigate
|
|
@@ -801,10 +799,11 @@ const createLocale = (options) => {
|
|
|
801
799
|
const locale = createState(options.defaultLocale);
|
|
802
800
|
const messages = createState();
|
|
803
801
|
const registerLocaleContext = async (scope) => {
|
|
804
|
-
const { inputs
|
|
802
|
+
const { inputs } = useRuntime(scope);
|
|
803
|
+
const { navigator } = useRouter(scope);
|
|
805
804
|
const fetch$1 = async () => {
|
|
806
805
|
if (options.input) {
|
|
807
|
-
const input = inputs
|
|
806
|
+
const input = inputs[options.input];
|
|
808
807
|
if (input && input in options.locales) locale.value = input;
|
|
809
808
|
}
|
|
810
809
|
if (locale.value) {
|
|
@@ -935,4 +934,4 @@ const markdownToSlot = (input, options) => {
|
|
|
935
934
|
};
|
|
936
935
|
|
|
937
936
|
//#endregion
|
|
938
|
-
export { $fetch, CLIENT, Compute, HOST_CONTEXT, Handler, LOCALE_CONTEXT, MountedEvent, NavigateEvent, Page, ROUTER_CONTEXT, RUNTIME_CONTEXT, Radix, SERVER, Scope, StopEvent, activeCompute, components, createApp, createCompute, createElement,
|
|
937
|
+
export { $fetch, CLIENT, Compute, Event$1 as Event, HOST_CONTEXT, Handler, LOCALE_CONTEXT, MountedEvent, NavigateEvent, Page, ROUTER_CONTEXT, RUNTIME_CONTEXT, Radix, SERVER, Scope, StopEvent, VARIABLE_CONTEXT, activeCompute, components, createApp, createCompute, createElement, createLocale, createMemo, createRouter, createRuntime, createState, defineComponent, defineContext, defineRoute, fileName, fromValue, getCookies, getCustomElement, getMimeType, getRequestUrl, getSetCookies, hydrate, isClient, isServer, isTemplate, markdownToSlot, preventDefault, registerComponent, renderToString, sendBadRequest, sendHtml, sendJson, sendRedirect, sendText, sendUnauthorized, setCookie, stopImmediatePropagation, stopPropagation, targets, toArray, toCustomElement, toFragment, toPath, toRange, toString, useEvent, useHost, useLocale, useRouter, useRuntime, useVariables };
|
package/dist/presets/bun.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
+
import { Event, VARIABLE_CONTEXT } from "./runtime-7PuIOxLz.js";
|
|
1
2
|
import { runtime } from "#virtual/runtime";
|
|
2
3
|
import { serve } from "bun";
|
|
3
4
|
|
|
4
5
|
//#region src/presets/bun.ts
|
|
5
6
|
serve({ fetch: (request) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const event = new Event(request);
|
|
8
|
+
event.setContext(VARIABLE_CONTEXT, process.env);
|
|
9
|
+
try {
|
|
10
|
+
return runtime.fetch(event);
|
|
11
|
+
} finally {
|
|
12
|
+
event.stop();
|
|
13
|
+
}
|
|
10
14
|
} });
|
|
11
15
|
|
|
12
16
|
//#endregion
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
import { Event, VARIABLE_CONTEXT } from "./runtime-7PuIOxLz.js";
|
|
1
2
|
import { runtime } from "#virtual/runtime";
|
|
2
3
|
|
|
3
4
|
//#region src/presets/cloudflare.ts
|
|
4
|
-
var cloudflare_default = { fetch: (request,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
var cloudflare_default = { fetch: (request, variables) => {
|
|
6
|
+
const event = new Event(request);
|
|
7
|
+
event.setContext(VARIABLE_CONTEXT, variables);
|
|
8
|
+
try {
|
|
9
|
+
return runtime.fetch(event);
|
|
10
|
+
} finally {
|
|
11
|
+
event.stop();
|
|
12
|
+
}
|
|
9
13
|
} };
|
|
10
14
|
|
|
11
15
|
//#endregion
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
//#region src/signals/index.ts
|
|
2
|
+
var StopEvent = class extends Event {
|
|
3
|
+
constructor() {
|
|
4
|
+
super("stop");
|
|
5
|
+
}
|
|
6
|
+
};
|
|
7
|
+
var Scope = class extends EventTarget {
|
|
8
|
+
parentScope;
|
|
9
|
+
context;
|
|
10
|
+
constructor(scope) {
|
|
11
|
+
super();
|
|
12
|
+
this.parentScope = scope;
|
|
13
|
+
this.context = new Map();
|
|
14
|
+
}
|
|
15
|
+
getContext(input) {
|
|
16
|
+
let scope = this;
|
|
17
|
+
const seen = new Set();
|
|
18
|
+
while (scope && !seen.has(scope)) {
|
|
19
|
+
seen.add(scope);
|
|
20
|
+
if (scope.context.has(input)) return scope.context.get(input);
|
|
21
|
+
scope = scope.parentScope;
|
|
22
|
+
}
|
|
23
|
+
return {};
|
|
24
|
+
}
|
|
25
|
+
setContext(input, value) {
|
|
26
|
+
this.context.set(input, value);
|
|
27
|
+
}
|
|
28
|
+
onStop(input) {
|
|
29
|
+
this.addEventListener("stop", input, { once: true });
|
|
30
|
+
}
|
|
31
|
+
stop() {
|
|
32
|
+
return this.dispatchEvent(new StopEvent());
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
function defineContext(key) {
|
|
36
|
+
return key;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/http/index.ts
|
|
41
|
+
var Event$1 = class extends Scope {
|
|
42
|
+
request;
|
|
43
|
+
response;
|
|
44
|
+
constructor(request) {
|
|
45
|
+
super();
|
|
46
|
+
this.request = request;
|
|
47
|
+
this.response = { headers: new Headers() };
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/html/index.ts
|
|
53
|
+
const HOST_CONTEXT = defineContext("HOST_CONTEXT");
|
|
54
|
+
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/runtime/index.ts
|
|
57
|
+
const RUNTIME_CONTEXT = defineContext("RUNTIME_CONTEXT");
|
|
58
|
+
const VARIABLE_CONTEXT = defineContext("VARIABLE_CONTEXT");
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
export { Event$1 as Event, VARIABLE_CONTEXT };
|
package/dist/router/index.d.ts
CHANGED
|
@@ -11,7 +11,6 @@ export type RouterContext<T extends RouterOptions = RouterOptions> = {
|
|
|
11
11
|
url: State<URL | undefined>;
|
|
12
12
|
radix: Radix<() => Promise<ComponentConstructor<Events, Attributes>>>;
|
|
13
13
|
route: State<Slot | undefined>;
|
|
14
|
-
inputs: State<Record<string, string> | undefined>;
|
|
15
14
|
};
|
|
16
15
|
export declare class NavigateEvent extends Event {
|
|
17
16
|
constructor();
|
|
@@ -22,7 +21,6 @@ export declare const createRouter: <T extends RouterOptions>(options: T) => {
|
|
|
22
21
|
registerRouterContext: (scope: Scope) => Promise<{
|
|
23
22
|
url: State<URL | undefined>;
|
|
24
23
|
route: State<unknown>;
|
|
25
|
-
inputs: State<Record<string, string> | undefined>;
|
|
26
24
|
navigator: EventTarget;
|
|
27
25
|
navigate: (path: string) => void;
|
|
28
26
|
anchorNavigate: (event: Event) => void;
|
|
@@ -31,7 +29,6 @@ export declare const createRouter: <T extends RouterOptions>(options: T) => {
|
|
|
31
29
|
export declare const useRouter: <T extends RouterContext>(scope: Scope, context?: Descriptor<T>) => {
|
|
32
30
|
url: State<URL | undefined>;
|
|
33
31
|
route: State<unknown>;
|
|
34
|
-
inputs: State<Record<string, string> | undefined>;
|
|
35
32
|
navigator: EventTarget;
|
|
36
33
|
navigate: (path: string) => void;
|
|
37
34
|
anchorNavigate: (event: Event) => void;
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Event, type Handle, type Middleware } from "../http";
|
|
2
2
|
import { Radix } from "../radix";
|
|
3
|
-
import {
|
|
4
|
-
export type Route
|
|
5
|
-
fetch: Handle
|
|
3
|
+
import { Scope } from "../signals";
|
|
4
|
+
export type Route = {
|
|
5
|
+
fetch: Handle;
|
|
6
6
|
};
|
|
7
|
-
export type Runtime
|
|
8
|
-
radix: Radix<Route
|
|
9
|
-
middlewares: Array<Middleware
|
|
10
|
-
fetch: (
|
|
7
|
+
export type Runtime = {
|
|
8
|
+
radix: Radix<Route>;
|
|
9
|
+
middlewares: Array<Middleware>;
|
|
10
|
+
fetch: (event: Event) => Promise<Response>;
|
|
11
11
|
};
|
|
12
|
-
export type RuntimeContext
|
|
13
|
-
event?: Event
|
|
12
|
+
export type RuntimeContext = {
|
|
13
|
+
event?: Event;
|
|
14
|
+
inputs: Record<string, string>;
|
|
14
15
|
};
|
|
15
|
-
export declare const useRuntime:
|
|
16
|
-
export declare const
|
|
16
|
+
export declare const useRuntime: (scope: Scope) => RuntimeContext;
|
|
17
|
+
export declare const useVariables: <T>(scope: Scope) => T;
|
|
18
|
+
export declare const defineRoute: (route: Route) => Route;
|
|
17
19
|
export declare const fileName: (path: string) => string | undefined;
|
|
18
20
|
export declare const toPath: (value: string) => (string | undefined)[];
|
|
19
|
-
export declare const $fetch: <T>(scope: Scope, input: string | URL,
|
|
20
|
-
export declare const
|
|
21
|
-
export declare const
|
|
22
|
-
export declare const
|
|
21
|
+
export declare const $fetch: <T>(scope: Scope, input: string | URL, options?: RequestInit) => Promise<T>;
|
|
22
|
+
export declare const createRuntime: () => Promise<Runtime>;
|
|
23
|
+
export declare const RUNTIME_CONTEXT: import("..").Descriptor<RuntimeContext>;
|
|
24
|
+
export declare const VARIABLE_CONTEXT: import("..").Descriptor<Record<string, unknown>>;
|
package/package.json
CHANGED
package/src/types/index.d.ts
CHANGED
|
@@ -13,11 +13,11 @@ declare module "#virtual/client" {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
declare module "#virtual/routes" {
|
|
16
|
-
export const routes: Record<string, () => Promise<Route
|
|
16
|
+
export const routes: Record<string, () => Promise<Route | ComponentConstructor<Events, Attributes>>>;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
declare module "#virtual/runtime" {
|
|
20
20
|
import type { Runtime } from "revojs";
|
|
21
21
|
|
|
22
|
-
export const runtime: Runtime
|
|
22
|
+
export const runtime: Runtime;
|
|
23
23
|
}
|