@potok-web-framework/core 0.1.0 → 0.3.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 (94) hide show
  1. package/dist/block.d.ts +17 -0
  2. package/dist/bootstrap-app.d.ts +8 -0
  3. package/dist/client-only.d.ts +3 -0
  4. package/dist/client.mjs +133 -0
  5. package/dist/constants-BOAOReQ3.mjs +26 -0
  6. package/dist/constants.d.ts +2 -0
  7. package/dist/context.d.ts +12 -0
  8. package/dist/detect-child.d.ts +6 -0
  9. package/dist/error-boundary.d.ts +5 -0
  10. package/dist/exports/client.d.ts +1 -0
  11. package/dist/exports/hmr.d.ts +1 -0
  12. package/dist/exports/index.d.ts +14 -0
  13. package/dist/exports/jsx-runtime.d.ts +4 -0
  14. package/dist/exports/server.d.ts +1 -0
  15. package/dist/fragment-BahmURhz.mjs +17 -0
  16. package/dist/fragment.d.ts +4 -0
  17. package/dist/hmr/hmr-dev.d.ts +9 -0
  18. package/dist/hmr/register-component.d.ts +2 -0
  19. package/dist/hmr/registered-component.d.ts +23 -0
  20. package/dist/hmr/registry.d.ts +12 -0
  21. package/dist/hmr/types.d.ts +4 -0
  22. package/dist/hmr/utils.d.ts +3 -0
  23. package/dist/hmr.mjs +42 -0
  24. package/dist/html-element-Cm0RtMkT.mjs +42 -0
  25. package/dist/html-element.d.ts +6 -0
  26. package/dist/index.mjs +199 -0
  27. package/dist/jsx-runtime.mjs +10 -0
  28. package/dist/jsx-types.d.ts +11 -0
  29. package/dist/lazy.d.ts +7 -0
  30. package/dist/lib-context-reader.d.ts +5 -0
  31. package/dist/lib-scripts.d.ts +2 -0
  32. package/dist/lifecycle-4vjEuXGy.mjs +57 -0
  33. package/dist/lifecycle.d.ts +8 -0
  34. package/dist/list.d.ts +9 -0
  35. package/dist/portal-CbcYOHLv.mjs +44 -0
  36. package/dist/portal.d.ts +10 -0
  37. package/dist/prop-types.d.ts +939 -0
  38. package/dist/ref.d.ts +6 -0
  39. package/dist/render-to-dom.d.ts +8 -0
  40. package/dist/render-to-string.d.ts +2 -0
  41. package/dist/server-node.d.ts +10 -0
  42. package/dist/server.mjs +1192 -0
  43. package/dist/show.d.ts +6 -0
  44. package/dist/signals.d.ts +32 -0
  45. package/dist/store.d.ts +26 -0
  46. package/dist/text.d.ts +5 -0
  47. package/dist/types.d.ts +39 -0
  48. package/dist/utils-CAe_kbSH.mjs +345 -0
  49. package/dist/utils.d.ts +11 -0
  50. package/package.json +9 -3
  51. package/CHANGELOG.md +0 -7
  52. package/bun.lock +0 -25
  53. package/src/block.ts +0 -102
  54. package/src/bootstrap-app.ts +0 -115
  55. package/src/client-only.ts +0 -17
  56. package/src/constants.ts +0 -27
  57. package/src/context.ts +0 -85
  58. package/src/detect-child.ts +0 -21
  59. package/src/error-boundary.ts +0 -51
  60. package/src/exports/client.ts +0 -1
  61. package/src/exports/hmr.ts +0 -1
  62. package/src/exports/index.ts +0 -21
  63. package/src/exports/jsx-runtime.ts +0 -4
  64. package/src/exports/server.ts +0 -1
  65. package/src/fragment.ts +0 -28
  66. package/src/global.dev.d.ts +0 -12
  67. package/src/hmr/hmr-dev.ts +0 -10
  68. package/src/hmr/register-component.ts +0 -109
  69. package/src/hmr/registered-component.ts +0 -59
  70. package/src/hmr/registry.ts +0 -78
  71. package/src/hmr/types.ts +0 -6
  72. package/src/hmr/utils.ts +0 -20
  73. package/src/html-element.ts +0 -95
  74. package/src/jsx-types.ts +0 -13
  75. package/src/lazy.ts +0 -44
  76. package/src/lib-context-reader.ts +0 -33
  77. package/src/lib-scripts.ts +0 -8
  78. package/src/lifecycle.ts +0 -44
  79. package/src/list.ts +0 -175
  80. package/src/portal.ts +0 -101
  81. package/src/prop-types.ts +0 -1165
  82. package/src/ref.ts +0 -11
  83. package/src/render-to-dom.ts +0 -325
  84. package/src/render-to-string.ts +0 -65
  85. package/src/server-node.ts +0 -98
  86. package/src/show.ts +0 -46
  87. package/src/signals.ts +0 -323
  88. package/src/store.ts +0 -68
  89. package/src/text.ts +0 -35
  90. package/src/types.ts +0 -69
  91. package/src/utils.ts +0 -118
  92. package/tests/signals.test.ts +0 -403
  93. package/tsconfig.json +0 -17
  94. package/vite.config.ts +0 -21
