@cdk8s/awscdk-resolver 0.0.608 → 0.0.610

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 (145) hide show
  1. package/.jsii +3 -3
  2. package/lib/resolve.js +1 -1
  3. package/node_modules/@aws-sdk/client-cloudformation/package.json +3 -3
  4. package/node_modules/@aws-sdk/core/package.json +2 -2
  5. package/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
  6. package/node_modules/@aws-sdk/credential-provider-http/package.json +2 -2
  7. package/node_modules/@aws-sdk/credential-provider-ini/package.json +9 -9
  8. package/node_modules/@aws-sdk/credential-provider-login/package.json +3 -3
  9. package/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
  10. package/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
  11. package/node_modules/@aws-sdk/credential-provider-sso/package.json +4 -4
  12. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
  13. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +1 -1
  14. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +1 -1
  15. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +1 -1
  16. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +1 -1
  17. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +1 -1
  18. package/node_modules/@aws-sdk/nested-clients/package.json +2 -2
  19. package/node_modules/@aws-sdk/token-providers/package.json +3 -3
  20. package/node_modules/@aws-sdk/xml-builder/dist-cjs/xml-parser.browser.js +1 -1
  21. package/node_modules/@aws-sdk/xml-builder/dist-cjs/xml-parser.js +233 -43
  22. package/node_modules/@aws-sdk/xml-builder/dist-es/xml-parser.browser.js +1 -1
  23. package/node_modules/@aws-sdk/xml-builder/dist-es/xml-parser.js +233 -43
  24. package/node_modules/@aws-sdk/xml-builder/dist-types/ts3.4/xml-parser.d.ts +1 -1
  25. package/node_modules/@aws-sdk/xml-builder/dist-types/xml-parser.d.ts +2 -1
  26. package/node_modules/@aws-sdk/xml-builder/package.json +4 -4
  27. package/node_modules/@smithy/core/dist-cjs/submodules/cbor/index.js +518 -371
  28. package/node_modules/@smithy/core/dist-cjs/submodules/client/index.js +1 -1
  29. package/node_modules/@smithy/core/dist-es/submodules/cbor/cbor-decode.js +326 -269
  30. package/node_modules/@smithy/core/dist-es/submodules/cbor/cbor-encode.js +192 -103
  31. package/node_modules/@smithy/core/dist-es/submodules/cbor/cbor.js +4 -2
  32. package/node_modules/@smithy/core/dist-es/submodules/client/smithy-client/get-value-from-text-node.js +1 -1
  33. package/node_modules/@smithy/core/dist-types/submodules/cbor/cbor-decode.d.ts +4 -0
  34. package/node_modules/@smithy/core/dist-types/submodules/cbor/cbor-encode.d.ts +8 -4
  35. package/node_modules/@smithy/core/package.json +1 -1
  36. package/node_modules/@smithy/credential-provider-imds/package.json +2 -2
  37. package/node_modules/@smithy/fetch-http-handler/package.json +2 -2
  38. package/node_modules/@smithy/node-http-handler/package.json +2 -2
  39. package/node_modules/@smithy/signature-v4/package.json +2 -2
  40. package/package.json +6 -6
  41. package/node_modules/@aws-sdk/xml-builder/dist-cjs/xml-external/nodable_entities.js +0 -333
  42. package/node_modules/@aws-sdk/xml-builder/dist-es/xml-external/nodable_entities.js +0 -332
  43. package/node_modules/@aws-sdk/xml-builder/dist-types/ts3.4/xml-external/nodable_entities.d.ts +0 -66
  44. package/node_modules/@aws-sdk/xml-builder/dist-types/xml-external/nodable_entities.d.ts +0 -65
  45. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/CHANGELOG.md +0 -827
  46. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/LICENSE +0 -21
  47. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/README.md +0 -202
  48. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxbuilder.min.js +0 -2
  49. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxbuilder.min.js.map +0 -1
  50. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxp.cjs +0 -1
  51. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxp.d.cts +0 -770
  52. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxp.min.js +0 -2
  53. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxp.min.js.map +0 -1
  54. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxparser.min.js +0 -2
  55. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxparser.min.js.map +0 -1
  56. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxvalidator.min.js +0 -2
  57. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxvalidator.min.js.map +0 -1
  58. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/package.json +0 -93
  59. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/cli/cli.js +0 -97
  60. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/cli/man.js +0 -17
  61. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/cli/read.js +0 -43
  62. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/fxp.d.ts +0 -739
  63. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/fxp.js +0 -14
  64. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/ignoreAttributes.js +0 -18
  65. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/util.js +0 -61
  66. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/CharsSymbol.js +0 -16
  67. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/EntitiesParser.js +0 -106
  68. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/OptionsBuilder.js +0 -61
  69. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/OutputBuilders/BaseOutputBuilder.js +0 -69
  70. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsArrBuilder.js +0 -103
  71. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsMinArrBuilder.js +0 -100
  72. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsObjBuilder.js +0 -154
  73. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/OutputBuilders/ParserOptionsBuilder.js +0 -94
  74. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/Report.js +0 -0
  75. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/TagPath.js +0 -81
  76. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/TagPathMatcher.js +0 -13
  77. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/XMLParser.js +0 -83
  78. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/Xml2JsParser.js +0 -235
  79. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/XmlPartReader.js +0 -210
  80. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/XmlSpecialTagsReader.js +0 -111
  81. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/inputSource/BufferSource.js +0 -116
  82. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/inputSource/StringSource.js +0 -121
  83. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/EntitiesParser.js +0 -105
  84. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/booleanParser.js +0 -22
  85. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/booleanParserExt.js +0 -19
  86. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/currency.js +0 -38
  87. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/join.js +0 -13
  88. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/number.js +0 -14
  89. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/trim.js +0 -6
  90. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/validator.js +0 -425
  91. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlbuilder/json2xml.js +0 -6
  92. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js +0 -407
  93. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js +0 -163
  94. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js +0 -840
  95. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/XMLParser.js +0 -71
  96. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/node2json.js +0 -177
  97. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/xmlNode.js +0 -40
  98. package/node_modules/@nodable/entities/README.md +0 -41
  99. package/node_modules/@nodable/entities/package.json +0 -57
  100. package/node_modules/@nodable/entities/src/EntityDecoder.js +0 -644
  101. package/node_modules/@nodable/entities/src/EntityEncoder.js +0 -194
  102. package/node_modules/@nodable/entities/src/entities.js +0 -1159
  103. package/node_modules/@nodable/entities/src/entityTries.js +0 -49
  104. package/node_modules/@nodable/entities/src/index.d.ts +0 -341
  105. package/node_modules/@nodable/entities/src/index.js +0 -29
  106. package/node_modules/anynum/LICENSE +0 -21
  107. package/node_modules/anynum/README.md +0 -142
  108. package/node_modules/anynum/anynum.js +0 -135
  109. package/node_modules/anynum/digitTable.js +0 -116
  110. package/node_modules/anynum/package.json +0 -42
  111. package/node_modules/fast-xml-builder/CHANGELOG.md +0 -40
  112. package/node_modules/fast-xml-builder/LICENSE +0 -21
  113. package/node_modules/fast-xml-builder/README.md +0 -74
  114. package/node_modules/fast-xml-builder/lib/fxb.cjs +0 -1
  115. package/node_modules/fast-xml-builder/lib/fxb.d.cts +0 -270
  116. package/node_modules/fast-xml-builder/lib/fxb.min.js +0 -2
  117. package/node_modules/fast-xml-builder/lib/fxb.min.js.map +0 -1
  118. package/node_modules/fast-xml-builder/package.json +0 -81
  119. package/node_modules/fast-xml-builder/src/fxb.d.ts +0 -270
  120. package/node_modules/fast-xml-builder/src/fxb.js +0 -599
  121. package/node_modules/fast-xml-builder/src/ignoreAttributes.js +0 -18
  122. package/node_modules/fast-xml-builder/src/orderedJs2Xml.js +0 -359
  123. package/node_modules/fast-xml-builder/src/prettifyJs2Xml.js +0 -0
  124. package/node_modules/fast-xml-builder/src/util.js +0 -16
  125. package/node_modules/path-expression-matcher/LICENSE +0 -21
  126. package/node_modules/path-expression-matcher/README.md +0 -947
  127. package/node_modules/path-expression-matcher/lib/pem.cjs +0 -1
  128. package/node_modules/path-expression-matcher/lib/pem.d.cts +0 -715
  129. package/node_modules/path-expression-matcher/lib/pem.min.js +0 -2
  130. package/node_modules/path-expression-matcher/lib/pem.min.js.map +0 -1
  131. package/node_modules/path-expression-matcher/package.json +0 -79
  132. package/node_modules/path-expression-matcher/src/Expression.js +0 -232
  133. package/node_modules/path-expression-matcher/src/ExpressionSet.js +0 -225
  134. package/node_modules/path-expression-matcher/src/Matcher.js +0 -660
  135. package/node_modules/path-expression-matcher/src/index.d.ts +0 -589
  136. package/node_modules/path-expression-matcher/src/index.js +0 -29
  137. package/node_modules/strnum/CHANGELOG.md +0 -51
  138. package/node_modules/strnum/LICENSE +0 -21
  139. package/node_modules/strnum/README.md +0 -113
  140. package/node_modules/strnum/package.json +0 -36
  141. package/node_modules/strnum/strnum.js +0 -171
  142. package/node_modules/xml-naming/README.md +0 -189
  143. package/node_modules/xml-naming/package.json +0 -54
  144. package/node_modules/xml-naming/src/index.d.ts +0 -74
  145. package/node_modules/xml-naming/src/index.js +0 -270
