Repository: filiptibell/lune Branch: main Commit: 43484f131c3e Files: 457 Total size: 1.1 MB Directory structure: gitextract_9kvtan03/ ├── .cargo/ │ └── config.toml ├── .editorconfig ├── .gitattributes ├── .github/ │ └── workflows/ │ ├── ci.yaml │ └── release.yaml ├── .gitignore ├── .gitmodules ├── .luaurc ├── .lune/ │ ├── csv_printer.luau │ ├── data/ │ │ └── test.csv │ ├── hello_lune.luau │ ├── http_server.luau │ ├── websocket_client.luau │ └── websocket_server.luau ├── .vscode/ │ ├── extensions.json │ └── settings.json ├── CHANGELOG.md ├── CONTRIBUTING.md ├── Cargo.toml ├── LICENSE.txt ├── README.md ├── crates/ │ ├── lune/ │ │ ├── Cargo.toml │ │ └── src/ │ │ ├── cli/ │ │ │ ├── build/ │ │ │ │ ├── base_exe.rs │ │ │ │ ├── files.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── result.rs │ │ │ │ └── target.rs │ │ │ ├── list.rs │ │ │ ├── mod.rs │ │ │ ├── repl.rs │ │ │ ├── run.rs │ │ │ ├── setup.rs │ │ │ └── utils/ │ │ │ ├── files.rs │ │ │ ├── listing.rs │ │ │ └── mod.rs │ │ ├── lib.rs │ │ ├── main.rs │ │ ├── rt/ │ │ │ ├── mod.rs │ │ │ ├── result.rs │ │ │ └── runtime.rs │ │ ├── standalone/ │ │ │ ├── metadata.rs │ │ │ ├── mod.rs │ │ │ └── tracer.rs │ │ └── tests.rs │ ├── lune-roblox/ │ │ ├── Cargo.toml │ │ └── src/ │ │ ├── datatypes/ │ │ │ ├── attributes.rs │ │ │ ├── conversion.rs │ │ │ ├── extension.rs │ │ │ ├── mod.rs │ │ │ ├── result.rs │ │ │ ├── types/ │ │ │ │ ├── axes.rs │ │ │ │ ├── brick_color.rs │ │ │ │ ├── cframe.rs │ │ │ │ ├── color3.rs │ │ │ │ ├── color_sequence.rs │ │ │ │ ├── color_sequence_keypoint.rs │ │ │ │ ├── content.rs │ │ │ │ ├── enum.rs │ │ │ │ ├── enum_item.rs │ │ │ │ ├── enums.rs │ │ │ │ ├── faces.rs │ │ │ │ ├── font.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── number_range.rs │ │ │ │ ├── number_sequence.rs │ │ │ │ ├── number_sequence_keypoint.rs │ │ │ │ ├── physical_properties.rs │ │ │ │ ├── ray.rs │ │ │ │ ├── rect.rs │ │ │ │ ├── region3.rs │ │ │ │ ├── region3int16.rs │ │ │ │ ├── udim.rs │ │ │ │ ├── udim2.rs │ │ │ │ ├── unique_id.rs │ │ │ │ ├── vector2.rs │ │ │ │ ├── vector2int16.rs │ │ │ │ ├── vector3.rs │ │ │ │ └── vector3int16.rs │ │ │ └── util.rs │ │ ├── document/ │ │ │ ├── error.rs │ │ │ ├── format.rs │ │ │ ├── kind.rs │ │ │ ├── mod.rs │ │ │ └── postprocessing.rs │ │ ├── exports.rs │ │ ├── instance/ │ │ │ ├── base.rs │ │ │ ├── data_model.rs │ │ │ ├── mod.rs │ │ │ ├── registry.rs │ │ │ ├── terrain.rs │ │ │ └── workspace.rs │ │ ├── lib.rs │ │ ├── reflection/ │ │ │ ├── class.rs │ │ │ ├── enums.rs │ │ │ ├── mod.rs │ │ │ ├── property.rs │ │ │ └── utils.rs │ │ └── shared/ │ │ ├── classes.rs │ │ ├── instance.rs │ │ ├── mod.rs │ │ └── userdata.rs │ ├── lune-std/ │ │ ├── Cargo.toml │ │ └── src/ │ │ ├── global.rs │ │ ├── globals/ │ │ │ ├── g_table.rs │ │ │ ├── mod.rs │ │ │ ├── print.rs │ │ │ ├── require.rs │ │ │ ├── version.rs │ │ │ └── warn.rs │ │ ├── lib.rs │ │ ├── library.rs │ │ └── require/ │ │ ├── loader.rs │ │ ├── mod.rs │ │ └── resolver.rs │ ├── lune-std-datetime/ │ │ ├── Cargo.toml │ │ ├── src/ │ │ │ ├── date_time.rs │ │ │ ├── lib.rs │ │ │ ├── result.rs │ │ │ └── values.rs │ │ └── types.d.luau │ ├── lune-std-fs/ │ │ ├── Cargo.toml │ │ ├── src/ │ │ │ ├── copy.rs │ │ │ ├── lib.rs │ │ │ ├── metadata.rs │ │ │ └── options.rs │ │ └── types.d.luau │ ├── lune-std-luau/ │ │ ├── Cargo.toml │ │ ├── src/ │ │ │ ├── lib.rs │ │ │ └── options.rs │ │ └── types.d.luau │ ├── lune-std-net/ │ │ ├── Cargo.toml │ │ ├── src/ │ │ │ ├── body/ │ │ │ │ ├── cursor.rs │ │ │ │ ├── incoming.rs │ │ │ │ ├── inner.rs │ │ │ │ ├── mod.rs │ │ │ │ └── readable.rs │ │ │ ├── client/ │ │ │ │ ├── fetch.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── rustls.rs │ │ │ │ ├── send.rs │ │ │ │ ├── stream.rs │ │ │ │ └── tcp.rs │ │ │ ├── lib.rs │ │ │ ├── server/ │ │ │ │ ├── config.rs │ │ │ │ ├── handle.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── service.rs │ │ │ │ └── upgrade.rs │ │ │ ├── shared/ │ │ │ │ ├── futures.rs │ │ │ │ ├── headers.rs │ │ │ │ ├── hyper.rs │ │ │ │ ├── lua.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── request.rs │ │ │ │ ├── response.rs │ │ │ │ ├── tcp.rs │ │ │ │ └── websocket.rs │ │ │ └── url/ │ │ │ ├── decode.rs │ │ │ ├── encode.rs │ │ │ └── mod.rs │ │ └── types.d.luau │ ├── lune-std-process/ │ │ ├── Cargo.toml │ │ ├── src/ │ │ │ ├── create/ │ │ │ │ ├── child.rs │ │ │ │ ├── child_reader.rs │ │ │ │ ├── child_writer.rs │ │ │ │ └── mod.rs │ │ │ ├── exec/ │ │ │ │ ├── mod.rs │ │ │ │ ├── tee_writer.rs │ │ │ │ └── wait_for_child.rs │ │ │ ├── lib.rs │ │ │ └── options/ │ │ │ ├── kind.rs │ │ │ ├── mod.rs │ │ │ └── stdio.rs │ │ └── types.d.luau │ ├── lune-std-regex/ │ │ ├── Cargo.toml │ │ ├── src/ │ │ │ ├── captures.rs │ │ │ ├── lib.rs │ │ │ ├── matches.rs │ │ │ └── regex.rs │ │ └── types.d.luau │ ├── lune-std-roblox/ │ │ ├── Cargo.toml │ │ ├── src/ │ │ │ └── lib.rs │ │ └── types.d.luau │ ├── lune-std-serde/ │ │ ├── Cargo.toml │ │ ├── src/ │ │ │ ├── compress_decompress.rs │ │ │ ├── encode_decode.rs │ │ │ ├── hash.rs │ │ │ └── lib.rs │ │ └── types.d.luau │ ├── lune-std-stdio/ │ │ ├── Cargo.toml │ │ ├── src/ │ │ │ ├── lib.rs │ │ │ ├── prompt.rs │ │ │ └── style_and_color.rs │ │ └── types.d.luau │ ├── lune-std-task/ │ │ ├── Cargo.toml │ │ ├── src/ │ │ │ └── lib.rs │ │ └── types.d.luau │ ├── lune-utils/ │ │ ├── Cargo.toml │ │ └── src/ │ │ ├── fmt/ │ │ │ ├── error/ │ │ │ │ ├── components.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── stack_trace.rs │ │ │ │ └── tests.rs │ │ │ ├── label.rs │ │ │ ├── mod.rs │ │ │ └── value/ │ │ │ ├── basic.rs │ │ │ ├── config.rs │ │ │ ├── metamethods.rs │ │ │ ├── mod.rs │ │ │ ├── recursive.rs │ │ │ └── style.rs │ │ ├── lib.rs │ │ ├── path/ │ │ │ ├── constants.rs │ │ │ ├── luau.rs │ │ │ ├── mod.rs │ │ │ └── std.rs │ │ ├── process/ │ │ │ ├── args.rs │ │ │ ├── env.rs │ │ │ ├── jit.rs │ │ │ └── mod.rs │ │ ├── table_builder.rs │ │ └── version_string.rs │ └── mlua-luau-scheduler/ │ ├── Cargo.toml │ ├── README.md │ ├── examples/ │ │ ├── basic_sleep.rs │ │ ├── basic_spawn.rs │ │ ├── callbacks.rs │ │ ├── exit_code.rs │ │ ├── lots_of_threads.rs │ │ ├── lua/ │ │ │ ├── basic_sleep.luau │ │ │ ├── basic_spawn.luau │ │ │ ├── callbacks.luau │ │ │ ├── exit_code.luau │ │ │ ├── lots_of_threads.luau │ │ │ └── scheduler_ordering.luau │ │ ├── scheduler_ordering.rs │ │ └── tracy.rs │ └── src/ │ ├── error_callback.rs │ ├── events/ │ │ ├── mod.rs │ │ ├── multi.rs │ │ └── once.rs │ ├── exit.rs │ ├── functions.rs │ ├── lib.rs │ ├── queue/ │ │ ├── deferred.rs │ │ ├── futures.rs │ │ ├── mod.rs │ │ ├── spawned.rs │ │ └── threads.rs │ ├── scheduler.rs │ ├── status.rs │ ├── threads/ │ │ ├── id.rs │ │ ├── map.rs │ │ └── mod.rs │ ├── traits.rs │ └── util.rs ├── rokit.toml ├── scripts/ │ ├── analyze.sh │ ├── analyze_copy_typedefs.luau │ ├── brick_color.luau │ ├── font_enum_map.luau │ ├── format-check.sh │ ├── format.sh │ ├── generate_compression_test_files.luau │ ├── get-version.sh │ ├── physical_properties_enum_map.luau │ ├── unpack-releases.sh │ └── zip-release.sh ├── stylua.toml └── tests/ ├── datetime/ │ ├── formatLocalTime.luau │ ├── formatUniversalTime.luau │ ├── fromLocalTime.luau │ ├── fromRfc2822.luau │ ├── fromRfc3339.luau │ ├── fromUniversalTime.luau │ ├── fromUnixTimestamp.luau │ ├── now.luau │ ├── toLocalTime.luau │ ├── toRfc2822.luau │ ├── toRfc3339.luau │ └── toUniversalTime.luau ├── fs/ │ ├── copy.luau │ ├── dirs.luau │ ├── files.luau │ ├── metadata.luau │ ├── move.luau │ └── utils.luau ├── globals/ │ ├── _G.luau │ ├── _VERSION.luau │ ├── coroutine.luau │ ├── error.luau │ ├── pcall.luau │ ├── type.luau │ ├── typeof.luau │ └── warn.luau ├── luau/ │ ├── compile.luau │ ├── load.luau │ ├── options.luau │ └── safeenv.luau ├── net/ │ ├── request/ │ │ ├── codes.luau │ │ ├── compression.luau │ │ ├── https.luau │ │ ├── methods.luau │ │ ├── query.luau │ │ ├── redirect.luau │ │ ├── user_agent.luau │ │ └── util.luau │ ├── serve/ │ │ ├── addresses.luau │ │ ├── handles.luau │ │ ├── non_blocking.luau │ │ ├── requests.luau │ │ └── websockets.luau │ ├── socket/ │ │ ├── basic.luau │ │ ├── wss.luau │ │ └── wss_rw.luau │ ├── tcp/ │ │ ├── basic.luau │ │ ├── info.luau │ │ └── tls.luau │ └── url/ │ ├── decode.luau │ └── encode.luau ├── process/ │ ├── args.luau │ ├── create/ │ │ ├── kill.luau │ │ ├── non_blocking.luau │ │ ├── status.luau │ │ └── stream.luau │ ├── cwd.luau │ ├── env.luau │ ├── exec/ │ │ ├── async.luau │ │ ├── basic.luau │ │ ├── cwd.luau │ │ ├── no_panic.luau │ │ ├── shell.luau │ │ ├── stdin.luau │ │ └── stdio.luau │ └── exit.luau ├── regex/ │ ├── general.luau │ ├── metamethods.luau │ └── replace.luau ├── require/ │ ├── modules/ │ │ ├── init.luau │ │ └── module.luau │ └── tests/ │ ├── aliases.luau │ ├── async.luau │ ├── async_concurrent.luau │ ├── async_sequential.luau │ ├── builtins.luau │ ├── children.luau │ ├── init_files.luau │ ├── invalid.luau │ ├── module.luau │ ├── modules/ │ │ ├── async.luau │ │ ├── init.luau │ │ ├── module.luau │ │ ├── modules/ │ │ │ ├── init.luau │ │ │ └── module.luau │ │ ├── nested.luau │ │ └── self_alias/ │ │ ├── init.luau │ │ └── module.luau │ ├── multi.ext.file.luau │ ├── multi_ext.luau │ ├── nested.luau │ ├── parents.luau │ ├── siblings.luau │ ├── state.luau │ ├── state_module.luau │ └── state_second.luau ├── roblox/ │ ├── datatypes/ │ │ ├── Axes.luau │ │ ├── BrickColor.luau │ │ ├── CFrame.luau │ │ ├── Color3.luau │ │ ├── ColorSequence.luau │ │ ├── ColorSequenceKeypoint.luau │ │ ├── Content.luau │ │ ├── Enum.luau │ │ ├── Faces.luau │ │ ├── Font.luau │ │ ├── NumberRange.luau │ │ ├── NumberSequence.luau │ │ ├── NumberSequenceKeypoint.luau │ │ ├── PhysicalProperties.luau │ │ ├── Ray.luau │ │ ├── Rect.luau │ │ ├── Region3.luau │ │ ├── Region3int16.luau │ │ ├── UDim.luau │ │ ├── UDim2.luau │ │ ├── UniqueId.luau │ │ ├── Vector2.luau │ │ ├── Vector2int16.luau │ │ ├── Vector3.luau │ │ └── Vector3int16.luau │ ├── files/ │ │ ├── deserializeModel.luau │ │ ├── deserializePlace.luau │ │ ├── serializeModel.luau │ │ └── serializePlace.luau │ ├── instance/ │ │ ├── attributes.luau │ │ ├── classes/ │ │ │ ├── DataModel.luau │ │ │ ├── Terrain.luau │ │ │ └── Workspace.luau │ │ ├── custom/ │ │ │ ├── async.luau │ │ │ ├── methods.luau │ │ │ └── properties.luau │ │ ├── methods/ │ │ │ ├── ClearAllChildren.luau │ │ │ ├── Clone.luau │ │ │ ├── Destroy.luau │ │ │ ├── FindFirstAncestor.luau │ │ │ ├── FindFirstAncestorOfClass.luau │ │ │ ├── FindFirstAncestorWhichIsA.luau │ │ │ ├── FindFirstChild.luau │ │ │ ├── FindFirstChildOfClass.luau │ │ │ ├── FindFirstChildWhichIsA.luau │ │ │ ├── GetChildren.luau │ │ │ ├── GetDebugId.luau │ │ │ ├── GetDescendants.luau │ │ │ ├── GetFullName.luau │ │ │ ├── IsA.luau │ │ │ ├── IsAncestorOf.luau │ │ │ └── IsDescendantOf.luau │ │ ├── new.luau │ │ ├── properties.luau │ │ └── tags.luau │ ├── misc/ │ │ └── typeof.luau │ └── reflection/ │ ├── class.luau │ ├── database.luau │ ├── enums.luau │ └── property.luau ├── serde/ │ ├── compression/ │ │ ├── files.luau │ │ └── roundtrip.luau │ ├── hashing/ │ │ ├── hash.luau │ │ └── hmac.luau │ ├── json/ │ │ ├── decode.luau │ │ ├── encode.luau │ │ └── source.luau │ ├── jsonc/ │ │ ├── decode.luau │ │ ├── encode.luau │ │ └── source.luau │ ├── test-files/ │ │ ├── loremipsum.txt │ │ ├── loremipsum.txt.br │ │ ├── loremipsum.txt.lz4 │ │ ├── loremipsum.txt.z │ │ ├── loremipsum.txt.zst │ │ ├── uncompressed.csv │ │ ├── uncompressed.json │ │ └── uncompressed.yaml │ └── toml/ │ ├── decode.luau │ ├── encode.luau │ └── source.luau ├── stdio/ │ ├── color.luau │ ├── ewrite.luau │ ├── format.luau │ ├── prompt.luau │ ├── style.luau │ └── write.luau └── task/ ├── cancel.luau ├── defer.luau ├── delay.luau ├── fcheck.luau ├── spawn.luau └── wait.luau ================================================ FILE CONTENTS ================================================ ================================================ FILE: .cargo/config.toml ================================================ # Statically link the vcruntime # https://users.rust-lang.org/t/static-vcruntime-distribute-windows-msvc-binaries-without-needing-to-deploy-vcruntime-dll/57599 [target.'cfg(all(windows, target_env = "msvc"))'] rustflags = [ "-C", "link-args=/DEFAULTLIB:ucrt.lib /DEFAULTLIB:libvcruntime.lib libcmt.lib", "-C", "link-args=/NODEFAULTLIB:libvcruntimed.lib /NODEFAULTLIB:vcruntime.lib /NODEFAULTLIB:vcruntimed.lib", "-C", "link-args=/NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcrtd.lib", "-C", "link-args=/NODEFAULTLIB:libucrt.lib /NODEFAULTLIB:libucrtd.lib /NODEFAULTLIB:ucrtd.lib", ] [target.aarch64-unknown-linux-gnu] linker = "aarch64-linux-gnu-gcc" ================================================ FILE: .editorconfig ================================================ root = true [*] charset = utf-8 end_of_line = lf trim_trailing_whitespace = true insert_final_newline = true [*.{json,jsonc,json5}] indent_style = space indent_size = 4 [*.{yml,yaml,md}] indent_style = space indent_size = 2 ================================================ FILE: .gitattributes ================================================ * text=auto # Ensure all lua files use LF *.lua eol=lf *.luau eol=lf # Ensure all txt files within tests use LF tests/**/*.txt eol=lf ================================================ FILE: .github/workflows/ci.yaml ================================================ name: CI on: push: pull_request: workflow_dispatch: defaults: run: shell: bash env: CARGO_TERM_COLOR: always jobs: fmt: name: Check formatting runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Install Rust uses: dtolnay/rust-toolchain@stable with: components: rustfmt - name: Install Tooling uses: CompeyDev/setup-rokit@v0.1.2 - name: Check Formatting run: ./scripts/format-check.sh analyze: needs: ["fmt"] name: Analyze and lint Luau files runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Install Tooling uses: CompeyDev/setup-rokit@v0.1.2 - name: Analyze run: ./scripts/analyze.sh ci: needs: ["fmt"] strategy: fail-fast: false matrix: include: - name: Windows x86_64 runner-os: windows-2022 cargo-target: x86_64-pc-windows-msvc - name: Windows aarch64 runner-os: windows-11-arm cargo-target: aarch64-pc-windows-msvc - name: Linux x86_64 runner-os: ubuntu-22.04 cargo-target: x86_64-unknown-linux-gnu - name: Linux aarch64 runner-os: ubuntu-22.04-arm cargo-target: aarch64-unknown-linux-gnu - name: macOS x86_64 runner-os: macos-15 cargo-target: x86_64-apple-darwin - name: macOS aarch64 runner-os: macos-15 cargo-target: aarch64-apple-darwin name: CI - ${{ matrix.name }} runs-on: ${{ matrix.runner-os }} steps: - name: Checkout repository uses: actions/checkout@v4 with: submodules: true - name: Install Rust uses: dtolnay/rust-toolchain@stable with: components: clippy targets: ${{ matrix.cargo-target }} - name: Install binstall uses: cargo-bins/cargo-binstall@main - name: Install nextest run: cargo binstall cargo-nextest - name: Build run: | cargo build --workspace \ --locked --all-features \ --target ${{ matrix.cargo-target }} - name: Lint run: | cargo clippy --workspace \ --locked --all-features \ --target ${{ matrix.cargo-target }} - name: Test run: | cargo nextest run --no-fail-fast \ --locked --all-features \ --target ${{ matrix.cargo-target }} ================================================ FILE: .github/workflows/release.yaml ================================================ name: Release on: workflow_dispatch: permissions: contents: write defaults: run: shell: bash jobs: init: name: Init runs-on: ubuntu-latest outputs: version: ${{ steps.get_version.outputs.value }} steps: - name: Checkout repository uses: actions/checkout@v4 - name: Get version from manifest id: get_version run: | PACKAGE_VERSION=$(./scripts/get-version.sh) echo "value=${PACKAGE_VERSION}" >> $GITHUB_OUTPUT dry-run: name: Dry-run needs: ["init"] runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Install Rust uses: dtolnay/rust-toolchain@stable - name: Publish (dry-run) uses: katyo/publish-crates@v2 with: dry-run: true check-repo: true registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} build: needs: ["init", "dry-run"] strategy: fail-fast: false matrix: include: - name: Windows x86_64 runner-os: windows-2022 artifact-name: lune-${{ needs.init.outputs.version }}-windows-x86_64 cargo-target: x86_64-pc-windows-msvc - name: Windows aarch64 runner-os: windows-11-arm artifact-name: lune-${{ needs.init.outputs.version }}-windows-aarch64 cargo-target: aarch64-pc-windows-msvc - name: Linux x86_64 runner-os: ubuntu-22.04 artifact-name: lune-${{ needs.init.outputs.version }}-linux-x86_64 cargo-target: x86_64-unknown-linux-gnu - name: Linux aarch64 runner-os: ubuntu-22.04-arm artifact-name: lune-${{ needs.init.outputs.version }}-linux-aarch64 cargo-target: aarch64-unknown-linux-gnu - name: macOS x86_64 runner-os: macos-15 artifact-name: lune-${{ needs.init.outputs.version }}-macos-x86_64 cargo-target: x86_64-apple-darwin - name: macOS aarch64 runner-os: macos-15 artifact-name: lune-${{ needs.init.outputs.version }}-macos-aarch64 cargo-target: aarch64-apple-darwin name: Build - ${{ matrix.name }} runs-on: ${{ matrix.runner-os }} steps: - name: Checkout repository uses: actions/checkout@v4 - name: Install Rust uses: dtolnay/rust-toolchain@stable with: targets: ${{ matrix.cargo-target }} - name: Build binary run: | cargo build \ --locked --all-features \ --release --target ${{ matrix.cargo-target }} - name: Create release archive run: ./scripts/zip-release.sh ${{ matrix.cargo-target }} - name: Upload release artifact uses: actions/upload-artifact@v4 with: name: ${{ matrix.artifact-name }} path: release.zip release-github: name: Release (GitHub) runs-on: ubuntu-latest needs: ["init", "dry-run", "build"] steps: - name: Checkout repository uses: actions/checkout@v4 - name: Download releases uses: actions/download-artifact@v4 with: path: ./releases - name: Unpack releases run: ./scripts/unpack-releases.sh "./releases" - name: Create release uses: softprops/action-gh-release@v2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: name: ${{ needs.init.outputs.version }} tag_name: v${{ needs.init.outputs.version }} fail_on_unmatched_files: true files: ./releases/*.zip draft: true release-crates: name: Release (crates.io) runs-on: ubuntu-latest needs: ["init", "dry-run", "build"] steps: - name: Checkout repository uses: actions/checkout@v4 - name: Install Rust uses: dtolnay/rust-toolchain@stable - name: Publish crates uses: katyo/publish-crates@v2 with: dry-run: false check-repo: true registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} ================================================ FILE: .gitignore ================================================ # Annoying macOS finder stuff /.DS_Store /**/.DS_Store # Autogenerated dirs /bin /out /target /staging /**/bin /**/out /**/target /**/staging # Autogenerated files lune.yml luneDocs.json luneTypes.d.luau # Dirs generated by runtime or build scripts /types # Files generated by runtime or build scripts scripts/brick_color.rs scripts/font_enum_map.rs scripts/physical_properties_enum_map.rs ================================================ FILE: .gitmodules ================================================ [submodule "tests/roblox/rbx-test-files"] path = tests/roblox/rbx-test-files url = https://github.com/rojo-rbx/rbx-test-files ================================================ FILE: .luaurc ================================================ { "languageMode": "strict", "lint": { "*": true }, "lintErrors": false, "typeErrors": true, "globals": [ "warn" ], "aliases": { "lune": "./types/", "tests": "./tests", "require-tests": "./tests/require/tests" } } ================================================ FILE: .lune/csv_printer.luau ================================================ --> A utility script that prints out a CSV --> file in a prettified format to stdout local LINE_SEPARATOR = "\n" local COMMA_SEPARATOR = "," local fs = require("@lune/fs") local process = require("@lune/process") local path = process.args[1] or ".lune/data/test.csv" assert(path ~= nil and #path > 0, "No input file path was given") assert(not fs.isDir(path), "Input file path was a dir, not a file") assert(fs.isFile(path), "Input file path does not exist") -- Read all the lines of the wanted file, and then split -- out the raw lines containing comma-separated values local csvTable = {} for index, rawLine in string.split(fs.readFile(path), LINE_SEPARATOR) do if #rawLine > 0 then csvTable[index] = string.split(rawLine, COMMA_SEPARATOR) end end -- Gather the maximum widths of strings -- for alignment & spacing in advance local maxWidths = {} for _, row in csvTable do for index, value in row do maxWidths[index] = math.max(maxWidths[index] or 0, #value) end end local totalWidth = 0 local totalColumns = 0 for _, width in maxWidths do totalWidth += width totalColumns += 1 end -- We have everything we need, print it out with -- the help of some unicode box drawing characters local thiccLine = string.rep("━", totalWidth + totalColumns * 3 - 1) print(string.format("┏%s┓", thiccLine)) for rowIndex, row in csvTable do local paddedValues = {} for valueIndex, value in row do local spacing = string.rep(" ", maxWidths[valueIndex] - #value) table.insert(paddedValues, value .. spacing) end print(string.format("┃ %s ┃", table.concat(paddedValues, " ┃ "))) -- The first line is the header, we should -- print out an extra separator below it if rowIndex == 1 then print(string.format("┣%s┫", thiccLine)) end end print(string.format("┗%s┛", thiccLine)) ================================================ FILE: .lune/data/test.csv ================================================ Header1,Header2,Header3 Hello,World,! 1,2,3 Foo,Bar,Baz ================================================ FILE: .lune/hello_lune.luau ================================================ local fs = require("@lune/fs") local net = require("@lune/net") local process = require("@lune/process") local serde = require("@lune/serde") local stdio = require("@lune/stdio") local task = require("@lune/task") --[[ EXAMPLE #1 Using arguments given to the program ]] if #process.args > 0 then print("Got arguments:") print(process.args) if #process.args > 3 then error("Too many arguments!") end else print("Got no arguments ☹️") end --[[ EXAMPLE #2 Using the stdio library to prompt for terminal input ]] local text = stdio.prompt("text", "Please write some text") print("You wrote '" .. text .. "'!") local confirmed = stdio.prompt("confirm", "Please confirm that you wrote some text") if confirmed == false then error("You didn't confirm!") else print("Confirmed!") end --[[ EXAMPLE #3 Get & set environment variables Checks if environment variables are empty or not, prints out ❌ if empty and ✅ if they have a value ]] print("Reading current environment 🔎") -- Environment variables can be read directly assert(process.env.PATH ~= nil, "Missing PATH") assert(process.env.PWD ~= nil, "Missing PWD") -- And they can also be accessed using Luau's generalized iteration (but not pairs()) for key, value in process.env do local box = if value and value ~= "" then "✅" else "❌" print(string.format("[%s] %s", box, key)) end --[[ EXAMPLE #4 Spawning concurrent tasks These tasks will run at the same time as other Lua code which lets you do primitive multitasking ]] task.spawn(function() print("Spawned a task that will run instantly but not block") task.wait(5) end) print("Spawning a delayed task that will run in 5 seconds") task.delay(5, function() print("...") task.wait(1) print("Hello again!") task.wait(1) print("Goodbye again! 🌙") end) --[[ EXAMPLE #5 Read files in the current directory This prints out directory & file names with some fancy icons ]] print("Reading current dir 🗂️") local entries = fs.readDir(".") -- NOTE: We have to do this outside of the sort function -- to avoid yielding across the metamethod boundary, all -- of the filesystem APIs are asynchronous and yielding local entryIsDir = {} for _, entry in entries do entryIsDir[entry] = fs.isDir(entry) end -- Sort prioritizing directories first, then alphabetically table.sort(entries, function(entry0, entry1) if entryIsDir[entry0] ~= entryIsDir[entry1] then return entryIsDir[entry0] end return entry0 < entry1 end) -- Make sure we got some known files that should always exist assert(table.find(entries, "Cargo.toml") ~= nil, "Missing Cargo.toml") assert(table.find(entries, "Cargo.lock") ~= nil, "Missing Cargo.lock") -- Print the pretty stuff for _, entry in entries do if fs.isDir(entry) then print("📁 " .. entry) else print("📄 " .. entry) end end --[[ EXAMPLE #6 Call out to another program / executable You can also get creative and combine this with example #6 to spawn several programs at the same time! ]] print("Sending 4 pings to google 🌏") local result = process.exec("ping", { "google.com", "-c 4", }) --[[ EXAMPLE #7 Using the result of a spawned process, exiting the process This looks scary with lots of weird symbols, but, it's just some Lua-style pattern matching to parse the lines of "min/avg/max/stddev = W/X/Y/Z ms" that the ping program outputs to us ]] if result.ok then assert(#result.stdout > 0, "Result output was empty") local min, avg, max, stddev = string.match(result.stdout, "min/avg/max/stddev = ([%d%.]+)/([%d%.]+)/([%d%.]+)/([%d%.]+) ms") print(string.format("Minimum ping time: %.3fms", assert(tonumber(min)))) print(string.format("Maximum ping time: %.3fms", assert(tonumber(max)))) print(string.format("Average ping time: %.3fms", assert(tonumber(avg)))) print(string.format("Standard deviation: %.3fms", assert(tonumber(stddev)))) else print("Failed to send ping to google!") print(result.stderr) process.exit(result.code) end --[[ EXAMPLE #8 Using the built-in networking library, encoding & decoding json ]] print("Sending PATCH request to web API 📤") local apiResult = net.request({ url = "https://jsonplaceholder.typicode.com/posts/1", method = "PATCH", headers = { ["Content-Type"] = "application/json", } :: { [string]: string }, body = serde.encode("json", { title = "foo", body = "bar", }), }) if not apiResult.ok then print("Failed to send network request!") print(string.format("%d (%s)", apiResult.statusCode, apiResult.statusMessage)) print(apiResult.body) process.exit(1) end type ApiResponse = { id: number, title: string, body: string, userId: number, } local apiResponse: ApiResponse = serde.decode("json", apiResult.body) assert(apiResponse.title == "foo", "Invalid json response") assert(apiResponse.body == "bar", "Invalid json response") print("Got valid JSON response with changes applied") --[[ EXAMPLE #9 Using the stdio library to print pretty ]] print("Printing with pretty colors and auto-formatting 🎨") print(stdio.color("blue") .. string.rep("—", 22) .. stdio.color("reset")) print("API response:", apiResponse) warn({ Oh = { No = { TooMuch = { Nesting = { "Will not print", }, }, }, }, }) print(stdio.color("blue") .. string.rep("—", 22) .. stdio.color("reset")) --[[ EXAMPLE #10 Saying goodbye 😔 ]] print("Goodbye, lune! 🌙") ================================================ FILE: .lune/http_server.luau ================================================ --> A basic http server that echoes the given request --> body at /ping and otherwise responds 404 "Not Found" local net = require("@lune/net") local process = require("@lune/process") local PORT = if process.env.PORT ~= nil and #process.env.PORT > 0 then assert(tonumber(process.env.PORT), "Failed to parse port from env") else 8080 -- Create our responder functions local function root(_request: net.ServeRequest): string return `Hello from Lune server!` end local function pong(request: net.ServeRequest): string return `Pong!\n{request.path}\n{request.body}` end local function teapot(_request: net.ServeRequest): net.ServeResponse return { status = 418, body = "🫖", } end local function notFound(_request: net.ServeRequest): net.ServeResponse return { status = 404, body = "Not Found", } end -- Run the server on the port forever net.serve(PORT, function(request) if request.path == "/" then return root(request) elseif string.sub(request.path, 1, 5) == "/ping" then return pong(request) elseif string.sub(request.path, 1, 7) == "/teapot" then return teapot(request) else return notFound(request) end end) print(`Listening on port {PORT} 🚀`) print("Press Ctrl+C to stop") ================================================ FILE: .lune/websocket_client.luau ================================================ --> A basic web socket client that communicates with an echo server local net = require("@lune/net") local process = require("@lune/process") local task = require("@lune/task") local PORT = if process.env.PORT ~= nil and #process.env.PORT > 0 then assert(tonumber(process.env.PORT), "Failed to parse port from env") else 8080 local URL = `ws://127.0.0.1:{PORT}` -- Connect to our web socket server local socket = net.socket(URL) print("Connected to echo web socket server at '" .. URL .. "'") print("Sending a message every second for 5 seconds...") -- Force exit after 10 seconds in case the server is not responding well local forceExit = task.delay(10, function() warn("Example did not complete in time, exiting...") process.exit(1) end) -- Send one message per second and time it for _ = 1, 5 do local start = os.clock() socket:send(tostring(1)) local response = socket:next() local elapsed = os.clock() - start print(`Got response '{response}' in {elapsed * 1_000} milliseconds`) task.wait(1 - elapsed) end -- Everything went well, and we are done with the socket, so we can close it print("Closing web socket...") socket:close() task.cancel(forceExit) print("Done! 🌙") ================================================ FILE: .lune/websocket_server.luau ================================================ --> A basic web socket server that echoes given messages local net = require("@lune/net") local process = require("@lune/process") local task = require("@lune/task") local PORT = if process.env.PORT ~= nil and #process.env.PORT > 0 then assert(tonumber(process.env.PORT), "Failed to parse port from env") else 8080 -- Run the server on port 8080, if we get a normal http request on -- the port this will respond with 426 Upgrade Required by default local handle = net.serve(PORT, { handleWebSocket = function(socket) print("Got new web socket connection!") repeat local message = socket:next() if message ~= nil then socket:send("Echo - " .. message) end until message == nil print("Web socket disconnected.") end, }) print(`Listening on port {PORT} 🚀`) -- Exit our example after a small delay, if you copy this -- example just remove this part to keep the server running task.delay(10, function() print("Shutting down...") task.wait(1) handle.stop() task.wait(1) end) ================================================ FILE: .vscode/extensions.json ================================================ { "recommendations": [ "rust-lang.rust-analyzer", "esbenp.prettier-vscode", "JohnnyMorganz.stylua", "DavidAnson.vscode-markdownlint" ] } ================================================ FILE: .vscode/settings.json ================================================ { "luau-lsp.sourcemap.enabled": false, "luau-lsp.types.roblox": false, "luau-lsp.ignoreGlobs": [ "tests/roblox/rbx-test-files/**/*.lua", "tests/roblox/rbx-test-files/**/*.luau" ], "rust-analyzer.check.command": "clippy", "editor.formatOnSave": true, "stylua.searchParentDirectories": true, "prettier.tabWidth": 2, "[luau][lua]": { "editor.defaultFormatter": "JohnnyMorganz.stylua" }, "[json][jsonc][markdown][yaml]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, "[rust]": { "editor.defaultFormatter": "rust-lang.rust-analyzer" } } ================================================ FILE: CHANGELOG.md ================================================ # Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## `0.10.4` - October 14th, 2025 ### Added - Added support for the `jsonc` serialization format in the `serde` standard library - Added an `mlua` feature flag to `lune-roblox`, so that it may be used from Rust without bundling the entirety of Luau ### Changed - Updated to rbx-dom database version `0.694` - Updated to Luau version `0.694` ### Fixed - Fixed attribute name validation being too strict in the `roblox` standard library, not allowing the characters `/.-` - Fixed various issues in the `roblox` standard library caused by an outdated reflection database and version of `rbx-dom` ([#358]) [#358]: https://github.com/lune-org/lune/pull/358 ## `0.10.3` - October 6th, 2025 ### Changed - Updated to Luau version `0.693` ### Fixed - Fixed `readToEnd` being slow for child processes with large output ([#354]) - Fixed `process.exec` not reading stdio until child exits ([#353]) [#354]: https://github.com/lune-org/lune/pull/354 [#353]: https://github.com/lune-org/lune/pull/353 ## `0.10.2` - August 31st, 2025 ### Added - Added support for the ZSTD compression format in the `serde` standard library ([#339]) - Added support for `UniqueId` properties to the `roblox` standard library ([#343]) - Added prebuilt Lune binaries for Windows on ARM to GitHub releases ### Changed - Updated to Luau version `0.688` - Lune no longer depends on `liblzma`, making it easier to install on macOS - Prebuilt binaries for Ubuntu now use an older version (22.04) for better GLIBC compatibility ### Fixed - Fixed Lune crashing while emitting an error and parsing its source [#339]: https://github.com/lune-org/lune/pull/339 [#343]: https://github.com/lune-org/lune/pull/343 ## `0.10.1` - July 16th, 2025 ### Fixed - Fixed a regression where it was not possible to run directories with `init.luau` files in them directly using `lune run directory-name`. - Fixed a panic when calling `process.exit` inside a file that `require` was called on. ([#333]) - Fixed a panic when calling `process.exit` inside a request handler for `net.serve`. ([#333]) [#333]: https://github.com/lune-org/lune/pull/333 ## `0.10.0` - July 15th, 2025 This version of Lune contains a major internal refactoring of the `require` function, now using the proper require-by-string APIs exposed by Luau. If you relied on any (incorrect) behavior of relative, non-`@self` requires, from within `init.luau` files in Lune `0.9.0`, you may need to update your code. No other usages of `require` will be affected - but if you previously encountered any internal bugs or panics during `require`, these will have been fixed! ### Added - Added support for TCP client in the `net` standard library. It may be used either with TLS or not, and basic usage looks as such: ```luau -- Plain TCP connections local stream = net.tcp.connect("example.com", 80) -- TLS connections (shorthand) local tlsStream = net.tcp.connect("example.com", 443, true) -- Connections with custom TLS setting & TTL local customStream = net.tcp.connect("192.168.1.100", 8080, { tls = false, ttl = 128 }) -- Interacting with the stream tlsStream:write("GET / HTTP/1.1\r\nHost: example.com\r\n\r\n") while true do local data = tlsStream:read() if data ~= nil then print(data) else break -- Connection was closed end end ``` - Added submodules to the `net` standard library: `http`, `tcp`, and `ws`. These will be the preferred way of interacting with the `net` standard library going forward, but none of the old functions have been removed or deprecated yet to allow users time to migrate. In a future major version of Lune, direct functions such as `net.socket` will be removed in favor of their equivalent functions in submodules, such as `net.ws.connect`. Here is the full new list of functions: - `net.http.request` - `net.http.serve` - `net.tcp.connect` - `net.ws.connect` - Added a method `with_lib` to the `Runtime` struct in the `lune` crate, to allow registering custom libraries. ### Changed - Updated to Luau version `0.682` - Upgraded to `mlua` version `0.11` - if you use any of the Lune crates as a dependency, you may also need to upgrade ### Fixed - Fixed errors being emitted twice when the error is thrown from the main (entrypoint) script - Fixed a panic when calling `net.request` and related functions in the main body of a module during `require` - Fixed various issues with not conforming to the new Luau require-by-string semantics ## `0.9.4` - June 13th, 2025 ### Changed - `lune setup` now properly sets up a `.luaurc` file instead of using legacy VSCode-specific settings - `process.args` and `process.env` are now plain tables again - _not userdata_ - thank you to everyone who provided feedback on this and the usability issues! ### Fixed - Fixed invalid handling of http redirects in `net.request` - Fixed not being able to download binaries for cross-compiling with `lune build` - Fixed binary output when running `lune build` not being deterministic and sometimes truncating - Fixed `cargo install lune` failing due to a yanked dependency ([#323]) [#323]: https://github.com/lune-org/lune/pull/323 ## `0.9.3` - May 6th, 2025 ### Added - Added support for non-UTF8 strings in arguments to `process.exec` and `process.spawn` ### Changed - Improved cross-platform compatibility and correctness for values in `process.args` and `process.env`, especially on Windows ### Fixed - Fixed stdin not being properly closed when not providing the stdin option to `process.exec` - Fixed various crashes during require that had the error `cannot mutably borrow app data container` ## `0.9.2` - April 30th, 2025 ### Changed - Improved performance of `net.request` and `net.serve` when handling large request bodies - Improved performance and memory usage of `task.spawn`, `task.defer`, and `task.delay` ### Fixed - Fixed accidental breakage of `net.request` in version `0.9.1` ## `0.9.1` - April 29th, 2025 ### Added - Added support for automatic decompression of HTTP requests in `net.serve` ([#310]) ### Fixed - Fixed `net.serve` no longer serving requests if the returned `ServeHandle` is discarded ([#310]) - Fixed `net.serve` having various performance issues ([#310]) - Fixed Lune still running after cancelling a task such as `task.delay(5, ...)` and all tasks having completed [#310]: https://github.com/lune-org/lune/pull/310 ## `0.9.0` - April 25th, 2025 The next major version of Lune has finally been released! This release has been a long time coming, and many breaking changes have been made. If you are an existing Lune user upgrading to this version, you will **most likely** be affected. The full list of breaking changes can be found on below. ### Breaking changes & additions - The behavior of `require` has changed, according to the latest Luau RFCs and specifications. For the full details, feel free to read documentation [here](https://github.com/luau-lang/rfcs), otherwise, the most notable changes here are: - Paths passed to require must start with either `./`, `../` or `@` - require statements such as `require("foo")` **will now error** and must be changed to `require("./foo")`. - The behavior of require from within `init.luau` and `init.lua` files has changed - previously `require("./foo")` would resolve to the file or directory `foo` _as a **sibling** of the init file_, but will now resolve to the file or directory `foo` _which is a sibling of the **parent directory** of the init file_. To require files inside of the same directory as the init file, the new `@self` alias must be used - like `require("@self/foo")`. - The main `lune run` subcommand will no longer sink flags passed to it - `lune run --` will now _literally_ pass the string `--` as the first value in `process.args`, and `--` is no longer necessary to be able to pass flag arguments such as `--foo` and `-b` properly to your Lune programs. - Two new process spawning functions - `process.create` and `process.exec` - replace the previous `process.spawn` API. ([#211]) To migrate from `process.spawn`, use the new `process.exec` API which retains the same behavior as the old function, with slight changes in how the `stdin` option is passed. The new `process.create` function is a non-blocking process creation API and can be used to interactively read and write to standard input and output streams of the child process. ```lua local child = process.create("program", { "first-argument", "second-argument" }) -- Writing to stdin child.stdin:write("Hello from Lune!") -- Reading partial data from stdout local data = child.stdout:read() print(data) -- Reading the full stdout local full = child.stdout:readToEnd() print(full) ``` - Removed `net.jsonEncode` and `net.jsonDecode` - please use the equivalent `serde.encode("json", ...)` and `serde.decode("json", ...)` instead - WebSocket methods in `net.socket` and `net.serve` now use standard Lua method calling convention and colon syntax. This means `socket.send(...)` is now `socket:send(...)`, `socket.close(...)` is now `socket:close(...)`, and so on. - Various changes have been made to the Lune Rust crates: - `Runtime::run` now returns a more useful value instead of an `ExitCode` ([#178]) - All Lune standard library crates now export a `typedefs` function that returns the source code for the respective standard library module type definitions - All Lune crates now depend on `mlua` version `0.10` or above - Most Lune crates have been migrated to the `smol` and `async-*` ecosystem instead of `tokio`, with a full migration expected soon (this will not break public types) - The `roblox` crate re-export has been removed from the main `lune` crate - please depend on `lune-roblox` crate directly instead ### Added - Added functions for getting Roblox Studio locations to the `roblox` standard library ([#284]) - Added support for the `Content` datatype in the `roblox` standard library ([#305]) - Added support for `EnumItem` instance attributes in the `roblox` standard library ([#306]) - Added support for RFC 2822 dates in the `datetime` standard library using `fromRfc2822` ([#285]) - the `fromIsoDate` function has also been deprecated (not removed yet) and `fromRfc3339` should instead be preferred for any new work. - Added a `readLine` function to the `stdio` standard library for reading line-by-line from stdin. - Added a way to disable JIT by setting the `LUNE_LUAU_JIT` environment variable to `false` before running Lune. - Added `process.endianness` constant ([#267]) ### Changed - Documentation comments for several standard library properties have been improved ([#248], [#250]) - Error messages no longer contain redundant or duplicate stack trace information - Updated to Luau version `0.663` - Updated to rbx-dom database version `0.670` ### Fixed - Fixed deadlock in `stdio.format` calls in `__tostring` metamethods ([#288]) - Fixed `task.wait` and `task.delay` not being guaranteed to yield when duration is set to zero or very small values - Fixed `__tostring` metamethods sometimes not being respected in `print` and `stdio.format` calls [#178]: https://github.com/lune-org/lune/pull/178 [#211]: https://github.com/lune-org/lune/pull/211 [#248]: https://github.com/lune-org/lune/pull/248 [#250]: https://github.com/lune-org/lune/pull/250 [#265]: https://github.com/lune-org/lune/pull/265 [#267]: https://github.com/lune-org/lune/pull/267 [#284]: https://github.com/lune-org/lune/pull/284 [#285]: https://github.com/lune-org/lune/pull/285 [#288]: https://github.com/lune-org/lune/pull/288 [#305]: https://github.com/lune-org/lune/pull/305 [#306]: https://github.com/lune-org/lune/pull/306 ## `0.8.9` - October 7th, 2024 ### Changed - Updated to Luau version `0.640` ## `0.8.8` - August 22nd, 2024 ### Fixed - Fixed errors when deserializing `Lighting.AttributesSerialize` by updating `rbx-dom` dependencies ([#245]) [#245]: https://github.com/lune-org/lune/pull/245 ## `0.8.7` - August 10th, 2024 ### Added - Added a compression level option to `serde.compress` ([#224]) - Added missing vector methods to the `roblox` library ([#228]) ### Changed - Updated to Luau version `0.635` - Updated to rbx-dom database version `0.634` ### Fixed - Fixed `fs.readDir` with trailing forward-slash on Windows ([#220]) - Fixed `__type` and `__tostring` metamethods not always being respected when formatting tables [#220]: https://github.com/lune-org/lune/pull/220 [#224]: https://github.com/lune-org/lune/pull/224 [#228]: https://github.com/lune-org/lune/pull/228 ## `0.8.6` - June 23rd, 2024 ### Added - Added a builtin API for hashing and calculating HMACs as part of the `serde` library ([#193]) Basic usage: ```lua local serde = require("@lune/serde") local hash = serde.hash("sha256", "a message to hash") local hmac = serde.hmac("sha256", "a message to hash", "a secret string") print(hash) print(hmac) ``` The returned hashes are sequences of lowercase hexadecimal digits. The following algorithms are supported: `md5`, `sha1`, `sha224`, `sha256`, `sha384`, `sha512`, `sha3-224`, `sha3-256`, `sha3-384`, `sha3-512`, `blake3` - Added two new options to `luau.load`: - `codegenEnabled` - whether or not codegen should be enabled for the loaded chunk. - `injectGlobals` - whether or not to inject globals into a passed `environment`. By default, globals are injected and codegen is disabled. Check the documentation for the `luau` standard library for more information. - Implemented support for floor division operator / `__idiv` for the `Vector2` and `Vector3` types in the `roblox` standard library ([#196]) - Fixed the `_VERSION` global containing an incorrect Lune version string. ### Changed - Sandboxing and codegen in the Luau VM is now fully enabled, resulting in up to 2x or faster code execution. This should not result in any behavior differences in Lune, but if it does, please open an issue. - Improved formatting of custom error objects (such as when `fs.readFile` returns an error) when printed or formatted using `stdio.format`. ### Fixed - Fixed `__type` and `__tostring` metamethods on userdatas and tables not being respected when printed or formatted using `stdio.format`. [#193]: https://github.com/lune-org/lune/pull/193 [#196]: https://github.com/lune-org/lune/pull/196 ## `0.8.5` - June 1st, 2024 ### Changed - Improved table pretty formatting when using `print`, `warn`, and `stdio.format`: - Keys are sorted numerically / alphabetically when possible. - Keys of different types are put in distinct sections for mixed tables. - Tables that are arrays no longer display their keys. - Empty tables are no longer spread across lines. ## Fixed - Fixed formatted values in tables not being separated by newlines. - Fixed panicking (crashing) when using `process.spawn` with a program that does not exist. - Fixed `instance:SetAttribute("name", nil)` throwing an error and not removing the attribute. ## `0.8.4` - May 12th, 2024 ### Added - Added a builtin API for regular expressions. Example basic usage: ```lua local Regex = require("@lune/regex") local re = Regex.new("hello") if re:isMatch("hello, world!") then print("Matched!") end local caps = re:captures("hello, world! hello, again!") print(#caps) -- 2 print(caps:get(1)) -- "hello" print(caps:get(2)) -- "hello" print(caps:get(3)) -- nil ``` Check out the documentation for more details. - Added support for buffers as arguments in builtin APIs ([#148]) This includes APIs such as `fs.writeFile`, `serde.encode`, and more. - Added support for cross-compilation of standalone binaries ([#162]) You can now compile standalone binaries for other platforms by passing an additional `target` argument to the `build` subcommand: ```sh lune build my-file.luau --output my-bin --target windows-x86_64 ``` Currently supported targets are the same as the ones included with each release of Lune on GitHub. Check releases for a full list of targets. - Added `stdio.readToEnd()` for reading the entire stdin passed to Lune ### Changed - Split the repository into modular crates instead of a monolith. ([#188]) If you previously depended on Lune as a crate, nothing about it has changed for version `0.8.4`, but now each individual sub-crate has also been published and is available for use: - `lune` (old) - `lune-utils` - `lune-roblox` - `lune-std-*` for every builtin library When depending on the main `lune` crate, each builtin library also has a feature flag that can be toggled in the format `std-*`. In general, this should mean that it is now much easier to make your own Lune builtin, publish your own flavor of a Lune CLI, or take advantage of all the work that has been done for Lune as a runtime when making your own Rust programs. - Changed the `User-Agent` header in `net.request` to be more descriptive ([#186]) - Updated to Luau version `0.622`. ### Fixed - Fixed not being able to decompress `lz4` format in high compression mode - Fixed stack overflow for tables with circular keys ([#183]) - Fixed `net.serve` no longer accepting ipv6 addresses - Fixed headers in `net.serve` being raw bytes instead of strings [#148]: https://github.com/lune-org/lune/pull/148 [#162]: https://github.com/lune-org/lune/pull/162 [#183]: https://github.com/lune-org/lune/pull/183 [#186]: https://github.com/lune-org/lune/pull/186 [#188]: https://github.com/lune-org/lune/pull/188 ## `0.8.3` - April 15th, 2024 ### Fixed - Fixed `require` not throwing syntax errors ([#168]) - Fixed `require` caching not working correctly ([#171]) - Fixed case-sensitivity issue in `require` with aliases ([#173]) - Fixed `itertools` dependency being marked optional even though it is mandatory ([#176]) - Fixed test cases for the `net` built-in library on Windows ([#177]) [#168]: https://github.com/lune-org/lune/pull/168 [#171]: https://github.com/lune-org/lune/pull/171 [#173]: https://github.com/lune-org/lune/pull/173 [#176]: https://github.com/lune-org/lune/pull/176 [#177]: https://github.com/lune-org/lune/pull/177 ## `0.8.2` - March 12th, 2024 ### Fixed - Fixed REPL panicking after the first evaluation / run. - Fixed globals reloading on each run in the REPL, causing unnecessary slowdowns. - Fixed `net.serve` requests no longer being plain tables in Lune `0.8.1`, breaking usage of things such as `table.clone`. ## `0.8.1` - March 11th, 2024 ### Added - Added the ability to specify an address in `net.serve`. ([#142]) ### Changed - Update to Luau version `0.616`. - Major performance improvements when using a large amount of threads / asynchronous Lune APIs. ([#165]) - Minor performance improvements and less overhead for `net.serve` and `net.socket`. ([#165]) ### Fixed - Fixed `fs.copy` not working with empty dirs. ([#155]) - Fixed stack overflow when printing tables with cyclic references. ([#158]) - Fixed not being able to yield in `net.serve` handlers without blocking other requests. ([#165]) - Fixed various scheduler issues / panics. ([#165]) [#142]: https://github.com/lune-org/lune/pull/142 [#155]: https://github.com/lune-org/lune/pull/155 [#158]: https://github.com/lune-org/lune/pull/158 [#165]: https://github.com/lune-org/lune/pull/165 ## `0.8.0` - January 14th, 2024 ### Breaking Changes - The Lune CLI now uses subcommands instead of flag options:
- `lune script_name arg1 arg2 arg3` -> `lune run script_name arg1 arg2 arg3` - `lune --list` -> `lune list` - `lune --setup` -> `lune setup` This unfortunately hurts ergonomics for quickly running scripts but is a necessary change to allow us to add more commands, such as the new `build` subcommand. - The `createdAt`, `modifiedAt`, and `accessedAt` properties returned from `fs.metadata` are now `DateTime` values instead of numbers. - The `Lune` struct has been renamed to `Runtime` in the Lune rust crate. ### Added - Added support for compiling single Lune scripts into standalone executables! ([#140]) Example usage: ```lua -- my_cool_script.luau print("Hello, standalone!") ``` ```sh > lune build my_cool_script.luau # Creates `my_cool_script.exe` (Windows) or `my_cool_script` (macOS / Linux) ``` ```sh > ./my_cool_script.exe # Windows > ./my_cool_script # macOS / Linux > "Hello, standalone!" ``` To compile scripts that use `require` and reference multiple files, a bundler such as [darklua](https://github.com/seaofvoices/darklua) should preferrably be used. You may also distribute files alongside the standalone binary, they will still be able to be `require`-d. This limitation will be lifted in the future and Lune will automatically bundle any referenced scripts. - Added support for path aliases using `.luaurc` config files! For full documentation and reference, check out the [official Luau RFC](https://rfcs.luau-lang.org/require-by-string-aliases.html), but here's a quick example: ```jsonc // .luaurc { "aliases": { "modules": "./some/long/path/to/modules", }, } ``` ```lua -- ./some/long/path/to/modules/foo.luau return { World = "World!" } -- ./anywhere/you/want/my_script.luau local mod = require("@modules/foo") print("Hello, " .. mod.World) ``` - Added support for multiple values for a single query, and multiple values for a single header, in `net.request`. This is a part of the HTTP specification that is not widely used but that may be useful in certain cases. To clarify: - Single values remain unchanged and will work exactly the same as before.
```lua -- https://example.com/?foo=bar&baz=qux local net = require("@lune/net") net.request({ url = "example.com", query = { foo = "bar", baz = "qux", } }) ``` - Multiple values _on a single query / header_ are represented as an ordered array of strings.
```lua -- https://example.com/?foo=first&foo=second&foo=third&bar=baz local net = require("@lune/net") net.request({ url = "example.com", query = { foo = { "first", "second", "third" }, bar = "baz", } }) ``` [#140]: https://github.com/lune-org/lune/pull/140 ### Changed - Update to Luau version `0.606`. ### Fixed - Fixed the `print` and `warn` global functions yielding the thread, preventing them from being used in places such as the callback to `table.sort`. - Fixed the `overwrite` option for `fs.move` not correctly removing existing files / directories. ([#133]) [#133]: https://github.com/lune-org/lune/pull/133 ## `0.7.11` - October 29th, 2023 ### Changed - Update to Luau version `0.601`. ### Fixed - Fixed `roblox.getAuthCookie` not being compatible with the latest cookie format by upgrading rbx_cookie. ## `0.7.10` - October 25th, 2023 ### Added - Added the `GetDebugId` instance method to the `roblox` built-in. This will return the internal id used by the instance, and as the name implies, it should be primarily used for _debugging_ purposes and cases where you need a globally unique identifier for an instance. It is guaranteed to be a 32-digit hexadecimal string. ### Fixed - Fixed issues with `SecurityCapabilities` on instances in the `roblox` built-in by upgrading rbx-dom. ## `0.7.9` - October 21st, 2023 ### Added - Added `implementProperty` and `implementMethod` to the `roblox` built-in library to fill in missing functionality that Lune does not aim to implement itself. Example usage: ```lua local roblox = require("@lune/roblox") local part = roblox.Instance.new("Part") roblox.implementMethod("BasePart", "TestMethod", function(_, ...) print("Tried to call TestMethod with", ...) end) part:TestMethod("Hello", "world!") ``` ### Changed - Update to Luau version `0.599`. - Stdio options when using `process.spawn` can now be set with more granularity, allowing stderr & stdout to be disabled individually and completely to improve memory usage when they are not being used. ## `0.7.8` - October 5th, 2023 ### Added - Added a new `datetime` built-in library for handling date & time values, parsing, formatting, and more. ([#94]) Example usage: ```lua local DateTime = require("@lune/datetime") -- Creates a DateTime for the current exact moment in time local now = DateTime.now() -- Formats the current moment in time as an ISO 8601 string print(now:toIsoDate()) -- Formats the current moment in time, using the local -- time, the French locale, and the specified time string print(now:formatLocalTime("%A, %d %B %Y", "fr")) -- Returns a specific moment in time as a DateTime instance local someDayInTheFuture = DateTime.fromLocalTime({ year = 3033, month = 8, day = 26, hour = 16, minute = 56, second = 28, millisecond = 892, }) -- Extracts the current local date & time as separate values (same values as above table) print(now:toLocalTime()) -- Returns a DateTime instance from a given float, where the whole -- denotes the seconds and the fraction denotes the milliseconds -- Note that the fraction for millis here is completely optional DateTime.fromUnixTimestamp(871978212313.321) -- Extracts the current universal (UTC) date & time as separate values print(now:toUniversalTime()) ``` - Added support for passing `stdin` in `process.spawn` ([#106]) - Added support for setting a custom environment in load options for `luau.load`, not subject to `getfenv` / `setfenv` deoptimizations - Added [Terrain:GetMaterialColor](https://create.roblox.com/docs/reference/engine/classes/Terrain#GetMaterialColor) and [Terrain:SetMaterialColor](https://create.roblox.com/docs/reference/engine/classes/Terrain#SetMaterialColor) ([#93]) - Added support for a variable number of arguments for CFrame methods ([#85]) ### Changed - Update to Luau version `0.596`. - Update to rbx-dom database version `0.596`. - `process.spawn` now uses `powershell` instead of `/bin/bash` as the shell on Windows, with `shell = true`. - CFrame and Vector3 values are now rounded to the nearest 2 ^ 16 decimal place to reduce floating point errors and diff noise. Note that this does not affect intermediate calculations done in lua, and only happens when a property value is set on an Instance. ### Fixed - Fixed the `process` built-in library not loading correctly when using Lune in REPL mode. - Fixed list subcommand not listing global scripts without a local `.lune` / `lune` directory present. - Fixed `net.serve` stopping when the returned `ServeHandle` is garbage collected. - Fixed missing trailing newline when using the `warn` global. - Fixed constructor for `CFrame` in the `roblox` built-in library not parsing the 12-arg overload correctly. ([#102]) - Fixed various functions for `CFrame` in the `roblox` built-in library being incorrect, specifically row-column ordering and some flipped signs. ([#103]) - Fixed cross-service Instance references disappearing when using the `roblox` built-in library ([#117]) [#85]: https://github.com/lune-org/lune/pull/85 [#93]: https://github.com/lune-org/lune/pull/93 [#94]: https://github.com/lune-org/lune/pull/94 [#102]: https://github.com/lune-org/lune/pull/102 [#103]: https://github.com/lune-org/lune/pull/103 [#106]: https://github.com/lune-org/lune/pull/106 [#117]: https://github.com/lune-org/lune/pull/117 ## `0.7.7` - August 23rd, 2023 ### Added - Added a [REPL](https://en.wikipedia.org/wiki/Read–eval–print_loop) to Lune. ([#83]) This allows you to run scripts within Lune without writing files! Example usage, inside your favorite terminal: ```bash # 1. Run the Lune executable, without any arguments lune # 2. You will be shown the current Lune version and a blank prompt arrow: Lune v0.7.7 > # 3. Start typing, and hit enter when you want to run your script! # Your script will run until completion and output things along the way. > print(2 + 3) 5 > print("Hello, lune changelog!") Hello, lune changelog! # 4. You can also set variables that will get preserved between runs. # Note that local variables do not get preserved here. > myVariable = 123 > print(myVariable) 123 # 5. Press either of these key combinations to exit the REPL: # - Ctrl + D # - Ctrl + C ``` - Added a new `luau` built-in library for manually compiling and loading Luau source code. ([#82]) Example usage: ```lua local luau = require("@lune/luau") local bytecode = luau.compile("print('Hello, World!')") local callableFn = luau.load(bytecode) callableFn() -- Additionally, we can skip the bytecode generation and -- load a callable function directly from the code itself. local callableFn2 = luau.load("print('Hello, World!')") callableFn2() ``` ### Changed - Update to Luau version `0.591`. - Lune's internal task scheduler and `require` functionality has been completely rewritten.
The new scheduler is much more stable, conforms to a larger test suite, and has a few additional benefits: - Built-in libraries are now lazily loaded, meaning nothing gets allocated until the built-in library gets loaded using `require("@lune/builtin-name")`. This also improves startup times slightly. - Spawned processes using `process.spawn` now run on different thread(s), freeing up resources for the main thread where luau runs. - Serving requests using `net.serve` now processes requests on background threads, also freeing up resources. In the future, this will also allow us to offload heavy tasks such as compression/decompression to background threads. - Groundwork for custom / user-defined require aliases has been implemented, as well as absolute / cwd-relative requires. These will both be exposed as options and be made available to use some time in the future. - When using the `serde` built-in library, keys are now sorted during serialization. This means that the output of `encode` is now completely deterministic, and wont cause issues when committing generated files to git etc. ### Fixed - Fixed not being able to pass arguments to the thread using `coroutine.resume`. ([#86]) - Fixed a large number of long-standing issues, from the task scheduler rewrite: - Fixed `require` hanging indefinitely when the module being require-d uses an async function in its main body. - Fixed background tasks (such as `net.serve`) not keeping Lune alive even if there are no lua threads to run. - Fixed spurious panics and error messages such as `Tried to resume next queued future but none are queued`. - Fixed not being able to catch non-string errors properly, errors were accidentally being wrapped in an opaque `userdata` type. [#82]: https://github.com/lune-org/lune/pull/82 [#83]: https://github.com/lune-org/lune/pull/83 [#86]: https://github.com/lune-org/lune/pull/86 ## `0.7.6` - August 9th, 2023 ### Changed - Update to Luau version `0.588` - Enabled Luau JIT backend for potential performance improvements 🚀
If you run into any strange behavior please open an issue! ### Fixed - Fixed publishing of the Lune library to `crates.io` - Fixed `serde.decode` deserializing `null` values as `userdata` instead of `nil`. - Fixed not being able to require files with multiple extensions, eg. `module.spec.luau` was not require-able using `require("module.spec")`. - Fixed instances and `roblox` built-in library APIs erroring when used asynchronously/concurrently. ## `0.7.5` - July 22nd, 2023 ### Added - Lune now has a new documentation site!
This addresses new APIs from version `0.7.0` not being available on the docs site, brings much improved searching functionality, and will help us keep documentation more up-to-date going forward with a more automated process. You can check out the new site at [lune-org.github.io](https://lune-org.github.io/docs). - Added `fs.copy` to recursively copy files and directories. Example usage: ```lua local fs = require("@lune/fs") fs.writeDir("myCoolDir") fs.writeFile("myCoolDir/myAwesomeFile.json", "{}") fs.copy("myCoolDir", "myCoolDir2") assert(fs.isDir("myCoolDir2")) assert(fs.isFile("myCoolDir2/myAwesomeFile.json")) assert(fs.readFile("myCoolDir2/myAwesomeFile.json") == "{}") ``` - Added `fs.metadata` to get metadata about files and directories. Example usage: ```lua local fs = require("@lune/fs") fs.writeFile("myAwesomeFile.json", "{}") local meta = fs.metadata("myAwesomeFile.json") print(meta.exists) --> true print(meta.kind) --> "file" print(meta.createdAt) --> 1689848548.0577152 (unix timestamp) print(meta.permissions) --> { readOnly: false } ``` - Added `roblox.getReflectionDatabase` to access the builtin database containing information about classes and enums. Example usage: ```lua local roblox = require("@lune/roblox") local db = roblox.getReflectionDatabase() print("There are", #db:GetClassNames(), "classes in the reflection database") print("All base instance properties:") local class = db:GetClass("Instance") for name, prop in class.Properties do print(string.format( "- %s with datatype %s and default value %s", prop.Name, prop.Datatype, tostring(class.DefaultProperties[prop.Name]) )) end ``` - Added support for running directories with an `init.luau` or `init.lua` file in them in the CLI. ### Changed - Update to Luau version `0.583` ### Fixed - Fixed publishing of Lune to crates.io by migrating away from a monorepo. - Fixed crashes when writing a very deeply nested `Instance` to a file. ([#62]) - Fixed not being able to read & write to WebSocket objects at the same time. ([#68]) - Fixed tab character at the start of a script causing it not to parse correctly. ([#72]) [#62]: https://github.com/lune-org/lune/pull/62 [#68]: https://github.com/lune-org/lune/pull/66 [#72]: https://github.com/lune-org/lune/pull/72 ## `0.7.4` - July 7th, 2023 ### Added - Added support for `CFrame` and `Font` types in attributes when using the `roblox` builtin. ### Fixed - Fixed `roblox.serializeModel` still keeping some unique ids. ## `0.7.3` - July 5th, 2023 ### Changed - When using `roblox.serializeModel`, Lune will no longer keep internal unique ids.
This is consistent with what Roblox does and prevents Lune from always generating a new and unique file.
This previously caused unnecessary diffs when using git or other kinds of source control. ([Relevant issue](https://github.com/lune-org/lune/issues/61)) ## `0.7.2` - June 28th, 2023 ### Added - Added support for `init` files in directories, similar to Rojo, or `index.js` / `mod.rs` in JavaScript / Rust.
This means that placing a file named `init.luau` or `init.lua` in a directory will now let you `require` that directory. ### Changed - The `lune --setup` command is now much more user-friendly. - Update to Luau version `0.581` ## `0.7.1` - June 17th, 2023 ### Added - Added support for TLS in websockets, enabling usage of `wss://`-prefixed URLs. ([#57]) ### Fixed - Fixed `closeCode` erroring when being accessed on websockets. ([#57]) - Fixed issues with `UniqueId` when using the `roblox` builtin by downgrading `rbx-dom`. [#57]: https://github.com/lune-org/lune/pull/57 ## `0.7.0` - June 12th, 2023 ### Breaking Changes - Globals for the `fs`, `net`, `process`, `stdio`, and `task` builtins have been removed, and the `require("@lune/...")` syntax is now the only way to access builtin libraries. If you have previously been using a global such as `fs` directly, you will now need to put `local fs = require("@lune/fs")` at the top of the file instead. - Migrated several functions in the `roblox` builtin to new, more flexible APIs: - `readPlaceFile -> deserializePlace` - `readModelFile -> deserializeModel` - `writePlaceFile -> serializePlace` - `writeModelFile -> serializeModel` These new APIs **_no longer use file paths_**, meaning to use them with files you must first read them using the `fs` builtin. - Removed `CollectionService` and its methods from the `roblox` builtin library - new instance methods have been added as replacements. - Removed [`Instance:FindFirstDescendant`](https://create.roblox.com/docs/reference/engine/classes/Instance#FindFirstDescendant) which was a method that was never enabled in the official Roblox API and will soon be removed.
Use the second argument of the already existing find methods instead to find descendants. - Removed the global `printinfo` function - it was generally not used, and did not work as intended. Use the `stdio` builtin for formatting and logging instead. - Removed support for Windows on ARM - it's more trouble than its worth right now, we may revisit it later. ### Added - Added `serde.compress` and `serde.decompress` for compressing and decompressing strings using one of several compression formats: `brotli`, `gzip`, `lz4`, or `zlib`. Example usage: ```lua local INPUT = string.rep("Input string to compress", 16) -- Repeated string 16 times for the purposes of this example local serde = require("@lune/serde") local compressed = serde.compress("gzip", INPUT) local decompressed = serde.decompress("gzip", compressed) assert(decompressed == INPUT) ``` - Added automatic decompression for compressed responses when using `net.request`. This behavior can be disabled by passing `options = { decompress = false }` in request params. - Added support for finding scripts in the current home directory. This means that if you have a script called `script-name.luau`, you can place it in the following location: - `C:\Users\YourName\.lune\script-name.luau` (Windows) - `/Users/YourName/.lune/script-name.luau` (macOS) - `/home/YourName/.lune/script-name.luau` (Linux) And then run it using `lune script-name` from any directory you are currently in. - Added several new instance methods in the `roblox` builtin library: - [`Instance:AddTag`](https://create.roblox.com/docs/reference/engine/classes/Instance#AddTag) - [`Instance:GetTags`](https://create.roblox.com/docs/reference/engine/classes/Instance#GetTags) - [`Instance:HasTag`](https://create.roblox.com/docs/reference/engine/classes/Instance#HasTag) - [`Instance:RemoveTag`](https://create.roblox.com/docs/reference/engine/classes/Instance#RemoveTag) - Implemented the second argument of the `FindFirstChild` / `FindFirstChildOfClass` / `FindFirstChildWhichIsA` instance methods. ### Changed - Update to Luau version `0.579` - Both `stdio.write` and `stdio.ewrite` now support writing arbitrary bytes, instead of only valid UTF-8. ### Fixed - Fixed `stdio.write` and `stdio.ewrite` not being flushed and causing output to be interleaved. ([#47]) - Fixed `typeof` returning `userdata` for roblox types such as `Instance`, `Vector3`, ... [#47]: https://github.com/lune-org/lune/pull/47 ## `0.6.7` - May 14th, 2023 ### Added - Replaced all of the separate typedef & documentation generation commands with a unified `lune --setup` command. This command will generate type definition files for all of the builtins and will work with the new `require("@lune/...")` syntax. Note that this also means that there is no longer any way to generate type definitions for globals - this is because they will be removed in the next major release in favor of the beforementioned syntax. - New releases now include prebuilt binaries for arm64 / aarch64!
These new binaries will have names with the following format: - `lune-windows-0.6.7-aarch64.exe` - `lune-linux-0.6.7-aarch64` - `lune-macos-0.6.7-aarch64` - Added global types to documentation site ## `0.6.6` - April 30th, 2023 ### Added - Added tracing / logging for rare and hard to diagnose error cases, which can be configured using the env var `RUST_LOG`. ### Changed - The `_VERSION` global now follows a consistent format `Lune x.y.z+luau` to allow libraries to check against it for version requirements. Examples: - `Lune 0.0.0+0` - `Lune 1.0.0+500` - `Lune 0.11.22+9999` - Updated to Luau version `0.573` - Updated `rbx-dom` to support reading and writing `Font` datatypes ### Fixed - Fixed `_G` not being a readable & writable table - Fixed `_G` containing normal globals such as `print`, `math`, ... - Fixed using instances as keys in tables ## `0.6.5` - March 27th, 2023 ### Changed - Functions such as `print`, `warn`, ... now respect `__tostring` metamethods. ### Fixed - Fixed access of roblox instance properties such as `Workspace.Terrain`, `game.Workspace` that are actually links to child instances.
These properties are always guaranteed to exist, and they are not always properly set, meaning they must be found through an internal lookup. - Fixed issues with the `CFrame.lookAt` and `CFrame.new(Vector3, Vector3)` constructors. - Fixed issues with CFrame math operations returning rotation angles in the wrong order. ## `0.6.4` - March 26th, 2023 ### Fixed - Fixed instances with attributes not saving if they contain integer attributes. - Fixed attributes not being set properly if the instance has an empty attributes property. - Fixed error messages for reading & writing roblox files not containing the full error message. - Fixed crash when trying to access an instance reference property that points to a destroyed instance. - Fixed crash when trying to save instances that contain unsupported attribute types. ## `0.6.3` - March 26th, 2023 ### Added - Added support for instance tags & `CollectionService` in the `roblox` built-in.
Currently implemented methods are listed on the [docs site](https://lune-org.github.io/docs/roblox/4-api-status). ### Fixed - Fixed accessing a destroyed instance printing an error message even if placed inside a pcall. - Fixed cloned instances not having correct instance reference properties set (`ObjectValue.Value`, `Motor6D.Part0`, ...) - Fixed `Instance::GetDescendants` returning the same thing as `Instance::GetChildren`. ## `0.6.2` - March 25th, 2023 This release adds some new features and fixes for the `roblox` built-in. ### Added - Added `GetAttribute`, `GetAttributes` and `SetAttribute` methods for instances. - Added support for getting & setting properties that are instance references. ### Changed - Improved handling of optional property types such as optional cframes & default physical properties. ### Fixed - Fixed handling of instance properties that are serialized as binary strings. ## `0.6.1` - March 22nd, 2023 ### Fixed - Fixed `writePlaceFile` and `writeModelFile` in the new `roblox` built-in making mysterious "ROOT" instances. ## `0.6.0` - March 22nd, 2023 ### Added - Added a `roblox` built-in If you're familiar with [Remodel](https://github.com/rojo-rbx/remodel), this new built-in contains more or less the same APIs, integrated into Lune.
There are just too many new APIs to list in this changelog, so head over to the [docs sit](https://lune-org.github.io/docs/roblox/1-introduction) to learn more! - Added a `serde` built-in This built-in contains previously available functions `encode` and `decode` from the `net` global.
The plan is for this built-in to contain more serialization and encoding functionality in the future. - `require` has been reimplemented and overhauled in several ways: - New built-ins such as `roblox` and `serde` can **_only_** be imported using `require("@lune/roblox")`, `require("@lune/serde")`, ... - Previous globals such as `fs`, `net` and others can now _also_ be imported using `require("@lune/fs")`, `require("@lune/net")`, ... - Requiring a script is now completely asynchronous and will not block lua threads other than the caller. - Requiring a script will no longer error when using async APIs in the main body of the required script. All new built-ins will be added using this syntax and new built-ins will no longer be available in the global scope, and current globals will stay available as globals until proper editor and LSP support is available to ensure Lune users have a good development experience. This is the first step towards moving away from adding each library as a global, and allowing Lune to have more built-in libraries in general. Behavior otherwise stays the same, and requires are still relative to file unless the special `@` prefix is used. - Added `net.urlEncode` and `net.urlDecode` for URL-encoding and decoding strings ### Changed - Renamed the global `info` function to `printinfo` to make it less ambiguous ### Removed - Removed experimental `net.encode` and `net.decode` functions, since they are now available using `require("@lune/serde")` - Removed option to preserve default Luau require behavior ## `0.5.6` - March 11th, 2023 ### Added - Added support for shebangs at the top of a script, meaning scripts such as this one will now run without throwing a syntax error: ```lua #!/usr/bin/env lune print("Hello, world!") ``` ### Fixed - Fixed `fs.writeFile` and `fs.readFile` not working with strings / files that are invalid utf-8 ## `0.5.5` - March 8th, 2023 ### Added - Added support for running scripts by passing absolute file paths in the CLI - This does not have the restriction of scripts having to use the `.luau` or `.lua` extension, since it is presumed that if you pass an absolute path you know exactly what you are doing ### Changed - Improved error messages for passing invalid file names / file paths substantially - they now include helpful formatting to make file names distinct from file extensions, and give suggestions on how to solve the problem - Improved general formatting of error messages, both in the CLI and for Luau scripts being run ### Fixed - Fixed the CLI being a bit too picky about file names when trying to run files in `lune` or `.lune` directories - Fixed documentation misses from large changes made in version `0.5.0` ## `0.5.4` - March 7th, 2023 ### Added - Added support for reading scripts from stdin by passing `"-"` as the script name - Added support for close codes in the `net` WebSocket APIs: - A close code can be sent by passing it to `socket.close` - A received close code can be checked with the `socket.closeCode` value, which is populated after a socket has been closed - note that using `socket.close` will not set the close code value, it is only set when received and is guaranteed to exist after closure ### Changed - Update to Luau version 0.566 ### Fixed - Fixed scripts having to be valid utf8, they may now use any kind of encoding that base Luau supports - The `net` WebSocket APIs will no longer return `nil` for partial messages being received in `socket.next`, and will instead wait for the full message to arrive ## `0.5.3` - February 26th, 2023 ### Fixed - Fixed `lune --generate-selene-types` generating an invalid Selene definitions file - Fixed type definition parsing issues on Windows ## `0.5.2` - February 26th, 2023 ### Fixed - Fixed crash when using `stdio.color()` or `stdio.style()` in a CI environment or non-interactive terminal ## `0.5.1` - February 25th, 2023 ### Added - Added `net.encode` and `net.decode` which are equivalent to `net.jsonEncode` and `net.jsonDecode`, but with support for more formats. **_WARNING: Unstable API_** _This API is unstable and may change or be removed in the next major version of Lune. The purpose of making a new release with these functions is to gather feedback from the community, and potentially replace the JSON-specific encoding and decoding utilities._ Example usage: ```lua local toml = net.decode("toml", [[ [package] name = "my-cool-toml-package" version = "0.1.0" [values] epic = true ]]) assert(toml.package.name == "my-cool-toml-package") assert(toml.package.version == "0.1.0") assert(toml.values.epic == true) ``` ### Fixed - Fixed indentation of closing curly bracket when printing tables ## `0.5.0` - February 23rd, 2023 ### Added - Added auto-generated API reference pages and documentation using GitHub wiki pages - Added support for `query` in `net.request` parameters, which enables usage of query parameters in URLs without having to manually URL encode values. - Added a new function `fs.move` to move / rename a file or directory from one path to another. - Implemented a new task scheduler which resolves several long-standing issues: - Issues with yielding across the C-call/metamethod boundary no longer occur when calling certain async APIs that Lune provides. - Ordering of interleaved calls to `task.spawn/task.defer` is now completely deterministic, deferring is now guaranteed to run last even in these cases. - The minimum wait time possible when using `task.wait` and minimum delay time using `task.delay` are now much smaller, and only limited by the underlying OS implementation. For most systems this means `task.wait` and `task.delay` are now accurate down to about 5 milliseconds or less. ### Changed - Type definitions are now bundled as part of the Lune executable, meaning they no longer need to be downloaded. - `lune --generate-selene-types` will generate the Selene type definitions file, replacing `lune --download-selene-types` - `lune --generate-luau-types` will generate the Luau type definitions file, replacing `lune --download-luau-types` - Improved accuracy of Selene type definitions, strongly typed arrays are now used where possible - Improved error handling and messages for `net.serve` - Improved error handling and messages for `stdio.prompt` - File path representations on Windows now use legacy paths instead of UNC paths wherever possible, preventing some confusing cases where file paths don't work as expected ### Fixed - Fixed `process.cwd` not having the correct ending path separator on Windows - Fixed remaining edge cases where the `task` and `coroutine` libraries weren't interoperable - Fixed `task.delay` keeping the script running even if it was cancelled using `task.cancel` - Fixed `stdio.prompt` blocking all other lua threads while prompting for input ## `0.4.0` - February 11th, 2023 ### Added - ### Web Sockets `net` now supports web sockets for both clients and servers!
Note that the web socket object is identical on both client and server, but how you retrieve a web socket object is different. #### Server API The server web socket API is an extension of the existing `net.serve` function.
This allows for serving both normal HTTP requests and web socket requests on the same port. Example usage: ```lua net.serve(8080, { handleRequest = function(request) return "Hello, world!" end, handleWebSocket = function(socket) task.delay(10, function() socket.send("Timed out!") socket.close() end) -- The message will be nil when the socket has closed repeat local messageFromClient = socket.next() if messageFromClient == "Ping" then socket.send("Pong") end until messageFromClient == nil end, }) ``` #### Client API Example usage: ```lua local socket = net.socket("ws://localhost:8080") socket.send("Ping") task.delay(5, function() socket.close() end) -- The message will be nil when the socket has closed repeat local messageFromServer = socket.next() if messageFromServer == "Ping" then socket.send("Pong") end until messageFromServer == nil ``` ### Changed - `net.serve` now returns a `NetServeHandle` which can be used to stop serving requests safely. Example usage: ```lua local handle = net.serve(8080, function() return "Hello, world!" end) print("Shutting down after 1 second...") task.wait(1) handle.stop() print("Shut down succesfully") ``` - The third and optional argument of `process.spawn` is now a global type `ProcessSpawnOptions`. - Setting `cwd` in the options for `process.spawn` to a path starting with a tilde (`~`) will now use a path relative to the platform-specific home / user directory. - `NetRequest` query parameters value has been changed to be a table of key-value pairs similar to `process.env`. If any query parameter is specified more than once in the request url, the value chosen will be the last one that was specified. - The internal http client for `net.request` now reuses headers and connections for more efficient requests. - Refactored the Lune rust crate to be much more user-friendly and documented all of the public functions. ### Fixed - Fixed `process.spawn` blocking all lua threads if the spawned child process yields. ## `0.3.0` - February 6th, 2023 ### Added - Added a new global `stdio` which replaces `console` - Added `stdio.write` which writes a string directly to stdout, without any newlines - Added `stdio.ewrite` which writes a string directly to stderr, without any newlines - Added `stdio.prompt` which will prompt the user for different kinds of input Example usage: ```lua local text = stdio.prompt() local text2 = stdio.prompt("text", "Please write some text") local didConfirm = stdio.prompt("confirm", "Please confirm this action") local optionIndex = stdio.prompt("select", "Please select an option", { "one", "two", "three" }) local optionIndices = stdio.prompt( "multiselect", "Please select one or more options", { "one", "two", "three", "four", "five" } ) ``` ### Changed - Migrated `console.setColor/resetColor` and `console.setStyle/resetStyle` to `stdio.color` and `stdio.style` to allow for more flexibility in custom printing using ANSI color codes. Check the documentation for new usage and behavior. - Migrated the pretty-printing and formatting behavior of `console.log/info/warn/error` to the standard Luau printing functions. ### Removed - Removed printing functions `console.log/info/warn/error` in favor of regular global functions for printing. ### Fixed - Fixed scripts hanging indefinitely on error ## `0.2.2` - February 5th, 2023 ### Added - Added global types for networking & child process APIs - `net.request` gets `NetFetchParams` and `NetFetchResponse` for its argument and return value - `net.serve` gets `NetRequest` and `NetResponse` for the handler function argument and return value - `process.spawn` gets `ProcessSpawnOptions` for its third and optional parameter ### Changed - Reorganize repository structure to take advantage of cargo workspaces, improves compile times ## `0.2.1` - February 3rd, 2023 ### Added - Added support for string interpolation syntax (update to Luau 0.561) - Added network server functionality using `net.serve` Example usage: ```lua net.serve(8080, function(request) print(`Got a {request.method} request at {request.path}!`) local data = net.jsonDecode(request.body) -- For simple text responses with a 200 status return "OK" -- For anything else return { status = 203, headers = { ["Content-Type"] = "application/json" }, body = net.jsonEncode({ message = "echo", data = data, }) } end) ``` ### Changed - Improved type definitions file for Selene, now including constants like `process.env` + tags such as `readonly` and `mustuse` wherever applicable ### Fixed - Fixed type definitions file for Selene not including all API members and parameters - Fixed `process.exit` exiting at the first yield instead of exiting instantly as it should ## `0.2.0` - January 28th, 2023 ### Added - Added full documentation for all global APIs provided by Lune! This includes over 200 lines of pure documentation about behavior & error cases for all of the current 35 constants & functions. Check the [README](/README.md) to find out how to enable documentation in your editor. - Added a third argument `options` for `process.spawn`: - `cwd` - The current working directory for the process - `env` - Extra environment variables to give to the process - `shell` - Whether to run in a shell or not - set to `true` to run using the default shell, or a string to run using a specific shell - `stdio` - How to treat output and error streams from the child process - set to `"inherit"` to pass output and error streams to the current process - Added `process.cwd`, the path to the current working directory in which the Lune script is running ## `0.1.3` - January 25th, 2023 ### Added - Added a `--list` subcommand to list scripts found in the `lune` or `.lune` directory. ## `0.1.2` - January 24th, 2023 ### Added - Added automatic publishing of the Lune library to [crates.io](https://crates.io/crates/lune) ### Fixed - Fixed scripts that terminate instantly sometimes hanging ## `0.1.1` - January 24th, 2023 ### Fixed - Fixed errors containing `./` and / or `../` in the middle of file paths - Potential fix for spawned processes that yield erroring with "attempt to yield across metamethod/c-call boundary" ## `0.1.0` - January 24th, 2023 ### Added - `task` now supports passing arguments in `task.spawn` / `task.delay` / `task.defer` - `require` now uses paths relative to the file instead of being relative to the current directory, which is consistent with almost all other languages but not original Lua / Luau - this is a breaking change but will allow for proper packaging of third-party modules and more in the future. - **_NOTE:_** _If you still want to use the default Lua behavior instead of relative paths, set the environment variable `LUAU_PWD_REQUIRE` to `true`_ ### Changed - Improved error message when an invalid file path is passed to `require` - Much improved error formatting and stack traces ### Fixed - Fixed downloading of type definitions making json files instead of the proper format - Process termination will now always make sure all lua state is cleaned up before exiting, in all cases ## `0.0.6` - January 23rd, 2023 ### Added - Initial implementation of [Roblox's task library](https://create.roblox.com/docs/reference/engine/libraries/task), with some caveats: - Minimum wait / delay time is currently set to 10ms, subject to change - It is not yet possible to pass arguments to tasks created using `task.spawn` / `task.delay` / `task.defer` - Timings for `task.defer` are flaky and deferred tasks are not (yet) guaranteed to run after spawned tasks With all that said, everything else should be stable! - Mixing and matching the `coroutine` library with `task` works in all cases - `process.exit()` will stop all spawned / delayed / deferred threads and exit the process - Lune is guaranteed to keep running until there are no longer any waiting threads If any of the abovementioned things do not work as expected, it is a bug, please file an issue! ### Fixed - Potential fix for spawned processes that yield erroring with "attempt to yield across metamethod/c-call boundary" ## `0.0.5` - January 22nd, 2023 ### Added - Added full test suites for all Lune globals to ensure correct behavior - Added library version of Lune that can be used from other Rust projects ### Changed - Large internal changes to allow for implementing the `task` library. - Improved general formatting of errors to make them more readable & glanceable - Improved output formatting of non-primitive types - Improved output formatting of empty tables ### Fixed - Fixed double stack trace for certain kinds of errors ## `0.0.4` - January 21st, 2023 ### Added - Added `process.args` for inspecting values given to Lune when running (read only) - Added `process.env` which is a plain table where you can get & set environment variables ### Changed - Improved error formatting & added proper file name to stack traces ### Removed - Removed `...` for process arguments, use `process.args` instead - Removed individual functions for getting & setting environment variables, use `process.env` instead ## `0.0.3` - January 20th, 2023 ### Added - Added networking functions under `net` Example usage: ```lua local apiResult = net.request({ url = "https://jsonplaceholder.typicode.com/posts/1", method = "PATCH", headers = { ["Content-Type"] = "application/json", }, body = net.jsonEncode({ title = "foo", body = "bar", }), }) local apiResponse = net.jsonDecode(apiResult.body) assert(apiResponse.title == "foo", "Invalid json response") assert(apiResponse.body == "bar", "Invalid json response") ``` - Added console logging & coloring functions under `console` This piece of code: ```lua local tab = { Integer = 1234, Hello = { "World" } } console.log(tab) ``` Will print the following formatted text to the console, **_with syntax highlighting_**: ```lua { Integer = 1234, Hello = { "World", } } ``` Additional utility functions exist with the same behavior but that also print out a colored tag together with any data given to them: `console.info`, `console.warn`, `console.error` - These print out prefix tags `[INFO]`, `[WARN]`, `[ERROR]` in blue, orange, and red, respectively. ### Changed - The `json` api is now part of `net` - `json.encode` becomes `net.jsonEncode` - `json.decode` become `net.jsonDecode` ### Fixed - Fixed JSON decode not working properly ## `0.0.2` - January 19th, 2023 ### Added - Added support for command-line parameters to scripts These can be accessed as a vararg in the root of a script: ```lua local firstArg: string, secondArg: string = ... print(firstArg, secondArg) ``` - Added CLI parameters for downloading type definitions: - `lune --download-selene-types` to download Selene types to the current directory - `lune --download-luau-types` to download Luau types to the current directory These files will be downloaded as `lune.yml` and `luneTypes.d.luau` respectively and are also available in each release on GitHub. ## `0.0.1` - January 18th, 2023 Initial Release ================================================ FILE: CONTRIBUTING.md ================================================ # Contributing --- ### Reporting a Bug - Make sure the bug has not already been reported by searching on GitHub under [Issues](https://github.com/lune-org/lune/issues). - If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/lune-org/lune/issues/new). Be sure to include a **title and description**, as much relevant information as possible, and if applicable, a **code sample** or a **test case** demonstrating the expected behavior. --- ### Contributing - Bug Fixes 1. Make sure an [issue](https://github.com/lune-org/lune/issues) has been created for the bug first, so that it can be tracked and searched for in the repository history. This is not mandatory for small fixes. 2. Open a new GitHub pull request for it. A pull request for a bug fix must include: - A clear and concise description of the bug it is fixing. - A new test file ensuring there are no regressions after the bug has been fixed. - A link to the relevant issue, or a `Fixes #issue` line, if an issue exists. ### Contributing - Features 1. Make sure an [issue](https://github.com/lune-org/lune/issues) has been created for the feature first, so that it can be tracked and searched for in the repository history. If you are making changes to an existing feature, and no issue exists, one should be created for the proposed changes. 2. Any API design or considerations should first be brought up and discussed in the relevant issue, to prevent long review times on pull requests and unnecessary work for maintainers. 3. Familiarize yourself with the codebase and the tools you will be using. Some important parts include: - The [mlua](https://crates.io/crates/mlua) library, which we use to interface with Luau. - Any [built-in libraries](https://github.com/lune-org/lune/tree/main/src/lune/builtins) that are relevant for your new feature. If you are making a new built-in library, refer to existing ones for structure and implementation details. - Our toolchain, notably [StyLua](https://github.com/JohnnyMorganz/StyLua), [rustfmt](https://github.com/rust-lang/rustfmt), and [clippy](https://github.com/rust-lang/rust-clippy). If you do not use these tools there is a decent chance CI will fail on your pull request, blocking it from getting approved. 4. Write some code! 5. Open a new GitHub pull request. A pull request for a feature must include: - A clear and concise description of the new feature or changes to the feature. - Test files for any added or changed functionality. - A link to the relevant issue, or a `Closes #issue` line. ### Contributing - Formatting & Cosmetic Changes Changes that are purely cosmetic, and do not add to the stability, functionality, or testability of Lune, will generally not be accepted unless there has been previous discussion about the changes being made. ### Contributing - Documentation #### Documentation Site Check out the [docs](https://github.com/lune-org/docs) repository and its contribution guidelines. #### Type Definitions If type definitions for built-in libraries need improvements: 1. Check out the [types](https://github.com/lune-org/lune/tree/main/types) directory at the root of the repository. 2. Make the desired changes, and verify that they have the desired outcome. 3. Open a new GitHub pull request for your changes. --- ### Publishing a Release The Lune release process is semi-automated, and takes care of most things for you. Here's how to create a new release: 1. Make sure the changelog is up to date and contains all of the changes since the last release. 2. Add the release date in the changelog + set a new version number in `Cargo.toml`. 3. Commit and push changes from step 2 to GitHub. This will automatically publish the Lune library to [crates.io](https://crates.io) when the version number changes. 4. Trigger the [release](https://github.com/lune-org/lune/actions/workflows/release.yaml) workflow on GitHub manually, and wait for it to finish. Find the new pending release in the [Releases](https://github.com/lune-org/lune/releases) section. 5. Add in changes from the changelog for the new pending release into the description, hit "accept" on creating a new version tag, and publish 🚀 --- If you have any questions, check out the `#lune` channel in the [Roblox OSS discord](https://discord.gg/H9WqmFAB5Y), where most of our realtime discussion takes place! Thank you for contributing to Lune! 🌙 ================================================ FILE: Cargo.toml ================================================ [workspace] resolver = "2" default-members = ["crates/lune"] members = [ "crates/lune", "crates/lune-roblox", "crates/lune-std", "crates/lune-std-datetime", "crates/lune-std-fs", "crates/lune-std-luau", "crates/lune-std-net", "crates/lune-std-process", "crates/lune-std-regex", "crates/lune-std-roblox", "crates/lune-std-serde", "crates/lune-std-stdio", "crates/lune-std-task", "crates/lune-utils", "crates/mlua-luau-scheduler", ] # Profile for building the release binary, with the following options set: # # 1. Optimize for size # 2. Automatically strip symbols from the binary # 3. Enable link-time optimization # # Note that we could abort instead of panicking to cut down on size # even more, but because we use the filesystem & some other APIs we # need the panic unwinding to properly handle usage of said APIs # [profile.release] opt-level = "z" strip = true lto = true # Lints for all crates in the workspace # # 1. Error on all lints by default, then make cargo + clippy pedantic lints just warn # 2. Selectively allow some lints that are _too_ pedantic, such as: # - Casts between number types # - Module naming conventions # - Imports and multiple dependency versions [workspace.lints.clippy] all = { level = "deny", priority = -3 } cargo = { level = "warn", priority = -2 } pedantic = { level = "warn", priority = -1 } cast_lossless = { level = "allow", priority = 1 } cast_possible_truncation = { level = "allow", priority = 1 } cast_possible_wrap = { level = "allow", priority = 1 } cast_precision_loss = { level = "allow", priority = 1 } cast_sign_loss = { level = "allow", priority = 1 } similar_names = { level = "allow", priority = 1 } unnecessary_wraps = { level = "allow", priority = 1 } unnested_or_patterns = { level = "allow", priority = 1 } unreadable_literal = { level = "allow", priority = 1 } multiple_crate_versions = { level = "allow", priority = 1 } module_inception = { level = "allow", priority = 1 } module_name_repetitions = { level = "allow", priority = 1 } needless_pass_by_value = { level = "allow", priority = 1 } wildcard_imports = { level = "allow", priority = 1 } ================================================ FILE: LICENSE.txt ================================================ Mozilla Public License Version 2.0 ================================== 1. Definitions -------------- 1.1. "Contributor" means each individual or legal entity that creates, contributes to the creation of, or owns Covered Software. 1.2. "Contributor Version" means the combination of the Contributions of others (if any) used by a Contributor and that particular Contributor's Contribution. 1.3. "Contribution" means Covered Software of a particular Contributor. 1.4. "Covered Software" means Source Code Form to which the initial Contributor has attached the notice in Exhibit A, the Executable Form of such Source Code Form, and Modifications of such Source Code Form, in each case including portions thereof. 1.5. "Incompatible With Secondary Licenses" means (a) that the initial Contributor has attached the notice described in Exhibit B to the Covered Software; or (b) that the Covered Software was made available under the terms of version 1.1 or earlier of the License, but not also under the terms of a Secondary License. 1.6. "Executable Form" means any form of the work other than Source Code Form. 1.7. "Larger Work" means a work that combines Covered Software with other material, in a separate file or files, that is not Covered Software. 1.8. "License" means this document. 1.9. "Licensable" means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently, any and all of the rights conveyed by this License. 1.10. "Modifications" means any of the following: (a) any file in Source Code Form that results from an addition to, deletion from, or modification of the contents of Covered Software; or (b) any new file in Source Code Form that contains any Covered Software. 1.11. "Patent Claims" of a Contributor means any patent claim(s), including without limitation, method, process, and apparatus claims, in any patent Licensable by such Contributor that would be infringed, but for the grant of the License, by the making, using, selling, offering for sale, having made, import, or transfer of either its Contributions or its Contributor Version. 1.12. "Secondary License" means either the GNU General Public License, Version 2.0, the GNU Lesser General Public License, Version 2.1, the GNU Affero General Public License, Version 3.0, or any later versions of those licenses. 1.13. "Source Code Form" means the form of the work preferred for making modifications. 1.14. "You" (or "Your") means an individual or a legal entity exercising rights under this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with You. For purposes of this definition, "control" means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity. 2. License Grants and Conditions -------------------------------- 2.1. Grants Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license: (a) under intellectual property rights (other than patent or trademark) Licensable by such Contributor to use, reproduce, make available, modify, display, perform, distribute, and otherwise exploit its Contributions, either on an unmodified basis, with Modifications, or as part of a Larger Work; and (b) under Patent Claims of such Contributor to make, use, sell, offer for sale, have made, import, and otherwise transfer either its Contributions or its Contributor Version. 2.2. Effective Date The licenses granted in Section 2.1 with respect to any Contribution become effective for each Contribution on the date the Contributor first distributes such Contribution. 2.3. Limitations on Grant Scope The licenses granted in this Section 2 are the only rights granted under this License. No additional rights or licenses will be implied from the distribution or licensing of Covered Software under this License. Notwithstanding Section 2.1(b) above, no patent license is granted by a Contributor: (a) for any code that a Contributor has removed from Covered Software; or (b) for infringements caused by: (i) Your and any other third party's modifications of Covered Software, or (ii) the combination of its Contributions with other software (except as part of its Contributor Version); or (c) under Patent Claims infringed by Covered Software in the absence of its Contributions. This License does not grant any rights in the trademarks, service marks, or logos of any Contributor (except as may be necessary to comply with the notice requirements in Section 3.4). 2.4. Subsequent Licenses No Contributor makes additional grants as a result of Your choice to distribute the Covered Software under a subsequent version of this License (see Section 10.2) or under the terms of a Secondary License (if permitted under the terms of Section 3.3). 2.5. Representation Each Contributor represents that the Contributor believes its Contributions are its original creation(s) or it has sufficient rights to grant the rights to its Contributions conveyed by this License. 2.6. Fair Use This License is not intended to limit any rights You have under applicable copyright doctrines of fair use, fair dealing, or other equivalents. 2.7. Conditions Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in Section 2.1. 3. Responsibilities ------------------- 3.1. Distribution of Source Form All distribution of Covered Software in Source Code Form, including any Modifications that You create or to which You contribute, must be under the terms of this License. You must inform recipients that the Source Code Form of the Covered Software is governed by the terms of this License, and how they can obtain a copy of this License. You may not attempt to alter or restrict the recipients' rights in the Source Code Form. 3.2. Distribution of Executable Form If You distribute Covered Software in Executable Form then: (a) such Covered Software must also be made available in Source Code Form, as described in Section 3.1, and You must inform recipients of the Executable Form how they can obtain a copy of such Source Code Form by reasonable means in a timely manner, at a charge no more than the cost of distribution to the recipient; and (b) You may distribute such Executable Form under the terms of this License, or sublicense it under different terms, provided that the license for the Executable Form does not attempt to limit or alter the recipients' rights in the Source Code Form under this License. 3.3. Distribution of a Larger Work You may create and distribute a Larger Work under terms of Your choice, provided that You also comply with the requirements of this License for the Covered Software. If the Larger Work is a combination of Covered Software with a work governed by one or more Secondary Licenses, and the Covered Software is not Incompatible With Secondary Licenses, this License permits You to additionally distribute such Covered Software under the terms of such Secondary License(s), so that the recipient of the Larger Work may, at their option, further distribute the Covered Software under the terms of either this License or such Secondary License(s). 3.4. Notices You may not remove or alter the substance of any license notices (including copyright notices, patent notices, disclaimers of warranty, or limitations of liability) contained within the Source Code Form of the Covered Software, except that You may alter any license notices to the extent required to remedy known factual inaccuracies. 3.5. Application of Additional Terms You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, You may do so only on Your own behalf, and not on behalf of any Contributor. You must make it absolutely clear that any such warranty, support, indemnity, or liability obligation is offered by You alone, and You hereby agree to indemnify every Contributor for any liability incurred by such Contributor as a result of warranty, support, indemnity or liability terms You offer. You may include additional disclaimers of warranty and limitations of liability specific to any jurisdiction. 4. Inability to Comply Due to Statute or Regulation --------------------------------------------------- If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Software due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be placed in a text file included with all distributions of the Covered Software under this License. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it. 5. Termination -------------- 5.1. The rights granted under this License will terminate automatically if You fail to comply with any of its terms. However, if You become compliant, then the rights granted under this License from a particular Contributor are reinstated (a) provisionally, unless and until such Contributor explicitly and finally terminates Your grants, and (b) on an ongoing basis, if such Contributor fails to notify You of the non-compliance by some reasonable means prior to 60 days after You have come back into compliance. Moreover, Your grants from a particular Contributor are reinstated on an ongoing basis if such Contributor notifies You of the non-compliance by some reasonable means, this is the first time You have received notice of non-compliance with this License from such Contributor, and You become compliant prior to 30 days after Your receipt of the notice. 5.2. If You initiate litigation against any entity by asserting a patent infringement claim (excluding declaratory judgment actions, counter-claims, and cross-claims) alleging that a Contributor Version directly or indirectly infringes any patent, then the rights granted to You by any and all Contributors for the Covered Software under Section 2.1 of this License shall terminate. 5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or Your distributors under this License prior to termination shall survive termination. ************************************************************************ * * * 6. Disclaimer of Warranty * * ------------------------- * * * * Covered Software is provided under this License on an "as is" * * basis, without warranty of any kind, either expressed, implied, or * * statutory, including, without limitation, warranties that the * * Covered Software is free of defects, merchantable, fit for a * * particular purpose or non-infringing. The entire risk as to the * * quality and performance of the Covered Software is with You. * * Should any Covered Software prove defective in any respect, You * * (not any Contributor) assume the cost of any necessary servicing, * * repair, or correction. This disclaimer of warranty constitutes an * * essential part of this License. No use of any Covered Software is * * authorized under this License except under this disclaimer. * * * ************************************************************************ ************************************************************************ * * * 7. Limitation of Liability * * -------------------------- * * * * Under no circumstances and under no legal theory, whether tort * * (including negligence), contract, or otherwise, shall any * * Contributor, or anyone who distributes Covered Software as * * permitted above, be liable to You for any direct, indirect, * * special, incidental, or consequential damages of any character * * including, without limitation, damages for lost profits, loss of * * goodwill, work stoppage, computer failure or malfunction, or any * * and all other commercial damages or losses, even if such party * * shall have been informed of the possibility of such damages. This * * limitation of liability shall not apply to liability for death or * * personal injury resulting from such party's negligence to the * * extent applicable law prohibits such limitation. Some * * jurisdictions do not allow the exclusion or limitation of * * incidental or consequential damages, so this exclusion and * * limitation may not apply to You. * * * ************************************************************************ 8. Litigation ------------- Any litigation relating to this License may be brought only in the courts of a jurisdiction where the defendant maintains its principal place of business and such litigation shall be governed by laws of that jurisdiction, without reference to its conflict-of-law provisions. Nothing in this Section shall prevent a party's ability to bring cross-claims or counter-claims. 9. Miscellaneous ---------------- This License represents the complete agreement concerning the subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not be used to construe this License against a Contributor. 10. Versions of the License --------------------------- 10.1. New Versions Mozilla Foundation is the license steward. Except as provided in Section 10.3, no one other than the license steward has the right to modify or publish new versions of this License. Each version will be given a distinguishing version number. 10.2. Effect of New Versions You may distribute the Covered Software under the terms of the version of the License under which You originally received the Covered Software, or under the terms of any subsequent version published by the license steward. 10.3. Modified Versions If you create software not governed by this License, and you want to create a new license for such software, you may create and use a modified version of this License if you rename the license and remove any references to the name of the license steward (except to note that such modified license differs from this License). 10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses If You choose to distribute Source Code Form that is Incompatible With Secondary Licenses under the terms of this version of the License, the notice described in Exhibit B of this License must be attached. Exhibit A - Source Code Form License Notice ------------------------------------------- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice. You may add additional accurate notices of copyright ownership. Exhibit B - "Incompatible With Secondary Licenses" Notice --------------------------------------------------------- This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0. ================================================ FILE: README.md ================================================ Lune logo

Lune

Current Lune library version CI status Release status Lune license

A standalone [Luau](https://luau-lang.org) runtime. Write and run programs, similar to runtimes for other languages such as [Node](https://nodejs.org), [Deno](https://deno.land), [Bun](https://bun.sh), or [Luvit](https://luvit.io) for vanilla Lua. Lune provides fully asynchronous APIs wherever possible, and is built in Rust 🦀 for speed, safety and correctness. ## Features - 🌙 Strictly minimal but powerful interface that is easy to read and remember, just like Luau itself - 🧰 Fully featured APIs for the filesystem, networking, stdio, all included in the small (~5mb zipped) executable - 📚 World-class documentation, on the web _or_ directly in your editor, no network connection necessary - 🏡 Familiar runtime environment for Roblox developers, with an included 1-to-1 task scheduler port - ✏️ Optional built-in library for manipulating Roblox place & model files, and their instances ## Non-goals - Making programs short and terse - proper autocomplete / intellisense make using Lune just as quick, and readability is important - Running full Roblox games outside of Roblox - there is some compatibility, but Lune is meant for different purposes ## Where do I start? Head over to the [Installation](https://lune-org.github.io/docs/getting-started/1-installation) page to get started using Lune! ================================================ FILE: crates/lune/Cargo.toml ================================================ [package] name = "lune" version = "0.10.4" edition = "2024" license = "MPL-2.0" repository = "https://github.com/lune-org/lune" description = "A standalone Luau runtime" readme = "../../README.md" keywords = ["cli", "lua", "luau", "runtime"] categories = ["command-line-interface"] [[bin]] name = "lune" path = "src/main.rs" [lib] name = "lune" path = "src/lib.rs" [features] default = ["std", "cli"] std-datetime = ["dep:lune-std", "lune-std/datetime"] std-fs = ["dep:lune-std", "lune-std/fs"] std-luau = ["dep:lune-std", "lune-std/luau"] std-net = ["dep:lune-std", "lune-std/net"] std-process = ["dep:lune-std", "lune-std/process"] std-regex = ["dep:lune-std", "lune-std/regex"] std-roblox = ["dep:lune-std", "lune-std/roblox"] std-serde = ["dep:lune-std", "lune-std/serde"] std-stdio = ["dep:lune-std", "lune-std/stdio"] std-task = ["dep:lune-std", "lune-std/task"] std = [ "std-datetime", "std-fs", "std-luau", "std-net", "std-process", "std-regex", "std-roblox", "std-serde", "std-stdio", "std-task", ] cli = ["dep:clap", "dep:rustyline", "dep:zip", "dep:lune-std-net"] [lints] workspace = true [dependencies] mlua = { version = "0.11.4", features = ["luau"] } mlua-luau-scheduler = { version = "0.2.3", path = "../mlua-luau-scheduler" } anyhow = "1.0" console = "0.16" dialoguer = "0.12" directories = "6.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" thiserror = "2.0" async-io = "2.4" async-fs = "2.1" blocking = "1.6" futures-lite = "2.6" tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } lune-std = { optional = true, version = "0.3.4", path = "../lune-std" } lune-std-net = { optional = true, version = "0.3.4", path = "../lune-std-net" } lune-utils = { version = "0.3.4", path = "../lune-utils" } ### CLI clap = { optional = true, version = "4.1", features = ["derive"] } rustyline = { optional = true, version = "17.0" } zip = { optional = true, version = "5.1", default-features = false, features = [ "bzip2", "deflate", "deflate64", "zstd" ] } ================================================ FILE: crates/lune/src/cli/build/base_exe.rs ================================================ use std::{ io::{Cursor, Read}, path::PathBuf, }; use async_fs as fs; use blocking::unblock; use crate::standalone::metadata::CURRENT_EXE; use super::{ files::write_executable_file_to, result::{BuildError, BuildResult}, target::{BuildTarget, CACHE_DIR}, }; const RELEASE_REQUEST_HEADERS: &[(&str, &str)] = &[ ( "User-Agent", concat!( "Lune/", env!("CARGO_PKG_VERSION"), " (", env!("CARGO_PKG_REPOSITORY"), ")" ), ), ("Accept", "application/octet-stream"), // ("Accept-Encoding", "gzip"), ]; /** Discovers the path to the base executable to use for cross-compilation. If the target is the same as the current system, the current executable is used. If no binary exists at the target path, it will attempt to download it from the internet. */ pub async fn get_or_download_base_executable(target: BuildTarget) -> BuildResult { if target.is_current_system() { return Ok(CURRENT_EXE.to_path_buf()); } if target.cache_path().exists() { return Ok(target.cache_path()); } // The target is not cached, we must download it println!("Requested target '{target}' does not exist in cache"); let version = env!("CARGO_PKG_VERSION"); let target_triple = format!("lune-{version}-{target}"); let release_url = format!( "{base_url}/v{version}/{target_triple}.zip", base_url = "https://github.com/lune-org/lune/releases/download", ); // NOTE: This is not entirely accurate, but it is clearer for a user println!("Downloading {target_triple}{}...", target.exe_suffix()); // Try to request to download the zip file from the target url, // making sure transient errors are handled gracefully and // with a different error message than "not found" let url = release_url.parse().expect("release url is valid"); let headers = RELEASE_REQUEST_HEADERS .iter() .map(|(k, v)| ((*k).to_string(), (*v).to_string())) .collect(); let res = lune_std_net::fetch(url, None, Some(headers), None) .await .map_err(BuildError::Download)?; let (parts, body) = res.into_inner().into_parts(); if !parts.status.is_success() { if parts.status.as_u16() == 404 { return Err(BuildError::ReleaseTargetNotFound(target)); } let body = body.into_bytes(); return Err(BuildError::Download(format!( "Request was not successful\ \nStatus: {}\ \nBody: {}", parts.status, if body.len() > 128 { String::from_utf8_lossy(&body[0..128]) } else { String::from_utf8_lossy(&body) } ))); } // Start reading the zip file let zip_file = Cursor::new(body.into_bytes()); // Look for and extract the binary file from the zip file // NOTE: We use spawn_blocking here since reading a zip // archive is a somewhat slow / blocking operation let binary_file_name = format!("lune{}", target.exe_suffix()); let binary_file_handle = unblock(move || { let mut archive = zip::ZipArchive::new(zip_file)?; let mut binary = Vec::new(); archive .by_name(&binary_file_name) .or(Err(BuildError::ZippedBinaryNotFound(binary_file_name)))? .read_to_end(&mut binary)?; Ok::<_, BuildError>(binary) }); let binary_file_contents = binary_file_handle.await?; // Finally, write the extracted binary to the cache if !CACHE_DIR.exists() { fs::create_dir_all(CACHE_DIR.as_path()).await?; } write_executable_file_to(target.cache_path(), binary_file_contents).await?; println!("Downloaded successfully and added to cache"); Ok(target.cache_path()) } ================================================ FILE: crates/lune/src/cli/build/files.rs ================================================ use std::path::{Path, PathBuf}; use anyhow::Result; use async_fs as fs; use futures_lite::prelude::*; /** Removes the source file extension from the given path, if it has one. A source file extension is an extension such as `.lua` or `.luau`. */ pub fn remove_source_file_ext(path: &Path) -> PathBuf { if path .extension() .is_some_and(|ext| matches!(ext.to_str(), Some("lua" | "luau"))) { path.with_extension("") } else { path.to_path_buf() } } /** Writes the given bytes to a file at the specified path, and makes sure it has permissions to be executed. */ pub async fn write_executable_file_to( path: impl AsRef, bytes: impl AsRef<[u8]>, ) -> Result<(), std::io::Error> { let mut options = fs::OpenOptions::new(); options.write(true).create(true).truncate(true); #[cfg(unix)] { use fs::unix::OpenOptionsExt; options.mode(0o755); // Read & execute for all, write for owner } let mut file = options.open(path).await?; file.write_all(bytes.as_ref()).await?; file.flush().await?; Ok(()) } ================================================ FILE: crates/lune/src/cli/build/mod.rs ================================================ use std::{path::PathBuf, process::ExitCode}; use anyhow::{Context, Result, bail}; use async_fs as fs; use clap::Parser; use console::style; use crate::standalone::metadata::Metadata; mod base_exe; mod files; mod result; mod target; use self::base_exe::get_or_download_base_executable; use self::files::{remove_source_file_ext, write_executable_file_to}; use self::target::BuildTarget; /// Build a standalone executable #[derive(Debug, Clone, Parser)] pub struct BuildCommand { /// The path to the input file pub input: PathBuf, /// The path to the output file - defaults to the /// input file path with an executable extension #[clap(short, long)] pub output: Option, /// The target to compile for in the format `os-arch` - /// defaults to the os and arch of the current system #[clap(short, long)] pub target: Option, } impl BuildCommand { pub async fn run(self) -> Result { // Derive target spec to use, or default to the current host system let target = self.target.unwrap_or_else(BuildTarget::current_system); // Derive paths to use, and make sure the output path is // not the same as the input, so that we don't overwrite it let output_path = self .output .clone() .unwrap_or_else(|| remove_source_file_ext(&self.input)); let output_path = output_path.with_extension(target.exe_extension()); if output_path == self.input { if self.output.is_some() { bail!("output path cannot be the same as input path"); } bail!( "output path cannot be the same as input path, please specify a different output path" ); } // Try to read the given input file // FUTURE: We should try and resolve a full require file graph using the input // path here instead, see the notes in the `standalone` module for more details let source_code = fs::read(&self.input) .await .context("failed to read input file")?; // Derive the base executable path based on the arguments provided let base_exe_path = get_or_download_base_executable(target).await?; // Read the contents of the lune interpreter as our starting point println!( "Compiling standalone binary from {}", style(self.input.display()).green() ); let patched_bin = Metadata::create_env_patched_bin(base_exe_path, source_code) .await .context("failed to create patched binary")?; // And finally write the patched binary to the output file println!( "Writing standalone binary to {}", style(output_path.display()).blue() ); write_executable_file_to(output_path, patched_bin).await?; // Read & execute for all, write for owner Ok(ExitCode::SUCCESS) } } ================================================ FILE: crates/lune/src/cli/build/result.rs ================================================ use thiserror::Error; use super::target::BuildTarget; /** Errors that may occur when building a standalone binary */ #[derive(Debug, Error)] pub enum BuildError { #[error("failed to find lune target '{0}' in GitHub release")] ReleaseTargetNotFound(BuildTarget), #[error("failed to find lune binary '{0}' in downloaded zip file")] ZippedBinaryNotFound(String), #[error("failed to download lune binary: {0}")] Download(String), #[error("failed to unzip lune binary: {0}")] Unzip(#[from] zip::result::ZipError), #[error("io error: {0}")] IoError(#[from] std::io::Error), } pub type BuildResult = std::result::Result; ================================================ FILE: crates/lune/src/cli/build/target.rs ================================================ use std::{env::consts::ARCH, fmt, path::PathBuf, str::FromStr, sync::LazyLock}; use directories::BaseDirs; static HOME_DIR: LazyLock = LazyLock::new(|| { BaseDirs::new() .expect("could not find home directory") .home_dir() .to_path_buf() }); pub static CACHE_DIR: LazyLock = LazyLock::new(|| HOME_DIR.join(".lune").join("target")); /** A target operating system supported by Lune */ #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum BuildTargetOS { Windows, Linux, MacOS, } impl BuildTargetOS { fn current_system() -> Self { match std::env::consts::OS { "windows" => Self::Windows, "linux" => Self::Linux, "macos" => Self::MacOS, _ => panic!("unsupported target OS"), } } fn exe_extension(self) -> &'static str { // NOTE: We can't use the constants from std since // they are only accessible for the current target match self { Self::Windows => "exe", _ => "", } } fn exe_suffix(self) -> &'static str { match self { Self::Windows => ".exe", _ => "", } } } impl fmt::Display for BuildTargetOS { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::Windows => write!(f, "windows"), Self::Linux => write!(f, "linux"), Self::MacOS => write!(f, "macos"), } } } impl FromStr for BuildTargetOS { type Err = &'static str; fn from_str(s: &str) -> Result { match s.trim().to_ascii_lowercase().as_str() { "win" | "windows" => Ok(Self::Windows), "linux" => Ok(Self::Linux), "mac" | "macos" | "darwin" => Ok(Self::MacOS), _ => Err("invalid target OS"), } } } /** A target architecture supported by Lune */ #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum BuildTargetArch { X86_64, Aarch64, } impl BuildTargetArch { fn current_system() -> Self { match ARCH { "x86_64" => Self::X86_64, "aarch64" => Self::Aarch64, _ => panic!("unsupported target architecture"), } } } impl fmt::Display for BuildTargetArch { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::X86_64 => write!(f, "x86_64"), Self::Aarch64 => write!(f, "aarch64"), } } } impl FromStr for BuildTargetArch { type Err = &'static str; fn from_str(s: &str) -> Result { match s.trim().to_ascii_lowercase().as_str() { "x86_64" | "x64" => Ok(Self::X86_64), "aarch64" | "arm64" => Ok(Self::Aarch64), _ => Err("invalid target architecture"), } } } /** A full target description that Lune supports (OS + Arch) This is used to determine the target to build for standalone binaries, and to download the correct base executable for cross-compilation. The target may be parsed from and displayed in the form `os-arch`. Examples of valid targets are: - `linux-aarch64` - `linux-x86_64` - `macos-aarch64` - `macos-x86_64` - `windows-x86_64` */ #[derive(Debug, Clone, PartialEq, Eq)] pub struct BuildTarget { pub os: BuildTargetOS, pub arch: BuildTargetArch, } impl BuildTarget { pub fn current_system() -> Self { Self { os: BuildTargetOS::current_system(), arch: BuildTargetArch::current_system(), } } pub fn is_current_system(&self) -> bool { self.os == BuildTargetOS::current_system() && self.arch == BuildTargetArch::current_system() } pub fn exe_extension(&self) -> &'static str { self.os.exe_extension() } pub fn exe_suffix(&self) -> &'static str { self.os.exe_suffix() } pub fn cache_path(&self) -> PathBuf { CACHE_DIR.join(format!("{self}{}", self.os.exe_extension())) } } impl fmt::Display for BuildTarget { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}-{}", self.os, self.arch) } } impl FromStr for BuildTarget { type Err = &'static str; fn from_str(s: &str) -> Result { let (left, right) = s .split_once('-') .ok_or("target must be in the form `os-arch`")?; let os = left.parse()?; let arch = right.parse()?; Ok(Self { os, arch }) } } ================================================ FILE: crates/lune/src/cli/list.rs ================================================ use std::{fmt::Write as _, process::ExitCode}; use anyhow::Result; use clap::Parser; use super::utils::listing::{find_lune_scripts, sort_lune_scripts, write_lune_scripts_list}; /// List scripts available to run #[derive(Debug, Clone, Parser)] pub struct ListCommand {} impl ListCommand { pub async fn run(self) -> Result { let sorted_relative = find_lune_scripts(false).await.map(sort_lune_scripts); let sorted_home_dir = find_lune_scripts(true).await.map(sort_lune_scripts); if sorted_relative.is_err() && sorted_home_dir.is_err() { eprintln!("{}", sorted_relative.unwrap_err()); return Ok(ExitCode::FAILURE); } let sorted_relative = sorted_relative.unwrap_or(Vec::new()); let sorted_home_dir = sorted_home_dir.unwrap_or(Vec::new()); let mut buffer = String::new(); if !sorted_relative.is_empty() { if sorted_home_dir.is_empty() { write!(&mut buffer, "Available scripts:")?; } else { write!(&mut buffer, "Available scripts in current directory:")?; } write_lune_scripts_list(&mut buffer, sorted_relative)?; } if !sorted_home_dir.is_empty() { write!(&mut buffer, "Available global scripts:")?; write_lune_scripts_list(&mut buffer, sorted_home_dir)?; } if buffer.is_empty() { println!("No scripts found."); } else { print!("{buffer}"); } Ok(ExitCode::SUCCESS) } } ================================================ FILE: crates/lune/src/cli/mod.rs ================================================ use std::{env::args_os, process::ExitCode}; use anyhow::Result; use clap::{Parser, Subcommand}; pub(crate) mod build; pub(crate) mod list; pub(crate) mod repl; pub(crate) mod run; pub(crate) mod setup; pub(crate) mod utils; pub use self::{ build::BuildCommand, list::ListCommand, repl::ReplCommand, run::RunCommand, setup::SetupCommand, }; #[derive(Debug, Clone, Subcommand)] pub enum CliSubcommand { Run(RunCommand), List(ListCommand), Setup(SetupCommand), Build(BuildCommand), Repl(ReplCommand), } impl Default for CliSubcommand { fn default() -> Self { Self::Repl(ReplCommand::default()) } } /// Lune, a standalone Luau runtime #[derive(Parser, Debug, Default, Clone)] #[command(version, about, long_about = None)] pub struct Cli { #[clap(subcommand)] subcommand: Option, } impl Cli { pub fn new() -> Self { // TODO: Figure out if there is a better way to do this using clap ... ? // https://github.com/lune-org/lune/issues/253 if args_os() .nth(1) .is_some_and(|arg| arg.eq_ignore_ascii_case("run")) { let Some(script_path) = args_os() .nth(2) .and_then(|arg| arg.to_str().map(String::from)) else { return Self::parse(); // Will fail and return the help message }; let script_args = args_os() .skip(3) .filter_map(|arg| arg.to_str().map(String::from)) .collect::>(); Self { subcommand: Some(CliSubcommand::Run(RunCommand { script_path, script_args, })), } } else { Self::parse() } } pub async fn run(self) -> Result { match self.subcommand.unwrap_or_default() { CliSubcommand::Run(cmd) => cmd.run().await, CliSubcommand::List(cmd) => cmd.run().await, CliSubcommand::Setup(cmd) => cmd.run().await, CliSubcommand::Build(cmd) => cmd.run().await, CliSubcommand::Repl(cmd) => cmd.run().await, } } } ================================================ FILE: crates/lune/src/cli/repl.rs ================================================ use std::{path::PathBuf, process::ExitCode}; use anyhow::{Context, Result}; use async_fs as fs; use clap::Parser; use directories::UserDirs; use rustyline::{DefaultEditor, error::ReadlineError}; use lune::Runtime; const MESSAGE_WELCOME: &str = concat!("Lune v", env!("CARGO_PKG_VERSION")); const MESSAGE_INTERRUPT: &str = "Interrupt: ^C again to exit"; enum PromptState { Regular, Continuation, } /// Launch an interactive REPL (default) #[derive(Debug, Clone, Default, Parser)] pub struct ReplCommand {} impl ReplCommand { pub async fn run(self) -> Result { println!("{MESSAGE_WELCOME}"); let history_file_path: &PathBuf = &UserDirs::new() .context("Failed to find user home directory")? .home_dir() .join(".lune_history"); if !history_file_path.exists() { fs::write(history_file_path, &[]).await?; } let mut repl = DefaultEditor::new()?; repl.load_history(history_file_path)?; let mut interrupt_counter = 0; let mut prompt_state = PromptState::Regular; let mut source_code = String::new(); let mut lune_instance = Runtime::new()?; loop { let prompt = match prompt_state { PromptState::Regular => "> ", PromptState::Continuation => ">> ", }; match repl.readline(prompt) { Ok(code) => { interrupt_counter = 0; // TODO: Should we add history entries for each separate line? // Or should we add and save history only when we have complete // lua input that may or may not be multiple lines long? repl.add_history_entry(&code)?; repl.save_history(history_file_path)?; match prompt_state { PromptState::Regular => source_code = code, PromptState::Continuation => source_code.push_str(&code), } } Err(ReadlineError::Eof) => break, Err(ReadlineError::Interrupted) => { interrupt_counter += 1; // NOTE: We actually want the user to do ^C twice to exit, // and if we get an interrupt we should continue to the next // readline loop iteration so we don't run input code twice if interrupt_counter == 1 { println!("{MESSAGE_INTERRUPT}"); continue; } break; } Err(err) => { eprintln!("REPL ERROR: {err}"); return Ok(ExitCode::FAILURE); } } match lune_instance.run_custom("REPL", &source_code).await { Ok(_) => prompt_state = PromptState::Regular, Err(err) => { if err.is_incomplete_input() { prompt_state = PromptState::Continuation; source_code.push('\n'); } else { eprintln!("{err}"); } } } } repl.save_history(history_file_path)?; Ok(ExitCode::SUCCESS) } } ================================================ FILE: crates/lune/src/cli/run.rs ================================================ use std::{env, io::stdin, process::ExitCode}; use anyhow::{Context, Result}; use blocking::Unblock; use clap::Parser; use futures_lite::prelude::*; use lune::Runtime; use super::utils::files::discover_script_path_including_lune_dirs; /// Run a script #[derive(Debug, Clone, Parser)] pub struct RunCommand { /// Script name or full path to the file to run pub(super) script_path: String, /// Arguments to pass to the script, stored in process.args pub(super) script_args: Vec, } impl RunCommand { pub async fn run(self) -> Result { // Check if the user has explicitly disabled JIT (on by default) let jit_disabled = env::var("LUNE_LUAU_JIT") .ok() .is_some_and(|s| matches!(s.as_str(), "0" | "false" | "off")); // Create a new lune runtime with all globals & run the script let mut rt = Runtime::new()? .with_args(self.script_args) .with_jit(!jit_disabled); // Figure out if we should run stdin or run a file, // reading from stdin is marked by passing a single "-" // (dash) as the script name to run to the cli let result = if &self.script_path == "-" { let mut stdin_contents = Vec::new(); Unblock::new(stdin()) .read_to_end(&mut stdin_contents) .await .context("Failed to read script contents from stdin")?; rt.run_custom("stdin", stdin_contents).await } else { let file_path = discover_script_path_including_lune_dirs(&self.script_path)?; rt.run_file(file_path).await }; Ok(match result { Err(err) => { eprintln!("{err}"); ExitCode::FAILURE } Ok(values) => ExitCode::from(values.status()), }) } } ================================================ FILE: crates/lune/src/cli/setup.rs ================================================ use std::{io::ErrorKind, process::ExitCode}; use anyhow::{Context, Result}; use async_fs as fs; use clap::Parser; use directories::UserDirs; use thiserror::Error; use serde_json::Value as JsonValue; const LUAURC_PATH: &str = ".luaurc"; /// Set up type definitions for your editor #[derive(Debug, Clone, Parser)] pub struct SetupCommand {} impl SetupCommand { pub async fn run(self) -> Result { generate_typedef_files_from_definitions() .await .expect("Failed to generate typedef files"); let mut luaurc = read_or_create_luaurc().await?; add_values_to_luaurc(&mut luaurc); write_luaurc(luaurc).await?; println!( "Type definitions for Lune v{} have been set up successfully.\ \nYou may need to restart your editor for the changes to take effect.", lune_version() ); Ok(ExitCode::SUCCESS) } } #[derive(Debug, Clone, Copy, Error)] enum SetupError { #[error("Failed to read settings")] Read, #[error("Failed to write settings")] Write, #[error("Failed to parse settings")] Deserialize, #[error("Failed to create settings")] Serialize, } fn lune_version() -> &'static str { env!("CARGO_PKG_VERSION") } async fn read_or_create_luaurc() -> Result { match fs::read(LUAURC_PATH).await { Err(e) if e.kind() == ErrorKind::NotFound => match fs::write(LUAURC_PATH, "{}").await { Err(_) => Err(SetupError::Write), Ok(()) => Ok(JsonValue::Object(serde_json::Map::new())), }, Err(_) => Err(SetupError::Read), Ok(contents) => match serde_json::from_slice(&contents) { Err(_) => Err(SetupError::Deserialize), Ok(json) => Ok(json), }, } } async fn write_luaurc(luaurc: JsonValue) -> Result<(), SetupError> { match serde_json::to_vec_pretty(&luaurc) { Err(_) => Err(SetupError::Serialize), Ok(mut json) => { json.push(b'\n'); match fs::write(LUAURC_PATH, json).await { Err(_) => Err(SetupError::Write), Ok(()) => Ok(()), } } } } fn add_values_to_luaurc(luaurc: &mut JsonValue) { if let JsonValue::Object(luaurc) = luaurc { let field = String::from("aliases"); let alias = String::from("lune"); let dir = JsonValue::String(format!("~/.lune/.typedefs/{}/", lune_version())); if let Some(JsonValue::Object(aliases)) = luaurc.get_mut(&field) { if aliases.contains_key(&alias) { if aliases.get(&alias).unwrap() != &dir { aliases.insert(alias, dir); } } else { aliases.insert(alias, dir); } } else { let mut map = serde_json::Map::new(); map.insert(alias, dir); luaurc.insert(field, JsonValue::Object(map)); } } } async fn generate_typedef_files_from_definitions() -> Result { let version_string = env!("CARGO_PKG_VERSION"); let mut dirs_to_write = Vec::new(); let mut files_to_write = Vec::new(); // Create the typedefs dir in the users cache dir let cache_dir = UserDirs::new() .context("Failed to find user home directory")? .home_dir() .join(".lune") .join(".typedefs") .join(version_string); dirs_to_write.push(cache_dir.clone()); // Make typedef files for builtin in lune_std::LuneStandardLibrary::ALL { let name = builtin.name().to_lowercase(); let path = cache_dir.join(&name).with_extension("luau"); files_to_write.push((name, path, builtin.typedefs())); } // Write all dirs and files for dir in dirs_to_write { fs::create_dir_all(dir).await?; } for (_name, path, contents) in files_to_write { fs::write(path, contents).await?; } Ok(version_string.to_string()) } ================================================ FILE: crates/lune/src/cli/utils/files.rs ================================================ use std::path::{Path, PathBuf}; use anyhow::{Context, Result, anyhow}; use console::style; use directories::UserDirs; use lune_utils::path::{LuauFilePath, LuauModulePath, get_current_dir}; const LUNE_COMMENT_PREFIX: &str = "-->"; /** Discovers a script file path based on a given module path *or* file path. See the documentation for [`LuauModulePath`] for more information about what a module path vs a script path is. */ pub fn discover_script_path(path: impl Into, in_home_dir: bool) -> Result { // First, for legacy compatibility, we will strip any lua/luau file extension, // and if the entire file stem is simply "init", we will get rid of that too // This lets users pass "dir/init.luau" and have it resolve to simply "dir", // which is a valid luau module path, while "dir/init.luau" is not let path = LuauModulePath::strip(path); // If we got an absolute path, we should not modify it, // otherwise we should either resolve against home or cwd let path = if path.is_absolute() { path } else if in_home_dir { UserDirs::new() .context("Missing home directory")? .home_dir() .join(path) } else { get_current_dir().join(path) }; // The rest of the logic should follow Luau module path resolution rules match LuauModulePath::resolve(&path) { Err(e) => Err(anyhow!( "Failed to resolve script at path {} ({})", style(path.display()).yellow(), style(format!("{e:?}")).red() )), Ok(m) => match m.target() { LuauFilePath::File(f) => Ok(f.clone()), LuauFilePath::Directory(_) => Err(anyhow!( "Failed to resolve script at path {}\ \nThe path is a directory without an init file", style(path.display()).yellow() )), }, } } /** Discovers a script file path based on a given script name, and tries to find scripts in `lune` and `.lune` folders if one was not directly found. Note that looking in `lune` and `.lune` folders is automatically disabled if the given script name is an absolute path. Behavior is otherwise exactly the same as for `discover_script_file_path`. */ pub fn discover_script_path_including_lune_dirs(path: impl AsRef) -> Result { let path: &Path = path.as_ref(); match discover_script_path(path, false) { Ok(path) => Ok(path), Err(e) => { // If we got any absolute path it means the user has also // told us to not look in any special relative directories // so we should error right away with the first err message if path.is_absolute() { return Err(e); } // Otherwise we take a look in relative lune and .lune // directories + the home directory for the current user let res = discover_script_path(Path::new("lune").join(path), false) .or_else(|_| discover_script_path(Path::new(".lune").join(path), false)) .or_else(|_| discover_script_path(Path::new("lune").join(path), true)) .or_else(|_| discover_script_path(Path::new(".lune").join(path), true)); match res { // NOTE: The first error message is generally more // descriptive than the ones for the lune subfolders Err(_) => Err(e), Ok(path) => Ok(path), } } } } pub fn parse_lune_description_from_file(contents: &str) -> Option { let mut comment_lines = Vec::new(); for line in contents.lines() { if let Some(stripped) = line.strip_prefix(LUNE_COMMENT_PREFIX) { comment_lines.push(stripped); } else { break; } } if comment_lines.is_empty() { None } else { let shortest_indent = comment_lines.iter().fold(usize::MAX, |acc, line| { let first_alphanumeric = line.find(char::is_alphanumeric).unwrap(); acc.min(first_alphanumeric) }); let unindented_lines = comment_lines .iter() .map(|line| line[shortest_indent..].to_string()) .collect::>() .join(" "); Some(unindented_lines) } } ================================================ FILE: crates/lune/src/cli/utils/listing.rs ================================================ #![allow(clippy::match_same_arms)] use std::{ cmp::Ordering, ffi::OsStr, fmt::Write as _, io::ErrorKind, path::PathBuf, sync::LazyLock, }; use anyhow::{Result, bail}; use async_fs as fs; use console::Style; use directories::UserDirs; use futures_lite::prelude::*; use super::files::{discover_script_path, parse_lune_description_from_file}; pub static COLOR_BLUE: LazyLock