essor 0.0.16-beta.1 → 0.0.16-beta.2

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,12 +1,12 @@
1
1
  /**
2
- * essor v0.0.16-beta.1
3
- * build time 2026-04-30T10:22:27.359Z
2
+ * essor v0.0.16-beta.2
3
+ * build time 2026-05-08T05:50:51.766Z
4
4
  * (c) 2023-Present jiangxd <jiangxd2016@gmail.com>
5
5
  * @license MIT
6
6
  **/
7
7
 
8
8
  // src/version.ts
9
- var __version = "0.0.16-beta.1";
9
+ var __version = "0.0.16-beta.2";
10
10
 
11
11
  // ../shared/dist/shared.esm.js
12
12
  var isObject = (val) => val !== null && typeof val === "object";
@@ -20,9 +20,6 @@ function isString(val) {
20
20
  function isNumber(val) {
21
21
  return typeof val === "number";
22
22
  }
23
- function isNull(val) {
24
- return val === null;
25
- }
26
23
  function isSymbol(val) {
27
24
  return typeof val === "symbol";
28
25
  }
@@ -42,13 +39,6 @@ function isNil(val) {
42
39
  return val === null || val === void 0;
43
40
  }
44
41
  var isFunction = (val) => typeof val === "function";
45
- function isFalsy(val) {
46
- return val === false || val === null || val === void 0;
47
- }
48
- var isPrimitive = (val) => val == null || typeof val === "string" || typeof val === "number" || typeof val === "boolean" || typeof val === "symbol" || typeof val === "undefined";
49
- function isHTMLElement(val) {
50
- return val instanceof HTMLElement;
51
- }
52
42
  var isPlainObject = (val) => _toString.call(val) === "[object Object]";
53
43
  function isStringNumber(val) {
54
44
  if (!isString(val) || val === "") {
@@ -56,12 +46,6 @@ function isStringNumber(val) {
56
46
  }
57
47
  return !Number.isNaN(Number(val));
58
48
  }
59
- function isUndefined(val) {
60
- return typeof val === "undefined";
61
- }
62
- function isBoolean(val) {
63
- return typeof val === "boolean";
64
- }
65
49
  var _toString = Object.prototype.toString;
66
50
  var hasOwnProperty = Object.prototype.hasOwnProperty;
67
51
  var hasOwn = (val, key) => hasOwnProperty.call(val, key);
@@ -2280,7 +2264,7 @@ var __objRest = (source, exclude) => {
2280
2264
  return target;
2281
2265
  };
2282
2266
  var __async = (__this, __arguments, generator) => {
2283
- return new Promise((resolve, reject) => {
2267
+ return new Promise((resolve2, reject) => {
2284
2268
  var fulfilled = (value) => {
2285
2269
  try {
2286
2270
  step(generator.next(value));
@@ -2295,7 +2279,7 @@ var __async = (__this, __arguments, generator) => {
2295
2279
  reject(e);
2296
2280
  }
2297
2281
  };
2298
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
2282
+ var step = (x) => x.done ? resolve2(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
2299
2283
  step((generator = generator.apply(__this, __arguments)).next());
2300
2284
  });
2301
2285
  };
@@ -2468,7 +2452,7 @@ function patchAttr(el, key, prev, next2) {
2468
2452
  const elementIsSVG = (el == null ? void 0 : el.namespaceURI) === SVG_NAMESPACE;
2469
2453
  const isXlink = elementIsSVG && key.startsWith("xlink:");
2470
2454
  const isXmlns = elementIsSVG && key.startsWith("xmlns:");
2471
- const isBoolean2 = isSpecialBooleanAttr(key) || isBooleanAttr(key);
2455
+ const isBoolean = isSpecialBooleanAttr(key) || isBooleanAttr(key);
2472
2456
  if (prev === next2) {
2473
2457
  return;
2474
2458
  }
@@ -2493,7 +2477,7 @@ function patchAttr(el, key, prev, next2) {
2493
2477
  }
2494
2478
  return;
2495
2479
  }
2496
- if (isBoolean2) {
2480
+ if (isBoolean) {
2497
2481
  if (includeBooleanAttr(next2)) {
2498
2482
  el.setAttribute(key, "");
2499
2483
  } else {
@@ -2931,13 +2915,19 @@ function insertNode(parent, child2, before) {
2931
2915
  }
2932
2916
  }
2933
2917
  function normalizeNode(node) {
2934
- if (isHTMLElement(node)) {
2935
- return node;
2918
+ if (node instanceof Node) return node;
2919
+ if (isComponent(node)) return node;
2920
+ const t = typeof node;
2921
+ if (node == null || t === "string" || t === "number" || t === "boolean" || t === "symbol") {
2922
+ return document.createTextNode(node === false || node == null ? "" : String(node));
2936
2923
  }
2937
- if (isPrimitive(node)) {
2938
- return document.createTextNode(isFalsy(node) ? "" : String(node));
2924
+ if (isObject(node)) {
2925
+ warn(
2926
+ "Rendering a plain object as a node is not recommended. The object will be converted to its string representation.",
2927
+ node
2928
+ );
2939
2929
  }
2940
- return node;
2930
+ return document.createTextNode(String(node));
2941
2931
  }
2942
2932
  function insert(parent, nodeFactory, before) {
2943
2933
  if (!parent) return;
@@ -2946,7 +2936,9 @@ function insert(parent, nodeFactory, before) {
2946
2936
  let isFirstRun = true;
2947
2937
  const resolveNodes = (raw) => {
2948
2938
  if (raw instanceof Node) return [raw];
2949
- if (isNull(raw) || isUndefined(raw) || isString(raw) || isNumber(raw) || isBoolean(raw)) {
2939
+ if (isComponent(raw)) return [raw];
2940
+ const t = typeof raw;
2941
+ if (raw == null || t === "string" || t === "number" || t === "boolean") {
2950
2942
  return [normalizeNode(raw)];
2951
2943
  }
2952
2944
  return coerceArray(raw).map((item) => isFunction(item) ? item() : item).flatMap((i) => i).map(normalizeNode);
@@ -3480,154 +3472,144 @@ function addEventListener(element, event, handler, options) {
3480
3472
  onCleanup(cleanup);
3481
3473
  }
3482
3474
  }
3483
- var INPUT_CHECKBOX_CHECKED = {
3475
+ function writeValue(el, v) {
3476
+ const target = el;
3477
+ const next2 = v == null ? "" : String(v);
3478
+ if (target.value !== next2) target.value = next2;
3479
+ }
3480
+ var CHECKBOX = {
3484
3481
  event: "change",
3485
- forceChangeEvent: true,
3486
- read: (n) => n.checked,
3487
- write: (n, v) => {
3488
- const el = n;
3482
+ forceChange: true,
3483
+ read: (el) => el.checked,
3484
+ write(el, v) {
3485
+ const e = el;
3489
3486
  const next2 = Boolean(v);
3490
- if (el.checked !== next2) el.checked = next2;
3487
+ if (e.checked !== next2) e.checked = next2;
3491
3488
  }
3492
3489
  };
3493
- var INPUT_RADIO_CHECKED = {
3490
+ var RADIO = {
3494
3491
  event: "change",
3495
- forceChangeEvent: true,
3496
- read: (n) => {
3497
- const el = n;
3498
- return el.checked ? el.value : "";
3492
+ forceChange: true,
3493
+ read(el) {
3494
+ const e = el;
3495
+ return e.checked ? e.value : "";
3499
3496
  },
3500
- write: (n, v) => {
3501
- const el = n;
3502
- const next2 = String(v) === el.value;
3503
- if (el.checked !== next2) el.checked = next2;
3497
+ write(el, v) {
3498
+ const e = el;
3499
+ const next2 = String(v) === e.value;
3500
+ if (e.checked !== next2) e.checked = next2;
3504
3501
  }
3505
3502
  };
3506
- var INPUT_FILE_FILES = {
3503
+ var FILE = {
3507
3504
  event: "change",
3508
- forceChangeEvent: true,
3509
- read: (n) => n.files,
3510
- // Browsers do not allow programmatic writes to <input type="file">.
3511
- write: () => {
3505
+ forceChange: true,
3506
+ read: (el) => el.files,
3507
+ write() {
3512
3508
  }
3509
+ // browsers forbid programmatic writes to file inputs
3513
3510
  };
3514
- var INPUT_VALUE = {
3511
+ var TEXT = {
3515
3512
  event: "input",
3516
- needsComposition: true,
3517
- read: (n) => n.value,
3518
- write: (n, v) => {
3519
- const el = n;
3520
- const next2 = v == null ? "" : String(v);
3521
- if (el.value !== next2) el.value = next2;
3522
- }
3513
+ ime: true,
3514
+ read: (el) => el.value,
3515
+ write: writeValue
3523
3516
  };
3524
- var SELECT_VALUE = {
3517
+ var TEXTAREA = {
3518
+ event: "input",
3519
+ ime: true,
3520
+ read: (el) => el.value,
3521
+ write: writeValue
3522
+ };
3523
+ var SELECT = {
3525
3524
  event: "change",
3526
- forceChangeEvent: true,
3527
- read: (n) => {
3528
- const s = n;
3525
+ forceChange: true,
3526
+ read(el) {
3527
+ const s = el;
3529
3528
  return s.multiple ? Array.from(s.selectedOptions, (o) => o.value) : s.value;
3530
3529
  },
3531
- write: (n, v) => {
3532
- const s = n;
3530
+ write(el, v) {
3531
+ const s = el;
3533
3532
  if (s.multiple) {
3534
- const set = new Set((Array.isArray(v) ? v : []).map(String));
3535
- for (const opt of Array.from(s.options)) opt.selected = set.has(opt.value);
3533
+ const selected = new Set((Array.isArray(v) ? v : []).map(String));
3534
+ for (const opt of Array.from(s.options)) opt.selected = selected.has(opt.value);
3536
3535
  } else {
3537
- const next2 = v == null ? "" : String(v);
3538
- if (s.value !== next2) s.value = next2;
3536
+ writeValue(el, v);
3539
3537
  }
3540
3538
  }
3541
3539
  };
3542
- var TEXTAREA_VALUE = {
3543
- event: "input",
3544
- needsComposition: true,
3545
- read: (n) => n.value,
3546
- write: (n, v) => {
3547
- const el = n;
3548
- const next2 = v == null ? "" : String(v);
3549
- if (el.value !== next2) el.value = next2;
3540
+ function resolve(node, prop) {
3541
+ switch (node.nodeName) {
3542
+ case "INPUT":
3543
+ if (prop === "checked") return node.type === "radio" ? RADIO : CHECKBOX;
3544
+ if (prop === "files") return FILE;
3545
+ return TEXT;
3546
+ case "SELECT":
3547
+ return SELECT;
3548
+ case "TEXTAREA":
3549
+ return TEXTAREA;
3550
+ default:
3551
+ return {
3552
+ event: "input",
3553
+ read: (el) => el[prop],
3554
+ write(el, v) {
3555
+ el[prop] = v;
3556
+ }
3557
+ };
3550
3558
  }
3551
- };
3552
- function resolveStrategy(node, prop) {
3553
- const tag = node.nodeName;
3554
- if (tag === "INPUT") {
3555
- const type = node.type;
3556
- if (prop === "checked") {
3557
- return type === "radio" ? INPUT_RADIO_CHECKED : INPUT_CHECKBOX_CHECKED;
3558
- }
3559
- if (prop === "files") return INPUT_FILE_FILES;
3560
- return INPUT_VALUE;
3561
- }
3562
- if (tag === "SELECT") return SELECT_VALUE;
3563
- if (tag === "TEXTAREA") return TEXTAREA_VALUE;
3564
- return {
3565
- event: "input",
3566
- read: (n) => n[prop],
3567
- write: (n, v) => {
3568
- n[prop] = v;
3569
- }
3570
- };
3571
3559
  }
3572
- function castValue(val, trim, number) {
3573
- if (!isString(val)) return val;
3574
- if (trim) val = val.trim();
3575
- if (number && val !== "") {
3576
- const parsed = Number(val);
3577
- if (!Number.isNaN(parsed)) return parsed;
3560
+ function applyModifiers(v, trim, toNum) {
3561
+ if (!isString(v)) return v;
3562
+ let s = v;
3563
+ if (trim) s = s.trim();
3564
+ if (toNum && s !== "") {
3565
+ const n = Number(s);
3566
+ if (!Number.isNaN(n)) return n;
3578
3567
  }
3579
- return val;
3568
+ return s;
3580
3569
  }
3581
- function isFocused(node) {
3582
- const root = node.getRootNode();
3583
- return (root instanceof Document || root instanceof ShadowRoot) && root.activeElement === node;
3570
+ function isFocused(el) {
3571
+ const root = el.getRootNode();
3572
+ return (root instanceof Document || root instanceof ShadowRoot) && root.activeElement === el;
3584
3573
  }
3585
3574
  function bindElement(node, prop, getter, setter, modifiers = {}) {
3586
3575
  if (!node) return;
3587
- const strategy = resolveStrategy(node, prop);
3588
- const { trim, number, lazy } = modifiers;
3589
- const isFiles = prop === "files";
3590
- const readModel = () => isFunction(getter) ? getter() : getter;
3591
- const transform = (v) => isFiles ? v : castValue(v, trim, number);
3592
- const eventName = lazy || strategy.forceChangeEvent ? "change" : strategy.event;
3576
+ const { event, read, write, forceChange, ime } = resolve(node, prop);
3577
+ const trim = modifiers.trim === true;
3578
+ const toNum = modifiers.number === true;
3579
+ const lazy = modifiers.lazy === true;
3580
+ const shouldCast = (trim || toNum) && prop !== "files";
3581
+ const getModel = isFunction(getter) ? getter : () => getter;
3582
+ const cast = shouldCast ? (v) => applyModifiers(v, trim, toNum) : (v) => v;
3593
3583
  let composing = false;
3594
- const syncFromDom = () => {
3584
+ const eventName = lazy || forceChange ? "change" : event;
3585
+ const syncToModel = () => {
3595
3586
  if (composing) return;
3596
- const raw = strategy.read(node);
3587
+ const raw = read(node);
3597
3588
  if (raw === void 0) return;
3598
- if (isFiles) {
3599
- setter(raw);
3600
- return;
3601
- }
3602
- const next2 = transform(raw);
3603
- if (!Object.is(readModel(), next2)) {
3604
- setter(next2);
3605
- }
3589
+ const next2 = cast(raw);
3590
+ if (!Object.is(getModel(), next2)) setter(next2);
3606
3591
  };
3607
- addEventListener(node, eventName, syncFromDom);
3608
- if (!lazy && !isFiles && (trim || number) && eventName !== "change") {
3609
- addEventListener(node, "change", () => {
3610
- strategy.write(node, transform(strategy.read(node)));
3611
- });
3592
+ addEventListener(node, eventName, syncToModel);
3593
+ if (!lazy && shouldCast && eventName !== "change") {
3594
+ addEventListener(node, "change", () => write(node, cast(read(node))));
3612
3595
  }
3613
- if (strategy.needsComposition && !lazy) {
3596
+ if (ime && !lazy) {
3614
3597
  addEventListener(node, "compositionstart", () => {
3615
3598
  composing = true;
3616
3599
  });
3617
3600
  addEventListener(node, "compositionend", () => {
3618
3601
  if (!composing) return;
3619
3602
  composing = false;
3620
- syncFromDom();
3603
+ syncToModel();
3621
3604
  });
3622
3605
  }
3623
3606
  const runner = effect(() => {
3624
- const value = readModel();
3625
- if (strategy.needsComposition && !lazy && isFocused(node)) {
3607
+ const value = getModel();
3608
+ if (ime && !lazy && isFocused(node)) {
3626
3609
  if (composing) return;
3627
- const current = transform(strategy.read(node));
3628
- if (Object.is(current, value)) return;
3610
+ if (Object.is(cast(read(node)), value)) return;
3629
3611
  }
3630
- strategy.write(node, value);
3612
+ write(node, value);
3631
3613
  });
3632
3614
  if (getActiveScope()) {
3633
3615
  onCleanup(() => runner.stop());
@@ -4375,5 +4357,5 @@ function For(props) {
4375
4357
  For[FOR_COMPONENT] = true;
4376
4358
 
4377
4359
  export { Component, For, Fragment, Portal, Suspense, TriggerOpTypes, __version, addEvent, addEventListener, batch, beginHydration, bindElement, child, clearDelegatedEvents, computed, consumeTeleportAnchor, consumeTeleportBlock, createApp, createComponent, createResource, createStore, defineAsyncComponent, delegateEvents, effect, endBatch, endHydration, error, escapeHTML, getBatchDepth, getHydrationKey, getRenderedElement, hydrate, inject, insert, isArray, isBatching, isComponent, isComputed, isEffect, isFragment, isFunction, isHydrating, isNil, isObject, isPortal, isPromise, isReactive, isRef, isShallow, isSignal, isString, isSuspense, memoEffect, next, nextTick, normalizeClass, normalizeClassName, normalizeStyle, nthChild, omitProps, onDestroy, onMount, onUpdate, patchAttr, patchAttrHydrate, patchClass, patchClassHydrate, patchStyle, patchStyleHydrate, provide, queueJob, queuePreFlushCb, reactive, ref, resetHydrationKey, setStyle, shallowReactive, shallowSignal, signal, startBatch, stop, styleToString, template, toRaw, toReactive, trigger, untrack, watch };
4378
- //# sourceMappingURL=chunk-6WF7W6MG.esm.js.map
4379
- //# sourceMappingURL=chunk-6WF7W6MG.esm.js.map
4360
+ //# sourceMappingURL=chunk-FIBC7TTZ.esm.js.map
4361
+ //# sourceMappingURL=chunk-FIBC7TTZ.esm.js.map