scjson 0.3.5 → 0.4.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/dist/comment_promotion.d.ts +105 -0
- package/dist/comment_promotion.js +920 -0
- package/dist/converters.d.ts +74 -3
- package/dist/converters.js +255 -9
- package/package.json +3 -3
- package/scjson.schema.json +219 -83
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local tag names that own a ``help_text`` field on the model side.
|
|
3
|
+
* Mirrors ``APPLIES_TO_TAGS`` in ``py/scjson/comment_promotion.py``.
|
|
4
|
+
*/
|
|
5
|
+
export const APPLIES_TO_TAGS: Set<string>;
|
|
6
|
+
/**
|
|
7
|
+
* Tags whose textual content is opaque target-language source. Comments
|
|
8
|
+
* inside these elements remain content and MUST NOT be promoted (CONV-F
|
|
9
|
+
* rule 5).
|
|
10
|
+
*/
|
|
11
|
+
export const SOURCE_BODY_TAGS: Set<string>;
|
|
12
|
+
export namespace TAG_TO_ATTR {
|
|
13
|
+
let _if: string;
|
|
14
|
+
export { _if as if };
|
|
15
|
+
export let raise: string;
|
|
16
|
+
let _else: string;
|
|
17
|
+
export { _else as else };
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Fields in the JS model that hold a *singleton* object rather than an
|
|
21
|
+
* array of objects under XML elements named ``transition``.
|
|
22
|
+
*
|
|
23
|
+
* Used by ``resolveAddress`` so a singleton field can still satisfy an
|
|
24
|
+
* address segment ``["transition", 0]`` even though it is not wrapped in
|
|
25
|
+
* a JS array.
|
|
26
|
+
*/
|
|
27
|
+
export const SINGLETON_TRANSITION_PARENTS: Set<string>;
|
|
28
|
+
/**
|
|
29
|
+
* Return the JS model attribute name for an XML local tag.
|
|
30
|
+
*
|
|
31
|
+
* @param {string} tag - XML local tag name.
|
|
32
|
+
* @returns {string} Attribute name on the JS model object.
|
|
33
|
+
*/
|
|
34
|
+
export function modelAttrForTag(tag: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Canonical key for a tuple-address. Used as a Map key so two addresses
|
|
37
|
+
* with the same shape collide.
|
|
38
|
+
*
|
|
39
|
+
* @param {Array<[string, number]>} address - Tuple address.
|
|
40
|
+
* @returns {string} JSON serialization of the address.
|
|
41
|
+
*/
|
|
42
|
+
export function addressKey(address: Array<[string, number]>): string;
|
|
43
|
+
/**
|
|
44
|
+
* Repair raw XML comment body text per CONV-F §294-299.
|
|
45
|
+
*
|
|
46
|
+
* Strips a common leading indentation margin from multi-line block comments
|
|
47
|
+
* and trims leading/trailing blank lines. Does NOT paragraph-wrap or
|
|
48
|
+
* coalesce. Single-line comments are stripped only of edge whitespace.
|
|
49
|
+
*
|
|
50
|
+
* @param {string} raw - Comment body text without the ``<!--`` / ``-->``
|
|
51
|
+
* delimiters.
|
|
52
|
+
* @returns {string} Repaired text suitable for storage in ``help_text``.
|
|
53
|
+
*/
|
|
54
|
+
export function repairCommentText(raw: string): string;
|
|
55
|
+
/**
|
|
56
|
+
* Return a body string safe to wrap in ``<!-- ... -->``.
|
|
57
|
+
*
|
|
58
|
+
* Per CONV-F §340-344: the forbidden sequence ``--`` is replaced with
|
|
59
|
+
* ``- -`` and a body ending in ``-`` gets one trailing space appended.
|
|
60
|
+
*
|
|
61
|
+
* @param {string} text - Repaired help_text entry.
|
|
62
|
+
* @returns {string} Comment-safe body.
|
|
63
|
+
*/
|
|
64
|
+
export function emitSafeCommentText(text: string): string;
|
|
65
|
+
/**
|
|
66
|
+
* Extract help_text promotion metadata from an SCXML string.
|
|
67
|
+
*
|
|
68
|
+
* @param {string} xmlStr - Raw SCXML string.
|
|
69
|
+
* @returns {{cleanedXml: string, addressMap: Map<string, string[]>, addressMapJson: Array<{address: Array<[string,number]>, comments: string[]}>}}
|
|
70
|
+
* The comment-free XML serialization and the address map.
|
|
71
|
+
* ``addressMapJson`` provides a stable JSON-friendly projection for
|
|
72
|
+
* downstream callers or cross-language fixture comparison.
|
|
73
|
+
* On parse failure returns the original string and an empty map.
|
|
74
|
+
*/
|
|
75
|
+
export function extractHelpTextFromXml(xmlStr: string): {
|
|
76
|
+
cleanedXml: string;
|
|
77
|
+
addressMap: Map<string, string[]>;
|
|
78
|
+
addressMapJson: Array<{
|
|
79
|
+
address: Array<[string, number]>;
|
|
80
|
+
comments: string[];
|
|
81
|
+
}>;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Append each address's comment list to the corresponding model element's
|
|
85
|
+
* ``help_text`` array.
|
|
86
|
+
*
|
|
87
|
+
* Comments are appended to any existing ``help_text`` entries per CONV-F
|
|
88
|
+
* rule 7.
|
|
89
|
+
*
|
|
90
|
+
* @param {object} model - Root SCJSON object.
|
|
91
|
+
* @param {Map<string, string[]>} addressMap - Map produced by
|
|
92
|
+
* ``extractHelpTextFromXml``.
|
|
93
|
+
*/
|
|
94
|
+
export function attachHelpTextToModel(model: object, addressMap: Map<string, string[]>): void;
|
|
95
|
+
/**
|
|
96
|
+
* Re-emit ``xmlStr`` with each model element's ``help_text`` entries as
|
|
97
|
+
* leading XML comments.
|
|
98
|
+
*
|
|
99
|
+
* @param {string} xmlStr - Comment-free SCXML produced by the existing
|
|
100
|
+
* ``jsonToXml`` pipeline.
|
|
101
|
+
* @param {object} model - The SCJSON model whose ``help_text`` lists drive
|
|
102
|
+
* injection.
|
|
103
|
+
* @returns {string} SCXML with leading comments inserted.
|
|
104
|
+
*/
|
|
105
|
+
export function injectHelpTextCommentsIntoXml(xmlStr: string, model: object): string;
|