@knapsack/types 4.70.0--canary.3797.b249674.0 → 4.70.0--canary.4821.56b0218.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/acd-test-fixtures/index.js +10246 -78
- package/dist/acd-test-fixtures/index.js.map +1 -1
- package/dist/acd-test-fixtures/index.mjs +10220 -76
- package/dist/acd-test-fixtures/index.mjs.map +1 -1
- package/dist/app-client-data/meta.d.ts +0 -1
- package/dist/app-client-data/meta.d.ts.map +1 -1
- package/dist/index.js +1958 -156
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1846 -9
- package/dist/index.mjs.map +1 -1
- package/dist/renderers.d.ts +17 -0
- package/dist/renderers.d.ts.map +1 -1
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
@@ -1,12 +1,1849 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
3
|
+
var __export = (target, all) => {
|
4
|
+
for (var name in all)
|
5
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
6
|
+
};
|
7
7
|
|
8
|
-
var ce=Object.defineProperty;var n=(e,r)=>ce(e,"name",{value:r,configurable:!0});var ge=(e,r)=>{for(var i in r)ce(e,i,{get:r[i],enumerable:!0});};function Fe(e){if(typeof e!="string")return !1;try{return !!Ae.get(e)}catch{return !1}}n(Fe,"isColor");var F=define("ColorStringStruct",e=>typeof e=="string"&&Fe(e)),p=union([type({type:literal("value"),colorValue:F}),type({type:literal("design-token"),tokenName:string()})]),go=type({type:literal("design-token"),tokenName:string()});var So=["h1","h2","h3","h4","h5","h6"],me=object({unit:enums(["rem","px"]),value:number()}),ye=union([string(),number()]),We=(i=>(i.woff2="woff2",i.woff="woff",i))(We||{}),_e=enums(["woff2","woff"]),Le=type({format:_e,type:literal("url"),path:string()}),N=type({family:optional(string()),weight:optional(union([ye,size(array(ye),2)])),src:optional(array(Le)),style:optional(string()),display:optional(enums(["auto","block","swap","fallback","optional"])),variationSettings:optional(string()),unicodeRange:optional(string())}),Ge=(f=>(f.inherit="As typed",f.capitalize="Capitalize",f.lowercase="Lowercase",f.uppercase="Uppercase",f))(Ge||{}),$e=(g=>(g["ultra-condensed"]="Ultra-condensed",g["extra-condensed"]="Extra-condensed",g.condensed="Condensed",g["semi-condensed"]="Semi-condensed",g.normal="Normal",g["semi-expanded"]="Semi-expanded",g.expanded="Expanded",g["extra-expanded"]="Extra-expanded",g["ultra-expanded"]="Ultra-expanded",g))($e||{}),w=type({fontWeight:optional(union([string(),number()])),textColor:optional(p),hoverColor:optional(p),underline:optional(boolean()),textTransform:optional(enums(["inherit","capitalize","lowercase","uppercase"])),fontStretch:optional(enums(["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded"]))}),He=type({min:me,max:optional(me)}),a=type({fontSize:optional(He),lineHeight:optional(union([string(),number()])),fontWeight:optional(union([string(),number()])),letterSpacing:optional(string()),fontFamily:optional(string()),textColor:optional(p),textTransform:optional(enums(["inherit","capitalize","lowercase","uppercase"])),fontStretch:optional(enums(["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded"]))}),m={},de={},Co={pageTitle:m,pageDescription:m,headingLarge:m,headingMedium:m,headingSmall:m,bodyText:m,link:de},xo={pageTitle:m,pageDescription:m,headingXLarge:m,headingLarge:m,headingMedium:m,headingSmall:m,headingXSmall:m,bodyText:m,link:de};var I=union([a,type({accentColor:optional(p)})]),j=union([I,type({hoverColor:optional(p),backgroundColor:optional(p)})]),W=union([I,type({backgroundColor:optional(p)})]),qe={},Je={},Ye={},Ro={primaryNav:Ye,secondaryNav:Je,tabs:qe};var jo=object({version:literal(1),oldSillySidebarBgColor:F}),Wo=object({version:literal(2),anotherSillySidebarBgColor:F}),_o=object({version:literal(3),sidebarBgColor:F}),Lo=object({version:literal(4),primaryColor:p,darkColor:p,lightColor:p,enableSidebarIcons:optional(defaulted(boolean(),!0))}),Go=object({version:literal(5),primaryColor:p,darkColor:p,lightColor:p,linkColor:p,enableSidebarIcons:optional(defaulted(boolean(),!0))}),$o=object({version:literal(6),primaryColor:p,darkColor:p,lightColor:p,linkColor:p,enableSidebarIcons:optional(defaulted(boolean(),!0)),appearance:type({customFonts:optional(array(N)),pageElements:type({pageTitle:optional(a),pageDescription:optional(a),headingLarge:optional(a),headingMedium:optional(a),headingSmall:optional(a),bodyText:optional(a),link:optional(w)})})}),Ho=object({version:literal(7),primaryColor:p,darkColor:p,lightColor:p,linkColor:p,enableSidebarIcons:optional(defaulted(boolean(),!0)),appearance:type({customFonts:optional(array(N)),navigation:optional(type({primaryNav:optional(j),secondaryNav:optional(W),tabs:optional(I)})),pageElements:type({pageTitle:optional(a),pageDescription:optional(a),headingLarge:optional(a),headingMedium:optional(a),headingSmall:optional(a),bodyText:optional(a),link:optional(w)})})}),qo=object({version:literal(8),primaryColor:p,darkColor:p,lightColor:p,linkColor:p,appearance:type({customFonts:optional(array(N)),navigation:optional(type({primaryNav:optional(j),secondaryNav:optional(W),tabs:optional(I)})),pageElements:type({pageTitle:optional(a),pageDescription:optional(a),headingLarge:optional(a),headingMedium:optional(a),headingSmall:optional(a),bodyText:optional(a),link:optional(w)})})}),Jo=object({version:literal(9),appearance:type({customFonts:optional(array(N)),navigation:optional(type({primaryNav:optional(j),secondaryNav:optional(W),tabs:optional(I)})),pageElements:type({pageTitle:optional(a),pageDescription:optional(a),headingLarge:optional(a),headingMedium:optional(a),headingSmall:optional(a),bodyText:optional(a),link:optional(w)})})}),Xe=object({version:literal(10),appearance:type({customFonts:optional(array(N)),navigation:optional(type({primaryNav:optional(j),secondaryNav:optional(W),tabs:optional(I)})),pageElements:type({pageTitle:optional(a),pageDescription:optional(a),headingXLarge:optional(a),headingLarge:optional(a),headingMedium:optional(a),headingSmall:optional(a),headingXSmall:optional(a),bodyText:optional(a),link:optional(w)})})}),Yo=Xe;var en=["large","medium","small"],tn=["large","medium","small"];var nn={default:"Default",android:"Android",cssVar:"CSS Var",json:"JSON",less:"Less",scss:"SCSS",swift:"Swift"};var an=["solid","dashed","dotted","double","groove","ridge","outset","inset"];function Qe(e){return typeof e!="string"?!1:e.split("{").length-1===1&&e.startsWith("{")&&e.endsWith("}")}n(Qe,"isTokenReference");function b(e){return typeof e=="string"&&e.includes("{")}n(b,"hasTokenReferences");function Ze(e){return !Qe(e)}n(Ze,"isNotTokenReference");var l=t.define("Token Reference",e=>typeof e!="string"?!1:Ze(e)?"Must start and end with curly braces":!0),et={border:"border",shadow:"shadow",transition:"transition"},tt=Object.values(et),ot={string:"string",number:"number",boolean:"boolean",color:"color",dimension:"dimension",duration:"duration",fontWeight:"fontWeight",strokeStyle:"strokeStyle",cubicBezier:"cubicBezier"},nt=Object.values(ot);function q(e){return tt.includes(e)}n(q,"isTokenTypeComposite");function Te(e){return nt.includes(e)}n(Te,"isTokenTypeSingular");expectType([{inset:!1,color:"#000",offsetX:"0px",offsetY:"0px",spread:"0px",blur:"0px"},{color:"#000",offsetX:"0px",offsetY:"0px",spread:"0px",blur:"0px",inset:!0}]);var c=t.type({id:t.string(),description:t.optional(t.string()),references:t.optional(t.array(t.array(t.string()))),tokenConfig:t.optional(t.type({purpose:t.optional(t.string())}))});expectType([{type:"duration",value:"1ms",originalValue:"1ms",id:"1",kind:"static"},{type:"duration",value:"1ms",kind:"ref",id:"1",originalValue:"{a.b}",referencedTokenId:"1"},{type:"duration",value:"1ms",originalValue:"1ms",id:"1",kind:"ref"},{type:"duration",value:"1ms",kind:"static",id:"1",originalValue:"{a.b}",referencedTokenId:"1"},{type:"color",value:"#000",kind:"static",id:"1",originalValue:"#000"},{type:"color",value:"#000",kind:"ref",id:"1",originalValue:"{c.b}",referencedTokenId:"c.b"},{type:"cubicBezier",kind:"static",value:[0,0,0,1],originalValue:[0,0,0,1],id:"1"}]);function Tn(e){return q(e.type)}n(Tn,"isTokenDataComposite");expectType([{type:"border",kind:"static",id:"1",value:{color:"#000",style:"solid",width:"1px"},originalValue:{color:"#000",style:"solid",width:"1px"}},{type:"border",kind:"ref",referencedTokenId:"a.b",id:"1",value:{color:"red",style:"dashed",width:"2px"},originalValue:"{a.b}"},{type:"shadow",value:{color:"#000",offsetX:"1px",offsetY:"1px",blur:"1px",spread:"1px",inset:!1},originalValue:{color:"#000",offsetX:"{a.a}",offsetY:"1px",blur:"1px",spread:"1px",inset:!1},id:"1",kind:"static"},{type:"shadow",kind:"ref",referencedTokenId:"a.b",value:{inset:!0,color:"red",offsetX:"1px",blur:"2px",offsetY:"3px",spread:"4px"},originalValue:"{a.b}",id:"1"},{type:"transition",value:{duration:"100ms",delay:"200ms",timingFunction:[0,0,0,0]},originalValue:"{a.b}",kind:"ref",referencedTokenId:"a.b",id:"1"},{type:"transition",kind:"static",value:{duration:"100ms",delay:"200ms",timingFunction:[0,0,0,0]},originalValue:{duration:"100ms",delay:"{a.c}",timingFunction:"{a.c}"},id:"1"},{type:"transition",kind:"static",value:{duration:"100ms",delay:"200ms",timingFunction:[0,0,0,0]},originalValue:{duration:"100ms",delay:"200ms",timingFunction:[0,0,0,0]},id:"1"}]);function it(e){return typeof e=="string"&&!b(e)}n(it,"isTokenValueColor");var A=t.define("Color Value",e=>typeof e!="string"?"Value must be a string":e===""?"Value must not be empty":b(e)?"Value must not contain {} (token references)":!0),at=t.assign(t.type({type:t.literal("color"),value:A,kind:t.literal("static"),originalValue:A}),c),st=t.assign(t.type({type:t.literal("color"),value:A,kind:t.literal("ref"),originalValue:l,referencedTokenId:t.string()}),c);function J(e){return typeof e=="string"&&(e.endsWith("px")||e.endsWith("rem"))&&!b(e)}n(J,"isTokenValueDimension");var D=t.define("Dimension Value",e=>typeof e!="string"?"Value must be a string":b(e)?"Value must not contain {} (token references)":!e.endsWith("px")&&!e.endsWith("rem")&&!e.endsWith("em")&&!e.endsWith("%")?"Value must end with px, rem, em or %":!0),pt=t.assign(t.type({type:t.literal("dimension"),value:D,kind:t.literal("static"),originalValue:D}),c),lt=t.assign(t.type({type:t.literal("dimension"),value:D,kind:t.literal("ref"),originalValue:l,referencedTokenId:t.string()}),c);function Sn(e){return typeof e=="string"&&e.endsWith("ms")&&!b(e)}n(Sn,"isTokenValueDuration");var R=t.define("Duration Value",e=>typeof e!="string"?"Value must be a string":b(e)?"Value must not contain {} (token references)":/^\d+ms$/.test(e)?!0:'Value must be a number followed by "ms" (e.g., "100ms")'),ct=t.assign(t.type({type:t.literal("duration"),value:R,kind:t.literal("static"),originalValue:R}),c),gt=t.assign(t.type({type:t.literal("duration"),value:R,kind:t.literal("ref"),originalValue:l,referencedTokenId:t.string()}),c);function Cn(e){return (typeof e=="string"||typeof e=="number")&&!b(e)}n(Cn,"isTokenValueFontWeight");var ae=t.define("Font Weight Value",e=>typeof e!="string"&&typeof e!="number"?"Value must be a string or number":b(e)?"Value must not contain {} (token references)":!0),ut=t.assign(t.type({type:t.literal("fontWeight"),value:ae,kind:t.literal("static"),originalValue:ae}),c),ft=t.assign(t.type({type:t.literal("fontWeight"),value:ae,kind:t.literal("ref"),originalValue:l,referencedTokenId:t.string()}),c),L=t.define("Cubic Bezier Value",e=>Array.isArray(e)?e.length!==4||!e.every(r=>typeof r=="number")?"Value must be an array of 4 numbers":e[0]<0||e[0]>1||e[2]<0||e[2]>1?"The first and third cubicBezier values must be between 0 and 1":!0:"Value must be an array"),mt=t.assign(t.type({type:t.literal("cubicBezier"),value:L,kind:t.literal("static"),originalValue:L}),c),yt=t.assign(t.type({type:t.literal("cubicBezier"),value:L,kind:t.literal("ref"),originalValue:l,referencedTokenId:t.string()}),c);function dt(e){return isObject(e)&&it(e.color)&&J(e.offsetX)&&J(e.offsetY)&&J(e.blur)&&J(e.spread)}n(dt,"isTokenValueShadow");var Se=t.define("Shadow Value",e=>dt(e)?!0:`Expected a shadow value, got ${JSON.stringify(e)}`),kt=t.assign(t.type({type:t.literal("shadow"),value:Se,kind:t.literal("static"),originalValue:t.type({color:t.union([A,l]),offsetX:t.union([D,l]),offsetY:t.union([D,l]),blur:t.union([D,l]),spread:t.union([D,l]),inset:t.union([t.optional(t.boolean()),l])})}),c),Tt=t.assign(t.type({type:t.literal("shadow"),value:Se,kind:t.literal("ref"),originalValue:l,referencedTokenId:t.string()}),c),O=t.union([t.literal("solid"),t.literal("dashed"),t.literal("dotted"),t.literal("double"),t.literal("groove"),t.literal("ridge"),t.literal("outset"),t.literal("inset")]);function St(e){return isObject(e)&&A.is(e.color)&&O.is(e.style)&&D.is(e.width)}n(St,"isTokenValueBorder");var Ce=t.define("Border Value",St),Ct=t.assign(t.type({type:t.literal("border"),value:Ce,kind:t.literal("static"),originalValue:t.type({color:t.union([A,l]),style:t.union([O,l]),width:t.union([D,l])})}),c),xt=t.assign(t.type({type:t.literal("border"),value:Ce,kind:t.literal("ref"),originalValue:l,referencedTokenId:t.string()}),c);function bt(e){return isObject(e)&&L.is(e.timingFunction)&&R.is(e.duration)&&R.is(e.delay)}n(bt,"isTokenValueTransition");var xe=t.define("Transition Value",bt),Dt=t.assign(t.type({type:t.literal("transition"),value:xe,kind:t.literal("static"),originalValue:t.type({timingFunction:t.union([L,l]),duration:t.union([R,l]),delay:t.union([R,l])})}),c),ht=t.assign(t.type({type:t.literal("transition"),value:xe,kind:t.literal("ref"),originalValue:l,referencedTokenId:t.string()}),c),Vt=t.assign(t.type({type:t.literal("string"),value:t.string(),kind:t.literal("static"),originalValue:t.string()}),c),vt=t.assign(t.type({type:t.literal("string"),value:t.string(),kind:t.literal("ref"),originalValue:l,referencedTokenId:t.string()}),c),Pt=t.assign(t.type({type:t.literal("strokeStyle"),value:O,kind:t.literal("static"),originalValue:O}),c),It=t.assign(t.type({type:t.literal("strokeStyle"),value:O,kind:t.literal("ref"),originalValue:l,referencedTokenId:O}),c),Rt=t.assign(t.type({type:t.literal("number"),value:t.number(),kind:t.literal("static"),originalValue:t.number()}),c),Bt=t.assign(t.type({type:t.literal("number"),value:t.number(),kind:t.literal("ref"),originalValue:l,referencedTokenId:t.string()}),c),Et=t.assign(t.type({type:t.literal("boolean"),value:t.boolean(),kind:t.literal("static"),originalValue:t.boolean()}),c),Nt=t.assign(t.type({type:t.literal("boolean"),value:t.boolean(),kind:t.literal("ref"),originalValue:l,referencedTokenId:t.string()}),c),xn=n(e=>{if(!isObject(e))throw new Error(`Expected token data to be an object, got ${JSON.stringify(e)}`);if(!isObjKey("type",e))throw new Error(`Expected token data to have a "type" property, got ${JSON.stringify(e)}`);if(typeof e.type!="string")throw new Error(`Expected token data "type" property to be a string, got ${JSON.stringify(e)}`);let r=e.type,i=e.kind;try{switch(r){case"boolean":i==="ref"?Nt.assert(e):Et.assert(e);return;case"border":i==="ref"?xt.assert(e):Ct.assert(e);return;case"color":i==="ref"?st.assert(e):at.assert(e);return;case"cubicBezier":i==="ref"?yt.assert(e):mt.assert(e);return;case"dimension":i==="ref"?lt.assert(e):pt.assert(e);return;case"duration":i==="ref"?gt.assert(e):ct.assert(e);return;case"fontWeight":i==="ref"?ft.assert(e):ut.assert(e);return;case"number":i==="ref"?Bt.assert(e):Rt.assert(e);return;case"shadow":i==="ref"?Tt.assert(e):kt.assert(e);return;case"string":i==="ref"?vt.assert(e):Vt.assert(e);return;case"strokeStyle":i==="ref"?It.assert(e):Pt.assert(e);return;case"transition":i==="ref"?ht.assert(e):Dt.assert(e);return;default:{throw new Error(`Unknown token data type: ${r}`)}}}catch(g){throw g instanceof t.StructError?new Error(`Invalid token data for type "${r}": ${g.message}. Received this data: "${JSON.stringify(e)}"`):g}},"assertTokenData");expectType([{type:"dimension",kind:"static",value:"1px"},{type:"dimension",kind:"ref",referencedTokenId:"a.b"}]);expectType([{type:"border",kind:"ref",referencedTokenId:"a.b"},{type:"border",kind:"static",value:{color:{kind:"static",type:"color",value:"red"},style:{kind:"ref",type:"strokeStyle",referencedTokenId:""},width:{kind:"static",type:"dimension",value:"2px"}}}]);expectType([{type:"transition",kind:"ref",referencedTokenId:"a.b"},{type:"transition",kind:"static",value:{delay:{kind:"static",type:"duration",value:"1ms"},duration:{kind:"ref",type:"duration",referencedTokenId:"animation.slow"},timingFunction:{kind:"static",type:"cubicBezier",value:[.4,0,.2,1]}}}]);function Bn(e){return Te(e?.type)}n(Bn,"isTokenSrcValueInfoSingular");function En(e){return q(e?.type)}n(En,"isTokenSrcValueInfoComposite");expectType([{type:"dimension",kind:"static",value:"1px"},{type:"transition",kind:"ref",referencedTokenId:"a.b"},{type:"transition",kind:"ref",value:"1px"},{kind:"ref",type:"duration",referencedTokenId:"animation.slow"},{kind:"static",type:"cubicBezier",value:[.4,0,.2,1]},{type:"transition",kind:"static",value:{delay:{kind:"static",type:"duration",value:"1ms"},duration:{kind:"ref",type:"duration",referencedTokenId:"animation.slow"},timingFunction:{kind:"static",type:"cubicBezier",value:[.4,0,.2,1]}}}]);function At(e){return isObject(e)&&isObjKey("cloud.knapsack",e)}n(At,"isTokenSrcExtensions");expectType(["#ddd",!0,[83,1,1,1],{color:"#000",style:"solid",width:"1px"},{inset:!0,color:"#000",offsetX:"0px",offsetY:"{spacing.medium}",spread:"0px",blur:"0px"},{timingFunction:"{timing.ease}",duration:"{timing.duration.medium}",delay:"7ms",color:"#000"}]);function Kn(e){return !!(isObject(e)&&isObjKey("$value",e))}n(Kn,"isTokenSrc");function Ot(e){return isObject(e)&&!At(e)&&!isObjKey("$value",e)&&!isObjKey("cloud.knapsack",e)}n(Ot,"isTokenGroup");function Fn(e){if(Ot(e)){let r=e.$extensions["cloud.knapsack"].group.collectionInfo;if(isObjKey("type",r)&&isObjKey("referenceId",r))return !0}return !1}n(Fn,"isTokenTypeVarRef");function jn(e){let r=typeof e;if(r==="string"||r==="number"||r==="boolean")return r;throw new Error(`Invalid token value type: ${JSON.stringify(r)}. Token value is: ${JSON.stringify(e)}`)}n(jn,"getPrimitiveValue");var Wn=n(e=>e.includes("px")||e.includes("rem")||e.includes("em")||e.includes("%"),"isDimensionString");function _n(e){let{value:r,unit:i}=parseNumberWithUnit(e);if(!i)return {value:r};if(i!=="px"&&i!=="rem"&&i!=="em"&&i!=="%")throw new Error(`Invalid unit "${i}" for value: ${r}`);return {value:r,unit:i}}n(_n,"parseTokenDimensionValue");var Hn=n(e=>isObject(e)&&e.type==="text","isSlottedText");function qn(e){return isObject(e)&&e.type==="template-demo"}n(qn,"isSlottedTemplateDemo");function Jn(e){return isObject(e)&&e.type==="template-reference"}n(Jn,"isSlottedTemplateReference");var Ft=(i=>(i.portrait="portrait",i.landscape="landscape",i))(Ft||{});function Yn(e){return e?.type==="data"}n(Yn,"isDataDemo");function Xn(e){return e?.type==="template"}n(Xn,"isTemplateDemo");var be=(d=>(d.auto="auto",d.small="small",d.medium="medium",d.large="large",d.full="full",d))(be||{});function zt(e){return !isObject(e)||!["assetSetsState","customPagesState","navsState","patternsState","tokensSrc","db"].every(i=>isObjKey(i,e))?!1:!isObjKey("metaState",e)}n(zt,"isKsAppClientDataNoMeta");var rr=define("KsAppClientDataNoMeta",zt);function Mt(e){return isObject(e)?["assetSetsState","customPagesState","navsState","patternsState","tokensSrc","metaState","db"].every(i=>isObjKey(i,e)):!1}n(Mt,"isKsAppClientDataAndMeta");var ir=define("KsAppClientDataAndMeta",Mt),jt=type({isLocalDev:boolean(),plugins:array(type({id:string(),hasContent:boolean(),clientPluginPath:optional(string()),cssPath:optional(string())})),meta:optional(type({version:optional(string()),hasKnapsackCloud:boolean(),knapsackCloudSiteId:optional(string()),serverPort:optional(number()),websocketsPort:optional(number()),https:optional(boolean()),cacheDir:optional(string()),ksVersions:type({app:string()})}))}),ar=jt.is;function _t(e){return !isObject(e)||!["assetSetsState","customPagesState","navsState","patternsState","settingsState","tokensState"].every(i=>isObjKey(i,e))?!1:!isObjKey("metaState",e)}n(_t,"isKsAppClientDataNoMetaV3");var br=define("KsAppClientDataNoMeta",_t);function Lt(e){return isObject(e)?["assetSetsState","customPagesState","navsState","patternsState","settingsState","tokensState","metaState"].every(i=>isObjKey(i,e)):!1}n(Lt,"isKsAppClientDataAndMetaV3");var Dr=define("KsAppClientDataAndMeta",Lt),Gt=type({isLocalDev:boolean(),plugins:array(type({id:string(),hasContent:boolean(),clientPluginPath:optional(string()),cssPath:optional(string())})),meta:optional(type({version:optional(string()),hasKnapsackCloud:boolean(),knapsackCloudSiteId:optional(string()),serverPort:optional(number()),websocketsPort:optional(number()),https:optional(boolean()),cacheDir:optional(string()),ksVersions:type({app:string()})}))}),hr=Gt.is;var Pe={version:"4.1.7",checkIfNeeded:n(e=>!0,"checkIfNeeded"),migrate:n(e=>{if(!isDraft(e))throw new Error("Tried to run migrations on appClientData but it is not an Immer Draft");Object.values(e.patternsState.patterns).forEach(r=>{delete r.demoSize;}),Object.values(e.db.demos.byId).forEach(r=>{r.type==="data"&&(Object.entries(r.data.slots??{}).forEach(([i,g])=>{r.data.slots[i]=g.map(f=>typeof f=="string"?{type:"text",text:f}:(f.type==="template-reference"||f.type==="text"||(f.type="template-demo"),f));}),!(r.patternId&&r.templateId)&&(()=>{for(let{id:i,templates:g=[]}of Object.values(e.patternsState.patterns))for(let{id:f,demoIds:d=[]}of g)if(d.includes(r.id)){r.patternId=i,r.templateId=f;return}})());});},"migrate")};var Er=[Pe];var Ht=(k=>(k.string="string",k.boolean="boolean",k.number="number",k.object="object",k.options="options",k.function="function",k.customTypeScript="customTypeScript",k.array="array",k.arrayOfObjects="arrayOfObjects",k.arrayOfStrings="arrayOfStrings",k.unknown="unknown",k))(Ht||{}),wr=n(e=>"type"in e&&e.type==="string"&&!("enum"in e),"isStringProp"),Ar=n(e=>"type"in e&&e.type==="number","isNumberProp"),Or=n(e=>"type"in e&&e.type==="boolean","isBooleanProp"),Kr=n(e=>"enum"in e,"isOptionsProp"),Fr=n(e=>"typeof"in e&&e?.typeof==="function","isFunctionProp"),Ur=n(e=>!("typeof"in e)&&"tsType"in e,"isCustomTypeScriptProp"),zr=n(e=>"type"in e&&e.type==="array"&&"items"in e&&e.items.type==="object","isArrayOfObjectsProp"),Mr=n(e=>"type"in e&&e.type==="object"&&"properties"in e&&Object.keys(e.properties).length>0,"isObjectProp"),jr=n(e=>"type"in e&&e.type==="array"&&"items"in e&&e.items.type==="string","isArrayOfStringsProp");var Ie=t.object({op:t.union([t.literal("replace"),t.literal("remove"),t.literal("add")]),path:t.array(t.union([t.string(),t.number()])),value:t.optional(t.any())}),qt=Ie,Lr=n(e=>qt.is(e),"isPatch"),le=t.array(Ie),Jt=le,Gr=n(e=>Jt.is(e),"isPatches"),Re=t.type({patches:le,inversePatches:t.optional(le),event:t.optional(t.object({type:t.string()})),id:t.string(),date:t.string(),userId:t.optional(t.string())}),Yt=Re,$r=n(e=>Yt.is(e),"isKsRemoteChange"),Xt=t.array(Re),Qt=Xt,Hr=n(e=>Qt.is(e),"isKsRemoteChanges");var Yr={react:"react",vue:"vue","web-components":"web-components",twig:"twig",hbs:"hbs",angular:"angular",html:"html"};var Zt=(r=>(r.ready="ready",r))(Zt||{}),Qr="ks-meta";var ei={PATTERN_TEMPLATE_CHANGED:"PATTERN_TEMPLATE_CHANGED",PATTERN_ASSET_CHANGED:"PATTERN_ASSET_CHANGED",DESIGN_TOKENS_CHANGED:"DESIGN_TOKENS_CHANGED",RENDERER_CLIENT_RELOAD:"RENDERER_CLIENT_RELOAD",APP_CLIENT_DATA_CHANGED:"APP_CLIENT_DATA_CHANGED"};var eo=(d=>(d.GitHub="GitHub",d.GitLab="GitLab",d.GitLabRest="GitLabRest",d.Bitbucket="Bitbucket",d.Azure="Azure",d))(eo||{}),to=(g=>(g.Conflicting="CONFLICTING",g.Mergeable="MERGEABLE",g.Unknown="UNKNOWN",g))(to||{}),oo=(f=>(f.Create="CREATE",f.Move="MOVE",f.Update="UPDATE",f.Chmod="CHMOD",f))(oo||{}),no=(i=>(i.Base64="BASE64",i.Text="TEXT",i))(no||{});var Ee={};ge(Ee,{ACTIONS:()=>Be,endpoint:()=>ro});var ro="/plugins",Be=(r=>(r.getContent="getContent",r))(Be||{});var we={};ge(we,{ACTIONS:()=>Ne,endpoint:()=>io});var io="/files",Ne=(r=>(r.verify="verify",r))(Ne||{});var ao={ADMIN:"ADMIN",ANONYMOUS:"ANONYMOUS",CONTRIBUTOR:"CONTRIBUTOR",EDITOR:"EDITOR",MANAGER:"MANAGER",VIEWER:"VIEWER"},ri=Object.values(ao);
|
8
|
+
// src/ui-config.ts
|
9
|
+
import {
|
10
|
+
type as type4,
|
11
|
+
literal as literal3,
|
12
|
+
optional as optional3,
|
13
|
+
defaulted,
|
14
|
+
boolean as boolean2,
|
15
|
+
array as array2,
|
16
|
+
object as object2
|
17
|
+
} from "superstruct";
|
9
18
|
|
10
|
-
|
11
|
-
|
19
|
+
// src/color-config.ts
|
20
|
+
import colorString from "color-string";
|
21
|
+
import { define, literal, string, type, union } from "superstruct";
|
22
|
+
function isColor(color) {
|
23
|
+
if (typeof color !== "string") return false;
|
24
|
+
try {
|
25
|
+
return !!colorString.get(color);
|
26
|
+
} catch (e) {
|
27
|
+
return false;
|
28
|
+
}
|
29
|
+
}
|
30
|
+
__name(isColor, "isColor");
|
31
|
+
var ColorStringStruct = define(
|
32
|
+
"ColorStringStruct",
|
33
|
+
(value) => typeof value === "string" && isColor(value)
|
34
|
+
);
|
35
|
+
var ColorConfigStruct = union([
|
36
|
+
type({
|
37
|
+
type: literal("value"),
|
38
|
+
colorValue: ColorStringStruct
|
39
|
+
}),
|
40
|
+
type({
|
41
|
+
type: literal("design-token"),
|
42
|
+
tokenName: string()
|
43
|
+
})
|
44
|
+
]);
|
45
|
+
var ColorTokenConfigStruct = type({
|
46
|
+
type: literal("design-token"),
|
47
|
+
tokenName: string()
|
48
|
+
});
|
49
|
+
|
50
|
+
// src/typography-config.ts
|
51
|
+
import {
|
52
|
+
string as string2,
|
53
|
+
type as type2,
|
54
|
+
union as union2,
|
55
|
+
number,
|
56
|
+
enums,
|
57
|
+
optional,
|
58
|
+
literal as literal2,
|
59
|
+
array,
|
60
|
+
size,
|
61
|
+
boolean,
|
62
|
+
object
|
63
|
+
} from "superstruct";
|
64
|
+
var HeadingLevels = ["h1", "h2", "h3", "h4", "h5", "h6"];
|
65
|
+
var FontSizeConfigValStruct = object({
|
66
|
+
unit: enums(["rem", "px"]),
|
67
|
+
value: number()
|
68
|
+
});
|
69
|
+
var FontFaceWeightStruct = union2([
|
70
|
+
string2(),
|
71
|
+
number()
|
72
|
+
]);
|
73
|
+
var FontFaceSourceFormats = /* @__PURE__ */ ((FontFaceSourceFormats2) => {
|
74
|
+
FontFaceSourceFormats2["woff2"] = "woff2";
|
75
|
+
FontFaceSourceFormats2["woff"] = "woff";
|
76
|
+
return FontFaceSourceFormats2;
|
77
|
+
})(FontFaceSourceFormats || {});
|
78
|
+
var FontFaceFormatsEnumStruct = enums(["woff2", "woff"]);
|
79
|
+
var FontFaceSourceStruct = type2({
|
80
|
+
format: FontFaceFormatsEnumStruct,
|
81
|
+
type: literal2("url"),
|
82
|
+
path: string2()
|
83
|
+
});
|
84
|
+
var FontFaceConfigStruct = type2({
|
85
|
+
family: optional(string2()),
|
86
|
+
weight: optional(
|
87
|
+
union2([FontFaceWeightStruct, size(array(FontFaceWeightStruct), 2)])
|
88
|
+
),
|
89
|
+
src: optional(array(FontFaceSourceStruct)),
|
90
|
+
style: optional(string2()),
|
91
|
+
display: optional(enums(["auto", "block", "swap", "fallback", "optional"])),
|
92
|
+
variationSettings: optional(string2()),
|
93
|
+
unicodeRange: optional(string2())
|
94
|
+
});
|
95
|
+
var TextTransforms = /* @__PURE__ */ ((TextTransforms2) => {
|
96
|
+
TextTransforms2["inherit"] = "As typed";
|
97
|
+
TextTransforms2["capitalize"] = "Capitalize";
|
98
|
+
TextTransforms2["lowercase"] = "Lowercase";
|
99
|
+
TextTransforms2["uppercase"] = "Uppercase";
|
100
|
+
return TextTransforms2;
|
101
|
+
})(TextTransforms || {});
|
102
|
+
var FontStretches = /* @__PURE__ */ ((FontStretches2) => {
|
103
|
+
FontStretches2["ultra-condensed"] = "Ultra-condensed";
|
104
|
+
FontStretches2["extra-condensed"] = "Extra-condensed";
|
105
|
+
FontStretches2["condensed"] = "Condensed";
|
106
|
+
FontStretches2["semi-condensed"] = "Semi-condensed";
|
107
|
+
FontStretches2["normal"] = "Normal";
|
108
|
+
FontStretches2["semi-expanded"] = "Semi-expanded";
|
109
|
+
FontStretches2["expanded"] = "Expanded";
|
110
|
+
FontStretches2["extra-expanded"] = "Extra-expanded";
|
111
|
+
FontStretches2["ultra-expanded"] = "Ultra-expanded";
|
112
|
+
return FontStretches2;
|
113
|
+
})(FontStretches || {});
|
114
|
+
var TypographyLinkConfigStruct = type2({
|
115
|
+
fontWeight: optional(union2([string2(), number()])),
|
116
|
+
textColor: optional(ColorConfigStruct),
|
117
|
+
hoverColor: optional(ColorConfigStruct),
|
118
|
+
underline: optional(boolean()),
|
119
|
+
textTransform: optional(
|
120
|
+
enums(["inherit", "capitalize", "lowercase", "uppercase"])
|
121
|
+
),
|
122
|
+
fontStretch: optional(
|
123
|
+
enums([
|
124
|
+
"ultra-condensed",
|
125
|
+
"extra-condensed",
|
126
|
+
"condensed",
|
127
|
+
"semi-condensed",
|
128
|
+
"normal",
|
129
|
+
"semi-expanded",
|
130
|
+
"expanded",
|
131
|
+
"extra-expanded",
|
132
|
+
"ultra-expanded"
|
133
|
+
])
|
134
|
+
)
|
135
|
+
});
|
136
|
+
var FontSizeConfigStruct = type2({
|
137
|
+
min: FontSizeConfigValStruct,
|
138
|
+
max: optional(FontSizeConfigValStruct)
|
139
|
+
});
|
140
|
+
var TypographyConfigStruct = type2({
|
141
|
+
fontSize: optional(FontSizeConfigStruct),
|
142
|
+
lineHeight: optional(union2([string2(), number()])),
|
143
|
+
fontWeight: optional(union2([string2(), number()])),
|
144
|
+
letterSpacing: optional(string2()),
|
145
|
+
fontFamily: optional(string2()),
|
146
|
+
textColor: optional(ColorConfigStruct),
|
147
|
+
textTransform: optional(
|
148
|
+
enums(["inherit", "capitalize", "lowercase", "uppercase"])
|
149
|
+
),
|
150
|
+
fontStretch: optional(
|
151
|
+
enums([
|
152
|
+
"ultra-condensed",
|
153
|
+
"extra-condensed",
|
154
|
+
"condensed",
|
155
|
+
"semi-condensed",
|
156
|
+
"normal",
|
157
|
+
"semi-expanded",
|
158
|
+
"expanded",
|
159
|
+
"extra-expanded",
|
160
|
+
"ultra-expanded"
|
161
|
+
])
|
162
|
+
)
|
163
|
+
});
|
164
|
+
var pageElementConfig = {};
|
165
|
+
var pageLinkElementConfig = {};
|
166
|
+
var pageElements = {
|
167
|
+
pageTitle: pageElementConfig,
|
168
|
+
pageDescription: pageElementConfig,
|
169
|
+
headingLarge: pageElementConfig,
|
170
|
+
headingMedium: pageElementConfig,
|
171
|
+
headingSmall: pageElementConfig,
|
172
|
+
bodyText: pageElementConfig,
|
173
|
+
link: pageLinkElementConfig
|
174
|
+
};
|
175
|
+
var pageElementsV2 = {
|
176
|
+
pageTitle: pageElementConfig,
|
177
|
+
pageDescription: pageElementConfig,
|
178
|
+
headingXLarge: pageElementConfig,
|
179
|
+
headingLarge: pageElementConfig,
|
180
|
+
headingMedium: pageElementConfig,
|
181
|
+
headingSmall: pageElementConfig,
|
182
|
+
headingXSmall: pageElementConfig,
|
183
|
+
bodyText: pageElementConfig,
|
184
|
+
link: pageLinkElementConfig
|
185
|
+
};
|
186
|
+
|
187
|
+
// src/nav-customization-config.ts
|
188
|
+
import { type as type3, union as union3, optional as optional2 } from "superstruct";
|
189
|
+
var NavCustomizationConfigStruct = union3([
|
190
|
+
TypographyConfigStruct,
|
191
|
+
type3({
|
192
|
+
accentColor: optional2(ColorConfigStruct)
|
193
|
+
})
|
194
|
+
]);
|
195
|
+
var PrimaryNavCustomizationConfigStruct = union3([
|
196
|
+
NavCustomizationConfigStruct,
|
197
|
+
type3({
|
198
|
+
hoverColor: optional2(ColorConfigStruct),
|
199
|
+
backgroundColor: optional2(ColorConfigStruct)
|
200
|
+
})
|
201
|
+
]);
|
202
|
+
var SecondaryNavCustomizationConfigStruct = union3([
|
203
|
+
NavCustomizationConfigStruct,
|
204
|
+
type3({
|
205
|
+
backgroundColor: optional2(ColorConfigStruct)
|
206
|
+
})
|
207
|
+
]);
|
208
|
+
var navCustomizationConfig = {};
|
209
|
+
var secondaryNavCustomizationConfig = {};
|
210
|
+
var primaryNavCustomizationConfig = {};
|
211
|
+
var customizableNavElements = {
|
212
|
+
primaryNav: primaryNavCustomizationConfig,
|
213
|
+
secondaryNav: secondaryNavCustomizationConfig,
|
214
|
+
tabs: navCustomizationConfig
|
215
|
+
};
|
216
|
+
|
217
|
+
// src/ui-config.ts
|
218
|
+
var UiConfigV1Struct = object2({
|
219
|
+
version: literal3(1),
|
220
|
+
oldSillySidebarBgColor: ColorStringStruct
|
221
|
+
});
|
222
|
+
var UiConfigV2Struct = object2({
|
223
|
+
version: literal3(2),
|
224
|
+
anotherSillySidebarBgColor: ColorStringStruct
|
225
|
+
});
|
226
|
+
var UiConfigV3Struct = object2({
|
227
|
+
version: literal3(3),
|
228
|
+
sidebarBgColor: ColorStringStruct
|
229
|
+
});
|
230
|
+
var UiConfigV4Struct = object2({
|
231
|
+
version: literal3(4),
|
232
|
+
primaryColor: ColorConfigStruct,
|
233
|
+
darkColor: ColorConfigStruct,
|
234
|
+
lightColor: ColorConfigStruct,
|
235
|
+
enableSidebarIcons: optional3(defaulted(boolean2(), true))
|
236
|
+
});
|
237
|
+
var UiConfigV5Struct = object2({
|
238
|
+
version: literal3(5),
|
239
|
+
primaryColor: ColorConfigStruct,
|
240
|
+
darkColor: ColorConfigStruct,
|
241
|
+
lightColor: ColorConfigStruct,
|
242
|
+
linkColor: ColorConfigStruct,
|
243
|
+
enableSidebarIcons: optional3(defaulted(boolean2(), true))
|
244
|
+
});
|
245
|
+
var UiConfigV6Struct = object2({
|
246
|
+
version: literal3(6),
|
247
|
+
primaryColor: ColorConfigStruct,
|
248
|
+
darkColor: ColorConfigStruct,
|
249
|
+
lightColor: ColorConfigStruct,
|
250
|
+
linkColor: ColorConfigStruct,
|
251
|
+
enableSidebarIcons: optional3(defaulted(boolean2(), true)),
|
252
|
+
appearance: type4({
|
253
|
+
customFonts: optional3(array2(FontFaceConfigStruct)),
|
254
|
+
pageElements: type4({
|
255
|
+
pageTitle: optional3(TypographyConfigStruct),
|
256
|
+
pageDescription: optional3(TypographyConfigStruct),
|
257
|
+
headingLarge: optional3(TypographyConfigStruct),
|
258
|
+
headingMedium: optional3(TypographyConfigStruct),
|
259
|
+
headingSmall: optional3(TypographyConfigStruct),
|
260
|
+
bodyText: optional3(TypographyConfigStruct),
|
261
|
+
link: optional3(TypographyLinkConfigStruct)
|
262
|
+
})
|
263
|
+
})
|
264
|
+
});
|
265
|
+
var UiConfigV7Struct = object2({
|
266
|
+
version: literal3(7),
|
267
|
+
primaryColor: ColorConfigStruct,
|
268
|
+
darkColor: ColorConfigStruct,
|
269
|
+
lightColor: ColorConfigStruct,
|
270
|
+
linkColor: ColorConfigStruct,
|
271
|
+
enableSidebarIcons: optional3(defaulted(boolean2(), true)),
|
272
|
+
appearance: type4({
|
273
|
+
customFonts: optional3(array2(FontFaceConfigStruct)),
|
274
|
+
navigation: optional3(
|
275
|
+
type4({
|
276
|
+
primaryNav: optional3(PrimaryNavCustomizationConfigStruct),
|
277
|
+
secondaryNav: optional3(SecondaryNavCustomizationConfigStruct),
|
278
|
+
tabs: optional3(NavCustomizationConfigStruct)
|
279
|
+
})
|
280
|
+
),
|
281
|
+
pageElements: type4({
|
282
|
+
pageTitle: optional3(TypographyConfigStruct),
|
283
|
+
pageDescription: optional3(TypographyConfigStruct),
|
284
|
+
headingLarge: optional3(TypographyConfigStruct),
|
285
|
+
headingMedium: optional3(TypographyConfigStruct),
|
286
|
+
headingSmall: optional3(TypographyConfigStruct),
|
287
|
+
bodyText: optional3(TypographyConfigStruct),
|
288
|
+
link: optional3(TypographyLinkConfigStruct)
|
289
|
+
})
|
290
|
+
})
|
291
|
+
});
|
292
|
+
var UiConfigV8Struct = object2({
|
293
|
+
version: literal3(8),
|
294
|
+
primaryColor: ColorConfigStruct,
|
295
|
+
darkColor: ColorConfigStruct,
|
296
|
+
lightColor: ColorConfigStruct,
|
297
|
+
linkColor: ColorConfigStruct,
|
298
|
+
appearance: type4({
|
299
|
+
customFonts: optional3(array2(FontFaceConfigStruct)),
|
300
|
+
navigation: optional3(
|
301
|
+
type4({
|
302
|
+
primaryNav: optional3(PrimaryNavCustomizationConfigStruct),
|
303
|
+
secondaryNav: optional3(SecondaryNavCustomizationConfigStruct),
|
304
|
+
tabs: optional3(NavCustomizationConfigStruct)
|
305
|
+
})
|
306
|
+
),
|
307
|
+
pageElements: type4({
|
308
|
+
pageTitle: optional3(TypographyConfigStruct),
|
309
|
+
pageDescription: optional3(TypographyConfigStruct),
|
310
|
+
headingLarge: optional3(TypographyConfigStruct),
|
311
|
+
headingMedium: optional3(TypographyConfigStruct),
|
312
|
+
headingSmall: optional3(TypographyConfigStruct),
|
313
|
+
bodyText: optional3(TypographyConfigStruct),
|
314
|
+
link: optional3(TypographyLinkConfigStruct)
|
315
|
+
})
|
316
|
+
})
|
317
|
+
});
|
318
|
+
var UiConfigV9Struct = object2({
|
319
|
+
version: literal3(9),
|
320
|
+
appearance: type4({
|
321
|
+
customFonts: optional3(array2(FontFaceConfigStruct)),
|
322
|
+
navigation: optional3(
|
323
|
+
type4({
|
324
|
+
primaryNav: optional3(PrimaryNavCustomizationConfigStruct),
|
325
|
+
secondaryNav: optional3(SecondaryNavCustomizationConfigStruct),
|
326
|
+
tabs: optional3(NavCustomizationConfigStruct)
|
327
|
+
})
|
328
|
+
),
|
329
|
+
pageElements: type4({
|
330
|
+
pageTitle: optional3(TypographyConfigStruct),
|
331
|
+
pageDescription: optional3(TypographyConfigStruct),
|
332
|
+
headingLarge: optional3(TypographyConfigStruct),
|
333
|
+
headingMedium: optional3(TypographyConfigStruct),
|
334
|
+
headingSmall: optional3(TypographyConfigStruct),
|
335
|
+
bodyText: optional3(TypographyConfigStruct),
|
336
|
+
link: optional3(TypographyLinkConfigStruct)
|
337
|
+
})
|
338
|
+
})
|
339
|
+
});
|
340
|
+
var UiConfigV10Struct = object2({
|
341
|
+
version: literal3(10),
|
342
|
+
appearance: type4({
|
343
|
+
customFonts: optional3(array2(FontFaceConfigStruct)),
|
344
|
+
navigation: optional3(
|
345
|
+
type4({
|
346
|
+
primaryNav: optional3(PrimaryNavCustomizationConfigStruct),
|
347
|
+
secondaryNav: optional3(SecondaryNavCustomizationConfigStruct),
|
348
|
+
tabs: optional3(NavCustomizationConfigStruct)
|
349
|
+
})
|
350
|
+
),
|
351
|
+
pageElements: type4({
|
352
|
+
pageTitle: optional3(TypographyConfigStruct),
|
353
|
+
pageDescription: optional3(TypographyConfigStruct),
|
354
|
+
headingXLarge: optional3(TypographyConfigStruct),
|
355
|
+
headingLarge: optional3(TypographyConfigStruct),
|
356
|
+
headingMedium: optional3(TypographyConfigStruct),
|
357
|
+
headingSmall: optional3(TypographyConfigStruct),
|
358
|
+
headingXSmall: optional3(TypographyConfigStruct),
|
359
|
+
bodyText: optional3(TypographyConfigStruct),
|
360
|
+
link: optional3(TypographyLinkConfigStruct)
|
361
|
+
})
|
362
|
+
})
|
363
|
+
});
|
364
|
+
var UiConfigStruct = UiConfigV10Struct;
|
365
|
+
|
366
|
+
// src/app-client-data/index.ts
|
367
|
+
import {
|
368
|
+
type as type6,
|
369
|
+
string as string4,
|
370
|
+
boolean as boolean4,
|
371
|
+
optional as optional5,
|
372
|
+
array as array4,
|
373
|
+
number as number3,
|
374
|
+
define as define4
|
375
|
+
} from "superstruct";
|
376
|
+
|
377
|
+
// src/type-utils.ts
|
378
|
+
import { isObjKey, isObject } from "@knapsack/utils";
|
379
|
+
|
380
|
+
// src/app-client-data/blocks.ts
|
381
|
+
var BlockSizes = ["large", "medium", "small"];
|
382
|
+
var BlockSpacings = ["large", "medium", "small"];
|
383
|
+
|
384
|
+
// src/app-client-data/design-tokens.ts
|
385
|
+
var tokenNameDisplayFormats = {
|
386
|
+
default: "Default",
|
387
|
+
android: "Android",
|
388
|
+
cssVar: "CSS Var",
|
389
|
+
json: "JSON",
|
390
|
+
less: "Less",
|
391
|
+
scss: "SCSS",
|
392
|
+
swift: "Swift"
|
393
|
+
};
|
394
|
+
|
395
|
+
// src/app-client-data/design-tokens-types/token-data.ts
|
396
|
+
import { expectType, isObjKey as isObjKey2, isObject as isObject2 } from "@knapsack/utils";
|
397
|
+
import * as s2 from "superstruct";
|
398
|
+
|
399
|
+
// src/app-client-data/design-tokens-types/token-definitions.ts
|
400
|
+
import * as s from "superstruct";
|
401
|
+
var strokeStyleValues = [
|
402
|
+
"solid",
|
403
|
+
"dashed",
|
404
|
+
"dotted",
|
405
|
+
"double",
|
406
|
+
"groove",
|
407
|
+
"ridge",
|
408
|
+
"outset",
|
409
|
+
"inset"
|
410
|
+
];
|
411
|
+
function isTokenReference(val) {
|
412
|
+
if (typeof val !== "string") return false;
|
413
|
+
const totalOpenBrackets = val.split("{").length - 1;
|
414
|
+
return totalOpenBrackets === 1 && val.startsWith("{") && val.endsWith("}");
|
415
|
+
}
|
416
|
+
__name(isTokenReference, "isTokenReference");
|
417
|
+
function hasTokenReferences(val) {
|
418
|
+
return typeof val === "string" && val.includes("{");
|
419
|
+
}
|
420
|
+
__name(hasTokenReferences, "hasTokenReferences");
|
421
|
+
function isNotTokenReference(value) {
|
422
|
+
return !isTokenReference(value);
|
423
|
+
}
|
424
|
+
__name(isNotTokenReference, "isNotTokenReference");
|
425
|
+
var TokenReferenceStruct = s.define(
|
426
|
+
"Token Reference",
|
427
|
+
(value) => {
|
428
|
+
if (typeof value !== "string") return false;
|
429
|
+
if (isNotTokenReference(value)) {
|
430
|
+
return "Must start and end with curly braces";
|
431
|
+
}
|
432
|
+
return true;
|
433
|
+
}
|
434
|
+
);
|
435
|
+
var compositeTypesRecord = {
|
436
|
+
border: "border",
|
437
|
+
shadow: "shadow",
|
438
|
+
transition: "transition"
|
439
|
+
};
|
440
|
+
var tokenTypeComposites = Object.values(compositeTypesRecord);
|
441
|
+
var singularTypesRecord = {
|
442
|
+
string: "string",
|
443
|
+
number: "number",
|
444
|
+
boolean: "boolean",
|
445
|
+
color: "color",
|
446
|
+
dimension: "dimension",
|
447
|
+
duration: "duration",
|
448
|
+
// fontFamily: 'fontFamily',
|
449
|
+
fontWeight: "fontWeight",
|
450
|
+
strokeStyle: "strokeStyle",
|
451
|
+
cubicBezier: "cubicBezier"
|
452
|
+
};
|
453
|
+
var tokenTypeSingulars = Object.values(singularTypesRecord);
|
454
|
+
function isTokenTypeComposite(type9) {
|
455
|
+
return tokenTypeComposites.includes(type9);
|
456
|
+
}
|
457
|
+
__name(isTokenTypeComposite, "isTokenTypeComposite");
|
458
|
+
function isTokenTypeSingular(type9) {
|
459
|
+
return tokenTypeSingulars.includes(type9);
|
460
|
+
}
|
461
|
+
__name(isTokenTypeSingular, "isTokenTypeSingular");
|
462
|
+
|
463
|
+
// src/app-client-data/design-tokens-types/token-data.ts
|
464
|
+
expectType([
|
465
|
+
{
|
466
|
+
inset: false,
|
467
|
+
color: "#000",
|
468
|
+
offsetX: "0px",
|
469
|
+
offsetY: "0px",
|
470
|
+
spread: "0px",
|
471
|
+
blur: "0px"
|
472
|
+
},
|
473
|
+
{
|
474
|
+
color: "#000",
|
475
|
+
offsetX: "0px",
|
476
|
+
offsetY: "0px",
|
477
|
+
spread: "0px",
|
478
|
+
blur: "0px",
|
479
|
+
inset: true
|
480
|
+
}
|
481
|
+
]);
|
482
|
+
var TokenDataBaseStruct = s2.type({
|
483
|
+
id: s2.string(),
|
484
|
+
description: s2.optional(s2.string()),
|
485
|
+
references: s2.optional(s2.array(s2.array(s2.string()))),
|
486
|
+
tokenConfig: s2.optional(
|
487
|
+
s2.type({
|
488
|
+
purpose: s2.optional(s2.string())
|
489
|
+
})
|
490
|
+
)
|
491
|
+
});
|
492
|
+
expectType([
|
493
|
+
{
|
494
|
+
type: "duration",
|
495
|
+
value: "1ms",
|
496
|
+
originalValue: "1ms",
|
497
|
+
id: "1",
|
498
|
+
kind: "static"
|
499
|
+
},
|
500
|
+
{
|
501
|
+
type: "duration",
|
502
|
+
value: "1ms",
|
503
|
+
kind: "ref",
|
504
|
+
id: "1",
|
505
|
+
originalValue: "{a.b}",
|
506
|
+
referencedTokenId: "1"
|
507
|
+
},
|
508
|
+
// @ts-expect-error - kind is wrong
|
509
|
+
{
|
510
|
+
type: "duration",
|
511
|
+
value: "1ms",
|
512
|
+
originalValue: "1ms",
|
513
|
+
id: "1",
|
514
|
+
kind: "ref"
|
515
|
+
},
|
516
|
+
// @ts-expect-error - kind is wrong
|
517
|
+
{
|
518
|
+
type: "duration",
|
519
|
+
value: "1ms",
|
520
|
+
kind: "static",
|
521
|
+
id: "1",
|
522
|
+
originalValue: "{a.b}",
|
523
|
+
referencedTokenId: "1"
|
524
|
+
},
|
525
|
+
{
|
526
|
+
type: "color",
|
527
|
+
value: "#000",
|
528
|
+
kind: "static",
|
529
|
+
id: "1",
|
530
|
+
originalValue: "#000"
|
531
|
+
},
|
532
|
+
{
|
533
|
+
type: "color",
|
534
|
+
value: "#000",
|
535
|
+
kind: "ref",
|
536
|
+
id: "1",
|
537
|
+
originalValue: "{c.b}",
|
538
|
+
referencedTokenId: "c.b"
|
539
|
+
},
|
540
|
+
{
|
541
|
+
type: "cubicBezier",
|
542
|
+
kind: "static",
|
543
|
+
value: [0, 0, 0, 1],
|
544
|
+
originalValue: [0, 0, 0, 1],
|
545
|
+
id: "1"
|
546
|
+
}
|
547
|
+
]);
|
548
|
+
function isTokenDataComposite(tokenData) {
|
549
|
+
return isTokenTypeComposite(tokenData.type);
|
550
|
+
}
|
551
|
+
__name(isTokenDataComposite, "isTokenDataComposite");
|
552
|
+
expectType([
|
553
|
+
{
|
554
|
+
type: "border",
|
555
|
+
kind: "static",
|
556
|
+
id: "1",
|
557
|
+
value: {
|
558
|
+
color: "#000",
|
559
|
+
style: "solid",
|
560
|
+
width: "1px"
|
561
|
+
},
|
562
|
+
originalValue: {
|
563
|
+
color: "#000",
|
564
|
+
style: "solid",
|
565
|
+
width: "1px"
|
566
|
+
}
|
567
|
+
},
|
568
|
+
{
|
569
|
+
type: "border",
|
570
|
+
kind: "ref",
|
571
|
+
referencedTokenId: "a.b",
|
572
|
+
id: "1",
|
573
|
+
value: {
|
574
|
+
color: "red",
|
575
|
+
style: "dashed",
|
576
|
+
width: "2px"
|
577
|
+
},
|
578
|
+
originalValue: "{a.b}"
|
579
|
+
},
|
580
|
+
{
|
581
|
+
type: "shadow",
|
582
|
+
value: {
|
583
|
+
color: "#000",
|
584
|
+
offsetX: "1px",
|
585
|
+
offsetY: "1px",
|
586
|
+
blur: "1px",
|
587
|
+
spread: "1px",
|
588
|
+
inset: false
|
589
|
+
},
|
590
|
+
originalValue: {
|
591
|
+
color: "#000",
|
592
|
+
offsetX: "{a.a}",
|
593
|
+
offsetY: "1px",
|
594
|
+
blur: "1px",
|
595
|
+
spread: "1px",
|
596
|
+
inset: false
|
597
|
+
},
|
598
|
+
id: "1",
|
599
|
+
kind: "static"
|
600
|
+
},
|
601
|
+
{
|
602
|
+
type: "shadow",
|
603
|
+
kind: "ref",
|
604
|
+
referencedTokenId: "a.b",
|
605
|
+
value: {
|
606
|
+
inset: true,
|
607
|
+
color: "red",
|
608
|
+
offsetX: "1px",
|
609
|
+
blur: "2px",
|
610
|
+
offsetY: "3px",
|
611
|
+
spread: "4px"
|
612
|
+
},
|
613
|
+
originalValue: "{a.b}",
|
614
|
+
id: "1"
|
615
|
+
},
|
616
|
+
{
|
617
|
+
type: "transition",
|
618
|
+
value: {
|
619
|
+
duration: "100ms",
|
620
|
+
delay: "200ms",
|
621
|
+
timingFunction: [0, 0, 0, 0]
|
622
|
+
},
|
623
|
+
originalValue: "{a.b}",
|
624
|
+
kind: "ref",
|
625
|
+
referencedTokenId: "a.b",
|
626
|
+
id: "1"
|
627
|
+
},
|
628
|
+
{
|
629
|
+
type: "transition",
|
630
|
+
kind: "static",
|
631
|
+
value: {
|
632
|
+
duration: "100ms",
|
633
|
+
delay: "200ms",
|
634
|
+
timingFunction: [0, 0, 0, 0]
|
635
|
+
},
|
636
|
+
originalValue: {
|
637
|
+
duration: "100ms",
|
638
|
+
delay: "{a.c}",
|
639
|
+
timingFunction: "{a.c}"
|
640
|
+
},
|
641
|
+
id: "1"
|
642
|
+
},
|
643
|
+
{
|
644
|
+
type: "transition",
|
645
|
+
kind: "static",
|
646
|
+
value: {
|
647
|
+
duration: "100ms",
|
648
|
+
delay: "200ms",
|
649
|
+
timingFunction: [0, 0, 0, 0]
|
650
|
+
},
|
651
|
+
originalValue: {
|
652
|
+
duration: "100ms",
|
653
|
+
delay: "200ms",
|
654
|
+
timingFunction: [0, 0, 0, 0]
|
655
|
+
},
|
656
|
+
id: "1"
|
657
|
+
}
|
658
|
+
]);
|
659
|
+
function isTokenValueColor(value) {
|
660
|
+
return typeof value === "string" && !hasTokenReferences(value);
|
661
|
+
}
|
662
|
+
__name(isTokenValueColor, "isTokenValueColor");
|
663
|
+
var TokenValueColorStruct = s2.define(
|
664
|
+
"Color Value",
|
665
|
+
(value) => {
|
666
|
+
if (typeof value !== "string") {
|
667
|
+
return "Value must be a string";
|
668
|
+
}
|
669
|
+
if (value === "") {
|
670
|
+
return "Value must not be empty";
|
671
|
+
}
|
672
|
+
if (hasTokenReferences(value)) {
|
673
|
+
return "Value must not contain {} (token references)";
|
674
|
+
}
|
675
|
+
return true;
|
676
|
+
}
|
677
|
+
);
|
678
|
+
var TokenDataColorNonRefStruct = s2.assign(
|
679
|
+
s2.type({
|
680
|
+
type: s2.literal("color"),
|
681
|
+
value: TokenValueColorStruct,
|
682
|
+
kind: s2.literal("static"),
|
683
|
+
originalValue: TokenValueColorStruct
|
684
|
+
}),
|
685
|
+
TokenDataBaseStruct
|
686
|
+
);
|
687
|
+
var TokenDataColorRefStruct = s2.assign(
|
688
|
+
s2.type({
|
689
|
+
type: s2.literal("color"),
|
690
|
+
value: TokenValueColorStruct,
|
691
|
+
kind: s2.literal("ref"),
|
692
|
+
originalValue: TokenReferenceStruct,
|
693
|
+
referencedTokenId: s2.string()
|
694
|
+
}),
|
695
|
+
TokenDataBaseStruct
|
696
|
+
);
|
697
|
+
function isTokenValueDimension(value) {
|
698
|
+
return typeof value === "string" && (value.endsWith("px") || value.endsWith("rem")) && !hasTokenReferences(value);
|
699
|
+
}
|
700
|
+
__name(isTokenValueDimension, "isTokenValueDimension");
|
701
|
+
var TokenValueDimensionStruct = s2.define("Dimension Value", (value) => {
|
702
|
+
if (typeof value !== "string") {
|
703
|
+
return "Value must be a string";
|
704
|
+
}
|
705
|
+
if (hasTokenReferences(value)) {
|
706
|
+
return "Value must not contain {} (token references)";
|
707
|
+
}
|
708
|
+
if (!value.endsWith("px") && !value.endsWith("rem") && !value.endsWith("em") && !value.endsWith("%")) {
|
709
|
+
return "Value must end with px, rem, em or %";
|
710
|
+
}
|
711
|
+
return true;
|
712
|
+
});
|
713
|
+
var TokenDataDimensionNonRefStruct = s2.assign(
|
714
|
+
s2.type({
|
715
|
+
type: s2.literal("dimension"),
|
716
|
+
value: TokenValueDimensionStruct,
|
717
|
+
kind: s2.literal("static"),
|
718
|
+
originalValue: TokenValueDimensionStruct
|
719
|
+
}),
|
720
|
+
TokenDataBaseStruct
|
721
|
+
);
|
722
|
+
var TokenDataDimensionRefStruct = s2.assign(
|
723
|
+
s2.type({
|
724
|
+
type: s2.literal("dimension"),
|
725
|
+
value: TokenValueDimensionStruct,
|
726
|
+
kind: s2.literal("ref"),
|
727
|
+
originalValue: TokenReferenceStruct,
|
728
|
+
referencedTokenId: s2.string()
|
729
|
+
}),
|
730
|
+
TokenDataBaseStruct
|
731
|
+
);
|
732
|
+
function isTokenValueDuration(value) {
|
733
|
+
return typeof value === "string" && value.endsWith("ms") && !hasTokenReferences(value);
|
734
|
+
}
|
735
|
+
__name(isTokenValueDuration, "isTokenValueDuration");
|
736
|
+
var TokenValueDurationStruct = s2.define("Duration Value", (value) => {
|
737
|
+
if (typeof value !== "string") {
|
738
|
+
return "Value must be a string";
|
739
|
+
}
|
740
|
+
if (hasTokenReferences(value)) {
|
741
|
+
return "Value must not contain {} (token references)";
|
742
|
+
}
|
743
|
+
const durationRegex = /^\d+ms$/;
|
744
|
+
if (!durationRegex.test(value)) {
|
745
|
+
return 'Value must be a number followed by "ms" (e.g., "100ms")';
|
746
|
+
}
|
747
|
+
return true;
|
748
|
+
});
|
749
|
+
var TokenDataDurationNonRefStruct = s2.assign(
|
750
|
+
s2.type({
|
751
|
+
type: s2.literal("duration"),
|
752
|
+
value: TokenValueDurationStruct,
|
753
|
+
kind: s2.literal("static"),
|
754
|
+
originalValue: TokenValueDurationStruct
|
755
|
+
}),
|
756
|
+
TokenDataBaseStruct
|
757
|
+
);
|
758
|
+
var TokenDataDurationRefStruct = s2.assign(
|
759
|
+
s2.type({
|
760
|
+
type: s2.literal("duration"),
|
761
|
+
value: TokenValueDurationStruct,
|
762
|
+
kind: s2.literal("ref"),
|
763
|
+
originalValue: TokenReferenceStruct,
|
764
|
+
referencedTokenId: s2.string()
|
765
|
+
}),
|
766
|
+
TokenDataBaseStruct
|
767
|
+
);
|
768
|
+
function isTokenValueFontWeight(value) {
|
769
|
+
return (typeof value === "string" || typeof value === "number") && !hasTokenReferences(value);
|
770
|
+
}
|
771
|
+
__name(isTokenValueFontWeight, "isTokenValueFontWeight");
|
772
|
+
var TokenValueFontWeightStruct = s2.define("Font Weight Value", (value) => {
|
773
|
+
if (typeof value !== "string" && typeof value !== "number") {
|
774
|
+
return "Value must be a string or number";
|
775
|
+
}
|
776
|
+
if (hasTokenReferences(value)) {
|
777
|
+
return "Value must not contain {} (token references)";
|
778
|
+
}
|
779
|
+
return true;
|
780
|
+
});
|
781
|
+
var TokenDataFontWeightNonRefStruct = s2.assign(
|
782
|
+
s2.type({
|
783
|
+
type: s2.literal("fontWeight"),
|
784
|
+
value: TokenValueFontWeightStruct,
|
785
|
+
kind: s2.literal("static"),
|
786
|
+
originalValue: TokenValueFontWeightStruct
|
787
|
+
}),
|
788
|
+
TokenDataBaseStruct
|
789
|
+
);
|
790
|
+
var TokenDataFontWeightRefStruct = s2.assign(
|
791
|
+
s2.type({
|
792
|
+
type: s2.literal("fontWeight"),
|
793
|
+
value: TokenValueFontWeightStruct,
|
794
|
+
kind: s2.literal("ref"),
|
795
|
+
originalValue: TokenReferenceStruct,
|
796
|
+
referencedTokenId: s2.string()
|
797
|
+
}),
|
798
|
+
TokenDataBaseStruct
|
799
|
+
);
|
800
|
+
var TokenValueCubicBezierStruct = s2.define("Cubic Bezier Value", (value) => {
|
801
|
+
if (!Array.isArray(value)) {
|
802
|
+
return "Value must be an array";
|
803
|
+
}
|
804
|
+
if (value.length !== 4) {
|
805
|
+
return "Value must be an array of 4 numbers";
|
806
|
+
}
|
807
|
+
if (!value.every((v) => typeof v === "number")) {
|
808
|
+
return "Value must be an array of 4 numbers";
|
809
|
+
}
|
810
|
+
if (value[0] < 0 || value[0] > 1 || value[2] < 0 || value[2] > 1) {
|
811
|
+
return "The first and third cubicBezier values must be between 0 and 1";
|
812
|
+
}
|
813
|
+
return true;
|
814
|
+
});
|
815
|
+
var TokenDataCubicBezierNonRefStruct = s2.assign(
|
816
|
+
s2.type({
|
817
|
+
type: s2.literal("cubicBezier"),
|
818
|
+
value: TokenValueCubicBezierStruct,
|
819
|
+
kind: s2.literal("static"),
|
820
|
+
originalValue: TokenValueCubicBezierStruct
|
821
|
+
}),
|
822
|
+
TokenDataBaseStruct
|
823
|
+
);
|
824
|
+
var TokenDataCubicBezierRefStruct = s2.assign(
|
825
|
+
s2.type({
|
826
|
+
type: s2.literal("cubicBezier"),
|
827
|
+
value: TokenValueCubicBezierStruct,
|
828
|
+
kind: s2.literal("ref"),
|
829
|
+
originalValue: TokenReferenceStruct,
|
830
|
+
referencedTokenId: s2.string()
|
831
|
+
}),
|
832
|
+
TokenDataBaseStruct
|
833
|
+
);
|
834
|
+
function isTokenValueShadow(value) {
|
835
|
+
return isObject2(value) && isTokenValueColor(value.color) && isTokenValueDimension(value.offsetX) && isTokenValueDimension(value.offsetY) && isTokenValueDimension(value.blur) && isTokenValueDimension(value.spread);
|
836
|
+
}
|
837
|
+
__name(isTokenValueShadow, "isTokenValueShadow");
|
838
|
+
var TokenValueShadowStruct = s2.define(
|
839
|
+
"Shadow Value",
|
840
|
+
(value) => {
|
841
|
+
if (isTokenValueShadow(value)) return true;
|
842
|
+
return `Expected a shadow value, got ${JSON.stringify(value)}`;
|
843
|
+
}
|
844
|
+
);
|
845
|
+
var TokenDataShadowNonRefStruct = s2.assign(
|
846
|
+
s2.type({
|
847
|
+
type: s2.literal("shadow"),
|
848
|
+
value: TokenValueShadowStruct,
|
849
|
+
kind: s2.literal("static"),
|
850
|
+
originalValue: s2.type({
|
851
|
+
color: s2.union([TokenValueColorStruct, TokenReferenceStruct]),
|
852
|
+
offsetX: s2.union([TokenValueDimensionStruct, TokenReferenceStruct]),
|
853
|
+
offsetY: s2.union([TokenValueDimensionStruct, TokenReferenceStruct]),
|
854
|
+
blur: s2.union([TokenValueDimensionStruct, TokenReferenceStruct]),
|
855
|
+
spread: s2.union([TokenValueDimensionStruct, TokenReferenceStruct]),
|
856
|
+
inset: s2.union([
|
857
|
+
// marking this as optional b/c it could be `undefined` instead of `false`
|
858
|
+
s2.optional(s2.boolean()),
|
859
|
+
TokenReferenceStruct
|
860
|
+
])
|
861
|
+
})
|
862
|
+
}),
|
863
|
+
TokenDataBaseStruct
|
864
|
+
);
|
865
|
+
var TokenDataShadowRefStruct = s2.assign(
|
866
|
+
s2.type({
|
867
|
+
type: s2.literal("shadow"),
|
868
|
+
value: TokenValueShadowStruct,
|
869
|
+
kind: s2.literal("ref"),
|
870
|
+
originalValue: TokenReferenceStruct,
|
871
|
+
referencedTokenId: s2.string()
|
872
|
+
}),
|
873
|
+
TokenDataBaseStruct
|
874
|
+
);
|
875
|
+
var TokenValueStrokeStyleStruct = s2.union([
|
876
|
+
s2.literal("solid"),
|
877
|
+
s2.literal("dashed"),
|
878
|
+
s2.literal("dotted"),
|
879
|
+
s2.literal("double"),
|
880
|
+
s2.literal("groove"),
|
881
|
+
s2.literal("ridge"),
|
882
|
+
s2.literal("outset"),
|
883
|
+
s2.literal("inset")
|
884
|
+
]);
|
885
|
+
function isTokenValueBorder(value) {
|
886
|
+
return isObject2(value) && TokenValueColorStruct.is(value.color) && TokenValueStrokeStyleStruct.is(value.style) && TokenValueDimensionStruct.is(value.width);
|
887
|
+
}
|
888
|
+
__name(isTokenValueBorder, "isTokenValueBorder");
|
889
|
+
var TokenValueBorderStruct = s2.define(
|
890
|
+
"Border Value",
|
891
|
+
isTokenValueBorder
|
892
|
+
);
|
893
|
+
var TokenDataBorderNonRefStruct = s2.assign(
|
894
|
+
s2.type({
|
895
|
+
type: s2.literal("border"),
|
896
|
+
value: TokenValueBorderStruct,
|
897
|
+
kind: s2.literal("static"),
|
898
|
+
originalValue: s2.type({
|
899
|
+
color: s2.union([TokenValueColorStruct, TokenReferenceStruct]),
|
900
|
+
style: s2.union([TokenValueStrokeStyleStruct, TokenReferenceStruct]),
|
901
|
+
width: s2.union([TokenValueDimensionStruct, TokenReferenceStruct])
|
902
|
+
})
|
903
|
+
}),
|
904
|
+
TokenDataBaseStruct
|
905
|
+
);
|
906
|
+
var TokenDataBorderRefStruct = s2.assign(
|
907
|
+
s2.type({
|
908
|
+
type: s2.literal("border"),
|
909
|
+
value: TokenValueBorderStruct,
|
910
|
+
kind: s2.literal("ref"),
|
911
|
+
originalValue: TokenReferenceStruct,
|
912
|
+
referencedTokenId: s2.string()
|
913
|
+
}),
|
914
|
+
TokenDataBaseStruct
|
915
|
+
);
|
916
|
+
function isTokenValueTransition(value) {
|
917
|
+
return isObject2(value) && TokenValueCubicBezierStruct.is(value.timingFunction) && TokenValueDurationStruct.is(value.duration) && TokenValueDurationStruct.is(value.delay);
|
918
|
+
}
|
919
|
+
__name(isTokenValueTransition, "isTokenValueTransition");
|
920
|
+
var TokenValueTransitionStruct = s2.define(
|
921
|
+
"Transition Value",
|
922
|
+
isTokenValueTransition
|
923
|
+
);
|
924
|
+
var TokenDataTransitionNonRefStruct = s2.assign(
|
925
|
+
s2.type({
|
926
|
+
type: s2.literal("transition"),
|
927
|
+
value: TokenValueTransitionStruct,
|
928
|
+
kind: s2.literal("static"),
|
929
|
+
originalValue: s2.type({
|
930
|
+
timingFunction: s2.union([
|
931
|
+
TokenValueCubicBezierStruct,
|
932
|
+
TokenReferenceStruct
|
933
|
+
]),
|
934
|
+
duration: s2.union([TokenValueDurationStruct, TokenReferenceStruct]),
|
935
|
+
delay: s2.union([TokenValueDurationStruct, TokenReferenceStruct])
|
936
|
+
})
|
937
|
+
}),
|
938
|
+
TokenDataBaseStruct
|
939
|
+
);
|
940
|
+
var TokenDataTransitionRefStruct = s2.assign(
|
941
|
+
s2.type({
|
942
|
+
type: s2.literal("transition"),
|
943
|
+
value: TokenValueTransitionStruct,
|
944
|
+
kind: s2.literal("ref"),
|
945
|
+
originalValue: TokenReferenceStruct,
|
946
|
+
referencedTokenId: s2.string()
|
947
|
+
}),
|
948
|
+
TokenDataBaseStruct
|
949
|
+
);
|
950
|
+
var TokenDataStringNonRefStruct = s2.assign(
|
951
|
+
s2.type({
|
952
|
+
type: s2.literal("string"),
|
953
|
+
value: s2.string(),
|
954
|
+
kind: s2.literal("static"),
|
955
|
+
originalValue: s2.string()
|
956
|
+
}),
|
957
|
+
TokenDataBaseStruct
|
958
|
+
);
|
959
|
+
var TokenDataStringRefStruct = s2.assign(
|
960
|
+
s2.type({
|
961
|
+
type: s2.literal("string"),
|
962
|
+
value: s2.string(),
|
963
|
+
kind: s2.literal("ref"),
|
964
|
+
originalValue: TokenReferenceStruct,
|
965
|
+
referencedTokenId: s2.string()
|
966
|
+
}),
|
967
|
+
TokenDataBaseStruct
|
968
|
+
);
|
969
|
+
var TokenDataStrokeStyleNonRefStruct = s2.assign(
|
970
|
+
s2.type({
|
971
|
+
type: s2.literal("strokeStyle"),
|
972
|
+
value: TokenValueStrokeStyleStruct,
|
973
|
+
kind: s2.literal("static"),
|
974
|
+
originalValue: TokenValueStrokeStyleStruct
|
975
|
+
}),
|
976
|
+
TokenDataBaseStruct
|
977
|
+
);
|
978
|
+
var TokenDataStrokeStyleRefStruct = s2.assign(
|
979
|
+
s2.type({
|
980
|
+
type: s2.literal("strokeStyle"),
|
981
|
+
value: TokenValueStrokeStyleStruct,
|
982
|
+
kind: s2.literal("ref"),
|
983
|
+
originalValue: TokenReferenceStruct,
|
984
|
+
referencedTokenId: TokenValueStrokeStyleStruct
|
985
|
+
}),
|
986
|
+
TokenDataBaseStruct
|
987
|
+
);
|
988
|
+
var TokenDataNumberNonRefStruct = s2.assign(
|
989
|
+
s2.type({
|
990
|
+
type: s2.literal("number"),
|
991
|
+
value: s2.number(),
|
992
|
+
kind: s2.literal("static"),
|
993
|
+
originalValue: s2.number()
|
994
|
+
}),
|
995
|
+
TokenDataBaseStruct
|
996
|
+
);
|
997
|
+
var TokenDataNumberRefStruct = s2.assign(
|
998
|
+
s2.type({
|
999
|
+
type: s2.literal("number"),
|
1000
|
+
value: s2.number(),
|
1001
|
+
kind: s2.literal("ref"),
|
1002
|
+
originalValue: TokenReferenceStruct,
|
1003
|
+
referencedTokenId: s2.string()
|
1004
|
+
}),
|
1005
|
+
TokenDataBaseStruct
|
1006
|
+
);
|
1007
|
+
var TokenDataBooleanNonRefStruct = s2.assign(
|
1008
|
+
s2.type({
|
1009
|
+
type: s2.literal("boolean"),
|
1010
|
+
value: s2.boolean(),
|
1011
|
+
kind: s2.literal("static"),
|
1012
|
+
originalValue: s2.boolean()
|
1013
|
+
}),
|
1014
|
+
TokenDataBaseStruct
|
1015
|
+
);
|
1016
|
+
var TokenDataBooleanRefStruct = s2.assign(
|
1017
|
+
s2.type({
|
1018
|
+
type: s2.literal("boolean"),
|
1019
|
+
value: s2.boolean(),
|
1020
|
+
kind: s2.literal("ref"),
|
1021
|
+
originalValue: TokenReferenceStruct,
|
1022
|
+
referencedTokenId: s2.string()
|
1023
|
+
}),
|
1024
|
+
TokenDataBaseStruct
|
1025
|
+
);
|
1026
|
+
var assertTokenData = /* @__PURE__ */ __name((data) => {
|
1027
|
+
if (!isObject2(data)) {
|
1028
|
+
throw new Error(
|
1029
|
+
`Expected token data to be an object, got ${JSON.stringify(data)}`
|
1030
|
+
);
|
1031
|
+
}
|
1032
|
+
if (!isObjKey2("type", data)) {
|
1033
|
+
throw new Error(
|
1034
|
+
`Expected token data to have a "type" property, got ${JSON.stringify(
|
1035
|
+
data
|
1036
|
+
)}`
|
1037
|
+
);
|
1038
|
+
}
|
1039
|
+
if (typeof data.type !== "string") {
|
1040
|
+
throw new Error(
|
1041
|
+
`Expected token data "type" property to be a string, got ${JSON.stringify(
|
1042
|
+
data
|
1043
|
+
)}`
|
1044
|
+
);
|
1045
|
+
}
|
1046
|
+
const type9 = data.type;
|
1047
|
+
const kind = data.kind;
|
1048
|
+
try {
|
1049
|
+
switch (type9) {
|
1050
|
+
case "boolean":
|
1051
|
+
if (kind === "ref") {
|
1052
|
+
TokenDataBooleanRefStruct.assert(data);
|
1053
|
+
} else {
|
1054
|
+
TokenDataBooleanNonRefStruct.assert(data);
|
1055
|
+
}
|
1056
|
+
return;
|
1057
|
+
case "border":
|
1058
|
+
if (kind === "ref") {
|
1059
|
+
TokenDataBorderRefStruct.assert(data);
|
1060
|
+
} else {
|
1061
|
+
TokenDataBorderNonRefStruct.assert(data);
|
1062
|
+
}
|
1063
|
+
return;
|
1064
|
+
case "color":
|
1065
|
+
if (kind === "ref") {
|
1066
|
+
TokenDataColorRefStruct.assert(data);
|
1067
|
+
} else {
|
1068
|
+
TokenDataColorNonRefStruct.assert(data);
|
1069
|
+
}
|
1070
|
+
return;
|
1071
|
+
case "cubicBezier":
|
1072
|
+
if (kind === "ref") {
|
1073
|
+
TokenDataCubicBezierRefStruct.assert(data);
|
1074
|
+
} else {
|
1075
|
+
TokenDataCubicBezierNonRefStruct.assert(data);
|
1076
|
+
}
|
1077
|
+
return;
|
1078
|
+
case "dimension":
|
1079
|
+
if (kind === "ref") {
|
1080
|
+
TokenDataDimensionRefStruct.assert(data);
|
1081
|
+
} else {
|
1082
|
+
TokenDataDimensionNonRefStruct.assert(data);
|
1083
|
+
}
|
1084
|
+
return;
|
1085
|
+
case "duration":
|
1086
|
+
if (kind === "ref") {
|
1087
|
+
TokenDataDurationRefStruct.assert(data);
|
1088
|
+
} else {
|
1089
|
+
TokenDataDurationNonRefStruct.assert(data);
|
1090
|
+
}
|
1091
|
+
return;
|
1092
|
+
case "fontWeight":
|
1093
|
+
if (kind === "ref") {
|
1094
|
+
TokenDataFontWeightRefStruct.assert(data);
|
1095
|
+
} else {
|
1096
|
+
TokenDataFontWeightNonRefStruct.assert(data);
|
1097
|
+
}
|
1098
|
+
return;
|
1099
|
+
case "number":
|
1100
|
+
if (kind === "ref") {
|
1101
|
+
TokenDataNumberRefStruct.assert(data);
|
1102
|
+
} else {
|
1103
|
+
TokenDataNumberNonRefStruct.assert(data);
|
1104
|
+
}
|
1105
|
+
return;
|
1106
|
+
case "shadow":
|
1107
|
+
if (kind === "ref") {
|
1108
|
+
TokenDataShadowRefStruct.assert(data);
|
1109
|
+
} else {
|
1110
|
+
TokenDataShadowNonRefStruct.assert(data);
|
1111
|
+
}
|
1112
|
+
return;
|
1113
|
+
case "string":
|
1114
|
+
if (kind === "ref") {
|
1115
|
+
TokenDataStringRefStruct.assert(data);
|
1116
|
+
} else {
|
1117
|
+
TokenDataStringNonRefStruct.assert(data);
|
1118
|
+
}
|
1119
|
+
return;
|
1120
|
+
case "strokeStyle":
|
1121
|
+
if (kind === "ref") {
|
1122
|
+
TokenDataStrokeStyleRefStruct.assert(data);
|
1123
|
+
} else {
|
1124
|
+
TokenDataStrokeStyleNonRefStruct.assert(data);
|
1125
|
+
}
|
1126
|
+
return;
|
1127
|
+
case "transition":
|
1128
|
+
if (kind === "ref") {
|
1129
|
+
TokenDataTransitionRefStruct.assert(data);
|
1130
|
+
} else {
|
1131
|
+
TokenDataTransitionNonRefStruct.assert(data);
|
1132
|
+
}
|
1133
|
+
return;
|
1134
|
+
default: {
|
1135
|
+
const _exhaustiveCheck = type9;
|
1136
|
+
throw new Error(`Unknown token data type: ${type9}`);
|
1137
|
+
}
|
1138
|
+
}
|
1139
|
+
} catch (error) {
|
1140
|
+
if (!(error instanceof s2.StructError)) throw error;
|
1141
|
+
throw new Error(
|
1142
|
+
`Invalid token data for type "${type9}": ${error.message}. Received this data: "${JSON.stringify(data)}"`
|
1143
|
+
);
|
1144
|
+
}
|
1145
|
+
}, "assertTokenData");
|
1146
|
+
|
1147
|
+
// src/app-client-data/design-tokens-types/token-src-value-info.ts
|
1148
|
+
import { expectType as expectType2 } from "@knapsack/utils";
|
1149
|
+
expectType2([
|
1150
|
+
{
|
1151
|
+
type: "dimension",
|
1152
|
+
kind: "static",
|
1153
|
+
value: "1px"
|
1154
|
+
},
|
1155
|
+
{
|
1156
|
+
type: "dimension",
|
1157
|
+
kind: "ref",
|
1158
|
+
referencedTokenId: "a.b"
|
1159
|
+
}
|
1160
|
+
]);
|
1161
|
+
expectType2([
|
1162
|
+
{
|
1163
|
+
type: "border",
|
1164
|
+
kind: "ref",
|
1165
|
+
referencedTokenId: "a.b"
|
1166
|
+
},
|
1167
|
+
{
|
1168
|
+
type: "border",
|
1169
|
+
kind: "static",
|
1170
|
+
value: {
|
1171
|
+
color: {
|
1172
|
+
kind: "static",
|
1173
|
+
type: "color",
|
1174
|
+
value: "red"
|
1175
|
+
},
|
1176
|
+
style: {
|
1177
|
+
kind: "ref",
|
1178
|
+
type: "strokeStyle",
|
1179
|
+
referencedTokenId: ""
|
1180
|
+
// FIX
|
1181
|
+
},
|
1182
|
+
width: {
|
1183
|
+
kind: "static",
|
1184
|
+
type: "dimension",
|
1185
|
+
value: "2px"
|
1186
|
+
}
|
1187
|
+
}
|
1188
|
+
}
|
1189
|
+
]);
|
1190
|
+
expectType2([
|
1191
|
+
{
|
1192
|
+
type: "transition",
|
1193
|
+
kind: "ref",
|
1194
|
+
referencedTokenId: "a.b"
|
1195
|
+
},
|
1196
|
+
{
|
1197
|
+
type: "transition",
|
1198
|
+
kind: "static",
|
1199
|
+
value: {
|
1200
|
+
delay: {
|
1201
|
+
kind: "static",
|
1202
|
+
type: "duration",
|
1203
|
+
value: "1ms"
|
1204
|
+
},
|
1205
|
+
duration: {
|
1206
|
+
kind: "ref",
|
1207
|
+
type: "duration",
|
1208
|
+
referencedTokenId: "animation.slow"
|
1209
|
+
},
|
1210
|
+
timingFunction: {
|
1211
|
+
kind: "static",
|
1212
|
+
type: "cubicBezier",
|
1213
|
+
value: [0.4, 0, 0.2, 1]
|
1214
|
+
}
|
1215
|
+
}
|
1216
|
+
}
|
1217
|
+
]);
|
1218
|
+
function isTokenSrcValueInfoSingular(tokenSrcValueInfo) {
|
1219
|
+
return isTokenTypeSingular(tokenSrcValueInfo?.type);
|
1220
|
+
}
|
1221
|
+
__name(isTokenSrcValueInfoSingular, "isTokenSrcValueInfoSingular");
|
1222
|
+
function isTokenSrcValueInfoComposite(tokenSrcValueInfo) {
|
1223
|
+
return isTokenTypeComposite(tokenSrcValueInfo?.type);
|
1224
|
+
}
|
1225
|
+
__name(isTokenSrcValueInfoComposite, "isTokenSrcValueInfoComposite");
|
1226
|
+
expectType2([
|
1227
|
+
{
|
1228
|
+
type: "dimension",
|
1229
|
+
kind: "static",
|
1230
|
+
value: "1px"
|
1231
|
+
},
|
1232
|
+
{
|
1233
|
+
type: "transition",
|
1234
|
+
kind: "ref",
|
1235
|
+
referencedTokenId: "a.b"
|
1236
|
+
},
|
1237
|
+
{
|
1238
|
+
type: "transition",
|
1239
|
+
kind: "ref",
|
1240
|
+
// @ts-expect-error - with `kind: 'ref'`, `value` is not allowed
|
1241
|
+
value: "1px"
|
1242
|
+
},
|
1243
|
+
{
|
1244
|
+
kind: "ref",
|
1245
|
+
type: "duration",
|
1246
|
+
referencedTokenId: "animation.slow"
|
1247
|
+
},
|
1248
|
+
{
|
1249
|
+
kind: "static",
|
1250
|
+
type: "cubicBezier",
|
1251
|
+
value: [0.4, 0, 0.2, 1]
|
1252
|
+
},
|
1253
|
+
{
|
1254
|
+
type: "transition",
|
1255
|
+
kind: "static",
|
1256
|
+
value: {
|
1257
|
+
delay: {
|
1258
|
+
kind: "static",
|
1259
|
+
type: "duration",
|
1260
|
+
value: "1ms"
|
1261
|
+
},
|
1262
|
+
duration: {
|
1263
|
+
kind: "ref",
|
1264
|
+
type: "duration",
|
1265
|
+
referencedTokenId: "animation.slow"
|
1266
|
+
},
|
1267
|
+
timingFunction: {
|
1268
|
+
kind: "static",
|
1269
|
+
type: "cubicBezier",
|
1270
|
+
value: [0.4, 0, 0.2, 1]
|
1271
|
+
}
|
1272
|
+
}
|
1273
|
+
}
|
1274
|
+
]);
|
1275
|
+
|
1276
|
+
// src/app-client-data/design-tokens-types/token-src.ts
|
1277
|
+
import { expectType as expectType3, isObjKey as isObjKey3, isObject as isObject3 } from "@knapsack/utils";
|
1278
|
+
function isTokenSrcExtensions(extensionsObj) {
|
1279
|
+
return isObject3(extensionsObj) && isObjKey3("cloud.knapsack", extensionsObj);
|
1280
|
+
}
|
1281
|
+
__name(isTokenSrcExtensions, "isTokenSrcExtensions");
|
1282
|
+
expectType3([
|
1283
|
+
"#ddd",
|
1284
|
+
true,
|
1285
|
+
[83, 1, 1, 1],
|
1286
|
+
{
|
1287
|
+
color: "#000",
|
1288
|
+
style: "solid",
|
1289
|
+
width: "1px"
|
1290
|
+
},
|
1291
|
+
{
|
1292
|
+
inset: true,
|
1293
|
+
color: "#000",
|
1294
|
+
offsetX: "0px",
|
1295
|
+
offsetY: "{spacing.medium}",
|
1296
|
+
spread: "0px",
|
1297
|
+
blur: "0px"
|
1298
|
+
},
|
1299
|
+
{
|
1300
|
+
timingFunction: "{timing.ease}",
|
1301
|
+
duration: "{timing.duration.medium}",
|
1302
|
+
delay: "7ms",
|
1303
|
+
color: "#000"
|
1304
|
+
}
|
1305
|
+
]);
|
1306
|
+
function isTokenSrc(tokenObject) {
|
1307
|
+
if (isObject3(tokenObject) && isObjKey3("$value", tokenObject)) return true;
|
1308
|
+
return false;
|
1309
|
+
}
|
1310
|
+
__name(isTokenSrc, "isTokenSrc");
|
1311
|
+
function isTokenGroup(tokenObject) {
|
1312
|
+
return isObject3(tokenObject) && !isTokenSrcExtensions(tokenObject) && !isObjKey3("$value", tokenObject) && // ensuring we are not in `$extensions` object
|
1313
|
+
!isObjKey3("cloud.knapsack", tokenObject);
|
1314
|
+
}
|
1315
|
+
__name(isTokenGroup, "isTokenGroup");
|
1316
|
+
function isTokenTypeVarRef(tokenObject) {
|
1317
|
+
if (isTokenGroup(tokenObject)) {
|
1318
|
+
const varRefCollectionInfo = tokenObject.$extensions["cloud.knapsack"].group.collectionInfo;
|
1319
|
+
if (isObjKey3("type", varRefCollectionInfo) && isObjKey3("referenceId", varRefCollectionInfo)) {
|
1320
|
+
return true;
|
1321
|
+
}
|
1322
|
+
}
|
1323
|
+
return false;
|
1324
|
+
}
|
1325
|
+
__name(isTokenTypeVarRef, "isTokenTypeVarRef");
|
1326
|
+
|
1327
|
+
// src/app-client-data/design-tokens-types/token-utils.ts
|
1328
|
+
import { parseNumberWithUnit } from "@knapsack/utils";
|
1329
|
+
function getPrimitiveValue(tokenValue) {
|
1330
|
+
const type9 = typeof tokenValue;
|
1331
|
+
if (type9 === "string" || type9 === "number" || type9 === "boolean") {
|
1332
|
+
return type9;
|
1333
|
+
}
|
1334
|
+
throw new Error(
|
1335
|
+
`Invalid token value type: ${JSON.stringify(
|
1336
|
+
type9
|
1337
|
+
)}. Token value is: ${JSON.stringify(tokenValue)}`
|
1338
|
+
);
|
1339
|
+
}
|
1340
|
+
__name(getPrimitiveValue, "getPrimitiveValue");
|
1341
|
+
var isDimensionString = /* @__PURE__ */ __name((value) => value.includes("px") || value.includes("rem") || value.includes("em") || value.includes("%"), "isDimensionString");
|
1342
|
+
function parseTokenDimensionValue(valueToParse) {
|
1343
|
+
const { value, unit } = parseNumberWithUnit(valueToParse);
|
1344
|
+
if (!unit) {
|
1345
|
+
return { value };
|
1346
|
+
}
|
1347
|
+
if (unit !== "px" && unit !== "rem" && unit !== "em" && unit !== "%") {
|
1348
|
+
throw new Error(`Invalid unit "${unit}" for value: ${value}`);
|
1349
|
+
}
|
1350
|
+
return { value, unit };
|
1351
|
+
}
|
1352
|
+
__name(parseTokenDimensionValue, "parseTokenDimensionValue");
|
1353
|
+
|
1354
|
+
// src/app-client-data/patterns.ts
|
1355
|
+
var isSlottedText = /* @__PURE__ */ __name((slottedData) => isObject(slottedData) && slottedData.type === "text", "isSlottedText");
|
1356
|
+
function isSlottedTemplateDemo(slottedData) {
|
1357
|
+
return isObject(slottedData) && slottedData.type === "template-demo";
|
1358
|
+
}
|
1359
|
+
__name(isSlottedTemplateDemo, "isSlottedTemplateDemo");
|
1360
|
+
function isSlottedTemplateReference(slottedData) {
|
1361
|
+
return isObject(slottedData) && slottedData.type === "template-reference";
|
1362
|
+
}
|
1363
|
+
__name(isSlottedTemplateReference, "isSlottedTemplateReference");
|
1364
|
+
var StageLayouts = /* @__PURE__ */ ((StageLayouts2) => {
|
1365
|
+
StageLayouts2["portrait"] = "portrait";
|
1366
|
+
StageLayouts2["landscape"] = "landscape";
|
1367
|
+
return StageLayouts2;
|
1368
|
+
})(StageLayouts || {});
|
1369
|
+
function isDataDemo(demo) {
|
1370
|
+
return demo?.type === "data";
|
1371
|
+
}
|
1372
|
+
__name(isDataDemo, "isDataDemo");
|
1373
|
+
function isTemplateDemo(demo) {
|
1374
|
+
return demo?.type === "template";
|
1375
|
+
}
|
1376
|
+
__name(isTemplateDemo, "isTemplateDemo");
|
1377
|
+
|
1378
|
+
// src/app-client-data/page.header.ts
|
1379
|
+
var PageHeaderSizes = /* @__PURE__ */ ((PageHeaderSizes2) => {
|
1380
|
+
PageHeaderSizes2["auto"] = "auto";
|
1381
|
+
PageHeaderSizes2["small"] = "small";
|
1382
|
+
PageHeaderSizes2["medium"] = "medium";
|
1383
|
+
PageHeaderSizes2["large"] = "large";
|
1384
|
+
PageHeaderSizes2["full"] = "full";
|
1385
|
+
return PageHeaderSizes2;
|
1386
|
+
})(PageHeaderSizes || {});
|
1387
|
+
|
1388
|
+
// src/app-client-data/index.ts
|
1389
|
+
function isKsAppClientDataNoMeta(data) {
|
1390
|
+
if (!isObject(data)) return false;
|
1391
|
+
const requiredKeys = [
|
1392
|
+
"assetSetsState",
|
1393
|
+
"customPagesState",
|
1394
|
+
"navsState",
|
1395
|
+
"patternsState",
|
1396
|
+
"tokensSrc",
|
1397
|
+
"db"
|
1398
|
+
];
|
1399
|
+
if (!requiredKeys.every((key) => isObjKey(key, data))) return false;
|
1400
|
+
if (!isObjKey("metaState", data)) return true;
|
1401
|
+
return false;
|
1402
|
+
}
|
1403
|
+
__name(isKsAppClientDataNoMeta, "isKsAppClientDataNoMeta");
|
1404
|
+
var KsAppClientDataNoMetaStruct = define4(
|
1405
|
+
"KsAppClientDataNoMeta",
|
1406
|
+
isKsAppClientDataNoMeta
|
1407
|
+
);
|
1408
|
+
function isKsAppClientDataAndMeta(data) {
|
1409
|
+
if (!isObject(data)) return false;
|
1410
|
+
const requiredKeys = [
|
1411
|
+
"assetSetsState",
|
1412
|
+
"customPagesState",
|
1413
|
+
"navsState",
|
1414
|
+
"patternsState",
|
1415
|
+
"tokensSrc",
|
1416
|
+
"metaState",
|
1417
|
+
"db"
|
1418
|
+
];
|
1419
|
+
return requiredKeys.every((key) => isObjKey(key, data));
|
1420
|
+
}
|
1421
|
+
__name(isKsAppClientDataAndMeta, "isKsAppClientDataAndMeta");
|
1422
|
+
var KsAppClientDataAndMetaStruct = define4(
|
1423
|
+
"KsAppClientDataAndMeta",
|
1424
|
+
isKsAppClientDataAndMeta
|
1425
|
+
);
|
1426
|
+
var KsMetaStateStruct = type6({
|
1427
|
+
isLocalDev: boolean4(),
|
1428
|
+
plugins: array4(
|
1429
|
+
type6({
|
1430
|
+
id: string4(),
|
1431
|
+
hasContent: boolean4(),
|
1432
|
+
clientPluginPath: optional5(string4()),
|
1433
|
+
cssPath: optional5(string4())
|
1434
|
+
})
|
1435
|
+
),
|
1436
|
+
meta: optional5(
|
1437
|
+
type6({
|
1438
|
+
version: optional5(string4()),
|
1439
|
+
hasKnapsackCloud: boolean4(),
|
1440
|
+
knapsackCloudSiteId: optional5(string4()),
|
1441
|
+
serverPort: optional5(number3()),
|
1442
|
+
websocketsPort: optional5(number3()),
|
1443
|
+
https: optional5(boolean4()),
|
1444
|
+
cacheDir: optional5(string4()),
|
1445
|
+
ksVersions: type6({
|
1446
|
+
app: string4()
|
1447
|
+
})
|
1448
|
+
})
|
1449
|
+
)
|
1450
|
+
});
|
1451
|
+
var isKsMetaState = KsMetaStateStruct.is;
|
1452
|
+
|
1453
|
+
// src/app-client-data-v3/index.ts
|
1454
|
+
import {
|
1455
|
+
type as type7,
|
1456
|
+
string as string5,
|
1457
|
+
boolean as boolean5,
|
1458
|
+
optional as optional6,
|
1459
|
+
array as array5,
|
1460
|
+
number as number4,
|
1461
|
+
define as define5
|
1462
|
+
} from "superstruct";
|
1463
|
+
function isKsAppClientDataNoMetaV3(data) {
|
1464
|
+
if (!isObject(data)) return false;
|
1465
|
+
const requiredKeys = [
|
1466
|
+
"assetSetsState",
|
1467
|
+
"customPagesState",
|
1468
|
+
"navsState",
|
1469
|
+
"patternsState",
|
1470
|
+
"settingsState",
|
1471
|
+
"tokensState"
|
1472
|
+
];
|
1473
|
+
if (!requiredKeys.every((key) => isObjKey(key, data))) return false;
|
1474
|
+
if (!isObjKey("metaState", data)) return true;
|
1475
|
+
return false;
|
1476
|
+
}
|
1477
|
+
__name(isKsAppClientDataNoMetaV3, "isKsAppClientDataNoMetaV3");
|
1478
|
+
var KsAppClientDataNoMetaStructV3 = define5(
|
1479
|
+
"KsAppClientDataNoMeta",
|
1480
|
+
isKsAppClientDataNoMetaV3
|
1481
|
+
);
|
1482
|
+
function isKsAppClientDataAndMetaV3(data) {
|
1483
|
+
if (!isObject(data)) return false;
|
1484
|
+
const requiredKeys = [
|
1485
|
+
"assetSetsState",
|
1486
|
+
"customPagesState",
|
1487
|
+
"navsState",
|
1488
|
+
"patternsState",
|
1489
|
+
"settingsState",
|
1490
|
+
"tokensState",
|
1491
|
+
"metaState"
|
1492
|
+
];
|
1493
|
+
return requiredKeys.every((key) => isObjKey(key, data));
|
1494
|
+
}
|
1495
|
+
__name(isKsAppClientDataAndMetaV3, "isKsAppClientDataAndMetaV3");
|
1496
|
+
var KsAppClientDataAndMetaStructV3 = define5(
|
1497
|
+
"KsAppClientDataAndMeta",
|
1498
|
+
isKsAppClientDataAndMetaV3
|
1499
|
+
);
|
1500
|
+
var KsMetaStateStructV3 = type7({
|
1501
|
+
isLocalDev: boolean5(),
|
1502
|
+
plugins: array5(
|
1503
|
+
type7({
|
1504
|
+
id: string5(),
|
1505
|
+
hasContent: boolean5(),
|
1506
|
+
clientPluginPath: optional6(string5()),
|
1507
|
+
cssPath: optional6(string5())
|
1508
|
+
})
|
1509
|
+
),
|
1510
|
+
meta: optional6(
|
1511
|
+
type7({
|
1512
|
+
version: optional6(string5()),
|
1513
|
+
hasKnapsackCloud: boolean5(),
|
1514
|
+
knapsackCloudSiteId: optional6(string5()),
|
1515
|
+
serverPort: optional6(number4()),
|
1516
|
+
websocketsPort: optional6(number4()),
|
1517
|
+
https: optional6(boolean5()),
|
1518
|
+
cacheDir: optional6(string5()),
|
1519
|
+
ksVersions: type7({
|
1520
|
+
app: string5()
|
1521
|
+
})
|
1522
|
+
})
|
1523
|
+
)
|
1524
|
+
});
|
1525
|
+
var isKsMetaStateV3 = KsMetaStateStructV3.is;
|
1526
|
+
|
1527
|
+
// src/app-client-data-migrations/4.1.7-demos.ts
|
1528
|
+
import { isDraft } from "immer";
|
1529
|
+
var migration417Demos = {
|
1530
|
+
version: "4.1.7",
|
1531
|
+
checkIfNeeded: /* @__PURE__ */ __name((appClientData) => {
|
1532
|
+
return true;
|
1533
|
+
}, "checkIfNeeded"),
|
1534
|
+
// note that `appClientData` is mutable since we're already in Immer
|
1535
|
+
migrate: /* @__PURE__ */ __name((appClientData) => {
|
1536
|
+
if (!isDraft(appClientData)) {
|
1537
|
+
throw new Error(
|
1538
|
+
`Tried to run migrations on appClientData but it is not an Immer Draft`
|
1539
|
+
);
|
1540
|
+
}
|
1541
|
+
Object.values(appClientData.patternsState.patterns).forEach(
|
1542
|
+
(pattern) => {
|
1543
|
+
delete pattern.demoSize;
|
1544
|
+
}
|
1545
|
+
);
|
1546
|
+
Object.values(appClientData.db.demos.byId).forEach((demo) => {
|
1547
|
+
if (demo.type !== "data") return;
|
1548
|
+
Object.entries(demo.data.slots ?? {}).forEach(([slotName, slotData]) => {
|
1549
|
+
demo.data.slots[slotName] = slotData.map(
|
1550
|
+
(slottedData) => {
|
1551
|
+
if (typeof slottedData === "string") {
|
1552
|
+
return {
|
1553
|
+
type: "text",
|
1554
|
+
text: slottedData
|
1555
|
+
};
|
1556
|
+
}
|
1557
|
+
if (
|
1558
|
+
// not doing anything with these
|
1559
|
+
slottedData.type === "template-reference" || // these already were migrated or made by the new editor
|
1560
|
+
slottedData.type === "text"
|
1561
|
+
) {
|
1562
|
+
return slottedData;
|
1563
|
+
}
|
1564
|
+
slottedData.type = "template-demo";
|
1565
|
+
return slottedData;
|
1566
|
+
}
|
1567
|
+
);
|
1568
|
+
});
|
1569
|
+
if (demo.patternId && demo.templateId) return;
|
1570
|
+
(() => {
|
1571
|
+
for (const { id: pId, templates = [] } of Object.values(
|
1572
|
+
appClientData.patternsState.patterns
|
1573
|
+
)) {
|
1574
|
+
for (const { id: tId, demoIds = [] } of templates) {
|
1575
|
+
if (demoIds.includes(demo.id)) {
|
1576
|
+
demo.patternId = pId;
|
1577
|
+
demo.templateId = tId;
|
1578
|
+
return;
|
1579
|
+
}
|
1580
|
+
}
|
1581
|
+
}
|
1582
|
+
})();
|
1583
|
+
});
|
1584
|
+
}, "migrate")
|
1585
|
+
};
|
1586
|
+
|
1587
|
+
// src/app-client-data-migrations/index.ts
|
1588
|
+
var migrations = [migration417Demos];
|
1589
|
+
|
1590
|
+
// src/json-schema.ts
|
1591
|
+
var PropTypeNames = /* @__PURE__ */ ((PropTypeNames2) => {
|
1592
|
+
PropTypeNames2["string"] = "string";
|
1593
|
+
PropTypeNames2["boolean"] = "boolean";
|
1594
|
+
PropTypeNames2["number"] = "number";
|
1595
|
+
PropTypeNames2["object"] = "object";
|
1596
|
+
PropTypeNames2["options"] = "options";
|
1597
|
+
PropTypeNames2["function"] = "function";
|
1598
|
+
PropTypeNames2["customTypeScript"] = "customTypeScript";
|
1599
|
+
PropTypeNames2["array"] = "array";
|
1600
|
+
PropTypeNames2["arrayOfObjects"] = "arrayOfObjects";
|
1601
|
+
PropTypeNames2["arrayOfStrings"] = "arrayOfStrings";
|
1602
|
+
PropTypeNames2["unknown"] = "unknown";
|
1603
|
+
return PropTypeNames2;
|
1604
|
+
})(PropTypeNames || {});
|
1605
|
+
var isStringProp = /* @__PURE__ */ __name((prop) => "type" in prop && prop.type === "string" && !("enum" in prop), "isStringProp");
|
1606
|
+
var isNumberProp = /* @__PURE__ */ __name((prop) => "type" in prop && prop.type === "number", "isNumberProp");
|
1607
|
+
var isBooleanProp = /* @__PURE__ */ __name((prop) => "type" in prop && prop.type === "boolean", "isBooleanProp");
|
1608
|
+
var isOptionsProp = /* @__PURE__ */ __name((prop) => "enum" in prop, "isOptionsProp");
|
1609
|
+
var isFunctionProp = /* @__PURE__ */ __name((prop) => "typeof" in prop && prop?.typeof === "function", "isFunctionProp");
|
1610
|
+
var isCustomTypeScriptProp = /* @__PURE__ */ __name((prop) => !("typeof" in prop) && "tsType" in prop, "isCustomTypeScriptProp");
|
1611
|
+
var isArrayOfObjectsProp = /* @__PURE__ */ __name((prop) => "type" in prop && prop.type === "array" && "items" in prop && prop.items.type === "object", "isArrayOfObjectsProp");
|
1612
|
+
var isObjectProp = /* @__PURE__ */ __name((prop) => "type" in prop && prop.type === "object" && "properties" in prop && Object.keys(prop.properties).length > 0, "isObjectProp");
|
1613
|
+
var isArrayOfStringsProp = /* @__PURE__ */ __name((prop) => "type" in prop && prop.type === "array" && "items" in prop && prop.items.type === "string", "isArrayOfStringsProp");
|
1614
|
+
|
1615
|
+
// src/changes.ts
|
1616
|
+
import * as s3 from "superstruct";
|
1617
|
+
var PatchStructRuntime = s3.object({
|
1618
|
+
op: s3.union([s3.literal("replace"), s3.literal("remove"), s3.literal("add")]),
|
1619
|
+
path: s3.array(s3.union([s3.string(), s3.number()])),
|
1620
|
+
value: s3.optional(s3.any())
|
1621
|
+
});
|
1622
|
+
var PatchStruct = PatchStructRuntime;
|
1623
|
+
var isPatch = /* @__PURE__ */ __name((patch) => PatchStruct.is(patch), "isPatch");
|
1624
|
+
var PatchesStructRuntime = s3.array(PatchStructRuntime);
|
1625
|
+
var PatchesStruct = PatchesStructRuntime;
|
1626
|
+
var isPatches = /* @__PURE__ */ __name((patches) => PatchesStruct.is(patches), "isPatches");
|
1627
|
+
var KsRemoteChangeRuntime = s3.type({
|
1628
|
+
patches: PatchesStructRuntime,
|
1629
|
+
inversePatches: s3.optional(PatchesStructRuntime),
|
1630
|
+
event: s3.optional(s3.object({ type: s3.string() })),
|
1631
|
+
id: s3.string(),
|
1632
|
+
date: s3.string(),
|
1633
|
+
userId: s3.optional(s3.string())
|
1634
|
+
});
|
1635
|
+
var KsRemoteChangeStruct = KsRemoteChangeRuntime;
|
1636
|
+
var isKsRemoteChange = /* @__PURE__ */ __name((change) => KsRemoteChangeStruct.is(change), "isKsRemoteChange");
|
1637
|
+
var KsRemoteChangesStructRuntime = s3.array(KsRemoteChangeRuntime);
|
1638
|
+
var KsRemoteChangesStruct = KsRemoteChangesStructRuntime;
|
1639
|
+
var isKsRemoteChanges = /* @__PURE__ */ __name((changes) => KsRemoteChangesStruct.is(changes), "isKsRemoteChanges");
|
1640
|
+
|
1641
|
+
// src/renderers.ts
|
1642
|
+
var rendererIds = {
|
1643
|
+
react: "react",
|
1644
|
+
vue: "vue",
|
1645
|
+
"web-components": "web-components",
|
1646
|
+
twig: "twig",
|
1647
|
+
hbs: "hbs",
|
1648
|
+
angular: "angular",
|
1649
|
+
html: "html"
|
1650
|
+
};
|
1651
|
+
|
1652
|
+
// src/renderer-client-types.ts
|
1653
|
+
var KsRendererClientEvents = /* @__PURE__ */ ((KsRendererClientEvents2) => {
|
1654
|
+
KsRendererClientEvents2["ready"] = "ready";
|
1655
|
+
return KsRendererClientEvents2;
|
1656
|
+
})(KsRendererClientEvents || {});
|
1657
|
+
var ksRendererClientMetaId = "ks-meta";
|
1658
|
+
|
1659
|
+
// src/web-sockets.ts
|
1660
|
+
var WS_EVENTS = {
|
1661
|
+
PATTERN_TEMPLATE_CHANGED: "PATTERN_TEMPLATE_CHANGED",
|
1662
|
+
PATTERN_ASSET_CHANGED: "PATTERN_ASSET_CHANGED",
|
1663
|
+
DESIGN_TOKENS_CHANGED: "DESIGN_TOKENS_CHANGED",
|
1664
|
+
RENDERER_CLIENT_RELOAD: "RENDERER_CLIENT_RELOAD",
|
1665
|
+
APP_CLIENT_DATA_CHANGED: "APP_CLIENT_DATA_CHANGED"
|
1666
|
+
};
|
1667
|
+
|
1668
|
+
// src/git-providers.ts
|
1669
|
+
var GitProviderType = /* @__PURE__ */ ((GitProviderType2) => {
|
1670
|
+
GitProviderType2["GitHub"] = "GitHub";
|
1671
|
+
GitProviderType2["GitLab"] = "GitLab";
|
1672
|
+
GitProviderType2["GitLabRest"] = "GitLabRest";
|
1673
|
+
GitProviderType2["Bitbucket"] = "Bitbucket";
|
1674
|
+
GitProviderType2["Azure"] = "Azure";
|
1675
|
+
return GitProviderType2;
|
1676
|
+
})(GitProviderType || {});
|
1677
|
+
var MergeableState = /* @__PURE__ */ ((MergeableState2) => {
|
1678
|
+
MergeableState2["Conflicting"] = "CONFLICTING";
|
1679
|
+
MergeableState2["Mergeable"] = "MERGEABLE";
|
1680
|
+
MergeableState2["Unknown"] = "UNKNOWN";
|
1681
|
+
return MergeableState2;
|
1682
|
+
})(MergeableState || {});
|
1683
|
+
var RestActions = /* @__PURE__ */ ((RestActions2) => {
|
1684
|
+
RestActions2["Create"] = "CREATE";
|
1685
|
+
RestActions2["Move"] = "MOVE";
|
1686
|
+
RestActions2["Update"] = "UPDATE";
|
1687
|
+
RestActions2["Chmod"] = "CHMOD";
|
1688
|
+
return RestActions2;
|
1689
|
+
})(RestActions || {});
|
1690
|
+
var TextEncoding = /* @__PURE__ */ ((TextEncoding2) => {
|
1691
|
+
TextEncoding2["Base64"] = "BASE64";
|
1692
|
+
TextEncoding2["Text"] = "TEXT";
|
1693
|
+
return TextEncoding2;
|
1694
|
+
})(TextEncoding || {});
|
1695
|
+
|
1696
|
+
// src/api/plugins.ts
|
1697
|
+
var plugins_exports = {};
|
1698
|
+
__export(plugins_exports, {
|
1699
|
+
ACTIONS: () => ACTIONS,
|
1700
|
+
endpoint: () => endpoint
|
1701
|
+
});
|
1702
|
+
var endpoint = `/plugins`;
|
1703
|
+
var ACTIONS = /* @__PURE__ */ ((ACTIONS3) => {
|
1704
|
+
ACTIONS3["getContent"] = "getContent";
|
1705
|
+
return ACTIONS3;
|
1706
|
+
})(ACTIONS || {});
|
1707
|
+
|
1708
|
+
// src/api/files.ts
|
1709
|
+
var files_exports = {};
|
1710
|
+
__export(files_exports, {
|
1711
|
+
ACTIONS: () => ACTIONS2,
|
1712
|
+
endpoint: () => endpoint2
|
1713
|
+
});
|
1714
|
+
var endpoint2 = `/files`;
|
1715
|
+
var ACTIONS2 = /* @__PURE__ */ ((ACTIONS3) => {
|
1716
|
+
ACTIONS3["verify"] = "verify";
|
1717
|
+
return ACTIONS3;
|
1718
|
+
})(ACTIONS2 || {});
|
1719
|
+
|
1720
|
+
// src/user-roles.ts
|
1721
|
+
var rolesById = {
|
1722
|
+
ADMIN: "ADMIN",
|
1723
|
+
ANONYMOUS: "ANONYMOUS",
|
1724
|
+
CONTRIBUTOR: "CONTRIBUTOR",
|
1725
|
+
EDITOR: "EDITOR",
|
1726
|
+
MANAGER: "MANAGER",
|
1727
|
+
VIEWER: "VIEWER"
|
1728
|
+
};
|
1729
|
+
var roles = Object.values(rolesById);
|
1730
|
+
export {
|
1731
|
+
BlockSizes,
|
1732
|
+
BlockSpacings,
|
1733
|
+
ColorConfigStruct,
|
1734
|
+
ColorStringStruct,
|
1735
|
+
ColorTokenConfigStruct,
|
1736
|
+
files_exports as FilesApi,
|
1737
|
+
FontFaceConfigStruct,
|
1738
|
+
FontFaceFormatsEnumStruct,
|
1739
|
+
FontFaceSourceFormats,
|
1740
|
+
FontFaceSourceStruct,
|
1741
|
+
FontFaceWeightStruct,
|
1742
|
+
FontSizeConfigStruct,
|
1743
|
+
FontSizeConfigValStruct,
|
1744
|
+
FontStretches,
|
1745
|
+
GitProviderType,
|
1746
|
+
HeadingLevels,
|
1747
|
+
KsAppClientDataAndMetaStruct,
|
1748
|
+
KsAppClientDataAndMetaStructV3,
|
1749
|
+
KsAppClientDataNoMetaStruct,
|
1750
|
+
KsAppClientDataNoMetaStructV3,
|
1751
|
+
KsMetaStateStruct,
|
1752
|
+
KsMetaStateStructV3,
|
1753
|
+
KsRemoteChangesStruct,
|
1754
|
+
KsRendererClientEvents,
|
1755
|
+
MergeableState,
|
1756
|
+
NavCustomizationConfigStruct,
|
1757
|
+
PageHeaderSizes,
|
1758
|
+
plugins_exports as PluginsApi,
|
1759
|
+
PrimaryNavCustomizationConfigStruct,
|
1760
|
+
PropTypeNames,
|
1761
|
+
RestActions,
|
1762
|
+
SecondaryNavCustomizationConfigStruct,
|
1763
|
+
StageLayouts,
|
1764
|
+
TextEncoding,
|
1765
|
+
TextTransforms,
|
1766
|
+
TokenReferenceStruct,
|
1767
|
+
TokenValueColorStruct,
|
1768
|
+
TokenValueCubicBezierStruct,
|
1769
|
+
TokenValueDimensionStruct,
|
1770
|
+
TokenValueDurationStruct,
|
1771
|
+
TokenValueFontWeightStruct,
|
1772
|
+
TokenValueStrokeStyleStruct,
|
1773
|
+
TypographyConfigStruct,
|
1774
|
+
TypographyLinkConfigStruct,
|
1775
|
+
UiConfigStruct,
|
1776
|
+
UiConfigV10Struct,
|
1777
|
+
UiConfigV1Struct,
|
1778
|
+
UiConfigV2Struct,
|
1779
|
+
UiConfigV3Struct,
|
1780
|
+
UiConfigV4Struct,
|
1781
|
+
UiConfigV5Struct,
|
1782
|
+
UiConfigV6Struct,
|
1783
|
+
UiConfigV7Struct,
|
1784
|
+
UiConfigV8Struct,
|
1785
|
+
UiConfigV9Struct,
|
1786
|
+
WS_EVENTS,
|
1787
|
+
assertTokenData,
|
1788
|
+
customizableNavElements,
|
1789
|
+
getPrimitiveValue,
|
1790
|
+
hasTokenReferences,
|
1791
|
+
isArrayOfObjectsProp,
|
1792
|
+
isArrayOfStringsProp,
|
1793
|
+
isBooleanProp,
|
1794
|
+
isCustomTypeScriptProp,
|
1795
|
+
isDataDemo,
|
1796
|
+
isDimensionString,
|
1797
|
+
isFunctionProp,
|
1798
|
+
isKsAppClientDataAndMeta,
|
1799
|
+
isKsAppClientDataAndMetaV3,
|
1800
|
+
isKsAppClientDataNoMeta,
|
1801
|
+
isKsAppClientDataNoMetaV3,
|
1802
|
+
isKsMetaState,
|
1803
|
+
isKsMetaStateV3,
|
1804
|
+
isKsRemoteChange,
|
1805
|
+
isKsRemoteChanges,
|
1806
|
+
isNotTokenReference,
|
1807
|
+
isNumberProp,
|
1808
|
+
isObjKey,
|
1809
|
+
isObject,
|
1810
|
+
isObjectProp,
|
1811
|
+
isOptionsProp,
|
1812
|
+
isPatch,
|
1813
|
+
isPatches,
|
1814
|
+
isSlottedTemplateDemo,
|
1815
|
+
isSlottedTemplateReference,
|
1816
|
+
isSlottedText,
|
1817
|
+
isStringProp,
|
1818
|
+
isTemplateDemo,
|
1819
|
+
isTokenDataComposite,
|
1820
|
+
isTokenGroup,
|
1821
|
+
isTokenReference,
|
1822
|
+
isTokenSrc,
|
1823
|
+
isTokenSrcExtensions,
|
1824
|
+
isTokenSrcValueInfoComposite,
|
1825
|
+
isTokenSrcValueInfoSingular,
|
1826
|
+
isTokenTypeComposite,
|
1827
|
+
isTokenTypeSingular,
|
1828
|
+
isTokenTypeVarRef,
|
1829
|
+
isTokenValueBorder,
|
1830
|
+
isTokenValueColor,
|
1831
|
+
isTokenValueDimension,
|
1832
|
+
isTokenValueDuration,
|
1833
|
+
isTokenValueFontWeight,
|
1834
|
+
isTokenValueShadow,
|
1835
|
+
isTokenValueTransition,
|
1836
|
+
ksRendererClientMetaId,
|
1837
|
+
migrations,
|
1838
|
+
pageElements,
|
1839
|
+
pageElementsV2,
|
1840
|
+
parseTokenDimensionValue,
|
1841
|
+
rendererIds,
|
1842
|
+
roles,
|
1843
|
+
rolesById,
|
1844
|
+
strokeStyleValues,
|
1845
|
+
tokenNameDisplayFormats,
|
1846
|
+
tokenTypeComposites,
|
1847
|
+
tokenTypeSingulars
|
1848
|
+
};
|
12
1849
|
//# sourceMappingURL=index.mjs.map
|