@gridland/web 0.2.28 → 0.2.30

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.
@@ -25075,141 +25075,17 @@ function parseWrap(value) {
25075
25075
  }
25076
25076
  }
25077
25077
 
25078
- // src/shims/node-util.ts
25079
- function inspect(obj, _options) {
25080
- try {
25081
- return JSON.stringify(obj, null, 2);
25082
- } catch {
25083
- return String(obj);
25084
- }
25085
- }
25086
- function format(fmt, ...args) {
25087
- let i = 0;
25088
- return fmt.replace(/%[sdjifoO%]/g, (match) => {
25089
- if (match === "%%") return "%";
25090
- if (i >= args.length) return match;
25091
- return String(args[i++]);
25092
- });
25093
- }
25094
- function promisify(fn) {
25095
- return (...args) => new Promise((resolve, reject) => {
25096
- fn(...args, (err, result) => {
25097
- if (err) reject(err);
25098
- else resolve(result);
25099
- });
25100
- });
25101
- }
25102
- function isDeepStrictEqual(a, b2) {
25103
- return JSON.stringify(a) === JSON.stringify(b2);
25104
- }
25105
- var node_util_default = { inspect, format, promisify, isDeepStrictEqual };
25106
-
25107
- // ../../opentui/packages/core/src/renderables/composition/vnode.ts
25108
- var BrandedVNode = /* @__PURE__ */ Symbol.for("@opentui/core/VNode");
25109
- function isRenderableConstructor(value) {
25110
- return typeof value === "function" && value.prototype && Renderable.prototype.isPrototypeOf(value.prototype);
25111
- }
25112
- function flattenChildren(children) {
25113
- const result = [];
25114
- for (const child of children) {
25115
- if (Array.isArray(child)) {
25116
- result.push(...flattenChildren(child));
25117
- } else if (child !== null && child !== void 0 && child !== false) {
25118
- result.push(child);
25119
- }
25120
- }
25121
- return result;
25078
+ // ../../opentui/packages/core/src/renderable-brand.ts
25079
+ var BrandedRenderable = /* @__PURE__ */ Symbol.for("@opentui/core/Renderable");
25080
+ function isRenderable2(obj) {
25081
+ return !!obj?.[BrandedRenderable];
25122
25082
  }
25123
- function isVNode(node) {
25124
- return node && node[BrandedVNode];
25083
+ var _maybeMakeRenderable = null;
25084
+ function registerMaybeMakeRenderable(fn) {
25085
+ _maybeMakeRenderable = fn;
25125
25086
  }
25126
25087
  function maybeMakeRenderable(ctx, node) {
25127
- if (isRenderable(node)) return node;
25128
- if (isVNode(node)) return instantiate(ctx, node);
25129
- if (process.env.NODE_ENV !== "production") {
25130
- console.warn("maybeMakeRenderable received an invalid node", node_util_default.inspect(node, { depth: 2 }));
25131
- }
25132
- return null;
25133
- }
25134
- function wrapWithDelegates(instance, delegateMap) {
25135
- if (!delegateMap || Object.keys(delegateMap).length === 0) return instance;
25136
- const descendantCache = /* @__PURE__ */ new Map();
25137
- const getDescendant = (id) => {
25138
- if (descendantCache.has(id)) {
25139
- const cached = descendantCache.get(id);
25140
- if (cached !== void 0) {
25141
- return cached;
25142
- }
25143
- }
25144
- const descendant = instance.findDescendantById(id);
25145
- if (descendant) {
25146
- descendantCache.set(id, descendant);
25147
- }
25148
- return descendant;
25149
- };
25150
- const proxy = new Proxy(instance, {
25151
- get(target, prop, receiver) {
25152
- if (typeof prop === "string" && delegateMap[prop]) {
25153
- const host = getDescendant(delegateMap[prop]);
25154
- if (host) {
25155
- const value = host[prop];
25156
- if (typeof value === "function") {
25157
- return value.bind(host);
25158
- }
25159
- return value;
25160
- }
25161
- }
25162
- return Reflect.get(target, prop, receiver);
25163
- },
25164
- set(target, prop, value, receiver) {
25165
- if (typeof prop === "string" && delegateMap[prop]) {
25166
- const host = getDescendant(delegateMap[prop]);
25167
- if (host) {
25168
- return Reflect.set(host, prop, value);
25169
- }
25170
- }
25171
- return Reflect.set(target, prop, value, receiver);
25172
- }
25173
- });
25174
- return proxy;
25175
- }
25176
- function instantiate(ctx, node) {
25177
- if (isRenderable(node)) return node;
25178
- if (!node || typeof node !== "object") {
25179
- throw new TypeError("mount() received an invalid vnode");
25180
- }
25181
- const vnode = node;
25182
- const { type, props } = vnode;
25183
- const children = flattenChildren(vnode.children || []);
25184
- const delegateMap = vnode.__delegateMap;
25185
- if (isRenderableConstructor(type)) {
25186
- const instance = new type(ctx, props || {});
25187
- for (const child of children) {
25188
- if (isRenderable(child)) {
25189
- instance.add(child);
25190
- } else {
25191
- const mounted = instantiate(ctx, child);
25192
- instance.add(mounted);
25193
- }
25194
- }
25195
- const delegatedInstance = wrapWithDelegates(instance, delegateMap);
25196
- const pendingCalls = vnode.__pendingCalls;
25197
- if (pendingCalls) {
25198
- for (const call of pendingCalls) {
25199
- if (call.isProperty) {
25200
- ;
25201
- delegatedInstance[call.method] = call.args[0];
25202
- } else {
25203
- ;
25204
- delegatedInstance[call.method].apply(delegatedInstance, call.args);
25205
- }
25206
- }
25207
- }
25208
- return delegatedInstance;
25209
- }
25210
- const resolved = type(props || {}, children);
25211
- const inst = instantiate(ctx, resolved);
25212
- return wrapWithDelegates(inst, delegateMap);
25088
+ return _maybeMakeRenderable?.(ctx, node) ?? null;
25213
25089
  }
25214
25090
 
25215
25091
  // ../../opentui/packages/core/src/lib/renderable.validations.ts
@@ -25286,7 +25162,6 @@ function isSizeType(value) {
25286
25162
  }
25287
25163
 
25288
25164
  // ../../opentui/packages/core/src/Renderable.ts
25289
- var BrandedRenderable = /* @__PURE__ */ Symbol.for("@opentui/core/Renderable");
25290
25165
  var LayoutEvents = /* @__PURE__ */ ((LayoutEvents2) => {
25291
25166
  LayoutEvents2["LAYOUT_CHANGED"] = "layout-changed";
25292
25167
  LayoutEvents2["ADDED"] = "added";
@@ -25299,9 +25174,6 @@ var RenderableEvents = /* @__PURE__ */ ((RenderableEvents2) => {
25299
25174
  RenderableEvents2["BLURRED"] = "blurred";
25300
25175
  return RenderableEvents2;
25301
25176
  })(RenderableEvents || {});
25302
- function isRenderable(obj) {
25303
- return !!obj?.[BrandedRenderable];
25304
- }
25305
25177
  var BaseRenderable = class _BaseRenderable extends EventEmitter {
25306
25178
  [BrandedRenderable] = true;
25307
25179
  static renderableNumber = 1;
@@ -32538,6 +32410,144 @@ var RootTextNodeRenderable = class extends TextNodeRenderable {
32538
32410
  }
32539
32411
  };
32540
32412
 
32413
+ // src/shims/node-util.ts
32414
+ function inspect(obj, _options) {
32415
+ try {
32416
+ return JSON.stringify(obj, null, 2);
32417
+ } catch {
32418
+ return String(obj);
32419
+ }
32420
+ }
32421
+ function format(fmt, ...args) {
32422
+ let i = 0;
32423
+ return fmt.replace(/%[sdjifoO%]/g, (match) => {
32424
+ if (match === "%%") return "%";
32425
+ if (i >= args.length) return match;
32426
+ return String(args[i++]);
32427
+ });
32428
+ }
32429
+ function promisify(fn) {
32430
+ return (...args) => new Promise((resolve, reject) => {
32431
+ fn(...args, (err, result) => {
32432
+ if (err) reject(err);
32433
+ else resolve(result);
32434
+ });
32435
+ });
32436
+ }
32437
+ function isDeepStrictEqual(a, b2) {
32438
+ return JSON.stringify(a) === JSON.stringify(b2);
32439
+ }
32440
+ var node_util_default = { inspect, format, promisify, isDeepStrictEqual };
32441
+
32442
+ // ../../opentui/packages/core/src/renderables/composition/vnode.ts
32443
+ var BrandedVNode = /* @__PURE__ */ Symbol.for("@opentui/core/VNode");
32444
+ function isRenderableConstructor(value) {
32445
+ return typeof value === "function" && value.prototype && !!value.prototype[BrandedRenderable];
32446
+ }
32447
+ function flattenChildren(children) {
32448
+ const result = [];
32449
+ for (const child of children) {
32450
+ if (Array.isArray(child)) {
32451
+ result.push(...flattenChildren(child));
32452
+ } else if (child !== null && child !== void 0 && child !== false) {
32453
+ result.push(child);
32454
+ }
32455
+ }
32456
+ return result;
32457
+ }
32458
+ function isVNode(node) {
32459
+ return node && node[BrandedVNode];
32460
+ }
32461
+ function maybeMakeRenderable2(ctx, node) {
32462
+ if (isRenderable2(node)) return node;
32463
+ if (isVNode(node)) return instantiate(ctx, node);
32464
+ if (process.env.NODE_ENV !== "production") {
32465
+ console.warn("maybeMakeRenderable received an invalid node", node_util_default.inspect(node, { depth: 2 }));
32466
+ }
32467
+ return null;
32468
+ }
32469
+ registerMaybeMakeRenderable(maybeMakeRenderable2);
32470
+ function wrapWithDelegates(instance, delegateMap) {
32471
+ if (!delegateMap || Object.keys(delegateMap).length === 0) return instance;
32472
+ const descendantCache = /* @__PURE__ */ new Map();
32473
+ const getDescendant = (id) => {
32474
+ if (descendantCache.has(id)) {
32475
+ const cached = descendantCache.get(id);
32476
+ if (cached !== void 0) {
32477
+ return cached;
32478
+ }
32479
+ }
32480
+ const descendant = instance.findDescendantById(id);
32481
+ if (descendant) {
32482
+ descendantCache.set(id, descendant);
32483
+ }
32484
+ return descendant;
32485
+ };
32486
+ const proxy = new Proxy(instance, {
32487
+ get(target, prop, receiver) {
32488
+ if (typeof prop === "string" && delegateMap[prop]) {
32489
+ const host = getDescendant(delegateMap[prop]);
32490
+ if (host) {
32491
+ const value = host[prop];
32492
+ if (typeof value === "function") {
32493
+ return value.bind(host);
32494
+ }
32495
+ return value;
32496
+ }
32497
+ }
32498
+ return Reflect.get(target, prop, receiver);
32499
+ },
32500
+ set(target, prop, value, receiver) {
32501
+ if (typeof prop === "string" && delegateMap[prop]) {
32502
+ const host = getDescendant(delegateMap[prop]);
32503
+ if (host) {
32504
+ return Reflect.set(host, prop, value);
32505
+ }
32506
+ }
32507
+ return Reflect.set(target, prop, value, receiver);
32508
+ }
32509
+ });
32510
+ return proxy;
32511
+ }
32512
+ function instantiate(ctx, node) {
32513
+ if (isRenderable2(node)) return node;
32514
+ if (!node || typeof node !== "object") {
32515
+ throw new TypeError("mount() received an invalid vnode");
32516
+ }
32517
+ const vnode = node;
32518
+ const { type, props } = vnode;
32519
+ const children = flattenChildren(vnode.children || []);
32520
+ const delegateMap = vnode.__delegateMap;
32521
+ if (isRenderableConstructor(type)) {
32522
+ const instance = new type(ctx, props || {});
32523
+ for (const child of children) {
32524
+ if (isRenderable2(child)) {
32525
+ instance.add(child);
32526
+ } else {
32527
+ const mounted = instantiate(ctx, child);
32528
+ instance.add(mounted);
32529
+ }
32530
+ }
32531
+ const delegatedInstance = wrapWithDelegates(instance, delegateMap);
32532
+ const pendingCalls = vnode.__pendingCalls;
32533
+ if (pendingCalls) {
32534
+ for (const call of pendingCalls) {
32535
+ if (call.isProperty) {
32536
+ ;
32537
+ delegatedInstance[call.method] = call.args[0];
32538
+ } else {
32539
+ ;
32540
+ delegatedInstance[call.method].apply(delegatedInstance, call.args);
32541
+ }
32542
+ }
32543
+ }
32544
+ return delegatedInstance;
32545
+ }
32546
+ const resolved = type(props || {}, children);
32547
+ const inst = instantiate(ctx, resolved);
32548
+ return wrapWithDelegates(inst, delegateMap);
32549
+ }
32550
+
32541
32551
  // ../../opentui/packages/core/src/renderables/LineNumberRenderable.ts
32542
32552
  var GutterRenderable = class extends Renderable {
32543
32553
  target;
@@ -45653,7 +45663,7 @@ function setProperty(instance, type, propKey, propValue, oldPropValue) {
45653
45663
  }
45654
45664
  break;
45655
45665
  case "focused":
45656
- if (isRenderable(instance)) {
45666
+ if (isRenderable2(instance)) {
45657
45667
  if (!!propValue) {
45658
45668
  instance.focus();
45659
45669
  } else {
@@ -46055,14 +46065,14 @@ export {
46055
46065
  isPaddingType,
46056
46066
  isPositionType,
46057
46067
  isPositionTypeType,
46058
- isRenderable,
46068
+ isRenderable2 as isRenderable,
46059
46069
  isSizeType,
46060
46070
  isStyledText,
46061
46071
  isTextNodeRenderable,
46062
46072
  isValidBorderStyle,
46063
46073
  italic,
46064
46074
  magenta,
46065
- maybeMakeRenderable,
46075
+ maybeMakeRenderable2 as maybeMakeRenderable,
46066
46076
  parseAlign,
46067
46077
  parseAlignItems,
46068
46078
  parseBorderStyle,