Compare commits

..

1 commit

Author SHA1 Message Date
forgejo-actions
afe56ce755 Sync to upstream Jecs 0.5.5-nightly.20250312T202956Z 2025-03-24 00:11:12 +00:00
13 changed files with 691 additions and 895 deletions

View file

@ -23,7 +23,7 @@ jobs:
- name: Install Luau
uses: https://github.com/EncodedVenom/install-luau@v4.3
with:
version: "0.668"
version: "latest"
verbose: "true"
- name: Install forgejo-cli

View file

@ -4,7 +4,6 @@
"testkit": "tools/testkit",
"mirror": "mirror",
"tools": "tools",
"addons": "addons",
},
"languageMode": "strict"
}

View file

@ -11,46 +11,29 @@ The format is based on [Keep a Changelog][kac], and this project adheres to
## [Unreleased]
- `[world]`:
- Changed `world:clear` to also look through the component record for the cleared `ID`
- Removes the cleared ID from every entity that has it
- Changed entity ID layouts by putting the index in the lower bits, which should make every world function 1-5 nanoseconds faster
- Fixed `world:delete` not removing every pair with an unalive target
- Specifically happened when you had at least two pairs of different relations with multiple targets each
- `[hooks]`:
- Replaced `OnSet` with `OnChange`
- The former was used to detect emplace/move actions. Now the behaviour for `OnChange` is that it will run only when the value has changed
- Changed `OnAdd` to specifically run after the data has been set for non-zero-sized components. Also returns the value that the component was set to
- This should allow a more lenient window for modifying data
- Changed `OnRemove` to lazily lookup which archetype the entity will move to
- Can now have interior structural changes within `OnRemove` hooks
- 16% faster `world:get`
- `world:has` no longer typechecks components after the 8th one.
- `[typescript]`
## [0.5.0] - 2024-12-26
- Fixed Entity type to default to `undefined | unknown` instead of just `undefined`
- `[world]`:
- Fixed `world:target` not giving adjacent pairs
- Added `world:each` to find entities with a specific Tag
- Added `world:children` to find children of entity
- `[query]`:
- Added `query:cached`
- Adds query cache that updates itself when an archetype matching the query gets created or deleted.
- `[luau]`:
- Changed how entities' types are inferred with user-defined type functions
- Changed `Pair<First, Second>` to return `Second` if `First` is a `Tag`; otherwise, returns `First`.
## [0.4.0] - 2024-11-17
- `[world]`:
- Added recycling to `world:entity`
- If you see much larger entity ids, that is because its generation has been incremented
- `[query]`:
- Removed `query:drain`
- The default behaviour is simply to drain the iterator
- Removed `query:next`
- Just call the iterator function returned by `query:iter` directly if you want to get the next results
- Removed `query:replace`
- `[luau]`:
- Fixed `query:archetypes` not taking `self`
- Changed so that the `jecs.Pair` type now returns the first element's type so you won't need to typecast anymore.
- Fixed bug where `world:clear` did not invoke `jecs.OnRemove` hooks
- Changed `query.__iter` to drain on iteration
- It will initialize once wherever you left iteration off at last time
- Changed `query:iter` to restart the iterator
- Removed `query:drain` and `query:next`
- If you want to get individual results outside of a for-loop, you need to call `query:iter` to initialize the iterator and then call the iterator function manually
```lua
local it = world:query(A, B, C):iter()
local entity, a, b, c = it()
entity, a, b, c = it() -- get next results
```
- `[world`
- Fixed a bug with `world:clear` not invoking `jecs.OnRemove` hooks
- `[typescript]`:
- Changed pair to accept generics
- Improved handling of Tags
## [0.3.2] - 2024-10-01

View file

