@appium/universal-xml-plugin 2.0.4 → 2.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/LICENSE +201 -0
- package/build/lib/attr-map.d.ts +3 -57
- package/build/lib/attr-map.d.ts.map +1 -1
- package/build/lib/attr-map.js +2 -5
- package/build/lib/attr-map.js.map +1 -1
- package/build/lib/index.d.ts +4 -3
- package/build/lib/index.d.ts.map +1 -1
- package/build/lib/index.js +20 -5
- package/build/lib/index.js.map +1 -1
- package/build/lib/node-map.d.ts +3 -199
- package/build/lib/node-map.d.ts.map +1 -1
- package/build/lib/node-map.js +2 -9
- package/build/lib/node-map.js.map +1 -1
- package/build/lib/plugin.d.ts +7 -6
- package/build/lib/plugin.d.ts.map +1 -1
- package/build/lib/plugin.js +16 -18
- package/build/lib/plugin.js.map +1 -1
- package/build/lib/source.d.ts +41 -47
- package/build/lib/source.d.ts.map +1 -1
- package/build/lib/source.js +104 -47
- package/build/lib/source.js.map +1 -1
- package/build/lib/transformers.d.ts +3 -7
- package/build/lib/transformers.d.ts.map +1 -1
- package/build/lib/transformers.js +9 -10
- package/build/lib/transformers.js.map +1 -1
- package/build/lib/types.d.ts +29 -0
- package/build/lib/types.d.ts.map +1 -0
- package/build/lib/types.js +3 -0
- package/build/lib/types.js.map +1 -0
- package/build/lib/xpath.d.ts +16 -7
- package/build/lib/xpath.d.ts.map +1 -1
- package/build/lib/xpath.js +19 -16
- package/build/lib/xpath.js.map +1 -1
- package/lib/{attr-map.js → attr-map.ts} +5 -5
- package/lib/{index.js → index.ts} +22 -4
- package/lib/{node-map.js → node-map.ts} +5 -1
- package/lib/plugin.ts +119 -0
- package/lib/source.ts +265 -0
- package/lib/{transformers.js → transformers.ts} +9 -12
- package/lib/types.ts +33 -0
- package/lib/{xpath.js → xpath.ts} +24 -20
- package/package.json +7 -7
- package/tsconfig.json +3 -2
- package/build/lib/logger.d.ts +0 -3
- package/build/lib/logger.d.ts.map +0 -1
- package/build/lib/logger.js +0 -6
- package/build/lib/logger.js.map +0 -1
- package/index.js +0 -7
- package/lib/logger.js +0 -3
- package/lib/plugin.js +0 -81
- package/lib/source.js +0 -226
package/build/lib/plugin.js
CHANGED
|
@@ -1,49 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.UniversalXMLPlugin = void 0;
|
|
7
4
|
const plugin_1 = require("appium/plugin");
|
|
8
5
|
const driver_1 = require("appium/driver");
|
|
9
6
|
const source_1 = require("./source");
|
|
10
7
|
const xpath_1 = require("./xpath");
|
|
11
|
-
const logger_1 = __importDefault(require("./logger"));
|
|
12
8
|
class UniversalXMLPlugin extends plugin_1.BasePlugin {
|
|
13
9
|
async getPageSource(next, driver, sessId, addIndexPath = false) {
|
|
14
|
-
const source = next ? await next() : await driver.getPageSource();
|
|
10
|
+
const source = (next ? await next() : await driver.getPageSource());
|
|
15
11
|
const metadata = {};
|
|
16
|
-
const
|
|
12
|
+
const platformName = getPlatformName(driver);
|
|
17
13
|
if (platformName.toLowerCase() === 'android') {
|
|
18
|
-
metadata.appPackage = driver.opts
|
|
14
|
+
metadata.appPackage = driver.opts?.appPackage;
|
|
19
15
|
}
|
|
20
16
|
const { xml, unknowns } = await (0, source_1.transformSourceXml)(source, platformName.toLowerCase(), {
|
|
21
17
|
metadata,
|
|
22
18
|
addIndexPath,
|
|
23
19
|
});
|
|
24
20
|
if (unknowns.nodes.length) {
|
|
25
|
-
|
|
21
|
+
this.log.warn(`The XML mapper found ${unknowns.nodes.length} node(s) / ` +
|
|
26
22
|
`tag name(s) that it didn't know about. These should be ` +
|
|
27
23
|
`reported to improve the quality of the plugin: ` +
|
|
28
24
|
unknowns.nodes.join(', '));
|
|
29
25
|
}
|
|
30
26
|
if (unknowns.attrs.length) {
|
|
31
|
-
|
|
27
|
+
this.log.warn(`The XML mapper found ${unknowns.attrs.length} attributes ` +
|
|
32
28
|
`that it didn't know about. These should be reported to ` +
|
|
33
29
|
`improve the quality of the plugin: ` +
|
|
34
30
|
unknowns.attrs.join(', '));
|
|
35
31
|
}
|
|
36
32
|
return xml;
|
|
37
33
|
}
|
|
38
|
-
async findElement(
|
|
39
|
-
return await this._find(false,
|
|
34
|
+
async findElement(next, driver, strategy, selector) {
|
|
35
|
+
return (await this._find(false, next, driver, strategy, selector));
|
|
40
36
|
}
|
|
41
|
-
async findElements(
|
|
42
|
-
return await this._find(true,
|
|
37
|
+
async findElements(next, driver, strategy, selector) {
|
|
38
|
+
return (await this._find(true, next, driver, strategy, selector));
|
|
43
39
|
}
|
|
44
40
|
async _find(multiple, next, driver, strategy, selector) {
|
|
45
|
-
const
|
|
46
|
-
if (strategy.toLowerCase() !== 'xpath' || (await driver.getCurrentContext()) !== 'NATIVE_APP') {
|
|
41
|
+
const platformName = getPlatformName(driver);
|
|
42
|
+
if (strategy.toLowerCase() !== 'xpath' || !driver.getCurrentContext || (await driver.getCurrentContext()) !== 'NATIVE_APP') {
|
|
47
43
|
return await next();
|
|
48
44
|
}
|
|
49
45
|
const xml = await this.getPageSource(null, driver, null, true);
|
|
@@ -51,7 +47,7 @@ class UniversalXMLPlugin extends plugin_1.BasePlugin {
|
|
|
51
47
|
// if the selector was not able to be transformed, that means no elements were found that
|
|
52
48
|
// matched, so do the appropriate thing based on element vs elements
|
|
53
49
|
if (newSelector === null) {
|
|
54
|
-
|
|
50
|
+
this.log.warn(`Selector was not able to be translated to underlying XML. Either the requested ` +
|
|
55
51
|
`element does not exist or there was an error in translation`);
|
|
56
52
|
if (multiple) {
|
|
57
53
|
return [];
|
|
@@ -64,12 +60,14 @@ class UniversalXMLPlugin extends plugin_1.BasePlugin {
|
|
|
64
60
|
// not work with WDA as-is. We need to remove the first path segment.
|
|
65
61
|
newSelector = newSelector.replace(/^\/\*\[1\]/, '');
|
|
66
62
|
}
|
|
67
|
-
|
|
63
|
+
this.log.info(`Selector was translated to: ${newSelector}`);
|
|
68
64
|
// otherwise just run the transformed query!
|
|
69
65
|
const finder = multiple ? 'findElements' : 'findElement';
|
|
70
66
|
return await driver[finder](strategy, newSelector);
|
|
71
67
|
}
|
|
72
68
|
}
|
|
73
|
-
exports.default = UniversalXMLPlugin;
|
|
74
69
|
exports.UniversalXMLPlugin = UniversalXMLPlugin;
|
|
70
|
+
function getPlatformName(driver) {
|
|
71
|
+
return driver.caps?.platformName || '';
|
|
72
|
+
}
|
|
75
73
|
//# sourceMappingURL=plugin.js.map
|
package/build/lib/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../lib/plugin.
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../lib/plugin.ts"],"names":[],"mappings":";;;AAAA,0CAAyC;AACzC,0CAAqC;AACrC,qCAA4C;AAC5C,mCAAuC;AAIvC,MAAa,kBAAmB,SAAQ,mBAAU;IAChD,KAAK,CAAC,aAAa,CACjB,IAA+B,EAC/B,MAAsB,EACtB,MAAY,EACZ,eAAwB,KAAK;QAE7B,MAAM,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,aAAa,EAAE,CAAW,CAAC;QAC9E,MAAM,QAAQ,GAAsB,EAAE,CAAC;QACvC,MAAM,YAAY,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;QAC7C,IAAI,YAAY,CAAC,WAAW,EAAE,KAAK,SAAS,EAAE,CAAC;YAC7C,QAAQ,CAAC,UAAU,GAAI,MAAM,CAAC,IAAY,EAAE,UAAU,CAAC;QACzD,CAAC;QACD,MAAM,EAAC,GAAG,EAAE,QAAQ,EAAC,GAAG,MAAM,IAAA,2BAAkB,EAAC,MAAM,EAAE,YAAY,CAAC,W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GED
|
@@ -1,69 +1,63 @@
|
|
|
1
|
+
import type { NodesAndAttributes, TransformSourceXmlOptions, TransformNodeOptions } from './types';
|
|
2
|
+
export declare const ATTR_PREFIX = "@_";
|
|
3
|
+
export declare const IDX_PATH_PREFIX = "@_indexPath";
|
|
4
|
+
export declare const IDX_PREFIX = "@_index";
|
|
1
5
|
/**
|
|
6
|
+
* Transforms source XML to universal format
|
|
2
7
|
*
|
|
3
|
-
* @param
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
6
|
-
* @
|
|
8
|
+
* @param xmlStr - The XML string to transform
|
|
9
|
+
* @param platform - The platform name ('ios' or 'android')
|
|
10
|
+
* @param opts - Transformation options
|
|
11
|
+
* @param opts.metadata - Optional metadata object
|
|
12
|
+
* @param opts.addIndexPath - Whether to add index path attributes
|
|
13
|
+
* @returns Promise resolving to transformed XML and unknown nodes/attributes
|
|
7
14
|
*/
|
|
8
|
-
export function transformSourceXml(xmlStr: string, platform: string, { metadata, addIndexPath }?: {
|
|
9
|
-
metadata?: any;
|
|
10
|
-
addIndexPath?: boolean;
|
|
11
|
-
}): Promise<{
|
|
15
|
+
export declare function transformSourceXml(xmlStr: string, platform: string, { metadata, addIndexPath }?: TransformSourceXmlOptions): Promise<{
|
|
12
16
|
xml: string;
|
|
13
17
|
unknowns: NodesAndAttributes;
|
|
14
18
|
}>;
|
|
15
19
|
/**
|
|
20
|
+
* Gets the universal node name for a platform-specific node name
|
|
16
21
|
*
|
|
17
|
-
* @param
|
|
18
|
-
* @param
|
|
19
|
-
* @returns
|
|
22
|
+
* @param nodeName - The platform-specific node name
|
|
23
|
+
* @param platform - The platform name
|
|
24
|
+
* @returns The universal node name or null if not found
|
|
20
25
|
*/
|
|
21
|
-
export function getUniversalNodeName(nodeName:
|
|
26
|
+
export declare function getUniversalNodeName(nodeName: string, platform: string): string | null;
|
|
22
27
|
/**
|
|
28
|
+
* Gets the universal attribute name for a platform-specific attribute name
|
|
23
29
|
*
|
|
24
|
-
* @param
|
|
25
|
-
* @param
|
|
26
|
-
* @returns
|
|
30
|
+
* @param attrName - The platform-specific attribute name
|
|
31
|
+
* @param platform - The platform name
|
|
32
|
+
* @returns The universal attribute name or null if not found
|
|
27
33
|
*/
|
|
28
|
-
export function getUniversalAttrName(attrName: string, platform: string): string | null;
|
|
34
|
+
export declare function getUniversalAttrName(attrName: string, platform: string): string | null;
|
|
29
35
|
/**
|
|
36
|
+
* Transforms a node object recursively
|
|
30
37
|
*
|
|
31
|
-
* @param
|
|
32
|
-
* @param
|
|
33
|
-
* @param
|
|
34
|
-
* @returns
|
|
38
|
+
* @param nodeObj - The node object to transform
|
|
39
|
+
* @param platform - The platform name
|
|
40
|
+
* @param opts - Transformation options
|
|
41
|
+
* @returns Object containing unknown nodes and attributes
|
|
35
42
|
*/
|
|
36
|
-
export function transformNode(nodeObj: any, platform: string, { metadata, addIndexPath, parentPath }:
|
|
37
|
-
metadata?: any;
|
|
38
|
-
addIndexPath?: boolean;
|
|
39
|
-
parentPath?: string;
|
|
40
|
-
}): NodesAndAttributes;
|
|
43
|
+
export declare function transformNode(nodeObj: any, platform: string, { metadata, addIndexPath, parentPath }: TransformNodeOptions): NodesAndAttributes;
|
|
41
44
|
/**
|
|
45
|
+
* Transforms child nodes of a node object
|
|
42
46
|
*
|
|
43
|
-
* @param
|
|
44
|
-
* @param
|
|
45
|
-
* @param
|
|
46
|
-
* @param
|
|
47
|
-
* @returns
|
|
47
|
+
* @param nodeObj - The node object containing child nodes
|
|
48
|
+
* @param childNodeNames - Array of child node names
|
|
49
|
+
* @param platform - The platform name
|
|
50
|
+
* @param opts - Transformation options
|
|
51
|
+
* @returns Object containing unknown nodes and attributes
|
|
48
52
|
*/
|
|
49
|
-
export function transformChildNodes(nodeObj: any, childNodeNames: string[], platform: string, { metadata, addIndexPath, parentPath }:
|
|
50
|
-
metadata?: any;
|
|
51
|
-
addIndexPath?: boolean;
|
|
52
|
-
parentPath?: string;
|
|
53
|
-
}): NodesAndAttributes;
|
|
53
|
+
export declare function transformChildNodes(nodeObj: any, childNodeNames: string[], platform: string, { metadata, addIndexPath, parentPath }: TransformNodeOptions): NodesAndAttributes;
|
|
54
54
|
/**
|
|
55
|
+
* Transforms attributes of a node object
|
|
55
56
|
*
|
|
56
|
-
* @param
|
|
57
|
-
* @param
|
|
58
|
-
* @param
|
|
59
|
-
* @returns
|
|
57
|
+
* @param nodeObj - The node object containing attributes
|
|
58
|
+
* @param attrs - Array of attribute keys
|
|
59
|
+
* @param platform - The platform name
|
|
60
|
+
* @returns Array of unknown attribute names
|
|
60
61
|
*/
|
|
61
|
-
export function transformAttrs(nodeObj: any, attrs: string[], platform: string): string[];
|
|
62
|
-
export const ATTR_PREFIX: "@_";
|
|
63
|
-
export const IDX_PATH_PREFIX: "@_indexPath";
|
|
64
|
-
export const IDX_PREFIX: "@_index";
|
|
65
|
-
export type NodesAndAttributes = {
|
|
66
|
-
nodes: string[];
|
|
67
|
-
attrs: string[];
|
|
68
|
-
};
|
|
62
|
+
export declare function transformAttrs(nodeObj: any, attrs: string[], platform: string): string[];
|
|
69
63
|
//# sourceMappingURL=source.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../lib/source.
|
|
1
|
+
{"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../lib/source.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,kBAAkB,EAClB,yBAAyB,EACzB,oBAAoB,EAGrB,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,WAAW,OAAO,CAAC;AAChC,eAAO,MAAM,eAAe,gBAA4B,CAAC;AACzD,eAAO,MAAM,UAAU,YAAwB,CAAC;AAKhD;;;;;;;;;GASG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,EAAC,QAAkC,EAAE,YAAoB,EAAC,GAAE,yBAA8B,GACzF,OAAO,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,kBAAkB,CAAA;CAAC,CAAC,CAatD;AA2BD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAEtF;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAEtF;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,GAAG,EACZ,QAAQ,EAAE,MAAM,EAChB,EAAC,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAC,EAAE,oBAAoB,GACzD,kBAAkB,CA6CpB;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,GAAG,EACZ,cAAc,EAAE,MAAM,EAAE,EACxB,QAAQ,EAAE,MAAM,EAChB,EAAC,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAC,EAAE,oBAAoB,GACzD,kBAAkB,CA+CpB;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAoBxF"}
|
package/build/lib/source.js
CHANGED
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
37
|
};
|
|
@@ -11,41 +44,46 @@ exports.transformNode = transformNode;
|
|
|
11
44
|
exports.transformChildNodes = transformChildNodes;
|
|
12
45
|
exports.transformAttrs = transformAttrs;
|
|
13
46
|
const lodash_1 = __importDefault(require("lodash"));
|
|
47
|
+
const fast_xml_parser_1 = require("fast-xml-parser");
|
|
14
48
|
const node_map_1 = __importDefault(require("./node-map"));
|
|
15
49
|
const attr_map_1 = require("./attr-map");
|
|
16
|
-
const
|
|
50
|
+
const TRANSFORMS = __importStar(require("./transformers"));
|
|
17
51
|
exports.ATTR_PREFIX = '@_';
|
|
18
52
|
exports.IDX_PATH_PREFIX = `${exports.ATTR_PREFIX}indexPath`;
|
|
19
53
|
exports.IDX_PREFIX = `${exports.ATTR_PREFIX}index`;
|
|
20
|
-
const isAttr = (
|
|
21
|
-
const isNode = (
|
|
54
|
+
const isAttr = (k) => k.startsWith(exports.ATTR_PREFIX);
|
|
55
|
+
const isNode = (k) => !isAttr(k);
|
|
22
56
|
/**
|
|
57
|
+
* Transforms source XML to universal format
|
|
23
58
|
*
|
|
24
|
-
* @param
|
|
25
|
-
* @param
|
|
26
|
-
* @param
|
|
27
|
-
* @
|
|
59
|
+
* @param xmlStr - The XML string to transform
|
|
60
|
+
* @param platform - The platform name ('ios' or 'android')
|
|
61
|
+
* @param opts - Transformation options
|
|
62
|
+
* @param opts.metadata - Optional metadata object
|
|
63
|
+
* @param opts.addIndexPath - Whether to add index path attributes
|
|
64
|
+
* @returns Promise resolving to transformed XML and unknown nodes/attributes
|
|
28
65
|
*/
|
|
29
66
|
async function transformSourceXml(xmlStr, platform, { metadata = {}, addIndexPath = false } = {}) {
|
|
30
67
|
// first thing we want to do is modify the ios source root node, because it doesn't include the
|
|
31
68
|
// necessary index attribute, so we add it if it's not there
|
|
32
69
|
xmlStr = xmlStr.replace('<AppiumAUT>', '<AppiumAUT index="0">');
|
|
33
|
-
const xmlObj =
|
|
70
|
+
const xmlObj = singletonXmlParser().parse(xmlStr);
|
|
34
71
|
const unknowns = transformNode(xmlObj, platform, {
|
|
35
72
|
metadata,
|
|
36
73
|
addIndexPath,
|
|
37
74
|
parentPath: '',
|
|
38
75
|
});
|
|
39
|
-
let transformedXml =
|
|
76
|
+
let transformedXml = singletonXmlBuilder().build(xmlObj).trim();
|
|
40
77
|
transformedXml = `<?xml version="1.0" encoding="UTF-8"?>\n${transformedXml}`;
|
|
41
78
|
return { xml: transformedXml, unknowns };
|
|
42
79
|
}
|
|
43
80
|
/**
|
|
81
|
+
* Gets the universal name for a platform-specific name from a name map
|
|
44
82
|
*
|
|
45
|
-
* @param
|
|
46
|
-
* @param
|
|
47
|
-
* @param
|
|
48
|
-
* @returns
|
|
83
|
+
* @param nameMap - The name mapping object
|
|
84
|
+
* @param name - The platform-specific name
|
|
85
|
+
* @param platform - The platform name
|
|
86
|
+
* @returns The universal name or null if not found
|
|
49
87
|
*/
|
|
50
88
|
function getUniversalName(nameMap, name, platform) {
|
|
51
89
|
for (const translatedName of Object.keys(nameMap)) {
|
|
@@ -60,29 +98,32 @@ function getUniversalName(nameMap, name, platform) {
|
|
|
60
98
|
return null;
|
|
61
99
|
}
|
|
62
100
|
/**
|
|
101
|
+
* Gets the universal node name for a platform-specific node name
|
|
63
102
|
*
|
|
64
|
-
* @param
|
|
65
|
-
* @param
|
|
66
|
-
* @returns
|
|
103
|
+
* @param nodeName - The platform-specific node name
|
|
104
|
+
* @param platform - The platform name
|
|
105
|
+
* @returns The universal node name or null if not found
|
|
67
106
|
*/
|
|
68
107
|
function getUniversalNodeName(nodeName, platform) {
|
|
69
108
|
return getUniversalName(node_map_1.default, nodeName, platform);
|
|
70
109
|
}
|
|
71
110
|
/**
|
|
111
|
+
* Gets the universal attribute name for a platform-specific attribute name
|
|
72
112
|
*
|
|
73
|
-
* @param
|
|
74
|
-
* @param
|
|
75
|
-
* @returns
|
|
113
|
+
* @param attrName - The platform-specific attribute name
|
|
114
|
+
* @param platform - The platform name
|
|
115
|
+
* @returns The universal attribute name or null if not found
|
|
76
116
|
*/
|
|
77
117
|
function getUniversalAttrName(attrName, platform) {
|
|
78
118
|
return getUniversalName(attr_map_1.ATTR_MAP, attrName, platform);
|
|
79
119
|
}
|
|
80
120
|
/**
|
|
121
|
+
* Transforms a node object recursively
|
|
81
122
|
*
|
|
82
|
-
* @param
|
|
83
|
-
* @param
|
|
84
|
-
* @param
|
|
85
|
-
* @returns
|
|
123
|
+
* @param nodeObj - The node object to transform
|
|
124
|
+
* @param platform - The platform name
|
|
125
|
+
* @param opts - Transformation options
|
|
126
|
+
* @returns Object containing unknown nodes and attributes
|
|
86
127
|
*/
|
|
87
128
|
function transformNode(nodeObj, platform, { metadata, addIndexPath, parentPath }) {
|
|
88
129
|
const unknownNodes = [];
|
|
@@ -91,15 +132,18 @@ function transformNode(nodeObj, platform, { metadata, addIndexPath, parentPath }
|
|
|
91
132
|
const keys = Object.keys(nodeObj);
|
|
92
133
|
const childNodeNames = keys.filter(isNode);
|
|
93
134
|
const attrs = keys.filter(isAttr);
|
|
94
|
-
let thisIndexPath = parentPath;
|
|
135
|
+
let thisIndexPath = parentPath || '';
|
|
95
136
|
if (attrs.length && addIndexPath) {
|
|
96
137
|
if (!attrs.includes(exports.IDX_PREFIX)) {
|
|
97
138
|
throw new Error(`Index path is required but node found with no 'index' attribute`);
|
|
98
139
|
}
|
|
99
|
-
thisIndexPath = `${parentPath}/${nodeObj[exports.IDX_PREFIX]}`;
|
|
140
|
+
thisIndexPath = `${parentPath || ''}/${nodeObj[exports.IDX_PREFIX]}`;
|
|
100
141
|
nodeObj[exports.IDX_PATH_PREFIX] = thisIndexPath;
|
|
101
142
|
}
|
|
102
|
-
|
|
143
|
+
const transformFn = TRANSFORMS[platform];
|
|
144
|
+
if (transformFn) {
|
|
145
|
+
transformFn(nodeObj, metadata || {});
|
|
146
|
+
}
|
|
103
147
|
unknownAttrs.push(...transformAttrs(nodeObj, attrs, platform));
|
|
104
148
|
const unknowns = transformChildNodes(nodeObj, childNodeNames, platform, {
|
|
105
149
|
metadata,
|
|
@@ -114,7 +158,7 @@ function transformNode(nodeObj, platform, { metadata, addIndexPath, parentPath }
|
|
|
114
158
|
const { nodes, attrs } = transformNode(childObj, platform, {
|
|
115
159
|
metadata,
|
|
116
160
|
addIndexPath,
|
|
117
|
-
parentPath,
|
|
161
|
+
parentPath: parentPath || '',
|
|
118
162
|
});
|
|
119
163
|
unknownNodes.push(...nodes);
|
|
120
164
|
unknownAttrs.push(...attrs);
|
|
@@ -126,12 +170,13 @@ function transformNode(nodeObj, platform, { metadata, addIndexPath, parentPath }
|
|
|
126
170
|
};
|
|
127
171
|
}
|
|
128
172
|
/**
|
|
173
|
+
* Transforms child nodes of a node object
|
|
129
174
|
*
|
|
130
|
-
* @param
|
|
131
|
-
* @param
|
|
132
|
-
* @param
|
|
133
|
-
* @param
|
|
134
|
-
* @returns
|
|
175
|
+
* @param nodeObj - The node object containing child nodes
|
|
176
|
+
* @param childNodeNames - Array of child node names
|
|
177
|
+
* @param platform - The platform name
|
|
178
|
+
* @param opts - Transformation options
|
|
179
|
+
* @returns Object containing unknown nodes and attributes
|
|
135
180
|
*/
|
|
136
181
|
function transformChildNodes(nodeObj, childNodeNames, platform, { metadata, addIndexPath, parentPath }) {
|
|
137
182
|
const unknownNodes = [];
|
|
@@ -141,7 +186,7 @@ function transformChildNodes(nodeObj, childNodeNames, platform, { metadata, addI
|
|
|
141
186
|
const { nodes, attrs } = transformNode(nodeObj[nodeName], platform, {
|
|
142
187
|
metadata,
|
|
143
188
|
addIndexPath,
|
|
144
|
-
parentPath,
|
|
189
|
+
parentPath: parentPath || '',
|
|
145
190
|
});
|
|
146
191
|
unknownNodes.push(...nodes);
|
|
147
192
|
unknownAttrs.push(...attrs);
|
|
@@ -158,7 +203,23 @@ function transformChildNodes(nodeObj, childNodeNames, platform, { metadata, addI
|
|
|
158
203
|
// if we already have a node with the universal name, that means we are mapping a second
|
|
159
204
|
// original node name to the same universal node name, so we just push all its children into
|
|
160
205
|
// the list
|
|
161
|
-
|
|
206
|
+
if (lodash_1.default.isArray(nodeObj[universalName])) {
|
|
207
|
+
if (lodash_1.default.isArray(nodeObj[nodeName])) {
|
|
208
|
+
nodeObj[universalName].push(...nodeObj[nodeName]);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
nodeObj[universalName].push(nodeObj[nodeName]);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
nodeObj[universalName] = [nodeObj[universalName]];
|
|
216
|
+
if (lodash_1.default.isArray(nodeObj[nodeName])) {
|
|
217
|
+
nodeObj[universalName].push(...nodeObj[nodeName]);
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
nodeObj[universalName].push(nodeObj[nodeName]);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
162
223
|
}
|
|
163
224
|
else {
|
|
164
225
|
nodeObj[universalName] = nodeObj[nodeName];
|
|
@@ -168,11 +229,12 @@ function transformChildNodes(nodeObj, childNodeNames, platform, { metadata, addI
|
|
|
168
229
|
return { nodes: unknownNodes, attrs: unknownAttrs };
|
|
169
230
|
}
|
|
170
231
|
/**
|
|
232
|
+
* Transforms attributes of a node object
|
|
171
233
|
*
|
|
172
|
-
* @param
|
|
173
|
-
* @param
|
|
174
|
-
* @param
|
|
175
|
-
* @returns
|
|
234
|
+
* @param nodeObj - The node object containing attributes
|
|
235
|
+
* @param attrs - Array of attribute keys
|
|
236
|
+
* @param platform - The platform name
|
|
237
|
+
* @returns Array of unknown attribute names
|
|
176
238
|
*/
|
|
177
239
|
function transformAttrs(nodeObj, attrs, platform) {
|
|
178
240
|
const unknownAttrs = [];
|
|
@@ -195,25 +257,20 @@ function transformAttrs(nodeObj, attrs, platform) {
|
|
|
195
257
|
}
|
|
196
258
|
return unknownAttrs;
|
|
197
259
|
}
|
|
198
|
-
const singletonXmlBuilder = lodash_1.default.memoize(
|
|
199
|
-
|
|
200
|
-
return new XMLBuilder({
|
|
260
|
+
const singletonXmlBuilder = lodash_1.default.memoize(function makeXmlBuilder() {
|
|
261
|
+
return new fast_xml_parser_1.XMLBuilder({
|
|
201
262
|
ignoreAttributes: false,
|
|
202
263
|
attributeNamePrefix: exports.ATTR_PREFIX,
|
|
203
264
|
suppressBooleanAttributes: false,
|
|
204
265
|
format: true,
|
|
205
266
|
});
|
|
206
267
|
});
|
|
207
|
-
const singletonXmlParser = lodash_1.default.memoize(
|
|
208
|
-
|
|
209
|
-
return new XMLParser({
|
|
268
|
+
const singletonXmlParser = lodash_1.default.memoize(function makeXmlParser() {
|
|
269
|
+
return new fast_xml_parser_1.XMLParser({
|
|
210
270
|
ignoreAttributes: false,
|
|
211
271
|
ignoreDeclaration: true,
|
|
212
272
|
attributeNamePrefix: exports.ATTR_PREFIX,
|
|
213
273
|
isArray: (name, jPath, isLeafNode, isAttribute) => !isAttribute,
|
|
214
274
|
});
|
|
215
275
|
});
|
|
216
|
-
/**
|
|
217
|
-
* @typedef {{nodes: string[], attrs: string[]}} NodesAndAttributes
|
|
218
|
-
*/
|
|
219
276
|
//# sourceMappingURL=source.js.map
|
package/build/lib/source.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source.js","sourceRoot":"","sources":["../../lib/source.
|
|
1
|
+
{"version":3,"file":"source.js","sourceRoot":"","sources":["../../lib/source.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,gDAiBC;AAkCD,oDAEC;AASD,oDAEC;AAUD,sCAiDC;AAWD,kDAoDC;AAUD,wCAoBC;AAtPD,oDAAuB;AACvB,qDAAsD;AACtD,0DAAkC;AAClC,yCAAkD;AAClD,2DAA6C;AAShC,QAAA,WAAW,GAAG,IAAI,CAAC;AACnB,QAAA,eAAe,GAAG,GAAG,mBAAW,WAAW,CAAC;AAC5C,QAAA,UAAU,GAAG,GAAG,mBAAW,OAAO,CAAC;AAEhD,MAAM,MAAM,GAAG,CAAC,CAAS,EAAW,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,mBAAW,CAAC,CAAC;AACjE,MAAM,MAAM,GAAG,CAAC,CAAS,EAAW,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAElD;;;;;;;;;GASG;AACI,KAAK,UAAU,kBAAkB,CACtC,MAAc,EACd,QAAgB,EAChB,EAAC,QAAQ,GAAG,EAAuB,EAAE,YAAY,GAAG,KAAK,KAA+B,EAAE;IAE1F,+FAA+F;IAC/F,4DAA4D;IAC5D,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa,EAAE,uBAAuB,CAAC,CAAC;IAChE,MAAM,MAAM,GAAG,kBAAkB,EAAE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AAO,IAAI,2BAAS,CAAC;QACnB,gBAAgB,EAAE,KAAK;QACvB,iBAAiB,EAAE,IAAI;QACvB,mBAAmB,EAAE,mBAAW;QAChC,OAAO,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE,CAAC,CAAC,WAAW;KAChE,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
export default _default;
|
|
6
|
-
declare function ios(nodeObj: any): any;
|
|
7
|
-
declare function android(nodeObj: any, metadata: any): void;
|
|
1
|
+
import type { TransformMetadata } from './types';
|
|
2
|
+
export declare function ios(_nodeObj: any): void;
|
|
3
|
+
export declare function android(nodeObj: any, metadata: TransformMetadata): void;
|
|
8
4
|
//# sourceMappingURL=transformers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformers.d.ts","sourceRoot":"","sources":["../../lib/transformers.
|
|
1
|
+
{"version":3,"file":"transformers.d.ts","sourceRoot":"","sources":["../../lib/transformers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,SAAS,CAAC;AAG/C,wBAAgB,GAAG,CAAC,QAAQ,EAAE,GAAG,GAAG,IAAI,CAEvC;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAoBvE"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ios = ios;
|
|
4
|
+
exports.android = android;
|
|
3
5
|
const source_1 = require("./source");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
7
|
+
function ios(_nodeObj) {
|
|
8
|
+
// iOS transformer does nothing
|
|
6
9
|
}
|
|
7
10
|
function android(nodeObj, metadata) {
|
|
8
11
|
// strip android:id from front of id
|
|
@@ -16,16 +19,12 @@ function android(nodeObj, metadata) {
|
|
|
16
19
|
.split(/\[|\]|,/)
|
|
17
20
|
.filter((str) => str !== '');
|
|
18
21
|
const [x, y, x2, y2] = boundsArray;
|
|
19
|
-
const width = x2 - x;
|
|
20
|
-
const height = y2 - y;
|
|
22
|
+
const width = parseInt(x2, 10) - parseInt(x, 10);
|
|
23
|
+
const height = parseInt(y2, 10) - parseInt(y, 10);
|
|
21
24
|
nodeObj[`${source_1.ATTR_PREFIX}x`] = x;
|
|
22
25
|
nodeObj[`${source_1.ATTR_PREFIX}y`] = y;
|
|
23
|
-
nodeObj[`${source_1.ATTR_PREFIX}width`] = width;
|
|
24
|
-
nodeObj[`${source_1.ATTR_PREFIX}height`] = height;
|
|
26
|
+
nodeObj[`${source_1.ATTR_PREFIX}width`] = width.toString();
|
|
27
|
+
nodeObj[`${source_1.ATTR_PREFIX}height`] = height.toString();
|
|
25
28
|
}
|
|
26
29
|
}
|
|
27
|
-
exports.default = {
|
|
28
|
-
ios,
|
|
29
|
-
android,
|
|
30
|
-
};
|
|
31
30
|
//# sourceMappingURL=transformers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformers.js","sourceRoot":"","sources":["../../lib/transformers.
|
|
1
|
+
{"version":3,"file":"transformers.js","sourceRoot":"","sources":["../../lib/transformers.ts"],"names":[],"mappings":";;AAIA,kBAEC;AAED,0BAoBC;AA5BD,qCAAqC;AAGrC,6DAA6D;AAC7D,SAAgB,GAAG,CAAC,QAAa;IAC/B,+BAA+B;AACjC,CAAC;AAED,SAAgB,OAAO,CAAC,OAAY,EAAE,QAA2B;IAC/D,oCAAoC;IACpC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,oBAAW,aAAa,CAAC,CAAC;IACnD,IAAI,KAAK,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC;QACjC,OAAO,CAAC,GAAG,oBAAW,aAAa,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,UAAU,MAAM,EAAE,EAAE,CAAC,CAAC;IACzF,CAAC;IAED,yCAAyC;IACzC,IAAI,OAAO,CAAC,GAAG,oBAAW,QAAQ,CAAC,EAAE,CAAC;QACpC,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,oBAAW,QAAQ,CAAC;aAChD,KAAK,CAAC,SAAS,CAAC;aAChB,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC;QAC/B,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,WAAW,CAAC;QACnC,MAAM,KAAK,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACjD,MAAM,MAAM,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAClD,OAAO,CAAC,GAAG,oBAAW,GAAG,CAAC,GAAG,CAAC,CAAC;QAC/B,OAAO,CAAC,GAAG,oBAAW,GAAG,CAAC,GAAG,CAAC,CAAC;QAC/B,OAAO,CAAC,GAAG,oBAAW,OAAO,CAAC,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;QAClD,OAAO,CAAC,GAAG,oBAAW,QAAQ,CAAC,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;IACtD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface NodesAndAttributes {
|
|
2
|
+
nodes: string[];
|
|
3
|
+
attrs: string[];
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Metadata used for XML transformations
|
|
7
|
+
*/
|
|
8
|
+
export interface TransformMetadata {
|
|
9
|
+
appPackage?: string;
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
}
|
|
12
|
+
export interface TransformSourceXmlOptions {
|
|
13
|
+
metadata?: TransformMetadata;
|
|
14
|
+
addIndexPath?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface TransformNodeOptions extends TransformSourceXmlOptions {
|
|
17
|
+
parentPath?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Type for platform-specific name mappings
|
|
21
|
+
* Values can be a string or an array of strings (for many-to-one mappings)
|
|
22
|
+
*/
|
|
23
|
+
export type PlatformNameMap = Record<string, string | readonly string[]>;
|
|
24
|
+
/**
|
|
25
|
+
* Type for universal name maps
|
|
26
|
+
* Keys are universal names, values are platform-specific mappings
|
|
27
|
+
*/
|
|
28
|
+
export type UniversalNameMap = Record<string, Partial<PlatformNameMap>>;
|
|
29
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../lib/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,oBAAqB,SAAQ,yBAAyB;IACrE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC,CAAC;AAEzE;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../lib/types.ts"],"names":[],"mappings":""}
|