Skip to content
Open
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
31 changes: 31 additions & 0 deletions .changeset/publish-types-layout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
"@tko/bind": patch
"@tko/binding.component": patch
"@tko/binding.core": patch
"@tko/binding.foreach": patch
"@tko/binding.if": patch
"@tko/binding.template": patch
"@tko/builder": patch
"@tko/build.knockout": patch
"@tko/build.reference": patch
"@tko/computed": patch
"@tko/filter.punches": patch
"@tko/lifecycle": patch
"@tko/observable": patch
"@tko/provider": patch
"@tko/provider.attr": patch
"@tko/provider.bindingstring": patch
"@tko/provider.component": patch
"@tko/provider.databind": patch
"@tko/provider.multi": patch
"@tko/provider.mustache": patch
"@tko/provider.native": patch
"@tko/provider.virtual": patch
"@tko/utils": patch
"@tko/utils.component": patch
"@tko/utils.functionrewrite": patch
"@tko/utils.jsx": patch
"@tko/utils.parser": patch
---

Publish generated `types/` folders for all public packages and both bundled builds, and advertise those declarations through package `types` metadata and `exports` conditions so consumer imports resolve the shipped type surface instead of repo-only sources.
3 changes: 3 additions & 0 deletions .github/workflows/lint-and-typecheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ jobs:

- name: Typecheck
run: bunx tsc

- name: Verify types (smoke test .d.ts)
run: bun run verify:types
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ COVERAGE.md
builds/**/meta
.nyc_output
**/dist/*
packages/*/types/*
builds/*/types/*
!packages/tko/dist/*

*-debug.log
Expand Down
7 changes: 5 additions & 2 deletions builds/knockout/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
]
},
"files": [
"dist/"
"dist/",
"types/"
],
"licenses": [
{
Expand All @@ -53,6 +54,7 @@
},
"exports": {
".": {
"types": "./types/index.d.ts",
"require": "./dist/index.cjs",
"import": "./dist/index.mjs"
}
Expand All @@ -71,5 +73,6 @@
"mvvm",
"data-binding",
"compatible"
]
],
"types": "./types/index.d.ts"
}
13 changes: 11 additions & 2 deletions builds/knockout/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ const expressionRewriting = {
preProcessBindings: s => dataBindProvider.preProcessBindings(s)
}

type KnockoutBuildExtensions = {
version: string
components: typeof components
Component: typeof components.ComponentABC
expressionRewriting: typeof expressionRewriting
}

const provider = new MultiProvider({
providers: [new ComponentProvider(), dataBindProvider, new VirtualProvider(), new AttributeProvider()]
})
Expand All @@ -47,9 +54,11 @@ const builder = new Builder({
})

const version = BUILD_VERSION
export default builder.create({
const knockoutBuild: KnockoutBuildExtensions = {
version,
components,
Component: components.ComponentABC,
expressionRewriting
})
}

export default builder.create(knockoutBuild)
7 changes: 5 additions & 2 deletions builds/reference/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"@tko/utils": "^4.1.0"
},
"files": [
"dist/"
"dist/",
"types/"
],
"homepage": "https://tko.io",
"licenses": [
Expand All @@ -39,6 +40,7 @@
],
"exports": {
".": {
"types": "./types/index.d.ts",
"require": "./dist/index.cjs",
"import": "./dist/index.mjs"
}
Expand All @@ -59,5 +61,6 @@
"mvvm",
"tsx",
"modern"
]
],
"types": "./types/index.d.ts"
}
33 changes: 18 additions & 15 deletions builds/reference/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import { bindings as componentBindings } from '@tko/binding.component'
import { filters } from '@tko/filter.punches'

import components from '@tko/utils.component'
import { createElement, Fragment } from '@tko/utils.jsx'
import { JsxObserver } from '@tko/utils.jsx'
import { createElement, Fragment, render } from '@tko/utils.jsx'
import type { JsxRenderResult } from '@tko/utils.jsx'

import { options } from '@tko/utils'

Expand All @@ -27,6 +27,17 @@ declare const BUILD_VERSION: string
/** Use === and !== instead of == and != in binding expressions */
options.strictEquality = true

type ReferenceBuildExtensions = {
jsx: {
createElement: typeof createElement
Fragment: typeof Fragment
render(jsx: any): JsxRenderResult
}
components: typeof components
version: string
Component: typeof components.ComponentABC
}

