@stacksjs/stx 0.2.303 → 0.2.304
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/api-client.d.ts +26 -0
- package/dist/api-client.js +22 -0
- package/dist/api-handler.d.ts +6 -0
- package/dist/api-handler.js +3 -0
- package/dist/app-shell.js +11 -2
- package/dist/application-layers.d.ts +30 -0
- package/dist/application-layers.js +202 -0
- package/dist/build.js +9 -1
- package/dist/chunk-02hm88m5.js +2 -0
- package/dist/{chunk-7eea1cse.js → chunk-09zjty4k.js} +1 -1
- package/dist/{chunk-7nfn7nj9.js → chunk-0gz0rhvs.js} +1 -1
- package/dist/{chunk-jsfch50r.js → chunk-1c2j4eby.js} +1 -1
- package/dist/{chunk-m6wz1hf5.js → chunk-2h94c5hm.js} +2 -2
- package/dist/{chunk-mjpqz66q.js → chunk-2ver2s2y.js} +1 -1
- package/dist/{chunk-hp3rjwnb.js → chunk-30nbe9hr.js} +2 -2
- package/dist/chunk-39qzhpn6.js +18 -0
- package/dist/chunk-3z6bqqr7.js +2 -0
- package/dist/chunk-43p1qq7g.js +2 -0
- package/dist/{chunk-c6b5nqct.js → chunk-45y8bjrv.js} +287 -352
- package/dist/{chunk-2rp09y5j.js → chunk-4evbx7sz.js} +1 -1
- package/dist/chunk-4jgr954p.js +2 -0
- package/dist/chunk-51j2aqvb.js +2 -0
- package/dist/{chunk-whm6bybj.js → chunk-54f8bpp6.js} +3 -3
- package/dist/{chunk-yfwyvh02.js → chunk-5k1hznvq.js} +2 -2
- package/dist/chunk-5qfpcgcs.js +2 -0
- package/dist/{chunk-7eg7ep8f.js → chunk-5tefa8qb.js} +2 -2
- package/dist/chunk-5x2fc4vk.js +30 -0
- package/dist/{chunk-683tfkz4.js → chunk-64djh88a.js} +1 -1
- package/dist/{chunk-btrmvj2y.js → chunk-695fkras.js} +1 -1
- package/dist/chunk-6hcc4973.js +2 -0
- package/dist/{chunk-y7dcdjav.js → chunk-6vswphz4.js} +2 -2
- package/dist/chunk-7gqbr8nr.js +2 -0
- package/dist/{chunk-x4prtyjs.js → chunk-7kw3grq5.js} +1 -1
- package/dist/{chunk-7jebw3ea.js → chunk-7skk34dh.js} +2 -2
- package/dist/chunk-8215nhej.js +12 -0
- package/dist/chunk-8ee62a9q.js +2 -0
- package/dist/{chunk-jj6yp7gm.js → chunk-8jam44my.js} +1 -1
- package/dist/chunk-8z0n5mtg.js +2 -0
- package/dist/{chunk-3bc8bqw2.js → chunk-9368t9jm.js} +1 -1
- package/dist/chunk-9499k64n.js +6 -0
- package/dist/chunk-976g5qe5.js +2 -0
- package/dist/{chunk-3jwmcf4k.js → chunk-9c835qjn.js} +1 -1
- package/dist/chunk-9px4y692.js +2 -0
- package/dist/{chunk-zn6xcc0a.js → chunk-9vqnrcrw.js} +2 -2
- package/dist/chunk-9wrrr7g3.js +4 -0
- package/dist/{chunk-95t0k8cz.js → chunk-9xzszvn5.js} +1 -1
- package/dist/chunk-a07chbgj.js +2 -0
- package/dist/{chunk-rdg1n42s.js → chunk-ankp4reb.js} +2 -2
- package/dist/{chunk-5d9cy7a0.js → chunk-awj7yy37.js} +1 -1
- package/dist/chunk-b1hd8kvy.js +2 -0
- package/dist/chunk-b4xwbh8a.js +2 -0
- package/dist/{chunk-1evf3bdg.js → chunk-bd9wrcq1.js} +205 -19
- package/dist/{chunk-q25mr70f.js → chunk-c131k3mt.js} +1 -1
- package/dist/chunk-c3tmzx7q.js +2 -0
- package/dist/{chunk-6btbgxh1.js → chunk-c79nfdyj.js} +1 -1
- package/dist/{chunk-cfgpk6bh.js → chunk-cbgh359m.js} +1 -1
- package/dist/chunk-ckzhp09g.js +2 -0
- package/dist/{chunk-weqpt9nt.js → chunk-cr8v8k53.js} +1 -1
- package/dist/{chunk-p3wwm6k4.js → chunk-d19tvdvv.js} +1 -1
- package/dist/{chunk-nb1zdh1y.js → chunk-d3srvh3q.js} +1 -1
- package/dist/{chunk-rqrfq305.js → chunk-d57gb0v2.js} +1 -1
- package/dist/{chunk-1xyhk1wr.js → chunk-d5cqnwdd.js} +1 -1
- package/dist/chunk-dgpjxmhs.js +2 -0
- package/dist/chunk-dvvx1wny.js +3 -0
- package/dist/{chunk-ctz53mbz.js → chunk-ej8mv2k6.js} +1 -1
- package/dist/{chunk-dv3z80gt.js → chunk-env6knrs.js} +1 -1
- package/dist/{chunk-rf10fkrf.js → chunk-ess2pgt5.js} +1 -1
- package/dist/chunk-ez28vck6.js +2 -0
- package/dist/{chunk-0tbgvp70.js → chunk-fczfdsab.js} +21 -5
- package/dist/{chunk-xdq52pwj.js → chunk-fp7ms6e7.js} +1 -1
- package/dist/{chunk-qg6pg6ze.js → chunk-fqq5k9ve.js} +1 -1
- package/dist/chunk-fvtv1s5j.js +3 -0
- package/dist/{chunk-5t0w4h6z.js → chunk-g912mb7x.js} +1 -1
- package/dist/chunk-g97atepq.js +2 -0
- package/dist/{chunk-wj25qt72.js → chunk-gbwhbasw.js} +1 -1
- package/dist/{chunk-f62fh1fw.js → chunk-gfc3qye3.js} +2 -2
- package/dist/{chunk-cratkhhb.js → chunk-ghw5p1yk.js} +1 -1
- package/dist/{chunk-f0g2q51j.js → chunk-gssbag3e.js} +1 -1
- package/dist/{chunk-c9vhtjtr.js → chunk-gt8ja700.js} +2 -2
- package/dist/chunk-hay1rzb0.js +3754 -0
- package/dist/{chunk-ftvmk1nj.js → chunk-hg2afckn.js} +1 -1
- package/dist/chunk-hgjjnjas.js +7 -0
- package/dist/{chunk-hhnzd03k.js → chunk-hrcxfvh1.js} +1 -1
- package/dist/chunk-hzav4hyd.js +2 -0
- package/dist/{chunk-29gjwajm.js → chunk-jfzfrmzy.js} +1 -1
- package/dist/chunk-jjq9q9jr.js +2 -0
- package/dist/{chunk-ddqkj56r.js → chunk-jp2f8yzw.js} +1 -1
- package/dist/{chunk-ry3a2674.js → chunk-jsg1rthc.js} +1 -1
- package/dist/chunk-jxxv18a0.js +5 -0
- package/dist/chunk-kbw2qzqx.js +2 -0
- package/dist/chunk-kdxvraec.js +2 -0
- package/dist/chunk-krfjb7b8.js +2 -0
- package/dist/{chunk-6b4k8fay.js → chunk-kxavsh3m.js} +1 -1
- package/dist/{chunk-4tffxxpd.js → chunk-m31n9pkr.js} +1 -1
- package/dist/{chunk-fj6fbqgb.js → chunk-m3a20mmb.js} +1 -1
- package/dist/{chunk-j21csh4j.js → chunk-mbmqpaq1.js} +1 -1
- package/dist/{chunk-y9nyqcha.js → chunk-mwh3ymwc.js} +1 -1
- package/dist/{chunk-51g95yts.js → chunk-mygq61f5.js} +2 -2
- package/dist/chunk-nqq7y7m9.js +3 -0
- package/dist/chunk-nws8fbde.js +2 -0
- package/dist/{chunk-q6xfyasj.js → chunk-pcvayb2f.js} +1 -1
- package/dist/{chunk-nvxv2wxv.js → chunk-ppyz9623.js} +1 -1
- package/dist/chunk-pr14wjkn.js +2 -0
- package/dist/{chunk-jb2r696a.js → chunk-qev11kg8.js} +1 -1
- package/dist/{chunk-6njgsr6w.js → chunk-qeyw5za9.js} +1 -1
- package/dist/chunk-rpfcnq8n.js +2 -0
- package/dist/chunk-rrankpmj.js +3 -0
- package/dist/chunk-rst1rw09.js +2 -0
- package/dist/{chunk-3p0zgfgz.js → chunk-rzevgemj.js} +2 -2
- package/dist/{chunk-aa6kt84c.js → chunk-sart9ehj.js} +1 -1
- package/dist/chunk-sb7ana2z.js +19 -0
- package/dist/chunk-snt2773t.js +2 -0
- package/dist/{chunk-jptkc64r.js → chunk-t3qb9s6s.js} +2 -2
- package/dist/{chunk-w8yac9xp.js → chunk-t41aaehf.js} +1 -1
- package/dist/{chunk-qjkzpd68.js → chunk-t51mwjyq.js} +1 -1
- package/dist/chunk-tt4r8q4v.js +2 -0
- package/dist/chunk-vd3h9z7e.js +2 -0
- package/dist/{chunk-6rzwef28.js → chunk-vd5xvsnv.js} +1 -1
- package/dist/chunk-wbecqx03.js +2 -0
- package/dist/{chunk-dcxtrqfy.js → chunk-wfffa8zm.js} +1 -1
- package/dist/{chunk-22p0ezj6.js → chunk-wx13qmaw.js} +1 -1
- package/dist/chunk-xd5ahrtn.js +2 -0
- package/dist/{chunk-2m6x8tcx.js → chunk-xganfzgn.js} +2 -2
- package/dist/chunk-xq1swv2e.js +2 -0
- package/dist/chunk-xsfwcj6x.js +2 -0
- package/dist/{chunk-91007tan.js → chunk-xwxdwqn9.js} +1 -1
- package/dist/{chunk-634gaa9d.js → chunk-xz3evxqp.js} +1 -1
- package/dist/chunk-xzgvcrnz.js +2 -0
- package/dist/chunk-y2kmm6bt.js +43 -0
- package/dist/{chunk-v8474ah4.js → chunk-y4nzmkea.js} +1 -1
- package/dist/chunk-y7wsk78j.js +3 -0
- package/dist/{chunk-6w8fa3b8.js → chunk-ya5m5vbn.js} +1 -1
- package/dist/{chunk-ps20v1ah.js → chunk-ym3r8ktq.js} +1 -1
- package/dist/chunk-yyebm8q4.js +2 -0
- package/dist/chunk-yyyxt326.js +2 -0
- package/dist/chunk-yz16bgs3.js +28 -0
- package/dist/{chunk-ew6tr7b1.js → chunk-z9ezmjwd.js} +2 -2
- package/dist/chunk-zbtfhxhn.js +2 -0
- package/dist/chunk-zggm7kjd.js +17 -0
- package/dist/{chunk-mdf3jbe6.js → chunk-zhcs8m2a.js} +2 -2
- package/dist/{chunk-f9d27v49.js → chunk-zs5y7xnt.js} +1 -1
- package/dist/cli.js +14 -14
- package/dist/client-script-bundler.js +22 -11
- package/dist/component-contract-checks.d.ts +19 -0
- package/dist/component-contract-checks.js +147 -0
- package/dist/component-contract.d.ts +20 -0
- package/dist/component-contract.js +108 -0
- package/dist/component-model.d.ts +29 -0
- package/dist/component-model.js +59 -0
- package/dist/component-registry.js +7 -64
- package/dist/component-renderer.d.ts +1 -26
- package/dist/component-renderer.js +4 -239
- package/dist/component-resolution.d.ts +21 -0
- package/dist/component-resolution.js +118 -0
- package/dist/component-tags.d.ts +9 -0
- package/dist/component-tags.js +174 -0
- package/dist/composable-loader.d.ts +2 -13
- package/dist/composable-loader.js +15 -26
- package/dist/composables/index.d.ts +1 -0
- package/dist/composables/index.js +1 -0
- package/dist/composables/use-fetch.d.ts +117 -42
- package/dist/composables/use-fetch.js +47 -4
- package/dist/composition-api.d.ts +43 -19
- package/dist/config.d.ts +1 -1
- package/dist/config.js +46 -4
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/database.js +1 -1
- package/dist/dev-server/serve-app.js +57 -17
- package/dist/dev-server/serve-file.js +8 -1
- package/dist/expressions.js +1 -1
- package/dist/imported-signals.js +1 -1
- package/dist/includes.js +8 -2
- package/dist/index.d.ts +11 -0
- package/dist/index.js +7 -0
- package/dist/manifest.d.ts +6 -0
- package/dist/misc-directives.d.ts +2 -0
- package/dist/misc-directives.js +39 -1
- package/dist/process.js +18 -1
- package/dist/production-builder.d.ts +4 -0
- package/dist/production-builder.js +47 -8
- package/dist/production-server.d.ts +4 -1
- package/dist/production-server.js +119 -71
- package/dist/pwa.js +2 -2
- package/dist/render.js +9 -2
- package/dist/route-response-cache.d.ts +7 -0
- package/dist/route-response-cache.js +72 -0
- package/dist/route-rules.d.ts +17 -0
- package/dist/route-rules.js +40 -0
- package/dist/router.d.ts +1 -0
- package/dist/runtime-config-loader.d.ts +5 -0
- package/dist/runtime-config-loader.js +42 -0
- package/dist/runtime-config-server.d.ts +26 -0
- package/dist/runtime-config-server.js +77 -0
- package/dist/runtime-config-types.d.ts +2 -0
- package/dist/runtime-config-types.js +0 -0
- package/dist/runtime-config.d.ts +5 -0
- package/dist/runtime-config.js +9 -0
- package/dist/runtime-globals.js +3 -0
- package/dist/serve.js +32 -10
- package/dist/server-api.d.ts +27 -0
- package/dist/server-api.js +181 -0
- package/dist/server-data.d.ts +17 -0
- package/dist/server-data.js +40 -0
- package/dist/signal-processing.js +2 -2
- package/dist/signals.js +138 -15
- package/dist/ssg.js +2 -2
- package/dist/stx-virtual-ts.d.ts +6 -0
- package/dist/stx-virtual-ts.js +31 -7
- package/dist/stx.d.ts +28 -0
- package/dist/template-compiler.d.ts +1 -0
- package/dist/template-compiler.js +1 -1
- package/dist/template-hydrator.js +15 -4
- package/dist/typecheck.d.ts +1 -0
- package/dist/typecheck.js +4 -3
- package/dist/types/config-types.d.ts +17 -0
- package/dist/utils.js +15 -5
- package/dist/variable-extractor.d.ts +1 -1
- package/dist/variable-extractor.js +12 -1
- package/dist/visual-testing.js +1 -1
- package/dist/vue-template.js +19 -41
- package/package.json +5 -5
- package/stx.d.ts +28 -0
- package/dist/chunk-0p44z42s.js +0 -2
- package/dist/chunk-2jd9bxmf.js +0 -2
- package/dist/chunk-2yp8ang5.js +0 -2
- package/dist/chunk-35x7s4cr.js +0 -2
- package/dist/chunk-3bqz5zre.js +0 -2
- package/dist/chunk-48p0k8y7.js +0 -2
- package/dist/chunk-4b625drg.js +0 -2
- package/dist/chunk-593kby1d.js +0 -2
- package/dist/chunk-5nac67r4.js +0 -18
- package/dist/chunk-70cf5h11.js +0 -2
- package/dist/chunk-78akhaws.js +0 -2
- package/dist/chunk-9a4q74r6.js +0 -2
- package/dist/chunk-9f5329rv.js +0 -2
- package/dist/chunk-9rv7akqq.js +0 -30
- package/dist/chunk-apjy1a72.js +0 -12
- package/dist/chunk-b3p3bzax.js +0 -3
- package/dist/chunk-c5hk1fxt.js +0 -2
- package/dist/chunk-c9rs5g1s.js +0 -2
- package/dist/chunk-dkd0bg8g.js +0 -2
- package/dist/chunk-dxhtry04.js +0 -2
- package/dist/chunk-ehp6fez3.js +0 -2
- package/dist/chunk-em3jb1dn.js +0 -4
- package/dist/chunk-ev4djb0p.js +0 -2
- package/dist/chunk-frejnjh9.js +0 -2
- package/dist/chunk-fvcr26a0.js +0 -22
- package/dist/chunk-g6ttsdz1.js +0 -2
- package/dist/chunk-gd73rpks.js +0 -2
- package/dist/chunk-ggwnrdqz.js +0 -17
- package/dist/chunk-h3t6fjba.js +0 -2
- package/dist/chunk-jc57j887.js +0 -2
- package/dist/chunk-jw248h1d.js +0 -2
- package/dist/chunk-k5xtf38q.js +0 -3
- package/dist/chunk-m78y5qys.js +0 -19
- package/dist/chunk-mc4rtf5d.js +0 -2
- package/dist/chunk-mx2wcb15.js +0 -2
- package/dist/chunk-p4w3wjbv.js +0 -2
- package/dist/chunk-pm3k8dyk.js +0 -2
- package/dist/chunk-qr59yfq9.js +0 -2
- package/dist/chunk-qsmdvy1z.js +0 -2
- package/dist/chunk-rsxmjfxq.js +0 -3754
- package/dist/chunk-s4sp78fn.js +0 -2
- package/dist/chunk-v2fp9vkh.js +0 -2
- package/dist/chunk-vwnnbzsp.js +0 -2
- package/dist/chunk-w0g99tx9.js +0 -2
- package/dist/chunk-x2pk87q2.js +0 -3
- package/dist/chunk-xn0asg46.js +0 -2
- package/dist/chunk-xwmw1wtk.js +0 -2
- package/dist/chunk-zdx9s3z0.js +0 -28
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Augmented by .stx/api-types.d.ts. This module has no server imports. */
|
|
2
|
+
export interface KnownApiRoutes {
|
|
3
|
+
}
|
|
4
|
+
export type ApiMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
|
|
5
|
+
export type ApiRouteKey = [keyof KnownApiRoutes] extends [never] ? `${ApiMethod} /${string}` : keyof KnownApiRoutes & string;
|
|
6
|
+
type Params<K extends ApiRouteKey> = K extends keyof KnownApiRoutes ? KnownApiRoutes[K] extends {
|
|
7
|
+
params: infer P;
|
|
8
|
+
} ? P : never : Record<string, string>;
|
|
9
|
+
/** Match JSON wire types rather than pretending Date survives serialization. */
|
|
10
|
+
export type ApiJson<T> = T extends Response ? unknown : T extends Date ? string : T extends bigint | symbol | ((...args: any[]) => any) ? never : T extends object ? {
|
|
11
|
+
[K in keyof T]: ApiJson<T[K]>;
|
|
12
|
+
} : T;
|
|
13
|
+
export type ApiResponse<K extends ApiRouteKey> = K extends keyof KnownApiRoutes ? KnownApiRoutes[K] extends {
|
|
14
|
+
response: infer R;
|
|
15
|
+
} ? ApiJson<R> : unknown : unknown;
|
|
16
|
+
export type ApiFetchOptions<K extends ApiRouteKey> = Omit<RequestInit, 'method'> & {
|
|
17
|
+
params?: Params<K>;
|
|
18
|
+
query?: Record<string, string | number | boolean | undefined>;
|
|
19
|
+
/** Useful for server-side callers. Browser calls default to the current origin. */
|
|
20
|
+
baseURL?: string;
|
|
21
|
+
};
|
|
22
|
+
/** Typed JSON fetch. Example: apiFetch('GET /api/users/:id', { params: { id: '42' } }). */
|
|
23
|
+
export declare function apiFetch<K extends ApiRouteKey>(route: K, ...args: {} extends Params<K> ? [options?: ApiFetchOptions<K>] : [options: ApiFetchOptions<K> & {
|
|
24
|
+
params: Params<K>;
|
|
25
|
+
}]): Promise<ApiResponse<K>>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export async function apiFetch(route, ...args) {
|
|
2
|
+
const { params = {}, query, baseURL = "", ...init } = args[0] ?? {}, separator = route.indexOf(" "), method = route.slice(0, separator);
|
|
3
|
+
let pathname = route.slice(separator + 1);
|
|
4
|
+
if (!["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"].includes(method) || !pathname.startsWith("/"))
|
|
5
|
+
throw Error(`Invalid API route: ${route}`);
|
|
6
|
+
pathname = pathname.replace(/:([\w]+)(\*)?/g, (_match, name, catchAll) => {
|
|
7
|
+
const value = params[name];
|
|
8
|
+
if (!Object.hasOwn(params, name) || value === void 0 || value === "")
|
|
9
|
+
throw Error(`Missing API route parameter: ${name}`);
|
|
10
|
+
return catchAll ? String(value).split("/").map(encodeURIComponent).join("/") : encodeURIComponent(String(value));
|
|
11
|
+
});
|
|
12
|
+
const search = new URLSearchParams;
|
|
13
|
+
for (const [key, value] of Object.entries(query ?? {}))
|
|
14
|
+
if (value !== void 0)
|
|
15
|
+
search.set(key, String(value));
|
|
16
|
+
const response = await fetch(`${baseURL.replace(/\/$/, "")}${pathname}${search.size ? `?${search}` : ""}`, { ...init, method });
|
|
17
|
+
if (!response.ok)
|
|
18
|
+
throw Object.assign(Error(`API request failed: ${response.status} ${method} ${pathname}`), { status: response.status, response });
|
|
19
|
+
if (response.status === 204 || method === "HEAD")
|
|
20
|
+
return;
|
|
21
|
+
return response.json();
|
|
22
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Context passed to opt-in file-based endpoints. */
|
|
2
|
+
export interface ApiHandlerContext {
|
|
3
|
+
params: Record<string, string>;
|
|
4
|
+
}
|
|
5
|
+
/** Preserve a handler's inferred return type for the generated client contract. */
|
|
6
|
+
export declare function defineApiHandler<T>(handler: (request: Request, context: ApiHandlerContext) => T): (request: Request, context: ApiHandlerContext) => T;
|
package/dist/app-shell.js
CHANGED
|
@@ -127,6 +127,12 @@ export function stripDocumentWrapper(html, options = {}) {
|
|
|
127
127
|
let m;
|
|
128
128
|
while ((m = styleRegex.exec(headContent)) !== null)
|
|
129
129
|
headStyles.push(m[0]);
|
|
130
|
+
const dataTag = headContent.match(/<script\b[^>]*data-stx-server-data[^>]*>[\s\S]*?<\/script>/i);
|
|
131
|
+
if (dataTag)
|
|
132
|
+
headStyles.push(dataTag[0]);
|
|
133
|
+
const runtimeTag = headContent.match(/<script\b[^>]*data-stx-runtime-config[^>]*>[\s\S]*?<\/script>/i);
|
|
134
|
+
if (runtimeTag)
|
|
135
|
+
headStyles.push(runtimeTag[0]);
|
|
130
136
|
}
|
|
131
137
|
if (options.preserveHead && headMatch) {
|
|
132
138
|
const headTags = [], tagRegex = /<title\b[^>]*>[\s\S]*?<\/title>|<meta\b[^>]*>|<link\b[^>]*>/gi;
|
|
@@ -171,9 +177,12 @@ export function extractContainerContent(html, containerSelector = "main") {
|
|
|
171
177
|
let m;
|
|
172
178
|
while ((m = styleRegex.exec(headContent)) !== null)
|
|
173
179
|
headStyles.push(m[0]);
|
|
174
|
-
const routeParamsRegex = /<script\b[^>]*data-stx-route-params[^>]*>[\s\S]*?<\/script>/gi;
|
|
175
|
-
while ((m = routeParamsRegex.exec(headContent)) !== null)
|
|
180
|
+
const routeParamsRegex = /<script\b[^>]*data-stx-(?:route-params|server-data|scoped|component-factories)[^>]*>[\s\S]*?<\/script>/gi;
|
|
181
|
+
while ((m = routeParamsRegex.exec(headContent)) !== null) {
|
|
182
|
+
if (COMPONENT_INSTANCE_SCRIPT.test(m[0]) || m[0].includes("__stx_early_mounts") || /^<script\b[^>]*\bdata-stx-runtime(?=[\s=>])/i.test(m[0]))
|
|
183
|
+
continue;
|
|
176
184
|
headScripts.push(m[0]);
|
|
185
|
+
}
|
|
177
186
|
}
|
|
178
187
|
const containerRegion = findContainerRegion(trimmed, containerSelector);
|
|
179
188
|
if (!containerRegion)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { StxOptions } from './types';
|
|
2
|
+
export interface ApplicationLayer {
|
|
3
|
+
root: string;
|
|
4
|
+
configFile: string;
|
|
5
|
+
resources: Record<'pages' | 'components' | 'layouts' | 'partials' | 'composables', string>;
|
|
6
|
+
}
|
|
7
|
+
export interface ApplicationLayerGraph {
|
|
8
|
+
/** Highest precedence first: app, first layer and its ancestors, next layer. */
|
|
9
|
+
layers: ApplicationLayer[];
|
|
10
|
+
configDependencies: string[];
|
|
11
|
+
/** Intentional resource overrides, suitable for diagnostics. */
|
|
12
|
+
overrides?: Array<{
|
|
13
|
+
resource: string;
|
|
14
|
+
winner: string;
|
|
15
|
+
shadowed: string;
|
|
16
|
+
}>;
|
|
17
|
+
}
|
|
18
|
+
export declare function isLayerConfigSource(file: string): boolean;
|
|
19
|
+
/** Objects merge recursively; arrays replace except ordered middleware/plugins. */
|
|
20
|
+
export declare function mergeLayerConfig(base: any, override: any, key?: string): any;
|
|
21
|
+
export declare function resolveApplicationLayers(appRoot: string, defaults: StxOptions): Promise<{
|
|
22
|
+
config: StxOptions;
|
|
23
|
+
graph: ApplicationLayerGraph;
|
|
24
|
+
}>;
|
|
25
|
+
export declare function refreshLayerDiagnostics(graph: ApplicationLayerGraph, appRoot: string): Promise<void>;
|
|
26
|
+
export declare function layerDependencies(graph: ApplicationLayerGraph): string[];
|
|
27
|
+
export declare function layerSignature(graph: ApplicationLayerGraph): string;
|
|
28
|
+
export declare function layerConfigSignature(graph: ApplicationLayerGraph): string;
|
|
29
|
+
/** Portable build provenance; no absolute paths or config values. */
|
|
30
|
+
export declare function layerManifest(graph: ApplicationLayerGraph): unknown;
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
const resourceKeys = ["pages", "components", "layouts", "partials", "composables"], configSources = new Set;
|
|
5
|
+
export function isLayerConfigSource(file) {
|
|
6
|
+
try {
|
|
7
|
+
return configSources.has(fs.realpathSync(file));
|
|
8
|
+
} catch {
|
|
9
|
+
return configSources.has(path.resolve(file));
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
const localKeys = new Set(["extends", "root", ...resourceKeys.map((key) => `${key}Dir`), "publicDir", "stateDir", "cachePath"]), plain = (value) => value !== null && typeof value === "object" && (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);
|
|
13
|
+
export function mergeLayerConfig(base, override, key = "") {
|
|
14
|
+
if (Array.isArray(override))
|
|
15
|
+
return ["middleware", "plugins"].includes(key) ? [...Array.isArray(base) ? base : [], ...override] : [...override];
|
|
16
|
+
if (!plain(override))
|
|
17
|
+
return override;
|
|
18
|
+
const out = { ...plain(base) ? base : {} };
|
|
19
|
+
for (const [name, value] of Object.entries(override)) {
|
|
20
|
+
if (["__proto__", "constructor", "prototype"].includes(name))
|
|
21
|
+
throw Error(`Invalid layer config key: ${name}`);
|
|
22
|
+
out[name] = mergeLayerConfig(out[name], value, name);
|
|
23
|
+
}
|
|
24
|
+
return out;
|
|
25
|
+
}
|
|
26
|
+
function findConfig(root) {
|
|
27
|
+
for (const name of ["stx.config.ts", "stx.config.js", "stx.config.mjs", ".config/stx.config.ts", ".config/stx.ts", "ui.config.ts"]) {
|
|
28
|
+
const file = path.join(root, name);
|
|
29
|
+
if (fs.existsSync(file))
|
|
30
|
+
return fs.realpathSync(file);
|
|
31
|
+
}
|
|
32
|
+
throw Error(`Application layer has no stx.config.ts: ${root}`);
|
|
33
|
+
}
|
|
34
|
+
function resolveLayer(specifier, parent, dependencies) {
|
|
35
|
+
if (typeof specifier !== "string" || !specifier || /^(?:https?:|git[+:])/.test(specifier))
|
|
36
|
+
throw Error(`Invalid application layer ${JSON.stringify(specifier)} in ${parent}; use a local path or installed package`);
|
|
37
|
+
if (specifier.startsWith(".") || path.isAbsolute(specifier)) {
|
|
38
|
+
const resolved = path.resolve(parent, specifier);
|
|
39
|
+
return fs.statSync(resolved).isDirectory() ? findConfig(resolved) : fs.realpathSync(resolved);
|
|
40
|
+
}
|
|
41
|
+
let directory = parent;
|
|
42
|
+
while (!0) {
|
|
43
|
+
const candidate = path.join(directory, "node_modules", specifier), pkg = path.join(candidate, "package.json");
|
|
44
|
+
if (fs.existsSync(pkg)) {
|
|
45
|
+
dependencies.add(fs.realpathSync(pkg));
|
|
46
|
+
const metadata = JSON.parse(fs.readFileSync(pkg, "utf8"));
|
|
47
|
+
return metadata.stx?.layer ? fs.realpathSync(path.resolve(candidate, metadata.stx.layer)) : findConfig(candidate);
|
|
48
|
+
}
|
|
49
|
+
const next = path.dirname(directory);
|
|
50
|
+
if (next === directory)
|
|
51
|
+
break;
|
|
52
|
+
directory = next;
|
|
53
|
+
}
|
|
54
|
+
throw Error(`Cannot resolve application layer ${JSON.stringify(specifier)} from ${parent}`);
|
|
55
|
+
}
|
|
56
|
+
async function readConfig(file, dependencies) {
|
|
57
|
+
const build = await Bun.build({
|
|
58
|
+
entrypoints: [file],
|
|
59
|
+
target: "bun",
|
|
60
|
+
format: "esm",
|
|
61
|
+
splitting: !1,
|
|
62
|
+
plugins: [{ name: "stx-layer-config", setup(builder) {
|
|
63
|
+
builder.onResolve({ filter: /^[^./]/ }, (args) => {
|
|
64
|
+
if (args.path.startsWith("node:"))
|
|
65
|
+
return { path: args.path, external: !0 };
|
|
66
|
+
return { path: Bun.resolveSync(args.path, args.resolveDir), external: !0 };
|
|
67
|
+
});
|
|
68
|
+
builder.onLoad({ filter: /./ }, (args) => {
|
|
69
|
+
const file = fs.realpathSync(args.path);
|
|
70
|
+
dependencies.add(file);
|
|
71
|
+
configSources.add(file);
|
|
72
|
+
return;
|
|
73
|
+
});
|
|
74
|
+
} }]
|
|
75
|
+
});
|
|
76
|
+
if (!build.success)
|
|
77
|
+
throw Error(`Cannot load layer ${file}: ${build.logs.join(`
|
|
78
|
+
`)}`);
|
|
79
|
+
const output = build.outputs.find((item) => item.kind === "entry-point");
|
|
80
|
+
if (!output || build.outputs.length !== 1)
|
|
81
|
+
throw Error(`Unsupported layer config output: ${file}`);
|
|
82
|
+
const loaded = (await import(`data:text/javascript;base64,${Buffer.from(await output.text()).toString("base64")}`)).default;
|
|
83
|
+
if (!plain(loaded))
|
|
84
|
+
throw Error(`Layer ${file} must default-export a config object`);
|
|
85
|
+
return loaded;
|
|
86
|
+
}
|
|
87
|
+
export async function resolveApplicationLayers(appRoot, defaults) {
|
|
88
|
+
const dependencies = new Set, layers = [], configs = [], seen = new Set, active = [];
|
|
89
|
+
async function visit(file, root) {
|
|
90
|
+
file = fs.realpathSync(file);
|
|
91
|
+
if (active.includes(file))
|
|
92
|
+
throw Error(`Application layer cycle: ${[...active, file].join(" -> ")}`);
|
|
93
|
+
if (seen.has(file))
|
|
94
|
+
return;
|
|
95
|
+
seen.add(file);
|
|
96
|
+
active.push(file);
|
|
97
|
+
const declared = await readConfig(file, dependencies);
|
|
98
|
+
root ??= path.basename(path.dirname(file)) === ".config" ? path.dirname(path.dirname(file)) : path.dirname(file);
|
|
99
|
+
root = fs.realpathSync(root);
|
|
100
|
+
const base = path.resolve(root, declared.root ?? "."), resources = Object.fromEntries(resourceKeys.map((name) => [name, path.resolve(base, declared[`${name}Dir`] ?? (name === "composables" ? "functions" : name))]));
|
|
101
|
+
layers.push({ root, configFile: file, resources });
|
|
102
|
+
const config = { ...declared };
|
|
103
|
+
if (config.plugins)
|
|
104
|
+
config.plugins = config.plugins.map((entry) => {
|
|
105
|
+
const spec = typeof entry === "string" ? entry : entry[0], resolved = spec.startsWith(".") ? path.resolve(root, spec) : path.isAbsolute(spec) ? spec : Bun.resolveSync(spec, root);
|
|
106
|
+
dependencies.add(fs.realpathSync(resolved));
|
|
107
|
+
return typeof entry === "string" ? resolved : [resolved, entry[1]];
|
|
108
|
+
});
|
|
109
|
+
if (typeof config.css === "string")
|
|
110
|
+
config.css = path.resolve(root, config.css);
|
|
111
|
+
if (config.serverApi)
|
|
112
|
+
config.serverApi = { ...typeof config.serverApi === "object" ? config.serverApi : {}, dir: path.resolve(root, typeof config.serverApi === "object" ? config.serverApi.dir ?? "server/api" : "server/api") };
|
|
113
|
+
configs.push(config);
|
|
114
|
+
if (declared.extends !== void 0 && !Array.isArray(declared.extends))
|
|
115
|
+
throw Error(`extends in ${file} must be an array`);
|
|
116
|
+
for (const spec of declared.extends ?? [])
|
|
117
|
+
await visit(resolveLayer(spec, root, dependencies));
|
|
118
|
+
active.pop();
|
|
119
|
+
}
|
|
120
|
+
await visit(findConfig(appRoot), appRoot);
|
|
121
|
+
for (const name of ["package.json", "bun.lock", "package-lock.json", "pnpm-lock.yaml"]) {
|
|
122
|
+
const file = path.join(appRoot, name);
|
|
123
|
+
if (fs.existsSync(file))
|
|
124
|
+
dependencies.add(fs.realpathSync(file));
|
|
125
|
+
}
|
|
126
|
+
let config = mergeLayerConfig({}, defaults);
|
|
127
|
+
for (let i = configs.length - 1;i >= 0; i--) {
|
|
128
|
+
const values = i === 0 ? configs[i] : Object.fromEntries(Object.entries(configs[i]).filter(([key]) => !localKeys.has(key)));
|
|
129
|
+
config = mergeLayerConfig(config, values);
|
|
130
|
+
}
|
|
131
|
+
const graph = { layers, configDependencies: [...dependencies].sort() };
|
|
132
|
+
config._layerGraph = graph;
|
|
133
|
+
config._layerPageDirs = layers.map((layer) => layer.resources.pages);
|
|
134
|
+
config._layerComponentDirs = layers.map((layer) => layer.resources.components);
|
|
135
|
+
config._layerLayoutDirs = layers.map((layer) => layer.resources.layouts);
|
|
136
|
+
config._layerPartialDirs = layers.map((layer) => layer.resources.partials);
|
|
137
|
+
config._layerComposableDirs = layers.map((layer) => layer.resources.composables);
|
|
138
|
+
await refreshLayerDiagnostics(graph, appRoot);
|
|
139
|
+
return { config, graph };
|
|
140
|
+
}
|
|
141
|
+
export async function refreshLayerDiagnostics(graph, appRoot) {
|
|
142
|
+
const selected = new Map, overrides = [];
|
|
143
|
+
for (const layer of graph.layers)
|
|
144
|
+
for (const [kind, dir] of Object.entries(layer.resources)) {
|
|
145
|
+
if (!fs.existsSync(dir))
|
|
146
|
+
continue;
|
|
147
|
+
const glob = new Bun.Glob(kind === "composables" ? "**/*.ts" : "**/*.stx");
|
|
148
|
+
for (const relative of [...glob.scanSync({ cwd: dir })].sort()) {
|
|
149
|
+
const resource = `${kind}/${relative}`, file = path.join(dir, relative), winner = selected.get(resource);
|
|
150
|
+
if (winner)
|
|
151
|
+
overrides.push({ resource, winner, shadowed: file });
|
|
152
|
+
else
|
|
153
|
+
selected.set(resource, file);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
Object.assign(graph, { overrides });
|
|
157
|
+
await Bun.write(path.join(appRoot, ".stx/layers.json"), JSON.stringify(graph, null, 2));
|
|
158
|
+
}
|
|
159
|
+
export function layerDependencies(graph) {
|
|
160
|
+
const files = new Set(graph.configDependencies);
|
|
161
|
+
function walk(dir) {
|
|
162
|
+
if (!fs.existsSync(dir))
|
|
163
|
+
return;
|
|
164
|
+
files.add(dir);
|
|
165
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: !0 }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
166
|
+
if (entry.name.startsWith(".") || entry.name === "node_modules")
|
|
167
|
+
continue;
|
|
168
|
+
const file = path.join(dir, entry.name);
|
|
169
|
+
if (entry.isDirectory())
|
|
170
|
+
walk(file);
|
|
171
|
+
else if (entry.isFile())
|
|
172
|
+
files.add(file);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
for (const layer of graph.layers)
|
|
176
|
+
for (const dir of Object.values(layer.resources))
|
|
177
|
+
walk(dir);
|
|
178
|
+
return [...files].sort();
|
|
179
|
+
}
|
|
180
|
+
export function layerSignature(graph) {
|
|
181
|
+
return fileSignature(layerDependencies(graph));
|
|
182
|
+
}
|
|
183
|
+
export function layerConfigSignature(graph) {
|
|
184
|
+
return fileSignature(graph.configDependencies);
|
|
185
|
+
}
|
|
186
|
+
function fileSignature(files) {
|
|
187
|
+
return files.map((file) => {
|
|
188
|
+
try {
|
|
189
|
+
const stat = fs.statSync(file);
|
|
190
|
+
return `${file}:${stat.mtimeMs}:${stat.size}`;
|
|
191
|
+
} catch {
|
|
192
|
+
return `${file}:missing`;
|
|
193
|
+
}
|
|
194
|
+
}).join(`
|
|
195
|
+
`);
|
|
196
|
+
}
|
|
197
|
+
export function layerManifest(graph) {
|
|
198
|
+
return graph.layers.map((layer) => ({
|
|
199
|
+
config: path.relative(layer.root, layer.configFile),
|
|
200
|
+
files: layerDependencies({ layers: [layer], configDependencies: graph.configDependencies.filter((file) => file.startsWith(`${layer.root}${path.sep}`)) }).filter((file) => fs.statSync(file).isFile()).map((file) => ({ path: path.relative(layer.root, file).replaceAll(path.sep, "/"), sha256: createHash("sha256").update(fs.readFileSync(file)).digest("hex") }))
|
|
201
|
+
}));
|
|
202
|
+
}
|
package/dist/build.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { loadStxConfig } from "./config.js";
|
|
3
|
+
import { validateRouteRules } from "./route-rules.js";
|
|
3
4
|
export async function buildApp(options = {}) {
|
|
4
|
-
const startTime = performance.now(), root = options.root || process.cwd(), config = await loadStxConfig(),
|
|
5
|
+
const startTime = performance.now(), root = options.root || process.cwd(), config = await loadStxConfig(root), rules = options.ssr?.routeRules ?? config.routeRules ?? {};
|
|
6
|
+
validateRouteRules(rules);
|
|
7
|
+
if (!config.ssr && Object.keys(rules).length)
|
|
8
|
+
throw Error("routeRules require ssr: true and the production server; flat SSG output cannot apply request/cache policies");
|
|
9
|
+
if (!config.ssr && (options.ssr?.serverApi ?? config.serverApi))
|
|
10
|
+
throw Error("serverApi requires ssr: true; flat SSG output cannot execute API endpoints");
|
|
11
|
+
const mode = config.ssr ? "ssr" : "ssg";
|
|
5
12
|
console.log(`[stx build] Mode: ${mode.toUpperCase()}${config.ssr ? " (ssr: true in stx.config.ts)" : " (default \u2014 ssr is false)"}`);
|
|
6
13
|
let ssgResult, ssrResult;
|
|
7
14
|
if (mode === "ssg") {
|
|
@@ -19,6 +26,7 @@ export async function buildApp(options = {}) {
|
|
|
19
26
|
} else {
|
|
20
27
|
const { buildForProduction } = await import("./production-builder.js");
|
|
21
28
|
ssrResult = await buildForProduction({
|
|
29
|
+
root,
|
|
22
30
|
outputDir: ".output",
|
|
23
31
|
debug: options.debug,
|
|
24
32
|
...options.ssr
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Ah as v,Bh as P,th as x,yh as M,zh as C}from"./chunk-vd5xvsnv.js";import{cw as y}from"./chunk-jp2f8yzw.js";import{resolve as h,basename as f,extname as u,join as m}from"path";import{mkdir as l}from"fs/promises";var I={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0};class z{config;constructor(J={}){this.config={...I,...J}}async get(J,Z){return C(J,Z,"image",this.config)}async set(J,Z,Y){return v(J,Z,Y,"image",this.config)}async clear(){return P("image",this.config)}updateConfig(J){this.config={...this.config,...J}}}var H=null;function S(J){if(!H)H=new z(J);else if(J)H.updateConfig(J);return H}async function w(J,Z,Y){let K=Y?{directory:`${Y.outputDir}/../.cache`}:{};return S(K).get(J,Z)}async function Q(J,Z,Y,K){let X=K?{directory:`${K.outputDir}/../.cache`}:{};return S(X).set(J,Z,Y)}async function d(){return S().clear()}async function R(){try{return await import("ts-images")}catch{return null}}function b(J){switch(J){case"quality":return{jpeg:{quality:90,mozjpeg:!0,progressive:!0},png:{compressionLevel:6,palette:!1},webp:{quality:90,effort:6,smartSubsample:!0},avif:{quality:85,effort:6}};case"performance":return{jpeg:{quality:70,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!0},webp:{quality:70,effort:4,smartSubsample:!0},avif:{quality:60,effort:2}};case"web":default:return{jpeg:{quality:82,mozjpeg:!0,progressive:!0},png:{compressionLevel:8,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4}}}}function p(J,Z){let Y=Z?b(Z):b("web"),K=J.formatQuality||{};return{jpeg:{...Y.jpeg,...K.jpeg},png:{...Y.png,...K.png},webp:{...Y.webp,...K.webp},avif:{...Y.avif,...K.avif}}}async function g(J,Z,Y){let K=await R();if(!K)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:J,processed:!1};let X=await w(J,Z,Y);if(X)return X;try{let N=h(J);if(!await M(N))return{src:J,processed:!1,errors:[`Source file not found: ${J}`]};let L=p(Y,Z.preset),V=Y.outputDir||"dist/images",F=Y.baseUrl||"/images";await l(V,{recursive:!0});let q=await x(N),U=f(J,u(J)),E=Z.outputFormat?[Z.outputFormat]:Y.defaultFormats||["avif","webp","jpeg"],G={src:J,processed:!0,variants:[],hash:q},j=null;if(Z.transformations&&Z.transformations.length>0)j=await D(N,Z.transformations,K);for(let $ of E){let A=L[$]||{},W=`${U}-${q}.${$}`,_=m(V,W);try{let O=await K.optimizeImage({input:j||N,output:_,format:$,quality:A.quality,progressive:A.progressive});if(O){if(G.variants.push({path:_,url:`${F}/${W}`,width:O.width||0,height:O.height||0,format:$,size:O.outputSize||0}),!G.originalWidth&&O.width)G.originalWidth=O.width,G.originalHeight=O.height}}catch(O){G.errors=G.errors||[],G.errors.push(`Failed to optimize ${$}: ${O}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let $=await K.generateThumbHash(N);G.placeholder=$.dataUrl}catch($){G.errors=G.errors||[],G.errors.push(`Failed to generate thumbhash: ${$}`)}if(Z.useDominantColor)try{let $=await K.generatePlaceholder(N,{strategy:"dominant-color"});G.dominantColor=$.dominantColor}catch($){G.errors=G.errors||[],G.errors.push(`Failed to extract dominant color: ${$}`)}return await Q(J,Z,G,Y),G}catch(N){return{src:J,processed:!1,errors:[`Processing failed: ${N}`]}}}async function n(J,Z,Y,K){let X=await R();if(!X)return{success:!1,error:"ts-images not installed"};try{return{success:!0,size:(await X.optimizeImage({input:J,output:K,format:Z,quality:Y}))?.outputSize}}catch(N){return{success:!1,error:String(N)}}}async function D(J,Z,Y){let K=Y||await R();if(!K)return console.warn("[stx-media] ts-images not installed, skipping transformations"),null;try{let X=await K.decode(J);for(let N of Z){let L=N.options||{};switch(N.type){case"resize":if(L.width||L.height)X=await K.resize(X,{width:L.width,height:L.height,fit:L.fit});break;case"blur":if(L.sigma!==void 0)X=await K.blur(X,L.sigma);break;case"sharpen":if(L.amount!==void 0)X=await K.sharpen(X,L.amount);break;case"grayscale":X=await K.grayscale(X);break;case"rotate":if(L.angle!==void 0)X=await K.rotate(X,L.angle);break;case"flip":X=await K.flip(X);break;case"flop":X=await K.flop(X);break;case"brightness":if(L.value!==void 0)X=await K.brightness(X,L.value);break;case"contrast":if(L.value!==void 0)X=await K.contrast(X,L.value);break;case"saturation":if(L.value!==void 0)X=await K.saturation(X,L.value);break}}return await K.encode(X,"png")}catch(X){return console.error(`[stx-media] Transformation failed: ${X}`),null}}import{resolve as c,basename as i,extname as r,join as o}from"path";import{mkdir as a}from"fs/promises";async function e(){try{return await import("ts-images")}catch{return null}}var s=[320,480,640,768,1024,1280,1536,1920];async function t(J,Z,Y){let K=await e();if(!K)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let X=c(J);if(!await M(X))return console.warn(`[stx-media] Source file not found: ${J}`),null;try{let N=Z.responsiveWidths||Y.breakpoints||s,L=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],V=Y.outputDir||"dist/images",F=Y.baseUrl||"/images";await a(V,{recursive:!0});let q=await x(X),U=i(J,r(J)),E=Y.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},G={src:J,byFormat:{},srcsets:{}};for(let $ of L){G.byFormat[$]=[];let A=[];for(let W of N){let _=`${U}-${W}w-${q}.${$}`,O=o(V,_),B=`${F}/${_}`;try{let T=E[$]?.quality||80;if(await M(O)){G.byFormat[$].push({path:O,url:B,width:W,height:0,format:$,size:0}),A.push(`${B} ${W}w`);continue}let k=await K.processImage({input:X,output:O,format:$,quality:T,resize:{width:W}});if(k)G.byFormat[$].push({path:O,url:B,width:W,height:k.height||Math.round(W*(k.height||1)/(k.width||1)),format:$,size:k.outputSize||0}),A.push(`${B} ${W}w`)}catch(T){console.warn(`[stx-media] Failed to generate ${$} at ${W}w: ${T}`)}}G.srcsets[$]=A.join(", ")}let j=Z.placeholder||Y.placeholderStrategy||"thumbhash";if(j!=="none")try{if(j==="thumbhash"){let $=await K.generateThumbHash(X);G.placeholder={dataURL:$.dataUrl,width:$.width||32,height:$.height||32,strategy:"thumbhash"}}else{let $=await K.generatePlaceholder(X,{strategy:j,width:20});G.placeholder={dataURL:$.dataURL,width:$.width,height:$.height,strategy:j}}}catch($){console.warn(`[stx-media] Failed to generate placeholder: ${$}`)}return G.sizes=Z.sizes||JJ(N),G}catch(N){return console.error(`[stx-media] Responsive generation failed: ${N}`),null}}function JJ(J){let Z=[...J].sort((K,X)=>K-X),Y=[];for(let K=0;K<Z.length-1;K++){let X=Z[K];Y.push(`(max-width: ${X}px) ${X}px`)}return Y.push(`${Z[Z.length-1]}px`),Y.join(", ")}function KJ(J,Z="width"){if(!J||J.length===0)return"";if(Z==="dpr")return J.filter((Y)=>Y.dpr).map((Y)=>`${Y.url} ${Y.dpr}x`).join(", ");return J.map((Y)=>`${Y.url} ${Y.width}w`).join(", ")}export{z as $g,w as ah,Q as bh,d as ch,g as dh,n as eh,D as fh,t as gh,KJ as hh};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
var K={},Y=[],O={};function I(){return K}function h(){return O}function D(){K={},Y.length=0,O={}}function U(j){K=Q(K,j)}function Q(j,z){return{title:z.title??j.title,titleTemplate:z.titleTemplate??j.titleTemplate,base:z.base??j.base,meta:[...j.meta||[],...z.meta||[]],link:[...j.link||[],...z.link||[]],script:[...j.script||[],...z.script||[]],style:[...j.style||[],...z.style||[]],htmlAttrs:{...j.htmlAttrs,...z.htmlAttrs},bodyAttrs:{...j.bodyAttrs,...z.bodyAttrs}}}function Z(j){U(_(j))}function _(j){let z=[];if(j.description)z.push({name:"description",content:j.description});if(j.keywords){let L=Array.isArray(j.keywords)?j.keywords.join(", "):j.keywords;z.push({name:"keywords",content:L})}if(j.author)z.push({name:"author",content:j.author});if(j.robots)z.push({name:"robots",content:j.robots});let A=j.ogTitle??j.title,B=j.ogDescription??j.description;if(A)z.push({property:"og:title",content:A});if(B)z.push({property:"og:description",content:B});if(j.ogImage)z.push({property:"og:image",content:j.ogImage});if(j.ogUrl)z.push({property:"og:url",content:j.ogUrl});if(j.ogType)z.push({property:"og:type",content:j.ogType});if(j.ogSiteName)z.push({property:"og:site_name",content:j.ogSiteName});if(j.ogLocale)z.push({property:"og:locale",content:j.ogLocale});let E=j.twitterTitle??j.title,F=j.twitterDescription??j.description,J=j.twitterImage??j.ogImage;if(j.twitterCard)z.push({name:"twitter:card",content:j.twitterCard});if(E)z.push({name:"twitter:title",content:E});if(F)z.push({name:"twitter:description",content:F});if(J)z.push({name:"twitter:image",content:J});if(j.twitterSite)z.push({name:"twitter:site",content:j.twitterSite});if(j.twitterCreator)z.push({name:"twitter:creator",content:j.twitterCreator});if(j.articleAuthor)z.push({property:"article:author",content:j.articleAuthor});if(j.articlePublishedTime)z.push({property:"article:published_time",content:j.articlePublishedTime});if(j.articleModifiedTime)z.push({property:"article:modified_time",content:j.articleModifiedTime});if(j.articleSection)z.push({property:"article:section",content:j.articleSection});if(j.articleTags)for(let L of j.articleTags)z.push({property:"article:tag",content:L});let G=[];if(j.canonical)G.push({rel:"canonical",href:j.canonical});return{title:j.title,titleTemplate:j.titleTemplate,meta:z,link:G}}function S(j){if(O={...O,...j},j.title||j.description)Z({title:j.title,description:j.description})}function P(j){let z=typeof j==="function"?j():j;U({title:z})}function C(j=K){let z=[];if(j.title){let A=j.title;if(j.titleTemplate)A=typeof j.titleTemplate==="function"?j.titleTemplate(A):j.titleTemplate.replace("%s",A);z.push(`<title>${N(A)}</title>`)}if(j.base){let A=Object.entries(j.base).map(([B,E])=>`${B}="${N(E)}"`).join(" ");z.push(`<base ${A}>`)}for(let A of j.meta||[]){let B=Object.entries(A).filter(([E,F])=>F!==void 0).map(([E,F])=>{return`${E==="httpEquiv"?"http-equiv":E}="${N(String(F))}"`}).join(" ");z.push(`<meta ${B}>`)}for(let A of j.link||[]){let B=Object.entries(A).filter(([E,F])=>F!==void 0).map(([E,F])=>`${E}="${N(String(F))}"`).join(" ");z.push(`<link ${B}>`)}for(let A of j.script||[]){let{content:B,...E}=A,F=Object.entries(E).filter(([J,G])=>G!==void 0).map(([J,G])=>{if(typeof G==="boolean")return G?J:"";return`${J}="${N(String(G))}"`}).filter(Boolean).join(" ");if(B)z.push(`<script ${F}>${B}</script>`);else z.push(`<script ${F}></script>`)}for(let A of j.style||[]){let B=A.type?` type="${A.type}"`:"";z.push(`<style${B}>${A.content}</style>`)}return z.join(`
|
|
3
3
|
`)}function M(j=K){if(!j.htmlAttrs)return"";return Object.entries(j.htmlAttrs).map(([z,A])=>`${z}="${N(A)}"`).join(" ")}function V(j=K){if(!j.bodyAttrs)return"";return Object.entries(j.bodyAttrs).map(([z,A])=>`${z}="${N(A)}"`).join(" ")}function N(j){return j.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function w(j=K){if(typeof document>"u")return;if(j.title){let z=j.title;if(j.titleTemplate)z=typeof j.titleTemplate==="function"?j.titleTemplate(z):j.titleTemplate.replace("%s",z);document.title=z}for(let z of j.meta||[]){let A=z.name?`meta[name="${z.name}"]`:z.property?`meta[property="${z.property}"]`:null;if(A){let B=document.querySelector(A);if(!B){if(B=document.createElement("meta"),z.name)B.setAttribute("name",z.name);if(z.property)B.setAttribute("property",z.property);document.head.appendChild(B)}B.setAttribute("content",z.content)}}for(let z of j.link||[]){let A=`link[rel="${z.rel}"]${z.href?`[href="${z.href}"]`:""}`,B=document.querySelector(A);if(!B)B=document.createElement("link"),document.head.appendChild(B);for(let[E,F]of Object.entries(z))if(F!==void 0)B.setAttribute(E,String(F))}if(j.htmlAttrs)for(let[z,A]of Object.entries(j.htmlAttrs))if(z==="class")for(let B of String(A).split(/\s+/).filter(Boolean))document.documentElement.classList.add(B);else document.documentElement.setAttribute(z,A);if(j.bodyAttrs)for(let[z,A]of Object.entries(j.bodyAttrs))document.body.setAttribute(z,A)}function y(j){let z="";return{content:j.replace(/@head\s*([\s\S]*?)@endhead/g,(B,E)=>{return z+=E.trim()+`
|
|
4
|
-
`,""}),headContent:z.trim()}}function x(j,z){return j.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(A,B,E,F)=>{let J=B?E:z[(F||"").trim()]??F,G=z.__stx_runtime_head??{};return z.__stx_runtime_head=Q(G,{title:J}),""})}function T(j,z){return j.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(A,B,E,F,J,G)=>{let L=F?J:G,R=F?L:z[(L||"").trim()]??L,W=E.includes(":")?{property:E,content:R}:{name:E,content:R},X=z.__stx_runtime_head??{};return z.__stx_runtime_head=Q(X,{meta:[W]}),""})}export{I as
|
|
4
|
+
`,""}),headContent:z.trim()}}function x(j,z){return j.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(A,B,E,F)=>{let J=B?E:z[(F||"").trim()]??F,G=z.__stx_runtime_head??{};return z.__stx_runtime_head=Q(G,{title:J}),""})}function T(j,z){return j.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(A,B,E,F,J,G)=>{let L=F?J:G,R=F?L:z[(L||"").trim()]??L,W=E.includes(":")?{property:E,content:R}:{name:E,content:R},X=z.__stx_runtime_head??{};return z.__stx_runtime_head=Q(X,{meta:[W]}),""})}export{I as xu,h as yu,D as zu,U as Au,Q as Bu,Z as Cu,_ as Du,S as Eu,P as Fu,C as Gu,M as Hu,V as Iu,w as Ju,y as Ku,x as Lu,T as Mu};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{ft as Iq}from"./chunk-8jam44my.js";import{cw as N}from"./chunk-jp2f8yzw.js";var Sq={1001:{message:"Unclosed directive: {{directive}}",help:"Make sure to close the directive with the appropriate end tag"},1002:{message:"Unclosed expression at position {{position}}",help:"Check for missing closing braces }}"},1003:{message:"Invalid directive syntax: {{directive}}",help:"Review the directive documentation for correct syntax"},1004:{message:"Malformed expression: {{expression}}",help:"Check for syntax errors in your expression"},1005:{message:"Unexpected token: {{token}}",help:"Remove or fix the unexpected token"},1101:{message:"Undefined variable: {{variable}}",help:"Make sure the variable is defined in the template context"},1102:{message:"Type error: {{details}}",help:"Check that you are using the correct types"},1103:{message:"Evaluation error: {{details}}",help:"Review the expression for errors"},1104:{message:"Infinite loop detected in {{location}}",help:"Check your loop conditions"},1105:{message:"Circular reference detected: {{path}}",help:"Remove the circular dependency"},1201:{message:"Unsafe expression blocked: {{expression}}",help:"This expression contains potentially dangerous code"},1202:{message:"Path traversal attempt blocked: {{path}}",help:"Use only relative paths within allowed directories"},1203:{message:"Potential XSS attempt blocked",help:"Sanitize user input before rendering"},1204:{message:"Code injection attempt blocked: {{code}}",help:"Avoid executing dynamic code"},1205:{message:"Prohibited DOM API usage: {{api}}",help:"Use STX.useRefs(), STX.useRef(), STX.el() and other STX helpers instead of direct DOM manipulation"},1301:{message:"File not found: {{path}}",help:"Check that the file exists and the path is correct"},1302:{message:"Error reading file: {{path}}",help:"Check file permissions and encoding"},1303:{message:"Invalid file path: {{path}}",help:"Use a valid file path"},1304:{message:"Permission denied: {{path}}",help:"Check file permissions"},1401:{message:"Invalid configuration: {{details}}",help:"Review your stx.config.ts file"},1402:{message:"Missing required configuration: {{key}}",help:"Add the required configuration option"},1403:{message:"Deprecated configuration: {{key}}",help:"Update to the new configuration format"},1501:{message:"Component not found: {{name}}",help:"Check that the component exists in your components directory"},1502:{message:"Invalid props for component {{name}}: {{details}}",help:"Check the component prop requirements"},1503:{message:"Error rendering component {{name}}: {{details}}",help:"Check the component template for errors"},1601:{message:"Filter not found: {{filter}}",help:"Register the filter or check the filter name"},1602:{message:"Invalid arguments for filter {{filter}}: {{details}}",help:"Check the filter documentation for correct arguments"},1603:{message:"Expression evaluation timed out",help:"Simplify the expression or increase the timeout"}},P={},qq="en";function Pq(q){qq=q}function Lq(){return qq}function bq(q){P={...P,...q}}function Cq(){P={}}function Jq(q,Q={}){let J=P[q]||Sq[q]||{message:`Unknown error (code: ${q})`},Z=J.message,$=J.help;for(let[W,H]of Object.entries(Q)){let Y=`{{${W}}}`;if(Z=Z.replace(new RegExp(Y,"g"),H),$)$=$.replace(new RegExp(Y,"g"),H)}return{message:Z,help:$}}function yq(q,Q={}){let{message:J,help:Z}=Jq(q,Q);return Z?`${J}
|
|
3
3
|
Help: ${Z}`:J}var j={UNCLOSED_DIRECTIVE:1001,UNCLOSED_EXPRESSION:1002,INVALID_DIRECTIVE_SYNTAX:1003,MALFORMED_EXPRESSION:1004,UNEXPECTED_TOKEN:1005,UNDEFINED_VARIABLE:1101,TYPE_ERROR:1102,EVALUATION_ERROR:1103,INFINITE_LOOP:1104,CIRCULAR_REFERENCE:1105,UNSAFE_EXPRESSION:1201,PATH_TRAVERSAL:1202,XSS_ATTEMPT:1203,CODE_INJECTION:1204,DOM_API_VIOLATION:1205,FILE_NOT_FOUND:1301,FILE_READ_ERROR:1302,INVALID_FILE_PATH:1303,PERMISSION_DENIED:1304,INVALID_CONFIG:1401,MISSING_REQUIRED_CONFIG:1402,DEPRECATED_CONFIG:1403,COMPONENT_NOT_FOUND:1501,INVALID_PROPS:1502,COMPONENT_RENDER_ERROR:1503,FILTER_NOT_FOUND:1601,INVALID_FILTER_ARGS:1602,EXPRESSION_TIMEOUT:1603};function g(q){for(let[Q,J]of Object.entries(j))if(J===q)return Q;return}function vq(){return!1}function E(){return!vq()||process.env.STX_DEBUG==="true"}function oJ(){return!1}import xq from"path";var Qq={showRelativePaths:!1,enableAutoRecovery:E(),logRecoveryWarnings:!0},R={...Qq};function gq(q){R={...R,...q}}function L(){return{...R}}function fq(){R={...Qq}}function b(q){if(!R.showRelativePaths||!q)return q;let Q=R.baseDir||process.cwd();try{let J=xq.relative(Q,q);return J.startsWith("..")?q:J}catch{return q}}class A extends Error{code;filePath;line;column;context;numericCode;constructor(q,Q,J,Z,$,W,H){super(q);this.code=Q;this.filePath=J;this.line=Z;this.column=$;this.context=W;if(this.name="StxError",this.numericCode=H||j.EVALUATION_ERROR,this.filePath)this.filePath=b(this.filePath)}}class Zq extends A{constructor(q,Q,J,Z,$,W){super(q,"stx_SYNTAX_ERROR",Q,J,Z,$,W||j.INVALID_DIRECTIVE_SYNTAX);this.name="StxSyntaxError"}}class $q extends A{constructor(q,Q,J,Z,$,W){super(q,"stx_RUNTIME_ERROR",Q,J,Z,$,W||j.EVALUATION_ERROR);this.name="StxRuntimeError"}}class Xq extends A{constructor(q,Q,J,Z,$,W){super(q,"stx_SECURITY_ERROR",Q,J,Z,$,W||j.UNSAFE_EXPRESSION);this.name="StxSecurityError"}}class Wq extends A{constructor(q,Q,J,Z,$,W){super(q,"stx_FILE_ERROR",Q,J,Z,$,W||j.FILE_NOT_FOUND);this.name="StxFileError"}}class Yq extends A{isFatal=!0;constructor(q,Q,J,Z,$,W){super(q,"stx_VALIDATION_ERROR",Q,J,Z,$,W||j.DOM_API_VIOLATION);this.name="StxValidationError"}}function f(q){let{type:Q,message:J,code:Z,filePath:$,line:W,column:H,template:Y,offset:X,snippet:B,suggestion:G,format:V="text"}=q,_=W,M=H;if(!_&&Y&&X!==void 0){let z=Gq(Y,X);_=z.line,M=z.column}let U=$?b($):void 0,w=Z?g(Z):void 0,O={type:Q,code:Z,codeName:w,message:J,filePath:U,line:_,column:M,snippet:B,suggestion:G,timestamp:new Date().toISOString()},F;switch(V){case"html":F=uq(O);break;case"json":F=JSON.stringify(O,null,2);break;case"console":F=dq(O,Y,X);break;case"text":default:F=hq(O,Y,X);break}return{formatted:F,data:O}}function hq(q,Q,J){let Z=[],$=q.code?` [${q.codeName||q.code}]`:"";if(Z.push(`[${q.type} Error${$}]`),q.filePath){let W=q.filePath;if(q.line){if(W+=`:${q.line}`,q.column)W+=`:${q.column}`}Z.push(`at ${W}`)}if(Z.push(`
|
|
4
4
|
${q.message}`),Q&&q.line){let W=pq(Q,q.line,2);if(W)Z.push(`
|
|
5
5
|
${W}`)}if(q.snippet)Z.push(`
|
|
@@ -57,4 +57,4 @@ catch (e) {
|
|
|
57
57
|
border-width: 0;
|
|
58
58
|
}
|
|
59
59
|
`.trim()}function hJ(){return typeof globalThis.document<"u"&&typeof globalThis.document.createElement==="function"}function Nq(q){let Q=new Map,J=q.replace(/<(\/?)([A-Z][\w:.-]*)(?=[\s/>])/g,($,W,H)=>{let Y=Q.get(H);if(!Y)Y=`stx-a11y-component-${Q.size}`,Q.set(H,Y);return`<${W}${Y}`}),Z=new Map([...Q.entries()].map(([$,W])=>[W,$]));return{protectedSource:J,restore:($)=>$.replace(/<(\/?)(stx-a11y-component-\d+)(?=[\s/>])/g,(W,H,Y)=>{let X=Z.get(Y);return X?`<${H}${X}`:W})}}function uJ(q,Q){let J=[],Z=/<img\s+([^>]*)>/gi,$;$=Z.exec(q);while($!==null){let F=$[1];if(!/\balt\s*=/i.test(F))J.push({type:"missing-alt",element:$[0].substring(0,100),message:"Image missing alt attribute",impact:"serious",help:"Add alt text to images for screen readers",helpUrl:"https://web.dev/learn/accessibility/images/"});$=Z.exec(q)}let W=/<button([^>]*)>\s*<\/button>/gi;$=W.exec(q);while($!==null){let F=$[1];if(!/\baria-label\s*=/i.test(F)&&!/\btitle\s*=/i.test(F))J.push({type:"missing-accessible-name",element:$[0].substring(0,100),message:"Empty button missing accessible name",impact:"critical",help:"Add text content, aria-label, or title",helpUrl:"https://web.dev/learn/accessibility/aria-html/"});$=W.exec(q)}let H=/<a\s+([^>]*)>\s*<\/a>/gi;$=H.exec(q);while($!==null){let F=$[1];if(!/\baria-label\s*=/i.test(F)&&!/\btitle\s*=/i.test(F))J.push({type:"link-missing-text",element:$[0].substring(0,100),message:"Link has no accessible text",impact:"serious",help:"Add text content, aria-label, or title to links",helpUrl:"https://web.dev/learn/accessibility/more-html/#links"});$=H.exec(q)}let Y=/<(input|select|textarea)\s+([^>]*)>/gi;$=Y.exec(q);while($!==null){let F=$[2];if(/\btype\s*=\s*["']hidden["']/i.test(F)){$=Y.exec(q);continue}let z=/\baria-label\s*=/i.test(F)||/\baria-labelledby\s*=/i.test(F),T=F.match(/\bid\s*=\s*["']([^"']+)["']/i);if(!z){let Rq=T&&new RegExp(`<label[^>]*\\bfor\\s*=\\s*["']${T[1]}["']`,"i").test(q),t=$.index,e=q.substring(0,t),rJ=q.substring(t),Tq=(e.match(/<label\b/gi)||[]).length,Eq=(e.match(/<\/label>/gi)||[]).length,kq=Tq>Eq;if(!Rq&&!kq)J.push({type:"input-missing-label",element:$[0].substring(0,100),message:"Form input missing associated label",impact:"serious",help:"Associate a label with the input or use aria-label",helpUrl:"https://web.dev/learn/accessibility/forms/"})}$=Y.exec(q)}let X=/<h([1-6])[^>]*>/gi,B=[];$=X.exec(q);while($!==null)B.push(Number.parseInt($[1],10)),$=X.exec(q);let G=0;for(let F of B){if(G>0&&F>G+1)J.push({type:"heading-skip",element:`<h${F}>`,message:`Heading level skipped from h${G} to h${F}`,impact:"moderate",help:"Maintain proper heading hierarchy without skipping levels",helpUrl:"https://web.dev/learn/accessibility/structure/"});G=F}if(/<html\b/i.test(q)&&!/<html[^>]*\slang\s*=/i.test(q))J.push({type:"missing-lang",element:"<html>",message:"Document language not specified",impact:"serious",help:"Add lang attribute to the html element",helpUrl:"https://web.dev/learn/accessibility/more-html/#language"});let V=q.match(/<html\b([^>]*)>/i);if(V&&a(S(V[1],"lang"),S(V[1],"dir")))J.push({type:"missing-dir",element:V[0].substring(0,100),message:'Document language is right-to-left but dir="rtl" is not set',impact:"serious",help:'Add dir="rtl" to the html element so the layout mirrors the text',helpUrl:"https://www.w3.org/International/questions/qa-html-dir"});let _=/<table([^>]*)>([\s\S]*?)<\/table>/gi;$=_.exec(q);while($!==null){let F=$[2];if(!Aq(S($[1],"role"))&&!/<th\b/i.test(F))J.push({type:"table-missing-headers",element:"<table>",message:"Table missing header cells (th)",impact:"serious",help:"Use th elements for table headers",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"});$=_.exec(q)}let M=/<(video|audio)[^>]*\sautoplay\s[^>]*>/gi;$=M.exec(q);while($!==null){if(!/\bmuted\b/i.test($[0]))J.push({type:"autoplay-audio",element:`<${$[1]}>`,message:"Auto-playing media may disrupt users",impact:"moderate",help:"Add muted attribute or provide controls to stop playback",helpUrl:"https://web.dev/learn/accessibility/more-html/#multimedia"});$=M.exec(q)}let U=/\btabindex\s*=\s*["']([1-9]\d*)["']/gi;$=U.exec(q);while($!==null)J.push({type:"positive-tabindex",element:`tabindex="${$[1]}"`,message:"Positive tabindex disrupts natural tab order",impact:"moderate",help:'Use tabindex="0" or "-1" instead of positive values',helpUrl:"https://web.dev/learn/accessibility/focus/#tab-index"}),$=U.exec(q);let w=/<iframe\s+([^>]*)>/gi;$=w.exec(q);while($!==null){let F=$[1];if(!/\btitle\s*=/i.test(F)&&!/\baria-label\s*=/i.test(F))J.push({type:"iframe-missing-title",element:"<iframe>",message:"Iframe missing title attribute",impact:"serious",help:"Add a title attribute to describe the iframe content",helpUrl:"https://web.dev/learn/accessibility/more-html/#frames"});$=w.exec(q)}let O=/<([a-z]+)\s+([^>]*role\s*=\s*["']button["'][^>]*)>/gi;$=O.exec(q);while($!==null){let F=$[1].toLowerCase(),z=$[2];if(F!=="button"&&!/\btabindex\s*=/i.test(z))J.push({type:"button-not-focusable",element:$[0].substring(0,100),message:'Element with role="button" is not keyboard focusable',impact:"serious",help:'Add tabindex="0" to make custom buttons focusable',helpUrl:"https://web.dev/learn/accessibility/focus/"});$=O.exec(q)}return J}async function dJ(q,Q){let{protectedSource:J}=Nq(q);if(!hJ())return uJ(J,Q);let Z=[];try{let $=globalThis.document.createElement("div");$.innerHTML=J,$.querySelectorAll("img").forEach((X)=>{if(!X.hasAttribute("alt"))Z.push({type:"missing-alt",element:`<${X.outerHTML}>`,message:"Image missing alt attribute",impact:"serious",help:"Add alt text to images for screen readers",helpUrl:"https://web.dev/learn/accessibility/images/"})}),$.querySelectorAll('button, a, [role="button"]').forEach((X)=>{if(!(X.hasAttribute("aria-label")||X.hasAttribute("aria-labelledby")||X.textContent&&X.textContent.trim().length>0))Z.push({type:"missing-accessible-name",element:`<${X.outerHTML}>`,message:"Interactive element missing accessible name",impact:"critical",help:"Add text content, aria-label, or aria-labelledby",helpUrl:"https://web.dev/learn/accessibility/aria-html/"})}),$.querySelectorAll("input, select, textarea").forEach((X)=>{let B=X.getAttribute("id"),G=B&&$.querySelector(`label[for="${B}"]`),V=X.hasAttribute("aria-label")||X.hasAttribute("aria-labelledby"),_=X.closest("label")!==null;if(!G&&!V&&!_)Z.push({type:"input-missing-label",element:`<${X.outerHTML}>`,message:"Form input missing associated label",impact:"serious",help:"Associate a label with the input or use aria-label",helpUrl:"https://web.dev/learn/accessibility/forms/"})});let W=Array.from($.querySelectorAll("h1, h2, h3, h4, h5, h6")),H=0;for(let X of W){let B=Number.parseInt(X.tagName.charAt(1));if(H>0&&B>H+1)Z.push({type:"heading-skip",element:`<${X.outerHTML}>`,message:`Heading level skipped from h${H} to h${B}`,impact:"moderate",help:"Maintain proper heading hierarchy without skipping levels",helpUrl:"https://web.dev/learn/accessibility/structure/"});H=B}let Y=$.querySelector("html");if(J.includes("<html")&&Y&&!Y.hasAttribute("lang"))Z.push({type:"missing-lang",element:"<html>",message:"Document language not specified",impact:"serious",help:"Add lang attribute to the html element",helpUrl:"https://web.dev/learn/accessibility/more-html/#language"});if(Y&&a(Y.getAttribute("lang"),Y.getAttribute("dir")))Z.push({type:"missing-dir",element:"<html>",message:'Document language is right-to-left but dir="rtl" is not set',impact:"serious",help:'Add dir="rtl" to the html element so the layout mirrors the text',helpUrl:"https://www.w3.org/International/questions/qa-html-dir"});if($.querySelectorAll("a").forEach((X)=>{let B=X.textContent&&X.textContent.trim().length>0,G=X.hasAttribute("aria-label")||X.hasAttribute("aria-labelledby"),V=X.hasAttribute("title"),_=X.querySelector("img[alt]");if(!B&&!G&&!V&&!_)Z.push({type:"link-missing-text",element:`<${X.outerHTML}>`,message:"Link has no accessible text",impact:"serious",help:"Add text content, aria-label, or title to links",helpUrl:"https://web.dev/learn/accessibility/more-html/#links"})}),J.includes("<nav")||J.includes("<header")){if(!$.querySelector('a[href="#main"], a[href="#content"], .skip-link, [class*="skip"]')&&$.querySelectorAll("a").length>5)Z.push({type:"missing-skip-link",element:"<nav>",message:"Consider adding a skip navigation link",impact:"minor",help:"Add a skip link to allow keyboard users to bypass navigation",helpUrl:"https://web.dev/learn/accessibility/focus/#skip-links"})}if($.querySelectorAll("table").forEach((X)=>{if(Aq(X.getAttribute("role")))return;let B=X.querySelector("caption");if(!X.querySelector("th"))Z.push({type:"table-missing-headers",element:"<table>",message:"Table missing header cells (th)",impact:"serious",help:"Use th elements for table headers",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"});if(!B&&!X.hasAttribute("aria-label")&&!X.hasAttribute("aria-labelledby"))Z.push({type:"table-missing-caption",element:"<table>",message:"Table missing caption or accessible name",impact:"minor",help:"Add a caption element or aria-label to describe the table",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"})}),$.querySelectorAll('[style*="color"]').forEach((X)=>{let B=X.getAttribute("style")||"";if(B.includes("color:")&&!B.includes("background"))Z.push({type:"potential-contrast-issue",element:`<${X.tagName.toLowerCase()}>`,message:"Element has inline color style - verify contrast ratio",impact:"minor",help:"Ensure text has sufficient contrast ratio (4.5:1 for normal text)",helpUrl:"https://web.dev/learn/accessibility/color-contrast/"})}),$.querySelectorAll("video[autoplay], audio[autoplay]").forEach((X)=>{if(!X.hasAttribute("muted"))Z.push({type:"autoplay-audio",element:`<${X.tagName.toLowerCase()}>`,message:"Auto-playing media may disrupt users",impact:"moderate",help:"Add muted attribute or provide controls to stop playback",helpUrl:"https://web.dev/learn/accessibility/more-html/#multimedia"})}),$.querySelectorAll("[tabindex]").forEach((X)=>{if(Number.parseInt(X.getAttribute("tabindex")||"0")>0)Z.push({type:"positive-tabindex",element:`<${X.tagName.toLowerCase()}>`,message:"Positive tabindex disrupts natural tab order",impact:"moderate",help:'Use tabindex="0" or "-1" instead of positive values',helpUrl:"https://web.dev/learn/accessibility/focus/#tab-index"})}),$.querySelectorAll('[role="button"]').forEach((X)=>{if(!X.hasAttribute("tabindex"))Z.push({type:"button-not-focusable",element:`<${X.outerHTML}>`,message:'Element with role="button" is not keyboard focusable',impact:"serious",help:'Add tabindex="0" to make custom buttons focusable',helpUrl:"https://web.dev/learn/accessibility/focus/"})}),J.includes("<body")&&!$.querySelector('main, [role="main"]'))Z.push({type:"missing-main-landmark",element:"<body>",message:"Document missing main landmark region",impact:"moderate",help:"Add a main element to identify the primary content",helpUrl:"https://web.dev/learn/accessibility/structure/#landmarks"});$.querySelectorAll("iframe").forEach((X)=>{if(!X.hasAttribute("title")&&!X.hasAttribute("aria-label"))Z.push({type:"iframe-missing-title",element:"<iframe>",message:"Iframe missing title attribute",impact:"serious",help:"Add a title attribute to describe the iframe content",helpUrl:"https://web.dev/learn/accessibility/more-html/#frames"})})}catch($){console.error(`Error checking accessibility in ${Q}:`,$)}return Z}async function pJ(q,Q={}){let J={},{recursive:Z=!0,ignorePaths:$=[]}=Q,W=Array.isArray(q)?q:[q],H=await Iq(W,{recursive:Z,ignorePaths:$}),Y=[];for(let X of H)try{let B=await Bun.file(X).text();if(X.endsWith("good-a11y.stx"))continue;let G=await dJ(B,X);if(Y.push(X),G.length>0)J[X]=G}catch(B){console.error(`Error scanning ${X}:`,B)}return{results:J,scannedFiles:Y}}async function cQ(q,Q={}){return(await pJ(q,Q)).results}var mJ={fixMissingAlt:!0,fixMissingLabels:!0,fixMissingFormLabels:!0,fixTableHeaders:!0,fixMissingLang:!0,fixMissingDir:!0,fixPositiveTabindex:!0,fixButtonFocusable:!0,defaultLang:"en"};function cJ(q,Q={}){let J={...mJ,...Q},Z=[],{protectedSource:$,restore:W}=Nq(q),H=$;if(J.fixMissingAlt)H=H.replace(/<img([^>]*?)(?<!\balt\s*=\s*["'][^"']*["'])(\s*\/?>)/gi,(Y,X,B)=>{if(/\balt\s*=/i.test(X))return Y;let G=Y,V=`<img${X} alt=""${B}`;return Z.push({type:"missing-alt",description:"Added empty alt attribute to image",before:G,after:V}),V});if(J.fixMissingLabels)H=H.replace(/<button([^>]*)>\s*<\/button>/gi,(Y,X)=>{if(/\baria-label\s*=/i.test(X)||/\btitle\s*=/i.test(X))return Y;let B=Y,G=`<button${X} aria-label="Button"></button>`;return Z.push({type:"missing-accessible-name",description:"Added aria-label to empty button",before:B,after:G}),G}),H=H.replace(/<a([^>]*)>\s*(<(?:i|span|svg)[^>]*(?:class="[^"]*icon[^"]*")?[^>]*>.*?<\/(?:i|span|svg)>)?\s*<\/a>/gi,(Y,X,B)=>{if(/\baria-label\s*=/i.test(X)||/\btitle\s*=/i.test(X))return Y;if(!B&&Y.replace(/<a[^>]*>|<\/a>/gi,"").trim())return Y;let G=Y,V=`<a${X} aria-label="Link">${B||""}</a>`;return Z.push({type:"missing-accessible-name",description:"Added aria-label to link without text",before:G,after:V}),V});if(J.fixMissingFormLabels)H=H.replace(/<(input|select|textarea)([^>]*)>/gi,(Y,X,B)=>{if(/\baria-label\s*=/i.test(B)||/\baria-labelledby\s*=/i.test(B))return Y;if(/\btype\s*=\s*["']hidden["']/i.test(B))return Y;let G=B.match(/\bname\s*=\s*["']([^"']+)["']/i),V=B.match(/\bid\s*=\s*["']([^"']+)["']/i),_=G?.[1]||V?.[1]||X,M=Y,U=`<${X}${B} aria-label="${_}">`;return Z.push({type:"input-missing-label",description:`Added aria-label to ${X} element`,before:M,after:U}),U});if(J.fixMissingLang)H=H.replace(/<html([^>]*)>/gi,(Y,X)=>{if(/\blang\s*=/i.test(X))return Y;let B=Y,G=`<html${X} lang="${J.defaultLang}">`;return Z.push({type:"missing-lang",description:`Added lang="${J.defaultLang}" to html element`,before:B,after:G}),G});if(J.fixMissingDir)H=H.replace(/<html([^>]*)>/gi,(Y,X)=>{let B=S(X,"lang");if(!a(B,S(X,"dir")))return Y;let G=/\bdir\s*=/i.test(X)?`<html${X.replace(/\bdir\s*=\s*(["'])[^"']*\1/i,'dir="rtl"')}>`:`<html${X} dir="rtl">`;return Z.push({type:"missing-dir",description:`Added dir="rtl" to html element (lang="${B}" is right-to-left)`,before:Y,after:G}),G});if(J.fixPositiveTabindex)H=H.replace(/\btabindex\s*=\s*["']([1-9]\d*)["']/gi,(Y,X)=>{let B=Y,G='tabindex="0"';return Z.push({type:"positive-tabindex",description:`Changed tabindex="${X}" to tabindex="0"`,before:B,after:'tabindex="0"'}),'tabindex="0"'});if(J.fixButtonFocusable)H=H.replace(/<([a-z]+)(\s[^>]*role\s*=\s*["']button["'][^>]*)>/gi,(Y,X,B)=>{if(/\btabindex\s*=/i.test(B))return Y;if(X.toLowerCase()==="button")return Y;let G=Y,V=`<${X}${B} tabindex="0">`;return Z.push({type:"button-not-focusable",description:'Added tabindex="0" to element with role="button"',before:G,after:V}),V});if(J.fixTableHeaders)H=H.replace(/<th([^>]*)>/gi,(Y,X)=>{if(/\bscope\s*=/i.test(X))return Y;let B=Y,G=`<th${X} scope="col">`;return Z.push({type:"table-missing-scope",description:'Added scope="col" to table header',before:B,after:G}),G});return{original:q,fixed:W(H),fixCount:Z.length,fixes:Z}}async function lJ(q,Q={},J=!1){let Z=await Bun.file(q).text(),$=cJ(Z,Q);if(J&&$.fixCount>0)await Bun.write(q,$.fixed);return $}async function lQ(q,Q={},J={}){let Z={},{recursive:$=!0,ignorePaths:W=[],writeBack:H=!1,extensions:Y=[".stx",".html",".htm"]}=J,X=Y.length===1?`*${Y[0]}`:`*{${Y.join(",")}}`,B=zq.join(q,$?`**/${X}`:X),G=new Bun.Glob(B);for await(let V of G.scan()){if(W.some((M)=>V.includes(zq.normalize(M))))continue;try{let M=await lJ(V,Q,H);if(M.fixCount>0)Z[V]=M}catch(M){console.error(`Error fixing ${V}:`,M)}}return Z}var sJ={name:"a11y",handler:(q,Q,J,Z)=>{if(!Q.length)return q;let $=Q[0].replace(/['"]/g,""),W=Q.length>1?Q[1].replace(/['"]/g,""):"",Y={"aria-label":"Ensure interactive elements have accessible labels","alt-text":"Provide alternative text for images",focus:"Ensure the element can receive keyboard focus",landmark:"Use appropriate landmark roles","heading-order":"Maintain proper heading hierarchy","color-contrast":"Ensure sufficient color contrast","keyboard-nav":"Make sure element is keyboard navigable","screen-reader":"Optimize for screen reader users"}[$]||"Make this element accessible";return`<!-- a11y-hint: ${W||Y} -->${q}`},hasEndTag:!1},iJ={name:"screenReader",handler:(q)=>{return`<span class="sr-only">${q}</span>`},hasEndTag:!0};function sQ(){return[sJ,iJ]}
|
|
60
|
-
export{Pq as
|
|
60
|
+
export{Pq as Er,Lq as Fr,bq as Gr,Cq as Hr,Jq as Ir,yq as Jr,j as Kr,g as Lr,vq as Mr,E as Nr,oJ as Or,gq as Pr,L as Qr,fq as Rr,b as Sr,A as Tr,Zq as Ur,$q as Vr,Xq as Wr,Wq as Xr,Yq as Yr,f as Zr,C as _r,cq as $r,lq as as,sq as bs,iq as cs,rq as ds,h as es,nq as fs,oq as gs,d as hs,y as is,tq as js,eq as ks,qJ as ls,Bq as ms,Mq as ns,HJ as os,OQ as ps,m as qs,jQ as rs,_J as ss,FJ as ts,DQ as us,r as vs,RQ as ws,TQ as xs,EQ as ys,kQ as zs,SQ as As,wJ as Bs,PQ as Cs,x as Ds,KJ as Es,LQ as Fs,bQ as Gs,CQ as Hs,yQ as Is,AJ as Js,RJ as Ks,gJ as Ls,i as Ms,o as Ns,vQ as Os,xQ as Ps,gQ as Qs,Aq as Rs,S as Ss,pQ as Ts,mQ as Us,hJ as Vs,uJ as Ws,dJ as Xs,pJ as Ys,cQ as Zs,cJ as _s,lJ as $s,lQ as at,sJ as bt,iJ as ct,sQ as dt};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
var{WebView:F}=globalThis.Bun;import{existsSync as V,mkdirSync as k,readdirSync as O,statSync as E}from"fs";import $ from"path";var C=16384;function X(j){if(/^https?:\/\//.test(j)||j.startsWith("file://"))return j;return`file://${$.resolve(j)}`}function K(j,B,z,L){return new Promise((Q)=>{let J=!1,G,Y,R=()=>{if(!J){if(J=!0,clearTimeout(Y),G)clearTimeout(G);j.onNavigated=void 0,Q()}};Y=setTimeout(R,L),j.onNavigated=()=>{if(!J)G=setTimeout(R,z)};try{let Z=j.navigate(B);if(Z&&typeof Z.catch==="function")Z.catch(R)}catch{R()}})}async function U(j,B,z){let L=`!!document.querySelector(${JSON.stringify(B)})`,Q=Date.now()+z;while(Date.now()<Q){try{if(await j.evaluate(L))return}catch{}await new Promise((J)=>setTimeout(J,100))}}async function _(j){try{let B=await j.evaluate("Math.ceil(Math.max(document.documentElement.scrollHeight, document.documentElement.offsetHeight, document.body ? document.body.scrollHeight : 0, document.body ? document.body.offsetHeight : 0))");return typeof B==="number"&&Number.isFinite(B)&&B>0?Math.min(B,C):0}catch{return 0}}async function x(j,B,z={}){let L=Math.min(z.width??1440,C),Q=Math.min(z.height??2200,C),J=z.waitMs??800,G=z.timeoutMs??15000,Y=z.format??"png",R=X(j),Z=(q)=>new F({width:L,height:q,headless:!0,...z.backend?{backend:z.backend}:{}}),P=Z(Q);try{if(await K(P,R,J,G),z.waitSelector)await U(P,z.waitSelector,G);if(z.fullPage){let H=await _(P);if(H>Q){if(P.close(),P=Z(H),await K(P,R,J,G),z.waitSelector)await U(P,z.waitSelector,G)}}let q=await P.screenshot({encoding:"buffer",format:Y});k($.dirname($.resolve(B)),{recursive:!0}),await Bun.write(B,q)}finally{P.close()}if(!V(B))throw Error(`Screenshot was not produced for ${j}`);return{input:j,output:B,bytes:E(B).size}}async function W(j,B,z={}){k(B,{recursive:!0});let L;if(!/^https?:\/\//.test(j)&&V(j)&&E(j).isDirectory())L=O(j).filter((G)=>G.endsWith(".html")).map((G)=>$.join(j,G));else L=[j];let Q=z.format??"png",J=[];for(let G of L){let Y=/^https?:\/\//.test(G)?new URL(G).pathname.replace(/\W+/g,"-").replace(/^-|-$/g,"")||"index":$.basename(G).replace(/\.html?$/,"");J.push(await x(G,$.join(B,`${Y}.${Q}`),z))}return J}
|
|
3
|
-
export{x as
|
|
3
|
+
export{x as Re,W as Se};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
`),B;try{let{bundleClientScript:j}=await import("./chunk-
|
|
2
|
+
import{cw as H}from"./chunk-jp2f8yzw.js";import P from"path";var $=/__stxModules\["((?:[^"\\]|\\.)*)"\]/g;function G(...v){let w=new Set;for(let q of v){if(!q||!q.includes("__stxModules["))continue;for(let z of q.matchAll($))try{w.add(JSON.parse(`"${z[1]}"`))}catch{}}return[...w].sort()}async function T(v,w={}){if(v.length===0)return null;let q=process.cwd(),z=[],J=[];v.forEach((j,X)=>{let Z=j.startsWith("npm:")?j.slice(4):P.resolve(q,j),N=`__stxRegistered${X}`,O=JSON.stringify(j);z.push(`import * as ${N} from ${JSON.stringify(Z)};`),J.push(`if (!globalThis.__stxModules[${O}]) globalThis.__stxModules[${O}] = ${N};`)});let L=[...z,"globalThis.__stxModules = globalThis.__stxModules || {};",...J].join(`
|
|
3
|
+
`),B;try{let{bundleClientScript:j}=await import("./chunk-b1hd8kvy.js");B=await j(L,P.join(q,".stx-module-registry.ts"),{projectRoot:q,minify:w.minify,externalizeUserModules:!1})}catch(j){return console.warn("[stx] could not build the page module registry (#1957):",j),null}let{transformAutoImports:Q,generateAutoImportDestructuring:U}=await import("./chunk-a07chbgj.js"),F=Q(B),V=U(F.stxImports,F.browserImports),{transformStoreImports:W}=await import("./chunk-nws8fbde.js");B=W(F.code);let M=JSON.stringify(new Bun.CryptoHasher("md5").update(L).digest("hex").slice(0,12));return[";(function() {"," var __stxBundles = globalThis.__stxModuleBundles || (globalThis.__stxModuleBundles = {});",` if (__stxBundles[${M}]) return;`,` __stxBundles[${M}] = true;`,V,B,"})();"].join(`
|
|
4
4
|
`)}export{G as registeredModuleIdsIn,T as buildModuleRegistryScript};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Io as x,Po as k,Zl as A,_l as b,_p as w,an as T,bn as y,co as M,om as B,qm as F,uo as R,vr as P}from"./chunk-hay1rzb0.js";import{cw as v}from"./chunk-jp2f8yzw.js";function j(K){return K.endsWith(".md")||K.endsWith(".markdown")}function C(K){let z=[];_(/<pre\b[^>]*>[\s\S]*?<\/pre>/gi);let G=[...z];_(/<code\b[^>]*>[\s\S]*?<\/code>/gi,G);function _(J,Y){let $;while(($=J.exec(K))!==null){let q=$.index,N=q+$[0].length;if(Y?.some((X)=>q>=X.start&&N<=X.end))continue;z.push({start:q,end:N})}}if(z.length===0)return K;z.sort((J,Y)=>J.start-Y.start);let U="",Q=0;for(let J of z){if(J.start<Q)continue;U+=K.slice(Q,J.start),U+=`@raw${K.slice(J.start,J.end)}@endraw`,Q=J.end}return U+=K.slice(Q),U}async function D(K,z={}){let{data:G,content:_}=A(K),Q=await(z.renderer??((J)=>b(J)))(_);return{html:C(Q),frontmatter:G??{}}}import{dirname as f,resolve as H}from"path";function S(K){let z=K,G=M(K);if(G)z=G.content.trim();let _=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,U=[],Q=[],J=[],Y=(N)=>/\b(?:state|derived|effect|batch)\s*(?:<[^<>()]*>)?\s*\(/.test(N),$;while(($=_.exec(K))!==null){let N=$[1],X=$[2],E=$[0],Z=N.includes("server");if(Y(X))J.push(E);else if(Z)Q.push(X);else U.push(E)}let q=z;{let N=/<script\b(?![^>]*\b(?:client|type\s*=\s*["']module["']|src\s*=))[^>]*>/gi,X,E=[];while((X=N.exec(q))!==null){let Z=X.index+X[0].length,L=q.indexOf("</script>",Z);if(L===-1)continue;E.push({start:X.index,end:L+9}),N.lastIndex=L+9}for(let Z=E.length-1;Z>=0;Z--)q=q.substring(0,E[Z].start)+q.substring(E[Z].end)}for(let N of U)q=q.replace(N,"");return{templateContent:q,serverScripts:Q,clientScripts:U,signalsScripts:J}}function g(K,z){return`<!DOCTYPE html>
|
|
3
|
+
<html lang="en">
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
|
+
<title>${(z||"stx").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
${K}
|
|
11
|
+
</body>
|
|
12
|
+
</html>`}async function o(K,z={}){let G=H(K),_=Bun.file(G);if(!await _.exists())throw Error(`Template file not found: ${G}`);let U=await _.text(),Q=null;if(j(G)){let J=await D(U,{renderer:z.markdownRenderer});U=J.html,Q=J.frontmatter}if(Q)z={...z,context:{...Q,...z.context||{}}};if(z.layout){let J=H(z.layout),Y=Bun.file(J);if(!await Y.exists())throw Error(`Layout template not found: ${J}`);let{layout:$,injectCSS:q,...N}=z,X={...z.context||{}};x(X);let E=await V(U,G,{...N,context:{...X,__stx_defer_server_data:!0},injectCSS:!1}),Z=await Y.text(),L={...X,content:E},I={...N,context:L,injectCSS:q};return V(Z,J,I)}return V(U,G,z)}async function r(K,z={},G={}){return V(K,process.cwd(),{context:z,...G})}async function V(K,z,G={}){let{templateContent:_,serverScripts:U,clientScripts:Q}=S(K),J={...P,...G.options},Y={__filename:z,__dirname:f(z),__stx:{},__stx_options:J,__stx_sfc_mode:!0,__stx_inject_css:G.injectCSS===!0,__stxServeContext:void 0,...y(G.context??{}),definePageMeta:()=>{},...G.context||{}};for(let N of U)await k(N,Y,z);let $=new Set,q=_;if(q=await w(q,Y,z,J,$),T(Y,G.context),G.templateOnly){if(q=q.replace(/<script data-stx-scoped>[\s\S]*?<\/script>\s*/gi,""),q=q.replace(/<!-- stx SEO Tags -->[\s\S]*?(?=<)/i,""),Q.length>0)q+=`
|
|
13
|
+
${Q.join(`
|
|
14
|
+
`)}`}else{if(G.processClientScripts!==!1&&Q.length>0){let N=Y.__stx_event_bindings||[],X=B(Y),Z=(await Promise.all(Q.map(async(I)=>{let W=I.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!W)return I;return await F(W[1],{eventBindings:N,templateContent:q,serverData:X,filePath:z})}))).join(`
|
|
15
|
+
`);if(q.match(/(<\/body>)/i))q=q.replace(/(<\/body>)/i,`${Z}
|
|
16
|
+
$1`);else q+=`
|
|
17
|
+
${Z}`}q=await R(q)}if(G.wrapInDocument){if(!q.trim().toLowerCase().startsWith("<!doctype")&&!q.trim().toLowerCase().startsWith("<html"))q=g(q,G.title)}if(G.injectCSS)try{let{injectCss:N}=await import("./chunk-9xzszvn5.js");q=await N(q)}catch{}return q}
|
|
18
|
+
export{j as xk,C as yk,D as zk,o as Ak,r as Bk,V as Ck};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{oo as b,po as c,qo as d}from"./chunk-hay1rzb0.js";import{rs as a}from"./chunk-2h94c5hm.js";import"./chunk-8jam44my.js";import"./chunk-t51mwjyq.js";import"./chunk-wfffa8zm.js";import"./chunk-54f8bpp6.js";import"./chunk-4evbx7sz.js";import"./chunk-jxxv18a0.js";import"./chunk-c131k3mt.js";import"./chunk-hgjjnjas.js";import"./chunk-nqq7y7m9.js";import"./chunk-1c2j4eby.js";import"./chunk-kxavsh3m.js";import"./chunk-qev11kg8.js";import"./chunk-rrankpmj.js";import"./chunk-fczfdsab.js";import"./chunk-fp7ms6e7.js";import"./chunk-jp2f8yzw.js";export{b as rendersAsElement,c as processESImports,d as processComponents,a as freeIdentifiers};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Te as a}from"./chunk-9vqnrcrw.js";import"./chunk-hay1rzb0.js";import"./chunk-2h94c5hm.js";import"./chunk-8jam44my.js";import"./chunk-t51mwjyq.js";import"./chunk-wfffa8zm.js";import"./chunk-54f8bpp6.js";import"./chunk-4evbx7sz.js";import"./chunk-jxxv18a0.js";import"./chunk-c131k3mt.js";import"./chunk-hgjjnjas.js";import"./chunk-nqq7y7m9.js";import"./chunk-1c2j4eby.js";import"./chunk-kxavsh3m.js";import"./chunk-qev11kg8.js";import"./chunk-rrankpmj.js";import"./chunk-fczfdsab.js";import"./chunk-fp7ms6e7.js";import"./chunk-jp2f8yzw.js";export{a as startInteractive};
|