Skip to content

Commit

Permalink
refactor: inline export/import type (#670)
Browse files Browse the repository at this point in the history
  • Loading branch information
alimd authored Jan 17, 2023
2 parents eb1b0fd + b83a25a commit 9dd3c56
Show file tree
Hide file tree
Showing 34 changed files with 63 additions and 88 deletions.
2 changes: 1 addition & 1 deletion core/fetch/src/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {
AlwatrServiceResponseSuccess,
} from '@alwatr/type';

export {
export type {
FetchOptions,
CacheDuplicate,
CacheStrategy,
Expand Down
2 changes: 1 addition & 1 deletion core/i18n/src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {SignalInterface} from '@alwatr/signal';

import type {I18nConfig, L10Resource, Locale} from './type.js';

export * from './type.js';
export type {I18nConfig, L10Resource, Locale} from './type.js';

const logger = createLogger('alwatr/i18n');

Expand Down
2 changes: 1 addition & 1 deletion core/i18n/src/type.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {L10Resource, Locale} from '@alwatr/type';

export {L10Resource, Locale};
export type {L10Resource, Locale};

declare global {
interface AlwatrSignals {
Expand Down
2 changes: 1 addition & 1 deletion core/logger/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {globalAlwatr} from './global-alwatr.js';

import type {AlwatrLogger} from './type.js';

export {AlwatrLogger, globalAlwatr};
export {type AlwatrLogger, globalAlwatr};

const isBrowser = typeof process === 'undefined';

Expand Down
4 changes: 2 additions & 2 deletions core/math/src/math.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {globalAlwatr} from '@alwatr/logger';

import {TransformRangeOptions} from './type.js';
export * from './unicode-digits.js';
import type {TransformRangeOptions} from './type.js';
export {UnicodeDigits, type UnicodeLangKeys} from './unicode-digits.js';

globalAlwatr.registeredList.push({
name: '@alwatr/math',
Expand Down
3 changes: 1 addition & 2 deletions core/nano-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ Elegant powerful nodejs server for nanoservice use cases, written in tiny TypeSc
## Example usage

```ts
import {AlwatrNanoServer} from 'https://esm.run/@alwatr/nano-server';
import type {AlwatrConnection} from 'https://esm.run/@alwatr/nano-server';
import {type AlwatrConnection, AlwatrNanoServer} from 'https://esm.run/@alwatr/nano-server';

const nanoServer = new AlwatrNanoServer();

Expand Down
2 changes: 1 addition & 1 deletion core/nano-server/src/nano-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type RouteMiddleware<TData = Record<string, unknown>, TMeta = Record<stri
connection: AlwatrConnection
) => MaybePromise<AlwatrServiceResponse<TData, TMeta> | null>;

export {
export type {
NanoServerConfig,
ConnectionConfig,
AlwatrServiceResponse,
Expand Down
5 changes: 2 additions & 3 deletions core/router/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import {routeChangeSignal} from './signal.js';
import {clickTrigger} from './trigger-click.js';
import {popstateTrigger} from './trigger-popstate.js';

import type {InitOptions, Route, RoutesConfig} from './type.js';
import type {InitOptions, Route, RoutesConfig, RequestRouteParam} from './type.js';
import type {SignalInterface} from '@alwatr/signal';

export {routeChangeSignal};
export type {Route, RequestRouteParam, RoutesConfig} from './type.js';
export {type Route, type RequestRouteParam, type RoutesConfig, routeChangeSignal};

/**
* Initial and config the Router.
Expand Down
3 changes: 1 addition & 2 deletions core/storage-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ Elegant micro client for storage server written in tiny TypeScript ES module.
## Example usage

```ts
import {AlwatrStorageClient} from '@alwatr/storage-client';
import type {AlwatrDocumentObject} from '@alwatr/storage-client';
import {type AlwatrDocumentObject, AlwatrStorageClient} from '@alwatr/storage-client';

type User = AlwatrDocumentObject & {
email: string;
Expand Down
8 changes: 3 additions & 5 deletions core/storage-client/src/storage-client.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import {serviceRequest} from '@alwatr/fetch';
import {type FetchOptions, serviceRequest} from '@alwatr/fetch';
import {createLogger, globalAlwatr} from '@alwatr/logger';

import type {AlwatrStorageClientConfig} from './type.js';
import type {FetchOptions} from '@alwatr/fetch';
import type {AlwatrDocumentObject, AlwatrDocumentStorage} from '@alwatr/type';

export {AlwatrStorageClientConfig};
export {type AlwatrStorageClientConfig};

globalAlwatr.registeredList.push({
name: '@alwatr/storage-client',
Expand All @@ -18,8 +17,7 @@ globalAlwatr.registeredList.push({
* Example:
*
* ```ts
* import {AlwatrStorageClient} from '@alwatr/storage-client';
* import type {AlwatrDocumentObject } from '@alwatr/storage-client';
* import {type AlwatrDocumentObject, AlwatrStorageClient} from '@alwatr/storage-client';
*
* interface User extends AlwatrDocumentObject {
* fname: string;
Expand Down
4 changes: 1 addition & 3 deletions core/storage-engine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ Elegant micro in-memory json-like storage with disk backed, Fastest NoSQL Databa
## Example usage

```ts
import {AlwatrStorageEngine} from '@alwatr/storage-engine';

import type {AlwatrDocumentObject} from '@alwatr/storage-engine';
import {type AlwatrDocumentObject, AlwatrStorageEngine} from '@alwatr/storage-engine';

type User = AlwatrDocumentObject & {
fname: string;
Expand Down
11 changes: 5 additions & 6 deletions core/storage-engine/src/storage-engine.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import {resolve} from 'node:path';

import {createLogger, globalAlwatr, type AlwatrLogger} from '@alwatr/logger';
import {type AlwatrDocumentStorage, type AlwatrDocumentObject} from '@alwatr/type';
import exitHook from 'exit-hook';

import {type AlwatrStorageEngineConfig} from './type.js';
import {readJsonFile, writeJsonFile} from './util.js';

export {type AlwatrDocumentObject, type AlwatrDocumentStorage};
import type {AlwatrStorageEngineConfig} from './type.js';
import type {AlwatrDocumentStorage, AlwatrDocumentObject} from '@alwatr/type';

export type {AlwatrDocumentObject, AlwatrDocumentStorage};

globalAlwatr.registeredList.push({
name: '@alwatr/storage-engine',
Expand All @@ -21,9 +22,7 @@ globalAlwatr.registeredList.push({
* Example:
*
* ```ts
* import {AlwatrStorageEngine} from '@alwatr/storage-engine';
*
* import type {AlwatrDocumentObject} from '@alwatr/storage-engine';
* import {type AlwatrDocumentObject, AlwatrStorageEngine} from '@alwatr/storage-engine';
*
* interface User extends AlwatrDocumentObject {
* fname: string;
Expand Down
4 changes: 1 addition & 3 deletions core/token/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ Secure authentication HOTP token generator (HMAC-based One-Time Password algorit

```ts
import {createLogger} from '@alwatr/logger';
import {AlwatrTokenGenerator} from '@alwatr/token';

import type {TokenStatus} from '@alwatr/token';
import {type TokenStatus, AlwatrTokenGenerator} from '@alwatr/token';

type User = {
id: string;
Expand Down
4 changes: 2 additions & 2 deletions core/token/src/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import {createHmac} from 'node:crypto';
import {createLogger, globalAlwatr} from '@alwatr/logger';
import {parseDuration} from '@alwatr/math';

import type {TokenGeneratorConfig, TokenStatus} from './type.js';
import type {TokenGeneratorConfig, TokenStatus, DigestAlgorithm} from './type.js';

export * from './type.js';
export type {TokenGeneratorConfig, TokenStatus, DigestAlgorithm};

globalAlwatr.registeredList.push({
name: '@alwatr/token',
Expand Down
2 changes: 1 addition & 1 deletion core/validator/src/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {isNumber} from '@alwatr/math';

import type {JsonSchema, ValidType} from './type.js';

export {JsonSchema};
export type {JsonSchema};

export function validator<T extends ValidType>(
validSchema: JsonSchema,
Expand Down
4 changes: 1 addition & 3 deletions demo/fetch/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import {fetch} from '@alwatr/fetch';

import type {CacheStrategy, CacheDuplicate} from '@alwatr/fetch';
import {type CacheStrategy, type CacheDuplicate, fetch} from '@alwatr/fetch';

const buttons = document.querySelectorAll('button') as NodeListOf<HTMLButtonElement>;

Expand Down
4 changes: 1 addition & 3 deletions demo/token/benchmark.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {AlwatrTokenGenerator} from '@alwatr/token';

import type {DigestAlgorithm} from '@alwatr/token';
import {type DigestAlgorithm, AlwatrTokenGenerator} from '@alwatr/token';

if (process.env.NODE_ENV !== 'production') {
console.log('Please run node in production for benchmark. NODE_ENV=production node demo/token/benchmark.js');
Expand Down
4 changes: 1 addition & 3 deletions demo/token/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import {createLogger} from '@alwatr/logger';
import {AlwatrTokenGenerator} from '@alwatr/token';

import type {TokenStatus} from '@alwatr/token';
import {type TokenStatus, AlwatrTokenGenerator} from '@alwatr/token';

const logger = createLogger('token/demo');

Expand Down
3 changes: 1 addition & 2 deletions services/flight-crawler/src/crawl.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import {fetch} from '@alwatr/fetch';
import {type FetchOptions, fetch} from '@alwatr/fetch';

import {config, logger} from './config.js';
import {cityList} from './lib/city-list.js';
import {storageClient} from './lib/storage.js';

import type {SepehrResponse} from './lib/type.js';
import type {FetchOptions} from '@alwatr/fetch';
import type {Job, JobDetail, JobResult} from '@alwatr/type/flight-finder.js';

export async function crawlAllJobs(): Promise<void> {
Expand Down
4 changes: 2 additions & 2 deletions ui/demo-pwa/src/pwa-root.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {AlwatrRootElement, html, customElement} from '@alwatr/element';

import type {RoutesConfig} from '@alwatr/router';

import './page-chat.js';
import './page-card.js';

import type {RoutesConfig} from '@alwatr/router';

declare global {
interface HTMLElementTagNameMap {
'alwatr-pwa-root': AlwatrPwaRoot;
Expand Down
3 changes: 1 addition & 2 deletions ui/element/src/mixins/logging.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {createLogger} from '@alwatr/logger';
import {type AlwatrLogger, createLogger} from '@alwatr/logger';

import type {AlwatrLogger} from '@alwatr/logger/type.js';
import type {Constructor} from '@alwatr/type';
import type {LitElement, PropertyValues} from 'lit';

Expand Down
7 changes: 2 additions & 5 deletions ui/element/src/root-element.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import {l10n} from '@alwatr/i18n';
import {router} from '@alwatr/router';
import {html, css} from 'lit';
import {type RoutesConfig, router} from '@alwatr/router';
import {type CSSResultGroup, html, css} from 'lit';
import {cache} from 'lit/directives/cache.js';

import {AlwatrSmartElement} from './smart-element.js';

import type {RoutesConfig} from '@alwatr/router';
import type {CSSResultGroup} from 'lit';

/**
* Alwatr Root Base Element
*
Expand Down
4 changes: 1 addition & 3 deletions ui/element/src/surface-element.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import {css} from 'lit';
import {type CSSResultGroup, css} from 'lit';

import {AlwatrDummyElement} from './dummy-element.js';

import type {CSSResultGroup} from 'lit';

/**
* Alwatr Surface Base Element
*
Expand Down
4 changes: 2 additions & 2 deletions ui/icon/src/icon.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import {
type PropertyValues,
type HTMLTemplateResult,
AlwatrDummyElement,
unsafeSVG,
customElement,
Expand All @@ -11,8 +13,6 @@ import {
import {fetch} from '@alwatr/fetch';
import {globalAlwatr} from '@alwatr/logger';

import type {PropertyValues, HTMLTemplateResult} from '@alwatr/element';

globalAlwatr.registeredList.push({
name: '@alwatr/icon',
version: '{{ALWATR_VERSION}}',
Expand Down
4 changes: 1 addition & 3 deletions ui/ui-kit/src/card/card.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {AlwatrSurfaceElement, css, customElement, html} from '@alwatr/element';

import type {CSSResultGroup} from '@alwatr/element';
import {type CSSResultGroup, AlwatrSurfaceElement, css, customElement, html} from '@alwatr/element';

export type CardType = 'elevated' | 'filled' | 'outlined';

Expand Down
3 changes: 1 addition & 2 deletions ui/ui-kit/src/chat/chat-text-input.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import {AlwatrDummyElement, css, customElement, html, LocalizeMixin} from '@alwatr/element';
import {type PropertyValues, AlwatrDummyElement, css, customElement, html, LocalizeMixin} from '@alwatr/element';

import '../icon-button/standard-icon-button.js';

import type {AlwatrStandardIconButton} from '../icon-button/standard-icon-button.js';
import type {PropertyValues} from '@alwatr/element';

declare global {
interface HTMLElementTagNameMap {
Expand Down
4 changes: 2 additions & 2 deletions ui/ui-kit/src/chat/chat.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {customElement, AlwatrSmartElement, css, html} from '@alwatr/element';

import type {ChatStorage} from '@alwatr/type';

import './chat-footer.js';
import './chat-list.js';

import type {ChatStorage} from '@alwatr/type';

declare global {
interface HTMLElementTagNameMap {
'alwatr-chat': AlwatrChat;
Expand Down
4 changes: 1 addition & 3 deletions uniquely/flight-finder-pwa/src/alwatr-pwa.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import {AlwatrSmartElement, customElement, css, html} from '@alwatr/element';
import {l10n} from '@alwatr/i18n';
import {router} from '@alwatr/router';
import {type RoutesConfig, router} from '@alwatr/router';

import ionNormalize from './style/ionic.normalize.js';
import ionTheming from './style/ionic.theming.js';

import './component/page-flight-finder.js';
import './component/ionic-components.js';

import type {RoutesConfig} from '@alwatr/router';

declare global {
interface HTMLElementTagNameMap {
'alwatr-pwa': AlwatrPWA;
Expand Down
4 changes: 2 additions & 2 deletions uniquely/flight-finder-pwa/src/component/job-add-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import {cityList} from '../city-list.js';
import ionNormalize from '../style/ionic.normalize.js';
import ionTheming from '../style/ionic.theming.js';

import './ionic-components';

import type {NewJobDetail} from '../type.js';
import type {InputCustomEvent, SelectCustomEvent} from '@ionic/core';

import './ionic-components';

declare global {
interface HTMLElementTagNameMap {
'job-add-form': JobAddForm;
Expand Down
20 changes: 14 additions & 6 deletions uniquely/flight-finder-pwa/src/component/job-item.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
import {AlwatrSmartElement, customElement, property, query, when, css, html, nothing} from '@alwatr/element';
import {
type TemplateResult,
AlwatrSmartElement,
customElement,
property,
query,
when,
css,
html,
nothing,
} from '@alwatr/element';
import {l10n} from '@alwatr/i18n';
import {SignalInterface} from '@alwatr/signal';

import '@alwatr/icon';

import {cityList} from '../city-list.js';
import ionNormalize from '../style/ionic.normalize.js';
import ionTheming from '../style/ionic.theming.js';

import './ionic-components.js';

import type {TemplateResult} from '@alwatr/element';
import type {Job, JobResult} from '@alwatr/type/flight-finder.js';

import '@alwatr/icon';
import './ionic-components.js';

declare global {
interface HTMLElementTagNameMap {
'job-item': JobItem;
Expand Down
Loading

0 comments on commit 9dd3c56

Please sign in to comment.