@ -1,157 +0,0 @@
local jecs = require("@jecs")
local testkit = require("@testkit")
local function observers_new(world, description)
local query = description.query
local callback = description.callback
local terms = query.filter_with
if not terms then
local ids = query.ids
query.filter_with = ids
terms = ids
end
local entity_index = world.entity_index
local function emplaced(entity)
local r = jecs.entity_index_try_get_fast(
entity_index, entity)
if not r then
return
end
local archetype = r.archetype
if jecs.query_match(query, archetype) then
callback(entity)
end
end
for _, term in terms do
world:added(term, emplaced)
world:changed(term, emplaced)
end
end
local function world_track(world, ...)
local entity_index = world.entity_index
local terms = { ... }
local q_shim = { filter_with = terms }
local n = 0
local dense_array = {}
local sparse_array = {}
local function emplaced(entity)
local r = jecs.entity_index_try_get_fast(
entity_index, entity)
if not r then
return
end
local archetype = r.archetype
if jecs.query_match(q_shim :: any, archetype) then
n += 1
dense_array[n] = entity
sparse_array[entity] = n
end
end
local function removed(entity)
local i = sparse_array[entity]
if i ~= n then
dense_array[i] = dense_array[n]
end
dense_array[n] = nil
end
for _, term in terms do
world:added(term, emplaced)
world:changed(term, emplaced)
end
local function iter()
local i = n
return function()
local row = i
if row == 0 then
return nil
end
i -= 1
return dense_array[row] :: any
end
end
local it = {
__iter = iter,
without = function(self, ...)
q_shim.filter_without = { ... }
return self
end
}
return setmetatable(it, it)
end
local function observers_add(world)
local signals = {
added = {},
emplaced = {},
removed = {}
}
world.added = function(_, component, fn)
local listeners = signals.added[component]
if not listeners then
listeners = {}
signals.added[component] = listeners
local idr = jecs.id_record_ensure(world, component)
idr.hooks.on_add = function(entity)
for _, listener in listeners do
listener(entity)
end
end
end
table.insert(listeners, fn)
end
world.changed = function(_, component, fn)
local listeners = signals.emplaced[component]
if not listeners then
listeners = {}
signals.emplaced[component] = listeners
local idr = jecs.id_record_ensure(world, component)
idr.hooks.on_change = function(entity, value)
for _, listener in listeners do
listener(entity, value)
end
end
end
table.insert(listeners, fn)
end
world.removed = function(_, component, fn)
local listeners = signals.removed[component]
if not listeners then
listeners = {}
signals.removed[component] = listeners
local idr = jecs.id_record_ensure(world, component)
idr.hooks.on_remove = function(entity)
for _, listener in listeners do
listener(entity)
end
end
end
table.insert(listeners, fn)
end
world.signals = signals
world.track = world_track
world.observer = observers_new
return world
end
return observers_add

View file

@ -1,2 +1,2 @@
modified = ["addons/observers.luau", ".luaurc", "CHANGELOG.md", "jecs.luau"]
version = "0.5.5-nightly.20250412T181729Z"
modified = [".luaurc", "jecs.luau"]
version = "0.5.5-nightly.20250312T202956Z"

File diff suppressed because it is too large Load diff

View file

