@autono/open-pages 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 (110) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +108 -0
  3. package/bin.js +2 -0
  4. package/dist/build-TP72kiw7.js +35 -0
  5. package/dist/cli/bin.d.ts +1 -0
  6. package/dist/cli/bin.js +100 -0
  7. package/dist/config-C9or4m4J.d.ts +23 -0
  8. package/dist/config-L0IbktJ0.js +3135 -0
  9. package/dist/design-C13iz9_4.js +35 -0
  10. package/dist/dev-I2IyEh5W.js +97 -0
  11. package/dist/export-B-kBRWB1.js +4 -0
  12. package/dist/export-ic28osQP.js +131 -0
  13. package/dist/index.d.ts +56 -0
  14. package/dist/index.js +3 -0
  15. package/dist/locale/index.d.ts +24 -0
  16. package/dist/locale/index.js +881 -0
  17. package/dist/open-pages-plugin-D_DN_zjh.js +632 -0
  18. package/dist/preview-BrDuvgAN.js +21 -0
  19. package/dist/sync-Be_hxSOF.js +139 -0
  20. package/dist/sync-lKEXyPOh.js +3 -0
  21. package/dist/types-C5NCdDT-.d.ts +219 -0
  22. package/dist/update-CV62NhBT.js +37 -0
  23. package/dist/update-package-Cxt57pz7.js +152 -0
  24. package/dist/version-B6AiiGvT.js +26 -0
  25. package/dist/version-CeffgdfZ.js +3 -0
  26. package/dist/vite/index.d.ts +14 -0
  27. package/dist/vite/index.js +7 -0
  28. package/env.d.ts +59 -0
  29. package/package.json +106 -0
  30. package/skills/apply-comments/SKILL.md +86 -0
  31. package/skills/create-page/SKILL.md +92 -0
  32. package/skills/create-theme/SKILL.md +223 -0
  33. package/skills/current-page/SKILL.md +106 -0
  34. package/skills/page-authoring/SKILL.md +148 -0
  35. package/skills/page-authoring/references/assets-and-fonts.md +85 -0
  36. package/skills/page-authoring/references/html-pages.md +65 -0
  37. package/skills/page-authoring/references/interactivity.md +77 -0
  38. package/skills/page-authoring/references/layout-and-responsive.md +71 -0
  39. package/skills/page-authoring/references/typography-and-color.md +60 -0
  40. package/src/app/app.tsx +45 -0
  41. package/src/app/components/asset-view.tsx +1665 -0
  42. package/src/app/components/command/command-menu.tsx +227 -0
  43. package/src/app/components/command/command.tsx +142 -0
  44. package/src/app/components/command/home-command-menu.tsx +96 -0
  45. package/src/app/components/icon-tooltip.tsx +34 -0
  46. package/src/app/components/language-toggle.tsx +46 -0
  47. package/src/app/components/sidebar/folder-item.tsx +269 -0
  48. package/src/app/components/sidebar/icon-picker.tsx +61 -0
  49. package/src/app/components/sidebar/sidebar-footer.tsx +139 -0
  50. package/src/app/components/sidebar/sidebar.tsx +302 -0
  51. package/src/app/components/theme-toggle.tsx +66 -0
  52. package/src/app/components/themes/theme-detail.tsx +226 -0
  53. package/src/app/components/themes/themes-gallery.tsx +104 -0
  54. package/src/app/components/ui/badge.tsx +48 -0
  55. package/src/app/components/ui/button.tsx +93 -0
  56. package/src/app/components/ui/card.tsx +92 -0
  57. package/src/app/components/ui/context-menu.tsx +247 -0
  58. package/src/app/components/ui/dialog.tsx +155 -0
  59. package/src/app/components/ui/dropdown-menu.tsx +267 -0
  60. package/src/app/components/ui/input.tsx +25 -0
  61. package/src/app/components/ui/label.tsx +21 -0
  62. package/src/app/components/ui/popover.tsx +82 -0
  63. package/src/app/components/ui/progress.tsx +33 -0
  64. package/src/app/components/ui/scroll-area.tsx +53 -0
  65. package/src/app/components/ui/select.tsx +195 -0
  66. package/src/app/components/ui/separator.tsx +26 -0
  67. package/src/app/components/ui/slider.tsx +68 -0
  68. package/src/app/components/ui/sonner.tsx +48 -0
  69. package/src/app/components/ui/tabs.tsx +79 -0
  70. package/src/app/components/ui/textarea.tsx +22 -0
  71. package/src/app/components/ui/toggle-group.tsx +84 -0
  72. package/src/app/components/ui/toggle.tsx +45 -0
  73. package/src/app/components/ui/tooltip.tsx +75 -0
  74. package/src/app/favicon.ico +0 -0
  75. package/src/app/frame/inspect.ts +140 -0
  76. package/src/app/frame/main.tsx +91 -0
  77. package/src/app/frame.html +12 -0
  78. package/src/app/index.html +13 -0
  79. package/src/app/lib/asset-filter.test.ts +176 -0
  80. package/src/app/lib/asset-filter.ts +80 -0
  81. package/src/app/lib/assets.ts +257 -0
  82. package/src/app/lib/design.ts +58 -0
  83. package/src/app/lib/folders.ts +239 -0
  84. package/src/app/lib/frame.ts +38 -0
  85. package/src/app/lib/locale-store.ts +67 -0
  86. package/src/app/lib/page-thumb.tsx +46 -0
  87. package/src/app/lib/pages.ts +28 -0
  88. package/src/app/lib/sdk.ts +43 -0
  89. package/src/app/lib/themes.ts +22 -0
  90. package/src/app/lib/use-locale.ts +8 -0
  91. package/src/app/lib/use-page-module.ts +48 -0
  92. package/src/app/lib/use-page-titles.ts +29 -0
  93. package/src/app/lib/use-restart-server.ts +78 -0
  94. package/src/app/lib/utils.test.ts +25 -0
  95. package/src/app/lib/utils.ts +6 -0
  96. package/src/app/main.tsx +14 -0
  97. package/src/app/routes/assets.tsx +9 -0
  98. package/src/app/routes/home-shell.tsx +252 -0
  99. package/src/app/routes/home.tsx +846 -0
  100. package/src/app/routes/page.tsx +329 -0
  101. package/src/app/routes/themes.tsx +34 -0
  102. package/src/app/styles.css +405 -0
  103. package/src/app/virtual.d.ts +53 -0
  104. package/src/locale/en.ts +218 -0
  105. package/src/locale/format.ts +12 -0
  106. package/src/locale/index.ts +6 -0
  107. package/src/locale/ja.ts +221 -0
  108. package/src/locale/types.ts +215 -0
  109. package/src/locale/zh-cn.ts +218 -0
  110. package/src/locale/zh-tw.ts +218 -0
