@carbonenginejs/runtime-resource 0.1.0 → 0.8.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/FORMAT-PROVENANCE.md +155 -135
- package/LICENSE +21 -21
- package/NOTICE +29 -29
- package/README.md +548 -241
- package/dist/CjsMotherLode.js +1271 -56
- package/dist/CjsMotherLode.js.map +1 -1
- package/dist/CjsResMan.js +3005 -740
- package/dist/CjsResMan.js.map +1 -1
- package/dist/CjsResManQueue.js +214 -214
- package/dist/CjsResource.js +566 -366
- package/dist/CjsResource.js.map +1 -1
- package/dist/CjsResourceSource.js +59 -59
- package/dist/_virtual/_rollupPluginBabelHelpers.js +153 -153
- package/dist/format/CjsBlueReader.js +269 -0
- package/dist/format/CjsBlueReader.js.map +1 -0
- package/dist/format/CjsFormat.js +192 -178
- package/dist/format/CjsFormat.js.map +1 -1
- package/dist/format/CjsReader.js +18 -0
- package/dist/format/CjsReader.js.map +1 -0
- package/dist/format/CjsResourceProbe.js +277 -269
- package/dist/format/CjsResourceProbe.js.map +1 -1
- package/dist/format/payloadContract.js +173 -173
- package/dist/formats/black/CjsBlackFormat.js +278 -272
- package/dist/formats/black/CjsBlackFormat.js.map +1 -1
- package/dist/formats/black/core/CjsBlackBinaryReader.js +153 -153
- package/dist/formats/black/core/CjsBlackPropertyReaders.js +382 -382
- package/dist/formats/black/core/CjsBlackReader.js +639 -760
- package/dist/formats/black/core/CjsBlackReader.js.map +1 -1
- package/dist/formats/black/core/CjsBlackSchemaRegistry.js +433 -433
- package/dist/formats/black/core/black-schema-v1-2026-07-11.json.js +4 -4
- package/dist/formats/black/core/blackConstants.js +7 -7
- package/dist/formats/black/core/blackDefinitions.js +10 -10
- package/dist/formats/black/core/blackEnums.js +6 -6
- package/dist/formats/black/core/blackSchema.js +3 -3
- package/dist/formats/black/core/blackVersion.js +22 -22
- package/dist/formats/black/core/helpers.js +182 -182
- package/dist/formats/black/core/schema.js +4 -4
- package/dist/formats/black/index.js +2 -2
- package/dist/formats/bnk/CjsBnkFormat.js +238 -245
- package/dist/formats/bnk/CjsBnkFormat.js.map +1 -1
- package/dist/formats/bnk/core/graph.js +140 -0
- package/dist/formats/bnk/core/graph.js.map +1 -0
- package/dist/formats/bnk/core/helpers.js +409 -354
- package/dist/formats/bnk/core/helpers.js.map +1 -1
- package/dist/formats/bnk/core/musicNodes.js +521 -0
- package/dist/formats/bnk/core/musicNodes.js.map +1 -0
- package/dist/formats/bnk/core/soundbanksInfo.js +246 -246
- package/dist/formats/bnk/index.js +2 -3
- package/dist/formats/bnk/index.js.map +1 -1
- package/dist/formats/cmf/CjsCmfFormat.js +497 -491
- package/dist/formats/cmf/CjsCmfFormat.js.map +1 -1
- package/dist/formats/cmf/core/binary.js +118 -118
- package/dist/formats/cmf/core/buffers.js +233 -233
- package/dist/formats/cmf/core/constants.js +47 -47
- package/dist/formats/cmf/core/gr2Anim.js +453 -453
- package/dist/formats/cmf/core/helpers.js +287 -287
- package/dist/formats/cmf/core/pack.js +276 -276
- package/dist/formats/cmf/core/schema.js +364 -364
- package/dist/formats/cmf/core/shared.js +268 -268
- package/dist/formats/cmf/core/writer.js +517 -517
- package/dist/formats/cmf/index.js +2 -2
- package/dist/formats/dds/CjsDdsFormat.js +193 -187
- package/dist/formats/dds/CjsDdsFormat.js.map +1 -1
- package/dist/formats/dds/core/bc6h.js +288 -0
- package/dist/formats/dds/core/bc6h.js.map +1 -0
- package/dist/formats/dds/core/bc7.js +251 -0
- package/dist/formats/dds/core/bc7.js.map +1 -0
- package/dist/formats/dds/core/helpers.js +815 -812
- package/dist/formats/dds/core/helpers.js.map +1 -1
- package/dist/formats/dds/index.js +2 -2
- package/dist/formats/fbx/CjsFbxFormat.js +266 -260
- package/dist/formats/fbx/CjsFbxFormat.js.map +1 -1
- package/dist/formats/fbx/core/helpers.js +3901 -3901
- package/dist/formats/fbx/index.js +2 -2
- package/dist/formats/flac/CjsFlacFormat.js +87 -81
- package/dist/formats/flac/CjsFlacFormat.js.map +1 -1
- package/dist/formats/flac/core/helpers.js +295 -295
- package/dist/formats/flac/index.js +2 -2
- package/dist/formats/gif/CjsGifFormat.js +87 -81
- package/dist/formats/gif/CjsGifFormat.js.map +1 -1
- package/dist/formats/gif/core/helpers.js +360 -360
- package/dist/formats/gif/index.js +2 -2
- package/dist/formats/gltf/CjsGltfFormat.js +290 -284
- package/dist/formats/gltf/CjsGltfFormat.js.map +1 -1
- package/dist/formats/gltf/core/helpers.js +292 -292
- package/dist/formats/gltf/core/json.js +79 -79
- package/dist/formats/gltf/core/parser.js +666 -666
- package/dist/formats/gltf/core/targets.js +163 -163
- package/dist/formats/gltf/index.js +2 -2
- package/dist/formats/index.js +23 -23
- package/dist/formats/jpeg/CjsJpegFormat.js +206 -200
- package/dist/formats/jpeg/CjsJpegFormat.js.map +1 -1
- package/dist/formats/jpeg/core/helpers.js +350 -350
- package/dist/formats/jpeg/core/jpeg.js +377 -377
- package/dist/formats/jpeg/index.js +2 -2
- package/dist/formats/mp3/CjsMp3Format.js +192 -186
- package/dist/formats/mp3/CjsMp3Format.js.map +1 -1
- package/dist/formats/mp3/core/helpers.js +338 -338
- package/dist/formats/mp3/index.js +2 -2
- package/dist/formats/mp4/CjsMp4Format.js +191 -185
- package/dist/formats/mp4/CjsMp4Format.js.map +1 -1
- package/dist/formats/mp4/core/helpers.js +449 -449
- package/dist/formats/mp4/index.js +2 -2
- package/dist/formats/obj/CjsObjFormat.js +253 -247
- package/dist/formats/obj/CjsObjFormat.js.map +1 -1
- package/dist/formats/obj/core/helpers.js +573 -573
- package/dist/formats/obj/core/json.js +64 -64
- package/dist/formats/obj/core/parser.js +321 -321
- package/dist/formats/obj/index.js +2 -2
- package/dist/formats/ogg/CjsOggFormat.js +88 -82
- package/dist/formats/ogg/CjsOggFormat.js.map +1 -1
- package/dist/formats/ogg/core/helpers.js +387 -387
- package/dist/formats/ogg/core/imdct.js +178 -178
- package/dist/formats/ogg/core/vorbis.js +999 -999
- package/dist/formats/ogg/index.js +2 -2
- package/dist/formats/png/CjsPngFormat.js +195 -189
- package/dist/formats/png/CjsPngFormat.js.map +1 -1
- package/dist/formats/png/core/helpers.js +583 -583
- package/dist/formats/png/index.js +2 -2
- package/dist/formats/red/CjsRedFormat.js +261 -247
- package/dist/formats/red/CjsRedFormat.js.map +1 -1
- package/dist/formats/red/core/CjsRedReader.js +194 -201
- package/dist/formats/red/core/CjsRedReader.js.map +1 -1
- package/dist/formats/red/core/blackDefinitions.js +3 -3
- package/dist/formats/red/core/helpers.js +139 -136
- package/dist/formats/red/core/helpers.js.map +1 -1
- package/dist/formats/red/core/redGraph.js +68 -68
- package/dist/formats/red/core/schema.js +4 -4
- package/dist/formats/red/index.js +2 -2
- package/dist/formats/stl/CjsStlFormat.js +365 -304
- package/dist/formats/stl/CjsStlFormat.js.map +1 -1
- package/dist/formats/stl/core/helpers.js +261 -257
- package/dist/formats/stl/core/helpers.js.map +1 -1
- package/dist/formats/stl/core/json.js +51 -51
- package/dist/formats/stl/core/stl.js +629 -544
- package/dist/formats/stl/core/stl.js.map +1 -1
- package/dist/formats/stl/core/targets.js +163 -163
- package/dist/formats/stl/index.js +2 -2
- package/dist/formats/tga/CjsTgaFormat.js +192 -186
- package/dist/formats/tga/CjsTgaFormat.js.map +1 -1
- package/dist/formats/tga/core/helpers.js +446 -446
- package/dist/formats/tga/index.js +2 -2
- package/dist/formats/wav/CjsWavFormat.js +192 -186
- package/dist/formats/wav/CjsWavFormat.js.map +1 -1
- package/dist/formats/wav/core/helpers.js +328 -328
- package/dist/formats/wav/index.js +2 -2
- package/dist/formats/webm/CjsWebmFormat.js +191 -185
- package/dist/formats/webm/CjsWebmFormat.js.map +1 -1
- package/dist/formats/webm/core/helpers.js +537 -537
- package/dist/formats/webm/index.js +2 -2
- package/dist/formats/webp/CjsWebpFormat.js +86 -80
- package/dist/formats/webp/CjsWebpFormat.js.map +1 -1
- package/dist/formats/webp/core/helpers.js +214 -214
- package/dist/formats/webp/index.js +2 -2
- package/dist/formats/wem/CjsWemFormat.js +241 -197
- package/dist/formats/wem/CjsWemFormat.js.map +1 -1
- package/dist/formats/wem/core/bitStream.js +259 -259
- package/dist/formats/wem/core/codebookLibrary.js +164 -164
- package/dist/formats/wem/core/helpers.js +417 -336
- package/dist/formats/wem/core/helpers.js.map +1 -1
- package/dist/formats/wem/core/packedCodebooksAotuv603.js +30 -30
- package/dist/formats/wem/core/ptadpcm.js +77 -0
- package/dist/formats/wem/core/ptadpcm.js.map +1 -0
- package/dist/formats/wem/core/resolve.js +121 -0
- package/dist/formats/wem/core/resolve.js.map +1 -0
- package/dist/formats/wem/core/wemToOgg.js +485 -485
- package/dist/formats/wem/index.js +2 -2
- package/dist/formats/yaml/CjsYamlFormat.js +83 -77
- package/dist/formats/yaml/CjsYamlFormat.js.map +1 -1
- package/dist/formats/yaml/core/CjsYamlReader.js +305 -304
- package/dist/formats/yaml/core/CjsYamlReader.js.map +1 -1
- package/dist/formats/yaml/core/helpers.js +160 -160
- package/dist/formats/yaml/index.js +2 -2
- package/dist/index.js +48 -52
- package/dist/index.js.map +1 -1
- package/dist/resourcePath.js +18 -18
- package/dist/resourceStates.js +9 -9
- package/dist/{generated/resources → resources}/AudioGeometryResData.js +47 -47
- package/dist/resources/AudioGeometryResData.js.map +1 -0
- package/dist/{generated/resources → resources}/GStateBindingCallbackData.js +31 -31
- package/dist/resources/GStateBindingCallbackData.js.map +1 -0
- package/dist/{generated/resources → resources}/MeshDecalData.js +37 -37
- package/dist/resources/MeshDecalData.js.map +1 -0
- package/dist/{generated/resources → resources}/MeshDecalLodData.js +34 -34
- package/dist/resources/MeshDecalLodData.js.map +1 -0
- package/dist/resources/Tr2EffectRes.js +71 -71
- package/dist/resources/Tr2GrannyIntersectionResult.js +60 -0
- package/dist/resources/Tr2GrannyIntersectionResult.js.map +1 -0
- package/dist/resources/Tr2GrannyStateRes.js +44 -44
- package/dist/resources/Tr2ImageRes.js +114 -114
- package/dist/resources/Tr2LightProfileRes.js +40 -40
- package/dist/{generated/resources → resources}/Tr2MaterialArea.js +34 -34
- package/dist/resources/Tr2MaterialArea.js.map +1 -0
- package/dist/{generated/resources → resources}/Tr2MaterialMesh.js +31 -31
- package/dist/resources/Tr2MaterialMesh.js.map +1 -0
- package/dist/{generated/resources → resources}/Tr2MaterialRes.js +34 -34
- package/dist/resources/Tr2MaterialRes.js.map +1 -0
- package/dist/{generated/resources → resources}/Tr2ShaderPermutation.js +43 -43
- package/dist/resources/Tr2ShaderPermutation.js.map +1 -0
- package/dist/{generated/resources → resources}/Tr2TextureLodManager.js +100 -60
- package/dist/resources/Tr2TextureLodManager.js.map +1 -0
- package/dist/{generated/resources → resources}/Tr2TextureLodUpdateRequest.js +37 -37
- package/dist/resources/Tr2TextureLodUpdateRequest.js.map +1 -0
- package/dist/{generated/resources → resources}/Tr2TexturePackChannel.js +37 -37
- package/dist/resources/Tr2TexturePackChannel.js.map +1 -0
- package/dist/resources/Tr2TexturePipeline.js +68 -0
- package/dist/resources/Tr2TexturePipeline.js.map +1 -0
- package/dist/{generated/resources → resources}/Tr2TexturePipelineParams.js +34 -34
- package/dist/resources/Tr2TexturePipelineParams.js.map +1 -0
- package/dist/{generated/resources → resources}/Tr2TexturePipelineStepCompress.js +40 -40
- package/dist/resources/Tr2TexturePipelineStepCompress.js.map +1 -0
- package/dist/{generated/resources → resources}/Tr2TexturePipelineStepLimitSize.js +34 -34
- package/dist/resources/Tr2TexturePipelineStepLimitSize.js.map +1 -0
- package/dist/{generated/resources → resources}/Tr2TexturePipelineStepLoad.js +31 -31
- package/dist/resources/Tr2TexturePipelineStepLoad.js.map +1 -0
- package/dist/{generated/resources → resources}/Tr2TexturePipelineStepPack.js +43 -43
- package/dist/resources/Tr2TexturePipelineStepPack.js.map +1 -0
- package/dist/resources/TriGeometryRes.js +239 -216
- package/dist/resources/TriGeometryRes.js.map +1 -1
- package/dist/{generated/resources → resources}/TriGeometryResAreaData.js +59 -59
- package/dist/resources/TriGeometryResAreaData.js.map +1 -0
- package/dist/{generated/resources → resources}/TriGeometryResJointData.js +38 -38
- package/dist/resources/TriGeometryResJointData.js.map +1 -0
- package/dist/{generated/resources → resources}/TriGeometryResLodData.js +88 -88
- package/dist/resources/TriGeometryResLodData.js.map +1 -0
- package/dist/{generated/resources → resources}/TriGeometryResMeshData.js +63 -63
- package/dist/resources/TriGeometryResMeshData.js.map +1 -0
- package/dist/{generated/resources → resources}/TriGeometryResSkeletonData.js +34 -34
- package/dist/resources/TriGeometryResSkeletonData.js.map +1 -0
- package/dist/resources/TriGrannyRes.js +43 -43
- package/dist/{generated/resources → resources}/TriJointBinding.js +38 -38
- package/dist/resources/TriJointBinding.js.map +1 -0
- package/dist/{generated/resources → resources}/TriMorphTargetGeometryConstants.js +46 -46
- package/dist/resources/TriMorphTargetGeometryConstants.js.map +1 -0
- package/dist/{generated/resources → resources}/TriRtGeometryConstants.js +88 -88
- package/dist/resources/TriRtGeometryConstants.js.map +1 -0
- package/dist/resources/TriTextureRes.js +304 -304
- package/dist/{generated/resources → resources}/enums.js +18 -18
- package/dist/resources/enums.js.map +1 -0
- package/dist/resources/resourceBoundary.js +47 -47
- package/dist/resources/texturePipelineBehavior.js +320 -0
- package/dist/resources/texturePipelineBehavior.js.map +1 -0
- package/dist/texture/CjsTextureArrayRes.js +406 -406
- package/dist/texture/CjsTextureParameterProxy.js +133 -133
- package/format-notices/black/LICENSE +21 -21
- package/format-notices/black/NOTICE +47 -47
- package/format-notices/bnk/LICENSE +21 -21
- package/format-notices/bnk/NOTICE +20 -17
- package/format-notices/cmf/LICENSE +21 -21
- package/format-notices/cmf/NOTICE +36 -36
- package/format-notices/dds/LICENSE +21 -21
- package/format-notices/dds/NOTICE +14 -14
- package/format-notices/fbx/LICENSE +21 -21
- package/format-notices/fbx/NOTICE +14 -14
- package/format-notices/flac/LICENSE +21 -21
- package/format-notices/flac/NOTICE +14 -14
- package/format-notices/gif/LICENSE +21 -21
- package/format-notices/gif/NOTICE +14 -14
- package/format-notices/gltf/LICENSE +21 -21
- package/format-notices/gltf/NOTICE +27 -27
- package/format-notices/jpeg/LICENSE +21 -21
- package/format-notices/jpeg/NOTICE +14 -14
- package/format-notices/mp3/LICENSE +21 -21
- package/format-notices/mp3/NOTICE +14 -14
- package/format-notices/mp4/LICENSE +21 -21
- package/format-notices/mp4/NOTICE +14 -14
- package/format-notices/obj/LICENSE +21 -21
- package/format-notices/obj/NOTICE +26 -26
- package/format-notices/ogg/LICENSE +21 -21
- package/format-notices/ogg/NOTICE +28 -28
- package/format-notices/png/LICENSE +21 -21
- package/format-notices/png/NOTICE +14 -14
- package/format-notices/red/LICENSE +21 -21
- package/format-notices/red/NOTICE +31 -31
- package/format-notices/stl/LICENSE +21 -21
- package/format-notices/stl/NOTICE +21 -21
- package/format-notices/tga/LICENSE +21 -21
- package/format-notices/tga/NOTICE +14 -14
- package/format-notices/wav/LICENSE +21 -21
- package/format-notices/wav/NOTICE +14 -14
- package/format-notices/webm/LICENSE +21 -21
- package/format-notices/webm/NOTICE +14 -14
- package/format-notices/webp/LICENSE +21 -21
- package/format-notices/webp/NOTICE +14 -14
- package/format-notices/wem/LICENSE +57 -57
- package/format-notices/wem/NOTICE +33 -33
- package/format-notices/yaml/LICENSE +21 -21
- package/format-notices/yaml/NOTICE +44 -44
- package/package.json +51 -51
- package/resource-lifecycle.md +679 -487
- package/dist/generated/resources/AudioGeometryResData.js.map +0 -1
- package/dist/generated/resources/CmfVertexReader.js +0 -46
- package/dist/generated/resources/CmfVertexReader.js.map +0 -1
- package/dist/generated/resources/GStateBindingCallbackData.js.map +0 -1
- package/dist/generated/resources/MeshDecalData.js.map +0 -1
- package/dist/generated/resources/MeshDecalLodData.js.map +0 -1
- package/dist/generated/resources/Tr2AsyncSave.js +0 -46
- package/dist/generated/resources/Tr2AsyncSave.js.map +0 -1
- package/dist/generated/resources/Tr2CmfContents.js +0 -37
- package/dist/generated/resources/Tr2CmfContents.js.map +0 -1
- package/dist/generated/resources/Tr2GrannyIntersectionResult.js +0 -58
- package/dist/generated/resources/Tr2GrannyIntersectionResult.js.map +0 -1
- package/dist/generated/resources/Tr2LoadPrepareFence.js +0 -37
- package/dist/generated/resources/Tr2LoadPrepareFence.js.map +0 -1
- package/dist/generated/resources/Tr2MaterialArea.js.map +0 -1
- package/dist/generated/resources/Tr2MaterialMesh.js.map +0 -1
- package/dist/generated/resources/Tr2MaterialRes.js.map +0 -1
- package/dist/generated/resources/Tr2ShaderPermutation.js.map +0 -1
- package/dist/generated/resources/Tr2TextureLodManager.js.map +0 -1
- package/dist/generated/resources/Tr2TextureLodUpdateRequest.js.map +0 -1
- package/dist/generated/resources/Tr2TexturePackChannel.js.map +0 -1
- package/dist/generated/resources/Tr2TexturePipeline.js +0 -44
- package/dist/generated/resources/Tr2TexturePipeline.js.map +0 -1
- package/dist/generated/resources/Tr2TexturePipelineParams.js.map +0 -1
- package/dist/generated/resources/Tr2TexturePipelineStepCompress.js.map +0 -1
- package/dist/generated/resources/Tr2TexturePipelineStepLimitSize.js.map +0 -1
- package/dist/generated/resources/Tr2TexturePipelineStepLoad.js.map +0 -1
- package/dist/generated/resources/Tr2TexturePipelineStepPack.js.map +0 -1
- package/dist/generated/resources/TriGeometryResAreaData.js.map +0 -1
- package/dist/generated/resources/TriGeometryResJointData.js.map +0 -1
- package/dist/generated/resources/TriGeometryResLodData.js.map +0 -1
- package/dist/generated/resources/TriGeometryResMeshData.js.map +0 -1
- package/dist/generated/resources/TriGeometryResSkeletonData.js.map +0 -1
- package/dist/generated/resources/TriJointBinding.js.map +0 -1
- package/dist/generated/resources/TriMorphTargetGeometryConstants.js.map +0 -1
- package/dist/generated/resources/TriRtGeometryConstants.js.map +0 -1
- package/dist/generated/resources/enums.js.map +0 -1
- package/dist/generated/resources/index.js +0 -32
- package/dist/generated/resources/index.js.map +0 -1
|
@@ -1,136 +1,139 @@
|
|
|
1
|
-
const OUTPUT_JSON = "json";
|
|
2
|
-
const OUTPUT_PAYLOAD = "payload";
|
|
3
|
-
const OUTPUT_RUNTIME = "runtime";
|
|
4
|
-
const OUTPUT_RAW = "raw";
|
|
5
|
-
const DEFAULT_VALUES = Object.freeze({
|
|
6
|
-
emit: OUTPUT_JSON,
|
|
7
|
-
schema: null,
|
|
8
|
-
registry: null,
|
|
9
|
-
firstId: 1,
|
|
10
|
-
parse: null,
|
|
11
|
-
adapter: null,
|
|
12
|
-
adapters: null,
|
|
13
|
-
payloadTypeField: "_type",
|
|
14
|
-
payloadIdField: "_id",
|
|
15
|
-
payloadReferenceField: "_reference",
|
|
16
|
-
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (emit ===
|
|
25
|
-
if (emit ===
|
|
26
|
-
if (emit ===
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (hasOwn(options, "
|
|
89
|
-
if (hasOwn(options, "
|
|
90
|
-
if (hasOwn(options, "
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (hasOwn(options, "
|
|
99
|
-
if (hasOwn(options, "
|
|
100
|
-
if (hasOwn(options, "
|
|
101
|
-
if (hasOwn(options, "
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
if (
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
1
|
+
const OUTPUT_JSON = "json";
|
|
2
|
+
const OUTPUT_PAYLOAD = "payload";
|
|
3
|
+
const OUTPUT_RUNTIME = "runtime";
|
|
4
|
+
const OUTPUT_RAW = "raw";
|
|
5
|
+
const DEFAULT_VALUES = Object.freeze({
|
|
6
|
+
emit: OUTPUT_JSON,
|
|
7
|
+
schema: null,
|
|
8
|
+
registry: null,
|
|
9
|
+
firstId: 1,
|
|
10
|
+
parse: null,
|
|
11
|
+
adapter: null,
|
|
12
|
+
adapters: null,
|
|
13
|
+
payloadTypeField: "_type",
|
|
14
|
+
payloadIdField: "_id",
|
|
15
|
+
payloadReferenceField: "_reference",
|
|
16
|
+
payloadValuesField: "_values",
|
|
17
|
+
classes: Object.freeze({})
|
|
18
|
+
});
|
|
19
|
+
const OPTION_KEYS = new Set(Object.keys(DEFAULT_VALUES));
|
|
20
|
+
function hasOwn(value, key) {
|
|
21
|
+
return Object.prototype.hasOwnProperty.call(value, key);
|
|
22
|
+
}
|
|
23
|
+
function normalizeEmit(emit, readerName) {
|
|
24
|
+
if (emit === undefined || emit === OUTPUT_JSON) return OUTPUT_JSON;
|
|
25
|
+
if (emit === OUTPUT_PAYLOAD) return OUTPUT_PAYLOAD;
|
|
26
|
+
if (emit === OUTPUT_RUNTIME) return OUTPUT_RUNTIME;
|
|
27
|
+
if (emit === OUTPUT_RAW) return OUTPUT_RAW;
|
|
28
|
+
throw new Error(`${readerName} unknown emit value "${emit}"`);
|
|
29
|
+
}
|
|
30
|
+
function assertKnownOptions(options, readerName) {
|
|
31
|
+
for (const key of Object.keys(options)) {
|
|
32
|
+
if (!OPTION_KEYS.has(key)) {
|
|
33
|
+
throw new TypeError(`${readerName} unknown option "${key}"`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function classMap(values) {
|
|
38
|
+
return values && values.classes ? values.classes : {};
|
|
39
|
+
}
|
|
40
|
+
function cloneValues(values) {
|
|
41
|
+
return {
|
|
42
|
+
emit: values.emit,
|
|
43
|
+
schema: values.schema ?? null,
|
|
44
|
+
registry: values.registry ?? null,
|
|
45
|
+
firstId: values.firstId ?? 1,
|
|
46
|
+
parse: values.parse ?? null,
|
|
47
|
+
adapter: values.adapter ?? null,
|
|
48
|
+
adapters: values.adapters ?? null,
|
|
49
|
+
payloadTypeField: values.payloadTypeField,
|
|
50
|
+
payloadIdField: values.payloadIdField,
|
|
51
|
+
payloadReferenceField: values.payloadReferenceField,
|
|
52
|
+
payloadValuesField: values.payloadValuesField,
|
|
53
|
+
classes: {
|
|
54
|
+
...classMap(values)
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function validateClassKey(classKeys, key, readerName) {
|
|
59
|
+
if (typeof key !== "string" || !key) {
|
|
60
|
+
throw new Error(`${readerName} class type must be a non-empty string`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function validateClass(classKeys, type, Class, readerName) {
|
|
64
|
+
validateClassKey(classKeys, type, readerName);
|
|
65
|
+
if (typeof Class !== "function") {
|
|
66
|
+
throw new TypeError(`${readerName} class "${type}" must be a constructor`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function mergeClasses(values, classes, classKeys, readerName) {
|
|
70
|
+
if (!classes || typeof classes !== "object") {
|
|
71
|
+
throw new TypeError(`${readerName} classes option must be an object`);
|
|
72
|
+
}
|
|
73
|
+
const next = {
|
|
74
|
+
...values.classes
|
|
75
|
+
};
|
|
76
|
+
for (const [type, Class] of Object.entries(classes)) {
|
|
77
|
+
validateClass(classKeys, type, Class, readerName);
|
|
78
|
+
next[type] = Class;
|
|
79
|
+
}
|
|
80
|
+
values.classes = next;
|
|
81
|
+
}
|
|
82
|
+
function normalizeValues(base, options, classKeys, readerName) {
|
|
83
|
+
if (!options || typeof options !== "object") {
|
|
84
|
+
throw new TypeError(`${readerName} options must be an object`);
|
|
85
|
+
}
|
|
86
|
+
assertKnownOptions(options, readerName);
|
|
87
|
+
const values = cloneValues(base);
|
|
88
|
+
if (hasOwn(options, "emit")) values.emit = normalizeEmit(options.emit, readerName);
|
|
89
|
+
if (hasOwn(options, "schema")) values.schema = options.schema ?? null;
|
|
90
|
+
if (hasOwn(options, "registry")) values.registry = options.registry ?? null;
|
|
91
|
+
if (hasOwn(options, "firstId")) values.firstId = options.firstId ?? 1;
|
|
92
|
+
if (hasOwn(options, "parse")) {
|
|
93
|
+
if (options.parse !== null && options.parse !== undefined && typeof options.parse !== "function") {
|
|
94
|
+
throw new TypeError(`${readerName} parse option must be a function`);
|
|
95
|
+
}
|
|
96
|
+
values.parse = options.parse ?? null;
|
|
97
|
+
}
|
|
98
|
+
if (hasOwn(options, "adapter")) values.adapter = options.adapter ?? null;
|
|
99
|
+
if (hasOwn(options, "adapters")) values.adapters = options.adapters ?? null;
|
|
100
|
+
if (hasOwn(options, "payloadTypeField")) values.payloadTypeField = options.payloadTypeField;
|
|
101
|
+
if (hasOwn(options, "payloadIdField")) values.payloadIdField = options.payloadIdField;
|
|
102
|
+
if (hasOwn(options, "payloadReferenceField")) values.payloadReferenceField = options.payloadReferenceField;
|
|
103
|
+
if (hasOwn(options, "payloadValuesField")) values.payloadValuesField = options.payloadValuesField;
|
|
104
|
+
if (hasOwn(options, "classes")) mergeClasses(values, options.classes, classKeys, readerName);
|
|
105
|
+
return values;
|
|
106
|
+
}
|
|
107
|
+
function copyReaderOptions(values) {
|
|
108
|
+
const {
|
|
109
|
+
emit: _emit,
|
|
110
|
+
schema: _schema,
|
|
111
|
+
classes: _classes,
|
|
112
|
+
...readerOptions
|
|
113
|
+
} = values;
|
|
114
|
+
return readerOptions;
|
|
115
|
+
}
|
|
116
|
+
function toJsonValue(value, seen = new WeakSet()) {
|
|
117
|
+
if (value === null || typeof value !== "object") return value;
|
|
118
|
+
if (ArrayBuffer.isView(value)) return Array.from(value, item => toJsonValue(item, seen));
|
|
119
|
+
if (Array.isArray(value)) return value.map(item => toJsonValue(item, seen));
|
|
120
|
+
if (seen.has(value)) {
|
|
121
|
+
throw new TypeError("Reader.toJSON cannot convert circular data");
|
|
122
|
+
}
|
|
123
|
+
if (typeof value.toJSON === "function") {
|
|
124
|
+
seen.add(value);
|
|
125
|
+
const json = toJsonValue(value.toJSON(), seen);
|
|
126
|
+
seen.delete(value);
|
|
127
|
+
return json;
|
|
128
|
+
}
|
|
129
|
+
seen.add(value);
|
|
130
|
+
const out = {};
|
|
131
|
+
for (const key of Object.keys(value)) {
|
|
132
|
+
out[key] = toJsonValue(value[key], seen);
|
|
133
|
+
}
|
|
134
|
+
seen.delete(value);
|
|
135
|
+
return out;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export { DEFAULT_VALUES, OUTPUT_JSON, OUTPUT_PAYLOAD, OUTPUT_RAW, OUTPUT_RUNTIME, copyReaderOptions, normalizeValues, toJsonValue, validateClass, validateClassKey };
|
|
139
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sources":["../../../../../src/formats/red/core/helpers.js"],"sourcesContent":["export const OUTPUT_JSON = \"json\";\nexport const OUTPUT_PAYLOAD = \"payload\";\nexport const OUTPUT_RUNTIME = \"runtime\";\nexport const OUTPUT_RAW = \"raw\";\n\nexport const DEFAULT_VALUES = Object.freeze({\n emit: OUTPUT_JSON,\n schema: null,\n registry: null,\n firstId: 1,\n parse: null,\n adapter: null,\n adapters: null,\n payloadTypeField: \"_type\",\n payloadIdField: \"_id\",\n payloadReferenceField: \"_reference\",\n classes: Object.freeze({})\n});\n\nconst OPTION_KEYS = new Set(Object.keys(DEFAULT_VALUES));\n\nfunction hasOwn(value, key)\n{\n return Object.prototype.hasOwnProperty.call(value, key);\n}\n\nfunction normalizeEmit(emit, readerName)\n{\n if (emit === undefined || emit === OUTPUT_JSON) return OUTPUT_JSON;\n if (emit === OUTPUT_PAYLOAD) return OUTPUT_PAYLOAD;\n if (emit === OUTPUT_RUNTIME) return OUTPUT_RUNTIME;\n if (emit === OUTPUT_RAW) return OUTPUT_RAW;\n throw new Error(`${readerName} unknown emit value \"${emit}\"`);\n}\n\nfunction assertKnownOptions(options, readerName)\n{\n for (const key of Object.keys(options))\n {\n if (!OPTION_KEYS.has(key))\n {\n throw new TypeError(`${readerName} unknown option \"${key}\"`);\n }\n }\n}\n\nfunction classMap(values)\n{\n return values && values.classes ? values.classes : {};\n}\n\nfunction cloneValues(values)\n{\n return {\n emit: values.emit,\n schema: values.schema ?? null,\n registry: values.registry ?? null,\n firstId: values.firstId ?? 1,\n parse: values.parse ?? null,\n adapter: values.adapter ?? null,\n adapters: values.adapters ?? null,\n payloadTypeField: values.payloadTypeField,\n payloadIdField: values.payloadIdField,\n payloadReferenceField: values.payloadReferenceField,\n classes: { ...classMap(values) }\n };\n}\n\nexport function validateClassKey(classKeys, key, readerName)\n{\n if (typeof key !== \"string\" || !key)\n {\n throw new Error(`${readerName} class type must be a non-empty string`);\n }\n}\n\nexport function validateClass(classKeys, type, Class, readerName)\n{\n validateClassKey(classKeys, type, readerName);\n if (typeof Class !== \"function\")\n {\n throw new TypeError(`${readerName} class \"${type}\" must be a constructor`);\n }\n}\n\nfunction mergeClasses(values, classes, classKeys, readerName)\n{\n if (!classes || typeof classes !== \"object\")\n {\n throw new TypeError(`${readerName} classes option must be an object`);\n }\n\n const next = { ...values.classes };\n for (const [ type, Class ] of Object.entries(classes))\n {\n validateClass(classKeys, type, Class, readerName);\n next[type] = Class;\n }\n values.classes = next;\n}\n\nexport function normalizeValues(base, options, classKeys, readerName)\n{\n if (!options || typeof options !== \"object\")\n {\n throw new TypeError(`${readerName} options must be an object`);\n }\n\n assertKnownOptions(options, readerName);\n\n const values = cloneValues(base);\n if (hasOwn(options, \"emit\")) values.emit = normalizeEmit(options.emit, readerName);\n if (hasOwn(options, \"schema\")) values.schema = options.schema ?? null;\n if (hasOwn(options, \"registry\")) values.registry = options.registry ?? null;\n if (hasOwn(options, \"firstId\")) values.firstId = options.firstId ?? 1;\n if (hasOwn(options, \"parse\"))\n {\n if (options.parse !== null && options.parse !== undefined && typeof options.parse !== \"function\")\n {\n throw new TypeError(`${readerName} parse option must be a function`);\n }\n values.parse = options.parse ?? null;\n }\n if (hasOwn(options, \"adapter\")) values.adapter = options.adapter ?? null;\n if (hasOwn(options, \"adapters\")) values.adapters = options.adapters ?? null;\n if (hasOwn(options, \"payloadTypeField\")) values.payloadTypeField = options.payloadTypeField;\n if (hasOwn(options, \"payloadIdField\")) values.payloadIdField = options.payloadIdField;\n if (hasOwn(options, \"payloadReferenceField\")) values.payloadReferenceField = options.payloadReferenceField;\n if (hasOwn(options, \"classes\")) mergeClasses(values, options.classes, classKeys, readerName);\n return values;\n}\n\nexport function copyReaderOptions(values)\n{\n const { emit: _emit, schema: _schema, classes: _classes, ...readerOptions } = values;\n return readerOptions;\n}\n\nexport function toJsonValue(value, seen = new WeakSet())\n{\n if (value === null || typeof value !== \"object\") return value;\n if (ArrayBuffer.isView(value)) return Array.from(value, item => toJsonValue(item, seen));\n if (Array.isArray(value)) return value.map(item => toJsonValue(item, seen));\n\n if (seen.has(value))\n {\n throw new TypeError(\"Reader.toJSON cannot convert circular data\");\n }\n\n if (typeof value.toJSON === \"function\")\n {\n seen.add(value);\n const json = toJsonValue(value.toJSON(), seen);\n seen.delete(value);\n return json;\n }\n\n seen.add(value);\n const out = {};\n for (const key of Object.keys(value))\n {\n out[key] = toJsonValue(value[key], seen);\n }\n seen.delete(value);\n return out;\n}\n"],"names":["OUTPUT_JSON","OUTPUT_PAYLOAD","OUTPUT_RUNTIME","OUTPUT_RAW","DEFAULT_VALUES","Object","freeze","emit","schema","registry","firstId","parse","adapter","adapters","payloadTypeField","payloadIdField","payloadReferenceField","classes","OPTION_KEYS","Set","keys","hasOwn","value","key","prototype","hasOwnProperty","call","normalizeEmit","readerName","undefined","Error","assertKnownOptions","options","has","TypeError","classMap","values","cloneValues","validateClassKey","classKeys","validateClass","type","Class","mergeClasses","next","entries","normalizeValues","base","copyReaderOptions","_emit","_schema","_classes","readerOptions","toJsonValue","seen","WeakSet","ArrayBuffer","isView","Array","from","item","isArray","map","toJSON","add","json","delete","out"],"mappings":"AAAO,MAAMA,WAAW,GAAG;AACpB,MAAMC,cAAc,GAAG;AACvB,MAAMC,cAAc,GAAG;AACvB,MAAMC,UAAU,GAAG;MAEbC,cAAc,GAAGC,MAAM,CAACC,MAAM,CAAC;AACxCC,EAAAA,IAAI,EAAEP,WAAW;AACjBQ,EAAAA,MAAM,EAAE,IAAI;AACZC,EAAAA,QAAQ,EAAE,IAAI;AACdC,EAAAA,OAAO,EAAE,CAAC;AACVC,EAAAA,KAAK,EAAE,IAAI;AACXC,EAAAA,OAAO,EAAE,IAAI;AACbC,EAAAA,QAAQ,EAAE,IAAI;AACdC,EAAAA,gBAAgB,EAAE,OAAO;AACzBC,EAAAA,cAAc,EAAE,KAAK;AACrBC,EAA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f,MAAM6C,GAAG,GAAG,EAAE;EACd,KAAK,MAAM5C,GAAG,IAAIlB,MAAM,CAACe,IAAI,CAACE,KAAK,CAAC,EACpC;AACI6C,IAAAA,GAAG,CAAC5C,GAAG,CAAC,GAAG8B,WAAW,CAAC/B,KAAK,CAACC,GAAG,CAAC,EAAE+B,IAAI,CAAC;AAC5C,EAAA;AACAA,EAAAA,IAAI,CAACY,MAAM,CAAC5C,KAAK,CAAC;AAClB,EAAA,OAAO6C,GAAG;AACd;;;;"}
|
|
1
|
+
{"version":3,"file":"helpers.js","sources":["../../../../../src/formats/red/core/helpers.js"],"sourcesContent":["export const OUTPUT_JSON = \"json\";\nexport const OUTPUT_PAYLOAD = \"payload\";\nexport const OUTPUT_RUNTIME = \"runtime\";\nexport const OUTPUT_RAW = \"raw\";\n\nexport const DEFAULT_VALUES = Object.freeze({\n emit: OUTPUT_JSON,\n schema: null,\n registry: null,\n firstId: 1,\n parse: null,\n adapter: null,\n adapters: null,\n payloadTypeField: \"_type\",\n payloadIdField: \"_id\",\n payloadReferenceField: \"_reference\",\n payloadValuesField: \"_values\",\n classes: Object.freeze({})\n});\n\nconst OPTION_KEYS = new Set(Object.keys(DEFAULT_VALUES));\n\nfunction hasOwn(value, key)\n{\n return Object.prototype.hasOwnProperty.call(value, key);\n}\n\nfunction normalizeEmit(emit, readerName)\n{\n if (emit === undefined || emit === OUTPUT_JSON) return OUTPUT_JSON;\n if (emit === OUTPUT_PAYLOAD) return OUTPUT_PAYLOAD;\n if (emit === OUTPUT_RUNTIME) return OUTPUT_RUNTIME;\n if (emit === OUTPUT_RAW) return OUTPUT_RAW;\n throw new Error(`${readerName} unknown emit value \"${emit}\"`);\n}\n\nfunction assertKnownOptions(options, readerName)\n{\n for (const key of Object.keys(options))\n {\n if (!OPTION_KEYS.has(key))\n {\n throw new TypeError(`${readerName} unknown option \"${key}\"`);\n }\n }\n}\n\nfunction classMap(values)\n{\n return values && values.classes ? values.classes : {};\n}\n\nfunction cloneValues(values)\n{\n return {\n emit: values.emit,\n schema: values.schema ?? null,\n registry: values.registry ?? null,\n firstId: values.firstId ?? 1,\n parse: values.parse ?? null,\n adapter: values.adapter ?? null,\n adapters: values.adapters ?? null,\n payloadTypeField: values.payloadTypeField,\n payloadIdField: values.payloadIdField,\n payloadReferenceField: values.payloadReferenceField,\n payloadValuesField: values.payloadValuesField,\n classes: { ...classMap(values) }\n };\n}\n\nexport function validateClassKey(classKeys, key, readerName)\n{\n if (typeof key !== \"string\" || !key)\n {\n throw new Error(`${readerName} class type must be a non-empty string`);\n }\n}\n\nexport function validateClass(classKeys, type, Class, readerName)\n{\n validateClassKey(classKeys, type, readerName);\n if (typeof Class !== \"function\")\n {\n throw new TypeError(`${readerName} class \"${type}\" must be a constructor`);\n }\n}\n\nfunction mergeClasses(values, classes, classKeys, readerName)\n{\n if (!classes || typeof classes !== \"object\")\n {\n throw new TypeError(`${readerName} classes option must be an object`);\n }\n\n const next = { ...values.classes };\n for (const [ type, Class ] of Object.entries(classes))\n {\n validateClass(classKeys, type, Class, readerName);\n next[type] = Class;\n }\n values.classes = next;\n}\n\nexport function normalizeValues(base, options, classKeys, readerName)\n{\n if (!options || typeof options !== \"object\")\n {\n throw new TypeError(`${readerName} options must be an object`);\n }\n\n assertKnownOptions(options, readerName);\n\n const values = cloneValues(base);\n if (hasOwn(options, \"emit\")) values.emit = normalizeEmit(options.emit, readerName);\n if (hasOwn(options, \"schema\")) values.schema = options.schema ?? null;\n if (hasOwn(options, \"registry\")) values.registry = options.registry ?? null;\n if (hasOwn(options, \"firstId\")) values.firstId = options.firstId ?? 1;\n if (hasOwn(options, \"parse\"))\n {\n if (options.parse !== null && options.parse !== undefined && typeof options.parse !== \"function\")\n {\n throw new TypeError(`${readerName} parse option must be a function`);\n }\n values.parse = options.parse ?? null;\n }\n if (hasOwn(options, \"adapter\")) values.adapter = options.adapter ?? null;\n if (hasOwn(options, \"adapters\")) values.adapters = options.adapters ?? null;\n if (hasOwn(options, \"payloadTypeField\")) values.payloadTypeField = options.payloadTypeField;\n if (hasOwn(options, \"payloadIdField\")) values.payloadIdField = options.payloadIdField;\n if (hasOwn(options, \"payloadReferenceField\")) values.payloadReferenceField = options.payloadReferenceField;\n if (hasOwn(options, \"payloadValuesField\")) values.payloadValuesField = options.payloadValuesField;\n if (hasOwn(options, \"classes\")) mergeClasses(values, options.classes, classKeys, readerName);\n return values;\n}\n\nexport function copyReaderOptions(values)\n{\n const { emit: _emit, schema: _schema, classes: _classes, ...readerOptions } = values;\n return readerOptions;\n}\n\nexport function toJsonValue(value, seen = new WeakSet())\n{\n if (value === null || typeof value !== \"object\") return value;\n if (ArrayBuffer.isView(value)) return Array.from(value, item => toJsonValue(item, seen));\n if (Array.isArray(value)) return value.map(item => toJsonValue(item, seen));\n\n if (seen.has(value))\n {\n throw new TypeError(\"Reader.toJSON cannot convert circular data\");\n }\n\n if (typeof value.toJSON === \"function\")\n {\n seen.add(value);\n const json = toJsonValue(value.toJSON(), seen);\n seen.delete(value);\n return json;\n }\n\n seen.add(value);\n const out = {};\n for (const key of Object.keys(value))\n {\n out[key] = toJsonValue(value[key], seen);\n }\n seen.delete(value);\n return out;\n}\n"],"names":["OUTPUT_JSON","OUTPUT_PAYLOAD","OUTPUT_RUNTIME","OUTPUT_RAW","DEFAULT_VALUES","Object","freeze","emit","schema","registry","firstId","parse","adapter","adapters","payloadTypeField","payloadIdField","payloadReferenceField","payloadValuesField","classes","OPTION_KEYS","Set","keys","hasOwn","value","key","prototype","hasOwnProperty","call","normalizeEmit","readerName","undefined","Error","assertKnownOptions","options","has","TypeError","classMap","values","cloneValues","validateClassKey","classKeys","validateClass","type","Class","mergeClasses","next","entries","normalizeValues","base","copyReaderOptions","_emit","_schema","_classes","readerOptions","toJsonValue","seen","WeakSet","ArrayBuffer","isView","Array","from","item","isArray","map","toJSON","add","json","delete","out"],"mappings":"AAAO,MAAMA,WAAW,GAAG;AACpB,MAAMC,cAAc,GAAG;AACvB,MAAMC,cAAc,GAAG;AACvB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,EAAE,OAAOA,KAAK,CAACwC,GAAG,CAACF,IAAI,IAAIP,WAAW,CAACO,IAAI,EAAEN,IAAI,CAAC,CAAC;AAE3E,EAAA,IAAIA,IAAI,CAACrB,GAAG,CAACX,KAAK,CAAC,EACnB;AACI,IAAA,MAAM,IAAIY,SAAS,CAAC,4CAA4C,CAAC;AACrE,EAAA;AAEA,EAAA,IAAI,OAAOZ,KAAK,CAACyC,MAAM,KAAK,UAAU,EACtC;AACIT,IAAAA,IAAI,CAACU,GAAG,CAAC1C,KAAK,CAAC;IACf,MAAM2C,IAAI,GAAGZ,WAAW,CAAC/B,KAAK,CAACyC,MAAM,EAAE,EAAET,IAAI,CAAC;AAC9CA,IAAAA,IAAI,CAACY,MAAM,CAAC5C,KAAK,CAAC;AAClB,IAAA,OAAO2C,IAAI;AACf,EAAA;AAEAX,EAAAA,IAAI,CAACU,GAAG,CAAC1C,KAAK,CAAC;EACf,MAAM6C,GAAG,GAAG,EAAE;EACd,KAAK,MAAM5C,GAAG,IAAInB,MAAM,CAACgB,IAAI,CAACE,KAAK,CAAC,EACpC;AACI6C,IAAAA,GAAG,CAAC5C,GAAG,CAAC,GAAG8B,WAAW,CAAC/B,KAAK,CAACC,GAAG,CAAC,EAAE+B,IAAI,CAAC;AAC5C,EAAA;AACAA,EAAAA,IAAI,CAACY,MAAM,CAAC5C,KAAK,CAAC;AAClB,EAAA,OAAO6C,GAAG;AACd;;;;"}
|
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
import { CjsYamlFormat } from '../../yaml/CjsYamlFormat.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Keys added by authoring tools are prefixed with a double underscore and are
|
|
5
|
-
* not part of the Red data. They can carry environment-specific information, so
|
|
6
|
-
* they are stripped on every read and never emitted.
|
|
7
|
-
* @param {string} key
|
|
8
|
-
* @returns {boolean}
|
|
9
|
-
*/
|
|
10
|
-
function isStrippedKey(key) {
|
|
11
|
-
return typeof key === "string" && key.length > 1 && key[0] === "_" && key[1] === "_";
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Parses Red input into a plain object graph.
|
|
16
|
-
*
|
|
17
|
-
* Accepts an already-parsed object (returned as-is) or a YAML string. YAML
|
|
18
|
-
* anchors/aliases resolve to shared object identities, which the reader uses
|
|
19
|
-
* to rebuild the Red reference graph.
|
|
20
|
-
*
|
|
21
|
-
* @param {unknown} input parsed Red object or YAML string
|
|
22
|
-
* @param {object} [options] `options.parse(text)` overrides the built-in parser
|
|
23
|
-
* @param {string} [readerName]
|
|
24
|
-
* @returns {object} parsed Red object graph
|
|
25
|
-
*/
|
|
26
|
-
function parseRed(input, options = {}, readerName = "CjsRedFormat") {
|
|
27
|
-
if (input && typeof input === "object") return input;
|
|
28
|
-
if (typeof input === "string") {
|
|
29
|
-
if (typeof options.parse === "function") return options.parse(input);
|
|
30
|
-
return CjsYamlFormat.readRaw(input, {
|
|
31
|
-
tagPolicy: "reject"
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
throw new TypeError(`${readerName}: input must be a parsed Red object or a YAML string.`);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* A "typed table" is Red's compact columnar encoding: a `structure` array of
|
|
39
|
-
* `[name, typeCode, byteOffset]` columns plus an `items` array where each row
|
|
40
|
-
* is one record aligned to those columns. Curve `keys`, effect `options`, and
|
|
41
|
-
* `samplerOverrides` all use this shape.
|
|
42
|
-
* @param {*} node
|
|
43
|
-
* @returns {boolean}
|
|
44
|
-
*/
|
|
45
|
-
function isTypedTable(node) {
|
|
46
|
-
return Boolean(node && typeof node === "object" && !Array.isArray(node) && Array.isArray(node.structure) && Array.isArray(node.items));
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Decodes a typed table into an array of row objects keyed by column name.
|
|
51
|
-
* @param {object} node typed table (`{ structure, items }`)
|
|
52
|
-
* @returns {Array<object>}
|
|
53
|
-
*/
|
|
54
|
-
function decodeTypedTable(node) {
|
|
55
|
-
const columns = node.structure.map(column => Array.isArray(column) ? column[0] : column && column.name);
|
|
56
|
-
return node.items.map(row => {
|
|
57
|
-
const record = {};
|
|
58
|
-
const cells = Array.isArray(row) ? row : [row];
|
|
59
|
-
for (let i = 0; i < columns.length; i++) {
|
|
60
|
-
if (columns[i] === undefined || columns[i] === null) continue;
|
|
61
|
-
record[columns[i]] = cells[i];
|
|
62
|
-
}
|
|
63
|
-
return record;
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export { decodeTypedTable, isStrippedKey, isTypedTable, parseRed };
|
|
68
|
-
//# sourceMappingURL=redGraph.js.map
|
|
1
|
+
import { CjsYamlFormat } from '../../yaml/CjsYamlFormat.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Keys added by authoring tools are prefixed with a double underscore and are
|
|
5
|
+
* not part of the Red data. They can carry environment-specific information, so
|
|
6
|
+
* they are stripped on every read and never emitted.
|
|
7
|
+
* @param {string} key
|
|
8
|
+
* @returns {boolean}
|
|
9
|
+
*/
|
|
10
|
+
function isStrippedKey(key) {
|
|
11
|
+
return typeof key === "string" && key.length > 1 && key[0] === "_" && key[1] === "_";
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Parses Red input into a plain object graph.
|
|
16
|
+
*
|
|
17
|
+
* Accepts an already-parsed object (returned as-is) or a YAML string. YAML
|
|
18
|
+
* anchors/aliases resolve to shared object identities, which the reader uses
|
|
19
|
+
* to rebuild the Red reference graph.
|
|
20
|
+
*
|
|
21
|
+
* @param {unknown} input parsed Red object or YAML string
|
|
22
|
+
* @param {object} [options] `options.parse(text)` overrides the built-in parser
|
|
23
|
+
* @param {string} [readerName]
|
|
24
|
+
* @returns {object} parsed Red object graph
|
|
25
|
+
*/
|
|
26
|
+
function parseRed(input, options = {}, readerName = "CjsRedFormat") {
|
|
27
|
+
if (input && typeof input === "object") return input;
|
|
28
|
+
if (typeof input === "string") {
|
|
29
|
+
if (typeof options.parse === "function") return options.parse(input);
|
|
30
|
+
return CjsYamlFormat.readRaw(input, {
|
|
31
|
+
tagPolicy: "reject"
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
throw new TypeError(`${readerName}: input must be a parsed Red object or a YAML string.`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A "typed table" is Red's compact columnar encoding: a `structure` array of
|
|
39
|
+
* `[name, typeCode, byteOffset]` columns plus an `items` array where each row
|
|
40
|
+
* is one record aligned to those columns. Curve `keys`, effect `options`, and
|
|
41
|
+
* `samplerOverrides` all use this shape.
|
|
42
|
+
* @param {*} node
|
|
43
|
+
* @returns {boolean}
|
|
44
|
+
*/
|
|
45
|
+
function isTypedTable(node) {
|
|
46
|
+
return Boolean(node && typeof node === "object" && !Array.isArray(node) && Array.isArray(node.structure) && Array.isArray(node.items));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Decodes a typed table into an array of row objects keyed by column name.
|
|
51
|
+
* @param {object} node typed table (`{ structure, items }`)
|
|
52
|
+
* @returns {Array<object>}
|
|
53
|
+
*/
|
|
54
|
+
function decodeTypedTable(node) {
|
|
55
|
+
const columns = node.structure.map(column => Array.isArray(column) ? column[0] : column && column.name);
|
|
56
|
+
return node.items.map(row => {
|
|
57
|
+
const record = {};
|
|
58
|
+
const cells = Array.isArray(row) ? row : [row];
|
|
59
|
+
for (let i = 0; i < columns.length; i++) {
|
|
60
|
+
if (columns[i] === undefined || columns[i] === null) continue;
|
|
61
|
+
record[columns[i]] = cells[i];
|
|
62
|
+
}
|
|
63
|
+
return record;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export { decodeTypedTable, isStrippedKey, isTypedTable, parseRed };
|
|
68
|
+
//# sourceMappingURL=redGraph.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const CLASS_KEYS = Object.freeze(["Root", "Document", "Mapping", "Sequence", "Scalar", "Reference"]);
|
|
2
|
-
|
|
3
|
-
export { CLASS_KEYS };
|
|
4
|
-
//# sourceMappingURL=schema.js.map
|
|
1
|
+
const CLASS_KEYS = Object.freeze(["Root", "Document", "Mapping", "Sequence", "Scalar", "Reference"]);
|
|
2
|
+
|
|
3
|
+
export { CLASS_KEYS };
|
|
4
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { CjsRedFormat, CjsRedFormat as default } from './CjsRedFormat.js';
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export { CjsRedFormat, CjsRedFormat as default } from './CjsRedFormat.js';
|
|
2
|
+
//# sourceMappingURL=index.js.map
|