From f82cb6d1633ed84c8b71a286f5f8083e864d56e8 Mon Sep 17 00:00:00 2001 From: forgejo-actions <+forgejo-actions@users.noreply.github.com> Date: Sun, 8 Jun 2025 00:11:16 +0000 Subject: [PATCH] Sync to upstream Jecs 0.6.0-nightly.20250608T001058Z --- jecs/addons/observers.luau | 76 +++++++++++++++++++------------------- jecs/build.txt | 4 +- jecs/jecs.luau | 70 +++++++++++++++++------------------ jecs/pesde-rbx.toml | 2 +- jecs/pesde.toml | 2 +- jecs/test.txt | 2 +- jecs/test_fulllog.txt | 8 ++-- jecs/wally.toml | 2 +- 8 files changed, 83 insertions(+), 83 deletions(-) diff --git a/jecs/addons/observers.luau b/jecs/addons/observers.luau index 809d32e..e2e18e7 100644 --- a/jecs/addons/observers.luau +++ b/jecs/addons/observers.luau @@ -1,26 +1,22 @@ local jecs = require("@jecs") -type Observer = { - callback: (jecs.Entity) -> (), - query: jecs.Query<...any>, -} - -type Monitor = { - callback: (jecs.Entity, jecs.Entity) -> (), - query: jecs.Query -} - export type PatchedWorld = jecs.World & { added: (PatchedWorld, jecs.Id, (e: jecs.Entity, id: jecs.Id, value: T) -> ()) -> () -> (), removed: (PatchedWorld, jecs.Id, (e: jecs.Entity, id: jecs.Id) -> ()) -> () -> (), changed: (PatchedWorld, jecs.Id, (e: jecs.Entity, id: jecs.Id, value: T) -> ()) -> () -> (), - observer: (PatchedWorld, Observer) -> (), - monitor: (PatchedWorld, Monitor) -> (), + observer: ( + PatchedWorld, + any, + (jecs.Entity) -> () + ) -> (), + monitor: ( + PatchedWorld, + any, + (jecs.Entity, jecs.Id) -> () + ) -> () } -local function observers_new(world, description) - local query = description.query - local callback = description.callback +local function observers_new(world, query, callback) local terms = query.filter_with :: { jecs.Id } if not terms then local ids = query.ids @@ -94,9 +90,7 @@ local function join(world, component) end end -local function monitors_new(world, description) - local query = description.query - local callback = description.callback +local function monitors_new(world, query, callback) local terms = query.filter_with :: { jecs.Id } if not terms then local ids = query.ids @@ -131,7 +125,8 @@ local function monitors_new(world, description) local archetype = r.archetype if jecs.query_match(query, archetype) then - callback(entity, jecs.OnRemove) + local EcsOnRemove = jecs.OnRemove :: jecs.Id + callback(entity, EcsOnRemove) end end @@ -162,7 +157,7 @@ local function observers_add(world: jecs.World): PatchedWorld listeners = {} signals.added[component] = listeners - local function on_add(entity: number, id: number, value: any) + local function on_add(entity, id, value) for _, listener in listeners :: any do listener(entity, id, value) end @@ -170,13 +165,14 @@ local function observers_add(world: jecs.World): PatchedWorld local existing_hook = world:get(component, jecs.OnAdd) if existing_hook then table.insert(listeners, existing_hook) - local idr = world.component_index[component] - if idr then - idr.hooks.on_add = on_add - end end - world:set(component, jecs.OnAdd, on_add) + local idr = world.component_index[component] + if idr then + idr.hooks.on_add = on_add + else + world:set(component, jecs.OnAdd, on_add) + end end table.insert(listeners, fn) return function() @@ -196,7 +192,7 @@ local function observers_add(world: jecs.World): PatchedWorld if not listeners then listeners = {} signals.emplaced[component] = listeners - local function on_change(entity: number, id: number, value: any) + local function on_change(entity, id, value: any) for _, listener in listeners :: any do listener(entity, id, value) end @@ -204,12 +200,13 @@ local function observers_add(world: jecs.World): PatchedWorld local existing_hook = world:get(component, jecs.OnChange) if existing_hook then table.insert(listeners, existing_hook) - local idr = world.component_index[component] - if idr then - idr.hooks.on_change = on_change - end end - world:set(component, jecs.OnChange, on_change) + local idr = world.component_index[component] + if idr then + idr.hooks.on_change = on_change + else + world:set(component, jecs.OnChange, on_change) + end end table.insert(listeners, fn) return function() @@ -229,23 +226,26 @@ local function observers_add(world: jecs.World): PatchedWorld if not listeners then listeners = {} signals.removed[component] = listeners - local function on_remove(entity: number, id: number, value: any) + local function on_remove(entity, id) for _, listener in listeners :: any do - listener(entity, id, value) + listener(entity, id) end end local existing_hook = world:get(component, jecs.OnRemove) if existing_hook then table.insert(listeners, existing_hook) - local idr = world.component_index[component] - if idr then - idr.hooks.on_remove = on_remove - end end - world:set(component, jecs.OnRemove, on_remove) + local idr = world.component_index[component] + if idr then + idr.hooks.on_remove = on_remove + else + world:set(component, jecs.OnRemove, on_remove) + end end + table.insert(listeners, fn) + return function() local n = #listeners local i = table.find(listeners, fn) diff --git a/jecs/build.txt b/jecs/build.txt index 57110df..bc0a745 100644 --- a/jecs/build.txt +++ b/jecs/build.txt @@ -1,2 +1,2 @@ -modified = [".luaurc", "jecs.luau"] -version = "0.6.0-nightly.20250606T001110Z" +modified = ["addons/observers.luau", "jecs.luau"] +version = "0.6.0-nightly.20250608T001058Z" diff --git a/jecs/jecs.luau b/jecs/jecs.luau index 798052b..e5faf96 100644 --- a/jecs/jecs.luau +++ b/jecs/jecs.luau @@ -1,4 +1,3 @@ - --!optimize 2 --!native --!strict @@ -95,30 +94,31 @@ type ecs_world_t = { observable: Map>, } -local HI_COMPONENT_ID = _G.__JECS_HI_COMPONENT_ID or 256 -- stylua: ignore start -local EcsOnAdd = HI_COMPONENT_ID + 1 -local EcsOnRemove = HI_COMPONENT_ID + 2 -local EcsOnChange = HI_COMPONENT_ID + 3 -local EcsWildcard = HI_COMPONENT_ID + 4 -local EcsChildOf = HI_COMPONENT_ID + 5 -local EcsComponent = HI_COMPONENT_ID + 6 -local EcsOnDelete = HI_COMPONENT_ID + 7 -local EcsOnDeleteTarget = HI_COMPONENT_ID + 8 -local EcsDelete = HI_COMPONENT_ID + 9 -local EcsRemove = HI_COMPONENT_ID + 10 -local EcsName = HI_COMPONENT_ID + 11 -local EcsOnArchetypeCreate = HI_COMPONENT_ID + 12 -local EcsOnArchetypeDelete = HI_COMPONENT_ID + 13 -local EcsRest = HI_COMPONENT_ID + 14 -local ECS_ID_DELETE = 0b01 -local ECS_ID_IS_TAG = 0b10 -local ECS_ID_MASK = 0b00 +local ECS_ENTITY_MASK = bit32.lshift(1, 24) +local ECS_GENERATION_MASK = bit32.lshift(1, 16) +local ECS_PAIR_OFFSET = 2^48 -local ECS_ENTITY_MASK = bit32.lshift(1, 24) -local ECS_GENERATION_MASK = bit32.lshift(1, 16) -local ECS_PAIR_OFFSET = 2^48 +local ECS_ID_DELETE = 0b01 +local ECS_ID_IS_TAG = 0b10 +local ECS_ID_MASK = 0b00 + +local HI_COMPONENT_ID = 256 +local EcsOnAdd = HI_COMPONENT_ID + 1 +local EcsOnRemove = HI_COMPONENT_ID + 2 +local EcsOnChange = HI_COMPONENT_ID + 3 +local EcsWildcard = HI_COMPONENT_ID + 4 +local EcsChildOf = HI_COMPONENT_ID + 5 +local EcsComponent = HI_COMPONENT_ID + 6 +local EcsOnDelete = HI_COMPONENT_ID + 7 +local EcsOnDeleteTarget = HI_COMPONENT_ID + 8 +local EcsDelete = HI_COMPONENT_ID + 9 +local EcsRemove = HI_COMPONENT_ID + 10 +local EcsName = HI_COMPONENT_ID + 11 +local EcsOnArchetypeCreate = HI_COMPONENT_ID + 12 +local EcsOnArchetypeDelete = HI_COMPONENT_ID + 13 +local EcsRest = HI_COMPONENT_ID + 14 local NULL_ARRAY = table.freeze({}) :: Column local NULL = newproxy(false) @@ -2655,19 +2655,19 @@ return { meta = (ECS_META :: any) :: (id: Entity, id: Id, value: T) -> Entity, is_tag = (ecs_is_tag :: any) :: (World, Id) -> boolean, - OnAdd = EcsOnAdd :: Entity<(entity: Entity, id: Id, data: T) -> ()>, - OnRemove = EcsOnRemove :: Entity<(entity: Entity, id: Id) -> ()>, - OnChange = EcsOnChange :: Entity<(entity: Entity, id: Id, data: T) -> ()>, - ChildOf = EcsChildOf :: Entity, - Component = EcsComponent :: Entity, - Wildcard = EcsWildcard :: Entity, - w = EcsWildcard :: Entity, - OnDelete = EcsOnDelete :: Entity, - OnDeleteTarget = EcsOnDeleteTarget :: Entity, - Delete = EcsDelete :: Entity, - Remove = EcsRemove :: Entity, - Name = EcsName :: Entity, - Rest = EcsRest :: Entity, + OnAdd = (EcsOnAdd :: any) :: Entity<(entity: Entity, id: Id, data: T) -> ()>, + OnRemove = (EcsOnRemove :: any) :: Entity<(entity: Entity, id: Id) -> ()>, + OnChange = (EcsOnChange :: any) :: Entity<(entity: Entity, id: Id, data: T) -> ()>, + ChildOf = (EcsChildOf :: any) :: Entity, + Component = (EcsComponent :: any) :: Entity, + Wildcard = (EcsWildcard :: any) :: Entity, + w = (EcsWildcard :: any) :: Entity, + OnDelete = (EcsOnDelete :: any) :: Entity, + OnDeleteTarget = (EcsOnDeleteTarget :: any) :: Entity, + Delete = (EcsDelete :: any) :: Entity, + Remove = (EcsRemove :: any) :: Entity, + Name = (EcsName :: any) :: Entity, + Rest = (EcsRest :: any) :: Entity, pair = (ECS_PAIR :: any) :: (first: Id