@@ -0,0 +1,35 @@
1
+ //#region src/app/lib/design.ts
2
+ function designToCssVars(d) {
3
+ return {
4
+ "--osd-bg": d.palette.bg,
5
+ "--osd-text": d.palette.text,
6
+ "--osd-accent": d.palette.accent,
7
+ "--osd-font-display": d.fonts.display,
8
+ "--osd-font-body": d.fonts.body,
9
+ "--osd-size-hero": `${d.typeScale.hero}px`,
10
+ "--osd-size-body": `${d.typeScale.body}px`,
11
+ "--osd-radius": `${d.radius}px`
12
+ };
13
+ }
14
+ function cssVarsToString(vars) {
15
+ return Object.entries(vars).map(([k, v]) => ` ${k}: ${v};`).join("\n");
16
+ }
17
+ const defaultDesign = {
18
+ palette: {
19
+ bg: "#f7f5f0",
20
+ text: "#1a1814",
21
+ accent: "#6d4cff"
22
+ },
23
+ fonts: {
24
+ display: "Georgia, \"Times New Roman\", serif",
25
+ body: "-apple-system, BlinkMacSystemFont, \"Inter\", system-ui, sans-serif"
26
+ },
27
+ typeScale: {
28
+ hero: 168,
29
+ body: 36
30
+ },
31
+ radius: 12
32
+ };
33
+
34
+ //#endregion
35
+ export { cssVarsToString, defaultDesign, designToCssVars };
@@ -0,0 +1,97 @@
1
+ import "./design-C13iz9_4.js";
2
+ import "./open-pages-plugin-D_DN_zjh.js";
3
+ import { DEV_SUPERVISED_ENV, RESTART_EXIT_CODE, createViteConfig } from "./config-L0IbktJ0.js";
4
+ import "./update-package-Cxt57pz7.js";
5
+ import "./version-B6AiiGvT.js";
6
+ import chalk from "chalk";
7
+ import path from "node:path";
8
+ import { existsSync } from "node:fs";
9
+ import { createServer, mergeConfig } from "vite";
10
+ import { fork } from "node:child_process";
11
+
12
+ //#region src/cli/dev.ts
13
+ async function dev(opts = {}) {
14
+ if (process.env[DEV_SUPERVISED_ENV] === "1") {
15
+ await startServer(opts);
16
+ return;
17
+ }
18
+ supervise(opts);
19
+ }
20
+ async function startServer(opts) {
21
+ const base = await createViteConfig({ userCwd: process.cwd() });
22
+ const config = mergeConfig(base, { server: {
23
+ ...opts.port !== void 0 ? { port: opts.port } : {},
24
+ ...opts.host !== void 0 ? { host: opts.host } : {},
25
+ ...opts.open !== void 0 ? { open: opts.open } : {}
26
+ } });
27
+ const server = await createServer(config);
28
+ await server.listen();
29
+ server.printUrls();
30
+ server.bindCLIShortcuts({ print: true });
31
+ const address = server.httpServer?.address();
32
+ if (process.send && address && typeof address === "object") process.send({
33
+ type: "open-pages:listening",
34
+ port: address.port
35
+ });
36
+ }
37
+ function supervise(opts) {
38
+ const userCwd = process.cwd();
39
+ let port = opts.port;
40
+ let openBrowser = opts.open;
41
+ let child;
42
+ let shuttingDown = false;
43
+ const spawnChild = () => {
44
+ child = fork(resolveDevEntry(userCwd), devArgs({
45
+ ...opts,
46
+ port,
47
+ open: openBrowser
48
+ }), {
49
+ cwd: userCwd,
50
+ stdio: "inherit",
51
+ env: {
52
+ ...process.env,
53
+ [DEV_SUPERVISED_ENV]: "1"
54
+ }
55
+ });
56
+ child.on("error", (err) => {
57
+ process.stderr.write(`${chalk.red("error:")} ${err.message}\n`);
58
+ process.exit(1);
59
+ });
60
+ child.on("message", (message) => {
61
+ if (typeof message !== "object" || message === null) return;
62
+ const { type, port: reportedPort } = message;
63
+ if (type === "open-pages:listening" && typeof reportedPort === "number") port = reportedPort;
64
+ });
65
+ child.on("exit", (code, signal) => {
66
+ if (shuttingDown) process.exit(0);
67
+ if (code === RESTART_EXIT_CODE) {
68
+ openBrowser = false;
69
+ spawnChild();
70
+ return;
71
+ }
72
+ if (signal) process.exit(1);
73
+ process.exit(code ?? 0);
74
+ });
75
+ };
76
+ for (const signal of ["SIGINT", "SIGTERM"]) process.on(signal, () => {
77
+ shuttingDown = true;
78
+ child?.kill(signal);
79
+ });
80
+ spawnChild();
81
+ }
82
+ function devArgs(opts) {
83
+ const args = ["dev", "--no-skills-check"];
84
+ if (opts.port !== void 0) args.push("--port", String(opts.port));
85
+ if (opts.host === true) args.push("--host");
86
+ else if (typeof opts.host === "string") args.push("--host", opts.host);
87
+ if (opts.open) args.push("--open");
88
+ return args;
89
+ }
90
+ function resolveDevEntry(userCwd) {
91
+ const installed = path.join(userCwd, "node_modules", "@autono", "open-pages", "bin.js");
92
+ if (existsSync(installed)) return installed;
93
+ return process.argv[1];
94
+ }
95
+
96
+ //#endregion
97
+ export { dev };
@@ -0,0 +1,4 @@
1
+ import "./open-pages-plugin-D_DN_zjh.js";
2
+ import { buildPage, exportPages } from "./export-ic28osQP.js";
3
+
4
+ export { exportPages };
@@ -0,0 +1,131 @@
1
+ import { extractMeta, findPages, loadUserConfig, openPagesPlugin } from "./open-pages-plugin-D_DN_zjh.js";
2
+ import chalk from "chalk";
3
+ import { mkdir, readFile, realpath, rm, writeFile } from "node:fs/promises";
4
+ import path from "node:path";
5
+ import tailwindcss from "@tailwindcss/vite";
6
+ import react from "@vitejs/plugin-react";
7
+ import { build } from "vite";
8
+
9
+ //#region src/cli/export.ts
10
+ function escapeHtml(s) {
11
+ return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/"/g, "&quot;");
12
+ }
13
+ /**
14
+ * Build one page into a self-contained static folder: `index.html` plus
15
+ * hashed assets, with relative URLs so the folder deploys from any path.
16
+ * React pages get a generated entry that mounts the component; HTML pages
17
+ * build straight from their folder.
18
+ */
19
+ async function buildPage(opts) {
20
+ const { userCwd, config, coreVersion, entry, outDir } = opts;
21
+ const base = opts.base ?? "./";
22
+ const assetsAbs = path.resolve(userCwd, config.assetsDir ?? "assets");
23
+ let root;
24
+ if (entry.kind === "html") root = path.dirname(entry.file);
25
+ else {
26
+ root = path.join(userCwd, "node_modules", ".open-pages", "export", entry.id);
27
+ await rm(root, {
28
+ recursive: true,
29
+ force: true
30
+ });
31
+ await mkdir(root, { recursive: true });
32
+ root = await realpath(root);
33
+ const meta = extractMeta(await readFile(entry.file, "utf8"));
34
+ const title = escapeHtml(meta.title ?? entry.id);
35
+ const description = extractDescription(await readFile(entry.file, "utf8"));
36
+ await writeFile(path.join(root, "index.html"), [
37
+ "<!doctype html>",
38
+ "<html lang=\"en\">",
39
+ " <head>",
40
+ " <meta charset=\"UTF-8\" />",
41
+ " <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />",
42
+ ` <title>${title}</title>`,
43
+ description ? ` <meta name="description" content="${escapeHtml(description)}" />` : "",
44
+ " </head>",
45
+ " <body>",
46
+ " <div id=\"root\"></div>",
47
+ " <script type=\"module\" src=\"./entry.tsx\"></script>",
48
+ " </body>",
49
+ "</html>",
50
+ ""
51
+ ].filter((l) => l !== "").join("\n"), "utf8");
52
+ await writeFile(path.join(root, "entry.tsx"), [
53
+ "import 'virtual:open-pages/pages.css';",
54
+ "import { StrictMode } from 'react';",
55
+ "import { createRoot } from 'react-dom/client';",
56
+ `import Page from ${JSON.stringify(entry.file)};`,
57
+ "",
58
+ "createRoot(document.getElementById('root')!).render(",
59
+ " <StrictMode>",
60
+ " <Page />",
61
+ " </StrictMode>,",
62
+ ");",
63
+ ""
64
+ ].join("\n"), "utf8");
65
+ }
66
+ await build({
67
+ root,
68
+ base,
69
+ configFile: false,
70
+ envDir: userCwd,
71
+ logLevel: "error",
72
+ plugins: [
73
+ react(),
74
+ tailwindcss(),
75
+ openPagesPlugin({
76
+ userCwd,
77
+ config,
78
+ coreVersion
79
+ })
80
+ ],
81
+ resolve: { alias: { "@assets": assetsAbs } },
82
+ build: {
83
+ outDir,
84
+ emptyOutDir: true,
85
+ target: "es2022"
86
+ }
87
+ });
88
+ }
89
+ const META_DESCRIPTION_RE = /(?:^|[\s,{])description\s*:\s*['"]([^'"]+)['"]/;
90
+ function extractDescription(src) {
91
+ const metaStart = src.search(/export\s+const\s+meta\b/);
92
+ if (metaStart === -1) return null;
93
+ const end = src.indexOf("};", metaStart);
94
+ const body = src.slice(metaStart, end === -1 ? void 0 : end);
95
+ return body.match(META_DESCRIPTION_RE)?.[1] ?? null;
96
+ }
97
+ async function exportPages(opts = {}) {
98
+ const userCwd = process.cwd();
99
+ const config = await loadUserConfig(userCwd);
100
+ const pagesDir = config.pagesDir ?? "pages";
101
+ const outDir = path.resolve(userCwd, opts.outDir ?? "export");
102
+ const entries = await findPages(userCwd, pagesDir);
103
+ const idsOnDisk = entries.map((e) => e.id);
104
+ if (idsOnDisk.length === 0) throw new Error(`No pages found under ${pagesDir}/`);
105
+ const requested = opts.pages && opts.pages.length > 0 ? opts.pages : idsOnDisk;
106
+ const unknown = requested.filter((id) => !idsOnDisk.includes(id));
107
+ if (unknown.length > 0) throw new Error(`Page not found: ${unknown.join(", ")} (available: ${idsOnDisk.join(", ")})`);
108
+ const { readCoreVersion } = await import("./version-CeffgdfZ.js");
109
+ const coreVersion = readCoreVersion();
110
+ await mkdir(outDir, { recursive: true });
111
+ for (const id of requested) {
112
+ const entry = entries.find((e) => e.id === id);
113
+ if (!entry) continue;
114
+ const started = performance.now();
115
+ const target = path.join(outDir, id);
116
+ await buildPage({
117
+ userCwd,
118
+ config,
119
+ coreVersion,
120
+ entry,
121
+ outDir: target
122
+ });
123
+ const ms = Math.round(performance.now() - started);
124
+ process.stdout.write(`${chalk.green("ok")} ${path.relative(userCwd, target)}/ ${chalk.dim(`${entry.kind} · ${ms}ms`)}\n`);
125
+ }
126
+ const n = requested.length;
127
+ process.stdout.write(chalk.dim(`${n} ${n === 1 ? "page" : "pages"} → ${path.relative(userCwd, outDir)}/\n`));
128
+ }
129
+
130
+ //#endregion
131
+ export { buildPage, exportPages };
@@ -0,0 +1,56 @@
1
+ import { Locale, Plural } from "./types-C5NCdDT-.js";
2
+ import { OpenPagesConfig } from "./config-C9or4m4J.js";
3
+ import { ComponentType } from "react";
4
+
5
+ //#region src/app/lib/design.d.ts
6
+ type DesignPalette = {
7
+ bg: string;
8
+ text: string;
9
+ accent: string;
10
+ };
11
+ type DesignFonts = {
12
+ display: string;
13
+ body: string;
14
+ };
15
+ type DesignTypeScale = {
16
+ hero: number;
17
+ body: number;
18
+ };
19
+ type DesignSystem = {
20
+ palette: DesignPalette;
21
+ fonts: DesignFonts;
22
+ typeScale: DesignTypeScale;
23
+ radius: number;
24
+ };
25
+ declare function designToCssVars(d: DesignSystem): Record<string, string>;
26
+ declare function cssVarsToString(vars: Record<string, string>): string;
27
+ declare const defaultDesign: DesignSystem;
28
+ //#endregion
29
+ //#region src/app/lib/sdk.d.ts
30
+ /**
31
+ * A page is one React component rendered into a real browser document. It
32
+ * owns the whole viewport: layout, styling (Tailwind via `className` or a
33
+ * sibling stylesheet), interactivity, and any client-side routing it wants.
34
+ */
35
+ type PageComponent = ComponentType;
36
+ type PageMeta = {
37
+ /** Document title (browser tab, workspace card). Default: the folder name. */
38
+ title?: string;
39
+ /** `<meta name="description">` in the exported HTML. */
40
+ description?: string;
41
+ /** Id of a theme under `themes/` this page was built from. */
42
+ theme?: string;
43
+ /** ISO 8601 timestamp. Set once at scaffold time; used to sort the page list. */
44
+ createdAt?: string;
45
+ };
46
+ /** How a page entry is authored: a React module or a plain HTML file. */
47
+ type PageKind = 'react' | 'html';
48
+ type PageModule = {
49
+ /** Absent for `index.html` pages, which the workspace serves as-is. */
50
+ default?: PageComponent;
51
+ meta?: PageMeta;
52
+ design?: DesignSystem;
53
+ };
54
+
55
+ //#endregion
56
+ export { DesignFonts, DesignPalette, DesignSystem, DesignTypeScale, Locale, OpenPagesConfig, PageComponent, PageKind, PageMeta, PageModule, Plural, cssVarsToString, defaultDesign, designToCssVars };
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ import { cssVarsToString, defaultDesign, designToCssVars } from "./design-C13iz9_4.js";
2
+
3
+ export { cssVarsToString, defaultDesign, designToCssVars };
@@ -0,0 +1,24 @@
1
+ import { Locale, Plural } from "../types-C5NCdDT-.js";
2
+
3
+ //#region src/locale/en.d.ts
4
+ declare const en: Locale;
5
+
6
+ //#endregion
7
+ //#region src/locale/format.d.ts
8
+ declare function format(template: string, vars: Record<string, string | number>): string;
9
+ declare function plural(count: number, forms: Plural): string;
10
+
11
+ //#endregion
12
+ //#region src/locale/ja.d.ts
13
+ declare const ja: Locale;
14
+
15
+ //#endregion
16
+ //#region src/locale/zh-cn.d.ts
17
+ declare const zhCN: Locale;
18
+
19
+ //#endregion
20
+ //#region src/locale/zh-tw.d.ts
21
+ declare const zhTW: Locale;
22
+
23
+ //#endregion
24
+ export { Locale, Plural, en, format, ja, plural, zhCN, zhTW };