@loveluthien/carta-frontend 6.0.0-dev

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 (148) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.md +34 -0
  2. package/.github/pull_request_template.md +23 -0
  3. package/.github/workflows/continuous_integration.yml +139 -0
  4. package/.github/workflows/deploy.yml +30 -0
  5. package/.husky/pre-commit +16 -0
  6. package/.husky/pre-push +42 -0
  7. package/.prettierignore +1 -0
  8. package/.prettierrc.json +18 -0
  9. package/CHANGELOG.md +363 -0
  10. package/COPYING.md +636 -0
  11. package/README.md +112 -0
  12. package/babel.config.json +10 -0
  13. package/build/ast_wrapper.wasm +0 -0
  14. package/build/carta_computation.wasm +0 -0
  15. package/build/carta_icon_128px.png +0 -0
  16. package/build/carta_logo.png +0 -0
  17. package/build/gsl_wrapper.wasm +0 -0
  18. package/build/index.html +147 -0
  19. package/build/manifest.json +15 -0
  20. package/build/robots.txt +3 -0
  21. package/build/static/css/546.aa44a897.css +1 -0
  22. package/build/static/css/async/359.4d8f6ff7.css +1 -0
  23. package/build/static/css/async/403.ea9edfac.css +1 -0
  24. package/build/static/css/async/462.8bde08e0.css +1 -0
  25. package/build/static/css/index.c1f77b92.css +1 -0
  26. package/build/static/font/blueprint-icons-16.5fb1af27.woff2 +0 -0
  27. package/build/static/font/blueprint-icons-16.79f603d1.woff +0 -0
  28. package/build/static/font/blueprint-icons-16.83d51978.eot +0 -0
  29. package/build/static/font/blueprint-icons-16.af0c342f.ttf +0 -0
  30. package/build/static/font/blueprint-icons-20.83fddc09.ttf +0 -0
  31. package/build/static/font/blueprint-icons-20.9a51bc58.woff +0 -0
  32. package/build/static/font/blueprint-icons-20.d61315fe.eot +0 -0
  33. package/build/static/font/blueprint-icons-20.ebf16e9a.woff2 +0 -0
  34. package/build/static/image/allmaps.03f2ba92.png +0 -0
  35. package/build/static/image/gamma.6fca425b.png +0 -0
  36. package/build/static/image/linear.c7941b64.png +0 -0
  37. package/build/static/image/log.7fce6aee.png +0 -0
  38. package/build/static/image/power.5dac9727.png +0 -0
  39. package/build/static/image/sqrt.0ec2b3f1.png +0 -0
  40. package/build/static/image/squared.798b23aa.png +0 -0
  41. package/build/static/js/546.b5841ade.js +489 -0
  42. package/build/static/js/546.b5841ade.js.LICENSE.txt +925 -0
  43. package/build/static/js/async/359.97257512.js +1 -0
  44. package/build/static/js/async/403.b00f768c.js +1 -0
  45. package/build/static/js/async/462.92c07a07.js +1 -0
  46. package/build/static/js/async/905.70044ee8.js +1 -0
  47. package/build/static/js/async/907.dc17f1d2.js +1 -0
  48. package/build/static/js/async/blueprint-icons-16px-paths.e17db832.js +1 -0
  49. package/build/static/js/async/blueprint-icons-20px-paths.6ad43f5f.js +1 -0
  50. package/build/static/js/async/blueprint-icons-all-paths-loader.61cc0f7b.js +1 -0
  51. package/build/static/js/async/blueprint-icons-all-paths.0c699441.js +1 -0
  52. package/build/static/js/async/blueprint-icons-split-paths-by-size-loader.5cff79f5.js +1 -0
  53. package/build/static/js/index.8fc34b4d.js +1344 -0
  54. package/build/static/js/index.9a30d560.worker.js +1 -0
  55. package/build/static/js/zfp_wrapper.wasm +0 -0
  56. package/build/static/svg/blueprint-icons-16.130888ef.svg +2097 -0
  57. package/build/static/svg/blueprint-icons-20.c8456d56.svg +2097 -0
  58. package/build/zfp_wrapper.wasm +0 -0
  59. package/declarations.d.ts +18 -0
  60. package/docs_website/.prettierignore +1 -0
  61. package/docs_website/api/api.md +13 -0
  62. package/docs_website/babel.config.js +3 -0
  63. package/docs_website/docs/assets/enable-code-snippets.png +0 -0
  64. package/docs_website/docs/code-snippet-tutorial/_category_.json +8 -0
  65. package/docs_website/docs/code-snippet-tutorial/basics.md +97 -0
  66. package/docs_website/docs/code-snippet-tutorial/image-blending.mdx +57 -0
  67. package/docs_website/docs/code-snippet-tutorial/image-fitting.mdx +44 -0
  68. package/docs_website/docs/code-snippet-tutorial/image-properties.mdx +84 -0
  69. package/docs_website/docs/code-snippet-tutorial/moment-images.mdx +31 -0
  70. package/docs_website/docs/code-snippet-tutorial/pv-images.mdx +28 -0
  71. package/docs_website/docs/code-snippet-tutorial/quick-start.mdx +82 -0
  72. package/docs_website/docs/code-snippet-tutorial/regions.mdx +49 -0
  73. package/docs_website/docs/contributing/_category_.json +7 -0
  74. package/docs_website/docs/contributing/developer-tips.md +61 -0
  75. package/docs_website/docs/contributing/documentation-guidelines.md +87 -0
  76. package/docs_website/docs/contributing/github-workflow.md +146 -0
  77. package/docs_website/docs/contributing/release-guidelines.md +73 -0
  78. package/docs_website/docs/contributing/unit-test-guidelines.md +79 -0
  79. package/docs_website/docs/documents.mdx +15 -0
  80. package/docs_website/docusaurus.config.js +167 -0
  81. package/docs_website/package-lock.json +16769 -0
  82. package/docs_website/package.json +121 -0
  83. package/docs_website/patches/@docusaurus+core+3.9.2.patch +20 -0
  84. package/docs_website/sidebars.js +33 -0
  85. package/docs_website/static/.nojekyll +0 -0
  86. package/docs_website/static/img/carta_icon_128px.png +0 -0
  87. package/docs_website/versioned_docs/version-4.1.0/api-packages.json +1 -0
  88. package/docs_website/versioned_docs/version-4.1.0/api-typedoc.json +214112 -0
  89. package/docs_website/versioned_docs/version-4.1.0/assets/enable-code-snippets.png +0 -0
  90. package/docs_website/versioned_docs/version-4.1.0/code-snippet-tutorial/_category_.json +8 -0
  91. package/docs_website/versioned_docs/version-4.1.0/code-snippet-tutorial/basics.md +97 -0
  92. package/docs_website/versioned_docs/version-4.1.0/code-snippet-tutorial/image-fitting.mdx +42 -0
  93. package/docs_website/versioned_docs/version-4.1.0/code-snippet-tutorial/image-properties.mdx +86 -0
  94. package/docs_website/versioned_docs/version-4.1.0/code-snippet-tutorial/moment-images.mdx +31 -0
  95. package/docs_website/versioned_docs/version-4.1.0/code-snippet-tutorial/pv-images.mdx +28 -0
  96. package/docs_website/versioned_docs/version-4.1.0/code-snippet-tutorial/quick-start.mdx +82 -0
  97. package/docs_website/versioned_docs/version-4.1.0/code-snippet-tutorial/regions.mdx +49 -0
  98. package/docs_website/versioned_docs/version-4.1.0/contributing/_category_.json +7 -0
  99. package/docs_website/versioned_docs/version-4.1.0/contributing/developer-tips.md +36 -0
  100. package/docs_website/versioned_docs/version-4.1.0/contributing/documentation-guidelines.md +87 -0
  101. package/docs_website/versioned_docs/version-4.1.0/contributing/github-workflow.md +141 -0
  102. package/docs_website/versioned_docs/version-4.1.0/contributing/release-guidelines.md +73 -0
  103. package/docs_website/versioned_docs/version-4.1.0/contributing/unit-test-guidelines.md +79 -0
  104. package/docs_website/versioned_docs/version-4.1.0/documents.mdx +15 -0
  105. package/docs_website/versioned_docs/version-5.0.0/api-packages.json +1 -0
  106. package/docs_website/versioned_docs/version-5.0.0/api-typedoc.json +315266 -0
  107. package/docs_website/versioned_docs/version-5.0.0/assets/enable-code-snippets.png +0 -0
  108. package/docs_website/versioned_docs/version-5.0.0/code-snippet-tutorial/_category_.json +8 -0
  109. package/docs_website/versioned_docs/version-5.0.0/code-snippet-tutorial/basics.md +97 -0
  110. package/docs_website/versioned_docs/version-5.0.0/code-snippet-tutorial/image-blending.mdx +57 -0
  111. package/docs_website/versioned_docs/version-5.0.0/code-snippet-tutorial/image-fitting.mdx +44 -0
  112. package/docs_website/versioned_docs/version-5.0.0/code-snippet-tutorial/image-properties.mdx +86 -0
  113. package/docs_website/versioned_docs/version-5.0.0/code-snippet-tutorial/moment-images.mdx +31 -0
  114. package/docs_website/versioned_docs/version-5.0.0/code-snippet-tutorial/pv-images.mdx +28 -0
  115. package/docs_website/versioned_docs/version-5.0.0/code-snippet-tutorial/quick-start.mdx +82 -0
  116. package/docs_website/versioned_docs/version-5.0.0/code-snippet-tutorial/regions.mdx +49 -0
  117. package/docs_website/versioned_docs/version-5.0.0/contributing/_category_.json +7 -0
  118. package/docs_website/versioned_docs/version-5.0.0/contributing/developer-tips.md +36 -0
  119. package/docs_website/versioned_docs/version-5.0.0/contributing/documentation-guidelines.md +87 -0
  120. package/docs_website/versioned_docs/version-5.0.0/contributing/github-workflow.md +141 -0
  121. package/docs_website/versioned_docs/version-5.0.0/contributing/release-guidelines.md +73 -0
  122. package/docs_website/versioned_docs/version-5.0.0/contributing/unit-test-guidelines.md +79 -0
  123. package/docs_website/versioned_docs/version-5.0.0/documents.mdx +15 -0
  124. package/docs_website/versioned_sidebars/version-4.1.0-sidebars.json +8 -0
  125. package/docs_website/versioned_sidebars/version-5.0.0-sidebars.json +8 -0
  126. package/docs_website/versions.json +4 -0
  127. package/eslint.config.mjs +86 -0
  128. package/jest.config.js +101 -0
  129. package/package.json +186 -0
  130. package/patches/golden-layout+1.5.9.patch +24 -0
  131. package/patches/react-split-pane+0.1.92.patch +20 -0
  132. package/rsbuild.config.ts +75 -0
  133. package/schemas/.github/workflows/AddToCartaVisProject.yml +23 -0
  134. package/schemas/.prettierrc.json +18 -0
  135. package/schemas/CMakeLists.txt +15 -0
  136. package/schemas/README.md +1 -0
  137. package/schemas/_config.yml +7 -0
  138. package/schemas/controller_config_schema_1.json +343 -0
  139. package/schemas/controller_config_schema_2.json +685 -0
  140. package/schemas/layout_schema_2.json +440 -0
  141. package/schemas/preference_backend_schema_1.json +81 -0
  142. package/schemas/preference_backend_schema_2.json +118 -0
  143. package/schemas/preference_schema_1.json +410 -0
  144. package/schemas/preferences_schema_2.json +421 -0
  145. package/schemas/schemacompiler.c +200 -0
  146. package/schemas/snippet_schema_1.json +45 -0
  147. package/schemas/workspace_schema_1.json +573 -0
  148. package/scripts/make_colormaps.py +161 -0
