@vef-framework-react/dev 2.12.0 → 2.13.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 (37) hide show
  1. package/dist/cjs/code-generation/code-set/core.cjs +1 -0
  2. package/dist/cjs/code-generation/code-set/index.cjs +1 -0
  3. package/dist/cjs/code-generation/code-set/load-config.cjs +1 -0
  4. package/dist/cjs/code-generation/code-set/render.cjs +2 -0
  5. package/dist/cjs/code-generation/index.cjs +1 -1
  6. package/dist/cjs/index.cjs +1 -1
  7. package/dist/cli/index.js +4 -4
  8. package/dist/es/code-generation/code-set/core.js +109 -0
  9. package/dist/es/code-generation/code-set/index.js +11 -0
  10. package/dist/es/code-generation/code-set/load-config.js +50 -0
  11. package/dist/es/code-generation/code-set/render.js +31 -0
  12. package/dist/es/code-generation/index.js +7 -7
  13. package/dist/es/index.js +17 -17
  14. package/dist/types/cli/commands/gen-code-set-keys.d.ts +6 -0
  15. package/dist/types/code-generation/{dictionary → code-set}/core.d.ts +6 -6
  16. package/dist/types/code-generation/code-set/index.d.ts +4 -0
  17. package/dist/types/code-generation/{dictionary → code-set}/load-config.d.ts +1 -1
  18. package/dist/types/code-generation/code-set/render.d.ts +24 -0
  19. package/dist/types/code-generation/{dictionary → code-set}/types.d.ts +12 -12
  20. package/dist/types/code-generation/index.d.ts +1 -1
  21. package/package.json +1 -1
  22. package/dist/cjs/code-generation/dictionary/core.cjs +0 -1
  23. package/dist/cjs/code-generation/dictionary/index.cjs +0 -1
  24. package/dist/cjs/code-generation/dictionary/load-config.cjs +0 -1
  25. package/dist/cjs/code-generation/dictionary/render.cjs +0 -2
  26. package/dist/es/code-generation/dictionary/core.js +0 -109
  27. package/dist/es/code-generation/dictionary/index.js +0 -11
  28. package/dist/es/code-generation/dictionary/load-config.js +0 -50
  29. package/dist/es/code-generation/dictionary/render.js +0 -31
  30. package/dist/types/cli/commands/gen-dictionary-keys.d.ts +0 -6
  31. package/dist/types/code-generation/dictionary/index.d.ts +0 -4
  32. package/dist/types/code-generation/dictionary/render.d.ts +0 -24
  33. /package/dist/cjs/code-generation/{dictionary → code-set}/errors.cjs +0 -0
  34. /package/dist/cjs/code-generation/{dictionary → code-set}/types.cjs +0 -0
  35. /package/dist/es/code-generation/{dictionary → code-set}/errors.js +0 -0
  36. /package/dist/es/code-generation/{dictionary → code-set}/types.js +0 -0
  37. /package/dist/types/code-generation/{dictionary → code-set}/errors.d.ts +0 -0
