@codama/spec 1.6.0-rc.2 → 1.6.0-rc.4

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.
Files changed (98) hide show
  1. package/dist/api.browser.cjs +355 -0
  2. package/dist/api.browser.cjs.map +1 -0
  3. package/dist/api.browser.mjs +315 -0
  4. package/dist/api.browser.mjs.map +1 -0
  5. package/dist/api.node.cjs +355 -0
  6. package/dist/api.node.cjs.map +1 -0
  7. package/dist/api.node.mjs +315 -0
  8. package/dist/api.node.mjs.map +1 -0
  9. package/dist/api.react-native.mjs +315 -0
  10. package/dist/api.react-native.mjs.map +1 -0
  11. package/dist/index.browser.cjs +645 -438
  12. package/dist/index.browser.cjs.map +1 -1
  13. package/dist/index.browser.mjs +645 -438
  14. package/dist/index.browser.mjs.map +1 -1
  15. package/dist/index.node.cjs +645 -438
  16. package/dist/index.node.cjs.map +1 -1
  17. package/dist/index.node.mjs +645 -438
  18. package/dist/index.node.mjs.map +1 -1
  19. package/dist/index.react-native.mjs +645 -438
  20. package/dist/index.react-native.mjs.map +1 -1
  21. package/dist/types/api/attribute.d.ts +2 -2
  22. package/dist/types/api/attribute.d.ts.map +1 -1
  23. package/dist/types/api/defineCategory.d.ts +19 -0
  24. package/dist/types/api/defineCategory.d.ts.map +1 -0
  25. package/dist/types/api/defineEnumeration.d.ts +2 -2
  26. package/dist/types/api/defineEnumeration.d.ts.map +1 -1
  27. package/dist/types/api/defineNestedUnion.d.ts +29 -0
  28. package/dist/types/api/defineNestedUnion.d.ts.map +1 -0
  29. package/dist/types/api/defineNode.d.ts +2 -2
  30. package/dist/types/api/defineNode.d.ts.map +1 -1
  31. package/dist/types/api/defineUnion.d.ts +1 -1
  32. package/dist/types/api/defineUnion.d.ts.map +1 -1
  33. package/dist/types/api/index.d.ts +6 -4
  34. package/dist/types/api/index.d.ts.map +1 -1
  35. package/dist/types/api/primitives.d.ts +8 -4
  36. package/dist/types/api/primitives.d.ts.map +1 -1
  37. package/dist/types/api/public.d.ts +1 -1
  38. package/dist/types/api/public.d.ts.map +1 -1
  39. package/dist/types/api/semanticAliases.d.ts +17 -7
  40. package/dist/types/api/semanticAliases.d.ts.map +1 -1
  41. package/dist/types/api/types.d.ts +78 -21
  42. package/dist/types/api/types.d.ts.map +1 -1
  43. package/dist/types/api/validate.d.ts +5 -3
  44. package/dist/types/api/validate.d.ts.map +1 -1
  45. package/dist/types/v1/enumerations.d.ts.map +1 -1
  46. package/dist/types/v1/index.d.ts.map +1 -1
  47. package/dist/types/v1/nestedUnions.d.ts +9 -0
  48. package/dist/types/v1/nestedUnions.d.ts.map +1 -0
  49. package/dist/types/v1/nodes/AccountNode.d.ts.map +1 -1
  50. package/dist/types/v1/nodes/EventNode.d.ts.map +1 -1
  51. package/dist/types/v1/nodes/InstructionAccountNode.d.ts.map +1 -1
  52. package/dist/types/v1/nodes/InstructionByteDeltaNode.d.ts.map +1 -1
  53. package/dist/types/v1/nodes/InstructionNode.d.ts.map +1 -1
  54. package/dist/types/v1/nodes/InstructionRemainingAccountsNode.d.ts.map +1 -1
  55. package/dist/types/v1/nodes/InstructionStatusNode.d.ts.map +1 -1
  56. package/dist/types/v1/nodes/PdaNode.d.ts.map +1 -1
  57. package/dist/types/v1/nodes/ProgramNode.d.ts.map +1 -1
  58. package/dist/types/v1/nodes/RootNode.d.ts.map +1 -1
  59. package/dist/types/v1/nodes/contextualValueNodes/ConditionalValueNode.d.ts.map +1 -1
  60. package/dist/types/v1/nodes/contextualValueNodes/ContextualValueNode.d.ts.map +1 -1
  61. package/dist/types/v1/nodes/contextualValueNodes/ResolverValueNode.d.ts.map +1 -1
  62. package/dist/types/v1/nodes/linkNodes/InstructionAccountLinkNode.d.ts.map +1 -1
  63. package/dist/types/v1/nodes/linkNodes/InstructionArgumentLinkNode.d.ts.map +1 -1
  64. package/dist/types/v1/nodes/linkNodes/InstructionLinkNode.d.ts.map +1 -1
  65. package/dist/types/v1/nodes/typeNodes/AmountTypeNode.d.ts.map +1 -1
  66. package/dist/types/v1/nodes/typeNodes/ArrayTypeNode.d.ts.map +1 -1
  67. package/dist/types/v1/nodes/typeNodes/BytesTypeNode.d.ts.map +1 -1
  68. package/dist/types/v1/nodes/typeNodes/DateTimeTypeNode.d.ts.map +1 -1
  69. package/dist/types/v1/nodes/typeNodes/EnumEmptyVariantTypeNode.d.ts.map +1 -1
  70. package/dist/types/v1/nodes/typeNodes/EnumStructVariantTypeNode.d.ts.map +1 -1
  71. package/dist/types/v1/nodes/typeNodes/EnumTupleVariantTypeNode.d.ts.map +1 -1
  72. package/dist/types/v1/nodes/typeNodes/HiddenPrefixTypeNode.d.ts.map +1 -1
  73. package/dist/types/v1/nodes/typeNodes/HiddenSuffixTypeNode.d.ts.map +1 -1
  74. package/dist/types/v1/nodes/typeNodes/MapTypeNode.d.ts.map +1 -1
  75. package/dist/types/v1/nodes/typeNodes/OptionTypeNode.d.ts.map +1 -1
  76. package/dist/types/v1/nodes/typeNodes/PostOffsetTypeNode.d.ts.map +1 -1
  77. package/dist/types/v1/nodes/typeNodes/PreOffsetTypeNode.d.ts.map +1 -1
  78. package/dist/types/v1/nodes/typeNodes/RemainderOptionTypeNode.d.ts.map +1 -1
  79. package/dist/types/v1/nodes/typeNodes/SentinelTypeNode.d.ts.map +1 -1
  80. package/dist/types/v1/nodes/typeNodes/SetTypeNode.d.ts.map +1 -1
  81. package/dist/types/v1/nodes/typeNodes/StringTypeNode.d.ts.map +1 -1
  82. package/dist/types/v1/nodes/typeNodes/StructTypeNode.d.ts.map +1 -1
  83. package/dist/types/v1/nodes/typeNodes/ZeroableOptionTypeNode.d.ts.map +1 -1
  84. package/dist/types/v1/nodes/valueNodes/EnumValueNode.d.ts.map +1 -1
  85. package/dist/types/v1/nodes/valueNodes/NumberValueNode.d.ts.map +1 -1
  86. package/dist/v1.browser.cjs +645 -438
  87. package/dist/v1.browser.cjs.map +1 -1
  88. package/dist/v1.browser.mjs +645 -438
  89. package/dist/v1.browser.mjs.map +1 -1
  90. package/dist/v1.node.cjs +645 -438
  91. package/dist/v1.node.cjs.map +1 -1
  92. package/dist/v1.node.mjs +645 -438
  93. package/dist/v1.node.mjs.map +1 -1
  94. package/dist/v1.react-native.mjs +645 -438
  95. package/dist/v1.react-native.mjs.map +1 -1
  96. package/package.json +13 -1
  97. package/dist/types/v1/nestedTypeNodeWrappers.d.ts +0 -10
  98. package/dist/types/v1/nestedTypeNodeWrappers.d.ts.map +0 -1
