@next-core/build-next-bricks 1.8.0 → 1.9.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next-core/build-next-bricks",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
4
4
  "description": "Build next bricks",
5
5
  "homepage": "https://github.com/easyops-cn/next-core/tree/v3/packages/build-next-bricks",
6
6
  "license": "GPL-3.0",
@@ -49,7 +49,7 @@
49
49
  "webpack": "^5.84.1"
50
50
  },
51
51
  "devDependencies": {
52
- "@next-core/brick-manifest": "^0.1.0"
52
+ "@next-core/brick-manifest": "^0.2.0"
53
53
  },
54
- "gitHead": "a2f8ca6b36b45b4a306f4b933e6bc2ca195cdd1f"
54
+ "gitHead": "618559c95f5a1ef0eaf4d2792b530deaf933d45d"
55
55
  }
package/src/build.js CHANGED
@@ -81,6 +81,8 @@ async function getWebpackConfig(config) {
81
81
  "js-yaml",
82
82
  "i18next-browser-languagedetector",
83
83
  "react-i18next",
84
+ "@easyops-cn/brick-next-pipes",
85
+ "@next-core/pipes",
84
86
  "@next-core/runtime",
85
87
  "@next-core/easyops-runtime",
86
88
  "@next-core/http",
@@ -5,6 +5,7 @@ import { parse } from "doctrine";
5
5
  * @typedef {import("@next-core/brick-manifest").PropertyManifest} PropertyManifest
6
6
  * @typedef {import("@next-core/brick-manifest").EventManifest} EventManifest
7
7
  * @typedef {import("@next-core/brick-manifest").MethodManifest} MethodManifest
8
+ * @typedef {import("@next-core/brick-manifest").ProviderManifest} ProviderManifest
8
9
  * @typedef {import("@babel/types").Node} Node
9
10
  * @typedef {import("@babel/traverse").NodePath} NodePath
10
11
  * @typedef {import("@babel/types").ClassDeclaration} ClassDeclaration
@@ -32,6 +33,7 @@ export default function makeBrickManifest(name, nodePath, source) {
32
33
  const docComment = findDocComment(nodePath, source);
33
34
  if (docComment) {
34
35
  manifest.description = docComment.description;
36
+ manifest.deprecated = getDeprecatedInfo(docComment.tags);
35
37
  for (const tag of docComment.tags) {
36
38
  if (tag.title === "slot") {
37
39
  const match = tag.description.match(/^(?:([-\w]+)\s+-\s+)?(.*)$/);
@@ -53,6 +55,25 @@ export default function makeBrickManifest(name, nodePath, source) {
53
55
  return manifest;
54
56
  }
55
57
 
58
+ /**
59
+ * @param {string} name
60
+ * @param {NodePath} nodePath
61
+ * @param {string} source
62
+ * @returns {ProviderManifest}
63
+ */
64
+ export function makeProviderManifest(name, nodePath, source) {
65
+ /** @type {ProviderManifest} */
66
+ const manifest = {
67
+ name,
68
+ };
69
+ const docComment = findDocComment(nodePath, source);
70
+ if (docComment) {
71
+ manifest.description = docComment.description;
72
+ manifest.deprecated = getDeprecatedInfo(docComment.tags);
73
+ }
74
+ return manifest;
75
+ }
76
+
56
77
  /**
57
78
  * @param {NodePath} nodePath
58
79
  * @param {string} source
package/src/scanBricks.js CHANGED
@@ -5,7 +5,9 @@ import { parse } from "@babel/parser";
5
5
  import babelTraverse from "@babel/traverse";
6
6
  import _ from "lodash";
7
7
  import getCamelPackageName from "./getCamelPackageName.js";
8
- import makeBrickManifest from "./makeBrickManifest.js";
8
+ import makeBrickManifest, {
9
+ makeProviderManifest,
10
+ } from "./makeBrickManifest.js";
9
11
  import { BASE_TYPE, TS_KEYWORD_LIST, getTypeAnnotation } from "./utils.js";
10
12
  import {
11
13
  isImportDefaultSpecifier,
@@ -57,6 +59,7 @@ export default async function scanBricks(packageDir) {
57
59
  package: packageJson.name,
58
60
  name: packageName,
59
61
  bricks: [],
62
+ providers: [],
60
63
  };
61
64
 
62
65
  /** @type {Map<string, Set<string>} */
@@ -216,7 +219,10 @@ export default async function scanBricks(packageDir) {
216
219
  }
217
220
 
218
221
  traverse(ast, {
219
- CallExpression({ node: { callee, arguments: args } }) {
222
+ CallExpression(nodePath) {
223
+ const {
224
+ node: { callee, arguments: args },
225
+ } = nodePath;
220
226
  // Match `customProcessors.define(...)`
221
227
  // Match `customElements.define(...)`
222
228
  if (
@@ -265,6 +271,9 @@ export default async function scanBricks(packageDir) {
265
271
  const { type, value: fullName } = args[0];
266
272
  if (type === "StringLiteral") {
267
273
  collectBrick(fullName);
274
+ manifest.providers.push(
275
+ makeProviderManifest(fullName, nodePath, content)
276
+ );
268
277
  } else {
269
278
  throw new Error(
270
279
  "Please call `customElements.define()` only with literal string"