@potok-web-framework/core 0.7.0 → 0.9.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 (71) hide show
  1. package/dist/block.d.ts +11 -6
  2. package/dist/client/potok-preload.d.ts +6 -0
  3. package/dist/{dom/utils.d.ts → client/utils/dom.d.ts} +1 -1
  4. package/dist/client.mjs +93 -71
  5. package/dist/constants-Bxn0R4hW.mjs +34 -0
  6. package/dist/constants.d.ts +4 -2
  7. package/dist/css-BercB0Kp.mjs +8 -0
  8. package/dist/escape-from-script-tag-CRT2evI1.mjs +4 -0
  9. package/dist/exports/client.d.ts +1 -1
  10. package/dist/exports/hmr.d.ts +2 -0
  11. package/dist/exports/index.d.ts +2 -2
  12. package/dist/exports/jsx-runtime.d.ts +2 -1
  13. package/dist/exports/server.d.ts +2 -1
  14. package/dist/exports/store.d.ts +2 -0
  15. package/dist/footer-scripts.d.ts +2 -0
  16. package/dist/fragment-CXNEPBWB.mjs +18 -0
  17. package/dist/get-component-instance-id-CP6LDtpX.mjs +97 -0
  18. package/dist/header-scripts.d.ts +2 -0
  19. package/dist/hmr/constants.d.ts +12 -0
  20. package/dist/hmr/register-component.d.ts +4 -0
  21. package/dist/hmr/register-style.d.ts +1 -0
  22. package/dist/hmr/registered-component.d.ts +1 -6
  23. package/dist/hmr/remove-style.d.ts +1 -0
  24. package/dist/hmr/utils.d.ts +0 -2
  25. package/dist/hmr.mjs +13 -41
  26. package/dist/html-element-DBut4UCf.mjs +31 -0
  27. package/dist/html-element.d.ts +9 -1
  28. package/dist/index.mjs +202 -129
  29. package/dist/is-pure-object-s_MkQp1w.mjs +4 -0
  30. package/dist/jsx-runtime.mjs +4 -4
  31. package/dist/lib-node-DyXPvvVQ.mjs +192 -0
  32. package/dist/lib-node.d.ts +6 -0
  33. package/dist/list.d.ts +3 -0
  34. package/dist/normalize-children-BWrn16R7.mjs +48 -0
  35. package/dist/prop-types.d.ts +219 -240
  36. package/dist/register-component-B92kGFqC.mjs +67 -0
  37. package/dist/serialization-qOayQbjE.mjs +108 -0
  38. package/dist/{bootstrap-app.d.ts → server/bootstrap-app.d.ts} +3 -4
  39. package/dist/{render-to-string.d.ts → server/render-to-string.d.ts} +1 -1
  40. package/dist/server-node.d.ts +1 -1
  41. package/dist/server.mjs +83 -1145
  42. package/dist/signals.d.ts +5 -0
  43. package/dist/store/create-store.d.ts +2 -0
  44. package/dist/store/http-extension.d.ts +26 -0
  45. package/dist/store/types.d.ts +40 -0
  46. package/dist/store.mjs +137 -0
  47. package/dist/text-node.d.ts +12 -0
  48. package/dist/types.d.ts +11 -14
  49. package/dist/utils/css.d.ts +2 -0
  50. package/dist/utils/deep-assign-object.d.ts +1 -0
  51. package/dist/utils/escape-from-script-tag.d.ts +1 -0
  52. package/dist/utils/escape-html.d.ts +1 -0
  53. package/dist/utils/get-component-instance-id.d.ts +2 -0
  54. package/dist/utils/is-pure-object.d.ts +1 -0
  55. package/dist/utils/merge-context.d.ts +2 -0
  56. package/dist/utils/normalize-array.d.ts +2 -0
  57. package/dist/utils/normalize-children.d.ts +2 -0
  58. package/dist/utils/serialization.d.ts +2 -0
  59. package/package.json +6 -5
  60. package/dist/constants-BOAOReQ3.mjs +0 -26
  61. package/dist/fragment-BSt6shYv.mjs +0 -103
  62. package/dist/hmr/hmr-dev.d.ts +0 -9
  63. package/dist/html-element-DeGD0uGZ.mjs +0 -24
  64. package/dist/lib-scripts.d.ts +0 -2
  65. package/dist/lifecycle-C9_o5zOU.mjs +0 -58
  66. package/dist/portal-BxUviJsE.mjs +0 -45
  67. package/dist/signals-ZsU9bGc3.mjs +0 -262
  68. package/dist/store.d.ts +0 -26
  69. package/dist/text.d.ts +0 -5
  70. package/dist/utils.d.ts +0 -9
  71. /package/dist/{dom → client}/hydrate.d.ts +0 -0