@@ -0,0 +1,355 @@
1
+ 'use strict';
2
+
3
+ // src/api/attribute.ts
4
+ function attribute(name, type, options = {}) {
5
+ return Object.freeze({
6
+ name,
7
+ type,
8
+ ...options.optional ? { optional: true } : {},
9
+ ...options.docs !== void 0 ? { docs: Object.freeze([...options.docs]) } : {}
10
+ });
11
+ }
12
+ function optionalAttribute(name, type, options = {}) {
13
+ return attribute(name, type, { ...options, optional: true });
14
+ }
15
+
16
+ // src/api/compounds.ts
17
+ function array(inner) {
18
+ return Object.freeze({ kind: "array", of: inner });
19
+ }
20
+ function tuple(...items) {
21
+ return Object.freeze({ kind: "tuple", items: Object.freeze([...items]) });
22
+ }
23
+
24
+ // src/api/defineCategory.ts
25
+ function defineCategory(name, options = {}) {
26
+ return Object.freeze({
27
+ name,
28
+ ...options.docs !== void 0 ? { docs: Object.freeze([...options.docs]) } : {},
29
+ nodes: Object.freeze([...options.nodes ?? []]),
30
+ unions: Object.freeze([...options.unions ?? []]),
31
+ enumerations: Object.freeze([...options.enumerations ?? []]),
32
+ nestedUnions: Object.freeze([...options.nestedUnions ?? []])
33
+ });
34
+ }
35
+
36
+ // src/api/defineEnumeration.ts
37
+ function variant(name, options = {}) {
38
+ return Object.freeze({
39
+ name,
40
+ ...options.docs !== void 0 ? { docs: Object.freeze([...options.docs]) } : {}
41
+ });
42
+ }
43
+ function defineEnumeration(name, options) {
44
+ if (options.variants.length === 0) {
45
+ throw new Error(`defineEnumeration("${name}"): variants must be non-empty`);
46
+ }
47
+ const seen = /* @__PURE__ */ new Set();
48
+ for (const v of options.variants) {
49
+ if (seen.has(v.name)) {
50
+ throw new Error(`defineEnumeration("${name}"): duplicate variant "${v.name}"`);
51
+ }
52
+ seen.add(v.name);
53
+ }
54
+ return Object.freeze({
55
+ name,
56
+ variants: Object.freeze([...options.variants]),
57
+ ...options.docs !== void 0 ? { docs: Object.freeze([...options.docs]) } : {}
58
+ });
59
+ }
60
+
61
+ // src/api/defineNestedUnion.ts
62
+ function defineNestedUnion(name, options) {
63
+ return Object.freeze({
64
+ name,
65
+ ...options.docs !== void 0 ? { docs: Object.freeze([...options.docs]) } : {},
66
+ base: options.base,
67
+ wrappers: Object.freeze([...options.wrappers])
68
+ });
69
+ }
70
+
71
+ // src/api/defineNode.ts
72
+ function defineNode(kind, options) {
73
+ return Object.freeze({
74
+ kind,
75
+ ...options.docs !== void 0 ? { docs: Object.freeze([...options.docs]) } : {},
76
+ attributes: Object.freeze([...options.attributes]),
77
+ examples: Object.freeze([...options.examples ?? []])
78
+ });
79
+ }
80
+
81
+ // src/api/defineUnion.ts
82
+ function defineUnion(name, options) {
83
+ const normalised = options.members.map(normaliseMember);
84
+ return Object.freeze({
85
+ name,
86
+ members: Object.freeze(normalised),
87
+ ...options.docs !== void 0 ? { docs: Object.freeze([...options.docs]) } : {}
88
+ });
89
+ }
90
+ function normaliseMember(input) {
91
+ if (typeof input === "string") {
92
+ return Object.freeze({ kind: "node", name: input });
93
+ }
94
+ if (input.kind === "node") return Object.freeze({ kind: "node", name: input.name });
95
+ if (input.kind === "union") return Object.freeze({ kind: "union", name: input.name });
96
+ throw new Error(
97
+ `defineUnion: members must be node kind strings, node(...) or union(...) references; got ${JSON.stringify(input)}`
98
+ );
99
+ }
100
+
101
+ // src/api/primitives.ts
102
+ function string() {
103
+ return Object.freeze({ kind: "string" });
104
+ }
105
+ function stringIdentifier() {
106
+ return Object.freeze({ kind: "string", constraint: "identifier" });
107
+ }
108
+ function stringVersion() {
109
+ return Object.freeze({ kind: "string", constraint: "version" });
110
+ }
111
+ function codamaVersion() {
112
+ return Object.freeze({ kind: "codamaVersion" });
113
+ }
114
+ var integer = (width) => Object.freeze({ kind: "integer", width });
115
+ var u8 = () => integer("u8");
116
+ var u16 = () => integer("u16");
117
+ var u32 = () => integer("u32");
118
+ var u64 = () => integer("u64");
119
+ var u128 = () => integer("u128");
120
+ var i8 = () => integer("i8");
121
+ var i16 = () => integer("i16");
122
+ var i32 = () => integer("i32");
123
+ var i64 = () => integer("i64");
124
+ var i128 = () => integer("i128");
125
+ var float = (width) => Object.freeze({ kind: "float", width });
126
+ var f32 = () => float("f32");
127
+ var f64 = () => float("f64");
128
+ function boolean() {
129
+ return Object.freeze({ kind: "boolean" });
130
+ }
131
+ function literal(value) {
132
+ return Object.freeze({ kind: "literal", value });
133
+ }
134
+ function literalUnion(...values) {
135
+ if (values.length === 0) {
136
+ throw new Error("literalUnion: at least one value required");
137
+ }
138
+ const seen = /* @__PURE__ */ new Set();
139
+ for (const v of values) {
140
+ if (seen.has(v)) {
141
+ throw new Error(`literalUnion: duplicate value ${JSON.stringify(v)}`);
142
+ }
143
+ seen.add(v);
144
+ }
145
+ return Object.freeze({ kind: "literalUnion", values: Object.freeze([...values]) });
146
+ }
147
+ function enumeration(name) {
148
+ return Object.freeze({ kind: "enumeration", name });
149
+ }
150
+ function node(name) {
151
+ return Object.freeze({ kind: "node", name });
152
+ }
153
+ function union(name) {
154
+ return Object.freeze({ kind: "union", name });
155
+ }
156
+ function nestedUnion(alias, name) {
157
+ return Object.freeze({ kind: "nestedUnion", alias, name });
158
+ }
159
+
160
+ // src/api/semanticAliases.ts
161
+ function byteSize() {
162
+ return u64();
163
+ }
164
+ function byteOffset() {
165
+ return i64();
166
+ }
167
+ function count() {
168
+ return u32();
169
+ }
170
+ function docs() {
171
+ return Object.freeze({ kind: "docs" });
172
+ }
173
+
174
+ // src/api/validate.ts
175
+ function validate(spec) {
176
+ const errors = [];
177
+ const allNodes = [];
178
+ const allUnions = [];
179
+ const allEnumerations = [];
180
+ const allNestedUnions = [];
181
+ for (const c of spec.categories) {
182
+ allNodes.push(...c.nodes);
183
+ allUnions.push(...c.unions);
184
+ allEnumerations.push(...c.enumerations);
185
+ allNestedUnions.push(...c.nestedUnions);
186
+ }
187
+ const nodeKinds = new Set(allNodes.map((n) => n.kind));
188
+ const unionNames = new Set(allUnions.map((u) => u.name));
189
+ const enumerationNames = new Set(allEnumerations.map((e) => e.name));
190
+ const nestedUnionNames = new Set(allNestedUnions.map((nu) => nu.name));
191
+ const registrations = /* @__PURE__ */ new Map();
192
+ const record = (name, kind) => {
193
+ const list = registrations.get(name);
194
+ if (list) list.push(kind);
195
+ else registrations.set(name, [kind]);
196
+ };
197
+ for (const n of allNodes) record(n.kind, "node");
198
+ for (const u of allUnions) record(u.name, "union");
199
+ for (const e of allEnumerations) record(e.name, "enumeration");
200
+ for (const nu of allNestedUnions) record(nu.name, "nestedUnion");
201
+ for (const [name, kinds] of registrations) {
202
+ if (kinds.length > 1) errors.push(formatCollisionError(name, kinds));
203
+ }
204
+ const seenCategories = /* @__PURE__ */ new Set();
205
+ for (const c of spec.categories) {
206
+ if (seenCategories.has(c.name)) {
207
+ errors.push(`Category "${c.name}" is declared more than once.`);
208
+ }
209
+ seenCategories.add(c.name);
210
+ }
211
+ for (const n of allNodes) {
212
+ if (!/^[a-z][A-Za-z0-9]*Node$/.test(n.kind)) {
213
+ errors.push(`Node kind "${n.kind}" does not match the camelCase ...Node naming convention.`);
214
+ }
215
+ const seenAttrs = /* @__PURE__ */ new Set();
216
+ for (const a of n.attributes) {
217
+ if (seenAttrs.has(a.name)) {
218
+ errors.push(`Node "${n.kind}" declares attribute "${a.name}" more than once.`);
219
+ }
220
+ seenAttrs.add(a.name);
221
+ walkTypeExpr(
222
+ a.type,
223
+ (expr) => checkRef(expr, n.kind, a.name, errors, nodeKinds, unionNames, enumerationNames, nestedUnionNames)
224
+ );
225
+ }
226
+ }
227
+ for (const u of allUnions) {
228
+ if (u.members.length === 0) {
229
+ errors.push(`Union "${u.name}" has no members.`);
230
+ }
231
+ const seenMembers = /* @__PURE__ */ new Set();
232
+ for (const m of u.members) {
233
+ const key = `${m.kind}:${m.name}`;
234
+ if (seenMembers.has(key)) {
235
+ errors.push(`Union "${u.name}" lists member ${key} more than once.`);
236
+ }
237
+ seenMembers.add(key);
238
+ if (m.kind === "node" && !nodeKinds.has(m.name)) {
239
+ errors.push(`Union "${u.name}" references undefined node "${m.name}".`);
240
+ }
241
+ if (m.kind === "union" && !unionNames.has(m.name)) {
242
+ errors.push(`Union "${u.name}" references undefined union "${m.name}".`);
243
+ }
244
+ }
245
+ }
246
+ for (const nu of allNestedUnions) {
247
+ if (nu.wrappers.length === 0) {
248
+ errors.push(`Nested union "${nu.name}" has no wrappers.`);
249
+ }
250
+ for (const w of nu.wrappers) {
251
+ if (!nodeKinds.has(w)) {
252
+ errors.push(`Nested union "${nu.name}" wrapper "${w}" is not a defined node.`);
253
+ }
254
+ }
255
+ }
256
+ return errors;
257
+ }
258
+ function formatCollisionError(name, kinds) {
259
+ const counts = /* @__PURE__ */ new Map();
260
+ for (const k of kinds) counts.set(k, (counts.get(k) ?? 0) + 1);
261
+ const breakdown = [...counts.entries()].sort((a, b) => a[0].localeCompare(b[0])).map(([k, n]) => `${n} ${k}${n > 1 ? "s" : ""}`).join(", ");
262
+ return `Name "${name}" is registered ${kinds.length} times (${breakdown}); names must be unique across nodes, unions, enumerations, and nested unions.`;
263
+ }
264
+ function walkTypeExpr(expr, visit) {
265
+ visit(expr);
266
+ if (expr.kind === "array") {
267
+ walkTypeExpr(expr.of, visit);
268
+ } else if (expr.kind === "tuple") {
269
+ for (const item of expr.items) walkTypeExpr(item, visit);
270
+ }
271
+ }
272
+ function checkRef(expr, nodeKind, attrName, errors, nodeKinds, unionNames, enumerationNames, nestedUnionNames) {
273
+ const where = `Node "${nodeKind}", attribute "${attrName}":`;
274
+ switch (expr.kind) {
275
+ case "node":
276
+ if (!nodeKinds.has(expr.name)) {
277
+ errors.push(`${where} references undefined node "${expr.name}".`);
278
+ }
279
+ break;
280
+ case "union":
281
+ if (!unionNames.has(expr.name)) {
282
+ errors.push(`${where} references undefined union "${expr.name}".`);
283
+ }
284
+ break;
285
+ case "enumeration":
286
+ if (!enumerationNames.has(expr.name)) {
287
+ errors.push(`${where} references undefined enumeration "${expr.name}".`);
288
+ }
289
+ break;
290
+ case "nestedUnion":
291
+ if (!nodeKinds.has(expr.name)) {
292
+ errors.push(`${where} nestedUnion references undefined node "${expr.name}".`);
293
+ }
294
+ if (!nestedUnionNames.has(expr.alias)) {
295
+ errors.push(`${where} nestedUnion references undefined alias "${expr.alias}".`);
296
+ }
297
+ break;
298
+ }
299
+ }
300
+ function isChildAttribute(type) {
301
+ switch (type.kind) {
302
+ case "node":
303
+ case "nestedUnion":
304
+ case "union":
305
+ return true;
306
+ case "array":
307
+ return isChildAttribute(type.of);
308
+ case "tuple":
309
+ return type.items.some(isChildAttribute);
310
+ default:
311
+ return false;
312
+ }
313
+ }
314
+
315
+ exports.array = array;
316
+ exports.attribute = attribute;
317
+ exports.boolean = boolean;
318
+ exports.byteOffset = byteOffset;
319
+ exports.byteSize = byteSize;
320
+ exports.codamaVersion = codamaVersion;
321
+ exports.count = count;
322
+ exports.defineCategory = defineCategory;
323
+ exports.defineEnumeration = defineEnumeration;
324
+ exports.defineNestedUnion = defineNestedUnion;
325
+ exports.defineNode = defineNode;
326
+ exports.defineUnion = defineUnion;
327
+ exports.docs = docs;
328
+ exports.enumeration = enumeration;
329
+ exports.f32 = f32;
330
+ exports.f64 = f64;
331
+ exports.i128 = i128;
332
+ exports.i16 = i16;
333
+ exports.i32 = i32;
334
+ exports.i64 = i64;
335
+ exports.i8 = i8;
336
+ exports.isChildAttribute = isChildAttribute;
337
+ exports.literal = literal;
338
+ exports.literalUnion = literalUnion;
339
+ exports.nestedUnion = nestedUnion;
340
+ exports.node = node;
341
+ exports.optionalAttribute = optionalAttribute;
342
+ exports.string = string;
343
+ exports.stringIdentifier = stringIdentifier;
344
+ exports.stringVersion = stringVersion;
345
+ exports.tuple = tuple;
346
+ exports.u128 = u128;
347
+ exports.u16 = u16;
348
+ exports.u32 = u32;
349
+ exports.u64 = u64;
350
+ exports.u8 = u8;
351
+ exports.union = union;
352
+ exports.validate = validate;
353
+ exports.variant = variant;
354
+ //# sourceMappingURL=api.browser.cjs.map
355
+ //# sourceMappingURL=api.browser.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/api/attribute.ts","../src/api/compounds.ts","../src/api/defineCategory.ts","../src/api/defineEnumeration.ts","../src/api/defineNestedUnion.ts","../src/api/defineNode.ts","../src/api/defineUnion.ts","../src/api/primitives.ts","../src/api/semanticAliases.ts","../src/api/validate.ts"],"names":[],"mappings":";;;AAoBO,SAAS,SAAA,CAAU,IAAA,EAAc,IAAA,EAAgB,OAAA,GAA4B,EAAC,EAAkB;AACnG,EAAA,OAAO,OAAO,MAAA,CAAO;AAAA,IACjB,IAAA;AAAA,IACA,IAAA;AAAA,IACA,GAAI,OAAA,CAAQ,QAAA,GAAW,EAAE,QAAA,EAAU,IAAA,KAAkB,EAAC;AAAA,IACtD,GAAI,OAAA,CAAQ,IAAA,KAAS,MAAA,GAAY,EAAE,IAAA,EAAM,MAAA,CAAO,MAAA,CAAO,CAAC,GAAG,OAAA,CAAQ,IAAI,CAAC,CAAA,KAAM;AAAC,GAClF,CAAA;AACL;AAMO,SAAS,iBAAA,CACZ,IAAA,EACA,IAAA,EACA,OAAA,GAA8C,EAAC,EAClC;AACb,EAAA,OAAO,SAAA,CAAU,MAAM,IAAA,EAAM,EAAE,GAAG,OAAA,EAAS,QAAA,EAAU,MAAM,CAAA;AAC/D;;;AC3BO,SAAS,MAAM,KAAA,EAA2B;AAC7C,EAAA,OAAO,OAAO,MAAA,CAAO,EAAE,MAAM,OAAA,EAAkB,EAAA,EAAI,OAAO,CAAA;AAC9D;AAOO,SAAS,SAAS,KAAA,EAA6B;AAClD,EAAA,OAAO,MAAA,CAAO,MAAA,CAAO,EAAE,IA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,aAAA;AACD,MAAA,IAAI,CAAC,SAAA,CAAU,GAAA,CAAI,IAAA,CAAK,IAAI,CAAA,EAAG;AAC3B,QAAA,MAAA,CAAO,KAAK,CAAA,EAAG,KAAK,CAAA,wCAAA,EAA2C,IAAA,CAAK,IAAI,CAAA,EAAA,CAAI,CAAA;AAAA,MAChF;AACA,MAAA,IAAI,CAAC,gBAAA,CAAiB,GAAA,CAAI,IAAA,CAAK,KAAK,CAAA,EAAG;AACnC,QAAA,MAAA,CAAO,KAAK,CAAA,EAAG,KAAK,CAAA,yCAAA,EAA4C,IAAA,CAAK,KAAK,CAAA,EAAA,CAAI,CAAA;AAAA,MAClF;AACA,MAAA;AAEA;AAEZ;AAUO,SAAS,iBAAiB,IAAA,EAAyB;AACtD,EAAA,QAAQ,KAAK,IAAA;AAAM,IACf,KAAK,MAAA;AAAA,IACL,KAAK,aAAA;AAAA,IACL,KAAK,OAAA;AACD,MAAA,OAAO,IAAA;AAAA,IACX,KAAK,OAAA;AACD,MAAA,OAAO,gBAAA,CAAiB,KAAK,EAAE,CAAA;AAAA,IACnC,KAAK,OAAA;AACD,MAAA,OAAO,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,gBAAgB,CAAA;AAAA,IAC3C;AACI,MAAA,OAAO,KAAA;AAAA;AAEnB","file":"api.browser.cjs","sourcesContent":["/**\n * Attribute factories — produce frozen `AttributeSpec` values directly.\n *\n * Every attribute of a node MUST be constructed via one of these helpers.\n * The returned value IS the encoded form; `defineNode` consumes them as-is.\n */\n\nimport type { AttributeSpec, TypeExpr } from './types';\n\nexport interface AttributeOptions {\n /** Free-form prose paragraphs describing this attribute. */\n readonly docs?: readonly string[];\n /** When `true`, the attribute may be absent in encoded values. */\n readonly optional?: boolean;\n}\n\n/**\n * Declare an attribute. The default is a required attribute; pass\n * `{ optional: true }` (or use `optionalAttribute`) to mark it optional.\n */\nexport function attribute(name: string, type: TypeExpr, options: AttributeOptions = {}): AttributeSpec {\n return Object.freeze({\n name,\n type,\n ...(options.optional ? { optional: true as const } : {}),\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n });\n}\n\n/**\n * Sugar for `attribute(name, type, { optional: true, ...rest })` — the most\n * common attribute shape after required ones.\n */\nexport function optionalAttribute(\n name: string,\n type: TypeExpr,\n options: Omit<AttributeOptions, 'optional'> = {},\n): AttributeSpec {\n return attribute(name, type, { ...options, optional: true });\n}\n","/**\n * Compound type-expression constructors — wrap or combine other type\n * expressions. Returned values are frozen.\n *\n * Optionality is intentionally NOT a compound: it's an attribute-level\n * concern, expressed via `optionalAttribute(...)` or\n * `attribute(..., { optional: true })`.\n */\n\nimport type { TypeExpr } from './types';\n\n/** An array (homogeneous list) of `inner`. */\nexport function array(inner: TypeExpr): TypeExpr {\n return Object.freeze({ kind: 'array' as const, of: inner });\n}\n\n/**\n * A heterogeneous fixed-length tuple. Each positional slot has its own type.\n *\n * Tuples use `items` (plural) rather than `of` to signal cardinality > 1.\n */\nexport function tuple(...items: TypeExpr[]): TypeExpr {\n return Object.freeze({ kind: 'tuple' as const, items: Object.freeze([...items]) });\n}\n","/**\n * `defineCategory(name, options)` — group a coherent set of nodes,\n * unions, enumerations, and nested unions under a single name.\n *\n * Categories double as a filing hint for codegen targets that organise\n * output by category (e.g. the TypeScript node-types generator emits\n * each category into its own subdirectory). Category names are arbitrary\n * strings; the spec doesn't constrain them.\n */\n\nimport type { CategorySpec, EnumerationSpec, NestedUnionSpec, NodeSpec, UnionSpec } from './types';\n\nexport interface DefineCategoryOptions {\n readonly docs?: readonly string[];\n readonly nodes?: readonly NodeSpec[];\n readonly unions?: readonly UnionSpec[];\n readonly enumerations?: readonly EnumerationSpec[];\n readonly nestedUnions?: readonly NestedUnionSpec[];\n}\n\nexport function defineCategory(name: string, options: DefineCategoryOptions = {}): CategorySpec {\n return Object.freeze({\n name,\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n nodes: Object.freeze([...(options.nodes ?? [])]),\n unions: Object.freeze([...(options.unions ?? [])]),\n enumerations: Object.freeze([...(options.enumerations ?? [])]),\n nestedUnions: Object.freeze([...(options.nestedUnions ?? [])]),\n });\n}\n","/**\n * `defineEnumeration(name, options)` — declares a named enumeration.\n *\n * Codegen emits a string-literal union (TS), a real `enum` (Rust), a class\n * (Python), etc., according to each language's idiom. Per-variant docs are\n * carried through to language-native member documentation.\n */\n\nimport type { EnumerationSpec, EnumerationVariantSpec } from './types';\n\nexport interface VariantOptions {\n readonly docs?: readonly string[];\n}\n\n/** Construct a single enumeration variant. */\nexport function variant(name: string, options: VariantOptions = {}): EnumerationVariantSpec {\n return Object.freeze({\n name,\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n });\n}\n\nexport interface DefineEnumerationOptions {\n readonly docs?: readonly string[];\n readonly variants: readonly EnumerationVariantSpec[];\n}\n\nexport function defineEnumeration(name: string, options: DefineEnumerationOptions): EnumerationSpec {\n if (options.variants.length === 0) {\n throw new Error(`defineEnumeration(\"${name}\"): variants must be non-empty`);\n }\n const seen = new Set<string>();\n for (const v of options.variants) {\n if (seen.has(v.name)) {\n throw new Error(`defineEnumeration(\"${name}\"): duplicate variant \"${v.name}\"`);\n }\n seen.add(v.name);\n }\n return Object.freeze({\n name,\n variants: Object.freeze([...options.variants]),\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n });\n}\n","/**\n * `defineNestedUnion(name, options)` — declares a recursive type alias,\n * e.g. `NestedTypeNode<T>`.\n *\n * Codegen renders one alternative per wrapper kind, plus the base case:\n *\n * ```ts\n * type Alias<T extends Base> = Wrapper1<Alias<T>> | Wrapper2<Alias<T>> | … | T;\n * ```\n *\n * Use the `nestedUnion(alias, innerKind)` `TypeExpr` helper to reference\n * an instance of this alias from an attribute.\n */\n\nimport type { NestedUnionSpec, TypeExpr } from './types';\n\nexport interface DefineNestedUnionOptions {\n readonly docs?: readonly string[];\n /**\n * The base type the recursion bottoms out in. Codegen renders this\n * as the alias's type-parameter constraint and as the final union arm.\n */\n readonly base: TypeExpr;\n /**\n * Node kinds that act as wrappers in the recursion. Each must be a\n * node whose attribute structure can wrap another `NestedUnion<T>`.\n */\n readonly wrappers: readonly string[];\n}\n\nexport function defineNestedUnion(name: string, options: DefineNestedUnionOptions): NestedUnionSpec {\n return Object.freeze({\n name,\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n base: options.base,\n wrappers: Object.freeze([...options.wrappers]),\n });\n}\n","/**\n * `defineNode(kind, options)` — declares a single Codama node.\n *\n * The `kind` string is the discriminator value. By convention it ends in\n * `Node` and uses camelCase (e.g. `accountNode`, `arrayTypeNode`).\n *\n * `attributes` is an ordered array of values produced by `attribute(...)` or\n * `optionalAttribute(...)`. Order is preserved in the encoded spec and, by\n * extension, in generated code. The `kind: literal(<kind>)` discriminator\n * is implicit and is NOT declared by authors.\n *\n * The data-vs-children distinction is derived at codegen time from each\n * attribute's type tree (see `isChildAttribute` in `validate.ts`); the\n * meta-model itself just stores a flat list.\n */\n\nimport type { AttributeSpec, NodeSpec } from './types';\n\nexport interface DefineNodeOptions {\n /** Free-form prose paragraphs describing this node. */\n readonly docs?: readonly string[];\n /**\n * Attributes of the node, in declaration order. Construct each entry\n * via `attribute(...)` or `optionalAttribute(...)`.\n */\n readonly attributes: readonly AttributeSpec[];\n /** Free-form examples (shape defined per spec major version). */\n readonly examples?: readonly unknown[];\n}\n\nexport function defineNode(kind: string, options: DefineNodeOptions): NodeSpec {\n return Object.freeze({\n kind,\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n attributes: Object.freeze([...options.attributes]),\n examples: Object.freeze([...(options.examples ?? [])]),\n });\n}\n","/**\n * `defineUnion(name, options)` — declares a named union of nodes.\n *\n * Members can be:\n * - a node kind string (e.g. `'arrayTypeNode'`), or\n * - a `node(...)` / `union(...)` reference (a `TypeExpr` produced by\n * `primitives.ts`).\n *\n * Nested unions are preserved structurally in the encoded spec rather than\n * flattened. This serves two purposes:\n * - DRY authoring (`union('StandaloneTypeNode')` instead of repeating 23\n * kind names).\n * - A signal to the Rust codegen to emit `From`/`Into` trait impls between\n * the parent union and each nested union.\n */\n\nimport type { TypeExpr, UnionMember, UnionSpec } from './types';\n\nexport type UnionMemberInput = TypeExpr | string;\n\nexport interface DefineUnionOptions {\n readonly docs?: readonly string[];\n readonly members: readonly UnionMemberInput[];\n}\n\nexport function defineUnion(name: string, options: DefineUnionOptions): UnionSpec {\n const normalised: UnionMember[] = options.members.map(normaliseMember);\n return Object.freeze({\n name,\n members: Object.freeze(normalised),\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n });\n}\n\nfunction normaliseMember(input: UnionMemberInput): UnionMember {\n if (typeof input === 'string') {\n // Bare strings are treated as node kinds (the most common case).\n return Object.freeze({ kind: 'node' as const, name: input });\n }\n if (input.kind === 'node') return Object.freeze({ kind: 'node' as const, name: input.name });\n if (input.kind === 'union') return Object.freeze({ kind: 'union' as const, name: input.name });\n throw new Error(\n `defineUnion: members must be node kind strings, node(...) or union(...) references; got ${JSON.stringify(input)}`,\n );\n}\n","/**\n * Type-expression primitives — the leaves of any attribute's type tree.\n *\n * Each function returns a frozen `TypeExpr` value. The encoded spec stores\n * those objects verbatim; codegen targets read them and emit native types.\n */\n\nimport type { FloatWidth, IntegerWidth, LiteralValue, StringConstraint, TypeExpr } from './types';\n\n// Strings.\n\n/** Plain UTF-8 string. */\nexport function string(): TypeExpr {\n return Object.freeze({ kind: 'string' as const });\n}\n\n/**\n * A string that must be a valid IDL identifier (stored canonically in\n * camelCase). Renderers may convert to other casings at output time.\n */\nexport function stringIdentifier(): TypeExpr {\n return Object.freeze({ kind: 'string' as const, constraint: 'identifier' as const });\n}\n\n/** A string that must be a valid version (e.g. `\"1.6.0\"`). */\nexport function stringVersion(): TypeExpr {\n return Object.freeze({ kind: 'string' as const, constraint: 'version' as const });\n}\n\n/**\n * The version string of the surrounding Codama spec. Treat as a brand on\n * top of `stringVersion()` — the value is always pinned to the spec\n * version of the IDL document. Codegen targets typically emit a literal\n * type or a constant.\n */\nexport function codamaVersion(): TypeExpr {\n return Object.freeze({ kind: 'codamaVersion' as const });\n}\n\n// Integers (explicit bit widths — no machine-dependent usize/isize).\n\nconst integer = (width: IntegerWidth): TypeExpr => Object.freeze({ kind: 'integer' as const, width });\n\nexport const u8 = (): TypeExpr => integer('u8');\nexport const u16 = (): TypeExpr => integer('u16');\nexport const u32 = (): TypeExpr => integer('u32');\nexport const u64 = (): TypeExpr => integer('u64');\nexport const u128 = (): TypeExpr => integer('u128');\nexport const i8 = (): TypeExpr => integer('i8');\nexport const i16 = (): TypeExpr => integer('i16');\nexport const i32 = (): TypeExpr => integer('i32');\nexport const i64 = (): TypeExpr => integer('i64');\nexport const i128 = (): TypeExpr => integer('i128');\n\n// Floats.\n\nconst float = (width: FloatWidth): TypeExpr => Object.freeze({ kind: 'float' as const, width });\n\nexport const f32 = (): TypeExpr => float('f32');\nexport const f64 = (): TypeExpr => float('f64');\n\n// Booleans and literals.\n\nexport function boolean(): TypeExpr {\n return Object.freeze({ kind: 'boolean' as const });\n}\n\n/** A single fixed value of a primitive type. */\nexport function literal(value: LiteralValue): TypeExpr {\n return Object.freeze({ kind: 'literal' as const, value });\n}\n\n/**\n * A heterogeneous union of literal values — for sum types like\n * `boolean | 'either'` that don't fit a string-only enumeration.\n *\n * Codegen targets render this as the appropriate language idiom (a literal\n * union in TS, a tagged enum with custom serde in Rust, etc.).\n */\nexport function literalUnion(...values: LiteralValue[]): TypeExpr {\n if (values.length === 0) {\n throw new Error('literalUnion: at least one value required');\n }\n const seen = new Set<LiteralValue>();\n for (const v of values) {\n if (seen.has(v)) {\n throw new Error(`literalUnion: duplicate value ${JSON.stringify(v)}`);\n }\n seen.add(v);\n }\n return Object.freeze({ kind: 'literalUnion' as const, values: Object.freeze([...values]) });\n}\n\n// Named references.\n\n/** Reference to a named enumeration declared via `defineEnumeration`. */\nexport function enumeration(name: string): TypeExpr {\n return Object.freeze({ kind: 'enumeration' as const, name });\n}\n\n/** Reference to a named node declared via `defineNode`. */\nexport function node(name: string): TypeExpr {\n return Object.freeze({ kind: 'node' as const, name });\n}\n\n/** Reference to a named union declared via `defineUnion`. */\nexport function union(name: string): TypeExpr {\n return Object.freeze({ kind: 'union' as const, name });\n}\n\n/**\n * Reference to a named node, wrapped by a named recursive `NestedUnion`\n * alias. `alias` selects which `NestedUnion` declared via\n * `defineNestedUnion` the wrapping uses (e.g. `'NestedTypeNode'`); `name`\n * is the inner node kind.\n *\n * Renderers emit `<alias><<innerInterface>>` and an import for the alias\n * file.\n */\nexport function nestedUnion(alias: string, name: string): TypeExpr {\n return Object.freeze({ kind: 'nestedUnion' as const, alias, name });\n}\n\n// Re-exports for type ergonomics.\nexport type { FloatWidth, IntegerWidth, LiteralValue, StringConstraint, TypeExpr };\n","/**\n * Author-side semantic aliases.\n *\n * Most aliases desugar at call time so the encoded spec only ever shows\n * the underlying primitive (e.g. `{ kind: \"integer\", width: \"u64\" }` for\n * both `u64()` and `byteSize()`). Each language's codegen may further\n * specialise rendering for these widths (e.g. Rust may render `u64` as\n * `usize` for byte-size fields if it wants). Those are codegen policies\n * — not spec content.\n *\n * `docs()` is the exception: it returns its own `'docs'` `TypeExpr` kind\n * so the documentation intent survives in the encoded spec rather than\n * collapsing to `array(string())`.\n */\n\nimport { i64, u32, u64 } from './primitives';\nimport type { TypeExpr } from './types';\n\n/** Number of bytes; non-negative. Encoded as `u64`. */\nexport function byteSize(): TypeExpr {\n return u64();\n}\n\n/** Signed byte offset. Encoded as `i64`. */\nexport function byteOffset(): TypeExpr {\n return i64();\n}\n\n/** Count of items in a collection; non-negative. Encoded as `u32`. */\nexport function count(): TypeExpr {\n return u32();\n}\n\n/**\n * Documentation for a node — semantically a list of paragraph strings,\n * but rendered per language at codegen time (e.g. `Array<string>` in\n * TypeScript, `Vec<String>` in Rust). Returns its own `'docs'` kind so\n * the intent isn't lost in the encoded spec.\n */\nexport function docs(): TypeExpr {\n return Object.freeze({ kind: 'docs' as const });\n}\n","/**\n * Self-consistency validation for an assembled spec.\n *\n * Returns an array of human-readable error strings. An empty array means\n * the spec is internally coherent — every reference resolves, no\n * duplicate names, naming conventions hold.\n */\n\nimport type { EnumerationSpec, NestedUnionSpec, NodeSpec, Spec, TypeExpr, UnionSpec } from './types';\n\ntype RegistryKind = 'enumeration' | 'nestedUnion' | 'node' | 'union';\n\nexport function validate(spec: Spec): string[] {\n const errors: string[] = [];\n\n const allNodes: NodeSpec[] = [];\n const allUnions: UnionSpec[] = [];\n const allEnumerations: EnumerationSpec[] = [];\n const allNestedUnions: NestedUnionSpec[] = [];\n for (const c of spec.categories) {\n allNodes.push(...c.nodes);\n allUnions.push(...c.unions);\n allEnumerations.push(...c.enumerations);\n allNestedUnions.push(...c.nestedUnions);\n }\n\n const nodeKinds = new Set(allNodes.map(n => n.kind));\n const unionNames = new Set(allUnions.map(u => u.name));\n const enumerationNames = new Set(allEnumerations.map(e => e.name));\n const nestedUnionNames = new Set(allNestedUnions.map(nu => nu.name));\n\n // Single-pass name-collision check across nodes, unions, enumerations,\n // and nested unions. One error per offending name.\n const registrations = new Map<string, RegistryKind[]>();\n const record = (name: string, kind: RegistryKind): void => {\n const list = registrations.get(name);\n if (list) list.push(kind);\n else registrations.set(name, [kind]);\n };\n for (const n of allNodes) record(n.kind, 'node');\n for (const u of allUnions) record(u.name, 'union');\n for (const e of allEnumerations) record(e.name, 'enumeration');\n for (const nu of allNestedUnions) record(nu.name, 'nestedUnion');\n\n for (const [name, kinds] of registrations) {\n if (kinds.length > 1) errors.push(formatCollisionError(name, kinds));\n }\n\n // Duplicate category names.\n const seenCategories = new Set<string>();\n for (const c of spec.categories) {\n if (seenCategories.has(c.name)) {\n errors.push(`Category \"${c.name}\" is declared more than once.`);\n }\n seenCategories.add(c.name);\n }\n\n // Per-node validation.\n for (const n of allNodes) {\n if (!/^[a-z][A-Za-z0-9]*Node$/.test(n.kind)) {\n errors.push(`Node kind \"${n.kind}\" does not match the camelCase ...Node naming convention.`);\n }\n const seenAttrs = new Set<string>();\n for (const a of n.attributes) {\n if (seenAttrs.has(a.name)) {\n errors.push(`Node \"${n.kind}\" declares attribute \"${a.name}\" more than once.`);\n }\n seenAttrs.add(a.name);\n walkTypeExpr(a.type, expr =>\n checkRef(expr, n.kind, a.name, errors, nodeKinds, unionNames, enumerationNames, nestedUnionNames),\n );\n }\n }\n\n // Union member resolution.\n for (const u of allUnions) {\n if (u.members.length === 0) {\n errors.push(`Union \"${u.name}\" has no members.`);\n }\n const seenMembers = new Set<string>();\n for (const m of u.members) {\n const key = `${m.kind}:${m.name}`;\n if (seenMembers.has(key)) {\n errors.push(`Union \"${u.name}\" lists member ${key} more than once.`);\n }\n seenMembers.add(key);\n if (m.kind === 'node' && !nodeKinds.has(m.name)) {\n errors.push(`Union \"${u.name}\" references undefined node \"${m.name}\".`);\n }\n if (m.kind === 'union' && !unionNames.has(m.name)) {\n errors.push(`Union \"${u.name}\" references undefined union \"${m.name}\".`);\n }\n }\n }\n\n // Nested-union wrapper sanity.\n for (const nu of allNestedUnions) {\n if (nu.wrappers.length === 0) {\n errors.push(`Nested union \"${nu.name}\" has no wrappers.`);\n }\n for (const w of nu.wrappers) {\n if (!nodeKinds.has(w)) {\n errors.push(`Nested union \"${nu.name}\" wrapper \"${w}\" is not a defined node.`);\n }\n }\n }\n\n return errors;\n}\n\nfunction formatCollisionError(name: string, kinds: RegistryKind[]): string {\n const counts = new Map<RegistryKind, number>();\n for (const k of kinds) counts.set(k, (counts.get(k) ?? 0) + 1);\n const breakdown = [...counts.entries()]\n .sort((a, b) => a[0].localeCompare(b[0]))\n .map(([k, n]) => `${n} ${k}${n > 1 ? 's' : ''}`)\n .join(', ');\n return `Name \"${name}\" is registered ${kinds.length} times (${breakdown}); names must be unique across nodes, unions, enumerations, and nested unions.`;\n}\n\nfunction walkTypeExpr(expr: TypeExpr, visit: (expr: TypeExpr) => void): void {\n visit(expr);\n if (expr.kind === 'array') {\n walkTypeExpr(expr.of, visit);\n } else if (expr.kind === 'tuple') {\n for (const item of expr.items) walkTypeExpr(item, visit);\n }\n}\n\nfunction checkRef(\n expr: TypeExpr,\n nodeKind: string,\n attrName: string,\n errors: string[],\n nodeKinds: Set<string>,\n unionNames: Set<string>,\n enumerationNames: Set<string>,\n nestedUnionNames: Set<string>,\n): void {\n const where = `Node \"${nodeKind}\", attribute \"${attrName}\":`;\n switch (expr.kind) {\n case 'node':\n if (!nodeKinds.has(expr.name)) {\n errors.push(`${where} references undefined node \"${expr.name}\".`);\n }\n break;\n case 'union':\n if (!unionNames.has(expr.name)) {\n errors.push(`${where} references undefined union \"${expr.name}\".`);\n }\n break;\n case 'enumeration':\n if (!enumerationNames.has(expr.name)) {\n errors.push(`${where} references undefined enumeration \"${expr.name}\".`);\n }\n break;\n case 'nestedUnion':\n if (!nodeKinds.has(expr.name)) {\n errors.push(`${where} nestedUnion references undefined node \"${expr.name}\".`);\n }\n if (!nestedUnionNames.has(expr.alias)) {\n errors.push(`${where} nestedUnion references undefined alias \"${expr.alias}\".`);\n }\n break;\n default:\n break;\n }\n}\n\n/**\n * Discriminator helper used by codegen, docs, and visitor-table generators.\n *\n * A \"child\" attribute is one whose value contains another node. Specifically,\n * any attribute whose type tree includes a `node`, `nestedUnion`, or\n * `union` is treated as a child. Optionality (the `optional` flag on the\n * attribute itself) is orthogonal to this classification.\n */\nexport function isChildAttribute(type: TypeExpr): boolean {\n switch (type.kind) {\n case 'node':\n case 'nestedUnion':\n case 'union':\n return true;\n case 'array':\n return isChildAttribute(type.of);\n case 'tuple':\n return type.items.some(isChildAttribute);\n default:\n return false;\n }\n}\n"]}