@kosmojs/dev 0.3.0 → 0.4.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/package.json +10 -9
- package/pkg/assets/pkg-DU-tTiIp.js +465 -0
- package/pkg/assets/pkg-DU-tTiIp.js.map +1 -0
- package/pkg/chassis.js +1 -309
- package/pkg/chassis.js.map +1 -1
- package/pkg/index.d.ts +2 -0
- package/pkg/index.js +1299 -693
- package/pkg/index.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@kosmojs/dev",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.0",
|
|
5
5
|
"cacheVersion": "001",
|
|
6
6
|
"author": "Slee Woo",
|
|
7
7
|
"license": "MIT",
|
|
@@ -26,32 +26,33 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@mdx-js/rollup": "^3.1.1",
|
|
29
|
-
"@sveltejs/vite-plugin-svelte": "^7.
|
|
30
|
-
"@vitejs/plugin-react": "^6.0
|
|
29
|
+
"@sveltejs/vite-plugin-svelte": "^7.3.0",
|
|
30
|
+
"@vitejs/plugin-react": "^6.1.0",
|
|
31
31
|
"@vitejs/plugin-vue": "^6.0.8",
|
|
32
32
|
"crc": "^4.3.2",
|
|
33
33
|
"path-to-regexp": "^8.4.2",
|
|
34
34
|
"semver": "^7.8.5",
|
|
35
|
-
"typebox": "^1.3.
|
|
36
|
-
"vite": "^8.2.
|
|
35
|
+
"typebox": "^1.3.16",
|
|
36
|
+
"vite": "^8.2.2",
|
|
37
37
|
"vite-plugin-solid": "^2.11.14",
|
|
38
38
|
"yaml": "^2.9.0",
|
|
39
|
-
"@kosmojs/
|
|
40
|
-
"@kosmojs/
|
|
39
|
+
"@kosmojs/core": "^0.4.0",
|
|
40
|
+
"@kosmojs/lib": "^0.4.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@kosmojs/core-generator": "^0.3.0",
|
|
44
|
+
"@kosmojs/h3-generator": "^0.3.0",
|
|
44
45
|
"@kosmojs/fetch-generator": "^0.3.0",
|
|
45
46
|
"@kosmojs/hono-generator": "^0.3.0",
|
|
46
47
|
"@kosmojs/koa-generator": "^0.3.0",
|
|
47
48
|
"@kosmojs/mdx-generator": "^0.3.0",
|
|
48
|
-
"@kosmojs/react-generator": "^0.3.0",
|
|
49
49
|
"@kosmojs/openapi-generator": "^0.3.0",
|
|
50
50
|
"@kosmojs/solid-generator": "^0.3.0",
|
|
51
|
+
"@kosmojs/react-generator": "^0.3.0",
|
|
52
|
+
"@kosmojs/ssg-generator": "^0.3.0",
|
|
51
53
|
"@kosmojs/ssr-generator": "^0.3.0",
|
|
52
54
|
"@kosmojs/svelte-generator": "^0.3.0",
|
|
53
55
|
"@kosmojs/typebox-generator": "^0.3.0",
|
|
54
|
-
"@kosmojs/ssg-generator": "^0.3.0",
|
|
55
56
|
"@kosmojs/vue-generator": "^0.3.0"
|
|
56
57
|
},
|
|
57
58
|
"scripts": {
|
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
import{dirname as e,resolve as t}from"node:path";import{styleText as n}from"node:util";import{defaults as r}from"@kosmojs/core";import{defineGenerator as i,defineGeneratorFactory as a,pathResolver as o,renderFactory as s,renderToFile as c}from"@kosmojs/lib";import l from"semver";import{routeRenderHelpers as u}from"@kosmojs/core/generators";var d={type:`module`,private:!0,name:`@kosmojs/core-generator`,version:`0.3.0`,author:`Slee Woo`,license:`MIT`,files:[`pkg/*`],exports:{".":{types:`./pkg/index.d.ts`,default:`./pkg/index.js`}},scripts:{build:`wsbuild src/index.ts`},dependencies:{"@kosmojs/core":`workspace:^`,"@kosmojs/lib":`workspace:^`,semver:`^7.8.5`},devDependencies:{"@types/semver":`^7.8.0`,"path-to-regexp":`^8.4.2`}},f=`export const base = "{{config.base}}";
|
|
2
|
+
export const apiBase = "{{config.apiBase}}";
|
|
3
|
+
`,p=`export * from "./config";
|
|
4
|
+
export * from "./routes";
|
|
5
|
+
`,m=`{{> routeMapperPartial}}
|
|
6
|
+
|
|
7
|
+
import { base, apiBase } from "./config";
|
|
8
|
+
|
|
9
|
+
// used by backend generators and fetch clients
|
|
10
|
+
export const apiRouteMap = {
|
|
11
|
+
{{#each apiRoutes}}
|
|
12
|
+
"{{name}}": apiRouteMapper<[{{serializeParamsTupleElements .}}]>(
|
|
13
|
+
apiBase,
|
|
14
|
+
{{serializeApiRoute .}},
|
|
15
|
+
),
|
|
16
|
+
{{/each}}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// used by frontend generators on Link component
|
|
20
|
+
export const pageRouteMap = {
|
|
21
|
+
{{#each pageRoutes}}
|
|
22
|
+
"{{name}}": pageRouteMapper<[{{serializeParamsTupleElements .}}]>(
|
|
23
|
+
base,
|
|
24
|
+
{{serializePageRoute .}},
|
|
25
|
+
),
|
|
26
|
+
{{/each}}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
{{#if pageRoutes.length}}
|
|
30
|
+
export type LinkProps =
|
|
31
|
+
{{#each pageRoutes}}
|
|
32
|
+
| [ "{{name}}", {{serializeParamsTupleElements .}} ]
|
|
33
|
+
{{/each}};
|
|
34
|
+
{{else}}
|
|
35
|
+
export type LinkProps = never;
|
|
36
|
+
{{/if}}
|
|
37
|
+
`,h=`import { compile, match } from "path-to-regexp";
|
|
38
|
+
|
|
39
|
+
import {
|
|
40
|
+
type ApiRouteSerialized,
|
|
41
|
+
type PageRouteSerialized,
|
|
42
|
+
stringifySearchParams,
|
|
43
|
+
type ValidationTarget,
|
|
44
|
+
} from "@kosmojs/core";
|
|
45
|
+
import type { HTTPMethod } from "@kosmojs/core/api";
|
|
46
|
+
import { createHost, type HostOpt, join } from "@kosmojs/core/fetch";
|
|
47
|
+
|
|
48
|
+
export const apiRouteMapper = <ParamsT extends readonly unknown[]>(
|
|
49
|
+
basePath: string,
|
|
50
|
+
{ name, pathPattern, params, numericProperties }: ApiRouteSerialized,
|
|
51
|
+
) => {
|
|
52
|
+
const toPath = compile(pathPattern);
|
|
53
|
+
const pathMatcher = match(join(basePath, pathPattern));
|
|
54
|
+
|
|
55
|
+
const maybeNumber = (val: unknown) => {
|
|
56
|
+
if (val === undefined || val === null) {
|
|
57
|
+
return val;
|
|
58
|
+
}
|
|
59
|
+
const n = Number(val);
|
|
60
|
+
return Number.isFinite(n) ? n : val;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const resolveParam = (path: string, param: (typeof params)[number]) => {
|
|
64
|
+
try {
|
|
65
|
+
const match = pathMatcher(path);
|
|
66
|
+
return match ? match.params[param] : undefined;
|
|
67
|
+
} catch (e) {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const normalizeSearchParams = (
|
|
73
|
+
searchParams: Record<string, unknown>,
|
|
74
|
+
method: HTTPMethod,
|
|
75
|
+
) => {
|
|
76
|
+
return Object.fromEntries(
|
|
77
|
+
Object.entries(searchParams).map(([k, v]) => [
|
|
78
|
+
k,
|
|
79
|
+
numericProperties.query?.[method]?.includes(k)
|
|
80
|
+
? Array.isArray(v)
|
|
81
|
+
? v.map((e) => maybeNumber(e))
|
|
82
|
+
: maybeNumber(v)
|
|
83
|
+
: v,
|
|
84
|
+
]),
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const normalizeParams = (path: string) => {
|
|
89
|
+
return params.reduce((map: Record<string, unknown>, param) => {
|
|
90
|
+
const value = resolveParam(path, param);
|
|
91
|
+
if (Array.isArray(value)) {
|
|
92
|
+
map[param] = numericProperties.params.includes(param)
|
|
93
|
+
? value.map((e) => maybeNumber(e))
|
|
94
|
+
: value;
|
|
95
|
+
} else if (value) {
|
|
96
|
+
map[param] = numericProperties.params.includes(param)
|
|
97
|
+
? maybeNumber(value)
|
|
98
|
+
: value;
|
|
99
|
+
}
|
|
100
|
+
return map;
|
|
101
|
+
}, {});
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const paramsMapper = (input: ParamsT, opt?: { coerceNumbers?: boolean }) => {
|
|
105
|
+
return params.reduce<Record<string, unknown>>((map, name, i) => {
|
|
106
|
+
const coerceNumbers = opt?.coerceNumbers
|
|
107
|
+
? numericProperties.params.includes(name)
|
|
108
|
+
: false;
|
|
109
|
+
if (Array.isArray(input[i])) {
|
|
110
|
+
map[name] = coerceNumbers
|
|
111
|
+
? input[i].map((v) => maybeNumber(v))
|
|
112
|
+
: input[i].map(String);
|
|
113
|
+
} else if (input[i] !== undefined) {
|
|
114
|
+
map[name] = coerceNumbers ? maybeNumber(input[i]) : String(input[i]);
|
|
115
|
+
}
|
|
116
|
+
return map;
|
|
117
|
+
}, {});
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const parametrize = (params: ParamsT) => {
|
|
121
|
+
try {
|
|
122
|
+
return toPath(paramsMapper(params) as never);
|
|
123
|
+
} catch (error) {
|
|
124
|
+
console.error(\`❗ERROR: Failed building path for \${name}\`);
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const base = (params: ParamsT, query?: Record<string, unknown>) => {
|
|
130
|
+
const path = join("/", parametrize(params));
|
|
131
|
+
return query ? [path, stringifySearchParams(query)].join("?") : path;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const path = (params: ParamsT, query?: Record<string, unknown>) => {
|
|
135
|
+
return join(basePath, base(params, query));
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const href = (
|
|
139
|
+
host: HostOpt,
|
|
140
|
+
params: ParamsT,
|
|
141
|
+
query?: Record<string, unknown>,
|
|
142
|
+
) => {
|
|
143
|
+
return createHost(host) + path(params, query);
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const payloadResolver = <T>(
|
|
147
|
+
payload: Record<ValidationTarget, T> | undefined,
|
|
148
|
+
target: ValidationTarget,
|
|
149
|
+
method: HTTPMethod,
|
|
150
|
+
) => {
|
|
151
|
+
const data = payload?.[target];
|
|
152
|
+
|
|
153
|
+
if (target === "query") {
|
|
154
|
+
return Object.fromEntries(
|
|
155
|
+
Object.entries({ ...data }).map(([k, v]) => {
|
|
156
|
+
return [
|
|
157
|
+
k,
|
|
158
|
+
numericProperties.query[method]?.includes(k)
|
|
159
|
+
? Array.isArray(v)
|
|
160
|
+
? v.map((v) => maybeNumber(v))
|
|
161
|
+
: maybeNumber(v)
|
|
162
|
+
: v,
|
|
163
|
+
];
|
|
164
|
+
}),
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (data instanceof FormData) {
|
|
169
|
+
return [...data].reduce<
|
|
170
|
+
Record<string, FormDataEntryValue | Array<FormDataEntryValue>>
|
|
171
|
+
>((map, [key, val]) => {
|
|
172
|
+
if (key in map) {
|
|
173
|
+
map[key] = [map[key]].flat().concat(val);
|
|
174
|
+
} else {
|
|
175
|
+
map[key] = val;
|
|
176
|
+
}
|
|
177
|
+
return map;
|
|
178
|
+
}, {}) as T;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return data;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
return {
|
|
185
|
+
normalizeParams,
|
|
186
|
+
normalizeSearchParams,
|
|
187
|
+
paramsMapper,
|
|
188
|
+
parametrize,
|
|
189
|
+
base,
|
|
190
|
+
path,
|
|
191
|
+
href,
|
|
192
|
+
payloadResolver,
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
export const pageRouteMapper = <ParamsT extends readonly unknown[]>(
|
|
197
|
+
basePath: string,
|
|
198
|
+
route: PageRouteSerialized,
|
|
199
|
+
) => {
|
|
200
|
+
const toPath = compile(route.pathPattern);
|
|
201
|
+
|
|
202
|
+
const paramsMapper = (params: ParamsT) => {
|
|
203
|
+
return route.params.reduce<Record<string, unknown>>((map, name, i) => {
|
|
204
|
+
if (Array.isArray(params[i])) {
|
|
205
|
+
map[name] = params[i].map(String);
|
|
206
|
+
} else if (params[i] !== undefined) {
|
|
207
|
+
map[name] = String(params[i]);
|
|
208
|
+
}
|
|
209
|
+
return map;
|
|
210
|
+
}, {});
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
const parametrize = (params: ParamsT) => {
|
|
214
|
+
try {
|
|
215
|
+
return toPath(paramsMapper(params) as never);
|
|
216
|
+
} catch (error) {
|
|
217
|
+
console.error(\`❗ERROR: Failed building path for \${route.name}\`);
|
|
218
|
+
throw error;
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
const base = (params: ParamsT, query?: Record<string, unknown>) => {
|
|
223
|
+
const path = join("/", parametrize(params));
|
|
224
|
+
return query ? [path, stringifySearchParams(query)].join("?") : path;
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
const path = (params: ParamsT, query?: Record<string, unknown>) => {
|
|
228
|
+
return join(basePath, base(params, query));
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
const href = (
|
|
232
|
+
host: HostOpt,
|
|
233
|
+
params: ParamsT,
|
|
234
|
+
query?: Record<string, unknown>,
|
|
235
|
+
) => {
|
|
236
|
+
return createHost(host) + path(params, query);
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
return {
|
|
240
|
+
paramsMapper,
|
|
241
|
+
parametrize,
|
|
242
|
+
base,
|
|
243
|
+
path,
|
|
244
|
+
href,
|
|
245
|
+
};
|
|
246
|
+
};
|
|
247
|
+
`,g=`declare const KOSMO_PRODUCTION_BUILD: boolean;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Enhances base TypeScript types with JSON Schema validation constraints.
|
|
251
|
+
* Allows declaring refined types that carry validation metadata for runtime
|
|
252
|
+
* schema validation while maintaining full TypeScript type safety.
|
|
253
|
+
*
|
|
254
|
+
* Useful for generating validation schemas and ensuring
|
|
255
|
+
* data conforms to specific business rules beyond basic type checking.
|
|
256
|
+
* */
|
|
257
|
+
declare type VRefine<
|
|
258
|
+
T extends unknown[] | number | string | object,
|
|
259
|
+
_ extends T extends unknown[]
|
|
260
|
+
? TArrayOptions
|
|
261
|
+
: T extends number
|
|
262
|
+
? TNumberOptions
|
|
263
|
+
: T extends string
|
|
264
|
+
? TStringOptions
|
|
265
|
+
: TObjectOptions,
|
|
266
|
+
> = T;
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Type definitions inspired by and gently adapted from TypeBox.
|
|
270
|
+
* Original TypeBox created by sinclairzx81: https://github.com/sinclairzx81/typebox
|
|
271
|
+
* TypeBox is licensed under MIT: https://github.com/sinclairzx81/typebox/blob/main/license
|
|
272
|
+
*
|
|
273
|
+
* These types provide JSON Schema compatible type refinements for TypeScript.
|
|
274
|
+
* */
|
|
275
|
+
interface TSchema {}
|
|
276
|
+
|
|
277
|
+
// ------------------------------------------------------------------
|
|
278
|
+
// ObjectOptions
|
|
279
|
+
// ------------------------------------------------------------------
|
|
280
|
+
interface TObjectOptions {
|
|
281
|
+
/**
|
|
282
|
+
* Defines whether additional properties are allowed beyond those explicitly defined in \`properties\`.
|
|
283
|
+
*/
|
|
284
|
+
additionalProperties?: TSchema | boolean;
|
|
285
|
+
/**
|
|
286
|
+
* The minimum number of properties required in the object.
|
|
287
|
+
*/
|
|
288
|
+
minProperties?: number;
|
|
289
|
+
/**
|
|
290
|
+
* The maximum number of properties allowed in the object.
|
|
291
|
+
*/
|
|
292
|
+
maxProperties?: number;
|
|
293
|
+
/**
|
|
294
|
+
* Defines conditional requirements for properties.
|
|
295
|
+
*/
|
|
296
|
+
dependencies?: Record<string, boolean | TSchema | string[]>;
|
|
297
|
+
/**
|
|
298
|
+
* Specifies properties that *must* be present if a given property is present.
|
|
299
|
+
*/
|
|
300
|
+
dependentRequired?: Record<string, string[]>;
|
|
301
|
+
/**
|
|
302
|
+
* Defines schemas that apply if a specific property is present.
|
|
303
|
+
*/
|
|
304
|
+
dependentSchemas?: Record<string, TSchema>;
|
|
305
|
+
/**
|
|
306
|
+
* Maps regular expressions to schemas properties matching a pattern must validate against the schema.
|
|
307
|
+
*/
|
|
308
|
+
patternProperties?: Record<string, TSchema>;
|
|
309
|
+
/**
|
|
310
|
+
* A schema that all property names within the object must validate against.
|
|
311
|
+
*/
|
|
312
|
+
propertyNames?: TSchema;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// ------------------------------------------------------------------
|
|
316
|
+
// ArrayOptions
|
|
317
|
+
// ------------------------------------------------------------------
|
|
318
|
+
interface TArrayOptions {
|
|
319
|
+
/**
|
|
320
|
+
* The minimum number of items allowed in the array.
|
|
321
|
+
*/
|
|
322
|
+
minItems?: number;
|
|
323
|
+
/**
|
|
324
|
+
* The maximum number of items allowed in the array.
|
|
325
|
+
*/
|
|
326
|
+
maxItems?: number;
|
|
327
|
+
/**
|
|
328
|
+
* A schema that at least one item in the array must validate against.
|
|
329
|
+
*/
|
|
330
|
+
contains?: TSchema;
|
|
331
|
+
/**
|
|
332
|
+
* The minimum number of array items that must validate against the \`contains\` schema.
|
|
333
|
+
*/
|
|
334
|
+
minContains?: number;
|
|
335
|
+
/**
|
|
336
|
+
* The maximum number of array items that may validate against the \`contains\` schema.
|
|
337
|
+
*/
|
|
338
|
+
maxContains?: number;
|
|
339
|
+
/**
|
|
340
|
+
* An array of schemas, where each schema in \`prefixItems\` validates against items at corresponding positions from the beginning of the array.
|
|
341
|
+
*/
|
|
342
|
+
prefixItems?: TSchema[];
|
|
343
|
+
/**
|
|
344
|
+
* If \`true\`, all items in the array must be unique.
|
|
345
|
+
*/
|
|
346
|
+
uniqueItems?: boolean;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// ------------------------------------------------------------------
|
|
350
|
+
// NumberOptions
|
|
351
|
+
// ------------------------------------------------------------------
|
|
352
|
+
interface TNumberOptions {
|
|
353
|
+
/**
|
|
354
|
+
* Specifies an exclusive upper limit for the number (number must be less than this value).
|
|
355
|
+
*/
|
|
356
|
+
exclusiveMaximum?: number | bigint;
|
|
357
|
+
/**
|
|
358
|
+
* Specifies an exclusive lower limit for the number (number must be greater than this value).
|
|
359
|
+
*/
|
|
360
|
+
exclusiveMinimum?: number | bigint;
|
|
361
|
+
/**
|
|
362
|
+
* Specifies an inclusive upper limit for the number (number must be less than or equal to this value).
|
|
363
|
+
*/
|
|
364
|
+
maximum?: number | bigint;
|
|
365
|
+
/**
|
|
366
|
+
* Specifies an inclusive lower limit for the number (number must be greater than or equal to this value).
|
|
367
|
+
*/
|
|
368
|
+
minimum?: number | bigint;
|
|
369
|
+
/**
|
|
370
|
+
* Specifies that the number must be a multiple of this value.
|
|
371
|
+
*/
|
|
372
|
+
multipleOf?: number | bigint;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// ------------------------------------------------------------------
|
|
376
|
+
// StringOptions
|
|
377
|
+
// ------------------------------------------------------------------
|
|
378
|
+
type TFormat =
|
|
379
|
+
| "date-time"
|
|
380
|
+
| "date"
|
|
381
|
+
| "duration"
|
|
382
|
+
| "email"
|
|
383
|
+
| "hostname"
|
|
384
|
+
| "idn-email"
|
|
385
|
+
| "idn-hostname"
|
|
386
|
+
| "ipv4"
|
|
387
|
+
| "ipv6"
|
|
388
|
+
| "iri-reference"
|
|
389
|
+
| "iri"
|
|
390
|
+
| "json-pointer-uri-fragment"
|
|
391
|
+
| "json-pointer"
|
|
392
|
+
| "json-string"
|
|
393
|
+
| "regex"
|
|
394
|
+
| "relative-json-pointer"
|
|
395
|
+
| "time"
|
|
396
|
+
| "uri-reference"
|
|
397
|
+
| "uri-template"
|
|
398
|
+
| "url"
|
|
399
|
+
| "uuid";
|
|
400
|
+
|
|
401
|
+
interface TStringOptions {
|
|
402
|
+
/**
|
|
403
|
+
* Specifies the expected string format.
|
|
404
|
+
*
|
|
405
|
+
* Common values include:
|
|
406
|
+
* - \`base64\` – Base64-encoded string.
|
|
407
|
+
* - \`date-time\` – [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time format.
|
|
408
|
+
* - \`date\` – [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date (YYYY-MM-DD).
|
|
409
|
+
* - \`duration\` – [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) duration format.
|
|
410
|
+
* - \`email\` – RFC 5321/5322 compliant email address.
|
|
411
|
+
* - \`hostname\` – RFC 1034/1035 compliant host name.
|
|
412
|
+
* - \`idn-email\` – Internationalized email address.
|
|
413
|
+
* - \`idn-hostname\` – Internationalized host name.
|
|
414
|
+
* - \`ipv4\` – IPv4 address.
|
|
415
|
+
* - \`ipv6\` – IPv6 address.
|
|
416
|
+
* - \`iri\` / \`iri-reference\` – Internationalized Resource Identifier.
|
|
417
|
+
* - \`json-pointer\` / \`json-pointer-uri-fragment\` – JSON Pointer format.
|
|
418
|
+
* - \`json-string\` – String containing valid JSON.
|
|
419
|
+
* - \`regex\` – Regular expression syntax.
|
|
420
|
+
* - \`relative-json-pointer\` – Relative JSON Pointer format.
|
|
421
|
+
* - \`time\` – [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) time (HH:MM:SS).
|
|
422
|
+
* - \`uri-reference\` / \`uri-template\` – URI reference or template.
|
|
423
|
+
* - \`url\` – Web URL format.
|
|
424
|
+
* - \`uuid\` – RFC 4122 UUID string.
|
|
425
|
+
*
|
|
426
|
+
* May also be a custom format string.
|
|
427
|
+
*/
|
|
428
|
+
format?: TFormat;
|
|
429
|
+
/**
|
|
430
|
+
* Specifies the minimum number of characters allowed in the string.
|
|
431
|
+
* Must be a non-negative integer.
|
|
432
|
+
*/
|
|
433
|
+
minLength?: number;
|
|
434
|
+
/**
|
|
435
|
+
* Specifies the maximum number of characters allowed in the string.
|
|
436
|
+
* Must be a non-negative integer.
|
|
437
|
+
*/
|
|
438
|
+
maxLength?: number;
|
|
439
|
+
/**
|
|
440
|
+
* Specifies a regular expression pattern that the string value must match.
|
|
441
|
+
* Can be provided as a string (ECMA-262 regex syntax) or a \`RegExp\` object.
|
|
442
|
+
*/
|
|
443
|
+
pattern?: string | RegExp;
|
|
444
|
+
}
|
|
445
|
+
`,_=`# Ignore all files
|
|
446
|
+
*
|
|
447
|
+
|
|
448
|
+
# But don't ignore directories (so Git can traverse them)
|
|
449
|
+
!*/
|
|
450
|
+
|
|
451
|
+
# And don't ignore these files at any depth
|
|
452
|
+
!cache.json
|
|
453
|
+
!types.ts
|
|
454
|
+
`,v=`export declare global {
|
|
455
|
+
interface Window {
|
|
456
|
+
__KOSMO_HYDRATION_BOOL__: boolean;
|
|
457
|
+
__KOSMO_HYDRATION_DATA__: Record<string, unknown> | undefined;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
`,y=`// stub schemas, specialized generators supposed to overwrite this file
|
|
461
|
+
import type { ValidationSchemas } from "@kosmojs/core/api";
|
|
462
|
+
export type { ValidationSchemas };
|
|
463
|
+
export const validationSchemas: ValidationSchemas = {};
|
|
464
|
+
`,b=e=>{let t="${configDir}",n={types:[`@types/node`,`vite/client`],moduleResolution:`bundler`,module:`ESNext`,target:`ESNext`,strict:!0,exactOptionalPropertyTypes:!0,noImplicitAny:!0,noImplicitThis:!0,noImplicitOverride:!0,noImplicitReturns:!0,noUnusedLocals:!1,noUnusedParameters:!1,allowArbitraryExtensions:!0,allowImportingTsExtensions:!0,allowUnreachableCode:!1,allowUnusedLabels:!1,useUnknownInCatchVariables:!0,noFallthroughCasesInSwitch:!0,noUncheckedSideEffectImports:!0,resolveJsonModule:!0,esModuleInterop:!0,verbatimModuleSyntax:!0,skipLibCheck:!0,noEmit:!0};return e?{include:[`${t}/`,`${t}/../../${r.libDir}/${e}/`,`${t}/../../**/*.d.ts`],compilerOptions:{...n,types:[...n.types],paths:{[`${r.appPrefix}/*`]:[`${t}/../../*`],[`${r.srcPrefix}/*`]:[`${t}/*`],[`${r.libPrefix}/*`]:[`${t}/../../${r.libDir}/${e}/*`]}}}:{include:[`${t}/`],exclude:[`${t}/${r.srcDir}/`],compilerOptions:{...n,paths:{[`${r.appPrefix}/*`]:[`${t}/*`]}}}},x=a(i=>{let{createPath:a,createImportHelpers:d}=o(i),x=async()=>{let{generators:e=[]}=i.config;{let{dependencies:r={},devDependencies:a={}}=await import(t(i.root,`package.json`),{with:{type:`json`}}).then(e=>e.default),o=[],s=[],c=e.flatMap(e=>[`dependencies`,`devDependencies`].flatMap(t=>e[t]?Object.entries(typeof e[t]==`function`?e[t](e.options):e[t]).flatMap(([e,n])=>{let r=l.minVersion(n)?.version;return r?[[e,r,t]]:[]}):[]));for(let[e,t,n]of c){let i=r[e]||a[e],c=i?l.minVersion(i)?.version:void 0;!i||!c?o.push([e,t,n]):l.lt(c,t)&&s.push([e,t,n])}if(o.length){console.error(n([`red`,`italic`],`There are ${o.length} missing dependencies, please consider installing them.`));for(let e of[`dependencies`,`devDependencies`]){let t=o.filter(t=>t[2]===e);t.length&&console.error(`${e}: ${n([`blue`],t.map(([e])=>e).join(` `))}`)}}s.length&&(console.error(n([`yellow`,`italic`],`There are ${s.length} outdated dependencies, please consider updating them:`)),console.error(s.map(([e])=>e).join(` `)),console.error())}{await c(t(i.root,`tsconfig.json`),JSON.stringify({extends:`./${r.libDir}/tsconfig.json`},void 0,2),{},{overwrite:!1}),await c(a.lib(`../tsconfig.json`),JSON.stringify(b(),void 0,2),{}),await c(a.src(`tsconfig.json`),JSON.stringify({extends:`../../${r.libDir}/${i.name}/tsconfig.json`},void 0,2),{},{overwrite:!1});let e=b(i.name),n={},o=new Set(e.compilerOptions.types||[]);for(let{meta:e}of i.config.generators||[]){e.jsx&&(n.jsx=e.jsx),e.jsxImportSource&&(n.jsxImportSource=e.jsxImportSource);for(let t of e.types||[])o.add(t)}await c(a.lib(`tsconfig.json`),JSON.stringify({...e,compilerOptions:{...e.compilerOptions,...n,types:[...o.values()]}},void 0,2),{})}for(let[e,t]of[[`env.d.ts`,g],[`global.d.ts`,v]])await c(a.lib(`../${e}`),t,{});await c(a.lib(`../.gitignore`),_,{},{overwrite:!1});for(let[e,t]of[[`ssg.ts`,`export default [];`]])await c(a.lib(e),t,{})},S=async t=>{let{renderToFile:n}=s({helpers:{...d({origin:`lib`}),...u()},partials:{routeMapperPartial:h}});await n(a.libCore(`routes.ts`),m,{apiRoutes:t.flatMap(({kind:e,entry:t})=>e===`apiRoute`?[t]:[]),pageRoutes:t.flatMap(({kind:e,entry:t})=>e===`pageRoute`?[t]:[])});for(let[e,t]of[[`config.ts`,f],[`index.ts`,p]])await n(a.libCore(e),t,i);for(let{kind:r,entry:i}of t)r===`apiRoute`&&await n(a.libApi(e(i.file),`schemas.ts`),y,{route:i},{overwrite:!1})};return{start:x,watch:S,build:S}}),S=i({meta:{name:`Core`},dependencies:{"path-to-regexp":d.devDependencies[`path-to-regexp`]},factory:x});export{S as t};
|
|
465
|
+
//# sourceMappingURL=pkg-DU-tTiIp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pkg-DU-tTiIp.js","names":["l","t","n","o","s","i","r","u","a","e"],"sources":["../../../../generators/core-generator/pkg/index.js"],"sourcesContent":["import{defineGenerator as e,defineGeneratorFactory as t,pathResolver as n,renderFactory as r,renderToFile as i}from\"@kosmojs/lib\";import{dirname as a,resolve as o}from\"node:path\";import{styleText as s}from\"node:util\";import c from\"semver\";import{defaults as l}from\"@kosmojs/core\";import{routeRenderHelpers as u}from\"@kosmojs/core/generators\";var d={type:`module`,private:!0,name:`@kosmojs/core-generator`,version:`0.3.0`,author:`Slee Woo`,license:`MIT`,files:[`pkg/*`],exports:{\".\":{types:`./pkg/index.d.ts`,default:`./pkg/index.js`}},scripts:{build:`wsbuild src/index.ts`},dependencies:{\"@kosmojs/core\":`workspace:^`,\"@kosmojs/lib\":`workspace:^`,semver:`^7.8.5`},devDependencies:{\"@types/semver\":`^7.8.0`,\"path-to-regexp\":`^8.4.2`}},f=`export const base = \"{{config.base}}\";\nexport const apiBase = \"{{config.apiBase}}\";\n`,p=`export * from \"./config\";\nexport * from \"./routes\";\n`,m=`{{> routeMapperPartial}}\n\nimport { base, apiBase } from \"./config\";\n\n// used by backend generators and fetch clients\nexport const apiRouteMap = {\n {{#each apiRoutes}}\n \"{{name}}\": apiRouteMapper<[{{serializeParamsTupleElements .}}]>(\n apiBase,\n {{serializeApiRoute .}},\n ),\n {{/each}}\n};\n\n// used by frontend generators on Link component\nexport const pageRouteMap = {\n {{#each pageRoutes}}\n \"{{name}}\": pageRouteMapper<[{{serializeParamsTupleElements .}}]>(\n base,\n {{serializePageRoute .}},\n ),\n {{/each}}\n};\n\n{{#if pageRoutes.length}}\nexport type LinkProps =\n {{#each pageRoutes}}\n | [ \"{{name}}\", {{serializeParamsTupleElements .}} ]\n {{/each}};\n{{else}}\nexport type LinkProps = never;\n{{/if}}\n`,h=`import { compile, match } from \"path-to-regexp\";\n\nimport {\n type ApiRouteSerialized,\n type PageRouteSerialized,\n stringifySearchParams,\n type ValidationTarget,\n} from \"@kosmojs/core\";\nimport type { HTTPMethod } from \"@kosmojs/core/api\";\nimport { createHost, type HostOpt, join } from \"@kosmojs/core/fetch\";\n\nexport const apiRouteMapper = <ParamsT extends readonly unknown[]>(\n basePath: string,\n { name, pathPattern, params, numericProperties }: ApiRouteSerialized,\n) => {\n const toPath = compile(pathPattern);\n const pathMatcher = match(join(basePath, pathPattern));\n\n const maybeNumber = (val: unknown) => {\n if (val === undefined || val === null) {\n return val;\n }\n const n = Number(val);\n return Number.isFinite(n) ? n : val;\n };\n\n const resolveParam = (path: string, param: (typeof params)[number]) => {\n try {\n const match = pathMatcher(path);\n return match ? match.params[param] : undefined;\n } catch (e) {\n return undefined;\n }\n };\n\n const normalizeSearchParams = (\n searchParams: Record<string, unknown>,\n method: HTTPMethod,\n ) => {\n return Object.fromEntries(\n Object.entries(searchParams).map(([k, v]) => [\n k,\n numericProperties.query?.[method]?.includes(k)\n ? Array.isArray(v)\n ? v.map((e) => maybeNumber(e))\n : maybeNumber(v)\n : v,\n ]),\n );\n };\n\n const normalizeParams = (path: string) => {\n return params.reduce((map: Record<string, unknown>, param) => {\n const value = resolveParam(path, param);\n if (Array.isArray(value)) {\n map[param] = numericProperties.params.includes(param)\n ? value.map((e) => maybeNumber(e))\n : value;\n } else if (value) {\n map[param] = numericProperties.params.includes(param)\n ? maybeNumber(value)\n : value;\n }\n return map;\n }, {});\n };\n\n const paramsMapper = (input: ParamsT, opt?: { coerceNumbers?: boolean }) => {\n return params.reduce<Record<string, unknown>>((map, name, i) => {\n const coerceNumbers = opt?.coerceNumbers\n ? numericProperties.params.includes(name)\n : false;\n if (Array.isArray(input[i])) {\n map[name] = coerceNumbers\n ? input[i].map((v) => maybeNumber(v))\n : input[i].map(String);\n } else if (input[i] !== undefined) {\n map[name] = coerceNumbers ? maybeNumber(input[i]) : String(input[i]);\n }\n return map;\n }, {});\n };\n\n const parametrize = (params: ParamsT) => {\n try {\n return toPath(paramsMapper(params) as never);\n } catch (error) {\n console.error(\\`❗ERROR: Failed building path for \\${name}\\`);\n throw error;\n }\n };\n\n const base = (params: ParamsT, query?: Record<string, unknown>) => {\n const path = join(\"/\", parametrize(params));\n return query ? [path, stringifySearchParams(query)].join(\"?\") : path;\n };\n\n const path = (params: ParamsT, query?: Record<string, unknown>) => {\n return join(basePath, base(params, query));\n };\n\n const href = (\n host: HostOpt,\n params: ParamsT,\n query?: Record<string, unknown>,\n ) => {\n return createHost(host) + path(params, query);\n };\n\n const payloadResolver = <T>(\n payload: Record<ValidationTarget, T> | undefined,\n target: ValidationTarget,\n method: HTTPMethod,\n ) => {\n const data = payload?.[target];\n\n if (target === \"query\") {\n return Object.fromEntries(\n Object.entries({ ...data }).map(([k, v]) => {\n return [\n k,\n numericProperties.query[method]?.includes(k)\n ? Array.isArray(v)\n ? v.map((v) => maybeNumber(v))\n : maybeNumber(v)\n : v,\n ];\n }),\n );\n }\n\n if (data instanceof FormData) {\n return [...data].reduce<\n Record<string, FormDataEntryValue | Array<FormDataEntryValue>>\n >((map, [key, val]) => {\n if (key in map) {\n map[key] = [map[key]].flat().concat(val);\n } else {\n map[key] = val;\n }\n return map;\n }, {}) as T;\n }\n\n return data;\n };\n\n return {\n normalizeParams,\n normalizeSearchParams,\n paramsMapper,\n parametrize,\n base,\n path,\n href,\n payloadResolver,\n };\n};\n\nexport const pageRouteMapper = <ParamsT extends readonly unknown[]>(\n basePath: string,\n route: PageRouteSerialized,\n) => {\n const toPath = compile(route.pathPattern);\n\n const paramsMapper = (params: ParamsT) => {\n return route.params.reduce<Record<string, unknown>>((map, name, i) => {\n if (Array.isArray(params[i])) {\n map[name] = params[i].map(String);\n } else if (params[i] !== undefined) {\n map[name] = String(params[i]);\n }\n return map;\n }, {});\n };\n\n const parametrize = (params: ParamsT) => {\n try {\n return toPath(paramsMapper(params) as never);\n } catch (error) {\n console.error(\\`❗ERROR: Failed building path for \\${route.name}\\`);\n throw error;\n }\n };\n\n const base = (params: ParamsT, query?: Record<string, unknown>) => {\n const path = join(\"/\", parametrize(params));\n return query ? [path, stringifySearchParams(query)].join(\"?\") : path;\n };\n\n const path = (params: ParamsT, query?: Record<string, unknown>) => {\n return join(basePath, base(params, query));\n };\n\n const href = (\n host: HostOpt,\n params: ParamsT,\n query?: Record<string, unknown>,\n ) => {\n return createHost(host) + path(params, query);\n };\n\n return {\n paramsMapper,\n parametrize,\n base,\n path,\n href,\n };\n};\n`,g=`declare const KOSMO_PRODUCTION_BUILD: boolean;\n\n/**\n * Enhances base TypeScript types with JSON Schema validation constraints.\n * Allows declaring refined types that carry validation metadata for runtime\n * schema validation while maintaining full TypeScript type safety.\n *\n * Useful for generating validation schemas and ensuring\n * data conforms to specific business rules beyond basic type checking.\n * */\ndeclare type VRefine<\n T extends unknown[] | number | string | object,\n _ extends T extends unknown[]\n ? TArrayOptions\n : T extends number\n ? TNumberOptions\n : T extends string\n ? TStringOptions\n : TObjectOptions,\n> = T;\n\n/**\n * Type definitions inspired by and gently adapted from TypeBox.\n * Original TypeBox created by sinclairzx81: https://github.com/sinclairzx81/typebox\n * TypeBox is licensed under MIT: https://github.com/sinclairzx81/typebox/blob/main/license\n *\n * These types provide JSON Schema compatible type refinements for TypeScript.\n * */\ninterface TSchema {}\n\n// ------------------------------------------------------------------\n// ObjectOptions\n// ------------------------------------------------------------------\ninterface TObjectOptions {\n /**\n * Defines whether additional properties are allowed beyond those explicitly defined in \\`properties\\`.\n */\n additionalProperties?: TSchema | boolean;\n /**\n * The minimum number of properties required in the object.\n */\n minProperties?: number;\n /**\n * The maximum number of properties allowed in the object.\n */\n maxProperties?: number;\n /**\n * Defines conditional requirements for properties.\n */\n dependencies?: Record<string, boolean | TSchema | string[]>;\n /**\n * Specifies properties that *must* be present if a given property is present.\n */\n dependentRequired?: Record<string, string[]>;\n /**\n * Defines schemas that apply if a specific property is present.\n */\n dependentSchemas?: Record<string, TSchema>;\n /**\n * Maps regular expressions to schemas properties matching a pattern must validate against the schema.\n */\n patternProperties?: Record<string, TSchema>;\n /**\n * A schema that all property names within the object must validate against.\n */\n propertyNames?: TSchema;\n}\n\n// ------------------------------------------------------------------\n// ArrayOptions\n// ------------------------------------------------------------------\ninterface TArrayOptions {\n /**\n * The minimum number of items allowed in the array.\n */\n minItems?: number;\n /**\n * The maximum number of items allowed in the array.\n */\n maxItems?: number;\n /**\n * A schema that at least one item in the array must validate against.\n */\n contains?: TSchema;\n /**\n * The minimum number of array items that must validate against the \\`contains\\` schema.\n */\n minContains?: number;\n /**\n * The maximum number of array items that may validate against the \\`contains\\` schema.\n */\n maxContains?: number;\n /**\n * An array of schemas, where each schema in \\`prefixItems\\` validates against items at corresponding positions from the beginning of the array.\n */\n prefixItems?: TSchema[];\n /**\n * If \\`true\\`, all items in the array must be unique.\n */\n uniqueItems?: boolean;\n}\n\n// ------------------------------------------------------------------\n// NumberOptions\n// ------------------------------------------------------------------\ninterface TNumberOptions {\n /**\n * Specifies an exclusive upper limit for the number (number must be less than this value).\n */\n exclusiveMaximum?: number | bigint;\n /**\n * Specifies an exclusive lower limit for the number (number must be greater than this value).\n */\n exclusiveMinimum?: number | bigint;\n /**\n * Specifies an inclusive upper limit for the number (number must be less than or equal to this value).\n */\n maximum?: number | bigint;\n /**\n * Specifies an inclusive lower limit for the number (number must be greater than or equal to this value).\n */\n minimum?: number | bigint;\n /**\n * Specifies that the number must be a multiple of this value.\n */\n multipleOf?: number | bigint;\n}\n\n// ------------------------------------------------------------------\n// StringOptions\n// ------------------------------------------------------------------\ntype TFormat =\n | \"date-time\"\n | \"date\"\n | \"duration\"\n | \"email\"\n | \"hostname\"\n | \"idn-email\"\n | \"idn-hostname\"\n | \"ipv4\"\n | \"ipv6\"\n | \"iri-reference\"\n | \"iri\"\n | \"json-pointer-uri-fragment\"\n | \"json-pointer\"\n | \"json-string\"\n | \"regex\"\n | \"relative-json-pointer\"\n | \"time\"\n | \"uri-reference\"\n | \"uri-template\"\n | \"url\"\n | \"uuid\";\n\ninterface TStringOptions {\n /**\n * Specifies the expected string format.\n *\n * Common values include:\n * - \\`base64\\` – Base64-encoded string.\n * - \\`date-time\\` – [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time format.\n * - \\`date\\` – [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date (YYYY-MM-DD).\n * - \\`duration\\` – [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) duration format.\n * - \\`email\\` – RFC 5321/5322 compliant email address.\n * - \\`hostname\\` – RFC 1034/1035 compliant host name.\n * - \\`idn-email\\` – Internationalized email address.\n * - \\`idn-hostname\\` – Internationalized host name.\n * - \\`ipv4\\` – IPv4 address.\n * - \\`ipv6\\` – IPv6 address.\n * - \\`iri\\` / \\`iri-reference\\` – Internationalized Resource Identifier.\n * - \\`json-pointer\\` / \\`json-pointer-uri-fragment\\` – JSON Pointer format.\n * - \\`json-string\\` – String containing valid JSON.\n * - \\`regex\\` – Regular expression syntax.\n * - \\`relative-json-pointer\\` – Relative JSON Pointer format.\n * - \\`time\\` – [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) time (HH:MM:SS).\n * - \\`uri-reference\\` / \\`uri-template\\` – URI reference or template.\n * - \\`url\\` – Web URL format.\n * - \\`uuid\\` – RFC 4122 UUID string.\n *\n * May also be a custom format string.\n */\n format?: TFormat;\n /**\n * Specifies the minimum number of characters allowed in the string.\n * Must be a non-negative integer.\n */\n minLength?: number;\n /**\n * Specifies the maximum number of characters allowed in the string.\n * Must be a non-negative integer.\n */\n maxLength?: number;\n /**\n * Specifies a regular expression pattern that the string value must match.\n * Can be provided as a string (ECMA-262 regex syntax) or a \\`RegExp\\` object.\n */\n pattern?: string | RegExp;\n}\n`,_=`# Ignore all files\n*\n\n# But don't ignore directories (so Git can traverse them)\n!*/\n\n# And don't ignore these files at any depth\n!cache.json\n!types.ts\n`,v=`export declare global {\n interface Window {\n __KOSMO_HYDRATION_BOOL__: boolean;\n __KOSMO_HYDRATION_DATA__: Record<string, unknown> | undefined;\n }\n}\n`,y=`// stub schemas, specialized generators supposed to overwrite this file\nimport type { ValidationSchemas } from \"@kosmojs/core/api\";\nexport type { ValidationSchemas };\nexport const validationSchemas: ValidationSchemas = {};\n`,b=e=>{let t=\"${configDir}\",n={types:[`@types/node`,`vite/client`],moduleResolution:`bundler`,module:`ESNext`,target:`ESNext`,strict:!0,exactOptionalPropertyTypes:!0,noImplicitAny:!0,noImplicitThis:!0,noImplicitOverride:!0,noImplicitReturns:!0,noUnusedLocals:!1,noUnusedParameters:!1,allowArbitraryExtensions:!0,allowImportingTsExtensions:!0,allowUnreachableCode:!1,allowUnusedLabels:!1,useUnknownInCatchVariables:!0,noFallthroughCasesInSwitch:!0,noUncheckedSideEffectImports:!0,resolveJsonModule:!0,esModuleInterop:!0,verbatimModuleSyntax:!0,skipLibCheck:!0,noEmit:!0};return e?{include:[`${t}/`,`${t}/../../${l.libDir}/${e}/`,`${t}/../../**/*.d.ts`],compilerOptions:{...n,types:[...n.types],paths:{[`${l.appPrefix}/*`]:[`${t}/../../*`],[`${l.srcPrefix}/*`]:[`${t}/*`],[`${l.libPrefix}/*`]:[`${t}/../../${l.libDir}/${e}/*`]}}}:{include:[`${t}/`],exclude:[`${t}/${l.srcDir}/`],compilerOptions:{...n,paths:{[`${l.appPrefix}/*`]:[`${t}/*`]}}}},x=t(e=>{let{createPath:t,createImportHelpers:d}=n(e),x=async()=>{let{generators:n=[]}=e.config;{let{dependencies:t={},devDependencies:r={}}=await import(o(e.root,`package.json`),{with:{type:`json`}}).then(e=>e.default),i=[],a=[],l=n.flatMap(e=>[`dependencies`,`devDependencies`].flatMap(t=>e[t]?Object.entries(typeof e[t]==`function`?e[t](e.options):e[t]).flatMap(([e,n])=>{let r=c.minVersion(n)?.version;return r?[[e,r,t]]:[]}):[]));for(let[e,n,o]of l){let s=t[e]||r[e],l=s?c.minVersion(s)?.version:void 0;!s||!l?i.push([e,n,o]):c.lt(l,n)&&a.push([e,n,o])}if(i.length){console.error(s([`red`,`italic`],`There are ${i.length} missing dependencies, please consider installing them.`));for(let e of[`dependencies`,`devDependencies`]){let t=i.filter(t=>t[2]===e);t.length&&console.error(`${e}: ${s([`blue`],t.map(([e])=>e).join(` `))}`)}}a.length&&(console.error(s([`yellow`,`italic`],`There are ${a.length} outdated dependencies, please consider updating them:`)),console.error(a.map(([e])=>e).join(` `)),console.error())}{await i(o(e.root,`tsconfig.json`),JSON.stringify({extends:`./${l.libDir}/tsconfig.json`},void 0,2),{},{overwrite:!1}),await i(t.lib(`../tsconfig.json`),JSON.stringify(b(),void 0,2),{}),await i(t.src(`tsconfig.json`),JSON.stringify({extends:`../../${l.libDir}/${e.name}/tsconfig.json`},void 0,2),{},{overwrite:!1});let n=b(e.name),r={},a=new Set(n.compilerOptions.types||[]);for(let{meta:t}of e.config.generators||[]){t.jsx&&(r.jsx=t.jsx),t.jsxImportSource&&(r.jsxImportSource=t.jsxImportSource);for(let e of t.types||[])a.add(e)}await i(t.lib(`tsconfig.json`),JSON.stringify({...n,compilerOptions:{...n.compilerOptions,...r,types:[...a.values()]}},void 0,2),{})}for(let[e,n]of[[`env.d.ts`,g],[`global.d.ts`,v]])await i(t.lib(`../${e}`),n,{});await i(t.lib(`../.gitignore`),_,{},{overwrite:!1});for(let[e,n]of[[`ssg.ts`,`export default [];`]])await i(t.lib(e),n,{})},S=async n=>{let{renderToFile:i}=r({helpers:{...d({origin:`lib`}),...u()},partials:{routeMapperPartial:h}});await i(t.libCore(`routes.ts`),m,{apiRoutes:n.flatMap(({kind:e,entry:t})=>e===`apiRoute`?[t]:[]),pageRoutes:n.flatMap(({kind:e,entry:t})=>e===`pageRoute`?[t]:[])});for(let[n,r]of[[`config.ts`,f],[`index.ts`,p]])await i(t.libCore(n),r,e);for(let{kind:e,entry:r}of n)e===`apiRoute`&&await i(t.libApi(a(r.file),`schemas.ts`),y,{route:r},{overwrite:!1})};return{start:x,watch:S,build:S}}),S=e({meta:{name:`Core`},dependencies:{\"path-to-regexp\":d.devDependencies[`path-to-regexp`]},factory:x});export{S as default};\n//# sourceMappingURL=index.js.map"],"mappings":"sVAAsV,IAAI,EAAE,CAAC,KAAK,SAAS,QAAQ,CAAC,EAAE,KAAK,0BAA0B,QAAQ,QAAQ,OAAO,WAAW,QAAQ,MAAM,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM,mBAAmB,QAAQ,gBAAgB,CAAC,EAAE,QAAQ,CAAC,MAAM,sBAAsB,EAAE,aAAa,CAAC,gBAAgB,cAAc,eAAe,cAAc,OAAO,QAAQ,EAAE,gBAAgB,CAAC,gBAAgB,SAAS,iBAAiB,QAAQ,CAAC,EAAE,EAAE;;EAE9tB,EAAE;;EAEF,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgCF,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkNF,EAAE;;;;;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