@@ -0,0 +1 @@
1
+ const c=require("./errors.cjs"),C=require("./load-config.cjs"),E=require("./render.cjs");let _=require("node:crypto"),f=require("node:fs"),i=require("node:fs/promises"),a=require("node:path");var S="src/types/code-set-keys.gen.ts",T=3e4,k=/^[\w.-]+$/,p="letters, digits, underscore, dot, hyphen",O=e=>console.warn(e);function v(e,t){return e.key<t.key?-1:e.key>t.key?1:0}async function K({projectDir:e,configFile:t,output:n,check:r=!1,augmentTarget:o,onWarn:d=O}){const{config:s,configPath:l}=await C.loadCodeGenerationConfig({projectDir:e,configFile:t});if(!s.codeSetKeys)throw new c.CodeGenerationValidationError(`Code generation config at ${l} has no \`codeSetKeys\` block.`);const{codeSetKeys:y}=s,w=await $(y.fetchCodeSetKeys,y.timeout??T);A(w);const h=F(w,d);h.length===0&&d("`fetchCodeSetKeys` returned no entries; the generated file will declare `CodeSetKey = never`.");const u=q(e,n??y.output??S),m=E.renderCodeSetKeysFile(h,{configFile:(0,a.relative)(e,l),augmentTarget:o}),g=await L(u)!==m;return g&&!r&&(await N(u),await b(u,m)),{outputPath:u,keyCount:h.length,changed:g}}async function $(e,t){if(t<=0)return await e();let n;try{return await Promise.race([e(),new Promise((r,o)=>{n=setTimeout(()=>o(new Error(`fetchCodeSetKeys timed out after ${t}ms.`)),t)})])}finally{n&&clearTimeout(n)}}function A(e){for(const t of e)if(typeof t.key!="string"||!k.test(t.key))throw new c.CodeGenerationValidationError(`Invalid code set key ${JSON.stringify(t.key)}. Keys must match ${k} (${p}).`)}function F(e,t){const n=new Map;for(const r of e){const o=n.get(r.key);if(!o){n.set(r.key,r);continue}o.comment!==r.comment&&t(`Duplicate code set key "${r.key}" with conflicting comments; keeping the first occurrence.`)}return n.values().toArray().toSorted(v)}function q(e,t){if((0,a.isAbsolute)(t))throw new c.CodeGenerationValidationError(`Output path must be relative to project root; absolute paths are rejected: ${t}`);const n=(0,a.resolve)(e,t),r=(0,a.relative)(e,n);if(r.startsWith("..")||(0,a.isAbsolute)(r))throw new c.CodeGenerationValidationError(`Output path escapes project root: ${t}. Must stay within ${e}.`);return n}async function N(e){let t;try{t=await(0,i.lstat)(e)}catch(n){if(n.code==="ENOENT")return;throw n}if(t.isSymbolicLink())throw new c.CodeGenerationValidationError(`Refusing to overwrite symlink at output path: ${e}. Delete the symlink and rerun generation if this is intentional.`)}async function L(e){try{return await(0,i.readFile)(e,"utf-8")}catch(t){if(t.code==="ENOENT")return null;throw t}}async function b(e,t){await(0,i.mkdir)((0,a.dirname)(e),{recursive:!0});const n=(0,_.randomBytes)(6).toString("hex"),r=`${e}.${n}.tmp`,o=f.constants.O_NOFOLLOW??0,d=f.constants.O_WRONLY|f.constants.O_CREAT|f.constants.O_EXCL|o,s=await(0,i.open)(r,d,384);try{await s.writeFile(t,"utf-8")}finally{await s.close()}try{await(0,i.rename)(r,e)}catch(l){throw await(0,i.unlink)(r).catch(()=>{}),l}await(0,i.chmod)(e,420)}exports.generateCodeSetKeys=K;
@@ -0,0 +1 @@
1
+ const r=require("./errors.cjs"),e=require("./render.cjs"),o=require("./core.cjs"),n=require("./types.cjs");exports.CODE_SET_AUGMENT_TARGET=e.CODE_SET_AUGMENT_TARGET;exports.CodeGenerationValidationError=r.CodeGenerationValidationError;exports.defineCodeGenerationConfig=n.defineCodeGenerationConfig;exports.generateCodeSetKeys=o.generateCodeSetKeys;exports.renderCodeSetKeysFile=e.renderCodeSetKeysFile;
@@ -0,0 +1 @@
1
+ const o=require("./errors.cjs");let s=require("node:fs"),r=require("node:path"),f=require("jiti");var c=["code-generation.config.ts","code-generation.config.mts","code-generation.config.js","code-generation.config.mjs"];async function C({projectDir:e,configFile:t}){const i=t?[g(e,t)]:c.map(a=>(0,r.resolve)(e,a)),n=i.find(a=>(0,s.existsSync)(a));if(!n)throw new o.CodeGenerationValidationError(`Code generation config not found. Looked for: ${i.join(", ")}`);const u=await(0,f.createJiti)(e).import(n),d=l(u);return w(d,n),{config:d,configPath:n}}function g(e,t){const i=(0,r.isAbsolute)(t)?t:(0,r.resolve)(e,t),n=(0,r.relative)(e,i);if(n.startsWith("..")||(0,r.isAbsolute)(n))throw new o.CodeGenerationValidationError(`Code generation config file escapes project root: ${t}. Must stay within ${e}.`);return i}function l(e){return e!==null&&typeof e=="object"&&"default"in e&&e.default!==null&&typeof e.default=="object"?e.default:e}function w(e,t){if(typeof e!="object"||e===null)throw new o.CodeGenerationValidationError(`Code generation config at ${t} must export a CodeGenerationConfig object.`);e.codeSetKeys!==void 0&&y(e.codeSetKeys,t)}function y(e,t){if(typeof e!="object"||e===null)throw new o.CodeGenerationValidationError(`Code generation config at ${t} field \`codeSetKeys\` must be an object when set.`);if(typeof e.fetchCodeSetKeys!="function")throw new o.CodeGenerationValidationError(`Code generation config at ${t} field \`codeSetKeys.fetchCodeSetKeys\` must be a function.`);if(e.output!==void 0&&typeof e.output!="string")throw new o.CodeGenerationValidationError(`Code generation config at ${t} field \`codeSetKeys.output\` must be a string when set; got ${typeof e.output}.`);if(e.timeout!==void 0&&!p(e.timeout))throw new o.CodeGenerationValidationError(`Code generation config at ${t} field \`codeSetKeys.timeout\` must be a finite non-negative number when set; got ${String(e.timeout)}.`)}function p(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}exports.loadCodeGenerationConfig=C;
@@ -0,0 +1,2 @@
1
+ var o="@vef-framework-react/hooks",f=["/* eslint-disable */","// @ts-nocheck","// noinspection JSUnusedGlobalSymbols","// AUTO-GENERATED by @vef-framework-react/dev (vef gen:code-set-keys). DO NOT EDIT."];function a(t,r){const{configFile:s,augmentTarget:i=o}=r,e=[...f,`// Source: ${s}`,""];if(t.length===0)e.push("export type CodeSetKey = never;");else{e.push("export type CodeSetKey =");for(const[c,n]of t.entries()){const l=c===t.length-1?";":"";n.comment&&e.push(` /** ${d(n.comment)} */`),e.push(` | ${JSON.stringify(n.key)}${l}`)}}return e.push("",`declare module ${JSON.stringify(i)} {`," interface Register {"," codeSetKeys: CodeSetKey;"," }","}",""),e.join(`
2
+ `)}function d(t){return t.replaceAll(/\s+/g," ").trim().replaceAll("*/",String.raw`*\/`)}exports.CODE_SET_AUGMENT_TARGET=o;exports.renderCodeSetKeysFile=a;
@@ -1 +1 @@
1
- const r=require("./dictionary/errors.cjs"),e=require("./dictionary/render.cjs"),i=require("./dictionary/core.cjs"),n=require("./dictionary/types.cjs");exports.CodeGenerationValidationError=r.CodeGenerationValidationError;exports.DICTIONARY_AUGMENT_TARGET=e.DICTIONARY_AUGMENT_TARGET;exports.defineCodeGenerationConfig=n.defineCodeGenerationConfig;exports.generateDictionaryKeys=i.generateDictionaryKeys;exports.renderDictionaryKeysFile=e.renderDictionaryKeysFile;
1
+ const r=require("./code-set/errors.cjs"),e=require("./code-set/render.cjs"),o=require("./code-set/core.cjs"),n=require("./code-set/types.cjs");exports.CODE_SET_AUGMENT_TARGET=e.CODE_SET_AUGMENT_TARGET;exports.CodeGenerationValidationError=r.CodeGenerationValidationError;exports.defineCodeGenerationConfig=n.defineCodeGenerationConfig;exports.generateCodeSetKeys=o.generateCodeSetKeys;exports.renderCodeSetKeysFile=e.renderCodeSetKeysFile;
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./code-generation/dictionary/errors.cjs"),e=require("./code-generation/dictionary/render.cjs"),r=require("./code-generation/dictionary/core.cjs"),n=require("./code-generation/dictionary/types.cjs"),t=require("./lint/eslint.cjs"),o=require("./lint/stylelint.cjs"),f=require("./vite/config.cjs");let u=require("@coldsmirk/commitlint-config"),d=require("recast");exports.CodeGenerationValidationError=i.CodeGenerationValidationError;exports.DICTIONARY_AUGMENT_TARGET=e.DICTIONARY_AUGMENT_TARGET;exports.defineCodeGenerationConfig=n.defineCodeGenerationConfig;Object.defineProperty(exports,"defineCommitlintConfig",{enumerable:!0,get:function(){return u.defineCommitlintConfig}});exports.defineEslintConfig=t.defineEslintConfig;exports.defineStylelintConfig=o.defineStylelintConfig;exports.defineViteConfig=f.defineViteConfig;exports.generateDictionaryKeys=r.generateDictionaryKeys;exports.renderDictionaryKeysFile=e.renderDictionaryKeysFile;Object.defineProperty(exports,"types",{enumerable:!0,get:function(){return d.types}});
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./code-generation/code-set/errors.cjs"),e=require("./code-generation/code-set/render.cjs"),i=require("./code-generation/code-set/core.cjs"),n=require("./code-generation/code-set/types.cjs"),t=require("./lint/eslint.cjs"),o=require("./lint/stylelint.cjs"),d=require("./vite/config.cjs");let f=require("@coldsmirk/commitlint-config"),u=require("recast");exports.CODE_SET_AUGMENT_TARGET=e.CODE_SET_AUGMENT_TARGET;exports.CodeGenerationValidationError=r.CodeGenerationValidationError;exports.defineCodeGenerationConfig=n.defineCodeGenerationConfig;Object.defineProperty(exports,"defineCommitlintConfig",{enumerable:!0,get:function(){return f.defineCommitlintConfig}});exports.defineEslintConfig=t.defineEslintConfig;exports.defineStylelintConfig=o.defineStylelintConfig;exports.defineViteConfig=d.defineViteConfig;exports.generateCodeSetKeys=i.generateCodeSetKeys;exports.renderCodeSetKeysFile=e.renderCodeSetKeysFile;Object.defineProperty(exports,"types",{enumerable:!0,get:function(){return u.types}});
package/dist/cli/index.js CHANGED
@@ -1,6 +1,6 @@
1
- /*! @vef-framework-react/dev v2.12.0 made by Venus | 2026-07-17T09:22:36.577Z */
2
- import ft from"chalk";import{program as u}from"commander";import N from"process";import R from"consola";import{randomBytes as fe}from"crypto";import{constants as h}from"fs";import{chmod as pe,lstat as de,mkdir as me,open as ge,readFile as ye,rename as le,unlink as ue}from"fs/promises";import{dirname as he,isAbsolute as T,relative as G,resolve as we}from"path";var c=class extends Error{constructor(t){super(t),this.name="CodeGenerationValidationError"}};import{existsSync as Q}from"fs";import{isAbsolute as P,relative as X,resolve as _}from"path";import{createJiti as Z}from"jiti";var ee=["code-generation.config.ts","code-generation.config.mts","code-generation.config.js","code-generation.config.mjs"];async function S({projectDir:e,configFile:t}){let n=t?[te(e,t)]:ee.map(a=>_(e,a)),i=n.find(a=>Q(a));if(!i)throw new c(`Code generation config not found. Looked for: ${n.join(", ")}`);let s=await Z(e).import(i),r=ne(s);return ie(r,i),{config:r,configPath:i}}function te(e,t){let n=P(t)?t:_(e,t),i=X(e,n);if(i.startsWith("..")||P(i))throw new c(`Code generation config file escapes project root: ${t}. Must stay within ${e}.`);return n}function ne(e){return e!==null&&typeof e=="object"&&"default"in e&&e.default!==null&&typeof e.default=="object"?e.default:e}function ie(e,t){if(typeof e!="object"||e===null)throw new c(`Code generation config at ${t} must export a CodeGenerationConfig object.`);e.dictionaryKeys!==void 0&&oe(e.dictionaryKeys,t)}function oe(e,t){if(typeof e!="object"||e===null)throw new c(`Code generation config at ${t} field \`dictionaryKeys\` must be an object when set.`);if(typeof e.fetchDictionaryKeys!="function")throw new c(`Code generation config at ${t} field \`dictionaryKeys.fetchDictionaryKeys\` must be a function.`);if(e.output!==void 0&&typeof e.output!="string")throw new c(`Code generation config at ${t} field \`dictionaryKeys.output\` must be a string when set; got ${typeof e.output}.`);if(e.timeout!==void 0&&!re(e.timeout))throw new c(`Code generation config at ${t} field \`dictionaryKeys.timeout\` must be a finite non-negative number when set; got ${String(e.timeout)}.`)}function re(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}var ae="@vef-framework-react/hooks",se=["/* eslint-disable */","// @ts-nocheck","// noinspection JSUnusedGlobalSymbols","// AUTO-GENERATED by @vef-framework-react/dev (vef gen:dictionary-keys). DO NOT EDIT."];function O(e,t){let{configFile:n,augmentTarget:i=ae}=t,o=[...se,`// Source: ${n}`,""];if(e.length===0)o.push("export type DictionaryKey = never;");else{o.push("export type DictionaryKey =");for(let[s,r]of e.entries()){let a=s===e.length-1?";":"";r.comment&&o.push(` /** ${ce(r.comment)} */`),o.push(` | ${JSON.stringify(r.key)}${a}`)}}return o.push("",`declare module ${JSON.stringify(i)} {`," interface Register {"," dictionaryKeys: DictionaryKey;"," }","}",""),o.join(`
3
- `)}function ce(e){return e.replaceAll(/\s+/g," ").trim().replaceAll("*/",String.raw`*\/`)}var Ee="src/types/dictionary.gen.ts",ve=3e4,A=/^[\w.-]+$/,Ce="letters, digits, underscore, dot, hyphen",ke=e=>console.warn(e);function xe(e,t){return e.key<t.key?-1:e.key>t.key?1:0}async function v({projectDir:e,configFile:t,output:n,check:i=!1,augmentTarget:o,onWarn:s=ke}){let{config:r,configPath:a}=await S({projectDir:e,configFile:t});if(!r.dictionaryKeys)throw new c(`Code generation config at ${a} has no \`dictionaryKeys\` block.`);let{dictionaryKeys:d}=r,m=await Ke(d.fetchDictionaryKeys,d.timeout??ve);De(m);let f=Pe(m,s);f.length===0&&s("`fetchDictionaryKeys` returned no entries; the generated file will declare `DictionaryKey = never`.");let g=_e(e,n??d.output??Ee),K=O(f,{configFile:G(e,a),augmentTarget:o}),D=await Oe(g)!==K;return D&&!i&&(await Se(g),await Te(g,K)),{outputPath:g,keyCount:f.length,changed:D}}async function Ke(e,t){if(t<=0)return await e();let n;try{return await Promise.race([e(),new Promise((i,o)=>{n=setTimeout(()=>o(new Error(`fetchDictionaryKeys timed out after ${t}ms.`)),t)})])}finally{n&&clearTimeout(n)}}function De(e){for(let t of e)if(typeof t.key!="string"||!A.test(t.key))throw new c(`Invalid dictionary key ${JSON.stringify(t.key)}. Keys must match ${A} (${Ce}).`)}function Pe(e,t){let n=new Map;for(let i of e){let o=n.get(i.key);if(!o){n.set(i.key,i);continue}o.comment!==i.comment&&t(`Duplicate dictionary key "${i.key}" with conflicting comments; keeping the first occurrence.`)}return n.values().toArray().toSorted(xe)}function _e(e,t){if(T(t))throw new c(`Output path must be relative to project root; absolute paths are rejected: ${t}`);let n=we(e,t),i=G(e,n);if(i.startsWith("..")||T(i))throw new c(`Output path escapes project root: ${t}. Must stay within ${e}.`);return n}async function Se(e){let t;try{t=await de(e)}catch(n){if(n.code==="ENOENT")return;throw n}if(t.isSymbolicLink())throw new c(`Refusing to overwrite symlink at output path: ${e}. Delete the symlink and rerun generation if this is intentional.`)}async function Oe(e){try{return await ye(e,"utf-8")}catch(t){if(t.code==="ENOENT")return null;throw t}}async function Te(e,t){await me(he(e),{recursive:!0});let n=fe(6).toString("hex"),i=`${e}.${n}.tmp`,o=h.O_NOFOLLOW??0,s=h.O_WRONLY|h.O_CREAT|h.O_EXCL|o,r=await ge(i,s,384);try{await r.writeFile(t,"utf-8")}finally{await r.close()}try{await le(i,e)}catch(a){throw await ue(i).catch(()=>{}),a}await pe(e,420)}import{resolve as Ae}from"path";import{exit as Ge}from"process";import F from"consola";import{execa as Fe}from"execa";import $e from"fs-extra";var{readJsonSync:Ne}=$e,p=class extends Error{};function w(){let e=Ae(import.meta.dirname,"../../package.json");return Ne(e,{encoding:"utf-8"}).version}function $(e){e instanceof p?F.error(e.message):F.error(e),Ge(1)}async function E(){try{await Fe("pnpm",["--version"])}catch{throw new p("VEF requires pnpm. Install it from https://pnpm.io and try again.")}}async function I(e,t=N.cwd()){try{let n=await v({projectDir:t,configFile:e.config,output:e.output,check:e.check,onWarn:o=>R.warn(o)});if(e.check&&n.changed)throw new p(`Generated dictionary keys file is stale at ${n.outputPath}. Run \`vef gen:dictionary-keys\` to refresh.`);let i=n.changed?"":" (unchanged)";R.success(`Generated ${n.keyCount} dictionary keys -> ${n.outputPath}${i}`)}catch(n){if(n instanceof p)throw n;if(N.env.CI){let i=n instanceof Error?n.message:String(n);throw new p(`gen:dictionary-keys failed: ${i}`)}throw n}}import{resolve as y}from"path";import Re,{exit as Ie}from"process";import l from"consola";import{execa as k}from"execa";import be from"fs-extra";import H from"ora";import je from"prompts";var b={"pre-commit":"pnpm dlx lint-staged","commit-msg":"pnpm dlx commitlint --edit $1","pre-push":"pnpm typecheck && pnpm test"},j={"*.{js,ts,tsx,json,jsonc,md,mdx,html}":"eslint --fix","*.{css,scss}":"stylelint --fix"},U={prepare:"vef prepare",typecheck:"tsc --noEmit",test:"vitest run --passWithNoTests"},L="@vef-framework-react/";var{copy:Ue,exists:Le,move:Je,readdir:Ve,readFile:J,readJson:We,writeFile:V,writeJson:Me}=be,W="http://127.0.0.1:8080";function He(e){return e.trim().toLowerCase().replaceAll(/\s+/g,"-").replace(/^[._]+/,"").replaceAll(/[^a-z0-9~-]+/g,"-").replaceAll(/^-+|-+$/g,"")}function M(e){let t=typeof e=="string"?e.trim():"";return t?/[/\\]/.test(t)||t.includes("..")?"App name cannot contain path separators or '..'":!0:"App name is required"}function Ye(e,t){for(let n of["dependencies","devDependencies"]){let i=e[n];if(i)for(let o of Object.keys(i))o.startsWith(L)&&(i[o]=t)}}function C(e,t,n){return e.replace(new RegExp(`^${t}=.*$`,"m"),()=>`${t}=${n}`)}async function Y(e={},t=Re.cwd()){l.start("Creating a new VEF project");let n=[];e.name===void 0&&n.push({type:"text",name:"name",message:"What is the name of your app?",validate:M}),e.title===void 0&&n.push({type:"text",name:"title",message:"What is the title of your app?",validate:g=>typeof g=="string"&&g.trim().length>0||"App title is required"}),e.apiUrl===void 0&&n.push({type:"text",name:"apiUrl",message:"Dev API base URL?",initial:W});let i=await je(n,{onCancel:()=>{l.info("Operation cancelled"),Ie(0)}}),o=e.name??i.name,s=M(o);if(s!==!0)throw new p(s);let r=o.trim(),a=He(r),d=(e.title??i.title)?.trim()||r,m=(e.apiUrl??i.apiUrl)?.trim()||W,f=y(t,r);if(await Le(f)&&(await Ve(f)).length>0)throw new p(`Target directory "${r}" already exists and is not empty. Choose another name or empty it first.`);await E(),await qe(f),await Be(a,f),await Qe(f,{packageName:a,appTitle:d,apiUrl:m}),await Xe(f),await Ze(f),et(r)}var ze=[["_gitignore",".gitignore"],["_gitattributes",".gitattributes"],["_editorconfig",".editorconfig"],["_package.json","package.json"],["_tsconfig.json","tsconfig.json"],["_eslint.config.ts","eslint.config.ts"],["_stylelint.config.js","stylelint.config.js"],["_commitlint.config.ts","commitlint.config.ts"],["_vite.config.ts","vite.config.ts"]];async function qe(e){let t=y(import.meta.dirname,"../template");await Ue(t,e),l.success("Successfully copied template files");for(let[n,i]of ze)await Je(y(e,n),y(e,i))}async function Be(e,t){let n=y(t,"package.json"),i=await We(n,{encoding:"utf-8"}),o=w();i.name=e,Ye(i,o),await Me(n,i,{encoding:"utf-8",spaces:2}),l.success(`Successfully set the app name and pinned framework packages to v${o}`)}async function Qe(e,t){let n=y(e,"env/.env"),i=await J(n,{encoding:"utf-8"}),o=C(C(i,"VEF_APP_NAME",t.packageName),"VEF_APP_TITLE",t.appTitle);await V(n,o);let s=y(e,"env/.env.development"),r=await J(s,{encoding:"utf-8"});await V(s,C(r,"VEF_APP_API_BASE_URL",t.apiUrl)),l.success("Successfully configured environment files")}async function Xe(e){let t=H("Initializing git repository...").start();try{await k`git --version`,await k({cwd:e})`git init`,t.succeed("Successfully initialized git repository")}catch(n){throw t.fail("Failed to initialize git repository"),n}}async function Ze(e){let t=H("Installing dependencies...").start();try{await k({cwd:e})("pnpm",["install"]),t.succeed("Successfully installed dependencies")}catch(n){throw t.fail("Failed to install dependencies"),n}}function et(e){l.success("VEF project created successfully!"),l.box(`Next steps:
1
+ /*! @vef-framework-react/dev v2.13.0 made by Venus | 2026-07-21T07:15:21.827Z */
2
+ import dt from"chalk";import{program as y}from"commander";import R from"process";import b from"consola";import{randomBytes as de}from"crypto";import{constants as h}from"fs";import{chmod as fe,lstat as pe,mkdir as me,open as ge,readFile as le,rename as ue,unlink as ye}from"fs/promises";import{dirname as he,isAbsolute as A,relative as F,resolve as we}from"path";var c=class extends Error{constructor(t){super(t),this.name="CodeGenerationValidationError"}};import{existsSync as Q}from"fs";import{isAbsolute as P,relative as X,resolve as _}from"path";import{createJiti as Z}from"jiti";var ee=["code-generation.config.ts","code-generation.config.mts","code-generation.config.js","code-generation.config.mjs"];async function O({projectDir:e,configFile:t}){let n=t?[te(e,t)]:ee.map(s=>_(e,s)),o=n.find(s=>Q(s));if(!o)throw new c(`Code generation config not found. Looked for: ${n.join(", ")}`);let a=await Z(e).import(o),r=ne(a);return oe(r,o),{config:r,configPath:o}}function te(e,t){let n=P(t)?t:_(e,t),o=X(e,n);if(o.startsWith("..")||P(o))throw new c(`Code generation config file escapes project root: ${t}. Must stay within ${e}.`);return n}function ne(e){return e!==null&&typeof e=="object"&&"default"in e&&e.default!==null&&typeof e.default=="object"?e.default:e}function oe(e,t){if(typeof e!="object"||e===null)throw new c(`Code generation config at ${t} must export a CodeGenerationConfig object.`);e.codeSetKeys!==void 0&&ie(e.codeSetKeys,t)}function ie(e,t){if(typeof e!="object"||e===null)throw new c(`Code generation config at ${t} field \`codeSetKeys\` must be an object when set.`);if(typeof e.fetchCodeSetKeys!="function")throw new c(`Code generation config at ${t} field \`codeSetKeys.fetchCodeSetKeys\` must be a function.`);if(e.output!==void 0&&typeof e.output!="string")throw new c(`Code generation config at ${t} field \`codeSetKeys.output\` must be a string when set; got ${typeof e.output}.`);if(e.timeout!==void 0&&!re(e.timeout))throw new c(`Code generation config at ${t} field \`codeSetKeys.timeout\` must be a finite non-negative number when set; got ${String(e.timeout)}.`)}function re(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}var se="@vef-framework-react/hooks",ae=["/* eslint-disable */","// @ts-nocheck","// noinspection JSUnusedGlobalSymbols","// AUTO-GENERATED by @vef-framework-react/dev (vef gen:code-set-keys). DO NOT EDIT."];function T(e,t){let{configFile:n,augmentTarget:o=se}=t,i=[...ae,`// Source: ${n}`,""];if(e.length===0)i.push("export type CodeSetKey = never;");else{i.push("export type CodeSetKey =");for(let[a,r]of e.entries()){let s=a===e.length-1?";":"";r.comment&&i.push(` /** ${ce(r.comment)} */`),i.push(` | ${JSON.stringify(r.key)}${s}`)}}return i.push("",`declare module ${JSON.stringify(o)} {`," interface Register {"," codeSetKeys: CodeSetKey;"," }","}",""),i.join(`
3
+ `)}function ce(e){return e.replaceAll(/\s+/g," ").trim().replaceAll("*/",String.raw`*\/`)}var Ce="src/types/code-set-keys.gen.ts",Se=3e4,G=/^[\w.-]+$/,Ee="letters, digits, underscore, dot, hyphen",ve=e=>console.warn(e);function ke(e,t){return e.key<t.key?-1:e.key>t.key?1:0}async function S({projectDir:e,configFile:t,output:n,check:o=!1,augmentTarget:i,onWarn:a=ve}){let{config:r,configPath:s}=await O({projectDir:e,configFile:t});if(!r.codeSetKeys)throw new c(`Code generation config at ${s} has no \`codeSetKeys\` block.`);let{codeSetKeys:p}=r,m=await xe(p.fetchCodeSetKeys,p.timeout??Se);Ke(m);let d=Pe(m,a);d.length===0&&a("`fetchCodeSetKeys` returned no entries; the generated file will declare `CodeSetKey = never`.");let g=_e(e,n??p.output??Ce),x=T(d,{configFile:F(e,s),augmentTarget:i}),K=await Te(g)!==x;return K&&!o&&(await Oe(g),await Ae(g,x)),{outputPath:g,keyCount:d.length,changed:K}}async function xe(e,t){if(t<=0)return await e();let n;try{return await Promise.race([e(),new Promise((o,i)=>{n=setTimeout(()=>i(new Error(`fetchCodeSetKeys timed out after ${t}ms.`)),t)})])}finally{n&&clearTimeout(n)}}function Ke(e){for(let t of e)if(typeof t.key!="string"||!G.test(t.key))throw new c(`Invalid code set key ${JSON.stringify(t.key)}. Keys must match ${G} (${Ee}).`)}function Pe(e,t){let n=new Map;for(let o of e){let i=n.get(o.key);if(!i){n.set(o.key,o);continue}i.comment!==o.comment&&t(`Duplicate code set key "${o.key}" with conflicting comments; keeping the first occurrence.`)}return n.values().toArray().toSorted(ke)}function _e(e,t){if(A(t))throw new c(`Output path must be relative to project root; absolute paths are rejected: ${t}`);let n=we(e,t),o=F(e,n);if(o.startsWith("..")||A(o))throw new c(`Output path escapes project root: ${t}. Must stay within ${e}.`);return n}async function Oe(e){let t;try{t=await pe(e)}catch(n){if(n.code==="ENOENT")return;throw n}if(t.isSymbolicLink())throw new c(`Refusing to overwrite symlink at output path: ${e}. Delete the symlink and rerun generation if this is intentional.`)}async function Te(e){try{return await le(e,"utf-8")}catch(t){if(t.code==="ENOENT")return null;throw t}}async function Ae(e,t){await me(he(e),{recursive:!0});let n=de(6).toString("hex"),o=`${e}.${n}.tmp`,i=h.O_NOFOLLOW??0,a=h.O_WRONLY|h.O_CREAT|h.O_EXCL|i,r=await ge(o,a,384);try{await r.writeFile(t,"utf-8")}finally{await r.close()}try{await ue(o,e)}catch(s){throw await ye(o).catch(()=>{}),s}await fe(e,420)}import{resolve as Ge}from"path";import{exit as Fe}from"process";import $ from"consola";import{execa as $e}from"execa";import Ne from"fs-extra";var{readJsonSync:Re}=Ne,f=class extends Error{};function w(){let e=Ge(import.meta.dirname,"../../package.json");return Re(e,{encoding:"utf-8"}).version}function N(e){e instanceof f?$.error(e.message):$.error(e),Fe(1)}async function C(){try{await $e("pnpm",["--version"])}catch{throw new f("VEF requires pnpm. Install it from https://pnpm.io and try again.")}}async function j(e,t=R.cwd()){try{let n=await S({projectDir:t,configFile:e.config,output:e.output,check:e.check,onWarn:i=>b.warn(i)});if(e.check&&n.changed)throw new f(`Generated code set keys file is stale at ${n.outputPath}. Run \`vef gen:code-set-keys\` to refresh.`);let o=n.changed?"":" (unchanged)";b.success(`Generated ${n.keyCount} code set keys -> ${n.outputPath}${o}`)}catch(n){if(n instanceof f)throw n;if(R.env.CI){let o=n instanceof Error?n.message:String(n);throw new f(`gen:code-set-keys failed: ${o}`)}throw n}}import{resolve as l}from"path";import be,{exit as je}from"process";import u from"consola";import{execa as v}from"execa";import Ie from"fs-extra";import H from"ora";import Ue from"prompts";var I={"pre-commit":"pnpm dlx lint-staged","commit-msg":"pnpm dlx commitlint --edit $1","pre-push":"pnpm typecheck && pnpm test"},U={"*.{js,ts,tsx,json,jsonc,md,mdx,html}":"eslint --fix","*.{css,scss}":"stylelint --fix"},L={prepare:"vef prepare",typecheck:"tsc --noEmit",test:"vitest run --passWithNoTests"},J="@vef-framework-react/";var{copy:Le,exists:Je,move:De,readdir:Ve,readFile:D,readJson:We,writeFile:V,writeJson:Me}=Ie,W="http://127.0.0.1:8080";function He(e){return e.trim().toLowerCase().replaceAll(/\s+/g,"-").replace(/^[._]+/,"").replaceAll(/[^a-z0-9~-]+/g,"-").replaceAll(/^-+|-+$/g,"")}function M(e){let t=typeof e=="string"?e.trim():"";return t?/[/\\]/.test(t)||t.includes("..")?"App name cannot contain path separators or '..'":!0:"App name is required"}function ze(e,t){for(let n of["dependencies","devDependencies"]){let o=e[n];if(o)for(let i of Object.keys(o))i.startsWith(J)&&(o[i]=t)}}function E(e,t,n){return e.replace(new RegExp(`^${t}=.*$`,"m"),()=>`${t}=${n}`)}async function z(e={},t=be.cwd()){u.start("Creating a new VEF project");let n=[];e.name===void 0&&n.push({type:"text",name:"name",message:"What is the name of your app?",validate:M}),e.title===void 0&&n.push({type:"text",name:"title",message:"What is the title of your app?",validate:g=>typeof g=="string"&&g.trim().length>0||"App title is required"}),e.apiUrl===void 0&&n.push({type:"text",name:"apiUrl",message:"Dev API base URL?",initial:W});let o=await Ue(n,{onCancel:()=>{u.info("Operation cancelled"),je(0)}}),i=e.name??o.name,a=M(i);if(a!==!0)throw new f(a);let r=i.trim(),s=He(r),p=(e.title??o.title)?.trim()||r,m=(e.apiUrl??o.apiUrl)?.trim()||W,d=l(t,r);if(await Je(d)&&(await Ve(d)).length>0)throw new f(`Target directory "${r}" already exists and is not empty. Choose another name or empty it first.`);await C(),await qe(d),await Be(s,d),await Qe(d,{packageName:s,appTitle:p,apiUrl:m}),await Xe(d),await Ze(d),et(r)}var Ye=[["_gitignore",".gitignore"],["_gitattributes",".gitattributes"],["_editorconfig",".editorconfig"],["_package.json","package.json"],["_tsconfig.json","tsconfig.json"],["_eslint.config.ts","eslint.config.ts"],["_stylelint.config.js","stylelint.config.js"],["_commitlint.config.ts","commitlint.config.ts"],["_vite.config.ts","vite.config.ts"]];async function qe(e){let t=l(import.meta.dirname,"../template");await Le(t,e),u.success("Successfully copied template files");for(let[n,o]of Ye)await De(l(e,n),l(e,o))}async function Be(e,t){let n=l(t,"package.json"),o=await We(n,{encoding:"utf-8"}),i=w();o.name=e,ze(o,i),await Me(n,o,{encoding:"utf-8",spaces:2}),u.success(`Successfully set the app name and pinned framework packages to v${i}`)}async function Qe(e,t){let n=l(e,"env/.env"),o=await D(n,{encoding:"utf-8"}),i=E(E(o,"VEF_APP_NAME",t.packageName),"VEF_APP_TITLE",t.appTitle);await V(n,i);let a=l(e,"env/.env.development"),r=await D(a,{encoding:"utf-8"});await V(a,E(r,"VEF_APP_API_BASE_URL",t.apiUrl)),u.success("Successfully configured environment files")}async function Xe(e){let t=H("Initializing git repository...").start();try{await v`git --version`,await v({cwd:e})`git init`,t.succeed("Successfully initialized git repository")}catch(n){throw t.fail("Failed to initialize git repository"),n}}async function Ze(e){let t=H("Installing dependencies...").start();try{await v({cwd:e})("pnpm",["install"]),t.succeed("Successfully installed dependencies")}catch(n){throw t.fail("Failed to install dependencies"),n}}function et(e){u.success("VEF project created successfully!"),u.box(`Next steps:
4
4
 
5
5
  cd ${e}
6
- pnpm dev`)}import{resolve as z}from"path";import tt from"process";import x from"consola";import nt from"fs-extra";var{exists:it,readJson:ot,writeFile:rt,writeJson:at}=nt;async function q(e=tt.cwd()){let t=z(e,"package.json"),{default:n}=await import("husky"),i=n();if(i)x.warn(`Skipped husky setup: ${i}`);else for(let[a,d]of Object.entries(b)){let m=z(e,".husky",a);await it(m)||(await rt(m,d),x.success(`Successfully set up ${a} hook`))}let o=await ot(t,{encoding:"utf-8"});o.scripts??={};let{scripts:s}=o,r=!1;for(let[a,d]of Object.entries(U))s[a]||(s[a]=d,r=!0);o["lint-staged"]||(o["lint-staged"]={...j},r=!0),r&&(await at(t,o,{encoding:"utf-8",spaces:2}),x.success("Successfully set up package.json scripts and lint-staged"))}import st from"process";import{execa as ct}from"execa";async function B(e=st.cwd()){await E(),await ct({cwd:e,stdio:"inherit"})("pnpm",["update","@vef-framework-react/*"])}var pt=w();u.name("vef").description(ft.magenta("VEF Framework CLI")).version(pt).action(()=>u.help());u.command("init").description("Scaffold a new VEF project in a new directory").argument("[name]","Project directory name (also used as the npm package name)").option("-t, --title <title>","Human-readable app title").option("--api-url <url>","Dev API base URL, written to .env.development").action((e,t)=>Y({name:e,title:t.title,apiUrl:t.apiUrl}));u.command("prepare").description("Install git hooks and lint-staged, and seed package.json scripts").action(()=>q());u.command("update").description("Update @vef-framework-react/* dependencies within their semver range").action(()=>B());u.command("gen:dictionary-keys").description("Generate the DictionaryKey union type from the project's code-generation config").option("-c, --config <file>","Path to code-generation.config.ts (relative to cwd or absolute)").option("-o, --output <file>","Output file path (overrides config.dictionaryKeys.output)").option("--check","Exit non-zero if the generated file would change (CI guard)").action(e=>I(e));try{await u.parseAsync()}catch(e){$(e)}
6
+ pnpm dev`)}import{resolve as Y}from"path";import tt from"process";import k from"consola";import nt from"fs-extra";var{exists:ot,readJson:it,writeFile:rt,writeJson:st}=nt;async function q(e=tt.cwd()){let t=Y(e,"package.json"),{default:n}=await import("husky"),o=n();if(o)k.warn(`Skipped husky setup: ${o}`);else for(let[s,p]of Object.entries(I)){let m=Y(e,".husky",s);await ot(m)||(await rt(m,p),k.success(`Successfully set up ${s} hook`))}let i=await it(t,{encoding:"utf-8"});i.scripts??={};let{scripts:a}=i,r=!1;for(let[s,p]of Object.entries(L))a[s]||(a[s]=p,r=!0);i["lint-staged"]||(i["lint-staged"]={...U},r=!0),r&&(await st(t,i,{encoding:"utf-8",spaces:2}),k.success("Successfully set up package.json scripts and lint-staged"))}import at from"process";import{execa as ct}from"execa";async function B(e=at.cwd()){await C(),await ct({cwd:e,stdio:"inherit"})("pnpm",["update","@vef-framework-react/*"])}var ft=w();y.name("vef").description(dt.magenta("VEF Framework CLI")).version(ft).action(()=>y.help());y.command("init").description("Scaffold a new VEF project in a new directory").argument("[name]","Project directory name (also used as the npm package name)").option("-t, --title <title>","Human-readable app title").option("--api-url <url>","Dev API base URL, written to .env.development").action((e,t)=>z({name:e,title:t.title,apiUrl:t.apiUrl}));y.command("prepare").description("Install git hooks and lint-staged, and seed package.json scripts").action(()=>q());y.command("update").description("Update @vef-framework-react/* dependencies within their semver range").action(()=>B());y.command("gen:code-set-keys").description("Generate the CodeSetKey union type from the project's code-generation config").option("-c, --config <file>","Path to code-generation.config.ts (relative to cwd or absolute)").option("-o, --output <file>","Output file path (overrides config.codeSetKeys.output)").option("--check","Exit non-zero if the generated file would change (CI guard)").action(e=>j(e));try{await y.parseAsync()}catch(e){N(e)}
@@ -0,0 +1,109 @@
1
+ import { CodeGenerationValidationError as a } from "./errors.js";
2
+ import { loadCodeGenerationConfig as p } from "./load-config.js";
3
+ import { renderCodeSetKeysFile as S } from "./render.js";
4
+ import { randomBytes as E } from "node:crypto";
5
+ import { constants as y } from "node:fs";
6
+ import { chmod as C, lstat as T, mkdir as O, open as v, readFile as K, rename as _, unlink as $ } from "node:fs/promises";
7
+ import { dirname as A, isAbsolute as h, relative as k, resolve as F } from "node:path";
8
+ var N = "src/types/code-set-keys.gen.ts", L = 3e4, g = /^[\w.-]+$/, x = "letters, digits, underscore, dot, hyphen", P = (e) => console.warn(e);
9
+ function U(e, t) {
10
+ return e.key < t.key ? -1 : e.key > t.key ? 1 : 0;
11
+ }
12
+ async function z({ projectDir: e, configFile: t, output: n, check: o = !1, augmentTarget: r, onWarn: s = P }) {
13
+ const { config: i, configPath: c } = await p({
14
+ projectDir: e,
15
+ configFile: t
16
+ });
17
+ if (!i.codeSetKeys)
18
+ throw new a(`Code generation config at ${c} has no \`codeSetKeys\` block.`);
19
+ const { codeSetKeys: l } = i, u = await b(l.fetchCodeSetKeys, l.timeout ?? L);
20
+ I(u);
21
+ const d = R(u, s);
22
+ d.length === 0 && s("`fetchCodeSetKeys` returned no entries; the generated file will declare `CodeSetKey = never`.");
23
+ const f = W(e, n ?? l.output ?? N), m = S(d, {
24
+ configFile: k(e, c),
25
+ augmentTarget: r
26
+ }), w = await D(f) !== m;
27
+ return w && !o && (await Y(f), await G(f, m)), {
28
+ outputPath: f,
29
+ keyCount: d.length,
30
+ changed: w
31
+ };
32
+ }
33
+ async function b(e, t) {
34
+ if (t <= 0)
35
+ return await e();
36
+ let n;
37
+ try {
38
+ return await Promise.race([e(), new Promise((o, r) => {
39
+ n = setTimeout(() => r(new Error(`fetchCodeSetKeys timed out after ${t}ms.`)), t);
40
+ })]);
41
+ } finally {
42
+ n && clearTimeout(n);
43
+ }
44
+ }
45
+ function I(e) {
46
+ for (const t of e)
47
+ if (typeof t.key != "string" || !g.test(t.key))
48
+ throw new a(`Invalid code set key ${JSON.stringify(t.key)}. Keys must match ${g} (${x}).`);
49
+ }
50
+ function R(e, t) {
51
+ const n = /* @__PURE__ */ new Map();
52
+ for (const o of e) {
53
+ const r = n.get(o.key);
54
+ if (!r) {
55
+ n.set(o.key, o);
56
+ continue;
57
+ }
58
+ r.comment !== o.comment && t(`Duplicate code set key "${o.key}" with conflicting comments; keeping the first occurrence.`);
59
+ }
60
+ return n.values().toArray().toSorted(U);
61
+ }
62
+ function W(e, t) {
63
+ if (h(t))
64
+ throw new a(`Output path must be relative to project root; absolute paths are rejected: ${t}`);
65
+ const n = F(e, t), o = k(e, n);
66
+ if (o.startsWith("..") || h(o))
67
+ throw new a(`Output path escapes project root: ${t}. Must stay within ${e}.`);
68
+ return n;
69
+ }
70
+ async function Y(e) {
71
+ let t;
72
+ try {
73
+ t = await T(e);
74
+ } catch (n) {
75
+ if (n.code === "ENOENT")
76
+ return;
77
+ throw n;
78
+ }
79
+ if (t.isSymbolicLink())
80
+ throw new a(`Refusing to overwrite symlink at output path: ${e}. Delete the symlink and rerun generation if this is intentional.`);
81
+ }
82
+ async function D(e) {
83
+ try {
84
+ return await K(e, "utf-8");
85
+ } catch (t) {
86
+ if (t.code === "ENOENT")
87
+ return null;
88
+ throw t;
89
+ }
90
+ }
91
+ async function G(e, t) {
92
+ await O(A(e), { recursive: !0 });
93
+ const n = E(6).toString("hex"), o = `${e}.${n}.tmp`, r = y.O_NOFOLLOW ?? 0, s = y.O_WRONLY | y.O_CREAT | y.O_EXCL | r, i = await v(o, s, 384);
94
+ try {
95
+ await i.writeFile(t, "utf-8");
96
+ } finally {
97
+ await i.close();
98
+ }
99
+ try {
100
+ await _(o, e);
101
+ } catch (c) {
102
+ throw await $(o).catch(() => {
103
+ }), c;
104
+ }
105
+ await C(e, 420);
106
+ }
107
+ export {
108
+ z as generateCodeSetKeys
109
+ };
@@ -0,0 +1,11 @@
1
+ import { CodeGenerationValidationError as o } from "./errors.js";
2
+ import { CODE_SET_AUGMENT_TARGET as i, renderCodeSetKeysFile as t } from "./render.js";
3
+ import { generateCodeSetKeys as m } from "./core.js";
4
+ import { defineCodeGenerationConfig as f } from "./types.js";
5
+ export {
6
+ i as CODE_SET_AUGMENT_TARGET,
7
+ o as CodeGenerationValidationError,
8
+ f as defineCodeGenerationConfig,
9
+ m as generateCodeSetKeys,
10
+ t as renderCodeSetKeysFile
11
+ };
@@ -0,0 +1,50 @@
1
+ import { CodeGenerationValidationError as o } from "./errors.js";
2
+ import { existsSync as d } from "node:fs";
3
+ import { isAbsolute as u, relative as c, resolve as s } from "node:path";
4
+ import { createJiti as m } from "jiti";
5
+ var g = [
6
+ "code-generation.config.ts",
7
+ "code-generation.config.mts",
8
+ "code-generation.config.js",
9
+ "code-generation.config.mjs"
10
+ ];
11
+ async function b({ projectDir: e, configFile: t }) {
12
+ const i = t ? [p(e, t)] : g.map((r) => s(e, r)), n = i.find((r) => d(r));
13
+ if (!n)
14
+ throw new o(`Code generation config not found. Looked for: ${i.join(", ")}`);
15
+ const a = await m(e).import(n), f = w(a);
16
+ return y(f, n), {
17
+ config: f,
18
+ configPath: n
19
+ };
20
+ }
21
+ function p(e, t) {
22
+ const i = u(t) ? t : s(e, t), n = c(e, i);
23
+ if (n.startsWith("..") || u(n))
24
+ throw new o(`Code generation config file escapes project root: ${t}. Must stay within ${e}.`);
25
+ return i;
26
+ }
27
+ function w(e) {
28
+ return e !== null && typeof e == "object" && "default" in e && e.default !== null && typeof e.default == "object" ? e.default : e;
29
+ }
30
+ function y(e, t) {
31
+ if (typeof e != "object" || e === null)
32
+ throw new o(`Code generation config at ${t} must export a CodeGenerationConfig object.`);
33
+ e.codeSetKeys !== void 0 && C(e.codeSetKeys, t);
34
+ }
35
+ function C(e, t) {
36
+ if (typeof e != "object" || e === null)
37
+ throw new o(`Code generation config at ${t} field \`codeSetKeys\` must be an object when set.`);
38
+ if (typeof e.fetchCodeSetKeys != "function")
39
+ throw new o(`Code generation config at ${t} field \`codeSetKeys.fetchCodeSetKeys\` must be a function.`);
40
+ if (e.output !== void 0 && typeof e.output != "string")
41
+ throw new o(`Code generation config at ${t} field \`codeSetKeys.output\` must be a string when set; got ${typeof e.output}.`);
42
+ if (e.timeout !== void 0 && !S(e.timeout))
43
+ throw new o(`Code generation config at ${t} field \`codeSetKeys.timeout\` must be a finite non-negative number when set; got ${String(e.timeout)}.`);
44
+ }
45
+ function S(e) {
46
+ return typeof e == "number" && Number.isFinite(e) && e >= 0;
47
+ }
48
+ export {
49
+ b as loadCodeGenerationConfig
50
+ };
@@ -0,0 +1,31 @@
1
+ var l = "@vef-framework-react/hooks", f = [
2
+ "/* eslint-disable */",
3
+ "// @ts-nocheck",
4
+ "// noinspection JSUnusedGlobalSymbols",
5
+ "// AUTO-GENERATED by @vef-framework-react/dev (vef gen:code-set-keys). DO NOT EDIT."
6
+ ];
7
+ function p(t, o) {
8
+ const { configFile: r, augmentTarget: s = l } = o, e = [
9
+ ...f,
10
+ `// Source: ${r}`,
11
+ ""
12
+ ];
13
+ if (t.length === 0)
14
+ e.push("export type CodeSetKey = never;");
15
+ else {
16
+ e.push("export type CodeSetKey =");
17
+ for (const [c, n] of t.entries()) {
18
+ const i = c === t.length - 1 ? ";" : "";
19
+ n.comment && e.push(` /** ${a(n.comment)} */`), e.push(` | ${JSON.stringify(n.key)}${i}`);
20
+ }
21
+ }
22
+ return e.push("", `declare module ${JSON.stringify(s)} {`, " interface Register {", " codeSetKeys: CodeSetKey;", " }", "}", ""), e.join(`
23
+ `);
24
+ }
25
+ function a(t) {
26
+ return t.replaceAll(/\s+/g, " ").trim().replaceAll("*/", String.raw`*\/`);
27
+ }
28
+ export {
29
+ l as CODE_SET_AUGMENT_TARGET,
30
+ p as renderCodeSetKeysFile
31
+ };
@@ -1,11 +1,11 @@
1
- import { CodeGenerationValidationError as o } from "./dictionary/errors.js";
2
- import { DICTIONARY_AUGMENT_TARGET as i, renderDictionaryKeysFile as n } from "./dictionary/render.js";
3
- import { generateDictionaryKeys as m } from "./dictionary/core.js";
4
- import { defineCodeGenerationConfig as f } from "./dictionary/types.js";
1
+ import { CodeGenerationValidationError as o } from "./code-set/errors.js";
2
+ import { CODE_SET_AUGMENT_TARGET as i, renderCodeSetKeysFile as t } from "./code-set/render.js";
3
+ import { generateCodeSetKeys as m } from "./code-set/core.js";
4
+ import { defineCodeGenerationConfig as f } from "./code-set/types.js";
5
5
  export {
6
+ i as CODE_SET_AUGMENT_TARGET,
6
7
  o as CodeGenerationValidationError,
7
- i as DICTIONARY_AUGMENT_TARGET,
8
8
  f as defineCodeGenerationConfig,
9
- m as generateDictionaryKeys,
10
- n as renderDictionaryKeysFile
9
+ m as generateCodeSetKeys,
10
+ t as renderCodeSetKeysFile
11
11
  };
