Skip to content

Commit

Permalink
Move to native TS support in Node.js (#237)
Browse files Browse the repository at this point in the history
* Move to native TS support in Node.js

* Clean up output by hiding TS experimental warning

* Add docs for script
  • Loading branch information
ai authored Aug 9, 2024
1 parent 3020dcd commit d53709f
Show file tree
Hide file tree
Showing 109 changed files with 306 additions and 337 deletions.
4 changes: 2 additions & 2 deletions core/busy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { atom, computed } from 'nanostores'

import { onEnvironment } from './environment.js'
import { hasFeeds } from './feed.js'
import { onEnvironment } from './environment.ts'
import { hasFeeds } from './feed.ts'

const $tasks = atom(0)

Expand Down
6 changes: 3 additions & 3 deletions core/category.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
} from '@logux/client'
import { nanoid } from 'nanoid'

import { getClient } from './client.js'
import type { FeedValue } from './feed.js'
import { commonMessages as common } from './messages/index.js'
import { getClient } from './client.ts'
import type { FeedValue } from './feed.ts'
import { commonMessages as common } from './messages/index.ts'

export type CategoryValue = {
id: string
Expand Down
8 changes: 4 additions & 4 deletions core/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { TestPair, TestTime } from '@logux/core'
import { SUBPROTOCOL } from '@slowreader/api'
import { atom } from 'nanostores'

import { onEnvironment } from './environment.js'
import { SlowReaderError } from './error.js'
import { computeFrom, readonlyExport } from './lib/stores.js'
import { userId } from './settings.js'
import { onEnvironment } from './environment.ts'
import { SlowReaderError } from './error.ts'
import { computeFrom, readonlyExport } from './lib/stores.ts'
import { userId } from './settings.ts'

let testTime: TestTime | undefined

Expand Down
10 changes: 5 additions & 5 deletions core/devtools.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { busyDuring } from './busy.js'
import { createDownloadTask } from './download.js'
import { getFeedLatestPosts, loadFeeds } from './feed.js'
import { loadFilters, prepareFilters } from './filter.js'
import { addPost, deletePost, loadPosts, processOriginPost } from './post.js'
import { busyDuring } from './busy.ts'
import { createDownloadTask } from './download.ts'
import { getFeedLatestPosts, loadFeeds } from './feed.ts'
import { loadFilters, prepareFilters } from './filter.ts'
import { addPost, deletePost, loadPosts, processOriginPost } from './post.ts'

export async function fillFeedsWithPosts(): Promise<void> {
await busyDuring(async () => {
Expand Down
4 changes: 2 additions & 2 deletions core/download.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { warning } from './devtools.js'
import { request } from './request.js'
import { warning } from './devtools.ts'
import { request } from './request.ts'

export interface TextResponse {
readonly contentType: string
Expand Down
4 changes: 2 additions & 2 deletions core/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
} from '@nanostores/persistent'
import { atom, type ReadableAtom, type StoreValue } from 'nanostores'

import { SlowReaderError } from './error.js'
import type { BaseRoute, BaseRouter, Route, Routes } from './router.js'
import { SlowReaderError } from './error.ts'
import type { BaseRoute, BaseRouter, Route, Routes } from './router.ts'

interface LogStoreCreator {
(): ClientOptions['store']
Expand Down
8 changes: 4 additions & 4 deletions core/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import {
feedsByCategory,
getCategories,
getCategoryTitle
} from './category.js'
import { type FeedValue, getFeeds } from './feed.js'
import { readonlyExport } from './lib/stores.js'
import { getPosts, type PostValue } from './post.js'
} from './category.ts'
import { type FeedValue, getFeeds } from './feed.ts'
import { readonlyExport } from './lib/stores.ts'
import { getPosts, type PostValue } from './post.ts'

type FeedWithPosts = {
posts?: PostValue[]
Expand Down
18 changes: 9 additions & 9 deletions core/fast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import {
type CategoryValue,
GENERAL_CATEGORY,
loadCategories
} from './category.js'
import { client } from './client.js'
import { onEnvironment } from './environment.js'
import { BROKEN_FEED, type FeedValue, loadFeed, loadFeeds } from './feed.js'
import { loadFilters } from './filter.js'
import { listenMany, readonlyExport } from './lib/stores.js'
import { deletePost, getPost, loadPosts } from './post.js'
import type { PostValue } from './post.js'
import { type Route, router } from './router.js'
} from './category.ts'
import { client } from './client.ts'
import { onEnvironment } from './environment.ts'
import { BROKEN_FEED, type FeedValue, loadFeed, loadFeeds } from './feed.ts'
import { loadFilters } from './filter.ts'
import { listenMany, readonlyExport } from './lib/stores.ts'
import { deletePost, getPost, loadPosts } from './post.ts'
import type { PostValue } from './post.ts'
import { type Route, router } from './router.ts'

function notEmpty<Value>(array: Value[]): array is [Value, ...Value[]] {
return array.length > 0
Expand Down
12 changes: 6 additions & 6 deletions core/feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import {
import { nanoid } from 'nanoid'
import { atom, onMount } from 'nanostores'

import { client, getClient } from './client.js'
import { createDownloadTask } from './download.js'
import { type OptionalId, readonlyExport } from './lib/stores.js'
import { type LoaderName, loaders } from './loader/index.js'
import { deletePost, loadPosts, recalcPostsReading } from './post.js'
import type { PostsPage } from './posts-page.js'
import { client, getClient } from './client.ts'
import { createDownloadTask } from './download.ts'
import { type OptionalId, readonlyExport } from './lib/stores.ts'
import { type LoaderName, loaders } from './loader/index.ts'
import { deletePost, loadPosts, recalcPostsReading } from './post.ts'
import type { PostsPage } from './posts-page.ts'

export type FeedValue = {
categoryId: string
Expand Down
6 changes: 3 additions & 3 deletions core/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import {
} from '@logux/client'
import { nanoid } from 'nanoid'

import { getClient } from './client.js'
import type { FeedValue } from './feed.js'
import { type OriginPost, recalcPostsReading } from './post.js'
import { getClient } from './client.ts'
import type { FeedValue } from './feed.ts'
import { type OriginPost, recalcPostsReading } from './post.ts'

const QUERY_REGEXP = /^(not\s+)?([\w]+)(?:\(([^]+)\))?$/

Expand Down
2 changes: 1 addition & 1 deletion core/i18n.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createI18n, type TranslationLoader } from '@nanostores/i18n'
import { atom } from 'nanostores'

import { onEnvironment } from './environment.js'
import { onEnvironment } from './environment.ts'

let $locale = atom('en')

Expand Down
10 changes: 5 additions & 5 deletions core/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import {
addCategory,
type CategoryValue,
type FeedsByCategory
} from './category.js'
import { addFeed, type FeedValue } from './feed.js'
import { readonlyExport } from './lib/stores.js'
import { importMessages } from './messages/index.js'
import { createFeedFromUrl } from './preview.js'
} from './category.ts'
import { addFeed, type FeedValue } from './feed.ts'
import { readonlyExport } from './lib/stores.ts'
import { importMessages } from './messages/index.ts'
import { createFeedFromUrl } from './preview.ts'

let $importedFeedsByCategory = atom<FeedsByCategory>([])
let $importedCategories = atom<string[]>([])
Expand Down
54 changes: 27 additions & 27 deletions core/index.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
export * from './busy.js'
export * from './category.js'
export * from './client.js'
export * from './devtools.js'
export * from './download.js'
export * from './environment.js'
export * from './error.js'
export * from './export.js'
export * from './fast.js'
export * from './feed.js'
export * from './filter.js'
export * from './filter.js'
export * from './html.js'
export * from './i18n.js'
export * from './import.js'
export * from './loader/index.js'
export * from './messages/index.js'
export * from './not-found.js'
export * from './post.js'
export * from './posts-page.js'
export * from './preview.js'
export * from './refresh.js'
export * from './request.js'
export * from './router.js'
export * from './settings.js'
export * from './slow.js'
export * from './two-steps.js'
export * from './busy.ts'
export * from './category.ts'
export * from './client.ts'
export * from './devtools.ts'
export * from './download.ts'
export * from './environment.ts'
export * from './error.ts'
export * from './export.ts'
export * from './fast.ts'
export * from './feed.ts'
export * from './filter.ts'
export * from './filter.ts'
export * from './html.ts'
export * from './i18n.ts'
export * from './import.ts'
export * from './loader/index.ts'
export * from './messages/index.ts'
export * from './not-found.ts'
export * from './post.ts'
export * from './posts-page.ts'
export * from './preview.ts'
export * from './refresh.ts'
export * from './request.ts'
export * from './router.ts'
export * from './settings.ts'
export * from './slow.ts'
export * from './two-steps.ts'
10 changes: 5 additions & 5 deletions core/loader/atom.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type { TextResponse } from '../download.js'
import type { OriginPost } from '../post.js'
import { createPostsPage } from '../posts-page.js'
import type { Loader } from './index.js'
import type { TextResponse } from '../download.ts'
import type { OriginPost } from '../post.ts'
import { createPostsPage } from '../posts-page.ts'
import type { Loader } from './index.ts'
import {
findAnchorHrefs,
findImageByAttr,
findLinksByType,
isHTML,
toTime
} from './utils.js'
} from './utils.ts'

function parsePosts(text: TextResponse): OriginPost[] {
let document = text.parseXml()
Expand Down
10 changes: 5 additions & 5 deletions core/loader/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { DownloadTask, TextResponse } from '../download.js'
import type { PostsPage } from '../posts-page.js'
import { atom } from './atom.js'
import { jsonFeed } from './json-feed.js'
import { rss } from './rss.js'
import type { DownloadTask, TextResponse } from '../download.ts'
import type { PostsPage } from '../posts-page.ts'
import { atom } from './atom.ts'
import { jsonFeed } from './json-feed.ts'
import { rss } from './rss.ts'

export type Loader = {
getMineLinksFromText(response: TextResponse): string[]
Expand Down
12 changes: 6 additions & 6 deletions core/loader/json-feed.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { warning } from '../devtools.js'
import type { TextResponse } from '../download.js'
import type { OriginPost } from '../post.js'
import { createPostsPage } from '../posts-page.js'
import type { Loader } from './index.js'
import { warning } from '../devtools.ts'
import type { TextResponse } from '../download.ts'
import type { OriginPost } from '../post.ts'
import { createPostsPage } from '../posts-page.ts'
import type { Loader } from './index.ts'
import {
findAnchorHrefs,
findLinksByType,
isHTML,
toTime,
unique
} from './utils.js'
} from './utils.ts'

// https://www.jsonfeed.org/version/1.1/
interface JsonFeed {
Expand Down
10 changes: 5 additions & 5 deletions core/loader/rss.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import type { TextResponse } from '../download.js'
import type { OriginPost } from '../post.js'
import { createPostsPage } from '../posts-page.js'
import type { Loader } from './index.js'
import type { TextResponse } from '../download.ts'
import type { OriginPost } from '../post.ts'
import { createPostsPage } from '../posts-page.ts'
import type { Loader } from './index.ts'
import {
findAnchorHrefs,
findImageByAttr,
findLinksByType,
isHTML,
toTime,
unique
} from './utils.js'
} from './utils.ts'

const MEDIA_NS_URI = 'http://search.yahoo.com/mrss/'

Expand Down
2 changes: 1 addition & 1 deletion core/loader/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { TextResponse } from '../download.js'
import type { TextResponse } from '../download.ts'

export function isString(attr: null | string): attr is string {
return typeof attr === 'string' && attr.length > 0
Expand Down
2 changes: 1 addition & 1 deletion core/messages/common/en.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { i18n } from '../../i18n.js'
import { i18n } from '../../i18n.ts'

export const commonMessages = i18n('common', {
brokenCategory: 'Broken category',
Expand Down
2 changes: 1 addition & 1 deletion core/messages/export/en.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { i18n } from '../../i18n.js'
import { i18n } from '../../i18n.ts'

export const exportMessages = i18n('export', {
allFeeds: 'All feeds',
Expand Down
2 changes: 1 addition & 1 deletion core/messages/fast/en.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { i18n } from '../../i18n.js'
import { i18n } from '../../i18n.ts'

export const fastMessages = i18n('fast', {
noPosts: 'No posts',
Expand Down
2 changes: 1 addition & 1 deletion core/messages/import/en.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { i18n } from '../../i18n.js'
import { i18n } from '../../i18n.ts'

export const importMessages = i18n('import', {
allFeeds: 'All feeds',
Expand Down
22 changes: 11 additions & 11 deletions core/messages/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export * from './common/en.js'
export * from './export/en.js'
export * from './fast/en.js'
export * from './import/en.js'
export * from './navbar/en.js'
export * from './organize/en.js'
export * from './preview/en.js'
export * from './refresh/en.js'
export * from './settings/en.js'
export * from './slow/en.js'
export * from './start/en.js'
export * from './common/en.ts'
export * from './export/en.ts'
export * from './fast/en.ts'
export * from './import/en.ts'
export * from './navbar/en.ts'
export * from './organize/en.ts'
export * from './preview/en.ts'
export * from './refresh/en.ts'
export * from './settings/en.ts'
export * from './slow/en.ts'
export * from './start/en.ts'
2 changes: 1 addition & 1 deletion core/messages/navbar/en.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { i18n } from '../../i18n.js'
import { i18n } from '../../i18n.ts'

export const navbarMessages = i18n('navbar', {
about: 'About the App',
Expand Down
2 changes: 1 addition & 1 deletion core/messages/organize/en.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { i18n } from '../../i18n.js'
import { i18n } from '../../i18n.ts'

export const organizeMessages = i18n('organize', {
addCategory: 'Add category…',
Expand Down
2 changes: 1 addition & 1 deletion core/messages/preview/en.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { i18n } from '../../i18n.js'
import { i18n } from '../../i18n.ts'

export const previewMessages = i18n('preview', {
add: 'Subscribe to feed',
Expand Down
2 changes: 1 addition & 1 deletion core/messages/refresh/en.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { i18n } from '../../i18n.js'
import { i18n } from '../../i18n.ts'

export const refreshMessages = i18n('refresh', {
stop: 'Stop'
Expand Down
2 changes: 1 addition & 1 deletion core/messages/settings/en.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { i18n } from '../../i18n.js'
import { i18n } from '../../i18n.ts'

export const settingsMessages = i18n('settings', {
about: 'About the App',
Expand Down
2 changes: 1 addition & 1 deletion core/messages/slow/en.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { i18n } from '../../i18n.js'
import { i18n } from '../../i18n.ts'

export const slowMessages = i18n('slow', {
noPosts: 'No posts',
Expand Down
2 changes: 1 addition & 1 deletion core/messages/start/en.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { i18n } from '../../i18n.js'
import { i18n } from '../../i18n.ts'

export const startMessages = i18n('start', {
localButton: 'Start local demo',
Expand Down
Loading

0 comments on commit d53709f

Please sign in to comment.