@stencil/angular-output-target 0.10.1 → 0.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/generate-angular-component.js +4 -0
- package/dist/index.cjs.js +27 -17
- package/dist/index.js +4 -0
- package/package.json +2 -2
|
@@ -139,6 +139,10 @@ const formatOutputType = (componentClassName, event) => {
|
|
|
139
139
|
return [p1, `I${componentClassName}${v.substring(1, v.length - 1)}`, p2].join('');
|
|
140
140
|
}
|
|
141
141
|
return [p1, dst, p2].join('');
|
|
142
|
+
})
|
|
143
|
+
// Capture all instances that contain sub types, e.g. `IMyComponent.SomeMoreComplexType.SubType`.
|
|
144
|
+
.replace(new RegExp(`^${src}(\.\\w+)+$`, 'g'), (type) => {
|
|
145
|
+
return `I${componentClassName}${src}.${type.split('.').slice(1).join('.')}`;
|
|
142
146
|
}));
|
|
143
147
|
}, event.complexType.original
|
|
144
148
|
.replace(/\n/g, ' ')
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
3
5
|
var path = require('path');
|
|
4
6
|
var os = require('os');
|
|
5
7
|
|
|
8
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
+
|
|
10
|
+
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
11
|
+
|
|
6
12
|
const OutputTypes = {
|
|
7
13
|
Component: 'component',
|
|
8
14
|
Scam: 'scam',
|
|
@@ -52,18 +58,18 @@ function normalizePath(str) {
|
|
|
52
58
|
return str;
|
|
53
59
|
}
|
|
54
60
|
function relativeImport(pathFrom, pathTo, ext) {
|
|
55
|
-
let relativePath =
|
|
61
|
+
let relativePath = path__default["default"].relative(path__default["default"].dirname(pathFrom), path__default["default"].dirname(pathTo));
|
|
56
62
|
if (relativePath === '') {
|
|
57
63
|
relativePath = '.';
|
|
58
64
|
}
|
|
59
65
|
else if (relativePath[0] !== '.') {
|
|
60
66
|
relativePath = './' + relativePath;
|
|
61
67
|
}
|
|
62
|
-
return normalizePath(`${relativePath}/${
|
|
68
|
+
return normalizePath(`${relativePath}/${path__default["default"].basename(pathTo, ext)}`);
|
|
63
69
|
}
|
|
64
70
|
async function readPackageJson(config, rootDir) {
|
|
65
71
|
var _a;
|
|
66
|
-
const pkgJsonPath =
|
|
72
|
+
const pkgJsonPath = path__default["default"].join(rootDir, 'package.json');
|
|
67
73
|
let pkgJson;
|
|
68
74
|
try {
|
|
69
75
|
pkgJson = (await ((_a = config.sys) === null || _a === void 0 ? void 0 : _a.readFile(pkgJsonPath, 'utf8')));
|
|
@@ -278,6 +284,10 @@ const formatOutputType = (componentClassName, event) => {
|
|
|
278
284
|
return [p1, `I${componentClassName}${v.substring(1, v.length - 1)}`, p2].join('');
|
|
279
285
|
}
|
|
280
286
|
return [p1, dst, p2].join('');
|
|
287
|
+
})
|
|
288
|
+
// Capture all instances that contain sub types, e.g. `IMyComponent.SomeMoreComplexType.SubType`.
|
|
289
|
+
.replace(new RegExp(`^${src}(\.\\w+)+$`, 'g'), (type) => {
|
|
290
|
+
return `I${componentClassName}${src}.${type.split('.').slice(1).join('.')}`;
|
|
281
291
|
}));
|
|
282
292
|
}, event.complexType.original
|
|
283
293
|
.replace(/\n/g, ' ')
|
|
@@ -348,7 +358,7 @@ async function generateValueAccessors(compilerCtx, components, outputTarget, con
|
|
|
348
358
|
if (!Array.isArray(outputTarget.valueAccessorConfigs) || outputTarget.valueAccessorConfigs.length === 0) {
|
|
349
359
|
return;
|
|
350
360
|
}
|
|
351
|
-
const targetDir =
|
|
361
|
+
const targetDir = path__default["default"].dirname(outputTarget.directivesProxyFile);
|
|
352
362
|
const normalizedValueAccessors = outputTarget.valueAccessorConfigs.reduce((allAccessors, va) => {
|
|
353
363
|
const elementSelectors = Array.isArray(va.elementSelectors) ? va.elementSelectors : [va.elementSelectors];
|
|
354
364
|
const type = va.type;
|
|
@@ -366,8 +376,8 @@ async function generateValueAccessors(compilerCtx, components, outputTarget, con
|
|
|
366
376
|
await Promise.all(Object.keys(normalizedValueAccessors).map(async (type) => {
|
|
367
377
|
const valueAccessorType = type; // Object.keys converts to string
|
|
368
378
|
const targetFileName = `${type}-value-accessor.ts`;
|
|
369
|
-
const targetFilePath =
|
|
370
|
-
const srcFilePath =
|
|
379
|
+
const targetFilePath = path__default["default"].join(targetDir, targetFileName);
|
|
380
|
+
const srcFilePath = path__default["default"].join(__dirname, '../resources/control-value-accessors/', targetFileName);
|
|
371
381
|
const srcFileContents = await compilerCtx.fs.readFile(srcFilePath);
|
|
372
382
|
const finalText = createValueAccessor(srcFileContents, normalizedValueAccessors[valueAccessorType], outputTarget.outputType);
|
|
373
383
|
await compilerCtx.fs.writeFile(targetFilePath, finalText);
|
|
@@ -387,14 +397,14 @@ function copyResources$1(config, resourcesFilesToCopy, directory) {
|
|
|
387
397
|
}
|
|
388
398
|
const copyTasks = resourcesFilesToCopy.map((rf) => {
|
|
389
399
|
return {
|
|
390
|
-
src:
|
|
391
|
-
dest:
|
|
400
|
+
src: path__default["default"].join(__dirname, '../resources/control-value-accessors/', rf),
|
|
401
|
+
dest: path__default["default"].join(directory, rf),
|
|
392
402
|
keepDirStructure: false,
|
|
393
403
|
warn: false,
|
|
394
404
|
ignore: [],
|
|
395
405
|
};
|
|
396
406
|
});
|
|
397
|
-
return config.sys.copy(copyTasks,
|
|
407
|
+
return config.sys.copy(copyTasks, path__default["default"].join(directory));
|
|
398
408
|
}
|
|
399
409
|
const VALUE_ACCESSOR_SELECTORS = `<VALUE_ACCESSOR_SELECTORS>`;
|
|
400
410
|
const VALUE_ACCESSOR_EVENT = `<VALUE_ACCESSOR_EVENT>`;
|
|
@@ -438,8 +448,8 @@ async function copyResources(config, outputTarget) {
|
|
|
438
448
|
if (!config.sys || !config.sys.copy || !config.sys.glob) {
|
|
439
449
|
throw new Error('stencil is not properly initialized at this step. Notify the developer');
|
|
440
450
|
}
|
|
441
|
-
const srcDirectory =
|
|
442
|
-
const destDirectory =
|
|
451
|
+
const srcDirectory = path__default["default"].join(__dirname, '..', 'angular-component-lib');
|
|
452
|
+
const destDirectory = path__default["default"].join(path__default["default"].dirname(outputTarget.directivesProxyFile), 'angular-component-lib');
|
|
443
453
|
return config.sys.copy([
|
|
444
454
|
{
|
|
445
455
|
src: srcDirectory,
|
|
@@ -451,8 +461,8 @@ async function copyResources(config, outputTarget) {
|
|
|
451
461
|
], srcDirectory);
|
|
452
462
|
}
|
|
453
463
|
function generateProxies(components, pkgData, outputTarget, rootDir) {
|
|
454
|
-
const distTypesDir =
|
|
455
|
-
const dtsFilePath =
|
|
464
|
+
const distTypesDir = path__default["default"].dirname(pkgData.types);
|
|
465
|
+
const dtsFilePath = path__default["default"].join(rootDir, distTypesDir, GENERATED_DTS);
|
|
456
466
|
const { outputType } = outputTarget;
|
|
457
467
|
const componentsTypeFile = relativeImport(outputTarget.directivesProxyFile, dtsFilePath, '.d.ts');
|
|
458
468
|
const includeSingleComponentAngularModules = outputType === OutputTypes.Scam;
|
|
@@ -578,11 +588,11 @@ function normalizeOutputTarget(config, outputTarget) {
|
|
|
578
588
|
if (outputTarget.directivesProxyFile == null) {
|
|
579
589
|
throw new Error('directivesProxyFile is required. Please set it in the Stencil config.');
|
|
580
590
|
}
|
|
581
|
-
if (outputTarget.directivesProxyFile && !
|
|
582
|
-
results.directivesProxyFile = normalizePath(
|
|
591
|
+
if (outputTarget.directivesProxyFile && !path__default["default"].isAbsolute(outputTarget.directivesProxyFile)) {
|
|
592
|
+
results.directivesProxyFile = normalizePath(path__default["default"].join(config.rootDir, outputTarget.directivesProxyFile));
|
|
583
593
|
}
|
|
584
|
-
if (outputTarget.directivesArrayFile && !
|
|
585
|
-
results.directivesArrayFile = normalizePath(
|
|
594
|
+
if (outputTarget.directivesArrayFile && !path__default["default"].isAbsolute(outputTarget.directivesArrayFile)) {
|
|
595
|
+
results.directivesArrayFile = normalizePath(path__default["default"].join(config.rootDir, outputTarget.directivesArrayFile));
|
|
586
596
|
}
|
|
587
597
|
if (outputTarget.includeSingleComponentAngularModules !== undefined) {
|
|
588
598
|
throw new Error("The 'includeSingleComponentAngularModules' option has been removed. Please use 'outputType' instead.");
|
package/dist/index.js
CHANGED
|
@@ -276,6 +276,10 @@ const formatOutputType = (componentClassName, event) => {
|
|
|
276
276
|
return [p1, `I${componentClassName}${v.substring(1, v.length - 1)}`, p2].join('');
|
|
277
277
|
}
|
|
278
278
|
return [p1, dst, p2].join('');
|
|
279
|
+
})
|
|
280
|
+
// Capture all instances that contain sub types, e.g. `IMyComponent.SomeMoreComplexType.SubType`.
|
|
281
|
+
.replace(new RegExp(`^${src}(\.\\w+)+$`, 'g'), (type) => {
|
|
282
|
+
return `I${componentClassName}${src}.${type.split('.').slice(1).join('.')}`;
|
|
279
283
|
}));
|
|
280
284
|
}, event.complexType.original
|
|
281
285
|
.replace(/\n/g, ' ')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stencil/angular-output-target",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.2",
|
|
4
4
|
"description": "Angular output target for @stencil/core components.",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
24
|
"prepublishOnly": "pnpm run build",
|
|
25
|
-
"prebuild": "rimraf ./dist
|
|
25
|
+
"prebuild": "rimraf ./dist",
|
|
26
26
|
"build": "tsc && pnpm run rollup",
|
|
27
27
|
"dev": "run-p dev:*",
|
|
28
28
|
"dev:build": "tsc --watch --preserveWatchOutput",
|