@lwc/babel-plugin-component 2.42.0 → 2.44.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.
Files changed (45) hide show
  1. package/README.md +37 -0
  2. package/dist/index.cjs.js +1146 -0
  3. package/dist/index.cjs.js.map +1 -0
  4. package/dist/index.js +1144 -0
  5. package/dist/index.js.map +1 -0
  6. package/package.json +26 -9
  7. package/types/compiler-version-number.d.ts +3 -0
  8. package/types/component.d.ts +3 -0
  9. package/types/constants.d.ts +26 -0
  10. package/types/decorators/api/index.d.ts +8 -0
  11. package/types/decorators/api/shared.d.ts +3 -0
  12. package/types/decorators/api/transform.d.ts +6 -0
  13. package/types/decorators/api/validate.d.ts +2 -0
  14. package/types/decorators/index.d.ts +21 -0
  15. package/types/decorators/track/index.d.ts +10 -0
  16. package/types/decorators/types.d.ts +20 -0
  17. package/types/decorators/wire/index.d.ts +8 -0
  18. package/types/decorators/wire/shared.d.ts +3 -0
  19. package/types/decorators/wire/transform.d.ts +4 -0
  20. package/types/decorators/wire/validate.d.ts +2 -0
  21. package/types/dedupe-imports.d.ts +4 -0
  22. package/types/dynamic-imports.d.ts +3 -0
  23. package/types/index.d.ts +9 -0
  24. package/types/scope-css-imports.d.ts +3 -0
  25. package/types/types.d.ts +18 -0
  26. package/types/utils.d.ts +21 -0
  27. package/src/compiler-version-number.js +0 -33
  28. package/src/component.js +0 -89
  29. package/src/constants.js +0 -67
  30. package/src/decorators/api/index.js +0 -18
  31. package/src/decorators/api/shared.js +0 -17
  32. package/src/decorators/api/transform.js +0 -95
  33. package/src/decorators/api/validate.js +0 -160
  34. package/src/decorators/index.js +0 -271
  35. package/src/decorators/track/index.js +0 -49
  36. package/src/decorators/wire/index.js +0 -18
  37. package/src/decorators/wire/shared.js +0 -17
  38. package/src/decorators/wire/transform.js +0 -261
  39. package/src/decorators/wire/validate.js +0 -100
  40. package/src/dedupe-imports.js +0 -56
  41. package/src/dynamic-imports.js +0 -70
  42. package/src/index.d.ts +0 -10
  43. package/src/index.js +0 -77
  44. package/src/scope-css-imports.js +0 -23
  45. package/src/utils.js +0 -116
package/src/utils.js DELETED
@@ -1,116 +0,0 @@
1
- /*
2
- * Copyright (c) 2018, salesforce.com, inc.
3
- * All rights reserved.
4
- * SPDX-License-Identifier: MIT
5
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6
- */
7
- const { generateErrorMessage } = require('@lwc/errors');
8
- const lineColumn = require('line-column');
9
-
10
- const { LWC_PACKAGE_ALIAS } = require('./constants');
11
-
12
- function isClassMethod(classMethod, properties = {}) {
13
- const { kind = 'method', name } = properties;
14
- return (
15
- classMethod.isClassMethod({ kind }) &&
16
- (!name || classMethod.get('key').isIdentifier({ name })) &&
17
- (properties.static === undefined || classMethod.node.static === properties.static)
18
- );
19
- }
20
-
21
- function isGetterClassMethod(classMethod, properties = {}) {
22
- return isClassMethod(classMethod, {
23
- kind: 'get',
24
- name: properties.name,
25
- static: properties.static,
26
- });
27
- }
28
-
29
- function isSetterClassMethod(classMethod, properties = {}) {
30
- return isClassMethod(classMethod, {
31
- kind: 'set',
32
- name: properties.name,
33
- static: properties.static,
34
- });
35
- }
36
-
37
- function staticClassProperty(types, name, expression) {
38
- const classProperty = types.classProperty(types.identifier(name), expression);
39
- classProperty.static = true;
40
- return classProperty;
41
- }
42
-
43
- function getEngineImportsStatements(path) {
44
- const programPath = path.isProgram() ? path : path.findParent((node) => node.isProgram());
45
-
46
- return programPath.get('body').filter((node) => {
47
- const source = node.get('source');
48
- return node.isImportDeclaration() && source.isStringLiteral({ value: LWC_PACKAGE_ALIAS });
49
- });
50
- }
51
-
52
- function getEngineImportSpecifiers(path) {
53
- const imports = getEngineImportsStatements(path);
54
- return (
55
- imports
56
- // Flat-map the specifier list for each import statement
57
- .flatMap((importStatement) => importStatement.get('specifiers'))
58
- // Skip ImportDefaultSpecifier and ImportNamespaceSpecifier
59
- .filter((specifier) => specifier.type === 'ImportSpecifier')
60
- // Get the list of specifiers with their name
61
- .map((specifier) => {
62
- const imported = specifier.get('imported').node.name;
63
- return { name: imported, path: specifier };
64
- })
65
- );
66
- }
67
-
68
- function normalizeFilename(source) {
69
- return (
70
- (source.hub && source.hub.file && source.hub.file.opts && source.hub.file.opts.filename) ||
71
- null
72
- );
73
- }
74
-
75
- function normalizeLocation(source) {
76
- const location = (source.node && (source.node.loc || source.node._loc)) || null;
77
- if (!location) {
78
- return null;
79
- }
80
- const code = source.hub.getCode();
81
- if (!code) {
82
- return {
83
- line: location.start.line,
84
- column: location.start.column,
85
- };
86
- }
87
- const lineFinder = lineColumn(code);
88
- const startOffset = lineFinder.toIndex(location.start.line, location.start.column + 1);
89
- const endOffset = lineFinder.toIndex(location.end.line, location.end.column) + 1;
90
- const length = endOffset - startOffset;
91
- return {
92
- line: location.start.line,
93
- column: location.start.column,
94
- start: startOffset,
95
- length,
96
- };
97
- }
98
-
99
- function generateError(source, { errorInfo, messageArgs } = {}) {
100
- const message = generateErrorMessage(errorInfo, messageArgs);
101
- const error = source.buildCodeFrameError(message);
102
-
103
- error.filename = normalizeFilename(source);
104
- error.loc = normalizeLocation(source);
105
- error.lwcCode = errorInfo && errorInfo.code;
106
- return error;
107
- }
108
-
109
- module.exports = {
110
- isClassMethod,
111
- isGetterClassMethod,
112
- isSetterClassMethod,
113
- generateError,
114
- getEngineImportSpecifiers,
115
- staticClassProperty,
116
- };