Skip to content

Releases: mint-lang/mint

0.14.0

03 Jul 15:37
Compare
Choose a tag to compare

Documentation Generator

  • Fix documentation generation for modules.

Installer

  • Eliminate versions of packages with missing or invalid mint.json when installing dependencies.

Compiler

  • #467 #115 Don't minimize the CSS classes in development.

    before-after

    Don't use these CSS classes for targeting - either with DOM or as sub styles - because they are minimized in production!

  • Update the list of valid CSS property names - @Sija

  • Fixes in the generated service worker.

Standard Library

  • BREAKING CHANGE Renamed treshold field to threshold in the subscription for Provider.Intersection.
  • Fixes documentation comments for some functions.

Housekeeping

  • More cleanups and refactors - @Sija
  • Update documentation viewer app.

0.13.1

18 Jun 07:08
Compare
Choose a tag to compare

Fixes a regression with service workers which results in the website not loading.

0.13.0

17 Jun 14:39
Compare
Choose a tag to compare

Breaking Changes

  • Enum destructuring within case statements now uses parentheses and commas instead of whitespaces.

    Given this enum:

    enum Status {
      LoggedIn(Time, User)
      LoggedOut
    }

    Destructuing before:

    case (maybe) {
      Status::LoggedIn time user => true
      Status::LoggedOut => flase
    }

    After:

    case (maybe) {
      Status::LoggedIn(time, user) => true
      Status::LoggedOut => flase
    }

    This was a necessary step to make nested destructuring work.

Language

  • #81 #451 Added line comments: 🎉

    // Line comment
    fun render : Html {
      ...
    }
  • Added @inline directive which inlines a text file into Mint code as String:

    @inline(path/to/file.html) /* String */
  • #418 #419 Added index variable to the for loops:

    /* Iterating over Array(item) or Set(item). */
    for (item, index of array) {
      ...
    }
    
    /* Iterating over Map(key, value). */
    for (key, value, index of map) {
      ...
    }
  • #437 Tuples can be destructured recursively (@matthewmcgarvey):

    case ({"A", {"B", "C"}}) {
      {a, {b, c}} => c
      => ""
    }

Official Docker Image

