Skip to content

Commit

Permalink
remove tilde imports
Browse files Browse the repository at this point in the history
  • Loading branch information
KingSora committed Aug 1, 2024
1 parent 61f11e9 commit b11536b
Show file tree
Hide file tree
Showing 46 changed files with 389 additions and 374 deletions.
9 changes: 0 additions & 9 deletions local/config/src/playwright.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,6 @@ export default {
fullyParallel: true,
reporter: 'list',
outputDir: '.playwright',
build: {
// external: [
// 'local/playwright-tooling/**/*',
// 'local/config/**/*',
// 'local/rollup/**/*',
// 'local/esbuild/**/*',
// 'scrollSnap/**/*',
// ],
},
projects: [
{
name: 'Chromium',
Expand Down
4 changes: 2 additions & 2 deletions local/playwright-tooling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "@~local/playwright-tooling",
"private": true,
"type": "module",
"main": "./src/index.cjs",
"module": "./src/index.cjs",
"main": "./src/index.js",
"module": "./src/index.js",
"bin": {
"playwright-merge-coverage": "./bin/mergeCoverage.js"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
const fs = require('fs');
const { basename, dirname, join } = require('path');
import fs from 'node:fs';
import { basename, dirname, join } from 'node:path';
import playwrightCoverageConfig from '@~local/config/playwright.coverage';

module.exports = async (coverageOutputDir, coverage, testfile) => {
const { tmpCoverageDirectory } = (await import('@~local/config/playwright.coverage')).default;
const { tmpCoverageDirectory } = playwrightCoverageConfig;

export default async (coverageOutputDir, coverage, testfile) => {
if (coverage) {
// eslint-disable-next-line no-restricted-syntax
const coveragePath = join(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { expect } = require('@playwright/test');
import { expect } from '@playwright/test';

const startSelector = '#start';
const resultSelector = '#testResult';
Expand All @@ -9,7 +9,7 @@ const logError = async (page, ...args) => {
};

// default timeout = // 15mins
module.exports = async (page, timeout = 10 * 60 * 1500) => {
export default async (page, timeout = 10 * 60 * 1500) => {
page.on('pageerror', (err) => {
logError(page, err.message);
});
Expand Down
7 changes: 0 additions & 7 deletions local/playwright-tooling/src/index.cjs

This file was deleted.

2 changes: 2 additions & 0 deletions local/playwright-tooling/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default as playwrightRollup } from './playwrightRollup.js';
export { default as expectSuccess } from './expectSuccess.js';
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const { dirname } = require('path');
const { watch: rollupWatch } = require('rollup');
const { test } = require('@playwright/test');
const collectCoverage = require('./collectCoverage');
import { dirname } from 'node:path';
import { watch as rollupWatch } from 'rollup';
import { test } from '@playwright/test';
import createPlaywrightRollupConfig from '@~local/rollup/playwright';
import collectCoverage from './collectCoverage.js';

const createRollupBundle = async (testDir, useEsbuild, dev) => {
const createPlaywrightRollupConfig = (await import('@~local/rollup/playwright')).default;
const [config, getServer] = await createPlaywrightRollupConfig(testDir, useEsbuild, dev);
const watcher = rollupWatch(config);

Expand Down Expand Up @@ -53,7 +53,7 @@ const createRollupBundle = async (testDir, useEsbuild, dev) => {
};
};

module.exports = (options) => {
export default (options) => {
const { useEsbuild = true, adaptUrl = (originalUrl) => originalUrl } = options || {};
let url;
let close;
Expand Down
1 change: 1 addition & 0 deletions packages/overlayscrollbars/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
},
"scripts": {
"build": "rollup -c",
"types": "tsc --emitDeclarationOnly -p tsconfig.types.json",
"test": "jest --coverage",
"e2e": "playwright test",
"e2e:dev": "playwright test --workers 1 --timeout 0 --global-timeout 0",
Expand Down
14 changes: 7 additions & 7 deletions packages/overlayscrollbars/src/environment.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import type { XY, EventListener } from './support';
import type { Options, PartialOptions } from './options';
import type { Initialization, PartialInitialization } from './initialization';
import type { StyleObjectKey } from './typings';
import { defaultOptions } from './options';
import { classNameEnvironment, classNameEnvironmentScrollbarHidden } from './classnames';
import {
createDOM,
addClass,
Expand All @@ -18,13 +24,7 @@ import {
isBodyElement,
isFunction,
addEventListener,
} from '~/support';
import { classNameEnvironment, classNameEnvironmentScrollbarHidden } from '~/classnames';
import { defaultOptions } from '~/options';
import type { XY, EventListener } from '~/support';
import type { Options, PartialOptions } from '~/options';
import type { Initialization, PartialInitialization } from '~/initialization';
import type { StyleObjectKey } from './typings';
} from './support';
import { getNonce } from './nonce';

type EnvironmentEventArgs = {
Expand Down
6 changes: 3 additions & 3 deletions packages/overlayscrollbars/src/eventListeners.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { OverlayScrollbars } from '~/overlayscrollbars';
import type { PartialOptions } from '~/options';
import type { OverlayScrollbars } from './overlayscrollbars';
import type { PartialOptions } from './options';
import type {
EventListeners as GeneralEventListeners,
EventListener as GeneralEventListener,
AddEvent as GeneralAddEvent,
RemoveEvent as GeneralRemoveEvent,
TriggerEvent as GeneralTriggerEvent,
} from '~/support';
} from './support';

/**
* Describes the changes that happend due to an update.
Expand Down
12 changes: 6 additions & 6 deletions packages/overlayscrollbars/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export {
State,
CloneableScrollbarElements,
ScrollbarElements,
} from '~/overlayscrollbars';
export { ScrollbarsHidingPlugin, SizeObserverPlugin, ClickScrollPlugin } from '~/plugins';
} from './overlayscrollbars';
export { ScrollbarsHidingPlugin, SizeObserverPlugin, ClickScrollPlugin } from './plugins';

export type {
Options,
Expand All @@ -17,13 +17,13 @@ export type {
OverflowBehavior,
ScrollbarsVisibilityBehavior,
ScrollbarsAutoHideBehavior,
} from '~/options';
} from './options';
export type {
EventListener,
EventListeners,
EventListenerArgs,
OnUpdatedEventListenerArgs,
} from '~/eventListeners';
} from './eventListeners';
export type {
Initialization,
PartialInitialization,
Expand All @@ -34,7 +34,7 @@ export type {
DynamicInitialization,
StaticInitializationElement,
DynamicInitializationElement,
} from '~/initialization';
} from './initialization';
export type {
PluginModuleInstance,
PluginModule,
Expand All @@ -44,4 +44,4 @@ export type {
InstancePluginEvent,
InferStaticPluginModuleInstance,
InferInstancePluginModuleInstance,
} from '~/plugins';
} from './plugins';
32 changes: 16 additions & 16 deletions packages/overlayscrollbars/src/initialization.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { isFunction, isHTMLElement, isNull, isUndefined } from '~/support';
import { getEnvironment } from '~/environment';
import type { DeepPartial } from '~/typings';

type FallbackStaticInitializtationElement<Args extends any[]> = Extract<
StaticInitializationElement<Args>,
(...args: Args) => any
> extends (...args: infer P) => any
? (...args: P) => HTMLElement
: never;
type FallbackDynamicInitializtationElement<Args extends any[]> = Extract<
DynamicInitializationElement<Args>,
(...args: Args) => any
> extends (...args: infer P) => any
? (...args: P) => HTMLElement
: never;
import type { DeepPartial } from './typings';
import { isFunction, isHTMLElement, isNull, isUndefined } from './support';
import { getEnvironment } from './environment';

type FallbackStaticInitializtationElement<Args extends any[]> =
Extract<StaticInitializationElement<Args>, (...args: Args) => any> extends (
...args: infer P
) => any
? (...args: P) => HTMLElement
: never;
type FallbackDynamicInitializtationElement<Args extends any[]> =
Extract<DynamicInitializationElement<Args>, (...args: Args) => any> extends (
...args: infer P
) => any
? (...args: P) => HTMLElement
: never;

export type StaticInitialization = HTMLElement | false | null;
export type DynamicInitialization = HTMLElement | boolean | null;
Expand Down
2 changes: 1 addition & 1 deletion packages/overlayscrollbars/src/instances.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { OverlayScrollbars } from '~/overlayscrollbars';
import type { OverlayScrollbars } from './overlayscrollbars';

const targetInstanceMap: WeakMap<Element, OverlayScrollbars> = new WeakMap();

Expand Down
4 changes: 2 additions & 2 deletions packages/overlayscrollbars/src/observers/domObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
concat,
getAttr,
isString,
} from '~/support';
} from '../support';

type DOMContentObserverCallback = (contentChangedThroughEvent: boolean) => any;

Expand Down Expand Up @@ -77,7 +77,7 @@ export type DOMObserverOptions<ContentObserver extends boolean> = ContentObserve

export type DOMObserver<ContentObserver extends boolean> = [
construct: () => () => void,
update: () => void | false | Parameters<DOMObserverCallback<ContentObserver>>
update: () => void | false | Parameters<DOMObserverCallback<ContentObserver>>,
];

type EventContentChangeUpdateElement = (
Expand Down
8 changes: 4 additions & 4 deletions packages/overlayscrollbars/src/observers/sizeObserver.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { SizeObserverPlugin } from '../plugins';
import {
createCache,
createDOM,
Expand All @@ -12,14 +13,13 @@ import {
noop,
domRectAppeared,
concat,
} from '~/support';
} from '../support';
import {
classNameSizeObserver,
classNameSizeObserverAppear,
classNameSizeObserverListener,
} from '~/classnames';
import { getStaticPluginModuleInstance, sizeObserverPluginName } from '~/plugins';
import type { SizeObserverPlugin } from '~/plugins';
} from '../classnames';
import { getStaticPluginModuleInstance, sizeObserverPluginName } from '../plugins';

export interface SizeObserverOptions {
/** Whether appearing should be observed. */
Expand Down
10 changes: 5 additions & 5 deletions packages/overlayscrollbars/src/observers/trinsicObserver.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import type { WH, CacheValues } from '../support';
import { createSizeObserver } from './sizeObserver';
import { classNameTrinsicObserver } from '../classnames';
import {
createDiv,
getOffsetSize,
Expand All @@ -7,15 +10,12 @@ import {
IntersectionObserverConstructor,
appendChildren,
bind,
} from '~/support';
import { createSizeObserver } from '~/observers/sizeObserver';
import { classNameTrinsicObserver } from '~/classnames';
import type { WH, CacheValues } from '~/support';
} from '../support';

export type TrinsicObserverCallback = (heightIntrinsic: CacheValues<boolean>) => any;
export type TrinsicObserver = [
construct: () => () => void,
update: () => void | false | null | undefined | Parameters<TrinsicObserverCallback>
update: () => void | false | null | undefined | Parameters<TrinsicObserverCallback>,
];

/**
Expand Down
46 changes: 24 additions & 22 deletions packages/overlayscrollbars/src/options.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { DeepPartial, DeepReadonly } from './typings';
import {
assignDeep,
each,
Expand All @@ -8,8 +9,7 @@ import {
isFunction,
isEmptyObject,
concat,
} from '~/support';
import type { DeepPartial, DeepReadonly } from '~/typings';
} from './support';

export type OptionsField = string;

Expand All @@ -36,36 +36,36 @@ type OptionsObjectFieldNameTuples<T> = T extends OptionsPrimitiveValue

type JoinOptionsObjectFieldTuples<
T extends OptionsField[],
IncompletePath extends boolean = false
IncompletePath extends boolean = false,
> = T extends [infer F]
? F
: T extends [infer F, ...infer R]
? F extends OptionsField
?
| (IncompletePath extends true ? F : never)
| `${F}.${JoinOptionsObjectFieldTuples<Extract<R, OptionsField[]>>}`
: never
: OptionsField;
? F extends OptionsField
?
| (IncompletePath extends true ? F : never)
| `${F}.${JoinOptionsObjectFieldTuples<Extract<R, OptionsField[]>>}`
: never
: OptionsField;

type SplitJoinedOptionsObjectFieldTuples<S extends string> = string extends S
? OptionsField[]
: S extends ''
? []
: S extends `${infer T}.${infer U}`
? [T, ...SplitJoinedOptionsObjectFieldTuples<U>]
: [S];
? []
: S extends `${infer T}.${infer U}`
? [T, ...SplitJoinedOptionsObjectFieldTuples<U>]
: [S];

type OptionsObjectFieldTuplesType<O, T extends OptionsField[]> = T extends [infer F]
? F extends keyof O
? O[F]
: never
: T extends [infer F, ...infer R]
? F extends keyof O
? O[F] extends OptionsPrimitiveValue
? O[F]
: OptionsObjectFieldTuplesType<O[F], Extract<R, OptionsField[]>>
: never
: never;
? F extends keyof O
? O[F] extends OptionsPrimitiveValue
? O[F]
: OptionsObjectFieldTuplesType<O[F], Extract<R, OptionsField[]>>
: never
: never;

type OptionsObjectFieldPath<O extends OptionsObject> = JoinOptionsObjectFieldTuples<
OptionsObjectFieldNameTuples<O>,
Expand All @@ -74,7 +74,7 @@ type OptionsObjectFieldPath<O extends OptionsObject> = JoinOptionsObjectFieldTup

type OptionsObjectFieldPathType<
O extends OptionsObject,
P extends string
P extends string,
> = OptionsObjectFieldTuplesType<O, SplitJoinedOptionsObjectFieldTuples<P>>;

const opsStringify = (value: any) =>
Expand Down Expand Up @@ -289,5 +289,7 @@ export const createOptionCheck =
changedOptions: DeepPartial<T>,
force?: boolean
): OptionsCheckFn<T> =>
(path) =>
[getPropByPath(options, path), force || getPropByPath(changedOptions, path) !== undefined];
(path) => [
getPropByPath(options, path),
force || getPropByPath(changedOptions, path) !== undefined,
];
Loading

0 comments on commit b11536b

Please sign in to comment.