frontend-auto-cms 1.0.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 (42) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +64 -0
  3. package/dist/cli/apply.d.ts +7 -0
  4. package/dist/cli/apply.js +102 -0
  5. package/dist/cli/apply.js.map +1 -0
  6. package/dist/cli/fs-utils.d.ts +5 -0
  7. package/dist/cli/fs-utils.js +54 -0
  8. package/dist/cli/fs-utils.js.map +1 -0
  9. package/dist/cli/index.d.ts +2 -0
  10. package/dist/cli/index.js +32 -0
  11. package/dist/cli/index.js.map +1 -0
  12. package/dist/cli/postinstall.d.ts +1 -0
  13. package/dist/cli/postinstall.js +10 -0
  14. package/dist/cli/postinstall.js.map +1 -0
  15. package/dist/cli/scanner.d.ts +2 -0
  16. package/dist/cli/scanner.js +97 -0
  17. package/dist/cli/scanner.js.map +1 -0
  18. package/dist/cli/setup.d.ts +6 -0
  19. package/dist/cli/setup.js +256 -0
  20. package/dist/cli/setup.js.map +1 -0
  21. package/dist/runtime/dashboard.js +1189 -0
  22. package/dist/runtime/index.js +7 -0
  23. package/dist/runtime/runtime/dashboard.d.ts +2 -0
  24. package/dist/runtime/runtime/dom-scan.d.ts +3 -0
  25. package/dist/runtime/runtime/i18n.d.ts +7 -0
  26. package/dist/runtime/runtime/index.d.ts +1 -0
  27. package/dist/runtime/runtime/publish.d.ts +11 -0
  28. package/dist/runtime/runtime/store.d.ts +7 -0
  29. package/dist/runtime/runtime/types.d.ts +8 -0
  30. package/dist/runtime/shared/constants.d.ts +10 -0
  31. package/dist/runtime/shared/hash.d.ts +4 -0
  32. package/dist/runtime/shared/types.d.ts +71 -0
  33. package/dist/shared/constants.d.ts +10 -0
  34. package/dist/shared/constants.js +11 -0
  35. package/dist/shared/constants.js.map +1 -0
  36. package/dist/shared/hash.d.ts +4 -0
  37. package/dist/shared/hash.js +19 -0
  38. package/dist/shared/hash.js.map +1 -0
  39. package/dist/shared/types.d.ts +71 -0
  40. package/dist/shared/types.js +2 -0
  41. package/dist/shared/types.js.map +1 -0
  42. package/package.json +68 -0
