Skip to content

Commit

Permalink
Update require paths to relative string
Browse files Browse the repository at this point in the history
  • Loading branch information
centau committed Nov 13, 2024
1 parent 0897821 commit 5abd5ee
Show file tree
Hide file tree
Showing 25 changed files with 90 additions and 125 deletions.
19 changes: 9 additions & 10 deletions src/apply.luau
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
if not game then script = require "test/relative-string" end
local typeof = game and typeof or require "test/mock".typeof :: never
local Vector2 = game and Vector2 or require "test/mock".Vector2 :: never
local UDim2 = game and UDim2 or require "test/mock".UDim2 :: never

local flags = require(script.Parent.flags)
local throw = require(script.Parent.throw)
local bind = require(script.Parent.bind)
local _, is_action = require(script.Parent.action)()
local graph = require(script.Parent.graph)
local typeof = game and typeof or require "../test/mock".typeof :: never
local Vector2 = game and Vector2 or require "../test/mock".Vector2 :: never
local UDim2 = game and UDim2 or require "../test/mock".UDim2 :: never

local flags = require "./flags"
local throw = require "./throw"
local bind = require "./bind"
local _, is_action = require "./action"()
local graph = require "./graph"
type Node<T> = graph.Node<T>

type Array<V> = { V }
Expand Down
8 changes: 3 additions & 5 deletions src/batch.luau
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
if not game then script = require "test/relative-string" end

local flags = require(script.Parent.flags)
local throw = require(script.Parent.throw)
local graph = require(script.Parent.graph)
local flags = require "./flags"
local throw = require "./throw"
local graph = require "./graph"

local function batch(setter: () -> ())
local already_batching = flags.batch
Expand Down
4 changes: 1 addition & 3 deletions src/bind.luau
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
if not game then script = require "test/relative-string" end

local graph = require(script.Parent.graph)
local graph = require "./graph"
type Node<T> = graph.Node<T>
local create_node = graph.create_node
local assert_stable_scope = graph.assert_stable_scope
Expand Down
6 changes: 2 additions & 4 deletions src/changed.luau
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
if not game then script = require "test/relative-string" end

local action = require(script.Parent.action)()
local cleanup = require(script.Parent.cleanup)
local action = require "./action"()
local cleanup = require "./cleanup"

