@vector-nodes/core 0.1.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/LICENSE +201 -0
- package/README.md +20 -0
- package/dist/colors.d.ts +13 -0
- package/dist/colors.d.ts.map +1 -0
- package/dist/colors.js +23 -0
- package/dist/colors.js.map +1 -0
- package/dist/conversions.d.ts +12 -0
- package/dist/conversions.d.ts.map +1 -0
- package/dist/conversions.js +45 -0
- package/dist/conversions.js.map +1 -0
- package/dist/graph.d.ts +104 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/graph.js +66 -0
- package/dist/graph.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/node-definition.d.ts +55 -0
- package/dist/node-definition.d.ts.map +1 -0
- package/dist/node-definition.js +14 -0
- package/dist/node-definition.js.map +1 -0
- package/dist/nodes.d.ts +16 -0
- package/dist/nodes.d.ts.map +1 -0
- package/dist/nodes.js +207 -0
- package/dist/nodes.js.map +1 -0
- package/dist/registry.d.ts +28 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +50 -0
- package/dist/registry.js.map +1 -0
- package/dist/schema.d.ts +220 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +163 -0
- package/dist/schema.js.map +1 -0
- package/dist/socket-types.d.ts +25 -0
- package/dist/socket-types.d.ts.map +1 -0
- package/dist/socket-types.js +26 -0
- package/dist/socket-types.js.map +1 -0
- package/dist/validate-graph.d.ts +37 -0
- package/dist/validate-graph.d.ts.map +1 -0
- package/dist/validate-graph.js +201 -0
- package/dist/validate-graph.js.map +1 -0
- package/dist/vnodes.d.ts +37 -0
- package/dist/vnodes.d.ts.map +1 -0
- package/dist/vnodes.js +59 -0
- package/dist/vnodes.js.map +1 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Sergey Chernyshev
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# @vector-nodes/core
|
|
2
|
+
|
|
3
|
+
Types, graph model, and `.vnodes` schema for
|
|
4
|
+
[Vector Nodes](https://github.com/sergeychernyshev/vector-nodes) — a node-based procedural
|
|
5
|
+
geometry generator for 2D and 3D.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @vector-nodes/core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Provides the socket type system (with Blender color-coding), the declarative node-definition
|
|
12
|
+
model and basic node registry, the graph model, and the `.vnodes` (de)serializer plus
|
|
13
|
+
JSON-Schema validation.
|
|
14
|
+
|
|
15
|
+
See the [project README](https://github.com/sergeychernyshev/vector-nodes#readme) for the full
|
|
16
|
+
design.
|
|
17
|
+
|
|
18
|
+
## License
|
|
19
|
+
|
|
20
|
+
Apache-2.0
|
package/dist/colors.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SocketType } from './socket-types';
|
|
2
|
+
/**
|
|
3
|
+
* Canonical Blender socket-palette colors for each socket type, as hex strings.
|
|
4
|
+
*
|
|
5
|
+
* These mirror Blender's Geometry/Shader node socket colors so a network reads
|
|
6
|
+
* at a glance for anyone familiar with Blender. Values are the canonical hex
|
|
7
|
+
* codes from the README's type-system table; in the editor they are theme
|
|
8
|
+
* values and can be overridden, but these are the defaults.
|
|
9
|
+
*/
|
|
10
|
+
export declare const SOCKET_COLORS: Record<SocketType, string>;
|
|
11
|
+
/** Look up the canonical Blender color for a socket type. */
|
|
12
|
+
export declare function socketColor(type: SocketType): string;
|
|
13
|
+
//# sourceMappingURL=colors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../src/colors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CASpD,CAAC;AAEF,6DAA6D;AAC7D,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAEpD"}
|
package/dist/colors.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical Blender socket-palette colors for each socket type, as hex strings.
|
|
3
|
+
*
|
|
4
|
+
* These mirror Blender's Geometry/Shader node socket colors so a network reads
|
|
5
|
+
* at a glance for anyone familiar with Blender. Values are the canonical hex
|
|
6
|
+
* codes from the README's type-system table; in the editor they are theme
|
|
7
|
+
* values and can be overridden, but these are the defaults.
|
|
8
|
+
*/
|
|
9
|
+
export const SOCKET_COLORS = {
|
|
10
|
+
Float: '#A1A1A1', // Gray
|
|
11
|
+
Integer: '#108526', // Green
|
|
12
|
+
Boolean: '#CCA6D6', // Lavender
|
|
13
|
+
Vector: '#6363C7', // Blue
|
|
14
|
+
Color: '#C7C729', // Yellow
|
|
15
|
+
String: '#70B3FF', // Light blue
|
|
16
|
+
Geometry: '#00D6A3', // Teal
|
|
17
|
+
Matrix: '#ED9E5C', // Orange
|
|
18
|
+
};
|
|
19
|
+
/** Look up the canonical Blender color for a socket type. */
|
|
20
|
+
export function socketColor(type) {
|
|
21
|
+
return SOCKET_COLORS[type];
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=colors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colors.js","sourceRoot":"","sources":["../src/colors.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GAA+B;IACvD,KAAK,EAAE,SAAS,EAAE,OAAO;IACzB,OAAO,EAAE,SAAS,EAAE,QAAQ;IAC5B,OAAO,EAAE,SAAS,EAAE,WAAW;IAC/B,MAAM,EAAE,SAAS,EAAE,OAAO;IAC1B,KAAK,EAAE,SAAS,EAAE,SAAS;IAC3B,MAAM,EAAE,SAAS,EAAE,aAAa;IAChC,QAAQ,EAAE,SAAS,EAAE,OAAO;IAC5B,MAAM,EAAE,SAAS,EAAE,SAAS;CAC7B,CAAC;AAEF,6DAA6D;AAC7D,MAAM,UAAU,WAAW,CAAC,IAAgB;IAC1C,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SocketType } from './socket-types';
|
|
2
|
+
/**
|
|
3
|
+
* Whether a value of type `from` may feed a socket of type `to` without an
|
|
4
|
+
* explicit conversion node. Identity (`from === to`) is always allowed.
|
|
5
|
+
*/
|
|
6
|
+
export declare function canConvertImplicitly(from: SocketType, to: SocketType): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* The target types `from` can implicitly convert to, excluding the identity
|
|
9
|
+
* conversion. Returns a fresh array so callers cannot mutate the table.
|
|
10
|
+
*/
|
|
11
|
+
export declare function implicitConversionTargets(from: SocketType): SocketType[];
|
|
12
|
+
//# sourceMappingURL=conversions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversions.d.ts","sourceRoot":"","sources":["../src/conversions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAiCjD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,UAAU,GAAG,OAAO,CAE9E;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,EAAE,CAExE"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Allowed implicit conversions between socket types.
|
|
3
|
+
*
|
|
4
|
+
* Per the README, implicit conversions "mirror Blender where unambiguous";
|
|
5
|
+
* everything else requires an explicit conversion node. We seed the table with
|
|
6
|
+
* the conversions that have a single, well-defined meaning:
|
|
7
|
+
*
|
|
8
|
+
* - **Numeric widening** (lossless): `Boolean → Integer → Float`.
|
|
9
|
+
* - **Scalar → Vector broadcast**: a scalar `f` fills all components, `(f, f, f)`.
|
|
10
|
+
* - **Scalar → Color broadcast**: a scalar `f` becomes grayscale `(f, f, f, 1)`.
|
|
11
|
+
*
|
|
12
|
+
* Deliberately excluded (ambiguous or lossy — require an explicit node):
|
|
13
|
+
* narrowing (`Float → Integer` rounding, `Float → Boolean` thresholding),
|
|
14
|
+
* `Vector → Float` (which component / average?), `Vector ↔ Color`, and anything
|
|
15
|
+
* involving `String`, `Geometry`, or `Matrix`.
|
|
16
|
+
*
|
|
17
|
+
* The map is keyed by source type; the value lists the target types reachable
|
|
18
|
+
* without an explicit conversion node. The identity conversion (`T → T`) is
|
|
19
|
+
* always allowed and is not listed here.
|
|
20
|
+
*/
|
|
21
|
+
const IMPLICIT_CONVERSIONS = {
|
|
22
|
+
Boolean: ['Integer', 'Float', 'Vector', 'Color'],
|
|
23
|
+
Integer: ['Float', 'Vector', 'Color'],
|
|
24
|
+
Float: ['Vector', 'Color'],
|
|
25
|
+
Vector: [],
|
|
26
|
+
Color: [],
|
|
27
|
+
String: [],
|
|
28
|
+
Geometry: [],
|
|
29
|
+
Matrix: [],
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Whether a value of type `from` may feed a socket of type `to` without an
|
|
33
|
+
* explicit conversion node. Identity (`from === to`) is always allowed.
|
|
34
|
+
*/
|
|
35
|
+
export function canConvertImplicitly(from, to) {
|
|
36
|
+
return from === to || IMPLICIT_CONVERSIONS[from].includes(to);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The target types `from` can implicitly convert to, excluding the identity
|
|
40
|
+
* conversion. Returns a fresh array so callers cannot mutate the table.
|
|
41
|
+
*/
|
|
42
|
+
export function implicitConversionTargets(from) {
|
|
43
|
+
return [...IMPLICIT_CONVERSIONS[from]];
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=conversions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversions.js","sourceRoot":"","sources":["../src/conversions.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,oBAAoB,GAA8C;IACtE,OAAO,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC;IAChD,OAAO,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC;IACrC,KAAK,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC1B,MAAM,EAAE,EAAE;IACV,KAAK,EAAE,EAAE;IACT,MAAM,EAAE,EAAE;IACV,QAAQ,EAAE,EAAE;IACZ,MAAM,EAAE,EAAE;CACX,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAgB,EAAE,EAAc;IACnE,OAAO,IAAI,KAAK,EAAE,IAAI,oBAAoB,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AAChE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CAAC,IAAgB;IACxD,OAAO,CAAC,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC;AACzC,CAAC"}
|
package/dist/graph.d.ts
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { SocketType } from './socket-types';
|
|
2
|
+
/** Format discriminator written into every `.vnodes` document. */
|
|
3
|
+
export declare const VNODES_FORMAT = "vector-nodes";
|
|
4
|
+
/** Current `.vnodes` format version. */
|
|
5
|
+
export declare const VNODES_VERSION = "1.0";
|
|
6
|
+
/** Node type of the network's single result node. */
|
|
7
|
+
export declare const OUTPUT_NODE_TYPE = "OutputGeometry";
|
|
8
|
+
/** Human-facing network info; `name` seeds the generated function name. */
|
|
9
|
+
export interface GraphMetadata {
|
|
10
|
+
name?: string;
|
|
11
|
+
author?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
created?: string;
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A network-level parameter: an external, typed input exposed as an argument of
|
|
18
|
+
* the generated function. Distinct from a node's baked-in `params`.
|
|
19
|
+
*/
|
|
20
|
+
export interface GraphParameter {
|
|
21
|
+
id: string;
|
|
22
|
+
type: SocketType;
|
|
23
|
+
isArray?: boolean;
|
|
24
|
+
default?: unknown;
|
|
25
|
+
min?: number;
|
|
26
|
+
max?: number;
|
|
27
|
+
}
|
|
28
|
+
/** A node instance in a graph; `type` references a definition in the registry. */
|
|
29
|
+
export interface GraphNode {
|
|
30
|
+
/** Stable unique id used by links. */
|
|
31
|
+
id: string;
|
|
32
|
+
type: string;
|
|
33
|
+
/** Editor canvas position `[x, y]`. */
|
|
34
|
+
position?: [number, number];
|
|
35
|
+
/** Static parameter values baked into this node. */
|
|
36
|
+
params?: Record<string, unknown>;
|
|
37
|
+
label?: string;
|
|
38
|
+
}
|
|
39
|
+
/** A `[nodeId, socketName]` reference to one end of a link. */
|
|
40
|
+
export type Endpoint = [nodeId: string, socket: string];
|
|
41
|
+
/** An edge connecting an output socket to an input socket. */
|
|
42
|
+
export interface GraphLink {
|
|
43
|
+
/** Source output socket `[nodeId, outputSocketName]`. */
|
|
44
|
+
from: Endpoint;
|
|
45
|
+
/** Target input socket `[nodeId, inputSocketName]`. */
|
|
46
|
+
to: Endpoint;
|
|
47
|
+
}
|
|
48
|
+
/** A boundary socket on a meta-node's interface. */
|
|
49
|
+
export interface InterfaceSocket {
|
|
50
|
+
name: string;
|
|
51
|
+
type: SocketType;
|
|
52
|
+
isArray?: boolean;
|
|
53
|
+
}
|
|
54
|
+
/** The input/output boundary that a meta-node exposes to its parent graph. */
|
|
55
|
+
export interface NodeInterface {
|
|
56
|
+
inputs: InterfaceSocket[];
|
|
57
|
+
outputs: InterfaceSocket[];
|
|
58
|
+
}
|
|
59
|
+
/** A reusable meta-node (function) definition embedded in a graph. */
|
|
60
|
+
export interface MetaNodeDefinition {
|
|
61
|
+
interface: NodeInterface;
|
|
62
|
+
nodes: GraphNode[];
|
|
63
|
+
links: GraphLink[];
|
|
64
|
+
}
|
|
65
|
+
/** The in-memory representation of a `.vnodes` network. */
|
|
66
|
+
export interface Graph {
|
|
67
|
+
format: typeof VNODES_FORMAT;
|
|
68
|
+
version: string;
|
|
69
|
+
metadata?: GraphMetadata;
|
|
70
|
+
parameters: GraphParameter[];
|
|
71
|
+
nodes: GraphNode[];
|
|
72
|
+
links: GraphLink[];
|
|
73
|
+
/** Reusable meta-node definitions, keyed by name. */
|
|
74
|
+
metaNodes?: Record<string, MetaNodeDefinition>;
|
|
75
|
+
}
|
|
76
|
+
/** Fields a caller may seed when constructing a graph. */
|
|
77
|
+
export type GraphInit = Partial<Pick<Graph, 'version' | 'metadata' | 'parameters' | 'nodes' | 'links' | 'metaNodes'>>;
|
|
78
|
+
/**
|
|
79
|
+
* Construct a {@link Graph} with the format discriminator set and array fields
|
|
80
|
+
* defaulted to empty, overlaying any provided `init`.
|
|
81
|
+
*/
|
|
82
|
+
export declare function createGraph(init?: GraphInit): Graph;
|
|
83
|
+
/** Append a node and return it. */
|
|
84
|
+
export declare function addNode(graph: Graph, node: GraphNode): GraphNode;
|
|
85
|
+
/** Append a link and return it. */
|
|
86
|
+
export declare function addLink(graph: Graph, link: GraphLink): GraphLink;
|
|
87
|
+
/** The node id of an endpoint. */
|
|
88
|
+
export declare function endpointNode(endpoint: Endpoint): string;
|
|
89
|
+
/** The socket name of an endpoint. */
|
|
90
|
+
export declare function endpointSocket(endpoint: Endpoint): string;
|
|
91
|
+
/** Find a node by id, or `undefined` if absent. */
|
|
92
|
+
export declare function getNode(graph: Graph, id: string): GraphNode | undefined;
|
|
93
|
+
/** All nodes of a given node type. */
|
|
94
|
+
export declare function getNodesByType(graph: Graph, type: string): GraphNode[];
|
|
95
|
+
/**
|
|
96
|
+
* The network's output node (first node of type {@link OUTPUT_NODE_TYPE}), or
|
|
97
|
+
* `undefined` if none exists. The single-output rule is enforced in validation.
|
|
98
|
+
*/
|
|
99
|
+
export declare function getOutputNode(graph: Graph): GraphNode | undefined;
|
|
100
|
+
/** Links whose source (`from`) is the given node. */
|
|
101
|
+
export declare function linksFrom(graph: Graph, nodeId: string): GraphLink[];
|
|
102
|
+
/** Links whose target (`to`) is the given node. */
|
|
103
|
+
export declare function linksTo(graph: Graph, nodeId: string): GraphLink[];
|
|
104
|
+
//# sourceMappingURL=graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../src/graph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,kEAAkE;AAClE,eAAO,MAAM,aAAa,iBAAiB,CAAC;AAE5C,wCAAwC;AACxC,eAAO,MAAM,cAAc,QAAQ,CAAC;AAEpC,qDAAqD;AACrD,eAAO,MAAM,gBAAgB,mBAAmB,CAAC;AAEjD,2EAA2E;AAC3E,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO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,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,CAEjE"}
|
package/dist/graph.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/** Format discriminator written into every `.vnodes` document. */
|
|
2
|
+
export const VNODES_FORMAT = 'vector-nodes';
|
|
3
|
+
/** Current `.vnodes` format version. */
|
|
4
|
+
export const VNODES_VERSION = '1.0';
|
|
5
|
+
/** Node type of the network's single result node. */
|
|
6
|
+
export const OUTPUT_NODE_TYPE = 'OutputGeometry';
|
|
7
|
+
/**
|
|
8
|
+
* Construct a {@link Graph} with the format discriminator set and array fields
|
|
9
|
+
* defaulted to empty, overlaying any provided `init`.
|
|
10
|
+
*/
|
|
11
|
+
export function createGraph(init = {}) {
|
|
12
|
+
const graph = {
|
|
13
|
+
format: VNODES_FORMAT,
|
|
14
|
+
version: init.version ?? VNODES_VERSION,
|
|
15
|
+
parameters: init.parameters ?? [],
|
|
16
|
+
nodes: init.nodes ?? [],
|
|
17
|
+
links: init.links ?? [],
|
|
18
|
+
};
|
|
19
|
+
if (init.metadata !== undefined)
|
|
20
|
+
graph.metadata = init.metadata;
|
|
21
|
+
if (init.metaNodes !== undefined)
|
|
22
|
+
graph.metaNodes = init.metaNodes;
|
|
23
|
+
return graph;
|
|
24
|
+
}
|
|
25
|
+
/** Append a node and return it. */
|
|
26
|
+
export function addNode(graph, node) {
|
|
27
|
+
graph.nodes.push(node);
|
|
28
|
+
return node;
|
|
29
|
+
}
|
|
30
|
+
/** Append a link and return it. */
|
|
31
|
+
export function addLink(graph, link) {
|
|
32
|
+
graph.links.push(link);
|
|
33
|
+
return link;
|
|
34
|
+
}
|
|
35
|
+
/** The node id of an endpoint. */
|
|
36
|
+
export function endpointNode(endpoint) {
|
|
37
|
+
return endpoint[0];
|
|
38
|
+
}
|
|
39
|
+
/** The socket name of an endpoint. */
|
|
40
|
+
export function endpointSocket(endpoint) {
|
|
41
|
+
return endpoint[1];
|
|
42
|
+
}
|
|
43
|
+
/** Find a node by id, or `undefined` if absent. */
|
|
44
|
+
export function getNode(graph, id) {
|
|
45
|
+
return graph.nodes.find((node) => node.id === id);
|
|
46
|
+
}
|
|
47
|
+
/** All nodes of a given node type. */
|
|
48
|
+
export function getNodesByType(graph, type) {
|
|
49
|
+
return graph.nodes.filter((node) => node.type === type);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The network's output node (first node of type {@link OUTPUT_NODE_TYPE}), or
|
|
53
|
+
* `undefined` if none exists. The single-output rule is enforced in validation.
|
|
54
|
+
*/
|
|
55
|
+
export function getOutputNode(graph) {
|
|
56
|
+
return graph.nodes.find((node) => node.type === OUTPUT_NODE_TYPE);
|
|
57
|
+
}
|
|
58
|
+
/** Links whose source (`from`) is the given node. */
|
|
59
|
+
export function linksFrom(graph, nodeId) {
|
|
60
|
+
return graph.links.filter((link) => link.from[0] === nodeId);
|
|
61
|
+
}
|
|
62
|
+
/** Links whose target (`to`) is the given node. */
|
|
63
|
+
export function linksTo(graph, nodeId) {
|
|
64
|
+
return graph.links.filter((link) => link.to[0] === nodeId);
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=graph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.js","sourceRoot":"","sources":["../src/graph.ts"],"names":[],"mappings":"AAEA,kEAAkE;AAClE,MAAM,CAAC,MAAM,aAAa,GAAG,cAAc,CAAC;AAE5C,wCAAwC;AACxC,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC;AAEpC,qDAAqD;AACrD,MAAM,CAAC,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;AAoFjD;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,OAAkB,EAAE;IAC9C,MAAM,KAAK,GAAU;QACnB,MAAM,EAAE,aAAa;QACrB,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,cAAc;QACvC,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,EAAE;QACjC,KAAK,EAAE,IAAI,CAAC,K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AGG;AACH,MAAM,UAAU,aAAa,CAAC,KAAY;IACxC,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,gBAAgB,CAAC,CAAC;AACpE,CAAC;AAED,qDAAqD;AACrD,MAAM,UAAU,SAAS,CAAC,KAAY,EAAE,MAAc;IACpD,OAAO,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC;AAC/D,CAAC;AAED,mDAAmD;AACnD,MAAM,UAAU,OAAO,CAAC,KAAY,EAAE,MAAc;IAClD,OAAO,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC;AAC7D,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vector-nodes/core — types, graph model, and `.vnodes` schema.
|
|
3
|
+
*/
|
|
4
|
+
export * from './socket-types';
|
|
5
|
+
export * from './colors';
|
|
6
|
+
export * from './conversions';
|
|
7
|
+
export * from './node-definition';
|
|
8
|
+
export * from './registry';
|
|
9
|
+
export * from './graph';
|
|
10
|
+
export * from './schema';
|
|
11
|
+
export * from './vnodes';
|
|
12
|
+
export * from './validate-graph';
|
|
13
|
+
export * from './nodes';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vector-nodes/core — types, graph model, and `.vnodes` schema.
|
|
3
|
+
*/
|
|
4
|
+
export * from './socket-types';
|
|
5
|
+
export * from './colors';
|
|
6
|
+
export * from './conversions';
|
|
7
|
+
export * from './node-definition';
|
|
8
|
+
export * from './registry';
|
|
9
|
+
export * from './graph';
|
|
10
|
+
export * from './schema';
|
|
11
|
+
export * from './vnodes';
|
|
12
|
+
export * from './validate-graph';
|
|
13
|
+
export * from './nodes';
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { SocketType } from './socket-types';
|
|
2
|
+
/**
|
|
3
|
+
* An input or output socket on a node definition.
|
|
4
|
+
*
|
|
5
|
+
* `isArray` marks a field (array) socket and defaults to `false`. `default` is
|
|
6
|
+
* an optional value used for an input socket that is left unconnected; its shape
|
|
7
|
+
* depends on `type` (e.g. a number for `Float`, `[x, y, z]` for `Vector`).
|
|
8
|
+
*/
|
|
9
|
+
export interface SocketDefinition {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly type: SocketType;
|
|
12
|
+
readonly isArray?: boolean;
|
|
13
|
+
readonly default?: unknown;
|
|
14
|
+
readonly description?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A static parameter baked into a node (the node's `params` in a `.vnodes`
|
|
18
|
+
* file). Carries an optional `default` plus an optional numeric `min`/`max`
|
|
19
|
+
* range for editor widgets and validation.
|
|
20
|
+
*/
|
|
21
|
+
export interface ParamDefinition {
|
|
22
|
+
readonly name: string;
|
|
23
|
+
readonly type: SocketType;
|
|
24
|
+
readonly isArray?: boolean;
|
|
25
|
+
readonly default?: unknown;
|
|
26
|
+
readonly min?: number;
|
|
27
|
+
readonly max?: number;
|
|
28
|
+
/** Enumerated allowed values; when set, editors present a dropdown. */
|
|
29
|
+
readonly options?: readonly string[];
|
|
30
|
+
readonly description?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The declarative definition of a node *type* in the library — its sockets and
|
|
34
|
+
* parameters plus display metadata. This is the single source of truth consumed
|
|
35
|
+
* by the editor, validator, interpreter, and codegen. Node *instances* in a
|
|
36
|
+
* graph reference a definition by its `type`.
|
|
37
|
+
*/
|
|
38
|
+
export interface NodeDefinition {
|
|
39
|
+
/** Unique node-type id, e.g. `"VectorMath"` or `"OutputGeometry"`. */
|
|
40
|
+
readonly type: string;
|
|
41
|
+
/** Display name for the palette; falls back to `type` when omitted. */
|
|
42
|
+
readonly label?: string;
|
|
43
|
+
/** Palette grouping, e.g. `"Vector"` or `"Geometry"`. */
|
|
44
|
+
readonly category?: string;
|
|
45
|
+
readonly description?: string;
|
|
46
|
+
readonly inputs: readonly SocketDefinition[];
|
|
47
|
+
readonly outputs: readonly SocketDefinition[];
|
|
48
|
+
readonly params: readonly ParamDefinition[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Resolve a node definition's parameter defaults into a `name → value` map,
|
|
52
|
+
* including only parameters that declare a `default`.
|
|
53
|
+
*/
|
|
54
|
+
export declare function resolveParamDefaults(def: NodeDefinition): Record<string, unknown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C9B,QAAQ,CAAC,MAAM,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAC7C,QAAQ,CAAC,OAAO,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAC9C,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAC;CAC7C;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQjF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve a node definition's parameter defaults into a `name → value` map,
|
|
3
|
+
* including only parameters that declare a `default`.
|
|
4
|
+
*/
|
|
5
|
+
export function resolveParamDefaults(def) {
|
|
6
|
+
const defaults = {};
|
|
7
|
+
for (const param of def.params) {
|
|
8
|
+
if (param.default !== undefined) {
|
|
9
|
+
defaults[param.name] = param.default;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return defaults;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=node-definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-definition.js","sourceRoot":"","sources":["../src/node-definition.ts"],"names":[],"mappings":"AAqDA;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAmB;IACtD,MAAM,QAAQ,GAA4B,EAAE,CAAC;IAC7C,KAAK,MAAM,KAAK,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;QAC/B,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YAChC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC;QACvC,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|