veryfront 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/index.js +173 -11
- package/dist/ai/index.js.map +2 -2
- package/dist/cli.js +1203 -596
- package/dist/components.js +125 -41
- package/dist/components.js.map +3 -3
- package/dist/config.js +12 -5
- package/dist/config.js.map +2 -2
- package/dist/data.js +2 -1
- package/dist/data.js.map +2 -2
- package/dist/index.js +129 -41
- package/dist/index.js.map +3 -3
- package/package.json +2 -2
package/dist/components.js
CHANGED
|
@@ -525,7 +525,7 @@ var init_deno = __esm({
|
|
|
525
525
|
"deno.json"() {
|
|
526
526
|
deno_default = {
|
|
527
527
|
name: "veryfront",
|
|
528
|
-
version: "0.0.
|
|
528
|
+
version: "0.0.8",
|
|
529
529
|
nodeModulesDir: "auto",
|
|
530
530
|
workspace: [
|
|
531
531
|
"./examples/async-worker-redis",
|
|
@@ -654,6 +654,7 @@ var init_deno = __esm({
|
|
|
654
654
|
dev: "deno run --allow-all --no-lock --unstable-net --unstable-worker-options src/cli/main.ts dev",
|
|
655
655
|
build: "deno compile --allow-all --output ../../bin/veryfront src/cli/main.ts",
|
|
656
656
|
"build:npm": "deno run -A scripts/build-npm.ts",
|
|
657
|
+
release: "deno run -A scripts/release.ts",
|
|
657
658
|
test: "DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --unstable-worker-options --unstable-net",
|
|
658
659
|
"test:unit": "DENO_JOBS=1 deno test --parallel --allow-all --v8-flags=--max-old-space-size=8192 --ignore=tests --unstable-worker-options --unstable-net",
|
|
659
660
|
"test:integration": "DENO_JOBS=1 deno test --parallel --fail-fast --allow-all tests --unstable-worker-options --unstable-net",
|
|
@@ -8871,9 +8872,122 @@ ${transformed}`;
|
|
|
8871
8872
|
|
|
8872
8873
|
// src/build/transforms/mdx/parser.ts
|
|
8873
8874
|
init_utils();
|
|
8875
|
+
|
|
8876
|
+
// src/build/transforms/mdx/module-loader/metadata-extractor.ts
|
|
8877
|
+
init_utils();
|
|
8878
|
+
|
|
8879
|
+
// src/build/transforms/mdx/module-loader/string-parser.ts
|
|
8880
|
+
function extractBalancedBlock(source, startIndex, open, close) {
|
|
8881
|
+
const closeCh = close || (open === "{" ? "}" : open === "[" ? "]" : ")");
|
|
8882
|
+
let depth = 0;
|
|
8883
|
+
let i = startIndex;
|
|
8884
|
+
while (i < source.length) {
|
|
8885
|
+
const ch = source[i];
|
|
8886
|
+
if (ch === '"' || ch === "'") {
|
|
8887
|
+
const quote = ch;
|
|
8888
|
+
i++;
|
|
8889
|
+
while (i < source.length) {
|
|
8890
|
+
const q = source[i];
|
|
8891
|
+
if (q === "\\") {
|
|
8892
|
+
i += 2;
|
|
8893
|
+
continue;
|
|
8894
|
+
}
|
|
8895
|
+
if (q === quote) {
|
|
8896
|
+
i++;
|
|
8897
|
+
break;
|
|
8898
|
+
}
|
|
8899
|
+
i++;
|
|
8900
|
+
}
|
|
8901
|
+
continue;
|
|
8902
|
+
}
|
|
8903
|
+
if (ch === open)
|
|
8904
|
+
depth++;
|
|
8905
|
+
if (ch === closeCh) {
|
|
8906
|
+
depth--;
|
|
8907
|
+
if (depth === 0) {
|
|
8908
|
+
return source.slice(startIndex, i + 1);
|
|
8909
|
+
}
|
|
8910
|
+
}
|
|
8911
|
+
i++;
|
|
8912
|
+
}
|
|
8913
|
+
return "";
|
|
8914
|
+
}
|
|
8915
|
+
function parseJsonish(value) {
|
|
8916
|
+
const jsonish = value.replace(/'([^']*)'/g, '"$1"').replace(/([{,]\s*)([A-Za-z_$][\w$]*)\s*:/g, '$1"$2":');
|
|
8917
|
+
return JSON.parse(jsonish);
|
|
8918
|
+
}
|
|
8919
|
+
|
|
8920
|
+
// src/build/transforms/mdx/module-loader/metadata-extractor.ts
|
|
8921
|
+
function extractFrontmatter(moduleCode) {
|
|
8922
|
+
try {
|
|
8923
|
+
const fmIndex = moduleCode.search(/(?:export\s+)?const\s+frontmatter\s*=\s*/);
|
|
8924
|
+
if (fmIndex < 0)
|
|
8925
|
+
return void 0;
|
|
8926
|
+
const braceStart = moduleCode.indexOf("{", fmIndex);
|
|
8927
|
+
if (braceStart < 0)
|
|
8928
|
+
return void 0;
|
|
8929
|
+
const raw = extractBalancedBlock(moduleCode, braceStart, "{", "}");
|
|
8930
|
+
if (!raw)
|
|
8931
|
+
return void 0;
|
|
8932
|
+
const jsonish = raw.replace(/([^\s"{[:,]+)\s*:/g, '"$1":').replace(/'([^']*)'/g, '"$1"');
|
|
8933
|
+
try {
|
|
8934
|
+
return JSON.parse(jsonish);
|
|
8935
|
+
} catch (e) {
|
|
8936
|
+
rendererLogger.debug("[mdx] frontmatter JSON parse failed", e);
|
|
8937
|
+
return void 0;
|
|
8938
|
+
}
|
|
8939
|
+
} catch (e) {
|
|
8940
|
+
rendererLogger.debug("[mdx] frontmatter extraction failed", e);
|
|
8941
|
+
return void 0;
|
|
8942
|
+
}
|
|
8943
|
+
}
|
|
8944
|
+
var METADATA_PATTERNS = [
|
|
8945
|
+
{ regex: /(?:export\s+)?const\s+title\s*=\s*["']([^"']+)["']/, key: "title" },
|
|
8946
|
+
{ regex: /(?:export\s+)?const\s+description\s*=\s*["']([^"']+)["']/, key: "description" },
|
|
8947
|
+
{ regex: /(?:export\s+)?const\s+layout\s*=\s*(true|false|["'][^"']+["'])/, key: "layout" },
|
|
8948
|
+
{ regex: /(?:export\s+)?const\s+headings\s*=\s*(\[[\s\S]*?\])/, key: "headings" },
|
|
8949
|
+
{ regex: /(?:export\s+)?const\s+nested\s*=\s*({[\s\S]*?})/, key: "nested" },
|
|
8950
|
+
{ regex: /(?:export\s+)?const\s+tags\s*=\s*(\[[\s\S]*?\])/, key: "tags" },
|
|
8951
|
+
{ regex: /(?:export\s+)?const\s+date\s*=\s*["']([^"']+)["']/, key: "date" },
|
|
8952
|
+
{ regex: /(?:export\s+)?const\s+draft\s*=\s*(true|false)/, key: "draft" }
|
|
8953
|
+
];
|
|
8954
|
+
function extractMetadata(moduleCode) {
|
|
8955
|
+
const exports = {};
|
|
8956
|
+
METADATA_PATTERNS.forEach(({ regex, key }) => {
|
|
8957
|
+
const match = moduleCode.match(regex);
|
|
8958
|
+
if (!match)
|
|
8959
|
+
return;
|
|
8960
|
+
const value = match[1];
|
|
8961
|
+
switch (key) {
|
|
8962
|
+
case "title":
|
|
8963
|
+
case "description":
|
|
8964
|
+
case "date":
|
|
8965
|
+
exports[key] = value;
|
|
8966
|
+
break;
|
|
8967
|
+
case "layout":
|
|
8968
|
+
exports[key] = value === "true" ? true : value === "false" ? false : String(value).replace(/^"|"$/g, "");
|
|
8969
|
+
break;
|
|
8970
|
+
case "headings":
|
|
8971
|
+
case "tags":
|
|
8972
|
+
case "nested":
|
|
8973
|
+
try {
|
|
8974
|
+
exports[key] = parseJsonish(value);
|
|
8975
|
+
} catch (e) {
|
|
8976
|
+
rendererLogger.warn(`Failed to parse ${key}`, e);
|
|
8977
|
+
}
|
|
8978
|
+
break;
|
|
8979
|
+
case "draft":
|
|
8980
|
+
exports[key] = value === "true";
|
|
8981
|
+
break;
|
|
8982
|
+
}
|
|
8983
|
+
});
|
|
8984
|
+
return exports;
|
|
8985
|
+
}
|
|
8986
|
+
|
|
8987
|
+
// src/build/transforms/mdx/parser.ts
|
|
8874
8988
|
function parseMDXCode(compiledCode) {
|
|
8875
8989
|
rendererLogger.debug("Parsing MDX code, first 200 chars:", compiledCode.substring(0, 200));
|
|
8876
|
-
const importRegex =
|
|
8990
|
+
const importRegex = /^\s*import\s+(?:{([^}]+)}|(\w+))\s+from\s+['"]([^'"]+)['"]\s*;?\s*$/gm;
|
|
8877
8991
|
const imports = /* @__PURE__ */ new Map();
|
|
8878
8992
|
let match;
|
|
8879
8993
|
while ((match = importRegex.exec(compiledCode)) !== null) {
|
|
@@ -8894,7 +9008,7 @@ function parseMDXCode(compiledCode) {
|
|
|
8894
9008
|
}
|
|
8895
9009
|
}
|
|
8896
9010
|
}
|
|
8897
|
-
const cleanedCode = compiledCode.replace(
|
|
9011
|
+
const cleanedCode = compiledCode.replace(importRegex, "").replace(/^\s*export\s+\{[\s\S]*?\};?\s*$/gm, "").replace(/^\s*export\s+default\s+function/gm, "function").replace(/^\s*export\s+default\s+/gm, "").replace(/^\s*export\s+const\s+/gm, "const ").replace(/^\s*export\s+function\s+/gm, "function ").replace(/^\s*const\s+React\s*=.*?;?\s*$/gm, "").replace(/^\s*import\s+React\s+from.*?;?\s*$/gm, "").replace(/^\s*const\s+(Fragment|Fragment2)\s*=.*?;?\s*$/gm, "").replace(/^\s*const\s+(jsx|jsx2)\s*=.*?;?\s*$/gm, "").replace(/^\s*const\s+(jsxs|jsxs2)\s*=.*?;?\s*$/gm, "");
|
|
8898
9012
|
if (cleanedCode.includes("import React")) {
|
|
8899
9013
|
rendererLogger.warn("Import React still in cleaned code");
|
|
8900
9014
|
}
|
|
@@ -8903,46 +9017,16 @@ function parseMDXCode(compiledCode) {
|
|
|
8903
9017
|
rendererLogger.debug("Code snippet:", cleanedCode.substring(0, 200));
|
|
8904
9018
|
}
|
|
8905
9019
|
const exports = {};
|
|
8906
|
-
const
|
|
8907
|
-
if (
|
|
8908
|
-
|
|
8909
|
-
|
|
8910
|
-
|
|
8911
|
-
|
|
8912
|
-
|
|
9020
|
+
const frontmatter = extractFrontmatter(cleanedCode);
|
|
9021
|
+
if (frontmatter) {
|
|
9022
|
+
exports.frontmatter = frontmatter;
|
|
9023
|
+
}
|
|
9024
|
+
const metadata = extractMetadata(cleanedCode);
|
|
9025
|
+
for (const [key, value] of Object.entries(metadata)) {
|
|
9026
|
+
if (value !== void 0) {
|
|
9027
|
+
exports[key] = value;
|
|
8913
9028
|
}
|
|
8914
9029
|
}
|
|
8915
|
-
const exportMatches = [
|
|
8916
|
-
{ regex: /const\s+title\s*=\s*["']([^"']+)["']/, key: "title", parse: (v) => v },
|
|
8917
|
-
{
|
|
8918
|
-
regex: /const\s+description\s*=\s*["']([^"']+)["']/,
|
|
8919
|
-
key: "description",
|
|
8920
|
-
parse: (v) => v
|
|
8921
|
-
},
|
|
8922
|
-
{ regex: /const\s+layout\s*=\s*true/, key: "layout", parse: () => true },
|
|
8923
|
-
{ regex: /const\s+layout\s*=\s*false/, key: "layout", parse: () => false },
|
|
8924
|
-
{ regex: /const\s+layout\s*=\s*["']([^"']+)["']/, key: "layout", parse: (v) => v },
|
|
8925
|
-
{
|
|
8926
|
-
regex: /const\s+headings\s*=\s*(\[[\s\S]*?\]);/,
|
|
8927
|
-
key: "headings",
|
|
8928
|
-
parse: (v) => {
|
|
8929
|
-
try {
|
|
8930
|
-
return JSON.parse(v.replace(/'/g, '"'));
|
|
8931
|
-
} catch {
|
|
8932
|
-
return [];
|
|
8933
|
-
}
|
|
8934
|
-
}
|
|
8935
|
-
}
|
|
8936
|
-
];
|
|
8937
|
-
exportMatches.forEach(({ regex, key, parse }) => {
|
|
8938
|
-
const m = cleanedCode.match(regex);
|
|
8939
|
-
if (m) {
|
|
8940
|
-
try {
|
|
8941
|
-
exports[key] = parse(m[1] || m[0]);
|
|
8942
|
-
} catch (_error) {
|
|
8943
|
-
}
|
|
8944
|
-
}
|
|
8945
|
-
});
|
|
8946
9030
|
return { code: cleanedCode, imports, exports };
|
|
8947
9031
|
}
|
|
8948
9032
|
|