voodoojs 0.10.0 → 0.11.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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Voodoo.js v0.10.0
2
+ * Voodoo.js v0.11.0
3
3
  * JavaScript feels like magic.
4
4
  * (c) 2026 Voodoo.js contributors. MIT License.
5
5
  */
@@ -2971,13 +2971,28 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
2971
2971
  var componentAliases = /* @__PURE__ */ new Map();
2972
2972
  var started = false;
2973
2973
  var observer = null;
2974
+ var startHooks = [];
2975
+ function onStart(hook) {
2976
+ startHooks.push(hook);
2977
+ }
2978
+ function runPhase(target, after) {
2979
+ for (const hook of startHooks) {
2980
+ try {
2981
+ hook(target, after);
2982
+ } catch (error) {
2983
+ console.error("[Voodoo] a start hook failed", error);
2984
+ }
2985
+ }
2986
+ }
2974
2987
  function start(root) {
2975
2988
  var _a2;
2976
2989
  if (typeof document === "undefined") return;
2977
2990
  const target = (_a2 = root != null ? root : config.root) != null ? _a2 : document.body;
2978
2991
  if (!target) return;
2979
2992
  Object.assign(allowedGlobals, config.globals);
2993
+ runPhase(target, false);
2980
2994
  walk(target, rootScope);
2995
+ runPhase(target, true);
2981
2996
  if (!started) {
2982
2997
  started = true;
2983
2998
  if (config.autoDiscover) observeDOM(target);
@@ -6868,7 +6883,7 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
6868
6883
  Object.defineProperties(rootScope.data, Object.getOwnPropertyDescriptors(values));
6869
6884
  return rootScope.data;
6870
6885
  }
6871
- var version2 = "0.10.0";
6886
+ var version2 = "0.11.0";
6872
6887
  var core = {
6873
6888
  // Utilities first: Voodoo's own names can override.
6874
6889
  ...utils_exports,
@@ -21015,6 +21030,10 @@ textarea.v-dialog-input{min-height:96px;resize:vertical}
21015
21030
  "NOSCRIPT"
21016
21031
  ]);
21017
21032
  magic("$__jsx", (scope) => scope);
21033
+ onStart((root, after) => {
21034
+ if (after) activateJsx();
21035
+ else extractJsx(root);
21036
+ });
21018
21037
  var TEMPLATE = /* @__PURE__ */ Symbol("voodoo.jsx.template");
21019
21038
  function isTemplate(value) {
21020
21039
  return typeof value === "object" && value !== null && TEMPLATE in value;
@@ -21088,6 +21107,31 @@ textarea.v-dialog-input{min-height:96px;resize:vertical}
21088
21107
  if (!closed) return null;
21089
21108
  return { source, templates, nodes, tail };
21090
21109
  }
21110
+ function recoverFromTable(collected) {
21111
+ const empties = collected.source.match(/\(\s*\)/g);
21112
+ if (!empties) return false;
21113
+ const first = collected.nodes[0];
21114
+ const last = collected.nodes[collected.nodes.length - 1];
21115
+ const table = [last == null ? void 0 : last.nextSibling, first == null ? void 0 : first.previousSibling].map((from) => {
21116
+ var _a2;
21117
+ let node = from != null ? from : null;
21118
+ while (node && node.nodeType === Node.TEXT_NODE && !((_a2 = node.textContent) != null ? _a2 : "").trim()) {
21119
+ node = node === (last == null ? void 0 : last.nextSibling) ? node.nextSibling : node.previousSibling;
21120
+ }
21121
+ return node && node.nodeType === Node.ELEMENT_NODE ? node : null;
21122
+ }).find((el) => (el == null ? void 0 : el.tagName) === "TABLE");
21123
+ if (!table) return false;
21124
+ const body = table.querySelector("tbody");
21125
+ if (!body) return false;
21126
+ const rows = Array.from(body.children).filter((el) => el.tagName === "TR");
21127
+ if (rows.length !== empties.length) return false;
21128
+ let index = 0;
21129
+ collected.source = collected.source.replace(/\(\s*\)/g, () => `($t(${index++}, $__jsx))`);
21130
+ collected.templates = rows;
21131
+ collected.host = body;
21132
+ collected.nodes.push(...rows);
21133
+ return true;
21134
+ }
21091
21135
  function render2(value, templates, scope, out) {
21092
21136
  var _a2;
21093
21137
  if (value == null || value === false || value === true) return;
@@ -21131,7 +21175,11 @@ textarea.v-dialog-input{min-height:96px;resize:vertical}
21131
21175
  continue;
21132
21176
  }
21133
21177
  const collected = collect(child, open);
21134
- if (!collected || collected.templates.length === 0) {
21178
+ if (!collected) {
21179
+ child = next;
21180
+ continue;
21181
+ }
21182
+ if (collected.templates.length === 0 && !recoverFromTable(collected)) {
21135
21183
  child = next;
21136
21184
  continue;
21137
21185
  }
@@ -21141,7 +21189,7 @@ textarea.v-dialog-input{min-height:96px;resize:vertical}
21141
21189
  }
21142
21190
  var pending = [];
21143
21191
  function install(parent, collected, hint) {
21144
- var _a2;
21192
+ var _a2, _b;
21145
21193
  const { source, templates, nodes, tail } = collected;
21146
21194
  let ast;
21147
21195
  try {
@@ -21155,8 +21203,9 @@ textarea.v-dialog-input{min-height:96px;resize:vertical}
21155
21203
  if (tail && tail.offset < ((_a2 = tail.node.textContent) != null ? _a2 : "").length) {
21156
21204
  tail.node.splitText(tail.offset);
21157
21205
  }
21206
+ const target = (_b = collected.host) != null ? _b : parent;
21158
21207
  const anchor = document.createComment("v-jsx");
21159
- parent.insertBefore(anchor, nodes[0]);
21208
+ target.insertBefore(anchor, collected.host ? collected.host.firstChild : nodes[0]);
21160
21209
  for (const node of nodes) node.remove();
21161
21210
  let rendered = [];
21162
21211
  pending.push(() => activateRegion());
@@ -21172,7 +21221,7 @@ textarea.v-dialog-input{min-height:96px;resize:vertical}
21172
21221
  render2(value, templates, local, out);
21173
21222
  for (const node of rendered) node.remove();
21174
21223
  rendered = out;
21175
- for (const node of out) parent.insertBefore(node, anchor);
21224
+ for (const node of out) target.insertBefore(node, anchor);
21176
21225
  });
21177
21226
  addCleanup(anchor, () => {
21178
21227
  runner.effect.stop();
@@ -21712,9 +21761,7 @@ textarea.v-dialog-input{min-height:96px;resize:vertical}
21712
21761
  const boot = () => {
21713
21762
  theme.init();
21714
21763
  applySavedPalette();
21715
- if (typeof V2.extractJsx === "function") V2.extractJsx();
21716
21764
  V2.start();
21717
- if (typeof V2.activateJsx === "function") V2.activateJsx();
21718
21765
  if (typeof V2.enableXrayShortcut === "function") V2.enableXrayShortcut();
21719
21766
  if (config.devtools) mountDevtools(V2);
21720
21767
  };