Skip to content

Commit

Permalink
refactor: deprecate some names
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode committed Jul 2, 2024
1 parent f4ca584 commit 880fd65
Show file tree
Hide file tree
Showing 65 changed files with 531 additions and 165 deletions.
9 changes: 7 additions & 2 deletions apps/demo/src/app/pages/midi/demo/response.ts

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions libs/audio/src/tokens/audio-context.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import {InjectionToken} from '@angular/core';

export const AUDIO_CONTEXT = new InjectionToken<BaseAudioContext>(
'[AUDIO_CONTEXT]: Web Audio API context',
export const WA_AUDIO_CONTEXT = new InjectionToken<BaseAudioContext>(
'[WA_AUDIO_CONTEXT]: Web Audio API context',
{
providedIn: 'root',
factory: () => new AudioContext(),
},
);

/**
* @deprecated: drop in v5.0
*/
export const AUDIO_CONTEXT = WA_AUDIO_CONTEXT;
18 changes: 14 additions & 4 deletions libs/audio/src/tokens/audio-node.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
import type {ExistingProvider, Type} from '@angular/core';
import {InjectionToken} from '@angular/core';

export const AUDIO_NODE = new InjectionToken<AudioNode | null>(
'[AUDIO_NODE]: Web Audio API audio node',
export const WA_AUDIO_NODE = new InjectionToken<AudioNode | null>(
'[WA_AUDIO_NODE]: Web Audio API audio node',
{
factory: () => null,
},
);

export function asAudioNode(useExisting: Type<AudioNode>): ExistingProvider {
export function waAsAudioNode(useExisting: Type<AudioNode>): ExistingProvider {
return {
provide: AUDIO_NODE,
provide: WA_AUDIO_NODE,
useExisting,
};
}

/**
* @deprecated: drop in v5.0
*/
export const asAudioNode = waAsAudioNode;

/**
* @deprecated: drop in v5.0
*/
export const AUDIO_NODE = WA_AUDIO_NODE;
21 changes: 13 additions & 8 deletions libs/audio/src/tokens/audio-worklet-processors-ready.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import {inject, InjectionToken} from '@angular/core';

import {AUDIO_CONTEXT} from './audio-context';
import {AUDIO_WORKLET_PROCESSORS} from './audio-worklet-processors';
import {AUDIO_WORKLET_SUPPORT} from './audio-worklet-support';
import {WA_AUDIO_CONTEXT} from './audio-context';
import {WA_AUDIO_WORKLET_PROCESSORS} from './audio-worklet-processors';
import {WA_AUDIO_WORKLET_SUPPORT} from './audio-worklet-support';

export const AUDIO_WORKLET_PROCESSORS_READY = new InjectionToken<Promise<boolean>>(
'[AUDIO_WORKLET_PROCESSORS_READY]: Web Audio API worklet processors resolution promise',
export const WA_AUDIO_WORKLET_PROCESSORS_READY = new InjectionToken<Promise<boolean>>(
'[WA_AUDIO_WORKLET_PROCESSORS_READY]: Web Audio API worklet processors resolution promise',
{
providedIn: 'root',
factory: async () => {
const context = inject(AUDIO_CONTEXT);
const processors = inject(AUDIO_WORKLET_PROCESSORS);
const context = inject(WA_AUDIO_CONTEXT);
const processors = inject(WA_AUDIO_WORKLET_PROCESSORS);

if (!inject(AUDIO_WORKLET_SUPPORT)) {
if (!inject(WA_AUDIO_WORKLET_SUPPORT)) {
// eslint-disable-next-line no-restricted-syntax,prefer-promise-reject-errors
return Promise.reject('AudioWorklet is not supported').catch(() => false);
}
Expand All @@ -26,3 +26,8 @@ export const AUDIO_WORKLET_PROCESSORS_READY = new InjectionToken<Promise<boolean
},
},
);

/**
* @deprecated: drop in v5.0
*/
export const AUDIO_WORKLET_PROCESSORS_READY = WA_AUDIO_WORKLET_PROCESSORS_READY;
9 changes: 7 additions & 2 deletions libs/audio/src/tokens/audio-worklet-processors.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import {InjectionToken} from '@angular/core';

export const AUDIO_WORKLET_PROCESSORS = new InjectionToken<readonly string[]>(
'[AUDIO_WORKLET_PROCESSORS]: Web Audio API worklet processors paths',
export const WA_AUDIO_WORKLET_PROCESSORS = new InjectionToken<readonly string[]>(
'[WA_AUDIO_WORKLET_PROCESSORS]: Web Audio API worklet processors paths',
{
providedIn: 'root',
factory: () => [],
},
);

/**
* @deprecated: drop in v5.0
*/
export const AUDIO_WORKLET_PROCESSORS = WA_AUDIO_WORKLET_PROCESSORS;
13 changes: 9 additions & 4 deletions libs/audio/src/tokens/audio-worklet-support.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import {inject, InjectionToken} from '@angular/core';

import {AUDIO_CONTEXT} from './audio-context';
import {WA_AUDIO_CONTEXT} from './audio-context';

export const AUDIO_WORKLET_SUPPORT = new InjectionToken<boolean>(
'[AUDIO_WORKLET_SUPPORT]: AudioWorklet browser support',
export const WA_AUDIO_WORKLET_SUPPORT = new InjectionToken<boolean>(
'[WA_AUDIO_WORKLET_SUPPORT]: AudioWorklet browser support',
{
factory: () => !!inject(AUDIO_CONTEXT).audioWorklet,
factory: () => !!inject(WA_AUDIO_CONTEXT).audioWorklet,
},
);

/**
* @deprecated: drop in v5.0
*/
export const AUDIO_WORKLET_SUPPORT = WA_AUDIO_WORKLET_SUPPORT;
13 changes: 9 additions & 4 deletions libs/audio/src/tokens/constructor-support.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
import {inject, InjectionToken} from '@angular/core';

import {AUDIO_CONTEXT} from './audio-context';
import {WA_AUDIO_CONTEXT} from './audio-context';

/**
* This is mostly for internal use only
*/
export const CONSTRUCTOR_SUPPORT = new InjectionToken<boolean>(
'[CONSTRUCTOR_SUPPORT]: Tests if constructor mode of node creation is supported or a fallback to factory method is needed',
export const WA_CONSTRUCTOR_SUPPORT = new InjectionToken<boolean>(
'[WA_CONSTRUCTOR_SUPPORT]: Tests if constructor mode of node creation is supported or a fallback to factory method is needed',
{
providedIn: 'root',
factory: () => {
try {
return !!new GainNode(inject(AUDIO_CONTEXT));
return !!new GainNode(inject(WA_AUDIO_CONTEXT));
} catch (_) {
return false;
}
},
},
);

/**
* @deprecated: drop in v5.0
*/
export const CONSTRUCTOR_SUPPORT = WA_CONSTRUCTOR_SUPPORT;
9 changes: 7 additions & 2 deletions libs/audio/src/tokens/feedback-coefficients.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import {InjectionToken} from '@angular/core';

export const FEEDBACK_COEFFICIENTS = new InjectionToken<number[]>(
'[FEEDBACK_COEFFICIENTS]: A sequence of feedback coefficients for IIRFilterNode',
export const WA_FEEDBACK_COEFFICIENTS = new InjectionToken<number[]>(
'[WA_FEEDBACK_COEFFICIENTS]: A sequence of feedback coefficients for IIRFilterNode',
);

/**
* @deprecated: drop in v5.0
*/
export const FEEDBACK_COEFFICIENTS = WA_FEEDBACK_COEFFICIENTS;
9 changes: 7 additions & 2 deletions libs/audio/src/tokens/feedforward-coefficients.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import {InjectionToken} from '@angular/core';

export const FEEDFORWARD_COEFFICIENTS = new InjectionToken<number[]>(
'[FEEDFORWARD_COEFFICIENTS]: A sequence of feedforward coefficients for IIRFilterNode',
export const WA_FEEDFORWARD_COEFFICIENTS = new InjectionToken<number[]>(
'[WA_FEEDFORWARD_COEFFICIENTS]: A sequence of feedforward coefficients for IIRFilterNode',
);

/**
* @deprecated: drop in v5.0
*/
export const FEEDFORWARD_COEFFICIENTS = WA_FEEDFORWARD_COEFFICIENTS;
9 changes: 7 additions & 2 deletions libs/audio/src/tokens/media-stream.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import {InjectionToken} from '@angular/core';

export const MEDIA_STREAM = new InjectionToken<MediaStream>(
'[MEDIA_STREAM]: MediaStream for MediaStreamAudioSourceNode',
export const WA_MEDIA_STREAM = new InjectionToken<MediaStream>(
'[WA_MEDIA_STREAM]: MediaStream for MediaStreamAudioSourceNode',
);

/**
* @deprecated: drop in v5.0
*/
export const MEDIA_STREAM = WA_MEDIA_STREAM;
9 changes: 7 additions & 2 deletions libs/audio/src/tokens/support.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import {InjectionToken} from '@angular/core';

export const WEB_AUDIO_SUPPORT = new InjectionToken<boolean>(
'[WEB_AUDIO_SUPPORT]: Web Audio API support',
export const WA_WEB_AUDIO_SUPPORT = new InjectionToken<boolean>(
'[WA_WEB_AUDIO_SUPPORT]: Web Audio API support',
{
providedIn: 'root',
factory: () => !!AudioContext,
},
);

/**
* @deprecated: drop in v5.0
*/
export const WEB_AUDIO_SUPPORT = WA_WEB_AUDIO_SUPPORT;
9 changes: 7 additions & 2 deletions libs/canvas/src/tokens/canvas-2d-context.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import {InjectionToken} from '@angular/core';

export const CANVAS_2D_CONTEXT = new InjectionToken<CanvasRenderingContext2D>(
'[CANVAS_2D_CONTEXT]: Canvas 2D rendering context',
export const WA_CANVAS_2D_CONTEXT = new InjectionToken<CanvasRenderingContext2D>(
'[WA_CANVAS_2D_CONTEXT]: Canvas 2D rendering context',
);

/**
* @deprecated: drop in v5.0
*/
export const CANVAS_2D_CONTEXT = WA_CANVAS_2D_CONTEXT;
18 changes: 14 additions & 4 deletions libs/canvas/src/tokens/canvas-method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,23 @@ import {InjectionToken} from '@angular/core';

import type {CanvasMethod} from '../interfaces/canvas-method';

export const CANVAS_METHOD = new InjectionToken<CanvasMethod>(
'[CANVAS_METHOD]: A directive that draws on canvas',
export const WA_CANVAS_METHOD = new InjectionToken<CanvasMethod>(
'[WA_CANVAS_METHOD]: A directive that draws on canvas',
);

export function asCanvasMethod(useExisting: Type<CanvasMethod>): ExistingProvider {
export function waAsCanvasMethod(useExisting: Type<CanvasMethod>): ExistingProvider {
return {
provide: CANVAS_METHOD,
provide: WA_CANVAS_METHOD,
useExisting,
};
}

/**
* @deprecated: drop in v5.0
*/
export const asCanvasMethod = waAsCanvasMethod;

/**
* @deprecated: drop in v5.0
*/
export const CANVAS_METHOD = WA_CANVAS_METHOD;
18 changes: 14 additions & 4 deletions libs/canvas/src/tokens/canvas-properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,27 @@ import {InjectionToken} from '@angular/core';

import type {CanvasMethod} from '../interfaces/canvas-method';

export const CANVAS_PROPERTIES = new InjectionToken<CanvasMethod[]>(
'[CANVAS_PROPERTIES]: A directive performing processing before and after drawing to canvas',
export const WA_CANVAS_PROPERTIES = new InjectionToken<CanvasMethod[]>(
'[WA_CANVAS_PROPERTIES]: A directive performing processing before and after drawing to canvas',
{
factory: () => [],
},
);

export function asCanvasProperty(useExisting: Type<CanvasMethod>): ExistingProvider {
export function waAsCanvasProperty(useExisting: Type<CanvasMethod>): ExistingProvider {
return {
provide: CANVAS_PROPERTIES,
provide: WA_CANVAS_PROPERTIES,
multi: true,
useExisting,
};
}

/**
* @deprecated: drop in v5.0
*/
export const asCanvasProperty = waAsCanvasProperty;

/**
* @deprecated: drop in v5.0
*/
export const CANVAS_PROPERTIES = WA_CANVAS_PROPERTIES;
9 changes: 7 additions & 2 deletions libs/common/src/tokens/animation-frame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {Observable, share} from 'rxjs';

import {WINDOW} from './window';

export const ANIMATION_FRAME = new InjectionToken<Observable<DOMHighResTimeStamp>>(
'[ANIMATION_FRAME]: Shared Observable based on `window.requestAnimationFrame`',
export const WA_ANIMATION_FRAME = new InjectionToken<Observable<DOMHighResTimeStamp>>(
'[WA_ANIMATION_FRAME]: Shared Observable based on `window.requestAnimationFrame`',
{
factory: () => {
const {requestAnimationFrame, cancelAnimationFrame} = inject(WINDOW);
Expand All @@ -26,3 +26,8 @@ export const ANIMATION_FRAME = new InjectionToken<Observable<DOMHighResTimeStamp
},
},
);

/**
* @deprecated: drop in v5.0
*/
export const ANIMATION_FRAME = WA_ANIMATION_FRAME;
9 changes: 7 additions & 2 deletions libs/common/src/tokens/caches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@ import {inject, InjectionToken} from '@angular/core';

import {WINDOW} from './window';

export const CACHES = new InjectionToken<CacheStorage>(
'[CACHES]: An abstraction over window.caches object',
export const WA_CACHES = new InjectionToken<CacheStorage>(
'[WA_CACHES]: An abstraction over window.caches object',
{
factory: () => inject(WINDOW).caches,
},
);

/**
* @deprecated: drop in v5.0
*/
export const CACHES = WA_CACHES;
9 changes: 7 additions & 2 deletions libs/common/src/tokens/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@ import {inject, InjectionToken} from '@angular/core';

import {WINDOW} from './window';

export const CRYPTO = new InjectionToken<Crypto>(
'[CRYPTO]: An abstraction over window.crypto object',
export const WA_CRYPTO = new InjectionToken<Crypto>(
'[WA_CRYPTO]: An abstraction over window.crypto object',
{
factory: () => inject(WINDOW).crypto,
},
);

/**
* @deprecated: drop in v5.0
*/
export const CRYPTO = WA_CRYPTO;
9 changes: 7 additions & 2 deletions libs/common/src/tokens/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ declare global {
}
}

const TOKEN_CSS = new InjectionToken<typeof CSS>(
'[TOKEN_CSS]: An abstraction over window.CSS object',
export const WA_CSS = new InjectionToken<typeof CSS>(
'[WA_CSS]: An abstraction over window.CSS object',
{
factory: () =>
inject(WINDOW).CSS ??
Expand All @@ -21,4 +21,9 @@ const TOKEN_CSS = new InjectionToken<typeof CSS>(
},
);

/**
* @deprecated: drop in v5.0
*/
export const TOKEN_CSS = WA_CSS;

export {TOKEN_CSS as CSS};
9 changes: 7 additions & 2 deletions libs/common/src/tokens/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@ import {inject, InjectionToken} from '@angular/core';

import {WINDOW} from './window';

export const HISTORY = new InjectionToken<History>(
'[HISTORY]: An abstraction over window.history object',
export const WA_HISTORY = new InjectionToken<History>(
'[WA_HISTORY]: An abstraction over window.history object',
{
factory: () => inject(WINDOW).history,
},
);

/**
* @deprecated: drop in v5.0
*/
export const HISTORY = WA_HISTORY;
9 changes: 7 additions & 2 deletions libs/common/src/tokens/local-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@ import {inject, InjectionToken} from '@angular/core';

import {WINDOW} from './window';

export const LOCAL_STORAGE = new InjectionToken<Storage>(
'[LOCAL_STORAGE]: An abstraction over window.localStorage object',
export const WA_LOCAL_STORAGE = new InjectionToken<Storage>(
'[WA_LOCAL_STORAGE]: An abstraction over window.localStorage object',
{
factory: () => inject(WINDOW).localStorage,
},
);

/**
* @deprecated: drop in v5.0
*/
export const LOCAL_STORAGE = WA_LOCAL_STORAGE;
Loading

0 comments on commit 880fd65

Please sign in to comment.