diff --git a/.changeset/fix-jsx-clean-teardown-race.md b/.changeset/fix-jsx-clean-teardown-race.md index 1479c19c6..750af01a4 100644 --- a/.changeset/fix-jsx-clean-teardown-race.md +++ b/.changeset/fix-jsx-clean-teardown-race.md @@ -1,5 +1,5 @@ --- -"@tko/utils.jsx": patch +"@tko/utils.jsx": minor --- Add `options.jsxCleanBatchSize` (default `1000`) controlling JSX node cleanup diff --git a/.changeset/modernize-utils-dead-polyfills.md b/.changeset/modernize-utils-dead-polyfills.md index 49a9fd19f..99e1026cf 100644 --- a/.changeset/modernize-utils-dead-polyfills.md +++ b/.changeset/modernize-utils-dead-polyfills.md @@ -1,28 +1,34 @@ --- -"@tko/utils": minor +"@tko/utils": patch "@tko/utils.parser": patch "@tko/observable": patch "@tko/binding.core": patch "@tko/binding.foreach": patch "@tko/computed": patch "@tko/lifecycle": patch -"@tko/builder": minor +"@tko/builder": patch --- Drop dead polyfill probes from `@tko/utils` Removes runtime feature detection for capabilities that all supported runtimes -(modern browsers, Node, Bun, happy-dom) already expose unconditionally: +(modern browsers, Node, Bun, happy-dom) already expose unconditionally. The +public API surface is preserved as one-line passthroughs in +`packages/utils/src/compat.ts` so existing consumers continue to work; these +shims are slated for removal in the next major. - `functionSupportsLengthOverwrite` + `overwriteLengthPropertyIfSupported` — `Object.defineProperty(fn, 'length', …)` has worked since IE9. Call sites - in `@tko/observable` now invoke `Object.defineProperty` directly. + in `@tko/observable` now invoke `Object.defineProperty` directly. The + internal probe is gone; `overwriteLengthPropertyIfSupported` is preserved + on `@tko/utils` exports as an inline `Object.defineProperty` call. - `useSymbols` + `createSymbolOrString` — `Symbol` is always defined; call - sites now use `Symbol(identifier)` directly. `createSymbolOrString` is no - longer exposed on `ko.utils` (public API removal — minor bump for - `@tko/utils` and `@tko/builder`). -- `stringTrim` + `stringStartsWith` — removed; call sites use - `String(value ?? '').trim()` / `value.startsWith(prefix)` inline. + sites now use `Symbol(identifier)` directly. `createSymbolOrString` is + preserved as `s => Symbol(s)` on both `@tko/utils` exports and + `ko.utils.createSymbolOrString`. +- `stringTrim` + `stringStartsWith` — call sites use `String(value ?? '') + .trim()` / `value.startsWith(prefix)` inline. Both names remain exported + from `@tko/utils` as inline passthroughs. - `toggleDomNodeCssClass` SVGAnimatedString fallback — `classList` is available on every supported `Element` (including SVG since SVG2). - `parseJson` no longer routes through `stringTrim`; it trims inline when the @@ -31,3 +37,7 @@ Removes runtime feature detection for capabilities that all supported runtimes `packages/utils.parser/src/preparse.ts` also guards `str.match(bindingToken)` against the `null` return case using `?? []` — previously relied on the match never returning `null` for the transformed input. + +Patch-level for all packages: zero observable surface change for consumers +not reaching into internal probes (`useSymbols`, `functionSupportsLengthOverwrite`), +which had no monorepo callers. diff --git a/bun.lock b/bun.lock index 0dbc5630a..c7637a11e 100644 --- a/bun.lock +++ b/bun.lock @@ -76,9 +76,6 @@ "@tko/provider": "^4.0.1", "@tko/utils": "^4.0.1", }, - "peerDependencies": { - "@tko/binding.foreach": "^4.0.1", - }, }, "packages/binding.component": { "name": "@tko/binding.component", @@ -130,9 +127,6 @@ "@tko/observable": "^4.0.1", "@tko/utils": "^4.0.1", }, - "peerDependencies": { - "@tko/binding.if": "^4.0.1", - }, }, "packages/builder": { "name": "@tko/builder", @@ -170,9 +164,6 @@ "@tko/computed": "^4.0.1", "@tko/utils": "^4.0.1", }, - "peerDependencies": { - "@tko/observable": "^4.0.1", - }, }, "packages/observable": { "name": "@tko/observable", @@ -276,13 +267,6 @@ "@tko/observable": "^4.0.1", "@tko/utils": "^4.0.1", }, - "peerDependencies": { - "@tko/bind": "^4.0.1", - "@tko/binding.core": "^4.0.1", - "@tko/computed": "^4.0.1", - "@tko/provider.multi": "^4.0.1", - "@tko/provider.virtual": "^4.0.1", - }, }, "packages/utils.functionrewrite": { "name": "@tko/utils.functionrewrite", @@ -307,11 +291,6 @@ "@tko/observable": "^4.0.1", "@tko/utils": "^4.0.1", }, - "peerDependencies": { - "@tko/bind": "^4.0.1", - "@tko/binding.core": "^4.0.1", - "@tko/provider.databind": "^4.0.1", - }, }, }, "packages": { diff --git a/packages/bind/package.json b/packages/bind/package.json index 2ff5d3306..57760e669 100644 --- a/packages/bind/package.json +++ b/packages/bind/package.json @@ -11,9 +11,6 @@ "@tko/utils": "^4.0.1", "@tko/builder": "^4.0.1" }, - "peerDependencies": { - "@tko/binding.foreach": "^4.0.1" - }, "files": [ "dist/" ], diff --git a/packages/binding.template/package.json b/packages/binding.template/package.json index f526228c6..62c735911 100644 --- a/packages/binding.template/package.json +++ b/packages/binding.template/package.json @@ -29,9 +29,6 @@ "@tko/observable": "^4.0.1", "@tko/utils": "^4.0.1" }, - "peerDependencies": { - "@tko/binding.if": "^4.0.1" - }, "licenses": [ { "type": "MIT", diff --git a/packages/builder/src/Builder.ts b/packages/builder/src/Builder.ts index 3295ba213..a5e1da4be 100644 --- a/packages/builder/src/Builder.ts +++ b/packages/builder/src/Builder.ts @@ -17,6 +17,7 @@ import { cleanNode, cloneNodes, compareArrays, + createSymbolOrString, domData, extend, memoization, @@ -115,6 +116,7 @@ export type Utils = { arrayRemoveItem: typeof arrayRemoveItem cloneNodes: typeof cloneNodes compareArrays: typeof compareArrays + createSymbolOrString: typeof createSymbolOrString domData: typeof domData domNodeDisposal: typeof domNodeDisposal extend: typeof extend @@ -147,6 +149,7 @@ const utils: Utils = { arrayRemoveItem, cloneNodes, compareArrays, + createSymbolOrString, domData, domNodeDisposal, extend, diff --git a/packages/lifecycle/package.json b/packages/lifecycle/package.json index 3a04e1849..8afc1b335 100644 --- a/packages/lifecycle/package.json +++ b/packages/lifecycle/package.json @@ -3,11 +3,9 @@ "module": "dist/index.js", "dependencies": { "@tko/computed": "^4.0.1", + "@tko/observable": "^4.0.1", "@tko/utils": "^4.0.1" }, - "peerDependencies": { - "@tko/observable": "^4.0.1" - }, "files": [ "dist/" ], diff --git a/packages/utils.component/package.json b/packages/utils.component/package.json index 94f08c45d..3479aba02 100644 --- a/packages/utils.component/package.json +++ b/packages/utils.component/package.json @@ -12,13 +12,6 @@ "@tko/observable": "^4.0.1", "@tko/utils": "^4.0.1" }, - "peerDependencies": { - "@tko/bind": "^4.0.1", - "@tko/binding.core": "^4.0.1", - "@tko/computed": "^4.0.1", - "@tko/provider.multi": "^4.0.1", - "@tko/provider.virtual": "^4.0.1" - }, "homepage": "https://tko.io", "licenses": [ { diff --git a/packages/utils.parser/package.json b/packages/utils.parser/package.json index f360fecbb..9f9f73cb1 100644 --- a/packages/utils.parser/package.json +++ b/packages/utils.parser/package.json @@ -11,11 +11,6 @@ "@tko/observable": "^4.0.1", "@tko/utils": "^4.0.1" }, - "peerDependencies": { - "@tko/bind": "^4.0.1", - "@tko/binding.core": "^4.0.1", - "@tko/provider.databind": "^4.0.1" - }, "homepage": "https://tko.io", "licenses": [ { diff --git a/packages/utils/src/compat.ts b/packages/utils/src/compat.ts new file mode 100644 index 000000000..ca5bc4693 --- /dev/null +++ b/packages/utils/src/compat.ts @@ -0,0 +1,34 @@ +// Compat passthroughs preserving the public @tko/utils API after the +// post-Symbol/post-IE9 polyfill removals. Each function delegates to a +// native API; kept so consumers importing these names continue to work. +// All entries here are slated for removal in the next major version. + +/** + * @deprecated Use `Symbol(identifier)` directly. Will be removed in a future major. + */ +export function createSymbolOrString(identifier: string): symbol { + return Symbol(identifier) +} + +/** + * @deprecated Use `String(value ?? '').trim()` directly (or `String.prototype.trim` + * when the input is known to be a string). Will be removed in a future major. + */ +export function stringTrim(value: any): string { + return String(value ?? '').trim() +} + +/** + * @deprecated Use `String.prototype.startsWith` directly. Will be removed in a future major. + */ +export function stringStartsWith(value: string, prefix: string): boolean { + return (value ?? '').startsWith(prefix) +} + +/** + * @deprecated Use `Object.defineProperty(fn, 'length', descriptor)` directly. + * Will be removed in a future major. + */ +export function overwriteLengthPropertyIfSupported(fn: Function, descriptor: PropertyDescriptor): void { + Object.defineProperty(fn, 'length', descriptor) +} diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index a55923b00..607e4121f 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -6,6 +6,7 @@ export * from './array' export * from './async' +export * from './compat' export * from './error' export * from './object' export * from './string'