@almadar/core 10.101.0 → 10.103.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 +5 -5
- package/dist/builders.js +6 -2
- package/dist/builders.js.map +1 -1
- package/dist/{bus-B8evi8AZ.d.ts → bus-BGojNDOE.d.ts} +52 -7
- package/dist/{domain-Ds_7wZIL.d.ts → domain-OgMkN3WN.d.ts} +13 -1
- package/dist/{effect-Hm_QDaSI.d.ts → effect-Xn3LIyL7.d.ts} +1 -1
- package/dist/{entityAccess-DdcKps16.d.ts → entityAccess-z5HA0P7P.d.ts} +3 -3
- package/dist/{expression-DRwzVnMu.d.ts → expression-CfeHdS-f.d.ts} +10 -1
- package/dist/factory/index.d.ts +5 -5
- package/dist/factory/index.js.map +1 -1
- package/dist/factory-runtime/index.d.ts +5 -5
- package/dist/factory-runtime/index.js +42 -8
- package/dist/factory-runtime/index.js.map +1 -1
- package/dist/fixtures.d.ts +3 -3
- package/dist/fixtures.js +27 -2
- package/dist/fixtures.js.map +1 -1
- package/dist/i18n/index.js +27 -6
- package/dist/i18n/index.js.map +1 -1
- package/dist/{index-1b2JJVYl.d.ts → index-CVYZ3GcI.d.ts} +122 -23
- package/dist/index.d.ts +74 -17
- package/dist/index.js +417 -72
- package/dist/index.js.map +1 -1
- package/dist/lolo-document/index.d.ts +166 -0
- package/dist/lolo-document/index.js +615 -0
- package/dist/lolo-document/index.js.map +1 -0
- package/dist/mock/index.d.ts +6 -6
- package/dist/mock/index.js +12 -1
- package/dist/mock/index.js.map +1 -1
- package/dist/patterns/index.d.ts +22 -4
- package/dist/patterns/index.js +41 -1
- package/dist/patterns/index.js.map +1 -1
- package/dist/{schema-TqLV2wlK.d.ts → schema-sHVqe8Kb.d.ts} +1307 -4
- package/dist/state-machine/index.d.ts +1 -1
- package/dist/themes/index.d.ts +1 -1
- package/dist/themes/index.js +2 -1
- package/dist/themes/index.js.map +1 -1
- package/dist/{trait-YlNXc4H3.d.ts → trait-BSe6oDBd.d.ts} +79 -3
- package/dist/types/index.d.ts +8 -8
- package/dist/types/index.js +227 -12
- package/dist/types/index.js.map +1 -1
- package/dist/{types-Ug92oza4.d.ts → types-DK29MMOQ.d.ts} +2 -2
- package/fixtures/events-wire/client-effects-provenance/request.json +5 -0
- package/fixtures/events-wire/client-effects-provenance/response.json +57 -0
- package/package.json +6 -1
- package/src/types/bindings.ts +28 -3
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* lolo-document — structural index + text-span mutations over a `.lolo` source
|
|
3
|
+
* (moved from Kura's scene editor so every editor of `.lolo` shares one owner).
|
|
4
|
+
*
|
|
5
|
+
* NOT a lolo parser: `orbital-lolo` (the `orb` binary) is the parser of record and the
|
|
6
|
+
* server's emit + validate is the correctness gate after every mutation. This module only
|
|
7
|
+
* locates the constructs the editor mutates (uses / entity / traits / config entries /
|
|
8
|
+
* events / listens / pages) as byte spans and produces `TextEdit[]`; every byte outside a
|
|
9
|
+
* touched span is preserved verbatim, so `applyEdits(text, [])` is the identity.
|
|
10
|
+
*/
|
|
11
|
+
interface Span {
|
|
12
|
+
start: number;
|
|
13
|
+
end: number;
|
|
14
|
+
}
|
|
15
|
+
interface TextEdit {
|
|
16
|
+
start: number;
|
|
17
|
+
end: number;
|
|
18
|
+
insert: string;
|
|
19
|
+
}
|
|
20
|
+
type LoloValue = string | number | boolean | null | ReadonlyArray<LoloValue> | {
|
|
21
|
+
readonly [key: string]: LoloValue;
|
|
22
|
+
};
|
|
23
|
+
interface UsesDecl {
|
|
24
|
+
alias: string;
|
|
25
|
+
from: string;
|
|
26
|
+
span: Span;
|
|
27
|
+
}
|
|
28
|
+
interface TypeDecl {
|
|
29
|
+
name: string;
|
|
30
|
+
span: Span;
|
|
31
|
+
}
|
|
32
|
+
interface EntityFieldDecl {
|
|
33
|
+
name: string;
|
|
34
|
+
type: string;
|
|
35
|
+
span: Span;
|
|
36
|
+
}
|
|
37
|
+
interface EntityDecl {
|
|
38
|
+
name: string;
|
|
39
|
+
tags: string;
|
|
40
|
+
fields: EntityFieldDecl[];
|
|
41
|
+
span: Span;
|
|
42
|
+
bodySpan: Span;
|
|
43
|
+
}
|
|
44
|
+
interface ConfigEntry {
|
|
45
|
+
key: string;
|
|
46
|
+
/** Present for inline (typed) config declarations: `key : Type = value`. */
|
|
47
|
+
type?: string;
|
|
48
|
+
valueSpan: Span;
|
|
49
|
+
rawValue: string;
|
|
50
|
+
span: Span;
|
|
51
|
+
}
|
|
52
|
+
interface EventsEntry {
|
|
53
|
+
upstream: string;
|
|
54
|
+
local: string;
|
|
55
|
+
span: Span;
|
|
56
|
+
}
|
|
57
|
+
interface BlockDecl {
|
|
58
|
+
span: Span;
|
|
59
|
+
bodySpan: Span;
|
|
60
|
+
}
|
|
61
|
+
interface ConfigBlock extends BlockDecl {
|
|
62
|
+
entries: ConfigEntry[];
|
|
63
|
+
}
|
|
64
|
+
interface EventsBlock extends BlockDecl {
|
|
65
|
+
entries: EventsEntry[];
|
|
66
|
+
}
|
|
67
|
+
interface TraitDecl {
|
|
68
|
+
name: string;
|
|
69
|
+
inline: boolean;
|
|
70
|
+
alias?: string;
|
|
71
|
+
trait?: string;
|
|
72
|
+
entity?: string;
|
|
73
|
+
rebindable: boolean;
|
|
74
|
+
span: Span;
|
|
75
|
+
bodySpan: Span;
|
|
76
|
+
config?: ConfigBlock;
|
|
77
|
+
events?: EventsBlock;
|
|
78
|
+
listens?: BlockDecl;
|
|
79
|
+
stateBlocks: Array<{
|
|
80
|
+
name: string;
|
|
81
|
+
span: Span;
|
|
82
|
+
}>;
|
|
83
|
+
}
|
|
84
|
+
interface PageDecl {
|
|
85
|
+
path: string;
|
|
86
|
+
name?: string;
|
|
87
|
+
traits: string[];
|
|
88
|
+
/** The ` ->` token (leading whitespace included); absent for a trait-less page. */
|
|
89
|
+
arrowSpan?: Span;
|
|
90
|
+
/** The trait list after `->`; for a trait-less page, the empty insertion point after the head. */
|
|
91
|
+
traitsSpan: Span;
|
|
92
|
+
span: Span;
|
|
93
|
+
}
|
|
94
|
+
interface LoloDocument {
|
|
95
|
+
text: string;
|
|
96
|
+
app?: {
|
|
97
|
+
name: string;
|
|
98
|
+
version: string;
|
|
99
|
+
span: Span;
|
|
100
|
+
};
|
|
101
|
+
orbital: {
|
|
102
|
+
name: string;
|
|
103
|
+
span: Span;
|
|
104
|
+
bodySpan: Span;
|
|
105
|
+
};
|
|
106
|
+
uses: UsesDecl[];
|
|
107
|
+
types: TypeDecl[];
|
|
108
|
+
entities: EntityDecl[];
|
|
109
|
+
traits: TraitDecl[];
|
|
110
|
+
pages: PageDecl[];
|
|
111
|
+
/** Indentation (whitespace string) of the orbital's direct children. */
|
|
112
|
+
indent: string;
|
|
113
|
+
}
|
|
114
|
+
interface ListenRoute {
|
|
115
|
+
source: string;
|
|
116
|
+
event: string;
|
|
117
|
+
local: string;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Find the index of the matching closing delimiter for the opener at `openIdx`.
|
|
121
|
+
* Respects strings and comments. Returns -1 when unbalanced.
|
|
122
|
+
*/
|
|
123
|
+
declare function matchDelimiter(text: string, openIdx: number): number;
|
|
124
|
+
declare function lineStart(text: string, idx: number): number;
|
|
125
|
+
/** The `uses` alias for a behavior: its kebab name in PascalCase, the identifier form `USES_RE` indexes (`std-arcade-flow` → `StdArcadeFlow`). */
|
|
126
|
+
declare function aliasForBehavior(behavior: string): string;
|
|
127
|
+
declare function parseLoloDocument(text: string): LoloDocument;
|
|
128
|
+
declare function applyEdits(text: string, edits: ReadonlyArray<TextEdit>): string;
|
|
129
|
+
/**
|
|
130
|
+
* Render a value in the `.lolo` literal style the corpus uses: objects inline with commas,
|
|
131
|
+
* arrays of objects one element per line (no commas), scalar arrays inline space-separated.
|
|
132
|
+
*/
|
|
133
|
+
declare function formatLoloValue(value: LoloValue, indent?: string): string;
|
|
134
|
+
declare function addUses(doc: LoloDocument, alias: string, from: string): TextEdit[];
|
|
135
|
+
declare function usesAlias(doc: LoloDocument, from: string): string | undefined;
|
|
136
|
+
interface AddTraitRefInput {
|
|
137
|
+
name: string;
|
|
138
|
+
alias: string;
|
|
139
|
+
trait: string;
|
|
140
|
+
entity: string;
|
|
141
|
+
config: Record<string, LoloValue>;
|
|
142
|
+
events?: Record<string, string>;
|
|
143
|
+
}
|
|
144
|
+
declare function addTraitRef(doc: LoloDocument, input: AddTraitRefInput): TextEdit[];
|
|
145
|
+
declare function removeTrait(doc: LoloDocument, name: string): TextEdit[];
|
|
146
|
+
declare function findPage(doc: LoloDocument, path: string): PageDecl;
|
|
147
|
+
declare function appendPageTrait(doc: LoloDocument, path: string, traitName: string): TextEdit[];
|
|
148
|
+
declare function removePageTrait(doc: LoloDocument, path: string, traitName: string): TextEdit[];
|
|
149
|
+
declare function setConfigValue(doc: LoloDocument, traitName: string, key: string, value: LoloValue): TextEdit[];
|
|
150
|
+
/** Top-level elements of an array literal `[ … ]` as spans (balanced, string-aware). */
|
|
151
|
+
declare function arrayElementSpans(text: string, arraySpan: Span): Span[];
|
|
152
|
+
declare function setConfigArrayRow(doc: LoloDocument, traitName: string, key: string, index: number, patch: Record<string, LoloValue>): TextEdit[];
|
|
153
|
+
declare function renameEvent(doc: LoloDocument, traitName: string, upstream: string, local: string): TextEdit[];
|
|
154
|
+
/**
|
|
155
|
+
* Add a listens route. On a referenced trait a `listens {}` override REPLACES the atom's
|
|
156
|
+
* set, so the atom's own routes are restated first (`atomRoutes`) — the rebind-listens trap.
|
|
157
|
+
*/
|
|
158
|
+
declare function addListens(doc: LoloDocument, traitName: string, route: ListenRoute, atomRoutes?: ReadonlyArray<ListenRoute>): TextEdit[];
|
|
159
|
+
interface LoloFieldInput {
|
|
160
|
+
name: string;
|
|
161
|
+
type: string;
|
|
162
|
+
default?: LoloValue;
|
|
163
|
+
}
|
|
164
|
+
declare function addEntityFields(doc: LoloDocument, entityName: string, fields: ReadonlyArray<LoloFieldInput>): TextEdit[];
|
|
165
|
+
|
|
166
|
+
export { type AddTraitRefInput, type BlockDecl, type ConfigBlock, type ConfigEntry, type EntityDecl, type EntityFieldDecl, type EventsBlock, type EventsEntry, type ListenRoute, type LoloDocument, type LoloFieldInput, type LoloValue, type PageDecl, type Span, type TextEdit, type TraitDecl, type TypeDecl, type UsesDecl, addEntityFields, addListens, addTraitRef, addUses, aliasForBehavior, appendPageTrait, applyEdits, arrayElementSpans, findPage, formatLoloValue, lineStart, matchDelimiter, parseLoloDocument, removePageTrait, removeTrait, renameEvent, setConfigArrayRow, setConfigValue, usesAlias };
|