Skip to content

Commit

Permalink
Add multiple NoOp types
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbieTheWagner committed Mar 19, 2024
1 parent 4e76760 commit dac721e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
10 changes: 5 additions & 5 deletions shepherd.js/src/shepherd.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Shepherd, Tour } from './tour.ts';
import { NoOp } from './utils/general.ts';
import { Step } from './step.ts';
import { Shepherd, Tour, type TourOptions } from './tour.ts';
import { StepNoOp, TourNoOp } from './utils/general.ts';
import { Step, type StepOptions } from './step.ts';

const isServerSide = typeof window === 'undefined';

Shepherd.Step = isServerSide ? NoOp : Step;
Shepherd.Tour = isServerSide ? NoOp : Tour;
Shepherd.Step = isServerSide ? StepNoOp : Step;
Shepherd.Tour = isServerSide ? TourNoOp : Tour;

export default Shepherd;
6 changes: 3 additions & 3 deletions shepherd.js/src/tour.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import DataRequest from './utils/datarequest.ts';
import { normalizePrefix, uuid } from './utils/general.ts';
// @ts-expect-error TODO: not yet typed
import ShepherdModal from './components/shepherd-modal.svelte';
import type { NoOp } from './utils/general.ts';
import type { StepNoOp, TourNoOp } from './utils/general.ts';

interface Actor {
actorId: number;
Expand Down Expand Up @@ -95,8 +95,8 @@ export class ShepherdPro extends Evented {
apiKey?: string;
apiPath?: string;
dataRequester?: DataRequest;
declare Step: NoOp | Step;
declare Tour: NoOp | Tour;
declare Step: StepNoOp | Step;
declare Tour: TourNoOp | Tour;

init(apiKey?: string, apiPath?: string) {
if (!apiKey) {
Expand Down
15 changes: 12 additions & 3 deletions shepherd.js/src/utils/general.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import { type StepOptionsAttachTo, type Step } from '../step.ts';
import { type Tour, type TourOptions } from '../tour.ts';
import {
type StepOptionsAttachTo,
type Step,
type StepOptions
} from '../step.ts';
import { isFunction, isString } from './type-check.ts';

export class NoOp {
constructor() {}
export class StepNoOp {
constructor(options: StepOptions) {}
}

export class TourNoOp {
constructor(tour: Tour, options: TourOptions) {}
}

/**
Expand Down

0 comments on commit dac721e

Please sign in to comment.