@@ -0,0 +1,421 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "title": "Preferences",
4
+ "description": "Schema for CARTA Preferences (Version 2)",
5
+ "$id": "https://cartavis.org/schemas/preferences_schema_2.json",
6
+ "type": "object",
7
+ "required": ["version"],
8
+ "properties": {
9
+ "version": {
10
+ "description": "The version of the preferences contained",
11
+ "type": "integer",
12
+ "minimum": 1,
13
+ "maximum": 2
14
+ },
15
+ "theme": {
16
+ "enum": ["auto", "light", "dark"]
17
+ },
18
+ "autoLaunch": {
19
+ "type": "boolean"
20
+ },
21
+ "fileSortingString": {
22
+ "type": "string",
23
+ "pattern": "^([+\\-])(date|filename|type|size)$"
24
+ },
25
+ "fileFilteringType": {
26
+ "enum": ["fuzzy", "unix", "regex"]
27
+ },
28
+ "layout": {
29
+ "type": "string"
30
+ },
31
+ "cursorPosition": {
32
+ "enum": ["fixed", "tracking"]
33
+ },
34
+ "zoomMode": {
35
+ "enum": ["fit", "full"]
36
+ },
37
+ "zoomPoint": {
38
+ "enum": ["cursor", "center"]
39
+ },
40
+ "dragPanning": {
41
+ "type": "boolean"
42
+ },
43
+ "spectralMatchingType": {
44
+ "enum": ["VRAD", "VOPT", "FREQ", "WAVE", "AWAV", "CHANNEL"]
45
+ },
46
+ "transparentImageBackground": {
47
+ "type": "boolean"
48
+ },
49
+ "scaling": {
50
+ "type": "integer",
51
+ "minimum": 0,
52
+ "maximum": 7
53
+ },
54
+ "colormap": {
55
+ "type": "string"
56
+ },
57
+ "percentile": {
58
+ "type": "number",
59
+ "minimum": 0,
60
+ "maximum": 100
61
+ },
62
+ "scalingAlpha": {
63
+ "type": "number",
64
+ "minimum": 0.1,
65
+ "maximum": 1000000
66
+ },
67
+ "scalingGamma": {
68
+ "type": "number",
69
+ "minimum": 0.1,
70
+ "maximum": 2
71
+ },
72
+ "nanColorHex": {
73
+ "type": "string",
74
+ "description": "TODO: validate color string"
75
+ },
76
+ "nanAlpha": {
77
+ "type": "number",
78
+ "minimum": 0,
79
+ "maximum": 1
80
+ },
81
+ "useSmoothedBiasContrast": {
82
+ "type": "boolean"
83
+ },
84
+ "contourGeneratorType": {
85
+ "enum": ["start-step-multiplier", "min-max-scaling", "percentages-ref.value", "mean-sigma-list"]
86
+ },
87
+ "contourSmoothingMode": {
88
+ "type": "integer",
89
+ "minimum": 0,
90
+ "maximum": 2
91
+ },
92
+ "contourSmoothingFactor": {
93
+ "type": "integer",
94
+ "minimum": 1,
95
+ "maximum": 33
96
+ },
97
+ "contourNumLevels": {
98
+ "type": "integer",
99
+ "minimum": 1,
100
+ "maximum": 15
101
+ },
102
+ "contourThickness": {
103
+ "type": "number",
104
+ "minimum": 0.5,
105
+ "maximum": 10
106
+ },
107
+ "contourColormapEnabled": {
108
+ "type": "boolean"
109
+ },
110
+ "contourColor": {
111
+ "type": "string",
112
+ "description": "TODO: validate color string"
113
+ },
114
+ "contourColormap": {
115
+ "type": "string"
116
+ },
117
+ "vectorOverlayPixelAveraging": {
118
+ "type": "number",
119
+ "minimum": 0,
120
+ "maximum": 64,
121
+ "default": 4
122
+ },
123
+ "vectorOverlayFractionalIntensity": {
124
+ "type": "boolean",
125
+ "default": false
126
+ },
127
+ "vectorOverlayThickness": {
128
+ "type": "number",
129
+ "minimum": 0.5,
130
+ "maximum": 10
131
+ },
132
+ "vectorOverlayColormapEnabled": {
133
+ "type": "boolean"
134
+ },
135
+ "vectorOverlayColor": {
136
+ "type": "string",
137
+ "description": "TODO: validate color string",
138
+ "default": "#ffffff"
139
+ },
140
+ "vectorOverlayColormap": {
141
+ "type": "string",
142
+ "default": "viridis"
143
+ },
144
+ "astColor": {
145
+ "type": "string",
146
+ "description": "TODO: validate color string"
147
+ },
148
+ "astGridVisible": {
149
+ "type": "boolean"
150
+ },
151
+ "astLabelsVisible": {
152
+ "type": "boolean"
153
+ },
154
+ "wcsType": {
155
+ "enum": ["automatic", "degrees", "sexagesimal"]
156
+ },
157
+ "colorbarVisible": {
158
+ "type": "boolean"
159
+ },
160
+ "colorbarInteractive": {
161
+ "type": "boolean"
162
+ },
163
+ "colorbarPosition": {
164
+ "enum": ["right", "top", "bottom"]
165
+ },
166
+ "colorbarWidth": {
167
+ "type": "integer",
168
+ "minimum": 1,
169
+ "maximum": 100
170
+ },
171
+ "colorbarTicksDensity": {
172
+ "type": "number",
173
+ "minimum": 0.2,
174
+ "maximum": 20
175
+ },
176
+ "colorbarLabelVisible": {
177
+ "type": "boolean"
178
+ },
179
+ "beamVisible": {
180
+ "type": "boolean"
181
+ },
182
+ "beamColor": {
183
+ "type": "string"
184
+ },
185
+ "beamType": {
186
+ "enum": ["open", "solid"]
187
+ },
188
+ "beamWidth": {
189
+ "type": "number",
190
+ "minimum": 0.5,
191
+ "maximum": 10
192
+ },
193
+ "regionColor": {
194
+ "type": "string",
195
+ "description": "TODO: validate color string"
196
+ },
197
+ "regionLineWidth": {
198
+ "type": "number",
199
+ "minimum": 0.5,
200
+ "maximum": 10
201
+ },
202
+ "regionDashLength": {
203
+ "type": "integer",
204
+ "minimum": 0,
205
+ "maximum": 50
206
+ },
207
+ "regionType": {
208
+ "enum": [0, 1, 2, 3, 4, 6]
209
+ },
210
+ "regionCreationMode": {
211
+ "enum": ["center", "corner"]
212
+ },
213
+ "regionSize": {
214
+ "type": "number",
215
+ "minimum": 10,
216
+ "maximum": 100
217
+ },
218
+ "imageCompressionQuality": {
219
+ "type": "integer",
220
+ "minimum": 1,
221
+ "maximum": 32
222
+ },
223
+ "animationCompressionQuality": {
224
+ "type": "integer",
225
+ "minimum": 1,
226
+ "maximum": 32
227
+ },
228
+ "GPUTileCache": {
229
+ "type": "integer",
230
+ "multipleOf": 256,
231
+ "minimum": 256
232
+ },
233
+ "systemTileCache": {
234
+ "type": "integer",
235
+ "multipleOf": 256,
236
+ "minimum": 256
237
+ },
238
+ "contourDecimation": {
239
+ "type": "integer",
240
+ "minimum": 1,
241
+ "maximum": 32
242
+ },
243
+ "contourCompressionLevel": {
244
+ "type": "integer",
245
+ "minimum": 0,
246
+ "maximum": 19
247
+ },
248
+ "contourChunkSize": {
249
+ "type": "integer",
250
+ "minimum": 1000
251
+ },
252
+ "contourControlMapWidth": {
253
+ "type": "integer",
254
+ "multipleOf": 128,
255
+ "minimum": 128
256
+ },
257
+ "streamContoursWhileZooming": {
258
+ "type": "boolean"
259
+ },
260
+ "lowBandwidthMode": {
261
+ "type": "boolean"
262
+ },
263
+ "stopAnimationPlaybackMinutes": {
264
+ "type": "number",
265
+ "minimum": 0
266
+ },
267
+ "pixelGridVisible": {
268
+ "type": "boolean"
269
+ },
270
+ "pixelGridColor": {
271
+ "type": "string"
272
+ },
273
+ "codeSnippetsEnabled": {
274
+ "type": "boolean"
275
+ },
276
+ "limitOverlayRedraw": {
277
+ "type": "boolean",
278
+ "default": true
279
+ },
280
+ "cursorInfoVisible": {
281
+ "enum": ["always", "activeImage", "hideTiled", "never"],
282
+ "default": "activeImage"
283
+ },
284
+ "keepLastUsedFolder": {
285
+ "type": "boolean",
286
+ "default": false
287
+ },
288
+ "lastUsedFolder": {
289
+ "type": "string",
290
+ "default": ""
291
+ },
292
+ "imageMultiPanelEnabled": {
293
+ "type": "boolean",
294
+ "default": false
295
+ },
296
+ "imagePanelMode": {
297
+ "enum": ["dynamic", "fixed"],
298
+ "default": "dynamic"
299
+ },
300
+ "imagePanelColumns": {
301
+ "type": "number",
302
+ "minimum": 1,
303
+ "default": 2
304
+ },
305
+ "imagePanelRows": {
306
+ "type": "number",
307
+ "minimum": 1,
308
+ "default": 2
309
+ },
310
+ "statsPanelEnabled": {
311
+ "type": "boolean",
312
+ "default": false
313
+ },
314
+ "statsPanelMode": {
315
+ "type": "integer",
316
+ "minimum": 0,
317
+ "default": 0
318
+ },
319
+ "telemetryUuid": {
320
+ "type": "string"
321
+ },
322
+ "telemetryMode": {
323
+ "enum": ["none", "minimal", "usage"],
324
+ "default": "usage"
325
+ },
326
+ "telemetryConsentShown": {
327
+ "type": "boolean",
328
+ "default": false
329
+ },
330
+ "telemetryLogging": {
331
+ "type": "boolean",
332
+ "default": false
333
+ },
334
+ "fileFilterMode": {
335
+ "enum": ["content", "extension", "all"],
336
+ "default": "content"
337
+ },
338
+ "pvAxesOrderReverse": {
339
+ "type": "boolean"
340
+ },
341
+ "autoWCSMatching": {
342
+ "type": "integer",
343
+ "minimum": 0,
344
+ "maximum": 7
345
+ },
346
+ "colormapHex": {
347
+ "type": "string"
348
+ },
349
+ "colormapHexStart": {
350
+ "type": "string"
351
+ },
352
+ "dynamicLayoutEnable": {
353
+ "type": "boolean"
354
+ },
355
+ "isHighDimPriority": {
356
+ "type": "boolean"
357
+ },
358
+ "dynamicLayout": {
359
+ "type": "object"
360
+ },
361
+ "annotationColor": {
362
+ "type": "string"
363
+ },
364
+ "annotationLineWidth": {
365
+ "type": "number",
366
+ "minimum": 0.5,
367
+ "maximum": 10
368
+ },
369
+ "annotationDashLength": {
370
+ "type": "number",
371
+ "minimum": 0,
372
+ "maximum": 50
373
+ },
374
+ "pointAnnotationShape": {
375
+ "type": "integer",
376
+ "minimum": 0,
377
+ "maximum": 7
378
+ },
379
+ "pointAnnotationWidth": {
380
+ "type": "number",
381
+ "minimum": 1,
382
+ "maximum": 100
383
+ },
384
+ "textAnnotationLineWidth": {
385
+ "type": "number",
386
+ "minimum": 0.5,
387
+ "maximum": 10
388
+ },
389
+ "pvPreviewCubeSizeLimit": {
390
+ "type": "number",
391
+ "minimum": 0.1,
392
+ "description": "PV preview cube size limit, in GB."
393
+ },
394
+ "pvPreviewCubeSizeLimitUnit": {
395
+ "enum": ["TB", "GB", "MB", "kB", "B"],
396
+ "description": "This is a deprecated preference."
397
+ },
398
+ "logEventList": {
399
+ "type": "array",
400
+ "items": {
401
+ "type": "number"
402
+ }
403
+ },
404
+ "catalogDisplayedColumnSize": {
405
+ "type": "number",
406
+ "minimum": 1
407
+ },
408
+ "catalogTableSeparatorPosition": {
409
+ "type": "string"
410
+ },
411
+ "checkNewRelease": {
412
+ "type": "boolean"
413
+ },
414
+ "latestRelease": {
415
+ "type": "string"
416
+ },
417
+ "compatibilityAipsBeamSupport": {
418
+ "type": "boolean"
419
+ }
420
+ }
421
+ }
@@ -0,0 +1,200 @@
1
+ /* This program converts a schema file into a header which can be included in
2
+ the CARTA backend at compile time. The header contains an unsigned char array
3
+ containing the raw data, an unsigned int containing the array length, and a
4
+ std::string constructed from these variables.
5
+
6
+ Based on: https://github.com/mortie/strliteral
7
+ */
8
+
9
+ #include <stdlib.h>
10
+ #include <stdio.h>
11
+ #include <stdint.h>
12
+ #include <string.h>
13
+ #include <ctype.h>
14
+
15
+ static void make_identifier(char *str) {
16
+ char c;
17
+ size_t i;
18
+ for (i = 0; (c = str[i]) != '\0'; ++i) {
19
+ if (c == '.') {
20
+ str[i] = '\0';
21
+ return;
22
+ } else if (!(
23
+ (c >= '0' && c <= '9') ||
24
+ (c >= 'a' && c <= 'z') ||
25
+ (c >= 'A' && c <= 'Z'))) {
26
+ str[i] = '_';
27
+ }
28
+ }
29
+ }
30
+
31
+ static void make_headername(char *str) {
32
+ char c;
33
+ size_t i;
34
+ for (i = 0; (c = str[i]) != '\0'; ++i) {
35
+ if (c >= 'a' && c <= 'z') {
36
+ str[i] = toupper((unsigned char) c);
37
+ }
38
+ }
39
+ }
40
+
41
+ /* strdup is actually a POSIX thing, not a C thing, so don't use it */
42
+ static char *dupstr(char *str) {
43
+ size_t len = strlen(str);
44
+ char *dup = malloc(len + 1);
45
+ strcpy(dup, str);
46
+ dup[len] = '\0';
47
+ return dup;
48
+ }
49
+
50
+ int main(int argc, char **argv) {
51
+ int ret = 0;
52
+ char *inp = "stdin", *outp = "stdout";
53
+ FILE *inf = stdin, *outf = stdout;
54
+ char *inbase = NULL;
55
+ char *ident = NULL;
56
+ char *headername = NULL;
57
+ char *buffer = NULL;
58
+ char *conststr = "const ";
59
+ int alwaysescape = 0;
60
+ size_t maxlength = 100;
61
+
62
+ if (argc < 3) {
63
+ fprintf(stderr, "USAGE: schemacompiler <input> <output>\n");
64
+ goto fail;
65
+ }
66
+
67
+ inp = argv[1];
68
+ inf = fopen(inp, "rb");
69
+ if (inf == NULL) {
70
+ perror(inp);
71
+ goto fail;
72
+ }
73
+
74
+ (inbase = strrchr(inp, '/')) ? ++inbase : (inbase = inp);
75
+ ident = dupstr(inbase);
76
+ make_identifier(ident);
77
+
78
+ headername = dupstr(ident);
79
+ make_headername(headername);
80
+
81
+ outp = argv[2];
82
+ outf = fopen(outp, "w");
83
+ if (outf == NULL) {
84
+ perror(outp);
85
+ goto fail;
86
+ }
87
+
88
+ if (fprintf(outf, "#ifndef _%s\n#define _%s\n\nnamespace CARTASCHEMA {\n\n",
89
+ headername, headername) < 0) {
90
+ perror("write header");
91
+ goto fail;
92
+ }
93
+
94
+ if (fprintf(outf, "%sunsigned char %s_char[] =\n\t\"", conststr, ident) < 0) {
95
+ perror("write char header");
96
+ goto fail;
97
+ }
98
+
99
+ buffer = malloc(maxlength + 4);
100
+
101
+ size_t linechar = 0;
102
+ size_t length = 0;
103
+ int c;
104
+ while ((c = fgetc(inf)) != EOF) {
105
+ if (alwaysescape) {
106
+ buffer[linechar++] = '\\';
107
+ buffer[linechar++] = '0' + ((c & 0700) >> 6);
108
+ buffer[linechar++] = '0' + ((c & 0070) >> 3);
109
+ buffer[linechar++] = '0' + ((c & 0007) >> 0);
110
+ } else if (c >= 32 && c <= 126 && c != '"' && c != '\\' && c != '?' && c != ':' && c != '%') {
111
+ buffer[linechar++] = (char)c;
112
+ } else if (c == '\r') {
113
+ buffer[linechar++] = '\\';
114
+ buffer[linechar++] = 'r';
115
+ } else if (c == '\n') {
116
+ buffer[linechar++] = '\\';
117
+ buffer[linechar++] = 'n';
118
+ } else if (c == '\t') {
119
+ buffer[linechar++] = '\\';
120
+ buffer[linechar++] = 't';
121
+ } else if (c == '\"') {
122
+ buffer[linechar++] = '\\';
123
+ buffer[linechar++] = '"';
124
+ } else if (c == '\\') {
125
+ buffer[linechar++] = '\\';
126
+ buffer[linechar++] = '\\';
127
+ } else {
128
+ buffer[linechar++] = '\\';
129
+ buffer[linechar++] = '0' + ((c & 0700) >> 6);
130
+ buffer[linechar++] = '0' + ((c & 0070) >> 3);
131
+ buffer[linechar++] = '0' + ((c & 0007) >> 0);
132
+ }
133
+
134
+ length += 1;
135
+
136
+ if (linechar >= maxlength) {
137
+ if (fwrite(buffer, 1, linechar, outf) != linechar) {
138
+ perror("write");
139
+ goto fail;
140
+ }
141
+
142
+ if (fwrite("\"\n\t\"", 1, 4, outf) != 4) {
143
+ perror("write");
144
+ goto fail;
145
+ }
146
+
147
+ linechar = 0;
148
+ }
149
+ }
150
+
151
+ if (linechar >= 1) {
152
+ if (fwrite(buffer, 1, linechar, outf) != linechar) {
153
+ perror("write buffer");
154
+ goto fail;
155
+ }
156
+ }
157
+
158
+ if (ferror(inf)) {
159
+ perror("read");
160
+ goto fail;
161
+ }
162
+
163
+ if (fprintf(outf, "\";\n\n%sunsigned int %s_len = %u;\n",
164
+ conststr, ident, (unsigned int)length) < 0) {
165
+ perror("write char footer");
166
+ goto fail;
167
+ }
168
+
169
+ if (fprintf(outf, "\ninline std::string_view %s(reinterpret_cast<%schar*>(%s_char), %s_len);\n",
170
+ ident, conststr, ident, ident) < 0) {
171
+ perror("write string");
172
+ goto fail;
173
+ }
174
+
175
+ if (fprintf(outf, "\n} // CARTASCHEMA\n#endif // _%s\n",
176
+ headername) < 0) {
177
+ perror("write footer");
178
+ goto fail;
179
+ }
180
+
181
+ if (fclose(inf) == EOF) {
182
+ perror("close");
183
+ goto fail;
184
+ }
185
+
186
+ if (fclose(outf) == EOF) {
187
+ perror("close");
188
+ goto fail;
189
+ }
190
+
191
+ exit:
192
+ free(ident);
193
+ free(headername);
194
+ free(buffer);
195
+ return ret;
196
+
197
+ fail:
198
+ ret = 1;
199
+ goto exit;
200
+ }
@@ -0,0 +1,45 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "title": "Snippet",
4
+ "description": "Schema for CARTA Snippet (Version 1)",
5
+ "$id": "https://cartavis.org/schemas/snippet_schema_1.json",
6
+ "type": "object",
7
+ "required": ["snippetVersion", "frontendVersion", "code"],
8
+ "properties": {
9
+ "snippetVersion": {
10
+ "description": "The version of the snippet contained",
11
+ "type": "integer",
12
+ "minimum": 1,
13
+ "maximum": 1
14
+ },
15
+ "frontendVersion": {
16
+ "description": "The version of the frontend targeted by this snippet",
17
+ "type": "string"
18
+ },
19
+ "code": {
20
+ "description": "Snippet source code",
21
+ "type": "string"
22
+ },
23
+ "tags": {
24
+ "description": "List of tags associated with this snippet",
25
+ "type": "array",
26
+ "items": {
27
+ "type": "string"
28
+ }
29
+ },
30
+ "categories": {
31
+ "description": "List of categories under which to place this snippet",
32
+ "type": "array",
33
+ "items": {
34
+ "type": "string"
35
+ }
36
+ },
37
+ "requires": {
38
+ "description": "List of snippets (by name) which need to be run before running this snippet",
39
+ "type": "array",
40
+ "items": {
41
+ "type": "string"
42
+ }
43
+ }
44
+ }
45
+ }