local function changed<T>(property: string, callback: (T) -> ())
return action(function(instance)
Expand Down
7 changes: 3 additions & 4 deletions src/cleanup.luau
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
if not game then script = require "test/relative-string" end
local typeof = game and typeof or require "test/mock".typeof :: never
local typeof = game and typeof or require "../test/mock".typeof :: never

local throw = require(script.Parent.throw)
local graph = require(script.Parent.graph)
local throw = require "./throw"
local graph = require "./graph"
local get_scope = graph.get_scope
local push_cleanup = graph.push_cleanup

Expand Down
6 changes: 3 additions & 3 deletions src/context.luau
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
if not game then script = require "test/relative-string" end
if not game then script = require "../test/relative-string" end

local throw = require(script.Parent.throw)
local graph = require(script.Parent.graph)
local throw = require "./throw"
local graph = require "./graph"
type Node<T> = graph.Node<T>
local create_node = graph.create_node
local get_scope = graph.get_scope
Expand Down
12 changes: 6 additions & 6 deletions src/create.luau
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
if not game then script = require "test/relative-string" end
local typeof = game and typeof or require "test/mock".typeof:: never
local Instance = game and Instance or require "test/mock".Instance :: never
if not game then script = require "../test/relative-string" end
local typeof = game and typeof or require "../test/mock".typeof :: never
local Instance = game and Instance or require "../test/mock".Instance :: never

local throw = require(script.Parent.throw)
local defaults = require(script.Parent.defaults)
local apply = require(script.Parent.apply)
local throw = require "./throw"
local defaults = require "./defaults"
local apply = require "./apply"

local ctor_cache = {} :: { [string]: () -> Instance }

Expand Down
6 changes: 3 additions & 3 deletions src/defaults.luau
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local Enum = game and Enum or require "test/mock".Enum :: never
local Color3 = game and Color3 or require "test/mock".Color3 :: never
local Vector3 = game and Vector3 or require "test/mock".Vector3 :: never
local Enum = game and Enum or require "../test/mock".Enum :: never
local Color3 = game and Color3 or require "../test/mock".Color3 :: never
local Vector3 = game and Vector3 or require "../test/mock".Vector3 :: never

return {
Part = {
Expand Down
4 changes: 1 addition & 3 deletions src/derive.luau
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
if not game then script = require "test/relative-string" end

local graph = require(script.Parent.graph)
local graph = require "./graph"
local create_node = graph.create_node
local push_child_to_scope = graph.push_child_to_scope
local assert_stable_scope = graph.assert_stable_scope
Expand Down
4 changes: 1 addition & 3 deletions src/effect.luau
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
if not game then script = require "test/relative-string" end

local graph = require(script.Parent.graph)
local graph = require "./graph"
local create_node = graph.create_node
local assert_stable_scope = graph.assert_stable_scope
local evaluate_node = graph.evaluate_node
Expand Down
6 changes: 2 additions & 4 deletions src/graph.luau
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
if not game then script = require "test/relative-string" end

local throw = require(script.Parent.throw)
local flags = require(script.Parent.flags)
local throw = require "./throw"
local flags = require "./flags"

export type SourceNode<T> = {
cache: T,
Expand Down
42 changes: 20 additions & 22 deletions src/init.luau
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,26 @@

local version = { major = 0, minor = 3, patch = 1 }

if not game then script = require "test/relative-string" end

local root = require(script.root)
local mount = require(script.mount)
local create = require(script.create)
local apply = require(script.apply)
local source = require(script.source)
local effect = require(script.effect)
local derive = require(script.derive)
local cleanup = require(script.cleanup)
local untrack = require(script.untrack)
local read = require(script.read)
local batch = require(script.batch)
local context = require(script.context)
local switch = require(script.switch)
local show = require(script.show)
local indexes, values = require(script.maps)()
local spring, update_springs = require(script.spring)()
local action = require(script.action)()
local changed = require(script.changed)
local throw = require(script.throw)
local flags = require(script.flags)
local root = require "./root"
local mount = require "./mount"
local create = require "./create"
local apply = require "./apply"
local source = require "./source"
local effect = require "./effect"
local derive = require "./derive"
local cleanup = require "./cleanup"
local untrack = require "./untrack"
local read = require "./read"
local batch = require "./batch"
local context = require "./context"
local switch = require "./switch"
local show = require "./show"
local indexes, values = require "./maps"()
local spring, update_springs = require "./spring"()
local action = require "./action"()
local changed = require "./changed"
local throw = require "./throw"
local flags = require "./flags"

export type Source<T> = source.Source<T>
export type source<T> = Source<T>
Expand Down
8 changes: 3 additions & 5 deletions src/maps.luau
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
if not game then script = require "test/relative-string" end

local throw = require(script.Parent.throw)
local flags = require(script.Parent.flags)
local graph = require(script.Parent.graph)
local throw = require "./throw"
local flags = require "./flags"
local graph = require "./graph"
type Node<T> = graph.Node<T>
type SourceNode<T> = graph.SourceNode<T>
local create_node = graph.create_node
Expand Down
6 changes: 2 additions & 4 deletions src/mount.luau
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
if not game then script = require "test/relative-string" end

local root = require(script.Parent.root)
local apply = require(script.Parent.apply)
local root = require "./root"
local apply = require "./apply"

local function mount<T>(component: () -> T, target: Instance?): () -> ()
return root(function()
Expand Down
2 changes: 0 additions & 2 deletions src/read.luau
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
if not game then script = require "test/relative-string" end

local function read<T>(value: T | () -> T): T
return if type(value) == "function" then value() else value
end
Expand Down
6 changes: 2 additions & 4 deletions src/root.luau
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
if not game then script = require "test/relative-string" end

local throw = require(script.Parent.throw)
local graph = require(script.Parent.graph)
local throw = require "./throw"
local graph = require "./graph"
type Node<T> = graph.Node<T>
local create_node = graph.create_node
local push_scope = graph.push_scope
Expand Down
4 changes: 1 addition & 3 deletions src/show.luau
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
if not game then script = require "test/relative-string" end

local switch = require(script.Parent.switch)
local switch = require "./switch"

local function show<T>(source: () -> any, component: () -> T, fallback: (() -> T)?): () -> T?
local function truthy()
Expand Down
4 changes: 1 addition & 3 deletions src/source.luau
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
if not game then script = require "test/relative-string" end

local graph = require(script.Parent.graph)
local graph = require "./graph"
type Node<T> = graph.Node<T>
local create_source_node = graph.create_source_node
local push_child_to_scope = graph.push_child_to_scope
Expand Down
7 changes: 3 additions & 4 deletions src/spring.luau
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
if not game then script = require "test/relative-string" end
local Vector3 = game and Vector3 or require "test/mock".Vector3 :: never
local Vector3 = game and Vector3 or require "../test/mock".Vector3 :: never

--[[
Expand All @@ -21,8 +20,8 @@ Unsupported datatypes:
]]

local throw = require(script.Parent.throw)
local graph = require(script.Parent.graph)
local throw = require "./throw"
local graph = require "./graph"
type Node<T> = graph.Node<T>
type SourceNode<T> = graph.SourceNode<T>
local create_node = graph.create_node
Expand Down
6 changes: 2 additions & 4 deletions src/switch.luau
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
if not game then script = require "test/relative-string" end

local throw = require(script.Parent.throw)
local graph = require(script.Parent.graph)
local throw = require "./throw"
local graph = require "./graph"
type Node<T> = graph.Node<T>
type SourceNode<T> = graph.SourceNode<T>
local create_node = graph.create_node
Expand Down
2 changes: 0 additions & 2 deletions src/throw.luau
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
if not game then script = require "test/relative-string" end

local function VIDE_ASSERT(msg): any
error(msg, 0)
end
Expand Down
4 changes: 1 addition & 3 deletions src/untrack.luau
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
if not game then script = require "test/relative-string" end

local graph = require(script.Parent.graph)
local graph = require "./graph"
type Node<T> = graph.Node<T>
local get_scope = graph.get_scope

Expand Down
20 changes: 10 additions & 10 deletions test/benchmark.luau
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local testkit = require("test/testkit")
local testkit = require("./testkit")
local BENCH, START = testkit.benchmark()

local vide = require "src/init"
local vide = require "../src/init"
local source = vide.source
local derive = vide.derive
local effect = vide.effect
Expand Down Expand Up @@ -200,7 +200,7 @@ end)
TITLE "property apply"

ROOT_BENCH("apply 0 properties", function()
local apply = require "src/apply"
local apply = require "../src/apply"
local instance = create("Frame") {}

for i = 1, START(N) do
Expand All @@ -209,7 +209,7 @@ ROOT_BENCH("apply 0 properties", function()
end)

ROOT_BENCH("apply 8 properties", function()
local apply = require "src/apply"
local apply = require "../src/apply"
local instance = create("Frame") {}

for i = 1, START(N) do
Expand All @@ -227,7 +227,7 @@ ROOT_BENCH("apply 8 properties", function()
end)

ROOT_BENCH("bind property", function()
local apply = require "src/apply"
local apply = require "../src/apply"

local instance = create("Frame") {}
local src = source(1)
Expand All @@ -242,7 +242,7 @@ ROOT_BENCH("bind property", function()
end)

ROOT_BENCH("update binding", function()
local apply = require "src/apply"
local apply = require "../src/apply"

local instance = create("Frame") {}
local src = source(1)
Expand Down Expand Up @@ -512,8 +512,8 @@ do
-- the purpose of the two following benchmarks is to measure the overhead of
-- aggregate construction
ROOT_BENCH("set explicit mock vector2", function()
local apply = require "src/apply"
local Vector2 = require "test/mock".Vector2
local apply = require "../src/apply"
local Vector2 = require "../test/mock".Vector2

local label = create "TextLabel" {
AnchorPoint = Vector2.new(1, 1)
Expand All @@ -527,8 +527,8 @@ do
end)

ROOT_BENCH("set aggregate mock vector2", function()
local apply = require "src/apply"
local Vector2 = require "test/mock".Vector2
local apply = require "../src/apply"
local Vector2 = require "../test/mock".Vector2

local label = create "TextLabel" {
AnchorPoint = Vector2.new(1, 1)
Expand Down
4 changes: 2 additions & 2 deletions test/spring-test.luau
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local vide = require "src/init"
local testkit = require("test/testkit")
local vide = require "../src/init"
local testkit = require("../test/testkit")

local program_time = os.clock()

Expand Down
Loading

0 comments on commit 5abd5ee

Please sign in to comment.