Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/mono-dev
2 changes: 1 addition & 1 deletion packages/pure-i18next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pistonite/pure-i18next",
"version": "0.4.5",
"version": "0.4.6",
"type": "module",
"description": "I18next binding for pure library",
"homepage": "https://github.com/Pistonite/pure",
Expand Down
21 changes: 9 additions & 12 deletions packages/pure-i18next/src/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { BackendModule } from "i18next";
import { convertToSupportedLocale } from "@pistonite/pure/pref";

import type { LoadLanguageFn } from "./types.ts";
import { log } from "./util.ts";

/** Create an i18next backend module given the loader functions */
export const createBackend = (
Expand All @@ -27,9 +28,7 @@ export const createBackend = (
if (namespace !== "translation" || !hasNonDefaultNamespace) {
// only log an error if the namespace is not the default
// if there are non-default namespaces
console.error(
`[pure-i18next] no loader found for namespace ${namespace}`,
);
log.error(`no loader found for namespace ${namespace}`);
}
return undefined;
}
Expand All @@ -39,27 +38,25 @@ export const createBackend = (
return strings;
}
} catch (e) {
console.error(e);
log.error(e);
}
if (locale === fallbackLocale) {
console.warn(
`[pure-i18next] failed to load ${namespace} for ${locale}`,
);
log.warn(`failed to load ${namespace} for ${locale}`);
return undefined;
}
console.warn(
`[pure-i18next] failed to load ${namespace} for ${locale}, falling back to ${fallbackLocale}`,
log.warn(
`failed to load ${namespace} for ${locale}, falling back to ${fallbackLocale}`,
);
try {
const strings = await loader(fallbackLocale);
if (strings) {
return strings;
}
} catch (e) {
console.error(e);
log.error(e);
}
console.warn(
`[pure-i18next] failed to load ${namespace} for fallback locale ${fallbackLocale}`,
log.warn(
`failed to load ${namespace} for fallback locale ${fallbackLocale}`,
);
return undefined;
},
Expand Down
3 changes: 3 additions & 0 deletions packages/pure-i18next/src/util.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { logger } from "@pistonite/pure/log";

export const log = logger("pure-i18next", "gray").default();
2 changes: 1 addition & 1 deletion packages/pure-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pistonite/pure-react",
"version": "0.7.10",
"version": "0.7.11",
"type": "module",
"description": "React binding for pure library",
"homepage": "https://github.com/Pistonite/pure",
Expand Down
2 changes: 1 addition & 1 deletion packages/pure/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pistonite/pure",
"version": "0.26.5",
"version": "0.26.6",
"type": "module",
"description": "Pure TypeScript libraries for my projects",
"homepage": "https://github.com/Pistonite/pure",
Expand Down
5 changes: 3 additions & 2 deletions packages/pure/src/fs/FsFileStandaloneImplFileAPI.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ilog } from "../log/internal.ts";
import { errstr } from "../result";

import { fsErr, FsErr, fsFail, type FsVoid, type FsResult } from "./FsError.ts";
Expand Down Expand Up @@ -29,7 +30,7 @@ export class FsFileStandaloneImplFileAPI implements FsFileStandalone {
const data = await this.file.arrayBuffer();
return { val: new Uint8Array(data) };
} catch (e) {
console.error(e);
ilog.error(e);
return { err: fsFail(errstr(e)) };
}
}
Expand All @@ -41,7 +42,7 @@ export class FsFileStandaloneImplFileAPI implements FsFileStandalone {
const data = await this.file.text();
return { val: data };
} catch (e) {
console.error(e);
ilog.error(e);
return { err: fsFail(errstr(e)) };
}
}
Expand Down
11 changes: 6 additions & 5 deletions packages/pure/src/fs/FsFileStandaloneImplHandleAPI.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ilog } from "../log/internal.ts";
import { errstr } from "../result";

