view-contracts 0.5.16 → 0.5.17
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/cli-contract.yaml
CHANGED
|
@@ -3,7 +3,7 @@ cli_contracts: 0.1.0
|
|
|
3
3
|
|
|
4
4
|
info:
|
|
5
5
|
title: view-contracts CLI
|
|
6
|
-
version: 0.5.
|
|
6
|
+
version: 0.5.17
|
|
7
7
|
description: >-
|
|
8
8
|
Contract-first UI design toolchain. Compiles restricted view-contract TSX
|
|
9
9
|
to language-neutral View IR and renders platform targets (React, SwiftUI, Compose).
|
|
@@ -2,6 +2,11 @@ import type { UiDslSchema } from './types.js';
|
|
|
2
2
|
export type { UiDslSchema } from './types.js';
|
|
3
3
|
export { elementProps, propertyAppliesTo } from './dsl-catalog.js';
|
|
4
4
|
export declare const DEFAULT_SCHEMA_PATH = "spec/ui-dsl.schema.json";
|
|
5
|
+
export interface PackageManifest {
|
|
6
|
+
version: string;
|
|
7
|
+
peerDependencies: Record<string, string>;
|
|
8
|
+
}
|
|
9
|
+
export declare function loadPackageManifest(root?: string): Promise<PackageManifest>;
|
|
5
10
|
export declare function loadPackageVersion(root?: string): Promise<string>;
|
|
6
11
|
export declare function loadUiDslSchema(schemaPath?: string): Promise<UiDslSchema>;
|
|
7
12
|
export declare function allComponentNames(): string[];
|
|
@@ -179,7 +179,7 @@ Expecting `+de.join(", ")+", got '"+(this.terminals_[I]||I)+"'":Y="Parse error o
|
|
|
179
179
|
return undefined
|
|
180
180
|
}
|
|
181
181
|
`.trim()},blockValue:function(e){var n=this.aliasable("container.hooks.blockHelperMissing"),r=[this.contextName(0)];this.setupHelperArgs(e,0,r);var i=this.popStack();r.splice(1,0,i),this.push(this.source.functionCall(n,"call",r))},ambiguousBlockValue:function(){var e=this.aliasable("container.hooks.blockHelperMissing"),n=[this.contextName(0)];this.setupHelperArgs("",0,n,!0),this.flushInline();var r=this.topStack();n.splice(1,0,r),this.pushSource(["if (!",this.lastHelper,") { ",r," = ",this.source.functionCall(e,"call",n),"}"])},appendContent:function(e){this.pendingContent?e=this.pendingContent+e:this.pendingLocation=this.source.currentLocation,this.pendingContent=e},append:function(){if(this.isInline())this.replaceStack(function(n){return[" != null ? ",n,' : ""']}),this.pushSource(this.appendToBuffer(this.popStack()));else{var e=this.popStack();this.pushSource(["if (",e," != null) { ",this.appendToBuffer(e,void 0,!0)," }"]),this.environment.isSimple&&this.pushSource(["else { ",this.appendToBuffer("''",void 0,!0)," }"])}},appendEscaped:function(){this.pushSource(this.appendToBuffer([this.aliasable("container.escapeExpression"),"(",this.popStack(),")"]))},getContext:function(e){this.lastContext=e},pushContext:function(){this.pushStackLiteral(this.contextName(this.lastContext))},lookupOnContext:function(e,n,r,i){var o=0;!i&&this.options.compat&&!this.lastContext?this.push(this.depthedLookup(e[o++])):this.pushContext(),this.resolvePath("context",e,o,n,r)},lookupBlockParam:function(e,n){this.useBlockParams=!0,this.push(["blockParams[",e[0],"][",e[1],"]"]),this.resolvePath("context",n,1)},lookupData:function(e,n,r){e?this.pushStackLiteral("container.data(data, "+e+")"):this.pushStackLiteral("data"),this.resolvePath("data",n,0,!0,r)},resolvePath:function(e,n,r,i,o){var s=this;if(this.options.strict||this.options.assumeObjects){this.push(OI(this.options.strict&&o,this,n,r,e));return}for(var a=n.length,c=function(p){s.replaceStack(function(d){var f=s.nameLookup(d,n[p],e);return i?[" && ",f]:[" != null ? ",f," : ",d]})},l=r;l<a;l++)c(l)},resolvePossibleLambda:function(){this.push([this.aliasable("container.lambda"),"(",this.popStack(),", ",this.contextName(0),")"])},pushStringParam:function(e,n){this.pushContext(),this.pushString(n),n!=="SubExpression"&&(typeof e=="string"?this.pushString(e):this.pushStackLiteral(e))},emptyHash:function(e){this.trackIds&&this.push("{}"),this.stringParams&&(this.push("{}"),this.push("{}")),this.pushStackLiteral(e?"undefined":"{}")},pushHash:function(){this.hash&&this.hashes.push(this.hash),this.hash={values:{},types:[],contexts:[],ids:[]}},popHash:function(){var e=this.hash;this.hash=this.hashes.pop(),this.trackIds&&this.push(this.objectLiteral(e.ids)),this.stringParams&&(this.push(this.objectLiteral(e.contexts)),this.push(this.objectLiteral(e.types))),this.push(this.objectLiteral(e.values))},pushString:function(e){this.pushStackLiteral(this.quotedString(e))},pushLiteral:function(e){this.pushStackLiteral(e)},pushProgram:function(e){e!=null?this.pushStackLiteral(this.programExpression(e)):this.pushStackLiteral(null)},registerDecorator:function(e,n){var r=this.nameLookup("decorators",n,"decorator"),i=this.setupHelperArgs(n,e);this.decorators.push(["var decorator = ",r,";"]),this.decorators.push(['if (typeof decorator !== "function") { throw new Error(',this.quotedString('Missing decorator: "'+n+'"'),"); }"]),this.decorators.push(["fn = ",this.decorators.functionCall("decorator","",["fn","props","container",i])," || fn;"])},invokeHelper:function(e,n,r){var i=this.popStack(),o=this.setupHelper(e,n),s=[];r&&s.push(o.name),s.push(i),this.options.strict||s.push(this.aliasable("container.hooks.helperMissing"));var a=["(",this.itemsSeparatedBy(s,"||"),")"],c=this.source.functionCall(a,"call",o.callParams);this.push(c)},itemsSeparatedBy:function(e,n){var r=[];r.push(e[0]);for(var i=1;i<e.length;i++)r.push(n,e[i]);return r},invokeKnownHelper:function(e,n){var r=this.setupHelper(e,n);this.push(this.source.functionCall(r.name,"call",r.callParams))},invokeAmbiguous:function(e,n){this.useRegister("helper");var r=this.popStack();this.emptyHash();var i=this.setupHelper(0,e,n),o=this.lastHelper=this.nameLookup("helpers",e,"helper"),s=["(","(helper = ",o," || ",r,")"];this.options.strict||(s[0]="(helper = ",s.push(" != null ? helper : ",this.aliasable("container.hooks.helperMissing"))),this.push(["(",s,i.paramsInit?["),(",i.paramsInit]:[],"),","(typeof helper === ",this.aliasable('"function"')," ? ",this.source.functionCall("helper","call",i.callParams)," : helper))"])},invokePartial:function(e,n,r){var i=[],o=this.setupParams(n,1,i);e&&(n=this.popStack(),delete o.name),r&&(o.indent=this.quotedString(r)),o.helpers="helpers",o.partials="partials",o.decorators="container.decorators",e?i.unshift(n):i.unshift(this.nameLookup("partials",n,"partial")),this.options.compat&&(o.depths="depths"),o=this.objectLiteral(o),i.push(o),this.push(this.source.functionCall("container.invokePartial","",i))},assignToHash:function(e){var n=this.popStack(),r=void 0,i=void 0,o=void 0;this.trackIds&&(o=this.popStack()),this.stringParams&&(i=this.popStack(),r=this.popStack());var s=this.hash;r&&(s.contexts[e]=r),i&&(s.types[e]=i),o&&(s.ids[e]=o),s.values[e]=n},pushId:function(e,n,r){e==="BlockParam"?this.pushStackLiteral("blockParams["+n[0]+"].path["+n[1]+"]"+(r?" + "+this.quotedString("."+r):"")):e==="PathExpression"?this.pushString(n):e==="SubExpression"?this.pushStackLiteral("true"):this.pushStackLiteral("null")},compiler:Ur,compileChildren:function(e,n){for(var r=e.children,i=void 0,o=void 0,s=0,a=r.length;s<a;s++){i=r[s],o=new this.compiler;var c=this.matchExistingProgram(i);if(c==null){var l=this.context.programs.push("")-1;i.index=l,i.name="program"+l,this.context.programs[l]=o.compile(i,n,this.context,!this.precompile),this.context.decorators[l]=o.decorators,this.context.environments[l]=i,this.useDepths=this.useDepths||o.useDepths,this.useBlockParams=this.useBlockParams||o.useBlockParams,i.useDepths=this.useDepths,i.useBlockParams=this.useBlockParams}else i.index=c.index,i.name="program"+c.index,this.useDepths=this.useDepths||c.useDepths,this.useBlockParams=this.useBlockParams||c.useBlockParams}},matchExistingProgram:function(e){for(var n=0,r=this.context.environments.length;n<r;n++){var i=this.context.environments[n];if(i&&i.equals(e))return i}},programExpression:function(e){var n=this.environment.children[e],r=[n.index,"data",n.blockParams];return(this.useBlockParams||this.useDepths)&&r.push("blockParams"),this.useDepths&&r.push("depths"),"container.program("+r.join(", ")+")"},useRegister:function(e){this.registers[e]||(this.registers[e]=!0,this.registers.list.push(e))},push:function(e){return e instanceof Wr||(e=this.source.wrap(e)),this.inlineStack.push(e),e},pushStackLiteral:function(e){this.push(new Wr(e))},pushSource:function(e){this.pendingContent&&(this.source.push(this.appendToBuffer(this.source.quotedString(this.pendingContent),this.pendingLocation)),this.pendingContent=void 0),e&&this.source.push(e)},replaceStack:function(e){var n=["("],r=void 0,i=void 0,o=void 0;if(!this.isInline())throw new yd.default("replaceStack on non-inline");var s=this.popStack(!0);if(s instanceof Wr)r=[s.value],n=["(",r],o=!0;else{i=!0;var a=this.incrStack();n=["((",this.push(a)," = ",s,")"],r=this.topStack()}var c=e.call(this,r);o||this.popStack(),i&&this.stackSlot--,this.push(n.concat(c,")"))},incrStack:function(){return this.stackSlot++,this.stackSlot>this.stackVars.length&&this.stackVars.push("stack"+this.stackSlot),this.topStackName()},topStackName:function(){return"stack"+this.stackSlot},flushInline:function(){var e=this.inlineStack;this.inlineStack=[];for(var n=0,r=e.length;n<r;n++){var i=e[n];if(i instanceof Wr)this.compileStack.push(i);else{var o=this.incrStack();this.pushSource([o," = ",i,";"]),this.compileStack.push(o)}}},isInline:function(){return this.inlineStack.length},popStack:function(e){var n=this.isInline(),r=(n?this.inlineStack:this.compileStack).pop();if(!e&&r instanceof Wr)return r.value;if(!n){if(!this.stackSlot)throw new yd.default("Invalid stack pop");this.stackSlot--}return r},topStack:function(){var e=this.isInline()?this.inlineStack:this.compileStack,n=e[e.length-1];return n instanceof Wr?n.value:n},contextName:function(e){return this.useDepths&&e?"depths["+e+"]":"depth"+e},quotedString:function(e){return this.source.quotedString(e)},objectLiteral:function(e){return this.source.objectLiteral(e)},aliasable:function(e){var n=this.aliases[e];return n?(n.referenceCount++,n):(n=this.aliases[e]=this.source.wrap(e),n.aliasable=!0,n.referenceCount=1,n)},setupHelper:function(e,n,r){var i=[],o=this.setupHelperArgs(n,e,i,r),s=this.nameLookup("helpers",n,"helper"),a=this.aliasable(this.contextName(0)+" != null ? "+this.contextName(0)+" : (container.nullContext || {})");return{params:i,paramsInit:o,name:s,callParams:[a].concat(i)}},setupParams:function(e,n,r){var i={},o=[],s=[],a=[],c=!r,l=void 0;c&&(r=[]),i.name=this.quotedString(e),i.hash=this.popStack(),this.trackIds&&(i.hashIds=this.popStack()),this.stringParams&&(i.hashTypes=this.popStack(),i.hashContexts=this.popStack());var p=this.popStack(),d=this.popStack();(d||p)&&(i.fn=d||"container.noop",i.inverse=p||"container.noop");for(var f=n;f--;)l=this.popStack(),r[f]=l,this.trackIds&&(a[f]=this.popStack()),this.stringParams&&(s[f]=this.popStack(),o[f]=this.popStack());return c&&(i.args=this.source.generateArray(r)),this.trackIds&&(i.ids=this.source.generateArray(a)),this.stringParams&&(i.types=this.source.generateArray(s),i.contexts=this.source.generateArray(o)),this.options.data&&(i.data="data"),this.useBlockParams&&(i.blockParams="blockParams"),i},setupHelperArgs:function(e,n,r,i){var o=this.setupParams(e,n,r);return o.loc=eb(this),o=this.objectLiteral(o),i?(this.useRegister("options"),r.push("options"),["options=",o]):r?(r.push(o),""):o}};(function(){for(var t="break else new var case finally return void catch for switch while continue function this with default if throw delete in try do instanceof typeof abstract enum int short boolean export interface static byte extends long super char final native synchronized class float package throws const goto private transient debugger implements protected volatile double import public let yield await null true false".split(" "),e=Ur.RESERVED_WORDS={},n=0,r=t.length;n<r;n++)e[t[n]]=!0})();Ur.isValidJavaScriptVariableName=function(t){return!Ur.RESERVED_WORDS[t]&&/^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(t)};function eb(t){var e=t.source.currentLocation;return e?Zv.safeJsonLiteral(e):"undefined"}function OI(t,e,n,r,i){var o=e.popStack(),s=n.length;t&&s--;for(var a=r;a<s;a++)o=e.nameLookup(o,n[a],i);return t?[e.aliasable("container.strict"),"(",o,", ",e.quotedString(n[s]),", ",eb(e)," )"]:o}_a.default=Ur;tb.exports=_a.default});var ob=$((xa,ib)=>{"use strict";xa.__esModule=!0;function go(t){return t&&t.__esModule?t:{default:t}}var NI=nv(),MI=go(NI),VI=Wp(),LI=go(VI),wd=gv(),vd=_v(),jI=nb(),DI=go(jI),FI=pa(),qI=go(FI),BI=Fp(),HI=go(BI),WI=MI.default.create;function rb(){var t=WI();return t.compile=function(e,n){return vd.compile(e,n,t)},t.precompile=function(e,n){return vd.precompile(e,n,t)},t.AST=LI.default,t.Compiler=vd.Compiler,t.JavaScriptCompiler=DI.default,t.Parser=wd.parser,t.parse=wd.parse,t.parseWithoutProcessing=wd.parseWithoutProcessing,t}var zr=rb();zr.create=rb;HI.default(zr);zr.Visitor=qI.default;zr.default=zr;xa.default=zr;ib.exports=xa.default});var sb=$($a=>{"use strict";$a.__esModule=!0;$a.print=JI;$a.PrintVisitor=ke;function UI(t){return t&&t.__esModule?t:{default:t}}var zI=pa(),GI=UI(zI);function JI(t){return new ke().accept(t)}function ke(){this.padding=0}ke.prototype=new GI.default;ke.prototype.pad=function(t){for(var e="",n=0,r=this.padding;n<r;n++)e+=" ";return e+=t+`
|
|
182
|
-
`,e};ke.prototype.Program=function(t){var e="",n=t.body,r=void 0,i=void 0;if(t.blockParams){var o="BLOCK PARAMS: [";for(r=0,i=t.blockParams.length;r<i;r++)o+=" "+t.blockParams[r];o+=" ]",e+=this.pad(o)}for(r=0,i=n.length;r<i;r++)e+=this.accept(n[r]);return this.padding--,e};ke.prototype.MustacheStatement=function(t){return this.pad("{{ "+this.SubExpression(t)+" }}")};ke.prototype.Decorator=function(t){return this.pad("{{ DIRECTIVE "+this.SubExpression(t)+" }}")};ke.prototype.BlockStatement=ke.prototype.DecoratorBlock=function(t){var e="";return e+=this.pad((t.type==="DecoratorBlock"?"DIRECTIVE ":"")+"BLOCK:"),this.padding++,e+=this.pad(this.SubExpression(t)),t.program&&(e+=this.pad("PROGRAM:"),this.padding++,e+=this.accept(t.program),this.padding--),t.inverse&&(t.program&&this.padding++,e+=this.pad("{{^}}"),this.padding++,e+=this.accept(t.inverse),this.padding--,t.program&&this.padding--),this.padding--,e};ke.prototype.PartialStatement=function(t){var e="PARTIAL:"+t.name.original;return t.params[0]&&(e+=" "+this.accept(t.params[0])),t.hash&&(e+=" "+this.accept(t.hash)),this.pad("{{> "+e+" }}")};ke.prototype.PartialBlockStatement=function(t){var e="PARTIAL BLOCK:"+t.name.original;return t.params[0]&&(e+=" "+this.accept(t.params[0])),t.hash&&(e+=" "+this.accept(t.hash)),e+=" "+this.pad("PROGRAM:"),this.padding++,e+=this.accept(t.program),this.padding--,this.pad("{{> "+e+" }}")};ke.prototype.ContentStatement=function(t){return this.pad("CONTENT[ '"+t.value+"' ]")};ke.prototype.CommentStatement=function(t){return this.pad("{{! '"+t.value+"' }}")};ke.prototype.SubExpression=function(t){for(var e=t.params,n=[],r=void 0,i=0,o=e.length;i<o;i++)n.push(this.accept(e[i]));return e="["+n.join(", ")+"]",r=t.hash?" "+this.accept(t.hash):"",this.accept(t.path)+" "+e+r};ke.prototype.PathExpression=function(t){var e=t.parts.join("/");return(t.data?"@":"")+"PATH:"+e};ke.prototype.StringLiteral=function(t){return'"'+t.value+'"'};ke.prototype.NumberLiteral=function(t){return"NUMBER{"+t.value+"}"};ke.prototype.BooleanLiteral=function(t){return"BOOLEAN{"+t.value+"}"};ke.prototype.UndefinedLiteral=function(){return"UNDEFINED"};ke.prototype.NullLiteral=function(){return"NULL"};ke.prototype.Hash=function(t){for(var e=t.pairs,n=[],r=0,i=e.length;r<i;r++)n.push(this.accept(e[r]));return"HASH{"+n.join(", ")+"}"};ke.prototype.HashPair=function(t){return t.key+"="+this.accept(t.value)}});var ub=$((
|
|
182
|
+
`,e};ke.prototype.Program=function(t){var e="",n=t.body,r=void 0,i=void 0;if(t.blockParams){var o="BLOCK PARAMS: [";for(r=0,i=t.blockParams.length;r<i;r++)o+=" "+t.blockParams[r];o+=" ]",e+=this.pad(o)}for(r=0,i=n.length;r<i;r++)e+=this.accept(n[r]);return this.padding--,e};ke.prototype.MustacheStatement=function(t){return this.pad("{{ "+this.SubExpression(t)+" }}")};ke.prototype.Decorator=function(t){return this.pad("{{ DIRECTIVE "+this.SubExpression(t)+" }}")};ke.prototype.BlockStatement=ke.prototype.DecoratorBlock=function(t){var e="";return e+=this.pad((t.type==="DecoratorBlock"?"DIRECTIVE ":"")+"BLOCK:"),this.padding++,e+=this.pad(this.SubExpression(t)),t.program&&(e+=this.pad("PROGRAM:"),this.padding++,e+=this.accept(t.program),this.padding--),t.inverse&&(t.program&&this.padding++,e+=this.pad("{{^}}"),this.padding++,e+=this.accept(t.inverse),this.padding--,t.program&&this.padding--),this.padding--,e};ke.prototype.PartialStatement=function(t){var e="PARTIAL:"+t.name.original;return t.params[0]&&(e+=" "+this.accept(t.params[0])),t.hash&&(e+=" "+this.accept(t.hash)),this.pad("{{> "+e+" }}")};ke.prototype.PartialBlockStatement=function(t){var e="PARTIAL BLOCK:"+t.name.original;return t.params[0]&&(e+=" "+this.accept(t.params[0])),t.hash&&(e+=" "+this.accept(t.hash)),e+=" "+this.pad("PROGRAM:"),this.padding++,e+=this.accept(t.program),this.padding--,this.pad("{{> "+e+" }}")};ke.prototype.ContentStatement=function(t){return this.pad("CONTENT[ '"+t.value+"' ]")};ke.prototype.CommentStatement=function(t){return this.pad("{{! '"+t.value+"' }}")};ke.prototype.SubExpression=function(t){for(var e=t.params,n=[],r=void 0,i=0,o=e.length;i<o;i++)n.push(this.accept(e[i]));return e="["+n.join(", ")+"]",r=t.hash?" "+this.accept(t.hash):"",this.accept(t.path)+" "+e+r};ke.prototype.PathExpression=function(t){var e=t.parts.join("/");return(t.data?"@":"")+"PATH:"+e};ke.prototype.StringLiteral=function(t){return'"'+t.value+'"'};ke.prototype.NumberLiteral=function(t){return"NUMBER{"+t.value+"}"};ke.prototype.BooleanLiteral=function(t){return"BOOLEAN{"+t.value+"}"};ke.prototype.UndefinedLiteral=function(){return"UNDEFINED"};ke.prototype.NullLiteral=function(){return"NULL"};ke.prototype.Hash=function(t){for(var e=t.pairs,n=[],r=0,i=e.length;r<i;r++)n.push(this.accept(e[r]));return"HASH{"+n.join(", ")+"}"};ke.prototype.HashPair=function(t){return t.key+"="+this.accept(t.value)}});var ub=$((gL,lb)=>{var Sa=ob().default,cb=sb();Sa.PrintVisitor=cb.PrintVisitor;Sa.print=cb.print;lb.exports=Sa;function ab(t,e){var n=_t("fs"),r=n.readFileSync(e,"utf8");t.exports=Sa.compile(r)}typeof _t<"u"&&_t.extensions&&(_t.extensions[".handlebars"]=ab,_t.extensions[".hbs"]=ab)});import{readFile as KI}from"node:fs/promises";import{resolve as YI}from"node:path";async function It(t,e,n){let r=YI(t,e),i=pb.get(r);if(!i){let o=await KI(r,"utf-8");i=db.default.compile(o,{noEscape:!0}),pb.set(r,i)}return i(n)}var db,pb,yo=K(()=>{"use strict";db=Ua(ub(),1),pb=new Map});var bd=K(()=>{"use strict";Nr()});import{readFile as fb,writeFile as XI,mkdir as QI,stat as ZI,rm as eA,unlink as tA}from"node:fs/promises";import{resolve as Qt}from"node:path";async function hb(t){try{return await ZI(t),!0}catch{return!1}}async function _d(t){let e=Qt(t,"..");for(let n of[Qt(t,"runtime"),Qt(e,"components"),Qt(e,"runtime")])await hb(n)&&await eA(n,{recursive:!0,force:!0});for(let n of["extensions.tsx","extensions.ts","contracts.ts"]){let r=Qt(t,n);await hb(r)&&await tA(r)}}function nA(t){return t.replace(/^import type \{ DispatchableAction \} from [^;]+;\n/gm,"")}async function mb(t,e,n){let r=ye(t),i=e.generated.reactDir,o=wo(n??(e.rendererTemplatesDir?Qt(r,e.rendererTemplatesDir):void 0)),s=Gr();await QI(i,{recursive:!0}),await _d(i);let a=await fb(Qt(s,"types.ts"),"utf-8"),c=await fb(Qt(s,"style.ts"),"utf-8"),l=await It(o,"dispatch.ts.hbs",{}),p=nA(l),d=await It(o,"runtime.ts.hbs",{typesBody:a.trim(),styleBody:c.trim(),dispatchBody:p.trim()}),f=Qt(i,"runtime.ts");return await XI(f,d,"utf-8"),{runtimePath:f}}var gb=K(()=>{"use strict";xt();yo();bd()});var wb={};Pn(wb,{renderReactRuntime:()=>uA});import{writeFile as yb,stat as rA,unlink as iA}from"node:fs/promises";import{relative as oA,resolve as Jr}from"node:path";async function sA(t){try{return await rA(t),!0}catch{return!1}}async function aA(t,e,n,r){let i=await so(n,t),o=await It(wo(r),"theme.css.hbs",{themeCss:i});await yb(e,o,"utf-8")}async function cA(t){let e=Jr(t,"..");for(let n of["theme.css","contracts.ts","view-bridge.generated.ts"]){let r=Jr(e,n);await sA(r)&&await iA(r)}}async function lA(t,e){let n=ye(t),r=e.generated.reactDir,i=Jr(n,"src/components/extensions.tsx"),o=oA(r,i).replace(/\\/g,"/");o.startsWith(".")||(o=`./${o}`);let s=o.replace(/\.tsx?$/,".js"),a=Jr(r,"extensions.generated.ts");return await yb(a,`/** Auto-generated extension re-export \u2014 DO NOT EDIT */
|
|
183
183
|
export * from '${s}';
|
|
184
184
|
`,"utf-8"),a}async function uA(t,e){let n=ye(t),r=e.rendererTemplatesDir?Jr(n,e.rendererTemplatesDir):void 0,i=e.generated.reactDir;await cA(i),await _d(i);let{runtimePath:o}=await mb(t,e,r),s=await lA(t,e),a=Jr(i,"theme.css");await aA(t,a,e,r),console.log(` react/runtime \u2192 ${o}`),console.log(` react/extensions \u2192 ${s}`),console.log(` react/theme \u2192 ${a}`)}var vb=K(()=>{"use strict";xt();Fs();yo();bd();gb()});function pA(t,e){return t.entries.find(r=>r.path===e)?.value??""}function dA(t){let e=t.match(/^#([0-9a-fA-F]{6})$/);if(!e)return null;let n=e[1],r=parseInt(n.slice(0,2),16),i=parseInt(n.slice(2,4),16),o=parseInt(n.slice(4,6),16);return`Color(red: ${(r/255).toFixed(3)}, green: ${(i/255).toFixed(3)}, blue: ${(o/255).toFixed(3)})`}function er(t){let e=t.match(/^([\d.]+)px$/);return e?Number(e[1]):null}function bb(t){return dA(t)??(t?`Color(${JSON.stringify(t)})`:null)}function _b(t,e){let n=[];for(let[r,i]of Object.entries(t)){let o=pA(e,i.ref);if(o)switch(r){case"background":case"foreground":{let s=bb(o);s&&n.push({property:r,swiftValue:s});break}case"padding":{let s=er(o);if(s!==null)n.push({property:r,swiftValue:String(s)});else{let a=o.trim().split(/\s+/);if(a.length===2){let c=er(a[0]),l=er(a[1]);c!==null&&n.push({property:"paddingV",swiftValue:String(c)}),l!==null&&n.push({property:"paddingH",swiftValue:String(l)})}}break}case"radius":case"fontSize":case"minHeight":case"maxWidth":{let s=er(o);s!==null&&n.push({property:r,swiftValue:String(s)});break}case"width":{if(o==="100%"||o==="fill")n.push({property:"widthFill",swiftValue:"true"});else{let s=er(o);s!==null&&n.push({property:r,swiftValue:String(s)})}break}case"height":{if(o==="100%"||o==="fill")n.push({property:"heightFill",swiftValue:"true"});else{let s=er(o);s!==null&&n.push({property:r,swiftValue:String(s)})}break}case"border":{let s=o.match(/^([\d.]+)px/);s&&n.push({property:"borderWidth",swiftValue:String(Number(s[1]))});break}case"borderColor":{let s=bb(o);s&&n.push({property:"borderColor",swiftValue:s});break}case"margin":{let s=er(o);s!==null&&n.push({property:r,swiftValue:String(s)});break}case"fontWeight":{let s=fA[o];s&&n.push({property:r,swiftValue:s});break}case"shadow":{n.push({property:r,swiftValue:o==="true"||o==="none"?"false":"true"});break}case"display":case"flexDirection":case"gridTemplateColumns":case"alignItems":case"justifyContent":case"typography":break;default:console.warn(`[view-contracts] SwiftUI theme: variant property "${r}" is not handled (value: "${o}"). Add a case to renderTheme.ts resolveVariantEntries().`);break}}return n}function $b(t,e){if(t.length===0)return`${e}VcVariantStyle()`;let r=[...t].sort((i,o)=>xb.indexOf(i.property)-xb.indexOf(o.property)).map(i=>`${i.property}: ${i.swiftValue}`).join(", ");return`${e}VcVariantStyle(${r})`}function hA(t,e){return{...t,...e}}function Sb(t,e){let n=[];n.push("/**"),n.push(" * Auto-generated SwiftUI theme \u2014 variant style dictionary."),n.push(" * Each entry is pre-merged: base theme defaults < variant overrides."),n.push(" * DO NOT EDIT \u2014 regenerate with: view-contracts build"),n.push(" */"),n.push("import SwiftUI"),n.push(""),n.push("struct VcVariantStyle {"),n.push(" var foreground: Color?"),n.push(" var background: Color?"),n.push(" var padding: CGFloat?"),n.push(" var paddingH: CGFloat?"),n.push(" var paddingV: CGFloat?"),n.push(" var widthFill: Bool?"),n.push(" var heightFill: Bool?"),n.push(" var radius: CGFloat?"),n.push(" var fontSize: CGFloat?"),n.push(" var fontWeight: Font.Weight?"),n.push(" var shadow: Bool?"),n.push(" var borderWidth: CGFloat?"),n.push(" var borderColor: Color?"),n.push(" var minHeight: CGFloat?"),n.push(" var maxWidth: CGFloat?"),n.push("}"),n.push(""),n.push("extension View {"),n.push(" func applyVcStyle(_ s: VcVariantStyle) -> some View {"),n.push(" self"),n.push(" .ifSet(s.foreground) { $0.foregroundStyle($1) }"),n.push(" .ifSet(s.fontSize) { $0.font(.system(size: $1, weight: s.fontWeight ?? .regular)) }"),n.push(" .ifSet(s.padding) { $0.padding($1) }"),n.push(" .ifSet(s.paddingH) { $0.padding(.horizontal, $1) }"),n.push(" .ifSet(s.paddingV) { $0.padding(.vertical, $1) }"),n.push(" .vcFillFrame(widthFill: s.widthFill ?? false, heightFill: s.heightFill ?? false)"),n.push(" .ifSet(s.background) { $0.background($1) }"),n.push(" .ifSet(s.radius) { $0.clipShape(RoundedRectangle(cornerRadius: $1)) }"),n.push(" .ifSet(s.borderColor) { $0.overlay(RoundedRectangle(cornerRadius: s.radius ?? 0).stroke($1, lineWidth: s.borderWidth ?? 1)) }"),n.push(" .ifSet(s.shadow) { v, on in on ? AnyView(v.shadow(color: Color.black.opacity(0.08), radius: 4, x: 0, y: 2)) : AnyView(v) }"),n.push(" }"),n.push("}"),n.push(""),n.push("extension View {"),n.push(" @ViewBuilder"),n.push(" func vcFillFrame(widthFill: Bool, heightFill: Bool) -> some View {"),n.push(" if widthFill && heightFill {"),n.push(" self.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)"),n.push(" } else if widthFill {"),n.push(" self.frame(maxWidth: .infinity, alignment: .leading)"),n.push(" } else if heightFill {"),n.push(" self.frame(maxHeight: .infinity, alignment: .top)"),n.push(" } else {"),n.push(" self"),n.push(" }"),n.push(" }"),n.push("}"),n.push(""),n.push("extension View {"),n.push(" @ViewBuilder"),n.push(" func ifSet<T, V: View>(_ value: T?, _ transform: (Self, T) -> V) -> some View {"),n.push(" if let value { transform(self, value) } else { self }"),n.push(" }"),n.push("}"),n.push(""),n.push("enum VcTheme {"),n.push(" static let defaults: [String: VcVariantStyle] = [");for(let[r,i]of Object.entries(t.defaults)){if(Object.keys(i).length===0)continue;let o=_b(i,e);o.length!==0&&n.push(` ${JSON.stringify(r)}: ${$b(o,"").trim()},`)}n.push(" ]"),n.push(""),n.push(" static let variants: [String: [String: VcVariantStyle]] = [");for(let[r,i]of Object.entries(t.variants)){let o=Object.entries(i);if(o.length===0)continue;let s=t.defaults[r]??{};n.push(` ${JSON.stringify(r)}: [`);for(let[a,c]of o){let l=hA(s,c),p=_b(l,e),d=$b(p," ");n.push(` ${JSON.stringify(a)}: ${d.trim()},`)}n.push(" ],")}return n.push(" ]"),n.push(""),n.push(" static func resolve(_ element: String, variant: String) -> VcVariantStyle {"),n.push(" variants[element]?[variant] ?? defaults[element] ?? VcVariantStyle()"),n.push(" }"),n.push("}"),n.push(""),n.join(`
|
|
185
185
|
`)}var fA,xb,Cb=K(()=>{"use strict";fA={bold:".bold",semibold:".semibold",medium:".medium",regular:".regular",600:".semibold",700:".bold",500:".medium",400:".regular"};xb=["foreground","background","padding","paddingH","paddingV","widthFill","heightFill","radius","fontSize","fontWeight","shadow","borderWidth","borderColor","minHeight","maxWidth"]});import{resolve as mA}from"node:path";function yA(t){for(let[e,n]of Object.entries(t.elements)){let r=n.container!==void 0&&n.container!==null,i=n.leaf!==void 0&&n.leaf!==null;if(r===i)throw new Error(`${gA}: element "${e}" must have exactly one of "container" or "leaf"`);(n.container==="vstack"||n.container==="hstack")&&n.spacingProp}}async function kb(t){if(!t&&xd)return xd;let e=t??mA(Ce(),"renderers/swiftui/elements.yaml"),n=await Pr(e);return yA(n),t||(xd=n),n}var gA,xd,Eb=K(()=>{"use strict";Vt();Rs();gA="renderers/swiftui/elements.yaml",xd=null});function wA(t,e){let n=t.entries.find(r=>r.path===e);if(!n)throw new Error(`Token reference "${e}" not found while merging visual props`);return n.value}function Pb(t,e){let n={};for(let[r,i]of Object.entries(t))n[r]=wA(e,i.ref);return n}function vA(t){let e={};for(let[n,r]of Object.entries(t))r!=null&&(typeof r=="string"||typeof r=="number"||typeof r=="boolean")&&(e[n]=r);return e}function Zt(t){let e=t.theme.defaults[t.elementName]??{},n=t.variantLiteral?t.theme.variants[t.elementName]?.[t.variantLiteral]??{}:{};return{...Pb(e,t.tokens),...Pb(n,t.tokens),...vA(t.instanceLiterals)}}var $d=K(()=>{"use strict"});function tr(t){let e=new Set,n=r=>{if(Array.isArray(r)){for(let i of r)n(i);return}if(!(typeof r!="object"||r===null)){if(r.kind==="binding"){r.scope&&e.add(r.scope);return}if(r.kind==="concat")for(let i of r.parts)typeof i!="string"&&n(i)}};for(let r of t)n(r);return e}function Ca(t,e){e&&t.emittedScopes?.add(e)}function Sd(t,e,n){let r=t.emittedScopes,i=new Set;t.emittedScopes=i;let o=e.filter(a=>t.optionalProps?.delete(a)),s=n();for(let a of o)t.optionalProps.add(a);return t.emittedScopes=r,{code:s,emitted:i}}function nr(t,e,n,r){let i=[...e].filter(c=>t.optionalProps?.has(c));if(i.length===0)return n();let o=Sd(t,[],n),s=i.filter(c=>o.emitted.has(c));if(s.length===0||!o.code)return o.code;let a=Sd(t,s,n).code;return r(s,a)}function en(t,e,n){return Sd(t,e,n).code}function ka(t,e){return t.split(`
|
|
@@ -432,7 +432,7 @@ cli_contracts: 0.1.0
|
|
|
432
432
|
|
|
433
433
|
info:
|
|
434
434
|
title: view-contracts CLI
|
|
435
|
-
version: 0.5.
|
|
435
|
+
version: 0.5.17
|
|
436
436
|
description: >-
|
|
437
437
|
Contract-first UI design toolchain. Compiles restricted view-contract TSX
|
|
438
438
|
to language-neutral View IR and renders platform targets (React, SwiftUI, Compose).
|
|
@@ -635,7 +635,7 @@ command_sets:
|
|
|
635
635
|
"cli_contracts": "0.1.0",
|
|
636
636
|
"info": {
|
|
637
637
|
"title": "view-contracts CLI",
|
|
638
|
-
"version": "0.5.
|
|
638
|
+
"version": "0.5.17",
|
|
639
639
|
"description": "Contract-first UI design toolchain. Compiles restricted view-contract TSX to language-neutral View IR and renders platform targets (React, SwiftUI, Compose)."
|
|
640
640
|
},
|
|
641
641
|
"artifact_slots": {
|
|
@@ -939,7 +939,7 @@ ${o.errors.map(s=>` - ${s}`).join(`
|
|
|
939
939
|
${i.errors.map(a=>` - ${a}`).join(`
|
|
940
940
|
`)}`);let o={version:1,source:yi(e.projectRoot,Cf(t.sourcePath)),viewModel:i.viewModel,exportName:i.exportName,root:i.root},s=await H0(o.root,{...e,targets:t.targets??e.targets});if(e.extensionRegistry){let a=xf(o.root,s.map(c=>c.root),e.extensionRegistry,t.targets??["react"],{screen:o.source,partials:s.map(c=>c.source)});if(a.errors.length>0)throw new Error(`Extension validation errors in ${t.sourcePath}:
|
|
941
941
|
${a.errors.map(c=>` - ${c}`).join(`
|
|
942
|
-
`)}`);i.warnings.push(...a.warnings)}await $f([o,...s],e.allowlistExtra);for(let a of i.warnings)console.warn(`Warning in ${t.sourcePath}: ${a}`);return{screen:o,partials:s}}async function kf(t,e){let n=[],r=new Map;for(let i of t){let o=await bc(i,e);n.push(o.screen);for(let s of o.partials){let a=`${s.source}:${s.exportName}`;r.set(a,s)}}return{screens:n,partials:[...r.values()]}}xt();var Ry=Ua(Py(),1);ur();Vt();import{readFile as Iy}from"node:fs/promises";import{resolve as Ay}from"node:path";var Yk=Ry.default,Xk=Ay(Ce(),"spec/ui-dsl-extensions.meta.json"),ks;async function Qk(){if(ks)return ks;let t=JSON.parse(await Iy(Xk,"utf-8"));return ks=new Yk({allErrors:!0,strict:!1}).compile(t),ks}async function Es(t){if(!t)return{extensions:{}};let e=Ay(t),n=await Iy(e,"utf-8"),r=pt.load(n),i=await Qk();if(!i(r)){let o=i.errors?.map(s=>`${s.instancePath||"/"} ${s.message??""}`).join("; ")??"unknown";throw new Error(`Extension registry validation failed (${e}): ${o}`)}return r}Nr();import{resolve as VT}from"node:path";async function Bd(t,e,n){return(await ri()).renderReactFromIr(t,e,n)}async function j_(t,e,n){return(await ri()).renderReactPreviewBundle(t,e,n)}function D_(t,e){return VT(t,"components",`${e.exportName}.generated.tsx`)}async function F_(t,e){return(await ri()).renderReactRuntime(t,e)}async function q_(t,e,n,r,i){return(await ri()).renderSwiftUIRuntime(t,e,n,r,i)}async function B_(t,e,n,r,i){return(await ri()).renderComposeRuntime(t,e,n,r,i)}Ds();xt();import{access as FT,writeFile as rn,mkdir as Ma}from"node:fs/promises";import{resolve as et,dirname as W_}from"node:path";Vt();nt();nt();import{readFile as LT}from"node:fs/promises";import{resolve as jT}from"node:path";var DT=Ce();async function H_(t=DT){let e=jT(t,"package.json"),n=await LT(e,"utf-8"),r=JSON.parse(n);if(!r.version)throw new Error(`package.json missing version: ${e}`);return
|
|
942
|
+
`)}`);i.warnings.push(...a.warnings)}await $f([o,...s],e.allowlistExtra);for(let a of i.warnings)console.warn(`Warning in ${t.sourcePath}: ${a}`);return{screen:o,partials:s}}async function kf(t,e){let n=[],r=new Map;for(let i of t){let o=await bc(i,e);n.push(o.screen);for(let s of o.partials){let a=`${s.source}:${s.exportName}`;r.set(a,s)}}return{screens:n,partials:[...r.values()]}}xt();var Ry=Ua(Py(),1);ur();Vt();import{readFile as Iy}from"node:fs/promises";import{resolve as Ay}from"node:path";var Yk=Ry.default,Xk=Ay(Ce(),"spec/ui-dsl-extensions.meta.json"),ks;async function Qk(){if(ks)return ks;let t=JSON.parse(await Iy(Xk,"utf-8"));return ks=new Yk({allErrors:!0,strict:!1}).compile(t),ks}async function Es(t){if(!t)return{extensions:{}};let e=Ay(t),n=await Iy(e,"utf-8"),r=pt.load(n),i=await Qk();if(!i(r)){let o=i.errors?.map(s=>`${s.instancePath||"/"} ${s.message??""}`).join("; ")??"unknown";throw new Error(`Extension registry validation failed (${e}): ${o}`)}return r}Nr();import{resolve as VT}from"node:path";async function Bd(t,e,n){return(await ri()).renderReactFromIr(t,e,n)}async function j_(t,e,n){return(await ri()).renderReactPreviewBundle(t,e,n)}function D_(t,e){return VT(t,"components",`${e.exportName}.generated.tsx`)}async function F_(t,e){return(await ri()).renderReactRuntime(t,e)}async function q_(t,e,n,r,i){return(await ri()).renderSwiftUIRuntime(t,e,n,r,i)}async function B_(t,e,n,r,i){return(await ri()).renderComposeRuntime(t,e,n,r,i)}Ds();xt();import{access as FT,writeFile as rn,mkdir as Ma}from"node:fs/promises";import{resolve as et,dirname as W_}from"node:path";Vt();nt();nt();import{readFile as LT}from"node:fs/promises";import{resolve as jT}from"node:path";var DT=Ce();async function H_(t=DT){let e=jT(t,"package.json"),n=await LT(e,"utf-8"),r=JSON.parse(n);if(!r.version)throw new Error(`package.json missing version: ${e}`);return{version:r.version,peerDependencies:r.peerDependencies??{}}}rr();async function Hd(t){try{return await FT(t),!0}catch{return!1}}var ii={preview:5173,app:5174,built:4174};function qT(t){let e=t.peerDependencies.vite;if(!e)throw new Error("view-contracts package.json declares no vite peer range");return`{
|
|
943
943
|
"name": "admin-dashboard",
|
|
944
944
|
"private": true,
|
|
945
945
|
"type": "module",
|
|
@@ -958,10 +958,10 @@ ${a.errors.map(c=>` - ${c}`).join(`
|
|
|
958
958
|
"react-dom": "^19.2.0"
|
|
959
959
|
},
|
|
960
960
|
"devDependencies": {
|
|
961
|
-
"@vitejs/plugin-react": "^
|
|
961
|
+
"@vitejs/plugin-react": "^5.2.0",
|
|
962
962
|
"typescript": "^5.9.3",
|
|
963
|
-
"view-contracts": "^${t}",
|
|
964
|
-
"vite":
|
|
963
|
+
"view-contracts": "^${t.version}",
|
|
964
|
+
"vite": ${JSON.stringify(e)}
|
|
965
965
|
}
|
|
966
966
|
}
|
|
967
967
|
`}var BT=`import '../src/main.tsx';
|
|
@@ -1097,6 +1097,6 @@ ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
|
|
|
1097
1097
|
);
|
|
1098
1098
|
`,s=La(t,"entry.tsx");return await Wd(s,o,"utf8"),s}async function Ud(t,e,n){let r=await Je(t),o=(await Tt(r.bindings)).views.find(E=>E.screenName===e);if(!o)throw new Error(`No view binding for screen "${e}"`);if(!o.targets.includes("react"))throw new Error(`Screen "${e}" is not a react target`);let s=ye(t),[a,c,l]=await Promise.all([z_(t,e),Hb(t,r,e),so(r,t)]),p=tO(o.exportName),d=Kr(e),f=La(s,"node_modules",".view-contracts-preview",String(process.pid));await ZT(f,{recursive:!0});let m=await iO(f,a,c,p,d),y=Ce(),g=[on(s,"node_modules"),on(y,"node_modules")],w=await eO({entryPoints:[m],bundle:!0,write:!1,format:"esm",platform:"browser",target:"es2022",jsx:"automatic",jsxImportSource:"react",absWorkingDir:s,nodePaths:g,alias:nO(s),logLevel:"silent"});if(w.errors.length>0)throw new Error(w.errors.map(E=>E.text).join(`
|
|
1099
1099
|
`));let b=w.outputFiles[0]?.text??"";return{html:rO(),themeCss:l,bundleJs:b,version:n}}async function G_(t,e){let n=await Tt((await Je(t)).bindings);if(e){let i=n.views.find(o=>o.screenName===e);if(!i)throw new Error(`Unknown screen "${e}" in view-bindings.yaml`);if(!i.targets.includes("react"))throw new Error(`Screen "${e}" is not a react target`);return e}let r=n.views.find(i=>i.targets.includes("react"));if(!r)throw new Error("No react target views in view-bindings.yaml");return r.screenName}rr();function oi(t,e,n,r){t.writeHead(e,{"Content-Type":r,"Cache-Control":"no-store"}),t.end(n)}function cO(t,e){if(!t)return!1;let n=(t.startsWith("[")?t.slice(1,t.indexOf("]")):t.replace(/:\d+$/,"")).toLowerCase();return aO(n)!==0||n==="localhost"||n.endsWith(".localhost")||n===e.toLowerCase()}function lO(t,e,n,r){if(!cO(t.headers.host,r)){oi(e,403,`Host not allowed: ${t.headers.host??"(none)"}. Start preview with --host <name> to serve that name.`,"text/plain; charset=utf-8");return}let i=t.url?.split("?")[0]??"/";if(i==="/"||i==="/index.html"){oi(e,200,n.html,"text/html; charset=utf-8");return}if(i==="/bundle.js"){oi(e,200,n.bundleJs,"text/javascript; charset=utf-8");return}if(i==="/theme.css"){oi(e,200,n.themeCss,"text/css; charset=utf-8");return}if(i==="/__vc-reload"){oi(e,200,JSON.stringify({version:n.version}),"application/json");return}oi(e,404,"Not found","text/plain; charset=utf-8")}async function uO(t,e,n){let r=await Je(t),i=ye(t),{tokensPath:o,themePath:s}=dn(r),a=await Wb(t,r),c=L_(),l=[or(i,r.viewsDir),or(i,o),or(i,s),a,c];r.extensions&&l.push(or(i,r.extensions)),r.design?.extensionsCss&&l.push(or(i,r.design.extensionsCss)),l.push(or(i,"contracts/view-models.ts")),l.push(or(i,"src/components/extensions.tsx"));let p,d=()=>{p&&clearTimeout(p),p=setTimeout(()=>n(),150)},f=[];for(let y of l)await Yr(y)&&f.push(y);let m=f.map(y=>sO(y,{recursive:!0},()=>d()));return()=>{p&&clearTimeout(p);for(let y of m)y.close()}}async function J_(t){let e=t.port??5173,n=t.host??"127.0.0.1",r=await G_(t.configPath,t.screen),i=0,o=await Ud(t.configPath,r,i),s=!1,a=!1,c=async()=>{if(s){a=!0;return}s=!0;try{i+=1,o=await Ud(t.configPath,r,i),console.log(`[preview] rebuilt (v${i})`)}catch(f){let m=f instanceof Error?f.message:String(f);console.error(`[preview] compile error:
|
|
1100
|
-
${m}`)}finally{s=!1,a&&(a=!1,c())}},l=oO((f,m)=>lO(f,m,o,n));await new Promise((f,m)=>{l.once("error",m),l.listen(e,n,()=>f())});let p=`http://${n}:${e}/`;console.log(`[preview] ${r} \u2192 ${p}`),console.log("[preview] watching views/ and design files (Ctrl+C to stop)");let d=await uO(t.configPath,r,()=>{c()});await new Promise(f=>{let m=()=>{d(),l.close(()=>f())};process.once("SIGINT",m),process.once("SIGTERM",m)})}async function Q_(t){if(!t.extensions)return{allowlistExtra:t.allowlistExtra??[]};let e=await Es(t.extensions),n=[...new Set([...t.allowlistExtra??[],...Object.keys(e.extensions)])];return{extensionRegistry:e,allowlistExtra:n}}async function K_(t){await new Promise((
|
|
1101
|
-
`),"utf-8"),console.log(`Bridge registry \u2192 ${e.generated.bridge} (${n.views.length} view(s))`)}var Z_={compile:async(t,e)=>{let{screens:n,partials:r}=await zd(await pn(t.config));console.log(`Compiled ${n.size} screen(s) and ${r.length} partial(s) to View IR (in-memory)`)},renderReact:async(t,e)=>{let n=await pn(t.config),{screens:r,partials:i}=await zd(n);await Y_(n,r,i)},renderBridge:async(t,e)=>{await X_(await pn(t.config))},build:async(t,e)=>{let n=await pn(t.config),r=await Je(n),i=await Tt(r.bindings),{screens:o,partials:s}=await zd(n);console.log(`Compiled ${o.size} screen(s) and ${s.length} partial(s) to View IR (in-memory)`);let{tokensPath:a,themePath:c}=dn(r),{tokenIR:l,themeIR:p}=await Or(a,c);await zn(r,n),oo([...o.values(),...s],p),await F_(n,r),await Y_(n,o,s),await X_(n),await q_(n,r,i,{theme:p,tokens:l},{screens:o,partials:s}),await B_(n,r,i,{theme:p,tokens:l},{screens:o,partials:s}),await U_(n,r,i)},contractsGenerate:async(t,e)=>{let n=await
|
|
1100
|
+
${m}`)}finally{s=!1,a&&(a=!1,c())}},l=oO((f,m)=>lO(f,m,o,n));await new Promise((f,m)=>{l.once("error",m),l.listen(e,n,()=>f())});let p=`http://${n}:${e}/`;console.log(`[preview] ${r} \u2192 ${p}`),console.log("[preview] watching views/ and design files (Ctrl+C to stop)");let d=await uO(t.configPath,r,()=>{c()});await new Promise(f=>{let m=()=>{d(),l.close(()=>f())};process.once("SIGINT",m),process.once("SIGTERM",m)})}async function Q_(t){if(!t.extensions)return{allowlistExtra:t.allowlistExtra??[]};let e=await Es(t.extensions),n=[...new Set([...t.allowlistExtra??[],...Object.keys(e.extensions)])];return{extensionRegistry:e,allowlistExtra:n}}async function K_(t,e){await new Promise((n,r)=>{let i=hO("npx",["micro-contracts",...e],{stdio:"inherit",cwd:ye(t)});i.on("error",r),i.on("close",o=>{o===0?n():r(new Error(`micro-contracts exited with code ${o}`))})})}async function zd(t){let e=await Je(t),n=await Tt(e.bindings),{extensionRegistry:r,allowlistExtra:i}=await Q_(e),o=ye(t),{screens:s,partials:a}=await kf(n.views.map(c=>({sourcePath:kn(o,c.source),exportName:c.exportName,screenName:c.screenName,targets:c.targets})),{projectRoot:o,allowlistExtra:i,extensionRegistry:r});return{screens:new Map(n.views.map((c,l)=>[c.screenName,s[l]])),partials:a}}async function Y_(t,e,n){let r=await Je(t),i=ye(t),{allowlistExtra:o}=await Q_(r),s=await Tt(r.bindings);for(let a of n){let c=kn(r.generated.reactDir,"components",`${a.exportName}.generated.tsx`),l=ut(c,pr(r)),p=ut(c,kn(r.generated.reactDir,"extensions.generated.ts")),d=ut(c,kn(i,"contracts/view-models.ts"));await Bd(a,c,{runtimeImportFrom:l,extensionsImportFrom:p,contractsImportFrom:d,allowlistExtra:o}),console.log(` ${a.exportName} \u2192 ${c}`)}for(let a of s.views){if(!a.targets.includes("react"))continue;let c=e.get(a.screenName);if(!c)throw new Error(`Missing View IR for ${a.screenName}`);let l=Bo(r,a),p=ut(l,pr(r)),d=ut(l,kn(r.generated.reactDir,"extensions.generated.ts")),f=ut(l,kn(i,"contracts/view-models.ts")),m=new Map;for(let y of n){let g=D_(r.generated.reactDir,y);m.set(y.exportName,ut(l,g))}await Bd(c,l,{runtimeImportFrom:p,extensionsImportFrom:d,contractsImportFrom:f,allowlistExtra:o,viewRefImportFrom:m}),console.log(` ${a.exportName} \u2192 ${l}`)}}async function X_(t){let e=await Je(t),n=await Tt(e.bindings),r=ye(t),o=["// Auto-generated view bridge registry \u2014 DO NOT EDIT",`// Generated from ${yi(r,e.bindings)}`,"","export const viewBridgeRegistry = {"];for(let s of n.views)o.push(` ${s.screenConst}: {`),o.push(` id: ${JSON.stringify(s.id)},`),o.push(` screenId: ${JSON.stringify(s.screenId)},`),o.push(` screenName: ${JSON.stringify(s.screenName)},`),o.push(` route: ${JSON.stringify(s.route)},`),o.push(` operationId: ${JSON.stringify(s.operationId)},`),o.push(` viewModel: ${JSON.stringify(s.viewModel)},`),o.push(` source: ${JSON.stringify(s.source)},`),o.push(` targets: ${JSON.stringify(s.targets)},`),o.push(" },");o.push("} as const;",""),o.push("export type ViewBridgeKey = keyof typeof viewBridgeRegistry;",""),await dO(fO(kn(e.generated.bridge)),{recursive:!0}),await pO(kn(e.generated.bridge),o.join(`
|
|
1101
|
+
`),"utf-8"),console.log(`Bridge registry \u2192 ${e.generated.bridge} (${n.views.length} view(s))`)}var Z_={compile:async(t,e)=>{let{screens:n,partials:r}=await zd(await pn(t.config));console.log(`Compiled ${n.size} screen(s) and ${r.length} partial(s) to View IR (in-memory)`)},renderReact:async(t,e)=>{let n=await pn(t.config),{screens:r,partials:i}=await zd(n);await Y_(n,r,i)},renderBridge:async(t,e)=>{await X_(await pn(t.config))},build:async(t,e)=>{let n=await pn(t.config),r=await Je(n),i=await Tt(r.bindings),{screens:o,partials:s}=await zd(n);console.log(`Compiled ${o.size} screen(s) and ${s.length} partial(s) to View IR (in-memory)`);let{tokensPath:a,themePath:c}=dn(r),{tokenIR:l,themeIR:p}=await Or(a,c);await zn(r,n),oo([...o.values(),...s],p),await F_(n,r),await Y_(n,o,s),await X_(n),await q_(n,r,i,{theme:p,tokens:l},{screens:o,partials:s}),await B_(n,r,i,{theme:p,tokens:l},{screens:o,partials:s}),await U_(n,r,i)},contractsGenerate:async(t,e)=>{let n=await pn(t.config),r=await Je(n);await K_(n,["generate","-c",r.microContractsConfig]),console.log("Contracts generated via micro-contracts")},contractsCheck:async(t,e)=>{let n=await pn(t.config),r=await Je(n);await K_(n,["lint",r.openapi])},preview:async(t,e)=>{try{await J_({configPath:await pn(t.config),port:t.port!=null?Number(t.port):void 0,host:t.host,screen:t.screen})}catch(n){console.error(n instanceof Error?n.message:n),process.exit(1)}}};var mO={version:"0.5.17"};uf(Z_,mO.version).parseAsync(process.argv).catch(t=>{console.error(t instanceof Error?t.message:t),process.exit(1)});
|
|
1102
1102
|
//# sourceMappingURL=view-contracts.bundle.mjs.map
|