1
0
mirror of https://github.com/robonen/tools.git synced 2026-03-20 02:44:45 +00:00

feat: update pnpm workspace and dependencies, migrate to tsdown for builds

This commit is contained in:
2026-02-14 03:49:10 +07:00
parent a9a6c04176
commit efadb5fe28
17 changed files with 2898 additions and 3957 deletions

View File

@@ -15,7 +15,7 @@
"url": "git+https://github.com/robonen/tools.git", "url": "git+https://github.com/robonen/tools.git",
"directory": "packages/tsconfig" "directory": "packages/tsconfig"
}, },
"packageManager": "pnpm@10.15.1", "packageManager": "pnpm@10.29.3",
"engines": { "engines": {
"node": ">=22.18.0" "node": ">=22.18.0"
}, },

View File

@@ -1,16 +0,0 @@
import { defineBuildConfig } from 'unbuild';
export default defineBuildConfig({
entries: [
'src/browsers',
'src/multi',
],
clean: true,
declaration: true,
rollup: {
emitCJS: true,
esbuild: {
// minify: true,
},
},
});

View File

@@ -18,7 +18,7 @@
"url": "git+https://github.com/robonen/tools.git", "url": "git+https://github.com/robonen/tools.git",
"directory": "packages/platform" "directory": "packages/platform"
}, },
"packageManager": "pnpm@10.15.1", "packageManager": "pnpm@10.29.3",
"engines": { "engines": {
"node": ">=22.18.0" "node": ">=22.18.0"
}, },
@@ -29,22 +29,22 @@
"exports": { "exports": {
"./browsers": { "./browsers": {
"types": "./dist/browsers.d.ts", "types": "./dist/browsers.d.ts",
"import": "./dist/browsers.mjs", "import": "./dist/browsers.js",
"require": "./dist/browsers.cjs" "require": "./dist/browsers.cjs"
}, },
"./multi": { "./multi": {
"types": "./dist/multi.d.ts", "types": "./dist/multi.d.ts",
"import": "./dist/multi.mjs", "import": "./dist/multi.js",
"require": "./dist/multi.cjs" "require": "./dist/multi.cjs"
} }
}, },
"scripts": { "scripts": {
"test": "vitest run", "test": "vitest run",
"dev": "vitest dev", "dev": "vitest dev",
"build": "unbuild" "build": "tsdown"
}, },
"devDependencies": { "devDependencies": {
"@robonen/tsconfig": "workspace:*", "@robonen/tsconfig": "workspace:*",
"unbuild": "catalog:" "tsdown": "catalog:"
} }
} }

View File

@@ -0,0 +1,12 @@
import { defineConfig } from 'tsdown';
export default defineConfig({
entry: {
browsers: 'src/browsers/index.ts',
multi: 'src/multi/index.ts',
},
format: ['esm', 'cjs'],
dts: true,
clean: true,
hash: false,
});

View File

@@ -1,9 +0,0 @@
import { defineBuildConfig } from 'unbuild';
export default defineBuildConfig({
rollup: {
esbuild: {
// minify: true,
},
},
});

View File

@@ -18,7 +18,7 @@
"url": "git+https://github.com/robonen/tools.git", "url": "git+https://github.com/robonen/tools.git",
"directory": "packages/stdlib" "directory": "packages/stdlib"
}, },
"packageManager": "pnpm@10.15.1", "packageManager": "pnpm@10.29.3",
"engines": { "engines": {
"node": ">=22.18.0" "node": ">=22.18.0"
}, },
@@ -29,18 +29,17 @@
"exports": { "exports": {
".": { ".": {
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",
"import": "./dist/index.mjs", "import": "./dist/index.js",
"require": "./dist/index.cjs" "require": "./dist/index.cjs"
} }
}, },
"scripts": { "scripts": {
"test": "vitest run", "test": "vitest run",
"dev": "vitest dev", "dev": "vitest dev",
"build": "unbuild" "build": "tsdown"
}, },
"devDependencies": { "devDependencies": {
"@robonen/tsconfig": "workspace:*", "@robonen/tsconfig": "workspace:*",
"pathe": "catalog:", "tsdown": "catalog:"
"unbuild": "catalog:"
} }
} }

View File

@@ -0,0 +1,9 @@
import { defineConfig } from 'tsdown';
export default defineConfig({
entry: ['src/index.ts'],
format: ['esm', 'cjs'],
dts: true,
clean: true,
hash: false,
});

View File

