or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

annotations.mdcapabilities.mdcollections.mdcore-types.mdderivation.mdindex.mdmetaprogramming.mdruntime.mdutilities.md
tile.json

tessl/maven-org-scala-lang--scala3-library-sjs1-3

Scala.js-specific runtime library components for Scala 3, providing JavaScript-specific functionality and bridge components between Scala 3 and the Scala.js runtime environment

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/org.scala-lang/scala3-library_sjs1_3@3.7.x

To install, run

npx @tessl/cli install tessl/maven-org-scala-lang--scala3-library-sjs1-3@3.7.0

index.mddocs/

Scala 3 Library for Scala.js

The Scala 3 library compiled for JavaScript environments via Scala.js, providing the complete Scala 3 standard library API with JavaScript-specific runtime support and cross-platform compatibility. This library enables Scala 3 applications to run efficiently in web browsers and Node.js environments while maintaining type safety and performance.

Package Information

  • Package Name: org.scala-lang:scala3-library_sjs1_3
  • Package Type: maven
  • Language: Scala
  • Version: 3.7.0
  • Platform: Scala.js 1.x
  • Installation: Add to your build.sbt:
libraryDependencies += "org.scala-lang" %%% "scala3-library" % "3.7.0"

Core Imports

Standard Scala imports work seamlessly:

import scala.*
import scala.util.*
import scala.compiletime.*
import scala.quoted.*
import scala.deriving.*

Package-specific imports:

import scala.scalajs.js.internal.UnitOps.given
import scala.caps.{Capability, cap}
import scala.util.boundary.{boundary, break}

Basic Usage

import scala.*
import scala.util.boundary

// Use Scala 3 tuples and named tuples
val coordinates: (Double, Double) = (1.5, 2.7)
val person = (name = "Alice", age = 30, city = "San Francisco")

// Immutable arrays with full API
val numbers = IArray(1, 2, 3, 4, 5)
val doubled = numbers.map(_ * 2)

// Union and intersection types  
def process[T](value: String | Int): T | Unit = value match
  case s: String => println(s"String: $s")
  case i: Int => println(s"Number: $i")

// Boundary-based control flow
boundary:
  for i <- 1 to 100 do
    if i > 50 then break(i)

Architecture

The Scala 3 library for Scala.js is organized around several key architectural components:

  • Type System: Union types (|), intersection types (&), and enhanced tuple system
  • Metaprogramming: Compile-time operations, quoted expressions, and derivation system
  • Capability System: Experimental capture checking and capability-safe programming
  • Runtime Support: JavaScript-specific runtime adaptations and standard library patches
  • Collection APIs: Immutable arrays (IArray) and enhanced tuple operations
  • Control Flow: Boundary/break pattern for structured control flow

Capabilities

Core Type System

Foundation types including union types, intersection types, tuples, named tuples, equality system, and structural types. Essential for all Scala 3 programming with advanced type features.

type |[A, B] = A | B  // Union types
type &[A, B] = A & B  // Intersection types

sealed trait Tuple extends Product
case object EmptyTuple extends Tuple
sealed abstract class *:[+H, +T <: Tuple] extends NonEmptyTuple

trait CanEqual[-L, -R]
trait Matchable

Core Types

Immutable Collections

High-performance immutable arrays with covariant types and comprehensive collection operations. Provides JavaScript-optimized implementations of standard collection patterns.

opaque type IArray[+T] = Array[? <: T]

object IArray:
  def empty[T]: IArray[T]
  def apply[T](elems: T*): IArray[T]
  def fill[T](n: Int)(elem: => T): IArray[T]
  def tabulate[T](n: Int)(f: Int => T): IArray[T]

Collections

Metaprogramming

Compile-time operations, quoted expressions, and macro support. Enables powerful metaprogramming with type-safe code generation and compile-time computation.

// Compile-time operations
inline def constValue[T]: T
inline def summonInline[T]: T
inline def error(msg: String): Nothing

// Quoted expressions  
abstract class Expr[+T]
trait Quotes

// Type-level operations
type ToString[X] <: String
type +[X <: Int, Y <: Int] <: Int

Metaprogramming

Derivation System

Mirror-based generic programming for automatic derivation of type class instances. Supports both sum types (enums) and product types (case classes).

sealed trait Mirror:
  type MirroredMonoType
  type MirroredLabel <: String
  type MirroredElemLabels <: Tuple

trait Mirror.Sum extends Mirror:
  def ordinal(x: MirroredMonoType): Int

trait Mirror.Product extends Mirror:
  def fromProduct(p: scala.Product): MirroredMonoType

Derivation

Capability System

Experimental capture checking system for capability-safe programming. Provides fine-grained control over side effects and resource access.

trait Capability extends Any

object cap extends Capability

erased class CanThrow[-E <: Exception] extends Capability

sealed trait Contains[+C, R]

Capabilities

Control Flow and Utilities

Boundary-based control flow, utility types, and helper functions. Includes structured exception-like control flow and advanced utility classes.

// Boundary control flow
object boundary:
  def apply[T](body: Label[T] ?=> T): T
  def break[T](value: T)(using Label[T]): Nothing

// Utility types
final class NotGiven[+T]
sealed trait TupledFunction[F, G]

Utilities

Annotations

Comprehensive annotation system including experimental features, macro annotations, and compiler hints. Supports both behavioral annotations and metaprogramming constructs.

class experimental extends StaticAnnotation
class targetName(name: String) extends StaticAnnotation
trait MacroAnnotation extends StaticAnnotation:
  def transform(definition: Any, companion: Option[Any]): List[Any]

Annotations

Runtime and JavaScript Interop

JavaScript-specific runtime support and Scala.js interoperability. Provides the bridge between Scala 3 language features and JavaScript runtime environment.

// Scala.js specific operations
object UnitOps:
  given unitOrOps[A](x: A | Unit): js.UndefOrOps[A]

// Runtime support
object Scala3RunTime
sealed abstract class AnonFunctionXXL extends scala.runtime.FunctionXXL

Runtime

Types

Core types used throughout the API:

// Foundation types
abstract class AnyKind
trait Matchable

// Tuple types
sealed trait Tuple extends Product
case object EmptyTuple extends Tuple
sealed trait NonEmptyTuple extends Tuple
sealed abstract class *:[+H, +T <: Tuple] extends NonEmptyTuple

// Opaque types
opaque type IArray[+T] = Array[? <: T]
opaque type NamedTuple[N <: Tuple, +V <: Tuple] = V

// Function types
trait PolyFunction
abstract class Conversion[-T, +U] extends Function1[T, U]

// Meta types
abstract class Expr[+T]
trait Type[T]