@potok-web-framework/core 0.12.0 → 0.14.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.
package/dist/block.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { LibHTMLElementNode } from './html-element';
1
+ import { LibDocumentTypeNode } from './document-type-node';
2
+ import { LibHTMLElementNode } from './html-element-node';
2
3
  import { LibNode } from './lib-node';
3
4
  import { Effect } from './signals';
4
5
  import { LibTextNode } from './text-node';
@@ -16,6 +17,7 @@ export declare abstract class LibBlock {
16
17
  isNode(): this is LibNode;
17
18
  isHTMLElementNode(): this is LibHTMLElementNode;
18
19
  isTextNode(): this is LibTextNode;
20
+ isDocumentTypeNode(): this is LibDocumentTypeNode;
19
21
  addEffect(effect: Effect): void;
20
22
  unmountChildren(): void;
21
23
  unmount(): void;
@@ -1,4 +1,5 @@
1
1
  import { LibNode } from '../../lib-node';
2
2
  export declare function isTextNode(node: Node): node is Text;
3
3
  export declare function isHTMLElementNode(node: Node): node is HTMLElement;
4
+ export declare function isDocumentTypeNode(node: Node): node is DocumentType;
4
5
  export declare function isLibNodeEqualToDomNode(libNode: LibNode, domNode: Node): boolean;
package/dist/client.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { i as createSignal, n as batch, r as createEffect } from "./lib-node-JxhtuJyh.mjs";
1
+ import { i as createSignal, n as batch, r as createEffect } from "./lib-node-A2uZ5QH1.mjs";
2
2
  import { i as PRELOAD_SCRIPTS_SCRIPT_ID, n as HYDRATION_STATE_SCRIPT_ID, r as NON_BUBBLING_EVENTS } from "./constants-Bxn0R4hW.mjs";
3
3
  import { t as deserializeWithTypes } from "./serialization-qOayQbjE.mjs";
4
4
  import { n as normalizeCssPropertyValue, t as normalizeCssPropertyName } from "./css-BercB0Kp.mjs";
@@ -8,8 +8,11 @@ function isTextNode(e) {
8
8
  function isHTMLElementNode(e) {
9
9
  return e.nodeType === Node.ELEMENT_NODE;
10
10
  }
11
+ function isDocumentTypeNode(e) {
12
+ return e.nodeType === Node.DOCUMENT_TYPE_NODE;
13
+ }
11
14
  function isLibNodeEqualToDomNode(e, t) {
12
- return e.isTextNode() && isTextNode(t) ? String(e.props.text) === t.textContent : e.isHTMLElementNode() && isHTMLElementNode(t) ? e.props.tag === t.tagName.toLowerCase() : !1;
15
+ return e.isTextNode() && isTextNode(t) ? String(e.props.text) === t.textContent : e.isHTMLElementNode() && isHTMLElementNode(t) ? e.props.tag === t.tagName.toLowerCase() : e.isDocumentTypeNode() && isDocumentTypeNode(t) ? e.props.type === t.name.toLowerCase() : !1;
13
16
  }
14
17
  function hydrate(s) {
15
18
  let c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Set(), d = document.getElementById(PRELOAD_SCRIPTS_SCRIPT_ID), f = createSignal({
@@ -79,7 +82,7 @@ function hydrate(s) {
79
82
  n = n.nextSibling, e.parentElement?.removeChild(e);
80
83
  }
81
84
  }
82
- } else c.has(e) || (e.isTextNode() ? c.set(e, document.createTextNode(String(e.props.text))) : e.isHTMLElementNode() && c.set(e, document.createElement(e.props.tag)));
85
+ } else c.has(e) || (e.isTextNode() ? c.set(e, document.createTextNode(String(e.props.text))) : e.isHTMLElementNode() ? c.set(e, document.createElement(e.props.tag)) : e.isDocumentTypeNode() && c.set(e, document.implementation.createDocumentType(e.props.type, "", "")));
83
86
  let s = c.get(e);
84
87
  h(e, (t, n) => {
85
88
  if (e.isTextNode()) s.textContent = String(n);
@@ -0,0 +1,12 @@
1
+ import { LibNode } from './lib-node';
2
+ import { LibContext, PotokElement } from './types';
3
+ export type LibDocumentTypeNodeProps = {
4
+ type: "html" | "xml" | "svg";
5
+ };
6
+ export declare class LibDocumentTypeNode extends LibNode {
7
+ readonly props: LibDocumentTypeNodeProps;
8
+ readonly context: LibContext;
9
+ constructor(props: LibDocumentTypeNodeProps, context: LibContext);
10
+ isDocumentTypeNode(): this is LibDocumentTypeNode;
11
+ }
12
+ export declare function DocumentType(props: LibDocumentTypeNodeProps): PotokElement;
@@ -10,5 +10,6 @@ export { PortalIn, PortalOut } from '../portal';
10
10
  export { createElementReference } from '../ref';
11
11
  export { Show } from '../show';
12
12
  export { createSignal, createEffect, batch, untrack, deepTrack, getSignal, } from '../signals';
13
+ export { DocumentType } from '../document-type-node';
13
14
  export type { PotokElement, WithChildren } from '../types';
14
15
  export type * from '../jsx-types';
@@ -1,5 +1,5 @@
1
1
  export { fragment } from '../fragment';
2
- export { htmlElement } from '../html-element';
2
+ export { htmlElement } from '../html-element-node';
3
3
  export { text } from '../text-node';
4
4
  export { detectChild } from '../detect-child';
5
5
  export { potokPreload } from '../client/potok-preload';
@@ -1,5 +1,5 @@
1
- import { l as LibBlock } from "./lib-node-JxhtuJyh.mjs";
2
- import { i as mergeContext, t as normalizeChildren } from "./normalize-children-Dh51Diw_.mjs";
1
+ import { l as LibBlock } from "./lib-node-A2uZ5QH1.mjs";
2
+ import { i as mergeContext, t as normalizeChildren } from "./normalize-children-C7XDL3rl.mjs";
3
3
  var FragmentClass = class extends LibBlock {
4
4
  constructor(e, r) {
5
5
  super(), this.props = e, this.context = r, normalizeChildren(e.children).forEach((e, n) => {
@@ -1,5 +1,5 @@
1
- import { i as createSignal, l as LibBlock } from "./lib-node-JxhtuJyh.mjs";
2
- import { i as mergeContext, r as normalizeArray, t as normalizeChildren } from "./normalize-children-Dh51Diw_.mjs";
1
+ import { i as createSignal, l as LibBlock } from "./lib-node-A2uZ5QH1.mjs";
2
+ import { i as mergeContext, r as normalizeArray, t as normalizeChildren } from "./normalize-children-C7XDL3rl.mjs";
3
3
  var LibContextReaderClass = class extends LibBlock {
4
4
  constructor(e, t) {
5
5
  super(), this.props = e, this.context = t, normalizeArray(e.children).forEach((e, r) => {
package/dist/hmr.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { i as createSignal } from "./lib-node-JxhtuJyh.mjs";
2
- import { i as HMR_STYLES } from "./get-component-instance-id-BC0t58Yc.mjs";
3
- import { n as registerComponent } from "./register-component-BpqHm9l-.mjs";
1
+ import { i as createSignal } from "./lib-node-A2uZ5QH1.mjs";
2
+ import { i as HMR_STYLES } from "./get-component-instance-id-BsCBJaZv.mjs";
3
+ import { n as registerComponent } from "./register-component-fwzVBk6g.mjs";
4
4
  function registerStyle(n, r) {
5
5
  let i = HMR_STYLES.styles.find((e) => e.id === n);
6
6
  i ? i.css = r : HMR_STYLES.styles = [...HMR_STYLES.styles, createSignal({
@@ -1,5 +1,5 @@
1
- import { t as LibNode } from "./lib-node-JxhtuJyh.mjs";
2
- import { i as mergeContext, t as normalizeChildren } from "./normalize-children-Dh51Diw_.mjs";
1
+ import { t as LibNode } from "./lib-node-A2uZ5QH1.mjs";
2
+ import { i as mergeContext, t as normalizeChildren } from "./normalize-children-C7XDL3rl.mjs";
3
3
  function potokPreload(e, t) {
4
4
  let n = () => e();
5
5
  return n.dependencies = t, n;
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
- import { a as deepTrack, c as untrack, i as createSignal, l as LibBlock, n as batch, o as getSignal, r as createEffect, s as isSignal } from "./lib-node-JxhtuJyh.mjs";
2
- import { i as mergeContext, n as text, t as normalizeChildren } from "./normalize-children-Dh51Diw_.mjs";
3
- import { a as Lifecycle, i as HMR_STYLES, o as LibContextReader } from "./get-component-instance-id-BC0t58Yc.mjs";
4
- import { r as Show, t as isRegisteredComponentElement } from "./register-component-BpqHm9l-.mjs";
5
- import { n as isPotokPreloader, t as htmlElement } from "./html-element-C4QFddWA.mjs";
6
- import { t as fragment } from "./fragment-miU_1DSF.mjs";
1
+ import { a as deepTrack, c as untrack, i as createSignal, l as LibBlock, n as batch, o as getSignal, r as createEffect, s as isSignal, t as LibNode } from "./lib-node-A2uZ5QH1.mjs";
2
+ import { i as mergeContext, n as text, t as normalizeChildren } from "./normalize-children-C7XDL3rl.mjs";
3
+ import { a as Lifecycle, i as HMR_STYLES, o as LibContextReader } from "./get-component-instance-id-BsCBJaZv.mjs";
4
+ import { r as Show, t as isRegisteredComponentElement } from "./register-component-fwzVBk6g.mjs";
5
+ import { n as isPotokPreloader, t as htmlElement } from "./html-element-node-TpTgOUo-.mjs";
6
+ import { t as fragment } from "./fragment-BPbIbst6.mjs";
7
7
  import { i as PRELOAD_SCRIPTS_SCRIPT_ID, n as HYDRATION_STATE_SCRIPT_ID } from "./constants-Bxn0R4hW.mjs";
8
8
  import { t as escapeFromScriptTag } from "./escape-from-script-tag-CRT2evI1.mjs";
9
9
  import { n as serializeWithTypes } from "./serialization-qOayQbjE.mjs";
@@ -152,8 +152,6 @@ var ListClass = class extends LibBlock {
152
152
  });
153
153
  }), this.entries.forEach((e, n) => {
154
154
  t.has(n) || e.block.unmount();
155
- }), this.children.forEach((e) => {
156
- e?.isNode() && e.insert();
157
155
  }), this.entries = t;
158
156
  }
159
157
  unmount() {
@@ -270,4 +268,17 @@ function PortalOut(e) {
270
268
  return new PortalOutClass(e, t);
271
269
  };
272
270
  }
273
- export { ClientOnly, ErrorBoundary, FooterScripts, HeaderScripts, Lazy, LibContextReader, Lifecycle, List, PortalIn, PortalOut, Show, batch, createEffect, createElementReference, createSignal, deepTrack, getSignal, untrack };
271
+ var LibDocumentTypeNode = class extends LibNode {
272
+ constructor(e, t) {
273
+ super(), this.props = e, this.context = t, this.insert();
274
+ }
275
+ isDocumentTypeNode() {
276
+ return !0;
277
+ }
278
+ };
279
+ function DocumentType(e) {
280
+ return function(t) {
281
+ return new LibDocumentTypeNode(e, t);
282
+ };
283
+ }
284
+ export { ClientOnly, DocumentType, ErrorBoundary, FooterScripts, HeaderScripts, Lazy, LibContextReader, Lifecycle, List, PortalIn, PortalOut, Show, batch, createEffect, createElementReference, createSignal, deepTrack, getSignal, untrack };
@@ -1,6 +1,6 @@
1
- import { n as text } from "./normalize-children-Dh51Diw_.mjs";
2
- import { r as potokPreload, t as htmlElement } from "./html-element-C4QFddWA.mjs";
3
- import { t as fragment } from "./fragment-miU_1DSF.mjs";
1
+ import { n as text } from "./normalize-children-C7XDL3rl.mjs";
2
+ import { r as potokPreload, t as htmlElement } from "./html-element-node-TpTgOUo-.mjs";
3
+ import { t as fragment } from "./fragment-BPbIbst6.mjs";
4
4
  function detectChild(e) {
5
5
  let t = e.value, n = typeof t;
6
6
  return n === "string" || n === "number" || n === "boolean" ? text({ get text() {
@@ -32,6 +32,9 @@ var LibBlock = class {
32
32
  isTextNode() {
33
33
  return !1;
34
34
  }
35
+ isDocumentTypeNode() {
36
+ return !1;
37
+ }
35
38
  addEffect(e) {
36
39
  this.effects.add(e);
37
40
  }
@@ -1,4 +1,4 @@
1
- import { t as LibNode } from "./lib-node-JxhtuJyh.mjs";
1
+ import { t as LibNode } from "./lib-node-A2uZ5QH1.mjs";
2
2
  function mergeContext(e, t) {
3
3
  return {
4
4
  parentBlock: t.parentBlock,
@@ -1,7 +1,7 @@
1
- import { c as untrack, i as createSignal, l as LibBlock, r as createEffect } from "./lib-node-JxhtuJyh.mjs";
2
- import { i as mergeContext, t as normalizeChildren } from "./normalize-children-Dh51Diw_.mjs";
3
- import { a as Lifecycle, n as HMR_COMPONENTS_REGISTRY, o as LibContextReader, t as getComponentInstanceId } from "./get-component-instance-id-BC0t58Yc.mjs";
4
- import { t as fragment } from "./fragment-miU_1DSF.mjs";
1
+ import { c as untrack, i as createSignal, l as LibBlock, r as createEffect } from "./lib-node-A2uZ5QH1.mjs";
2
+ import { i as mergeContext, t as normalizeChildren } from "./normalize-children-C7XDL3rl.mjs";
3
+ import { a as Lifecycle, n as HMR_COMPONENTS_REGISTRY, o as LibContextReader, t as getComponentInstanceId } from "./get-component-instance-id-BsCBJaZv.mjs";
4
+ import { t as fragment } from "./fragment-BPbIbst6.mjs";
5
5
  var ShowClass = class extends LibBlock {
6
6
  constructor(t, n) {
7
7
  super(), this.props = t, this.context = n;
@@ -1,10 +1,11 @@
1
- import { LibNode } from './lib-node';
1
+ import { LibNode } from '../lib-node';
2
2
  export declare class ServerNode {
3
- libNode: LibNode;
3
+ readonly libNode: LibNode | null;
4
4
  parent: ServerNode | null;
5
5
  children: ServerNode[];
6
- constructor(libNode: LibNode);
6
+ constructor(libNode: LibNode | null);
7
7
  addChild(node: ServerNode, after: ServerNode | null): void;
8
8
  remove(): void;
9
+ private stringifyChildren;
9
10
  stringify(): string;
10
11
  }
package/dist/server.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { i as createSignal, n as batch } from "./lib-node-JxhtuJyh.mjs";
1
+ import { i as createSignal, n as batch } from "./lib-node-A2uZ5QH1.mjs";
2
2
  import { t as escapeFromScriptTag } from "./escape-from-script-tag-CRT2evI1.mjs";
3
3
  import { n as normalizeCssPropertyValue, t as normalizeCssPropertyName } from "./css-BercB0Kp.mjs";
4
4
  import { clientDependencies } from "virtual:client-variables";
@@ -29,14 +29,14 @@ function escapeHtml(e) {
29
29
  return /[&<>"']/.test(e) ? e.replace(/[&<>"']/g, (e) => HTML_ESCAPE_MAP[e]) : e;
30
30
  }
31
31
  var ServerNode = class {
32
- libNode;
33
32
  parent = null;
34
33
  children = [];
35
34
  constructor(e) {
36
35
  this.libNode = e;
37
36
  }
38
37
  addChild(e, t) {
39
- if (t) {
38
+ let n = this.children.indexOf(e);
39
+ if (n !== -1 && this.children.splice(n, 1), t) {
40
40
  let n = this.children.indexOf(t);
41
41
  this.children.splice(n + 1, 0, e);
42
42
  } else this.children.push(e);
@@ -45,7 +45,11 @@ var ServerNode = class {
45
45
  remove() {
46
46
  this.parent && this.parent.children.splice(this.parent.children.indexOf(this), 1);
47
47
  }
48
+ stringifyChildren() {
49
+ return this.children.map((e) => e.stringify()).join("");
50
+ }
48
51
  stringify() {
52
+ if (!this.libNode) return this.stringifyChildren();
49
53
  if (this.libNode.isTextNode()) {
50
54
  let e = this.libNode.parentElementNode?.props.tag;
51
55
  return e === "title" ? escapeHtml(String(this.libNode.props.text)) : e === "script" ? escapeFromScriptTag(String(this.libNode.props.text)) : `<!-- -->${escapeHtml(String(this.libNode.props.text))}<!-- -->`;
@@ -73,10 +77,8 @@ var ServerNode = class {
73
77
  } else if (t.startsWith("on")) continue;
74
78
  else e += ` ${t}="${escapeHtml(String(a))}"`;
75
79
  }
76
- return e += ">", this.children.forEach((t) => {
77
- e += t.stringify();
78
- }), e += `</${this.libNode.props.tag}>`, e;
79
- }
80
+ return e += ">", e += this.stringifyChildren(), e += `</${this.libNode.props.tag}>`, e;
81
+ } else if (this.libNode.isDocumentTypeNode()) return `<!DOCTYPE ${escapeHtml(this.libNode.props.type)}>`;
80
82
  throw Error("Not implemented");
81
83
  }
82
84
  }, clientDependencyScripts = clientDependencies.map((t) => createSignal({
@@ -98,7 +100,7 @@ async function renderToString(n) {
98
100
  });
99
101
  }
100
102
  }
101
- }), i = /* @__PURE__ */ new Map(), a, o = [];
103
+ }), i = /* @__PURE__ */ new Map(), a = new ServerNode(null), o = [];
102
104
  function s(e) {
103
105
  return i.has(e) || i.set(e, new ServerNode(e)), i.get(e);
104
106
  }
@@ -113,14 +115,14 @@ async function renderToString(n) {
113
115
  promises: o,
114
116
  isHydrating: !1,
115
117
  insertNode(e) {
116
- let t = e.parentElementNode ? s(e.parentElementNode) : null, n = s(e), r = e.previousNode ? s(e.previousNode) : null;
117
- t === null ? a = n : t?.addChild(n, r);
118
+ let t = e.parentElementNode ? s(e.parentElementNode) : a, n = s(e), r = e.previousNode ? s(e.previousNode) : null;
119
+ t.addChild(n, r);
118
120
  },
119
121
  removeNode(e) {
120
122
  i.get(e)?.remove();
121
123
  }
122
124
  });
123
- if (await Promise.all(o), !a) throw Error("Корневая нода не найдена");
125
+ await Promise.all(o);
124
126
  let l = a.stringify();
125
127
  return c.unmount(), l;
126
128
  }
package/dist/store.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { a as deepTrack, i as createSignal, l as LibBlock, n as batch, r as createEffect } from "./lib-node-JxhtuJyh.mjs";
2
- import { i as mergeContext, r as normalizeArray, t as normalizeChildren } from "./normalize-children-Dh51Diw_.mjs";
3
- import { a as Lifecycle, o as LibContextReader, r as HMR_STATE_CACHE, t as getComponentInstanceId } from "./get-component-instance-id-BC0t58Yc.mjs";
1
+ import { a as deepTrack, i as createSignal, l as LibBlock, n as batch, r as createEffect } from "./lib-node-A2uZ5QH1.mjs";
2
+ import { i as mergeContext, r as normalizeArray, t as normalizeChildren } from "./normalize-children-C7XDL3rl.mjs";
3
+ import { a as Lifecycle, o as LibContextReader, r as HMR_STATE_CACHE, t as getComponentInstanceId } from "./get-component-instance-id-BsCBJaZv.mjs";
4
4
  import { t as isPureObject } from "./is-pure-object-s_MkQp1w.mjs";
5
5
  var ContextProvider = class extends LibBlock {
6
6
  constructor(e, t, n) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@potok-web-framework/core",
3
- "version": "0.12.0",
3
+ "version": "0.14.0",
4
4
  "exports": {
5
5
  ".": {
6
6
  "import": "./dist/index.mjs",