Mint now has alpine-based Docker images hosted on DockerHub (https://hub.docker.com/r/mintlang/mint) for tags and from master (latest).

Housekeeping

  • #429 Run core tests both on Chrome and Firefox in CI.
  • Run a format test on the standard library in CI.
  • Added Dockerfile for official docker images.
  • Cleanup Markdown files in the repository.
  • #421 #423 #424 #425 No longer depending on string_inflection, time_format, time_format shards - @matthewmcgarvey
  • Move inlined HTML templates to their own files.
  • Lot of assorted refactors 🙏 - @Sija

Standard Library

  • Fixed some typos in the documentation comments.
  • #427 Fixed Window.scrollHeight, Window.scrollWidth, Window.scrollLeft, Window.scrollTop functions in non quirks mode.
  • Added File.download function.
  • Added Http.Header record.
  • Added Http.hasHeader function.
  • #454 Added Maybe.withLazyDefault function.
  • #453 #460 AnimationFrame and its provider now provides the elapsed timestamp.
  • #432 #438 #434 Http.jsonBody now sets the Content-Type header of the request to application/json.

Parser

  • #435 #431 Optimizations to the parser lead to significant speedups in parsing.
  • #420 try expressions now need a space after the try keyword.
  • Don't parse double equals as a statement.

Type Checker

  • #403 Fix rendering of types in error messages.

Formatter

  • #273 Record constructors now format into multiple lines if it contains a line break.
  • Only use a single space for empty records instead of two.
  • Don't format Mint code in JavaScript interpolations.

Installer

  • #398 The installer now uses the force flag to checkout using Git.
  • #198 Added mint-version field to the mint.json which specifies which Mint versions the package works on.

Language Server

  • The server now exits properly instead of hanging if the client disconnects unexpectedly.

Test Runner

  • #433 #436 The suite name is displayed for failing test cases.
  • #441 #443 The test location (filename, line, and column) is displayed for each failing test case.

Compiler

  • Fixed the compile order of constants depending on other constants.

CLI

  • #408 Added sandbox-server command which starts a server for compiling and formatting projects using requests.
  • #405 Added lint command to lint the project for syntax and type errors.
  • #412 Added --minify, --no-minify flags to the build and compile commands which control whether or not to minify the output JavaScript.
  • #450 Show syntax errors for the format command.
  • #413 Don't generate icons if there is no icon specified.
  • Added --check flag to format command, allowing to check for changes without actually modifying the files (returns with exit code 1 if there are changes)
  • Added -r, --live-reload, --no-live-reload flags to start command which controls the live reload functionality.
  • Building assets now respect the --relative flag.
  • Fixed format command without any arguments.
  • Fixed test command to return with exit code 1 if any tests fail.
  • Changed version command now returns the plain version only.

0.12.0

13 Apr 08:23
Compare
Choose a tag to compare

This release brings language server support and asset handling to Mint!

Language Server 🎉

One of the highly requested features the language server is now available using the mint ls command.

Having this shipped allows us to incrementally implement other features such as showing errors and goto declaration / implementation.

Format on save

The files are formatted when saved if they don't contain any errors.

format-on-save

Hover Provider

The type information of most entities can be checked by hovering over them also, if available the documentation is displayed as well.

hover

Completion

Completions are provided for entities in stores, components, modules and also in scope variables (depending on where to cursor is).

completion

New App Template

A new application template has been implemented!

App Template

Language Features

The asset directive was implemented also support for constants in tests.

Asset Directive

The asset directive allows you to reference an asset (image, stylesheet, video, etc..) - relative to the current file. These assets are bundled in the production build.

component Main {
  fun render : Html {
    /* The image should be in the same directory as this file. */
    <img src={@asset(some-image.jpg)}/>
  }
}

Only those assets get bundled which are touched during type checking, for example if a component references some assets then those assets are only bundled if that component is used.

Constants in Tests

Constants can now be used in tests:

suite "Some tests" {
  const VALUE = "Hello"

  test "Constant equals Hello" {
    VALUE == "Hello"
  }
}

Runtime

  • Fixed Preact to 10.4.4 (last known working version).
  • Don't use shouldComponentUpdate in components #316.
  • Normalize dataTransfer and clipboardData fields in events.
  • Properly resolve page position after navigation (hash jump, scroll to top).
  • Don't handle links that point out of the current frame.

Formatter

  • Implemented missing CSS keyframes formatter.
  • Properly format Html body when there are only comments inside.
  • Open modules now format properly (not duplicating entities).
  • Format Html body properly if it's children has new lines.
  • Format inline functions as multiline if they contain new lines.
  • Format state statements as multiline if appropriate.

Housekeeping

  • Crystal 1.0 compatibility.
  • Builds now use the latest crystal version.
  • #375 Contribution guide has been updated (@itsgreggreg).
  • #383 Github actions has been improved (@Sija).

Standard Library

  • Added Map.fromArray.
  • Added String.wrap.
  • Added String.indent.
  • Added String.indentWithOptions.
  • Added Time.nextWeek.
  • Added Time.previousWeek.
  • Added Function.debounce1.
  • Added Html.Portals.Head component.
  • String.parameterize now converts titlecase to dash case.
  • Window.isActiveURL now ignores search (query) parameters and the hash.
  • Window.open now works again #390.
  • Make sure the copy clipboard function does not scroll the page.

Minor changes / fixes

  • Use Array(Char) instead of String in the parser which speeds up parsing in some cases.
  • #385 Rename manifest.json to manifest.webmanifest (@jonathanoberg).

Fixed issues

  • #371 Case does not unify branches which can lead to unexpected behaviour.
  • #372 Make sure that module functions are resolved in the proper scope.
  • #373 Convert string literals in CSS values to string unless they contain interpolations.
  • #376, #358 Make sure that error messages render properly.
  • #381 Try now can return a result directly (@itsgreggreg).
  • #366 Gracefully shut down the test runner in case of uncaught exceptions in JavaScript (@Sam647254).

0.11.0

07 Jan 13:51
Compare
Choose a tag to compare

This release focused on bug fixes, although there are some new language features.

Language Features

Regular Expression Literal #250

Mint now supports regular expression literals:

Regexp.match("abbc", /ab+c/i) == true

Open Modules #265

Modules now can be defined in multiple places allowing to define constants and functions.

module Greeter {
  fun greet (name : String) {
    "Hello #{name}!"
  }
}

module Greeter {
  fun greetPolitely (name : String) {
    "Have a nice day Mr. #{name}!"
  }
}

This is mostly useful if you want to extend a module in the standard library (like Array).

Or operator

Added the or operator as an alias to Maybe.withDefault:

Maybe.withDefault("Hello", Maybe::Just("Value")) /* "Value" */
Maybe.withDefault("Hello", Maybe::Nothing)       /* "Hello" */

Maybe::Just("Value") or "Hello" /* "Value" */
Maybe::Nothing or "Hello"       /* "Hello" */

[] access on tuples

It is now possible to use [] on tuples:

{"Name", "Joe"}[0] == "Name"

Only literal numbers are valid since it's the only way we can only determine the type.

Formatter

  • Format the type signature of the inline JavaScript if given.
  • Format the type signature of an array literal if given.

Housekeeping

  • Moved the CI from Travis to Github actions.

Standard Library

  • #288 - Added API wrapper for DataTransfer and added dataTransfer to Html.Event.
  • Added return types to all functions @s0kil
  • Added Array.uniq

Minor changes / fixes

  • Fixed compiling of calls when the expression is an anonymous function.
  • Fixed compiling of referenced html elements.
  • Compile empty HTML fragments as nil.

Fixed issues

  • #249 #319 - Disallow referencing other entities from the same top level entity in the default value of a state or property.
  • #277 - Added clean command to delete compiler and package artifacts @s0kil
  • #278 - Format code from STDIN if --stdin flag is passed @s0kil
  • #302 - Added error message for ambiguous pipe operators
  • #305 - Allow parsing string literals in css definitions
  • #317 - Throw error when record does not have a record definition @s0kil
  • #320 - Set manifest.json as relative path when --relative flag is set @s0kil
  • #326 - Refactor encoding to be explicit
  • #327 - Confusing error when trying to add styles to custom components @matthewmcgarvey
  • #330 - Make sure inlined variable names are not conflicting with generated ones
  • #332 - Add the record type as the last parameter in record constructor functions
  • #338 - Allow trailing comment in record definitions.
  • #339 - Better error message for NextCallStateTypeMismatch @s0kil
  • #341 - Update documentation viewer to handle inferred types @s0kil
  • #349 - Allow prefixing CSS classes using mint.json

0.10.0

13 Sep 09:47
a95a27d
Compare
Choose a tag to compare

Language Features

Providers

Providers got overhauled in this release, it is possible to write a provider entirely in Mint.

Providers now work like stores they can have states, constants and getters, the next keyword can also be used.

All providers need to implement the update function which is called any time the subscriptions for that provider change. This allows changing the state accordingly, for example by adding or removing event listeners from entities (window, document, etc...)

If you are curious about them you can check the currently available providers here: https://github.com/mint-lang/mint/tree/master/core/source/Provider

Directives

This release adds the @svg, @format and @documentation directives.

Directives are processed at compile time. They interact with entities both in the code or outside of them (for example files).

The @svg directive embeds the SVG at the given path (relative to the file) as Html so it can be used directly in components.

<div>
  <{ @svg(../path/to/file) }>
</div>

The @format directive returns the formatted string version of the code it's given and the result of the code in a tuple Tuple(a, String). This is created to make it easy to display a simple example of Mint code:

try {
  {result, code} =
    @format {
      <div>
        "Hello There!"
      </div>
    }

  <div>
    <{ result }>

    <pre>
      <code>
        <{ code }>
      </code>
    </pre>
  </div>
}

The @documentation directive compiles the JSON documentation of the given entity into the resulting JavaScript code so it can be used to display information about the entity.

record Component {
  name : String
}

try {
  decoded =
    decode @documentation(Main) as Component

  decoded.name
}

Enums

Enums now can have named parameters:

enum Item {
  Link(name : String, href : String)
}

Item::Link(name = "Home", href = "/")

This way there is no need to define a record for an enum item.

Html

  • Html expressions can now be used for attributes:

    <Field label=<{ "Hello" }>/>
  • Html expressions can now be used as expressions:

    try {
      label =
        <{ "Hello" }>
    
      <Field label={label}/>
    }
  • Html expressions now supports multiple expressions (without needing Html expressions):

    <{
      "String"
    
      <div>
        "Hello"
      </div>
    
      if (Html.isNotEmpty(content)) {
        content
      } else {
        <{}>
      }
    }>

Record Update

Record update now supports updating the result of an expression instead of just
updating a record pointing to a variable:

{ { a = "b" } | a = "x" } # { a = "x" }

Constants

  • Constants are now compiled into properties with static value instead of a
    property getter.
  • Constants now can have numbers in them: const SOME_CONSTANT_01 = "A"

References

Component and DOM element references are property returning a Maybe.

Formatter

  • Multiple operations can now be forced to format into multiple lines:

    "Hello" == "True" &&
      "a" == "b" &&
      "c" == "d"
  • Case branches can now be forced to format as multiple by placing the expression in a new line:

    Maybe::Nothing =>
      "Hello There!"
  • Constants can now be forced to format as multiple by placing the expression in a new line:

    const HELLO =
      "Hello There!"
  • Html elements with only a string child will now be formatted in one line:

    <div>"Hello There!"</div>
  • Html fragments and Html expressions are formatted more consistently

CSS

Added the following properties:

  • overscroll-behavior
  • overscroll-behavior-x
  • overscroll-behavior-y

Standard Library

In this release there are a lot of additions to the standard library.

Added

  • Array.findByAndMap
  • Dom.getElementsBySelector
  • Dom.containsMaybe
  • Dom.setAttribute
  • Dom.getTagName
  • Dom.getChildren
  • Dom.getTextContent
  • Dom.getActiveElement
  • Dom.blurActiveElement
  • Dom.getTextWidth
  • Dom.getFocusableElements
  • Dom.focusFirst
  • Dom.smoothScrollTo
  • Dom.scrollTo
  • Dom.getClientWidth
  • Dom.getClientHeight
  • Dom.getScrollLeft
  • Dom.getScrollWidth
  • Dom.getScrollTop
  • Dom.getScrollHeight
  • Dom.getTableOfContents
  • Html.isNotEmpty
  • Map.entries
  • Promise.never1
  • Promise.never2
  • Promise.never3
  • Promise.create
  • String.isNotEmpty
  • String.isBlank
  • String.isNotBlank
  • String.dropLeft
  • String.parameterize
  • Test.Context.spyOn
  • Test.Context.assertFunctionCalled
  • Test.Context.assertFunctionNotCalled
  • Window.alert
  • Window.isActiveURL
  • Window.triggerHashJump
  • Window.addEventListener
  • Window.addMediaQueryListener
  • Window.matchesMediaQuery

Changed

  • String.isAnagarm -> String.isAnagram
  • Http.sendWithID -> Http.sendWithId
  • Test.Html.assertCSSOf -> Test.Html.assertCssOf
  • Dom.getAttribute now returns Maybe(String)
  • Map is now using arrays for the implementation #268
  • Set is now using arrays for the implementation #268

Fixed

  • Dom.getElementFromPoint no longer results in a runtime error
  • Dom.getAttribute no longer results in a runtime error

Web Api Wrappers

  • WebSocket - #285 #276
  • AnimationFrame
  • MutationObserver
  • ResizeObserver
  • IntersectionObserver

New Providers

  • Provider.ElementSize
  • Provider.Intersection
  • Provider.Keydown
  • Provider.Keyup
  • Provider.Mutation
  • Provider.OutsideClick
  • Provider.TabFocus
  • Provider.Url
  • Provider.WebSocket

New Modules

  • Validation

Minor fixes

  • Fix formatting of a global component with a comment
  • Fix formatting of constant access
  • Fix an issue of generating wrong CSS
  • Fix formatting of number literals #263 #247
  • Make sure Tuple(Bool) can be destructured in case branches
  • CSS definitions can now have numbers in them
  • The format command now formats using the given pattern
  • The Main component cannot have properties and will result in a type error
  • Updated scaffolding of a new project to include a head file

Fixed issues

  • #241 - Array destructuring conflicting with array access
  • #242 - Required property does not generate a type checker error
  • #243 - Emit compilation error message to the CLI for mint start
  • #248 - Serve Documentation Assets With Proper Content Type
  • #295 - Error message text does not fit in its container
  • #252 - Not enough context in required props error
  • #247, #263 - Mint formatting of Numbers doesn't round-trip
  • #271 - Add entries to Map

0.9.0

06 Apr 06:01
Compare
Choose a tag to compare

This release contains 67 commits from 7 contributors 🎉

Type system changes

There are several improvements relating to the type system (#216)

  • the return type signature of a function is now optional
  • the type signature of a computed property is now optional
  • the type signature of a property is now optional
  • the type signature of a state is now optional
  • the type of an arrays items can be specified using the of keyword
  • the type of an inline javascript can be specified using the as keyword

CSS features

Added support for @font-face, @supports, @keyframes rules #166 #238

Changes / Additions

  • fix whitespace parsing in list type nodes #232
  • added record constructors #191
  • it is now possible to pipe into any expression #228
  • the default value of a property is no optional #132
  • config option to turn off generation of icons #224
  • add Array.min, Array.max now returns Maybe(Number) #229
  • when running mint start if default port is taken, allow return (with no explicit Y) to start dev server
  • fixed exhaustiveness check for case which contains array destructuring #225
  • print alternative link when starting a server if it's different # 230
  • added String.toArray and String.fromArray #178
  • change failing test indicator from red dot to red "F"
  • add Mint::VERSION constant shelled-out to shards version

Special thanks to @Sija for doing an overall code review and many refactors and optimizations.

0.8.0

13 Mar 08:21
Compare
Choose a tag to compare

This release contains 122 commits from 6 contributors 🎉

🚧 Breaking changes 🚧

  • Mint now uses Preact instead of React (this should not break anything though) which will result in smaller compile files.

  • External assets are now handled differently:

    • stylesheets are now supported as well
    • javascripts and stylesheets are now compiled into their own file
    • more information in issues and PRs: #151 #155 #183
  • CSS rules whith multiple selectors are now compiled separately f2eab4b:

    div,
    p {
      color: red;
    }

    now compiles as:

    div {
      color: red;
    }
    
    p {
      color: red;
    }

Additions

  • Implemented constants for stores, components and modules #194

  • Implemented unary minus expression #201

  • Implemented tuples #209

  • Implemented array destructuring #210

  • Allows inline functions to be called recursively #181, #199

  • Added more functions to the core library:

    • Clipboard.set
    • FileSize.format
    • Provider.MediaQuery
    • Provider.Resize
    • Provider.Shortcuts
    • Dom.containedInSelector
    • Dom.getAttribute
    • Dom.setStyle
    • Dom.focus
    • Dom.getElementFromPoint
    • String.trim
    • String.withDefault
    • Window.prompt
    • Window.open
    • Window.getScrollbarWidth
    • Maybe.andThen #197
    • Math.random #190

Fixes and other changes

  • Show error for formatter if the pattern is invalid #157
  • Format files in both source-directories and test-directories #158
  • Allow underscores in environment variable names
  • Fixed an issue when media query provider triggering events for non subscribers
  • Fixed String.trim
  • Fixed Time.range because of DatFNS update
  • Fixed an error when rendering HTML errors on WSL
  • Fixed an issue of resolving function type definitions #212
  • sequence and parallel reserved variable names #185
  • Make host:port configurable for test server #207
  • Show more context for the missing closing tag syntax error #213
  • Display more relevant errors for property and state if the type is a record without definition #188

0.7.1

13 Dec 12:43
Compare
Choose a tag to compare

Update code for Crystal 0.32.0

0.7.0

09 Dec 08:15
Compare
Choose a tag to compare

Global components

Components can be prefixed with the global keyword, this will add them to the DOM automatically and it's methods can be called the same way as a store or module.

It is useful for components that only need one instance in the application,
like modals and notifications:

global component AlertModal {
  state shown : Bool = false

  fun open : Promise(Never, Void) {
    next { shown = true }
  }

  fun close : Promise(Never, Void) {
    next { shown = flase }
  }

  style base {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    top: 0;
  }

  fun render : Html {
    if (shown) {
      <div::base> 
        <p>
          Are you sure?
        </p>

        <button onClick={close}>
          Ok
        </button>
      </div>
    } else {
      <></>
    }
  }
}

/* Later on somewhere else */
AlertModal.open()

Statically compiled components / HTML

In this release the compiler will detect components and HTML fragments that are essentially static, meaning that subsequent renders would always result in the same virtual DOM structure.

These fragments and components will be cached so to speak, they will only rendered once and get reused after that.

To give you an example, the following component will only be rendered once and is reused after that:

component Icons.Checkmark {
  fun render : Html {
    <svg>
      /* The svg data */
    </svg>
  }
}

component Main {
  fun render : Html {
    <div>
      <Icons.Checkmark/>
      <Icons.Checkmark/>
    </div>
  }
}

New Features

  • Allow omitting else branch of if in HTML
  • Added command to generate the documentation in JSON format
  • Allow "&" for attributes and classes (CSS)
  • Allow embedding the Main component without taking over the body

Miscellaneous

  • Updated documentation of some functions

Bugfixes:

  • Fix compiling of multiple sytles with parameters.
  • Fix compiling of interpolations in css values
  • Properly merge ifs and cases in a style and preseve their order
  • Allow creating records for nested records in encode
  • Don't catch and unbox values from the last returning result in a try expression.
  • Make sure we scope to the entities correctly.