@visulima/vis 2.0.1 → 3.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.
- package/CHANGELOG.md +48 -0
- package/LICENSE.md +850 -128
- package/dist/bin.js +1 -1
- package/dist/binx.js +1 -1
- package/dist/packem_chunks/CONFIG_FILES.js +3 -3
- package/dist/packem_chunks/bloom-status.js +1 -1
- package/dist/packem_chunks/bloom-sync.js +1 -1
- package/dist/packem_chunks/catalog.js +67 -67
- package/dist/packem_chunks/cli-exec.js +1 -1
- package/dist/packem_chunks/cli-main.js +150 -148
- package/dist/packem_chunks/dispatch.js +1 -1
- package/dist/packem_chunks/doctor-probe.js +1 -1
- package/dist/packem_chunks/fix.js +3 -3
- package/dist/packem_chunks/handler.js +1 -1
- package/dist/packem_chunks/handler10.js +3 -3
- package/dist/packem_chunks/handler11.js +1 -1
- package/dist/packem_chunks/handler12.js +3 -3
- package/dist/packem_chunks/handler13.js +1 -1
- package/dist/packem_chunks/handler14.js +1 -1
- package/dist/packem_chunks/handler15.js +1 -1
- package/dist/packem_chunks/handler16.js +1 -1
- package/dist/packem_chunks/handler17.js +1 -1
- package/dist/packem_chunks/handler18.js +1 -1
- package/dist/packem_chunks/handler19.js +1 -1
- package/dist/packem_chunks/handler2.js +1 -1
- package/dist/packem_chunks/handler20.js +2 -2
- package/dist/packem_chunks/handler21.js +1 -1
- package/dist/packem_chunks/handler22.js +1 -1
- package/dist/packem_chunks/handler23.js +1 -1
- package/dist/packem_chunks/handler24.js +1 -1
- package/dist/packem_chunks/handler26.js +1 -1
- package/dist/packem_chunks/handler27.js +1 -1
- package/dist/packem_chunks/handler28.js +1 -1
- package/dist/packem_chunks/handler29.js +1 -1
- package/dist/packem_chunks/handler3.js +1 -1
- package/dist/packem_chunks/handler30.js +1 -1
- package/dist/packem_chunks/handler4.js +4 -4
- package/dist/packem_chunks/handler5.js +1 -1
- package/dist/packem_chunks/handler50.js +5 -5
- package/dist/packem_chunks/handler51.js +2 -2
- package/dist/packem_chunks/handler53.js +1 -1
- package/dist/packem_chunks/handler54.js +2 -2
- package/dist/packem_chunks/handler55.js +1 -1
- package/dist/packem_chunks/handler58.js +4 -4
- package/dist/packem_chunks/handler59.js +1 -1
- package/dist/packem_chunks/handler6.js +7 -7
- package/dist/packem_chunks/handler60.js +2 -2
- package/dist/packem_chunks/handler61.js +13 -13
- package/dist/packem_chunks/handler62.js +3 -3
- package/dist/packem_chunks/handler63.js +2 -2
- package/dist/packem_chunks/handler64.js +4 -4
- package/dist/packem_chunks/handler66.js +1 -1
- package/dist/packem_chunks/handler67.js +13 -13
- package/dist/packem_chunks/handler68.js +1 -1
- package/dist/packem_chunks/handler69.js +15 -15
- package/dist/packem_chunks/handler7.js +1 -1
- package/dist/packem_chunks/handler70.js +5 -5
- package/dist/packem_chunks/handler71.js +1 -1
- package/dist/packem_chunks/handler72.js +23 -23
- package/dist/packem_chunks/handler73.js +5 -5
- package/dist/packem_chunks/handler74.js +24 -24
- package/dist/packem_chunks/handler75.js +2 -2
- package/dist/packem_chunks/handler76.js +5 -5
- package/dist/packem_chunks/handler77.js +18 -18
- package/dist/packem_chunks/handler78.js +25 -25
- package/dist/packem_chunks/handler8.js +1 -1
- package/dist/packem_chunks/handler9.js +1 -1
- package/dist/packem_chunks/heal-accept.js +2 -2
- package/dist/packem_chunks/heal.js +4 -4
- package/dist/packem_chunks/help-command.js +46 -46
- package/dist/packem_chunks/index2.js +6 -4
- package/dist/packem_chunks/index3.js +3 -3
- package/dist/packem_chunks/index4.js +49 -49
- package/dist/packem_chunks/keys-refresh.js +1 -1
- package/dist/packem_chunks/lean.js +2 -2
- package/dist/packem_chunks/list.js +1 -1
- package/dist/packem_chunks/loader.js +1 -1
- package/dist/packem_chunks/orchestrator.js +2 -2
- package/dist/packem_chunks/prompts.js +1 -1
- package/dist/packem_chunks/prune.js +1 -1
- package/dist/packem_chunks/registry.js +10 -10
- package/dist/packem_chunks/status.js +1 -1
- package/dist/packem_chunks/sync.js +1 -1
- package/dist/packem_chunks/sync2.js +1 -1
- package/dist/packem_chunks/tripwire.js +1 -1
- package/dist/packem_chunks/ts-loader.js +6 -6
- package/dist/packem_chunks/verify-lockfile.js +1 -1
- package/dist/packem_shared/{advisories-BGeuHJQg.js → advisories-DsXRmIA5.js} +1 -1
- package/dist/packem_shared/{affected-selection-B85ND6JV.js → affected-selection-BE6VFCDV.js} +1 -1
- package/dist/packem_shared/{affected-shas-BWRRAB47.js → affected-shas-BKEu4RZc.js} +1 -1
- package/dist/packem_shared/ai-analysis-DikAj6rX.js +68 -0
- package/dist/packem_shared/{ai-fix-BgBU0TOz.js → ai-fix-bfWo0cZX.js} +4 -4
- package/dist/packem_shared/{augment-HVeX6LpU.js → augment-BkJxi_GW.js} +1 -1
- package/dist/packem_shared/{bin-DKod8Iqo.js → bin-B-TytgzW.js} +1 -1
- package/dist/packem_shared/{build-scripts-CM8M1xcG.js → build-scripts-DWypBQ--.js} +1 -1
- package/dist/packem_shared/{command-runtime-BVi4lL8k.js → command-runtime-DQ7ZpLYL.js} +1 -1
- package/dist/packem_shared/{cyclonedx-y7VLI-1d.js → cyclonedx-DLBi65MV.js} +3 -3
- package/dist/packem_shared/dependency-scan-ZLOuLkGN.js +1 -0
- package/dist/packem_shared/{docker-D1LStSlH.js → docker-B4zAZCZG.js} +28 -28
- package/dist/packem_shared/{en-BxrK-n-J.js → en-BDYMmM2_.js} +13 -13
- package/dist/packem_shared/{failure-log-ChuFC-8f.js → failure-log-DyhWPqno.js} +2 -2
- package/dist/packem_shared/glob-BUjyjdE8-Dp_QcayW.js +1 -0
- package/dist/packem_shared/index-BLtnel38.js +35 -0
- package/dist/packem_shared/index-CuKDxOCI.js +1 -0
- package/dist/packem_shared/index-tNFGWxc0.js +39 -0
- package/dist/packem_shared/index.server-CusjRLCh.js +2 -0
- package/dist/packem_shared/{lifecycle-Db0qh6vR.js → lifecycle-KY9umOg6.js} +1 -1
- package/dist/packem_shared/{lockfile-CDQ0n4P5.js → lockfile-YAuZf1gh.js} +1 -1
- package/dist/packem_shared/{manifests-Da_no4ZH.js → manifests-BwTn_1ad.js} +1 -1
- package/dist/packem_shared/{min-release-age-V6L6dpiP.js → min-release-age-6avfn81h.js} +1 -1
- package/dist/packem_shared/missing-package-json-Cl0vdz6K.js +1 -0
- package/dist/packem_shared/{native-config-sync-C0pUePad.js → native-config-sync-CHMCJx7H.js} +7 -7
- package/dist/packem_shared/{osv-bloom-DNFpvSSO.js → osv-bloom-DdqDnLCt.js} +2 -2
- package/dist/packem_shared/package-version-BNRJ3o9C.js +4 -0
- package/dist/packem_shared/packument-B9-WqReu.js +1 -0
- package/dist/packem_shared/pm-runner-DRybtzOV.js +1 -0
- package/dist/packem_shared/{project-name-filter-u2Q7YpQH.js → project-name-filter-Dw0fC6IO.js} +1 -1
- package/dist/packem_shared/{provenance-9OT8sTqn.js → provenance-CLxuqCfL.js} +1 -1
- package/dist/packem_shared/{readJsonSync-BnWiH5-R-BpnwAB0Z.js → readJsonSync-DweZd5ZA-CtrDlqpb.js} +1 -1
- package/dist/packem_shared/{registry-keys-CYHd7qU2.js → registry-keys-cTN24144.js} +1 -1
- package/dist/packem_shared/{resolve-explicit-DC3XssJa.js → resolve-explicit-Uw6WQl9R.js} +1 -1
- package/dist/packem_shared/{resolve-runtime-f5l4ODsH.js → resolve-runtime-DztanwkZ.js} +1 -1
- package/dist/packem_shared/{run-file-zB4ACnUy.js → run-file-CaE5_xBY.js} +1 -1
- package/dist/packem_shared/{runtime-check-CWvAfu5u.js → runtime-check-C32yE57I.js} +1 -1
- package/dist/packem_shared/{s1ngularity-DsmC71xt.js → s1ngularity-BIYhg82u.js} +1 -1
- package/dist/packem_shared/scan-progress-DWfY4zkp.js +2 -0
- package/dist/packem_shared/{selectors-CtxnIT4X.js → selectors-D2j4M9Ul.js} +1 -1
- package/dist/packem_shared/{signatures-Dwx5fD4g.js → signatures-C8iQ5fUq.js} +1 -1
- package/dist/packem_shared/target-merge-DLxJTcxn.js +11 -0
- package/dist/packem_shared/{target-options-BO4Uxt0k.js → target-options-3t4-2F-F.js} +1 -1
- package/dist/packem_shared/{toolchain-BY8lJaSN.js → toolchain-BPzbahcQ.js} +1 -1
- package/dist/packem_shared/{typosquats-BUGgotNu.js → typosquats-BWrmhh36.js} +1 -1
- package/dist/packem_shared/{use-measured-height-BLZt9dW2.js → use-measured-height-BwAwGHjw.js} +1 -1
- package/dist/packem_shared/verify-CzUPT6Uk.js +1 -0
- package/dist/packem_shared/vis-update-app-D6Wq8ZHM.js +1 -0
- package/dist/packem_shared/vis-user-error-CfM4_ORo.js +30 -0
- package/dist/packem_shared/{watch-CGrUW_JD.js → watch-D_oAxW_Z.js} +1 -1
- package/dist/packem_shared/{watch-loop-DIwSMjlA.js → watch-loop-BrjblOz5.js} +4 -4
- package/dist/runtime/preload.js +1 -1
- package/index.d.ts +204 -204
- package/index.js +52 -52
- package/package.json +16 -16
- package/dist/packem_shared/ai-analysis-oNMAj1wd.js +0 -68
- package/dist/packem_shared/dependency-scan-BAzKpXdW.js +0 -1
- package/dist/packem_shared/glob-BUjyjdE8-BSrdzgma.js +0 -1
- package/dist/packem_shared/index-BJw7gKD1.js +0 -1
- package/dist/packem_shared/index-DND6ptxQ.js +0 -35
- package/dist/packem_shared/index.server-qvZ-cy29.js +0 -2
- package/dist/packem_shared/missing-package-json-Jw8IEHct.js +0 -1
- package/dist/packem_shared/package-version-DjHDww_5.js +0 -4
- package/dist/packem_shared/packument-N3EWbZpL.js +0 -1
- package/dist/packem_shared/pm-runner-Bssje5qH.js +0 -1
- package/dist/packem_shared/public-api-WqUCiyIe.js +0 -131
- package/dist/packem_shared/scan-progress-Ch8s3Uwl.js +0 -2
- package/dist/packem_shared/target-merge-b7bE1AEx.js +0 -11
- package/dist/packem_shared/verify-B0ztxKMa.js +0 -1
- package/dist/packem_shared/vis-update-app-D1gLJB1O.js +0 -1
- package/dist/packem_shared/vis-user-error-DjFv8uxy.js +0 -28
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as u}from"node:module";let _;const
|
|
1
|
+
import{createRequire as u}from"node:module";let _;const $=t=>(_??=u(import.meta.url))(t),p=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,h=t=>{if(typeof p<"u"&&p.versions&&p.versions.node){const[i,e]=p.versions.node.split(".").map(Number);if(i>22||i===22&&e>=3||i===20&&e>=16)return p.getBuiltinModule(t)}return $(t)},f=h("node:assert");function g(t,i){return`#compdef ${t}
|
|
2
2
|
compdef _${t} ${t}
|
|
3
3
|
|
|
4
4
|
# zsh completion for ${t} -*- shell-script -*-
|
|
@@ -45,7 +45,7 @@ _${t}() {
|
|
|
45
45
|
|
|
46
46
|
# Prepare the command to obtain completions, ensuring arguments are quoted for eval
|
|
47
47
|
local -a args_to_quote=("\${(@)words[2,-1]}")
|
|
48
|
-
if [ "\${lastChar}" = "" ]; then
|
|
48
|
+
if [ "\${lastChar}" = "" ] && [ "\${args_to_quote[-1]}" != "" ]; then
|
|
49
49
|
# If the last parameter is complete (there is a space following it)
|
|
50
50
|
# We add an extra empty parameter so we can indicate this to the go completion code.
|
|
51
51
|
__${t}_debug "Adding extra empty parameter"
|
|
@@ -622,8 +622,10 @@ complete -k -c ${t} -n '__${e}_requires_order_preservation && __${e}_prepare_com
|
|
|
622
622
|
# Remove the flag part
|
|
623
623
|
$Flag, $WordToComplete = $WordToComplete.Split("=", 2)
|
|
624
624
|
}
|
|
625
|
-
|
|
626
|
-
|
|
625
|
+
$HasTrailingEmptyArg = $QuotedArgs -match "(^| )''$"
|
|
626
|
+
__${t}_debug "HasTrailingEmptyArg: $HasTrailingEmptyArg"
|
|
627
|
+
|
|
628
|
+
if ( $WordToComplete -eq "" -And ( -Not $IsEqualFlag ) -And ( -Not $HasTrailingEmptyArg )) {
|
|
627
629
|
# If the last parameter is complete (there is a space following it)
|
|
628
630
|
# We add an extra empty parameter so we can indicate this to the go method.
|
|
629
631
|
__${t}_debug "Adding extra empty parameter"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{b as U,w as z,a as H,e as K,z as $}from"../packem_shared/index-BLtnel38.js";import{b as X}from"../packem_shared/index-tNFGWxc0.js";import{p as Z}from"./cli-main.js";import{k as I,W as A,j as x}from"../packem_shared/en-BDYMmM2_.js";const ee=(e,t)=>typeof e!="string"||e===""?"":e[0].toLowerCase()+e.slice(1),k=(e,t)=>typeof e!="string"||e===""?"":(t?.locale?e[0].toLocaleUpperCase(t.locale):e[0].toUpperCase())+e.slice(1),te=(e,t)=>`${e}::${t?.joiner??""}::${t?.locale??""}::${t?.knownAcronyms?.join(",")??""}::${t?.normalize?"true":"false"}::${t?.stripAnsi?"true":"false"}::${t?.stripEmoji?"true":"false"}::${t?.handleAnsi?"true":"false"}::${t?.handleEmoji?"true":"false"}`,j=(e,t)=>{const{length:r}=e;if(r===0)return"";if(r===1)return e[0];const n=[];let o="",s="";for(let i=0;i<r;i++){const l=e[i];if(I.test(l)){o?(n.push(o+s+l),o="",s=""):(n.length>0&&n.push(t),o=l);continue}o?(s&&(s+=t),s+=l):(n.length>0&&n.push(t),n.push(l))}return n.join("")},ne=/(?<![a-zß])SS(?![a-z])/g,re=e=>e.replaceAll(ne,"ß"),oe=(e,t)=>{if(typeof e!="string"||!e)return"";let r=!0;return j(A(e,{handleAnsi:t?.handleAnsi,handleEmoji:t?.handleEmoji,knownAcronyms:t?.knownAcronyms,locale:t?.locale,normalize:t?.normalize,separators:void 0,stripAnsi:t?.stripAnsi,stripEmoji:t?.stripEmoji}).map(o=>{const s=o,i=s.toLowerCase();return r?(r=!1,ee(i)):k(i,t)}),"")},se=new x(1e3),S=(e,t)=>{if(typeof e!="string")return"";const r=t?.cache??!1,n=t?.cacheStore??se;let o;if(r&&(o=te(e,t)),r&&o&&n.has(o))return n.get(o);const s=A(e,{handleAnsi:t?.handleAnsi,handleEmoji:t?.handleEmoji,knownAcronyms:t?.knownAcronyms,locale:t?.locale,normalize:t?.normalize,separators:void 0,stripAnsi:t?.stripAnsi,stripEmoji:t?.stripEmoji}).map(l=>{if(t?.handleAnsi&&I.test(l))return l;if(t?.toUpperCase)return t.locale?l.toLocaleUpperCase(t.locale):l.toUpperCase();const a=t?.locale?.startsWith("de")?re(l):l;return t?.locale?a.toLocaleLowerCase(t.locale):a.toLowerCase()}),i=j(s,t?.joiner??"-");return r&&o&&n.set(o,i),i},ie=new x(1e3),le=(e,t)=>S(e,{cacheStore:ie,...t,joiner:"_",toUpperCase:!0}),ae=(e,t)=>typeof e!="string"||!e?"":j(A(e,{handleAnsi:t?.handleAnsi,handleEmoji:t?.handleEmoji,knownAcronyms:t?.knownAcronyms,locale:t?.locale,normalize:t?.normalize,separators:void 0,stripAnsi:t?.stripAnsi,stripEmoji:t?.stripEmoji}).map(n=>k(n.toLowerCase(),{locale:t?.locale})),""),ce=new x(1e3),fe=(e,t)=>S(e,{cacheStore:ce,...t,joiner:"_"}),ue=(e,t)=>typeof e!="string"?"":j(A(e,{handleAnsi:t?.handleAnsi,handleEmoji:t?.handleEmoji,knownAcronyms:t?.knownAcronyms,locale:t?.locale,normalize:t?.normalize,separators:void 0,stripAnsi:t?.stripAnsi,stripEmoji:t?.stripEmoji}).map(n=>k(n,{locale:t?.locale})),"-"),m=e=>e==null?"":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"||typeof e=="bigint"?String(e):JSON.stringify(e),T={camel_case:e=>oe(m(e)),kebab_case:e=>S(m(e)),lower_case:e=>m(e).toLowerCase(),pascal_case:e=>ae(m(e)),path_join:(e,...t)=>{const r=[m(e),...t.map(n=>m(n))];return z(...r)},path_relative:(e,t)=>U(m(t),m(e)),snake_case:e=>fe(m(e)),upper_case:e=>m(e).toUpperCase(),upper_kebab_case:e=>ue(m(e)),upper_snake_case:e=>le(m(e))},N=(e,t,r=[])=>{const n=T[e];if(!n)throw new Error(`Unknown filter "${e}". Known filters: ${Object.keys(T).sort().join(", ")}.`);return n(t,...r)},R=e=>{const t=[];let r=0,n=0,o,s=-1;for(const i of e){if(s+=1,o){i===o&&(o=void 0);continue}if(i==='"'||i==="'"){o=i;continue}i==="("?r+=1:i===")"?r-=1:i===","&&r===0&&(t.push(e.slice(n,s)),n=s+1)}return t.push(e.slice(n)),t},pe=e=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1)},me=/\[([^\]]+)\]/g,de=e=>{const t=e.trim(),r=t.indexOf("(");if(r===-1)return{args:[],name:t};if(!t.endsWith(")"))throw new Error(`Filter call "${e}" missing closing ")"`);const n=t.slice(0,r).trim(),o=t.slice(r+1,-1).trim();return o===""?{args:[],name:n}:{args:R(o).map(s=>{const i=s.trim();return pe(i)??i}),name:n}},he=e=>{const t=e.split("|").map(n=>n.trim()),r=t[0]??"";if(!r)throw new Error(`Empty variable name in expression "${e}"`);return{filters:t.slice(1).map(n=>de(n)),name:r}},ye=e=>e==null?"":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"||typeof e=="bigint"?String(e):JSON.stringify(e),ge=(e,t)=>{const r=e.replaceAll(me,(n,o)=>{const{filters:s,name:i}=he(o);if(!Object.hasOwn(t,i))throw new Error(`Variable "${i}" used in filename "${e}" but not defined`);let l=t[i];for(const a of s)l=N(a.name,l,a.args);return ye(l)});return P(r)},P=e=>e.split("/").map(t=>t.endsWith(".tera")||t.endsWith(".twig")?t.slice(0,-5):t).join("/"),we=e=>e.endsWith(".raw")?e.slice(0,-4):e,$e=e=>{const t=e.split("/");return(t.at(-1)??"").startsWith("_")?!0:t.slice(0,-1).includes("partials")},be=(e,t)=>{if(!e.startsWith(`---
|
|
2
2
|
`)&&!e.startsWith(`---\r
|
|
3
3
|
`))return{body:e};const r=e.indexOf(`
|
|
4
4
|
---`,3);if(r===-1)return{body:e};let n=r+1+3;e[n]==="\r"&&(n+=1),e[n]===`
|
|
5
5
|
`&&(n+=1);const o=e.startsWith(`---\r
|
|
6
|
-
`)?5:4,s=e.slice(o,r).replaceAll("\r","");let i;try{i=t(s)}catch(l){const a=l instanceof Error?l.message:String(l);throw new Error(`Failed to parse frontmatter YAML: ${a}`,{cause:l})}if(i==null)return{body:e.slice(n)};if(typeof i!="object"||Array.isArray(i))throw new TypeError(`Frontmatter must be a YAML mapping, got ${Array.isArray(i)?"array":typeof i}`);return{body:e.slice(n),frontmatter:i}},
|
|
7
|
-
`&&(n+=1)};for(const s of e.matchAll(
|
|
6
|
+
`)?5:4,s=e.slice(o,r).replaceAll("\r","");let i;try{i=t(s)}catch(l){const a=l instanceof Error?l.message:String(l);throw new Error(`Failed to parse frontmatter YAML: ${a}`,{cause:l})}if(i==null)return{body:e.slice(n)};if(typeof i!="object"||Array.isArray(i))throw new TypeError(`Frontmatter must be a YAML mapping, got ${Array.isArray(i)?"array":typeof i}`);return{body:e.slice(n),frontmatter:i}},Ee=/\{\{-?(.+?)-?\}\}|\{%-?(.+?)-?%\}/gs,q=e=>{const t=[];let r=0,n=1;const o=s=>{for(const i of s)i===`
|
|
7
|
+
`&&(n+=1)};for(const s of e.matchAll(Ee)){const i=s.index??0;if(i>r){const c=e.slice(r,i);t.push({line:n,type:"text",value:c}),o(c)}const l=n,a=s[0];a.startsWith("{{")?t.push({line:l,type:"expr",value:(s[1]??"").trim()}):t.push({line:l,type:"stmt",value:(s[2]??"").trim()}),o(a),r=i+a.length}if(r<e.length){const s=e.slice(r);t.push({line:n,type:"text",value:s})}return t},Ae=new Set(["block","endblock","endfilter","endmacro","extends","filter","import","macro","set"]),F=(e,t)=>{let r=0;const n=(s,i)=>{throw new Error(`${t}:${s}: ${i}`)},o=s=>{const i=[];for(;r<e.length;){const l=e[r];if(l.type==="text"){i.push({type:"text",value:l.value}),r+=1;continue}if(l.type==="expr"){i.push({expression:l.value,line:l.line,type:"expr"}),r+=1;continue}const a=l.value.split(/\s+/)[0]??"";if(s.includes(a))return i;if(Ae.has(a)&&n(l.line,`Tera feature "{% ${a} %}" is not supported. Supported: if/else/endif, for/endfor, include. Rewrite the template to avoid macros, set, extends, block, and import.`),a==="if"){r+=1;const c=l.value.slice(2).trim(),p=o(["else","endif"]);let f;r<e.length&&e[r].type==="stmt"&&e[r].value.split(/\s+/)[0]==="else"&&(r+=1,f=o(["endif"])),(r>=e.length||e[r].type!=="stmt"||e[r].value.split(/\s+/)[0]!=="endif")&&n(l.line,"Unterminated {% if %} — missing {% endif %}"),r+=1,i.push({alternate:f,condition:c,consequent:p,line:l.line,type:"if"});continue}if(a==="for"){r+=1;const c=l.value.slice(3).trim(),p=c.indexOf(" in ");p===-1&&n(l.line,"Malformed {% for %} — expected `for <name> in <collection>`");const f=c.slice(0,p).trim(),d=c.slice(p+4).trim();(!f||!d)&&n(l.line,"Malformed {% for %} — missing binding or collection");const u=o(["endfor"]);(r>=e.length||e[r].type!=="stmt"||e[r].value.split(/\s+/)[0]!=="endfor")&&n(l.line,"Unterminated {% for %} — missing {% endfor %}"),r+=1,i.push({binding:f,body:u,collection:d,line:l.line,type:"for"});continue}if(a==="include"){r+=1;const c=l.value.slice(7).trim(),p=G(c);p===void 0&&n(l.line,"Malformed {% include %} — expected a quoted partial name"),i.push({line:l.line,name:p,type:"include"});continue}n(l.line,`Unknown tag "{% ${a} %}". Supported: if, for, include.`)}return i};return o([])},G=e=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1)},je=e=>e==null?"":typeof e=="boolean"||typeof e=="number"?String(e):typeof e=="string"?e:JSON.stringify(e),ve=e=>e==null||e===!1||e===0||e===""?!1:Array.isArray(e)?e.length>0:!0,B=(e,t,r,n,o=!0)=>{const s=e.split(".");if(o&&s.length>0&&!Object.hasOwn(t,s[0]))throw new Error(`${n}:${r}: Variable "${e}" is not defined`);let i=t;for(const l of s){if(i==null)return;if(typeof i!="object")throw new TypeError(`${n}:${r}: Cannot read "${l}" on non-object value`);i=i[l]}return i},xe=e=>{const t=[];let r=0,n=0,o;for(let s=0;s<e.length;s+=1){const i=e[s];if(o){i===o&&(o=void 0);continue}if(i==='"'||i==="'"){o=i;continue}i==="("?r+=1:i===")"?r-=1:i==="|"&&r===0&&(t.push(e.slice(n,s)),n=s+1)}return t.push(e.slice(n)),t},ke=e=>{const t=e.trim(),r=t.indexOf("(");if(r===-1)return{args:[],name:t};if(!t.endsWith(")"))throw new Error(`Filter call "${e}" missing closing ")"`);const n=t.slice(0,r).trim(),o=t.slice(r+1,-1).trim();return o?{args:R(o).map(s=>s.trim()),name:n}:{args:[],name:n}},E=(e,t,r,n,o=!0)=>{const s=e.trim();if(s==="true")return!0;if(s==="false")return!1;if(s==="null"||s==="none")return null;const i=G(s);return i!==void 0?i:/^-?\d+(?:\.\d+)?$/.test(s)?Number(s):B(s,t,r,n,o)},D=(e,t,r,n,o=!0)=>{const s=xe(e),i=s[0].trim();let l=E(i,t,r,n,o);for(let a=1;a<s.length;a+=1){const c=s[a].trim(),{args:p,name:f}=ke(c),d=p.map(u=>E(u,t,r,n,o));try{l=N(f,l,d)}catch(u){const y=u instanceof Error?u.message:String(u);throw new Error(`${n}:${r}: ${y}`,{cause:u})}}return l},Y=(e,t)=>{let r,n=0;for(let o=0;o<=e.length-t.length;o+=1){const s=e[o];if(r){s===r&&(r=void 0);continue}if(s==='"'||s==="'"){r=s;continue}if(s==="("){n+=1;continue}if(s===")"){n-=1;continue}if(n===0&&e.slice(o,o+t.length)===t)return o}return-1},_=(e,t)=>{const r=[];let n=0,o=0;for(;o<=e.length-t.length;){const s=Y(e.slice(o),t);if(s===-1)break;r.push(e.slice(n,o+s)),o+=s+t.length,n=o}return r.push(e.slice(n)),r},g=(e,t,r,n)=>{const o=e.trim();if(o==="")return!1;if(o.startsWith("(")&&o.endsWith(")")&&Se(o)===o.length-1)return g(o.slice(1,-1),t,r,n);const s=_(o," or ");if(s.length>1)return s.some(l=>g(l,t,r,n));const i=_(o," and ");if(i.length>1)return i.every(l=>g(l,t,r,n));if(o.startsWith("not "))return!g(o.slice(4),t,r,n);for(const l of["==","!="]){const a=Y(o,l);if(a!==-1){const c=E(o.slice(0,a),t,n,r,!1),p=E(o.slice(a+l.length),t,n,r,!1),f=c===p;return l==="=="?f:!f}}return ve(D(o,t,n,r,!1))},Se=e=>{if(e[0]!=="(")return-1;let t=0,r,n=-1;for(const o of e){if(n+=1,r){o===r&&(r=void 0);continue}if(o==='"'||o==="'"){r=o;continue}if(o==="(")t+=1;else if(o===")"&&(t-=1,t===0))return n}return-1},b=(e,t)=>{let r="";for(const n of e){if(n.type==="text"){r+=n.value;continue}if(n.type==="expr"){r+=je(D(n.expression,t.scope,n.line,t.filename));continue}if(n.type==="if"){const o=g(n.condition,t.scope,t.filename,n.line)?n.consequent:n.alternate??[];r+=b(o,t);continue}if(n.type==="for"){const o=B(n.collection,t.scope,n.line,t.filename,!1);if(o==null)continue;if(!Array.isArray(o))throw new TypeError(`${t.filename}:${n.line}: {% for %} expected an array, got ${typeof o}`);for(const s of o){const i={...t.scope,[n.binding]:s};r+=b(n.body,{...t,scope:i})}continue}if(n.type==="include"){const o=t.partials?.get(n.name);if(!o)throw new Error(`${t.filename}:${n.line}: Partial "${n.name}" not found. Available: ${[...t.partials?.keys()??[]].join(", ")||"(none)"}`);const s=t.includeStack??new Set;if(s.has(n.name)){const i=[...s,n.name].join(" → ");throw new Error(`${t.filename}:${n.line}: Circular partial include detected: ${i}`)}s.add(n.name);try{r+=b(o,{...t,filename:`<partial:${n.name}>`,includeStack:s})}finally{s.delete(n.name)}}}return r},Ce=(e,t)=>F(q(e),t),v=(e,t)=>b(F(q(e),t.filename),t),L="template.yml",Oe=".raw",We=new Set([".cjs",".css",".env",".gitattributes",".gitignore",".graphql",".html",".ini",".js",".json",".json5",".jsonc",".jsx",".lock",".md",".mdx",".mjs",".prettierrc",".raw",".rs",".scss",".sh",".sql",".svg",".tera",".toml",".ts",".tsx",".twig",".txt",".vue",".xml",".yaml",".yml"]),Te=new Set(["Brewfile","CHANGELOG","CODEOWNERS","CONTRIBUTING","COPYING","Dockerfile","Gemfile","LICENCE","LICENSE","Makefile","NOTICE","Procfile","Rakefile","README","VERSION"]),_e=e=>{const t=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\")),r=t===-1?e:e.slice(t+1),n=r.lastIndexOf(".");return n===-1||n===0?"":r.slice(n).toLowerCase()},J=e=>{const t=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));return t===-1?e:e.slice(t+1)},Le=e=>{const t=_e(e);if(t!=="")return We.has(t);const r=J(e);return Te.has(r)},Me=e=>{const t={default:e.default,internal:e.internal,order:e.order,prompt:e.prompt,required:e.required};switch(e.type){case"array":return{...t,type:"array"};case"boolean":return{...t,default:typeof t.default=="boolean"?t.default:void 0,type:"boolean"};case"enum":return{...t,multiple:e.multiple,type:"enum",values:e.values??[]};case"number":return{...t,type:"number"};case"string":return{...t,type:"string"};default:throw new Error(`Unsupported variable type "${String(e.type)}"`)}},Ue=e=>e.replaceAll("\\","/").replace(/^\.\//,"").replaceAll(/\/+/g,"/"),ze=(e,t,r)=>{const n=t.split("/").filter(Boolean);if(n.length===0)throw new Error("Empty destination path for value");let o=e;for(let s=0;s<n.length-1;s+=1){const i=n[s],l=o[i];if(l===void 0){const a={};o[i]=a,o=a}else if(typeof l=="object"&&!Buffer.isBuffer(l))o=l;else throw new TypeError(`Path conflict: "${n.slice(0,s+1).join("/")}" is both a file and a directory`)}o[n.at(-1)]=r},M=(e,t,r)=>{if(typeof e!="string")return Ie(e);const n=e.includes("{{")||e.includes("{%")?v(e,{filename:`${r}#frontmatter`,scope:t}):e;return g(n,t,`${r}#frontmatter`,1)},Ie=e=>e==null||e===!1||e===0||e===""?!1:Array.isArray(e)?e.length>0:typeof e=="string"?e!=="false"&&e!=="0":!0,Ge=(e,t)=>{const r=z(e,L),n=H(r);if(!n||typeof n!="object")throw new Error(`${r}: must contain a YAML mapping`);const o={};if(n.variables)for(const[a,c]of Object.entries(n.variables))o[a]=Me(c);const s=new Map,i=[];for(const a of K(e,{includeDirs:!1,includeSymlinks:!1})){if(a.path===r)continue;const c=U(e,a.path).replaceAll("\\","/");if(c===L)continue;if($e(c)){const f=$(a.path),d=Ce(f,c);for(const u of Ne(c))s.has(u)&&s.get(u)!==d&&Z.warn(`partial name "${u}" is declared by multiple files — last one wins. Use distinct names or fully-qualified includes.`),s.set(u,d);continue}if(c.endsWith(Oe)){const f=$(a.path);i.push({binary:null,isRaw:!0,rawText:f,relativePath:c});continue}if(Le(c)){const f=$(a.path);i.push({binary:null,isRaw:!1,rawText:f,relativePath:c});continue}const p=$(a.path,{buffer:!0});i.push({binary:p,isRaw:!1,rawText:null,relativePath:c})}const l=a=>{const c={...a.builtins,...a.options},p={},f={};for(const u of i){const y=u.relativePath;let w,C,O=!1;if(u.binary)w=u.binary;else if(u.isRaw)w=u.rawText??"";else{const Q=u.rawText??"",h=be(Q,V=>X(V));if(h.frontmatter){if(h.frontmatter.skip!==void 0&&M(h.frontmatter.skip,c,y)||h.frontmatter.if!==void 0&&!M(h.frontmatter.if,c,y))continue;typeof h.frontmatter.to=="string"&&(C=v(h.frontmatter.to,{filename:`${y}#frontmatter.to`,partials:s,scope:c})),h.frontmatter.force===!0&&(O=!0)}w=v(h.body,{filename:y,partials:s,scope:c})}const W=Ue(C??ge(we(y),c));ze(p,W,w),O&&(f[W]={force:!0})}const d={files:p};return Object.keys(f).length>0&&(d.filesMeta=f),d};return{about:{description:n.description??`Moon-format template at ${e}`,name:n.title??t},destination:n.destination,options:o,produce:l}},Ne=e=>{const t=P(e),r=J(t),n=new Set([r,t]);if(r.startsWith("_")){n.add(r.replace(/^_+/,""));const o=t.slice(0,t.length-r.length);n.add(`${o}${r.replace(/^_+/,"")}`)}return[...n]};export{Ge as loadMoonTemplate};
|