@ -3,7 +3,7 @@ includes = ["init.luau", "pesde.toml", "README.md", "CHANGELOG.md", "LICENSE", "
license = "MIT"
name = "marked/jecs_nightly"
repository = "https://git.devmarked.win/marked/jecs-nightly"
version = "0.5.5-nightly.20250412T181729Z"
version = "0.5.5-nightly.20250312T202956Z"
[indices]
default = "https://github.com/pesde-pkg/index"

View file

@ -3,7 +3,7 @@ includes = ["init.luau", "pesde.toml", "README.md", "CHANGELOG.md", "LICENSE", "
license = "MIT"
name = "marked/jecs_nightly"
repository = "https://git.devmarked.win/marked/jecs-nightly"
version = "0.5.5-nightly.20250412T181729Z"
version = "0.5.5-nightly.20250312T202956Z"
[indices]
default = "https://github.com/pesde-pkg/index"

View file

@ -1,2 +1,2 @@
passed = true
timestamp = "20250412T181730Z"
timestamp = "20250324T001101Z"

View file

@ -1,72 +1,17 @@
*created e271v0
*created e272v0
*created e273v0
*created e274v0
*created e275v0
*created e276v0
*created e277v0
*created e278v0
*created e279v0
*created e280v0
|-alive--|
| e271v0 |
|--------|
| e272v0 |
|--------|
| e273v0 |
|--------|
| e274v0 |
|--------|
| e275v0 |
|--------|
| e276v0 |
|--------|
| e277v0 |
|--------|
| e278v0 |
|--------|
| e279v0 |
|--------|
| e280v0 |
|--------|
*deleted e270v0
*deleted e271v0
*deleted e272v0
*deleted e273v0
*deleted e274v0
*deleted e275v0
*deleted e274v1
*deleted e273v1
*deleted e272v1
*deleted e271v1
*deleted e270v1
----idempotent
1_2
1_2
7.1 us  1 kB│ delete children of entity
9.2 us  1 kB│ remove friends of entity
346 ns  0  B│ simple deletion of entity
the great reset
PASS│ 
#repro3
PASS│ should add the correct ModelBase for parts
PASS│ should add the correct ModelBase for parts
PASS│ 
#adding a recycled target
PASS│ 
#repro2
PASS│ 
another
PASS│ 
271 272 273
---------------- delete e2 ---------------
"268439800_268439816_536875256_536875272"
"268439800_268439816_536875256"
"268439816_536875272"
"268439816"
-----------------------------
{}
7.7 us  2 kB│ delete children of entity
 11 us  2 kB│ remove friends of entity
321 ns  0  B│ simple deletion of entity
removing
#repro
PASS│ 
NONE│ 
archetype
PASS│ 
@ -107,7 +52,7 @@
PASS│ should allow wildcards in queries
PASS│ should match against multiple pairs
PASS│ should only relate alive entities
PASS│ should error when setting invalid pair
NONE│ should error when setting invalid pair
PASS│ should find target for ChildOf
PASS│ despawning while iterating
NONE│ iterator invalidation
@ -124,7 +69,7 @@
world:clear()
PASS│ should remove its components
PASS│ remove cleared ID from entities
PASS│ should move last record
world:has()
PASS│ should find Tag on entity
@ -141,7 +86,6 @@
PASS│ should allow deleting components
PASS│ delete entities using another Entity as component with Delete cleanup action
PASS│ delete children
PASS│ remove deleted ID from entities
PASS│ fast delete
PASS│ cycle
@ -177,5 +121,5 @@
PASS│ #2
PASS│ #3
77/77 test cases passed in 29.411 ms.
69/69 test cases passed in 31.149 ms.
0 fails

View file

@ -5,4 +5,4 @@ license = "MIT"
name = "mark-marks/jecs-nightly"
realm = "shared"
registry = "https://github.com/UpliftGames/wally-index"
version = "0.5.5-nightly.20250412T181729Z"
version = "0.5.5-nightly.20250312T202956Z"

View file

@ -27,14 +27,9 @@ local function sync(to: string): result.Identity<boolean>
fs.writeDir(to)
end
if not fs.metadata(`{to}/addons`).exists then
fs.writeDir(`{to}/addons`)
end
progress:nextStage() -- fetch
local includes = {
"addons/observers.luau",
"jecs.luau",
"README.md",
"CHANGELOG.md",

View file

@ -46,23 +46,23 @@ local function test(origin: string): result.Identity<boolean>
progress:nextStage() -- fetch
local includes = {
"tools/testkit.luau",
"tools/runtime_lints.luau",
"tools/lifetime_tracker.luau",
"tools/entity_visualiser.luau",
"test/tests.luau",
}
for _, file in includes do
local contents = shared.fetch_raw(file)
do
local contents = shared.fetch_raw("tools/testkit.luau")
if not contents.ok then
progress:stop()
stdio.ewrite(`🔥 Couldn't get the latest source for {file}:\n{contents.err}\n`)
return result(false, `Couldn't get the latest source for {file}.`)
stdio.ewrite(`🔥 Couldn't get the latest source for tools/testkit.luau:\n{contents.err}\n`)
return result(false, "Couldn't get the latest source for tools/testkit.luau.")
end
fs.writeFile(`{origin}/{file}`, contents.val)
fs.writeFile(`{origin}/tools/testkit.luau`, contents.val)
end
do
local contents = shared.fetch_raw("test/tests.luau")
if not contents.ok then
progress:stop()
stdio.ewrite(`🔥 Couldn't get the latest source for test/tests.luau:\n{contents.err}\n`)
return result(false, "Couldn't get the latest source for test/tests.luau.")
end
fs.writeFile(`{origin}/test/tests.luau`, contents.val)
end
progress:nextStage() -- test