@eventra_dev/eventra-cli 1.0.5 → 1.0.6

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 CHANGED
@@ -206,11 +206,12 @@ pnpm add -D @eventra_dev/cli-plugin-vue
206
206
 
207
207
  The plugin:
208
208
 
209
- - splits each `.vue` file into virtual TypeScript modules (`App.vue.ts`, `App.vue.template.ts`)
210
- - extracts `track()` calls from `<script>` blocks
211
- - detects static `event="feature_name"` attributes in `<template>` (literals only)
209
+ - parses each `.vue` file with the real Vue compiler (`@vue/compiler-sfc`) into a single virtual TypeScript module combining `<script>`/`<script setup>`
210
+ - extracts `track()` calls from the script exactly like a regular `.ts` file (direct calls, wrappers, propagation)
211
+ - detects `event="feature_name"` attributes in `<template>` — both literal and dynamic (`:event="expr"`); dynamic bindings resolve through the same module scope as the script, or surface as a dynamic occurrence if unresolvable
212
+ - Nuxt `.vue` files (pages/layouts/components) are handled the same way; auto-imported composables resolve once the project has run `nuxt prepare`/`nuxt dev`
212
213
 
213
- `sync.include` does **not** need `**/*.vue` manually — the plugin registers `**/*.vue` via `includeGlobs`.
214
+ `sync.include` does **not** need `**/*.vue` manually — the plugin registers `**/*.vue` via `includeGlobs`. See [`@eventra_dev/cli-plugin-vue`](https://www.npmjs.com/package/@eventra_dev/cli-plugin-vue) for details.
214
215
 
215
216
  ### Before publishing / local development
216
217
 
@@ -15,6 +15,42 @@ function isConcreteDeclaration(node) {
15
15
  || typescript_1.default.isMethodDeclaration(node)
16
16
  || typescript_1.default.isPropertyDeclaration(node));
17
17
  }
18
+ /**
19
+ * `declare const x: typeof import("./module")["name"]` (or the dotted form,
20
+ * `typeof import("./module").name`) is how Nuxt/unplugin-auto-import
21
+ * generate global ambient bindings for auto-imported exports. A `const`
22
+ * with no initializer is only legal in an ambient context, so this shape is
23
+ * unambiguous. Without unwrapping it, this ambient variable is its own
24
+ * distinct symbol — the wrapper/export registered under the *real*
25
+ * declaration's symbol would never match a call site that resolves to the
26
+ * ambient one instead.
27
+ */
28
+ function resolveAmbientAutoImportSymbol(symbol, checker) {
29
+ const declarations = symbol.getDeclarations();
30
+ if (!declarations || declarations.length !== 1) {
31
+ return null;
32
+ }
33
+ const [declaration] = declarations;
34
+ if (!typescript_1.default.isVariableDeclaration(declaration) || declaration.initializer || !declaration.type) {
35
+ return null;
36
+ }
37
+ let nameNode;
38
+ const type = declaration.type;
39
+ if (typescript_1.default.isImportTypeNode(type) && type.qualifier && typescript_1.default.isIdentifier(type.qualifier)) {
40
+ nameNode = type.qualifier;
41
+ }
42
+ else if (typescript_1.default.isIndexedAccessTypeNode(type)
43
+ && typescript_1.default.isImportTypeNode(type.objectType)
44
+ && typescript_1.default.isLiteralTypeNode(type.indexType)
45
+ && typescript_1.default.isStringLiteral(type.indexType.literal)) {
46
+ nameNode = type.indexType.literal;
47
+ }
48
+ if (!nameNode) {
49
+ return null;
50
+ }
51
+ const resolved = checker.getSymbolAtLocation(nameNode);
52
+ return resolved && resolved !== symbol ? resolved : null;
53
+ }
18
54
  function resolveExportedSymbol(symbol, checker, cache, visited) {
19
55
  if (typeof symbol.getDeclarations !== "function") {
20
56
  return null;
@@ -44,6 +80,13 @@ function resolveExportedSymbol(symbol, checker, cache, visited) {
44
80
  cache.set(symbol, resolved);
45
81
  return resolved;
46
82
  }
83
+ // ambient auto-import unwrap (Nuxt/unplugin-auto-import style globals)
84
+ const ambientTarget = resolveAmbientAutoImportSymbol(symbol, checker);
85
+ if (ambientTarget) {
86
+ const resolved = resolveExportedSymbol(ambientTarget, checker, cache, seen);
87
+ cache.set(symbol, resolved);
88
+ return resolved;
89
+ }
47
90
  // declaration existence
48
91
  const declarations = symbol.getDeclarations() ?? [];
49
92
  for (const declaration of declarations) {
@@ -48,10 +48,6 @@ function createStaticCalleeSinkDetector(sink) {
48
48
  if (call.arguments.length <= argIndex) {
49
49
  return null;
50
50
  }
51
- const arg = call.arguments[argIndex];
52
- if (!typescript_1.default.isStringLiteral(arg)) {
53
- return null;
54
- }
55
51
  return {
56
52
  call,
57
53
  trackedArguments: [{ index: argIndex, propertyPath: [] }],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eventra_dev/eventra-cli",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "Static analytics event extraction CLI powered by the TypeScript compiler API",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",