view-contracts 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +297 -0
- package/cli-contract.yaml +201 -0
- package/dist/view-contracts.bundle.mjs +808 -0
- package/dist/view-contracts.bundle.mjs.map +7 -0
- package/docs/cli-reference.md +239 -0
- package/package.json +94 -0
- package/renderers/compose/README.md +8 -0
- package/renderers/react/README.md +10 -0
- package/renderers/react/routes.yaml +27 -0
- package/renderers/swiftui/README.md +8 -0
- package/spec/ui-dsl.linter-rules.json +90 -0
- package/spec/ui-dsl.meta.json +113 -0
- package/spec/ui-dsl.schema.json +738 -0
- package/src/generated/schema/allowed-components.ts +36 -0
- package/src/generated/schema/dsl-properties.ts +63 -0
- package/src/generated/schema/index.ts +4 -0
- package/src/generated/schema/schema-document.ts +33 -0
- package/src/generated/schema/tokens.ts +19 -0
- package/src/renderer/react/runtime/actionRuntime.ts +26 -0
- package/src/renderer/react/runtime/components.tsx +216 -0
- package/src/renderer/react/runtime/index.ts +4 -0
- package/src/renderer/react/runtime/shared.tsx +53 -0
- package/src/renderer/react/runtime/style.ts +69 -0
- package/src/renderer/react/runtime/theme.css +68 -0
- package/src/renderer/react/runtime/types.ts +46 -0
|
@@ -0,0 +1,808 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __banner_createRequire } from 'module';
|
|
3
|
+
const require = __banner_createRequire(import.meta.url);
|
|
4
|
+
var fi=Object.create;var Kn=Object.defineProperty;var di=Object.getOwnPropertyDescriptor;var mi=Object.getOwnPropertyNames;var hi=Object.getPrototypeOf,gi=Object.prototype.hasOwnProperty;var Ne=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):o)(function(o){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var ge=(o,e)=>()=>{try{return e||o((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}};var wi=(o,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of mi(e))!gi.call(o,r)&&r!==t&&Kn(o,r,{get:()=>e[r],enumerable:!(i=di(e,r))||i.enumerable});return o};var xi=(o,e,t)=>(t=o!=null?fi(hi(o)):{},wi(e||!o||!o.__esModule?Kn(t,"default",{value:o,enumerable:!0}):t,o));var Re=ge(yn=>{var Ze=class extends Error{constructor(e,t,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},xn=class extends Ze{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};yn.CommanderError=Ze;yn.InvalidArgumentError=xn});var en=ge(vn=>{var{InvalidArgumentError:yi}=Re(),_n=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,i)=>{if(!this.argChoices.includes(t))throw new yi(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,i):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function _i(o){let e=o.name()+(o.variadic===!0?"...":"");return o.required?"<"+e+">":"["+e+"]"}vn.Argument=_n;vn.humanReadableArgName=_i});var bn=ge(An=>{var{humanReadableArgName:vi}=en(),Cn=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(r=>!r._hidden),i=e._getHelpCommand();return i&&!i._hidden&&t.push(i),this.sortSubcommands&&t.sort((r,a)=>r.name().localeCompare(a.name())),t}compareOptions(e,t){let i=r=>r.short?r.short.replace(/^-/,""):r.long.replace(/^--/,"");return i(e).localeCompare(i(t))}visibleOptions(e){let t=e.options.filter(r=>!r.hidden),i=e._getHelpOption();if(i&&!i.hidden){let r=i.short&&e._findOption(i.short),a=i.long&&e._findOption(i.long);!r&&!a?t.push(i):i.long&&!a?t.push(e.createOption(i.long,i.description)):i.short&&!r&&t.push(e.createOption(i.short,i.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let i=e.parent;i;i=i.parent){let r=i.options.filter(a=>!a.hidden);t.push(...r)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(i=>vi(i)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((i,r)=>Math.max(i,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(r)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((i,r)=>Math.max(i,this.displayWidth(t.styleOptionTerm(t.optionTerm(r)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((i,r)=>Math.max(i,this.displayWidth(t.styleOptionTerm(t.optionTerm(r)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((i,r)=>Math.max(i,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(r)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let i="";for(let r=e.parent;r;r=r.parent)i=r.name()+" "+i;return i+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let i=`(${t.join(", ")})`;return e.description?`${e.description} ${i}`:i}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let i=`(${t.join(", ")})`;return e.description?`${e.description} ${i}`:i}return e.description}formatItemList(e,t,i){return t.length===0?[]:[i.styleTitle(e),...t,""]}groupItems(e,t,i){let r=new Map;return e.forEach(a=>{let c=i(a);r.has(c)||r.set(c,[])}),t.forEach(a=>{let c=i(a);r.has(c)||r.set(c,[]),r.get(c).push(a)}),r}formatHelp(e,t){let i=t.padWidth(e,t),r=t.helpWidth??80;function a(u,f){return t.formatItem(u,i,f,t)}let c=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""],l=t.commandDescription(e);l.length>0&&(c=c.concat([t.boxWrap(t.styleCommandDescription(l),r),""]));let p=t.visibleArguments(e).map(u=>a(t.styleArgumentTerm(t.argumentTerm(u)),t.styleArgumentDescription(t.argumentDescription(u))));if(c=c.concat(this.formatItemList("Arguments:",p,t)),this.groupItems(e.options,t.visibleOptions(e),u=>u.helpGroupHeading??"Options:").forEach((u,f)=>{let E=u.map(k=>a(t.styleOptionTerm(t.optionTerm(k)),t.styleOptionDescription(t.optionDescription(k))));c=c.concat(this.formatItemList(f,E,t))}),t.showGlobalOptions){let u=t.visibleGlobalOptions(e).map(f=>a(t.styleOptionTerm(t.optionTerm(f)),t.styleOptionDescription(t.optionDescription(f))));c=c.concat(this.formatItemList("Global Options:",u,t))}return this.groupItems(e.commands,t.visibleCommands(e),u=>u.helpGroup()||"Commands:").forEach((u,f)=>{let E=u.map(k=>a(t.styleSubcommandTerm(t.subcommandTerm(k)),t.styleSubcommandDescription(t.subcommandDescription(k))));c=c.concat(this.formatItemList(f,E,t))}),c.join(`
|
|
5
|
+
`)}displayWidth(e){return zn(e).length}styleTitle(e){return e}styleUsage(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t==="[command]"?this.styleSubcommandText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleCommandText(t)).join(" ")}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleSubcommandText(t)).join(" ")}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,i,r){let c=" ".repeat(2);if(!i)return c+e;let l=e.padEnd(t+e.length-r.displayWidth(e)),p=2,h=(this.helpWidth??80)-t-p-2,u;return h<this.minWidthToWrap||r.preformatted(i)?u=i:u=r.boxWrap(i,h).replace(/\n/g,`
|
|
6
|
+
`+" ".repeat(t+p)),c+l+" ".repeat(p)+u.replace(/\n/g,`
|
|
7
|
+
${c}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let i=e.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,a=[];return i.forEach(c=>{let l=c.match(r);if(l===null){a.push("");return}let p=[l.shift()],m=this.displayWidth(p[0]);l.forEach(h=>{let u=this.displayWidth(h);if(m+u<=t){p.push(h),m+=u;return}a.push(p.join(""));let f=h.trimStart();p=[f],m=this.displayWidth(f)}),a.push(p.join(""))}),a.join(`
|
|
8
|
+
`)}};function zn(o){let e=/\x1b\[\d*(;\d*)*m/g;return o.replace(e,"")}An.Help=Cn;An.stripColor=zn});var In=ge(Sn=>{var{InvalidArgumentError:Ci}=Re(),On=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let i=Ai(e);this.short=i.shortFlag,this.long=i.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e=="string"&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,i)=>{if(!this.argChoices.includes(t))throw new Ci(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,i):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?Xn(this.name().replace(/^no-/,"")):Xn(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},En=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,i)=>{this.positiveOptions.has(i)&&this.dualOptions.add(i)})}valueFromOption(e,t){let i=t.attributeName();if(!this.dualOptions.has(i))return!0;let r=this.negativeOptions.get(i).presetArg,a=r!==void 0?r:!1;return t.negate===(a===e)}};function Xn(o){return o.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function Ai(o){let e,t,i=/^-[^-]$/,r=/^--[^-]/,a=o.split(/[ |,]+/).concat("guard");if(i.test(a[0])&&(e=a.shift()),r.test(a[0])&&(t=a.shift()),!e&&i.test(a[0])&&(e=a.shift()),!e&&r.test(a[0])&&(e=t,t=a.shift()),a[0].startsWith("-")){let c=a[0],l=`option creation failed due to '${c}' in option flags '${o}'`;throw/^-[^-][^-]/.test(c)?new Error(`${l}
|
|
9
|
+
- a short flag is a single dash and a single character
|
|
10
|
+
- either use a single dash and a single character (for a short flag)
|
|
11
|
+
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`):i.test(c)?new Error(`${l}
|
|
12
|
+
- too many short flags`):r.test(c)?new Error(`${l}
|
|
13
|
+
- too many long flags`):new Error(`${l}
|
|
14
|
+
- unrecognised flag format`)}if(e===void 0&&t===void 0)throw new Error(`option creation failed due to no flags found in '${o}'.`);return{shortFlag:e,longFlag:t}}Sn.Option=On;Sn.DualOptions=En});var Zn=ge(Qn=>{function bi(o,e){if(Math.abs(o.length-e.length)>3)return Math.max(o.length,e.length);let t=[];for(let i=0;i<=o.length;i++)t[i]=[i];for(let i=0;i<=e.length;i++)t[0][i]=i;for(let i=1;i<=e.length;i++)for(let r=1;r<=o.length;r++){let a=1;o[r-1]===e[i-1]?a=0:a=1,t[r][i]=Math.min(t[r-1][i]+1,t[r][i-1]+1,t[r-1][i-1]+a),r>1&&i>1&&o[r-1]===e[i-2]&&o[r-2]===e[i-1]&&(t[r][i]=Math.min(t[r][i],t[r-2][i-2]+1))}return t[o.length][e.length]}function Oi(o,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=o.startsWith("--");t&&(o=o.slice(2),e=e.map(c=>c.slice(2)));let i=[],r=3,a=.4;return e.forEach(c=>{if(c.length<=1)return;let l=bi(o,c),p=Math.max(o.length,c.length);(p-l)/p>a&&(l<r?(r=l,i=[c]):l===r&&i.push(c))}),i.sort((c,l)=>c.localeCompare(l)),t&&(i=i.map(c=>`--${c}`)),i.length>1?`
|
|
15
|
+
(Did you mean one of ${i.join(", ")}?)`:i.length===1?`
|
|
16
|
+
(Did you mean ${i[0]}?)`:""}Qn.suggestSimilar=Oi});var it=ge(Rn=>{var Ei=Ne("node:events").EventEmitter,Tn=Ne("node:child_process"),le=Ne("node:path"),nn=Ne("node:fs"),M=Ne("node:process"),{Argument:Si,humanReadableArgName:Ii}=en(),{CommanderError:kn}=Re(),{Help:Ti,stripColor:ki}=bn(),{Option:et,DualOptions:Pi}=In(),{suggestSimilar:nt}=Zn(),Pn=class o extends Ei{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:t=>M.stdout.write(t),writeErr:t=>M.stderr.write(t),outputError:(t,i)=>i(t),getOutHelpWidth:()=>M.stdout.isTTY?M.stdout.columns:void 0,getErrHelpWidth:()=>M.stderr.isTTY?M.stderr.columns:void 0,getOutHasColors:()=>Nn()??(M.stdout.isTTY&&M.stdout.hasColors?.()),getErrHasColors:()=>Nn()??(M.stderr.isTTY&&M.stderr.hasColors?.()),stripColor:t=>ki(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,i){let r=t,a=i;typeof r=="object"&&r!==null&&(a=r,r=null),a=a||{};let[,c,l]=e.match(/([^ ]+) *(.*)/),p=this.createCommand(c);return r&&(p.description(r),p._executableHandler=!0),a.isDefault&&(this._defaultCommandName=p._name),p._hidden=!!(a.noHelp||a.hidden),p._executableFile=a.executableFile||null,l&&p.arguments(l),this._registerCommand(p),p.parent=this,p.copyInheritedSettings(this),r?this:p}createCommand(e){return new o(e)}createHelp(){return Object.assign(new Ti,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...e},this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name
|
|
17
|
+
- specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new Si(e,t)}argument(e,t,i,r){let a=this.createArgument(e,t);return typeof i=="function"?a.default(r).argParser(i):a.default(i),this.addArgument(a),this}arguments(e){return e.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t?.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e=="boolean")return this._addImplicitHelpCommand=e,e&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let i=e??"help [command]",[,r,a]=i.match(/([^ ]+) *(.*)/),c=t??"display help for command",l=this.createCommand(r);return l.helpOption(!1),a&&l.arguments(a),c&&l.description(c),this._addImplicitHelpCommand=!0,this._helpCommand=l,(e||t)&&this._initCommandGroup(l),this}addHelpCommand(e,t){return typeof e!="object"?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this._initCommandGroup(e),this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){let i=["preSubcommand","preAction","postAction"];if(!i.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
|
|
18
|
+
Expecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,i){this._exitCallback&&this._exitCallback(new kn(e,t,i)),M.exit(e)}action(e){let t=i=>{let r=this.registeredArguments.length,a=i.slice(0,r);return this._storeOptionsAsProperties?a[r]=this:a[r]=this.opts(),a.push(this),e.apply(this,a)};return this._actionHandler=t,this}createOption(e,t){return new et(e,t)}_callParseArg(e,t,i,r){try{return e.parseArg(t,i)}catch(a){if(a.code==="commander.invalidArgument"){let c=`${r} ${a.message}`;this.error(c,{exitCode:a.exitCode,code:a.code})}throw a}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let i=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${i}'
|
|
19
|
+
- already used by option '${t.flags}'`)}this._initOptionGroup(e),this.options.push(e)}_registerCommand(e){let t=r=>[r.name()].concat(r.aliases()),i=t(e).find(r=>this._findCommand(r));if(i){let r=t(this._findCommand(i)).join("|"),a=t(e).join("|");throw new Error(`cannot add command '${a}' as already have command '${r}'`)}this._initCommandGroup(e),this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),i=e.attributeName();if(e.negate){let a=e.long.replace(/^--no-/,"--");this._findOption(a)||this.setOptionValueWithSource(i,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(i,e.defaultValue,"default");let r=(a,c,l)=>{a==null&&e.presetArg!==void 0&&(a=e.presetArg);let p=this.getOptionValue(i);a!==null&&e.parseArg?a=this._callParseArg(e,a,p,c):a!==null&&e.variadic&&(a=e._collectValue(a,p)),a==null&&(e.negate?a=!1:e.isBoolean()||e.optional?a=!0:a=""),this.setOptionValueWithSource(i,a,l)};return this.on("option:"+t,a=>{let c=`error: option '${e.flags}' argument '${a}' is invalid.`;r(a,c,"cli")}),e.envVar&&this.on("optionEnv:"+t,a=>{let c=`error: option '${e.flags}' value '${a}' from env '${e.envVar}' is invalid.`;r(a,c,"env")}),this}_optionEx(e,t,i,r,a){if(typeof t=="object"&&t instanceof et)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let c=this.createOption(t,i);if(c.makeOptionMandatory(!!e.mandatory),typeof r=="function")c.default(a).argParser(r);else if(r instanceof RegExp){let l=r;r=(p,m)=>{let h=l.exec(p);return h?h[0]:m},c.default(a).argParser(r)}else c.default(r);return this.addOption(c)}option(e,t,i,r){return this._optionEx({},e,t,i,r)}requiredOption(e,t,i,r){return this._optionEx({mandatory:!0},e,t,i,r)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,i){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=i,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(i=>{i.getOptionValueSource(e)!==void 0&&(t=i.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},e===void 0&&t.from===void 0){M.versions?.electron&&(t.from="electron");let r=M.execArgv??[];(r.includes("-e")||r.includes("--eval")||r.includes("-p")||r.includes("--print"))&&(t.from="eval")}e===void 0&&(e=M.argv),this.rawArgs=e.slice();let i;switch(t.from){case void 0:case"node":this._scriptPath=e[1],i=e.slice(2);break;case"electron":M.defaultApp?(this._scriptPath=e[1],i=e.slice(2)):i=e.slice(1);break;case"user":i=e.slice(0);break;case"eval":i=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",i}parse(e,t){this._prepareForParse();let i=this._prepareUserArgs(e,t);return this._parseCommand([],i),this}async parseAsync(e,t){this._prepareForParse();let i=this._prepareUserArgs(e,t);return await this._parseCommand([],i),this}_prepareForParse(){this._savedState===null?this.saveStateBeforeParse():this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
|
|
20
|
+
- either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(e,t,i){if(nn.existsSync(e))return;let r=t?`searched for local subcommand relative to directory '${t}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",a=`'${e}' does not exist
|
|
21
|
+
- if '${i}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
22
|
+
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
23
|
+
- ${r}`;throw new Error(a)}_executeSubCommand(e,t){t=t.slice();let i=!1,r=[".js",".ts",".tsx",".mjs",".cjs"];function a(h,u){let f=le.resolve(h,u);if(nn.existsSync(f))return f;if(r.includes(le.extname(u)))return;let E=r.find(k=>nn.existsSync(`${f}${k}`));if(E)return`${f}${E}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let c=e._executableFile||`${this._name}-${e._name}`,l=this._executableDir||"";if(this._scriptPath){let h;try{h=nn.realpathSync(this._scriptPath)}catch{h=this._scriptPath}l=le.resolve(le.dirname(h),l)}if(l){let h=a(l,c);if(!h&&!e._executableFile&&this._scriptPath){let u=le.basename(this._scriptPath,le.extname(this._scriptPath));u!==this._name&&(h=a(l,`${u}-${e._name}`))}c=h||c}i=r.includes(le.extname(c));let p;M.platform!=="win32"?i?(t.unshift(c),t=tt(M.execArgv).concat(t),p=Tn.spawn(M.argv[0],t,{stdio:"inherit"})):p=Tn.spawn(c,t,{stdio:"inherit"}):(this._checkForMissingExecutable(c,l,e._name),t.unshift(c),t=tt(M.execArgv).concat(t),p=Tn.spawn(M.execPath,t,{stdio:"inherit"})),p.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(u=>{M.on(u,()=>{p.killed===!1&&p.exitCode===null&&p.kill(u)})});let m=this._exitCallback;p.on("close",h=>{h=h??1,m?m(new kn(h,"commander.executeSubCommandAsync","(close)")):M.exit(h)}),p.on("error",h=>{if(h.code==="ENOENT")this._checkForMissingExecutable(c,l,e._name);else if(h.code==="EACCES")throw new Error(`'${c}' not executable`);if(!m)M.exit(1);else{let u=new kn(1,"commander.executeSubCommandAsync","(error)");u.nestedError=h,m(u)}}),this.runningCommand=p}_dispatchSubcommand(e,t,i){let r=this._findCommand(e);r||this.help({error:!0}),r._prepareForParse();let a;return a=this._chainOrCallSubCommandHook(a,r,"preSubcommand"),a=this._chainOrCall(a,()=>{if(r._executableHandler)this._executeSubCommand(r,t.concat(i));else return r._parseCommand(t,i)}),a}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(i,r,a)=>{let c=r;if(r!==null&&i.parseArg){let l=`error: command-argument value '${r}' is invalid for argument '${i.name()}'.`;c=this._callParseArg(i,r,a,l)}return c};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((i,r)=>{let a=i.defaultValue;i.variadic?r<this.args.length?(a=this.args.slice(r),i.parseArg&&(a=a.reduce((c,l)=>e(i,l,c),i.defaultValue))):a===void 0&&(a=[]):r<this.args.length&&(a=this.args[r],i.parseArg&&(a=e(i,a,i.defaultValue))),t[r]=a}),this.processedArgs=t}_chainOrCall(e,t){return e?.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let i=e,r=[];return this._getCommandAndAncestors().reverse().filter(a=>a._lifeCycleHooks[t]!==void 0).forEach(a=>{a._lifeCycleHooks[t].forEach(c=>{r.push({hookedCommand:a,callback:c})})}),t==="postAction"&&r.reverse(),r.forEach(a=>{i=this._chainOrCall(i,()=>a.callback(a.hookedCommand,this))}),i}_chainOrCallSubCommandHook(e,t,i){let r=e;return this._lifeCycleHooks[i]!==void 0&&this._lifeCycleHooks[i].forEach(a=>{r=this._chainOrCall(r,()=>a(this,t))}),r}_parseCommand(e,t){let i=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(i.operands),t=i.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(i.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r=()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},a=`command:${this.name()}`;if(this._actionHandler){r(),this._processArguments();let c;return c=this._chainOrCallHooks(c,"preAction"),c=this._chainOrCall(c,()=>this._actionHandler(this.processedArgs)),this.parent&&(c=this._chainOrCall(c,()=>{this.parent.emit(a,e,t)})),c=this._chainOrCallHooks(c,"postAction"),c}if(this.parent?.listenerCount(a))r(),this._processArguments(),this.parent.emit(a,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(r(),this._processArguments())}else this.commands.length?(r(),this.help({error:!0})):(r(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(i=>{let r=i.attributeName();return this.getOptionValue(r)===void 0?!1:this.getOptionValueSource(r)!=="default"});e.filter(i=>i.conflictsWith.length>0).forEach(i=>{let r=e.find(a=>i.conflictsWith.includes(a.attributeName()));r&&this._conflictingOption(i,r)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],i=[],r=t;function a(h){return h.length>1&&h[0]==="-"}let c=h=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(h)?!this._getCommandAndAncestors().some(u=>u.options.map(f=>f.short).some(f=>/^-\d$/.test(f))):!1,l=null,p=null,m=0;for(;m<e.length||p;){let h=p??e[m++];if(p=null,h==="--"){r===i&&r.push(h),r.push(...e.slice(m));break}if(l&&(!a(h)||c(h))){this.emit(`option:${l.name()}`,h);continue}if(l=null,a(h)){let u=this._findOption(h);if(u){if(u.required){let f=e[m++];f===void 0&&this.optionMissingArgument(u),this.emit(`option:${u.name()}`,f)}else if(u.optional){let f=null;m<e.length&&(!a(e[m])||c(e[m]))&&(f=e[m++]),this.emit(`option:${u.name()}`,f)}else this.emit(`option:${u.name()}`);l=u.variadic?u:null;continue}}if(h.length>2&&h[0]==="-"&&h[1]!=="-"){let u=this._findOption(`-${h[1]}`);if(u){u.required||u.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${u.name()}`,h.slice(2)):(this.emit(`option:${u.name()}`),p=`-${h.slice(2)}`);continue}}if(/^--[^=]+=/.test(h)){let u=h.indexOf("="),f=this._findOption(h.slice(0,u));if(f&&(f.required||f.optional)){this.emit(`option:${f.name()}`,h.slice(u+1));continue}}if(r===t&&a(h)&&!(this.commands.length===0&&c(h))&&(r=i),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&i.length===0){if(this._findCommand(h)){t.push(h),i.push(...e.slice(m));break}else if(this._getHelpCommand()&&h===this._getHelpCommand().name()){t.push(h,...e.slice(m));break}else if(this._defaultCommandName){i.push(h,...e.slice(m));break}}if(this._passThroughOptions){r.push(h,...e.slice(m));break}r.push(h)}return{operands:t,unknown:i}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let i=0;i<t;i++){let r=this.options[i].attributeName();e[r]=r===this._versionOptionName?this._version:this[r]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
|
|
24
|
+
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
25
|
+
`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
|
|
26
|
+
`),this.outputHelp({error:!0}));let i=t||{},r=i.exitCode||1,a=i.code||"commander.error";this._exit(r,a,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in M.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,M.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new Pi(this.options),t=i=>this.getOptionValue(i)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(i));this.options.filter(i=>i.implied!==void 0&&t(i.attributeName())&&e.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach(i=>{Object.keys(i.implied).filter(r=>!t(r)).forEach(r=>{this.setOptionValueWithSource(r,i.implied[r],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let i=c=>{let l=c.attributeName(),p=this.getOptionValue(l),m=this.options.find(u=>u.negate&&l===u.attributeName()),h=this.options.find(u=>!u.negate&&l===u.attributeName());return m&&(m.presetArg===void 0&&p===!1||m.presetArg!==void 0&&p===m.presetArg)?m:h||c},r=c=>{let l=i(c),p=l.attributeName();return this.getOptionValueSource(p)==="env"?`environment variable '${l.envVar}'`:`option '${l.flags}'`},a=`error: ${r(e)} cannot be used with ${r(t)}`;this.error(a,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let r=[],a=this;do{let c=a.createHelp().visibleOptions(a).filter(l=>l.long).map(l=>l.long);r=r.concat(c),a=a.parent}while(a&&!a._enablePositionalOptions);t=nt(e,r)}let i=`error: unknown option '${e}'${t}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,i=t===1?"":"s",a=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${i} but got ${e.length}.`;this.error(a,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let r=[];this.createHelp().visibleCommands(this).forEach(a=>{r.push(a.name()),a.alias()&&r.push(a.alias())}),t=nt(e,r)}let i=`error: unknown command '${e}'${t}`;this.error(i,{code:"commander.unknownCommand"})}version(e,t,i){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",i=i||"output the version number";let r=this.createOption(t,i);return this._versionOptionName=r.attributeName(),this._registerOption(r),this.on("option:"+r.name(),()=>{this._outputConfiguration.writeOut(`${e}
|
|
27
|
+
`),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let i=this.parent?._findCommand(e);if(i){let r=[i.name()].concat(i.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${r}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(i=>Ii(i));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}helpGroup(e){return e===void 0?this._helpGroupHeading??"":(this._helpGroupHeading=e,this)}commandsGroup(e){return e===void 0?this._defaultCommandGroup??"":(this._defaultCommandGroup=e,this)}optionsGroup(e){return e===void 0?this._defaultOptionGroup??"":(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=le.basename(e,le.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),i=this._getOutputContext(e);t.prepareContext({error:i.error,helpWidth:i.helpWidth,outputHasColors:i.hasColors});let r=t.formatHelp(this,t);return i.hasColors?r:this._outputConfiguration.stripColor(r)}_getOutputContext(e){e=e||{};let t=!!e.error,i,r,a;return t?(i=l=>this._outputConfiguration.writeErr(l),r=this._outputConfiguration.getErrHasColors(),a=this._outputConfiguration.getErrHelpWidth()):(i=l=>this._outputConfiguration.writeOut(l),r=this._outputConfiguration.getOutHasColors(),a=this._outputConfiguration.getOutHelpWidth()),{error:t,write:l=>(r||(l=this._outputConfiguration.stripColor(l)),i(l)),hasColors:r,helpWidth:a}}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let i=this._getOutputContext(e),r={error:i.error,write:i.write,command:this};this._getCommandAndAncestors().reverse().forEach(c=>c.emit("beforeAllHelp",r)),this.emit("beforeHelp",r);let a=this.helpInformation({error:i.error});if(t&&(a=t(a),typeof a!="string"&&!Buffer.isBuffer(a)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(a),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",r),this._getCommandAndAncestors().forEach(c=>c.emit("afterAllHelp",r))}helpOption(e,t){return typeof e=="boolean"?(e?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??"-h, --help",t??"display help for command"),(e||t)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(M.exitCode??0);t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let i=["beforeAll","before","after","afterAll"];if(!i.includes(e))throw new Error(`Unexpected value for position to addHelpText.
|
|
28
|
+
Expecting one of '${i.join("', '")}'`);let r=`${e}Help`;return this.on(r,a=>{let c;typeof t=="function"?c=t({error:a.error,command:a.command}):c=t,c&&a.write(`${c}
|
|
29
|
+
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(r=>t.is(r))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function tt(o){return o.map(e=>{if(!e.startsWith("--inspect"))return e;let t,i="127.0.0.1",r="9229",a;return(a=e.match(/^(--inspect(-brk)?)$/))!==null?t=a[1]:(a=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=a[1],/^\d+$/.test(a[3])?r=a[3]:i=a[3]):(a=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=a[1],i=a[3],r=a[4]),t&&r!=="0"?`${t}=${i}:${parseInt(r)+1}`:e})}function Nn(){if(M.env.NO_COLOR||M.env.FORCE_COLOR==="0"||M.env.FORCE_COLOR==="false")return!1;if(M.env.FORCE_COLOR||M.env.CLICOLOR_FORCE!==void 0)return!0}Rn.Command=Pn;Rn.useColor=Nn});var at=ge(ne=>{var{Argument:rt}=en(),{Command:$n}=it(),{CommanderError:Ni,InvalidArgumentError:ot}=Re(),{Help:Ri}=bn(),{Option:st}=In();ne.program=new $n;ne.createCommand=o=>new $n(o);ne.createOption=(o,e)=>new st(o,e);ne.createArgument=(o,e)=>new rt(o,e);ne.Command=$n;ne.Option=st;ne.Argument=rt;ne.Help=Ri;ne.CommanderError=Ni;ne.InvalidArgumentError=ot;ne.InvalidOptionArgumentError=ot});var ct=xi(at(),1),{program:oo,createCommand:so,createArgument:ao,createOption:co,CommanderError:lo,InvalidArgumentError:uo,InvalidOptionArgumentError:po,Command:lt,Argument:fo,Option:mo,Help:ho}=ct.default;var ut=`# yaml-language-server: $schema=./node_modules/cli-contracts/schemas/cli-contract.schema.json
|
|
30
|
+
cli_contracts: 0.1.0
|
|
31
|
+
|
|
32
|
+
info:
|
|
33
|
+
title: view-contracts CLI
|
|
34
|
+
version: 0.1.0
|
|
35
|
+
description: >-
|
|
36
|
+
Contract-first UI design toolchain. Compiles restricted view-contract TSX
|
|
37
|
+
to language-neutral View IR and renders platform targets (React, SwiftUI, Compose).
|
|
38
|
+
|
|
39
|
+
artifact_slots:
|
|
40
|
+
openapi-specs:
|
|
41
|
+
direction: read
|
|
42
|
+
description: OpenAPI screen contracts
|
|
43
|
+
view-sources:
|
|
44
|
+
direction: read
|
|
45
|
+
description: Restricted .view.tsx design definitions
|
|
46
|
+
generated-react:
|
|
47
|
+
direction: write
|
|
48
|
+
description: Generated React components
|
|
49
|
+
bindings:
|
|
50
|
+
direction: read
|
|
51
|
+
description: view-bindings.yaml bridge registry input
|
|
52
|
+
|
|
53
|
+
command_sets:
|
|
54
|
+
view-contracts:
|
|
55
|
+
summary: View contract compiler and renderer toolchain.
|
|
56
|
+
executable: view-contracts
|
|
57
|
+
|
|
58
|
+
global_options:
|
|
59
|
+
- name: help
|
|
60
|
+
aliases: [h]
|
|
61
|
+
description: Show help and exit.
|
|
62
|
+
schema:
|
|
63
|
+
type: boolean
|
|
64
|
+
|
|
65
|
+
- name: version
|
|
66
|
+
aliases: [V]
|
|
67
|
+
description: Print version and exit.
|
|
68
|
+
schema:
|
|
69
|
+
type: boolean
|
|
70
|
+
|
|
71
|
+
commands:
|
|
72
|
+
compile:
|
|
73
|
+
summary: Compile .view.tsx files to View IR.
|
|
74
|
+
description: >-
|
|
75
|
+
Parses restricted view-contract TSX via the TypeScript AST, validates
|
|
76
|
+
allowed components and expressions, and holds View IR in memory.
|
|
77
|
+
usage:
|
|
78
|
+
- view-contracts compile
|
|
79
|
+
- view-contracts compile -c view-contracts.config.yaml
|
|
80
|
+
options:
|
|
81
|
+
- name: config
|
|
82
|
+
aliases: [c]
|
|
83
|
+
description: Path to view-contracts.config.yaml (discovered upward from cwd when omitted).
|
|
84
|
+
value_name: path
|
|
85
|
+
schema:
|
|
86
|
+
type: string
|
|
87
|
+
file:
|
|
88
|
+
mode: read
|
|
89
|
+
media_type: application/yaml
|
|
90
|
+
encoding: utf-8
|
|
91
|
+
exits:
|
|
92
|
+
'0':
|
|
93
|
+
description: Compilation succeeded.
|
|
94
|
+
'1':
|
|
95
|
+
description: Compilation failed.
|
|
96
|
+
|
|
97
|
+
render.react:
|
|
98
|
+
summary: Generate React components from View IR.
|
|
99
|
+
description: Compiles views in memory and emits production React to generated/react/.
|
|
100
|
+
usage:
|
|
101
|
+
- view-contracts render react
|
|
102
|
+
- view-contracts render react -c view-contracts.config.yaml
|
|
103
|
+
options:
|
|
104
|
+
- name: config
|
|
105
|
+
aliases: [c]
|
|
106
|
+
description: Path to view-contracts.config.yaml (discovered upward from cwd when omitted).
|
|
107
|
+
value_name: path
|
|
108
|
+
schema:
|
|
109
|
+
type: string
|
|
110
|
+
exits:
|
|
111
|
+
'0':
|
|
112
|
+
description: Render succeeded.
|
|
113
|
+
'1':
|
|
114
|
+
description: Render failed.
|
|
115
|
+
|
|
116
|
+
render.bridge:
|
|
117
|
+
summary: Generate view \u2194 ViewModel bridge registry.
|
|
118
|
+
description: Emits src/generated/view-bridge.generated.ts from view-bindings.yaml.
|
|
119
|
+
usage:
|
|
120
|
+
- view-contracts render bridge
|
|
121
|
+
- view-contracts render bridge -c view-contracts.config.yaml
|
|
122
|
+
options:
|
|
123
|
+
- name: config
|
|
124
|
+
aliases: [c]
|
|
125
|
+
description: Path to view-contracts.config.yaml (discovered upward from cwd when omitted).
|
|
126
|
+
value_name: path
|
|
127
|
+
schema:
|
|
128
|
+
type: string
|
|
129
|
+
exits:
|
|
130
|
+
'0':
|
|
131
|
+
description: Bridge registry generated.
|
|
132
|
+
'1':
|
|
133
|
+
description: Generation failed.
|
|
134
|
+
|
|
135
|
+
build:
|
|
136
|
+
summary: Full view pipeline (compile + render runtime + render react + bridge).
|
|
137
|
+
description: >-
|
|
138
|
+
Compiles views in memory, copies React runtime to generated/, emits
|
|
139
|
+
React components and bridge registry, and scaffolds .vite/ dev files.
|
|
140
|
+
usage:
|
|
141
|
+
- view-contracts build
|
|
142
|
+
- view-contracts build -c view-contracts.config.yaml
|
|
143
|
+
options:
|
|
144
|
+
- name: config
|
|
145
|
+
aliases: [c]
|
|
146
|
+
description: Path to view-contracts.config.yaml (discovered upward from cwd when omitted).
|
|
147
|
+
value_name: path
|
|
148
|
+
schema:
|
|
149
|
+
type: string
|
|
150
|
+
exits:
|
|
151
|
+
'0':
|
|
152
|
+
description: Build succeeded.
|
|
153
|
+
'1':
|
|
154
|
+
description: Build failed.
|
|
155
|
+
|
|
156
|
+
contracts.generate:
|
|
157
|
+
summary: Generate ViewModel types from OpenAPI via micro-contracts.
|
|
158
|
+
description: Delegates to micro-contracts generate using micro-contracts.config.yaml.
|
|
159
|
+
usage:
|
|
160
|
+
- view-contracts contracts generate
|
|
161
|
+
- view-contracts contracts generate -c view-contracts.config.yaml
|
|
162
|
+
options:
|
|
163
|
+
- name: config
|
|
164
|
+
aliases: [c]
|
|
165
|
+
description: Path to view-contracts.config.yaml (discovered upward from cwd when omitted).
|
|
166
|
+
value_name: path
|
|
167
|
+
schema:
|
|
168
|
+
type: string
|
|
169
|
+
exits:
|
|
170
|
+
'0':
|
|
171
|
+
description: Generation succeeded.
|
|
172
|
+
'1':
|
|
173
|
+
description: Generation failed.
|
|
174
|
+
|
|
175
|
+
contracts.check:
|
|
176
|
+
summary: Lint OpenAPI screen contracts via micro-contracts.
|
|
177
|
+
description: Delegates to micro-contracts lint.
|
|
178
|
+
usage:
|
|
179
|
+
- view-contracts contracts check
|
|
180
|
+
- view-contracts contracts check -c view-contracts.config.yaml
|
|
181
|
+
options:
|
|
182
|
+
- name: config
|
|
183
|
+
aliases: [c]
|
|
184
|
+
description: Path to view-contracts.config.yaml (discovered upward from cwd when omitted).
|
|
185
|
+
value_name: path
|
|
186
|
+
schema:
|
|
187
|
+
type: string
|
|
188
|
+
exits:
|
|
189
|
+
'0':
|
|
190
|
+
description: Lint passed.
|
|
191
|
+
'1':
|
|
192
|
+
description: Lint failed.
|
|
193
|
+
|
|
194
|
+
catalog.build:
|
|
195
|
+
summary: Build static catalog HTML for design review.
|
|
196
|
+
description: >-
|
|
197
|
+
Renders all registered views with mock ViewModels into a single HTML file
|
|
198
|
+
for design review, screenshot baselines, and accessibility checks.
|
|
199
|
+
usage:
|
|
200
|
+
- view-contracts catalog build
|
|
201
|
+
- view-contracts catalog build -c view-contracts.config.yaml
|
|
202
|
+
- view-contracts catalog build -o dist/catalog.html
|
|
203
|
+
options:
|
|
204
|
+
- name: config
|
|
205
|
+
aliases: [c]
|
|
206
|
+
description: Path to view-contracts.config.yaml (discovered upward from cwd when omitted).
|
|
207
|
+
value_name: path
|
|
208
|
+
schema:
|
|
209
|
+
type: string
|
|
210
|
+
- name: output
|
|
211
|
+
aliases: [o]
|
|
212
|
+
description: Output HTML path (defaults to dist/catalog.html next to bindings).
|
|
213
|
+
value_name: path
|
|
214
|
+
schema:
|
|
215
|
+
type: string
|
|
216
|
+
file:
|
|
217
|
+
mode: write
|
|
218
|
+
media_type: text/html
|
|
219
|
+
encoding: utf-8
|
|
220
|
+
exits:
|
|
221
|
+
'0':
|
|
222
|
+
description: Catalog built.
|
|
223
|
+
files:
|
|
224
|
+
- path: dist/catalog.html
|
|
225
|
+
required: false
|
|
226
|
+
media_type: text/html
|
|
227
|
+
encoding: utf-8
|
|
228
|
+
'1':
|
|
229
|
+
description: Build failed.
|
|
230
|
+
`,pt=`{
|
|
231
|
+
"cli_contracts": "0.1.0",
|
|
232
|
+
"info": {
|
|
233
|
+
"title": "view-contracts CLI",
|
|
234
|
+
"version": "0.1.0",
|
|
235
|
+
"description": "Contract-first UI design toolchain. Compiles restricted view-contract TSX to language-neutral View IR and renders platform targets (React, SwiftUI, Compose)."
|
|
236
|
+
},
|
|
237
|
+
"artifact_slots": {
|
|
238
|
+
"openapi-specs": {
|
|
239
|
+
"direction": "read",
|
|
240
|
+
"description": "OpenAPI screen contracts"
|
|
241
|
+
},
|
|
242
|
+
"view-sources": {
|
|
243
|
+
"direction": "read",
|
|
244
|
+
"description": "Restricted .view.tsx design definitions"
|
|
245
|
+
},
|
|
246
|
+
"generated-react": {
|
|
247
|
+
"direction": "write",
|
|
248
|
+
"description": "Generated React components"
|
|
249
|
+
},
|
|
250
|
+
"bindings": {
|
|
251
|
+
"direction": "read",
|
|
252
|
+
"description": "view-bindings.yaml bridge registry input"
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
"command_sets": {
|
|
256
|
+
"view-contracts": {
|
|
257
|
+
"summary": "View contract compiler and renderer toolchain.",
|
|
258
|
+
"executable": "view-contracts",
|
|
259
|
+
"global_options": [
|
|
260
|
+
{
|
|
261
|
+
"name": "help",
|
|
262
|
+
"aliases": [
|
|
263
|
+
"h"
|
|
264
|
+
],
|
|
265
|
+
"description": "Show help and exit.",
|
|
266
|
+
"schema": {
|
|
267
|
+
"type": "boolean"
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
"name": "version",
|
|
272
|
+
"aliases": [
|
|
273
|
+
"V"
|
|
274
|
+
],
|
|
275
|
+
"description": "Print version and exit.",
|
|
276
|
+
"schema": {
|
|
277
|
+
"type": "boolean"
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
],
|
|
281
|
+
"commands": {
|
|
282
|
+
"compile": {
|
|
283
|
+
"summary": "Compile .view.tsx files to View IR.",
|
|
284
|
+
"description": "Parses restricted view-contract TSX via the TypeScript AST, validates allowed components and expressions, and holds View IR in memory.",
|
|
285
|
+
"usage": [
|
|
286
|
+
"view-contracts compile",
|
|
287
|
+
"view-contracts compile -c view-contracts.config.yaml"
|
|
288
|
+
],
|
|
289
|
+
"options": [
|
|
290
|
+
{
|
|
291
|
+
"name": "config",
|
|
292
|
+
"aliases": [
|
|
293
|
+
"c"
|
|
294
|
+
],
|
|
295
|
+
"description": "Path to view-contracts.config.yaml (discovered upward from cwd when omitted).",
|
|
296
|
+
"value_name": "path",
|
|
297
|
+
"schema": {
|
|
298
|
+
"type": "string"
|
|
299
|
+
},
|
|
300
|
+
"file": {
|
|
301
|
+
"mode": "read",
|
|
302
|
+
"media_type": "application/yaml",
|
|
303
|
+
"encoding": "utf-8"
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
],
|
|
307
|
+
"exits": {
|
|
308
|
+
"0": {
|
|
309
|
+
"description": "Compilation succeeded."
|
|
310
|
+
},
|
|
311
|
+
"1": {
|
|
312
|
+
"description": "Compilation failed."
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
"render.react": {
|
|
317
|
+
"summary": "Generate React components from View IR.",
|
|
318
|
+
"description": "Compiles views in memory and emits production React to generated/react/.",
|
|
319
|
+
"usage": [
|
|
320
|
+
"view-contracts render react",
|
|
321
|
+
"view-contracts render react -c view-contracts.config.yaml"
|
|
322
|
+
],
|
|
323
|
+
"options": [
|
|
324
|
+
{
|
|
325
|
+
"name": "config",
|
|
326
|
+
"aliases": [
|
|
327
|
+
"c"
|
|
328
|
+
],
|
|
329
|
+
"description": "Path to view-contracts.config.yaml (discovered upward from cwd when omitted).",
|
|
330
|
+
"value_name": "path",
|
|
331
|
+
"schema": {
|
|
332
|
+
"type": "string"
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
],
|
|
336
|
+
"exits": {
|
|
337
|
+
"0": {
|
|
338
|
+
"description": "Render succeeded."
|
|
339
|
+
},
|
|
340
|
+
"1": {
|
|
341
|
+
"description": "Render failed."
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
},
|
|
345
|
+
"render.bridge": {
|
|
346
|
+
"summary": "Generate view \u2194 ViewModel bridge registry.",
|
|
347
|
+
"description": "Emits src/generated/view-bridge.generated.ts from view-bindings.yaml.",
|
|
348
|
+
"usage": [
|
|
349
|
+
"view-contracts render bridge",
|
|
350
|
+
"view-contracts render bridge -c view-contracts.config.yaml"
|
|
351
|
+
],
|
|
352
|
+
"options": [
|
|
353
|
+
{
|
|
354
|
+
"name": "config",
|
|
355
|
+
"aliases": [
|
|
356
|
+
"c"
|
|
357
|
+
],
|
|
358
|
+
"description": "Path to view-contracts.config.yaml (discovered upward from cwd when omitted).",
|
|
359
|
+
"value_name": "path",
|
|
360
|
+
"schema": {
|
|
361
|
+
"type": "string"
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
],
|
|
365
|
+
"exits": {
|
|
366
|
+
"0": {
|
|
367
|
+
"description": "Bridge registry generated."
|
|
368
|
+
},
|
|
369
|
+
"1": {
|
|
370
|
+
"description": "Generation failed."
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
},
|
|
374
|
+
"build": {
|
|
375
|
+
"summary": "Full view pipeline (compile + render runtime + render react + bridge).",
|
|
376
|
+
"description": "Compiles views in memory, copies React runtime to generated/, emits React components and bridge registry, and scaffolds .vite/ dev files.",
|
|
377
|
+
"usage": [
|
|
378
|
+
"view-contracts build",
|
|
379
|
+
"view-contracts build -c view-contracts.config.yaml"
|
|
380
|
+
],
|
|
381
|
+
"options": [
|
|
382
|
+
{
|
|
383
|
+
"name": "config",
|
|
384
|
+
"aliases": [
|
|
385
|
+
"c"
|
|
386
|
+
],
|
|
387
|
+
"description": "Path to view-contracts.config.yaml (discovered upward from cwd when omitted).",
|
|
388
|
+
"value_name": "path",
|
|
389
|
+
"schema": {
|
|
390
|
+
"type": "string"
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
],
|
|
394
|
+
"exits": {
|
|
395
|
+
"0": {
|
|
396
|
+
"description": "Build succeeded."
|
|
397
|
+
},
|
|
398
|
+
"1": {
|
|
399
|
+
"description": "Build failed."
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
},
|
|
403
|
+
"contracts.generate": {
|
|
404
|
+
"summary": "Generate ViewModel types from OpenAPI via micro-contracts.",
|
|
405
|
+
"description": "Delegates to micro-contracts generate using micro-contracts.config.yaml.",
|
|
406
|
+
"usage": [
|
|
407
|
+
"view-contracts contracts generate",
|
|
408
|
+
"view-contracts contracts generate -c view-contracts.config.yaml"
|
|
409
|
+
],
|
|
410
|
+
"options": [
|
|
411
|
+
{
|
|
412
|
+
"name": "config",
|
|
413
|
+
"aliases": [
|
|
414
|
+
"c"
|
|
415
|
+
],
|
|
416
|
+
"description": "Path to view-contracts.config.yaml (discovered upward from cwd when omitted).",
|
|
417
|
+
"value_name": "path",
|
|
418
|
+
"schema": {
|
|
419
|
+
"type": "string"
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
],
|
|
423
|
+
"exits": {
|
|
424
|
+
"0": {
|
|
425
|
+
"description": "Generation succeeded."
|
|
426
|
+
},
|
|
427
|
+
"1": {
|
|
428
|
+
"description": "Generation failed."
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
},
|
|
432
|
+
"contracts.check": {
|
|
433
|
+
"summary": "Lint OpenAPI screen contracts via micro-contracts.",
|
|
434
|
+
"description": "Delegates to micro-contracts lint.",
|
|
435
|
+
"usage": [
|
|
436
|
+
"view-contracts contracts check",
|
|
437
|
+
"view-contracts contracts check -c view-contracts.config.yaml"
|
|
438
|
+
],
|
|
439
|
+
"options": [
|
|
440
|
+
{
|
|
441
|
+
"name": "config",
|
|
442
|
+
"aliases": [
|
|
443
|
+
"c"
|
|
444
|
+
],
|
|
445
|
+
"description": "Path to view-contracts.config.yaml (discovered upward from cwd when omitted).",
|
|
446
|
+
"value_name": "path",
|
|
447
|
+
"schema": {
|
|
448
|
+
"type": "string"
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
],
|
|
452
|
+
"exits": {
|
|
453
|
+
"0": {
|
|
454
|
+
"description": "Lint passed."
|
|
455
|
+
},
|
|
456
|
+
"1": {
|
|
457
|
+
"description": "Lint failed."
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
},
|
|
461
|
+
"catalog.build": {
|
|
462
|
+
"summary": "Build static catalog HTML for design review.",
|
|
463
|
+
"description": "Renders all registered views with mock ViewModels into a single HTML file for design review, screenshot baselines, and accessibility checks.",
|
|
464
|
+
"usage": [
|
|
465
|
+
"view-contracts catalog build",
|
|
466
|
+
"view-contracts catalog build -c view-contracts.config.yaml",
|
|
467
|
+
"view-contracts catalog build -o dist/catalog.html"
|
|
468
|
+
],
|
|
469
|
+
"options": [
|
|
470
|
+
{
|
|
471
|
+
"name": "config",
|
|
472
|
+
"aliases": [
|
|
473
|
+
"c"
|
|
474
|
+
],
|
|
475
|
+
"description": "Path to view-contracts.config.yaml (discovered upward from cwd when omitted).",
|
|
476
|
+
"value_name": "path",
|
|
477
|
+
"schema": {
|
|
478
|
+
"type": "string"
|
|
479
|
+
}
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
"name": "output",
|
|
483
|
+
"aliases": [
|
|
484
|
+
"o"
|
|
485
|
+
],
|
|
486
|
+
"description": "Output HTML path (defaults to dist/catalog.html next to bindings).",
|
|
487
|
+
"value_name": "path",
|
|
488
|
+
"schema": {
|
|
489
|
+
"type": "string"
|
|
490
|
+
},
|
|
491
|
+
"file": {
|
|
492
|
+
"mode": "write",
|
|
493
|
+
"media_type": "text/html",
|
|
494
|
+
"encoding": "utf-8"
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
],
|
|
498
|
+
"exits": {
|
|
499
|
+
"0": {
|
|
500
|
+
"description": "Catalog built.",
|
|
501
|
+
"files": [
|
|
502
|
+
{
|
|
503
|
+
"path": "dist/catalog.html",
|
|
504
|
+
"required": false,
|
|
505
|
+
"media_type": "text/html",
|
|
506
|
+
"encoding": "utf-8"
|
|
507
|
+
}
|
|
508
|
+
]
|
|
509
|
+
},
|
|
510
|
+
"1": {
|
|
511
|
+
"description": "Build failed."
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}`;function ft(o,e){let t=new lt;t.name("view-contracts").version(e,"-V, --version").description("View contract compiler and renderer toolchain."),t.command("compile").description("Compile .view.tsx files to View IR.").option("-c, --config <path>","Path to view-contracts.config.yaml (discovered upward from cwd when omitted).").action(async(c,l)=>{await o.compile(c,l.optsWithGlobals())});let i=t.command("render");i.command("react").description("Generate React components from View IR.").option("-c, --config <path>","Path to view-contracts.config.yaml (discovered upward from cwd when omitted).").action(async(c,l)=>{await o.renderReact(c,l.optsWithGlobals())}),i.command("bridge").description("Generate view \u2194 ViewModel bridge registry.").option("-c, --config <path>","Path to view-contracts.config.yaml (discovered upward from cwd when omitted).").action(async(c,l)=>{await o.renderBridge(c,l.optsWithGlobals())}),t.command("build").description("Full view pipeline (compile + render runtime + render react + bridge).").option("-c, --config <path>","Path to view-contracts.config.yaml (discovered upward from cwd when omitted).").action(async(c,l)=>{await o.build(c,l.optsWithGlobals())});let r=t.command("contracts");return r.command("generate").description("Generate ViewModel types from OpenAPI via micro-contracts.").option("-c, --config <path>","Path to view-contracts.config.yaml (discovered upward from cwd when omitted).").action(async(c,l)=>{await o.contractsGenerate(c,l.optsWithGlobals())}),r.command("check").description("Lint OpenAPI screen contracts via micro-contracts.").option("-c, --config <path>","Path to view-contracts.config.yaml (discovered upward from cwd when omitted).").action(async(c,l)=>{await o.contractsCheck(c,l.optsWithGlobals())}),t.command("catalog").command("build").description("Build static catalog HTML for design review.").option("-c, --config <path>","Path to view-contracts.config.yaml (discovered upward from cwd when omitted).").option("-o, --output <path>","Output HTML path (defaults to dist/catalog.html next to bindings).").action(async(c,l)=>{await o.catalogBuild(c,l.optsWithGlobals())}),t.command("extract").description("Extract contract specification for this CLI tool.").argument("[commands...]","Command IDs to extract. Use dot notation.").option("-a, --all","Extract all commands.",!1).option("--include-meta","Include extraction metadata.",!0).option("-F, --format <format>","Output format (yaml or json).","yaml").action(async(c,l,p)=>{c.length===0&&!l.all&&(process.stderr.write(JSON.stringify({code:"INVALID_ARGS",message:"Specify command IDs or use --all"})+`
|
|
519
|
+
`),process.exit(2));let m=l.format||"yaml",h=JSON.parse(pt),u=l.all?[]:c;if(u.length===0)if(m==="json"){let f={};l.includeMeta&&(f._meta={source:"embedded",type:"cli-contracts/extract",extractedAt:new Date().toISOString(),specVersion:h.cli_contracts??"0.1.0",commands:["view-contracts.compile","view-contracts.render.react","view-contracts.render.bridge","view-contracts.build","view-contracts.contracts.generate","view-contracts.contracts.check","view-contracts.catalog.build"]}),Object.assign(f,h),process.stdout.write(JSON.stringify(f,null,2)+`
|
|
520
|
+
`)}else{let f=[];if(f.push("# view-contracts extract"),f.push("# source: embedded"),f.push("# type: cli-contracts/command-extract"),l.includeMeta){f.push("---"),f.push("source: embedded"),f.push("type: cli-contracts/command-extract"),f.push("extractedAt: "+new Date().toISOString()),f.push("spec_version: "+(h.cli_contracts??"0.1.0")),f.push("commands:");for(let E of["view-contracts.compile","view-contracts.render.react","view-contracts.render.bridge","view-contracts.build","view-contracts.contracts.generate","view-contracts.contracts.check","view-contracts.catalog.build"])f.push(" - "+E)}f.push("---"),f.push(ut),process.stdout.write(f.join(`
|
|
521
|
+
`)+`
|
|
522
|
+
`)}else{let f={cli_contracts:h.cli_contracts,info:h.info,command_sets:{}},E=f.command_sets;for(let[k,L]of Object.entries(h.command_sets??{})){let te=L.commands;if(!te)continue;let D={};for(let[G,ie]of Object.entries(te)){let J=k+"."+G;u.some(W=>W===G||W===J||G.startsWith(W+"."))&&(D[G]=ie)}if(Object.keys(D).length>0){let G={...L};G.commands=D,E[k]=G}}h.components&&(f.components=h.components),process.stdout.write(JSON.stringify(f,null,2)+`
|
|
523
|
+
`)}process.exit(0)}),t}import{writeFile as Ur,mkdir as Jr}from"node:fs/promises";import{resolve as xe,dirname as li}from"node:path";import{spawn as ui}from"node:child_process";import{fileURLToPath as Yr}from"node:url";import{readFile as Ui}from"node:fs/promises";import{basename as Ji,relative as Yi,resolve as Ki}from"node:path";import{readFileSync as Di}from"node:fs";import{dirname as gt,resolve as Fi}from"node:path";import S from"typescript";var dt=new Set(["App","Box","Button","Checkbox","Column","Divider","Drawer","Field","Form","Heading","Icon","IconButton","Image","Link","List","ListItem","Modal","Page","Popover","Progress","Radio","Row","SafeArea","ScrollArea","Select","Spacer","Spinner","Stack","Switch","Text","TextArea","TextInput","Tooltip"]);import{readFileSync as $i}from"node:fs";import{resolve as Li}from"node:path";import F from"typescript";function Ln(o,e){let t=new Map;for(let i of o.statements){if(!F.isImportDeclaration(i)||!i.importClause?.namedBindings||!F.isStringLiteral(i.moduleSpecifier)||!F.isNamedImports(i.importClause.namedBindings))continue;let r=i.moduleSpecifier.text;r.endsWith(".tsx")||(r=`${r}.tsx`);let a=Li(e,r);for(let c of i.importClause.namedBindings.elements)t.set(c.name.text,a)}return t}function Mi(o){if(!F.isObjectBindingPattern(o.name)||o.name.elements.length===0)return null;let e=o.name.elements[0];return!F.isBindingElement(e)||!F.isIdentifier(e.name)?null:e.name.text}function Vi(o){if(F.isParenthesizedExpression(o))return o.expression;if(F.isJsxElement(o)||F.isJsxSelfClosingElement(o)||F.isJsxFragment(o))return o;if(F.isBlock(o)&&o.statements.length===1){let e=o.statements[0];if(F.isReturnStatement(e)&&e.expression)return F.isParenthesizedExpression(e.expression)?e.expression.expression:e.expression}return null}function mt(o){if(!F.isIdentifier(o.expression)||o.expression.text!=="view"||o.arguments.length!==1)return null;let e=o.arguments[0];if(!F.isArrowFunction(e)&&!F.isFunctionExpression(e))return null;let t="__noop";if(e.parameters.length===1){let r=Mi(e.parameters[0]);if(r)t=r;else if(F.isIdentifier(e.parameters[0].name))t=e.parameters[0].name.text;else return null}else if(e.parameters.length>1)return null;let i=Vi(e.body);return i?{paramName:t,jsxRoot:i}:null}function ht(o,e){let t=$i(o,"utf-8"),i=F.createSourceFile(o,t,F.ScriptTarget.Latest,!0,F.ScriptKind.TSX),r=null;function a(c){if(F.isVariableStatement(c))for(let l of c.declarationList.declarations){if(!F.isIdentifier(l.name)||l.name.text!==e||!l.initializer||!F.isCallExpression(l.initializer))continue;let p=mt(l.initializer);p&&(r=p)}if(F.isExportAssignment(c)&&c.isExportEquals===!1&&c.expression&&F.isCallExpression(c.expression)){let l=mt(c.expression);l&&e==="default"&&(r=l)}F.forEachChild(c,a)}return a(i),r}function Mn(o){return o.join(".")}function Vn(o){if(S.isIdentifier(o))return[o.text];if(S.isPropertyAccessExpression(o)){let e=Vn(o.expression);return e?[...e,o.name.text]:null}return null}function ji(o){return typeof o=="object"&&o!==null&&"kind"in o&&o.kind==="binding"}function wt(o,e){if(e.length===0)return o;let t=e.join(".");return{kind:"binding",path:o.path?`${o.path}.${t}`:t,scope:o.scope}}function tn(o,e){let t=Vn(o);if(!t)return null;if(t[0]in e.propBindings)return wt(e.propBindings[t[0]],t.slice(1));if(t[0]===e.vmName)return{kind:"binding",path:Mn(t.slice(1))};let i=e.scopes[e.scopes.length-1];return i&&t[0]===i?{kind:"binding",path:Mn(t.slice(1)),scope:i}:null}function Hi(o,e){let t,i={};for(let r of o.properties){if(!S.isPropertyAssignment(r)||!S.isIdentifier(r.name))continue;let a=r.name.text;if(a==="name"&&S.isStringLiteral(r.initializer)){t=r.initializer.text;continue}if(a==="params"&&S.isObjectLiteralExpression(r.initializer))for(let c of r.initializer.properties){if(!S.isPropertyAssignment(c)||!S.isIdentifier(c.name))continue;let l=rn(c.initializer,e);l!==null&&(i[c.name.text]=l)}}return t?Object.keys(i).length>0?{kind:"action",name:t,params:i}:{kind:"action",name:t}:null}function rn(o,e){if(S.isStringLiteral(o)||S.isNoSubstitutionTemplateLiteral(o))return o.text;if(o.kind===S.SyntaxKind.TrueKeyword)return!0;if(o.kind===S.SyntaxKind.FalseKeyword)return!1;if(S.isNumericLiteral(o))return Number(o.text);if(o.kind===S.SyntaxKind.NullKeyword)return null;let t=tn(o,e);if(t)return t;if(S.isObjectLiteralExpression(o)){let i=Hi(o,e);if(i)return i;let r={};for(let a of o.properties){if(!S.isPropertyAssignment(a)||!S.isIdentifier(a.name))continue;let c=rn(a.initializer,e);c!==null&&(r[a.name.text]=c)}return{kind:"literal",value:r}}if(S.isArrayLiteralExpression(o)){let i=[];for(let r of o.elements){if(!S.isExpression(r))continue;let a=rn(r,e);a!==null&&i.push(a)}return i}return null}function Bi(o){return S.isIdentifier(o)?o.text:S.isPropertyAccessExpression(o)&&S.isIdentifier(o.name)?o.name.text:null}function xt(o){return o.getText()}function yt(o,e){let t=[];for(let i of o){if(S.isJsxText(i)){let r=i.getText().trim();r&&t.push({kind:"text",value:r});continue}if(S.isJsxExpression(i)&&i.expression){let r=tn(i.expression,e);if(r){t.push(r);continue}let a=_t(i.expression,e);a&&(Array.isArray(a)?t.push(...a):t.push(a));continue}if(S.isJsxElement(i)||S.isJsxSelfClosingElement(i)){let r=$e(i,e);r&&t.push(r)}}return t}function Gi(o,e){if(o.length===0)return null;let t=o[0];return t in e.propBindings?wt(e.propBindings[t],o.slice(1)):t===e.vmName?{kind:"binding",path:Mn(o.slice(1))}:null}function _t(o,e){if(S.isParenthesizedExpression(o))return _t(o.expression,e);if(S.isCallExpression(o)&&S.isPropertyAccessExpression(o.expression)){let i=Vn(o.expression.expression),r=o.expression.name.text;if(i&&r==="map"&&o.arguments.length>=1){let a=Gi(i,e);if(!a)return null;let c=o.arguments[0];if(!S.isArrowFunction(c)&&!S.isFunctionExpression(c))return e.errors.push("map callback must be an arrow function"),null;let l=c.parameters;if(l.length!==1||!S.isIdentifier(l[0].name))return e.errors.push("map callback must have a single item parameter"),null;let p=l[0].name.text,m={...e,scopes:[...e.scopes,p]},h=null,u=S.isParenthesizedExpression(c.body)?c.body.expression:c.body;if(S.isBlock(c.body))return e.errors.push("map callback body must be a JSX expression, not a block"),null;if(S.isJsxElement(u)||S.isJsxSelfClosingElement(u)?h=$e(u,m):S.isJsxFragment(u)&&(h=Dn(u,m)),!h)return null;let f;if(S.isJsxElement(u)||S.isJsxSelfClosingElement(u)){let E=S.isJsxElement(u)?u.openingElement.attributes:u.attributes;for(let k of E.properties)if(!(!S.isJsxAttribute(k)||xt(k.name)!=="key"||!k.initializer)&&S.isJsxExpression(k.initializer)&&k.initializer.expression){let L=tn(k.initializer.expression,m);L&&(f=L)}}return{kind:"map",source:a,item:p,key:f,body:h}}}if(S.isJsxElement(o)||S.isJsxSelfClosingElement(o))return $e(o,e);let t=tn(o,e);return t||null}function Dn(o,e){return{kind:"fragment",children:yt(o.children,e)}}function qi(o,e,t){let i=t.viewImports.get(o);if(!i)return null;let r=ht(i,o);if(!r)return t.errors.push(`View component "${o}" is imported but has no view() export`),null;let a=Di(i,"utf-8"),c=S.createSourceFile(i,a,S.ScriptTarget.Latest,!0,S.ScriptKind.TSX),l=Ln(c,gt(i)),p=new Map([...t.viewImports,...l]),m={...t.propBindings};for(let[u,f]of Object.entries(e))ji(f)&&(m[u]=f);let h={...t,vmName:r.paramName,propBindings:m,scopes:[],viewImports:p};return S.isJsxElement(r.jsxRoot)||S.isJsxSelfClosingElement(r.jsxRoot)?$e(r.jsxRoot,h):S.isJsxFragment(r.jsxRoot)?Dn(r.jsxRoot,h):null}function $e(o,e){let t=S.isJsxElement(o)?o.openingElement:o,i=Bi(t.tagName);if(!i)return e.errors.push("Unsupported JSX tag expression"),null;let r={};for(let c of t.attributes.properties){if(!S.isJsxAttribute(c))continue;let l=xt(c.name);if(l!=="key"){if(!c.initializer){r[l]=!0;continue}if(S.isStringLiteral(c.initializer)){r[l]=c.initializer.text;continue}if(S.isJsxExpression(c.initializer)&&c.initializer.expression){let p=rn(c.initializer.expression,e);p!==null&&(r[l]=p)}}}if(!e.allowedComponents.has(i)){let c=qi(i,r,e);return c||(e.errors.push(`Component "${i}" is not in the allowed registry`),null)}let a=S.isJsxElement(o)?yt(o.children,e):[];return{kind:"component",name:i,props:r,children:a}}function Wi(o){let e=null;function t(i){if(S.isCallExpression(i)&&S.isIdentifier(i.expression)&&i.expression.text==="screen"&&i.arguments.length===1&&(S.isArrowFunction(i.arguments[0])||S.isFunctionExpression(i.arguments[0]))){let r=i.arguments[0],a="unknown";if(i.typeArguments&&i.typeArguments.length===1){let l=i.typeArguments[0];S.isTypeReferenceNode(l)&&S.isIdentifier(l.typeName)&&(a=l.typeName.text)}let c=r.body;if(S.isParenthesizedExpression(c))(S.isJsxElement(c.expression)||S.isJsxSelfClosingElement(c.expression))&&(e={viewModel:a,jsxRoot:c.expression});else if(S.isJsxElement(c)||S.isJsxSelfClosingElement(c))e={viewModel:a,jsxRoot:c};else if(S.isBlock(c)&&c.statements.length===1){let l=c.statements[0];S.isReturnStatement(l)&&l.expression&&(S.isParenthesizedExpression(l.expression)?e={viewModel:a,jsxRoot:l.expression.expression}:e={viewModel:a,jsxRoot:l.expression})}}S.forEachChild(i,t)}return t(o),e}function vt(o,e,t,i={}){let r=new Set(dt);for(let u of i.allowlistExtra??[])r.add(u);let a=Fi(e),c=gt(a),l=S.createSourceFile(a,o,S.ScriptTarget.Latest,!0,S.ScriptKind.TSX),p={vmName:"vm",scopes:[],propBindings:{},errors:[],viewImports:Ln(l,c),allowedComponents:r},m=Wi(l);if(!m)return{viewModel:"unknown",exportName:t,root:{kind:"fragment",children:[]},errors:["No screen<T>() default export found"]};let h=S.isJsxElement(m.jsxRoot)||S.isJsxSelfClosingElement(m.jsxRoot)?$e(m.jsxRoot,p):S.isJsxFragment(m.jsxRoot)?Dn(m.jsxRoot,p):null;return h?{viewModel:m.viewModel,exportName:t,root:h,errors:p.errors}:(p.errors.push("screen() callback must return a single JSX root element"),{viewModel:m.viewModel,exportName:t,root:{kind:"fragment",children:[]},errors:p.errors})}async function zi(o,e={}){let t=await Ui(o.sourcePath,"utf-8"),i=o.exportName??Ji(o.sourcePath,".view.tsx"),r=vt(t,o.sourcePath,i,{allowlistExtra:e.allowlistExtra});if(r.errors.length>0)throw new Error(`Compile errors in ${o.sourcePath}:
|
|
524
|
+
${r.errors.map(a=>` - ${a}`).join(`
|
|
525
|
+
`)}`);return{version:1,source:Yi(process.cwd(),Ki(o.sourcePath)),viewModel:r.viewModel,exportName:r.exportName,root:r.root}}async function Ct(o,e={}){let t=[];for(let i of o)t.push(await zi(i,e));return t}import{access as ar,readFile as Bt}from"node:fs/promises";import{dirname as on,relative as cr,resolve as q}from"node:path";var Xi=Object.create,At=Object.defineProperty,Qi=Object.getOwnPropertyDescriptor,Zi=Object.getOwnPropertyNames,er=Object.getPrototypeOf,nr=Object.prototype.hasOwnProperty,j=(o,e)=>()=>(e||(o((e={exports:{}}).exports,e),o=null),e.exports),tr=(o,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(var r=Zi(e),a=0,c=r.length,l;a<c;a++)l=r[a],!nr.call(o,l)&&l!==t&&At(o,l,{get:(p=>e[p]).bind(null,l),enumerable:!(i=Qi(e,l))||i.enumerable});return o},ir=(o,e,t)=>(t=o!=null?Xi(er(o)):{},tr(e||!o||!o.__esModule?At(t,"default",{value:o,enumerable:!0}):t,o)),Le=j(((o,e)=>{function t(p){return typeof p>"u"||p===null}function i(p){return typeof p=="object"&&p!==null}function r(p){return Array.isArray(p)?p:t(p)?[]:[p]}function a(p,m){if(m){let h=Object.keys(m);for(let u=0,f=h.length;u<f;u+=1){let E=h[u];p[E]=m[E]}}return p}function c(p,m){let h="";for(let u=0;u<m;u+=1)h+=p;return h}function l(p){return p===0&&Number.NEGATIVE_INFINITY===1/p}e.exports.isNothing=t,e.exports.isObject=i,e.exports.toArray=r,e.exports.repeat=c,e.exports.isNegativeZero=l,e.exports.extend=a})),Me=j(((o,e)=>{function t(r,a){let c="",l=r.reason||"(unknown reason)";return r.mark?(r.mark.name&&(c+='in "'+r.mark.name+'" '),c+="("+(r.mark.line+1)+":"+(r.mark.column+1)+")",!a&&r.mark.snippet&&(c+=`
|
|
526
|
+
|
|
527
|
+
`+r.mark.snippet),l+" "+c):l}function i(r,a){Error.call(this),this.name="YAMLException",this.reason=r,this.mark=a,this.message=t(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}i.prototype=Object.create(Error.prototype),i.prototype.constructor=i,i.prototype.toString=function(a){return this.name+": "+t(this,a)},e.exports=i})),rr=j(((o,e)=>{var t=Le();function i(c,l,p,m,h){let u="",f="",E=Math.floor(h/2)-1;return m-l>E&&(u=" ... ",l=m-E+u.length),p-m>E&&(f=" ...",p=m+E-f.length),{str:u+c.slice(l,p).replace(/\t/g,"\u2192")+f,pos:m-l+u.length}}function r(c,l){return t.repeat(" ",l-c.length)+c}function a(c,l){if(l=Object.create(l||null),!c.buffer)return null;l.maxLength||(l.maxLength=79),typeof l.indent!="number"&&(l.indent=1),typeof l.linesBefore!="number"&&(l.linesBefore=3),typeof l.linesAfter!="number"&&(l.linesAfter=2);let p=/\r?\n|\r|\0/g,m=[0],h=[],u,f=-1;for(;u=p.exec(c.buffer);)h.push(u.index),m.push(u.index+u[0].length),c.position<=u.index&&f<0&&(f=m.length-2);f<0&&(f=m.length-1);let E="",k=Math.min(c.line+l.linesAfter,h.length).toString().length,L=l.maxLength-(l.indent+k+3);for(let D=1;D<=l.linesBefore&&!(f-D<0);D++){let G=i(c.buffer,m[f-D],h[f-D],c.position-(m[f]-m[f-D]),L);E=t.repeat(" ",l.indent)+r((c.line-D+1).toString(),k)+" | "+G.str+`
|
|
528
|
+
`+E}let te=i(c.buffer,m[f],h[f],c.position,L);E+=t.repeat(" ",l.indent)+r((c.line+1).toString(),k)+" | "+te.str+`
|
|
529
|
+
`,E+=t.repeat("-",l.indent+k+3+te.pos)+`^
|
|
530
|
+
`;for(let D=1;D<=l.linesAfter&&!(f+D>=h.length);D++){let G=i(c.buffer,m[f+D],h[f+D],c.position-(m[f]-m[f+D]),L);E+=t.repeat(" ",l.indent)+r((c.line+D+1).toString(),k)+" | "+G.str+`
|
|
531
|
+
`}return E.replace(/\n$/,"")}e.exports=a})),K=j(((o,e)=>{var t=Me(),i=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],r=["scalar","sequence","mapping"];function a(l){let p={};return l!==null&&Object.keys(l).forEach(function(m){l[m].forEach(function(h){p[String(h)]=m})}),p}function c(l,p){if(p=p||{},Object.keys(p).forEach(function(m){if(i.indexOf(m)===-1)throw new t('Unknown option "'+m+'" is met in definition of "'+l+'" YAML type.')}),this.options=p,this.tag=l,this.kind=p.kind||null,this.resolve=p.resolve||function(){return!0},this.construct=p.construct||function(m){return m},this.instanceOf=p.instanceOf||null,this.predicate=p.predicate||null,this.represent=p.represent||null,this.representName=p.representName||null,this.defaultStyle=p.defaultStyle||null,this.multi=p.multi||!1,this.styleAliases=a(p.styleAliases||null),r.indexOf(this.kind)===-1)throw new t('Unknown kind "'+this.kind+'" is specified for "'+l+'" YAML type.')}e.exports=c})),bt=j(((o,e)=>{var t=Me(),i=K();function r(l,p){let m=[];return l[p].forEach(function(h){let u=m.length;m.forEach(function(f,E){f.tag===h.tag&&f.kind===h.kind&&f.multi===h.multi&&(u=E)}),m[u]=h}),m}function a(){let l={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function p(m){m.multi?(l.multi[m.kind].push(m),l.multi.fallback.push(m)):l[m.kind][m.tag]=l.fallback[m.tag]=m}for(let m=0,h=arguments.length;m<h;m+=1)arguments[m].forEach(p);return l}function c(l){return this.extend(l)}c.prototype.extend=function(p){let m=[],h=[];if(p instanceof i)h.push(p);else if(Array.isArray(p))h=h.concat(p);else if(p&&(Array.isArray(p.implicit)||Array.isArray(p.explicit)))p.implicit&&(m=m.concat(p.implicit)),p.explicit&&(h=h.concat(p.explicit));else throw new t("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");m.forEach(function(f){if(!(f instanceof i))throw new t("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(f.loadKind&&f.loadKind!=="scalar")throw new t("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(f.multi)throw new t("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),h.forEach(function(f){if(!(f instanceof i))throw new t("Specified list of YAML types (or a single Type object) contains a non-Type object.")});let u=Object.create(c.prototype);return u.implicit=(this.implicit||[]).concat(m),u.explicit=(this.explicit||[]).concat(h),u.compiledImplicit=r(u,"implicit"),u.compiledExplicit=r(u,"explicit"),u.compiledTypeMap=a(u.compiledImplicit,u.compiledExplicit),u},e.exports=c})),Ot=j(((o,e)=>{e.exports=new(K())("tag:yaml.org,2002:str",{kind:"scalar",construct:function(t){return t!==null?t:""}})})),Et=j(((o,e)=>{e.exports=new(K())("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(t){return t!==null?t:[]}})})),St=j(((o,e)=>{e.exports=new(K())("tag:yaml.org,2002:map",{kind:"mapping",construct:function(t){return t!==null?t:{}}})})),It=j(((o,e)=>{e.exports=new(bt())({explicit:[Ot(),Et(),St()]})})),Tt=j(((o,e)=>{var t=K();function i(c){if(c===null)return!0;let l=c.length;return l===1&&c==="~"||l===4&&(c==="null"||c==="Null"||c==="NULL")}function r(){return null}function a(c){return c===null}e.exports=new t("tag:yaml.org,2002:null",{kind:"scalar",resolve:i,construct:r,predicate:a,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"})})),kt=j(((o,e)=>{var t=K();function i(c){if(c===null)return!1;let l=c.length;return l===4&&(c==="true"||c==="True"||c==="TRUE")||l===5&&(c==="false"||c==="False"||c==="FALSE")}function r(c){return c==="true"||c==="True"||c==="TRUE"}function a(c){return Object.prototype.toString.call(c)==="[object Boolean]"}e.exports=new t("tag:yaml.org,2002:bool",{kind:"scalar",resolve:i,construct:r,predicate:a,represent:{lowercase:function(c){return c?"true":"false"},uppercase:function(c){return c?"TRUE":"FALSE"},camelcase:function(c){return c?"True":"False"}},defaultStyle:"lowercase"})})),Pt=j(((o,e)=>{var t=Le(),i=K();function r(u){return u>=48&&u<=57||u>=65&&u<=70||u>=97&&u<=102}function a(u){return u>=48&&u<=55}function c(u){return u>=48&&u<=57}function l(u){if(u===null)return!1;let f=u.length,E=0,k=!1;if(!f)return!1;let L=u[E];if((L==="-"||L==="+")&&(L=u[++E]),L==="0"){if(E+1===f)return!0;if(L=u[++E],L==="b"){for(E++;E<f;E++){if(L=u[E],L!=="0"&&L!=="1")return!1;k=!0}return k&&Number.isFinite(p(u))}if(L==="x"){for(E++;E<f;E++){if(!r(u.charCodeAt(E)))return!1;k=!0}return k&&Number.isFinite(p(u))}if(L==="o"){for(E++;E<f;E++){if(!a(u.charCodeAt(E)))return!1;k=!0}return k&&Number.isFinite(p(u))}}for(;E<f;E++){if(!c(u.charCodeAt(E)))return!1;k=!0}return k?Number.isFinite(p(u)):!1}function p(u){let f=u,E=1,k=f[0];if((k==="-"||k==="+")&&(k==="-"&&(E=-1),f=f.slice(1),k=f[0]),f==="0")return 0;if(k==="0"){if(f[1]==="b")return E*parseInt(f.slice(2),2);if(f[1]==="x")return E*parseInt(f.slice(2),16);if(f[1]==="o")return E*parseInt(f.slice(2),8)}return E*parseInt(f,10)}function m(u){return p(u)}function h(u){return Object.prototype.toString.call(u)==="[object Number]"&&u%1===0&&!t.isNegativeZero(u)}e.exports=new i("tag:yaml.org,2002:int",{kind:"scalar",resolve:l,construct:m,predicate:h,represent:{binary:function(u){return u>=0?"0b"+u.toString(2):"-0b"+u.toString(2).slice(1)},octal:function(u){return u>=0?"0o"+u.toString(8):"-0o"+u.toString(8).slice(1)},decimal:function(u){return u.toString(10)},hexadecimal:function(u){return u>=0?"0x"+u.toString(16).toUpperCase():"-0x"+u.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}})})),Nt=j(((o,e)=>{var t=Le(),i=K(),r=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),a=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function c(u){return u===null||!r.test(u)?!1:Number.isFinite(parseFloat(u,10))?!0:a.test(u)}function l(u){let f=u.toLowerCase(),E=f[0]==="-"?-1:1;return"+-".indexOf(f[0])>=0&&(f=f.slice(1)),f===".inf"?E===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:f===".nan"?NaN:E*parseFloat(f,10)}var p=/^[-+]?[0-9]+e/;function m(u,f){if(isNaN(u))switch(f){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===u)switch(f){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===u)switch(f){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(t.isNegativeZero(u))return"-0.0";let E=u.toString(10);return p.test(E)?E.replace("e",".e"):E}function h(u){return Object.prototype.toString.call(u)==="[object Number]"&&(u%1!==0||t.isNegativeZero(u))}e.exports=new i("tag:yaml.org,2002:float",{kind:"scalar",resolve:c,construct:l,predicate:h,represent:m,defaultStyle:"lowercase"})})),Rt=j(((o,e)=>{e.exports=It().extend({implicit:[Tt(),kt(),Pt(),Nt()]})})),$t=j(((o,e)=>{e.exports=Rt()})),Lt=j(((o,e)=>{var t=K(),i=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),r=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function a(p){return p===null?!1:i.exec(p)!==null||r.exec(p)!==null}function c(p){let m=0,h=null,u=i.exec(p);if(u===null&&(u=r.exec(p)),u===null)throw new Error("Date resolve error");let f=+u[1],E=+u[2]-1,k=+u[3];if(!u[4])return new Date(Date.UTC(f,E,k));let L=+u[4],te=+u[5],D=+u[6];if(u[7]){for(m=u[7].slice(0,3);m.length<3;)m+="0";m=+m}if(u[9]){let ie=+u[10],J=+(u[11]||0);h=(ie*60+J)*6e4,u[9]==="-"&&(h=-h)}let G=new Date(Date.UTC(f,E,k,L,te,D,m));return h&&G.setTime(G.getTime()-h),G}function l(p){return p.toISOString()}e.exports=new t("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:a,construct:c,instanceOf:Date,represent:l})})),Mt=j(((o,e)=>{var t=K();function i(r){return r==="<<"||r===null}e.exports=new t("tag:yaml.org,2002:merge",{kind:"scalar",resolve:i})})),Vt=j(((o,e)=>{var t=K(),i=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
532
|
+
\r`;function r(p){if(p===null)return!1;let m=0,h=p.length,u=i;for(let f=0;f<h;f++){let E=u.indexOf(p.charAt(f));if(!(E>64)){if(E<0)return!1;m+=6}}return m%8===0}function a(p){let m=p.replace(/[\r\n=]/g,""),h=m.length,u=i,f=0,E=[];for(let L=0;L<h;L++)L%4===0&&L&&(E.push(f>>16&255),E.push(f>>8&255),E.push(f&255)),f=f<<6|u.indexOf(m.charAt(L));let k=h%4*6;return k===0?(E.push(f>>16&255),E.push(f>>8&255),E.push(f&255)):k===18?(E.push(f>>10&255),E.push(f>>2&255)):k===12&&E.push(f>>4&255),new Uint8Array(E)}function c(p){let m="",h=0,u=p.length,f=i;for(let k=0;k<u;k++)k%3===0&&k&&(m+=f[h>>18&63],m+=f[h>>12&63],m+=f[h>>6&63],m+=f[h&63]),h=(h<<8)+p[k];let E=u%3;return E===0?(m+=f[h>>18&63],m+=f[h>>12&63],m+=f[h>>6&63],m+=f[h&63]):E===2?(m+=f[h>>10&63],m+=f[h>>4&63],m+=f[h<<2&63],m+=f[64]):E===1&&(m+=f[h>>2&63],m+=f[h<<4&63],m+=f[64],m+=f[64]),m}function l(p){return Object.prototype.toString.call(p)==="[object Uint8Array]"}e.exports=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:r,construct:a,predicate:l,represent:c})})),Dt=j(((o,e)=>{var t=K(),i=Object.prototype.hasOwnProperty,r=Object.prototype.toString;function a(l){if(l===null)return!0;let p=[],m=l;for(let h=0,u=m.length;h<u;h+=1){let f=m[h],E=!1;if(r.call(f)!=="[object Object]")return!1;let k;for(k in f)if(i.call(f,k))if(!E)E=!0;else return!1;if(!E)return!1;if(p.indexOf(k)===-1)p.push(k);else return!1}return!0}function c(l){return l!==null?l:[]}e.exports=new t("tag:yaml.org,2002:omap",{kind:"sequence",resolve:a,construct:c})})),Ft=j(((o,e)=>{var t=K(),i=Object.prototype.toString;function r(c){if(c===null)return!0;let l=c,p=new Array(l.length);for(let m=0,h=l.length;m<h;m+=1){let u=l[m];if(i.call(u)!=="[object Object]")return!1;let f=Object.keys(u);if(f.length!==1)return!1;p[m]=[f[0],u[f[0]]]}return!0}function a(c){if(c===null)return[];let l=c,p=new Array(l.length);for(let m=0,h=l.length;m<h;m+=1){let u=l[m],f=Object.keys(u);p[m]=[f[0],u[f[0]]]}return p}e.exports=new t("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:r,construct:a})})),jt=j(((o,e)=>{var t=K(),i=Object.prototype.hasOwnProperty;function r(c){if(c===null)return!0;let l=c;for(let p in l)if(i.call(l,p)&&l[p]!==null)return!1;return!0}function a(c){return c!==null?c:{}}e.exports=new t("tag:yaml.org,2002:set",{kind:"mapping",resolve:r,construct:a})})),Fn=j(((o,e)=>{e.exports=$t().extend({implicit:[Lt(),Mt()],explicit:[Vt(),Dt(),Ft(),jt()]})})),or=j(((o,e)=>{var t=Le(),i=Me(),r=rr(),a=Fn(),c=Object.prototype.hasOwnProperty,l=1,p=2,m=3,h=4,u=1,f=2,E=3,k=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,L=/[\x85\u2028\u2029]/,te=/[,\[\]{}]/,D=/^(?:!|!!|![0-9A-Za-z-]+!)$/,G=/^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i;function ie(n){return Object.prototype.toString.call(n)}function J(n){return n===10||n===13}function W(n){return n===9||n===32}function Y(n){return n===9||n===32||n===10||n===13}function pe(n){return n===44||n===91||n===93||n===123||n===125}function ln(n){if(n>=48&&n<=57)return n-48;let d=n|32;return d>=97&&d<=102?d-97+10:-1}function un(n){return n===120?2:n===117?4:n===85?8:0}function je(n){return n>=48&&n<=57?n-48:-1}function Oe(n){switch(n){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return`
|
|
533
|
+
`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"\x85";case 95:return"\xA0";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function pn(n){return n<=65535?String.fromCharCode(n):String.fromCharCode((n-65536>>10)+55296,(n-65536&1023)+56320)}function Ee(n,d,x){d==="__proto__"?Object.defineProperty(n,d,{configurable:!0,enumerable:!0,writable:!0,value:x}):n[d]=x}var He=new Array(256),Se=new Array(256);for(let n=0;n<256;n++)He[n]=Oe(n)?1:0,Se[n]=Oe(n);function U(n,d){this.input=n,this.filename=d.filename||null,this.schema=d.schema||a,this.onWarning=d.onWarning||null,this.legacy=d.legacy||!1,this.json=d.json||!1,this.listener=d.listener||null,this.maxDepth=typeof d.maxDepth=="number"?d.maxDepth:100,this.maxMergeSeqLength=typeof d.maxMergeSeqLength=="number"?d.maxMergeSeqLength:20,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=n.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function Be(n,d){let x={name:n.filename,buffer:n.input.slice(0,-1),position:n.position,line:n.line,column:n.position-n.lineStart};return x.snippet=r(x),new i(d,x)}function P(n,d){throw Be(n,d)}function ye(n,d){n.onWarning&&n.onWarning.call(null,Be(n,d))}function re(n,d,x){let v=n.anchorMapTransactions;if(v.length!==0){let w=v[v.length-1];c.call(w,d)||(w[d]={existed:c.call(n.anchorMap,d),value:n.anchorMap[d]})}n.anchorMap[d]=x}function fn(n){n.anchorMapTransactions.push(Object.create(null))}function he(n){let d=n.anchorMapTransactions.pop(),x=n.anchorMapTransactions;if(x.length===0)return;let v=x[x.length-1],w=Object.keys(d);for(let O=0,s=w.length;O<s;O+=1){let g=w[O];c.call(v,g)||(v[g]=d[g])}}function dn(n){let d=n.anchorMapTransactions.pop(),x=Object.keys(d);for(let v=x.length-1;v>=0;v-=1){let w=d[x[v]];w.existed?n.anchorMap[x[v]]=w.value:delete n.anchorMap[x[v]]}}function Ie(n){return{position:n.position,line:n.line,lineStart:n.lineStart,lineIndent:n.lineIndent,firstTabInLine:n.firstTabInLine,tag:n.tag,anchor:n.anchor,kind:n.kind,result:n.result}}function _e(n,d){n.position=d.position,n.line=d.line,n.lineStart=d.lineStart,n.lineIndent=d.lineIndent,n.firstTabInLine=d.firstTabInLine,n.tag=d.tag,n.anchor=d.anchor,n.kind=d.kind,n.result=d.result}var Ge={YAML:function(d,x,v){d.version!==null&&P(d,"duplication of %YAML directive"),v.length!==1&&P(d,"YAML directive accepts exactly one argument");let w=/^([0-9]+)\.([0-9]+)$/.exec(v[0]);w===null&&P(d,"ill-formed argument of the YAML directive");let O=parseInt(w[1],10),s=parseInt(w[2],10);O!==1&&P(d,"unacceptable YAML version of the document"),d.version=v[0],d.checkLineBreaks=s<2,s!==1&&s!==2&&ye(d,"unsupported YAML version of the document")},TAG:function(d,x,v){let w;v.length!==2&&P(d,"TAG directive accepts exactly two arguments");let O=v[0];w=v[1],D.test(O)||P(d,"ill-formed tag handle (first argument) of the TAG directive"),c.call(d.tagMap,O)&&P(d,'there is a previously declared suffix for "'+O+'" tag handle'),G.test(w)||P(d,"ill-formed tag prefix (second argument) of the TAG directive");try{w=decodeURIComponent(w)}catch{P(d,"tag prefix is malformed: "+w)}d.tagMap[O]=w}};function X(n,d,x,v){if(d<x){let w=n.input.slice(d,x);if(v)for(let O=0,s=w.length;O<s;O+=1){let g=w.charCodeAt(O);g===9||g>=32&&g<=1114111||P(n,"expected valid JSON character")}else k.test(w)&&P(n,"the stream contains non-printable characters");n.result+=w}}function fe(n,d,x,v){t.isObject(x)||P(n,"cannot merge mappings; the provided source object is unacceptable");let w=Object.keys(x);for(let O=0,s=w.length;O<s;O+=1){let g=w[O];c.call(d,g)||(Ee(d,g,x[g]),v[g]=!0)}}function oe(n,d,x,v,w,O,s,g,b){if(Array.isArray(w)){w=Array.prototype.slice.call(w);for(let y=0,_=w.length;y<_;y+=1)Array.isArray(w[y])&&P(n,"nested arrays are not supported inside keys"),typeof w=="object"&&ie(w[y])==="[object Object]"&&(w[y]="[object Object]")}if(typeof w=="object"&&ie(w)==="[object Object]"&&(w="[object Object]"),w=String(w),d===null&&(d={}),v==="tag:yaml.org,2002:merge")if(Array.isArray(O)){O.length>n.maxMergeSeqLength&&P(n,"merge sequence length exceeded maxMergeSeqLength ("+n.maxMergeSeqLength+")");let y=new Set;for(let _=0,A=O.length;_<A;_+=1){let C=O[_];y.has(C)||(y.add(C),fe(n,d,C,x))}}else fe(n,d,O,x);else!n.json&&!c.call(x,w)&&c.call(d,w)&&(n.line=s||n.line,n.lineStart=g||n.lineStart,n.position=b||n.position,P(n,"duplicated mapping key")),Ee(d,w,O),delete x[w];return d}function ve(n){let d=n.input.charCodeAt(n.position);d===10?n.position++:d===13?(n.position++,n.input.charCodeAt(n.position)===10&&n.position++):P(n,"a line break is expected"),n.line+=1,n.lineStart=n.position,n.firstTabInLine=-1}function B(n,d,x){let v=0,w=n.input.charCodeAt(n.position);for(;w!==0;){for(;W(w);)w===9&&n.firstTabInLine===-1&&(n.firstTabInLine=n.position),w=n.input.charCodeAt(++n.position);if(d&&w===35)do w=n.input.charCodeAt(++n.position);while(w!==10&&w!==13&&w!==0);if(J(w))for(ve(n),w=n.input.charCodeAt(n.position),v++,n.lineIndent=0;w===32;)n.lineIndent++,w=n.input.charCodeAt(++n.position);else break}return x!==-1&&v!==0&&n.lineIndent<x&&ye(n,"deficient indentation"),v}function Ce(n){let d=n.position,x=n.input.charCodeAt(d);return!!((x===45||x===46)&&x===n.input.charCodeAt(d+1)&&x===n.input.charCodeAt(d+2)&&(d+=3,x=n.input.charCodeAt(d),x===0||Y(x)))}function se(n,d){d===1?n.result+=" ":d>1&&(n.result+=t.repeat(`
|
|
534
|
+
`,d-1))}function qe(n,d,x){let v,w,O,s,g,b,y=n.kind,_=n.result,A=n.input.charCodeAt(n.position);if(Y(A)||pe(A)||A===35||A===38||A===42||A===33||A===124||A===62||A===39||A===34||A===37||A===64||A===96)return!1;if(A===63||A===45){let C=n.input.charCodeAt(n.position+1);if(Y(C)||x&&pe(C))return!1}for(n.kind="scalar",n.result="",v=w=n.position,O=!1;A!==0;){if(A===58){let C=n.input.charCodeAt(n.position+1);if(Y(C)||x&&pe(C))break}else if(A===35){if(Y(n.input.charCodeAt(n.position-1)))break}else{if(n.position===n.lineStart&&Ce(n)||x&&pe(A))break;if(J(A))if(s=n.line,g=n.lineStart,b=n.lineIndent,B(n,!1,-1),n.lineIndent>=d){O=!0,A=n.input.charCodeAt(n.position);continue}else{n.position=w,n.line=s,n.lineStart=g,n.lineIndent=b;break}}O&&(X(n,v,w,!1),se(n,n.line-s),v=w=n.position,O=!1),W(A)||(w=n.position+1),A=n.input.charCodeAt(++n.position)}return X(n,v,w,!1),n.result?!0:(n.kind=y,n.result=_,!1)}function We(n,d){let x,v,w=n.input.charCodeAt(n.position);if(w!==39)return!1;for(n.kind="scalar",n.result="",n.position++,x=v=n.position;(w=n.input.charCodeAt(n.position))!==0;)if(w===39)if(X(n,x,n.position,!0),w=n.input.charCodeAt(++n.position),w===39)x=n.position,n.position++,v=n.position;else return!0;else J(w)?(X(n,x,v,!0),se(n,B(n,!1,d)),x=v=n.position):n.position===n.lineStart&&Ce(n)?P(n,"unexpected end of the document within a single quoted scalar"):(n.position++,W(w)||(v=n.position));P(n,"unexpected end of the stream within a single quoted scalar")}function Te(n,d){let x,v,w,O=n.input.charCodeAt(n.position);if(O!==34)return!1;for(n.kind="scalar",n.result="",n.position++,x=v=n.position;(O=n.input.charCodeAt(n.position))!==0;){if(O===34)return X(n,x,n.position,!0),n.position++,!0;if(O===92){if(X(n,x,n.position,!0),O=n.input.charCodeAt(++n.position),J(O))B(n,!1,d);else if(O<256&&He[O])n.result+=Se[O],n.position++;else if((w=un(O))>0){let s=w,g=0;for(;s>0;s--)O=n.input.charCodeAt(++n.position),(w=ln(O))>=0?g=(g<<4)+w:P(n,"expected hexadecimal character");n.result+=pn(g),n.position++}else P(n,"unknown escape sequence");x=v=n.position}else J(O)?(X(n,x,v,!0),se(n,B(n,!1,d)),x=v=n.position):n.position===n.lineStart&&Ce(n)?P(n,"unexpected end of the document within a double quoted scalar"):(n.position++,W(O)||(v=n.position))}P(n,"unexpected end of the stream within a double quoted scalar")}function Ue(n,d){let x=!0,v,w,O,s=n.tag,g,b=n.anchor,y,_,A,C,T=Object.create(null),I,N,R,$=n.input.charCodeAt(n.position);if($===91)y=93,C=!1,g=[];else if($===123)y=125,C=!0,g={};else return!1;for(n.anchor!==null&&re(n,n.anchor,g),$=n.input.charCodeAt(++n.position);$!==0;){if(B(n,!0,d),$=n.input.charCodeAt(n.position),$===y)return n.position++,n.tag=s,n.anchor=b,n.kind=C?"mapping":"sequence",n.result=g,!0;x?$===44&&P(n,"expected the node content, but found ','"):P(n,"missed comma between flow collection entries"),N=I=R=null,_=A=!1,$===63&&Y(n.input.charCodeAt(n.position+1))&&(_=A=!0,n.position++,B(n,!0,d)),v=n.line,w=n.lineStart,O=n.position,ce(n,d,l,!1,!0),N=n.tag,I=n.result,B(n,!0,d),$=n.input.charCodeAt(n.position),(A||n.line===v)&&$===58&&(_=!0,$=n.input.charCodeAt(++n.position),B(n,!0,d),ce(n,d,l,!1,!0),R=n.result),C?oe(n,g,T,N,I,R,v,w,O):_?g.push(oe(n,null,T,N,I,R,v,w,O)):g.push(I),B(n,!0,d),$=n.input.charCodeAt(n.position),$===44?(x=!0,$=n.input.charCodeAt(++n.position)):x=!1}P(n,"unexpected end of the stream within a flow collection")}function Je(n,d){let x,v=u,w=!1,O=!1,s=d,g=0,b=!1,y,_=n.input.charCodeAt(n.position);if(_===124)x=!1;else if(_===62)x=!0;else return!1;for(n.kind="scalar",n.result="";_!==0;)if(_=n.input.charCodeAt(++n.position),_===43||_===45)u===v?v=_===43?E:f:P(n,"repeat of a chomping mode identifier");else if((y=je(_))>=0)y===0?P(n,"bad explicit indentation width of a block scalar; it cannot be less than one"):O?P(n,"repeat of an indentation width identifier"):(s=d+y-1,O=!0);else break;if(W(_)){do _=n.input.charCodeAt(++n.position);while(W(_));if(_===35)do _=n.input.charCodeAt(++n.position);while(!J(_)&&_!==0)}for(;_!==0;){for(ve(n),n.lineIndent=0,_=n.input.charCodeAt(n.position);(!O||n.lineIndent<s)&&_===32;)n.lineIndent++,_=n.input.charCodeAt(++n.position);if(!O&&n.lineIndent>s&&(s=n.lineIndent),J(_)){g++;continue}if(!O&&s===0&&P(n,"missing indentation for block scalar"),n.lineIndent<s){v===E?n.result+=t.repeat(`
|
|
535
|
+
`,w?1+g:g):v===u&&w&&(n.result+=`
|
|
536
|
+
`);break}x?W(_)?(b=!0,n.result+=t.repeat(`
|
|
537
|
+
`,w?1+g:g)):b?(b=!1,n.result+=t.repeat(`
|
|
538
|
+
`,g+1)):g===0?w&&(n.result+=" "):n.result+=t.repeat(`
|
|
539
|
+
`,g):n.result+=t.repeat(`
|
|
540
|
+
`,w?1+g:g),w=!0,O=!0,g=0;let A=n.position;for(;!J(_)&&_!==0;)_=n.input.charCodeAt(++n.position);X(n,A,n.position,!1)}return!0}function ae(n,d){let x=n.tag,v=n.anchor,w=[],O=!1;if(n.firstTabInLine!==-1)return!1;n.anchor!==null&&re(n,n.anchor,w);let s=n.input.charCodeAt(n.position);for(;s!==0&&(n.firstTabInLine!==-1&&(n.position=n.firstTabInLine,P(n,"tab characters must not be used in indentation")),!(s!==45||!Y(n.input.charCodeAt(n.position+1))));){if(O=!0,n.position++,B(n,!0,-1)&&n.lineIndent<=d){w.push(null),s=n.input.charCodeAt(n.position);continue}let g=n.line;if(ce(n,d,m,!1,!0),w.push(n.result),B(n,!0,-1),s=n.input.charCodeAt(n.position),(n.line===g||n.lineIndent>d)&&s!==0)P(n,"bad indentation of a sequence entry");else if(n.lineIndent<d)break}return O?(n.tag=x,n.anchor=v,n.kind="sequence",n.result=w,!0):!1}function Ye(n,d,x){let v,w,O,s,g=n.tag,b=n.anchor,y={},_=Object.create(null),A=null,C=null,T=null,I=!1,N=!1;if(n.firstTabInLine!==-1)return!1;n.anchor!==null&&re(n,n.anchor,y);let R=n.input.charCodeAt(n.position);for(;R!==0;){!I&&n.firstTabInLine!==-1&&(n.position=n.firstTabInLine,P(n,"tab characters must not be used in indentation"));let $=n.input.charCodeAt(n.position+1),H=n.line;if((R===63||R===58)&&Y($))R===63?(I&&(oe(n,y,_,A,C,null,w,O,s),A=C=T=null),N=!0,I=!0,v=!0):I?(I=!1,v=!0):P(n,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),n.position+=1,R=$;else{if(w=n.line,O=n.lineStart,s=n.position,!ce(n,x,p,!1,!0))break;if(n.line===H){for(R=n.input.charCodeAt(n.position);W(R);)R=n.input.charCodeAt(++n.position);if(R===58)R=n.input.charCodeAt(++n.position),Y(R)||P(n,"a whitespace character is expected after the key-value separator within a block mapping"),I&&(oe(n,y,_,A,C,null,w,O,s),A=C=T=null),N=!0,I=!1,v=!1,A=n.tag,C=n.result;else if(N)P(n,"can not read an implicit mapping pair; a colon is missed");else return n.tag=g,n.anchor=b,!0}else if(N)P(n,"can not read a block mapping entry; a multiline key may not be an implicit key");else return n.tag=g,n.anchor=b,!0}if((n.line===H||n.lineIndent>d)&&(I&&(w=n.line,O=n.lineStart,s=n.position),ce(n,d,h,!0,v)&&(I?C=n.result:T=n.result),I||(oe(n,y,_,A,C,T,w,O,s),A=C=T=null),B(n,!0,-1),R=n.input.charCodeAt(n.position)),(n.line===H||n.lineIndent>d)&&R!==0)P(n,"bad indentation of a mapping entry");else if(n.lineIndent<d)break}return I&&oe(n,y,_,A,C,null,w,O,s),N&&(n.tag=g,n.anchor=b,n.kind="mapping",n.result=y),N}function mn(n){let d=!1,x=!1,v,w,O=n.input.charCodeAt(n.position);if(O!==33)return!1;n.tag!==null&&P(n,"duplication of a tag property"),O=n.input.charCodeAt(++n.position),O===60?(d=!0,O=n.input.charCodeAt(++n.position)):O===33?(x=!0,v="!!",O=n.input.charCodeAt(++n.position)):v="!";let s=n.position;if(d){do O=n.input.charCodeAt(++n.position);while(O!==0&&O!==62);n.position<n.length?(w=n.input.slice(s,n.position),O=n.input.charCodeAt(++n.position)):P(n,"unexpected end of the stream within a verbatim tag")}else{for(;O!==0&&!Y(O);)O===33&&(x?P(n,"tag suffix cannot contain exclamation marks"):(v=n.input.slice(s-1,n.position+1),D.test(v)||P(n,"named tag handle cannot contain such characters"),x=!0,s=n.position+1)),O=n.input.charCodeAt(++n.position);w=n.input.slice(s,n.position),te.test(w)&&P(n,"tag suffix cannot contain flow indicator characters")}w&&!G.test(w)&&P(n,"tag name cannot contain such characters: "+w);try{w=decodeURIComponent(w)}catch{P(n,"tag name is malformed: "+w)}return d?n.tag=w:c.call(n.tagMap,v)?n.tag=n.tagMap[v]+w:v==="!"?n.tag="!"+w:v==="!!"?n.tag="tag:yaml.org,2002:"+w:P(n,'undeclared tag handle "'+v+'"'),!0}function Ke(n){let d=n.input.charCodeAt(n.position);if(d!==38)return!1;n.anchor!==null&&P(n,"duplication of an anchor property"),d=n.input.charCodeAt(++n.position);let x=n.position;for(;d!==0&&!Y(d)&&!pe(d);)d=n.input.charCodeAt(++n.position);return n.position===x&&P(n,"name of an anchor node must contain at least one character"),n.anchor=n.input.slice(x,n.position),!0}function ze(n){let d=n.input.charCodeAt(n.position);if(d!==42)return!1;d=n.input.charCodeAt(++n.position);let x=n.position;for(;d!==0&&!Y(d)&&!pe(d);)d=n.input.charCodeAt(++n.position);n.position===x&&P(n,"name of an alias node must contain at least one character");let v=n.input.slice(x,n.position);return c.call(n.anchorMap,v)||P(n,'unidentified alias "'+v+'"'),n.result=n.anchorMap[v],B(n,!0,-1),!0}function hn(n,d,x,v){let w=Ie(n);return fn(n),_e(n,d),n.tag=null,n.anchor=null,n.kind=null,n.result=null,Ye(n,x,v)&&n.kind==="mapping"?(he(n),!0):(dn(n),_e(n,w),!1)}function ce(n,d,x,v,w){let O,s,g=1,b=!1,y=!1,_=null,A,C,T;n.depth>=n.maxDepth&&P(n,"nesting exceeded maxDepth ("+n.maxDepth+")"),n.depth+=1,n.listener!==null&&n.listener("open",n),n.tag=null,n.anchor=null,n.kind=null,n.result=null;let I=O=s=h===x||m===x;if(v&&B(n,!0,-1)&&(b=!0,n.lineIndent>d?g=1:n.lineIndent===d?g=0:n.lineIndent<d&&(g=-1)),g===1)for(;;){let N=n.input.charCodeAt(n.position),R=Ie(n);if(b&&(N===33&&n.tag!==null||N===38&&n.anchor!==null)||!mn(n)&&!Ke(n))break;_===null&&(_=R),B(n,!0,-1)?(b=!0,s=I,n.lineIndent>d?g=1:n.lineIndent===d?g=0:n.lineIndent<d&&(g=-1)):s=!1}if(s&&(s=b||w),g===1||h===x)if(l===x||p===x?C=d:C=d+1,T=n.position-n.lineStart,g===1)if(s&&(ae(n,T)||Ye(n,T,C))||Ue(n,C))y=!0;else{let N=n.input.charCodeAt(n.position);_!==null&&I&&!s&&N!==124&&N!==62&&hn(n,_,_.position-_.lineStart,C)||O&&Je(n,C)||We(n,C)||Te(n,C)?y=!0:ze(n)?(y=!0,(n.tag!==null||n.anchor!==null)&&P(n,"alias node should not have any properties")):qe(n,C,l===x)&&(y=!0,n.tag===null&&(n.tag="?")),n.anchor!==null&&re(n,n.anchor,n.result)}else g===0&&(y=s&&ae(n,T));if(n.tag===null)n.anchor!==null&&re(n,n.anchor,n.result);else if(n.tag==="?"){n.result!==null&&n.kind!=="scalar"&&P(n,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+n.kind+'"');for(let N=0,R=n.implicitTypes.length;N<R;N+=1)if(A=n.implicitTypes[N],A.resolve(n.result)){n.result=A.construct(n.result),n.tag=A.tag,n.anchor!==null&&re(n,n.anchor,n.result);break}}else if(n.tag!=="!"){if(c.call(n.typeMap[n.kind||"fallback"],n.tag))A=n.typeMap[n.kind||"fallback"][n.tag];else{A=null;let N=n.typeMap.multi[n.kind||"fallback"];for(let R=0,$=N.length;R<$;R+=1)if(n.tag.slice(0,N[R].tag.length)===N[R].tag){A=N[R];break}}A||P(n,"unknown tag !<"+n.tag+">"),n.result!==null&&A.kind!==n.kind&&P(n,"unacceptable node kind for !<"+n.tag+'> tag; it should be "'+A.kind+'", not "'+n.kind+'"'),A.resolve(n.result,n.tag)?(n.result=A.construct(n.result,n.tag),n.anchor!==null&&re(n,n.anchor,n.result)):P(n,"cannot resolve a node with !<"+n.tag+"> explicit tag")}return n.listener!==null&&n.listener("close",n),n.depth-=1,n.tag!==null||n.anchor!==null||y}function gn(n){let d=n.position,x=!1,v;for(n.version=null,n.checkLineBreaks=n.legacy,n.tagMap=Object.create(null),n.anchorMap=Object.create(null);(v=n.input.charCodeAt(n.position))!==0&&(B(n,!0,-1),v=n.input.charCodeAt(n.position),!(n.lineIndent>0||v!==37));){x=!0,v=n.input.charCodeAt(++n.position);let w=n.position;for(;v!==0&&!Y(v);)v=n.input.charCodeAt(++n.position);let O=n.input.slice(w,n.position),s=[];for(O.length<1&&P(n,"directive name must not be less than one character in length");v!==0;){for(;W(v);)v=n.input.charCodeAt(++n.position);if(v===35){do v=n.input.charCodeAt(++n.position);while(v!==0&&!J(v));break}if(J(v))break;for(w=n.position;v!==0&&!Y(v);)v=n.input.charCodeAt(++n.position);s.push(n.input.slice(w,n.position))}v!==0&&ve(n),c.call(Ge,O)?Ge[O](n,O,s):ye(n,'unknown document directive "'+O+'"')}if(B(n,!0,-1),n.lineIndent===0&&n.input.charCodeAt(n.position)===45&&n.input.charCodeAt(n.position+1)===45&&n.input.charCodeAt(n.position+2)===45?(n.position+=3,B(n,!0,-1)):x&&P(n,"directives end mark is expected"),ce(n,n.lineIndent-1,h,!1,!0),B(n,!0,-1),n.checkLineBreaks&&L.test(n.input.slice(d,n.position))&&ye(n,"non-ASCII line breaks are interpreted as content"),n.documents.push(n.result),n.position===n.lineStart&&Ce(n)){n.input.charCodeAt(n.position)===46&&(n.position+=3,B(n,!0,-1));return}n.position<n.length-1&&P(n,"end of the stream or a document separator is expected")}function Xe(n,d){n=String(n),d=d||{},n.length!==0&&(n.charCodeAt(n.length-1)!==10&&n.charCodeAt(n.length-1)!==13&&(n+=`
|
|
541
|
+
`),n.charCodeAt(0)===65279&&(n=n.slice(1)));let x=new U(n,d),v=n.indexOf("\0");for(v!==-1&&(x.position=v,P(x,"null byte is not allowed in input")),x.input+="\0";x.input.charCodeAt(x.position)===32;)x.lineIndent+=1,x.position+=1;for(;x.position<x.length-1;)gn(x);return x.documents}function Qe(n,d,x){d!==null&&typeof d=="object"&&typeof x>"u"&&(x=d,d=null);let v=Xe(n,x);if(typeof d!="function")return v;for(let w=0,O=v.length;w<O;w+=1)d(v[w])}function wn(n,d){let x=Xe(n,d);if(x.length!==0){if(x.length===1)return x[0];throw new i("expected a single document in the stream, but found more")}}e.exports.loadAll=Qe,e.exports.load=wn})),sr=j(((o,e)=>{var t=Le(),i=Me(),r=Fn(),a=Object.prototype.toString,c=Object.prototype.hasOwnProperty,l=65279,p=9,m=10,h=13,u=32,f=33,E=34,k=35,L=37,te=38,D=39,G=42,ie=44,J=45,W=58,Y=61,pe=62,ln=63,un=64,je=91,Oe=93,pn=96,Ee=123,He=124,Se=125,U={};U[0]="\\0",U[7]="\\a",U[8]="\\b",U[9]="\\t",U[10]="\\n",U[11]="\\v",U[12]="\\f",U[13]="\\r",U[27]="\\e",U[34]='\\"',U[92]="\\\\",U[133]="\\N",U[160]="\\_",U[8232]="\\L",U[8233]="\\P";var Be=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],P=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function ye(s,g){if(g===null)return{};let b={},y=Object.keys(g);for(let _=0,A=y.length;_<A;_+=1){let C=y[_],T=String(g[C]);C.slice(0,2)==="!!"&&(C="tag:yaml.org,2002:"+C.slice(2));let I=s.compiledTypeMap.fallback[C];I&&c.call(I.styleAliases,T)&&(T=I.styleAliases[T]),b[C]=T}return b}function re(s){let g,b,y=s.toString(16).toUpperCase();if(s<=255)g="x",b=2;else if(s<=65535)g="u",b=4;else if(s<=4294967295)g="U",b=8;else throw new i("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+g+t.repeat("0",b-y.length)+y}var fn=1,he=2;function dn(s){this.schema=s.schema||r,this.indent=Math.max(1,s.indent||2),this.noArrayIndent=s.noArrayIndent||!1,this.skipInvalid=s.skipInvalid||!1,this.flowLevel=t.isNothing(s.flowLevel)?-1:s.flowLevel,this.styleMap=ye(this.schema,s.styles||null),this.sortKeys=s.sortKeys||!1,this.lineWidth=s.lineWidth||80,this.noRefs=s.noRefs||!1,this.noCompatMode=s.noCompatMode||!1,this.condenseFlow=s.condenseFlow||!1,this.quotingType=s.quotingType==='"'?he:fn,this.forceQuotes=s.forceQuotes||!1,this.replacer=typeof s.replacer=="function"?s.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function Ie(s,g){let b=t.repeat(" ",g),y=0,_="",A=s.length;for(;y<A;){let C,T=s.indexOf(`
|
|
542
|
+
`,y);T===-1?(C=s.slice(y),y=A):(C=s.slice(y,T+1),y=T+1),C.length&&C!==`
|
|
543
|
+
`&&(_+=b),_+=C}return _}function _e(s,g){return`
|
|
544
|
+
`+t.repeat(" ",s.indent*g)}function Ge(s,g){for(let b=0,y=s.implicitTypes.length;b<y;b+=1)if(s.implicitTypes[b].resolve(g))return!0;return!1}function X(s){return s===u||s===p}function fe(s){return s>=32&&s<=126||s>=161&&s<=55295&&s!==8232&&s!==8233||s>=57344&&s<=65533&&s!==l||s>=65536&&s<=1114111}function oe(s){return fe(s)&&s!==l&&s!==h&&s!==m}function ve(s,g,b){let y=oe(s),_=y&&!X(s);return(b?y:y&&s!==ie&&s!==je&&s!==Oe&&s!==Ee&&s!==Se)&&s!==k&&!(g===W&&!_)||oe(g)&&!X(g)&&s===k||g===W&&_}function B(s){return fe(s)&&s!==l&&!X(s)&&s!==J&&s!==ln&&s!==W&&s!==ie&&s!==je&&s!==Oe&&s!==Ee&&s!==Se&&s!==k&&s!==te&&s!==G&&s!==f&&s!==He&&s!==Y&&s!==pe&&s!==D&&s!==E&&s!==L&&s!==un&&s!==pn}function Ce(s){return!X(s)&&s!==W}function se(s,g){let b=s.charCodeAt(g),y;return b>=55296&&b<=56319&&g+1<s.length&&(y=s.charCodeAt(g+1),y>=56320&&y<=57343)?(b-55296)*1024+y-56320+65536:b}function qe(s){return/^\n* /.test(s)}var We=1,Te=2,Ue=3,Je=4,ae=5;function Ye(s,g,b,y,_,A,C,T){let I,N=0,R=null,$=!1,H=!1,Yn=y!==-1,ke=-1,Pe=B(se(s,0))&&Ce(se(s,s.length-1));if(g||C)for(I=0;I<s.length;N>=65536?I+=2:I++){if(N=se(s,I),!fe(N))return ae;Pe=Pe&&ve(N,R,T),R=N}else{for(I=0;I<s.length;N>=65536?I+=2:I++){if(N=se(s,I),N===m)$=!0,Yn&&(H=H||I-ke-1>y&&s[ke+1]!==" ",ke=I);else if(!fe(N))return ae;Pe=Pe&&ve(N,R,T),R=N}H=H||Yn&&I-ke-1>y&&s[ke+1]!==" "}return!$&&!H?Pe&&!C&&!_(s)?We:A===he?ae:Te:b>9&&qe(s)?ae:C?A===he?ae:Te:H?Je:Ue}function mn(s,g,b,y,_){s.dump=(function(){if(g.length===0)return s.quotingType===he?'""':"''";if(!s.noCompatMode&&(Be.indexOf(g)!==-1||P.test(g)))return s.quotingType===he?'"'+g+'"':"'"+g+"'";let A=s.indent*Math.max(1,b),C=s.lineWidth===-1?-1:Math.max(Math.min(s.lineWidth,40),s.lineWidth-A),T=y||s.flowLevel>-1&&b>=s.flowLevel;function I(N){return Ge(s,N)}switch(Ye(g,T,s.indent,C,I,s.quotingType,s.forceQuotes&&!y,_)){case We:return g;case Te:return"'"+g.replace(/'/g,"''")+"'";case Ue:return"|"+Ke(g,s.indent)+ze(Ie(g,A));case Je:return">"+Ke(g,s.indent)+ze(Ie(hn(g,C),A));case ae:return'"'+gn(g,C)+'"';default:throw new i("impossible error: invalid scalar style")}})()}function Ke(s,g){let b=qe(s)?String(g):"",y=s[s.length-1]===`
|
|
545
|
+
`;return b+(y&&(s[s.length-2]===`
|
|
546
|
+
`||s===`
|
|
547
|
+
`)?"+":y?"":"-")+`
|
|
548
|
+
`}function ze(s){return s[s.length-1]===`
|
|
549
|
+
`?s.slice(0,-1):s}function hn(s,g){let b=/(\n+)([^\n]*)/g,y=(function(){let T=s.indexOf(`
|
|
550
|
+
`);return T=T!==-1?T:s.length,b.lastIndex=T,ce(s.slice(0,T),g)})(),_=s[0]===`
|
|
551
|
+
`||s[0]===" ",A,C;for(;C=b.exec(s);){let T=C[1],I=C[2];A=I[0]===" ",y+=T+(!_&&!A&&I!==""?`
|
|
552
|
+
`:"")+ce(I,g),_=A}return y}function ce(s,g){if(s===""||s[0]===" ")return s;let b=/ [^ ]/g,y,_=0,A,C=0,T=0,I="";for(;y=b.exec(s);)T=y.index,T-_>g&&(A=C>_?C:T,I+=`
|
|
553
|
+
`+s.slice(_,A),_=A+1),C=T;return I+=`
|
|
554
|
+
`,s.length-_>g&&C>_?I+=s.slice(_,C)+`
|
|
555
|
+
`+s.slice(C+1):I+=s.slice(_),I.slice(1)}function gn(s){let g="",b=0;for(let y=0;y<s.length;b>=65536?y+=2:y++){b=se(s,y);let _=U[b];!_&&fe(b)?(g+=s[y],b>=65536&&(g+=s[y+1])):g+=_||re(b)}return g}function Xe(s,g,b){let y="",_=s.tag;for(let A=0,C=b.length;A<C;A+=1){let T=b[A];s.replacer&&(T=s.replacer.call(b,String(A),T)),(x(s,g,T,!1,!1)||typeof T>"u"&&x(s,g,null,!1,!1))&&(y!==""&&(y+=","+(s.condenseFlow?"":" ")),y+=s.dump)}s.tag=_,s.dump="["+y+"]"}function Qe(s,g,b,y){let _="",A=s.tag;for(let C=0,T=b.length;C<T;C+=1){let I=b[C];s.replacer&&(I=s.replacer.call(b,String(C),I)),(x(s,g+1,I,!0,!0,!1,!0)||typeof I>"u"&&x(s,g+1,null,!0,!0,!1,!0))&&((!y||_!=="")&&(_+=_e(s,g)),s.dump&&m===s.dump.charCodeAt(0)?_+="-":_+="- ",_+=s.dump)}s.tag=A,s.dump=_||"[]"}function wn(s,g,b){let y="",_=s.tag,A=Object.keys(b);for(let C=0,T=A.length;C<T;C+=1){let I="";y!==""&&(I+=", "),s.condenseFlow&&(I+='"');let N=A[C],R=b[N];s.replacer&&(R=s.replacer.call(b,N,R)),x(s,g,N,!1,!1)&&(s.dump.length>1024&&(I+="? "),I+=s.dump+(s.condenseFlow?'"':"")+":"+(s.condenseFlow?"":" "),x(s,g,R,!1,!1)&&(I+=s.dump,y+=I))}s.tag=_,s.dump="{"+y+"}"}function n(s,g,b,y){let _="",A=s.tag,C=Object.keys(b);if(s.sortKeys===!0)C.sort();else if(typeof s.sortKeys=="function")C.sort(s.sortKeys);else if(s.sortKeys)throw new i("sortKeys must be a boolean or a function");for(let T=0,I=C.length;T<I;T+=1){let N="";(!y||_!=="")&&(N+=_e(s,g));let R=C[T],$=b[R];if(s.replacer&&($=s.replacer.call(b,R,$)),!x(s,g+1,R,!0,!0,!0))continue;let H=s.tag!==null&&s.tag!=="?"||s.dump&&s.dump.length>1024;H&&(s.dump&&m===s.dump.charCodeAt(0)?N+="?":N+="? "),N+=s.dump,H&&(N+=_e(s,g)),x(s,g+1,$,!0,H)&&(s.dump&&m===s.dump.charCodeAt(0)?N+=":":N+=": ",N+=s.dump,_+=N)}s.tag=A,s.dump=_||"{}"}function d(s,g,b){let y=b?s.explicitTypes:s.implicitTypes;for(let _=0,A=y.length;_<A;_+=1){let C=y[_];if((C.instanceOf||C.predicate)&&(!C.instanceOf||typeof g=="object"&&g instanceof C.instanceOf)&&(!C.predicate||C.predicate(g))){if(b?C.multi&&C.representName?s.tag=C.representName(g):s.tag=C.tag:s.tag="?",C.represent){let T=s.styleMap[C.tag]||C.defaultStyle,I;if(a.call(C.represent)==="[object Function]")I=C.represent(g,T);else if(c.call(C.represent,T))I=C.represent[T](g,T);else throw new i("!<"+C.tag+'> tag resolver accepts not "'+T+'" style');s.dump=I}return!0}}return!1}function x(s,g,b,y,_,A,C){s.tag=null,s.dump=b,d(s,b,!1)||d(s,b,!0);let T=a.call(s.dump),I=y;y&&(y=s.flowLevel<0||s.flowLevel>g);let N=T==="[object Object]"||T==="[object Array]",R,$;if(N&&(R=s.duplicates.indexOf(b),$=R!==-1),(s.tag!==null&&s.tag!=="?"||$||s.indent!==2&&g>0)&&(_=!1),$&&s.usedDuplicates[R])s.dump="*ref_"+R;else{if(N&&$&&!s.usedDuplicates[R]&&(s.usedDuplicates[R]=!0),T==="[object Object]")y&&Object.keys(s.dump).length!==0?(n(s,g,s.dump,_),$&&(s.dump="&ref_"+R+s.dump)):(wn(s,g,s.dump),$&&(s.dump="&ref_"+R+" "+s.dump));else if(T==="[object Array]")y&&s.dump.length!==0?(s.noArrayIndent&&!C&&g>0?Qe(s,g-1,s.dump,_):Qe(s,g,s.dump,_),$&&(s.dump="&ref_"+R+s.dump)):(Xe(s,g,s.dump),$&&(s.dump="&ref_"+R+" "+s.dump));else if(T==="[object String]")s.tag!=="?"&&mn(s,s.dump,g,A,I);else{if(T==="[object Undefined]")return!1;if(s.skipInvalid)return!1;throw new i("unacceptable kind of an object to dump "+T)}if(s.tag!==null&&s.tag!=="?"){let H=encodeURI(s.tag[0]==="!"?s.tag.slice(1):s.tag).replace(/!/g,"%21");s.tag[0]==="!"?H="!"+H:H.slice(0,18)==="tag:yaml.org,2002:"?H="!!"+H.slice(18):H="!<"+H+">",s.dump=H+" "+s.dump}}return!0}function v(s,g){let b=[],y=[];w(s,b,y);let _=y.length;for(let A=0;A<_;A+=1)g.duplicates.push(b[y[A]]);g.usedDuplicates=new Array(_)}function w(s,g,b){if(s!==null&&typeof s=="object"){let y=g.indexOf(s);if(y!==-1)b.indexOf(y)===-1&&b.push(y);else if(g.push(s),Array.isArray(s))for(let _=0,A=s.length;_<A;_+=1)w(s[_],g,b);else{let _=Object.keys(s);for(let A=0,C=_.length;A<C;A+=1)w(s[_[A]],g,b)}}}function O(s,g){g=g||{};let b=new dn(g);b.noRefs||v(s,b);let y=s;return b.replacer&&(y=b.replacer.call({"":y},"",y)),x(b,0,y,!0,!0)?b.dump+`
|
|
556
|
+
`:""}e.exports.dump=O})),Ht=ir(j(((o,e)=>{var t=or(),i=sr();function r(a,c){return function(){throw new Error("Function yaml."+a+" is removed in js-yaml 4. Use yaml."+c+" instead, which is now safe by default.")}}e.exports.Type=K(),e.exports.Schema=bt(),e.exports.FAILSAFE_SCHEMA=It(),e.exports.JSON_SCHEMA=Rt(),e.exports.CORE_SCHEMA=$t(),e.exports.DEFAULT_SCHEMA=Fn(),e.exports.load=t.load,e.exports.loadAll=t.loadAll,e.exports.dump=i.dump,e.exports.YAMLException=Me(),e.exports.types={binary:Vt(),float:Nt(),map:St(),null:Tt(),pairs:Ft(),set:jt(),timestamp:Lt(),bool:kt(),int:Pt(),merge:Mt(),omap:Dt(),seq:Et(),str:Ot()},e.exports.safeLoad=r("safeLoad","load"),e.exports.safeLoadAll=r("safeLoadAll","loadAll"),e.exports.safeDump=r("safeDump","dump")}))(),1),{Type:Vo,Schema:Do,FAILSAFE_SCHEMA:Fo,JSON_SCHEMA:jo,CORE_SCHEMA:Ho,DEFAULT_SCHEMA:Bo,load:Go,loadAll:qo,dump:Wo,YAMLException:Uo,types:Jo,safeLoad:Yo,safeLoadAll:Ko,safeDump:zo}=Ht.default,jn=Ht.default;async function lr(o=process.cwd()){let e=q(o);for(;;){let t=q(e,"view-contracts.config.yaml");try{return await ar(t),t}catch{let i=on(e);if(i===e)return null;e=i}}}async function de(o){if(o)return q(o);let e=await lr();if(!e)throw new Error("view-contracts.config.yaml not found. Pass -c <path> or run from a project directory.");return e}async function we(o){let e=q(o),t=await Bt(e,"utf-8"),i=jn.load(t);return ur(e,i)}function ur(o,e){let t=ue(o);return{...e,openapi:q(t,e.openapi),bindings:q(t,e.bindings),microContractsConfig:q(t,e.microContractsConfig),viewsDir:q(t,e.viewsDir),generated:{contractDir:q(t,e.generated.contractDir),actions:q(t,e.generated.actions),bridge:q(t,e.generated.bridge),reactDir:q(t,e.generated.reactDir)},componentsModule:e.componentsModule?q(t,e.componentsModule):void 0,themeModule:e.themeModule?q(t,e.themeModule):void 0}}async function Ve(o){let e=await Bt(q(o),"utf-8");return jn.load(e)}function Gt(o,e){return q(o.generated.reactDir,`${e.screenName}.generated.tsx`)}function ue(o){return on(q(o))}function qt(o,e,t){let i=q(on(t),"../components/index.ts"),r=cr(on(q(t)),i);return r.startsWith(".")||(r=`./${r}`),r.replace(/\.tsx?$/,".js")}import{relative as pr}from"node:path";function Wt(o,e){return pr(o,e).split("\\").join("/")}function Q(o){return" ".repeat(o)}function De(o,e="vm"){let t=o.scope??e;return o.path?`${t}.${o.path}`:t}function Bn(o,e=!1){let t=e?" as ActionDescriptor":"";if(!o.params||Object.keys(o.params).length===0)return`{ name: ${JSON.stringify(o.name)} }${t}`;let i=Object.entries(o.params).map(([r,a])=>`${r}: ${Gn(a,0)}`).join(", ");return`{ name: ${JSON.stringify(o.name)}, params: { ${i} } }${t}`}function Hn(o,e,t=!1){if(o===null)return"null";if(typeof o=="string")return JSON.stringify(o);if(typeof o=="number"||typeof o=="boolean")return String(o);if(Array.isArray(o))return`[
|
|
557
|
+
${o.map(i=>`${Q(e+1)}${Hn(i,e+1,t)}`).join(`,
|
|
558
|
+
`)}
|
|
559
|
+
${Q(e)}]`;if(typeof o=="object"&&o!==null){let i=o;return"kind"in i&&i.kind==="action"?Bn(i,t):`{
|
|
560
|
+
${Object.entries(i).map(([a,c])=>`${a}: ${Hn(c,e+1,t)}`).map(a=>`${Q(e+1)}${a}`).join(`,
|
|
561
|
+
`)}
|
|
562
|
+
${Q(e)}}`}return"undefined"}function Gn(o,e,t=!1){if(o===null)return"null";if(typeof o=="string")return JSON.stringify(o);if(typeof o=="number"||typeof o=="boolean")return String(o);if(Array.isArray(o))return`[
|
|
563
|
+
${o.map(i=>`${Q(e+1)}${Gn(i,e+1,t)}`).join(`,
|
|
564
|
+
`)}
|
|
565
|
+
${Q(e)}]`;if(typeof o=="object"&&o!==null&&"kind"in o){if(o.kind==="binding")return De(o);if(o.kind==="action")return Bn(o,t);if(o.kind==="literal")return Hn(o.value,e,t)}return"undefined"}function Ut(o,e,t){if(o.length===0)return"";let i=t??"vm";return o.map(a=>{if(a.kind==="text"){let c=a.value;return c?`${Q(e)}{${JSON.stringify(c)}}`:""}return a.kind==="binding"?`${Q(e)}{${De(a,i)}}`:a.kind==="map"?dr(a,e):a.kind==="fragment"?Ut(a.children,e,t):qn(a,e,t)}).filter(Boolean).join(`
|
|
566
|
+
`)}function fr(o,e){let t=e??"vm";return Object.entries(o).map(([i,r])=>i==="action"&&typeof r=="object"&&r!==null&&"kind"in r&&r.kind==="action"?`${i}={${Bn(r,!0)}}`:typeof r=="object"&&r!==null&&"kind"in r&&r.kind==="binding"?`${i}={${De(r,t)}}`:i==="children"?"":`${i}={${Gn(r,0,i==="columns")}}`).join(" ")}function dr(o,e){let t=o.item,i=qn(o.body,e+1,t);if(o.key){let r=` key={${De(o.key,t)}}`;i=i.replace(/^( +<\w+)/,`$1${r}`)}return`${Q(e)}{${De(o.source)}.map((${t}) => (
|
|
567
|
+
${i}
|
|
568
|
+
${Q(e)}))}`}function qn(o,e,t){let i=fr(o.props,t),r=i?` ${i}`:"",a=Ut(o.children,e+1,t);return a?`${Q(e)}<${o.name}${r}>
|
|
569
|
+
${a}
|
|
570
|
+
${Q(e)}</${o.name}>`:`${Q(e)}<${o.name}${r} />`}function sn(o,e){if(o.kind==="component"){e.add(o.name);for(let t of o.children)sn(t,e);return}if(o.kind==="map"&&sn(o.body,e),o.kind==="fragment")for(let t of o.children)sn(t,e)}function mr(o){let e=new Set;return sn(o.root,e),[...e].sort().join(", ")}function hr(o,e){let t=o.exportName.replace(/View$/,"")||o.exportName,i=t.charAt(0).toUpperCase()+t.slice(1),r=o.root.kind==="component"?o.root:null;if(!r)throw new Error(`View IR root must be a component node (${o.source})`);let a=qn(r,2),c=mr(o);return`/**
|
|
571
|
+
* Auto-generated React component from ${o.source}
|
|
572
|
+
* DO NOT EDIT \u2014 regenerate with: view-contracts render react
|
|
573
|
+
*/
|
|
574
|
+
import type { ReactElement } from 'react';
|
|
575
|
+
import {
|
|
576
|
+
${c},
|
|
577
|
+
} from '${e.componentsImportFrom}';
|
|
578
|
+
import type { ${o.viewModel}, ActionDescriptor } from '../contracts';
|
|
579
|
+
|
|
580
|
+
export function ${i}({ vm }: { vm: ${o.viewModel} }): ReactElement {
|
|
581
|
+
return (
|
|
582
|
+
${a}
|
|
583
|
+
);
|
|
584
|
+
}
|
|
585
|
+
`}async function Jt(o,e,t){let{writeFile:i,mkdir:r}=await import("node:fs/promises"),{dirname:a}=await import("node:path"),c=hr(o,t);await r(a(e),{recursive:!0}),await i(e,c,"utf-8")}import{cp as br,readFile as me,writeFile as Z,mkdir as Zt,stat as Or}from"node:fs/promises";import{resolve as V}from"node:path";import{readFile as Yt}from"node:fs/promises";import{createRequire as gr}from"node:module";import{dirname as wr,resolve as zt}from"node:path";var Kt=/^@import\s+['"](.+?)['"]\s*;/gm,xr=gr(import.meta.url);async function yr(o,e){return o.startsWith("@")||!o.startsWith(".")&&!o.startsWith("/")?xr.resolve(o):zt(e,o)}async function Xt(o){let e=zt(o),t=await Yt(e,"utf-8"),i=wr(e);for(let r of t.matchAll(Kt)){let a=r[0],c=r[1];if(!c)continue;let l=await yr(c,i),p=await Yt(l,"utf-8");t=t.replace(a,`${p}
|
|
586
|
+
`)}return t.replace(Kt,"").trim()}import{readFileSync as _r}from"node:fs";import{createRequire as vr}from"node:module";import{dirname as Wn,resolve as Cr}from"node:path";import{fileURLToPath as Ar}from"node:url";var Ae;function Qt(){if(Ae)return Ae;let o=vr(import.meta.url);try{return Ae=Wn(o.resolve("view-contracts/package.json")),Ae}catch{let e=Wn(Ar(import.meta.url));for(;;){try{let i=Cr(e,"package.json");if(JSON.parse(_r(i,"utf8")).name==="view-contracts")return Ae=e,Ae}catch{}let t=Wn(e);if(t===e)break;e=t}throw new Error("view-contracts package root not found")}}var ei=Qt(),Er=`/** Auto-generated component barrel \u2014 DO NOT EDIT */
|
|
587
|
+
export * from './core.js';
|
|
588
|
+
export * from './extensions.js';
|
|
589
|
+
export type { TableColumn } from './extensions.js';
|
|
590
|
+
`,Sr=`/** Auto-generated component primitives \u2014 DO NOT EDIT */
|
|
591
|
+
export * from './ui-components.js';
|
|
592
|
+
export { commonStyle, isHidden, toneClass } from './style.js';
|
|
593
|
+
export type { Action, CommonProps, Option } from './types.js';
|
|
594
|
+
`,Ir=`/** Auto-generated action wiring \u2014 DO NOT EDIT */
|
|
595
|
+
import type { DispatchableAction } from '../runtime/types.js';
|
|
596
|
+
import { dispatchAction } from '../runtime/dispatch.js';
|
|
597
|
+
|
|
598
|
+
export async function dispatchPreviewAction(action?: DispatchableAction): Promise<void> {
|
|
599
|
+
if (!action) return;
|
|
600
|
+
await dispatchAction(action);
|
|
601
|
+
}
|
|
602
|
+
`,Tr=`/** Auto-generated runtime dispatcher \u2014 DO NOT EDIT */
|
|
603
|
+
import type { DispatchableAction } from './types.js';
|
|
604
|
+
|
|
605
|
+
type ActionHandler = (action: DispatchableAction) => void | Promise<void>;
|
|
606
|
+
|
|
607
|
+
let handler: ActionHandler | undefined;
|
|
608
|
+
|
|
609
|
+
export function registerActionHandler(nextHandler: ActionHandler): void {
|
|
610
|
+
handler = nextHandler;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
export async function dispatchAction(action: DispatchableAction): Promise<void> {
|
|
614
|
+
if (handler) {
|
|
615
|
+
await handler(action);
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
618
|
+
if (action.name === 'navigate' && typeof action.params?.to === 'string') {
|
|
619
|
+
window.location.href = action.params.to;
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
window.dispatchEvent(new CustomEvent('view-contracts:action', { detail: action }));
|
|
623
|
+
}
|
|
624
|
+
`,kr=`/** Auto-generated \u2014 DO NOT EDIT */
|
|
625
|
+
export interface DispatchableAction {
|
|
626
|
+
name: string;
|
|
627
|
+
params?: Record<string, unknown>;
|
|
628
|
+
}
|
|
629
|
+
`;function ni(){return V(ei,"src/renderer/react/runtime")}function Pr(){return V(ei,"src/generated/schema")}async function an(o){try{return await Or(o),!0}catch{return!1}}function Fe(o){return o.replaceAll("../../../generated/schema/","./schema/").replace(/import type { ViewAction } from '@view-contracts\/core';\n/,`export interface ViewAction { name: string; params?: Record<string, unknown> }
|
|
630
|
+
`).replace(/import type { ViewAction } from '@view-contracts\/core'/,"export interface ViewAction { name: string; params?: Record<string, unknown> }")}async function Nr(o){let e=ni(),t=Pr();if(await an(t)){let c=V(o,"schema");await br(t,c,{recursive:!0});for(let l of["dsl-properties.ts","tokens.ts","schema-document.ts","index.ts"]){let p=V(c,l);await an(p)&&await Z(p,Fe(await me(p,"utf-8")),"utf-8")}}let i=Fe(await me(V(e,"components.tsx"),"utf-8"));await Z(V(o,"ui-components.tsx"),i,"utf-8");let r=Fe(await me(V(e,"style.ts"),"utf-8"));await Z(V(o,"style.ts"),r,"utf-8");let a=Fe(await me(V(e,"types.ts"),"utf-8"));if(await Z(V(o,"types.ts"),a,"utf-8"),await an(V(e,"shared.tsx"))){let c=Fe(await me(V(e,"shared.tsx"),"utf-8"));await Z(V(o,"shared.tsx"),c,"utf-8")}await Z(V(o,"actionRuntime.ts"),Ir,"utf-8"),await Z(V(o,"core.ts"),Sr,"utf-8")}async function Rr(o,e){let t=V(ni(),"theme.css"),i=await Xt(t),r=V(o,"src/theme.extensions.css");await an(r)&&(i+=`
|
|
631
|
+
|
|
632
|
+
${await me(r,"utf-8")}`),await Z(e,`/** Auto-generated theme \u2014 DO NOT EDIT */
|
|
633
|
+
${i}
|
|
634
|
+
`,"utf-8")}async function ti(o,e){let t=ue(o),i=V(e.generated.reactDir,"../components"),r=V(e.generated.reactDir,"../runtime"),a=V(t,"src/components");await Zt(i,{recursive:!0}),await Zt(r,{recursive:!0}),await Nr(i);for(let m of["extensions.tsx","sample-types.ts"]){let h=V(a,m),u=V(i,m);await Z(u,await me(h,"utf-8"),"utf-8")}let c=V(t,"src/runtime/handlers.ts"),p=`/** Auto-generated from src/runtime/handlers.ts \u2014 DO NOT EDIT */
|
|
635
|
+
import type { DispatchableAction } from './types.js';
|
|
636
|
+
|
|
637
|
+
${(await me(c,"utf-8")).replace(/export async function handleAppAction\(action:\s*\{[\s\S]*?\}\)/,"export async function handleAppAction(action: DispatchableAction)")}`;await Z(V(r,"handlers.ts"),p,"utf-8"),await Z(V(i,"index.ts"),Er,"utf-8"),await Rr(t,V(e.generated.reactDir,"../theme.css")),await Z(V(r,"types.ts"),kr,"utf-8"),await Z(V(r,"dispatch.ts"),Tr,"utf-8"),console.log(` components \u2192 ${i}`),console.log(` theme \u2192 ${V(e.generated.reactDir,"../theme.css")}`)}import{access as $r,writeFile as ee,mkdir as cn}from"node:fs/promises";import{resolve as z,dirname as ii}from"node:path";async function Un(o){try{return await $r(o),!0}catch{return!1}}var be={preview:5173,app:5174,built:4174},ri=`{
|
|
638
|
+
"name": "admin-dashboard",
|
|
639
|
+
"private": true,
|
|
640
|
+
"type": "module",
|
|
641
|
+
"scripts": {
|
|
642
|
+
"dev": "vite --config .vite/vite.config.ts",
|
|
643
|
+
"dev:preview": "vite --config .vite/vite.preview.config.ts --open /.vite/preview.html",
|
|
644
|
+
"dev:app": "vite --config .vite/vite.config.ts --open /.vite/index.html",
|
|
645
|
+
"dev:both": "bash scripts/dev-both.sh",
|
|
646
|
+
"check:both": "bash scripts/check-both.sh",
|
|
647
|
+
"serve:built": "vite preview --config .vite/vite.config.ts --host 0.0.0.0 --open /",
|
|
648
|
+
"build": "vite build --config .vite/vite.config.ts",
|
|
649
|
+
"build:views": "view-contracts build -c view-contracts.config.yaml"
|
|
650
|
+
},
|
|
651
|
+
"dependencies": {
|
|
652
|
+
"react": "^19.2.0",
|
|
653
|
+
"react-dom": "^19.2.0"
|
|
654
|
+
},
|
|
655
|
+
"devDependencies": {
|
|
656
|
+
"@view-contracts/core": "file:../../packages/core",
|
|
657
|
+
"@view-contracts/runtime": "file:../../packages/runtime",
|
|
658
|
+
"@vitejs/plugin-react": "^4.7.0",
|
|
659
|
+
"typescript": "^5.9.3",
|
|
660
|
+
"view-contracts": "file:../..",
|
|
661
|
+
"vite": "^6.4.1"
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
`,Lr=`import '../src/main.tsx';
|
|
665
|
+
`,Mr=`<!doctype html>
|
|
666
|
+
<html lang="en">
|
|
667
|
+
<head>
|
|
668
|
+
<meta charset="UTF-8" />
|
|
669
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
670
|
+
<title>admin-dashboard</title>
|
|
671
|
+
</head>
|
|
672
|
+
<body>
|
|
673
|
+
<div id="root"></div>
|
|
674
|
+
<script type="module" src="./app-main.tsx"></script>
|
|
675
|
+
</body>
|
|
676
|
+
</html>
|
|
677
|
+
`,Vr=`<!doctype html>
|
|
678
|
+
<html lang="en">
|
|
679
|
+
<head>
|
|
680
|
+
<meta charset="UTF-8" />
|
|
681
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
682
|
+
<title>admin-dashboard \u2014 preview</title>
|
|
683
|
+
</head>
|
|
684
|
+
<body>
|
|
685
|
+
<div id="root"></div>
|
|
686
|
+
<script type="module" src="/.vite/preview-main.tsx"></script>
|
|
687
|
+
</body>
|
|
688
|
+
</html>
|
|
689
|
+
`,Dr=`import '../src/theme.extensions.css';
|
|
690
|
+
import '../views/preview.entry.tsx';
|
|
691
|
+
`,Fr=`/** Auto-generated preview component barrel \u2014 DO NOT EDIT */
|
|
692
|
+
export * from '../../../src/renderer/react/runtime/index.js';
|
|
693
|
+
export * from '../src/components/extensions.js';
|
|
694
|
+
`;function jr(o){let t=o.views.filter(a=>a.targets.includes("react"))[0];if(!t)throw new Error("No react target views in bindings \u2014 cannot scaffold app entry.");let i=t.screenName,r=`${i.charAt(0).toLowerCase()}${i.slice(1)}Mock`;return`import React from 'react';
|
|
695
|
+
import ReactDOM from 'react-dom/client';
|
|
696
|
+
import '../generated/theme.css';
|
|
697
|
+
import { ${i} } from '../generated/react/${i}.generated';
|
|
698
|
+
import { ${r} } from '../generated/mock';
|
|
699
|
+
import { registerActionHandler } from '../generated/runtime/dispatch';
|
|
700
|
+
import { handleAppAction } from '../generated/runtime/handlers';
|
|
701
|
+
|
|
702
|
+
registerActionHandler(handleAppAction);
|
|
703
|
+
|
|
704
|
+
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
|
|
705
|
+
<React.StrictMode>
|
|
706
|
+
<${i} vm={${r}} />
|
|
707
|
+
</React.StrictMode>,
|
|
708
|
+
);
|
|
709
|
+
`}var Hr=`/** Hand-written action handlers \u2014 edit src/runtime/handlers.ts */
|
|
710
|
+
import type { DispatchableAction } from './types.js';
|
|
711
|
+
|
|
712
|
+
export async function handleAppAction(action: DispatchableAction): Promise<void> {
|
|
713
|
+
console.log('[app action]', action);
|
|
714
|
+
}
|
|
715
|
+
`;function Br(){return`/** Fixed dev server ports \u2014 single source of truth for this example. */
|
|
716
|
+
export const PREVIEW_PORT = ${be.preview};
|
|
717
|
+
export const APP_PORT = ${be.app};
|
|
718
|
+
export const BUILT_PORT = ${be.built};
|
|
719
|
+
`}function Gr(){return`# Fixed dev server ports \u2014 keep in sync with dev.ports.ts
|
|
720
|
+
PREVIEW_PORT=${be.preview}
|
|
721
|
+
APP_PORT=${be.app}
|
|
722
|
+
BUILT_PORT=${be.built}
|
|
723
|
+
`}function qr(){return`import { defineConfig } from 'vite';
|
|
724
|
+
import react from '@vitejs/plugin-react';
|
|
725
|
+
import path from 'node:path';
|
|
726
|
+
import { fileURLToPath } from 'node:url';
|
|
727
|
+
import { APP_PORT, BUILT_PORT } from '../dev.ports.js';
|
|
728
|
+
|
|
729
|
+
const viteDir = path.dirname(fileURLToPath(import.meta.url));
|
|
730
|
+
const exampleRoot = path.resolve(viteDir, '..');
|
|
731
|
+
|
|
732
|
+
/** Standalone app \u2014 src/main.tsx imports generated/ only. */
|
|
733
|
+
export default defineConfig({
|
|
734
|
+
root: viteDir,
|
|
735
|
+
plugins: [react()],
|
|
736
|
+
server: {
|
|
737
|
+
port: APP_PORT,
|
|
738
|
+
strictPort: true,
|
|
739
|
+
fs: {
|
|
740
|
+
allow: [viteDir, exampleRoot],
|
|
741
|
+
},
|
|
742
|
+
},
|
|
743
|
+
preview: {
|
|
744
|
+
port: BUILT_PORT,
|
|
745
|
+
strictPort: true,
|
|
746
|
+
},
|
|
747
|
+
build: {
|
|
748
|
+
outDir: path.resolve(exampleRoot, 'dist/app'),
|
|
749
|
+
emptyOutDir: true,
|
|
750
|
+
rollupOptions: {
|
|
751
|
+
input: path.resolve(viteDir, 'index.html'),
|
|
752
|
+
},
|
|
753
|
+
},
|
|
754
|
+
});
|
|
755
|
+
`}function Wr(){return`import path from 'node:path';
|
|
756
|
+
import { defineConfig } from 'vite';
|
|
757
|
+
import react from '@vitejs/plugin-react';
|
|
758
|
+
import { fileURLToPath } from 'node:url';
|
|
759
|
+
import { PREVIEW_PORT } from '../dev.ports.js';
|
|
760
|
+
|
|
761
|
+
const viteDir = path.dirname(fileURLToPath(import.meta.url));
|
|
762
|
+
const projectRoot = path.resolve(viteDir, '..');
|
|
763
|
+
const repoRoot = path.resolve(projectRoot, '../..');
|
|
764
|
+
|
|
765
|
+
/** Preview only \u2014 views/ + view-contracts toolchain. No generated/ or app src/. */
|
|
766
|
+
export default defineConfig({
|
|
767
|
+
root: projectRoot,
|
|
768
|
+
plugins: [react()],
|
|
769
|
+
resolve: {
|
|
770
|
+
alias: [
|
|
771
|
+
{
|
|
772
|
+
find: '@view-contracts/preview/fixtures/admin-dashboard',
|
|
773
|
+
replacement: path.join(repoRoot, 'src/preview/fixtures/admin-dashboard.ts'),
|
|
774
|
+
},
|
|
775
|
+
{ find: '@view-contracts/core', replacement: path.join(repoRoot, 'packages/core/src/index.ts') },
|
|
776
|
+
{ find: '@view-contracts/runtime', replacement: path.join(repoRoot, 'packages/runtime/src/index.ts') },
|
|
777
|
+
{ find: '@view-contracts/components', replacement: path.join(viteDir, 'preview-components.ts') },
|
|
778
|
+
{ find: '@view-contracts/theme', replacement: path.join(repoRoot, 'src/renderer/react/runtime/theme.css') },
|
|
779
|
+
{ find: '@view-contracts/preview', replacement: path.join(repoRoot, 'src/preview/index.ts') },
|
|
780
|
+
],
|
|
781
|
+
},
|
|
782
|
+
server: {
|
|
783
|
+
port: PREVIEW_PORT,
|
|
784
|
+
strictPort: true,
|
|
785
|
+
fs: {
|
|
786
|
+
allow: [projectRoot, repoRoot],
|
|
787
|
+
},
|
|
788
|
+
},
|
|
789
|
+
build: {
|
|
790
|
+
outDir: path.resolve(projectRoot, 'dist/preview'),
|
|
791
|
+
emptyOutDir: true,
|
|
792
|
+
rollupOptions: {
|
|
793
|
+
input: {
|
|
794
|
+
preview: path.resolve(viteDir, 'preview.html'),
|
|
795
|
+
},
|
|
796
|
+
},
|
|
797
|
+
},
|
|
798
|
+
});
|
|
799
|
+
`}async function oi(o,e,t){let i=ue(o),r=z(i,".vite");await cn(r,{recursive:!0});let a=z(i,"package.json");await Un(a)?await ee(a,`${ri}
|
|
800
|
+
`,"utf-8"):await ee(a,`${ri}
|
|
801
|
+
`,"utf-8"),await ee(z(r,"index.html"),Mr,"utf-8"),await ee(z(r,"preview.html"),Vr,"utf-8"),await ee(z(r,"preview-main.tsx"),Dr,"utf-8"),await ee(z(r,"app-main.tsx"),Lr,"utf-8"),await ee(z(r,"preview-components.ts"),Fr,"utf-8"),await ee(z(r,"vite.config.ts"),qr(),"utf-8"),await ee(z(r,"vite.preview.config.ts"),Wr(),"utf-8"),await ee(z(i,"dev.ports.ts"),Br(),"utf-8");let c=z(i,"scripts");await cn(c,{recursive:!0}),await ee(z(c,"ports.sh"),Gr(),"utf-8");let l=z(i,"src/main.tsx");await Un(l)||(await cn(ii(l),{recursive:!0}),await ee(l,jr(t),"utf-8"));let p=z(i,"src/runtime/handlers.ts");await Un(p)||(await cn(ii(p),{recursive:!0}),await ee(p,Hr,"utf-8")),console.log(` scaffold \u2192 ${r}/`)}async function si(o){await new Promise((e,t)=>{let i=ui("npx",["micro-contracts",...o],{stdio:"inherit"});i.on("error",t),i.on("close",r=>{r===0?e():t(new Error(`micro-contracts exited with code ${r}`))})})}async function Kr(o){await new Promise((e,t)=>{let i=ui("npx",["tsx",...o],{stdio:"inherit"});i.on("error",t),i.on("close",r=>{r===0?e():t(new Error(`catalog build exited with code ${r}`))})})}async function Jn(o){let e=await we(o),t=await Ve(e.bindings),i=ue(o),r=await Ct(t.views.map(a=>({sourcePath:xe(i,a.source),exportName:a.exportName,screenName:a.screenName})),{allowlistExtra:e.allowlistExtra});return new Map(t.views.map((a,c)=>[a.screenName,r[c]]))}async function ai(o,e){let t=await we(o),i=await Ve(t.bindings);for(let r of i.views){if(!r.targets.includes("react"))continue;let a=e.get(r.screenName);if(!a)throw new Error(`Missing View IR for ${r.screenName}`);let c=Gt(t,r),l=qt(o,t,c);await Jt(a,c,{componentsImportFrom:l}),console.log(` ${r.exportName} \u2192 ${c}`)}}async function ci(o){let e=await we(o),t=await Ve(e.bindings),i=ue(o),a=["// Auto-generated view bridge registry \u2014 DO NOT EDIT",`// Generated from ${Wt(i,e.bindings)}`,"","export const viewBridgeRegistry = {"];for(let c of t.views)a.push(` ${c.screenConst}: {`),a.push(` id: ${JSON.stringify(c.id)},`),a.push(` screenId: ${JSON.stringify(c.screenId)},`),a.push(` screenName: ${JSON.stringify(c.screenName)},`),a.push(` route: ${JSON.stringify(c.route)},`),a.push(` operationId: ${JSON.stringify(c.operationId)},`),a.push(` viewModel: ${JSON.stringify(c.viewModel)},`),a.push(` source: ${JSON.stringify(c.source)},`),a.push(` targets: ${JSON.stringify(c.targets)},`),a.push(" },");a.push("} as const;",""),a.push("export type ViewBridgeKey = keyof typeof viewBridgeRegistry;",""),await Jr(li(xe(e.generated.bridge)),{recursive:!0}),await Ur(xe(e.generated.bridge),a.join(`
|
|
802
|
+
`),"utf-8"),console.log(`Bridge registry \u2192 ${e.generated.bridge} (${t.views.length} view(s))`)}var pi={compile:async(o,e)=>{let t=await Jn(await de(o.config));console.log(`Compiled ${t.size} view(s) to View IR (in-memory)`)},renderReact:async(o,e)=>{let t=await de(o.config),i=await Jn(t);await ai(t,i)},renderBridge:async(o,e)=>{await ci(await de(o.config))},build:async(o,e)=>{let t=await de(o.config),i=await we(t),r=await Ve(i.bindings),a=await Jn(t);console.log(`Compiled ${a.size} view(s) to View IR (in-memory)`),await ti(t,i),await ai(t,a),await ci(t),await oi(t,i,r)},contractsGenerate:async(o,e)=>{let t=await we(await de(o.config));await si(["generate","-c",t.microContractsConfig]),console.log("Contracts generated via micro-contracts")},contractsCheck:async(o,e)=>{let t=await we(await de(o.config));await si(["lint","-c",t.microContractsConfig])},catalogBuild:async(o,e)=>{let t=await de(o.config),i=ue(t),r=o.output?xe(String(o.output)):xe(i,"dist/catalog.html"),a=xe(i,"tsconfig.catalog.json"),{existsSync:c}=await import("node:fs");if(!c(a))throw new Error(`Missing ${a}. Add tsconfig.catalog.json with @view-contracts/components paths for catalog SSR.`);let l=xe(li(Yr(import.meta.url)),"../catalog/run.ts");await Kr(["--tsconfig",a,l,r,t]),console.log(`Catalog \u2192 ${r}`)}};var zr={version:"0.1.0"};ft(pi,zr.version).parseAsync(process.argv).catch(o=>{console.error(o instanceof Error?o.message:o),process.exit(1)});
|
|
803
|
+
/*! Bundled license information:
|
|
804
|
+
|
|
805
|
+
js-yaml/dist/js-yaml.mjs:
|
|
806
|
+
(*! js-yaml 4.2.0 https://github.com/nodeca/js-yaml @license MIT *)
|
|
807
|
+
*/
|
|
808
|
+
//# sourceMappingURL=view-contracts.bundle.mjs.map
|