Skip to content

Commit

Permalink
a huge restructuring of packages
Browse files Browse the repository at this point in the history
- Add a build script for each package.
- Add a test:types script for each package.
- Upgrade TypeScript.
- Reconfigure TypeScript.
- Update the implementation of HTML components.
- Change a new resource's configuration file to the YAML format.
- Remove some unused packages.
- Update several type-related packages.
- Move stories out of the packages.
  • Loading branch information
vanyauhalin committed Dec 23, 2024
1 parent 4db6257 commit 172d155
Show file tree
Hide file tree
Showing 758 changed files with 5,589 additions and 6,460 deletions.
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default [
"!package.json",
"!stylelint.config.js",
"!tsconfig.base.json",
"!tsconfig.emit.json",
"!tsconfig.build.json",
"!tsconfig.json",
],
},
Expand Down
11 changes: 1 addition & 10 deletions makefile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,6 @@ interface PackageJson {

function main(): void {
sade("makefile.ts")
.command("clean")
.describe("Recursively run 'pnpm clean' on all packages")
.action(async (p: {_: string[]}) => {
if (p._.length === 0) {
p._ = await readdir("packages")
}
for (const n of p._) {
await run(n, "clean")
}
})
.command("build")
.describe("Recursively run 'pnpm build' on all packages")
.action(async (p: {_: string[]}) => {
Expand Down Expand Up @@ -65,6 +55,7 @@ function main(): void {
n === "node-path" ||
n === "preact-elements" ||
n === "preact-slots" ||
n === "preact-suspense" ||
n === "preact-template" ||
n === "rehype-clean" ||
n === "remark-config" ||
Expand Down
20 changes: 14 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
{
"name": "@onlyoffice/documentation",
"name": "@onlyoffice/api.onlyoffice.com",
"type": "module",
"private": true,
"engines": {
"node": "^21"
},
"scripts": {
"build": "tsx makefile.ts build",
"clean": "tsx makefile.ts clean",
"lint:code": "eslint .",
"lint:pages": "remark --frail --quiet site/pages",
"lint:styles": "stylelint --ignore-path .gitignore \"+(packages|site|storybook)/**/*.css\"",
"lint": "pnpm lint:code && pnpm lint:styles && pnpm lint:pages",
"test": "tsx makefile.ts test"
"test:packages": "tsx makefile.ts test",
"test:types": "tsc --noEmit",
"test": "pnpm test:types && pnpm test:packages"
},
"devDependencies": {
"@onlyoffice/eslint-config": "workspace:^",
Expand All @@ -29,12 +30,19 @@
"sade": "1.8.1",
"stylelint": "16.8.2",
"tsx": "4.16.5",
"typescript": "5.4.5"
"typescript": "5.7.2"
},
"pnpm": {
"supportedArchitectures": {
"os": ["current", "darwin", "win32"],
"cpu": ["arm64", "x64"]
"os": [
"current",
"darwin",
"win32"
],
"cpu": [
"arm64",
"x64"
]
}
}
}
11 changes: 5 additions & 6 deletions packages/async-transform/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@
"name": "@onlyoffice/async-transform",
"type": "module",
"private": true,
"main": "lib/main.ts",
"main": "dist/main.js",
"scripts": {
"clean": "rimraf coverage node_modules",
"test:types": "tsc",
"build": "tsc --project tsconfig.build.json",
"test:types": "tsc --noEmit",
"test:unit": "c8 --config ../../c8.config.json tsx node_modules/uvu/bin.js lib ^.*\\.test\\.ts$",
"test": "pnpm test:types && pnpm test:unit"
},
"dependencies": {
"@types/node": "20.12.12",
"typescript": "5.4.5"
"@types/node": "20.12.12"
},
"devDependencies": {
"@onlyoffice/stream-string": "workspace:^",
"c8": "9.1.0",
"rimraf": "6.0.1",
"tsx": "4.16.5",
"typescript": "5.7.2",
"uvu": "0.5.6"
}
}
3 changes: 3 additions & 0 deletions packages/async-transform/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../../tsconfig.build.json"
}
3 changes: 1 addition & 2 deletions packages/async-transform/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"extends": "../../tsconfig.base.json",
"include": ["lib"]
"extends": "../../tsconfig.base.json"
}
11 changes: 4 additions & 7 deletions packages/caller-position/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@
"name": "@onlyoffice/caller-position",
"type": "module",
"private": true,
"main": "lib/main.ts",
"main": "dist/main.js",
"scripts": {
"clean": "rimraf coverage node_modules",
"test:types": "tsc",
"build": "tsc --project tsconfig.build.json",
"test:types": "tsc --noEmit",
"test:unit": "c8 --config ../../c8.config.json tsx node_modules/uvu/bin.js lib ^.*\\.test\\.ts$",
"test": "pnpm test:types && pnpm test:unit"
},
"dependencies": {
"typescript": "5.4.5"
},
"devDependencies": {
"c8": "9.1.0",
"rimraf": "6.0.1",
"tsx": "4.16.5",
"typescript": "5.7.2",
"uvu": "0.5.6"
}
}
3 changes: 3 additions & 0 deletions packages/caller-position/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../../tsconfig.build.json"
}
3 changes: 1 addition & 2 deletions packages/caller-position/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"extends": "../../tsconfig.base.json",
"include": ["lib"]
"extends": "../../tsconfig.base.json"
}
40 changes: 5 additions & 35 deletions packages/combobox-container-html-element/lib/define.ts
Original file line number Diff line number Diff line change
@@ -1,49 +1,19 @@
import {ComboboxContainer} from "./element.ts"
import {
ComboboxContainer,
} from "./element.ts"
import {
ComboboxContainerChangeEvent,
type ComboboxContainerChangeEventListener,
ComboboxContainerChangedEvent,
type ComboboxContainerChangedEventListener,
type GlobalComboboxContainerChangeHandler,
type GlobalComboboxContainerChangedHandler,
} from "./events.ts"

