web-toolkit-x 0.0.1 → 0.71.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/AUTHORS +3 -0
  2. package/LICENSE +1 -1
  3. package/NOTICE +7 -0
  4. package/README.md +169 -6
  5. package/dist/release/global.d.ts +10 -0
  6. package/dist/release/index.d.ts +650 -0
  7. package/dist/release/index.d.ts.map +1 -0
  8. package/dist/release/index.js +2837 -0
  9. package/dist/release/index.js.map +1 -0
  10. package/dist/release/toolkit-0.71.0.js +2840 -0
  11. package/dist/release/toolkit-0.71.0.js.map +1 -0
  12. package/package.json +75 -18
  13. package/src/core/bragi.ts +122 -0
  14. package/src/core/browser.ts +555 -0
  15. package/src/core/child-nodes.ts +77 -0
  16. package/src/core/comment.ts +24 -0
  17. package/src/core/component.ts +190 -0
  18. package/src/core/created-roots.ts +38 -0
  19. package/src/core/custom-element.ts +191 -0
  20. package/src/core/description.ts +241 -0
  21. package/src/core/diff.ts +590 -0
  22. package/src/core/dispatcher.ts +221 -0
  23. package/src/core/dom.ts +124 -0
  24. package/src/core/draft.ts +609 -0
  25. package/src/core/lifecycle.ts +301 -0
  26. package/src/core/nodes.ts +13 -0
  27. package/src/core/patch.ts +412 -0
  28. package/src/core/plugins.ts +231 -0
  29. package/src/core/reconciler.ts +185 -0
  30. package/src/core/renderer.ts +75 -0
  31. package/src/core/runtime.ts +36 -0
  32. package/src/core/sandbox.ts +128 -0
  33. package/src/core/service.ts +39 -0
  34. package/src/core/template.ts +472 -0
  35. package/src/core/text.ts +24 -0
  36. package/src/core/toolkit.ts +220 -0
  37. package/src/core/utils.ts +148 -0
  38. package/src/core/virtual-dom.ts +118 -0
  39. package/src/core/virtual-element.ts +72 -0
  40. package/src/core/virtual-node.ts +87 -0
  41. package/src/core/web-component.ts +285 -0
  42. package/src/global.d.ts +10 -0
  43. package/src/index.ts +62 -0
  44. package/src/plugins/logger.ts +38 -0
  45. package/src/release.ts +3 -0
  46. package/index.js +0 -1
