Skip to content

Releases: mint-lang/mint

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.

0.6.0

30 Oct 11:42
Compare
Choose a tag to compare

Breaking Changes

  • References of elements and components now return a Maybe
  • Remove pre defined global styles from the generated HTML #125
  • Type variables are not allow in component properties and records
  • Record definitions are needed for records except records for encode

New Features

  • Improvements for the style tag #140 #128
  • String interpolation #141
  • Implemented member access function for records:
    object = Maybe::Just({
      name: "Joe"
    })
    Maybe.map(.name) /* Maybe::Just("Joe") */
  • Implemented safe operators (&. and &() for dealing with Maybe in specific cases:
    Maybe::Just({ name: "Joe" })&.name /* Maybe::Just("Joe") */
    Maybe::Just(() : String { "Joe" })&() /* Maybe::Just("Joe") */
  • Implement static and runtime type checking for route parameters #134

Changes

  • Add chromium as recognized executable name for test runner #116
  • Allow namespaces in HTML attributes #119
  • Allow string style attributes on elements
  • Allow function recursion by using it's static type definition
  • Allow decoding time from a number (unix timestamp) #137
  • Allow decoding Object as itself
  • Parenthesize JS interpolated values to avoid confusion #135
  • Serve files from baked files and public folder with right mime types #129
  • Don't generate links for icons if there aren't any #126
  • Replace native Maybe and Result implementations with enums #133
  • Use static recrod of a component when accessing it as a ref

Bugfixes:

  • Fix formatting of multiline strings #129
  • Fix readonly attribute compiling
  • Fix crash with remainder % operator

Core

  • Added Array.sumBy
  • Added Array.sum
  • Added Dom.focusWhenVisible
  • Added Dom.contains
  • Added Number.format
  • Added String.replace
  • Added Test.Html.assertActiveElement
  • Added Set.size
  • Fix some Set functions
  • Fix Time.month and Time.year comment
  • Fix Array.indexBy by adding tests and using interpolation

0.5.0

15 Apr 06:44
Compare
Choose a tag to compare
0.5.0 Pre-release
Pre-release

JavaScript output optimizations

All generated JavaScript code is now optimized in the following way:

  • top level entity names are now mangled (Components, Stores, Modules, etc.)
  • entity level names are now mangled
  • white space is removed from the generated code (build only)
  • the CSS selectors and variables are now mangled

This change means that inlined JavaScripts no longer can access arguments by name.

This will result in a runtime error because the argument message is mangled:

fun log (message : String) : Void {
  `console.log(message)`
}

To fix this we need to interpolate the argument:

fun log (message : String) : Void {
  `console.log(#{message})`
}

Calls on expressions

Previously the calls to functions were implemented in two forms: call on a
variable and call on a module function.

This meant that calling a function which
is in a record or which is a result of a function call were not possible.

This release makes it possible to make a call on the result of an expression.

This is an example which raises in error in 0.4.0 but compiles properly in 0.5.0:

module Test {
  fun a (message : String) : Function(String) {
    () : String => { message }
  }

  fun b : String {
    a("Hello")()
  }

  fun c : String {
    try {
      record = {
        function = (message : String) : String => { message }
      }

      record.message("Hello")
    }
  }
}

Partial Application

Functions now can be partially applied by calling them with less arguments than
needed.

An example of using partial application:

/* Format a number by thousands, output: 1,000,000 */

"1000000"
|> String.split("")
|> Array.groupsOfFromEnd(3)
|> Array.map(String.join(""))
|> String.join(",")

/* 
  The argument String.join("") (to Array.map) is a partially applied function
  where it's type is Function(Array(String), String)
*/

Warning for unknown CSS properties

CSS properties are now checked against a list and will result in an error if
they are not in the list.

Changes

  • Fixed array access ([]) when an expression is used as an index
  • Default values of properties are now only calculated once when the component is initialized
  • Providers can now be accessed the same a stores, or modules for introspection
  • Records now can be created without type definition. Such records have a temporary type definition created for them during type checking
  • [Runtime] Functions are bound to components and modules only once (in the constructor) instead of using .bind every time they are called

Formatter

  • Inline functions can now be forced to format the body on a new line by adding
    a line break after the opening bracket {
  • Properties can now be forced to format the default values on a new line by
    adding a line break after the equal sign =
  • Added missing formatter for array access ([])

Core

  • Added Array.groupsOfFromEnd which is the same as Array.groupsOf but grouping from the end
  • Added Array.indexBy to get an items index by a function
  • Added Http.requests for inspection purposes
  • Added String.rchop
  • Added String.lchop
  • Html.Event is now wrapped in an actual record, so it can now be safely used in sequence or parallel expression

0.4.0

23 Feb 11:27
Compare
Choose a tag to compare
0.4.0 Pre-release
Pre-release

Breaking Changes

  • Removed => from inline functions
  • mint-core package is now included in the binary (no longer needed as a dependency)

Features

  • Added --skip-service-worker flag to skip generation of service worker #96
  • Added for expression to allow iterating over some types #110
  • Added ability to expose an item of a store with a different name (connect X exposing { y as z })
  • Added formatter-config field in mint.json to allow setting indent-size #10
  • Implemented language feature for loading environment variables using the @VARIABLE syntax
  • Implemented Dead Code Elimination #98
  • Implemented JavaScript interpolation using the #{...} syntax
  • Implemented referencing childen of a component #108
  • Allow passing Map(String, String) to the style attribute of an element.

Bugfixes / Improvements

  • Raise proper exception when parsing type. #95
  • Allow hash to be matched in routes #101
  • Allow whitespace at the end of parameter list of inline function
  • Allow whitespace between parentheses of if condition #100
  • Allow functions without the event parameter to be passed to event attributes.
  • Added progress bar about parsing files in the CLI
  • The type checker now checks for naming conflicts of Types and Enums
  • Added formatter for array access.
  • Automatically break connect exposes if there is at least new line between them.
  • Don't automatically split long strings only if they are split at least once.

0.3.1

10 Sep 08:21
Compare
Choose a tag to compare
0.3.1 Pre-release
Pre-release

Fixes for the PWA (Progressive Web App) building process.

0.3.0

09 Sep 09:05
66277c0
Compare
Choose a tag to compare
0.3.0 Pre-release
Pre-release

Breaking changes

  • do has been removed
  • Variable shadowing are not allowed and will result in a type error

Language features

  • Added sequence and parallel for better asynchronous task handling
  • Enums now can have parameters and can now be destructured in case statements (essentially they become type ADTs) #71
  • else if can be written now #72
  • Added empty catch to catch all errors #69
  • Added version command to the CLI #80
  • Added type checks for case branches
  • Added support for encoding and decoding Map
  • Added initial support for progressive web apps (PWA) by caching all files for offline use
  • encode can now encode records which have no associated type

Smaller features / bug fixes

  • Fixed typo in build command
  • Block comment improvements #89
  • Fix error on project initialization #87
  • Allow specifing dependencies without the .git extension #77
  • Generate icons in more sizes
  • Correctly format empty fragments <></>
  • Break function arguments into separate lines if they would result in long lines
  • Don't raise initial parsing error when running the development server
  • Fix incorrect resolving of function type
  • Removed Void type restriction from route

Misc

  • Crystal 0.26 support
  • Use underscores to avoid style name conflicts
  • Added contributing guide

0.2.1

17 Aug 16:27
Compare
Choose a tag to compare
0.2.1 Pre-release
Pre-release

Bugfixes

  • Detect recursion during type checking #20
  • Typo fixes in messages #64 ce341f8
  • Property resolve the type of a state #67
  • Fix for the decode statement #68

Misc

  • Updates for the latest version of Crystal (0.26)
  • Added "What makes Mint unique?" question to FAQ in the readme 32d743b
  • Correct a link to project contributors in the readme #66