@rivinia/modal 0.6.0 → 0.6.1

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": "@rivinia/modal",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Headless modal manager for Angular: stack/queue strategies, typed results, guards, ownership.",
5
5
  "keywords": [
6
6
  "angular",
@@ -11,6 +11,7 @@
11
11
  ],
12
12
  "license": "MIT",
13
13
  "peerDependencies": {
14
+ "@angular-devkit/schematics": "^22.0.0",
14
15
  "@angular/common": "^22.0.0",
15
16
  "@angular/core": "^22.0.0"
16
17
  },
@@ -34,7 +34,7 @@ function ngAdd(options) {
34
34
  }
35
35
  const provideCall = options.strategy !== undefined ? `provideRiviniaModal({ strategy: '${options.strategy}' })` : 'provideRiviniaModal()';
36
36
  let changed = false;
37
- if (!content.includes(PROVIDE_IMPORT)) {
37
+ if (!importsValue(content, '@rivinia/modal', 'provideRiviniaModal')) {
38
38
  content = insertAfterLastImport(content, PROVIDE_IMPORT);
39
39
  changed = true;
40
40
  }
@@ -99,3 +99,33 @@ function insertProvider(content, call) {
99
99
  const at = match.index + match[0].length;
100
100
  return `${content.slice(0, at)}\n ${call},${content.slice(at)}`;
101
101
  }
102
+ /**
103
+ * Whether the file already binds `symbol` as a VALUE imported from `module`.
104
+ *
105
+ * A plain `content.includes(IMPORT_LINE)` recognises only ONE shape of the
106
+ * import — `import { symbol } from 'module';`. An app that imports the
107
+ * symbol beside others (`import { other, symbol } from 'module';`) would be
108
+ * given a SECOND import of the same symbol, and its build would then fail
109
+ * with "Duplicate identifier" (TS2300).
110
+ *
111
+ * An aliased or a type-only import does not bind the name we need, so it
112
+ * does not count as present.
113
+ */
114
+ function importsValue(content, module, symbol) {
115
+ const pattern = /import\s+(?:type\s+)?\{([^}]*)\}\s*from\s*['"]([^'"]+)['"]/g;
116
+ for (const match of content.matchAll(pattern)) {
117
+ if (match[2] !== module)
118
+ continue;
119
+ if (/^\s*import\s+type\s/.test(match[0]))
120
+ continue; // a type-only import
121
+ for (const entry of match[1].split(',')) {
122
+ const raw = entry.trim();
123
+ if (!raw || /^type\s/.test(raw))
124
+ continue; // a type-only specifier
125
+ const local = raw.split(/\s+as\s+/).pop().trim();
126
+ if (local === symbol)
127
+ return true;
128
+ }
129
+ }
130
+ return false;
131
+ }