@frdt/frdt 0.2.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.
Binary file
package/index.d.ts ADDED
@@ -0,0 +1,129 @@
1
+ /* auto-generated by NAPI-RS */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * Which binding artifact the generated loader actually loaded: `'native'` for
6
+ * a native addon, otherwise the `platformArchABI` of the WASI flavor. Every
7
+ * flavor napi-rs can build is listed, because `NAPI_RS_NATIVE_LIBRARY_PATH`
8
+ * can point the loader at a WASI artifact this package does not build itself.
9
+ */
10
+ export declare const __napiBindingTarget: 'native' | 'wasm32-wasi' | 'wasm32-wasip1'
11
+
12
+ /** An open `.brson` document. */
13
+ export declare class Document {
14
+ /** Open a Resonite `.brson` (or a frdt `FRWK` work file). */
15
+ static open(bytes: Uint8Array): Document
16
+ /** A document with one empty root slot. */
17
+ static empty(rootName: string, versionNumber: string, featureFlags: Array<FeatureFlag>): Document
18
+ root(): Slot
19
+ slotById(id: string): Slot
20
+ versionNumber(): string
21
+ featureFlags(): Array<FeatureFlag>
22
+ types(): Array<string>
23
+ typeVersion(name: string): number | null
24
+ slotCount(): number
25
+ componentCount(): number
26
+ assets(): Array<AssetInfo>
27
+ /** Copy `slots` (all from one document) under `parent`, renumbering ids. */
28
+ import(parent: Slot, slots: Array<Slot>): Import
29
+ addSlot(parent: Slot, name: string): Slot
30
+ addComponent(slot: Slot, typeName: string, typeVersion: number | undefined | null, fields: Array<Field>): NewComponent
31
+ moveSlot(slot: Slot, newParent: Slot): void
32
+ removeSlot(slot: Slot): void
33
+ /** Trim `Types` and `TypeVersions` to what remains. Returns removed names. */
34
+ rebuildTypes(): Array<string>
35
+ /** The Resonite `.brson` bytes. */
36
+ writeBrson(): Buffer
37
+ }
38
+
39
+ /** What `Document.import` copied. */
40
+ export declare class Import {
41
+ /** The copied slots in the destination, in the order given. */
42
+ slots(): Array<Slot>
43
+ /** The destination id that replaced a source id. */
44
+ newId(sourceId: string): string | null
45
+ /** Source ids the copy still names but that were not copied. */
46
+ unresolved(): Array<string>
47
+ assetCount(): number
48
+ }
49
+
50
+ /** A slot in a `Document`. It keeps pointing at the same slot across edits. */
51
+ export declare class Slot {
52
+ name(): string
53
+ id(): string
54
+ parentReference(): string | null
55
+ children(): Array<Slot>
56
+ components(): Array<ComponentInfo>
57
+ /** A slot field such as `Name` or `Position`. */
58
+ get(field: string): Value
59
+ /** Replace a slot field. A `{ID, Data}` field keeps its id. */
60
+ set(field: string, value: Value): void
61
+ /** A field of the `component`-th component. `null` when the value is null. */
62
+ componentValue(component: number, field: string): Value | null
63
+ setComponentValue(component: number, field: string, value?: Value | undefined | null): void
64
+ }
65
+
66
+ export interface AssetInfo {
67
+ id: string
68
+ typeIndex?: number
69
+ }
70
+
71
+ export interface ComponentInfo {
72
+ typeIndex: number
73
+ typeName: string
74
+ /** Every `{ID, Data: string}` inside the component, as in the Rust crate. */
75
+ references: Array<string>
76
+ }
77
+
78
+ export interface DynamicVariable {
79
+ /** `"value"`, `"reference"`, or `"space"`. */
80
+ kind: string
81
+ typeName: string
82
+ variableName?: string
83
+ spaceName?: string
84
+ value?: Value
85
+ reference?: Value
86
+ }
87
+
88
+ export interface FeatureFlag {
89
+ name: string
90
+ value: number
91
+ }
92
+
93
+ /** One field of a new component. A missing or `null` value writes null. */
94
+ export interface Field {
95
+ name: string
96
+ value?: Value | null
97
+ }
98
+
99
+ export interface NewComponent {
100
+ /** Position in `Slot.components()`. */
101
+ index: number
102
+ id: string
103
+ }
104
+
105
+ /** Count slots, components, and dynamic variables without opening a document. */
106
+ export declare function summarize(bytes: Uint8Array): Summary
107
+
108
+ export interface Summary {
109
+ slotCount: number
110
+ componentCount: number
111
+ types: Array<string>
112
+ dynamicVariables: Array<DynamicVariable>
113
+ }
114
+
115
+ /**
116
+ * A field value. References are the target's id as a `string`.
117
+ *
118
+ * `int` crosses as a JavaScript number, so it is exact up to 2^53.
119
+ */
120
+ export type Value =
121
+ | { kind: 'string'; value: string }
122
+ | { kind: 'int'; value: number }
123
+ | { kind: 'float'; value: number }
124
+ | { kind: 'bool'; value: boolean }
125
+ | { kind: 'float3'; value: Array<number> }
126
+ | { kind: 'floatQ'; value: Array<number> }
127
+
128
+ /** The leading `[year, month, day]` of a `VersionNumber`, or `null`. */
129
+ export declare function versionDate(versionNumber: string): Array<number> | null