revojs 0.1.45 → 0.1.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-B4HJTrxE.mjs → app-DqEq3uwt.mjs} +3 -6
- package/dist/commands/index.mjs +1 -1
- package/dist/{index--5m6SUpo.d.mts → index-nxflReVm.d.mts} +31 -20
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +13 -2
- package/dist/kit/index.d.mts +2 -3
- package/dist/kit/index.mjs +3 -6
- package/dist/{package-9EF2Bhnr.mjs → package-DSa1C_1a.mjs} +1 -1
- package/dist/vite/index.d.mts +3 -3
- package/dist/vite/index.mjs +35 -23
- package/package.json +1 -1
- package/src/types/assets.d.ts +7 -0
|
@@ -608,12 +608,9 @@ var App = class extends Hookable {
|
|
|
608
608
|
},
|
|
609
609
|
variables: {},
|
|
610
610
|
development: { middleware: [] },
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
virtuals: {},
|
|
615
|
-
alias: {}
|
|
616
|
-
}
|
|
611
|
+
templates: {},
|
|
612
|
+
virtuals: {},
|
|
613
|
+
vite: {}
|
|
617
614
|
});
|
|
618
615
|
}
|
|
619
616
|
};
|
package/dist/commands/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { n as version, t as name } from "../package-
|
|
2
|
+
import { n as version, t as name } from "../package-DSa1C_1a.mjs";
|
|
3
3
|
import { defineCommand, runMain } from "citty";
|
|
4
4
|
//#region src/commands/run/index.ts
|
|
5
5
|
var run_default = defineCommand({ setup() {} });
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { UserConfig } from "vite";
|
|
2
|
+
|
|
1
3
|
//#region src/shared/index.d.ts
|
|
2
4
|
type Descriptor<T> = string & {
|
|
3
5
|
[descriptor]: T;
|
|
@@ -7,7 +9,8 @@ type Context = Record<string, any>;
|
|
|
7
9
|
type Output<T> = Success<T> | Failure;
|
|
8
10
|
type InferInput<T extends Schema> = NonNullable<T["~standard"]["types"]>["input"];
|
|
9
11
|
type InferOutput<T extends Schema> = NonNullable<T["~standard"]["types"]>["output"];
|
|
10
|
-
type
|
|
12
|
+
type Primitive = string | number | boolean | bigint | symbol | null | undefined;
|
|
13
|
+
type Mergeable<T> = T extends Primitive ? T : T extends Array<infer U> ? Array<Mergeable<U>> : { [K in keyof T]?: Mergeable<T[K]> };
|
|
11
14
|
interface Issue {
|
|
12
15
|
readonly message: string;
|
|
13
16
|
}
|
|
@@ -93,6 +96,11 @@ interface Server {
|
|
|
93
96
|
middleware: Array<Middleware>;
|
|
94
97
|
fetch: (scope: Scope) => Result;
|
|
95
98
|
}
|
|
99
|
+
interface PathNode<T> {
|
|
100
|
+
type: "PATH";
|
|
101
|
+
value?: T;
|
|
102
|
+
children: Record<string, Node<T>>;
|
|
103
|
+
}
|
|
96
104
|
interface WildcardNode<T> {
|
|
97
105
|
type: "WILDCARD";
|
|
98
106
|
value?: T;
|
|
@@ -105,21 +113,16 @@ interface OptionalWildcardNode<T> {
|
|
|
105
113
|
parameter: string;
|
|
106
114
|
children: Record<string, Node<T>>;
|
|
107
115
|
}
|
|
108
|
-
interface OptionalParameterNode<T> {
|
|
109
|
-
type: "OPTIONAL-PARAMETER";
|
|
110
|
-
value?: T;
|
|
111
|
-
parameter: string;
|
|
112
|
-
children: Record<string, Node<T>>;
|
|
113
|
-
}
|
|
114
116
|
interface ParameterNode<T> {
|
|
115
117
|
type: "PARAMETER";
|
|
116
118
|
value?: T;
|
|
117
119
|
parameter: string;
|
|
118
120
|
children: Record<string, Node<T>>;
|
|
119
121
|
}
|
|
120
|
-
interface
|
|
121
|
-
type: "
|
|
122
|
+
interface OptionalParameterNode<T> {
|
|
123
|
+
type: "OPTIONAL-PARAMETER";
|
|
122
124
|
value?: T;
|
|
125
|
+
parameter: string;
|
|
123
126
|
children: Record<string, Node<T>>;
|
|
124
127
|
}
|
|
125
128
|
declare class Radix<T> {
|
|
@@ -187,7 +190,15 @@ declare const mimeTypes: Record<string, string>;
|
|
|
187
190
|
//#region src/app/index.d.ts
|
|
188
191
|
type Environment = typeof CLIENT | typeof SERVER;
|
|
189
192
|
type Virtual = (environment: Environment) => undefined | string | Promise<string>;
|
|
190
|
-
type Content = () => string
|
|
193
|
+
type Content = () => string | Promise<string>;
|
|
194
|
+
interface Asset {
|
|
195
|
+
type: string;
|
|
196
|
+
name: string;
|
|
197
|
+
relative: string;
|
|
198
|
+
entityTag: string;
|
|
199
|
+
lastModified: string;
|
|
200
|
+
size: number;
|
|
201
|
+
}
|
|
191
202
|
interface Template {
|
|
192
203
|
tagName: string;
|
|
193
204
|
attributes: Record<string, string>;
|
|
@@ -196,12 +207,6 @@ interface Template {
|
|
|
196
207
|
interface DevelopmentConfig {
|
|
197
208
|
middleware: Array<Middleware>;
|
|
198
209
|
}
|
|
199
|
-
interface BuildConfig {
|
|
200
|
-
externals: Array<string>;
|
|
201
|
-
templates: Record<string, Content>;
|
|
202
|
-
virtuals: Record<string, Virtual>;
|
|
203
|
-
alias: Record<string, string>;
|
|
204
|
-
}
|
|
205
210
|
interface Config {
|
|
206
211
|
modules: Array<Module>;
|
|
207
212
|
client?: string;
|
|
@@ -210,11 +215,12 @@ interface Config {
|
|
|
210
215
|
sources: Record<string, Source>;
|
|
211
216
|
variables: Record<string, unknown>;
|
|
212
217
|
development: DevelopmentConfig;
|
|
213
|
-
|
|
218
|
+
templates: Record<string, Content>;
|
|
219
|
+
virtuals: Record<string, Virtual>;
|
|
220
|
+
vite: UserConfig;
|
|
214
221
|
}
|
|
215
222
|
interface Module {
|
|
216
|
-
|
|
217
|
-
setup?: (app: App) => void | Promise<void>;
|
|
223
|
+
setup?: (app: App) => void | Mergeable<Config> | Promise<void | Mergeable<Config>>;
|
|
218
224
|
}
|
|
219
225
|
interface Source {
|
|
220
226
|
match: string | Array<string>;
|
|
@@ -232,4 +238,9 @@ declare const CLOSE_HOOK: Descriptor<() => void>;
|
|
|
232
238
|
//#region src/client/index.d.ts
|
|
233
239
|
declare function $fetch<T>(scope: Scope, input: string | URL, options?: RequestInit): Promise<T>;
|
|
234
240
|
//#endregion
|
|
235
|
-
|
|
241
|
+
//#region src/middleware/index.d.ts
|
|
242
|
+
declare function createStaticMiddleware<T>(resolve: (path: string | URL) => T | Promise<T>): {
|
|
243
|
+
fetch(scope: Scope, next: (() => Result) | undefined): Promise<void | Response>;
|
|
244
|
+
};
|
|
245
|
+
//#endregion
|
|
246
|
+
export { defineMiddleware as $, PARAMETER as A, useUrl as At, RouterContext as B, Mergeable as Bt, Node as C, useCookies as Ct, OPTIONAL_WILDCARD_MATCH as D, useRouter as Dt, OPTIONAL_WILDCARD as E, useQuery as Et, Radix as F, Hookable as Ft, States as G, Success as Gt, STATES as H, Primitive as Ht, ResponseConfig as I, InferInput as It, WILDCARD_MATCH as J, isFailure as Jt, StatusCode as K, defineContext as Kt, Result as L, InferOutput as Lt, ParameterNode as M, Context as Mt, PathNode as N, Descriptor as Nt, OptionalParameterNode as O, useServer as Ot, ROUTER_CONTEXT as P, Failure as Pt, createServer as Q, Route as R, Invoke as Rt, MimeType as S, useBody as St, OPTIONAL_PARAMETER_MATCH as T, useParameters as Tt, Server as U, Schema as Ut, SERVER_CONTEXT as V, Output as Vt, ServerContext as W, Scope as Wt, cookiePriorities as X, parseSchema as Xt, WildcardNode as Y, mergeObjects as Yt, cookieSameSites as Z, CookiePriority as _, sendResponse as _t, CLIENT as a, isClient as at, HttpMethod as b, setState as bt, Content as c, mimeTypes as ct, Module as d, sendCreated as dt, defineRoute as et, SERVER as f, sendForbidden as ft, CookieOptions as g, sendRedirect as gt, Virtual as h, sendOk as ht, Asset as i, invoke as it, PARAMETER_MATCH as j, withQuery as jt, OptionalWildcardNode as k, useSetCookies as kt, DevelopmentConfig as l, parseCookiePair as lt, Template as m, sendNotFound as mt, $fetch as n, getState as nt, CLOSE_HOOK as o, isServer as ot, Source as p, sendNoContent as pt, WILDCARD as q, defineHook as qt, App as r, httpMethods as rt, Config as s, mimeType as st, createStaticMiddleware as t, encodings as tt, Environment as u, sendBadRequest as ut, CookieSameSite as v, sendUnauthorized as vt, OPTIONAL_PARAMETER as w, useHeaders as wt, Middleware as x, statusCodes as xt, Encoding as y, setCookie as yt, Router as z, Issue as zt };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export { $fetch, App,
|
|
1
|
+
import { $ as defineMiddleware, A as PARAMETER, At as useUrl, B as RouterContext, Bt as Mergeable, C as Node, Ct as useCookies, D as OPTIONAL_WILDCARD_MATCH, Dt as useRouter, E as OPTIONAL_WILDCARD, Et as useQuery, F as Radix, Ft as Hookable, G as States, Gt as Success, H as STATES, Ht as Primitive, I as ResponseConfig, It as InferInput, J as WILDCARD_MATCH, Jt as isFailure, K as StatusCode, Kt as defineContext, L as Result, Lt as InferOutput, M as ParameterNode, Mt as Context, N as PathNode, Nt as Descriptor, O as OptionalParameterNode, Ot as useServer, P as ROUTER_CONTEXT, Pt as Failure, Q as createServer, R as Route, Rt as Invoke, S as MimeType, St as useBody, T as OPTIONAL_PARAMETER_MATCH, Tt as useParameters, U as Server, Ut as Schema, V as SERVER_CONTEXT, Vt as Output, W as ServerContext, Wt as Scope, X as cookiePriorities, Xt as parseSchema, Y as WildcardNode, Yt as mergeObjects, Z as cookieSameSites, _ as CookiePriority, _t as sendResponse, a as CLIENT, at as isClient, b as HttpMethod, bt as setState, c as Content, ct as mimeTypes, d as Module, dt as sendCreated, et as defineRoute, f as SERVER, ft as sendForbidden, g as CookieOptions, gt as sendRedirect, h as Virtual, ht as sendOk, i as Asset, it as invoke, j as PARAMETER_MATCH, jt as withQuery, k as OptionalWildcardNode, kt as useSetCookies, l as DevelopmentConfig, lt as parseCookiePair, m as Template, mt as sendNotFound, n as $fetch, nt as getState, o as CLOSE_HOOK, ot as isServer, p as Source, pt as sendNoContent, q as WILDCARD, qt as defineHook, r as App, rt as httpMethods, s as Config, st as mimeType, t as createStaticMiddleware, tt as encodings, u as Environment, ut as sendBadRequest, v as CookieSameSite, vt as sendUnauthorized, w as OPTIONAL_PARAMETER, wt as useHeaders, x as Middleware, xt as statusCodes, y as Encoding, yt as setCookie, z as Router, zt as Issue } from "./index-nxflReVm.mjs";
|
|
2
|
+
export { $fetch, App, Asset, CLIENT, CLOSE_HOOK, Config, Content, Context, CookieOptions, CookiePriority, CookieSameSite, Descriptor, DevelopmentConfig, Encoding, Environment, Failure, Hookable, HttpMethod, InferInput, InferOutput, Invoke, Issue, Mergeable, Middleware, MimeType, Module, Node, OPTIONAL_PARAMETER, OPTIONAL_PARAMETER_MATCH, OPTIONAL_WILDCARD, OPTIONAL_WILDCARD_MATCH, OptionalParameterNode, OptionalWildcardNode, Output, PARAMETER, PARAMETER_MATCH, ParameterNode, PathNode, Primitive, ROUTER_CONTEXT, Radix, ResponseConfig, Result, Route, Router, RouterContext, SERVER, SERVER_CONTEXT, STATES, Schema, Scope, Server, ServerContext, Source, States, StatusCode, Success, Template, Virtual, WILDCARD, WILDCARD_MATCH, WildcardNode, cookiePriorities, cookieSameSites, createServer, createStaticMiddleware, defineContext, defineHook, defineMiddleware, defineRoute, encodings, getState, httpMethods, invoke, isClient, isFailure, isServer, mergeObjects, mimeType, mimeTypes, parseCookiePair, parseSchema, sendBadRequest, sendCreated, sendForbidden, sendNoContent, sendNotFound, sendOk, sendRedirect, sendResponse, sendUnauthorized, setCookie, setState, statusCodes, useBody, useCookies, useHeaders, useParameters, useQuery, useRouter, useServer, useSetCookies, useUrl, withQuery };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { $ as useHeaders, A as encodings, B as sendCreated, C as WILDCARD, D as createServer, E as cookieSameSites, F as isServer, G as sendRedirect, H as sendNoContent, I as mimeType, J as setCookie, K as sendResponse, L as mimeTypes, M as httpMethods, N as invoke, O as defineMiddleware, P as isClient, Q as useCookies, R as parseCookiePair, S as STATES, T as cookiePriorities, U as sendNotFound, V as sendForbidden, W as sendOk, X as statusCodes, Y as setState, Z as useBody, _ as PARAMETER_MATCH, a as Hookable, at as useUrl, b as Router, c as defineHook, d as parseSchema, et as useParameters, f as OPTIONAL_PARAMETER, g as PARAMETER, h as OPTIONAL_WILDCARD_MATCH, i as SERVER, it as useSetCookies, j as getState, k as defineRoute, l as isFailure, m as OPTIONAL_WILDCARD, n as CLIENT, nt as useRouter, o as Scope, ot as withQuery, p as OPTIONAL_PARAMETER_MATCH, q as sendUnauthorized, r as CLOSE_HOOK, rt as useServer, s as defineContext, t as App, tt as useQuery, u as mergeObjects, v as ROUTER_CONTEXT, w as WILDCARD_MATCH, x as SERVER_CONTEXT, y as Radix, z as sendBadRequest } from "./app-
|
|
1
|
+
import { $ as useHeaders, A as encodings, B as sendCreated, C as WILDCARD, D as createServer, E as cookieSameSites, F as isServer, G as sendRedirect, H as sendNoContent, I as mimeType, J as setCookie, K as sendResponse, L as mimeTypes, M as httpMethods, N as invoke, O as defineMiddleware, P as isClient, Q as useCookies, R as parseCookiePair, S as STATES, T as cookiePriorities, U as sendNotFound, V as sendForbidden, W as sendOk, X as statusCodes, Y as setState, Z as useBody, _ as PARAMETER_MATCH, a as Hookable, at as useUrl, b as Router, c as defineHook, d as parseSchema, et as useParameters, f as OPTIONAL_PARAMETER, g as PARAMETER, h as OPTIONAL_WILDCARD_MATCH, i as SERVER, it as useSetCookies, j as getState, k as defineRoute, l as isFailure, m as OPTIONAL_WILDCARD, n as CLIENT, nt as useRouter, o as Scope, ot as withQuery, p as OPTIONAL_PARAMETER_MATCH, q as sendUnauthorized, r as CLOSE_HOOK, rt as useServer, s as defineContext, t as App, tt as useQuery, u as mergeObjects, v as ROUTER_CONTEXT, w as WILDCARD_MATCH, x as SERVER_CONTEXT, y as Radix, z as sendBadRequest } from "./app-DqEq3uwt.mjs";
|
|
2
|
+
import assets from "#assets";
|
|
2
3
|
//#region src/client/index.ts
|
|
3
4
|
async function $fetch(scope, input, options) {
|
|
4
5
|
let response;
|
|
@@ -41,4 +42,14 @@ async function $fetch(scope, input, options) {
|
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
//#endregion
|
|
44
|
-
|
|
45
|
+
//#region src/middleware/index.ts
|
|
46
|
+
function createStaticMiddleware(resolve) {
|
|
47
|
+
return defineMiddleware({ async fetch(scope, next) {
|
|
48
|
+
const { pathname } = useUrl(scope);
|
|
49
|
+
const asset = assets[pathname];
|
|
50
|
+
if (asset) return sendOk(scope, await resolve(asset.relative), { headers: new Headers({ "Content-Type": asset.type }) });
|
|
51
|
+
return next?.();
|
|
52
|
+
} });
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { $fetch, App, CLIENT, CLOSE_HOOK, Hookable, OPTIONAL_PARAMETER, OPTIONAL_PARAMETER_MATCH, OPTIONAL_WILDCARD, OPTIONAL_WILDCARD_MATCH, PARAMETER, PARAMETER_MATCH, ROUTER_CONTEXT, Radix, Router, SERVER, SERVER_CONTEXT, STATES, Scope, WILDCARD, WILDCARD_MATCH, cookiePriorities, cookieSameSites, createServer, createStaticMiddleware, defineContext, defineHook, defineMiddleware, defineRoute, encodings, getState, httpMethods, invoke, isClient, isFailure, isServer, mergeObjects, mimeType, mimeTypes, parseCookiePair, parseSchema, sendBadRequest, sendCreated, sendForbidden, sendNoContent, sendNotFound, sendOk, sendRedirect, sendResponse, sendUnauthorized, setCookie, setState, statusCodes, useBody, useCookies, useHeaders, useParameters, useQuery, useRouter, useServer, useSetCookies, useUrl, withQuery };
|
package/dist/kit/index.d.mts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as Content, h as Virtual, r as App } from "../index-nxflReVm.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/kit/index.d.ts
|
|
4
4
|
declare function useKit(source: string | URL): {
|
|
5
5
|
fromModule(...paths: Array<string>): string;
|
|
6
6
|
};
|
|
7
|
-
declare function addAlias(app: App, name: string, path: string): void;
|
|
8
7
|
declare function addTemplate(app: App, name: string, content: Content): void;
|
|
9
8
|
declare function addVirtual(app: App, name: string, virtual: Virtual): void;
|
|
10
9
|
declare function addRoutes(app: App, path: string): void;
|
|
11
10
|
declare function addMiddleware(app: App, path: string): void;
|
|
12
11
|
declare function addTypes(app: App, name: string, content: Content): void;
|
|
13
12
|
//#endregion
|
|
14
|
-
export {
|
|
13
|
+
export { addMiddleware, addRoutes, addTemplate, addTypes, addVirtual, useKit };
|
package/dist/kit/index.mjs
CHANGED
|
@@ -8,14 +8,11 @@ function useKit(source) {
|
|
|
8
8
|
return join(source, ...paths).split(win32.sep).join(posix.sep);
|
|
9
9
|
} };
|
|
10
10
|
}
|
|
11
|
-
function addAlias(app, name, path) {
|
|
12
|
-
app.config.build.alias["#alias/" + name] = path;
|
|
13
|
-
}
|
|
14
11
|
function addTemplate(app, name, content) {
|
|
15
|
-
app.config.
|
|
12
|
+
app.config.templates[name] = content;
|
|
16
13
|
}
|
|
17
14
|
function addVirtual(app, name, virtual) {
|
|
18
|
-
app.config.
|
|
15
|
+
app.config.virtuals["#" + name] = virtual;
|
|
19
16
|
}
|
|
20
17
|
function addRoutes(app, path) {
|
|
21
18
|
app.config.sources.routes?.entries.push(path);
|
|
@@ -27,4 +24,4 @@ function addTypes(app, name, content) {
|
|
|
27
24
|
addTemplate(app, `types/${name}.d.ts`, content);
|
|
28
25
|
}
|
|
29
26
|
//#endregion
|
|
30
|
-
export {
|
|
27
|
+
export { addMiddleware, addRoutes, addTemplate, addTypes, addVirtual, useKit };
|
package/dist/vite/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Bt as Mergeable, s as Config } from "../index-nxflReVm.mjs";
|
|
2
|
+
import { PluginOption } from "vite";
|
|
3
3
|
|
|
4
4
|
//#region src/vite/index.d.ts
|
|
5
5
|
interface Import {
|
|
@@ -8,6 +8,6 @@ interface Import {
|
|
|
8
8
|
path: string;
|
|
9
9
|
}
|
|
10
10
|
declare function toImportName(path: string): string;
|
|
11
|
-
declare function revojs(config?: Mergeable<Config>): Array<
|
|
11
|
+
declare function revojs(config?: Mergeable<Config>): Promise<Array<PluginOption>>;
|
|
12
12
|
//#endregion
|
|
13
13
|
export { Import, revojs, toImportName };
|
package/dist/vite/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { N as invoke, n as CLIENT, o as Scope, r as CLOSE_HOOK, t as App, u as mergeObjects, x as SERVER_CONTEXT } from "../app-
|
|
2
|
-
import { n as version, t as name } from "../package-
|
|
1
|
+
import { I as mimeType, N as invoke, n as CLIENT, o as Scope, r as CLOSE_HOOK, t as App, u as mergeObjects, x as SERVER_CONTEXT } from "../app-DqEq3uwt.mjs";
|
|
2
|
+
import { n as version, t as name } from "../package-DSa1C_1a.mjs";
|
|
3
3
|
import { addTemplate, addTypes, addVirtual, useKit } from "../kit/index.mjs";
|
|
4
4
|
import { basename, dirname, isAbsolute, join, posix, resolve, win32 } from "path";
|
|
5
|
-
import { mkdirSync, readFileSync, rmSync, writeFileSync } from "fs";
|
|
5
|
+
import { mkdirSync, readFileSync, rmSync, statSync, writeFileSync } from "fs";
|
|
6
6
|
import { cwd } from "process";
|
|
7
7
|
import { globSync } from "tinyglobby";
|
|
8
|
-
import { isRunnableDevEnvironment } from "vite";
|
|
8
|
+
import { isRunnableDevEnvironment, mergeConfig } from "vite";
|
|
9
9
|
import { once } from "events";
|
|
10
10
|
import { Readable } from "stream";
|
|
11
11
|
//#region src/vite/node/index.ts
|
|
@@ -141,8 +141,12 @@ function toHtmlTagDescriptor(template, injectTo) {
|
|
|
141
141
|
function toImportName(path) {
|
|
142
142
|
return path.replace(/\.[^/.]+$/, "").replace(/\[\[\.\.\.(.*?)\]\]/g, "$1").replace(/\[\.\.\.(.*?)\]/g, "$1").replace(/\[\[(.*?)\]\]/g, "$1").replace(/\[(.*?)\]/g, "$1").split("/").flatMap((segment) => segment.split(/[-_]/g)).filter(Boolean).map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1)).join("").replace(/[^a-zA-Z0-9_$]/g, "");
|
|
143
143
|
}
|
|
144
|
-
function revojs(config) {
|
|
144
|
+
async function revojs(config) {
|
|
145
145
|
const app = new App(config);
|
|
146
|
+
for (const module of app.config.modules) {
|
|
147
|
+
const result = await module.setup?.(app);
|
|
148
|
+
if (typeof result === "object") app.config = mergeObjects(app.config, result);
|
|
149
|
+
}
|
|
146
150
|
return [
|
|
147
151
|
{
|
|
148
152
|
name,
|
|
@@ -151,8 +155,6 @@ function revojs(config) {
|
|
|
151
155
|
api: { [name]: app },
|
|
152
156
|
async config() {
|
|
153
157
|
const { fromModule } = useKit(cwd());
|
|
154
|
-
for (const module of app.config.modules) app.config = mergeObjects(app.config, await module.config?.());
|
|
155
|
-
for (const module of app.config.modules) await module.setup?.(app);
|
|
156
158
|
addVirtual(app, "client", () => {
|
|
157
159
|
if (app.config.client) return `import client from "${fromModule(app.config.client)}?client"; export default client`;
|
|
158
160
|
});
|
|
@@ -178,15 +180,15 @@ function revojs(config) {
|
|
|
178
180
|
return content;
|
|
179
181
|
});
|
|
180
182
|
addTypes(app, name, () => {
|
|
181
|
-
let content = entries.reduce((content, entry) => content
|
|
183
|
+
let content = entries.reduce((content, entry) => content += `export declare const ${entry.import}: typeof import("${entry.path}") extends { default: infer D } ? D : typeof import("${entry.path}") \n`, "");
|
|
182
184
|
content += `declare const entries: { ${entries.map((entry) => `"${entry.name}": typeof ${entry.import}`)} } \n`;
|
|
183
185
|
content += `export default entries`;
|
|
184
|
-
return content
|
|
186
|
+
return `declare module "#${name}" { ${content} }`;
|
|
185
187
|
});
|
|
186
188
|
}
|
|
187
189
|
const meta = resolve(".revojs");
|
|
188
190
|
addTemplate(app, "index.d.ts", () => {
|
|
189
|
-
return Object.keys(app.config.
|
|
191
|
+
return Object.keys(app.config.templates).reduce((content, name) => {
|
|
190
192
|
if (name.startsWith("types/")) content += `import "./${name}" \n`;
|
|
191
193
|
return content;
|
|
192
194
|
}, "");
|
|
@@ -195,20 +197,15 @@ function revojs(config) {
|
|
|
195
197
|
recursive: true,
|
|
196
198
|
force: true
|
|
197
199
|
});
|
|
198
|
-
for (const template in app.config.
|
|
200
|
+
for (const template in app.config.templates) {
|
|
199
201
|
const path = join(meta, template);
|
|
200
202
|
mkdirSync(dirname(path), { recursive: true });
|
|
201
|
-
writeFileSync(path, app.config.
|
|
203
|
+
writeFileSync(path, await app.config.templates[template]());
|
|
202
204
|
}
|
|
203
|
-
return {
|
|
205
|
+
return mergeConfig({
|
|
204
206
|
appType: "custom",
|
|
205
207
|
optimizeDeps: { exclude: ["revojs"] },
|
|
206
|
-
|
|
207
|
-
build: {
|
|
208
|
-
emptyOutDir: false,
|
|
209
|
-
assetsInlineLimit: 4096 * 4,
|
|
210
|
-
rolldownOptions: { external: app.config.build.externals }
|
|
211
|
-
},
|
|
208
|
+
build: { emptyOutDir: false },
|
|
212
209
|
define: Object.entries(app.config.variables).reduce((variables, [name, value]) => ({
|
|
213
210
|
...variables,
|
|
214
211
|
[`import.meta.${name}`]: value
|
|
@@ -230,7 +227,6 @@ function revojs(config) {
|
|
|
230
227
|
environments: {
|
|
231
228
|
...app.config.client && { ["client"]: {
|
|
232
229
|
consumer: "client",
|
|
233
|
-
resolve: { noExternal: true },
|
|
234
230
|
build: {
|
|
235
231
|
rolldownOptions: { input: app.config.client },
|
|
236
232
|
outDir: "./dist/public",
|
|
@@ -259,7 +255,7 @@ function revojs(config) {
|
|
|
259
255
|
}
|
|
260
256
|
} }
|
|
261
257
|
}
|
|
262
|
-
};
|
|
258
|
+
}, app.config.vite);
|
|
263
259
|
},
|
|
264
260
|
transformIndexHtml: {
|
|
265
261
|
order: "pre",
|
|
@@ -273,6 +269,21 @@ function revojs(config) {
|
|
|
273
269
|
}
|
|
274
270
|
},
|
|
275
271
|
configResolved(config) {
|
|
272
|
+
addVirtual(app, "assets", () => {
|
|
273
|
+
const client = config.environments[CLIENT].build.outDir;
|
|
274
|
+
return `export default { ${globSync("**/*", { cwd: client }).reduce((assets, path) => {
|
|
275
|
+
const meta = statSync(join(client, path));
|
|
276
|
+
assets.push({
|
|
277
|
+
type: mimeType(path),
|
|
278
|
+
name: path,
|
|
279
|
+
relative: `./public/${path}`,
|
|
280
|
+
entityTag: `W/"${meta.size.toString(16)}-${Math.floor(meta.mtimeMs).toString(16)}"`,
|
|
281
|
+
lastModified: meta.mtime.toJSON(),
|
|
282
|
+
size: meta.size
|
|
283
|
+
});
|
|
284
|
+
return assets;
|
|
285
|
+
}, new Array()).map((asset) => `"/${asset.name}": ${JSON.stringify(asset)}`)} }`;
|
|
286
|
+
});
|
|
276
287
|
if (app.config.client === void 0) delete config.environments[CLIENT];
|
|
277
288
|
if (app.config.server === void 0) delete config.environments["ssr"];
|
|
278
289
|
},
|
|
@@ -301,8 +312,9 @@ function revojs(config) {
|
|
|
301
312
|
}
|
|
302
313
|
}
|
|
303
314
|
},
|
|
304
|
-
virtuals(app.config.
|
|
305
|
-
client()
|
|
315
|
+
virtuals(app.config.virtuals),
|
|
316
|
+
client(),
|
|
317
|
+
app.config.vite.plugins
|
|
306
318
|
];
|
|
307
319
|
}
|
|
308
320
|
//#endregion
|
package/package.json
CHANGED