const builder = new Builder({
filters,
extenders: {},
Expand Down Expand Up @@ -54,23 +65,15 @@ const builder = new Builder({

const version = BUILD_VERSION

export default builder.create({
const referenceBuild: ReferenceBuildExtensions = {
jsx: {
createElement,
Fragment,
/** Public render function that converts JSX to DOM nodes */
render(jsx: any) {
const fragment = document.createDocumentFragment()
const observer = new JsxObserver(jsx, fragment)
// Return the first child if single node, or the fragment if multiple
const node = fragment.childNodes.length === 1 ? fragment.firstChild : fragment
return {
node,
dispose: () => observer.dispose()
}
}
render
},
components,
version,
Component: components.ComponentABC
})
}

export default builder.create(referenceBuild)
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@
"url": "https://github.com/knockout/tko.git"
},
"scripts": {
"build": "bun run --filter './packages/*' build && bun run --filter './builds/*' build",
"build": "bun run dts && bun run --filter './packages/*' build && bun run --filter './builds/*' build",
"test": "bunx @biomejs/biome ci . && bun run build && bunx vitest run",
"test:ff": "bunx @biomejs/biome ci . && bun run build && VITEST_BROWSERS=firefox bunx vitest run",
"test:coverage": "bun run build && bunx vitest run --coverage --project browser",
"tsc": "bunx tsc",
"dts": "bunx tsc --build tsconfig.dts.json",
"dts": "bun tools/build-dts.ts",
"verify:types": "bunx tsc -p tools/types-smoke/tsconfig.json",
"format": "bunx @biomejs/biome format .",
"format:fix": "bunx @biomejs/biome format --write .",
"lint": "bunx @biomejs/biome lint .",
"lint:fix": "bunx @biomejs/biome check --fix .",
"check": "bunx @biomejs/biome check .",
"knip": "knip",
"verify:esm": "bun tools/verify-esm-extensions.ts",
"verify": "bunx @biomejs/biome check . && bunx tsc && bun run build && bun run verify:esm && bunx vitest run",
"clean": "rm -rf packages/*/dist builds/*/dist coverage"
"verify": "bunx @biomejs/biome check . && bunx tsc && bun run build && bun run verify:types && bun run verify:esm && bunx vitest run",
"clean": "rm -rf packages/*/dist packages/*/types builds/*/dist builds/*/types coverage .dts-tmp"
},
"bugs": "https://github.com/knockout/tko/issues",
"licenses": [
Expand Down
7 changes: 5 additions & 2 deletions packages/bind/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"@tko/builder": "^4.1.0"
},
"files": [
"dist/"
"dist/",
"types/"
],
"repository": {
"type": "git",
Expand All @@ -33,6 +34,7 @@
],
"exports": {
".": {
"types": "./types/index.d.ts",
"require": "./dist/index.cjs",
"import": "./dist/index.js"
}
Expand All @@ -47,5 +49,6 @@
"dom",
"observable",
"data-binding"
]
],
"types": "./types/index.d.ts"
}
7 changes: 5 additions & 2 deletions packages/binding.component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"@tko/utils.jsx": "^4.1.0"
},
"files": [
"dist/"
"dist/",
"types/"
],
"homepage": "https://tko.io",
"licenses": [
Expand All @@ -25,6 +26,7 @@
],
"exports": {
".": {
"types": "./types/index.d.ts",
"require": "./dist/index.cjs",
"import": "./dist/index.js"
}
Expand All @@ -46,5 +48,6 @@
"binding",
"web-components",
"custom-elements"
]
],
"types": "./types/index.d.ts"
}
7 changes: 5 additions & 2 deletions packages/binding.core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "TKO Core bindings",
"module": "dist/index.js",
"files": [
"dist/"
"dist/",
"types/"
],
"repository": {
"type": "git",
Expand Down Expand Up @@ -37,11 +38,13 @@
],
"exports": {
".": {
"types": "./types/index.d.ts",
"require": "./dist/index.cjs",
"import": "./dist/index.js"
}
},
"scripts": {
"build": "bun ../../tools/build.ts"
}
},
"types": "./types/index.d.ts"
}
7 changes: 5 additions & 2 deletions packages/binding.foreach/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "Knockout Foreach Binding",
"module": "dist/index.js",
"files": [
"dist/"
"dist/",
"types/"
],
"repository": {
"type": "git",
Expand Down Expand Up @@ -36,11 +37,13 @@
],
"exports": {
".": {
"types": "./types/index.d.ts",
"require": "./dist/index.cjs",
"import": "./dist/index.js"
}
},
"scripts": {
"build": "bun ../../tools/build.ts"
}
},
"types": "./types/index.d.ts"
}
7 changes: 5 additions & 2 deletions packages/binding.if/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "TKO conditional (if/ifnot/unless/with/else) bindings",
"module": "dist/index.js",
"files": [
"dist/"
"dist/",
"types/"
],
"repository": {
"type": "git",
Expand Down Expand Up @@ -36,11 +37,13 @@
],
"exports": {
".": {
"types": "./types/index.d.ts",
"require": "./dist/index.cjs",
"import": "./dist/index.js"
}
},
"scripts": {
"build": "bun ../../tools/build.ts"
}
},
"types": "./types/index.d.ts"
}
7 changes: 5 additions & 2 deletions packages/binding.template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "TKO Template bindings",
"module": "dist/index.js",
"files": [
"dist/"
"dist/",
"types/"
],
"repository": {
"type": "git",
Expand Down Expand Up @@ -37,11 +38,13 @@
],
"exports": {
".": {
"types": "./types/index.d.ts",
"require": "./dist/index.cjs",
"import": "./dist/index.js"
}
},
"scripts": {
"build": "bun ../../tools/build.ts"
}
},
"types": "./types/index.d.ts"
}
7 changes: 5 additions & 2 deletions packages/builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@
}
],
"files": [
"dist/"
"dist/",
"types/"
],
"exports": {
".": {
"types": "./types/index.d.ts",
"require": "./dist/index.cjs",
"import": "./dist/index.js"
}
Expand All @@ -47,5 +49,6 @@
"builder",
"framework",
"customizable"
]
],
"types": "./types/index.d.ts"
}
Loading
Loading