package/dist/es/index.js CHANGED
@@ -1,21 +1,21 @@
1
- import { CodeGenerationValidationError as o } from "./code-generation/dictionary/errors.js";
2
- import { DICTIONARY_AUGMENT_TARGET as e, renderDictionaryKeysFile as t } from "./code-generation/dictionary/render.js";
3
- import { generateDictionaryKeys as m } from "./code-generation/dictionary/core.js";
4
- import { defineCodeGenerationConfig as p } from "./code-generation/dictionary/types.js";
1
+ import { CodeGenerationValidationError as e } from "./code-generation/code-set/errors.js";
2
+ import { CODE_SET_AUGMENT_TARGET as r, renderCodeSetKeysFile as t } from "./code-generation/code-set/render.js";
3
+ import { generateCodeSetKeys as n } from "./code-generation/code-set/core.js";
4
+ import { defineCodeGenerationConfig as d } from "./code-generation/code-set/types.js";
5
5
  import { defineCommitlintConfig as C } from "./lint/commitlint.js";
6
- import { defineEslintConfig as g } from "./lint/eslint.js";
7
- import { defineStylelintConfig as y } from "./lint/stylelint.js";
8
- import { types as E } from "./vite/plugin-auto-enhance/index.js";
9
- import { defineViteConfig as T } from "./vite/config.js";
6
+ import { defineEslintConfig as l } from "./lint/eslint.js";
7
+ import { defineStylelintConfig as a } from "./lint/stylelint.js";
8
+ import { types as y } from "./vite/plugin-auto-enhance/index.js";
9
+ import { defineViteConfig as S } from "./vite/config.js";
10
10
  export {
11
- o as CodeGenerationValidationError,
12
- e as DICTIONARY_AUGMENT_TARGET,
13
- p as defineCodeGenerationConfig,
11
+ r as CODE_SET_AUGMENT_TARGET,
12
+ e as CodeGenerationValidationError,
13
+ d as defineCodeGenerationConfig,
14
14
  C as defineCommitlintConfig,
15
- g as defineEslintConfig,
16
- y as defineStylelintConfig,
17
- T as defineViteConfig,
18
- m as generateDictionaryKeys,
19
- t as renderDictionaryKeysFile,
20
- E as types
15
+ l as defineEslintConfig,
16
+ a as defineStylelintConfig,
17
+ S as defineViteConfig,
18
+ n as generateCodeSetKeys,
19
+ t as renderCodeSetKeysFile,
20
+ y as types
21
21
  };
