@stencil/angular-output-target 0.4.0 → 0.5.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 +49 -1
- package/angular-component-lib/utils.ts +9 -15
- package/dist/generate-angular-component.d.ts +22 -2
- package/dist/generate-angular-component.js +127 -94
- package/dist/generate-value-accessors.js +2 -5
- package/dist/index.cjs.js +233 -117
- package/dist/index.js +233 -117
- package/dist/output-angular.js +61 -17
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.js +2 -5
- package/dist/types.d.ts +9 -2
- package/dist/utils.d.ts +27 -1
- package/dist/utils.js +45 -0
- package/package.json +6 -2
package/dist/utils.js
CHANGED
|
@@ -74,6 +74,51 @@ export async function readPackageJson(config, rootDir) {
|
|
|
74
74
|
}
|
|
75
75
|
return pkgData;
|
|
76
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Formats an array of strings to a string of quoted, comma separated values.
|
|
79
|
+
* @param list The list of unformatted strings to format
|
|
80
|
+
* @returns The formatted array of strings. (e.g. ['foo', 'bar']) => `'foo', 'bar'`
|
|
81
|
+
*/
|
|
82
|
+
export const formatToQuotedList = (list) => list.map((item) => `'${item}'`).join(', ');
|
|
83
|
+
/**
|
|
84
|
+
* Creates an import statement for a list of named imports from a module.
|
|
85
|
+
* @param imports The list of named imports.
|
|
86
|
+
* @param module The module to import from.
|
|
87
|
+
*
|
|
88
|
+
* @returns The import statement as a string.
|
|
89
|
+
*/
|
|
90
|
+
export const createImportStatement = (imports, module) => {
|
|
91
|
+
if (imports.length === 0) {
|
|
92
|
+
return '';
|
|
93
|
+
}
|
|
94
|
+
return `import { ${imports.join(', ')} } from '${module}';`;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Creates the collection of import statements for a component based on the component's events type dependencies.
|
|
98
|
+
* @param componentTagName The tag name of the component (pascal case).
|
|
99
|
+
* @param events The events compiler metadata.
|
|
100
|
+
* @param options The options for generating the import statements (e.g. whether to import from the custom elements directory).
|
|
101
|
+
* @returns The import statements as an array of strings.
|
|
102
|
+
*/
|
|
103
|
+
export const createComponentEventTypeImports = (componentTagName, events, options) => {
|
|
104
|
+
const { componentCorePackage, includeImportCustomElements, customElementsDir } = options;
|
|
105
|
+
const imports = [];
|
|
106
|
+
const namedImports = new Set();
|
|
107
|
+
const importPathName = normalizePath(componentCorePackage) + (includeImportCustomElements ? `/${customElementsDir || 'components'}` : '');
|
|
108
|
+
events.forEach((event) => {
|
|
109
|
+
Object.entries(event.complexType.references).forEach(([typeName, refObject]) => {
|
|
110
|
+
if (refObject.location === 'local' || refObject.location === 'import') {
|
|
111
|
+
const newTypeName = `I${componentTagName}${typeName}`;
|
|
112
|
+
// Prevents duplicate imports for the same type.
|
|
113
|
+
if (!namedImports.has(newTypeName)) {
|
|
114
|
+
imports.push(`import type { ${typeName} as ${newTypeName} } from '${importPathName}';`);
|
|
115
|
+
namedImports.add(newTypeName);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
return imports.join('\n');
|
|
121
|
+
};
|
|
77
122
|
const EXTENDED_PATH_REGEX = /^\\\\\?\\/;
|
|
78
123
|
const NON_ASCII_REGEX = /[^\x00-\x80]+/;
|
|
79
124
|
const SLASH_REGEX = /\\/g;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stencil/angular-output-target",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Angular output target for @stencil/core components.",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -14,11 +14,15 @@
|
|
|
14
14
|
"access": "public"
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
|
+
"prepublishOnly": "npm run build",
|
|
17
18
|
"prebuild": "rimraf ./dist && npm run test",
|
|
18
19
|
"build": "tsc && npm run rollup",
|
|
19
20
|
"watch": "tsc --watch",
|
|
20
21
|
"rollup": "rollup -c",
|
|
21
22
|
"version": "npm run build",
|
|
23
|
+
"prettier": "npm run prettier.base -- --write",
|
|
24
|
+
"prettier.base": "prettier \"./({angular-component-lib,src,test,__tests__}/**/*.{ts,tsx,js,jsx})|*.{ts,tsx,js,jsx}\"",
|
|
25
|
+
"prettier.dry-run": "npm run prettier.base -- --list-different",
|
|
22
26
|
"release": "np",
|
|
23
27
|
"test": "jest --passWithNoTests",
|
|
24
28
|
"test.watch": "jest --watch"
|
|
@@ -38,7 +42,7 @@
|
|
|
38
42
|
"@angular/forms": "8.2.14"
|
|
39
43
|
},
|
|
40
44
|
"peerDependencies": {
|
|
41
|
-
"@stencil/core": "^2.9.0"
|
|
45
|
+
"@stencil/core": "^2.9.0 || ^3.0.0-beta.0"
|
|
42
46
|
},
|
|
43
47
|
"jest": {
|
|
44
48
|
"transform": {
|