@@ -1,49 +0,0 @@
1
- // entityTries.js
2
- // Builds integer-keyed tries so the decoder never allocates a string object
3
- // during lookup — every key is a plain charCode number.
4
- //
5
- // trie1: Map<code0, entity>
6
- // trie2: Map<code0, Map<code1, entity>>
7
- // trie3: Map<code0, Map<code1, Map<code2, entity>>>
8
-
9
- import { ALL_ENTITIES } from './entities.js';
10
-
11
- // Reverse map: character sequence → "&name;"
12
- const CHAR_TO_ENTITY = new Map();
13
- for (const [name, chars] of Object.entries(ALL_ENTITIES)) {
14
- CHAR_TO_ENTITY.set(chars, `&${name};`);
15
- }
16
-
17
- export const trie1 = new Map(); // code0 → entity string
18
- export const trie2 = new Map(); // code0 → Map → entity string
19
- export const trie3 = new Map(); // code0 → Map → Map → entity string
20
-
21
- for (const [chars, entity] of CHAR_TO_ENTITY) {
22
- const len = chars.length;
23
-
24
- if (len === 1) {
25
- const c0 = chars.charCodeAt(0);
26
- // Keep shortest match only if no longer match already claimed this code
27
- // (longer matches are inserted in the same pass so we just overwrite —
28
- // trie1 is only consulted after trie2/trie3 both miss, so no conflict)
29
- trie1.set(c0, entity);
30
-
31
- } else if (len === 2) {
32
- const c0 = chars.charCodeAt(0);
33
- const c1 = chars.charCodeAt(1);
34
- let inner = trie2.get(c0);
35
- if (inner === undefined) { inner = new Map(); trie2.set(c0, inner); }
36
- inner.set(c1, entity);
37
-
38
- } else if (len === 3) {
39
- const c0 = chars.charCodeAt(0);
40
- const c1 = chars.charCodeAt(1);
41
- const c2 = chars.charCodeAt(2);
42
- let mid = trie3.get(c0);
43
- if (mid === undefined) { mid = new Map(); trie3.set(c0, mid); }
44
- let inner = mid.get(c1);
45
- if (inner === undefined) { inner = new Map(); mid.set(c1, inner); }
46
- inner.set(c2, entity);
47
- }
48
- // HTML5 has no named entity whose character sequence is longer than 3 chars
49
- }
@@ -1,341 +0,0 @@
1
- // ---------------------------------------------------------------------------
2
- // @nodable/entities — TypeScript declarations
3
- // ---------------------------------------------------------------------------
4
-
5
- /** A function-based entity replacement value (used for numeric refs). */
6
- export type EntityValFn = (match: string, captured: string, ...rest: unknown[]) => string;
7
-
8
- // ---------------------------------------------------------------------------
9
- // Entity registration hook
10
- // ---------------------------------------------------------------------------
11
-
12
- /**
13
- * Actions returned by `onExternalEntity` / `onInputEntity` hooks.
14
- * Use the `ENTITY_ACTION` constant object instead of raw strings to avoid typos.
15
- *
16
- * - `'allow'` — register and expand the entity normally
17
- * - `'block'` — silently skip the entity (not registered, treated as unknown)
18
- * - `'throw'` — abort registration with an error
19
- */
20
- export type EntityHookAction = 'allow' | 'block' | 'throw';
21
-
22
- /**
23
- * Immutable constant bag for entity registration hook return values.
24
- *
25
- * @example
26
- * import { ENTITY_ACTION } from '@nodable/entities';
27
- * const dec = new EntityDecoder({
28
- * onInputEntity: (_name, _value) => ENTITY_ACTION.BLOCK,
29
- * });
30
- */
31
- export const ENTITY_ACTION: Readonly<{
32
- /** Register and expand the entity normally. */
33
- ALLOW: 'allow';
34
- /** Silently skip this entity — it will not be registered. */
35
- BLOCK: 'block';
36
- /** Throw an error, aborting entity registration. */
37
- THROW: 'throw';
38
- }>;
39
-
40
- /**
41
- * Callback signature for `onExternalEntity` and `onInputEntity` hooks.
42
- *
43
- * Called once per entity **at registration time** (not at decode time).
44
- * Return `ENTITY_ACTION.ALLOW` (or `'allow'`) to accept, `ENTITY_ACTION.BLOCK`
45
- * to silently skip, or `ENTITY_ACTION.THROW` to raise an error.
46
- *
47
- * @param name — the entity name without `&` / `;`, e.g. `"brand"`
48
- * @param value — the resolved string value after any `{regex,val}` unwrapping
49
- */
50
- export type EntityRegistrationHook = (name: string, value: string) => EntityHookAction;
51
-
52
- // ---------------------------------------------------------------------------
53
- // Encoder options
54
- // ---------------------------------------------------------------------------
55
-
56
- export interface EntityEncoderOptions {
57
- /**
58
- * Whether to encode XML unsafe characters: `&`, `<`, `>`, `"`, `'`.
59
- * @default true
60
- */
61
- encodeXmlSafe?: boolean;
62
-
63
- /**
64
- * Whether to encode non‑ASCII characters (e.g. `é` → `&eacute;`) using the
65
- * built‑in named entity trie.
66
- * @default true
67
- */
68
- encodeAllNamed?: boolean;
69
-
70
- /**
71
- * Maximum number of replacements performed **cumulatively** across all
72
- * `encode()` calls. `0` means unlimited.
73
- *
74
- * Use `reset()` to reset the internal counter.
75
- * @default 0
76
- */
77
- maxReplacements?: number;
78
- }
79
-
80
- // ---------------------------------------------------------------------------
81
- // EntityEncoder class
82
- // ---------------------------------------------------------------------------
83
-
84
- /**
85
- * High‑performance encoder that replaces characters with XML/HTML entities.
86
- *
87
- * - Escapes XML unsafe characters (`&`, `<`, `>`, `"`, `'`) when `encodeXmlSafe` is true.
88
- * - Replaces non‑ASCII characters (e.g. `é`, `©`) with named entities using
89
- * a compact trie‑based lookup when `encodeAllNamed` is true.
90
- * - Supports a cumulative replacement limit (`maxReplacements`) that persists
91
- * across multiple `encode()` calls until `reset()` is called.
92
- *
93
- * @example
94
- * const encoder = new EntityEncoder({ encodeXmlSafe: true, encodeAllNamed: true });
95
- * encoder.encode('<foo>'); // "&lt;foo&gt;"
96
- * encoder.encode('© 2025'); // "&copy; 2025"
97
- *
98
- * // With limit
99
- * const limited = new EntityEncoder({ maxReplacements: 2 });
100
- * limited.encode('<>&'); // "&lt;&gt;&" (third replacement omitted)
101
- * limited.reset(); // reset counter
102
- */
103
- export class EntityEncoder {
104
- constructor(options?: EntityEncoderOptions);
105
-
106
- /**
107
- * Encode a string by replacing XML‑unsafe characters and (optionally)
108
- * non‑ASCII characters with named entities.
109
- *
110
- * If `maxReplacements` is set and the cumulative limit has been reached,
111
- * the input string is returned unchanged.
112
- *
113
- * @returns Encoded string (may be identical to input if no replacements needed
114
- * or the limit has been exhausted).
115
- */
116
- encode(str: string): string;
117
-
118
- /**
119
- * Reset the internal replacement counter.
120
- * Does **not** change `encodeXmlSafe`, `encodeAllNamed`, or `maxReplacements`.
121
- */
122
- reset(): void;
123
- }
124
-
125
- // ---------------------------------------------------------------------------
126
- // Constructor options for EntityDecoder (existing)
127
- // ---------------------------------------------------------------------------
128
-
129
- /**
130
- * Controls which entity categories count toward the expansion limits.
131
- *
132
- * - `'external'` — only untrusted / injected entities (default)
133
- * - `'base'` — only built‑in XML entities + user‑supplied `namedEntities`
134
- * - `'all'` — all entities regardless of tier
135
- * - `string[]` — explicit combination, e.g. `['external', 'base']`
136
- */
137
- export type ApplyLimitsTo = 'external' | 'base' | 'all' | Array<'external' | 'base'>;
138
-
139
- export interface EntityDecoderLimitOptions {
140
- /**
141
- * Maximum number of entity references expanded **per document**.
142
- * `0` means unlimited.
143
- * @default 0
144
- */
145
- maxTotalExpansions?: number;
146
-
147
- /**
148
- * Maximum number of characters **added** by entity expansion per document.
149
- * `0` means unlimited.
150
- * @default 0
151
- */
152
- maxExpandedLength?: number;
153
-
154
- /**
155
- * Which entity tiers count toward the expansion limits.
156
- *
157
- * - `'external'` (default) – only input/runtime + persistent external entities
158
- * - `'base'` – only built‑in XML + `namedEntities`
159
- * - `'all'` – every entity regardless of tier
160
- * - `string[]` – explicit combination, e.g. `['external', 'base']`
161
- *
162
- * @default 'external'
163
- */
164
- applyLimitsTo?: ApplyLimitsTo;
165
- }
166
-
167
- export interface EntityDecoderNCROptions {
168
- /**
169
- * XML version used for NCR classification.
170
- * @default 1.0
171
- */
172
- xmlVersion?: 1.0 | 1.1;
173
-
174
- /**
175
- * Base action for all numeric references.
176
- * @default 'allow'
177
- */
178
- onNCR?: 'allow' | 'leave' | 'remove' | 'throw';
179
-
180
- /**
181
- * Action for null NCR (U+0000).
182
- * @default 'remove'
183
- */
184
- nullNCR?: 'remove' | 'throw';
185
- }
186
-
187
- export interface EntityDecoderOptions {
188
- /**
189
- * Extra named entities merged into the **base map** (trusted, counts as `'base'` tier).
190
- * These are combined with the built‑in XML entities (`lt`, `gt`, `quot`, `apos`).
191
- * Values containing `&` are silently skipped to prevent recursive expansion.
192
- *
193
- * @default null
194
- */
195
- namedEntities?: Record<string, string | { regex: RegExp; val: string | EntityValFn }> | null;
196
-
197
-
198
- /**
199
- * Hook called once on the fully decoded string (after all replacements).
200
- *
201
- * - Receives `(resolved, original)` and **must return a string**.
202
- * - To reject expansion, return `original`.
203
- * - To sanitize, return a cleaned version of `resolved`.
204
- *
205
- * @example
206
- * postCheck: (resolved, original) =>
207
- * /<[a-z]/i.test(resolved) ? original : resolved
208
- */
209
- postCheck?: ((resolved: string, original: string) => string) | null;
210
-
211
- /**
212
- * Whether numeric character references (`&#NNN;`, `&#xHH;`) are allowed.
213
- * @default true
214
- */
215
- numericAllowed?: boolean;
216
-
217
- /**
218
- * Array of entity names or numeric references to leave unexpanded.
219
- * @default []
220
- */
221
- leave?: string[];
222
-
223
- /**
224
- * Array of entity names or numeric references to remove.
225
- * @default []
226
- */
227
- remove?: string[];
228
-
229
- /**
230
- * Security limits for entity expansion.
231
- */
232
- limit?: EntityDecoderLimitOptions;
233
-
234
- /**
235
- * Numeric Character Reference (NCR) policy.
236
- */
237
- ncr?: EntityDecoderNCROptions;
238
-
239
- /**
240
- * Hook called once **at registration time** for each entity passed to
241
- * `setExternalEntities()` or `addExternalEntity()`.
242
- *
243
- * - `'allow'` (or `ENTITY_ACTION.ALLOW`) — register the entity normally (default)
244
- * - `'block'` (or `ENTITY_ACTION.BLOCK`) — silently skip; the entity is not stored
245
- * - `'throw'` (or `ENTITY_ACTION.THROW`) — abort registration with an `Error`
246
- *
247
- * The hook receives the entity name (without `&`/`;`) and the resolved string
248
- * value. It is **not** called during `decode()` — only when entities are added.
249
- *
250
- * @example
251
- * const dec = new EntityDecoder({
252
- * onExternalEntity: (name, value) =>
253
- * DANGEROUS_NAMES.has(name) ? ENTITY_ACTION.BLOCK : ENTITY_ACTION.ALLOW,
254
- * });
255
- */
256
- onExternalEntity?: EntityRegistrationHook | null;
257
-
258
- /**
259
- * Hook called once **at registration time** for each entity passed to
260
- * `addInputEntities()`.
261
- *
262
- * Follows the same `'allow' | 'block' | 'throw'` contract as `onExternalEntity`.
263
- *
264
- * @example
265
- * const dec = new EntityDecoder({
266
- * // Block all input / DOCTYPE entities unconditionally
267
- * onInputEntity: () => ENTITY_ACTION.BLOCK,
268
- * });
269
- */
270
- onInputEntity?: EntityRegistrationHook | null;
271
- }
272
-
273
- // ---------------------------------------------------------------------------
274
- // EntityDecoder class (default export)
275
- // ---------------------------------------------------------------------------
276
-
277
- /**
278
- * Single‑pass, zero‑regex entity decoder for XML/HTML content.
279
- *
280
- * ## Entity lookup priority (highest → lowest)
281
- * 1. **input / runtime** – injected via `addInputEntities()` (DOCTYPE per document)
282
- * 2. **persistent external** – set via `setExternalEntities()` / `addExternalEntity()`
283
- * 3. **base map** – built‑in XML entities + user‑supplied `namedEntities`
284
- *
285
- * Numeric references (`&#NNN;`, `&#xHH;`) are resolved directly and count as the `'base'` tier.
286
- *
287
- * @example
288
- * const decoder = new EntityDecoder({
289
- * namedEntities: COMMON_HTML,
290
- * maxTotalExpansions: 100
291
- * });
292
- * decoder.setExternalEntities({ brand: 'Acme' });
293
- *
294
- * decoder.addInputEntities({ version: '1.0' });
295
- * decoder.decode('&brand; v&version; &lt;'); // 'Acme v1.0 <'
296
- *
297
- * decoder.reset(); // clears input entities + counters, keeps external entities
298
- */
299
- export default class EntityDecoder {
300
- constructor(options?: EntityDecoderOptions);
301
-
302
- setExternalEntities(
303
- map: Record<string, string | { regex: RegExp; val: string | EntityValFn }>
304
- ): void;
305
-
306
- addExternalEntity(key: string, value: string): void;
307
-
308
- addInputEntities(
309
- map: Record<
310
- string,
311
- | string
312
- | { regx: RegExp; val: string | EntityValFn }
313
- | { regex: RegExp; val: string | EntityValFn }
314
- >
315
- ): void;
316
-
317
- reset(): this;
318
-
319
- decode(str: string): string;
320
- }
321
-
322
- // ---------------------------------------------------------------------------
323
- // Named entity group exports (for use with `namedEntities` option)
324
- // ---------------------------------------------------------------------------
325
-
326
- export const COMMON_HTML: Record<string, string>;
327
- export const ALL_ENTITIES: Record<string, string>;
328
- export const XML: Record<string, string>;
329
- export const BASIC_LATIN: Record<string, string>;
330
- export const LATIN_ACCENTS: Record<string, string>;
331
- export const LATIN_EXTENDED: Record<string, string>;
332
- export const GREEK: Record<string, string>;
333
- export const CYRILLIC: Record<string, string>;
334
- export const MATH: Record<string, string>;
335
- export const MATH_ADVANCED: Record<string, string>;
336
- export const ARROWS: Record<string, string>;
337
- export const SHAPES: Record<string, string>;
338
- export const PUNCTUATION: Record<string, string>;
339
- export const CURRENCY: Record<string, string>;
340
- export const FRACTIONS: Record<string, string>;
341
- export const MISC_SYMBOLS: Record<string, string>;
@@ -1,29 +0,0 @@
1
- /**
2
- * @nodable/entities
3
- *
4
- * Standalone, zero-dependency XML/HTML entity replacement.
5
- *
6
-
7
- */
8
-
9
- export { default as EntityDecoder, ENTITY_ACTION } from './EntityDecoder.js';
10
- export {
11
- COMMON_HTML,
12
- XML,
13
- ALL_ENTITIES,
14
- ARROWS,
15
- BASIC_LATIN,
16
- CURRENCY,
17
- MATH,
18
- MATH_ADVANCED,
19
- CYRILLIC,
20
- FRACTIONS,
21
- GREEK,
22
- LATIN_ACCENTS,
23
- LATIN_EXTENDED,
24
- MISC_SYMBOLS,
25
- PUNCTUATION,
26
- SHAPES,
27
- } from './entities.js';
28
-
29
- export { default as EntityEncoder } from './EntityEncoder.js';
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Natural Intelligence
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,142 +0,0 @@
1
- # anynum
2
-
3
- Normalize Unicode decimal digits and minus signs to ASCII.
4
-
5
- Converts digits from any script — Devanagari, Arabic-Indic, Thai, Bengali, Fullwidth, and [50+ others](#supported-scripts) — to their ASCII equivalents (`0`–`9`). Also normalizes Unicode minus variants (`−`, `-`, `﹣`) to ASCII `-`.
6
-
7
- Pairs naturally with [`strnum`](https://github.com/nicolo-ribaudo/strnum) — use `anynum` to normalize first, then `strnum` to detect the numeric type.
8
-
9
- ```js
10
- import anynum from 'anynum';
11
-
12
- anynum('१२.३४') // → '12.34' (Devanagari)
13
- anynum('٣٫١٤') // → '3.14' (Arabic-Indic)
14
- anynum('−४२') // → '-42' (Unicode minus + Devanagari)
15
- anynum('-99.5') // → '-99.5' (Fullwidth minus + Fullwidth digits)
16
- anynum('hello') // → 'hello' (no digits — zero allocation)
17
- anynum('100') // → '100' (already ASCII — zero allocation)
18
- ```
19
-
20
- ---
21
-
22
- ## Install
23
-
24
- ```bash
25
- npm install anynum
26
- ```
27
-
28
- ---
29
-
30
- ## Usage
31
-
32
- ```js
33
- // ESM
34
- import anynum from 'anynum';
35
- import { anynum } from 'anynum';
36
-
37
- ```
38
-
39
- ### API
40
-
41
- ```ts
42
- anynum(str: string): string
43
- ```
44
-
45
- - Accepts a `string`, returns a `string`.
46
- - Non-string values are returned as-is (no throw).
47
- - Non-digit characters pass through unchanged.
48
- - If no conversion is needed, the **original string is returned** (zero allocation).
49
-
50
- ---
51
-
52
- ## What gets converted
53
-
54
- ### Decimal digits
55
-
56
- Any Unicode character in category `Nd` (decimal digit) is mapped to its ASCII equivalent. This covers all positional decimal digit scripts — every script whose digits represent `0`–`9` by position.
57
-
58
- ```js
59
- anynum('๑๒๓') // Thai → '123'
60
- anynum('੧੨੩') // Gurmukhi → '123'
61
- anynum('᠑᠒᠓') // Mongolian → '123'
62
- anynum('𝟏𝟐𝟑') // Math Bold → '123'
63
- ```
64
-
65
- ### Unicode minus variants
66
-
67
- Three Unicode characters are normalized to ASCII `-` (`U+002D`):
68
-
69
- | Code point | Character | Name |
70
- |---|---|---|
71
- | `U+2212` | `−` | MINUS SIGN (mathematical) |
72
- | `U+FF0D` | `-` | FULLWIDTH HYPHEN-MINUS |
73
- | `U+FE63` | `﹣` | SMALL HYPHEN-MINUS |
74
-
75
- Dashes used for punctuation — EN DASH (`–`), EM DASH (`—`), HYPHEN (`‐`) — are intentionally **not** converted.
76
-
77
- ```js
78
- anynum('−42') // U+2212 MINUS SIGN → '-42'
79
- anynum('-42') // U+FF0D FULLWIDTH → '-42'
80
- anynum('–42') // U+2013 EN DASH → '–42' (unchanged)
81
- ```
82
-
83
- ---
84
-
85
- ## Use with strnum
86
-
87
- `anynum` and `strnum` compose cleanly:
88
-
89
- ```js
90
- import anynum from 'anynum';
91
- import strnum from 'strnum';
92
-
93
- strnum(anynum('१२.३४')) // → 12.34 (number, float)
94
- strnum(anynum('−४२')) // → '-42' (string; strnum handles sign detection)
95
- strnum(anynum('hello')) // → 'hello'
96
- ```
97
-
98
- ---
99
-
100
-
101
- ## Supported scripts
102
-
103
- 50+ decimal digit scripts from Unicode `Nd` category, including:
104
-
105
- | Script | Zero | Sample |
106
- |---|---|---|
107
- | Devanagari (Hindi/Marathi/Nepali) | `U+0966` | `०१२३४५६७८९` |
108
- | Arabic-Indic | `U+0660` | `٠١٢٣٤٥٦٧٨٩` |
109
- | Extended Arabic-Indic (Urdu/Persian) | `U+06F0` | `۰۱۲۳۴۵۶۷۸۹` |
110
- | Bengali | `U+09E6` | `০১২৩৪৫৬৭৮৯` |
111
- | Gurmukhi | `U+0A66` | `੦੧੨੩੪੫੬੭੮੯` |
112
- | Gujarati | `U+0AE6` | `૦૧૨૩૪૫૬૭૮૯` |
113
- | Odia | `U+0B66` | `୦୧୨୩୪୫୬୭୮୯` |
114
- | Tamil | `U+0BE6` | `௦௧௨௩௪௫௬௭௮௯` |
115
- | Telugu | `U+0C66` | `౦౧౨౩౪౫౬౭౮౯` |
116
- | Kannada | `U+0CE6` | `೦೧೨೩೪೫೬೭೮೯` |
117
- | Malayalam | `U+0D66` | `൦൧൨൩൪൫൬൭൮൯` |
118
- | Thai | `U+0E50` | `๐๑๒๓๔๕๖๗๘๙` |
119
- | Lao | `U+0ED0` | `໐໑໒໓໔໕໖໗໘໙` |
120
- | Tibetan | `U+0F20` | `༠༡༢༣༤༥༦༧༨༩` |
121
- | Myanmar | `U+1040` | `၀၁၂၃၄၅၆၇၈၉` |
122
- | Khmer | `U+17E0` | `០១២៣៤៥៦៧៨៩` |
123
- | Mongolian | `U+1810` | `᠐᠑᠒᠓᠔᠕᠖᠗᠘᠙` |
124
- | Fullwidth (CJK context) | `U+FF10` | `0123456789` |
125
- | Mathematical Bold | `U+1D7CE` | `𝟎𝟏𝟐𝟑𝟒𝟓𝟔𝟕𝟖𝟗` |
126
- | Adlam | `U+1E950` | `𞥐𞥑𞥒𞥓𞥔𞥕𞥖𞥗𞥘𞥙` |
127
- | … and 30+ more | | |
128
-
129
- ---
130
-
131
- ## What it does NOT convert
132
-
133
- - **Kanji/Chinese numeral words** (`三`, `百`, `万`) — these are ideographic numerals, not decimal digits. Each language has its own positional system requiring separate parsing logic.
134
- - **Roman numerals** (`Ⅳ`, `Ⅻ`) — not decimal digits.
135
- - **Punctuation dashes** (`–` EN, `—` EM, `‐` HYPHEN) — not numeric signs.
136
- - **Decimal separators** — commas, periods, Arabic decimal comma (`٫`) are passed through as-is. Separator normalization is the caller's responsibility.
137
-
138
- ---
139
-
140
- ## License
141
-
142
- MIT