@@ -0,0 +1,7 @@
1
+ import { registerCmsLauncher as e } from "./dashboard.js";
2
+ function n() {
3
+ typeof window > "u" || typeof document > "u" || (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", () => {
4
+ e();
5
+ }, { once: !0 }) : e());
6
+ }
7
+ n();
@@ -0,0 +1,2 @@
1
+ export declare function launchDashboard(): Promise<void>;
2
+ export declare function registerCmsLauncher(): Promise<void>;
@@ -0,0 +1,3 @@
1
+ import type { CmsContentFile, CmsNode } from "../shared/types.js";
2
+ export declare function scanDom(targetDocument?: Document, pagePath?: string): CmsContentFile;
3
+ export declare function applyNodeToDom(node: CmsNode, targetDocument?: Document): void;
@@ -0,0 +1,7 @@
1
+ export interface SupportedTranslationLanguage {
2
+ code: string;
3
+ label: string;
4
+ nllb: string;
5
+ }
6
+ export declare const SUPPORTED_TRANSLATION_LANGUAGES: SupportedTranslationLanguage[];
7
+ export declare function translateLanguage(sourceDict: Record<string, string>, targetLang: string, sourceLang?: string, onProgress?: (done: number, total: number) => void): Promise<Record<string, string>>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ import type { CmsContentFile, CmsPatchFile } from "../shared/types.js";
2
+ interface RuntimeHostingConfig {
3
+ version: 1;
4
+ provider: "none" | "github" | "gitlab";
5
+ repository: string;
6
+ branch: string;
7
+ }
8
+ export declare function loadHostingConfig(): Promise<RuntimeHostingConfig | null>;
9
+ export declare function publishToHosting(payload: CmsPatchFile, token: string, config: RuntimeHostingConfig | null): Promise<boolean>;
10
+ export declare function applyPublishedLocales(content: CmsContentFile): Record<string, string>;
11
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { CmsContentFile } from "../shared/types.js";
2
+ import type { RuntimeLocaleMap } from "./types.js";
3
+ export declare function saveCachedContent(content: CmsContentFile): void;
4
+ export declare function loadLocales(): RuntimeLocaleMap;
5
+ export declare function saveLocales(locales: RuntimeLocaleMap): void;
6
+ export declare function loadRuntimeLocales(): Promise<RuntimeLocaleMap>;
7
+ export declare function downloadPatchFile(payload: unknown): void;
@@ -0,0 +1,8 @@
1
+ import type { CmsContentFile, CmsNode } from "../shared/types.js";
2
+ export interface RuntimeState {
3
+ content: CmsContentFile;
4
+ byId: Map<string, CmsNode>;
5
+ }
6
+ export interface RuntimeLocaleMap {
7
+ [lang: string]: Record<string, string>;
8
+ }
@@ -0,0 +1,10 @@
1
+ export declare const CMS_CONFIG_FILE = ".cms-config.json";
2
+ export declare const CMS_HOSTING_FILE = ".cms-hosting.json";
3
+ export declare const CMS_CONTENT_FILE = "cms-content.json";
4
+ export declare const CMS_PATCH_FILE = "cms-export.patch.json";
5
+ export declare const CMS_ASSET_DIR = "public/cms-assets";
6
+ export declare const CMS_RUNTIME_AUTH_FILE = "public/cms-runtime-auth.json";
7
+ export declare const CMS_RUNTIME_HOSTING_FILE = "public/cms-hosting.json";
8
+ export declare const CMS_RUNTIME_SETTINGS_FILE = "public/cms-settings.json";
9
+ export declare const CMS_RUNTIME_LOCALES_FILE = "public/cms-locales.json";
10
+ export declare const SUPPORTED_EXTENSIONS: readonly [".html", ".jsx", ".tsx", ".vue", ".astro", ".svelte"];
@@ -0,0 +1,4 @@
1
+ export declare function createSalt(): string;
2
+ export declare function hashPasscode(passcode: string, salt: string): string;
3
+ export declare function verifyPasscode(passcode: string, salt: string, hash: string): boolean;
4
+ export declare function hashRuntimePasscode(passcode: string, salt: string): string;
@@ -0,0 +1,71 @@
1
+ export type CmsNodeType = "text" | "image" | "video" | "section" | "property";
2
+ export interface SourceRef {
3
+ file: string;
4
+ original: string;
5
+ occurrence?: number;
6
+ }
7
+ export interface CmsNode {
8
+ id: string;
9
+ key: string;
10
+ type: CmsNodeType;
11
+ label: string;
12
+ value: string;
13
+ selector?: string;
14
+ attrs?: Record<string, string>;
15
+ sourceRefs: SourceRef[];
16
+ sectionItems?: string[];
17
+ }
18
+ export interface CmsContentFile {
19
+ createdAt: string;
20
+ updatedAt: string;
21
+ nodes: CmsNode[];
22
+ }
23
+ export interface CmsConfigFile {
24
+ version: 1;
25
+ passcodeSalt: string;
26
+ passcodeHash: string;
27
+ contentFile: string;
28
+ localeDir: string;
29
+ dashboardPath?: string;
30
+ pages?: string[];
31
+ }
32
+ export interface CmsRuntimeAuthFile {
33
+ version: 1;
34
+ algorithm: "sha256";
35
+ salt: string;
36
+ passcodeHash: string;
37
+ }
38
+ export interface CmsHostingConfigFile {
39
+ version: 1;
40
+ provider: "none" | "github" | "gitlab";
41
+ repository: string;
42
+ branch: string;
43
+ token?: string;
44
+ }
45
+ export interface CmsRuntimeSettingsFile {
46
+ version: 1;
47
+ dashboardPath: string;
48
+ pages: string[];
49
+ showFloatingButton: boolean;
50
+ autoTranslateEnabled: boolean;
51
+ }
52
+ export interface CmsRuntimeLocalesFile {
53
+ version: 1;
54
+ locales: Record<string, Record<string, string>>;
55
+ }
56
+ export interface CmsPatchOperation {
57
+ file: string;
58
+ find: string;
59
+ replace: string;
60
+ occurrence?: number;
61
+ }
62
+ export interface CmsPatchFile {
63
+ generatedAt: string;
64
+ content: CmsContentFile;
65
+ operations: CmsPatchOperation[];
66
+ locales?: Record<string, Record<string, string>>;
67
+ integrity?: {
68
+ algorithm: "sha256";
69
+ value: string;
70
+ };
71
+ }
@@ -0,0 +1,10 @@
1
+ export declare const CMS_CONFIG_FILE = ".cms-config.json";
2
+ export declare const CMS_HOSTING_FILE = ".cms-hosting.json";
3
+ export declare const CMS_CONTENT_FILE = "cms-content.json";
4
+ export declare const CMS_PATCH_FILE = "cms-export.patch.json";
5
+ export declare const CMS_ASSET_DIR = "public/cms-assets";
6
+ export declare const CMS_RUNTIME_AUTH_FILE = "public/cms-runtime-auth.json";
7
+ export declare const CMS_RUNTIME_HOSTING_FILE = "public/cms-hosting.json";
8
+ export declare const CMS_RUNTIME_SETTINGS_FILE = "public/cms-settings.json";
9
+ export declare const CMS_RUNTIME_LOCALES_FILE = "public/cms-locales.json";
10
+ export declare const SUPPORTED_EXTENSIONS: readonly [".html", ".jsx", ".tsx", ".vue", ".astro", ".svelte"];
@@ -0,0 +1,11 @@
1
+ export const CMS_CONFIG_FILE = ".cms-config.json";
2
+ export const CMS_HOSTING_FILE = ".cms-hosting.json";
3
+ export const CMS_CONTENT_FILE = "cms-content.json";
4
+ export const CMS_PATCH_FILE = "cms-export.patch.json";
5
+ export const CMS_ASSET_DIR = "public/cms-assets";
6
+ export const CMS_RUNTIME_AUTH_FILE = "public/cms-runtime-auth.json";
7
+ export const CMS_RUNTIME_HOSTING_FILE = "public/cms-hosting.json";
8
+ export const CMS_RUNTIME_SETTINGS_FILE = "public/cms-settings.json";
9
+ export const CMS_RUNTIME_LOCALES_FILE = "public/cms-locales.json";
10
+ export const SUPPORTED_EXTENSIONS = [".html", ".jsx", ".tsx", ".vue", ".astro", ".svelte"];
11
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/shared/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAClD,MAAM,CAAC,MAAM,gBAAgB,GAAG,mBAAmB,CAAC;AACpD,MAAM,CAAC,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AACnD,MAAM,CAAC,MAAM,cAAc,GAAG,uBAAuB,CAAC;AACtD,MAAM,CAAC,MAAM,aAAa,GAAG,mBAAmB,CAAC;AACjD,MAAM,CAAC,MAAM,qBAAqB,GAAG,8BAA8B,CAAC;AACpE,MAAM,CAAC,MAAM,wBAAwB,GAAG,yBAAyB,CAAC;AAClE,MAAM,CAAC,MAAM,yBAAyB,GAAG,0BAA0B,CAAC;AACpE,MAAM,CAAC,MAAM,wBAAwB,GAAG,yBAAyB,CAAC;AAClE,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAU,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare function createSalt(): string;
2
+ export declare function hashPasscode(passcode: string, salt: string): string;
3
+ export declare function verifyPasscode(passcode: string, salt: string, hash: string): boolean;
4
+ export declare function hashRuntimePasscode(passcode: string, salt: string): string;
@@ -0,0 +1,19 @@
1
+ import { createHash, randomBytes, scryptSync, timingSafeEqual } from "node:crypto";
2
+ export function createSalt() {
3
+ return randomBytes(16).toString("hex");
4
+ }
5
+ export function hashPasscode(passcode, salt) {
6
+ return scryptSync(passcode, salt, 32).toString("hex");
7
+ }
8
+ export function verifyPasscode(passcode, salt, hash) {
9
+ const derived = Buffer.from(hashPasscode(passcode, salt), "hex");
10
+ const expected = Buffer.from(hash, "hex");
11
+ if (derived.length !== expected.length) {
12
+ return false;
13
+ }
14
+ return timingSafeEqual(derived, expected);
15
+ }
16
+ export function hashRuntimePasscode(passcode, salt) {
17
+ return createHash("sha256").update(`${salt}:${passcode}`).digest("hex");
18
+ }
19
+ //# sourceMappingURL=hash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash.js","sourceRoot":"","sources":["../../src/shared/hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnF,MAAM,UAAU,UAAU;IACxB,OAAO,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,QAAgB,EAAE,IAAY;IACzD,OAAO,UAAU,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,QAAgB,EAAE,IAAY,EAAE,IAAY;IACzE,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC;IACjE,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC1C,IAAI,OAAO,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM,EAAE,CAAC;QACvC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,eAAe,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,QAAgB,EAAE,IAAY;IAChE,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,IAAI,IAAI,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC1E,CAAC"}
@@ -0,0 +1,71 @@
1
+ export type CmsNodeType = "text" | "image" | "video" | "section" | "property";
2
+ export interface SourceRef {
3
+ file: string;
4
+ original: string;
5
+ occurrence?: number;
6
+ }
7
+ export interface CmsNode {
8
+ id: string;
9
+ key: string;
10
+ type: CmsNodeType;
11
+ label: string;
12
+ value: string;
13
+ selector?: string;
14
+ attrs?: Record<string, string>;
15
+ sourceRefs: SourceRef[];
16
+ sectionItems?: string[];
17
+ }
18
+ export interface CmsContentFile {
19
+ createdAt: string;
20
+ updatedAt: string;
21
+ nodes: CmsNode[];
22
+ }
23
+ export interface CmsConfigFile {
24
+ version: 1;
25
+ passcodeSalt: string;
26
+ passcodeHash: string;
27
+ contentFile: string;
28
+ localeDir: string;
29
+ dashboardPath?: string;
30
+ pages?: string[];
31
+ }
32
+ export interface CmsRuntimeAuthFile {
33
+ version: 1;
34
+ algorithm: "sha256";
35
+ salt: string;
36
+ passcodeHash: string;
37
+ }
38
+ export interface CmsHostingConfigFile {
39
+ version: 1;
40
+ provider: "none" | "github" | "gitlab";
41
+ repository: string;
42
+ branch: string;
43
+ token?: string;
44
+ }
45
+ export interface CmsRuntimeSettingsFile {
46
+ version: 1;
47
+ dashboardPath: string;
48
+ pages: string[];
49
+ showFloatingButton: boolean;
50
+ autoTranslateEnabled: boolean;
51
+ }
52
+ export interface CmsRuntimeLocalesFile {
53
+ version: 1;
54
+ locales: Record<string, Record<string, string>>;
55
+ }
56
+ export interface CmsPatchOperation {
57
+ file: string;
58
+ find: string;
59
+ replace: string;
60
+ occurrence?: number;
61
+ }
62
+ export interface CmsPatchFile {
63
+ generatedAt: string;
64
+ content: CmsContentFile;
65
+ operations: CmsPatchOperation[];
66
+ locales?: Record<string, Record<string, string>>;
67
+ integrity?: {
68
+ algorithm: "sha256";
69
+ value: string;
70
+ };
71
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/shared/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "frontend-auto-cms",
3
+ "version": "1.0.0",
4
+ "description": "Turn any frontend into an editable mini-CMS with one import.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "frontend-auto-cms",
8
+ "homepage": "https://example.com/frontend-auto-cms",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://example.com/frontend-auto-cms.git"
12
+ },
13
+ "keywords": [
14
+ "cms",
15
+ "frontend",
16
+ "content-management",
17
+ "i18n",
18
+ "dashboard",
19
+ "vite",
20
+ "zero-config"
21
+ ],
22
+ "main": "./dist/runtime/index.js",
23
+ "module": "./dist/runtime/index.js",
24
+ "types": "./dist/runtime/runtime/index.d.ts",
25
+ "exports": {
26
+ ".": {
27
+ "types": "./dist/runtime/runtime/index.d.ts",
28
+ "import": "./dist/runtime/index.js"
29
+ },
30
+ "./dashboard": {
31
+ "types": "./dist/runtime/runtime/dashboard.d.ts",
32
+ "import": "./dist/runtime/dashboard.js"
33
+ },
34
+ "./package.json": "./package.json"
35
+ },
36
+ "bin": {
37
+ "frontend-auto-cms": "./dist/cli/index.js"
38
+ },
39
+ "files": [
40
+ "dist",
41
+ "README.md",
42
+ "LICENSE"
43
+ ],
44
+ "scripts": {
45
+ "clean": "rm -rf dist",
46
+ "build": "npm run clean && npm run build:runtime && npm run build:types && npm run build:cli",
47
+ "build:runtime": "vite build",
48
+ "build:types": "tsc -p tsconfig.runtime.build.json",
49
+ "build:cli": "tsc -p tsconfig.cli.json && chmod +x dist/cli/index.js dist/cli/postinstall.js",
50
+ "dev": "vite build --watch",
51
+ "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.cli.json --noEmit",
52
+ "prepare": "npm run build",
53
+ "postinstall": "node ./scripts/postinstall.mjs"
54
+ },
55
+ "dependencies": {
56
+ "chalk": "^5.4.1",
57
+ "commander": "^14.0.1",
58
+ "inquirer": "^12.9.6"
59
+ },
60
+ "devDependencies": {
61
+ "@types/node": "^24.3.0",
62
+ "autoprefixer": "^10.4.27",
63
+ "postcss": "^8.5.8",
64
+ "tailwindcss": "^3.4.19",
65
+ "typescript": "^5.9.2",
66
+ "vite": "^7.1.3"
67
+ }
68
+ }