package/package.json CHANGED
@@ -1,37 +1,94 @@
1
1
  {
2
2
  "name": "web-toolkit-x",
3
- "version": "0.0.1",
4
- "description": "Web Toolkit X, a Web Components Toolkit",
5
- "type": "module",
6
- "main": "index.js",
7
- "exports": "./index.js",
8
- "files": [
9
- "index.js"
10
- ],
3
+ "version": "0.71.0",
4
+ "description": "Web Toolkit X, a Web UI toolkit",
11
5
  "scripts": {
12
- "test": "node --test"
6
+ "typecheck": "node node_modules/typescript-7/lib/tsc.js -p . && node node_modules/typescript-7/lib/tsc.js -p test && node node_modules/typescript-7/lib/tsc.js -p demo",
7
+ "test": "vitest run --browser=chromium",
8
+ "test:browsers": "vitest run",
9
+ "coverage": "vitest run --coverage --browser=chromium",
10
+ "bench": "vitest bench --run --reporter=verbose --browser=chromium",
11
+ "lint": "eslint .",
12
+ "format": "prettier --write .",
13
+ "build": "tsdown",
14
+ "dev": "tsdown --watch",
15
+ "verify": "npm run build && npm run typecheck && npm run lint && prettier --check .",
16
+ "demo": "npm run build && vite demo --mode release",
17
+ "prepublishOnly": "npm run verify",
18
+ "prepare": "simple-git-hooks"
13
19
  },
14
20
  "repository": {
15
21
  "type": "git",
16
22
  "url": "git+https://github.com/aswitalski/web-toolkit-x.git"
17
23
  },
18
- "bugs": {
19
- "url": "https://github.com/aswitalski/web-toolkit-x/issues"
20
- },
21
- "homepage": "https://github.com/aswitalski/web-toolkit-x#readme",
22
- "author": "Aleksander Świtalski",
23
- "license": "Apache-2.0",
24
24
  "keywords": [
25
25
  "web ui",
26
26
  "toolkit",
27
27
  "native",
28
28
  "javascript",
29
29
  "framework",
30
- "virtual dom",
31
- "web components",
32
- "native elements"
30
+ "virtual dom"
33
31
  ],
32
+ "author": "Aleksander Świtalski",
33
+ "license": "Apache-2.0",
34
+ "bugs": {
35
+ "url": "https://github.com/aswitalski/web-toolkit-x/issues"
36
+ },
37
+ "homepage": "https://github.com/aswitalski/web-toolkit-x#readme",
38
+ "devDependencies": {
39
+ "@arethetypeswrong/core": "^0.18.5",
40
+ "@eslint/js": "^10.0.1",
41
+ "@vitest/browser-playwright": "^5.0.2",
42
+ "@vitest/coverage-v8": "^5.0.2",
43
+ "eslint": "^10.11.0",
44
+ "eslint-config-prettier": "^10.1.8",
45
+ "globals": "^17.12.0",
46
+ "lint-staged": "^17.6.0",
47
+ "playwright": "^1.63.0",
48
+ "prettier": "^3.9.9",
49
+ "publint": "^0.3.24",
50
+ "simple-git-hooks": "^2.14.0",
51
+ "tsdown": "^0.23.0",
52
+ "typescript": "~6.0.3",
53
+ "typescript-7": "npm:typescript@^7.0.2",
54
+ "typescript-eslint": "^8.70.1",
55
+ "vite": "^8.3.1",
56
+ "vitest": "^5.0.2"
57
+ },
58
+ "type": "module",
59
+ "types": "./dist/release/index.d.ts",
60
+ "exports": {
61
+ ".": {
62
+ "types": "./dist/release/index.d.ts",
63
+ "default": "./dist/release/index.js"
64
+ },
65
+ "./global": {
66
+ "types": "./dist/release/global.d.ts"
67
+ },
68
+ "./package.json": "./package.json"
69
+ },
70
+ "files": [
71
+ "dist/release",
72
+ "src",
73
+ "NOTICE",
74
+ "AUTHORS"
75
+ ],
76
+ "allowScripts": {
77
+ "simple-git-hooks@2.14.0": true,
78
+ "fsevents": false
79
+ },
34
80
  "engines": {
35
81
  "node": ">=24"
82
+ },
83
+ "simple-git-hooks": {
84
+ "pre-commit": "npx lint-staged",
85
+ "pre-push": "npm run typecheck && npm test && npm run build && npm run lint"
86
+ },
87
+ "lint-staged": {
88
+ "*.{js,ts}": [
89
+ "eslint --fix",
90
+ "prettier --write"
91
+ ],
92
+ "*.{json,html,css,yml,md}": "prettier --write"
36
93
  }
37
94
  }