@@ -0,0 +1,6 @@
1
+ export interface GenCodeSetKeysOptions {
2
+ config?: string;
3
+ output?: string;
4
+ check?: boolean;
5
+ }
6
+ export declare function handleGenCodeSetKeys(options: GenCodeSetKeysOptions, cwd?: string): Promise<void>;
@@ -1,4 +1,4 @@
1
- export interface GenerateDictionaryKeysOptions {
1
+ export interface GenerateCodeSetKeysOptions {
2
2
  /**
3
3
  * Absolute path to the project root.
4
4
  */
@@ -27,7 +27,7 @@ export interface GenerateDictionaryKeysOptions {
27
27
  */
28
28
  onWarn?: (message: string) => void;
29
29
  }
30
- export interface GenerateDictionaryKeysResult {
30
+ export interface GenerateCodeSetKeysResult {
31
31
  /**
32
32
  * Absolute path of the generated file.
33
33
  */
@@ -42,17 +42,17 @@ export interface GenerateDictionaryKeysResult {
42
42
  changed: boolean;
43
43
  }
44
44
  /**
45
- * Run the dictionary keys generator.
45
+ * Run the code set keys generator.
46
46
  *
47
47
  * Strict failure modes (throws):
48
48
  * - missing config file or invalid config shape → `CodeGenerationValidationError`
49
- * - config has no `dictionaryKeys` block → `CodeGenerationValidationError`
49
+ * - config has no `codeSetKeys` block → `CodeGenerationValidationError`
50
50
  * - any returned key violates the key charset → `CodeGenerationValidationError`
51
51
  * - `output` path escapes `projectDir` or points to a symlink → `CodeGenerationValidationError`
52
52
  * - fetcher throws or times out → propagates the underlying error
53
53
  *
54
54
  * Soft failure modes (warn, continue):
55
- * - empty fetcher result → generates `DictionaryKey = never`
55
+ * - empty fetcher result → generates `CodeSetKey = never`
56
56
  * - duplicate keys with conflicting comments → first occurrence wins
57
57
  */
58
- export declare function generateDictionaryKeys({ projectDir, configFile, output, check, augmentTarget, onWarn }: GenerateDictionaryKeysOptions): Promise<GenerateDictionaryKeysResult>;
58
+ export declare function generateCodeSetKeys({ projectDir, configFile, output, check, augmentTarget, onWarn }: GenerateCodeSetKeysOptions): Promise<GenerateCodeSetKeysResult>;
@@ -0,0 +1,4 @@
1
+ export { generateCodeSetKeys, type GenerateCodeSetKeysOptions, type GenerateCodeSetKeysResult } from './core';
2
+ export { CodeGenerationValidationError } from './errors';
3
+ export { CODE_SET_AUGMENT_TARGET, renderCodeSetKeysFile, type RenderCodeSetKeysOptions } from './render';
4
+ export { defineCodeGenerationConfig, type CodeGenerationConfig, type CodeSetKeyEntry, type CodeSetKeysConfig } from './types';
@@ -16,7 +16,7 @@ export interface LoadedCodeGenerationConfig {
16
16
  * project tree.
17
17
  *
18
18
  * Shape safety: the loaded module is validated at the trust boundary —
19
- * if a `dictionaryKeys` block is present, its `fetchDictionaryKeys` must
19
+ * if a `codeSetKeys` block is present, its `fetchCodeSetKeys` must
20
20
  * be a function, `output` must be a string or absent, `timeout` must be a
21
21
  * finite non-negative number or absent.
22
22
  */
@@ -0,0 +1,24 @@
1
+ import { CodeSetKeyEntry } from './types';
2
+ /**
3
+ * Module name that the generated file augments. Centralized so that future
4
+ * refactors (e.g. moving the code set key registry to a different package) only
5
+ * touch this constant rather than every consumer's checked-in `.gen.ts`.
6
+ */
7
+ export declare const CODE_SET_AUGMENT_TARGET = "@vef-framework-react/hooks";
8
+ export interface RenderCodeSetKeysOptions {
9
+ /**
10
+ * Config file path (relative to project root) recorded in the file banner
11
+ * for traceability.
12
+ */
13
+ configFile: string;
14
+ /**
15
+ * Module name to augment. Defaults to {@link CODE_SET_AUGMENT_TARGET}.
16
+ * Overridable for tests and for downstream forks that re-publish the
17
+ * extension point under a different package name.
18
+ */
19
+ augmentTarget?: string;
20
+ }
21
+ /**
22
+ * Render the code set keys file content. Pure function for snapshot tests.
23
+ */
24
+ export declare function renderCodeSetKeysFile(entries: readonly CodeSetKeyEntry[], options: RenderCodeSetKeysOptions): string;
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Single dictionary key entry returned by the project-provided fetcher.
2
+ * Single code set key entry returned by the project-provided fetcher.
3
3
  */
4
- export interface DictionaryKeyEntry {
4
+ export interface CodeSetKeyEntry {
5
5
  /**
6
- * Dictionary key string, e.g. `"sys.menu.type"`.
6
+ * CodeSet key string, e.g. `"sys.menu.type"`.
7
7
  * Must match `/^[\w.-]+$/` (letters, digits, underscore, dot, hyphen).
8
8
  */
9
9
  key: string;
@@ -13,23 +13,23 @@ export interface DictionaryKeyEntry {
13
13
  comment?: string;
14
14
  }
15
15
  /**
16
- * Configuration block for dictionary key generation.
16
+ * Configuration block for code set key generation.
17
17
  */
18
- export interface DictionaryKeysConfig {
18
+ export interface CodeSetKeysConfig {
19
19
  /**
20
20
  * Output path resolved against the project root. Must stay within
21
21
  * `projectDir`; absolute paths and `..` traversal are rejected at runtime.
22
22
  *
23
- * @default "src/types/dictionary.gen.ts"
23
+ * @default "src/types/code-set-keys.gen.ts"
24
24
  */
25
25
  output?: string;
26
26
  /**
27
- * Fetcher invoked at generation time to retrieve all dictionary keys.
27
+ * Fetcher invoked at generation time to retrieve all code set keys.
28
28
  * Runs in Node, so use Node-side HTTP/DB clients with project credentials.
29
29
  */
30
- fetchDictionaryKeys: () => Promise<readonly DictionaryKeyEntry[]>;
30
+ fetchCodeSetKeys: () => Promise<readonly CodeSetKeyEntry[]>;
31
31
  /**
32
- * Timeout (ms) for `fetchDictionaryKeys`. After this, generation aborts with
32
+ * Timeout (ms) for `fetchCodeSetKeys`. After this, generation aborts with
33
33
  * an error. Set to `0` to disable the timeout entirely.
34
34
  *
35
35
  * @default 30000
@@ -39,14 +39,14 @@ export interface DictionaryKeysConfig {
39
39
  /**
40
40
  * Top-level code generation configuration container. Authored in
41
41
  * `code-generation.config.{ts,mts,js,mjs}` at the project root. Future generators
42
- * (i18n, apiSchema, etc.) live alongside `dictionaryKeys` so a project keeps
42
+ * (i18n, apiSchema, etc.) live alongside `codeSetKeys` so a project keeps
43
43
  * a single code generation entry point.
44
44
  */
45
45
  export interface CodeGenerationConfig {
46
46
  /**
47
- * Dictionary keys generator. See {@link DictionaryKeysConfig}.
47
+ * CodeSet keys generator. See {@link CodeSetKeysConfig}.
48
48
  */
49
- dictionaryKeys?: DictionaryKeysConfig;
49
+ codeSetKeys?: CodeSetKeysConfig;
50
50
  }
51
51
  /**
52
52
  * Identity helper for typed `code-generation.config.ts` authoring. Preserves
@@ -1 +1 @@
1
- export * from './dictionary';
1
+ export * from './code-set';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vef-framework-react/dev",
3
- "version": "2.12.0",
3
+ "version": "2.13.0",
4
4
  "private": false,
5
5
  "description": "Dev tools for VEF framework",
6
6
  "keywords": [
@@ -1 +0,0 @@
1
- const c=require("./errors.cjs"),k=require("./load-config.cjs"),_=require("./render.cjs");let T=require("node:crypto"),f=require("node:fs"),o=require("node:fs/promises"),a=require("node:path");var p="src/types/dictionary.gen.ts",O=3e4,E=/^[\w.-]+$/,v="letters, digits, underscore, dot, hyphen",C=e=>console.warn(e);function K(e,t){return e.key<t.key?-1:e.key>t.key?1:0}async function $({projectDir:e,configFile:t,output:n,check:r=!1,augmentTarget:i,onWarn:y=C}){const{config:s,configPath:l}=await k.loadCodeGenerationConfig({projectDir:e,configFile:t});if(!s.dictionaryKeys)throw new c.CodeGenerationValidationError(`Code generation config at ${l} has no \`dictionaryKeys\` block.`);const{dictionaryKeys:d}=s,w=await A(d.fetchDictionaryKeys,d.timeout??O);F(w);const h=q(w,y);h.length===0&&y("`fetchDictionaryKeys` returned no entries; the generated file will declare `DictionaryKey = never`.");const u=D(e,n??d.output??p),m=_.renderDictionaryKeysFile(h,{configFile:(0,a.relative)(e,l),augmentTarget:i}),g=await S(u)!==m;return g&&!r&&(await N(u),await L(u,m)),{outputPath:u,keyCount:h.length,changed:g}}async function A(e,t){if(t<=0)return await e();let n;try{return await Promise.race([e(),new Promise((r,i)=>{n=setTimeout(()=>i(new Error(`fetchDictionaryKeys timed out after ${t}ms.`)),t)})])}finally{n&&clearTimeout(n)}}function F(e){for(const t of e)if(typeof t.key!="string"||!E.test(t.key))throw new c.CodeGenerationValidationError(`Invalid dictionary key ${JSON.stringify(t.key)}. Keys must match ${E} (${v}).`)}function q(e,t){const n=new Map;for(const r of e){const i=n.get(r.key);if(!i){n.set(r.key,r);continue}i.comment!==r.comment&&t(`Duplicate dictionary key "${r.key}" with conflicting comments; keeping the first occurrence.`)}return n.values().toArray().toSorted(K)}function D(e,t){if((0,a.isAbsolute)(t))throw new c.CodeGenerationValidationError(`Output path must be relative to project root; absolute paths are rejected: ${t}`);const n=(0,a.resolve)(e,t),r=(0,a.relative)(e,n);if(r.startsWith("..")||(0,a.isAbsolute)(r))throw new c.CodeGenerationValidationError(`Output path escapes project root: ${t}. Must stay within ${e}.`);return n}async function N(e){let t;try{t=await(0,o.lstat)(e)}catch(n){if(n.code==="ENOENT")return;throw n}if(t.isSymbolicLink())throw new c.CodeGenerationValidationError(`Refusing to overwrite symlink at output path: ${e}. Delete the symlink and rerun generation if this is intentional.`)}async function S(e){try{return await(0,o.readFile)(e,"utf-8")}catch(t){if(t.code==="ENOENT")return null;throw t}}async function L(e,t){await(0,o.mkdir)((0,a.dirname)(e),{recursive:!0});const n=(0,T.randomBytes)(6).toString("hex"),r=`${e}.${n}.tmp`,i=f.constants.O_NOFOLLOW??0,y=f.constants.O_WRONLY|f.constants.O_CREAT|f.constants.O_EXCL|i,s=await(0,o.open)(r,y,384);try{await s.writeFile(t,"utf-8")}finally{await s.close()}try{await(0,o.rename)(r,e)}catch(l){throw await(0,o.unlink)(r).catch(()=>{}),l}await(0,o.chmod)(e,420)}exports.generateDictionaryKeys=$;
@@ -1 +0,0 @@
1
- const r=require("./errors.cjs"),e=require("./render.cjs"),i=require("./core.cjs"),n=require("./types.cjs");exports.CodeGenerationValidationError=r.CodeGenerationValidationError;exports.DICTIONARY_AUGMENT_TARGET=e.DICTIONARY_AUGMENT_TARGET;exports.defineCodeGenerationConfig=n.defineCodeGenerationConfig;exports.generateDictionaryKeys=i.generateDictionaryKeys;exports.renderDictionaryKeysFile=e.renderDictionaryKeysFile;
@@ -1 +0,0 @@
1
- const o=require("./errors.cjs");let s=require("node:fs"),r=require("node:path"),f=require("jiti");var c=["code-generation.config.ts","code-generation.config.mts","code-generation.config.js","code-generation.config.mjs"];async function y({projectDir:e,configFile:t}){const i=t?[g(e,t)]:c.map(a=>(0,r.resolve)(e,a)),n=i.find(a=>(0,s.existsSync)(a));if(!n)throw new o.CodeGenerationValidationError(`Code generation config not found. Looked for: ${i.join(", ")}`);const d=await(0,f.createJiti)(e).import(n),u=C(d);return l(u,n),{config:u,configPath:n}}function g(e,t){const i=(0,r.isAbsolute)(t)?t:(0,r.resolve)(e,t),n=(0,r.relative)(e,i);if(n.startsWith("..")||(0,r.isAbsolute)(n))throw new o.CodeGenerationValidationError(`Code generation config file escapes project root: ${t}. Must stay within ${e}.`);return i}function C(e){return e!==null&&typeof e=="object"&&"default"in e&&e.default!==null&&typeof e.default=="object"?e.default:e}function l(e,t){if(typeof e!="object"||e===null)throw new o.CodeGenerationValidationError(`Code generation config at ${t} must export a CodeGenerationConfig object.`);e.dictionaryKeys!==void 0&&w(e.dictionaryKeys,t)}function w(e,t){if(typeof e!="object"||e===null)throw new o.CodeGenerationValidationError(`Code generation config at ${t} field \`dictionaryKeys\` must be an object when set.`);if(typeof e.fetchDictionaryKeys!="function")throw new o.CodeGenerationValidationError(`Code generation config at ${t} field \`dictionaryKeys.fetchDictionaryKeys\` must be a function.`);if(e.output!==void 0&&typeof e.output!="string")throw new o.CodeGenerationValidationError(`Code generation config at ${t} field \`dictionaryKeys.output\` must be a string when set; got ${typeof e.output}.`);if(e.timeout!==void 0&&!p(e.timeout))throw new o.CodeGenerationValidationError(`Code generation config at ${t} field \`dictionaryKeys.timeout\` must be a finite non-negative number when set; got ${String(e.timeout)}.`)}function p(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}exports.loadCodeGenerationConfig=y;
@@ -1,2 +0,0 @@
1
- var i="@vef-framework-react/hooks",y=["/* eslint-disable */","// @ts-nocheck","// noinspection JSUnusedGlobalSymbols","// AUTO-GENERATED by @vef-framework-react/dev (vef gen:dictionary-keys). DO NOT EDIT."];function l(n,t){const{configFile:o,augmentTarget:c=i}=t,e=[...y,`// Source: ${o}`,""];if(n.length===0)e.push("export type DictionaryKey = never;");else{e.push("export type DictionaryKey =");for(const[s,r]of n.entries()){const a=s===n.length-1?";":"";r.comment&&e.push(` /** ${f(r.comment)} */`),e.push(` | ${JSON.stringify(r.key)}${a}`)}}return e.push("",`declare module ${JSON.stringify(c)} {`," interface Register {"," dictionaryKeys: DictionaryKey;"," }","}",""),e.join(`
2
- `)}function f(n){return n.replaceAll(/\s+/g," ").trim().replaceAll("*/",String.raw`*\/`)}exports.DICTIONARY_AUGMENT_TARGET=i;exports.renderDictionaryKeysFile=l;
@@ -1,109 +0,0 @@
1
- import { CodeGenerationValidationError as a } from "./errors.js";
2
- import { loadCodeGenerationConfig as p } from "./load-config.js";
3
- import { renderDictionaryKeysFile as E } from "./render.js";
4
- import { randomBytes as T } from "node:crypto";
5
- import { constants as f } from "node:fs";
6
- import { chmod as O, lstat as v, mkdir as K, open as _, readFile as $, rename as A, unlink as C } from "node:fs/promises";
7
- import { dirname as F, isAbsolute as h, relative as k, resolve as N } from "node:path";
8
- var S = "src/types/dictionary.gen.ts", D = 3e4, g = /^[\w.-]+$/, L = "letters, digits, underscore, dot, hyphen", x = (t) => console.warn(t);
9
- function P(t, e) {
10
- return t.key < e.key ? -1 : t.key > e.key ? 1 : 0;
11
- }
12
- async function z({ projectDir: t, configFile: e, output: n, check: i = !1, augmentTarget: r, onWarn: c = x }) {
13
- const { config: o, configPath: s } = await p({
14
- projectDir: t,
15
- configFile: e
16
- });
17
- if (!o.dictionaryKeys)
18
- throw new a(`Code generation config at ${s} has no \`dictionaryKeys\` block.`);
19
- const { dictionaryKeys: l } = o, m = await U(l.fetchDictionaryKeys, l.timeout ?? D);
20
- b(m);
21
- const u = I(m, c);
22
- u.length === 0 && c("`fetchDictionaryKeys` returned no entries; the generated file will declare `DictionaryKey = never`.");
23
- const y = R(t, n ?? l.output ?? S), d = E(u, {
24
- configFile: k(t, s),
25
- augmentTarget: r
26
- }), w = await Y(y) !== d;
27
- return w && !i && (await W(y), await G(y, d)), {
28
- outputPath: y,
29
- keyCount: u.length,
30
- changed: w
31
- };
32
- }
33
- async function U(t, e) {
34
- if (e <= 0)
35
- return await t();
36
- let n;
37
- try {
38
- return await Promise.race([t(), new Promise((i, r) => {
39
- n = setTimeout(() => r(new Error(`fetchDictionaryKeys timed out after ${e}ms.`)), e);
40
- })]);
41
- } finally {
42
- n && clearTimeout(n);
43
- }
44
- }
45
- function b(t) {
46
- for (const e of t)
47
- if (typeof e.key != "string" || !g.test(e.key))
48
- throw new a(`Invalid dictionary key ${JSON.stringify(e.key)}. Keys must match ${g} (${L}).`);
49
- }
50
- function I(t, e) {
51
- const n = /* @__PURE__ */ new Map();
52
- for (const i of t) {
53
- const r = n.get(i.key);
54
- if (!r) {
55
- n.set(i.key, i);
56
- continue;
57
- }
58
- r.comment !== i.comment && e(`Duplicate dictionary key "${i.key}" with conflicting comments; keeping the first occurrence.`);
59
- }
60
- return n.values().toArray().toSorted(P);
61
- }
62
- function R(t, e) {
63
- if (h(e))
64
- throw new a(`Output path must be relative to project root; absolute paths are rejected: ${e}`);
65
- const n = N(t, e), i = k(t, n);
66
- if (i.startsWith("..") || h(i))
67
- throw new a(`Output path escapes project root: ${e}. Must stay within ${t}.`);
68
- return n;
69
- }
70
- async function W(t) {
71
- let e;
72
- try {
73
- e = await v(t);
74
- } catch (n) {
75
- if (n.code === "ENOENT")
76
- return;
77
- throw n;
78
- }
79
- if (e.isSymbolicLink())
80
- throw new a(`Refusing to overwrite symlink at output path: ${t}. Delete the symlink and rerun generation if this is intentional.`);
81
- }
82
- async function Y(t) {
83
- try {
84
- return await $(t, "utf-8");
85
- } catch (e) {
86
- if (e.code === "ENOENT")
87
- return null;
88
- throw e;
89
- }
90
- }
91
- async function G(t, e) {
92
- await K(F(t), { recursive: !0 });
93
- const n = T(6).toString("hex"), i = `${t}.${n}.tmp`, r = f.O_NOFOLLOW ?? 0, c = f.O_WRONLY | f.O_CREAT | f.O_EXCL | r, o = await _(i, c, 384);
94
- try {
95
- await o.writeFile(e, "utf-8");
96
- } finally {
97
- await o.close();
98
- }
99
- try {
100
- await A(i, t);
101
- } catch (s) {
102
- throw await C(i).catch(() => {
103
- }), s;
104
- }
105
- await O(t, 420);
106
- }
107
- export {
108
- z as generateDictionaryKeys
109
- };
@@ -1,11 +0,0 @@
1
- import { CodeGenerationValidationError as o } from "./errors.js";
2
- import { DICTIONARY_AUGMENT_TARGET as i, renderDictionaryKeysFile as n } from "./render.js";
3
- import { generateDictionaryKeys as m } from "./core.js";
4
- import { defineCodeGenerationConfig as f } from "./types.js";
5
- export {
6
- o as CodeGenerationValidationError,
7
- i as DICTIONARY_AUGMENT_TARGET,
8
- f as defineCodeGenerationConfig,
9
- m as generateDictionaryKeys,
10
- n as renderDictionaryKeysFile
11
- };
@@ -1,50 +0,0 @@
1
- import { CodeGenerationValidationError as o } from "./errors.js";
2
- import { existsSync as d } from "node:fs";
3
- import { isAbsolute as f, relative as c, resolve as u } from "node:path";
4
- import { createJiti as y } from "jiti";
5
- var m = [
6
- "code-generation.config.ts",
7
- "code-generation.config.mts",
8
- "code-generation.config.js",
9
- "code-generation.config.mjs"
10
- ];
11
- async function v({ projectDir: t, configFile: e }) {
12
- const i = e ? [g(t, e)] : m.map((r) => u(t, r)), n = i.find((r) => d(r));
13
- if (!n)
14
- throw new o(`Code generation config not found. Looked for: ${i.join(", ")}`);
15
- const s = await y(t).import(n), a = p(s);
16
- return w(a, n), {
17
- config: a,
18
- configPath: n
19
- };
20
- }
21
- function g(t, e) {
22
- const i = f(e) ? e : u(t, e), n = c(t, i);
23
- if (n.startsWith("..") || f(n))
24
- throw new o(`Code generation config file escapes project root: ${e}. Must stay within ${t}.`);
25
- return i;
26
- }
27
- function p(t) {
28
- return t !== null && typeof t == "object" && "default" in t && t.default !== null && typeof t.default == "object" ? t.default : t;
29
- }
30
- function w(t, e) {
31
- if (typeof t != "object" || t === null)
32
- throw new o(`Code generation config at ${e} must export a CodeGenerationConfig object.`);
33
- t.dictionaryKeys !== void 0 && C(t.dictionaryKeys, e);
34
- }
35
- function C(t, e) {
36
- if (typeof t != "object" || t === null)
37
- throw new o(`Code generation config at ${e} field \`dictionaryKeys\` must be an object when set.`);
38
- if (typeof t.fetchDictionaryKeys != "function")
39
- throw new o(`Code generation config at ${e} field \`dictionaryKeys.fetchDictionaryKeys\` must be a function.`);
40
- if (t.output !== void 0 && typeof t.output != "string")
41
- throw new o(`Code generation config at ${e} field \`dictionaryKeys.output\` must be a string when set; got ${typeof t.output}.`);
42
- if (t.timeout !== void 0 && !h(t.timeout))
43
- throw new o(`Code generation config at ${e} field \`dictionaryKeys.timeout\` must be a finite non-negative number when set; got ${String(t.timeout)}.`);
44
- }
45
- function h(t) {
46
- return typeof t == "number" && Number.isFinite(t) && t >= 0;
47
- }
48
- export {
49
- v as loadCodeGenerationConfig
50
- };
@@ -1,31 +0,0 @@
1
- var a = "@vef-framework-react/hooks", y = [
2
- "/* eslint-disable */",
3
- "// @ts-nocheck",
4
- "// noinspection JSUnusedGlobalSymbols",
5
- "// AUTO-GENERATED by @vef-framework-react/dev (vef gen:dictionary-keys). DO NOT EDIT."
6
- ];
7
- function f(n, t) {
8
- const { configFile: i, augmentTarget: o = a } = t, e = [
9
- ...y,
10
- `// Source: ${i}`,
11
- ""
12
- ];
13
- if (n.length === 0)
14
- e.push("export type DictionaryKey = never;");
15
- else {
16
- e.push("export type DictionaryKey =");
17
- for (const [c, r] of n.entries()) {
18
- const s = c === n.length - 1 ? ";" : "";
19
- r.comment && e.push(` /** ${l(r.comment)} */`), e.push(` | ${JSON.stringify(r.key)}${s}`);
20
- }
21
- }
22
- return e.push("", `declare module ${JSON.stringify(o)} {`, " interface Register {", " dictionaryKeys: DictionaryKey;", " }", "}", ""), e.join(`
23
- `);
24
- }
25
- function l(n) {
26
- return n.replaceAll(/\s+/g, " ").trim().replaceAll("*/", String.raw`*\/`);
27
- }
28
- export {
29
- a as DICTIONARY_AUGMENT_TARGET,
30
- f as renderDictionaryKeysFile
31
- };
@@ -1,6 +0,0 @@
1
- export interface GenDictionaryKeysOptions {
2
- config?: string;
3
- output?: string;
4
- check?: boolean;
5
- }
6
- export declare function handleGenDictionaryKeys(options: GenDictionaryKeysOptions, cwd?: string): Promise<void>;
@@ -1,4 +0,0 @@
1
- export { generateDictionaryKeys, type GenerateDictionaryKeysOptions, type GenerateDictionaryKeysResult } from './core';
2
- export { CodeGenerationValidationError } from './errors';
3
- export { DICTIONARY_AUGMENT_TARGET, renderDictionaryKeysFile, type RenderDictionaryKeysOptions } from './render';
4
- export { defineCodeGenerationConfig, type CodeGenerationConfig, type DictionaryKeyEntry, type DictionaryKeysConfig } from './types';
@@ -1,24 +0,0 @@
1
- import { DictionaryKeyEntry } from './types';
2
- /**
3
- * Module name that the generated file augments. Centralized so that future
4
- * refactors (e.g. moving the dictionary key registry to a different package) only
5
- * touch this constant rather than every consumer's checked-in `.gen.ts`.
6
- */
7
- export declare const DICTIONARY_AUGMENT_TARGET = "@vef-framework-react/hooks";
8
- export interface RenderDictionaryKeysOptions {
9
- /**
10
- * Config file path (relative to project root) recorded in the file banner
11
- * for traceability.
12
- */
13
- configFile: string;
14
- /**
15
- * Module name to augment. Defaults to {@link DICTIONARY_AUGMENT_TARGET}.
16
- * Overridable for tests and for downstream forks that re-publish the
17
- * extension point under a different package name.
18
- */
19
- augmentTarget?: string;
20
- }
21
- /**
22
- * Render the dictionary keys file content. Pure function for snapshot tests.
23
- */
24
- export declare function renderDictionaryKeysFile(entries: readonly DictionaryKeyEntry[], options: RenderDictionaryKeysOptions): string;