Skip to content

Commit

Permalink
prevent reexports
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderkirtzel committed Feb 17, 2025
1 parent 82c8c2f commit 1ace1ef
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 40 deletions.
33 changes: 26 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions packages/sources/walkerjs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import { dataLayerDestination } from './lib/destination';

// Export types and elb
export * from './types';
export { elb };

const elb = createElb();
export const elb = createElb();

export function Walkerjs(
customConfig: SourceWalkerjs.InitConfig = {},
Expand Down
9 changes: 5 additions & 4 deletions packages/sources/walkerjs/src/types/destination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import type {
Mapping as WalkerOSMapping,
WalkerOS,
} from '@elbwalker/types';
import type { On, SourceWalkerjs } from '.';
import type { Instance } from './source';
import type { Config as OnConfig } from './on';

export interface Destination<Custom = unknown, CustomEvent = unknown>
extends WalkerOSDestination.Destination<Custom, CustomEvent> {
Expand All @@ -17,7 +18,7 @@ export type DestinationInit = Partial<Omit<Destination, 'push'>> &

export type InitFn<Custom, CustomEvent> = (
config: Config<Custom, CustomEvent>,
instance: SourceWalkerjs.Instance,
instance: Instance,
) => void | Config | false;

export type PushFn<Custom, CustomEvent> = (
Expand All @@ -35,7 +36,7 @@ export type PushBatchFn<Custom, CustomEvent> = (

export interface Config<Custom = unknown, CustomEvent = unknown>
extends WalkerOSDestination.Config<Custom, CustomEvent> {
on?: On.Config; // On events listener rules
on?: OnConfig; // On events listener rules
}

export interface Mapping<CustomEvent = unknown>
Expand All @@ -46,5 +47,5 @@ export interface EventMapping<CustomEvent = unknown>

export interface Options {
data?: WalkerOSDestination.Data;
instance?: SourceWalkerjs.Instance;
instance?: Instance;
}
27 changes: 16 additions & 11 deletions packages/sources/walkerjs/src/types/elb.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import type { Elb, WalkerOS } from '@elbwalker/types';
import type { On, DestinationWeb, Walker, SourceWalkerjs } from '.';
import type { Destination, DestinationInit, Config } from './destination';
import type { ConsentConfig, Options } from './on';
import type { State } from './source';
import type { Trigger } from './walker';

export interface Fn<R = void, D = PushData, O = PushOptions, C = PushContext>
extends Elb.Fn<R, D, O, C>,
Expand All @@ -15,36 +18,38 @@ export type CommandInit<R = void> = (

export type CommandDestination<R = void> = (
event: 'walker destination',
destination: DestinationWeb.Destination | DestinationWeb.DestinationInit,
config?: DestinationWeb.Config,
destination: Destination | DestinationInit,
config?: Config,
) => R;

export type CommandRun<R = void> = (
event: 'walker run',
state?: Partial<SourceWalkerjs.State>,
state?: Partial<State>,
) => R;

export type CommandOn<R = void> = (
event: 'walker on',
type: 'consent',
rules: WalkerOS.SingleOrArray<On.ConsentConfig>,
rules: WalkerOS.SingleOrArray<ConsentConfig>,
) => R;

export type Layer = Elb.Layer;

export type PushData =
| Elb.PushData
| DestinationWeb.Destination
| DestinationWeb.DestinationInit
| Partial<SourceWalkerjs.State>
| Destination
| DestinationInit
| Partial<State>
| ScopeType;

export type PushOptions =
| Elb.PushOptions
| Walker.Trigger
| WalkerOS.SingleOrArray<On.Options>
| DestinationWeb.Config;
| Trigger
| WalkerOS.SingleOrArray<Options>
| Config;

export type PushContext = Elb.PushContext | Element;

export type Scope = Element | Document;

export type ScopeType = Scope | Scope[];
29 changes: 14 additions & 15 deletions packages/sources/walkerjs/src/types/source.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import type { Hooks, WalkerOS } from '@elbwalker/types';
import type { SessionConfig } from '@elbwalker/utils';
import type { Elb, On, Walker, DestinationWeb } from '.';
import type { Destination, Config as DestConfig } from './destination';
import type { Fn, Layer } from './elb';
import type { Config as OnConfig } from './on';
import type { Events, Trigger } from './walker';

declare global {
interface Window {
elbwalker: Instance;
walkerjs: Instance;
elbLayer: Elb.Layer;
elbLayer: Layer;
dataLayer: WalkerEvent | unknown;
elb: Elb.Fn;
elb: Fn;
}
}

Expand All @@ -22,28 +25,24 @@ export interface Instance extends State, WalkerOS.Instance {
config: Config;
destinations: Destinations;
version: string;
push: Elb.Fn;
getAllEvents: (scope: Element, prefix: string) => Walker.Events;
getEvents: (
target: Element,
trigger: Walker.Trigger,
prefix: string,
) => Walker.Events;
push: Fn;
getAllEvents: (scope: Element, prefix: string) => Events;
getEvents: (target: Element, trigger: Trigger, prefix: string) => Events;
getGlobals: () => WalkerOS.Properties;
sessionStart: (options?: SessionStartOptions) => void | WalkerOS.SessionData;
}

export interface State extends WalkerOS.State {
config: Config;
destinations: Destinations;
on: On.Config;
on: OnConfig;
timing: number;
}

export interface Config extends WalkerOS.Config {
dataLayer: boolean;
dataLayerConfig: DestinationWeb.Config;
elbLayer: Elb.Layer;
dataLayerConfig: DestConfig;
elbLayer: Layer;
pageview: boolean;
prefix: string;
run: boolean;
Expand All @@ -59,7 +58,7 @@ export interface InitConfig extends Partial<Config> {
custom?: WalkerOS.Properties;
destinations?: Destinations;
hooks?: Hooks.Functions;
on?: On.Config;
on?: OnConfig;
tagging?: number;
user?: WalkerOS.User;
}
Expand All @@ -70,5 +69,5 @@ export interface SessionStartOptions {
}

export interface Destinations {
[name: string]: DestinationWeb.Destination;
[name: string]: Destination;
}
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"exports": {
".": {
"types": "./dist/index.d.ts",
"browser": "./dist/web.js",
"browser": "./dist/web.mjs",
"import": "./dist/index.mjs",
"require": "./dist/index.js"
},
Expand Down

0 comments on commit 1ace1ef

Please sign in to comment.