@rivinia/i18n 0.3.2 → 0.3.3

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
@@ -134,7 +134,6 @@ import { i18nConfig } from './i18n.config';
134
134
 
135
135
  @Component({
136
136
  selector: 'app-header',
137
- standalone: true,
138
137
  imports: [RTranslatePipe],
139
138
  templateUrl: './header.component.html',
140
139
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rivinia/i18n",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "Headless language manager for Angular: signals, RTL, loaders, ICU plurals, browser detection, Intl formatting.",
5
5
  "keywords": [
6
6
  "angular",
@@ -12,6 +12,7 @@
12
12
  ],
13
13
  "license": "MIT",
14
14
  "peerDependencies": {
15
+ "@angular-devkit/schematics": "^22.0.0",
15
16
  "@angular/core": "^22.0.0"
16
17
  },
17
18
  "sideEffects": false,
@@ -94,7 +94,7 @@ function ngAdd(options) {
94
94
  throw new schematics_1.SchematicsException(`[rivinia/i18n] ${configPath} is empty.`);
95
95
  }
96
96
  let changed = false;
97
- if (!content.includes(PROVIDE_IMPORT)) {
97
+ if (!importsValue(content, '@rivinia/i18n', 'provideRiviniaI18n')) {
98
98
  content = insertAfterLastImport(content, PROVIDE_IMPORT);
99
99
  changed = true;
100
100
  }
@@ -160,3 +160,33 @@ function insertProvider(content, call) {
160
160
  const at = match.index + match[0].length;
161
161
  return `${content.slice(0, at)}\n ${call},${content.slice(at)}`;
162
162
  }
163
+ /**
164
+ * Whether the file already binds `symbol` as a VALUE imported from `module`.
165
+ *
166
+ * A plain `content.includes(IMPORT_LINE)` recognises only ONE shape of the
167
+ * import — `import { symbol } from 'module';`. An app that imports the
168
+ * symbol beside others (`import { other, symbol } from 'module';`) would be
169
+ * given a SECOND import of the same symbol, and its build would then fail
170
+ * with "Duplicate identifier" (TS2300).
171
+ *
172
+ * An aliased or a type-only import does not bind the name we need, so it
173
+ * does not count as present.
174
+ */
175
+ function importsValue(content, module, symbol) {
176
+ const pattern = /import\s+(?:type\s+)?\{([^}]*)\}\s*from\s*['"]([^'"]+)['"]/g;
177
+ for (const match of content.matchAll(pattern)) {
178
+ if (match[2] !== module)
179
+ continue;
180
+ if (/^\s*import\s+type\s/.test(match[0]))
181
+ continue; // a type-only import
182
+ for (const entry of match[1].split(',')) {
183
+ const raw = entry.trim();
184
+ if (!raw || /^type\s/.test(raw))
185
+ continue; // a type-only specifier
186
+ const local = raw.split(/\s+as\s+/).pop().trim();
187
+ if (local === symbol)
188
+ return true;
189
+ }
190
+ }
191
+ return false;
192
+ }