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
@@ -0,0 +1,10 @@
1
+ import type { ToolkitAPI } from './index.js'
2
+
3
+ declare global {
4
+ /**
5
+ * The Toolkit exposed to non-module scripts.
6
+ */
7
+ var toolkit: ToolkitAPI
8
+ }
9
+
10
+ export {}
package/src/index.ts ADDED
@@ -0,0 +1,62 @@
1
+ import { Component, Root, WebComponent } from './core/nodes.js'
2
+ import Service from './core/service.js'
3
+ import Toolkit, { toolkit } from './core/toolkit.js'
4
+ import utils from './core/utils.js'
5
+
6
+ /* The classes and helpers available on the Toolkit instance. */
7
+ type ToolkitClasses = {
8
+ Component: typeof Component
9
+ WebComponent: typeof WebComponent
10
+ Root: typeof Root
11
+ Service: typeof Service
12
+ utils: typeof utils
13
+ noop: () => void
14
+ }
15
+
16
+ const classes: ToolkitClasses = {
17
+ Component,
18
+ WebComponent,
19
+ Root,
20
+ Service,
21
+ utils,
22
+ noop: () => {},
23
+ }
24
+
25
+ Object.assign(Toolkit.prototype, classes)
26
+
27
+ export type {
28
+ AttributeValue,
29
+ Child,
30
+ ClassName,
31
+ ComponentTemplate,
32
+ ComponentType,
33
+ ElementProps,
34
+ ElementTemplate,
35
+ EventListenerFor,
36
+ Listener,
37
+ PureComponent,
38
+ RenderResult,
39
+ Style,
40
+ TagName,
41
+ Template,
42
+ } from './core/bragi.js'
43
+ export type { AttributeName, EventName } from './core/browser.js'
44
+ export type { Props } from './core/description.js'
45
+ export type {
46
+ BoundCommands,
47
+ CommandMethod,
48
+ Commands,
49
+ CommandsAPI,
50
+ State,
51
+ } from './core/dispatcher.js'
52
+ export type { ComponentClass, Connectable } from './core/nodes.js'
53
+ export type { PluginManifest, PluginSandbox } from './core/plugins.js'
54
+ export type { Update } from './core/renderer.js'
55
+ export type { Options, Settings } from './core/toolkit.js'
56
+
57
+ export { Component, Root, Service, WebComponent, utils }
58
+
59
+ /* The Toolkit instance, with the classes and helpers assigned above. */
60
+ export type ToolkitAPI = Toolkit & ToolkitClasses
61
+
62
+ export default toolkit as ToolkitAPI
@@ -0,0 +1,38 @@
1
+ import type { WebComponent } from '../core/nodes.js'
2
+ import type { PluginManifest } from '../core/plugins.js'
3
+ import type { Update } from '../core/renderer.js'
4
+
5
+ const RENDER_TIME = 'Render time'
6
+ const title = (update: Update) =>
7
+ `==> ${(update.root.constructor as typeof WebComponent).displayName} <==`
8
+
9
+ /* eslint-disable no-console */
10
+
11
+ const Logger: PluginManifest = {
12
+ name: 'logger',
13
+ permissions: ['listen-for-updates'],
14
+
15
+ onBeforeUpdate(update: Update) {
16
+ console.group(title(update))
17
+ console.log(
18
+ 'Commands:',
19
+ update.commands.map(command => command.name),
20
+ )
21
+ console.time(RENDER_TIME)
22
+ },
23
+
24
+ onAfterUpdate(update: Update) {
25
+ if (update.patches!.length) {
26
+ console.log('%cPatches:', 'color: hsl(54, 70%, 45%)', update.patches)
27
+ } else {
28
+ console.log('%c=> No update', 'color: #07a707')
29
+ }
30
+ console.timeEnd(RENDER_TIME)
31
+ console.log('--------------------------------')
32
+ console.groupEnd()
33
+ },
34
+ }
35
+
36
+ /* eslint-enable no-console */
37
+
38
+ export default Logger
package/src/release.ts ADDED
@@ -0,0 +1,3 @@
1
+ import toolkit from './index.js'
2
+
3
+ globalThis.toolkit = toolkit
package/index.js DELETED
@@ -1 +0,0 @@
1
- export {};