@@ -16,7 +16,7 @@
"url": "git+https://github.com/robonen/tools.git", "url": "git+https://github.com/robonen/tools.git",
"directory": "packages/renovate" "directory": "packages/renovate"
}, },
"packageManager": "pnpm@10.15.1", "packageManager": "pnpm@10.29.3",
"engines": { "engines": {
"node": ">=22.18.0" "node": ">=22.18.0"
}, },
@@ -27,6 +27,6 @@
"test": "renovate-config-validator ./default.json" "test": "renovate-config-validator ./default.json"
}, },
"devDependencies": { "devDependencies": {
"renovate": "^41.97.7" "renovate": "^43.12.0"
} }
} }

View File

@@ -15,17 +15,17 @@
"type": "git", "type": "git",
"url": "git+https://github.com/robonen/tools.git" "url": "git+https://github.com/robonen/tools.git"
}, },
"packageManager": "pnpm@10.15.1", "packageManager": "pnpm@10.29.3",
"engines": { "engines": {
"node": ">=22.18.0" "node": ">=22.18.0"
}, },
"type": "module", "type": "module",
"devDependencies": { "devDependencies": {
"@types/node": "^22.18.1", "@types/node": "^22.19.11",
"@vitest/coverage-v8": "catalog:", "@vitest/coverage-v8": "catalog:",
"@vitest/ui": "catalog:", "@vitest/ui": "catalog:",
"citty": "^0.1.6", "citty": "^0.2.1",
"jiti": "^2.5.1", "jiti": "^2.6.1",
"jsdom": "catalog:", "jsdom": "catalog:",
"scule": "^1.3.0", "scule": "^1.3.0",
"vitest": "catalog:" "vitest": "catalog:"

6668
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -3,13 +3,14 @@ packages:
- core/* - core/*
- infra/* - infra/*
- web/* - web/*
- docs
catalog: catalog:
'@vitest/coverage-v8': ^3.2.4 '@vitest/coverage-v8': ^4.0.18
'@vue/test-utils': ^2.4.6 '@vue/test-utils': ^2.4.6
jsdom: ^26.1.0 jsdom: ^28.0.0
pathe: ^2.0.3 tsdown: ^0.12.5
unbuild: 3.6.1 vitest: ^4.0.18
vitest: ^3.2.4 '@vitest/ui': ^4.0.18
'@vitest/ui': ^3.2.4 vue: ^3.5.28
vue: ^3.5.21 nuxt: ^4.3.1

View File

@@ -1,11 +0,0 @@
import { defineBuildConfig } from 'unbuild';
export default defineBuildConfig({
externals: ['vue'],
rollup: {
inlineDependencies: true,
esbuild: {
// minify: true,
},
},
});

View File

@@ -16,7 +16,7 @@
"url": "git+https://github.com/robonen/tools.git", "url": "git+https://github.com/robonen/tools.git",
"directory": "./packages/vue" "directory": "./packages/vue"
}, },
"packageManager": "pnpm@10.15.1", "packageManager": "pnpm@10.29.3",
"engines": { "engines": {
"node": ">=22.18.0" "node": ">=22.18.0"
}, },
@@ -27,19 +27,19 @@
"exports": { "exports": {
".": { ".": {
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",
"import": "./dist/index.mjs", "import": "./dist/index.js",
"require": "./dist/index.cjs" "require": "./dist/index.cjs"
} }
}, },
"scripts": { "scripts": {
"test": "vitest run", "test": "vitest run",
"dev": "vitest dev", "dev": "vitest dev",
"build": "unbuild" "build": "tsdown"
}, },
"devDependencies": { "devDependencies": {
"@robonen/tsconfig": "workspace:*", "@robonen/tsconfig": "workspace:*",
"@vue/test-utils": "catalog:", "@vue/test-utils": "catalog:",
"unbuild": "catalog:" "tsdown": "catalog:"
}, },
"dependencies": { "dependencies": {
"@robonen/platform": "workspace:*", "@robonen/platform": "workspace:*",

View File

@@ -1,6 +1,7 @@
export * from './tryOnBeforeMount'; export * from './tryOnBeforeMount';
export * from './tryOnMounted'; export * from './tryOnMounted';
export * from './tryOnScopeDispose'; export * from './tryOnScopeDispose';
export * from './unrefElement';
export * from './useAppSharedState'; export * from './useAppSharedState';
export * from './useAsyncState'; export * from './useAsyncState';
export * from './useCached'; export * from './useCached';

View File

@@ -69,7 +69,7 @@ describe('useOffsetPagination', () => {
await nextTick(); await nextTick();
expect(onPageChange).toHaveBeenCalledTimes(1); expect(onPageChange).toHaveBeenCalledTimes(1);
expect(onPageChange).toHaveBeenCalledWith(expect.objectContaining({ currentPage: currentPage.value })); expect(onPageChange.mock.calls[0]![0]).toHaveProperty('currentPage', currentPage.value);
}); });
it('call onPageSizeChange callback', async () => { it('call onPageSizeChange callback', async () => {
@@ -81,7 +81,7 @@ describe('useOffsetPagination', () => {
await nextTick(); await nextTick();
expect(onPageSizeChange).toHaveBeenCalledTimes(1); expect(onPageSizeChange).toHaveBeenCalledTimes(1);
expect(onPageSizeChange).toHaveBeenCalledWith(expect.objectContaining({ currentPageSize: currentPageSize.value })); expect(onPageSizeChange.mock.calls[0]![0]).toHaveProperty('currentPageSize', currentPageSize.value);
}); });
it('call onPageCountChange callback', async () => { it('call onPageCountChange callback', async () => {
@@ -93,7 +93,7 @@ describe('useOffsetPagination', () => {
await nextTick(); await nextTick();
expect(onTotalPagesChange).toHaveBeenCalledTimes(1); expect(onTotalPagesChange).toHaveBeenCalledTimes(1);
expect(onTotalPagesChange).toHaveBeenCalledWith(expect.objectContaining({ totalPages: totalPages.value })); expect(onTotalPagesChange.mock.calls[0]![0]).toHaveProperty('totalPages', totalPages.value);
}); });
it('handle complex reactive options', async () => { it('handle complex reactive options', async () => {

View File

@@ -1,51 +1,39 @@
import { isRef, ref, toValue, type MaybeRefOrGetter, type MaybeRef, type Ref } from 'vue'; import { isRef, ref, toValue, type MaybeRefOrGetter, type MaybeRef, type Ref } from 'vue';
// TODO: wip export interface UseToggleOptions<Truthy, Falsy> {
truthyValue?: MaybeRefOrGetter<Truthy>,
export interface UseToggleOptions<Enabled, Disabled> { falsyValue?: MaybeRefOrGetter<Falsy>,
enabledValue?: MaybeRefOrGetter<Enabled>,
disabledValue?: MaybeRefOrGetter<Disabled>,
} }
// two overloads export function useToggle<Truthy = true, Falsy = false>(
// 1. const [state, toggle] = useToggle(nonRefValue, options) initialValue?: MaybeRef<Truthy | Falsy>,
// 2. const toggle = useToggle(refValue, options) options?: UseToggleOptions<Truthy, Falsy>,
// 3. const [state, toggle] = useToggle() // true, false by default ): { value: Ref<Truthy | Falsy>, toggle: (value?: Truthy | Falsy) => Truthy | Falsy };
export function useToggle<V extends Enabled | Disabled, Enabled = true, Disabled = false>( export function useToggle<Truthy = true, Falsy = false>(
initialValue: Ref<V>, initialValue: MaybeRef<Truthy | Falsy> = false as Truthy | Falsy,
options?: UseToggleOptions<Enabled, Disabled>, options: UseToggleOptions<Truthy, Falsy> = {},
): (value?: V) => V;
export function useToggle<V extends Enabled | Disabled, Enabled = true, Disabled = false>(
initialValue?: V,
options?: UseToggleOptions<Enabled, Disabled>,
): [Ref<V>, (value?: V) => V];
export function useToggle<V extends Enabled | Disabled, Enabled = true, Disabled = false>(
initialValue: MaybeRef<V> = false,
options: UseToggleOptions<Enabled, Disabled> = {},
) { ) {
const { const {
enabledValue = false, truthyValue = true as Truthy,
disabledValue = true, falsyValue = false as Falsy,
} = options; } = options;
const state = ref(initialValue) as Ref<V>; const value = ref(initialValue) as Ref<Truthy | Falsy>;
const toggle = (value?: V) => { const toggle = (newValue?: Truthy | Falsy) => {
if (arguments.length) { if (newValue !== undefined) {
state.value = value!; value.value = newValue;
return state.value; return value.value;
} }
const enabled = toValue(enabledValue); const truthy = toValue(truthyValue);
const disabled = toValue(disabledValue); const falsy = toValue(falsyValue);
state.value = state.value === enabled ? disabled : enabled; value.value = value.value === truthy ? falsy : truthy;
return state.value; return value.value;
}; };
return isRef(initialValue) ? toggle : [state, toggle]; return { value, toggle };
} }

11
web/vue/tsdown.config.ts Normal file
View File

@@ -0,0 +1,11 @@
import { defineConfig } from 'tsdown';
export default defineConfig({
entry: ['src/index.ts'],
format: ['esm', 'cjs'],
dts: true,
clean: true,
hash: false,
external: ['vue'],
noExternal: [/^@robonen\//],
});