@@ -0,0 +1,5 @@
1
+ import { LibContext, MaybeArray, PotokElement } from './types';
2
+ export type LibContextReaderProps = {
3
+ children: MaybeArray<(context: LibContext) => PotokElement>;
4
+ };
5
+ export declare function LibContextReader(props: LibContextReaderProps): PotokElement;
@@ -0,0 +1,2 @@
1
+ import { PotokElement } from './types';
2
+ export declare function LibScripts(): PotokElement;
@@ -0,0 +1,57 @@
1
+ import { _ as LibBlock, c as createEffect, i as normalizeChildren, n as mergeContext, p as untrack, r as normalizeArray } from "./utils-CAe_kbSH.mjs";
2
+ var LibContextReaderClass = class extends LibBlock {
3
+ constructor(e, t) {
4
+ super(), this.props = e, this.context = t, normalizeArray(e.children).forEach((e, n) => {
5
+ this.children.push(e(t)(mergeContext(t, {
6
+ parentBlock: this,
7
+ index: n
8
+ })));
9
+ });
10
+ }
11
+ };
12
+ function LibContextReader(e) {
13
+ return function(t) {
14
+ return new LibContextReaderClass(e, t);
15
+ };
16
+ }
17
+ var ShowClass = class extends LibBlock {
18
+ constructor(e, r) {
19
+ super(), this.props = e, this.context = r;
20
+ let i = normalizeChildren(e.children);
21
+ this.addEffect(createEffect(() => {
22
+ e.when ? untrack(() => {
23
+ i.forEach((e, t) => {
24
+ this.children.push(e(mergeContext(r, {
25
+ parentBlock: this,
26
+ index: t
27
+ })));
28
+ });
29
+ }) : this.unmountChildren();
30
+ }, !0));
31
+ }
32
+ };
33
+ function Show(e) {
34
+ return function(t) {
35
+ return new ShowClass(e, t);
36
+ };
37
+ }
38
+ var LifecycleClass = class extends LibBlock {
39
+ onMountedReturn;
40
+ constructor(e, t) {
41
+ super(), this.props = e, this.context = t, normalizeChildren(e.children).forEach((e, n) => {
42
+ this.children.push(e(mergeContext(t, {
43
+ parentBlock: this,
44
+ index: n
45
+ })));
46
+ }), this.onMountedReturn = e.onMounted?.();
47
+ }
48
+ unmount() {
49
+ super.unmount(), this.onMountedReturn?.(), this.props.onUnmounted?.();
50
+ }
51
+ };
52
+ function Lifecycle(e) {
53
+ return function(t) {
54
+ return new LifecycleClass(e, t);
55
+ };
56
+ }
57
+ export { Show as n, LibContextReader as r, Lifecycle as t };
@@ -0,0 +1,8 @@
1
+ import { PotokElement, WithChildren } from './types';
2
+ type OnMoutedReturnCallback = () => void;
3
+ export type LifecycleProps = WithChildren<{
4
+ onMounted?: () => OnMoutedReturnCallback | void;
5
+ onUnmounted?: () => void;
6
+ }>;
7
+ export declare function Lifecycle(props: LifecycleProps): PotokElement;
8
+ export {};
package/dist/list.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { PotokElement } from './types';
2
+ export type ListProps<Item> = {
3
+ items: Item[];
4
+ render: (each: {
5
+ item: Item;
6
+ index: number;
7
+ }) => PotokElement;
8
+ };
9
+ export declare function List<Item>(props: ListProps<Item>): PotokElement;
@@ -0,0 +1,44 @@
1
+ import { _ as LibBlock, c as createEffect, i as normalizeChildren, n as mergeContext, p as untrack } from "./utils-CAe_kbSH.mjs";
2
+ var PortalInClass = class extends LibBlock {
3
+ constructor(e, n) {
4
+ super(), this.props = e, this.context = n;
5
+ let r;
6
+ n.portals[e.name] ? console.warn(`Портал ${e.name} уже существует`) : this.addEffect(createEffect(() => {
7
+ let t = e.name;
8
+ t !== r && untrack(() => {
9
+ delete n.portals[t], n.portals[t] = e.children;
10
+ }), r = t;
11
+ }));
12
+ }
13
+ unmount() {
14
+ super.unmount(), delete this.context.portals[this.props.name];
15
+ }
16
+ };
17
+ function PortalIn(e) {
18
+ return function(t) {
19
+ return new PortalInClass(e, t);
20
+ };
21
+ }
22
+ var PortalOutClass = class extends LibBlock {
23
+ constructor(e, i) {
24
+ super(), this.props = e, this.context = i;
25
+ let a;
26
+ this.addEffect(createEffect(() => {
27
+ let t = e.name, o = normalizeChildren(i.portals[t]);
28
+ o ? o !== a && (this.unmountChildren(), untrack(() => {
29
+ o.forEach((e, t) => {
30
+ this.children.push(e(mergeContext(i, {
31
+ parentBlock: this,
32
+ index: t
33
+ })));
34
+ });
35
+ }), a = o) : (this.unmountChildren(), a = null);
36
+ }));
37
+ }
38
+ };
39
+ function PortalOut(e) {
40
+ return function(t) {
41
+ return new PortalOutClass(e, t);
42
+ };
43
+ }
44
+ export { PortalOut as n, PortalIn as t };
@@ -0,0 +1,10 @@
1
+ import { PotokElement, WithChildren } from './types';
2
+ type PortalInProps = WithChildren<{
3
+ name: string;
4
+ }>;
5
+ export declare function PortalIn(props: PortalInProps): PotokElement;
6
+ type PortalOutProps = {
7
+ name: string;
8
+ };
9
+ export declare function PortalOut(props: PortalOutProps): PotokElement;
10
+ export {};