@rivinia/http 0.5.2 → 0.5.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
@@ -239,7 +239,6 @@ import type { Trip } from './trip.service';
239
239
 
240
240
  @Component({
241
241
  selector: 'app-trip-list',
242
- standalone: true,
243
242
  templateUrl: './trip-list.component.html',
244
243
  })
245
244
  export class TripListComponent {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rivinia/http",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "Headless typed HTTP client for Angular: envelope unwrapping, plain Observables and httpResource.",
5
5
  "keywords": [
6
6
  "angular",
@@ -14,6 +14,7 @@
14
14
  "peerDependencies": {
15
15
  "@angular/common": "^22.0.0",
16
16
  "@angular/core": "^22.0.0",
17
+ "@angular-devkit/schematics": "^22.0.0",
17
18
  "rxjs": "^6.5.3 || ^7.4.0"
18
19
  },
19
20
  "dependencies": {
@@ -38,11 +38,11 @@ function ngAdd(options) {
38
38
  // the schematic emits no unwrap configuration. URLs are never touched:
39
39
  // the caller owns them (environment, joinUrl, …).
40
40
  let changed = false;
41
- if (!content.includes(HTTP_CLIENT_IMPORT)) {
41
+ if (!importsValue(content, '@angular/common/http', 'provideHttpClient')) {
42
42
  content = insertAfterLastImport(content, HTTP_CLIENT_IMPORT);
43
43
  changed = true;
44
44
  }
45
- if (!content.includes(PROVIDE_HTTP_IMPORT)) {
45
+ if (!importsValue(content, '@rivinia/http', 'provideRiviniaHttp')) {
46
46
  content = insertAfterLastImport(content, PROVIDE_HTTP_IMPORT);
47
47
  changed = true;
48
48
  }
@@ -115,3 +115,33 @@ function insertProvider(content, call) {
115
115
  const at = match.index + match[0].length;
116
116
  return `${content.slice(0, at)}\n ${call},${content.slice(at)}`;
117
117
  }
118
+ /**
119
+ * Whether the file already binds `symbol` as a VALUE imported from `module`.
120
+ *
121
+ * A plain `content.includes(IMPORT_LINE)` recognises only ONE shape of the
122
+ * import — `import { symbol } from 'module';`. An app that imports the
123
+ * symbol beside others (`import { other, symbol } from 'module';`) would be
124
+ * given a SECOND import of the same symbol, and its build would then fail
125
+ * with "Duplicate identifier" (TS2300).
126
+ *
127
+ * An aliased or a type-only import does not bind the name we need, so it
128
+ * does not count as present.
129
+ */
130
+ function importsValue(content, module, symbol) {
131
+ const pattern = /import\s+(?:type\s+)?\{([^}]*)\}\s*from\s*['"]([^'"]+)['"]/g;
132
+ for (const match of content.matchAll(pattern)) {
133
+ if (match[2] !== module)
134
+ continue;
135
+ if (/^\s*import\s+type\s/.test(match[0]))
136
+ continue; // a type-only import
137
+ for (const entry of match[1].split(',')) {
138
+ const raw = entry.trim();
139
+ if (!raw || /^type\s/.test(raw))
140
+ continue; // a type-only specifier
141
+ const local = raw.split(/\s+as\s+/).pop().trim();
142
+ if (local === symbol)
143
+ return true;
144
+ }
145
+ }
146
+ return false;
147
+ }