import { fsErr, FsErr, fsFail, type FsVoid, type FsResult } from "./FsError.ts";
Expand Down Expand Up @@ -39,7 +40,7 @@ export class FsFileStandaloneImplHandleAPI implements FsFileStandalone {
});
return requestedPermission === "granted";
} catch (e) {
console.error(e);
ilog.error(e);
return false;
}
}
Expand All @@ -58,7 +59,7 @@ export class FsFileStandaloneImplHandleAPI implements FsFileStandalone {
return { err: fsErr(FsErr.NotFound, "File not found") };
}
}
console.error(e);
ilog.error(e);
return { err: fsFail(errstr(e)) };
}
}
Expand All @@ -79,7 +80,7 @@ export class FsFileStandaloneImplHandleAPI implements FsFileStandalone {
const data = await file.val.arrayBuffer();
return { val: new Uint8Array(data) };
} catch (e) {
console.error(e);
ilog.error(e);
return { err: fsFail(errstr(e)) };
}
}
Expand All @@ -99,7 +100,7 @@ export class FsFileStandaloneImplHandleAPI implements FsFileStandalone {
const data = await file.val.text();
return { val: data };
} catch (e) {
console.error(e);
ilog.error(e);
return { err: fsFail(errstr(e)) };
}
}
Expand Down Expand Up @@ -145,7 +146,7 @@ export class FsFileStandaloneImplHandleAPI implements FsFileStandalone {
};
}
}
console.error(e);
ilog.error(e);
return { err: fsFail(errstr(e)) };
}
}
Expand Down
5 changes: 1 addition & 4 deletions packages/pure/src/fs/FsImplEntryAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ export class FsImplEntryAPI
constructor(root: string, rootEntry: FileSystemDirectoryEntry) {
this.root = root;
this.rootEntry = rootEntry;
this.capabilities = {
write: false,
live: true,
};
this.capabilities = { write: false, live: true };
this.mgr = new FsFileMgr();
}

Expand Down
9 changes: 4 additions & 5 deletions packages/pure/src/fs/FsImplFileAPI.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { ilog } from "../log/internal.ts";

import type { FsFile } from "./FsFile.ts";
import type {
FsFileSystem,
Expand Down Expand Up @@ -28,10 +30,7 @@ export class FsImplFileAPI
constructor(files: FileList) {
// this seems to also work for windows
this.root = files[0].webkitRelativePath.split("/", 1)[0];
this.capabilities = {
write: false,
live: false,
};
this.capabilities = { write: false, live: false };
this.files = {};
this.directories = {};
this.mgr = new FsFileMgr();
Expand All @@ -43,7 +42,7 @@ export class FsImplFileAPI
const normalized = fsNormalize(path);
if (normalized.err) {
// shouldn't happen since the path is from the File API
console.error("Invalid path: " + path);
ilog.error("invalid path: " + path);
continue;
}
this.files[normalized.val] = file;
Expand Down
5 changes: 1 addition & 4 deletions packages/pure/src/fs/FsImplHandleAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ export class FsImplHandleAPI
this.rootHandle = rootHandle;
this.writeMode = write;
this.permissionStatus = "prompt";
this.capabilities = {
write,
live: true,
};
this.capabilities = { write, live: true };
this.mgr = new FsFileMgr();
}

Expand Down
5 changes: 1 addition & 4 deletions packages/pure/src/fs/FsOpenFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,7 @@ const fsOpenFileWithFileSystemAccessAPI = async (
if (anyMimeType.length) {
convertedAccept["*/*"] = anyMimeType;
}
return {
description,
accept: convertedAccept,
};
return { description, accept: convertedAccept };
});
try {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
8 changes: 4 additions & 4 deletions packages/pure/src/fs/FsSave.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { ilog } from "../log/internal.ts";

import { fsFail, type FsVoid } from "./FsError.ts";

/** Save (download) a file using Blob */
Expand All @@ -11,7 +13,7 @@ export function fsSave(content: string | Uint8Array, filename: string): FsVoid {
saveAs(blob, filename);
return {};
} catch (e) {
console.error(e);
ilog.error(e);
return { err: fsFail("save failed") };
}
}
Expand All @@ -35,9 +37,7 @@ type SaveAsFn = (
filename?: string,
options?: SaveAsFnOptions,
) => void;
type SaveAsFnOptions = {
autoBom: boolean;
};
type SaveAsFnOptions = { autoBom: boolean };

/* eslint-disable @typescript-eslint/no-explicit-any */

Expand Down
Loading