imprensa 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +51 -0
  3. package/default.css +239 -0
  4. package/dist/client-runtime-D7MhMWCo.d.mts +45 -0
  5. package/dist/components/doc.d.mts +2 -0
  6. package/dist/components/doc.mjs +2 -0
  7. package/dist/components/icons.d.mts +23 -0
  8. package/dist/components/icons.mjs +40 -0
  9. package/dist/components/index.d.mts +33 -0
  10. package/dist/components/index.mjs +253 -0
  11. package/dist/core/client-runtime.d.mts +2 -0
  12. package/dist/core/client-runtime.mjs +121 -0
  13. package/dist/core/prerender-core.d.mts +2 -0
  14. package/dist/core/prerender-core.mjs +2 -0
  15. package/dist/core/runtime.d.mts +3 -0
  16. package/dist/core/runtime.mjs +3 -0
  17. package/dist/core/shiki-build.d.mts +9 -0
  18. package/dist/core/shiki-build.mjs +34 -0
  19. package/dist/doc-pager-D-YhwEQN.d.mts +27 -0
  20. package/dist/doc-toolbar-DUQS2gnK.mjs +460 -0
  21. package/dist/docs/config.d.mts +13 -0
  22. package/dist/docs/config.mjs +10 -0
  23. package/dist/docs/landing-shiki.d.mts +7 -0
  24. package/dist/docs/landing-shiki.mjs +7 -0
  25. package/dist/docs/mdx.d.mts +79 -0
  26. package/dist/docs/mdx.mjs +293 -0
  27. package/dist/docs/rehype.d.mts +25 -0
  28. package/dist/docs/rehype.mjs +2 -0
  29. package/dist/frontmatter-DVneGjCO.mjs +16 -0
  30. package/dist/global-search-Dfv8DYN3.mjs +310 -0
  31. package/dist/index.d.mts +41 -0
  32. package/dist/index.mjs +668 -0
  33. package/dist/prerender-core-D4Li--RS.mjs +172 -0
  34. package/dist/prerender-core-DBi9ntWW.d.mts +48 -0
  35. package/dist/rehype-BWpGaBql.mjs +182 -0
  36. package/dist/search-store-DDGHRAKl.mjs +64 -0
  37. package/dist/shiki-gFey7C-z.d.mts +3289 -0
  38. package/dist/sidebar-layout-DsEhSkJS.mjs +43 -0
  39. package/dist/socials-BIszPk-A.d.mts +8 -0
  40. package/docs/architecture.md +26 -0
  41. package/docs/integration-notes.md +6 -0
  42. package/index.d.ts +49 -0
  43. package/package.json +128 -0
  44. package/tsconfig.json +28 -0
