Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion goldens/public-api/angular_devkit/core/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ function oneLine(strings: TemplateStringsArray, ...values: any[]): string;
// @public (undocumented)
function parseJsonPointer(pointer: JsonPointer): string[];

// @public (undocumented)
// @public
export class PartiallyOrderedSet<T> {
// (undocumented)
[Symbol.iterator](): IterableIterator<T, undefined, unknown>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.dev/license
*/

import { BaseException, JsonValue, isPromise, logging } from '@angular-devkit/core';
import { BaseException, JsonValue, logging } from '@angular-devkit/core';
import {
Observable,
Observer,
Expand All @@ -27,6 +27,11 @@ import {
JobOutboundMessageKind,
} from './api';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
function isPromise(obj: any): obj is Promise<any> {
return !!obj && typeof obj.then === 'function';
}

export class ChannelAlreadyExistException extends BaseException {
constructor(name: string) {
super(`Channel ${JSON.stringify(name)} already exist.`);
Expand Down
4 changes: 2 additions & 2 deletions packages/angular_devkit/core/src/json/schema/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export interface SchemaRegistry {
/**
* Add a transformation step before the validation of any Json.
* @param {JsonVisitor} visitor The visitor to transform every value.
* @param {JsonVisitor[]} deps A list of other visitors to run before.
* @param {JsonVisitor[]} deps [Deprecated] A list of other visitors to run before. Add transforms in the desired execution order instead.
*/
addPreTransform(visitor: JsonVisitor, deps?: JsonVisitor[]): void;

Expand All @@ -94,7 +94,7 @@ export interface SchemaRegistry {
* after the POST, so if transformations are not compatible with the Schema it will not result
* in an error.
* @param {JsonVisitor} visitor The visitor to transform every value.
* @param {JsonVisitor[]} deps A list of other visitors to run before.
* @param {JsonVisitor[]} deps [Deprecated] A list of other visitors to run before. Add transforms in the desired execution order instead.
*/
addPostTransform(visitor: JsonVisitor, deps?: JsonVisitor[]): void;
}
Expand Down
8 changes: 4 additions & 4 deletions packages/angular_devkit/core/src/json/schema/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import * as https from 'node:https';
import * as Url from 'node:url';
import { Observable, from, isObservable, lastValueFrom } from 'rxjs';
import { BaseException } from '../../exception';
import { PartiallyOrderedSet, deepCopy } from '../../utils';
import { PartiallyOrderedSet } from '../../utils';
import { JsonArray, JsonObject, JsonValue, isJsonObject } from '../utils';
import {
JsonPointer,
Expand Down Expand Up @@ -171,7 +171,7 @@ export class CoreSchemaRegistry implements SchemaRegistry {
/**
* Add a transformation step before the validation of any Json.
* @param {JsonVisitor} visitor The visitor to transform every value.
* @param {JsonVisitor[]} deps A list of other visitors to run before.
* @param {JsonVisitor[]} deps [Deprecated] A list of other visitors to run before. Add transforms in the desired execution order instead.
*/
addPreTransform(visitor: JsonVisitor, deps?: JsonVisitor[]): void {
this._pre.add(visitor, deps);
Expand All @@ -182,7 +182,7 @@ export class CoreSchemaRegistry implements SchemaRegistry {
* after the POST, so if transformations are not compatible with the Schema it will not result
* in an error.
* @param {JsonVisitor} visitor The visitor to transform every value.
* @param {JsonVisitor[]} deps A list of other visitors to run before.
* @param {JsonVisitor[]} deps [Deprecated] A list of other visitors to run before. Add transforms in the desired execution order instead.
*/
addPostTransform(visitor: JsonVisitor, deps?: JsonVisitor[]): void {
this._post.add(visitor, deps);
Expand Down Expand Up @@ -257,7 +257,7 @@ export class CoreSchemaRegistry implements SchemaRegistry {
}
}

const schemaCopy = deepCopy(validate.schema as JsonObject);
const schemaCopy = structuredClone(validate.schema as JsonObject);
visitJsonSchema(schemaCopy, visitor);

return schemaCopy;
Expand Down
2 changes: 2 additions & 0 deletions packages/angular_devkit/core/src/utils/lang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

/**
* Determine if the argument is shaped like a Promise
*
* @deprecated Use `typeof obj?.then === 'function'` instead.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function isPromise(obj: any): obj is Promise<any> {
Expand Down
3 changes: 3 additions & 0 deletions packages/angular_devkit/core/src/utils/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

const copySymbol = Symbol();

/**
* @deprecated Use `structuredClone` instead.
Comment thread
clydin marked this conversation as resolved.
*/
export function deepCopy<T>(value: T): T {
if (Array.isArray(value)) {
return value.map((o) => deepCopy(o)) as unknown as T;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export class CircularDependencyFoundException extends BaseException {
}
}

/**
* @deprecated Use standard arrays and ensure correct insertion order instead.
*/
export class PartiallyOrderedSet<T> {
private _items = new Map<T, Set<T>>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.dev/license
*/

import { deepCopy, schema } from '@angular-devkit/core';
import { schema } from '@angular-devkit/core';
import { Observable, from, of as observableOf } from 'rxjs';
import { first, map, mergeMap } from 'rxjs/operators';
import { FileSystemSchematicContext, FileSystemSchematicDescription } from './description';
Expand All @@ -28,7 +28,7 @@ export function validateOptionsWithSchema(registry: schema.SchemaRegistry) {
context?: FileSystemSchematicContext,
): Observable<T> => {
// Prevent a schematic from changing the options object by making a copy of it.
options = deepCopy(options);
options = structuredClone(options);
Comment thread
clydin marked this conversation as resolved.

const withPrompts = context ? context.interactive : true;

Expand Down
Loading