@@ -0,0 +1,67 @@
1
+ import { c as untrack, i as createSignal, l as LibBlock, r as createEffect } from "./lib-node-DyXPvvVQ.mjs";
2
+ import { i as mergeContext, t as normalizeChildren } from "./normalize-children-BWrn16R7.mjs";
3
+ import { a as Lifecycle, n as HMR_COMPONENTS_REGISTRY, o as LibContextReader, t as getComponentInstanceId } from "./get-component-instance-id-CP6LDtpX.mjs";
4
+ import { t as fragment } from "./fragment-CXNEPBWB.mjs";
5
+ var ShowClass = class extends LibBlock {
6
+ constructor(t, n) {
7
+ super(), this.props = t, this.context = n;
8
+ let o = normalizeChildren(t.children), s = !1;
9
+ this.addEffect(createEffect(() => {
10
+ let r = t.when;
11
+ if (r) {
12
+ if (s) return;
13
+ untrack(() => {
14
+ o.forEach((e, t) => {
15
+ this.children.push(e(mergeContext(n, {
16
+ parentBlock: this,
17
+ index: t
18
+ })));
19
+ });
20
+ });
21
+ } else this.unmountChildren();
22
+ s = r;
23
+ }, !0));
24
+ }
25
+ };
26
+ function Show(e) {
27
+ return function(t) {
28
+ return new ShowClass(e, t);
29
+ };
30
+ }
31
+ function registerComponent(e, n, r) {
32
+ let i = HMR_COMPONENTS_REGISTRY.addComponent(n, r, e);
33
+ HMR_COMPONENTS_REGISTRY.notifyComponentUpdate(n, r);
34
+ function a(e, t, n = !1) {
35
+ let r = getComponentInstanceId(t), a = i.getCachedInstance(r);
36
+ if (!n && a) return a.element;
37
+ let o = i.component(e);
38
+ return i.addCachedInstance(r, o), o;
39
+ }
40
+ return (e) => LibContextReader({ children(c) {
41
+ let l = createSignal({ element: a(e, c) }), u = getComponentInstanceId(c);
42
+ return Lifecycle({
43
+ onMounted() {
44
+ let t = HMR_COMPONENTS_REGISTRY.subscribeToComponent(n, r, () => {
45
+ l.element = null, l.element = a(e, c, !0);
46
+ });
47
+ return i.unmarkInstanceAsRemovable(u), () => {
48
+ t(), i.markInstanceAsRemovable(u), setTimeout(() => {
49
+ i.getCachedInstance(u)?.isRemovable && i.removeCachedInstance(u);
50
+ });
51
+ };
52
+ },
53
+ children: [Show({
54
+ get when() {
55
+ return l.element !== null;
56
+ },
57
+ children: [fragment({ get children() {
58
+ return [l.element];
59
+ } })]
60
+ })]
61
+ });
62
+ } });
63
+ }
64
+ function isRegisteredComponentElement(e) {
65
+ return typeof e == "function" && "dependencies" in e;
66
+ }
67
+ export { registerComponent as n, Show as r, isRegisteredComponentElement as t };
@@ -0,0 +1,108 @@
1
+ import { t as isPureObject } from "./is-pure-object-s_MkQp1w.mjs";
2
+ var SERIALIZERS = {
3
+ Date: (e) => ({
4
+ $$type: "Date",
5
+ value: e.toISOString()
6
+ }),
7
+ BigInt: (e) => ({
8
+ $$type: "BigInt",
9
+ value: e.toString()
10
+ }),
11
+ RegExp: (e) => ({
12
+ $$type: "RegExp",
13
+ value: {
14
+ source: e.source,
15
+ flags: e.flags
16
+ }
17
+ }),
18
+ Error: (e) => ({
19
+ $$type: "Error",
20
+ value: {
21
+ name: e.name,
22
+ message: e.message,
23
+ stack: e.stack
24
+ }
25
+ }),
26
+ URL: (e) => ({
27
+ $$type: "URL",
28
+ value: e.href
29
+ }),
30
+ Set: (e, t) => ({
31
+ $$type: "Set",
32
+ value: Array.from(e, (e) => serializeValue(e, t))
33
+ }),
34
+ Map: (e, t) => ({
35
+ $$type: "Map",
36
+ value: Array.from(e, ([e, n]) => [serializeValue(e, t), serializeValue(n, t)])
37
+ }),
38
+ AbortController: () => ({
39
+ $$type: "AbortController",
40
+ value: null
41
+ })
42
+ }, DESERIALIZERS = {
43
+ Date: (e) => new Date(e),
44
+ BigInt: (e) => BigInt(e),
45
+ RegExp: (e) => new RegExp(e.source, e.flags),
46
+ Error: (e) => {
47
+ let t = Error(e.message);
48
+ return t.name = e.name, t.stack = e.stack, t;
49
+ },
50
+ URL: (e) => new URL(e),
51
+ Set: (e) => new Set(e.map(deserializeValue)),
52
+ Map: (e) => new Map(e.map(([e, t]) => [deserializeValue(e), deserializeValue(t)])),
53
+ AbortController: () => new AbortController()
54
+ };
55
+ function getSerializer(e) {
56
+ if (e instanceof Date) return SERIALIZERS.Date;
57
+ if (typeof e == "bigint") return SERIALIZERS.BigInt;
58
+ if (e instanceof RegExp) return SERIALIZERS.RegExp;
59
+ if (e instanceof Error) return SERIALIZERS.Error;
60
+ if (e instanceof URL) return SERIALIZERS.URL;
61
+ if (e instanceof Set) return SERIALIZERS.Set;
62
+ if (e instanceof Map) return SERIALIZERS.Map;
63
+ if (e instanceof AbortController) return SERIALIZERS.AbortController;
64
+ }
65
+ function isSerializedValue(e) {
66
+ return typeof e == "object" && !!e && "$$type" in e && "value" in e;
67
+ }
68
+ function serializeValue(t, n = /* @__PURE__ */ new WeakMap()) {
69
+ if (n.has(t)) return n.get(t);
70
+ if (typeof t != "object" || !t) return t;
71
+ let i = getSerializer(t);
72
+ if (i) {
73
+ let e = i(t, n);
74
+ return n.set(t, e), e;
75
+ } else if (Array.isArray(t)) {
76
+ let e = [];
77
+ n.set(t, e);
78
+ for (let r = 0; r < t.length; r++) e[r] = serializeValue(t[r], n);
79
+ return e;
80
+ } else if (isPureObject(t)) {
81
+ let e = {};
82
+ n.set(t, e);
83
+ for (let [r, i] of Object.entries(t)) e[r] = serializeValue(i, n);
84
+ return e;
85
+ }
86
+ return t;
87
+ }
88
+ function serializeWithTypes(e) {
89
+ return JSON.stringify(serializeValue(e));
90
+ }
91
+ function deserializeValue(t) {
92
+ if (typeof t != "object" || !t) return t;
93
+ if (isSerializedValue(t)) {
94
+ let e = DESERIALIZERS[t.$$type];
95
+ return e ? e(t.value) : t;
96
+ }
97
+ if (Array.isArray(t)) return t.map(deserializeValue);
98
+ if (isPureObject(t)) {
99
+ let e = {};
100
+ for (let n in t) Object.prototype.hasOwnProperty.call(t, n) && (e[n] = deserializeValue(t[n]));
101
+ return e;
102
+ }
103
+ return t;
104
+ }
105
+ function deserializeWithTypes(e) {
106
+ return deserializeValue(JSON.parse(e));
107
+ }
108
+ export { serializeWithTypes as n, deserializeWithTypes as t };
@@ -1,8 +1,7 @@
1
- import { PotokElement } from './types';
2
- type App = (request: Request) => PotokElement;
1
+ import { MaybePromise } from '../types';
3
2
  type BootstrapAppOptions = {
4
- app: App;
3
+ render: (request: Request) => MaybePromise<string>;
5
4
  port?: number;
6
5
  };
7
- export declare function bootstrapApp(options: BootstrapAppOptions): void;
6
+ export declare function bootstrapApp(options: BootstrapAppOptions): Promise<void>;
8
7
  export {};
@@ -1,2 +1,2 @@
1
- import { PotokElement } from './types';
1
+ import { PotokElement } from '../types';
2
2
  export declare function renderToString(creator: PotokElement): Promise<string>;
@@ -1,4 +1,4 @@
1
- import { LibNode } from './types';
1
+ import { LibNode } from './lib-node';
2
2
  export declare class ServerNode {
3
3
  libNode: LibNode;
4
4
  parent: ServerNode | null;