@emberkit/core 0.1.2 → 0.2.1
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/boundaries/error-boundary.d.ts +29 -0
- package/dist/boundaries/error-boundary.d.ts.map +1 -0
- package/dist/boundaries/errors.d.ts +39 -0
- package/dist/boundaries/errors.d.ts.map +1 -0
- package/dist/boundaries/index.d.ts +5 -0
- package/dist/boundaries/index.d.ts.map +1 -0
- package/dist/boundaries/loading-boundary.d.ts +42 -0
- package/dist/boundaries/loading-boundary.d.ts.map +1 -0
- package/dist/cache/index.d.ts +60 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/compiler/compiler.d.ts +6 -0
- package/dist/compiler/compiler.d.ts.map +1 -0
- package/dist/compiler/helpers/attributes.d.ts +4 -0
- package/dist/compiler/helpers/attributes.d.ts.map +1 -0
- package/dist/compiler/helpers/utils.d.ts +10 -0
- package/dist/compiler/helpers/utils.d.ts.map +1 -0
- package/dist/compiler/index.d.ts +5 -0
- package/dist/compiler/index.d.ts.map +1 -0
- package/dist/compiler/types.d.ts +40 -0
- package/dist/compiler/types.d.ts.map +1 -0
- package/dist/context/index.d.ts +34 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/types.d.ts +10 -0
- package/dist/context/types.d.ts.map +1 -0
- package/dist/dev-server/index.d.ts +30 -0
- package/dist/dev-server/index.d.ts.map +1 -0
- package/dist/forms/index.d.ts +58 -0
- package/dist/forms/index.d.ts.map +1 -0
- package/dist/forms/mutations.d.ts +48 -0
- package/dist/forms/mutations.d.ts.map +1 -0
- package/dist/hmr/client.d.ts +18 -0
- package/dist/hmr/client.d.ts.map +1 -0
- package/dist/hmr/index.d.ts +3 -0
- package/dist/hmr/index.d.ts.map +1 -0
- package/dist/hmr/types.d.ts +42 -0
- package/dist/hmr/types.d.ts.map +1 -0
- package/dist/hydration/helpers/analyzer.d.ts +9 -0
- package/dist/hydration/helpers/analyzer.d.ts.map +1 -0
- package/dist/hydration/helpers/hydration.d.ts +19 -0
- package/dist/hydration/helpers/hydration.d.ts.map +1 -0
- package/dist/hydration/index.d.ts +4 -0
- package/dist/hydration/index.d.ts.map +1 -0
- package/dist/hydration/types.d.ts +27 -0
- package/dist/hydration/types.d.ts.map +1 -0
- package/dist/image/index.d.ts +9 -0
- package/dist/image/index.d.ts.map +1 -0
- package/dist/image/processor.d.ts +57 -0
- package/dist/image/processor.d.ts.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/jsx-dev-runtime.d.ts +11 -0
- package/dist/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/jsx-runtime.d.ts +11 -0
- package/dist/jsx-runtime.d.ts.map +1 -0
- package/dist/loader/helpers/loader.d.ts +6 -0
- package/dist/loader/helpers/loader.d.ts.map +1 -0
- package/dist/loader/index.d.ts +3 -0
- package/dist/loader/index.d.ts.map +1 -0
- package/dist/loader/types.d.ts +34 -0
- package/dist/loader/types.d.ts.map +1 -0
- package/dist/markdown/index.d.ts +77 -0
- package/dist/markdown/index.d.ts.map +1 -0
- package/dist/markdown/index.js +10 -8
- package/dist/mdx/index.d.ts +43 -0
- package/dist/mdx/index.d.ts.map +1 -0
- package/dist/mdx/loader.d.ts +3 -0
- package/dist/mdx/loader.d.ts.map +1 -0
- package/dist/meta/head-registry.d.ts +5 -0
- package/dist/meta/head-registry.d.ts.map +1 -0
- package/dist/meta/head.d.ts +29 -0
- package/dist/meta/head.d.ts.map +1 -0
- package/dist/meta/index.d.ts +91 -0
- package/dist/meta/index.d.ts.map +1 -0
- package/dist/navigation/helpers/navigation.d.ts +15 -0
- package/dist/navigation/helpers/navigation.d.ts.map +1 -0
- package/dist/navigation/helpers/useNavigate.d.ts +6 -0
- package/dist/navigation/helpers/useNavigate.d.ts.map +1 -0
- package/dist/navigation/index.d.ts +5 -0
- package/dist/navigation/index.d.ts.map +1 -0
- package/dist/navigation/types.d.ts +24 -0
- package/dist/navigation/types.d.ts.map +1 -0
- package/dist/plugin/index.d.ts +73 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/router/helpers/path.d.ts +15 -0
- package/dist/router/helpers/path.d.ts.map +1 -0
- package/dist/router/helpers/route.d.ts +6 -0
- package/dist/router/helpers/route.d.ts.map +1 -0
- package/dist/router/index.d.ts +35 -0
- package/dist/router/index.d.ts.map +1 -0
- package/dist/router/types.d.ts +30 -0
- package/dist/router/types.d.ts.map +1 -0
- package/dist/runtime/helpers/element.d.ts +7 -0
- package/dist/runtime/helpers/element.d.ts.map +1 -0
- package/dist/runtime/helpers/render.d.ts +8 -0
- package/dist/runtime/helpers/render.d.ts.map +1 -0
- package/dist/runtime/helpers/render.js +41 -12
- package/dist/runtime/index.d.ts +16 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +53 -0
- package/dist/runtime/types.d.ts +65 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/signals/helpers/core.d.ts +11 -0
- package/dist/signals/helpers/core.d.ts.map +1 -0
- package/dist/signals/helpers/core.js +32 -12
- package/dist/signals/helpers/utils.d.ts +7 -0
- package/dist/signals/helpers/utils.d.ts.map +1 -0
- package/dist/signals/index.d.ts +4 -0
- package/dist/signals/index.d.ts.map +1 -0
- package/dist/signals/types.d.ts +23 -0
- package/dist/signals/types.d.ts.map +1 -0
- package/dist/ssg/index.d.ts +38 -0
- package/dist/ssg/index.d.ts.map +1 -0
- package/dist/ssr/helpers/render-html.d.ts +16 -0
- package/dist/ssr/helpers/render-html.d.ts.map +1 -0
- package/dist/ssr/helpers/ssr.d.ts +14 -0
- package/dist/ssr/helpers/ssr.d.ts.map +1 -0
- package/dist/ssr/index.d.ts +4 -0
- package/dist/ssr/index.d.ts.map +1 -0
- package/dist/ssr/types.d.ts +29 -0
- package/dist/ssr/types.d.ts.map +1 -0
- package/dist/vite-plugin/index.d.ts +5 -0
- package/dist/vite-plugin/index.d.ts.map +1 -0
- package/dist/vite-plugin/index.js +147 -21
- package/dist/vite-plugin/types.d.ts +36 -0
- package/dist/vite-plugin/types.d.ts.map +1 -0
- package/package.json +6 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/signals/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface SignalOptions<T> {
|
|
2
|
+
equals?: (prev: T, next: T) => boolean;
|
|
3
|
+
}
|
|
4
|
+
export interface Signal<T> {
|
|
5
|
+
value: T;
|
|
6
|
+
readonly peek: () => T;
|
|
7
|
+
subscribe: (fn: (v: T) => void) => () => void;
|
|
8
|
+
}
|
|
9
|
+
export interface ReadonlySignal<T> {
|
|
10
|
+
readonly value: T;
|
|
11
|
+
readonly peek: () => T;
|
|
12
|
+
subscribe: (fn: (v: T) => void) => () => void;
|
|
13
|
+
}
|
|
14
|
+
export interface WritableSignal<T> extends Signal<T> {
|
|
15
|
+
value: T;
|
|
16
|
+
}
|
|
17
|
+
export interface EffectCleanup {
|
|
18
|
+
readonly: () => void;
|
|
19
|
+
}
|
|
20
|
+
export type EffectCallback = () => void | (() => void);
|
|
21
|
+
export type EqualityFn<T> = (prev: T, next: T) => boolean;
|
|
22
|
+
export declare const DEFAULT_EQUALS: <T>(prev: T, next: T) => boolean;
|
|
23
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/signals/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa,CAAC,CAAC;IAC9B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC;CACxC;AAED,MAAM,WAAW,MAAM,CAAC,CAAC;IACvB,KAAK,EAAE,CAAC,CAAC;IACT,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACvB,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;CAC/C;AAED,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;IAClB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACvB,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;CAC/C;AAED,MAAM,WAAW,cAAc,CAAC,CAAC,CAAE,SAAQ,MAAM,CAAC,CAAC,CAAC;IAClD,KAAK,EAAE,CAAC,CAAC;CACV;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,MAAM,MAAM,cAAc,GAAG,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;AAEvD,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC;AAE1D,eAAO,MAAM,cAAc,GAAI,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,YAAkB,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export interface SSGConfig {
|
|
2
|
+
outDir: string;
|
|
3
|
+
routes: string[];
|
|
4
|
+
prerender?: boolean;
|
|
5
|
+
cacheControl?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface SSGManifest {
|
|
8
|
+
pages: Map<string, string>;
|
|
9
|
+
errors: Map<string, Error>;
|
|
10
|
+
buildTime: number;
|
|
11
|
+
}
|
|
12
|
+
export interface StaticPage {
|
|
13
|
+
path: string;
|
|
14
|
+
html: string;
|
|
15
|
+
status: number;
|
|
16
|
+
headers: Record<string, string>;
|
|
17
|
+
}
|
|
18
|
+
export declare class SSGBuilder {
|
|
19
|
+
private config;
|
|
20
|
+
private manifest;
|
|
21
|
+
constructor(config: SSGConfig);
|
|
22
|
+
build(renderFn: (path: string) => Promise<string>): Promise<SSGManifest>;
|
|
23
|
+
getManifest(): SSGManifest;
|
|
24
|
+
getBuildStats(): {
|
|
25
|
+
pages: number;
|
|
26
|
+
errors: number;
|
|
27
|
+
time: number;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export declare function generateStaticPages(routes: string[], renderFn: (path: string) => Promise<string>, options?: Partial<SSGConfig>): Promise<SSGManifest>;
|
|
31
|
+
export declare function createSSGManifest(pages: StaticPage[]): SSGManifest;
|
|
32
|
+
export declare function serializeManifest(manifest: SSGManifest): string;
|
|
33
|
+
export declare function deserializeManifest(json: string): SSGManifest;
|
|
34
|
+
export declare const STATIC_ROUTE_PATTERNS: string[];
|
|
35
|
+
export declare function isStaticRoute(path: string): boolean;
|
|
36
|
+
export declare function crawlRoutes(startPath: string, shouldCrawl: (path: string) => Promise<boolean>, getLinks: (html: string) => string[]): Promise<string[]>;
|
|
37
|
+
export declare function estimateBuildTime(pages: number): number;
|
|
38
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ssg/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3B,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,QAAQ,CAAc;gBAElB,MAAM,EAAE,SAAS;IAcvB,KAAK,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC;IAkC9E,WAAW,IAAI,WAAW;IAI1B,aAAa,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE;CAOjE;AAED,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,MAAM,EAAE,EAChB,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,EAC3C,OAAO,GAAE,OAAO,CAAC,SAAS,CAAM,GAC/B,OAAO,CAAC,WAAW,CAAC,CAQtB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,WAAW,CAMlE;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,WAAW,GAAG,MAAM,CAM/D;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAQ7D;AAED,eAAO,MAAM,qBAAqB,UAMjC,CAAC;AAEF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAOnD;AAED,wBAAsB,WAAW,CAC/B,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,EAC/C,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,EAAE,GACnC,OAAO,CAAC,MAAM,EAAE,CAAC,CA0BnB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEvD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { JSXNode } from '../../runtime/types.js';
|
|
2
|
+
export declare function renderToHTMLString(element: JSXNode | null): string;
|
|
3
|
+
export declare function renderChildrenToHTML(children: (string | number | JSXNode)[]): string;
|
|
4
|
+
export declare function createHtmlDocument(html: string, options?: {
|
|
5
|
+
title?: string;
|
|
6
|
+
lang?: string;
|
|
7
|
+
doctype?: string;
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
headExtra?: string;
|
|
10
|
+
}): string;
|
|
11
|
+
export declare function escapeHtml(text: string): string;
|
|
12
|
+
export declare function createMetaTags(meta: Record<string, string>): string;
|
|
13
|
+
export declare function createLinkTags(links: Record<string, string>): string;
|
|
14
|
+
export declare function createScriptTags(scripts: string[]): string;
|
|
15
|
+
export declare function createStyleTags(styles: string[]): string;
|
|
16
|
+
//# sourceMappingURL=render-html.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-html.d.ts","sourceRoot":"","sources":["../../../src/ssr/helpers/render-html.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAc,MAAM,wBAAwB,CAAC;AAElE,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,GAAG,MAAM,CAQlE;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,GAAG,MAAM,CAEpF;AAED,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;IACP,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACf,GACL,MAAM,CAgBR;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO/C;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAInE;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAIpE;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAE1D;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAExD"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { JSXNode } from '../../runtime/types.js';
|
|
2
|
+
import type { LoaderResult } from '../../loader/types.js';
|
|
3
|
+
import type { SSRRenderOptions, SSRRenderResult } from '../types.js';
|
|
4
|
+
export declare function renderSSR(element: JSXNode | null, options?: SSRRenderOptions): SSRRenderResult;
|
|
5
|
+
export declare function renderSSRWithError(element: JSXNode | null, error: LoaderResult<unknown> | null, options?: SSRRenderOptions): SSRRenderResult;
|
|
6
|
+
export declare function renderSSRWithHeaders(element: JSXNode | null, headers: Record<string, string>, options?: SSRRenderOptions): SSRRenderResult;
|
|
7
|
+
export declare function createStreamingRenderer(): {
|
|
8
|
+
write(html: string): void;
|
|
9
|
+
writeChunk(type: "html" | "status" | "error", content: string): void;
|
|
10
|
+
end(): string;
|
|
11
|
+
reset(): void;
|
|
12
|
+
};
|
|
13
|
+
export declare function injectScripts(html: string, scripts: string[]): string;
|
|
14
|
+
//# sourceMappingURL=ssr.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssr.d.ts","sourceRoot":"","sources":["../../../src/ssr/helpers/ssr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAG1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGrE,wBAAgB,SAAS,CACvB,OAAO,EAAE,OAAO,GAAG,IAAI,EACvB,OAAO,GAAE,gBAAqB,GAC7B,eAAe,CAsBjB;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,OAAO,GAAG,IAAI,EACvB,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,GAAG,IAAI,EACnC,OAAO,GAAE,gBAAqB,GAC7B,eAAe,CAuBjB;AAED,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,OAAO,GAAG,IAAI,EACvB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,OAAO,GAAE,gBAAqB,GAC7B,eAAe,CAQjB;AAED,wBAAgB,uBAAuB;gBAIvB,MAAM,GAAG,IAAI;qBAIR,MAAM,GAAG,QAAQ,GAAG,OAAO,WAAW,MAAM,GAAG,IAAI;WAU7D,MAAM;aAIJ,IAAI;EAIhB;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAWrE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ssr/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { LoaderResult } from '../loader/types.js';
|
|
2
|
+
export interface SSRContext {
|
|
3
|
+
request: Request;
|
|
4
|
+
params: Record<string, string>;
|
|
5
|
+
query: Record<string, string | string[]>;
|
|
6
|
+
loaderData: Record<string, LoaderResult<unknown>>;
|
|
7
|
+
}
|
|
8
|
+
export interface SSRRenderOptions {
|
|
9
|
+
doctype?: string;
|
|
10
|
+
title?: string;
|
|
11
|
+
lang?: string;
|
|
12
|
+
baseUrl?: string;
|
|
13
|
+
streaming?: boolean;
|
|
14
|
+
headExtra?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface SSRRenderResult {
|
|
17
|
+
html: string;
|
|
18
|
+
status: number;
|
|
19
|
+
headers: Headers;
|
|
20
|
+
}
|
|
21
|
+
export interface StreamChunk {
|
|
22
|
+
type: 'html' | 'error' | 'status';
|
|
23
|
+
content: string;
|
|
24
|
+
}
|
|
25
|
+
export declare const DEFAULT_DOCTYPE = "<!DOCTYPE html>";
|
|
26
|
+
export declare const DEFAULT_LANG = "en";
|
|
27
|
+
export declare const STATUS_CODES: Record<number, string>;
|
|
28
|
+
export declare function getStatusText(status: number): string;
|
|
29
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ssr/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;IACzC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;CACnD;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;IAClC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,eAAe,oBAAoB,CAAC;AACjD,eAAO,MAAM,YAAY,OAAO,CAAC;AAEjC,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAkB/C,CAAC;AAEF,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEpD"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
import type { EmberKitPluginOptions, EmberKitMode } from './types.js';
|
|
3
|
+
export declare function emberkitVitePlugin(userOptions?: EmberKitPluginOptions): Plugin;
|
|
4
|
+
export type { EmberKitPluginOptions, EmberKitMode };
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vite-plugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAqBtE,wBAAgB,kBAAkB,CAAC,WAAW,GAAE,qBAA0B,GAAG,MAAM,CA+ElF;AAwoBD,YAAY,EAAE,qBAAqB,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -2,6 +2,8 @@ import { DEFAULT_CONFIG } from './types.js';
|
|
|
2
2
|
import { readdirSync, statSync } from 'node:fs';
|
|
3
3
|
import { join, relative, dirname, resolve } from 'node:path';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { compile } from '@mdx-js/mdx';
|
|
6
|
+
import remarkGfm from 'remark-gfm';
|
|
5
7
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
6
8
|
const VIRTUAL_EMBERKIT_CONFIG = 'virtual:emberkit-config';
|
|
7
9
|
const VIRTUAL_EMBERKIT_ROUTES = 'virtual:emberkit-routes';
|
|
@@ -71,7 +73,10 @@ export function emberkitVitePlugin(userOptions = {}) {
|
|
|
71
73
|
}
|
|
72
74
|
return null;
|
|
73
75
|
}
|
|
74
|
-
if (
|
|
76
|
+
if (isMDX) {
|
|
77
|
+
return transformMDX(code, id);
|
|
78
|
+
}
|
|
79
|
+
if (isMD) {
|
|
75
80
|
return transformMarkdownToJSX(code, id, options);
|
|
76
81
|
}
|
|
77
82
|
return code;
|
|
@@ -128,6 +133,122 @@ export default function MDComponent(props) {
|
|
|
128
133
|
`;
|
|
129
134
|
return { code: componentCode };
|
|
130
135
|
}
|
|
136
|
+
async function transformMDX(code, id) {
|
|
137
|
+
const frontmatterMatch = code.match(/^---\n([\s\S]*?)\n---\n?/);
|
|
138
|
+
let frontmatter = {};
|
|
139
|
+
let content = code;
|
|
140
|
+
if (frontmatterMatch) {
|
|
141
|
+
const fmContent = frontmatterMatch[1];
|
|
142
|
+
frontmatter = parseFrontmatter(fmContent);
|
|
143
|
+
content = code.slice(frontmatterMatch[0].length);
|
|
144
|
+
}
|
|
145
|
+
// Extract code blocks before MDX compilation to preserve syntax
|
|
146
|
+
const codeBlocks = [];
|
|
147
|
+
let processedContent = content.replace(/```(\w*)\n([\s\S]*?)```/g, (_match, lang, blockCode) => {
|
|
148
|
+
const html = renderCodeBlock(lang, blockCode);
|
|
149
|
+
codeBlocks.push({ html, index: codeBlocks.length });
|
|
150
|
+
return `<CodeBlock_${codeBlocks.length - 1} />`;
|
|
151
|
+
});
|
|
152
|
+
const compiled = await compile(processedContent, {
|
|
153
|
+
outputFormat: 'program',
|
|
154
|
+
development: false,
|
|
155
|
+
jsx: false,
|
|
156
|
+
jsxImportSource: '@emberkit/core',
|
|
157
|
+
remarkPlugins: [remarkGfm],
|
|
158
|
+
});
|
|
159
|
+
let compiledCode = String(compiled);
|
|
160
|
+
// Build code block component definitions
|
|
161
|
+
const codeBlockComponents = codeBlocks
|
|
162
|
+
.map((block) => {
|
|
163
|
+
const escapedHtml = JSON.stringify(block.html);
|
|
164
|
+
return `function CodeBlock_${block.index}() {
|
|
165
|
+
return createElement('div', {
|
|
166
|
+
dangerouslySetInnerHTML: { __html: ${escapedHtml} }
|
|
167
|
+
});
|
|
168
|
+
}`;
|
|
169
|
+
})
|
|
170
|
+
.join('\n\n');
|
|
171
|
+
// Rename the MDX default export so we can wrap it
|
|
172
|
+
compiledCode = compiledCode.replace('export default function MDXContent', 'function _MDXContent');
|
|
173
|
+
const exportLines = [];
|
|
174
|
+
if (frontmatter.title) {
|
|
175
|
+
exportLines.push(`export const title = ${JSON.stringify(frontmatter.title)};`);
|
|
176
|
+
}
|
|
177
|
+
if (frontmatter.description) {
|
|
178
|
+
exportLines.push(`export const description = ${JSON.stringify(frontmatter.description)};`);
|
|
179
|
+
}
|
|
180
|
+
if (frontmatter.author) {
|
|
181
|
+
exportLines.push(`export const author = ${JSON.stringify(frontmatter.author)};`);
|
|
182
|
+
}
|
|
183
|
+
if (frontmatter.date) {
|
|
184
|
+
exportLines.push(`export const date = ${JSON.stringify(frontmatter.date)};`);
|
|
185
|
+
}
|
|
186
|
+
exportLines.push(`export const metadata = ${JSON.stringify(frontmatter)};`);
|
|
187
|
+
// Build components override object
|
|
188
|
+
const componentsOverride = codeBlocks.length > 0
|
|
189
|
+
? `
|
|
190
|
+
const _codeBlockComponents = {
|
|
191
|
+
${codeBlocks.map(b => `CodeBlock_${b.index}`).join(', ')}
|
|
192
|
+
};
|
|
193
|
+
`
|
|
194
|
+
: '';
|
|
195
|
+
const componentCode = `
|
|
196
|
+
import { createElement } from '@emberkit/core';
|
|
197
|
+
|
|
198
|
+
${exportLines.join('\n')}
|
|
199
|
+
|
|
200
|
+
${codeBlockComponents}
|
|
201
|
+
${componentsOverride}
|
|
202
|
+
|
|
203
|
+
${compiledCode}
|
|
204
|
+
|
|
205
|
+
function _GfmTable(props) {
|
|
206
|
+
return createElement('div', { className: 'table-wrapper' },
|
|
207
|
+
createElement('table', { className: 'gfm-table' }, props.children)
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function _GfmUl(props) {
|
|
212
|
+
return createElement('ul', { className: 'task-list' }, props.children);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function _GfmLi(props) {
|
|
216
|
+
return createElement('li', { className: 'task-item' }, props.children);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function _GfmDel(props) {
|
|
220
|
+
return createElement('span', { className: 'strikethrough' }, props.children);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function _GfmSup(props) {
|
|
224
|
+
return createElement('span', { className: 'footnote-ref' }, props.children);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export default function MDXComponent(props) {
|
|
228
|
+
const components = {
|
|
229
|
+
...(props.components || {}),
|
|
230
|
+
${codeBlocks.map(b => `CodeBlock_${b.index}`).join(', ')}
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
return createElement('div', {
|
|
234
|
+
className: 'md-content md-doc',
|
|
235
|
+
'data-file': ${JSON.stringify(id)},
|
|
236
|
+
children: createElement(_MDXContent, {
|
|
237
|
+
...props,
|
|
238
|
+
components: {
|
|
239
|
+
...components,
|
|
240
|
+
table: _GfmTable,
|
|
241
|
+
ul: _GfmUl,
|
|
242
|
+
li: _GfmLi,
|
|
243
|
+
del: _GfmDel,
|
|
244
|
+
sup: _GfmSup,
|
|
245
|
+
}
|
|
246
|
+
})
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
`;
|
|
250
|
+
return { code: componentCode };
|
|
251
|
+
}
|
|
131
252
|
function parseFrontmatter(content) {
|
|
132
253
|
const result = {};
|
|
133
254
|
const lines = content.split('\n');
|
|
@@ -151,8 +272,13 @@ function parseFrontmatter(content) {
|
|
|
151
272
|
return result;
|
|
152
273
|
}
|
|
153
274
|
function markdownToJSX(content, options) {
|
|
154
|
-
|
|
155
|
-
|
|
275
|
+
// Step 1: Extract all fenced code blocks before any markdown processing
|
|
276
|
+
const codeBlocks = [];
|
|
277
|
+
let html = content.replace(/```(\w*)\n([\s\S]*?)```/g, (_match, lang, code) => {
|
|
278
|
+
codeBlocks.push(renderCodeBlock(lang, code));
|
|
279
|
+
return `\n__CODE_BLOCK_${codeBlocks.length - 1}__\n`;
|
|
280
|
+
});
|
|
281
|
+
// Step 2: Process all other markdown (no backticks in code blocks to interfere)
|
|
156
282
|
html = processHeadings(html);
|
|
157
283
|
html = processHorizontalRules(html);
|
|
158
284
|
html = processTables(html);
|
|
@@ -162,6 +288,8 @@ function markdownToJSX(content, options) {
|
|
|
162
288
|
html = processBlockquotes(html);
|
|
163
289
|
html = processEmphasis(html);
|
|
164
290
|
html = processParagraphs(html, options.breaks);
|
|
291
|
+
// Step 3: Restore code blocks
|
|
292
|
+
html = html.replace(/__CODE_BLOCK_(\d+)__/g, (_, index) => codeBlocks[Number(index)]);
|
|
165
293
|
return html;
|
|
166
294
|
}
|
|
167
295
|
function processHeadings(html) {
|
|
@@ -170,24 +298,22 @@ function processHeadings(html) {
|
|
|
170
298
|
return `<h${hashes.length} id="${id}">${text}</h${hashes.length}>`;
|
|
171
299
|
});
|
|
172
300
|
}
|
|
173
|
-
function
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
return `<pre${langAttr}><button class="copy-btn" onclick="(async()=>{await navigator.clipboard.writeText(this.closest('pre').querySelector('code').textContent);this.textContent='Copied!';setTimeout(()=>this.textContent='Copy',1500)})()"><svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"9\" y=\"9\" width=\"13\" height=\"13\" rx=\"2\" ry=\"2\"/><path d=\"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1\"/></svg> Copy</button><code class="language-${lang}">${highlighted}</code></pre>`;
|
|
190
|
-
});
|
|
301
|
+
function renderCodeBlock(lang, code) {
|
|
302
|
+
let highlighted = code.trim();
|
|
303
|
+
if (lang === 'ts' || lang === 'tsx' || lang === 'js' || lang === 'jsx' || lang === 'typescript' || lang === 'javascript') {
|
|
304
|
+
highlighted = highlightTS(highlighted);
|
|
305
|
+
}
|
|
306
|
+
else if (lang === 'bash' || lang === 'sh' || lang === 'shell') {
|
|
307
|
+
highlighted = highlightBash(highlighted);
|
|
308
|
+
}
|
|
309
|
+
else if (lang === 'json') {
|
|
310
|
+
highlighted = highlightJSON(highlighted);
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
highlighted = escapeHtml(highlighted);
|
|
314
|
+
}
|
|
315
|
+
const langAttr = lang ? ` data-lang="${lang}"` : '';
|
|
316
|
+
return `<pre${langAttr}><button class="copy-btn" onclick="(async()=>{await navigator.clipboard.writeText(this.closest('pre').querySelector('code').textContent);this.textContent='Copied!';setTimeout(()=>this.textContent='Copy',1500)})()"><svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"9\" y=\"9\" width=\"13\" height=\"13\" rx=\"2\" ry=\"2\"/><path d=\"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1\"/></svg> Copy</button><code class="language-${lang}">${highlighted}</code></pre>`;
|
|
191
317
|
}
|
|
192
318
|
function escapeHtml(text) {
|
|
193
319
|
return text
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
export type EmberKitMode = 'static' | 'ssr' | 'spa' | 'hybrid';
|
|
3
|
+
export interface EmberKitPluginOptions {
|
|
4
|
+
mode?: EmberKitMode;
|
|
5
|
+
routeDir?: string;
|
|
6
|
+
outputDir?: string;
|
|
7
|
+
jsx?: 'automatic' | 'classic';
|
|
8
|
+
markdown?: Partial<MarkdownConfig>;
|
|
9
|
+
mdx?: MDXConfig;
|
|
10
|
+
}
|
|
11
|
+
export interface MarkdownConfig {
|
|
12
|
+
gfm: boolean;
|
|
13
|
+
breaks: boolean;
|
|
14
|
+
html: boolean;
|
|
15
|
+
tables: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface MDXConfig {
|
|
18
|
+
components?: Record<string, string>;
|
|
19
|
+
scope?: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
export type EmberKitPlugin = (options?: EmberKitPluginOptions) => Plugin;
|
|
22
|
+
export declare const DEFAULT_CONFIG: {
|
|
23
|
+
readonly mode: "hybrid";
|
|
24
|
+
readonly routeDir: "src/routes";
|
|
25
|
+
readonly outputDir: "dist";
|
|
26
|
+
readonly jsx: "automatic";
|
|
27
|
+
readonly markdown: {
|
|
28
|
+
readonly gfm: true;
|
|
29
|
+
readonly breaks: false;
|
|
30
|
+
readonly html: true;
|
|
31
|
+
readonly tables: true;
|
|
32
|
+
};
|
|
33
|
+
readonly mdx: {};
|
|
34
|
+
};
|
|
35
|
+
export type ResolvedConfig = typeof DEFAULT_CONFIG & EmberKitPluginOptions;
|
|
36
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/vite-plugin/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAGnC,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,CAAC;AAE/D,MAAM,WAAW,qBAAqB;IACpC,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IACnC,GAAG,CAAC,EAAE,SAAS,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,OAAO,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,SAAS;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,CAAC,EAAE,qBAAqB,KAAK,MAAM,CAAC;AAEzE,eAAO,MAAM,cAAc;;;;;;;;;;;;CAYjB,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,GAAG,qBAAqB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emberkit/core",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Lightweight TypeScript-first JSX framework core",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -21,6 +21,9 @@
|
|
|
21
21
|
"sideEffects": false,
|
|
22
22
|
"main": "./dist/index.js",
|
|
23
23
|
"types": "./dist/index.d.ts",
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
24
27
|
"files": [
|
|
25
28
|
"dist"
|
|
26
29
|
],
|
|
@@ -43,6 +46,8 @@
|
|
|
43
46
|
}
|
|
44
47
|
},
|
|
45
48
|
"dependencies": {
|
|
49
|
+
"@mdx-js/mdx": "^3.1.1",
|
|
50
|
+
"remark-gfm": "^4.0.0",
|
|
46
51
|
"vite": "^6.0.0"
|
|
47
52
|
},
|
|
48
53
|
"devDependencies": {
|