haori 0.66.0 → 0.67.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/haori.es.js CHANGED
@@ -453,21 +453,21 @@ const rr = /^[A-Za-z_$][A-Za-z0-9_$]*(\.[A-Za-z_$][A-Za-z0-9_$]*)*$/, ht = "new:
453
453
  I.enhancers = /* @__PURE__ */ new Map(), I.instances = /* @__PURE__ */ new WeakMap(), I.warnedUnknownNames = /* @__PURE__ */ new Set(), I.warnedMissingGlobals = /* @__PURE__ */ new Set(), I.visited = /* @__PURE__ */ new WeakSet(), I.mutationCapture = null;
454
454
  let le = I;
455
455
  const Ft = "yyyy/MM/dd HH:mm", ir = "en-US", ft = 1e4;
456
- function ge(f) {
456
+ function me(f) {
457
457
  return String(f).padStart(2, "0");
458
458
  }
459
459
  function Ct(f, e, t, r, i, s) {
460
460
  return {
461
461
  yyyy: String(f).padStart(4, "0"),
462
- yy: ge(f % 100),
463
- MM: ge(e),
462
+ yy: me(f % 100),
463
+ MM: me(e),
464
464
  M: String(e),
465
- dd: ge(t),
465
+ dd: me(t),
466
466
  d: String(t),
467
- HH: ge(r),
467
+ HH: me(r),
468
468
  H: String(r),
469
- mm: ge(i),
470
- ss: ge(s)
469
+ mm: me(i),
470
+ ss: me(s)
471
471
  };
472
472
  }
473
473
  function $t(f, e) {
@@ -623,13 +623,13 @@ function Qe(f, e) {
623
623
  if (i < 1 || i > 12)
624
624
  return "";
625
625
  const s = Number.isFinite(e) ? Math.trunc(e) : 0, n = r * 12 + (i - 1) + s, a = Math.floor(n / 12), o = n - a * 12 + 1;
626
- return `${String(a).padStart(4, "0")}-${ge(o)}`;
626
+ return `${String(a).padStart(4, "0")}-${me(o)}`;
627
627
  }
628
628
  function or(f) {
629
629
  if (typeof f == "string" && f.trim() !== "")
630
630
  return Qe(f, 0);
631
631
  const e = /* @__PURE__ */ new Date();
632
- return `${String(e.getFullYear()).padStart(4, "0")}-${ge(e.getMonth() + 1)}`;
632
+ return `${String(e.getFullYear()).padStart(4, "0")}-${me(e.getMonth() + 1)}`;
633
633
  }
634
634
  function Ut(f, e) {
635
635
  const t = Math.trunc(Number(f));
@@ -4964,20 +4964,20 @@ ${u.template}`,
4964
4964
  };
4965
4965
  P.GLOBAL_KEY = "__HAORI_EVALUATION_PROFILE__", P.ELEMENT_STORES = /* @__PURE__ */ new Map(), P.collecting = !1, P.DEFAULT_REPORT_LIMIT = 20;
4966
4966
  let Ye = P;
4967
- const me = class me {
4967
+ const ye = class ye {
4968
4968
  /**
4969
4969
  * フラグメントのコンストラクタ。
4970
4970
  *
4971
4971
  * @param target 対象ノード
4972
4972
  */
4973
4973
  constructor(e) {
4974
- this.parent = null, this.mounted = !1, this.skipMutationNodes = !1, this.skipMutationNodeSet = /* @__PURE__ */ new Set(), this.target = e, me.FRAGMENT_CACHE.set(e, this);
4974
+ this.parent = null, this.mounted = !1, this.skipMutationNodes = !1, this.skipMutationNodeSet = /* @__PURE__ */ new Set(), this.target = e, ye.FRAGMENT_CACHE.set(e, this);
4975
4975
  }
4976
4976
  static get(e) {
4977
4977
  if (e == null)
4978
4978
  return null;
4979
- if (me.FRAGMENT_CACHE.has(e))
4980
- return me.FRAGMENT_CACHE.get(e);
4979
+ if (ye.FRAGMENT_CACHE.has(e))
4980
+ return ye.FRAGMENT_CACHE.get(e);
4981
4981
  let t;
4982
4982
  switch (e.nodeType) {
4983
4983
  case Node.ELEMENT_NODE:
@@ -5005,7 +5005,7 @@ const me = class me {
5005
5005
  * @returns キャッシュ済みのフラグメント。無ければ `null`
5006
5006
  */
5007
5007
  static peek(e) {
5008
- return me.FRAGMENT_CACHE.get(e) ?? null;
5008
+ return ye.FRAGMENT_CACHE.get(e) ?? null;
5009
5009
  }
5010
5010
  /**
5011
5011
  * 指定した子ノードを、エンジン自身が出し入れしている最中かどうかを返します。
@@ -5100,7 +5100,7 @@ const me = class me {
5100
5100
  * @return 除去のPromise
5101
5101
  */
5102
5102
  remove(e = !0) {
5103
- return this.parent && this.parent.removeChild(this), me.FRAGMENT_CACHE.delete(this.target), e ? this.unmount() : Promise.resolve();
5103
+ return this.parent && this.parent.removeChild(this), ye.FRAGMENT_CACHE.delete(this.target), e ? this.unmount() : Promise.resolve();
5104
5104
  }
5105
5105
  /**
5106
5106
  * 対象ノードを取得します。
@@ -5127,8 +5127,8 @@ const me = class me {
5127
5127
  this.parent = e;
5128
5128
  }
5129
5129
  };
5130
- me.FRAGMENT_CACHE = /* @__PURE__ */ new WeakMap();
5131
- let D = me;
5130
+ ye.FRAGMENT_CACHE = /* @__PURE__ */ new WeakMap();
5131
+ let D = ye;
5132
5132
  const v = class v extends D {
5133
5133
  /**
5134
5134
  * エレメントフラグメントのコンストラクタ。
@@ -6719,11 +6719,11 @@ const v = class v extends D {
6719
6719
  if (s) {
6720
6720
  const fe = this.attributeMap.get(e);
6721
6721
  if (fe && (fe.isEvaluate || fe.isForceEvaluation()) && !o.isEvaluate && !o.isForceEvaluation()) {
6722
- const Ee = J.enqueue(() => {
6722
+ const Ae = J.enqueue(() => {
6723
6723
  }).finally(() => {
6724
6724
  this.releaseSelfWritingAttributes(n);
6725
6725
  });
6726
- return this.holdSelfWritingAttributes(n, Ee), Ee;
6726
+ return this.holdSelfWritingAttributes(n, Ae), Ae;
6727
6727
  }
6728
6728
  }
6729
6729
  this.attributeMap.set(e, o);
@@ -6732,21 +6732,21 @@ const v = class v extends D {
6732
6732
  element: l,
6733
6733
  rawName: e,
6734
6734
  template: r
6735
- }), d = v.isLateActionAttribute(e) ? re.withoutDiagnosis(u) : u(), y = o.isEvaluate || o.isRawEvaluate, b = e === t && v.BOOLEAN_ATTRIBUTES.has(t.toLowerCase()), E = o.isSingleExpression(), A = ye.joinEvaluateResults(d.results), w = d.results.length === 1 ? d.results[0] : A, $ = t === "value" && v.resolveDeclaredValueType(l) === "boolean", C = w === !1 && !$, se = !o.isForceEvaluation() && (t !== e ? d.hasUnresolvedReference || w === null || w === void 0 || C : b ? d.hasUnresolvedReference || w === null || w === void 0 || w === !1 : E ? d.hasUnresolvedReference || w === null || w === void 0 || C : y && A === "");
6735
+ }), d = v.isLateActionAttribute(e) ? re.withoutDiagnosis(u) : u(), y = o.isEvaluate || o.isRawEvaluate, b = e === t && v.BOOLEAN_ATTRIBUTES.has(t.toLowerCase()), E = o.isSingleExpression(), A = be.joinEvaluateResults(d.results), w = d.results.length === 1 ? d.results[0] : A, $ = t === "value" && v.resolveDeclaredValueType(l) === "boolean", C = w === !1 && !$, se = !o.isForceEvaluation() && (t !== e ? d.hasUnresolvedReference || w === null || w === void 0 || C : b ? d.hasUnresolvedReference || w === null || w === void 0 || w === !1 : E ? d.hasUnresolvedReference || w === null || w === void 0 || C : y && A === "");
6736
6736
  if (se && d.hasUnresolvedReference && v.warnUnresolvedAttribute(
6737
6737
  e,
6738
6738
  t,
6739
6739
  r,
6740
6740
  l
6741
6741
  ), V.isEnabled() && w === !1 && E) {
6742
- const fe = o.getSingleExpression(), Ee = fe === null ? null : re.diagnoseStrictComparison(
6742
+ const fe = o.getSingleExpression(), Ae = fe === null ? null : re.diagnoseStrictComparison(
6743
6743
  fe,
6744
6744
  this.getBindingData()
6745
6745
  );
6746
- Ee !== null && v.warnTypeMismatchedComparison(
6746
+ Ae !== null && v.warnTypeMismatchedComparison(
6747
6747
  e,
6748
6748
  r,
6749
- Ee,
6749
+ Ae,
6750
6750
  l
6751
6751
  );
6752
6752
  }
@@ -6756,25 +6756,25 @@ const v = class v extends D {
6756
6756
  `Attribute "${t}" was removed because the evaluated URL uses a script scheme: ${e}="${r}" -> ${ae}`,
6757
6757
  l
6758
6758
  );
6759
- const k = j ? null : ae, B = e !== t && l.getAttribute(e) !== r, ue = k === null ? l.hasAttribute(t) : l.getAttribute(t) !== k, U = k === null ? "" : k, Q = Z && !K && l.value !== U, pe = t === "checked" && l instanceof HTMLInputElement && (l.type === "checkbox" || l.type === "radio"), ce = t === "selected" && l instanceof HTMLOptionElement, W = ee.activeElement, G = W !== null && (pe && l === W || ce && l.closest("select") === W) || (pe || ce) && this.hasPendingCheckableUserEdit(ce), ie = this.getCheckableUserEditSequence(ce), be = k !== null, _e = pe && o.isEvaluate && !G && l.checked !== be, Ve = ce && o.isEvaluate && !G && l.selected !== be;
6759
+ const k = j ? null : ae, B = e !== t && l.getAttribute(e) !== r, ue = k === null ? l.hasAttribute(t) : l.getAttribute(t) !== k, U = k === null ? "" : k, Q = Z && !K && l.value !== U, pe = t === "checked" && l instanceof HTMLInputElement && (l.type === "checkbox" || l.type === "radio"), ce = t === "selected" && l instanceof HTMLOptionElement, W = ee.activeElement, G = W !== null && (pe && l === W || ce && l.closest("select") === W) || (pe || ce) && this.hasPendingCheckableUserEdit(ce), ie = this.getCheckableUserEditSequence(ce), Ee = k !== null, _e = pe && o.isEvaluate && !G && l.checked !== Ee, Ve = ce && o.isEvaluate && !G && l.selected !== Ee;
6760
6760
  if (!B && !ue && !Q && !_e && !Ve)
6761
6761
  return Z && !K && (this.value = this.normalizeValueForElement(
6762
6762
  l,
6763
6763
  U
6764
6764
  ), this.clearUnappliedValueWrite()), (pe || ce) && !G && this.syncCheckableValueFromDom(ce), Promise.resolve();
6765
6765
  const ut = J.enqueue(() => {
6766
- const fe = this.getCheckableUserEditSequence(ce) !== ie, Ee = ce && (G || fe) ? v.captureSelection(
6766
+ const fe = this.getCheckableUserEditSequence(ce) !== ie, Ae = ce && (G || fe) ? v.captureSelection(
6767
6767
  // 守るべき選択があるのは所属する `<select>` があるときだけ。
6768
6768
  l.closest(
6769
6769
  "select"
6770
6770
  )
6771
6771
  ) : null;
6772
- B && l.setAttribute(e, r), k === null ? l.removeAttribute(t) : ue && (l.setAttribute(t, k), t === `${c.prefix}bind` && this.recordSelfWrittenBind(k)), t === "style" && this.captureAndHideDisplay(), Ee?.(), Z && !K && !(v.isUserEditableValue(l) && this.isSupersededByUserEdit(ne)) && (this.value = this.normalizeValueForElement(
6772
+ B && l.setAttribute(e, r), k === null ? l.removeAttribute(t) : ue && (l.setAttribute(t, k), t === `${c.prefix}bind` && this.recordSelfWrittenBind(k)), t === "style" && this.captureAndHideDisplay(), Ae?.(), Z && !K && !(v.isUserEditableValue(l) && this.isSupersededByUserEdit(ne)) && (this.value = this.normalizeValueForElement(
6773
6773
  l,
6774
6774
  U
6775
6775
  ), Q && (l.value = U), this.recordValueWriteResult(l.value === U));
6776
6776
  const _t = _e && !fe, er = Ve && !fe;
6777
- _t && (l.checked = be), er && (l.selected = be), (_e || Ve) && this.syncCheckableValueFromDom(Ve);
6777
+ _t && (l.checked = Ee), er && (l.selected = Ee), (_e || Ve) && this.syncCheckableValueFromDom(Ve);
6778
6778
  }).finally(() => {
6779
6779
  this.releaseSelfWritingAttributes(n);
6780
6780
  });
@@ -6834,7 +6834,7 @@ const v = class v extends D {
6834
6834
  value: r.results[0],
6835
6835
  hasUnresolvedReference: r.hasUnresolvedReference
6836
6836
  } : {
6837
- value: ye.joinEvaluateResults(r.results),
6837
+ value: be.joinEvaluateResults(r.results),
6838
6838
  hasUnresolvedReference: r.hasUnresolvedReference
6839
6839
  };
6840
6840
  }
@@ -7284,7 +7284,7 @@ class de extends D {
7284
7284
  * @param target 対象テキストノード
7285
7285
  */
7286
7286
  constructor(e) {
7287
- super(e), this.skipMutation = !1, this.renderedText = null, this.text = e.textContent || "", this.contents = new ye(this.text);
7287
+ super(e), this.skipMutation = !1, this.renderedText = null, this.text = e.textContent || "", this.contents = new be(this.text);
7288
7288
  }
7289
7289
  /**
7290
7290
  * フラグメントをクローンします。
@@ -7329,7 +7329,7 @@ class de extends D {
7329
7329
  * @returns 更新のPromise
7330
7330
  */
7331
7331
  setContent(e) {
7332
- return this.skipMutation || this.text === e ? Promise.resolve() : (this.text = e, this.contents = new ye(e), this.evaluate());
7332
+ return this.skipMutation || this.text === e ? Promise.resolve() : (this.text = e, this.contents = new be(e), this.evaluate());
7333
7333
  }
7334
7334
  /**
7335
7335
  * フラグメントを評価します。
@@ -7345,7 +7345,7 @@ class de extends D {
7345
7345
  return J.enqueue(() => {
7346
7346
  this.skipMutation = !0;
7347
7347
  let t = this.text;
7348
- this.contents.isEvaluate && (t = ye.joinEvaluateResults(
7348
+ this.contents.isEvaluate && (t = be.joinEvaluateResults(
7349
7349
  this.contents.evaluate(this.parent.getBindingData(), {
7350
7350
  kind: "text",
7351
7351
  element: this.parent.getTarget(),
@@ -7549,8 +7549,8 @@ const Je = class Je {
7549
7549
  }
7550
7550
  };
7551
7551
  Je.PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g;
7552
- let ye = Je;
7553
- const _ = class _ extends ye {
7552
+ let be = Je;
7553
+ const _ = class _ extends be {
7554
7554
  /**
7555
7555
  * コンストラクタ。
7556
7556
  *
@@ -11269,7 +11269,7 @@ const wr = [
11269
11269
  ], Sr = "__haoriHistoryState__", tt = "data-haori-click-lock", Dt = "ファイルを保存できませんでした", Rr = 100;
11270
11270
  let Pe = null;
11271
11271
  const Tr = ["info", "warning", "error", "success"], xt = /^(\d{3})-(click|click-await|close|toast|toast-level|no-message|bind)$/;
11272
- function Ae() {
11272
+ function ge() {
11273
11273
  const e = globalThis.window?.Haori;
11274
11274
  return wr.every(
11275
11275
  (r) => typeof e?.[r] == "function"
@@ -12087,7 +12087,17 @@ ${U}
12087
12087
  Q && (r.runScript = Q);
12088
12088
  }
12089
12089
  const ue = g.attrName(t, "clipboard");
12090
- e.hasAttribute(ue) && (r.clipboardAttrName = ue);
12090
+ e.hasAttribute(ue) && (r.clipboardAttrName = ue, r.clipboardErrorToastMessage = g.readLateAttribute(
12091
+ e,
12092
+ r,
12093
+ "clipboard-error-toast",
12094
+ g.attrName(t, "clipboard-error-toast")
12095
+ ), r.clipboardErrorToastLevel = g.readToastLevel(
12096
+ e,
12097
+ r,
12098
+ "clipboard-error-toast-level",
12099
+ g.attrName(t, "clipboard-error-toast-level")
12100
+ ));
12091
12101
  }
12092
12102
  const s = g.attrName(t, "fetch"), n = e.hasAttribute(s);
12093
12103
  if (n) {
@@ -12192,8 +12202,8 @@ ${U}
12192
12202
  g.attrName(t, "adjust")
12193
12203
  );
12194
12204
  G.length > 0 ? (r.adjustFragments = [], G.forEach((ie) => {
12195
- const be = D.get(ie);
12196
- be && r.adjustFragments.push(be);
12205
+ const Ee = D.get(ie);
12206
+ Ee && r.adjustFragments.push(Ee);
12197
12207
  })) : m.error(
12198
12208
  "Haori",
12199
12209
  `Adjust element not found: ${W} (${g.attrName(t, "adjust")})`
@@ -12576,6 +12586,31 @@ ${W}
12576
12586
  return m.warn("Haori", `${e}: failed to write: ${n}`), Promise.resolve(!1);
12577
12587
  }
12578
12588
  }
12589
+ /**
12590
+ * クリップボードへ書けずに止まったことをトーストで知らせます。
12591
+ *
12592
+ * 仕様「`data-{event}-clipboard`」の「書けなかったことを知らせる」です。文言と
12593
+ * レベルは表示直前に評価し直します。
12594
+ *
12595
+ * @returns 表示を終えたら解決する Promise
12596
+ */
12597
+ async showClipboardErrorToast() {
12598
+ const e = g.normalizeAttributeText(
12599
+ this.resolveLateAttribute(
12600
+ "clipboard-error-toast",
12601
+ this.options.clipboardErrorToastMessage
12602
+ )
12603
+ );
12604
+ if (!e)
12605
+ return;
12606
+ const t = g.toToastLevel(
12607
+ this.resolveLateAttribute(
12608
+ "clipboard-error-toast-level",
12609
+ this.options.clipboardErrorToastLevel
12610
+ )
12611
+ );
12612
+ await ge().toast(e, t ?? "info");
12613
+ }
12579
12614
  /**
12580
12615
  * 一連の処理を実行します。成功結果を内部で扱うための実体です。
12581
12616
  *
@@ -12612,7 +12647,7 @@ ${W}
12612
12647
  m.error("Haori", `Run script execution error: ${A}`);
12613
12648
  }
12614
12649
  if (r && !await r)
12615
- return await this.commitEditOnStop(), !1;
12650
+ return await this.commitEditOnStop(), await this.showClipboardErrorToast(), !1;
12616
12651
  if (!await this.confirm())
12617
12652
  return await this.commitEditOnStop(), !1;
12618
12653
  if (this.options.downloadFolder && await this.prepareDownloadFolder() === "cancelled")
@@ -13008,7 +13043,7 @@ ${W}
13008
13043
  `保存先のフォルダを確かめられなかったため、今までどおり保存します: ${l}`
13009
13044
  ), "fallback";
13010
13045
  }
13011
- if (n && !await Ae().confirm(
13046
+ if (n && !await ge().confirm(
13012
13047
  `${s} は既にあります。上書きしますか?`
13013
13048
  ))
13014
13049
  return "cancelled";
@@ -13094,7 +13129,7 @@ ${W}
13094
13129
  * @returns 表示の完了 Promise
13095
13130
  */
13096
13131
  async showDownloadFailure(e) {
13097
- const t = this.resolveMessageScope(), r = Ae();
13132
+ const t = this.resolveMessageScope(), r = ge();
13098
13133
  await r.clearMessages(t), e && await r.addErrorMessage(t, Dt);
13099
13134
  }
13100
13135
  /**
@@ -13178,7 +13213,7 @@ ${W}
13178
13213
  * フェッチ後の処理を実行します。
13179
13214
  */
13180
13215
  async handleFetchResult(e, t, r) {
13181
- const i = Ae();
13216
+ const i = ge();
13182
13217
  if (!e.ok) {
13183
13218
  if (Jt(e.status, {
13184
13219
  element: this.options.targetFragment.getTarget(),
@@ -13377,7 +13412,7 @@ ${W}
13377
13412
  `${t.key}-click-await`
13378
13413
  ))
13379
13414
  return;
13380
- const i = Ae(), s = [];
13415
+ const i = ge(), s = [];
13381
13416
  t.closeFragments?.forEach((a) => {
13382
13417
  const o = a.getTarget();
13383
13418
  o instanceof HTMLElement ? s.push(i.closeDialog(o)) : m.error("Haori", "Element is not an HTML element: ", o);
@@ -13509,10 +13544,10 @@ ${W}
13509
13544
  let r = null;
13510
13545
  this.options.formFragment ? r = this.options.formFragment : this.options.targetFragment && (r = x.getFormFragment(this.options.targetFragment) || this.options.targetFragment);
13511
13546
  const i = r ? r.getTarget() : document.body;
13512
- await Ae().clearMessages(i);
13547
+ await ge().clearMessages(i);
13513
13548
  const s = async (u) => {
13514
13549
  const d = r ? r.getTarget() : document.body;
13515
- await Ae().addErrorMessage(d, u);
13550
+ await ge().addErrorMessage(d, u);
13516
13551
  }, n = () => {
13517
13552
  if (!this.options.scrollOnError)
13518
13553
  return;
@@ -13726,7 +13761,7 @@ ${W}
13726
13761
  */
13727
13762
  confirm() {
13728
13763
  const e = this.options.confirmMessage;
13729
- return e == null ? Promise.resolve(!0) : Ae().confirm(e);
13764
+ return e == null ? Promise.resolve(!0) : ge().confirm(e);
13730
13765
  }
13731
13766
  /**
13732
13767
  * 結果データを対象のフラグメントにバインドします。
@@ -18555,7 +18590,7 @@ S.CONFIG_KEYS = /* @__PURE__ */ new Set([
18555
18590
  "state"
18556
18591
  ]), S.DEFAULT_INTERVAL_MS = 5e3, S.MIN_INTERVAL_MS = 100, S.registrations = /* @__PURE__ */ new Map(), S.visibilityListener = null;
18557
18592
  let $e = S;
18558
- const Pr = "0.66.0";
18593
+ const Pr = "0.67.0";
18559
18594
  function Lr(f) {
18560
18595
  typeof requestAnimationFrame == "function" ? requestAnimationFrame(() => f()) : Promise.resolve().then(f);
18561
18596
  }