@combos-fun/engine 0.1.16 → 0.1.18
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/agent-skill.md +1 -1
- package/dist/engine.cjs.js +93 -3
- package/dist/engine.cjs.js.map +1 -1
- package/dist/engine.cjs.prod.js +1 -1
- package/dist/engine.d.ts +25 -3
- package/dist/engine.esm.js +91 -4
- package/dist/engine.esm.js.map +1 -1
- package/package.json +4 -6
- package/references/public-api.md +0 -95
package/agent-skill.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# `@combos-fun/engine` — Agent short card
|
|
2
2
|
|
|
3
|
-
ECS microkernel.
|
|
3
|
+
ECS microkernel. New plugins: `plugin-authoring.md`.
|
|
4
4
|
|
|
5
5
|
- `Game`, `Scene`, `GameObject`, `Component`, `System`, `resource`, `decorators`. Hierarchy: `addChild` / `parent` / `children`. 2D pose: `Transform2D`. 3D pose: `Transform3D`.
|
|
6
6
|
- `await game.addSystem(new XxxSystem(...))`. `Game({ systems })` awaits each `init`. `addSystem(XxxSystem, [params])` passes the tuple as one argument.
|
package/dist/engine.cjs.js
CHANGED
|
@@ -891,7 +891,7 @@ class Scene extends GameObject {
|
|
|
891
891
|
}
|
|
892
892
|
|
|
893
893
|
/** Generated at build from package.json */
|
|
894
|
-
const version = "0.1.
|
|
894
|
+
const version = "0.1.18";
|
|
895
895
|
|
|
896
896
|
/**
|
|
897
897
|
* Sent to `window.parent` after each `System.init` completes during `Game.addSystem`
|
|
@@ -1842,6 +1842,35 @@ function frameFromPackedItem(item) {
|
|
|
1842
1842
|
sourceSize: item.sourceSize,
|
|
1843
1843
|
};
|
|
1844
1844
|
}
|
|
1845
|
+
function cloneAnimations(source) {
|
|
1846
|
+
const animations = {};
|
|
1847
|
+
if (!source || typeof source !== 'object')
|
|
1848
|
+
return animations;
|
|
1849
|
+
for (const key of Object.keys(source)) {
|
|
1850
|
+
const list = source[key];
|
|
1851
|
+
animations[key] = Array.isArray(list) ? list.map((frame) => String(frame)) : [];
|
|
1852
|
+
}
|
|
1853
|
+
return animations;
|
|
1854
|
+
}
|
|
1855
|
+
function deriveClipNames(names, animations) {
|
|
1856
|
+
const listed = new Set();
|
|
1857
|
+
for (const frames of Object.values(animations)) {
|
|
1858
|
+
for (const name of frames)
|
|
1859
|
+
listed.add(name);
|
|
1860
|
+
}
|
|
1861
|
+
for (const name of names) {
|
|
1862
|
+
if (!name || listed.has(name))
|
|
1863
|
+
continue;
|
|
1864
|
+
const slash = name.lastIndexOf('/');
|
|
1865
|
+
if (slash <= 0)
|
|
1866
|
+
continue;
|
|
1867
|
+
const clip = name.slice(0, slash);
|
|
1868
|
+
if (!animations[clip])
|
|
1869
|
+
animations[clip] = [];
|
|
1870
|
+
animations[clip].push(name);
|
|
1871
|
+
listed.add(name);
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1845
1874
|
function collectArrayFrames(list, frames, animations) {
|
|
1846
1875
|
for (const raw of list) {
|
|
1847
1876
|
if (!raw || typeof raw !== 'object')
|
|
@@ -1876,15 +1905,17 @@ function normalizeSpritesheetData(raw) {
|
|
|
1876
1905
|
}
|
|
1877
1906
|
const json = raw;
|
|
1878
1907
|
if (isFrameMap(json.frames)) {
|
|
1908
|
+
const animations = cloneAnimations(json.animations);
|
|
1909
|
+
deriveClipNames(Object.keys(json.frames), animations);
|
|
1879
1910
|
return {
|
|
1880
1911
|
...json,
|
|
1881
1912
|
frames: json.frames,
|
|
1882
|
-
animations
|
|
1913
|
+
animations,
|
|
1883
1914
|
meta: { scale: 1, ...(json.meta || {}) },
|
|
1884
1915
|
};
|
|
1885
1916
|
}
|
|
1886
1917
|
const frames = {};
|
|
1887
|
-
const animations =
|
|
1918
|
+
const animations = cloneAnimations(json.animations);
|
|
1888
1919
|
if (Array.isArray(json.textures)) {
|
|
1889
1920
|
for (const sheet of json.textures) {
|
|
1890
1921
|
if (!sheet || typeof sheet !== 'object')
|
|
@@ -1921,6 +1952,62 @@ function normalizeSpritesheetData(raw) {
|
|
|
1921
1952
|
meta: { scale: 1, ...(json.meta || {}) },
|
|
1922
1953
|
};
|
|
1923
1954
|
}
|
|
1955
|
+
function spriteClipKeyOrder(raw) {
|
|
1956
|
+
if (!raw || typeof raw !== 'object')
|
|
1957
|
+
return 'insertion';
|
|
1958
|
+
const frames = raw.frames;
|
|
1959
|
+
if (isFrameMap(frames))
|
|
1960
|
+
return 'lexical';
|
|
1961
|
+
return 'insertion';
|
|
1962
|
+
}
|
|
1963
|
+
/**
|
|
1964
|
+
* Ordered frames plus clips named by the path prefix (`idle/frame0000` → `idle`).
|
|
1965
|
+
* TexturePacker `textures[].frames` and a top-level `frames` array keep source order.
|
|
1966
|
+
* A top-level `frames` object uses lexical key order.
|
|
1967
|
+
*/
|
|
1968
|
+
function readSpriteClipSheet(raw, keyOrder = spriteClipKeyOrder(raw)) {
|
|
1969
|
+
const normalized = normalizeSpritesheetData(raw);
|
|
1970
|
+
const names = Object.keys(normalized.frames);
|
|
1971
|
+
if (keyOrder === 'lexical')
|
|
1972
|
+
names.sort();
|
|
1973
|
+
const frames = names.map((name) => ({ ...normalized.frames[name], name }));
|
|
1974
|
+
const byName = new Map(frames.map((frame) => [frame.name, frame]));
|
|
1975
|
+
const animations = {};
|
|
1976
|
+
const declared = normalized.animations || {};
|
|
1977
|
+
for (const clip of Object.keys(declared)) {
|
|
1978
|
+
const sourceNames = declared[clip] || [];
|
|
1979
|
+
const frameNames = keyOrder === 'lexical' ? [...sourceNames].sort() : sourceNames;
|
|
1980
|
+
const list = [];
|
|
1981
|
+
for (const frameName of frameNames) {
|
|
1982
|
+
const frame = byName.get(frameName);
|
|
1983
|
+
if (frame)
|
|
1984
|
+
list.push(frame);
|
|
1985
|
+
}
|
|
1986
|
+
if (list.length)
|
|
1987
|
+
animations[clip] = list;
|
|
1988
|
+
}
|
|
1989
|
+
if (Object.keys(animations).length === 0) {
|
|
1990
|
+
for (const frame of frames) {
|
|
1991
|
+
const slash = frame.name.lastIndexOf('/');
|
|
1992
|
+
if (slash <= 0)
|
|
1993
|
+
continue;
|
|
1994
|
+
const clip = frame.name.slice(0, slash);
|
|
1995
|
+
if (!animations[clip])
|
|
1996
|
+
animations[clip] = [];
|
|
1997
|
+
animations[clip].push(frame);
|
|
1998
|
+
}
|
|
1999
|
+
}
|
|
2000
|
+
return { frames, animations, meta: normalized.meta };
|
|
2001
|
+
}
|
|
2002
|
+
function resolveSpriteClip(frames, animations, name) {
|
|
2003
|
+
const clip = String(name ?? '').trim();
|
|
2004
|
+
if (!clip)
|
|
2005
|
+
return { frames: [...frames], clip: '', missing: false };
|
|
2006
|
+
const found = animations[clip];
|
|
2007
|
+
if (!found || found.length === 0)
|
|
2008
|
+
return { frames: [], clip, missing: true };
|
|
2009
|
+
return { frames: [...found], clip, missing: false };
|
|
2010
|
+
}
|
|
1924
2011
|
|
|
1925
2012
|
/** Resource type */
|
|
1926
2013
|
exports.RESOURCE_TYPE = void 0;
|
|
@@ -2398,9 +2485,12 @@ exports.parseSetPlayingMessage = parseSetPlayingMessage;
|
|
|
2398
2485
|
exports.postParentGameReady = postParentGameReady;
|
|
2399
2486
|
exports.postParentGameState = postParentGameState;
|
|
2400
2487
|
exports.postParentPluginInitSuccess = postParentPluginInitSuccess;
|
|
2488
|
+
exports.readSpriteClipSheet = readSpriteClipSheet;
|
|
2401
2489
|
exports.resolveRenderQuality = resolveRenderQuality;
|
|
2490
|
+
exports.resolveSpriteClip = resolveSpriteClip;
|
|
2402
2491
|
exports.resource = resource;
|
|
2403
2492
|
exports.resourceLoader = resourceLoader;
|
|
2404
2493
|
exports.shouldPauseRendering = shouldPauseRendering;
|
|
2494
|
+
exports.spriteClipKeyOrder = spriteClipKeyOrder;
|
|
2405
2495
|
exports.version = version;
|
|
2406
2496
|
//# sourceMappingURL=engine.cjs.js.map
|