@oscarpalmer/abydon 0.16.0 → 0.17.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 (45) hide show
  1. package/dist/{abydon.full.js → abydon.full.mjs} +307 -186
  2. package/dist/constants.d.mts +20 -0
  3. package/dist/{constants.js → constants.mjs} +2 -0
  4. package/dist/fragment-9qTBAvtR.d.mts +82 -0
  5. package/dist/fragment.d.mts +2 -0
  6. package/dist/{fragment.js → fragment.mjs} +35 -6
  7. package/dist/fragments.d.mts +16 -0
  8. package/dist/{fragments.js → fragments.mjs} +8 -3
  9. package/dist/helpers/dom.d.mts +6 -0
  10. package/dist/helpers/{dom.js → dom.mjs} +3 -1
  11. package/dist/helpers/index.d.mts +9 -0
  12. package/dist/helpers/{index.js → index.mjs} +6 -4
  13. package/dist/index.d.mts +21 -0
  14. package/dist/index.mjs +24 -0
  15. package/dist/models.d.mts +2 -0
  16. package/dist/models.mjs +1 -0
  17. package/dist/node/attribute/index.d.mts +6 -0
  18. package/dist/node/attribute/{index.js → index.mjs} +5 -3
  19. package/dist/node/attribute/value.d.mts +6 -0
  20. package/dist/node/attribute/{value.js → value.mjs} +11 -8
  21. package/dist/node/event.d.mts +4 -0
  22. package/dist/node/{event.js → event.mjs} +3 -1
  23. package/dist/node/index.d.mts +6 -0
  24. package/dist/node/{index.js → index.mjs} +9 -7
  25. package/dist/node/value.d.mts +7 -0
  26. package/dist/node/{value.js → value.mjs} +7 -5
  27. package/dist/parse.d.mts +6 -0
  28. package/dist/{parse.js → parse.mjs} +3 -1
  29. package/package.json +42 -40
  30. package/src/node/attribute/value.ts +8 -5
  31. package/dist/index.js +0 -11
  32. package/dist/models.js +0 -0
  33. package/types/constants.d.ts +0 -17
  34. package/types/fragment.d.ts +0 -38
  35. package/types/fragments.d.ts +0 -13
  36. package/types/helpers/dom.d.ts +0 -3
  37. package/types/helpers/index.d.ts +0 -5
  38. package/types/index.d.ts +0 -20
  39. package/types/models.d.ts +0 -41
  40. package/types/node/attribute/index.d.ts +0 -2
  41. package/types/node/attribute/value.d.ts +0 -2
  42. package/types/node/event.d.ts +0 -1
  43. package/types/node/index.d.ts +0 -2
  44. package/types/node/value.d.ts +0 -3
  45. package/types/parse.d.ts +0 -2
@@ -0,0 +1,20 @@
1
+ //#region src/constants.d.ts
2
+ declare const ATTRIBUTE_CLASS_PREFIX_LENGTH = 6;
3
+ declare const EVENT_DEFAULTS: Record<string, string>;
4
+ declare const EXPRESSION_ABYDON_ATTRIBUTE_FULL: RegExp;
5
+ declare const EXPRESSION_ABYDON_ATTRIBUTE_PREFIX: RegExp;
6
+ declare const EXPRESSION_ABYDON_CONTENT: RegExp;
7
+ declare const EXPRESSION_ATTRIBUTE_CLASS: RegExp;
8
+ declare const EXPRESSION_ATTRIBUTE_STYLE_FULL: RegExp;
9
+ declare const EXPRESSION_ATTRIBUTE_STYLE_PREFIX: RegExp;
10
+ declare const EXPRESSION_EVENT_CHANGE_TYPES: RegExp;
11
+ declare const EXPRESSION_EVENT_NAME: RegExp;
12
+ declare const EXPRESSION_EVENT_OPTIONS_ACTIVE: RegExp;
13
+ declare const EXPRESSION_EVENT_OPTIONS_CAPTURE: RegExp;
14
+ declare const EXPRESSION_EVENT_OPTIONS_ONCE: RegExp;
15
+ declare const EXPRESSION_EVENT_PREFIX: RegExp;
16
+ declare const EXPRESSION_PERIOD: RegExp;
17
+ declare const NAME_FRAGMENT = "$fragment";
18
+ declare const NAME_FRAGMENTS = "$fragments";
19
+ //#endregion
20
+ export { ATTRIBUTE_CLASS_PREFIX_LENGTH, EVENT_DEFAULTS, EXPRESSION_ABYDON_ATTRIBUTE_FULL, EXPRESSION_ABYDON_ATTRIBUTE_PREFIX, EXPRESSION_ABYDON_CONTENT, EXPRESSION_ATTRIBUTE_CLASS, EXPRESSION_ATTRIBUTE_STYLE_FULL, EXPRESSION_ATTRIBUTE_STYLE_PREFIX, EXPRESSION_EVENT_CHANGE_TYPES, EXPRESSION_EVENT_NAME, EXPRESSION_EVENT_OPTIONS_ACTIVE, EXPRESSION_EVENT_OPTIONS_CAPTURE, EXPRESSION_EVENT_OPTIONS_ONCE, EXPRESSION_EVENT_PREFIX, EXPRESSION_PERIOD, NAME_FRAGMENT, NAME_FRAGMENTS };
@@ -1,3 +1,4 @@
1
+ //#region src/constants.ts
1
2
  const ATTRIBUTE_CLASS_PREFIX_LENGTH = 6;
