@almadar/core 10.11.0 → 10.13.0
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/dist/builders.d.ts +3 -3
- package/dist/builders.js +18 -2
- package/dist/builders.js.map +1 -1
- package/dist/{compose-behaviors-D9bQEgqN.d.ts → compose-behaviors-CmTHzC3Z.d.ts} +1 -1
- package/dist/factory/index.d.ts +3 -3
- package/dist/factory-runtime/index.d.ts +3 -3
- package/dist/factory-runtime/index.js +102 -73
- package/dist/factory-runtime/index.js.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.js +22 -3
- package/dist/index.js.map +1 -1
- package/dist/{schema-CtOoanon.d.ts → schema-DisJeRQc.d.ts} +1 -1
- package/dist/{trait-BB1dc5A_.d.ts → trait-Bwhkhv3V.d.ts} +190 -47
- package/dist/types/index.d.ts +6 -6
- package/dist/types/index.js +22 -3
- package/dist/types/index.js.map +1 -1
- package/dist/{types-COc0mLs1.d.ts → types-CIi6Vxmc.d.ts} +1 -1
- package/package.json +1 -1
package/dist/factory/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { g as FactoryParamValue, c as FactoryConfigTier, b as FactoryConfigParam, F as FactoryCallSite, h as FactorySignature, R as RuleOverlay, p as RuleOverlayEntry, o as PresentationOverlay, q as TraitOverlay } from '../types-
|
|
2
|
-
export { a as FactoryCallSiteParams, d as FactoryEntitySignature, e as FactoryEventSignature, f as FactoryPageSignature, i as FactorySignatureCatalog, j as FactorySignatureEntityField, k as FactoryTraitSignature, m as JsonSchema, n as JsonSchemaType, J as JsonValue, O as OwnershipOverlayEntry, P as PresentationNavItem, S as SchemaFieldType, r as TraitOverlayEntry, s as TraitOverlayListener } from '../types-
|
|
3
|
-
import { g as EntityPersistence, f as EntityField, j as TraitReference } from '../trait-
|
|
1
|
+
import { g as FactoryParamValue, c as FactoryConfigTier, b as FactoryConfigParam, F as FactoryCallSite, h as FactorySignature, R as RuleOverlay, p as RuleOverlayEntry, o as PresentationOverlay, q as TraitOverlay } from '../types-CIi6Vxmc.js';
|
|
2
|
+
export { a as FactoryCallSiteParams, d as FactoryEntitySignature, e as FactoryEventSignature, f as FactoryPageSignature, i as FactorySignatureCatalog, j as FactorySignatureEntityField, k as FactoryTraitSignature, m as JsonSchema, n as JsonSchemaType, J as JsonValue, O as OwnershipOverlayEntry, P as PresentationNavItem, S as SchemaFieldType, r as TraitOverlayEntry, s as TraitOverlayListener } from '../types-CIi6Vxmc.js';
|
|
3
|
+
import { g as EntityPersistence, f as EntityField, j as TraitReference } from '../trait-Bwhkhv3V.js';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import '../expression-BUIi9ezJ.js';
|
|
6
6
|
import '@almadar/patterns';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { O as OrbitalSchema, a as OrbitalDefinition } from '../schema-
|
|
2
|
-
import { f as EntityField, g as EntityPersistence, C as CallSiteConfig,
|
|
1
|
+
import { O as OrbitalSchema, a as OrbitalDefinition } from '../schema-DisJeRQc.js';
|
|
2
|
+
import { f as EntityField, g as EntityPersistence, C as CallSiteConfig, $ as CallSiteConfigEntry, a as Trait } from '../trait-Bwhkhv3V.js';
|
|
3
3
|
import { MakeTraitRefOpts } from '../builders.js';
|
|
4
4
|
import '../expression-BUIi9ezJ.js';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import '@almadar/patterns';
|
|
7
|
-
import '../compose-behaviors-
|
|
7
|
+
import '../compose-behaviors-CmTHzC3Z.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Orbital factory manifest types — shared across all packages.
|
|
@@ -1,67 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import '@almadar/patterns';
|
|
3
3
|
|
|
4
|
-
// src/
|
|
5
|
-
var STATIC_PARAM_FIELDS = [
|
|
6
|
-
{
|
|
7
|
-
name: "fields",
|
|
8
|
-
type: "EntityField[]",
|
|
9
|
-
description: "Extra fields appended to the canonical entity."
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
name: "pagePath",
|
|
13
|
-
type: "string",
|
|
14
|
-
description: "URL override for the orbital first page."
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
name: "persistence",
|
|
18
|
-
type: "'persistent' | 'runtime' | 'singleton' | 'instance' | 'local'",
|
|
19
|
-
description: "Override the canonical entity persistence mode."
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
name: "entityName",
|
|
23
|
-
type: "string",
|
|
24
|
-
description: "Rename the canonical entity. PascalCase singular, \u226432 chars. Threads through every trait's linkedEntity binding; compiler rewrites @Entity.x refs."
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
name: "collection",
|
|
28
|
-
type: "string",
|
|
29
|
-
description: "Override derived collection key. Defaults to plural(entityName).toLowerCase()."
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
name: "traitOverrides",
|
|
33
|
-
type: "Partial<Record<TraitName, { config?, linkedEntity?, events?, name?, emitsScope?, listens? }>>",
|
|
34
|
-
description: ".lolo's native trait-composition surface 1:1: per-imported-trait config, linkedEntity, events, name, emitsScope, listens. effects is excluded (atom-owned; use listens via a sibling trait)."
|
|
35
|
-
}
|
|
36
|
-
];
|
|
37
|
-
function splitTraits(traits) {
|
|
38
|
-
const refTraitNames = [];
|
|
39
|
-
const inlineTraitNames = [];
|
|
40
|
-
for (const t of traits) {
|
|
41
|
-
if (!t || typeof t !== "object") continue;
|
|
42
|
-
const tName = typeof t.name === "string" ? t.name : null;
|
|
43
|
-
if (!tName) continue;
|
|
44
|
-
if (typeof t.ref === "string") {
|
|
45
|
-
refTraitNames.push(tName);
|
|
46
|
-
} else {
|
|
47
|
-
inlineTraitNames.push(tName);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return { refTraitNames, inlineTraitNames };
|
|
51
|
-
}
|
|
52
|
-
function extractManifest(orb) {
|
|
53
|
-
const behaviorName = orb.name;
|
|
54
|
-
return orb.orbitals.map((orbital) => {
|
|
55
|
-
const { refTraitNames, inlineTraitNames } = splitTraits(orbital.traits);
|
|
56
|
-
return {
|
|
57
|
-
organism: behaviorName,
|
|
58
|
-
orbitalName: orbital.name,
|
|
59
|
-
paramFields: STATIC_PARAM_FIELDS,
|
|
60
|
-
traitNames: refTraitNames,
|
|
61
|
-
inlineTraitNames
|
|
62
|
-
};
|
|
63
|
-
});
|
|
64
|
-
}
|
|
4
|
+
// src/types/orbital.ts
|
|
65
5
|
z.enum([
|
|
66
6
|
"string",
|
|
67
7
|
"number",
|
|
@@ -224,11 +164,27 @@ var GAME_TYPES = [
|
|
|
224
164
|
"rpg"
|
|
225
165
|
];
|
|
226
166
|
var GameTypeSchema = z.enum(GAME_TYPES);
|
|
167
|
+
var ANIMATION_NAMES = ["idle", "walk", "attack", "hit", "death"];
|
|
168
|
+
var AnimationNameSchema = z.enum(ANIMATION_NAMES);
|
|
169
|
+
var SPRITE_DIRECTIONS = ["se", "sw"];
|
|
170
|
+
var SpriteDirectionSchema = z.enum(SPRITE_DIRECTIONS);
|
|
227
171
|
var AnimationDefSchema = z.object({
|
|
228
|
-
|
|
229
|
-
|
|
172
|
+
row: z.number().int().nonnegative(),
|
|
173
|
+
frames: z.number().int().positive(),
|
|
174
|
+
frameRate: z.number().positive(),
|
|
230
175
|
loop: z.boolean()
|
|
231
176
|
});
|
|
177
|
+
z.object({
|
|
178
|
+
unit: z.string().optional(),
|
|
179
|
+
type: z.string().optional(),
|
|
180
|
+
frameWidth: z.number().positive(),
|
|
181
|
+
frameHeight: z.number().positive(),
|
|
182
|
+
columns: z.number().int().positive(),
|
|
183
|
+
rows: z.number().int().positive(),
|
|
184
|
+
directions: z.array(SpriteDirectionSchema),
|
|
185
|
+
sheets: z.record(SpriteDirectionSchema, z.string()),
|
|
186
|
+
animations: z.record(AnimationNameSchema, AnimationDefSchema)
|
|
187
|
+
});
|
|
232
188
|
var SemanticAssetRefSchema = z.object({
|
|
233
189
|
role: EntityRoleSchema,
|
|
234
190
|
category: z.string().min(1),
|
|
@@ -296,6 +252,9 @@ var OrbitalEntitySchema = z.object({
|
|
|
296
252
|
assetRef: SemanticAssetRefSchema.optional()
|
|
297
253
|
});
|
|
298
254
|
var EntitySchema = OrbitalEntitySchema;
|
|
255
|
+
function persistenceModeAllowsOverrides(persistence) {
|
|
256
|
+
return persistence === "persistent" || persistence === void 0;
|
|
257
|
+
}
|
|
299
258
|
var UI_SLOTS = [
|
|
300
259
|
// App slots
|
|
301
260
|
"main",
|
|
@@ -1311,6 +1270,80 @@ z.object({
|
|
|
1311
1270
|
});
|
|
1312
1271
|
z.string();
|
|
1313
1272
|
|
|
1273
|
+
// src/factory-runtime/extract-manifest.ts
|
|
1274
|
+
var STATIC_PARAM_FIELDS = [
|
|
1275
|
+
{
|
|
1276
|
+
name: "fields",
|
|
1277
|
+
type: "EntityField[]",
|
|
1278
|
+
description: "Extra fields appended to the canonical entity."
|
|
1279
|
+
},
|
|
1280
|
+
{
|
|
1281
|
+
name: "pagePath",
|
|
1282
|
+
type: "string",
|
|
1283
|
+
description: "URL override for the orbital first page."
|
|
1284
|
+
},
|
|
1285
|
+
{
|
|
1286
|
+
name: "persistence",
|
|
1287
|
+
type: "'persistent' | 'runtime' | 'singleton' | 'instance' | 'local'",
|
|
1288
|
+
description: "Override the canonical entity persistence mode."
|
|
1289
|
+
},
|
|
1290
|
+
{
|
|
1291
|
+
name: "entityName",
|
|
1292
|
+
type: "string",
|
|
1293
|
+
description: "Rename the canonical entity. PascalCase singular, \u226432 chars. Threads through every trait's linkedEntity binding; compiler rewrites @Entity.x refs."
|
|
1294
|
+
},
|
|
1295
|
+
{
|
|
1296
|
+
name: "collection",
|
|
1297
|
+
type: "string",
|
|
1298
|
+
description: "Override derived collection key. Defaults to plural(entityName).toLowerCase()."
|
|
1299
|
+
},
|
|
1300
|
+
{
|
|
1301
|
+
name: "traitOverrides",
|
|
1302
|
+
type: "Partial<Record<TraitName, { config?, linkedEntity?, events?, name?, emitsScope?, listens? }>>",
|
|
1303
|
+
description: ".lolo's native trait-composition surface 1:1: per-imported-trait config, linkedEntity, events, name, emitsScope, listens. effects is excluded (atom-owned; use listens via a sibling trait)."
|
|
1304
|
+
}
|
|
1305
|
+
];
|
|
1306
|
+
function entityPersistence(entity) {
|
|
1307
|
+
if (entity && typeof entity === "object" && !("extends" in entity)) {
|
|
1308
|
+
return entity.persistence;
|
|
1309
|
+
}
|
|
1310
|
+
return void 0;
|
|
1311
|
+
}
|
|
1312
|
+
function paramFieldsForPersistence(persistence) {
|
|
1313
|
+
if (persistenceModeAllowsOverrides(persistence)) {
|
|
1314
|
+
return STATIC_PARAM_FIELDS;
|
|
1315
|
+
}
|
|
1316
|
+
return STATIC_PARAM_FIELDS.filter((f) => f.name !== "persistence" && f.name !== "collection");
|
|
1317
|
+
}
|
|
1318
|
+
function splitTraits(traits) {
|
|
1319
|
+
const refTraitNames = [];
|
|
1320
|
+
const inlineTraitNames = [];
|
|
1321
|
+
for (const t of traits) {
|
|
1322
|
+
if (!t || typeof t !== "object") continue;
|
|
1323
|
+
const tName = typeof t.name === "string" ? t.name : null;
|
|
1324
|
+
if (!tName) continue;
|
|
1325
|
+
if (typeof t.ref === "string") {
|
|
1326
|
+
refTraitNames.push(tName);
|
|
1327
|
+
} else {
|
|
1328
|
+
inlineTraitNames.push(tName);
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
return { refTraitNames, inlineTraitNames };
|
|
1332
|
+
}
|
|
1333
|
+
function extractManifest(orb) {
|
|
1334
|
+
const behaviorName = orb.name;
|
|
1335
|
+
return orb.orbitals.map((orbital) => {
|
|
1336
|
+
const { refTraitNames, inlineTraitNames } = splitTraits(orbital.traits);
|
|
1337
|
+
return {
|
|
1338
|
+
organism: behaviorName,
|
|
1339
|
+
orbitalName: orbital.name,
|
|
1340
|
+
paramFields: paramFieldsForPersistence(entityPersistence(orbital.entity)),
|
|
1341
|
+
traitNames: refTraitNames,
|
|
1342
|
+
inlineTraitNames
|
|
1343
|
+
};
|
|
1344
|
+
});
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1314
1347
|
// src/builders.ts
|
|
1315
1348
|
function makeTraitRef(opts) {
|
|
1316
1349
|
const ref2 = { ref: opts.ref };
|
|
@@ -1352,14 +1385,7 @@ function validateOrbitalFactoryParams(manifest, raw) {
|
|
|
1352
1385
|
error: { kind: "not-object", received: Array.isArray(raw) ? "array" : "null" }
|
|
1353
1386
|
};
|
|
1354
1387
|
}
|
|
1355
|
-
const ALLOWED_KEYS =
|
|
1356
|
-
"fields",
|
|
1357
|
-
"pagePath",
|
|
1358
|
-
"persistence",
|
|
1359
|
-
"entityName",
|
|
1360
|
-
"collection",
|
|
1361
|
-
"traitOverrides"
|
|
1362
|
-
]);
|
|
1388
|
+
const ALLOWED_KEYS = new Set(manifest.paramFields.map((f) => f.name));
|
|
1363
1389
|
for (const key of Object.keys(raw)) {
|
|
1364
1390
|
if (!ALLOWED_KEYS.has(key)) {
|
|
1365
1391
|
return { ok: false, error: { kind: "unknown-key", key } };
|
|
@@ -1450,12 +1476,15 @@ function buildEntity(ctx, effectiveName, effectiveCollection, params) {
|
|
|
1450
1476
|
...extras
|
|
1451
1477
|
];
|
|
1452
1478
|
}
|
|
1479
|
+
const allowPersistenceOverride = persistenceModeAllowsOverrides(
|
|
1480
|
+
ctx.canonicalEntity.persistence
|
|
1481
|
+
);
|
|
1453
1482
|
const entity = {
|
|
1454
1483
|
name: effectiveName,
|
|
1455
|
-
persistence: params.persistence ?? ctx.canonicalEntity.persistence,
|
|
1484
|
+
persistence: allowPersistenceOverride ? params.persistence ?? ctx.canonicalEntity.persistence : ctx.canonicalEntity.persistence,
|
|
1456
1485
|
fields: [...mergedFields]
|
|
1457
1486
|
};
|
|
1458
|
-
if (effectiveCollection !== void 0) {
|
|
1487
|
+
if (allowPersistenceOverride && effectiveCollection !== void 0) {
|
|
1459
1488
|
entity.collection = effectiveCollection;
|
|
1460
1489
|
}
|
|
1461
1490
|
return entity;
|