@@ -0,0 +1,122 @@
1
+ /*
2
+ * Types of Bragi templates, describing the rendered content with arrays,
3
+ * objects and primitive values.
4
+ */
5
+ import type {
6
+ AttributeName,
7
+ EventName,
8
+ FilterName,
9
+ TransformName,
10
+ } from './browser.js'
11
+ import type { Props } from './description.js'
12
+ import type { Component } from './nodes.js'
13
+
14
+ /* A value of an attribute, a data attribute or a function list entry. */
15
+ export type AttributeValue =
16
+ | string
17
+ | number
18
+ | bigint
19
+ | boolean
20
+ | null
21
+ | undefined
22
+ | ReadonlyArray<string | number>
23
+
24
+ /* Class names as a string, a list or an object of conditionally set names. */
25
+ export type ClassName =
26
+ | string
27
+ | false
28
+ | null
29
+ | undefined
30
+ | readonly ClassName[]
31
+ | { readonly [name: string]: unknown }
32
+
33
+ export type StyleValue =
34
+ string | number | boolean | null | undefined | ReadonlyArray<string | number>
35
+
36
+ /* Functions of the filter and transform style properties, e.g. { blur: 2 }. */
37
+ export type FunctionList<Name extends string> = {
38
+ readonly [F in Name]?: AttributeValue
39
+ }
40
+
41
+ type CSSPropertyName = {
42
+ [K in keyof CSSStyleDeclaration]: K extends string
43
+ ? CSSStyleDeclaration[K] extends string
44
+ ? K
45
+ : never
46
+ : never
47
+ }[keyof CSSStyleDeclaration]
48
+
49
+ export type Style = {
50
+ readonly [P in Exclude<CSSPropertyName, 'filter' | 'transform'>]?: StyleValue
51
+ } & {
52
+ readonly [P in `--${string}`]?: StyleValue
53
+ } & {
54
+ readonly filter?: StyleValue | FunctionList<FilterName>
55
+ readonly transform?: StyleValue | FunctionList<TransformName>
56
+ }
57
+
58
+ /* The DOM event name for a listener name, as resolved by the renderer. */
59
+ type DOMEventName<N extends string> = N extends 'onDoubleClick'
60
+ ? 'dblclick'
61
+ : N extends `on${infer E}`
62
+ ? Lowercase<E>
63
+ : never
64
+
65
+ export type Listener<E extends Event = Event> = (event: E) => unknown
66
+
67
+ export type EventListenerFor<N extends EventName> = Listener<
68
+ DOMEventName<N> extends keyof HTMLElementEventMap
69
+ ? HTMLElementEventMap[DOMEventName<N>]
70
+ : Event
71
+ >
72
+
73
+ type SpecialProps = {
74
+ readonly key?: string | number
75
+ readonly class?: ClassName
76
+ readonly style?: Style
77
+ readonly dataset?: { readonly [name: string]: AttributeValue }
78
+ readonly properties?: { readonly [name: string]: unknown }
79
+ readonly attrs?: { readonly [name: string]: AttributeValue }
80
+ readonly on?: {
81
+ readonly [event: string]: Listener | null | false | undefined
82
+ }
83
+ }
84
+
85
+ type AttributeProps = {
86
+ readonly [A in Exclude<AttributeName, keyof SpecialProps>]?: AttributeValue
87
+ }
88
+
89
+ type ListenerProps = {
90
+ readonly [E in EventName]?: EventListenerFor<E> | null | false | undefined
91
+ }
92
+
93
+ /* Props of an element: attributes, listeners and the special props. */
94
+ export type ElementProps = SpecialProps & AttributeProps & ListenerProps
95
+
96
+ /* Tag names, with suggestions for the known HTML elements. */
97
+ export type TagName = keyof HTMLElementTagNameMap | (string & {})
98
+
99
+ /* A child node: a nested template, text or a skipped null or false. */
100
+ export type Child = Template | string | number | true | null | false
101
+
102
+ export type ElementTemplate =
103
+ readonly [TagName, ...Child[]] | readonly [TagName, ElementProps, ...Child[]]
104
+
105
+ /* A function rendering the template for given props. */
106
+ export type PureComponent = (props: never) => RenderResult
107
+
108
+ /* A component class or a pure component. */
109
+ export type ComponentType = typeof Component<object> | PureComponent
110
+
111
+ export type ComponentTemplate =
112
+ | readonly [ComponentType, ...Child[]]
113
+ | readonly [ComponentType, Props, ...Child[]]
114
+
115
+ /*
116
+ * Component templates come first, so that type errors in element templates
117
+ * are reported against the element props.
118
+ */
119
+ export type Template = ComponentTemplate | ElementTemplate | null | false
120
+
121
+ /* The result of a render method, nothing rendered when falsy. */
122
+ export type RenderResult = Template | undefined