2
3
  const EVENT_DEFAULTS = {
3
4
  A: "click",
@@ -22,4 +23,5 @@ const EXPRESSION_EVENT_PREFIX = /^@/;
22
23
  const EXPRESSION_PERIOD = /\./;
23
24
  const NAME_FRAGMENT = "$fragment";
24
25
  const NAME_FRAGMENTS = "$fragments";
26
+ //#endregion
25
27
  export { ATTRIBUTE_CLASS_PREFIX_LENGTH, EVENT_DEFAULTS, EXPRESSION_ABYDON_ATTRIBUTE_FULL, EXPRESSION_ABYDON_ATTRIBUTE_PREFIX, EXPRESSION_ABYDON_CONTENT, EXPRESSION_ATTRIBUTE_CLASS, EXPRESSION_ATTRIBUTE_STYLE_FULL, EXPRESSION_ATTRIBUTE_STYLE_PREFIX, EXPRESSION_EVENT_CHANGE_TYPES, EXPRESSION_EVENT_NAME, EXPRESSION_EVENT_OPTIONS_ACTIVE, EXPRESSION_EVENT_OPTIONS_CAPTURE, EXPRESSION_EVENT_OPTIONS_ONCE, EXPRESSION_EVENT_PREFIX, EXPRESSION_PERIOD, NAME_FRAGMENT, NAME_FRAGMENTS };
@@ -0,0 +1,82 @@
1
+ import { Reactive, ReactiveArray, Unsubscribe } from "@oscarpalmer/mora";
2
+
3
+ //#region src/models.d.ts
4
+ type FragmentConfiguration = {
5
+ /**
6
+ * Should the template be cached? _(defaults to `true`)_
7
+ */
8
+ cache?: boolean;
9
+ /**
10
+ * Identifier for the fragment
11
+ *
12
+ * _(An identifier can be used to uniquely identify a fragment,
13
+ * which helps prevent re-rendering in certain scenarios)_
14
+ */
15
+ identifier?: unknown;
16
+ };
17
+ type FragmentData = {
18
+ expressions: unknown[];
19
+ items: FragmentItem[];
20
+ mora: MoraData;
21
+ strings: TemplateStringsArray;
22
+ template?: string;
23
+ values: unknown[];
24
+ };
25
+ type FragmentItem = {
26
+ fragments?: Fragment[];
27
+ nodes?: ChildNode[];
28
+ text?: Text;
29
+ };
30
+ type FragmentsState = {
31
+ array: ReactiveArray<unknown>;
32
+ fragment: (item: unknown) => Fragment;
33
+ identify: (item: unknown) => unknown;
34
+ instances: Record<string, Fragment>;
35
+ mapped: ReactiveArray<Fragment>;
36
+ subscriber: Unsubscribe | undefined;
37
+ };
38
+ type MoraData = {
39
+ subscribers: Set<() => void>;
40
+ values: Set<Reactive<unknown>>;
41
+ };
42
+ //#endregion
43
+ //#region src/fragment.d.ts
44
+ declare class Fragment {
45
+ #private;
46
+ /**
47
+ * Fragment identifier
48
+ */
49
+ get identifier(): unknown;
50
+ constructor(strings: TemplateStringsArray, expressions: unknown[]);
51
+ /**
52
+ * Append the fragment to the given element
53
+ * @param element Element to append to
54
+ */
55
+ appendTo(element: Element): void;
56
+ /**
57
+ * Configure the fragment
58
+ * @param configuration Configuration options
59
+ * @returns Fragment
60
+ */
61
+ configure(configuration: FragmentConfiguration): Fragment;
62
+ /**
63
+ * Get a list of the fragment's nodes
64
+ * @returns List of nodes
65
+ */
66
+ get(): ChildNode[];
67
+ /**
68
+ * Set an identifier for the fragment
69
+ *
70
+ * _An identifier can be used to uniquely identify a fragment,
71
+ * which helps prevent re-rendering in certain scenarios._
72
+ * @param identifier Identifier
73
+ * @returns Fragment
74
+ */
75
+ identify(identifier: unknown): Fragment;
76
+ /**
77
+ * Remove the fragment from the DOM
78
+ */
79
+ remove(): void;
80
+ }
81
+ //#endregion
82
+ export { FragmentsState as a, FragmentItem as i, FragmentConfiguration as n, FragmentData as r, Fragment as t };
@@ -0,0 +1,2 @@
1
+ import { t as Fragment } from "./fragment-9qTBAvtR.mjs";
2
+ export { Fragment };
@@ -1,17 +1,21 @@
1
- import { NAME_FRAGMENT } from "./constants.js";
2
- import { isFragments } from "./helpers/index.js";
3
- import { handleFragments } from "./fragments.js";
4
- import { removeNodes } from "./helpers/dom.js";
5
- import { mapNodes } from "./node/index.js";
6
- import { parse } from "./parse.js";
1
+ import { NAME_FRAGMENT } from "./constants.mjs";
2
+ import { isFragments } from "./helpers/index.mjs";
3
+ import { handleFragments } from "./fragments.mjs";
4
+ import { removeNodes } from "./helpers/dom.mjs";
5
+ import { mapNodes } from "./node/index.mjs";
6
+ import { parse } from "./parse.mjs";
7
7
  import { isPlainObject } from "@oscarpalmer/atoms/is";
8
8
  import { html } from "@oscarpalmer/toretto/html";
9
+ //#region src/fragment.ts
9
10
  var Fragment = class {
10
11
  #data;
11
12
  #configuration = {
12
13
  identifier: void 0,
13
14
  cache: true
14
15
  };
16
+ /**
17
+ * Fragment identifier
18
+ */
15
19
  get identifier() {
16
20
  return this.#configuration.identifier;
17
21
  }
@@ -28,15 +32,28 @@ var Fragment = class {
28
32
  values: []
29
33
  };
30
34
  }