@@ -0,0 +1,43 @@
1
+ //#region src/components/sidebar-layout.ts
2
+ const SIDEBAR_STORAGE_KEY = "imprensa:sidebar-layout";
3
+ const DEFAULT_SIDEBAR_LAYOUT = [20, 80];
4
+ function readSidebarLayout() {
5
+ if (typeof localStorage === "undefined") return DEFAULT_SIDEBAR_LAYOUT;
6
+ try {
7
+ const layout = JSON.parse(localStorage.getItem("imprensa:sidebar-layout") ?? "null");
8
+ if (Array.isArray(layout) && layout.length === 2 && layout.every((size) => typeof size === "number")) return [layout[0], layout[1]];
9
+ } catch {}
10
+ return DEFAULT_SIDEBAR_LAYOUT;
11
+ }
12
+ function writeSidebarLayout(layout) {
13
+ try {
14
+ localStorage.setItem(SIDEBAR_STORAGE_KEY, JSON.stringify(layout));
15
+ } catch {}
16
+ }
17
+ /** Injected into index.html so the saved split applies before first paint. */
18
+ const SIDEBAR_LAYOUT_BOOT_SCRIPT = `<script>
19
+ (function () {
20
+ try {
21
+ var raw = localStorage.getItem(${JSON.stringify(SIDEBAR_STORAGE_KEY)});
22
+ if (!raw) return;
23
+ var layout = JSON.parse(raw);
24
+ if (!Array.isArray(layout) || layout.length !== 2) return;
25
+ var a = layout[0], b = layout[1];
26
+ if (typeof a !== "number" || typeof b !== "number") return;
27
+ var root = document.documentElement;
28
+ root.dataset.imprensaSidebarLayout = "1";
29
+ root.style.setProperty("--imprensa-sidebar-pct", String(a));
30
+ root.style.setProperty("--imprensa-content-pct", String(b));
31
+ } catch (e) {}
32
+ })();
33
+ <\/script>
34
+ <style id="imprensa-sidebar-layout-boot">
35
+ html[data-imprensa-sidebar-layout] [data-slot="resizable"] > [data-slot="resizable-panel"]:first-child {
36
+ flex-grow: var(--imprensa-sidebar-pct) !important;
37
+ }
38
+ html[data-imprensa-sidebar-layout] [data-slot="resizable"] > [data-slot="resizable-panel"]:last-child {
39
+ flex-grow: var(--imprensa-content-pct) !important;
40
+ }
41
+ </style>`;
42
+ //#endregion
43
+ export { writeSidebarLayout as i, SIDEBAR_LAYOUT_BOOT_SCRIPT as n, readSidebarLayout as r, DEFAULT_SIDEBAR_LAYOUT as t };
@@ -0,0 +1,8 @@
1
+ //#region src/docs/socials.d.ts
2
+ type ImprensaSocialService = "github" | "x" | "discord";
3
+ type ImprensaSocialLink = {
4
+ service: ImprensaSocialService;
5
+ url: string;
6
+ };
7
+ //#endregion
8
+ export { ImprensaSocialService as n, ImprensaSocialLink as t };
@@ -0,0 +1,26 @@
1
+ # imprensa architecture
2
+
3
+ ## Layer boundaries
4
+
5
+ | Layer | Path | May import |
6
+ | ---------- | ------------------ | -------------------------------------------------------------------------- |
7
+ | Core | `src/core/` | Node, Ilha router types, Shiki — not `src/docs` or `src/components` |
8
+ | Docs | `src/docs/` | `src/core/`, Vite/MDX/unified |
9
+ | Components | `src/components/` | Ilha, Areia, virtual `imprensa/config`, `imprensa/mdx`, `imprensa/runtime` |
10
+ | Plugin | `src/docs/plugin/` | Orchestrates Vite plugins and virtual module resolution |
11
+
12
+ ## Public API
13
+
14
+ All published subpaths resolve to **`dist/`** (see `package.json` `exports` and `tsdown.config.ts` `entry`).
15
+
16
+ Runtime virtual modules (`imprensa/mdx`, `imprensa/config`, `imprensa/shiki`, `imprensa/landing-shiki`) are generated or transformed by the `imprensa:config` Vite plugin in dev/build; stubs exist under `src/docs/` for types and npm resolution.
17
+
18
+ ## MDX config injection
19
+
20
+ `src/docs/mdx/runtime-config.ts` contains `MDX_CONFIG_MARKER` (see `mdx-config.ts`). The plugin replaces that block with build-time values (`contentDir`, repo metadata, raw sources, `headDefaults`).
21
+
22
+ ## Large modules (split layout)
23
+
24
+ - **Rehype:** `src/docs/rehype/` — route graph, heading utils, dead links, preview
25
+ - **MDX:** `src/docs/mdx/` — types, document text, routes/index, render, source links, runtime config
26
+ - **Vite:** `src/docs/plugin/` — `create-plugins.ts`, landing Shiki, virtual runtime barrel
@@ -0,0 +1,6 @@
1
+ # Maintainer notes — Ilha × Areia × search
2
+
3
+ - **No VDOM** in Ilha; portaled `Dialog` markup is outside the island morph target.
4
+ - **State:** `@ilha/store` (`search-store.ts`) for `open` / `query`.
5
+ - **Bridge:** `search-portal-sync.ts` repaints `command-list` in the portal; remove when Areia supports `portal={false}` on body-mounted dialogs with same presence animations.
6
+ - **Mount:** `ensureGlobalSearchMounted()` in `createImprensa().init()` — do not duplicate search in layouts.
package/index.d.ts ADDED
@@ -0,0 +1,49 @@
1
+ declare const __IMPRENSA_CONTENT_DIR__: string;
2
+ declare const __IMPRENSA_REPO__: string;
3
+ declare const __IMPRENSA_REPO_BRANCH__: string;
4
+ declare const __IMPRENSA_REPO_PATH__: string;
5
+ declare const __IMPRENSA_RAW_SOURCES__: Record<string, string>;
6
+
7
+ declare module "imprensa/shiki" {
8
+ export const shiki: {
9
+ loadLanguage: (lang: string) => Promise<void>;
10
+ codeToHtml: (
11
+ code: string,
12
+ options: { lang: string; themes: { light: string; dark: string } },
13
+ ) => string;
14
+ };
15
+ }
16
+
17
+ declare module "imprensa/landing-shiki" {
18
+ export const fileTreeHtml: string;
19
+ export const mdxHtml: string;
20
+ export const buildHtml: string;
21
+ }
22
+
23
+ declare module "imprensa/config" {
24
+ import type { ImprensaShikiOptions, ImprensaSocialLink } from "imprensa";
25
+ export type { ImprensaSocialLink, ImprensaSocialService } from "imprensa";
26
+ export const socials: ImprensaSocialLink[];
27
+ export const preview: { importmap?: string; head?: string };
28
+ export const shiki: ImprensaShikiOptions;
29
+ export const hostname: string;
30
+ export const shikiThemes: { light: string; dark: string };
31
+ }
32
+
33
+ declare module "ilha:pages/server" {
34
+ import type { Island } from "ilha";
35
+ import type { RouterBuilder } from "@ilha/router";
36
+ export const pageRouter: RouterBuilder;
37
+ export const registry: Record<string, Island<Record<string, unknown>, Record<string, unknown>>>;
38
+ }
39
+
40
+ declare module "ilha:pages/client" {
41
+ import type { Island } from "ilha";
42
+ import type { RouterBuilder } from "@ilha/router";
43
+ export const pageRouter: RouterBuilder;
44
+ export const registry: Record<string, Island<Record<string, unknown>, Record<string, unknown>>>;
45
+ }
46
+
47
+ declare module "ilha:loaders" {
48
+ // Side-effect-only module. Importing it attaches loaders to the server pageRouter.
49
+ }
package/package.json ADDED
@@ -0,0 +1,128 @@
1
+ {
2
+ "name": "imprensa",
3
+ "version": "0.1.0",
4
+ "description": "Vite plugin and runtime for Ilha + Areia documentation sites (MDX, prerender, search)",
5
+ "keywords": [
6
+ "areia",
7
+ "docs",
8
+ "documentation",
9
+ "ilha",
10
+ "llms.txt",
11
+ "mdx",
12
+ "prerender",
13
+ "shiki",
14
+ "static-site",
15
+ "vite",
16
+ "vite-plugin"
17
+ ],
18
+ "homepage": "https://github.com/ilhajs/imprensa#readme",
19
+ "bugs": {
20
+ "url": "https://github.com/ilhajs/imprensa/issues"
21
+ },
22
+ "license": "MIT",
23
+ "author": "Ryuz <ryuzer@proton.me>",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/ilhajs/imprensa.git",
27
+ "directory": "packages/imprensa"
28
+ },
29
+ "files": [
30
+ "dist",
31
+ "default.css",
32
+ "index.d.ts",
33
+ "README.md",
34
+ "CHANGELOG.md",
35
+ "docs/",
36
+ "tsconfig.json"
37
+ ],
38
+ "type": "module",
39
+ "exports": {
40
+ ".": {
41
+ "browser": {
42
+ "types": "./dist/core/client-runtime.d.mts",
43
+ "import": "./dist/core/client-runtime.mjs"
44
+ },
45
+ "types": "./dist/index.d.mts",
46
+ "import": "./dist/index.mjs"
47
+ },
48
+ "./runtime": {
49
+ "types": "./dist/core/client-runtime.d.mts",
50
+ "import": "./dist/core/client-runtime.mjs"
51
+ },
52
+ "./prerender": {
53
+ "types": "./dist/core/prerender-core.d.mts",
54
+ "import": "./dist/core/prerender-core.mjs"
55
+ },
56
+ "./rehype": {
57
+ "types": "./dist/docs/rehype.d.mts",
58
+ "import": "./dist/docs/rehype.mjs"
59
+ },
60
+ "./mdx": {
61
+ "types": "./dist/docs/mdx.d.mts",
62
+ "import": "./dist/docs/mdx.mjs"
63
+ },
64
+ "./config": {
65
+ "types": "./dist/docs/config.d.mts",
66
+ "import": "./dist/docs/config.mjs"
67
+ },
68
+ "./icons": {
69
+ "types": "./dist/components/icons.d.mts",
70
+ "import": "./dist/components/icons.mjs"
71
+ },
72
+ "./components": {
73
+ "types": "./dist/components/index.d.mts",
74
+ "import": "./dist/components/index.mjs"
75
+ },
76
+ "./doc": {
77
+ "types": "./dist/components/doc.d.mts",
78
+ "import": "./dist/components/doc.mjs"
79
+ },
80
+ "./landing-shiki": {
81
+ "types": "./dist/docs/landing-shiki.d.mts",
82
+ "import": "./dist/docs/landing-shiki.mjs"
83
+ },
84
+ "./tsconfig.json": "./tsconfig.json",
85
+ "./default.css": "./default.css"
86
+ },
87
+ "scripts": {
88
+ "build": "tsdown",
89
+ "prepublishOnly": "bun run build"
90
+ },
91
+ "dependencies": {
92
+ "@areia/slots": "^0.1.5",
93
+ "@ilha/router": "^0.6.3",
94
+ "@ilha/store": "^0.4.0",
95
+ "@mdx-js/rollup": "^3.1.1",
96
+ "@shikijs/engine-javascript": "^4.2.0",
97
+ "@shikijs/langs": "^4.2.0",
98
+ "@shikijs/rehype": "^4.2.0",
99
+ "@shikijs/themes": "^4.2.0",
100
+ "@shikijs/twoslash": "^4.2.0",
101
+ "@tailwindcss/typography": "^0.5.19",
102
+ "@tailwindcss/vite": "^4.3.0",
103
+ "minisearch": "^7.2.0",
104
+ "quando": "^0.1.6",
105
+ "rehype-autolink-headings": "^7.1.0",
106
+ "rehype-slug": "^6.0.0",
107
+ "shiki": "^4.2.0",
108
+ "sonner": "^2.0.7",
109
+ "tailwindcss": "^4.3.0",
110
+ "unhead": "^3.1.3",
111
+ "vite-plugin-iso-import": "^1.3.0",
112
+ "vite-plugin-sitemap": "^0.8.2",
113
+ "vite-prerender-plugin": "^0.5.13"
114
+ },
115
+ "devDependencies": {
116
+ "@types/mdast": "^4.0.4",
117
+ "tsdown": "^0.22.2",
118
+ "typescript": "^6.0.3",
119
+ "unified": "^11.0.5"
120
+ },
121
+ "peerDependencies": {
122
+ "@ilha/store": "^0.4.0",
123
+ "areia": "^0.1.21",
124
+ "ilha": "^0.8.0",
125
+ "lucide": "^1.17.0",
126
+ "vite": "^8"
127
+ }
128
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2023",
4
+ "useDefineForClassFields": true,
5
+ "module": "ESNext",
6
+ "lib": ["ES2023", "DOM", "DOM.Iterable"],
7
+ "types": ["vite/client"],
8
+ "jsx": "react-jsx",
9
+ "jsxImportSource": "ilha",
10
+ "skipLibCheck": true,
11
+ "moduleResolution": "bundler",
12
+ "allowImportingTsExtensions": true,
13
+ "verbatimModuleSyntax": true,
14
+ "moduleDetection": "force",
15
+ "noEmit": true,
16
+ "strict": true,
17
+ "noUnusedLocals": true,
18
+ "noUnusedParameters": true,
19
+ "erasableSyntaxOnly": true,
20
+ "noFallthroughCasesInSwitch": true,
21
+ "noUncheckedSideEffectImports": true,
22
+ "paths": {
23
+ "$lib/*": ["${configDir}/src/lib/*"]
24
+ }
25
+ },
26
+ "include": ["index.d.ts", "src/**/*.ts", "src/**/*.tsx", "tsdown.config.ts"],
27
+ "exclude": ["dist"]
28
+ }