@sie-js/wbxml 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +105 -20
- package/build/wbxml.js +426 -3257
- package/build/wbxml.wasm +0 -0
- package/dist/bin/wbxml.d.ts +3 -0
- package/dist/bin/wbxml.d.ts.map +1 -0
- package/dist/bin/wbxml.js +4 -0
- package/dist/bin/wbxml.js.map +1 -0
- package/dist/bin/wbxml2xml.d.ts +3 -0
- package/dist/bin/wbxml2xml.d.ts.map +1 -0
- package/dist/bin/wbxml2xml.js +4 -0
- package/dist/bin/wbxml2xml.js.map +1 -0
- package/dist/bin/xml2wbxml.d.ts +3 -0
- package/dist/bin/xml2wbxml.d.ts.map +1 -0
- package/dist/bin/xml2wbxml.js +4 -0
- package/dist/bin/xml2wbxml.js.map +1 -0
- package/dist/cli.d.ts +11 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +294 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +130 -0
- package/dist/index.js.map +1 -0
- package/package.json +38 -13
- package/src/bin/wbxml.ts +4 -0
- package/src/bin/wbxml2xml.ts +4 -0
- package/src/bin/xml2wbxml.ts +4 -0
- package/src/cli.ts +322 -0
- package/src/index.ts +191 -0
- package/dist/src/index.d.ts +0 -19
- package/dist/src/index.js +0 -69
package/build/wbxml.wasm
CHANGED
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wbxml.d.ts","sourceRoot":"","sources":["../../src/bin/wbxml.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wbxml.js","sourceRoot":"","sources":["../../src/bin/wbxml.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wbxml2xml.d.ts","sourceRoot":"","sources":["../../src/bin/wbxml2xml.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wbxml2xml.js","sourceRoot":"","sources":["../../src/bin/wbxml2xml.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,IAAI,CAAC,WAAW,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xml2wbxml.d.ts","sourceRoot":"","sources":["../../src/bin/xml2wbxml.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xml2wbxml.js","sourceRoot":"","sources":["../../src/bin/xml2wbxml.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,IAAI,CAAC,WAAW,CAAC,CAAC"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare function runWbxml2xml(argv: string[]): Promise<void>;
|
|
2
|
+
declare function runXml2wbxml(argv: string[]): Promise<void>;
|
|
3
|
+
declare function runWbxml(argv: string[]): Promise<void>;
|
|
4
|
+
declare const TOOLS: {
|
|
5
|
+
wbxml: typeof runWbxml;
|
|
6
|
+
wbxml2xml: typeof runWbxml2xml;
|
|
7
|
+
xml2wbxml: typeof runXml2wbxml;
|
|
8
|
+
};
|
|
9
|
+
export declare function main(tool: keyof typeof TOOLS): Promise<void>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAoLA,iBAAe,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA8CzD;AAED,iBAAe,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA+BzD;AAED,iBAAe,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAgCrD;AAED,QAAA,MAAM,KAAK;IACV,KAAK;IACL,SAAS;IACT,SAAS;CACT,CAAC;AAEF,wBAAsB,IAAI,CAAC,IAAI,EAAE,MAAM,OAAO,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBlE"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { parseArgs } from 'node:util';
|
|
4
|
+
import { wbxml2xml, xml2wbxml, WBXML_GEN_MODES, WBXML_VERSIONS, WBXMLOptionError, } from './index.js';
|
|
5
|
+
class UsageError extends Error {
|
|
6
|
+
}
|
|
7
|
+
const LANG_DESCRIPTIONS = {
|
|
8
|
+
WML10: 'WML 1.0',
|
|
9
|
+
WML11: 'WML 1.1',
|
|
10
|
+
WML12: 'WML 1.2',
|
|
11
|
+
WML13: 'WML 1.3',
|
|
12
|
+
WTA10: 'WTA 1.0',
|
|
13
|
+
WTAWML12: 'WTAWML 1.2',
|
|
14
|
+
CHANNEL11: 'CHANNEL 1.1',
|
|
15
|
+
CHANNEL12: 'CHANNEL 1.2',
|
|
16
|
+
SI10: 'SI 1.0 (Service Indication)',
|
|
17
|
+
SL10: 'SL 1.0 (Service Loading)',
|
|
18
|
+
CO10: 'CO 1.0 (Cache Operation)',
|
|
19
|
+
PROV10: 'PROV 1.0 (OMA Provisioning)',
|
|
20
|
+
EMN10: 'EMN 1.0 (E-Mail Notification)',
|
|
21
|
+
DRMREL10: 'DRMREL 1.0 (DRM Rights Expression)',
|
|
22
|
+
OTA: 'OTA Settings (Nokia/Ericsson)',
|
|
23
|
+
SYNCML10: 'SyncML 1.0',
|
|
24
|
+
DEVINF10: 'SyncML DevInf 1.0',
|
|
25
|
+
SYNCML11: 'SyncML 1.1',
|
|
26
|
+
DEVINF11: 'SyncML DevInf 1.1',
|
|
27
|
+
METINF11: 'SyncML MetInf 1.1',
|
|
28
|
+
SYNCML12: 'SyncML 1.2',
|
|
29
|
+
DEVINF12: 'SyncML DevInf 1.2',
|
|
30
|
+
METINF12: 'SyncML MetInf 1.2',
|
|
31
|
+
DMDDF12: 'SyncML DM DDF 1.2',
|
|
32
|
+
CSP11: 'Wireless Village CSP 1.1',
|
|
33
|
+
CSP12: 'Wireless Village CSP 1.2',
|
|
34
|
+
AIRSYNC: 'Microsoft AirSync (SynCE namespaces)',
|
|
35
|
+
ACTIVESYNC: 'Microsoft ActiveSync (original namespaces)',
|
|
36
|
+
CONML: 'Nokia ConML',
|
|
37
|
+
};
|
|
38
|
+
const CHARSET_DESCRIPTIONS = {
|
|
39
|
+
'ASCII': 'US ASCII',
|
|
40
|
+
'ISO-8859-1': 'Western European',
|
|
41
|
+
'ISO-8859-2': 'Central European',
|
|
42
|
+
'ISO-8859-3': 'South European',
|
|
43
|
+
'ISO-8859-4': 'North European',
|
|
44
|
+
'ISO-8859-5': 'Latin/Cyrillic',
|
|
45
|
+
'ISO-8859-6': 'Latin/Arabic',
|
|
46
|
+
'ISO-8859-7': 'Latin/Greek',
|
|
47
|
+
'ISO-8859-8': 'Latin/Hebrew',
|
|
48
|
+
'ISO-8859-9': 'Latin/Turkish',
|
|
49
|
+
'ISO-10646-UCS-2': 'UCS-2',
|
|
50
|
+
'SHIFT_JIS': 'Shift JIS (Japanese)',
|
|
51
|
+
'BIG5': 'Big5 (Chinese)',
|
|
52
|
+
'UTF-8': 'UTF-8',
|
|
53
|
+
'UTF-16': 'UTF-16',
|
|
54
|
+
};
|
|
55
|
+
function getPackageVersion() {
|
|
56
|
+
const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf-8'));
|
|
57
|
+
return pkg.version;
|
|
58
|
+
}
|
|
59
|
+
function formatList(descriptions) {
|
|
60
|
+
const width = Math.max(...Object.keys(descriptions).map((k) => k.length));
|
|
61
|
+
return Object.entries(descriptions)
|
|
62
|
+
.map(([name, descr]) => ` ${name.padEnd(width)} ${descr}`)
|
|
63
|
+
.join('\n');
|
|
64
|
+
}
|
|
65
|
+
// libwbxml tools accept the generation mode as a number.
|
|
66
|
+
function parseMode(value) {
|
|
67
|
+
if (value !== undefined && /^\d+$/.test(value))
|
|
68
|
+
return WBXML_GEN_MODES[Number(value)] ?? value;
|
|
69
|
+
return value;
|
|
70
|
+
}
|
|
71
|
+
async function readInput(file) {
|
|
72
|
+
if (file !== undefined && file !== '-')
|
|
73
|
+
return readFile(file);
|
|
74
|
+
if (process.stdin.isTTY)
|
|
75
|
+
throw new UsageError('no input file given and stdin is a terminal');
|
|
76
|
+
const chunks = [];
|
|
77
|
+
for await (const chunk of process.stdin)
|
|
78
|
+
chunks.push(chunk);
|
|
79
|
+
return Buffer.concat(chunks);
|
|
80
|
+
}
|
|
81
|
+
async function writeOutput(file, data) {
|
|
82
|
+
if (file !== undefined && file !== '-')
|
|
83
|
+
return writeFile(file, data);
|
|
84
|
+
await new Promise((resolve, reject) => {
|
|
85
|
+
process.stdout.write(data, (err) => err ? reject(err) : resolve());
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function parse(argv, options) {
|
|
89
|
+
try {
|
|
90
|
+
return parseArgs({ args: argv, options, allowPositionals: true, strict: true });
|
|
91
|
+
}
|
|
92
|
+
catch (e) {
|
|
93
|
+
throw new UsageError(e.message);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function getSingleInput(positionals) {
|
|
97
|
+
if (positionals.length > 1)
|
|
98
|
+
throw new UsageError(`too many input files: ${positionals.join(' ')}`);
|
|
99
|
+
return positionals[0];
|
|
100
|
+
}
|
|
101
|
+
const WBXML2XML_HELP = `Usage: wbxml2xml [options] [input.wbxml]
|
|
102
|
+
|
|
103
|
+
Convert a WBXML document to XML.
|
|
104
|
+
Reads from stdin when input is omitted or '-'; writes to stdout unless -o is given.
|
|
105
|
+
|
|
106
|
+
Options:
|
|
107
|
+
-o, --output <file> Output file ('-' for stdout, default)
|
|
108
|
+
-m, --mode <mode> Generation mode (default: indent):
|
|
109
|
+
0, compact Compact generation
|
|
110
|
+
1, indent Indent generation
|
|
111
|
+
2, canonical Canonical generation
|
|
112
|
+
-i, --indent <n> Indent delta for the indent mode (default: 0)
|
|
113
|
+
-k, --keep-whitespace Keep ignorable whitespaces
|
|
114
|
+
-l, --lang <lang> Force language type of the document (see --list-langs)
|
|
115
|
+
-c, --charset <charset> Charset to use if the document does not specify one
|
|
116
|
+
(see --list-charsets)
|
|
117
|
+
--list-langs List supported languages
|
|
118
|
+
--list-charsets List supported charsets
|
|
119
|
+
-h, --help Show this help
|
|
120
|
+
-V, --version Show version
|
|
121
|
+
|
|
122
|
+
Examples:
|
|
123
|
+
wbxml2xml -o output.xml input.wbxml
|
|
124
|
+
wbxml2xml -i 4 -l CSP12 input.wbxml > output.xml
|
|
125
|
+
cat input.wbxml | wbxml2xml -m compact
|
|
126
|
+
`;
|
|
127
|
+
const XML2WBXML_HELP = `Usage: xml2wbxml [options] [input.xml]
|
|
128
|
+
|
|
129
|
+
Convert an XML document to WBXML.
|
|
130
|
+
Reads from stdin when input is omitted or '-'; writes to stdout unless -o is given.
|
|
131
|
+
|
|
132
|
+
Options:
|
|
133
|
+
-o, --output <file> Output file ('-' for stdout)
|
|
134
|
+
-v, --wbxml-version <ver> WBXML version of the output document: ${WBXML_VERSIONS.join(', ')} (default: 1.3)
|
|
135
|
+
-k, --keep-whitespace Keep ignorable whitespaces
|
|
136
|
+
-n, --no-string-table Do not generate the string table
|
|
137
|
+
-a, --anonymous Anonymous format: do not include any format
|
|
138
|
+
information (public ID or DTD)
|
|
139
|
+
-h, --help Show this help
|
|
140
|
+
-V, --version Show version
|
|
141
|
+
|
|
142
|
+
Examples:
|
|
143
|
+
xml2wbxml -o output.wbxml input.xml
|
|
144
|
+
xml2wbxml -k -n -v 1.1 -o output.wbxml input.xml
|
|
145
|
+
xml2wbxml input.xml | xxd
|
|
146
|
+
`;
|
|
147
|
+
const WBXML_HELP = `Usage: wbxml <command> [options] [input]
|
|
148
|
+
|
|
149
|
+
Commands:
|
|
150
|
+
decode, wbxml2xml Convert WBXML to XML (see 'wbxml decode --help')
|
|
151
|
+
encode, xml2wbxml Convert XML to WBXML (see 'wbxml encode --help')
|
|
152
|
+
langs List supported languages
|
|
153
|
+
charsets List supported charsets
|
|
154
|
+
|
|
155
|
+
Options:
|
|
156
|
+
-h, --help Show this help
|
|
157
|
+
-V, --version Show version
|
|
158
|
+
`;
|
|
159
|
+
async function runWbxml2xml(argv) {
|
|
160
|
+
const { values, positionals } = parse(argv, {
|
|
161
|
+
'output': { type: 'string', short: 'o' },
|
|
162
|
+
'mode': { type: 'string', short: 'm' },
|
|
163
|
+
'indent': { type: 'string', short: 'i' },
|
|
164
|
+
'keep-whitespace': { type: 'boolean', short: 'k' },
|
|
165
|
+
'lang': { type: 'string', short: 'l' },
|
|
166
|
+
'charset': { type: 'string', short: 'c' },
|
|
167
|
+
'list-langs': { type: 'boolean' },
|
|
168
|
+
'list-charsets': { type: 'boolean' },
|
|
169
|
+
'help': { type: 'boolean', short: 'h' },
|
|
170
|
+
'version': { type: 'boolean', short: 'V' },
|
|
171
|
+
});
|
|
172
|
+
if (values.help) {
|
|
173
|
+
process.stdout.write(WBXML2XML_HELP);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (values.version) {
|
|
177
|
+
process.stdout.write(`wbxml2xml (@sie-js/wbxml) ${getPackageVersion()}\n`);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
if (values['list-langs'] || values['list-charsets']) {
|
|
181
|
+
if (values['list-langs'])
|
|
182
|
+
process.stdout.write(`Languages:\n${formatList(LANG_DESCRIPTIONS)}\n`);
|
|
183
|
+
if (values['list-charsets'])
|
|
184
|
+
process.stdout.write(`Charsets:\n${formatList(CHARSET_DESCRIPTIONS)}\n`);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
const input = await readInput(getSingleInput(positionals));
|
|
188
|
+
let xml;
|
|
189
|
+
try {
|
|
190
|
+
xml = wbxml2xml(input, {
|
|
191
|
+
mode: parseMode(values.mode),
|
|
192
|
+
indent: values.indent === undefined ? undefined : Number(values.indent),
|
|
193
|
+
preserveWhitespace: values['keep-whitespace'],
|
|
194
|
+
lang: values.lang,
|
|
195
|
+
charset: values.charset,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
catch (e) {
|
|
199
|
+
if (values.lang === undefined && e.message === 'Unknown Public ID')
|
|
200
|
+
throw new Error('Unknown Public ID (the document has no known public ID, use -l <lang> to force the language; see --list-langs)');
|
|
201
|
+
throw e;
|
|
202
|
+
}
|
|
203
|
+
await writeOutput(values.output, xml);
|
|
204
|
+
}
|
|
205
|
+
async function runXml2wbxml(argv) {
|
|
206
|
+
const { values, positionals } = parse(argv, {
|
|
207
|
+
'output': { type: 'string', short: 'o' },
|
|
208
|
+
'wbxml-version': { type: 'string', short: 'v' },
|
|
209
|
+
'keep-whitespace': { type: 'boolean', short: 'k' },
|
|
210
|
+
'no-string-table': { type: 'boolean', short: 'n' },
|
|
211
|
+
'anonymous': { type: 'boolean', short: 'a' },
|
|
212
|
+
'help': { type: 'boolean', short: 'h' },
|
|
213
|
+
'version': { type: 'boolean', short: 'V' },
|
|
214
|
+
});
|
|
215
|
+
if (values.help) {
|
|
216
|
+
process.stdout.write(XML2WBXML_HELP);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
if (values.version) {
|
|
220
|
+
process.stdout.write(`xml2wbxml (@sie-js/wbxml) ${getPackageVersion()}\n`);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
if (values.output === undefined && process.stdout.isTTY)
|
|
224
|
+
throw new UsageError(`refusing to write binary WBXML to a terminal (use -o <file>, or '-o -' to force)`);
|
|
225
|
+
const input = await readInput(getSingleInput(positionals));
|
|
226
|
+
const wbxml = xml2wbxml(input, {
|
|
227
|
+
version: values['wbxml-version'],
|
|
228
|
+
preserveWhitespace: values['keep-whitespace'],
|
|
229
|
+
noStringTable: values['no-string-table'],
|
|
230
|
+
noPublicId: values.anonymous,
|
|
231
|
+
});
|
|
232
|
+
await writeOutput(values.output, wbxml);
|
|
233
|
+
}
|
|
234
|
+
async function runWbxml(argv) {
|
|
235
|
+
const [command, ...rest] = argv;
|
|
236
|
+
switch (command) {
|
|
237
|
+
case 'decode':
|
|
238
|
+
case 'wbxml2xml':
|
|
239
|
+
await runWbxml2xml(rest);
|
|
240
|
+
break;
|
|
241
|
+
case 'encode':
|
|
242
|
+
case 'xml2wbxml':
|
|
243
|
+
await runXml2wbxml(rest);
|
|
244
|
+
break;
|
|
245
|
+
case 'langs':
|
|
246
|
+
process.stdout.write(`${formatList(LANG_DESCRIPTIONS)}\n`);
|
|
247
|
+
break;
|
|
248
|
+
case 'charsets':
|
|
249
|
+
process.stdout.write(`${formatList(CHARSET_DESCRIPTIONS)}\n`);
|
|
250
|
+
break;
|
|
251
|
+
case '-h':
|
|
252
|
+
case '--help':
|
|
253
|
+
process.stdout.write(WBXML_HELP);
|
|
254
|
+
break;
|
|
255
|
+
case '-V':
|
|
256
|
+
case '--version':
|
|
257
|
+
process.stdout.write(`wbxml (@sie-js/wbxml) ${getPackageVersion()}\n`);
|
|
258
|
+
break;
|
|
259
|
+
case undefined:
|
|
260
|
+
process.stderr.write(WBXML_HELP);
|
|
261
|
+
process.exitCode = 2;
|
|
262
|
+
break;
|
|
263
|
+
default:
|
|
264
|
+
throw new UsageError(`unknown command '${command}' (see 'wbxml --help')`);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
const TOOLS = {
|
|
268
|
+
wbxml: runWbxml,
|
|
269
|
+
wbxml2xml: runWbxml2xml,
|
|
270
|
+
xml2wbxml: runXml2wbxml,
|
|
271
|
+
};
|
|
272
|
+
export async function main(tool) {
|
|
273
|
+
// Output closed early (e.g. piped to head): exit quietly.
|
|
274
|
+
process.stdout.on('error', (err) => {
|
|
275
|
+
if (err.code !== 'EPIPE')
|
|
276
|
+
throw err;
|
|
277
|
+
process.exit(process.exitCode ?? 0);
|
|
278
|
+
});
|
|
279
|
+
try {
|
|
280
|
+
await TOOLS[tool](process.argv.slice(2));
|
|
281
|
+
}
|
|
282
|
+
catch (e) {
|
|
283
|
+
const err = e;
|
|
284
|
+
if (err instanceof UsageError || err instanceof WBXMLOptionError) {
|
|
285
|
+
process.stderr.write(`${tool}: ${err.message}\nTry '${tool} --help' for more information.\n`);
|
|
286
|
+
process.exitCode = 2;
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
process.stderr.write(`${tool}: ${err.message}\n`);
|
|
290
|
+
process.exitCode = 1;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAwB,MAAM,WAAW,CAAC;AAC5D,OAAO,EACN,SAAS,EACT,SAAS,EACT,eAAe,EACf,cAAc,EACd,gBAAgB,GAKhB,MAAM,YAAY,CAAC;AAEpB,MAAM,UAAW,SAAQ,KAAK;CAAG;AAEjC,MAAM,iBAAiB,GAA8B;IACpD,KAAK,EAAE,SAAS;IAChB,KAAK,EAAE,SAAS;IAChB,KAAK,EAAE,SAAS;IAChB,KAAK,EAAE,SAAS;IAChB,KAAK,EAAE,SAAS;IAChB,QAAQ,EAAE,YAAY;IACtB,SAAS,EAAE,aA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AAI,CAAC,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC;QACJ,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACZ,MAAM,GAAG,GAAG,CAAU,CAAC;QACvB,IAAI,GAAG,YAAY,UAAU,IAAI,GAAG,YAAY,gBAAgB,EAAE,CAAC;YAClE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,KAAK,GAAG,CAAC,OAAO,UAAU,IAAI,kCAAkC,CAAC,CAAC;YAC9F,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACtB,CAAC;aAAM,CAAC;YACP,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,KAAK,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC;YAClD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACtB,CAAC;IACF,CAAC;AACF,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export declare const WBXML_VERSIONS: readonly ['1.0', '1.1', '1.2', '1.3'];
|
|
2
|
+
export declare const WBXML_LANGS: readonly ['WML10', 'WML11', 'WML12', 'WML13', 'WTA10', 'WTAWML12', 'CHANNEL11', 'CHANNEL12', 'SI10', 'SL10', 'CO10', 'PROV10', 'EMN10', 'DRMREL10', 'OTA', 'SYNCML10', 'DEVINF10', 'SYNCML11', 'DEVINF11', 'METINF11', 'SYNCML12', 'DEVINF12', 'METINF12', 'DMDDF12', 'CSP11', 'CSP12', 'AIRSYNC', 'ACTIVESYNC', 'CONML'];
|
|
3
|
+
export declare const WBXML_CHARSETS: readonly ['ASCII', 'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3', 'ISO-8859-4', 'ISO-8859-5', 'ISO-8859-6', 'ISO-8859-7', 'ISO-8859-8', 'ISO-8859-9', 'ISO-10646-UCS-2', 'SHIFT_JIS', 'BIG5', 'UTF-8', 'UTF-16'];
|
|
4
|
+
export declare const WBXML_GEN_MODES: readonly ['compact', 'indent', 'canonical'];
|
|
5
|
+
export type WBXMLVersion = typeof WBXML_VERSIONS[number];
|
|
6
|
+
export type WBXMLLang = typeof WBXML_LANGS[number];
|
|
7
|
+
export type WBXMLCharset = typeof WBXML_CHARSETS[number];
|
|
8
|
+
export type WBXMLGenMode = typeof WBXML_GEN_MODES[number];
|
|
9
|
+
export interface OptionsToWBXML {
|
|
10
|
+
/** WBXML version of the output document (default: 1.3). */
|
|
11
|
+
version?: WBXMLVersion | undefined;
|
|
12
|
+
/** Keep ignorable whitespaces. */
|
|
13
|
+
preserveWhitespace?: boolean | undefined;
|
|
14
|
+
/** Do not generate the string table. */
|
|
15
|
+
noStringTable?: boolean | undefined;
|
|
16
|
+
/** Anonymous document: do not include public ID or DTD. */
|
|
17
|
+
noPublicId?: boolean | undefined;
|
|
18
|
+
}
|
|
19
|
+
export interface OptionsFromWBXML {
|
|
20
|
+
/** XML generation mode (default: indent). */
|
|
21
|
+
mode?: WBXMLGenMode | undefined;
|
|
22
|
+
/** Indent delta for the 'indent' mode (default: 0). */
|
|
23
|
+
indent?: number | undefined;
|
|
24
|
+
/** Keep ignorable whitespaces. */
|
|
25
|
+
preserveWhitespace?: boolean | undefined;
|
|
26
|
+
/** Force the language of the document. */
|
|
27
|
+
lang?: WBXMLLang | undefined;
|
|
28
|
+
/** Charset used when the document does not specify one. */
|
|
29
|
+
charset?: WBXMLCharset | undefined;
|
|
30
|
+
}
|
|
31
|
+
/** Thrown when a conversion option has an unsupported value. */
|
|
32
|
+
export declare class WBXMLOptionError extends RangeError {
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Converts an XML document to WBXML.
|
|
36
|
+
* A string is encoded as UTF-8; pass raw bytes to use the encoding from the XML declaration.
|
|
37
|
+
*/
|
|
38
|
+
export declare function xml2wbxml(xml: string | Uint8Array, opts?: OptionsToWBXML): Buffer;
|
|
39
|
+
/**
|
|
40
|
+
* Converts a WBXML document to an XML string.
|
|
41
|
+
*/
|
|
42
|
+
export declare function wbxml2xml(wbxml: Uint8Array, opts?: OptionsFromWBXML): string;
|
|
43
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,YAAI,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAU,CAAC;AAEpE,eAAO,MAAM,WAAW,YACvB,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,UAAU,EACV,WAAW,EACX,WAAW,EACX,MAAM,EACN,MAAM,EACN,MAAM,EACN,QAAQ,EACR,OAAO,EACP,UAAU,EACV,KAAK,EACL,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,SAAS,EACT,OAAO,EACP,OAAO,EACP,SAAS,EACT,YAAY,EACZ,OAAO,CACE,CAAC;AAEX,eAAO,MAAM,cAAc,YAC1B,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,WAAW,EACX,MAAM,EACN,OAAO,EACP,QAAQ,CACC,CAAC;AAEX,eAAO,MAAM,eAAe,YAAI,SAAS,EAAE,QAAQ,EAAE,WAAW,CAAU,CAAC;AAE3E,MAAM,MAAM,YAAY,GAAG,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC;AACzD,MAAM,MAAM,SAAS,GAAG,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC;AACnD,MAAM,MAAM,YAAY,GAAG,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC;AACzD,MAAM,MAAM,YAAY,GAAG,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;AAE1D,MAAM,WAAW,cAAc;IAC9B,2DAA2D;IAC3D,OAAO,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;IACnC,kCAAkC;IAClC,kBAAkB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACzC,wCAAwC;IACxC,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACpC,2DAA2D;IAC3D,UAAU,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACjC;AAED,MAAM,WAAW,gBAAgB;IAChC,6CAA6C;IAC7C,IAAI,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;IAChC,uDAAuD;IACvD,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,kCAAkC;IAClC,kBAAkB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACzC,0CAA0C;IAC1C,IAAI,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAC7B,2DAA2D;IAC3D,OAAO,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;CACnC;AAED,gEAAgE;AAChE,qBAAa,gBAAiB,SAAQ,UAAU;CAAG;AA8DnD;;;GAGG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,EAAE,IAAI,GAAE,cAAmB,GAAG,MAAM,CAcrF;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,GAAE,gBAAqB,GAAG,MAAM,CAmBhF"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import Module from '#build/wbxml.js';
|
|
2
|
+
export const WBXML_VERSIONS = ['1.0', '1.1', '1.2', '1.3'];
|
|
3
|
+
export const WBXML_LANGS = [
|
|
4
|
+
'WML10',
|
|
5
|
+
'WML11',
|
|
6
|
+
'WML12',
|
|
7
|
+
'WML13',
|
|
8
|
+
'WTA10',
|
|
9
|
+
'WTAWML12',
|
|
10
|
+
'CHANNEL11',
|
|
11
|
+
'CHANNEL12',
|
|
12
|
+
'SI10',
|
|
13
|
+
'SL10',
|
|
14
|
+
'CO10',
|
|
15
|
+
'PROV10',
|
|
16
|
+
'EMN10',
|
|
17
|
+
'DRMREL10',
|
|
18
|
+
'OTA',
|
|
19
|
+
'SYNCML10',
|
|
20
|
+
'DEVINF10',
|
|
21
|
+
'SYNCML11',
|
|
22
|
+
'DEVINF11',
|
|
23
|
+
'METINF11',
|
|
24
|
+
'SYNCML12',
|
|
25
|
+
'DEVINF12',
|
|
26
|
+
'METINF12',
|
|
27
|
+
'DMDDF12',
|
|
28
|
+
'CSP11',
|
|
29
|
+
'CSP12',
|
|
30
|
+
'AIRSYNC',
|
|
31
|
+
'ACTIVESYNC',
|
|
32
|
+
'CONML',
|
|
33
|
+
];
|
|
34
|
+
export const WBXML_CHARSETS = [
|
|
35
|
+
'ASCII',
|
|
36
|
+
'ISO-8859-1',
|
|
37
|
+
'ISO-8859-2',
|
|
38
|
+
'ISO-8859-3',
|
|
39
|
+
'ISO-8859-4',
|
|
40
|
+
'ISO-8859-5',
|
|
41
|
+
'ISO-8859-6',
|
|
42
|
+
'ISO-8859-7',
|
|
43
|
+
'ISO-8859-8',
|
|
44
|
+
'ISO-8859-9',
|
|
45
|
+
'ISO-10646-UCS-2',
|
|
46
|
+
'SHIFT_JIS',
|
|
47
|
+
'BIG5',
|
|
48
|
+
'UTF-8',
|
|
49
|
+
'UTF-16',
|
|
50
|
+
];
|
|
51
|
+
export const WBXML_GEN_MODES = ['compact', 'indent', 'canonical'];
|
|
52
|
+
/** Thrown when a conversion option has an unsupported value. */
|
|
53
|
+
export class WBXMLOptionError extends RangeError {
|
|
54
|
+
}
|
|
55
|
+
const WBXML = await Module();
|
|
56
|
+
const _xml2wbxml = WBXML.cwrap('xml2wbxml', 'number', [
|
|
57
|
+
'number', // xml_in
|
|
58
|
+
'number', // xml_in_len
|
|
59
|
+
'number', // out**
|
|
60
|
+
'number', // out_len*
|
|
61
|
+
'string', // wbxml_version
|
|
62
|
+
'number', // preserve_whitespace
|
|
63
|
+
'number', // no_string_table
|
|
64
|
+
'number', // no_public_id
|
|
65
|
+
]);
|
|
66
|
+
const _wbxml2xml = WBXML.cwrap('wbxml2xml', 'number', [
|
|
67
|
+
'number', // wbxml_in
|
|
68
|
+
'number', // wbxml_in_len
|
|
69
|
+
'number', // out**
|
|
70
|
+
'number', // out_len*
|
|
71
|
+
'number', // gen_type
|
|
72
|
+
'number', // indent
|
|
73
|
+
'number', // preserve_whitespace
|
|
74
|
+
'string', // force_lang
|
|
75
|
+
'string', // force_charset
|
|
76
|
+
]);
|
|
77
|
+
function checkOption(name, value, allowed) {
|
|
78
|
+
if (value !== undefined && !allowed.includes(value))
|
|
79
|
+
throw new WBXMLOptionError(`Unknown ${name} '${value}' (expected one of: ${allowed.join(', ')})`);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Copies the input into the wasm heap, runs the converter and returns its output.
|
|
83
|
+
* The converter must store a malloc'ed result (or error message) in *out / *out_len.
|
|
84
|
+
*/
|
|
85
|
+
function convert(input, run) {
|
|
86
|
+
const inPtr = WBXML._malloc(input.length || 1);
|
|
87
|
+
const outPtrPtr = WBXML._malloc(4);
|
|
88
|
+
const outLenPtr = WBXML._malloc(4);
|
|
89
|
+
try {
|
|
90
|
+
WBXML.HEAPU8.set(input, inPtr);
|
|
91
|
+
WBXML.HEAPU32[outPtrPtr >> 2] = 0;
|
|
92
|
+
WBXML.HEAPU32[outLenPtr >> 2] = 0;
|
|
93
|
+
const rc = run(inPtr, input.length, outPtrPtr, outLenPtr);
|
|
94
|
+
const outPtr = WBXML.HEAPU32[outPtrPtr >> 2];
|
|
95
|
+
const outLen = WBXML.HEAPU32[outLenPtr >> 2];
|
|
96
|
+
const result = Buffer.from(WBXML.HEAPU8.slice(outPtr, outPtr + outLen));
|
|
97
|
+
WBXML._free(outPtr);
|
|
98
|
+
if (rc !== 0)
|
|
99
|
+
throw new Error(result.toString());
|
|
100
|
+
return result;
|
|
101
|
+
}
|
|
102
|
+
finally {
|
|
103
|
+
WBXML._free(inPtr);
|
|
104
|
+
WBXML._free(outPtrPtr);
|
|
105
|
+
WBXML._free(outLenPtr);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Converts an XML document to WBXML.
|
|
110
|
+
* A string is encoded as UTF-8; pass raw bytes to use the encoding from the XML declaration.
|
|
111
|
+
*/
|
|
112
|
+
export function xml2wbxml(xml, opts = {}) {
|
|
113
|
+
const { version = '1.3' } = opts;
|
|
114
|
+
checkOption('WBXML version', version, WBXML_VERSIONS);
|
|
115
|
+
const input = typeof xml === 'string' ? Buffer.from(xml) : xml;
|
|
116
|
+
return convert(input, (inPtr, inLen, outPtrPtr, outLenPtr) => _xml2wbxml(inPtr, inLen, outPtrPtr, outLenPtr, version, opts.preserveWhitespace ? 1 : 0, opts.noStringTable ? 1 : 0, opts.noPublicId ? 1 : 0));
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Converts a WBXML document to an XML string.
|
|
120
|
+
*/
|
|
121
|
+
export function wbxml2xml(wbxml, opts = {}) {
|
|
122
|
+
const { mode = 'indent', indent, lang, charset } = opts;
|
|
123
|
+
checkOption('mode', mode, WBXML_GEN_MODES);
|
|
124
|
+
checkOption('language', lang, WBXML_LANGS);
|
|
125
|
+
checkOption('charset', charset, WBXML_CHARSETS);
|
|
126
|
+
if (indent !== undefined && !(Number.isInteger(indent) && indent >= 0 && indent <= 127))
|
|
127
|
+
throw new WBXMLOptionError(`Invalid indent '${indent}' (expected 0..127)`);
|
|
128
|
+
return convert(wbxml, (inPtr, inLen, outPtrPtr, outLenPtr) => _wbxml2xml(inPtr, inLen, outPtrPtr, outLenPtr, WBXML_GEN_MODES.indexOf(mode), indent ?? -1, opts.preserveWhitespace ? 1 : 0, lang ?? '', charset ?? '')).toString();
|
|
129
|
+
}
|
|
130
|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ANGED
|
@@ -1,31 +1,56 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sie-js/wbxml",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"main": "dist/
|
|
6
|
-
"types": "dist/
|
|
7
|
-
"description": "WBXML converter
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"description": "WBXML <-> XML converter (libwbxml compiled to WebAssembly) with CLI tools",
|
|
8
|
+
"bin": {
|
|
9
|
+
"wbxml": "dist/bin/wbxml.js",
|
|
10
|
+
"wbxml2xml": "dist/bin/wbxml2xml.js",
|
|
11
|
+
"xml2wbxml": "dist/bin/xml2wbxml.js"
|
|
12
|
+
},
|
|
8
13
|
"files": [
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
14
|
+
"dist",
|
|
15
|
+
"src/*.ts",
|
|
16
|
+
"src/bin",
|
|
17
|
+
"!src/**/*.test.ts",
|
|
18
|
+
"build/*.wasm",
|
|
19
|
+
"build/*.js"
|
|
12
20
|
],
|
|
13
21
|
"imports": {
|
|
14
22
|
"#build/*": "./build/*"
|
|
15
23
|
},
|
|
16
|
-
"keywords": [
|
|
24
|
+
"keywords": [
|
|
25
|
+
"wbxml",
|
|
26
|
+
"xml",
|
|
27
|
+
"wap",
|
|
28
|
+
"syncml",
|
|
29
|
+
"activesync",
|
|
30
|
+
"ota",
|
|
31
|
+
"libwbxml",
|
|
32
|
+
"cli"
|
|
33
|
+
],
|
|
17
34
|
"author": "kirill.zhumarin@gmail.com",
|
|
18
35
|
"license": "LGPL-2.1-or-later",
|
|
19
36
|
"repository": {
|
|
20
37
|
"url": "git+https://github.com/siemens-mobile-hacks/node-sie-wbxml.git"
|
|
21
38
|
},
|
|
22
39
|
"devDependencies": {
|
|
23
|
-
"@types/node": "^
|
|
24
|
-
"tsx": "^4.
|
|
25
|
-
"typescript": "^
|
|
40
|
+
"@types/node": "^26.6.6",
|
|
41
|
+
"tsx": "^4.23.15",
|
|
42
|
+
"typescript": "^7.0.2",
|
|
43
|
+
"vitest": "^5.1.0"
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=20"
|
|
26
47
|
},
|
|
27
48
|
"scripts": {
|
|
28
|
-
"build": "tsc",
|
|
29
|
-
"watch": "tsc -w"
|
|
49
|
+
"build": "tsc -p tsconfig.build.json",
|
|
50
|
+
"watch": "tsc -p tsconfig.build.json -w",
|
|
51
|
+
"build:wasm": "emcmake cmake -B build && cmake --build build -j",
|
|
52
|
+
"test": "vitest run",
|
|
53
|
+
"test:watch": "vitest",
|
|
54
|
+
"typecheck": "tsc --noEmit"
|
|
30
55
|
}
|
|
31
56
|
}
|
package/src/bin/wbxml.ts
ADDED