35
+ /**
36
+ * Append the fragment to the given element
37
+ * @param element Element to append to
38
+ */
31
39
  appendTo(element) {
32
40
  element.append(...this.get());
33
41
  }
42
+ /**
43
+ * Configure the fragment
44
+ * @param configuration Configuration options
45
+ * @returns Fragment
46
+ */
34
47
  configure(configuration) {
35
48
  const actual = isPlainObject(configuration) ? configuration : {};
36
49
  if ("identifier" in actual) this.#configuration.identifier = actual.identifier;
37
50
  if (typeof actual.cache === "boolean") this.#configuration.cache = actual.cache;
38
51
  return this;
39
52
  }
53
+ /**
54
+ * Get a list of the fragment's nodes
55
+ * @returns List of nodes
56
+ */
40
57
  get() {
41
58
  const data = this.#data;
42
59
  if (data.items.length === 0) {
@@ -46,10 +63,21 @@ var Fragment = class {
46
63
  }
47
64
  return data.items.flatMap((item) => item.fragments?.flatMap((fragment) => fragment.get()) ?? item.nodes ?? []);
48
65
  }
66
+ /**
67
+ * Set an identifier for the fragment
68
+ *
69
+ * _An identifier can be used to uniquely identify a fragment,
70
+ * which helps prevent re-rendering in certain scenarios._
71
+ * @param identifier Identifier
72
+ * @returns Fragment
73
+ */
49
74
  identify(identifier) {
50
75
  this.#configuration.identifier = identifier;
51
76
  return this;
52
77
  }
78
+ /**
79
+ * Remove the fragment from the DOM
80
+ */
53
81
  remove() {
54
82
  removeFragment(this.#data);
55
83
  }
@@ -76,4 +104,5 @@ function removeMora(data) {
76
104
  data.mora.values.clear();
77
105
  for (const unsubscribe of unsubscribers) unsubscribe();
78
106
  }
107
+ //#endregion
79
108
  export { Fragment };
@@ -0,0 +1,16 @@
1
+ import { a as FragmentsState, t as Fragment } from "./fragment-9qTBAvtR.mjs";
2
+ import { ReactiveArray } from "@oscarpalmer/mora";
3
+
4
+ //#region src/fragments.d.ts
5
+ declare class Fragments {
6
+ #private;
7
+ /**
8
+ * Fragment items
9
+ */
10
+ get items(): ReactiveArray<Fragment>;
11
+ constructor(items: ReactiveArray<unknown>, identify: (item: unknown) => unknown, fragment: (item: unknown) => Fragment);
12
+ }
13
+ declare function handleFragments(item: Fragments | FragmentsState, remove: boolean): void;
14
+ declare function initializeFragments(state: FragmentsState): void;
15
+ //#endregion
16
+ export { Fragments, handleFragments, initializeFragments };
@@ -1,9 +1,13 @@
1
- import { NAME_FRAGMENTS } from "./constants.js";
2
- import { isFragment, isFragments } from "./helpers/index.js";
1
+ import { NAME_FRAGMENTS } from "./constants.mjs";
2
+ import { isFragment, isFragments } from "./helpers/index.mjs";
3
3
  import { getString } from "@oscarpalmer/atoms/string";
4
4
  import { array } from "@oscarpalmer/mora";
5
+ //#region src/fragments.ts
5
6
  var Fragments = class {
6
7
  #state;
8
+ /**
9
+ * Fragment items
10
+ */
7
11
  get items() {
8
12
  return this.#state.mapped;
9
13
  }
@@ -71,5 +75,6 @@ function updateFragments(state, active) {
71
75
  state.instances = next;
72
76
  active?.clear();
73
77
  }
74
- var states = /* @__PURE__ */ new WeakMap();
78
+ const states = /* @__PURE__ */ new WeakMap();
79
+ //#endregion
75
80
  export { Fragments, handleFragments, initializeFragments };
@@ -0,0 +1,6 @@
1
+ //#region src/helpers/dom.d.ts
2
+ declare function createNodes(value: unknown): ChildNode[];
3
+ declare function removeNodes(nodes: ChildNode[]): void;
4
+ declare function replaceNodes(from: ChildNode[], to: ChildNode[]): void;
5
+ //#endregion
6
+ export { createNodes, removeNodes, replaceNodes };
@@ -1,6 +1,7 @@
1
- import { isFragment } from "./index.js";
1
+ import { isFragment } from "./index.mjs";
2
2
  import { getString } from "@oscarpalmer/atoms/string";
3
3
  import { isChildNode } from "@oscarpalmer/toretto/is";
4
+ //#region src/helpers/dom.ts
4
5
  function createNodes(value) {
5
6
  if (isFragment(value)) return value.get();
6
7
  if (isChildNode(value)) return [value];
@@ -15,4 +16,5 @@ function replaceNodes(from, to) {
15
16
  const { length } = from;
16
17
  for (let index = 1; index < length; index += 1) from[index].remove();
17
18
  }
19
+ //#endregion
18
20
  export { createNodes, removeNodes, replaceNodes };
@@ -0,0 +1,9 @@
1
+ import { t as Fragment } from "../fragment-9qTBAvtR.mjs";
2
+ import { Fragments } from "../fragments.mjs";
3
+
4
+ //#region src/helpers/index.d.ts
5
+ declare function compareArrays(first: unknown[], second: unknown[]): 'added' | 'dissimilar' | 'removed';
6
+ declare function isFragment(value: unknown): value is Fragment;
7
+ declare function isFragments(value: unknown): value is Fragments;
8
+ //#endregion
9
+ export { compareArrays, isFragment, isFragments };
@@ -1,4 +1,5 @@
1
- import { NAME_FRAGMENT, NAME_FRAGMENTS } from "../constants.js";
1
+ import { NAME_FRAGMENT, NAME_FRAGMENTS } from "../constants.mjs";
2
+ //#region src/helpers/index.ts
2
3
  function compareArrays(first, second) {
3
4
  const firstIsLarger = first.length > second.length;
4
5
  const from = firstIsLarger ? first : second;
@@ -15,7 +16,8 @@ function isFragments(value) {
15
16
  function isNamed(value, name) {
16
17
  return typeof value === "object" && value != null && name in value && value[name] === true;
17
18
  }
18
- var COMPARISON_ADDED = "added";
19
- var COMPARISON_DISSIMILAR = "dissimilar";
20
- var COMPARISON_REMOVED = "removed";
19
+ const COMPARISON_ADDED = "added";
20
+ const COMPARISON_DISSIMILAR = "dissimilar";
21
+ const COMPARISON_REMOVED = "removed";
22
+ //#endregion
21
23
  export { compareArrays, isFragment, isFragments };
@@ -0,0 +1,21 @@
1
+ import { t as Fragment } from "./fragment-9qTBAvtR.mjs";
2
+ import { Fragments } from "./fragments.mjs";
3
+ import { ReactiveArray } from "@oscarpalmer/mora";
4
+ export * from "@oscarpalmer/mora";
5
+
6
+ //#region src/index.d.ts
7
+ /**
8
+ * Create Fragments from a reactive array
9
+ * @param array Reactive array
10
+ * @param identify Function to identify item
11
+ * @param fragment Function to create fragment from item
12
+ * @returns Fragments
13
+ */
14
+ declare function fragments<Item>(array: ReactiveArray<Item>, identify: (item: Item) => unknown, fragment: (item: Item) => Fragment): Fragments;
15
+ /**
16
+ * Create Fragment from a template
17
+ * @returns Fragment
18
+ */
19
+ declare function html(template: TemplateStringsArray, ...values: unknown[]): Fragment;
20
+ //#endregion
21
+ export { type Fragment, type Fragments, fragments, html };
package/dist/index.mjs ADDED
@@ -0,0 +1,24 @@
1
+ import { Fragments } from "./fragments.mjs";
2
+ import { Fragment } from "./fragment.mjs";
3
+ import "@oscarpalmer/mora";
4
+ export * from "@oscarpalmer/mora";
5
+ //#region src/index.ts
6
+ /**
7
+ * Create Fragments from a reactive array
8
+ * @param array Reactive array
9
+ * @param identify Function to identify item
10
+ * @param fragment Function to create fragment from item
11
+ * @returns Fragments
12
+ */
13
+ function fragments(array, identify, fragment) {
14
+ return new Fragments(array, identify, fragment);
15
+ }
16
+ /**
17
+ * Create Fragment from a template
18
+ * @returns Fragment
19
+ */
20
+ function html(template, ...values) {
21
+ return new Fragment(template, values);
22
+ }
23
+ //#endregion
24
+ export { fragments, html };
@@ -0,0 +1,2 @@
1
+ import { a as FragmentsState, i as FragmentItem, n as FragmentConfiguration, r as FragmentData } from "./fragment-9qTBAvtR.mjs";
2
+ export { FragmentConfiguration, FragmentData, FragmentItem, FragmentsState };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import { r as FragmentData } from "../../fragment-9qTBAvtR.mjs";
2
+
3
+ //#region src/node/attribute/index.d.ts
4
+ declare function mapAttributes(data: FragmentData, element: HTMLElement | SVGElement): void;
5
+ //#endregion
6
+ export { mapAttributes };
@@ -1,7 +1,8 @@
1
- import { EXPRESSION_ABYDON_ATTRIBUTE_PREFIX, EXPRESSION_ABYDON_CONTENT, EXPRESSION_EVENT_PREFIX, EXPRESSION_PERIOD } from "../../constants.js";
2
- import { mapEvent } from "../event.js";
3
- import { setAttribute } from "./value.js";
1
+ import { EXPRESSION_ABYDON_ATTRIBUTE_PREFIX, EXPRESSION_ABYDON_CONTENT, EXPRESSION_EVENT_PREFIX, EXPRESSION_PERIOD } from "../../constants.mjs";
2
+ import { mapEvent } from "../event.mjs";
3
+ import { setAttribute } from "./value.mjs";
4
4
  import { computed, isReactive } from "@oscarpalmer/mora";
5
+ //#region src/node/attribute/index.ts
5
6
  function getValue(data, original) {
6
7
  const matches = EXPRESSION_ABYDON_CONTENT.exec(original ?? "");
7
8
  return matches == null ? original : data.values[+matches[1]];
@@ -36,4 +37,5 @@ function setComputedAttribute(data, element, name, callback) {
36
37
  data.mora.values.add(value);
37
38
  setAttribute(data, element, name, value);
38
39
  }
40
+ //#endregion
39
41
  export { mapAttributes };
@@ -0,0 +1,6 @@
1
+ import { r as FragmentData } from "../../fragment-9qTBAvtR.mjs";
2
+
3
+ //#region src/node/attribute/value.d.ts
4
+ declare function setAttribute(data: FragmentData, element: HTMLElement | SVGElement, name: string, value: unknown): void;
5
+ //#endregion
6
+ export { setAttribute };
@@ -1,6 +1,7 @@
1
- import { ATTRIBUTE_CLASS_PREFIX_LENGTH, EXPRESSION_ATTRIBUTE_CLASS, EXPRESSION_ATTRIBUTE_STYLE_FULL, EXPRESSION_ATTRIBUTE_STYLE_PREFIX } from "../../constants.js";
1
+ import { EXPRESSION_ATTRIBUTE_CLASS, EXPRESSION_ATTRIBUTE_STYLE_FULL, EXPRESSION_ATTRIBUTE_STYLE_PREFIX } from "../../constants.mjs";
2
2
  import { isReactive } from "@oscarpalmer/mora";
3
- import { isBooleanAttribute, setAttribute as setAttribute$1, setProperty } from "@oscarpalmer/toretto/attribute";
3
+ import { isBooleanAttribute, setAttribute as setAttribute$1 } from "@oscarpalmer/toretto/attribute";
4
+ //#region src/node/attribute/value.ts
4
5
  function getCallback(element, name) {
5
6
  if (isBooleanAttribute(name) && name in element) return name === "checked" ? updateChecked : updateProperty;
6
7
  return name === "value" ? updateValue : setAttribute$1;
@@ -19,8 +20,8 @@ function setAttribute(data, element, name, value) {
19
20
  }
20
21
  }
21
22
  function setClasses(data, element, name, value) {
22
- function update(value$1) {
23
- if (value$1 === true) element.classList.add(...classes);
23
+ function update(value) {
24
+ if (value === true) element.classList.add(...classes);
24
25
  else element.classList.remove(...classes);
25
26
  }
26
27
  const classes = name.slice(6).split(".");
@@ -30,9 +31,9 @@ function setClasses(data, element, name, value) {
30
31
  function setStyle(data, element, name, value) {
31
32
  const [, property, unit] = EXPRESSION_ATTRIBUTE_STYLE_FULL.exec(name) ?? [];
32
33
  if (property == null) return;
33
- function update(value$1) {
34
- if (value$1 == null || value$1 === false || value$1 === true && unit == null) element.style.removeProperty(property);
35
- else element.style.setProperty(property, value$1 === true ? unit : String(value$1));
34
+ function update(value) {
35
+ if (value == null || value === false || value === true && unit == null) element.style.removeProperty(property);
36
+ else element.style.setProperty(property, value === true ? unit : String(value));
36
37
  }
37
38
  if (isReactive(value)) data.mora.subscribers.add(value.subscribe(update));
38
39
  else update(value);
@@ -50,13 +51,15 @@ function updateChecked(element, name, value) {
50
51
  function updateElement(event, property, element, name, value, next) {
51
52
  if (!(property in element) || element[property] === next) return;
52
53
  setAttribute$1(element, name, value);
54
+ if (element[property] === next) return;
53
55
  element[property] = next;
54
56
  element.dispatchEvent(new Event(event, { bubbles: true }));
55
57
  }
56
58
  function updateProperty(element, name, value) {
57
- setProperty(element, name, value === true);
59
+ setAttribute$1(element, name, value === true);
58
60
  }
59
61
  function updateValue(element, name, value) {
60
62
  updateElement(element instanceof HTMLSelectElement ? "change" : "input", "value", element, name, value, String(value));
61
63
  }
64
+ //#endregion
62
65
  export { setAttribute };
@@ -0,0 +1,4 @@
1
+ //#region src/node/event.d.ts
2
+ declare function mapEvent(element: HTMLElement | SVGElement, name: string, value: unknown): void;
3
+ //#endregion
4
+ export { mapEvent };
@@ -1,5 +1,6 @@
1
- import { EVENT_DEFAULTS, EXPRESSION_EVENT_CHANGE_TYPES, EXPRESSION_EVENT_NAME, EXPRESSION_EVENT_OPTIONS_ACTIVE, EXPRESSION_EVENT_OPTIONS_CAPTURE, EXPRESSION_EVENT_OPTIONS_ONCE } from "../constants.js";
1
+ import { EVENT_DEFAULTS, EXPRESSION_EVENT_CHANGE_TYPES, EXPRESSION_EVENT_NAME, EXPRESSION_EVENT_OPTIONS_ACTIVE, EXPRESSION_EVENT_OPTIONS_CAPTURE, EXPRESSION_EVENT_OPTIONS_ONCE } from "../constants.mjs";
2
2
  import { on } from "@oscarpalmer/toretto/event";
3
+ //#region src/node/event.ts
3
4
  function getOptions(options) {
4
5
  const parts = options.split(":");
5
6
  return {
@@ -20,4 +21,5 @@ function mapEvent(element, name, value) {
20
21
  const [, type, options] = EXPRESSION_EVENT_NAME.exec(name) ?? [];
21
22
  if (type != null && typeof value === "function") on(element, getType(element, type), value, getOptions(options ?? ""));
22
23
  }
24
+ //#endregion
23
25
  export { mapEvent };
@@ -0,0 +1,6 @@
1
+ import { r as FragmentData } from "../fragment-9qTBAvtR.mjs";
2
+
3
+ //#region src/node/index.d.ts
4
+ declare function mapNodes(data: FragmentData, nodes: ChildNode[]): void;
5
+ //#endregion
6
+ export { mapNodes };
@@ -1,11 +1,12 @@
1
- import { EXPRESSION_ABYDON_CONTENT } from "../constants.js";
2
- import { isFragment, isFragments } from "../helpers/index.js";
3
- import { handleFragments } from "../fragments.js";
4
- import { createNodes } from "../helpers/dom.js";
5
- import { mapAttributes } from "./attribute/index.js";
6
- import { setReactiveValue } from "./value.js";
1
+ import { EXPRESSION_ABYDON_CONTENT } from "../constants.mjs";
2
+ import { isFragment, isFragments } from "../helpers/index.mjs";
3
+ import { handleFragments } from "../fragments.mjs";
4
+ import { createNodes } from "../helpers/dom.mjs";
5
+ import { mapAttributes } from "./attribute/index.mjs";
6
+ import { setReactiveValue } from "./value.mjs";
7
7
  import { computed, isReactive } from "@oscarpalmer/mora";
8
8
  import { isHTMLOrSVGElement } from "@oscarpalmer/toretto/is";
9
+ //#region src/node/index.ts
9
10
  function mapNode(data, comment) {
10
11
  const matches = EXPRESSION_ABYDON_CONTENT.exec(comment.textContent ?? "");
11
12
  const value = matches == null ? null : data.values[+matches[1]];
@@ -41,7 +42,7 @@ function mapValue(data, comment, value) {
41
42
  }
42
43
  }
43
44
  function replaceComment(data, comment, value) {
44
- const item = data.items.find((item$1) => item$1.nodes?.includes(comment));
45
+ const item = data.items.find((item) => item.nodes?.includes(comment));
45
46
  const nodes = createNodes(value);
46
47
  if (item != null) {
47
48
  item.fragments = isFragment(value) ? [value] : void 0;
@@ -54,4 +55,5 @@ function setComputedValue(data, comment, callback) {
54
55
  data.mora.values.add(value);
55
56
  setReactiveValue(data, comment, value);
56
57
  }
58
+ //#endregion
57
59
  export { mapNodes };
@@ -0,0 +1,7 @@
1
+ import { r as FragmentData } from "../fragment-9qTBAvtR.mjs";
2
+ import { Reactive } from "@oscarpalmer/mora";
3
+
4
+ //#region src/node/value.d.ts
5
+ declare function setReactiveValue(data: FragmentData, comment: Comment, reactive: Reactive<unknown>): void;
6
+ //#endregion
7
+ export { setReactiveValue };
@@ -1,8 +1,9 @@
1
- import { compareArrays, isFragment } from "../helpers/index.js";
2
- import { createNodes, replaceNodes } from "../helpers/dom.js";
1
+ import { compareArrays, isFragment } from "../helpers/index.mjs";
2
+ import { createNodes, replaceNodes } from "../helpers/dom.mjs";
3
3
  import { isNullableOrWhitespace } from "@oscarpalmer/atoms/is";
4
4
  import { getString } from "@oscarpalmer/atoms/string";
5
5
  import { isChildNode } from "@oscarpalmer/toretto/is";
6
+ //#region src/node/value.ts
6
7
  function addToArray(identifiers, items, nodes, added) {
7
8
  let position = nodes[0];
8
9
  const before = added && !identifiers.previous.has(items.templates[0].identifier);
@@ -47,14 +48,14 @@ function replaceText(item, comment, isNullable) {
47
48
  }
48
49
  function setArray(item, comment, value) {
49
50
  if (value.length === 0) return { nodes: setText(item, comment, value) };
50
- let templates = value.filter((item$1) => isFragment(item$1) && item$1.identifier != null);
51
+ let templates = value.filter((item) => isFragment(item) && item.identifier != null);
51
52
  const next = templates.map((fragment) => fragment.identifier);
52
53
  const previous = item.fragments?.map((fragment) => fragment.identifier) ?? [];
53
54
  if (new Set(next).size !== templates.length) templates = [];
54
55
  const noTemplates = templates.length === 0;
55
56
  if (noTemplates || item.nodes == null || previous.some((identifier) => identifier == null)) return {
56
57
  fragments: noTemplates ? void 0 : templates,
57
- nodes: setNodes(item, comment, noTemplates ? value.flatMap((item$1) => createNodes(item$1)) : templates.flatMap((template) => template.get()))
58
+ nodes: setNodes(item, comment, noTemplates ? value.flatMap((item) => createNodes(item)) : templates.flatMap((template) => template.get()))
58
59
  };
59
60
  return handleArray({
60
61
  next: new Set(next),
@@ -73,7 +74,7 @@ function setNodes(item, comment, next) {
73
74
  return next;
74
75
  }
75
76
  function setReactiveValue(data, comment, reactive) {
76
- let item = data.items.find((item$1) => item$1.nodes?.includes(comment));
77
+ let item = data.items.find((item) => item.nodes?.includes(comment));
77
78
  item ??= {};
78
79
  item.text = new Text();
79
80
  data.mora.subscribers.add(reactive.subscribe((value) => {
@@ -110,4 +111,5 @@ function setText(item, comment, value) {
110
111
  removeFragments(item.fragments);
111
112
  if (result) return item.text == null ? [] : [item.text];
112
113
  }
114
+ //#endregion
113
115
  export { setReactiveValue };
@@ -0,0 +1,6 @@
1
+ import { r as FragmentData } from "./fragment-9qTBAvtR.mjs";
2
+
3
+ //#region src/parse.d.ts
4
+ declare function parse(data: FragmentData): string;
5
+ //#endregion
6
+ export { parse };
@@ -1,5 +1,6 @@
1
- import { EXPRESSION_ABYDON_ATTRIBUTE_FULL } from "./constants.js";
1
+ import { EXPRESSION_ABYDON_ATTRIBUTE_FULL } from "./constants.mjs";
2
2
  import { isNullableOrWhitespace } from "@oscarpalmer/atoms/is";
3
+ //#region src/parse.ts
3
4
  function handleExpression(data, prefix, expression) {
4
5
  if (Array.isArray(expression)) {
5
6
  const { length } = expression;
@@ -26,4 +27,5 @@ function transformAttribute(_, name, index) {
26
27
  function transformExpression(prefix, index) {
27
28
  return `${prefix}<!--abydon.${index}-->`;
28
29
  }
30
+ //#endregion
29
31
  export { parse };