@animus-ui/extract 0.1.0-next.30 → 0.1.0-next.31

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.
@@ -1,9 +1,12 @@
1
1
  /**
2
- * Extract external DS package names from a system entry file's import declarations.
2
+ * Extract external DS package names from `.includes([...])` calls in the system file.
3
3
  *
4
- * Reads the file at `systemFilePath`, regex-extracts all `from '...'` / `from "..."`
5
- * import specifiers, filters out relative imports, the system framework package,
6
- * and known non-DS packages. Returns normalized package names (subpaths stripped).
4
+ * Reads the system file source, finds `.includes([identifier, ...])` calls in the
5
+ * builder chain, traces each identifier back to its import declaration, and returns
6
+ * the import specifiers. This is the authoritative mechanism — only packages explicitly
7
+ * declared via `.includes()` are treated as external DS dependencies.
8
+ *
9
+ * Falls back to empty array if no `.includes()` call is found.
7
10
  */
8
11
  export declare function extractSystemFilePackages(systemFilePath: string): string[];
9
12
  //# sourceMappingURL=discover-packages.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"discover-packages.d.ts","sourceRoot":"","sources":["../pipeline/discover-packages.ts"],"names":[],"mappings":"AAsBA;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,EAAE,CAoC1E"}
1
+ {"version":3,"file":"discover-packages.d.ts","sourceRoot":"","sources":["../pipeline/discover-packages.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,EAAE,CAyE1E"}
package/dist/index.mjs CHANGED
@@ -6,29 +6,14 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
6
6
  //#endregion
7
7
  //#region pipeline/discover-packages.ts
8
8
  /**
9
- * Known non-DS packages that should never be treated as external DS dependencies.
10
- */
11
- const KNOWN_SKIP = new Set([
12
- "react",
13
- "react-dom",
14
- "react/jsx-runtime",
15
- "react/jsx-dev-runtime",
16
- "next",
17
- "next/image",
18
- "next/link",
19
- "next/router",
20
- "next/navigation",
21
- "vite",
22
- "lodash",
23
- "lodash-es"
24
- ]);
25
- const KNOWN_SKIP_PREFIXES = ["@types/", "node:"];
26
- /**
27
- * Extract external DS package names from a system entry file's import declarations.
9
+ * Extract external DS package names from `.includes([...])` calls in the system file.
28
10
  *
29
- * Reads the file at `systemFilePath`, regex-extracts all `from '...'` / `from "..."`
30
- * import specifiers, filters out relative imports, the system framework package,
31
- * and known non-DS packages. Returns normalized package names (subpaths stripped).
11
+ * Reads the system file source, finds `.includes([identifier, ...])` calls in the
12
+ * builder chain, traces each identifier back to its import declaration, and returns
13
+ * the import specifiers. This is the authoritative mechanism — only packages explicitly
14
+ * declared via `.includes()` are treated as external DS dependencies.
15
+ *
16
+ * Falls back to empty array if no `.includes()` call is found.
32
17
  */
33
18
  function extractSystemFilePackages(systemFilePath) {
34
19
  let source;
@@ -37,17 +22,37 @@ function extractSystemFilePackages(systemFilePath) {
37
22
  } catch {
38
23
  return [];
39
24
  }
40
- const importRegex = /^\s*import\s.*from\s+['"]([^'"]+)['"]/gm;
25
+ const includesRegex = /\.includes\(\s*\[([^\]]*)\]\s*\)/gs;
26
+ const identifiers = /* @__PURE__ */ new Set();
27
+ let includesMatch;
28
+ while ((includesMatch = includesRegex.exec(source)) !== null) {
29
+ const inner = includesMatch[1];
30
+ for (const token of inner.split(",")) {
31
+ const id = token.trim();
32
+ if (id && /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(id)) identifiers.add(id);
33
+ }
34
+ }
35
+ if (identifiers.size === 0) return [];
36
+ const importMap = /* @__PURE__ */ new Map();
37
+ const importRegex = /^\s*import\s+(?:([a-zA-Z_$][a-zA-Z0-9_$]*)\s*,\s*)?(?:\{([^}]*)\}|([a-zA-Z_$][a-zA-Z0-9_$]*))\s+from\s+['"]([^'"]+)['"]/gm;
38
+ let importMatch;
39
+ while ((importMatch = importRegex.exec(source)) !== null) {
40
+ const [, comboDefault, namedImports, defaultImport, specifier] = importMatch;
41
+ if (comboDefault) importMap.set(comboDefault, specifier);
42
+ if (defaultImport) importMap.set(defaultImport, specifier);
43
+ if (namedImports) for (const binding of namedImports.split(",")) {
44
+ const parts = binding.trim().split(/\s+as\s+/);
45
+ const localName = (parts[1] || parts[0]).trim();
46
+ if (localName) importMap.set(localName, specifier);
47
+ }
48
+ }
41
49
  const packages = /* @__PURE__ */ new Set();
42
- let match;
43
- while ((match = importRegex.exec(source)) !== null) {
44
- const specifier = match[1];
45
- if (specifier.startsWith(".")) continue;
46
- const pkgName = specifier.startsWith("@") ? specifier.split("/").slice(0, 2).join("/") : specifier.split("/")[0];
47
- if (pkgName === "@animus-ui/system") continue;
48
- if (KNOWN_SKIP.has(specifier) || KNOWN_SKIP.has(pkgName)) continue;
49
- if (KNOWN_SKIP_PREFIXES.some((p) => specifier.startsWith(p))) continue;
50
- packages.add(pkgName);
50
+ for (const id of identifiers) {
51
+ const specifier = importMap.get(id);
52
+ if (specifier && !specifier.startsWith(".")) {
53
+ const pkgName = specifier.startsWith("@") ? specifier.split("/").slice(0, 2).join("/") : specifier.split("/")[0];
54
+ packages.add(pkgName);
55
+ }
51
56
  }
52
57
  return Array.from(packages);
53
58
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@animus-ui/extract",
3
- "version": "0.1.0-next.30",
3
+ "version": "0.1.0-next.31",
4
4
  "description": "Animus static CSS extraction pipeline (Rust/NAPI)",
5
5
  "author": "codecaaron <airrobb@gmail.com>",
6
6
  "license": "MIT",
@@ -44,9 +44,9 @@
44
44
  "build:pipeline": "tsdown && tsc -p tsconfig.build.json"
45
45
  },
46
46
  "optionalDependencies": {
47
- "@animus-ui/extract-darwin-arm64": "0.1.0-next.30",
48
- "@animus-ui/extract-linux-x64-gnu": "0.1.0-next.30",
49
- "@animus-ui/extract-linux-arm64-gnu": "0.1.0-next.30"
47
+ "@animus-ui/extract-darwin-arm64": "0.1.0-next.31",
48
+ "@animus-ui/extract-linux-x64-gnu": "0.1.0-next.31",
49
+ "@animus-ui/extract-linux-arm64-gnu": "0.1.0-next.31"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@animus-ui/system": "workspace:*",