declare global {
interface Window {
ComboboxContainer: typeof ComboboxContainer
ComboboxContainerChangeEvent: typeof ComboboxContainerChangeEvent
ComboboxContainerChangedEvent: typeof ComboboxContainerChangedEvent
}

interface HTMLElementTagNameMap {
"combobox-container": ComboboxContainer
}

namespace preact {
namespace JSX {
interface IntrinsicElements {
"combobox-container": HTMLAttributes<ComboboxContainer>
}
}
}

interface GlobalEventHandlersEventMap {
comboboxcontainerchange: ComboboxContainerChangeEventListener
comboboxcontainerchanged: ComboboxContainerChangedEventListener
}

interface GlobalEventHandlers {
oncomboboxcontainerchange: GlobalComboboxContainerChangeHandler | null
oncomboboxcontainerchanged: GlobalComboboxContainerChangedHandler | null
}
}

export function define(): void {
if (window.customElements.get(ComboboxContainer.tagName)) {
return
}

window.ComboboxContainer = ComboboxContainer
window.customElements.define(ComboboxContainer.tagName, ComboboxContainer)

window.ComboboxContainerChangeEvent = ComboboxContainerChangeEvent
window.ComboboxContainerChangedEvent = ComboboxContainerChangedEvent
}
52 changes: 4 additions & 48 deletions packages/combobox-container-html-element/lib/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,60 +24,16 @@ import {
ComboboxContainerChangedEvent,
type ComboboxContainerChangedEventListener,
} from "./events.ts"

export type ComboboxContainerAttributeName =
Exclude<keyof ComboboxContainerAttributes, undefined>

export interface ComboboxContainerAttributes {
"default-index"?: string
"disabled"?: string
"name"?: string
"page-size"?: string
"oncomboboxcontainerchange"?: string
"oncomboboxcontainerchanged"?: string
}

export type ComboboxContainerFallbackStatesName =
keyof ComboboxContainerFallbackStates

export type ComboboxContainerFallbackStates = {
[K in keyof ComboboxContainerStates as `state-${string & K}`]: string
}

export type ComboboxContainerStateName =
keyof ComboboxContainerStates

export interface ComboboxContainerStates {
selected?: boolean
}

export type ComboboxContainerEvent =
Window[ComboboxContainerEventName]

export type ComboboxContainerEventName = Exclude<{
[K in keyof Window]: K extends `ComboboxContainer${string}Event` ? K : never
}[keyof Window], undefined>

export type ComboboxContainerEventListener =
GlobalEventHandlersEventMap[ComboboxContainerEventType]

export type ComboboxContainerEventType = {
[K in keyof GlobalEventHandlersEventMap]: K extends `comboboxcontainer${string}` ? K : never
}[keyof GlobalEventHandlersEventMap]