, second: Id) -> Pair, diff --git a/jecs/pesde-rbx.toml b/jecs/pesde-rbx.toml index dbe42e4..2ccb5a5 100644 --- a/jecs/pesde-rbx.toml +++ b/jecs/pesde-rbx.toml @@ -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.6.0-nightly.20250606T001110Z" +version = "0.6.0-nightly.20250608T001058Z" [indices] default = "https://github.com/pesde-pkg/index" diff --git a/jecs/pesde.toml b/jecs/pesde.toml index 22d87af..05676ef 100644 --- a/jecs/pesde.toml +++ b/jecs/pesde.toml @@ -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.6.0-nightly.20250606T001110Z" +version = "0.6.0-nightly.20250608T001058Z" [indices] default = "https://github.com/pesde-pkg/index" diff --git a/jecs/test.txt b/jecs/test.txt index cd0701e..7f98462 100644 --- a/jecs/test.txt +++ b/jecs/test.txt @@ -1,2 +1,2 @@ passed = true -timestamp = "20250607T001059Z" +timestamp = "20250608T001100Z" diff --git a/jecs/test_fulllog.txt b/jecs/test_fulllog.txt index ec58f36..0f76031 100644 --- a/jecs/test_fulllog.txt +++ b/jecs/test_fulllog.txt @@ -1,6 +1,6 @@ -7.3 us  3 kB│ delete children of entity -9.1 us  1 kB│ remove friends of entity -342 ns  10  B│ simple deletion of entity +7.2 us  2 kB│ delete children of entity +8.9 us  1 kB│ remove friends of entity +342 ns  0  B│ simple deletion of entity repro NONE│  @@ -121,5 +121,5 @@ PASS│ #2 PASS│ #3 -74/74 test cases passed in 32.356 ms. +74/74 test cases passed in 30.541 ms. 0 fails diff --git a/jecs/wally.toml b/jecs/wally.toml index 189b427..9654f72 100644 --- a/jecs/wally.toml +++ b/jecs/wally.toml @@ -5,4 +5,4 @@ license = "MIT" name = "mark-marks/jecs-nightly" realm = "shared" registry = "https://github.com/UpliftGames/wally-index" -version = "0.6.0-nightly.20250606T001110Z" +version = "0.6.0-nightly.20250608T001058Z"