aiecsjs 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/README_ZHTW.md +2 -2
- package/dist/{chunk-QC25WDOZ.js → chunk-2E3GMRF5.js} +2 -2
- package/dist/{chunk-QC25WDOZ.js.map → chunk-2E3GMRF5.js.map} +1 -1
- package/dist/{chunk-I2SPFVXH.cjs → chunk-FEICW2CS.cjs} +2 -2
- package/dist/{chunk-I2SPFVXH.cjs.map → chunk-FEICW2CS.cjs.map} +1 -1
- package/dist/{chunk-I726BP65.cjs → chunk-P2KTJ2NQ.cjs} +2 -2
- package/dist/{chunk-I726BP65.cjs.map → chunk-P2KTJ2NQ.cjs.map} +1 -1
- package/dist/{chunk-LU55S4LK.js → chunk-Q55M3YEQ.js} +2 -2
- package/dist/{chunk-LU55S4LK.js.map → chunk-Q55M3YEQ.js.map} +1 -1
- package/dist/{chunk-7O3CM4D2.cjs → chunk-RNWXP3GU.cjs} +2 -2
- package/dist/{chunk-7O3CM4D2.cjs.map → chunk-RNWXP3GU.cjs.map} +1 -1
- package/dist/{chunk-BUFJWGRQ.js → chunk-WZMRKSK5.js} +2 -2
- package/dist/{chunk-BUFJWGRQ.js.map → chunk-WZMRKSK5.js.map} +1 -1
- package/dist/commands.cjs +1 -1
- package/dist/commands.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/observers.cjs +1 -1
- package/dist/observers.js +1 -1
- package/dist/relations.cjs +1 -1
- package/dist/relations.js +1 -1
- package/dist/serialize.cjs +1 -1
- package/dist/serialize.js +1 -1
- package/dist/worker.cjs +1 -1
- package/dist/worker.js +1 -1
- package/llms-full.txt +13 -3
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internal/query.ts"],"names":["nextQueryId","moduleQueryCache","descKey","d","all","c","a","b","any","none","defineQuery","arg","desc","key","cached","q","enterQuery","query","reactive","exitQuery","ensureQueryRegistered","state","ww","withMask","createMask","anyMask","noneMask","compId","info","getComponentInfoById","bit","getOrRegisterComponentBit","setBit","bundle","isMaskZero","involvedBits","listBits","s","getQueryArchetypes","words","list","i","arch","matches","queryArchetypes","world","getWorldState","ids","out","id","runQuery","buf","e","archIds","r","iterQuery","src","forEachEntity","fn","cols","buildColumnViews","callWithCols","ents","n","eid","comp","getComponentInfo","storage","recordEntityMaskChange","changedBit","prevMask","nextMask","involved","qid","wasMatch","isMatch","pushReactive","queryId","kind","ensureReactiveBuffer","componentId","lazyGetComponentInfo","_getComponentInfoFn","registerComponentLookup"],"mappings":"uEAsBA,IAAIA,EAAc,CAAA,CACZC,CAAAA,CAAmB,IAAI,GAAA,CAE7B,SAASC,CAAAA,CAAQC,CAAAA,CAA4B,CAC3C,IAAMC,GAAOD,CAAAA,CAAE,GAAA,EAAO,EAAC,EACpB,GAAA,CAAKE,GAAMA,CAAAA,CAAE,IAAI,CAAA,CACjB,IAAA,CAAK,CAACC,CAAAA,CAAGC,CAAAA,GAAMD,EAAIC,CAAC,CAAA,CACpB,KAAK,GAAG,CAAA,CACLC,CAAAA,CAAAA,CAAOL,CAAAA,CAAE,KAAO,EAAC,EACpB,IAAKE,CAAAA,EAAMA,CAAAA,CAAE,IAAI,CAAA,CACjB,IAAA,CAAK,CAACC,CAAAA,CAAGC,IAAMD,CAAAA,CAAIC,CAAC,EACpB,IAAA,CAAK,GAAG,EACLE,CAAAA,CAAAA,CAAQN,CAAAA,CAAE,IAAA,EAAQ,IACrB,GAAA,CAAKE,CAAAA,EAAMA,EAAE,IAAI,CAAA,CACjB,KAAK,CAACC,CAAAA,CAAGC,CAAAA,GAAMD,CAAAA,CAAIC,CAAC,CAAA,CACpB,IAAA,CAAK,GAAG,CAAA,CACX,OAAO,IAAIH,CAAG,CAAA,EAAA,EAAKI,CAAG,CAAA,EAAA,EAAKC,CAAI,CAA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A,GAAS,OAAA,CAAS3B,EAAI,OAAA,CAAQ,IAAA,CAAKa,CAAa,CAAA,CAC/Cb,CAAAA,CAAI,OAAO,IAAA,CAAKa,CAAa,EACpC,CACF,CAEA,SAASe,CAAAA,CAAqB1D,EAAmBoD,CAAAA,CAA6B,CAC5E,IAAItB,CAAAA,CAAM9B,CAAAA,CAAM,eAAA,CAAgB,GAAA,CAAIoD,CAAG,CAAA,CACvC,OAAKtB,IACHA,CAAAA,CAAM,CAAE,QAAS,EAAC,CAAG,MAAA,CAAQ,EAAG,CAAA,CAChC9B,CAAAA,CAAM,gBAAgB,GAAA,CAAIoD,CAAAA,CAAKtB,CAAG,CAAA,CAAA,CAE7BA,CACT,CAIA,SAAStB,EAAqBmD,CAAAA,CAAoC,CAEhE,IAAMpD,CAAAA,CAAOqD,CAAAA,CAAqBD,CAAW,CAAA,CAC7C,GAAI,CAACpD,CAAAA,CAAM,MAAM,IAAI,KAAA,CAAM,yBAAyBoD,CAAW,CAAA,eAAA,CAAiB,EAChF,OAAOpD,CACT,CAEA,IAAIsD,EAA0E,IAAA,CACvE,SAASC,EAAwBzB,CAAAA,CAAqD,CAC3FwB,EAAsBxB,EACxB,CACA,SAASuB,CAAAA,CAAqBhC,EAAuC,CACnE,OAAOiC,EAAsBA,CAAAA,CAAoBjC,CAAE,EAAI,MACzD","file":"chunk-LU55S4LK.js","sourcesContent":["import { createMask, isMaskZero, listBits, matches, setBit } from './bitmask.js'\nimport { getComponentInfo } from './component.js'\nimport type {\n Archetype,\n ComponentInfo,\n ComponentLike,\n EntityId,\n Query,\n QueryDescriptor,\n QueryInternal,\n QueryMaskBundle,\n ReactiveBuffer,\n World,\n WorldState,\n} from './types.js'\nimport {\n getOrRegisterComponentBit,\n getWorldState,\n readEntityMask,\n tryGetComponentBit,\n} from './world.js'\n\nlet nextQueryId = 1\nconst moduleQueryCache = new Map<string, QueryInternal>()\n\nfunction descKey(d: QueryDescriptor): string {\n const all = (d.all ?? [])\n .map((c) => c.__id)\n .sort((a, b) => a - b)\n .join('-')\n const any = (d.any ?? [])\n .map((c) => c.__id)\n .sort((a, b) => a - b)\n .join('-')\n const none = (d.none ?? [])\n .map((c) => c.__id)\n .sort((a, b) => a - b)\n .join('-')\n return `A${all}|Y${any}|N${none}`\n}\n\nexport function defineQuery(arg: ComponentLike[] | QueryDescriptor): Query {\n const desc: QueryDescriptor = Array.isArray(arg) ? { all: arg } : arg\n\n // Validate all members are components\n for (const c of [...(desc.all ?? []), ...(desc.any ?? []), ...(desc.none ?? [])]) {\n if (!c || typeof c !== 'object' || typeof (c as any).__id !== 'number') {\n throw new TypeError('aiecsjs: defineQuery received a non-component value')\n }\n }\n\n const key = descKey(desc)\n const cached = moduleQueryCache.get(key)\n if (cached) return cached\n\n const q: QueryInternal = {\n id: nextQueryId++,\n mask: [],\n all: (desc.all ?? []).map((c) => c.__id),\n any: (desc.any ?? []).map((c) => c.__id),\n none: (desc.none ?? []).map((c) => c.__id),\n columnViewCache: [...(desc.all ?? []), ...(desc.any ?? [])],\n reactiveKind: 'normal',\n sourceQueryId: -1,\n sourceQuery: null,\n }\n moduleQueryCache.set(key, q)\n return q\n}\n\nexport function enterQuery(query: Query): Query {\n const q = query as QueryInternal\n const key = `enter:${q.id}`\n const cached = moduleQueryCache.get(key)\n if (cached) return cached\n const reactive: QueryInternal = {\n id: nextQueryId++,\n mask: [],\n all: q.all,\n any: q.any,\n none: q.none,\n columnViewCache: q.columnViewCache,\n reactiveKind: 'enter',\n sourceQueryId: q.id,\n sourceQuery: q,\n }\n moduleQueryCache.set(key, reactive)\n return reactive\n}\n\nexport function exitQuery(query: Query): Query {\n const q = query as QueryInternal\n const key = `exit:${q.id}`\n const cached = moduleQueryCache.get(key)\n if (cached) return cached\n const reactive: QueryInternal = {\n id: nextQueryId++,\n mask: [],\n all: q.all,\n any: q.any,\n none: q.none,\n columnViewCache: q.columnViewCache,\n reactiveKind: 'exit',\n sourceQueryId: q.id,\n sourceQuery: q,\n }\n moduleQueryCache.set(key, reactive)\n return reactive\n}\n\n// --- Per-world query setup ---\n\nfunction ensureQueryRegistered(state: WorldState, q: QueryInternal): void {\n if (state.queries[q.id] === q && state.queryMasks.has(q.id)) return\n\n // Build per-world bitmasks (this may register new bits)\n const ww = state.options.maskWordCount\n const withMask = createMask(ww)\n const anyMask = createMask(ww)\n const noneMask = createMask(ww)\n for (const compId of q.all) {\n const info = getComponentInfoById(compId)\n const bit = getOrRegisterComponentBit(state, info)\n setBit(withMask, bit)\n }\n for (const compId of q.any) {\n const info = getComponentInfoById(compId)\n const bit = getOrRegisterComponentBit(state, info)\n setBit(anyMask, bit)\n }\n for (const compId of q.none) {\n const info = getComponentInfoById(compId)\n const bit = getOrRegisterComponentBit(state, info)\n setBit(noneMask, bit)\n }\n\n const bundle: QueryMaskBundle = {\n withMask,\n anyMask,\n noneMask,\n anyHasBits: !isMaskZero(anyMask),\n }\n state.queryMasks.set(q.id, bundle)\n\n state.queries[q.id] = q\n state.queryArchetypeCache[q.id] = null\n state.queryArchetypeStamp[q.id] = -1\n\n // Build bit → queries index for fast reactive lookup\n const involvedBits: number[] = [\n ...listBits(withMask),\n ...listBits(anyMask),\n ...listBits(noneMask),\n ]\n for (const b of involvedBits) {\n let s = state.bitToQueries.get(b)\n if (!s) {\n s = new Set<number>()\n state.bitToQueries.set(b, s)\n }\n s.add(q.id)\n }\n\n // Initialize reactive buffer for enter/exit queries\n if (q.reactiveKind !== 'normal') {\n if (!state.reactiveBuffers.has(q.id)) {\n state.reactiveBuffers.set(q.id, { entered: [], exited: [] })\n }\n // Also register the source query so recordEntityMaskChange will see it\n if (q.sourceQuery) ensureQueryRegistered(state, q.sourceQuery)\n }\n}\n\nfunction getQueryArchetypes(state: WorldState, q: QueryInternal): number[] {\n ensureQueryRegistered(state, q)\n if (state.queryArchetypeCache[q.id] && state.queryArchetypeStamp[q.id] === state.queryVersion) {\n return state.queryArchetypeCache[q.id]!\n }\n const bundle = state.queryMasks.get(q.id)!\n const words = state.options.maskWordCount\n const list: number[] = []\n for (let i = 0; i < state.archetypes.length; i++) {\n const arch = state.archetypes[i]!\n if (\n matches(arch.mask, bundle.withMask, bundle.anyMask, bundle.noneMask, bundle.anyHasBits, words)\n ) {\n list.push(i)\n }\n }\n state.queryArchetypeCache[q.id] = list\n state.queryArchetypeStamp[q.id] = state.queryVersion\n return list\n}\n\nexport function queryArchetypes(world: World, query: Query): readonly Archetype[] {\n const state = getWorldState(world)\n const q = query as QueryInternal\n const ids = getQueryArchetypes(state, q)\n const out: Archetype[] = []\n for (const id of ids) {\n const arch = state.archetypes[id]!\n out.push({ id: arch.id, mask: Array.from(arch.mask), size: arch.size })\n }\n return out\n}\n\nexport function runQuery(world: World, query: Query): readonly EntityId[] {\n const state = getWorldState(world)\n const q = query as QueryInternal\n const out: EntityId[] = []\n if (q.reactiveKind === 'enter') {\n const buf = state.reactiveBuffers.get(q.id)\n if (buf) {\n for (const e of buf.entered) out.push(e as EntityId)\n buf.entered.length = 0\n }\n return out\n }\n if (q.reactiveKind === 'exit') {\n const buf = state.reactiveBuffers.get(q.id)\n if (buf) {\n for (const e of buf.exited) out.push(e as EntityId)\n buf.exited.length = 0\n }\n return out\n }\n const archIds = getQueryArchetypes(state, q)\n for (const id of archIds) {\n const arch = state.archetypes[id]!\n for (let r = 0; r < arch.size; r++) {\n out.push(arch.entities[r] as EntityId)\n }\n }\n return out\n}\n\nexport function* iterQuery(world: World, query: Query): IterableIterator<EntityId> {\n const state = getWorldState(world)\n const q = query as QueryInternal\n if (q.reactiveKind !== 'normal') {\n const buf = state.reactiveBuffers.get(q.id)\n if (!buf) return\n const src = q.reactiveKind === 'enter' ? buf.entered : buf.exited\n for (const e of src) yield e as EntityId\n src.length = 0\n return\n }\n const archIds = getQueryArchetypes(state, q)\n for (const id of archIds) {\n const arch = state.archetypes[id]!\n for (let r = 0; r < arch.size; r++) {\n yield arch.entities[r] as EntityId\n }\n }\n}\n\nexport function forEachEntity(\n world: World,\n query: Query,\n fn: (eid: EntityId, ...cols: any[]) => void,\n): void {\n const state = getWorldState(world)\n const q = query as QueryInternal\n\n if (q.reactiveKind !== 'normal') {\n const buf = state.reactiveBuffers.get(q.id)\n if (!buf) return\n const src = q.reactiveKind === 'enter' ? buf.entered : buf.exited\n if (src.length === 0) return\n const cols = buildColumnViews(state, q)\n for (let i = 0; i < src.length; i++) {\n const e = src[i] as EntityId\n callWithCols(fn, e, cols)\n }\n src.length = 0\n return\n }\n\n ensureQueryRegistered(state, q)\n const archIds = getQueryArchetypes(state, q)\n const cols = buildColumnViews(state, q)\n for (const id of archIds) {\n const arch = state.archetypes[id]!\n const ents = arch.entities\n const n = arch.size\n for (let r = 0; r < n; r++) {\n callWithCols(fn, ents[r] as EntityId, cols)\n }\n }\n}\n\nfunction callWithCols(\n fn: (eid: EntityId, ...cols: any[]) => void,\n eid: EntityId,\n cols: any[],\n): void {\n // Specialise for low arities to avoid spread allocation.\n switch (cols.length) {\n case 0:\n fn(eid)\n break\n case 1:\n fn(eid, cols[0])\n break\n case 2:\n fn(eid, cols[0], cols[1])\n break\n case 3:\n fn(eid, cols[0], cols[1], cols[2])\n break\n case 4:\n fn(eid, cols[0], cols[1], cols[2], cols[3])\n break\n case 5:\n fn(eid, cols[0], cols[1], cols[2], cols[3], cols[4])\n break\n default:\n fn(eid, ...cols)\n }\n}\n\nfunction buildColumnViews(state: WorldState, q: QueryInternal): any[] {\n const out: any[] = []\n for (const comp of q.columnViewCache) {\n const info = getComponentInfo(comp)\n const bit = state.componentBitFor.get(info.id)\n if (bit === undefined) {\n out.push(undefined)\n continue\n }\n const storage = state.componentStorageByBit[bit]\n if (!storage) {\n out.push(undefined)\n continue\n }\n if (storage.kind === 'soa') out.push(storage.soa)\n else if (storage.kind === 'aos') out.push(storage.aos)\n else out.push(true) // tag\n }\n return out\n}\n\n// --- Reactive query updates (called from migration code) ---\n\nexport function recordEntityMaskChange(\n state: WorldState,\n eid: EntityId,\n changedBit: number,\n prevMask: Uint32Array,\n nextMask: Uint32Array,\n): void {\n // Lazy-register any reactive queries (and their sources) so we can correctly\n // determine match transitions even if the user only ever called enterQuery/exitQuery.\n for (const q of moduleQueryCache.values()) {\n if (q.reactiveKind === 'normal') continue\n if (q.sourceQuery && state.queries[q.sourceQuery.id] !== q.sourceQuery) {\n ensureQueryRegistered(state, q.sourceQuery)\n }\n }\n\n const involved = state.bitToQueries.get(changedBit)\n if (!involved) return\n const words = state.options.maskWordCount\n for (const qid of involved) {\n const q = state.queries[qid]\n if (!q) continue\n if (q.reactiveKind !== 'normal') continue\n const bundle = state.queryMasks.get(qid)\n if (!bundle) continue\n const wasMatch = matches(\n prevMask,\n bundle.withMask,\n bundle.anyMask,\n bundle.noneMask,\n bundle.anyHasBits,\n words,\n )\n const isMatch = matches(\n nextMask,\n bundle.withMask,\n bundle.anyMask,\n bundle.noneMask,\n bundle.anyHasBits,\n words,\n )\n if (!wasMatch && isMatch) {\n pushReactive(state, qid, 'enter', eid)\n } else if (wasMatch && !isMatch) {\n pushReactive(state, qid, 'exit', eid)\n }\n }\n}\n\nfunction pushReactive(\n state: WorldState,\n queryId: number,\n kind: 'enter' | 'exit',\n eid: EntityId,\n): void {\n // Walk the module cache (not just state.queries) so reactive variants that\n // haven't been registered with this world yet still receive events.\n for (const r of moduleQueryCache.values()) {\n if (r.sourceQueryId !== queryId) continue\n if (r.reactiveKind !== kind) continue\n // Lazily register the reactive query in this world so subsequent reads can find it\n ensureQueryRegistered(state, r)\n const buf = ensureReactiveBuffer(state, r.id)\n if (kind === 'enter') buf.entered.push(eid as number)\n else buf.exited.push(eid as number)\n }\n}\n\nfunction ensureReactiveBuffer(state: WorldState, qid: number): ReactiveBuffer {\n let buf = state.reactiveBuffers.get(qid)\n if (!buf) {\n buf = { entered: [], exited: [] }\n state.reactiveBuffers.set(qid, buf)\n }\n return buf\n}\n\n// --- Helpers ---\n\nfunction getComponentInfoById(componentId: number): ComponentInfo {\n // We need access to the component registry's lookup by id. Re-import dynamically to avoid cycles.\n const info = lazyGetComponentInfo(componentId)\n if (!info) throw new Error(`aiecsjs: component id ${componentId} not registered`)\n return info\n}\n\nlet _getComponentInfoFn: ((id: number) => ComponentInfo | undefined) | null = null\nexport function registerComponentLookup(fn: (id: number) => ComponentInfo | undefined): void {\n _getComponentInfoFn = fn\n}\nfunction lazyGetComponentInfo(id: number): ComponentInfo | undefined {\n return _getComponentInfoFn ? _getComponentInfoFn(id) : undefined\n}\n\nexport function _resetQueryRegistry_FOR_TESTS_ONLY(): void {\n moduleQueryCache.clear()\n nextQueryId = 1\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/internal/query.ts"],"names":["nextQueryId","moduleQueryCache","descKey","d","all","c","a","b","any","none","defineQuery","arg","desc","key","cached","q","enterQuery","query","reactive","exitQuery","ensureQueryRegistered","state","ww","withMask","createMask","anyMask","noneMask","compId","info","getComponentInfoById","bit","getOrRegisterComponentBit","setBit","bundle","isMaskZero","involvedBits","listBits","s","getQueryArchetypes","words","list","i","arch","matches","queryArchetypes","world","getWorldState","ids","out","id","runQuery","buf","e","archIds","r","iterQuery","src","forEachEntity","fn","cols","buildColumnViews","callWithCols","ents","n","eid","comp","getComponentInfo","storage","recordEntityMaskChange","changedBit","prevMask","nextMask","involved","qid","wasMatch","isMatch","pushReactive","queryId","kind","ensureReactiveBuffer","componentId","lazyGetComponentInfo","_getComponentInfoFn","registerComponentLookup"],"mappings":"uEAsBA,IAAIA,EAAc,CAAA,CACZC,CAAAA,CAAmB,IAAI,GAAA,CAE7B,SAASC,CAAAA,CAAQC,CAAAA,CAA4B,CAC3C,IAAMC,GAAOD,CAAAA,CAAE,GAAA,EAAO,EAAC,EACpB,GAAA,CAAKE,GAAMA,CAAAA,CAAE,IAAI,CAAA,CACjB,IAAA,CAAK,CAACC,CAAAA,CAAGC,CAAAA,GAAMD,EAAIC,CAAC,CAAA,CACpB,KAAK,GAAG,CAAA,CACLC,CAAAA,CAAAA,CAAOL,CAAAA,CAAE,KAAO,EAAC,EACpB,IAAKE,CAAAA,EAAMA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","file":"chunk-Q55M3YEQ.js","sourcesContent":["import { createMask, isMaskZero, listBits, matches, setBit } from './bitmask.js'\nimport { getComponentInfo } from './component.js'\nimport type {\n Archetype,\n ComponentInfo,\n ComponentLike,\n EntityId,\n Query,\n QueryDescriptor,\n QueryInternal,\n QueryMaskBundle,\n ReactiveBuffer,\n World,\n WorldState,\n} from './types.js'\nimport {\n getOrRegisterComponentBit,\n getWorldState,\n readEntityMask,\n tryGetComponentBit,\n} from './world.js'\n\nlet nextQueryId = 1\nconst moduleQueryCache = new Map<string, QueryInternal>()\n\nfunction descKey(d: QueryDescriptor): string {\n const all = (d.all ?? [])\n .map((c) => c.__id)\n .sort((a, b) => a - b)\n .join('-')\n const any = (d.any ?? [])\n .map((c) => c.__id)\n .sort((a, b) => a - b)\n .join('-')\n const none = (d.none ?? [])\n .map((c) => c.__id)\n .sort((a, b) => a - b)\n .join('-')\n return `A${all}|Y${any}|N${none}`\n}\n\nexport function defineQuery(arg: ComponentLike[] | QueryDescriptor): Query {\n const desc: QueryDescriptor = Array.isArray(arg) ? { all: arg } : arg\n\n // Validate all members are components\n for (const c of [...(desc.all ?? []), ...(desc.any ?? []), ...(desc.none ?? [])]) {\n if (!c || typeof c !== 'object' || typeof (c as any).__id !== 'number') {\n throw new TypeError('aiecsjs: defineQuery received a non-component value')\n }\n }\n\n const key = descKey(desc)\n const cached = moduleQueryCache.get(key)\n if (cached) return cached\n\n const q: QueryInternal = {\n id: nextQueryId++,\n mask: [],\n all: (desc.all ?? []).map((c) => c.__id),\n any: (desc.any ?? []).map((c) => c.__id),\n none: (desc.none ?? []).map((c) => c.__id),\n columnViewCache: [...(desc.all ?? []), ...(desc.any ?? [])],\n reactiveKind: 'normal',\n sourceQueryId: -1,\n sourceQuery: null,\n }\n moduleQueryCache.set(key, q)\n return q\n}\n\nexport function enterQuery(query: Query): Query {\n const q = query as QueryInternal\n const key = `enter:${q.id}`\n const cached = moduleQueryCache.get(key)\n if (cached) return cached\n const reactive: QueryInternal = {\n id: nextQueryId++,\n mask: [],\n all: q.all,\n any: q.any,\n none: q.none,\n columnViewCache: q.columnViewCache,\n reactiveKind: 'enter',\n sourceQueryId: q.id,\n sourceQuery: q,\n }\n moduleQueryCache.set(key, reactive)\n return reactive\n}\n\nexport function exitQuery(query: Query): Query {\n const q = query as QueryInternal\n const key = `exit:${q.id}`\n const cached = moduleQueryCache.get(key)\n if (cached) return cached\n const reactive: QueryInternal = {\n id: nextQueryId++,\n mask: [],\n all: q.all,\n any: q.any,\n none: q.none,\n columnViewCache: q.columnViewCache,\n reactiveKind: 'exit',\n sourceQueryId: q.id,\n sourceQuery: q,\n }\n moduleQueryCache.set(key, reactive)\n return reactive\n}\n\n// --- Per-world query setup ---\n\nfunction ensureQueryRegistered(state: WorldState, q: QueryInternal): void {\n if (state.queries[q.id] === q && state.queryMasks.has(q.id)) return\n\n // Build per-world bitmasks (this may register new bits)\n const ww = state.options.maskWordCount\n const withMask = createMask(ww)\n const anyMask = createMask(ww)\n const noneMask = createMask(ww)\n for (const compId of q.all) {\n const info = getComponentInfoById(compId)\n const bit = getOrRegisterComponentBit(state, info)\n setBit(withMask, bit)\n }\n for (const compId of q.any) {\n const info = getComponentInfoById(compId)\n const bit = getOrRegisterComponentBit(state, info)\n setBit(anyMask, bit)\n }\n for (const compId of q.none) {\n const info = getComponentInfoById(compId)\n const bit = getOrRegisterComponentBit(state, info)\n setBit(noneMask, bit)\n }\n\n const bundle: QueryMaskBundle = {\n withMask,\n anyMask,\n noneMask,\n anyHasBits: !isMaskZero(anyMask),\n }\n state.queryMasks.set(q.id, bundle)\n\n state.queries[q.id] = q\n state.queryArchetypeCache[q.id] = null\n state.queryArchetypeStamp[q.id] = -1\n\n // Build bit → queries index for fast reactive lookup\n const involvedBits: number[] = [\n ...listBits(withMask),\n ...listBits(anyMask),\n ...listBits(noneMask),\n ]\n for (const b of involvedBits) {\n let s = state.bitToQueries.get(b)\n if (!s) {\n s = new Set<number>()\n state.bitToQueries.set(b, s)\n }\n s.add(q.id)\n }\n\n // Initialize reactive buffer for enter/exit queries\n if (q.reactiveKind !== 'normal') {\n if (!state.reactiveBuffers.has(q.id)) {\n state.reactiveBuffers.set(q.id, { entered: [], exited: [] })\n }\n // Also register the source query so recordEntityMaskChange will see it\n if (q.sourceQuery) ensureQueryRegistered(state, q.sourceQuery)\n }\n}\n\nfunction getQueryArchetypes(state: WorldState, q: QueryInternal): number[] {\n ensureQueryRegistered(state, q)\n if (state.queryArchetypeCache[q.id] && state.queryArchetypeStamp[q.id] === state.queryVersion) {\n return state.queryArchetypeCache[q.id]!\n }\n const bundle = state.queryMasks.get(q.id)!\n const words = state.options.maskWordCount\n const list: number[] = []\n for (let i = 0; i < state.archetypes.length; i++) {\n const arch = state.archetypes[i]!\n if (\n matches(arch.mask, bundle.withMask, bundle.anyMask, bundle.noneMask, bundle.anyHasBits, words)\n ) {\n list.push(i)\n }\n }\n state.queryArchetypeCache[q.id] = list\n state.queryArchetypeStamp[q.id] = state.queryVersion\n return list\n}\n\nexport function queryArchetypes(world: World, query: Query): readonly Archetype[] {\n const state = getWorldState(world)\n const q = query as QueryInternal\n const ids = getQueryArchetypes(state, q)\n const out: Archetype[] = []\n for (const id of ids) {\n const arch = state.archetypes[id]!\n out.push({ id: arch.id, mask: Array.from(arch.mask), size: arch.size })\n }\n return out\n}\n\nexport function runQuery(world: World, query: Query): readonly EntityId[] {\n const state = getWorldState(world)\n const q = query as QueryInternal\n const out: EntityId[] = []\n if (q.reactiveKind === 'enter') {\n const buf = state.reactiveBuffers.get(q.id)\n if (buf) {\n for (const e of buf.entered) out.push(e as EntityId)\n buf.entered.length = 0\n }\n return out\n }\n if (q.reactiveKind === 'exit') {\n const buf = state.reactiveBuffers.get(q.id)\n if (buf) {\n for (const e of buf.exited) out.push(e as EntityId)\n buf.exited.length = 0\n }\n return out\n }\n const archIds = getQueryArchetypes(state, q)\n for (const id of archIds) {\n const arch = state.archetypes[id]!\n for (let r = 0; r < arch.size; r++) {\n out.push(arch.entities[r] as EntityId)\n }\n }\n return out\n}\n\nexport function* iterQuery(world: World, query: Query): IterableIterator<EntityId> {\n const state = getWorldState(world)\n const q = query as QueryInternal\n if (q.reactiveKind !== 'normal') {\n const buf = state.reactiveBuffers.get(q.id)\n if (!buf) return\n const src = q.reactiveKind === 'enter' ? buf.entered : buf.exited\n for (const e of src) yield e as EntityId\n src.length = 0\n return\n }\n const archIds = getQueryArchetypes(state, q)\n for (const id of archIds) {\n const arch = state.archetypes[id]!\n for (let r = 0; r < arch.size; r++) {\n yield arch.entities[r] as EntityId\n }\n }\n}\n\nexport function forEachEntity(\n world: World,\n query: Query,\n fn: (eid: EntityId, ...cols: any[]) => void,\n): void {\n const state = getWorldState(world)\n const q = query as QueryInternal\n\n if (q.reactiveKind !== 'normal') {\n const buf = state.reactiveBuffers.get(q.id)\n if (!buf) return\n const src = q.reactiveKind === 'enter' ? buf.entered : buf.exited\n if (src.length === 0) return\n const cols = buildColumnViews(state, q)\n for (let i = 0; i < src.length; i++) {\n const e = src[i] as EntityId\n callWithCols(fn, e, cols)\n }\n src.length = 0\n return\n }\n\n ensureQueryRegistered(state, q)\n const archIds = getQueryArchetypes(state, q)\n const cols = buildColumnViews(state, q)\n for (const id of archIds) {\n const arch = state.archetypes[id]!\n const ents = arch.entities\n const n = arch.size\n for (let r = 0; r < n; r++) {\n callWithCols(fn, ents[r] as EntityId, cols)\n }\n }\n}\n\nfunction callWithCols(\n fn: (eid: EntityId, ...cols: any[]) => void,\n eid: EntityId,\n cols: any[],\n): void {\n // Specialise for low arities to avoid spread allocation.\n switch (cols.length) {\n case 0:\n fn(eid)\n break\n case 1:\n fn(eid, cols[0])\n break\n case 2:\n fn(eid, cols[0], cols[1])\n break\n case 3:\n fn(eid, cols[0], cols[1], cols[2])\n break\n case 4:\n fn(eid, cols[0], cols[1], cols[2], cols[3])\n break\n case 5:\n fn(eid, cols[0], cols[1], cols[2], cols[3], cols[4])\n break\n default:\n fn(eid, ...cols)\n }\n}\n\nfunction buildColumnViews(state: WorldState, q: QueryInternal): any[] {\n const out: any[] = []\n for (const comp of q.columnViewCache) {\n const info = getComponentInfo(comp)\n const bit = state.componentBitFor.get(info.id)\n if (bit === undefined) {\n out.push(undefined)\n continue\n }\n const storage = state.componentStorageByBit[bit]\n if (!storage) {\n out.push(undefined)\n continue\n }\n if (storage.kind === 'soa') out.push(storage.soa)\n else if (storage.kind === 'aos') out.push(storage.aos)\n else out.push(true) // tag\n }\n return out\n}\n\n// --- Reactive query updates (called from migration code) ---\n\nexport function recordEntityMaskChange(\n state: WorldState,\n eid: EntityId,\n changedBit: number,\n prevMask: Uint32Array,\n nextMask: Uint32Array,\n): void {\n // Lazy-register any reactive queries (and their sources) so we can correctly\n // determine match transitions even if the user only ever called enterQuery/exitQuery.\n for (const q of moduleQueryCache.values()) {\n if (q.reactiveKind === 'normal') continue\n if (q.sourceQuery && state.queries[q.sourceQuery.id] !== q.sourceQuery) {\n ensureQueryRegistered(state, q.sourceQuery)\n }\n }\n\n const involved = state.bitToQueries.get(changedBit)\n if (!involved) return\n const words = state.options.maskWordCount\n for (const qid of involved) {\n const q = state.queries[qid]\n if (!q) continue\n if (q.reactiveKind !== 'normal') continue\n const bundle = state.queryMasks.get(qid)\n if (!bundle) continue\n const wasMatch = matches(\n prevMask,\n bundle.withMask,\n bundle.anyMask,\n bundle.noneMask,\n bundle.anyHasBits,\n words,\n )\n const isMatch = matches(\n nextMask,\n bundle.withMask,\n bundle.anyMask,\n bundle.noneMask,\n bundle.anyHasBits,\n words,\n )\n if (!wasMatch && isMatch) {\n pushReactive(state, qid, 'enter', eid)\n } else if (wasMatch && !isMatch) {\n pushReactive(state, qid, 'exit', eid)\n }\n }\n}\n\nfunction pushReactive(\n state: WorldState,\n queryId: number,\n kind: 'enter' | 'exit',\n eid: EntityId,\n): void {\n // Walk the module cache (not just state.queries) so reactive variants that\n // haven't been registered with this world yet still receive events.\n for (const r of moduleQueryCache.values()) {\n if (r.sourceQueryId !== queryId) continue\n if (r.reactiveKind !== kind) continue\n // Lazily register the reactive query in this world so subsequent reads can find it\n ensureQueryRegistered(state, r)\n const buf = ensureReactiveBuffer(state, r.id)\n if (kind === 'enter') buf.entered.push(eid as number)\n else buf.exited.push(eid as number)\n }\n}\n\nfunction ensureReactiveBuffer(state: WorldState, qid: number): ReactiveBuffer {\n let buf = state.reactiveBuffers.get(qid)\n if (!buf) {\n buf = { entered: [], exited: [] }\n state.reactiveBuffers.set(qid, buf)\n }\n return buf\n}\n\n// --- Helpers ---\n\nfunction getComponentInfoById(componentId: number): ComponentInfo {\n // We need access to the component registry's lookup by id. Re-import dynamically to avoid cycles.\n const info = lazyGetComponentInfo(componentId)\n if (!info) throw new Error(`aiecsjs: component id ${componentId} not registered`)\n return info\n}\n\nlet _getComponentInfoFn: ((id: number) => ComponentInfo | undefined) | null = null\nexport function registerComponentLookup(fn: (id: number) => ComponentInfo | undefined): void {\n _getComponentInfoFn = fn\n}\nfunction lazyGetComponentInfo(id: number): ComponentInfo | undefined {\n return _getComponentInfoFn ? _getComponentInfoFn(id) : undefined\n}\n\nexport function _resetQueryRegistry_FOR_TESTS_ONLY(): void {\n moduleQueryCache.clear()\n nextQueryId = 1\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var j="0.5.1";function T(t){return new Uint32Array(t)}function F(t,n){let e=n>>>5;t[e]=(t[e]??0)|1<<(n&31);}function I(t,n){let e=n>>>5;t[e]=(t[e]??0)&~(1<<(n&31));}function b(t,n){let e=n>>>5;return ((t[e]??0)&1<<(n&31))!==0}function h(t){let n=new Uint32Array(t.length);for(let e=0;e<t.length;e++)n[e]=t[e]??0;return n}function S(t){let n=[];for(let e=0;e<t.length;e++)n.push((t[e]??0).toString(16));return n.join(",")}function wn(t){for(let n=0;n<t.length;n++)if((t[n]??0)!==0)return false;return true}function xn(t,n,e,o,r,i){let s=!r;for(let a=0;a<i;a++){let c=t[a]??0,f=n[a]??0,d=e[a]??0,u=o[a]??0;if((c&f)!==f||(c&u)!==0)return false;!s&&(c&d)!==0&&(s=true);}return s}function gn(t){let n=[];for(let e=0;e<t.length;e++){let o=t[e]??0;for(;o!==0;){let r=(e<<5)+z(o);n.push(r),o&=o-1;}}return n}function W(t,n,e,o){for(let r=0;r<e;r++){let i=t[n+r]??0;for(;i!==0;){let s=(r<<5)+z(i);o(s),i&=i-1;}}}function kn(t,n,e,o,r,i,s){let a=!s;for(let c=0;c<e;c++){let f=t[n+c]??0,d=o[c]??0,u=r[c]??0,y=i[c]??0;if((f&d)!==d||(f&y)!==0)return false;!a&&(f&u)!==0&&(a=true);}return a}function z(t){return 31-Math.clz32(t&-t)}var E={initialCapacity:1024,maxEntities:1e6,indexBits:24,generationBits:8},J=256,nn=1,A=new Map;function l(t){let n=A.get(t.id);if(!n)throw new Error(`aiecsjs: world ${t.id} is destroyed or unknown`);if(n.destroyed)throw new Error(`aiecsjs: world ${t.id} is destroyed`);return n}function tn(t){A.set(t.id,t);}function en(t){A.delete(t);}function Sn(t){return A.has(t)}function on(t){let n=t??{},e=n.indexBits??E.indexBits,o=n.generationBits??E.generationBits,r=J;if(e<1||e>24)throw new Error("aiecsjs: indexBits must be in [1, 24]");if(o<0||o>16)throw new Error("aiecsjs: generationBits must be in [0, 16]");if(e+o>32)throw new Error(`aiecsjs: indexBits (${e}) + generationBits (${o}) must be <= 32`);let i=1<<e,s=Math.max(1,Math.min(n.initialCapacity??E.initialCapacity,i)),a=Math.max(s,Math.min(n.maxEntities??E.maxEntities,i));return {initialCapacity:s,maxEntities:a,indexBits:e,generationBits:o,indexMask:(1<<e)-1,generationMask:o===0?0:(1<<o)-1,maxComponents:r,maskWordCount:Math.ceil(r/32),buffer:n.buffer??null,bufferByteOffset:n.bufferByteOffset??0}}function rn(t,n){return {id:0,mask:T(t),size:0,capacity:16,entities:new Uint32Array(16),entityRow:new Map,componentBits:[],edgeAdd:new Int32Array(n).fill(-1),edgeRemove:new Int32Array(n).fill(-1)}}function Wn(t){let n=on(t),e=nn++,o=n.generationBits>8?Uint16Array:Uint8Array,r=new o(n.initialCapacity),i={id:e,capacity:n.initialCapacity,version:j,options:n,size:0,nextFreshIndex:1,freeList:[],generations:r,destroyed:false,componentBitFor:new Map,componentInfoByBit:new Array(n.maxComponents).fill(null),componentStorageByBit:new Array(n.maxComponents).fill(null),nextComponentBit:0,entityArchetype:new Uint32Array(n.initialCapacity),entityMask:new Uint32Array(n.initialCapacity*n.maskWordCount),archetypes:[],archetypeByMaskHash:new Map,queryVersion:0,queries:[],queryMasks:new Map,queryArchetypeCache:[],queryArchetypeStamp:[],bitToQueries:new Map,reactiveBuffers:new Map,observers:[],relationStorage:new Map,sab:n.buffer,readOnly:false},s=rn(n.maskWordCount,n.maxComponents);return s.id=0,i.archetypes.push(s),i.archetypeByMaskHash.set(S(s.mask),0),tn(i),sn(i)}function sn(t){return {id:t.id,get capacity(){return t.capacity},version:t.version}}function Bn(t){let n=A.get(t.id);!n||n.destroyed||(n.destroyed=true,n.archetypes=[],n.archetypeByMaskHash.clear(),n.componentInfoByBit=[],n.componentStorageByBit=[],n.queries=[],n.queryMasks.clear(),n.queryArchetypeCache=[],n.observers=[],n.relationStorage.clear(),n.reactiveBuffers.clear(),n.entityMask=new Uint32Array(0),n.entityArchetype=new Uint32Array(0),n.generations=new Uint8Array(0),n.freeList=[],n.componentBitFor.clear(),n.bitToQueries.clear(),n.queryArchetypeStamp=[],n.sab=null,en(t.id));}function Mn(t){let n=l(t);n.size=0,n.nextFreshIndex=1,n.freeList=[],n.generations.fill(0),n.entityArchetype.fill(0),n.entityMask.fill(0);for(let e of n.archetypes)e.size=0,e.entityRow.clear();for(let e of n.componentStorageByBit)if(e)if(e.kind==="soa"&&e.soa)for(let o of Object.keys(e.soa))e.soa[o]?.fill(0);else e.kind==="aos"&&e.aos&&e.aos.fill(void 0);n.queryVersion++;for(let e of n.reactiveBuffers.values())e.entered.length=0,e.exited.length=0;}function Un(t){return l(t).size}function On(t){return l(t).capacity}function B(t,n){if(n<=t.capacity)return;if(n>t.options.maxEntities)throw new Error(`aiecsjs: requested capacity ${n} exceeds maxEntities ${t.options.maxEntities}`);let e=t.capacity;for(;e<n;)e=Math.min(e*2,t.options.maxEntities);an(t,e);}function an(t,n){let e=t.generations.constructor,o=new e(n);o.set(t.generations),t.generations=o;let r=new Uint32Array(n);r.set(t.entityArchetype),t.entityArchetype=r;let i=t.options.maskWordCount,s=new Uint32Array(n*i);s.set(t.entityMask),t.entityMask=s;for(let a of t.componentStorageByBit)if(a)if(a.kind==="soa"&&a.soa){let c=t.componentInfoByBit[a.bit];c&&cn(a.soa,c.fields,n);}else a.kind==="aos"&&a.aos&&(a.aos.length=n);t.capacity=n;}function cn(t,n,e){for(let o of n){let r=t[o.name];if(!r)continue;let i=e*o.vectorLen;if(r.length>=i)continue;let s=new o.ctor(i);s.set(r),t[o.name]=s;}}function D(t,n){let e=S(n),o=t.archetypeByMaskHash.get(e);if(o!==void 0)return {archId:o,created:false};let r=t.archetypes.length,i={id:r,mask:h(n),size:0,capacity:16,entities:new Uint32Array(16),entityRow:new Map,componentBits:fn(n),edgeAdd:new Int32Array(t.options.maxComponents).fill(-1),edgeRemove:new Int32Array(t.options.maxComponents).fill(-1)};return t.archetypes.push(i),t.archetypeByMaskHash.set(e,r),t.queryVersion++,{archId:r,created:true}}function g(t,n){if(n<=t.capacity)return;let e=t.capacity;for(;e<n;)e*=2;let o=new Uint32Array(e);o.set(t.entities),t.entities=o,t.capacity=e;}function fn(t){let n=[];for(let e=0;e<t.length;e++){let o=t[e]??0;for(;o!==0;){let r=o&-o,i=(e<<5)+(31-Math.clz32(r));n.push(i),o&=o-1;}}return n}function N(t,n){let e=t.componentBitFor.get(n.id);if(e!==void 0)return e;if(t.nextComponentBit>=t.options.maxComponents)throw new Error(`aiecsjs: world reached maxComponents=${t.options.maxComponents}`);let o=t.nextComponentBit++;t.componentBitFor.set(n.id,o),t.componentInfoByBit[o]=n;let r;if(n.kind==="soa"){let i={};for(let s of n.fields)i[s.name]=new s.ctor(t.capacity*s.vectorLen);r={kind:"soa",componentId:n.id,bit:o,soa:i};}else n.kind==="aos"?r={kind:"aos",componentId:n.id,bit:o,aos:new Array(t.capacity)}:r={kind:"tag",componentId:n.id,bit:o};return t.componentStorageByBit[o]=r,o}function m(t,n){let e=t.options.maskWordCount,o=new Uint32Array(e),i=(n&t.options.indexMask)*e;for(let s=0;s<e;s++)o[s]=t.entityMask[i+s]??0;return o}function P(t,n,e){let o=t.options.maskWordCount,i=(n&t.options.indexMask)*o;for(let s=0;s<o;s++)t.entityMask[i+s]=e[s]??0;}function k(t,n){return t.componentBitFor.get(n.id)}function Rn(t){if(!t||typeof t!="object")return false;let n=t;return typeof n.id!="number"||typeof n.version!="string"?false:A.has(n.id)}var U=1,dn={i8:Int8Array,u8:Uint8Array,i16:Int16Array,u16:Uint16Array,i32:Int32Array,u32:Uint32Array,f32:Float32Array,f64:Float64Array,eid:Uint32Array,bool:Uint8Array},w=new Map;function Fn(t){let n=[];for(let[i,s]of Object.entries(t)){let a,c=1;if(typeof s=="string")a=s;else if(Array.isArray(s)){let[d,u]=s;a=d,c=u;}else throw new TypeError(`aiecsjs: invalid field declaration for "${i}"`);let f=dn[a];if(!f)throw new TypeError(`aiecsjs: unknown field type "${a}" for field "${i}"`);n.push({name:i,type:a,vectorLen:c,ctor:f,bytesPerElement:f.BYTES_PER_ELEMENT});}let e=U++,o={id:e,kind:"soa",schema:t,fields:n,factory:null};return w.set(e,o),{__kind:"soa",__id:e,__schema:t}}function zn(){let t=U++,n={id:t,kind:"tag",schema:null,fields:[],factory:null};return w.set(t,n),{__kind:"tag",__id:t}}function Dn(t){let n=U++,e=t??(()=>({})),o={id:n,kind:"aos",schema:null,fields:[],factory:e};return w.set(n,o),{__kind:"aos",__id:n,__factory:e}}function x(t){let n=w.get(t.__id);if(!n)throw new Error("aiecsjs: component is not registered (call defineComponent/defineTag/defineObjectComponent)");return n}function q(t,n,e,o){let r=l(t);if(r.readOnly)throw new Error("aiecsjs: cannot mutate a read-only world");if(!p(r,n))throw new Error(`aiecsjs: addComponent on dead entity ${n}`);let i=x(e),s=N(r,i),a=m(r,n);if(b(a,s)){o!==void 0&&M(r,n,e,o);return}let c=h(a);F(c,s),H(r,n,c),M(r,n,e,o),un(r,n,s),O(r,n,s,a,c);}function Nn(t,n,e){let o=l(t);if(o.readOnly)throw new Error("aiecsjs: cannot mutate a read-only world");if(!p(o,n))return;let r=x(e),i=k(o,r);if(i===void 0)return;let s=m(o,n);if(!b(s,i))return;let a=h(s);I(a,i),H(o,n,a),yn(o,n,i);let c=n&o.options.indexMask,f=o.componentStorageByBit[i];f?.kind==="soa"&&f.soa?$(f.soa,r.fields,c):f?.kind==="aos"&&f.aos&&(f.aos[c]=void 0),O(o,n,i,s,a);}function Pn(t,n,e){let o=l(t);if(!p(o,n))return false;let r=x(e),i=k(o,r);if(i===void 0)return false;let s=m(o,n);return b(s,i)}function qn(t,n,e){let o=l(t);if(!p(o,n))return;let r=x(e),i=k(o,r);if(i===void 0)return;let s=m(o,n);if(!b(s,i))return;let a=o.componentStorageByBit[i];if(a){if(a.kind==="soa")return a.soa;if(a.kind==="aos"){let c=n&o.options.indexMask;return a.aos?.[c]}return true}}function $n(t,n,e,o){let r=l(t);if(r.readOnly)throw new Error("aiecsjs: cannot mutate a read-only world");if(!p(r,n))throw new Error(`aiecsjs: setComponent on dead entity ${n}`);let i=x(e),s=k(r,i);if(s===void 0){q(t,n,e,o);return}let a=m(r,n);if(!b(a,s)){q(t,n,e,o);return}M(r,n,e,o),ln(r,n,s,o);}function M(t,n,e,o){let r=x(e),i=t.componentBitFor.get(r.id);if(i===void 0)return;let s=t.componentStorageByBit[i];if(!s)return;let a=n&t.options.indexMask;if(r.kind==="soa"&&s.soa){if(o==null)return;let c=o;for(let f of r.fields){if(!(f.name in c))continue;let d=s.soa[f.name];if(!d)continue;let u=c[f.name];if(f.vectorLen===1)d[a]=typeof u=="boolean"?u?1:0:Number(u);else if(Array.isArray(u)||ArrayBuffer.isView(u)){let y=a*f.vectorLen,Z=u;for(let C=0;C<f.vectorLen;C++)d[y+C]=Number(Z[C]??0);}}}else if(r.kind==="aos"&&s.aos){let c=r.factory??(()=>({})),f=s.aos[a];if(f===void 0&&(f=c(),s.aos[a]=f),o&&typeof o=="object"){let d=o,u=f;for(let y of Object.keys(d))y==="__proto__"||y==="constructor"||y==="prototype"||(u[y]=d[y]);}}}function $(t,n,e){for(let o of n){let r=t[o.name];if(r)if(o.vectorLen===1)r[e]=0;else {let i=e*o.vectorLen;for(let s=0;s<o.vectorLen;s++)r[i+s]=0;}}}function G(t,n){let e=t.options.maskWordCount,o=n&t.options.indexMask,r=o*e;W(t.entityMask,r,e,i=>{let s=t.componentStorageByBit[i],a=t.componentInfoByBit[i];s?.kind==="soa"&&s.soa&&a?$(s.soa,a.fields,o):s?.kind==="aos"&&s.aos&&(s.aos[o]=void 0);});}function H(t,n,e){let o=n&t.options.indexMask,r=t.entityArchetype[o]??0,i=t.archetypes[r];if(!i)return;let a=D(t,e).archId,c=t.archetypes[a];if(c){if(a!==r){let f=i.entityRow.get(n);if(f!==void 0){let u=i.size-1;if(f!==u){let y=i.entities[u]??0;i.entities[f]=y,i.entityRow.set(y,f);}i.entities[u]=0,i.entityRow.delete(n),i.size--;}g(c,c.size+1);let d=c.size;c.entities[d]=n,c.entityRow.set(n,d),c.size++,t.entityArchetype[o]=a;}P(t,n,e);}}var v={fireAdd:()=>{},fireRemove:()=>{},fireSet:()=>{}},V=()=>{};function Gn(t){V=t;}function O(t,n,e,o,r){V(t,n,e,o,r);}function Y(t,n,e){let o=t.options.maskWordCount,r=h(e),i=h(e);W(e,0,o,s=>{I(i,s),O(t,n,s,r,i),I(r,s);});}function Hn(t){v=t;}function un(t,n,e){v.fireAdd(t,n,e);}function yn(t,n,e){v.fireRemove(t,n,e);}function ln(t,n,e,o){v.fireSet(t,n,e,o);}function Vn(t){return w.get(t)}function Yn(){return Array.from(w.values())}var L=24,pn=8,X=(1<<L)-1,K=(1<<pn)-1;function Q(t,n,e){return ((n&e.generationMask)<<e.indexBits|t&e.indexMask)>>>0}function Zn(t,n){return t&n.indexMask}function Jn(t,n){return t>>>n.indexBits&n.generationMask}function nt(t){let n=l(t);if(n.readOnly)throw new Error("aiecsjs: cannot createEntity on a read-only world (worker-attached)");let e;if(n.freeList.length>0)e=n.freeList.pop();else {if(n.nextFreshIndex>=n.options.maxEntities)throw new Error(`aiecsjs: reached maxEntities ${n.options.maxEntities}`);n.nextFreshIndex>=n.capacity&&B(n,n.nextFreshIndex+1),e=n.nextFreshIndex++;}let o=n.generations[e]??0,r=Q(e,o,n.options),i=n.archetypes[0];if(!i)throw new Error("aiecsjs: missing empty archetype");g(i,i.size+1);let s=i.size;i.entities[s]=r,i.entityRow.set(r,s),i.size++,n.entityArchetype[e]=0;let a=n.options.maskWordCount,c=e*a;for(let f=0;f<a;f++)n.entityMask[c+f]=0;return n.size++,r}function tt(t,n){if(t.readOnly)throw new Error("aiecsjs: cannot create entities on a read-only world (worker-attached)");if(n<=0||n>=t.options.maxEntities)throw new Error(`aiecsjs: slot index ${n} out of range`);n>=t.capacity&&B(t,n+1);let e=t.generations[n]??0,o=Q(n,e,t.options);if(p(t,o))return o;if(n>=t.nextFreshIndex){for(let c=t.nextFreshIndex;c<n;c++)t.freeList.push(c);t.nextFreshIndex=n+1;}else {let c=t.freeList.lastIndexOf(n);if(c!==-1){let f=t.freeList.length-1;t.freeList[c]=t.freeList[f],t.freeList.pop();}}let r=t.archetypes[0];if(!r)throw new Error("aiecsjs: missing empty archetype");g(r,r.size+1);let i=r.size;r.entities[i]=o,r.entityRow.set(o,i),r.size++,t.entityArchetype[n]=0;let s=t.options.maskWordCount,a=n*s;for(let c=0;c<s;c++)t.entityMask[a+c]=0;return t.size++,o}function et(t,n){let e=l(t);if(e.readOnly)throw new Error("aiecsjs: cannot destroyEntity on a read-only world");if(!p(e,n))return;let o=n&e.options.indexMask,r=m(e,n),{dispatchDestroyObservers:i}=hn();i(e,n),bn(e,n),G(e,n);let s=e.entityArchetype[o]??0,a=e.archetypes[s];if(a){let d=a.entityRow.get(n);if(d!==void 0){let u=a.size-1;if(d!==u){let y=a.entities[u]??0;a.entities[d]=y,a.entityRow.set(y,d);}a.entities[u]=0,a.entityRow.delete(n),a.size--;}}Y(e,n,r),e.entityArchetype[o]=0;let c=e.options.maskWordCount,f=o*c;for(let d=0;d<c;d++)e.entityMask[f+d]=0;e.generations[o]=(e.generations[o]??0)+1&e.options.generationMask,e.freeList.push(o),e.size--;}function mn(t,n){let e=l(t);return p(e,n)}function p(t,n){let e=n&t.options.indexMask;if(e<=0||e>=t.capacity)return false;let o=t.entityArchetype[e]??0,r=t.archetypes[o];if(!r||!r.entityRow.has(n))return false;let i=t.generations[e]??0,s=n>>>t.options.indexBits&t.options.generationMask;return i===s}function ot(t){return t&X}function rt(t){return t>>>L&K}function it(t,n){return ((n&K)<<L|t&X)>>>0}function st(t,n){return typeof n!="number"?false:mn(t,n)}var R=null;function at(t){R=t;}function hn(){return R||{dispatchDestroyObservers:()=>{}}}var _=null;function ct(t){_=t;}function bn(t,n){_&&_(t,n);}exports.A=rt;exports.B=it;exports.C=st;exports.D=at;exports.E=ct;exports.F=Fn;exports.G=zn;exports.H=Dn;exports.I=x;exports.J=q;exports.K=Nn;exports.L=Pn;exports.M=qn;exports.N=$n;exports.O=Gn;exports.P=Hn;exports.Q=Vn;exports.R=Yn;exports.a=j;exports.b=T;exports.c=F;exports.d=wn;exports.e=xn;exports.f=gn;exports.g=W;exports.h=kn;exports.i=l;exports.j=Sn;exports.k=Wn;exports.l=Bn;exports.m=Mn;exports.n=Un;exports.o=On;exports.p=N;exports.q=Rn;exports.r=Q;exports.s=Zn;exports.t=Jn;exports.u=nt;exports.v=tt;exports.w=et;exports.x=mn;exports.y=p;exports.z=ot;//# sourceMappingURL=chunk-7O3CM4D2.cjs.map
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
'use strict';var j="0.5.2";function T(t){return new Uint32Array(t)}function F(t,n){let e=n>>>5;t[e]=(t[e]??0)|1<<(n&31);}function I(t,n){let e=n>>>5;t[e]=(t[e]??0)&~(1<<(n&31));}function b(t,n){let e=n>>>5;return ((t[e]??0)&1<<(n&31))!==0}function h(t){let n=new Uint32Array(t.length);for(let e=0;e<t.length;e++)n[e]=t[e]??0;return n}function S(t){let n=[];for(let e=0;e<t.length;e++)n.push((t[e]??0).toString(16));return n.join(",")}function wn(t){for(let n=0;n<t.length;n++)if((t[n]??0)!==0)return false;return true}function xn(t,n,e,o,r,i){let s=!r;for(let a=0;a<i;a++){let c=t[a]??0,f=n[a]??0,d=e[a]??0,u=o[a]??0;if((c&f)!==f||(c&u)!==0)return false;!s&&(c&d)!==0&&(s=true);}return s}function gn(t){let n=[];for(let e=0;e<t.length;e++){let o=t[e]??0;for(;o!==0;){let r=(e<<5)+z(o);n.push(r),o&=o-1;}}return n}function W(t,n,e,o){for(let r=0;r<e;r++){let i=t[n+r]??0;for(;i!==0;){let s=(r<<5)+z(i);o(s),i&=i-1;}}}function kn(t,n,e,o,r,i,s){let a=!s;for(let c=0;c<e;c++){let f=t[n+c]??0,d=o[c]??0,u=r[c]??0,y=i[c]??0;if((f&d)!==d||(f&y)!==0)return false;!a&&(f&u)!==0&&(a=true);}return a}function z(t){return 31-Math.clz32(t&-t)}var E={initialCapacity:1024,maxEntities:1e6,indexBits:24,generationBits:8},J=256,nn=1,A=new Map;function l(t){let n=A.get(t.id);if(!n)throw new Error(`aiecsjs: world ${t.id} is destroyed or unknown`);if(n.destroyed)throw new Error(`aiecsjs: world ${t.id} is destroyed`);return n}function tn(t){A.set(t.id,t);}function en(t){A.delete(t);}function Sn(t){return A.has(t)}function on(t){let n=t??{},e=n.indexBits??E.indexBits,o=n.generationBits??E.generationBits,r=J;if(e<1||e>24)throw new Error("aiecsjs: indexBits must be in [1, 24]");if(o<0||o>16)throw new Error("aiecsjs: generationBits must be in [0, 16]");if(e+o>32)throw new Error(`aiecsjs: indexBits (${e}) + generationBits (${o}) must be <= 32`);let i=1<<e,s=Math.max(1,Math.min(n.initialCapacity??E.initialCapacity,i)),a=Math.max(s,Math.min(n.maxEntities??E.maxEntities,i));return {initialCapacity:s,maxEntities:a,indexBits:e,generationBits:o,indexMask:(1<<e)-1,generationMask:o===0?0:(1<<o)-1,maxComponents:r,maskWordCount:Math.ceil(r/32),buffer:n.buffer??null,bufferByteOffset:n.bufferByteOffset??0}}function rn(t,n){return {id:0,mask:T(t),size:0,capacity:16,entities:new Uint32Array(16),entityRow:new Map,componentBits:[],edgeAdd:new Int32Array(n).fill(-1),edgeRemove:new Int32Array(n).fill(-1)}}function Wn(t){let n=on(t),e=nn++,o=n.generationBits>8?Uint16Array:Uint8Array,r=new o(n.initialCapacity),i={id:e,capacity:n.initialCapacity,version:j,options:n,size:0,nextFreshIndex:1,freeList:[],generations:r,destroyed:false,componentBitFor:new Map,componentInfoByBit:new Array(n.maxComponents).fill(null),componentStorageByBit:new Array(n.maxComponents).fill(null),nextComponentBit:0,entityArchetype:new Uint32Array(n.initialCapacity),entityMask:new Uint32Array(n.initialCapacity*n.maskWordCount),archetypes:[],archetypeByMaskHash:new Map,queryVersion:0,queries:[],queryMasks:new Map,queryArchetypeCache:[],queryArchetypeStamp:[],bitToQueries:new Map,reactiveBuffers:new Map,observers:[],relationStorage:new Map,sab:n.buffer,readOnly:false},s=rn(n.maskWordCount,n.maxComponents);return s.id=0,i.archetypes.push(s),i.archetypeByMaskHash.set(S(s.mask),0),tn(i),sn(i)}function sn(t){return {id:t.id,get capacity(){return t.capacity},version:t.version}}function Bn(t){let n=A.get(t.id);!n||n.destroyed||(n.destroyed=true,n.archetypes=[],n.archetypeByMaskHash.clear(),n.componentInfoByBit=[],n.componentStorageByBit=[],n.queries=[],n.queryMasks.clear(),n.queryArchetypeCache=[],n.observers=[],n.relationStorage.clear(),n.reactiveBuffers.clear(),n.entityMask=new Uint32Array(0),n.entityArchetype=new Uint32Array(0),n.generations=new Uint8Array(0),n.freeList=[],n.componentBitFor.clear(),n.bitToQueries.clear(),n.queryArchetypeStamp=[],n.sab=null,en(t.id));}function Mn(t){let n=l(t);n.size=0,n.nextFreshIndex=1,n.freeList=[],n.generations.fill(0),n.entityArchetype.fill(0),n.entityMask.fill(0);for(let e of n.archetypes)e.size=0,e.entityRow.clear();for(let e of n.componentStorageByBit)if(e)if(e.kind==="soa"&&e.soa)for(let o of Object.keys(e.soa))e.soa[o]?.fill(0);else e.kind==="aos"&&e.aos&&e.aos.fill(void 0);n.queryVersion++;for(let e of n.reactiveBuffers.values())e.entered.length=0,e.exited.length=0;}function Un(t){return l(t).size}function On(t){return l(t).capacity}function B(t,n){if(n<=t.capacity)return;if(n>t.options.maxEntities)throw new Error(`aiecsjs: requested capacity ${n} exceeds maxEntities ${t.options.maxEntities}`);let e=t.capacity;for(;e<n;)e=Math.min(e*2,t.options.maxEntities);an(t,e);}function an(t,n){let e=t.generations.constructor,o=new e(n);o.set(t.generations),t.generations=o;let r=new Uint32Array(n);r.set(t.entityArchetype),t.entityArchetype=r;let i=t.options.maskWordCount,s=new Uint32Array(n*i);s.set(t.entityMask),t.entityMask=s;for(let a of t.componentStorageByBit)if(a)if(a.kind==="soa"&&a.soa){let c=t.componentInfoByBit[a.bit];c&&cn(a.soa,c.fields,n);}else a.kind==="aos"&&a.aos&&(a.aos.length=n);t.capacity=n;}function cn(t,n,e){for(let o of n){let r=t[o.name];if(!r)continue;let i=e*o.vectorLen;if(r.length>=i)continue;let s=new o.ctor(i);s.set(r),t[o.name]=s;}}function D(t,n){let e=S(n),o=t.archetypeByMaskHash.get(e);if(o!==void 0)return {archId:o,created:false};let r=t.archetypes.length,i={id:r,mask:h(n),size:0,capacity:16,entities:new Uint32Array(16),entityRow:new Map,componentBits:fn(n),edgeAdd:new Int32Array(t.options.maxComponents).fill(-1),edgeRemove:new Int32Array(t.options.maxComponents).fill(-1)};return t.archetypes.push(i),t.archetypeByMaskHash.set(e,r),t.queryVersion++,{archId:r,created:true}}function g(t,n){if(n<=t.capacity)return;let e=t.capacity;for(;e<n;)e*=2;let o=new Uint32Array(e);o.set(t.entities),t.entities=o,t.capacity=e;}function fn(t){let n=[];for(let e=0;e<t.length;e++){let o=t[e]??0;for(;o!==0;){let r=o&-o,i=(e<<5)+(31-Math.clz32(r));n.push(i),o&=o-1;}}return n}function N(t,n){let e=t.componentBitFor.get(n.id);if(e!==void 0)return e;if(t.nextComponentBit>=t.options.maxComponents)throw new Error(`aiecsjs: world reached maxComponents=${t.options.maxComponents}`);let o=t.nextComponentBit++;t.componentBitFor.set(n.id,o),t.componentInfoByBit[o]=n;let r;if(n.kind==="soa"){let i={};for(let s of n.fields)i[s.name]=new s.ctor(t.capacity*s.vectorLen);r={kind:"soa",componentId:n.id,bit:o,soa:i};}else n.kind==="aos"?r={kind:"aos",componentId:n.id,bit:o,aos:new Array(t.capacity)}:r={kind:"tag",componentId:n.id,bit:o};return t.componentStorageByBit[o]=r,o}function m(t,n){let e=t.options.maskWordCount,o=new Uint32Array(e),i=(n&t.options.indexMask)*e;for(let s=0;s<e;s++)o[s]=t.entityMask[i+s]??0;return o}function P(t,n,e){let o=t.options.maskWordCount,i=(n&t.options.indexMask)*o;for(let s=0;s<o;s++)t.entityMask[i+s]=e[s]??0;}function k(t,n){return t.componentBitFor.get(n.id)}function Rn(t){if(!t||typeof t!="object")return false;let n=t;return typeof n.id!="number"||typeof n.version!="string"?false:A.has(n.id)}var U=1,dn={i8:Int8Array,u8:Uint8Array,i16:Int16Array,u16:Uint16Array,i32:Int32Array,u32:Uint32Array,f32:Float32Array,f64:Float64Array,eid:Uint32Array,bool:Uint8Array},w=new Map;function Fn(t){let n=[];for(let[i,s]of Object.entries(t)){let a,c=1;if(typeof s=="string")a=s;else if(Array.isArray(s)){let[d,u]=s;a=d,c=u;}else throw new TypeError(`aiecsjs: invalid field declaration for "${i}"`);let f=dn[a];if(!f)throw new TypeError(`aiecsjs: unknown field type "${a}" for field "${i}"`);n.push({name:i,type:a,vectorLen:c,ctor:f,bytesPerElement:f.BYTES_PER_ELEMENT});}let e=U++,o={id:e,kind:"soa",schema:t,fields:n,factory:null};return w.set(e,o),{__kind:"soa",__id:e,__schema:t}}function zn(){let t=U++,n={id:t,kind:"tag",schema:null,fields:[],factory:null};return w.set(t,n),{__kind:"tag",__id:t}}function Dn(t){let n=U++,e=t??(()=>({})),o={id:n,kind:"aos",schema:null,fields:[],factory:e};return w.set(n,o),{__kind:"aos",__id:n,__factory:e}}function x(t){let n=w.get(t.__id);if(!n)throw new Error("aiecsjs: component is not registered (call defineComponent/defineTag/defineObjectComponent)");return n}function q(t,n,e,o){let r=l(t);if(r.readOnly)throw new Error("aiecsjs: cannot mutate a read-only world");if(!p(r,n))throw new Error(`aiecsjs: addComponent on dead entity ${n}`);let i=x(e),s=N(r,i),a=m(r,n);if(b(a,s)){o!==void 0&&M(r,n,e,o);return}let c=h(a);F(c,s),H(r,n,c),M(r,n,e,o),un(r,n,s),O(r,n,s,a,c);}function Nn(t,n,e){let o=l(t);if(o.readOnly)throw new Error("aiecsjs: cannot mutate a read-only world");if(!p(o,n))return;let r=x(e),i=k(o,r);if(i===void 0)return;let s=m(o,n);if(!b(s,i))return;let a=h(s);I(a,i),H(o,n,a),yn(o,n,i);let c=n&o.options.indexMask,f=o.componentStorageByBit[i];f?.kind==="soa"&&f.soa?$(f.soa,r.fields,c):f?.kind==="aos"&&f.aos&&(f.aos[c]=void 0),O(o,n,i,s,a);}function Pn(t,n,e){let o=l(t);if(!p(o,n))return false;let r=x(e),i=k(o,r);if(i===void 0)return false;let s=m(o,n);return b(s,i)}function qn(t,n,e){let o=l(t);if(!p(o,n))return;let r=x(e),i=k(o,r);if(i===void 0)return;let s=m(o,n);if(!b(s,i))return;let a=o.componentStorageByBit[i];if(a){if(a.kind==="soa")return a.soa;if(a.kind==="aos"){let c=n&o.options.indexMask;return a.aos?.[c]}return true}}function $n(t,n,e,o){let r=l(t);if(r.readOnly)throw new Error("aiecsjs: cannot mutate a read-only world");if(!p(r,n))throw new Error(`aiecsjs: setComponent on dead entity ${n}`);let i=x(e),s=k(r,i);if(s===void 0){q(t,n,e,o);return}let a=m(r,n);if(!b(a,s)){q(t,n,e,o);return}M(r,n,e,o),ln(r,n,s,o);}function M(t,n,e,o){let r=x(e),i=t.componentBitFor.get(r.id);if(i===void 0)return;let s=t.componentStorageByBit[i];if(!s)return;let a=n&t.options.indexMask;if(r.kind==="soa"&&s.soa){if(o==null)return;let c=o;for(let f of r.fields){if(!(f.name in c))continue;let d=s.soa[f.name];if(!d)continue;let u=c[f.name];if(f.vectorLen===1)d[a]=typeof u=="boolean"?u?1:0:Number(u);else if(Array.isArray(u)||ArrayBuffer.isView(u)){let y=a*f.vectorLen,Z=u;for(let C=0;C<f.vectorLen;C++)d[y+C]=Number(Z[C]??0);}}}else if(r.kind==="aos"&&s.aos){let c=r.factory??(()=>({})),f=s.aos[a];if(f===void 0&&(f=c(),s.aos[a]=f),o&&typeof o=="object"){let d=o,u=f;for(let y of Object.keys(d))y==="__proto__"||y==="constructor"||y==="prototype"||(u[y]=d[y]);}}}function $(t,n,e){for(let o of n){let r=t[o.name];if(r)if(o.vectorLen===1)r[e]=0;else {let i=e*o.vectorLen;for(let s=0;s<o.vectorLen;s++)r[i+s]=0;}}}function G(t,n){let e=t.options.maskWordCount,o=n&t.options.indexMask,r=o*e;W(t.entityMask,r,e,i=>{let s=t.componentStorageByBit[i],a=t.componentInfoByBit[i];s?.kind==="soa"&&s.soa&&a?$(s.soa,a.fields,o):s?.kind==="aos"&&s.aos&&(s.aos[o]=void 0);});}function H(t,n,e){let o=n&t.options.indexMask,r=t.entityArchetype[o]??0,i=t.archetypes[r];if(!i)return;let a=D(t,e).archId,c=t.archetypes[a];if(c){if(a!==r){let f=i.entityRow.get(n);if(f!==void 0){let u=i.size-1;if(f!==u){let y=i.entities[u]??0;i.entities[f]=y,i.entityRow.set(y,f);}i.entities[u]=0,i.entityRow.delete(n),i.size--;}g(c,c.size+1);let d=c.size;c.entities[d]=n,c.entityRow.set(n,d),c.size++,t.entityArchetype[o]=a;}P(t,n,e);}}var v={fireAdd:()=>{},fireRemove:()=>{},fireSet:()=>{}},V=()=>{};function Gn(t){V=t;}function O(t,n,e,o,r){V(t,n,e,o,r);}function Y(t,n,e){let o=t.options.maskWordCount,r=h(e),i=h(e);W(e,0,o,s=>{I(i,s),O(t,n,s,r,i),I(r,s);});}function Hn(t){v=t;}function un(t,n,e){v.fireAdd(t,n,e);}function yn(t,n,e){v.fireRemove(t,n,e);}function ln(t,n,e,o){v.fireSet(t,n,e,o);}function Vn(t){return w.get(t)}function Yn(){return Array.from(w.values())}var L=24,pn=8,X=(1<<L)-1,K=(1<<pn)-1;function Q(t,n,e){return ((n&e.generationMask)<<e.indexBits|t&e.indexMask)>>>0}function Zn(t,n){return t&n.indexMask}function Jn(t,n){return t>>>n.indexBits&n.generationMask}function nt(t){let n=l(t);if(n.readOnly)throw new Error("aiecsjs: cannot createEntity on a read-only world (worker-attached)");let e;if(n.freeList.length>0)e=n.freeList.pop();else {if(n.nextFreshIndex>=n.options.maxEntities)throw new Error(`aiecsjs: reached maxEntities ${n.options.maxEntities}`);n.nextFreshIndex>=n.capacity&&B(n,n.nextFreshIndex+1),e=n.nextFreshIndex++;}let o=n.generations[e]??0,r=Q(e,o,n.options),i=n.archetypes[0];if(!i)throw new Error("aiecsjs: missing empty archetype");g(i,i.size+1);let s=i.size;i.entities[s]=r,i.entityRow.set(r,s),i.size++,n.entityArchetype[e]=0;let a=n.options.maskWordCount,c=e*a;for(let f=0;f<a;f++)n.entityMask[c+f]=0;return n.size++,r}function tt(t,n){if(t.readOnly)throw new Error("aiecsjs: cannot create entities on a read-only world (worker-attached)");if(n<=0||n>=t.options.maxEntities)throw new Error(`aiecsjs: slot index ${n} out of range`);n>=t.capacity&&B(t,n+1);let e=t.generations[n]??0,o=Q(n,e,t.options);if(p(t,o))return o;if(n>=t.nextFreshIndex){for(let c=t.nextFreshIndex;c<n;c++)t.freeList.push(c);t.nextFreshIndex=n+1;}else {let c=t.freeList.lastIndexOf(n);if(c!==-1){let f=t.freeList.length-1;t.freeList[c]=t.freeList[f],t.freeList.pop();}}let r=t.archetypes[0];if(!r)throw new Error("aiecsjs: missing empty archetype");g(r,r.size+1);let i=r.size;r.entities[i]=o,r.entityRow.set(o,i),r.size++,t.entityArchetype[n]=0;let s=t.options.maskWordCount,a=n*s;for(let c=0;c<s;c++)t.entityMask[a+c]=0;return t.size++,o}function et(t,n){let e=l(t);if(e.readOnly)throw new Error("aiecsjs: cannot destroyEntity on a read-only world");if(!p(e,n))return;let o=n&e.options.indexMask,r=m(e,n),{dispatchDestroyObservers:i}=hn();i(e,n),bn(e,n),G(e,n);let s=e.entityArchetype[o]??0,a=e.archetypes[s];if(a){let d=a.entityRow.get(n);if(d!==void 0){let u=a.size-1;if(d!==u){let y=a.entities[u]??0;a.entities[d]=y,a.entityRow.set(y,d);}a.entities[u]=0,a.entityRow.delete(n),a.size--;}}Y(e,n,r),e.entityArchetype[o]=0;let c=e.options.maskWordCount,f=o*c;for(let d=0;d<c;d++)e.entityMask[f+d]=0;e.generations[o]=(e.generations[o]??0)+1&e.options.generationMask,e.freeList.push(o),e.size--;}function mn(t,n){let e=l(t);return p(e,n)}function p(t,n){let e=n&t.options.indexMask;if(e<=0||e>=t.capacity)return false;let o=t.entityArchetype[e]??0,r=t.archetypes[o];if(!r||!r.entityRow.has(n))return false;let i=t.generations[e]??0,s=n>>>t.options.indexBits&t.options.generationMask;return i===s}function ot(t){return t&X}function rt(t){return t>>>L&K}function it(t,n){return ((n&K)<<L|t&X)>>>0}function st(t,n){return typeof n!="number"?false:mn(t,n)}var R=null;function at(t){R=t;}function hn(){return R||{dispatchDestroyObservers:()=>{}}}var _=null;function ct(t){_=t;}function bn(t,n){_&&_(t,n);}exports.A=rt;exports.B=it;exports.C=st;exports.D=at;exports.E=ct;exports.F=Fn;exports.G=zn;exports.H=Dn;exports.I=x;exports.J=q;exports.K=Nn;exports.L=Pn;exports.M=qn;exports.N=$n;exports.O=Gn;exports.P=Hn;exports.Q=Vn;exports.R=Yn;exports.a=j;exports.b=T;exports.c=F;exports.d=wn;exports.e=xn;exports.f=gn;exports.g=W;exports.h=kn;exports.i=l;exports.j=Sn;exports.k=Wn;exports.l=Bn;exports.m=Mn;exports.n=Un;exports.o=On;exports.p=N;exports.q=Rn;exports.r=Q;exports.s=Zn;exports.t=Jn;exports.u=nt;exports.v=tt;exports.w=et;exports.x=mn;exports.y=p;exports.z=ot;//# sourceMappingURL=chunk-RNWXP3GU.cjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-RNWXP3GU.cjs.map
|