export type ComboboxContainerEventHandler =
Exclude<GlobalEventHandlers[ComboboxContainerEventHandlerName], null>

export type ComboboxContainerEventHandlerName = Exclude<{
[K in keyof GlobalEventHandlers]: K extends `oncomboboxcontainer${string}` ? K : never
}[keyof GlobalEventHandlers], undefined>
import {
type ComboboxContainerAttributeName,
} from "./types.ts"

/**
* A accessible combobox container element with keyboard support. Follows the
* {@link https://www.w3.org/WAI/ARIA/apg/patterns/combobox/ ARIA best practices guide on combobox}.
*/
export class ComboboxContainer extends HTMLElement {
static get tagName(): string {
static get tagName(): "combobox-container" {
return "combobox-container"
}

Expand Down
16 changes: 12 additions & 4 deletions packages/combobox-container-html-element/lib/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ class ComboboxContainerEvent extends Event {
}

export class ComboboxContainerChangeEvent extends ComboboxContainerEvent {
static get type(): string {
static get handlerName(): `on${typeof ComboboxContainerChangeEvent.type}` {
return `on${this.type}`
}

static get type(): "comboboxcontainerchange" {
return "comboboxcontainerchange"
}

Expand All @@ -47,12 +51,16 @@ export interface ComboboxContainerChangeEventListener extends EventListener {
(this: ComboboxContainer, ev: ComboboxContainerChangeEvent): void
}

export interface GlobalComboboxContainerChangeHandler {
export interface GlobalComboboxContainerChangeEventHandler {
(this: GlobalEventHandlers, ev: ComboboxContainerChangeEvent): void
}

export class ComboboxContainerChangedEvent extends ComboboxContainerEvent {
static get type(): string {
static get handlerName(): `on${typeof ComboboxContainerChangedEvent.type}` {
return `on${this.type}`
}

static get type(): "comboboxcontainerchanged" {
return "comboboxcontainerchanged"
}

Expand All @@ -65,6 +73,6 @@ export interface ComboboxContainerChangedEventListener extends EventListener {
(this: ComboboxContainer, ev: ComboboxContainerChangedEvent): void
}

export interface GlobalComboboxContainerChangedHandler {
export interface GlobalComboboxContainerChangedEventHandler {
(this: GlobalEventHandlers, ev: ComboboxContainerChangedEvent): void
}
44 changes: 44 additions & 0 deletions packages/combobox-container-html-element/lib/global.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/* eslint @stylistic/max-len: ["error", {code: 140}] */

import {
type ComboboxContainer,
} from "./element.ts"
import {
type ComboboxContainerChangeEvent,
type ComboboxContainerChangedEvent,
type GlobalComboboxContainerChangeEventHandler,
type GlobalComboboxContainerChangedEventHandler,
} from "./events.ts"
import {
type ComboboxContainerAttributeMap,
} from "./types.ts"

declare global {
namespace preact {
namespace JSX {
interface IntrinsicElements {
[ComboboxContainer.tagName]: HTMLAttributes<ComboboxContainer> & Partial<ComboboxContainerAttributeMap>
}
}
}

interface Window {
ComboboxContainer: typeof ComboboxContainer
ComboboxContainerChangeEvent: typeof ComboboxContainerChangeEvent
ComboboxContainerChangedEvent: typeof ComboboxContainerChangedEvent
}

interface HTMLElementTagNameMap {
[ComboboxContainer.tagName]: ComboboxContainer
}

interface GlobalEventHandlersEventMap {
[ComboboxContainerChangeEvent.type]: ComboboxContainerChangeEvent
[ComboboxContainerChangedEvent.type]: ComboboxContainerChangedEvent
}

interface GlobalEventHandlers {
[ComboboxContainerChangeEvent.handlerName]: GlobalComboboxContainerChangeEventHandler | null
[ComboboxContainerChangedEvent.handlerName]: GlobalComboboxContainerChangedEventHandler | null
}
}
3 changes: 3 additions & 0 deletions packages/combobox-container-html-element/lib/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import {define} from "./define.ts"

export * from "./element.ts"
export * from "./events.ts"
export * from "./global.ts"
export * from "./types.ts"

define()
Loading

0 comments on commit 172d155

Please sign in to comment.