@gridland/web 0.2.30 → 0.2.32

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/index.js CHANGED
@@ -1762,17 +1762,141 @@ function parseWrap(value) {
1762
1762
  }
1763
1763
  }
1764
1764
 
1765
- // ../../opentui/packages/core/src/renderable-brand.ts
1766
- var BrandedRenderable = /* @__PURE__ */ Symbol.for("@opentui/core/Renderable");
1767
- function isRenderable2(obj) {
1768
- return !!obj?.[BrandedRenderable];
1765
+ // src/shims/node-util.ts
1766
+ function inspect(obj, _options) {
1767
+ try {
1768
+ return JSON.stringify(obj, null, 2);
1769
+ } catch {
1770
+ return String(obj);
1771
+ }
1772
+ }
1773
+ function format(fmt, ...args) {
1774
+ let i = 0;
1775
+ return fmt.replace(/%[sdjifoO%]/g, (match) => {
1776
+ if (match === "%%") return "%";
1777
+ if (i >= args.length) return match;
1778
+ return String(args[i++]);
1779
+ });
1769
1780
  }
1770
- var _maybeMakeRenderable = null;
1771
- function registerMaybeMakeRenderable(fn) {
1772
- _maybeMakeRenderable = fn;
1781
+ function promisify(fn) {
1782
+ return (...args) => new Promise((resolve, reject) => {
1783
+ fn(...args, (err, result) => {
1784
+ if (err) reject(err);
1785
+ else resolve(result);
1786
+ });
1787
+ });
1788
+ }
1789
+ function isDeepStrictEqual(a, b2) {
1790
+ return JSON.stringify(a) === JSON.stringify(b2);
1791
+ }
1792
+ var node_util_default = { inspect, format, promisify, isDeepStrictEqual };
1793
+
1794
+ // ../../opentui/packages/core/src/renderables/composition/vnode.ts
1795
+ var BrandedVNode = /* @__PURE__ */ Symbol.for("@opentui/core/VNode");
1796
+ function isRenderableConstructor(value) {
1797
+ return typeof value === "function" && value.prototype && Renderable.prototype.isPrototypeOf(value.prototype);
1798
+ }
1799
+ function flattenChildren(children) {
1800
+ const result = [];
1801
+ for (const child of children) {
1802
+ if (Array.isArray(child)) {
1803
+ result.push(...flattenChildren(child));
1804
+ } else if (child !== null && child !== void 0 && child !== false) {
1805
+ result.push(child);
1806
+ }
1807
+ }
1808
+ return result;
1809
+ }
1810
+ function isVNode(node) {
1811
+ return node && node[BrandedVNode];
1773
1812
  }
1774
1813
  function maybeMakeRenderable(ctx, node) {
1775
- return _maybeMakeRenderable?.(ctx, node) ?? null;
1814
+ if (isRenderable(node)) return node;
1815
+ if (isVNode(node)) return instantiate(ctx, node);
1816
+ if (process.env.NODE_ENV !== "production") {
1817
+ console.warn("maybeMakeRenderable received an invalid node", node_util_default.inspect(node, { depth: 2 }));
1818
+ }
1819
+ return null;
1820
+ }
1821
+ function wrapWithDelegates(instance, delegateMap) {
1822
+ if (!delegateMap || Object.keys(delegateMap).length === 0) return instance;
1823
+ const descendantCache = /* @__PURE__ */ new Map();
1824
+ const getDescendant = (id) => {
1825
+ if (descendantCache.has(id)) {
1826
+ const cached = descendantCache.get(id);
1827
+ if (cached !== void 0) {
1828
+ return cached;
1829
+ }
1830
+ }
1831
+ const descendant = instance.findDescendantById(id);
1832
+ if (descendant) {
1833
+ descendantCache.set(id, descendant);
1834
+ }
1835
+ return descendant;
1836
+ };
1837
+ const proxy = new Proxy(instance, {
1838
+ get(target, prop, receiver) {
1839
+ if (typeof prop === "string" && delegateMap[prop]) {
1840
+ const host = getDescendant(delegateMap[prop]);
1841
+ if (host) {
1842
+ const value = host[prop];
1843
+ if (typeof value === "function") {
1844
+ return value.bind(host);
1845
+ }
1846
+ return value;
1847
+ }
1848
+ }
1849
+ return Reflect.get(target, prop, receiver);
1850
+ },
1851
+ set(target, prop, value, receiver) {
1852
+ if (typeof prop === "string" && delegateMap[prop]) {
1853
+ const host = getDescendant(delegateMap[prop]);
1854
+ if (host) {
1855
+ return Reflect.set(host, prop, value);
1856
+ }
1857
+ }
1858
+ return Reflect.set(target, prop, value, receiver);
1859
+ }
1860
+ });
1861
+ return proxy;
1862
+ }
1863
+ function instantiate(ctx, node) {
1864
+ if (isRenderable(node)) return node;
1865
+ if (!node || typeof node !== "object") {
1866
+ throw new TypeError("mount() received an invalid vnode");
1867
+ }
1868
+ const vnode = node;
1869
+ const { type, props } = vnode;
1870
+ const children = flattenChildren(vnode.children || []);
1871
+ const delegateMap = vnode.__delegateMap;
1872
+ if (isRenderableConstructor(type)) {
1873
+ const instance = new type(ctx, props || {});
1874
+ for (const child of children) {
1875
+ if (isRenderable(child)) {
1876
+ instance.add(child);
1877
+ } else {
1878
+ const mounted = instantiate(ctx, child);
1879
+ instance.add(mounted);
1880
+ }
1881
+ }
1882
+ const delegatedInstance = wrapWithDelegates(instance, delegateMap);
1883
+ const pendingCalls = vnode.__pendingCalls;
1884
+ if (pendingCalls) {
1885
+ for (const call of pendingCalls) {
1886
+ if (call.isProperty) {
1887
+ ;
1888
+ delegatedInstance[call.method] = call.args[0];
1889
+ } else {
1890
+ ;
1891
+ delegatedInstance[call.method].apply(delegatedInstance, call.args);
1892
+ }
1893
+ }
1894
+ }
1895
+ return delegatedInstance;
1896
+ }
1897
+ const resolved = type(props || {}, children);
1898
+ const inst = instantiate(ctx, resolved);
1899
+ return wrapWithDelegates(inst, delegateMap);
1776
1900
  }
1777
1901
 
1778
1902
  // ../../opentui/packages/core/src/lib/renderable.validations.ts
@@ -1849,6 +1973,10 @@ function isSizeType(value) {
1849
1973
  }
1850
1974
 
1851
1975
  // ../../opentui/packages/core/src/Renderable.ts
1976
+ var BrandedRenderable = /* @__PURE__ */ Symbol.for("@opentui/core/Renderable");
1977
+ function isRenderable(obj) {
1978
+ return !!obj?.[BrandedRenderable];
1979
+ }
1852
1980
  var BaseRenderable = class _BaseRenderable extends EventEmitter {
1853
1981
  [BrandedRenderable] = true;
1854
1982
  static renderableNumber = 1;
@@ -4492,144 +4620,6 @@ var TextNodeRenderable = class _TextNodeRenderable extends BaseRenderable {
4492
4620
  }
4493
4621
  };
4494
4622
 
4495
- // src/shims/node-util.ts
4496
- function inspect(obj, _options) {
4497
- try {
4498
- return JSON.stringify(obj, null, 2);
4499
- } catch {
4500
- return String(obj);
4501
- }
4502
- }
4503
- function format(fmt, ...args) {
4504
- let i = 0;
4505
- return fmt.replace(/%[sdjifoO%]/g, (match) => {
4506
- if (match === "%%") return "%";
4507
- if (i >= args.length) return match;
4508
- return String(args[i++]);
4509
- });
4510
- }
4511
- function promisify(fn) {
4512
- return (...args) => new Promise((resolve, reject) => {
4513
- fn(...args, (err, result) => {
4514
- if (err) reject(err);
4515
- else resolve(result);
4516
- });
4517
- });
4518
- }
4519
- function isDeepStrictEqual(a, b2) {
4520
- return JSON.stringify(a) === JSON.stringify(b2);
4521
- }
4522
- var node_util_default = { inspect, format, promisify, isDeepStrictEqual };
4523
-
4524
- // ../../opentui/packages/core/src/renderables/composition/vnode.ts
4525
- var BrandedVNode = /* @__PURE__ */ Symbol.for("@opentui/core/VNode");
4526
- function isRenderableConstructor(value) {
4527
- return typeof value === "function" && value.prototype && !!value.prototype[BrandedRenderable];
4528
- }
4529
- function flattenChildren(children) {
4530
- const result = [];
4531
- for (const child of children) {
4532
- if (Array.isArray(child)) {
4533
- result.push(...flattenChildren(child));
4534
- } else if (child !== null && child !== void 0 && child !== false) {
4535
- result.push(child);
4536
- }
4537
- }
4538
- return result;
4539
- }
4540
- function isVNode(node) {
4541
- return node && node[BrandedVNode];
4542
- }
4543
- function maybeMakeRenderable2(ctx, node) {
4544
- if (isRenderable2(node)) return node;
4545
- if (isVNode(node)) return instantiate(ctx, node);
4546
- if (process.env.NODE_ENV !== "production") {
4547
- console.warn("maybeMakeRenderable received an invalid node", node_util_default.inspect(node, { depth: 2 }));
4548
- }
4549
- return null;
4550
- }
4551
- registerMaybeMakeRenderable(maybeMakeRenderable2);
4552
- function wrapWithDelegates(instance, delegateMap) {
4553
- if (!delegateMap || Object.keys(delegateMap).length === 0) return instance;
4554
- const descendantCache = /* @__PURE__ */ new Map();
4555
- const getDescendant = (id) => {
4556
- if (descendantCache.has(id)) {
4557
- const cached = descendantCache.get(id);
4558
- if (cached !== void 0) {
4559
- return cached;
4560
- }
4561
- }
4562
- const descendant = instance.findDescendantById(id);
4563
- if (descendant) {
4564
- descendantCache.set(id, descendant);
4565
- }
4566
- return descendant;
4567
- };
4568
- const proxy = new Proxy(instance, {
4569
- get(target, prop, receiver) {
4570
- if (typeof prop === "string" && delegateMap[prop]) {
4571
- const host = getDescendant(delegateMap[prop]);
4572
- if (host) {
4573
- const value = host[prop];
4574
- if (typeof value === "function") {
4575
- return value.bind(host);
4576
- }
4577
- return value;
4578
- }
4579
- }
4580
- return Reflect.get(target, prop, receiver);
4581
- },
4582
- set(target, prop, value, receiver) {
4583
- if (typeof prop === "string" && delegateMap[prop]) {
4584
- const host = getDescendant(delegateMap[prop]);
4585
- if (host) {
4586
- return Reflect.set(host, prop, value);
4587
- }
4588
- }
4589
- return Reflect.set(target, prop, value, receiver);
4590
- }
4591
- });
4592
- return proxy;
4593
- }
4594
- function instantiate(ctx, node) {
4595
- if (isRenderable2(node)) return node;
4596
- if (!node || typeof node !== "object") {
4597
- throw new TypeError("mount() received an invalid vnode");
4598
- }
4599
- const vnode = node;
4600
- const { type, props } = vnode;
4601
- const children = flattenChildren(vnode.children || []);
4602
- const delegateMap = vnode.__delegateMap;
4603
- if (isRenderableConstructor(type)) {
4604
- const instance = new type(ctx, props || {});
4605
- for (const child of children) {
4606
- if (isRenderable2(child)) {
4607
- instance.add(child);
4608
- } else {
4609
- const mounted = instantiate(ctx, child);
4610
- instance.add(mounted);
4611
- }
4612
- }
4613
- const delegatedInstance = wrapWithDelegates(instance, delegateMap);
4614
- const pendingCalls = vnode.__pendingCalls;
4615
- if (pendingCalls) {
4616
- for (const call of pendingCalls) {
4617
- if (call.isProperty) {
4618
- ;
4619
- delegatedInstance[call.method] = call.args[0];
4620
- } else {
4621
- ;
4622
- delegatedInstance[call.method].apply(delegatedInstance, call.args);
4623
- }
4624
- }
4625
- }
4626
- return delegatedInstance;
4627
- }
4628
- const resolved = type(props || {}, children);
4629
- const inst = instantiate(ctx, resolved);
4630
- return wrapWithDelegates(inst, delegateMap);
4631
- }
4632
-
4633
4623
  // ../../opentui/node_modules/.bun/marked@17.0.1/node_modules/marked/lib/marked.esm.js
4634
4624
  function L() {
4635
4625
  return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null };