Skip to content

Commit

Permalink
feat(2d): make Code not experimental (#1000)
Browse files Browse the repository at this point in the history
  • Loading branch information
aarthificial committed Mar 20, 2024
1 parent c6db8ce commit aa871a1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
22 changes: 17 additions & 5 deletions packages/2d/src/lib/components/Code.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
BBox,
createSignal,
ExperimentalError,
experimentalLog,
lazy,
map,
SerializedVector2,
Expand All @@ -11,6 +11,8 @@ import {
ThreadGenerator,
TimingFunction,
unwrap,
useLogger,
useScene,
Vector2,
} from '@motion-canvas/core';
import {
Expand All @@ -35,7 +37,6 @@ import {
} from '../code';
import {computed, initial, nodeName, parser, signal} from '../decorators';
import {DesiredLength} from '../partials';
import {useScene2D} from '../scenes';
import {Shape, ShapeProps} from './Shape';

/**
Expand Down Expand Up @@ -249,6 +250,20 @@ export class Code extends Shape {
@signal()
public declare readonly drawHooks: SimpleSignal<DrawHooks, this>;

protected setDrawHooks(value: DrawHooks) {
if (
!useScene().experimentalFeatures &&
value !== this.drawHooks.context.getInitial()
) {
useLogger().log({
...experimentalLog(`Code uses experimental draw hooks.`),
inspect: this.key,
});
} else {
this.drawHooks.context.setter(value);
}
}

/**
* The currently selected code range.
*
Expand Down Expand Up @@ -331,9 +346,6 @@ export class Code extends Shape {
fontFamily: 'monospace',
...props,
});
if (!useScene2D().experimentalFeatures) {
throw new ExperimentalError('The Code node is an experimental feature');
}
}

/**
Expand Down
3 changes: 3 additions & 0 deletions packages/2d/src/lib/components/CodeBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ export interface CodeModification {
to: Code;
}

/**
* @deprecated Use {@link Code} instead.
*/
@nodeName('CodeBlock')
export class CodeBlock extends Shape {
private static initialized = createComputedAsync(
Expand Down

0 comments on commit aa871a1

Please sign in to comment.