@@ -2966,78 +2966,34 @@ var external_fs_ = __nccwpck_require__(7147);
29662966var external_path_ = __nccwpck_require__ ( 1017 ) ;
29672967// EXTERNAL MODULE: ../../node_modules/@actions /core/lib/core.js
29682968var core = __nccwpck_require__ ( 7117 ) ;
2969- ; // CONCATENATED MODULE: ./palettes.ts
2970- const basePalettes = {
2971- "github-light" : {
2972- colorDotBorder : "#1b1f230a" ,
2973- colorDots : [ "#ebedf0" , "#9be9a8" , "#40c463" , "#30a14e" , "#216e39" ] ,
2974- colorEmpty : "#ebedf0" ,
2975- colorSnake : "purple" ,
2976- } ,
2977- "github-dark" : {
2978- colorDotBorder : "#1b1f230a" ,
2979- colorEmpty : "#161b22" ,
2980- colorDots : [ "#161b22" , "#01311f" , "#034525" , "#0f6d31" , "#00c647" ] ,
2981- colorSnake : "purple" ,
2982- } ,
2983- } ;
2984- // aliases
2985- const palettes = { ...basePalettes } ;
2986- palettes [ "github" ] = palettes [ "github-light" ] ;
2987- palettes [ "default" ] = palettes [ "github" ] ;
2988-
2989- ; // CONCATENATED MODULE: ./outputsOptions.ts
2990-
2991- const DEFAULTS = {
2992- hideStack : false ,
2993- snakeSize : 4 ,
2994- } ;
2995- const SPEEDS = {
2996- slow : 200 ,
2997- normal : 150 ,
2998- fast : 100 ,
2999- } ;
3000- const parseOutputsOption = ( lines ) => lines . map ( parseEntry ) ;
3001- const parseEntry = ( entry ) => {
3002- const m = entry . trim ( ) . match ( / ^ ( .+ \. ( s v g | g i f ) ) ( \? ( .* ) | \s * ( { .* } ) ) ? $ / ) ;
3003- if ( ! m )
3004- return null ;
3005- const [ , filename , format , _ , q1 , q2 ] = m ;
3006- const query = q1 ?? q2 ;
3007- const searchParams = parseQuery ( query ) ;
3008- const hideStack = parseHideStack ( searchParams ) ;
3009- const snakeSize = parseSnakeSize ( searchParams ) ;
3010- const colors = parseColors ( searchParams ) ;
3011- const drawOptions = {
3012- sizeDotBorderRadius : 2 ,
3013- sizeCell : 16 ,
3014- sizeDot : 12 ,
3015- hideStack,
3016- ...colors ,
3017- } ;
3018- const animationOptions = {
3019- step : 1 ,
3020- frameDuration : parseSpeed ( searchParams ) ,
3021- } ;
3022- return {
3023- filename,
3024- format : format ,
3025- drawOptions,
3026- animationOptions,
3027- snakeSize,
3028- } ;
3029- } ;
3030- function parseSpeed ( searchParams ) {
3031- if ( searchParams . has ( "speed" ) ) {
3032- const speed = searchParams . get ( "speed" ) ;
3033- if ( speed in SPEEDS ) {
3034- return SPEEDS [ speed ] ;
2969+ ; // CONCATENATED MODULE: ./parsers/parseSnakeSize.ts
2970+ const DEFAULT_SNAKE_SIZE = 4 ;
2971+ const MIN_SIZE = 1 ;
2972+ const MAX_SIZE = 6 ;
2973+ function parseSnakeSize ( searchParams ) {
2974+ if ( searchParams . has ( "snake_size" ) ) {
2975+ try {
2976+ const paramsSnakeSize = Number ( searchParams . get ( "snake_size" ) ) ;
2977+ if ( Number . isNaN ( paramsSnakeSize ) ) {
2978+ throw new Error ( "Invalid snake_size provided, snake_size must be a number" ) ;
2979+ }
2980+ if ( ! Number . isInteger ( paramsSnakeSize ) ) {
2981+ throw new Error ( "Invalid snake_size provided, snake_size must be an integer" ) ;
2982+ }
2983+ if ( paramsSnakeSize < MIN_SIZE || paramsSnakeSize > MAX_SIZE ) {
2984+ throw new Error ( `Invalid snake_size provided, snake_size must be between ${ MIN_SIZE } and ${ MAX_SIZE } ` ) ;
2985+ }
2986+ return paramsSnakeSize ;
2987+ }
2988+ catch ( error ) {
2989+ console . warn ( error ) ;
2990+ console . warn ( "Using default snake size..." ) ;
30352991 }
3036- console . warn ( `Speed '${ speed } ' is not a valid speed.` ) ;
3037- console . warn ( "Using default speed..." ) ;
30382992 }
3039- return SPEEDS . normal ;
2993+ return DEFAULT_SNAKE_SIZE ;
30402994}
2995+
2996+ ; // CONCATENATED MODULE: ./parsers/parseQuery.ts
30412997function parseQuery ( query ) {
30422998 let searchParams = new URLSearchParams ( query || "" ) ;
30432999 try {
@@ -3056,34 +3012,29 @@ function parseQuery(query) {
30563012 }
30573013 return searchParams ;
30583014}
3059- function parseHideStack ( searchParams ) {
3060- if ( searchParams . has ( "hide_stack" ) ) {
3061- return searchParams . get ( "hide_stack" ) === "true" ;
3062- }
3063- return DEFAULTS . hideStack ;
3064- }
3065- function parseSnakeSize ( searchParams ) {
3066- if ( searchParams . has ( "snake_size" ) ) {
3067- try {
3068- const paramsSnakeSize = Number ( searchParams . get ( "snake_size" ) ) ;
3069- if ( Number . isNaN ( paramsSnakeSize ) ) {
3070- throw new Error ( "Invalid snake_size provided, snake_size must be a number" ) ;
3071- }
3072- if ( ! Number . isInteger ( paramsSnakeSize ) ) {
3073- throw new Error ( "Invalid snake_size provided, snake_size must be an integer" ) ;
3074- }
3075- if ( paramsSnakeSize <= 0 || paramsSnakeSize > 9 ) {
3076- throw new Error ( "Invalid snake_size provided, snake_size must be between 1 and 9" ) ;
3077- }
3078- return paramsSnakeSize ;
3079- }
3080- catch ( error ) {
3081- console . warn ( error ) ;
3082- console . warn ( "Using default snake size..." ) ;
3083- }
3084- }
3085- return DEFAULTS . snakeSize ;
3086- }
3015+
3016+ ; // CONCATENATED MODULE: ./palettes.ts
3017+ const basePalettes = {
3018+ "github-light" : {
3019+ colorDotBorder : "#1b1f230a" ,
3020+ colorDots : [ "#ebedf0" , "#9be9a8" , "#40c463" , "#30a14e" , "#216e39" ] ,
3021+ colorEmpty : "#ebedf0" ,
3022+ colorSnake : "purple" ,
3023+ } ,
3024+ "github-dark" : {
3025+ colorDotBorder : "#1b1f230a" ,
3026+ colorEmpty : "#161b22" ,
3027+ colorDots : [ "#161b22" , "#01311f" , "#034525" , "#0f6d31" , "#00c647" ] ,
3028+ colorSnake : "purple" ,
3029+ } ,
3030+ } ;
3031+ // aliases
3032+ const palettes = { ...basePalettes } ;
3033+ palettes [ "github" ] = palettes [ "github-light" ] ;
3034+ palettes [ "default" ] = palettes [ "github" ] ;
3035+
3036+ ; // CONCATENATED MODULE: ./parsers/parseColors.ts
3037+
30873038function parseColors ( searchParams ) {
30883039 const drawColors = {
30893040 ...palettes [ "default" ] ,
@@ -3134,6 +3085,106 @@ function parseColors(searchParams) {
31343085 return drawColors ;
31353086}
31363087
3088+ ; // CONCATENATED MODULE: ./parsers/parseSpeed.ts
3089+ const SPEEDS = {
3090+ slow : 200 ,
3091+ normal : 150 ,
3092+ fast : 100 ,
3093+ } ;
3094+ function parseSpeed ( searchParams ) {
3095+ if ( searchParams . has ( "speed" ) ) {
3096+ const speed = searchParams . get ( "speed" ) ;
3097+ if ( speed in SPEEDS ) {
3098+ return SPEEDS [ speed ] ;
3099+ }
3100+ console . warn ( `Speed '${ speed } ' is not a valid speed.` ) ;
3101+ console . warn ( "Using default speed..." ) ;
3102+ }
3103+ return SPEEDS . normal ;
3104+ }
3105+
3106+ ; // CONCATENATED MODULE: ./parsers/parseDotShape.ts
3107+ const SHAPES = {
3108+ square : {
3109+ sizeDot : 12 ,
3110+ sizeDotBorderRadius : 0 ,
3111+ } ,
3112+ "square-rounded" : {
3113+ sizeDot : 12 ,
3114+ sizeDotBorderRadius : 2 ,
3115+ } ,
3116+ circle : {
3117+ sizeDot : 13 ,
3118+ sizeDotBorderRadius : Math . floor ( 13 / 2 ) ,
3119+ } ,
3120+ } ;
3121+ function parseDotShape ( searchParams ) {
3122+ try {
3123+ if ( searchParams . has ( "dot_shape" ) ) {
3124+ const shape = searchParams . get ( "dot_shape" ) ;
3125+ if ( ! ( shape in SHAPES ) ) {
3126+ throw new Error ( `Shape '${ shape } ' is not a valid option.` ) ;
3127+ }
3128+ return SHAPES [ shape ] ;
3129+ }
3130+ }
3131+ catch ( error ) {
3132+ console . warn ( error ) ;
3133+ console . warn ( "Using default shape: 'square-rounded'" ) ;
3134+ }
3135+ return SHAPES [ "square-rounded" ] ;
3136+ }
3137+
3138+ ; // CONCATENATED MODULE: ./parsers/parseHideStack.ts
3139+ const DEFAULT_HIDE_STACK = false ;
3140+ function parseHideStack ( searchParams ) {
3141+ if ( searchParams . has ( "hide_stack" ) ) {
3142+ return searchParams . get ( "hide_stack" ) === "true" ;
3143+ }
3144+ return DEFAULT_HIDE_STACK ;
3145+ }
3146+
3147+ ; // CONCATENATED MODULE: ./parsers/index.ts
3148+
3149+
3150+
3151+
3152+
3153+
3154+
3155+ ; // CONCATENATED MODULE: ./outputsOptions.ts
3156+
3157+ const parseOutputsOption = ( lines ) => lines . map ( parseEntry ) ;
3158+ const parseEntry = ( entry ) => {
3159+ const m = entry . trim ( ) . match ( / ^ ( .+ \. ( s v g | g i f ) ) ( \? ( .* ) | \s * ( { .* } ) ) ? $ / ) ;
3160+ if ( ! m )
3161+ return null ;
3162+ const [ , filename , format , _ , q1 , q2 ] = m ;
3163+ const query = q1 ?? q2 ;
3164+ const searchParams = parseQuery ( query ) ;
3165+ const hideStack = parseHideStack ( searchParams ) ;
3166+ const snakeSize = parseSnakeSize ( searchParams ) ;
3167+ const colors = parseColors ( searchParams ) ;
3168+ const shape = parseDotShape ( searchParams ) ;
3169+ const drawOptions = {
3170+ sizeCell : 16 ,
3171+ hideStack,
3172+ ...colors ,
3173+ ...shape ,
3174+ } ;
3175+ const animationOptions = {
3176+ step : 1 ,
3177+ frameDuration : parseSpeed ( searchParams ) ,
3178+ } ;
3179+ return {
3180+ filename,
3181+ format : format ,
3182+ drawOptions,
3183+ animationOptions,
3184+ snakeSize,
3185+ } ;
3186+ } ;
3187+
31373188; // CONCATENATED MODULE: ./index.ts
31383189
31393190
0 commit comments