@jxsuite/runtime 0.18.0 → 0.20.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/runtime.js CHANGED
@@ -1,4 +1,4 @@
1
- // ../../node_modules/@vue/shared/dist/shared.esm-bundler.js
1
+ // ../../node_modules/.bun/@vue+shared@3.5.35/node_modules/@vue/shared/dist/shared.esm-bundler.js
2
2
  function makeMap(str) {
3
3
  const map = /* @__PURE__ */ Object.create(null);
4
4
  for (const key of str.split(","))
@@ -46,7 +46,7 @@ var hasChanged = (value, oldValue) => !Object.is(value, oldValue);
46
46
  var specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
47
47
  var isBooleanAttr = /* @__PURE__ */ makeMap(specialBooleanAttrs + `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`);
48
48
 
49
- // ../../node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js
49
+ // ../../node_modules/.bun/@vue+reactivity@3.5.35/node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js
50
50
  function warn(msg, ...args) {
51
51
  console.warn(`[Vue warn] ${msg}`, ...args);
52
52
  }
@@ -1091,9 +1091,6 @@ function targetTypeMap(rawType) {
1091
1091
  return 0;
1092
1092
  }
1093
1093
  }
1094
- function getTargetType(value) {
1095
- return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value));
1096
- }
1097
1094
  function reactive(target) {
1098
1095
  if (/* @__PURE__ */ isReadonly(target)) {
1099
1096
  return target;
@@ -1113,14 +1110,17 @@ function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandl
1113
1110
  if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) {
1114
1111
  return target;
1115
1112
  }
1116
- const targetType = getTargetType(target);
1117
- if (targetType === 0) {
1113
+ if (target["__v_skip"] || !Object.isExtensible(target)) {
1118
1114
  return target;
1119
1115
  }
1120
1116
  const existingProxy = proxyMap.get(target);
1121
1117
  if (existingProxy) {
1122
1118
  return existingProxy;
1123
1119
  }
1120
+ const targetType = targetTypeMap(toRawType(target));
1121
+ if (targetType === 0) {
1122
+ return target;
1123
+ }
1124
1124
  const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
1125
1125
  proxyMap.set(target, proxy);
1126
1126
  return proxy;
@@ -1408,15 +1408,15 @@ async function resolveFunction(def2, state, key, base) {
1408
1408
  if (_moduleCache.has(src)) {
1409
1409
  mod = _moduleCache.get(src);
1410
1410
  } else {
1411
- try {
1412
- mod = await import(src);
1413
- } catch {
1414
- if (base) {
1415
- const resolvedSrc = new URL(src, base).href;
1411
+ if (base) {
1412
+ const resolvedSrc = new URL(src, base).href;
1413
+ try {
1416
1414
  mod = await import(resolvedSrc);
1417
- } else {
1418
- throw new Error(`Jx: failed to import '$src' "${src}" for "${key}"`);
1415
+ } catch {
1416
+ mod = await import(src);
1419
1417
  }
1418
+ } else {
1419
+ mod = await import(src);
1420
1420
  }
1421
1421
  _moduleCache.set(src, mod);
1422
1422
  }
@@ -1425,7 +1425,16 @@ async function resolveFunction(def2, state, key, base) {
1425
1425
  throw new Error(`Jx: export "${exportName}" not found or not a function in "${src}"`);
1426
1426
  }
1427
1427
  }
1428
- if (def2.body && /\breturn\b/.test(def2.body)) {
1428
+ const hasParams = (def2.parameters ?? def2.arguments ?? []).length > 0;
1429
+ let isComputed = false;
1430
+ if (!hasParams) {
1431
+ if (def2.body) {
1432
+ isComputed = /\breturn\b/.test(def2.body);
1433
+ } else if (fn) {
1434
+ isComputed = fn.length <= 1 && /\breturn\b/.test(fn.toString());
1435
+ }
1436
+ }
1437
+ if (isComputed) {
1429
1438
  return computed(() => fn(state));
1430
1439
  }
1431
1440
  return fn;
@@ -1448,6 +1457,8 @@ var RESERVED_KEYS = new Set([
1448
1457
  "$ref",
1449
1458
  "$props",
1450
1459
  "$elements",
1460
+ "$title",
1461
+ "$description",
1451
1462
  "$switch",
1452
1463
  "$prototype",
1453
1464
  "$src",
@@ -1547,23 +1558,24 @@ function applyProperties(el, def2, state) {
1547
1558
  }
1548
1559
  }
1549
1560
  function bindProperty(el, key, val, state) {
1561
+ const target = el;
1550
1562
  if (isRefObj(val)) {
1551
1563
  if (key === "id") {
1552
- el[key] = resolveRef(val.$ref, state);
1564
+ target[key] = resolveRef(val.$ref, state);
1553
1565
  return;
1554
1566
  }
1555
1567
  effect(() => {
1556
- el[key] = resolveRef(val.$ref, state);
1568
+ target[key] = resolveRef(val.$ref, state);
1557
1569
  });
1558
1570
  return;
1559
1571
  }
1560
1572
  if (isTemplateString(val)) {
1561
1573
  effect(() => {
1562
- el[key] = evaluateTemplate(val, state);
1574
+ target[key] = evaluateTemplate(val, state);
1563
1575
  });
1564
1576
  return;
1565
1577
  }
1566
- el[key] = val;
1578
+ target[key] = val;
1567
1579
  }
1568
1580
  function applyStyle(el, styleDef, mediaQueries = {}, state = {}) {
1569
1581
  const nested = {};
@@ -1573,6 +1585,8 @@ function applyStyle(el, styleDef, mediaQueries = {}, state = {}) {
1573
1585
  media[prop] = val;
1574
1586
  else if (isNestedSelector(prop))
1575
1587
  nested[prop] = val;
1588
+ else if (val !== null && typeof val === "object" && !Array.isArray(val))
1589
+ nested[prop] = val;
1576
1590
  else if (prop.startsWith("--")) {
1577
1591
  if (isTemplateString(val))
1578
1592
  effect(() => {
@@ -1594,25 +1608,46 @@ function applyStyle(el, styleDef, mediaQueries = {}, state = {}) {
1594
1608
  const uid = `jx-${Math.random().toString(36).slice(2, 7)}`;
1595
1609
  el.dataset.jx = uid;
1596
1610
  let css = "";
1597
- for (const [sel, rules] of Object.entries(nested)) {
1598
- const resolved = sel.startsWith("&") ? sel.replace("&", `[data-jx="${uid}"]`) : sel.startsWith("[") ? `[data-jx="${uid}"]${sel}` : `[data-jx="${uid}"] ${sel}`;
1599
- css += `${resolved} { ${toCSSText(rules)} }
1611
+ function emitNested(scope, rules) {
1612
+ const props = toCSSText(rules);
1613
+ if (props)
1614
+ css += `${scope} { ${props} }
1600
1615
  `;
1616
+ for (const [sel, sub] of Object.entries(rules)) {
1617
+ if (sub === null || typeof sub !== "object" || Array.isArray(sub))
1618
+ continue;
1619
+ if (sel.startsWith("@"))
1620
+ continue;
1621
+ const resolved = sel.startsWith("&") ? sel.replace("&", scope) : sel.startsWith("[") ? `${scope}${sel}` : sel.startsWith(":") || sel.startsWith(".") ? `${scope}${sel}` : `${scope} ${sel}`;
1622
+ emitNested(resolved, sub);
1623
+ }
1624
+ }
1625
+ for (const [sel, rules] of Object.entries(nested)) {
1626
+ const resolved = sel.startsWith("&") ? sel.replace("&", `[data-jx="${uid}"]`) : sel.startsWith("[") ? `[data-jx="${uid}"]${sel}` : sel.startsWith(":") || sel.startsWith(".") ? `[data-jx="${uid}"]${sel}` : `[data-jx="${uid}"] ${sel}`;
1627
+ emitNested(resolved, rules);
1601
1628
  }
1602
1629
  for (const [key, rules] of Object.entries(media)) {
1630
+ let emitMediaNested = function(parentSel, obj) {
1631
+ for (const [sel, sub] of Object.entries(obj)) {
1632
+ if (sub === null || typeof sub !== "object" || Array.isArray(sub))
1633
+ continue;
1634
+ if (sel.startsWith("@"))
1635
+ continue;
1636
+ const resolved = sel.startsWith("&") ? sel.replace("&", parentSel) : sel.startsWith("[") ? `${parentSel}${sel}` : sel.startsWith(":") || sel.startsWith(".") ? `${parentSel}${sel}` : `${parentSel} ${sel}`;
1637
+ const props = toCSSText(sub);
1638
+ if (props)
1639
+ css += `@media ${query} { ${resolved} { ${props} } }
1640
+ `;
1641
+ emitMediaNested(resolved, sub);
1642
+ }
1643
+ };
1603
1644
  if (key === "@--")
1604
1645
  continue;
1605
1646
  const query = key.startsWith("@--") ? mediaQueries[key.slice(1)] ?? key.slice(1) : key.slice(1);
1606
1647
  const scope = `[data-jx="${uid}"]`;
1607
1648
  css += `@media ${query} { ${scope} { ${toCSSText(rules)} } }
1608
1649
  `;
1609
- for (const [sel, nestedRules] of Object.entries(rules)) {
1610
- if (!isNestedSelector(sel))
1611
- continue;
1612
- const resolved = sel.startsWith("&") ? sel.replace("&", scope) : sel.startsWith("[") ? `${scope}${sel}` : `${scope} ${sel}`;
1613
- css += `@media ${query} { ${resolved} { ${toCSSText(nestedRules)} } }
1614
- `;
1615
- }
1650
+ emitMediaNested(scope, rules);
1616
1651
  }
1617
1652
  const tag = document.createElement("style");
1618
1653
  tag.textContent = css;
@@ -1726,7 +1761,8 @@ async function resolvePrototype(def2, state, key, base) {
1726
1761
  const controller = new AbortController;
1727
1762
  onEffectCleanup(() => {
1728
1763
  controller.abort();
1729
- clearTimeout(debounceTimer);
1764
+ if (debounceTimer !== null)
1765
+ clearTimeout(debounceTimer);
1730
1766
  });
1731
1767
  const doFetch = () => fetch(url, {
1732
1768
  signal: controller.signal,
@@ -1828,7 +1864,7 @@ async function resolvePrototype(def2, state, key, base) {
1828
1864
  } = def2;
1829
1865
  const req = indexedDB.open(database, version);
1830
1866
  req.onupgradeneeded = (e) => {
1831
- const db = e.target?.result;
1867
+ const db = e.target.result;
1832
1868
  if (!db.objectStoreNames.contains(store)) {
1833
1869
  const os = db.createObjectStore(store, { keyPath, autoIncrement });
1834
1870
  for (const i of indexes)
@@ -1836,7 +1872,7 @@ async function resolvePrototype(def2, state, key, base) {
1836
1872
  }
1837
1873
  };
1838
1874
  req.onsuccess = (e) => {
1839
- const db = e.target?.result;
1875
+ const db = e.target.result;
1840
1876
  idbState.value = {
1841
1877
  database,
1842
1878
  store,
@@ -2032,7 +2068,8 @@ function classFromSchema(classDef) {
2032
2068
  }
2033
2069
  }
2034
2070
  Object.defineProperty(DynClass, "name", { value: classDef.title, configurable: true });
2035
- return DynClass;
2071
+ const dynCtor = DynClass;
2072
+ return dynCtor;
2036
2073
  }
2037
2074
  async function resolveViaDevProxy(def2, state, key, base) {
2038
2075
  const config = {};
@@ -2212,7 +2249,7 @@ function camelToKebab(s) {
2212
2249
  return s.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
2213
2250
  }
2214
2251
  function toCSSText(rules) {
2215
- return Object.entries(rules).filter(([k]) => !isNestedSelector(k)).map(([p, v]) => `${camelToKebab(p)}: ${v}`).join("; ");
2252
+ return Object.entries(rules).filter(([k, v]) => !isNestedSelector(k) && (v === null || typeof v !== "object")).map(([p, v]) => `${camelToKebab(p)}: ${v}`).join("; ");
2216
2253
  }
2217
2254
  var _elementDefs = new Map;
2218
2255
  async function registerElements(elements, base) {
@@ -2365,7 +2402,7 @@ async function defineElement(source, base) {
2365
2402
  function renderCustomElementWithProps(def2, state, options, path) {
2366
2403
  const el = document.createElement(def2.tagName);
2367
2404
  if (options?.onNodeCreated)
2368
- options.onNodeCreated(el, path, def2);
2405
+ options.onNodeCreated(el, path ?? [], def2);
2369
2406
  for (const [key, val] of Object.entries(def2.$props ?? {})) {
2370
2407
  if (isRefObj(val)) {
2371
2408
  const resolved = resolveRef(val.$ref, state);
@@ -2436,5 +2473,5 @@ export {
2436
2473
  Jx
2437
2474
  };
2438
2475
 
2439
- //# debugId=B787C22CCE11BBDE64756E2164756E21
2476
+ //# debugId=E0E588A2ACC641E264756E2164756E21
2440
2477
  //# sourceMappingURL=runtime.js.map