hyperscript-rxjs 1.3.14 → 1.3.16

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.
@@ -0,0 +1,4114 @@
1
+ /******/ (() => { // webpackBootstrap
2
+ /******/ "use strict";
3
+ /******/ // The require scope
4
+ /******/ var __webpack_require__ = {};
5
+ /******/
6
+ /************************************************************************/
7
+ /******/ /* webpack/runtime/define property getters */
8
+ /******/ (() => {
9
+ /******/ // define getter functions for harmony exports
10
+ /******/ __webpack_require__.d = (exports, definition) => {
11
+ /******/ for(var key in definition) {
12
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
13
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
14
+ /******/ }
15
+ /******/ }
16
+ /******/ };
17
+ /******/ })();
18
+ /******/
19
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
20
+ /******/ (() => {
21
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
22
+ /******/ })();
23
+ /******/
24
+ /******/ /* webpack/runtime/make namespace object */
25
+ /******/ (() => {
26
+ /******/ // define __esModule on exports
27
+ /******/ __webpack_require__.r = (exports) => {
28
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
29
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
30
+ /******/ }
31
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
32
+ /******/ };
33
+ /******/ })();
34
+ /******/
35
+ /************************************************************************/
36
+ var __webpack_exports__ = {};
37
+ // ESM COMPAT FLAG
38
+ __webpack_require__.r(__webpack_exports__);
39
+
40
+ // EXPORTS
41
+ __webpack_require__.d(__webpack_exports__, {
42
+ Comparer: () => (/* reexport */ Comparer),
43
+ Deep: () => (/* reexport */ Deep),
44
+ ObservableArray: () => (/* reexport */ ObservableArray),
45
+ a: () => (/* reexport */ a),
46
+ abbr: () => (/* reexport */ abbr),
47
+ address: () => (/* reexport */ address),
48
+ advance: () => (/* reexport */ advance),
49
+ area: () => (/* reexport */ tags_area),
50
+ arrayInsert: () => (/* reexport */ arrayInsert),
51
+ arrayRemove: () => (/* reexport */ arrayRemove),
52
+ article: () => (/* reexport */ article),
53
+ aside: () => (/* reexport */ aside),
54
+ attachSubscriptionToNode: () => (/* reexport */ attachSubscriptionToNode),
55
+ audio: () => (/* reexport */ audio),
56
+ b: () => (/* reexport */ b),
57
+ bdi: () => (/* reexport */ bdi),
58
+ bdo: () => (/* reexport */ bdo),
59
+ bindTabIndex: () => (/* reexport */ bindTabIndex),
60
+ blockLevelFamily: () => (/* reexport */ blockLevelFamily),
61
+ blockquote: () => (/* reexport */ blockquote),
62
+ br: () => (/* reexport */ br),
63
+ button: () => (/* reexport */ tags_button),
64
+ caption: () => (/* reexport */ caption),
65
+ checkbox: () => (/* reexport */ checkbox_checkbox),
66
+ choice: () => (/* reexport */ choice),
67
+ cite: () => (/* reexport */ cite),
68
+ code: () => (/* reexport */ code),
69
+ col: () => (/* reexport */ col),
70
+ colgroup: () => (/* reexport */ colgroup),
71
+ collapse: () => (/* reexport */ collapse),
72
+ compareDate: () => (/* reexport */ compareDate),
73
+ compareEntries: () => (/* reexport */ compareEntries),
74
+ compareKey: () => (/* reexport */ compareKey),
75
+ compareKeyPath: () => (/* reexport */ compareKeyPath),
76
+ compareNumber: () => (/* reexport */ compareNumber),
77
+ compose: () => (/* reexport */ compose),
78
+ cond: () => (/* reexport */ cond),
79
+ data: () => (/* reexport */ data),
80
+ datalist: () => (/* reexport */ datalist),
81
+ dd: () => (/* reexport */ dd),
82
+ defaultCompare: () => (/* reexport */ defaultCompare),
83
+ defaultComparer: () => (/* reexport */ defaultComparer),
84
+ del: () => (/* reexport */ del),
85
+ details: () => (/* reexport */ details),
86
+ dfn: () => (/* reexport */ dfn),
87
+ dialog: () => (/* reexport */ dialog),
88
+ div: () => (/* reexport */ div),
89
+ dl: () => (/* reexport */ dl),
90
+ dt: () => (/* reexport */ dt),
91
+ em: () => (/* reexport */ em),
92
+ entryComparer: () => (/* reexport */ entryComparer),
93
+ erectObject: () => (/* reexport */ erectObject),
94
+ fieldset: () => (/* reexport */ fieldset),
95
+ figcaption: () => (/* reexport */ figcaption),
96
+ figure: () => (/* reexport */ figure),
97
+ findLastIndex: () => (/* reexport */ findLastIndex),
98
+ flat: () => (/* reexport */ flat),
99
+ flip: () => (/* reexport */ flip),
100
+ fold: () => (/* reexport */ fold),
101
+ footer: () => (/* reexport */ footer),
102
+ form: () => (/* reexport */ tags_form),
103
+ fragment: () => (/* reexport */ fragment),
104
+ getDisplay: () => (/* reexport */ getDisplay),
105
+ getNestedProperty: () => (/* reexport */ getNestedProperty),
106
+ groupByFirstLevelKey: () => (/* reexport */ groupByFirstLevelKey),
107
+ h1: () => (/* reexport */ h1),
108
+ h2: () => (/* reexport */ h2),
109
+ h3: () => (/* reexport */ h3),
110
+ h4: () => (/* reexport */ h4),
111
+ h5: () => (/* reexport */ h5),
112
+ h6: () => (/* reexport */ h6),
113
+ header: () => (/* reexport */ header),
114
+ hgroup: () => (/* reexport */ hgroup),
115
+ hr: () => (/* reexport */ hr),
116
+ hyperscript: () => (/* reexport */ hyperscript),
117
+ i: () => (/* reexport */ i),
118
+ img: () => (/* reexport */ img),
119
+ inlineFamily: () => (/* reexport */ inlineFamily),
120
+ input: () => (/* reexport */ input),
121
+ ins: () => (/* reexport */ ins),
122
+ intersectObject: () => (/* reexport */ intersectObject),
123
+ isEmptyObject: () => (/* reexport */ isEmptyObject),
124
+ isPlainObject: () => (/* reexport */ isPlainObject),
125
+ isRange: () => (/* reexport */ isRange),
126
+ isRxType: () => (/* reexport */ isRxType),
127
+ kbd: () => (/* reexport */ kbd),
128
+ keyComparer: () => (/* reexport */ keyComparer),
129
+ keyPathComparer: () => (/* reexport */ keyPathComparer),
130
+ label: () => (/* reexport */ label),
131
+ legend: () => (/* reexport */ legend),
132
+ li: () => (/* reexport */ li),
133
+ main: () => (/* reexport */ main),
134
+ mark: () => (/* reexport */ mark),
135
+ menu: () => (/* reexport */ menu),
136
+ menuitem: () => (/* reexport */ menuitem),
137
+ meter: () => (/* reexport */ meter),
138
+ multiselect: () => (/* reexport */ multiselect),
139
+ nav: () => (/* reexport */ nav),
140
+ nestedCombineLatest: () => (/* reexport */ nestedCombineLatest),
141
+ nestedMerge: () => (/* reexport */ nestedMerge),
142
+ normalizeChildNodes: () => (/* reexport */ normalizeChildNodes),
143
+ numberbox: () => (/* reexport */ numberbox),
144
+ ol: () => (/* reexport */ ol),
145
+ optgroup: () => (/* reexport */ optgroup),
146
+ option: () => (/* reexport */ tags_option),
147
+ output: () => (/* reexport */ output),
148
+ p: () => (/* reexport */ p),
149
+ parseHyperscriptArgs: () => (/* reexport */ parseHyperscriptArgs),
150
+ parsePropName: () => (/* reexport */ parsePropName),
151
+ pickBehaviorSubject: () => (/* reexport */ pickBehaviorSubject),
152
+ pipe: () => (/* reexport */ pipe),
153
+ pipeEvent: () => (/* reexport */ pipeEvent),
154
+ pluckProperty: () => (/* reexport */ pluckProperty),
155
+ pre: () => (/* reexport */ pre),
156
+ progress: () => (/* reexport */ progress),
157
+ q: () => (/* reexport */ q),
158
+ queryStringify: () => (/* reexport */ queryStringify),
159
+ radio: () => (/* reexport */ radio_radio),
160
+ rangeArray: () => (/* reexport */ rangeArray),
161
+ rb: () => (/* reexport */ rb),
162
+ restore: () => (/* reexport */ restore),
163
+ rp: () => (/* reexport */ rp),
164
+ rt: () => (/* reexport */ rt),
165
+ rtc: () => (/* reexport */ rtc),
166
+ ruby: () => (/* reexport */ ruby),
167
+ s: () => (/* reexport */ s),
168
+ samp: () => (/* reexport */ samp),
169
+ section: () => (/* reexport */ section),
170
+ select: () => (/* reexport */ select_select),
171
+ setProp: () => (/* reexport */ setProp),
172
+ setProps: () => (/* reexport */ setProps),
173
+ small: () => (/* reexport */ small),
174
+ span: () => (/* reexport */ span),
175
+ splitObjectByObservable: () => (/* reexport */ splitObjectByObservable),
176
+ strong: () => (/* reexport */ strong),
177
+ sub: () => (/* reexport */ sub),
178
+ subscribeEvent: () => (/* reexport */ subscribeEvent),
179
+ subscribeProp: () => (/* reexport */ subscribeProp),
180
+ summary: () => (/* reexport */ summary),
181
+ sup: () => (/* reexport */ sup),
182
+ tabControl: () => (/* reexport */ tabControl),
183
+ tabNavItem: () => (/* reexport */ tabNavItem),
184
+ tabPanel: () => (/* reexport */ tabPanel),
185
+ tabRoot: () => (/* reexport */ tabRoot),
186
+ table: () => (/* reexport */ table),
187
+ tbody: () => (/* reexport */ tbody),
188
+ td: () => (/* reexport */ td),
189
+ textNode: () => (/* reexport */ textNode),
190
+ textarea: () => (/* reexport */ textarea_textarea),
191
+ textbox: () => (/* reexport */ textbox),
192
+ tfoot: () => (/* reexport */ tfoot),
193
+ th: () => (/* reexport */ th),
194
+ thead: () => (/* reexport */ thead),
195
+ time: () => (/* reexport */ time),
196
+ tojs: () => (/* reexport */ tojs),
197
+ tr: () => (/* reexport */ tr),
198
+ track: () => (/* reexport */ track),
199
+ tt: () => (/* reexport */ tt),
200
+ types: () => (/* reexport */ types),
201
+ u: () => (/* reexport */ u),
202
+ ul: () => (/* reexport */ ul),
203
+ unfold: () => (/* reexport */ unfold),
204
+ unquotedJsonStringify: () => (/* reexport */ unquotedJsonStringify),
205
+ unwrapArgs: () => (/* reexport */ unwrapArgs),
206
+ video: () => (/* reexport */ video),
207
+ wbr: () => (/* reexport */ wbr),
208
+ zipArray: () => (/* reexport */ zipArray)
209
+ });
210
+
211
+ ;// ./src/array/advance.js
212
+ /**
213
+ * @template T
214
+ * @param {Array<T>} array - 要处理的原数组
215
+ * @param {number} n - 要取出的元素个数
216
+ * @returns {[Array<T>, Array<T>]} - [已取出的元素数组, 剩余元素数组]
217
+ */
218
+ function advance(array, n) {
219
+ let taken = [];
220
+ for (let i = 0; i < n; i++) {
221
+ taken[n - 1 - i] = array[i];
222
+ }
223
+ return [taken, array.slice(n)];
224
+ }
225
+ ;// ./src/array/arrayInsert.js
226
+ /**
227
+ * insert a element at position in place.
228
+ * @param {any} array
229
+ * @param {any} item
230
+ * @param {any} index
231
+ */
232
+ function arrayInsert(array, item, index = array.length) {
233
+ const len = array.length;
234
+ for (let i = len; i > index; i--) {
235
+ array[i] = array[i - 1];
236
+ }
237
+ array[index] = item;
238
+ }
239
+ ;// ./src/array/arrayRemove.js
240
+ /**
241
+ * remove a element in place
242
+ *
243
+ * @template T
244
+ * @param {T[]} array
245
+ * @param {number} index
246
+ */
247
+ function arrayRemove(array, index = array.length - 1) {
248
+ const len = array.length;
249
+ for (let i = index; i < len - 1; i++) {
250
+ array[i] = array[i + 1];
251
+ }
252
+ Reflect.deleteProperty(array, len - 1);
253
+ array.length = len - 1;
254
+ }
255
+ ;// ./src/array/findLastIndex.js
256
+ /**
257
+ * 查找数组中最后一个满足条件的元素索引。
258
+ *
259
+ * @public
260
+ * @template T
261
+ * @param {T[]} array - 要查找的数组
262
+ * @param {(value: T, index: number) => boolean} callbackFn - 判断函数,返回 true 表示找到
263
+ * @param {number} [lastIndex=array.length-1] - 可选,查找的起始索引(从后往前)
264
+ * @returns {number} - 最后一个满足条件的元素索引,未找到返回 -1
265
+ */
266
+ function findLastIndex(array, callbackFn, lastIndex = array.length - 1) {
267
+ lastIndex = Math.min(lastIndex, array.length - 1);
268
+ while (lastIndex >= 0) {
269
+ if (callbackFn(array[lastIndex], lastIndex)) {
270
+ return lastIndex;
271
+ }
272
+ lastIndex--;
273
+ }
274
+ return -1;
275
+ }
276
+ ;// ./src/array/isRange.js
277
+ /**
278
+ * 判断输入的字符串数组是否为从0开始的连续数字区间(如 ['0','1','2',...])。
279
+ *
280
+ * @public
281
+ * @param {string[]} keys - 要检查的字符串数组
282
+ * @returns {boolean} - 如果是从0开始的连续数字区间返回 true,否则返回 false
283
+ */
284
+ function isRange(keys) {
285
+ if (keys.every(key => /^\d+$/.test(key))) {
286
+ let nums = keys.map(key => parseInt(key));
287
+ return nums.every((v, i) => v === i);
288
+ }
289
+ return false;
290
+ }
291
+ ;// ./src/array/rangeArray.js
292
+ /**
293
+ * 创建一个从 0 到 length-1 的数字数组。
294
+ *
295
+ * @public
296
+ * @param {number} length - 要创建的数组长度
297
+ * @returns {number[]} - 从 0 到 length-1 的数字数组
298
+ */
299
+ function rangeArray(length) {
300
+ return Array.from({
301
+ length
302
+ }).map((v, i) => i);
303
+ }
304
+ ;// ./src/array/unwrapArgs.js
305
+ /**
306
+ * 简易unwrap参数数组。如果子节点是单个数组,则解构为子节点,否则返回原数组。
307
+ *
308
+ * @template T
309
+ * @param {(T|T[])[]} args - 子节点数组。
310
+ * @returns {T[]} - 解构后的子节点数组。
311
+ */
312
+ function unwrapArgs(args) {
313
+ return /** @type{T[]} */args.length === 1 && Array.isArray(args[0]) ? args[0] : args;
314
+ }
315
+ ;// ./src/array/zipArray.js
316
+ /**
317
+ * 合并两个数组为一个元组数组。
318
+ *
319
+ * 如果数组长度不同,将以较长的数组为基准,短数组对应位置为 undefined。
320
+ *
321
+ * @public
322
+ * @template T, U
323
+ * @param {T[]} a - 第一个数组
324
+ * @param {U[]} b - 第二个数组
325
+ * @returns {Array<[T, U]>} - 合并后的元组数组
326
+ * @throws {Error} 如果 a 或 b 不是数组
327
+ */
328
+ function zipArray(a, b) {
329
+ if (!Array.isArray(a) || !Array.isArray(b)) {
330
+ throw new Error("arrayZip(a,b):both a and b should be array");
331
+ }
332
+ if (a.length >= b.length) {
333
+ return a.map((v, i) => [v, b[i]]);
334
+ } else {
335
+ return b.map((v, i) => [a[i], v]);
336
+ }
337
+ }
338
+ ;// ./src/array/0.js
339
+
340
+
341
+
342
+
343
+
344
+
345
+
346
+
347
+ ;// ./src/comparers/distinctArray.js
348
+ /**
349
+ * 数组去重,并保持元素的相对顺序。
350
+ * @template T
351
+ * @param {T[]} array
352
+ * @param {(a:T,b:T)=>boolean} equals
353
+ * @returns {T[]}
354
+ */
355
+ function distinctArray(array, equals) {
356
+ /**
357
+ * 递归处理去重
358
+ * @param {T[]} resultArray - 已去重的结果数组
359
+ * @param {T[]} rest - 剩余待处理的数组
360
+ * @returns {T[]} - 去重后的数组
361
+ */
362
+ function loop(resultArray, rest) {
363
+ if (rest.length === 0) {
364
+ return resultArray;
365
+ } else {
366
+ let [head, ...tail] = rest;
367
+ if (resultArray.findIndex(e => equals(head, e)) < 0) {
368
+ return loop([...resultArray, head], tail);
369
+ } else {
370
+ return loop(resultArray, tail);
371
+ }
372
+ }
373
+ }
374
+ return loop([], array);
375
+ }
376
+ ;// ./src/comparers/groupSortedEntries.js
377
+ /**
378
+ * Groups an array of sorted key-value entries into an array of groups,
379
+ * where each group contains entries with the same key.
380
+ *
381
+ * @template K, V
382
+ * @param {[K, V][]} sortedEntries - An array of key-value pairs,
383
+ * where the keys are already sorted in ascending order.
384
+ * @param {(a:K,b:K)=>number} compare - A comparison function that takes two keys
385
+ * and returns a number: 0 if the keys are equal, a negative number if the first key
386
+ * is less than the second, and a positive number otherwise.
387
+ * @returns {[K, V[]][]} An array of groups, where each group is a tuple
388
+ * containing a key and an array of values associated with that key.
389
+ */
390
+ function groupSortedEntries(sortedEntries, compare) {
391
+ if (sortedEntries.length === 0) {
392
+ return [];
393
+ }
394
+ const [head, ...tail] = sortedEntries;
395
+ /** @type {[K, V[]]} */
396
+ const firstGroup = [head[0], [head[1]]];
397
+ return tail.reduce((groups, [k, v]) => {
398
+ let [k0, group] = groups[groups.length - 1];
399
+ if (compare(k0, k) === 0) {
400
+ group.push(v);
401
+ } else {
402
+ groups.push([k, [v]]);
403
+ }
404
+ return groups;
405
+ }, [firstGroup]);
406
+ }
407
+ ;// ./src/comparers/groupArrayBy.js
408
+
409
+
410
+ /**
411
+ * 按指定的 key 函数对数组元素分组。
412
+ *
413
+ * 先将数组元素映射为 [key, value] 对,按 key 排序后,再分组。
414
+ *
415
+ * @public
416
+ * @template T, K
417
+ * @param {T[]} array - 要分组的数组
418
+ * @param {(item: T) => K} getKey - 生成分组 key 的函数
419
+ * @param {(a: K, b: K) => number} compare - key 的比较函数
420
+ * @returns {[K, T[]][]} 分组后的结果,每组为 [key, 元素数组]
421
+ */
422
+ function groupArrayBy(array, getKey, compare) {
423
+ if (array.length === 0) {
424
+ return [];
425
+ }
426
+ let sortedEntries = array.map(
427
+ /**
428
+ * @returns {[K, T]}
429
+ */
430
+ e => [getKey(e), e]).sort(([ka], [kb]) => compare(ka, kb));
431
+ return groupSortedEntries(sortedEntries, compare);
432
+ }
433
+ ;// ./src/comparers/differenceSet.js
434
+ /**
435
+ * return set1 - set2
436
+ * @template T
437
+ * @param {T[]} set1
438
+ * @param {T[]} set2
439
+ * @param {(a: T, b: T) => number} compare
440
+ * @returns {T[]}
441
+ */
442
+ function differenceSet(set1, set2, compare) {
443
+ /**
444
+ * @param {T[]} acc
445
+ * @param {T[]} a
446
+ * @param {T[]} b
447
+ * @returns {T[]}
448
+ */
449
+ function loop(acc, a, b) {
450
+ if (a.length === 0) {
451
+ return acc;
452
+ } else if (b.length === 0) {
453
+ return [...acc, ...a];
454
+ } else {
455
+ let n = compare(a[0], b[0]);
456
+ if (n === 0) {
457
+ return loop(acc, a.slice(1), b.slice(1));
458
+ } else if (n < 0) {
459
+ return loop([...acc, a[0]], a.slice(1), b);
460
+ } else {
461
+ // if (n > 0)
462
+ return loop(acc, a, b.slice(1));
463
+ }
464
+ }
465
+ }
466
+ return loop([], set1, set2);
467
+ }
468
+ ;// ./src/comparers/findIndexInSet.js
469
+ /**
470
+ * 同Array.findIndex,返回元素在集合中的索引位置
471
+ *
472
+ * @template T
473
+ * @param {T[]} set Array.sort(compare)后的Array
474
+ * @param {T} e 是要查找的元素
475
+ * @param {(a:T,b:T)=>number} compare 元素的比较函数
476
+ */
477
+ function findIndexInSet(set, e, compare) {
478
+ /** @param {number} i */
479
+ function loop(i) {
480
+ if (i === set.length) {
481
+ return -1;
482
+ } else {
483
+ const n = compare(set[i], e);
484
+ if (n === 0) {
485
+ return i;
486
+ } else if (n < 0) {
487
+ return loop(i + 1);
488
+ } else {
489
+ return -1;
490
+ }
491
+ }
492
+ }
493
+ return loop(0);
494
+ }
495
+ ;// ./src/comparers/intersectSet.js
496
+ /**
497
+ * 计算两个有序数组的交集。
498
+ * @template T
499
+ * @param {T[]} set1 - 第一个已排序的数组
500
+ * @param {T[]} set2 - 第二个已排序的数组
501
+ * @param {(a: T, b: T) => number} compare - 比较函数
502
+ * @returns {T[]} 两数组的交集
503
+ */
504
+ function intersectSet(set1, set2, compare) {
505
+ /**
506
+ * 递归计算交集
507
+ * @param {T[]} acc - 当前交集结果
508
+ * @param {T[]} a - 剩余的 set1
509
+ * @param {T[]} b - 剩余的 set2
510
+ * @returns {T[]} 交集
511
+ */
512
+ function loop(acc, a, b) {
513
+ if (a.length === 0 || b.length === 0) {
514
+ return acc;
515
+ } else {
516
+ //每次去掉最大的元素
517
+ switch (Math.sign(compare(a[0], b[0]))) {
518
+ case -1:
519
+ return loop(acc, a.slice(1), b);
520
+ case 0:
521
+ return loop([...acc, a[0]], a.slice(1), b.slice(1));
522
+ case 1:
523
+ default:
524
+ return loop(acc, a, b.slice(1));
525
+ }
526
+ }
527
+ }
528
+ return loop([], set1, set2);
529
+ }
530
+ ;// ./src/comparers/isEqualset.js
531
+ /**
532
+ * 判断两个集合是否相等(成员完全相同,顺序无关)。
533
+ * @template T
534
+ * @param {T[]} set1 - 第一个集合
535
+ * @param {T[]} set2 - 第二个集合
536
+ * @param {(a: T, b: T) => number} compare - 比较函数
537
+ * @returns {boolean} 如果集合相等返回 true,否则返回 false
538
+ */
539
+ function isEqualset(set1, set2, compare) {
540
+ /**
541
+ * @param {T[]} a
542
+ * @param {T[]} b
543
+ * @returns {boolean}
544
+ */
545
+ function loop(a, b) {
546
+ if (a.length === 0 && b.length === 0) {
547
+ return true;
548
+ }
549
+ if (a.length > 0 && b.length > 0) {
550
+ let [a0, ...aa] = a;
551
+ let [b0, ...bb] = b;
552
+ if (compare(a0, b0) === 0) {
553
+ return loop(aa, bb);
554
+ } else {
555
+ return false;
556
+ }
557
+ }
558
+ return false;
559
+ }
560
+ return loop(set1, set2);
561
+ }
562
+ ;// ./src/comparers/isSubset.js
563
+ /**
564
+ * 判断 set1 是否为 set2 的子集(假定已排序)。
565
+ * @template T
566
+ * @param {T[]} set1 - 可能为子集的数组
567
+ * @param {T[]} set2 - 可能为超集的数组
568
+ * @param {(a: T, b: T) => number} compare - 比较函数
569
+ * @returns {boolean} 如果 set1 是 set2 的子集返回 true,否则返回 false
570
+ */
571
+ function isSubset(set1, set2, compare) {
572
+ /**
573
+ * @param {T[]} a
574
+ * @param {T[]} b
575
+ * @returns {boolean}
576
+ */
577
+ function loop(a, b) {
578
+ if (a.length === 0) {
579
+ return true;
580
+ } else if (b.length === 0) {
581
+ return false;
582
+ } else {
583
+ switch (Math.sign(compare(a[0], b[0]))) {
584
+ case -1:
585
+ return false;
586
+ case 0:
587
+ return loop(a.slice(1), b.slice(1));
588
+ case 1:
589
+ default:
590
+ return loop(a, b.slice(1));
591
+ }
592
+ }
593
+ }
594
+ return loop(set1, set2);
595
+ }
596
+ ;// ./src/comparers/isSuperset.js
597
+
598
+
599
+ /**
600
+ * 判断 a 是否为 b 的超集(假定已排序)。
601
+ * @template T
602
+ * @param {T[]} a - 可能为超集的数组
603
+ * @param {T[]} b - 可能为子集的数组
604
+ * @param {(x: T, y: T) => number} compare - 比较函数
605
+ * @returns {boolean} 如果 a 是 b 的超集返回 true,否则返回 false
606
+ */
607
+ function isSuperset(a, b, compare) {
608
+ return isSubset(b, a, compare);
609
+ }
610
+ ;// ./src/comparers/unionSet.js
611
+ /**
612
+ * 计算两个有序数组的并集(去重)。
613
+ * @template T
614
+ * @param {T[]} set1 - 第一个已排序的数组
615
+ * @param {T[]} set2 - 第二个已排序的数组
616
+ * @param {(a: T, b: T) => number} compare - 比较函数
617
+ * @returns {T[]} 并集后的新数组
618
+ */
619
+ function unionSet(set1, set2, compare) {
620
+ /**
621
+ * @param {T[]} acc - 当前结果
622
+ * @param {T[]} a - 剩余的 set1
623
+ * @param {T[]} b - 剩余的 set2
624
+ * @returns {T[]} 并集
625
+ */
626
+ function loop(acc, a, b) {
627
+ if (a.length === 0) {
628
+ return [...acc, ...b];
629
+ } else if (b.length === 0) {
630
+ return [...acc, ...a];
631
+ } else {
632
+ switch (Math.sign(compare(a[0], b[0]))) {
633
+ case -1:
634
+ return loop([...acc, a[0]], a.slice(1), b);
635
+ case 0:
636
+ return loop([...acc, a[0]], a.slice(1), b.slice(1));
637
+ case 1:
638
+ default:
639
+ return loop([...acc, b[0]], a, b.slice(1));
640
+ }
641
+ }
642
+ }
643
+ return loop([], set1, set2);
644
+ }
645
+ ;// ./src/comparers/sortedArrayToSet.js
646
+ /**
647
+ * 数组去重,排序好后的数组去重。
648
+ * @template T
649
+ * @param {T[]} sortedArray - 已排序的数组
650
+ * @param {(a: T, b: T) => number} compare - 比较函数
651
+ * @returns {T[]} 去重后的新数组
652
+ */
653
+ function sortedArrayToSet(sortedArray, compare) {
654
+ /**
655
+ * @param {T[]} acc - 当前结果
656
+ * @param {T[]} sarray - 剩余待处理的数组
657
+ * @returns {T[]} 去重后的新数组
658
+ */
659
+ function loop(acc, sarray) {
660
+ if (sarray.length === 0) {
661
+ return acc;
662
+ } else {
663
+ switch (Math.sign(compare(acc[acc.length - 1], sarray[0]))) {
664
+ case -1:
665
+ return loop([...acc, sarray[0]], sarray.slice(1));
666
+ case 0:
667
+ return loop(acc, sarray.slice(1));
668
+ case 1:
669
+ default:
670
+ throw new Error('sort ascent');
671
+ }
672
+ }
673
+ }
674
+ if (sortedArray.length === 0) {
675
+ return [];
676
+ } else {
677
+ return loop([sortedArray[0]], sortedArray.slice(1));
678
+ }
679
+ }
680
+ ;// ./src/comparers/Comparer.js
681
+
682
+
683
+
684
+
685
+
686
+
687
+
688
+
689
+
690
+
691
+
692
+
693
+ /**
694
+ * 用于比较和操作数组及集合的工具类。
695
+ *
696
+ * @public
697
+ * @template T
698
+ */
699
+ class Comparer {
700
+ /**
701
+ * @param {(a: T, b: T) => number} compare - 比较函数
702
+ */
703
+ constructor(compare) {
704
+ this.compare = compare;
705
+ }
706
+
707
+ /**
708
+ * 使用实例的比较函数对数组进行排序。
709
+ * @param {T[]} array - 要排序的数组
710
+ * @returns {T[]} 排序后的数组
711
+ */
712
+ sort(array) {
713
+ return array.sort(this.compare);
714
+ }
715
+
716
+ /**
717
+ * 移除数组中的重复值。
718
+ * @param {T[]} array - 要处理的数组
719
+ * @returns {T[]} 去重后的新数组
720
+ */
721
+ distinct(array) {
722
+ return distinctArray(array, (a, b) => this.compare(a, b) === 0);
723
+ }
724
+
725
+ /**
726
+ * 将已排序的数组转为集合(去重)。
727
+ * @param {T[]} array - 已排序的数组
728
+ * @returns {T[]} 唯一元素数组
729
+ */
730
+ sortedArrayToSet(array) {
731
+ return sortedArrayToSet(array, this.compare);
732
+ }
733
+
734
+ /**
735
+ * 根据 getKey 生成的 key 对数组元素分组。
736
+ * @template U
737
+ * @param {U[]} array - 要分组的数组
738
+ * @param {(item:U) => T} getKey - 生成分组 key 的函数
739
+ * @returns {[T, U[]][]} 分组后的对象或数组
740
+ */
741
+ groupBy(array, getKey) {
742
+ return groupArrayBy(array, getKey, this.compare);
743
+ }
744
+
745
+ /**
746
+ * 对已排序的数组按 key 分组。
747
+ * @template V
748
+ * @param {[T,V][]} array - 已排序的数组
749
+ * @returns {[T, V[]][]} 分组结果
750
+ */
751
+ groupSortedEntries(array) {
752
+ return groupSortedEntries(array, this.compare);
753
+ }
754
+
755
+ /**
756
+ * 计算两个数组的差集。数组元素是升序排列
757
+ * @param {T[]} array1 - 第一个数组
758
+ * @param {T[]} array2 - 第二个数组
759
+ * @returns {T[]} array1 中有而 array2 中没有的元素
760
+ */
761
+ differenceSet(array1, array2) {
762
+ return differenceSet(array1, array2, this.compare);
763
+ }
764
+
765
+ /**
766
+ * 计算两个数组的交集。
767
+ * @param {T[]} array1 - 第一个数组
768
+ * @param {T[]} array2 - 第二个数组
769
+ * @returns {T[]} 同时存在于 array1 和 array2 的元素
770
+ */
771
+ intersectSet(array1, array2) {
772
+ return intersectSet(array1, array2, this.compare);
773
+ }
774
+
775
+ /**
776
+ * 计算两个数组的并集(去重)。
777
+ * @param {T[]} array1 - 第一个数组
778
+ * @param {T[]} array2 - 第二个数组
779
+ * @returns {T[]} 两个数组的唯一元素合集
780
+ */
781
+ unionSet(array1, array2) {
782
+ return unionSet(array1, array2, this.compare);
783
+ }
784
+
785
+ /**
786
+ * 在集合(数组)中查找元素的索引。
787
+ * @param {T[]} set - 要查找的数组
788
+ * @param {T} element - 要查找的元素
789
+ * @returns {number} 元素在集合中的索引,未找到返回 -1
790
+ */
791
+ findIndexInSet(set, element) {
792
+ return findIndexInSet(set, element, this.compare);
793
+ }
794
+
795
+ /**
796
+ * 判断两个数组作为集合是否相等。
797
+ * @param {T[]} array1 - 第一个数组
798
+ * @param {T[]} array2 - 第二个数组
799
+ * @returns {boolean} 如果集合相等返回 true,否则返回 false
800
+ */
801
+ isEqualset(array1, array2) {
802
+ return isEqualset(array1, array2, this.compare);
803
+ }
804
+
805
+ /**
806
+ * 判断第一个数组是否为第二个数组的子集。
807
+ * @param {T[]} array1 - 第一个数组
808
+ * @param {T[]} array2 - 第二个数组
809
+ * @returns {boolean} 如果 array1 是 array2 的子集返回 true,否则返回 false
810
+ */
811
+ isSubset(array1, array2) {
812
+ return isSubset(array1, array2, this.compare);
813
+ }
814
+
815
+ /**
816
+ * 判断第一个数组是否为第二个数组的超集。
817
+ * @param {T[]} array1 - 第一个数组
818
+ * @param {T[]} array2 - 第二个数组
819
+ * @returns {boolean} 如果 array1 是 array2 的超集返回 true,否则返回 false
820
+ */
821
+ isSuperset(array1, array2) {
822
+ return isSuperset(array1, array2, this.compare);
823
+ }
824
+ }
825
+ ;// ./src/comparison/defaultCompare.js
826
+ /**
827
+ * 默认比较函数,适用于可比较的基本类型。
828
+ *
829
+ * @public
830
+ * @template T
831
+ * @param {T} a - 第一个值
832
+ * @param {T} b - 第二个值
833
+ * @returns {number} 如果 a > b 返回 1,a < b 返回 -1,相等返回 0
834
+ */
835
+ function defaultCompare(a, b) {
836
+ return a > b ? 1 : a < b ? -1 : 0;
837
+ }
838
+ ;// ./src/comparison/compareKey.js
839
+
840
+
841
+ /**
842
+ *
843
+ * Compares two values and returns a number indicating their relative order.
844
+ * @param {number|string} a - The first value to compare.
845
+ * @param {number|string} b - The second value to compare.
846
+ * @returns {number} -1 if a < b, 1 if a > b, or 0 if they are equal.
847
+ *
848
+ */
849
+ function compareKey(a, b) {
850
+ let type1 = typeof a;
851
+ let type2 = typeof b;
852
+ if (type1 === type2) {
853
+ return defaultCompare(a, b);
854
+ }
855
+
856
+ //string > number
857
+ if (type1 === 'string') {
858
+ return 1;
859
+ }
860
+ return -1;
861
+ }
862
+ ;// ./src/comparison/compareKeyPath.js
863
+
864
+
865
+ /**
866
+ * 比较两个 key path(键路径数组)。
867
+ *
868
+ * @public
869
+ * @param {(number|string)[]} a - 第一个 key path
870
+ * @param {(number|string)[]} b - 第二个 key path
871
+ * @returns {number} 若 a < b 返回负数,相等返回 0,大于返回正数
872
+ */
873
+ function compareKeyPath(a, b) {
874
+ //两个空数组相等
875
+ if (a.length === 0 && b.length === 0) {
876
+ return 0;
877
+ }
878
+
879
+ //空数组小于非空数组。
880
+ if (a.length === 0) {
881
+ return -1;
882
+ }
883
+
884
+ //非空数组大于空数组。
885
+ if (b.length === 0) {
886
+ return 1;
887
+ }
888
+
889
+ //两个数组每次从0位出一个元素,进行比较。
890
+ let [a0, ...aa] = a;
891
+ let [b0, ...bb] = b;
892
+
893
+ //两个元素相等,递归比较剩余数组。
894
+ return compareKey(a0, b0) || compareKeyPath(aa, bb);
895
+ }
896
+ ;// ./src/comparison/compareEntries.js
897
+
898
+
899
+ /**
900
+ * 比较两个 entries(key-value 对)。依据他们的 key path。
901
+ *
902
+ * @public
903
+ * @param {[(number|string)[], any]} entry1 - 第一个 entry,key 为 key path(键路径数组)
904
+ * @param {[(number|string)[], any]} entry2 - 第二个 entry,key 为 key path(键路径数组)
905
+ * @returns {number} 若 entry1 < entry2 返回负数,相等返回 0,大于返回正数
906
+ */
907
+ function compareEntries([keypath1], [keypath2]) {
908
+ return compareKeyPath(keypath1, keypath2);
909
+ }
910
+ ;// ./src/comparers/comparers.js
911
+ // import { } from "../comparison/defaultCompare.js"
912
+ // import { } from "../comparison/compareKey.js"
913
+ // import { } from "../comparison/compareKeyPath.js"
914
+ // import { } from "../comparison/compareEntries.js"
915
+
916
+
917
+
918
+ const defaultComparer = new Comparer(defaultCompare);
919
+ const keyComparer = new Comparer(compareKey);
920
+ const keyPathComparer = new Comparer(compareKeyPath);
921
+ const entryComparer = new Comparer(compareEntries);
922
+ ;// ./src/comparers/0.js
923
+
924
+
925
+ // export * from "./differenceSet.js"
926
+ // export * from "./distinctArray.js"
927
+ // export * from "./findIndexInSet.js"
928
+ // export * from "./groupArrayBy.js"
929
+ // export * from "./groupSortedEntries.js"
930
+ // export * from "./intersectSet.js"
931
+ // export * from "./isEqualset.js"
932
+ // export * from "./isSubset.js"
933
+ // export * from "./isSuperset.js"
934
+ // export * from "./sortedArrayToSet.js"
935
+ // export * from "./unionSet.js"
936
+ ;// ./src/comparison/compareDate.js
937
+ /**
938
+ * 比较两个日期对象的大小。
939
+ *
940
+ * @public
941
+ * @param {Date} a - 第一个日期
942
+ * @param {Date} b - 第二个日期
943
+ * @returns {number} 如果 a > b 返回正数,a < b 返回负数,相等返回 0
944
+ */
945
+ function compareDate(a, b) {
946
+ return a.valueOf() - b.valueOf();
947
+ }
948
+ ;// ./src/comparison/compareNumber.js
949
+
950
+
951
+ /**
952
+ * 可以比较NaN,Infinity,number,bigint
953
+ * @param {number|bigint} a
954
+ * @param {number|bigint} b
955
+ */
956
+ function compareNumber(a, b) {
957
+ if (Number.isNaN(a) && Number.isNaN(b)) {
958
+ return 0;
959
+ }
960
+
961
+ //NaN最大
962
+ if (Number.isNaN(a)) {
963
+ return 1;
964
+ }
965
+ if (Number.isNaN(b)) {
966
+ return -1;
967
+ }
968
+ return defaultCompare(a, b);
969
+ }
970
+ ;// ./src/comparison/types.js
971
+ /// 这个字符串数组列举了JavaScript 中所有基本数据类型(primitive types)的名称。typeof 返回值域
972
+ const types = ["undefined",
973
+ // 未定义类型,表示未赋值的变量
974
+ "object",
975
+ // 对象类型(包括 null 和所有对象/数组/日期等)
976
+ "boolean",
977
+ // 布尔类型(true/false)
978
+ "number",
979
+ // 数字类型(包括整数和浮点数)
980
+ "bigint",
981
+ // 大整数类型(ES2020 新增,表示任意精度的整数)
982
+ "string",
983
+ // 字符串类型
984
+ "symbol",
985
+ // Symbol 类型(ES2015 新增,表示唯一标识符)
986
+ "function" // 函数类型(虽然 typeof 返回 'function',但函数本质是 object 的子类型)
987
+ ];
988
+ ;// ./src/comparison/0.js
989
+
990
+
991
+
992
+
993
+
994
+
995
+
996
+ ;// external "rxjs"
997
+ const external_rxjs_namespaceObject = require("rxjs");
998
+ ;// ./src/object/pluckProperty.js
999
+ /**
1000
+ * 获取对象的嵌套属性
1001
+ * @param {Record<string | number, any>} obj - 源对象/数组
1002
+ * @param {(string|number)[]} keyPath - 属性访问路径数组
1003
+ * @returns {any} 路径对应的属性值
1004
+ * @throws {TypeError} 当路径不存在时抛出错误
1005
+ */
1006
+ function pluckProperty(obj, keyPath) {
1007
+ // 类型检查
1008
+ if (typeof obj !== 'object' || obj === null) {
1009
+ throw new TypeError('First argument must be an object');
1010
+ }
1011
+ if (!Array.isArray(keyPath)) {
1012
+ throw new TypeError('keyPath must be an array');
1013
+ }
1014
+ return keyPath.reduce((prev, curr) => {
1015
+ if (prev == null || !(curr in prev)) {
1016
+ throw new TypeError(`Property '${curr}' not found in path`);
1017
+ }
1018
+ return prev[curr];
1019
+ }, obj);
1020
+ }
1021
+ ;// ./src/structures/groupByFirstLevelKey.js
1022
+
1023
+
1024
+ /**
1025
+ * Groups an array of flattened entries by their first level key.
1026
+ * This function is memory-optimized and adapted from `groupArrayBy`.
1027
+ *
1028
+ * @param {[ (string | number)[], any ][]} flatEntries - Array of flattened entries to be grouped.
1029
+ * Each entry is of the form [[key, ...keyPath], value] where:
1030
+ * - The first element is an array representing the key path (first element is primary key)
1031
+ * - The second element is the associated value
1032
+ * @returns {[ string | number, [ (string | number)[], any ][] ][]} An array of grouped entries where:
1033
+ * - Each entry is a tuple [key, group]
1034
+ * - key is the first-level grouping key (string|number)
1035
+ * - group is an array of entries sharing that key, each of form [keyPath, value]
1036
+ *
1037
+ */
1038
+ function groupByFirstLevelKey(flatEntries) {
1039
+ if (flatEntries.length === 0) {
1040
+ return [];
1041
+ }
1042
+ let sortedKvPairs = flatEntries.map(
1043
+ /**
1044
+ * @returns {[ string | number, [ (string | number)[], any ] ]}
1045
+ */
1046
+ ([[key, ...keyPath], value]) => [key, [keyPath, value]]);
1047
+ return keyComparer.groupSortedEntries(sortedKvPairs);
1048
+ }
1049
+ ;// ./src/structures/tojs.js
1050
+
1051
+
1052
+
1053
+ /**
1054
+ * 将扁平化的键值对数组转换为嵌套的 JavaScript 对象或数组。
1055
+ *
1056
+ * @param {[ (string | number)[], any ][]} flatEntries - 扁平化的键值对数组。
1057
+ * 每个键值对的格式为 `[keyPath, value]`,其中 `keyPath` 是一个表示嵌套路径的数组。假设输入的键值对数组已经按照键路径(keyPath)排好顺序。
1058
+ * @returns {Record<string|number, any>} - 返回嵌套的 JavaScript 对象或数组。
1059
+ *
1060
+ */
1061
+ function tojs(flatEntries) {
1062
+ if (!Array.isArray(flatEntries)) {
1063
+ throw new TypeError('Expected an array of flat entries');
1064
+ }
1065
+ if (flatEntries.length === 0) {
1066
+ return {};
1067
+ }
1068
+ if (flatEntries.length === 1 && flatEntries[0][0].length === 0) {
1069
+ return flatEntries[0][1];
1070
+ }
1071
+
1072
+ // 按第一层键分组,并递归处理嵌套结构
1073
+ let entries = groupByFirstLevelKey(flatEntries).map(([k, group]) => {
1074
+ // 如果组中只有一个键值对,且键路径为空,直接取值
1075
+ let v = group.length === 1 && group[0][0].length === 0 ? group[0][1] : tojs(group); // 否则递归处理
1076
+ return [k, v];
1077
+ });
1078
+
1079
+ // 获取第一层的键
1080
+ let keys = entries.map(([k]) => k);
1081
+
1082
+ // 将键值对数组转换为对象
1083
+ let obj = Object.fromEntries(entries);
1084
+
1085
+ // 如果第一层键是连续的数字序列,则转换为数组
1086
+ if (isRange(keys)) {
1087
+ return Array.from({
1088
+ ...obj,
1089
+ length: keys.length
1090
+ });
1091
+ } else {
1092
+ return obj;
1093
+ }
1094
+ }
1095
+ ;// ./src/structures/flat.js
1096
+ /**
1097
+ * 扁平化对象或数组,输入参数与JSON.stringify相同。
1098
+ * @param {any} data
1099
+ * @param {(value: any,key: string|number, keyPath: (string|number)[]) => boolean} [isLeaf] 当函数返回真时,属性作为叶节点。
1100
+ * @returns {[(string|number)[],any][]}
1101
+ */
1102
+ const flat = (data, isLeaf = () => false) => {
1103
+ /**
1104
+ *
1105
+ * @param {[(string | number)[], any][]} acc
1106
+ * @param {(string | number)[]} keyPath
1107
+ * @param {string | number} key
1108
+ * @param {*} value
1109
+ * @returns {[(string | number)[], any][]}
1110
+ */
1111
+ function loop(acc, keyPath, key, value) {
1112
+ keyPath = [...keyPath, key];
1113
+ if (isLeaf(value, key, keyPath)) {
1114
+ // 首先拦截叶节点
1115
+ return [...acc, [keyPath, value]];
1116
+ } else if (value && typeof value === 'object') {
1117
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects
1118
+ // 内置对象为叶节点
1119
+ if (value instanceof Function || value instanceof Boolean || value instanceof Symbol || value instanceof Error || value instanceof Number || value instanceof BigInt || value instanceof Date || value instanceof String || value instanceof RegExp || value instanceof Map || value instanceof Set || value instanceof WeakMap || value instanceof WeakSet) {
1120
+ return [...acc, [keyPath, value]];
1121
+ }
1122
+ // 空數組為叶節點
1123
+ if (Array.isArray(value) && value.length === 0) {
1124
+ return [...acc, [keyPath, value]];
1125
+ }
1126
+
1127
+ // 空对象为叶节点
1128
+ if (Object.keys(value).length === 0) {
1129
+ return [...acc, [keyPath, value]];
1130
+ }
1131
+
1132
+ // date,regex
1133
+ let entries = Array.isArray(value) ? value.map((v, i) => [i, v]) : Object.entries(value);
1134
+ if (entries.length > 0) {
1135
+ // 附加当前对象包含的所有词条到词条累加器后面
1136
+ return entries.map(([k, v]) => loop([], keyPath, k, v)).reduce((a, b) => [...a, ...b], acc);
1137
+ } else {
1138
+ return [...acc, [keyPath, value]];
1139
+ }
1140
+ } else {
1141
+ return [...acc, [keyPath, value]];
1142
+ }
1143
+ }
1144
+ return loop([], [], '', data).map(
1145
+ // 删除辅助的第一层路径: ['', ...paths] -> paths
1146
+ ([[_, ...keyPath], value]) => [keyPath, value]);
1147
+ };
1148
+ ;// ./src/deep/intersectEntries.js
1149
+
1150
+
1151
+ /**
1152
+ * 返回一个新entries,每个entry的key都在keys中。
1153
+ * @template T
1154
+ * @param {[(string|number)[],T][]} entries
1155
+ * @param {(string|number)[][]} keys
1156
+ */
1157
+ function intersectEntries(entries, keys) {
1158
+ /**
1159
+ *
1160
+ * @param {[(string|number)[],T][]} acc
1161
+ * @param {[(string|number)[],T][]} entries
1162
+ * @param {(string|number)[][]} keys
1163
+ * @returns {[(string|number)[],T][]}
1164
+ */
1165
+ const loop = (acc, entries, keys) => {
1166
+ // 由intersect修改而来
1167
+ if (entries.length === 0 || keys.length === 0) {
1168
+ return acc;
1169
+ } else {
1170
+ switch (Math.sign(compareKeyPath(entries[0][0], keys[0]))) {
1171
+ case 0:
1172
+ let yy = [...acc, entries[0]];
1173
+ return loop(yy, entries.slice(1), keys.slice(1));
1174
+ case -1:
1175
+ return loop(acc, entries.slice(1), keys);
1176
+ case 1:
1177
+ default:
1178
+ return loop(acc, entries, keys.slice(1));
1179
+ }
1180
+ }
1181
+ };
1182
+ return loop([], entries, keys);
1183
+ }
1184
+ ;// ./src/deep/Deep.js
1185
+
1186
+
1187
+
1188
+
1189
+
1190
+
1191
+
1192
+
1193
+ /**
1194
+ * 深度(嵌套)数据结构类,用于处理按键路径排序的键值对集合。
1195
+ * 提供了多种操作方法,包括集合操作、序列操作和数据转换。
1196
+ *
1197
+ * @template T
1198
+ *
1199
+ */
1200
+ class Deep {
1201
+ /**
1202
+ * 构造函数。
1203
+ *
1204
+ * @param {[(string|number)[], T][]} entries - 按键路径排序的键值对数组。键值对已经按keypath排序。
1205
+ */
1206
+ constructor(entries) {
1207
+ this._entries = entries;
1208
+ this._keys = this._entries.map(([k]) => k);
1209
+ }
1210
+
1211
+ ///基本數據屬性
1212
+
1213
+ get entries() {
1214
+ return this._entries;
1215
+ }
1216
+ get keys() {
1217
+ return this._keys;
1218
+ }
1219
+ getValues() {
1220
+ return this.entries.map(([k, v]) => v);
1221
+ }
1222
+
1223
+ ///构造正常数据对象
1224
+ /**
1225
+ * 将深度数据结构转换为普通对象。
1226
+ *
1227
+ * @returns {Record<string|number, any>} 转换后的普通对象。
1228
+ */
1229
+ toObject() {
1230
+ return tojs(this.entries);
1231
+ }
1232
+
1233
+ ///單個讀取
1234
+
1235
+ /**
1236
+ *
1237
+ * @param {(string|number)[]} searchKeyPath
1238
+ * @returns
1239
+ */
1240
+ findIndex(searchKeyPath) {
1241
+ return keyPathComparer.findIndexInSet(this.keys, searchKeyPath);
1242
+ }
1243
+
1244
+ ///集合操作
1245
+
1246
+ /**
1247
+ *
1248
+ * @param {(string|number)[][]} keys
1249
+ * @returns
1250
+ */
1251
+ structuralEqual(keys) {
1252
+ return keyPathComparer.isEqualset(this.keys, keys);
1253
+ }
1254
+
1255
+ /**
1256
+ *
1257
+ * @param {(string|number)[][]} keys
1258
+ * @returns
1259
+ */
1260
+ structuralSubset(keys) {
1261
+ return keyPathComparer.isSubset(this.keys, keys);
1262
+ }
1263
+
1264
+ /**
1265
+ *
1266
+ * @param {(string|number)[][]} keys
1267
+ * @returns
1268
+ */
1269
+ structuralSuperset(keys) {
1270
+ return keyPathComparer.isSuperset(this.keys, keys);
1271
+ }
1272
+
1273
+ /**
1274
+ * @param {(string|number)[][]} keys
1275
+ * @this {Deep<T>}
1276
+ * @returns {Deep<T>}
1277
+ */
1278
+ intersect(keys) {
1279
+ let entries = intersectEntries(this.entries, keys);
1280
+ return new Deep(entries);
1281
+ }
1282
+
1283
+ /**
1284
+ *
1285
+ * @param {(string|number)[][]} keys
1286
+ * @this {Deep<T>}
1287
+ * @returns {Deep<T>}
1288
+ */
1289
+ difference(keys) {
1290
+ let newkeys = keyPathComparer.differenceSet(this.keys, keys);
1291
+ return this.intersect(newkeys);
1292
+ }
1293
+
1294
+ /**
1295
+ * 后来者赢(参数赢)
1296
+ * @param {[(string | number)[], T][]} entries
1297
+ * @returns
1298
+ */
1299
+ union(entries) {
1300
+ let entries2 = entryComparer.sort([...this.entries, ...entries]);
1301
+ return new Deep(entries2);
1302
+ }
1303
+
1304
+ /// 序列操作符
1305
+
1306
+ /**
1307
+ *
1308
+ * @template U
1309
+ * @param {(value: [(string | number)[], T], index: number, array: [(string | number)[], T][]) => U} callbackfn 返回的是值,而不是键值对,KeyPath保持不变
1310
+ * @param {Deep<T>} [thisArg]
1311
+ * @this {Deep<T>}
1312
+ * @returns {Deep<U>}
1313
+ *
1314
+ */
1315
+ map(callbackfn, thisArg) {
1316
+ let values = this.entries.map(callbackfn, thisArg);
1317
+ return this.replaceValue(values);
1318
+ }
1319
+
1320
+ /**
1321
+ *
1322
+ * @param {(value: [(string | number)[], T], index: number, array: [(string | number)[], T][]) => boolean} predicate
1323
+ * @param {Deep<T>} [thisArg]
1324
+ * @returns
1325
+ */
1326
+ filter(predicate, thisArg) {
1327
+ let entries = this.entries.filter(predicate, thisArg);
1328
+ return new Deep(entries);
1329
+ }
1330
+
1331
+ /**
1332
+ *
1333
+ * @param { (value: [(string | number)[], T], index: number, array: [(string | number)[], T][]) => void} callbackfn
1334
+ * @param {Deep<T>} [thisArg]
1335
+ * @returns
1336
+ */
1337
+ forEach(callbackfn, thisArg) {
1338
+ this.entries.forEach(callbackfn, thisArg);
1339
+ }
1340
+
1341
+ /// 值操作
1342
+
1343
+ /**
1344
+ * 修改部分个别数值
1345
+ * @param {Record<string|number,any>} obj
1346
+ * @this {Deep<T>}
1347
+ * @returns
1348
+ */
1349
+ freshValue(obj) {
1350
+ let entries = this.keys.map(
1351
+ /**
1352
+ * @returns {[(string | number)[],any]}
1353
+ */
1354
+ k => [k, pluckProperty(obj, k)]);
1355
+ return new Deep(entries);
1356
+ }
1357
+
1358
+ /**
1359
+ * 按列替换数值
1360
+ * @template U
1361
+ * @param {U[]} values
1362
+ * @this {Deep<T>}
1363
+ * @returns {Deep<U>}
1364
+ */
1365
+ replaceValue(values) {
1366
+ let entries = zipArray(this.keys, values);
1367
+ return new Deep(entries);
1368
+ }
1369
+
1370
+ /**
1371
+ * 按列替换数值,保留原有数值
1372
+ * @template U
1373
+ * @param {U[]} values
1374
+ * @this {Deep<T>}
1375
+ * @returns {Deep<[T,U]>}
1376
+ */
1377
+ zipValue(values) {
1378
+ return this.replaceValue(zipArray(this.getValues(), values));
1379
+ }
1380
+
1381
+ /// rxjs操作符
1382
+
1383
+ /**
1384
+ * 返回Observable of 总体的当前值
1385
+ * @template U
1386
+ * @this {Deep<Observable<U>>}
1387
+ * @returns {Observable<Deep<U>>}
1388
+ */
1389
+ combineLatest() {
1390
+ let values = this.getValues();
1391
+ return (0,external_rxjs_namespaceObject.combineLatest)(values).pipe((0,external_rxjs_namespaceObject.map)(values => this.replaceValue(values)));
1392
+ }
1393
+
1394
+ /**
1395
+ * 返回发射消息的那一个成员的路径以及新值。
1396
+ * @template U
1397
+ * @this {Deep<Observable<U>>}
1398
+ * @returns {Observable<[(string|number)[], U]>}
1399
+ */
1400
+ merge() {
1401
+ return (0,external_rxjs_namespaceObject.from)(this.entries).pipe((0,external_rxjs_namespaceObject.mergeMap)(([keyPath, value$]) => value$.pipe((0,external_rxjs_namespaceObject.map)(
1402
+ /**
1403
+ * @returns {[(string|number)[], U]}
1404
+ */
1405
+ value => [keyPath, value]))));
1406
+ }
1407
+
1408
+ /// 静态构造方法
1409
+
1410
+ /**
1411
+ *
1412
+ * @param {{[_:string|number]:any}} obj
1413
+ * @param {(value: any, key: string | number, keyPath: (string | number)[]) => boolean} [filter]
1414
+ * @returns
1415
+ */
1416
+ static fromObject(obj, filter = () => false) {
1417
+ let arr = flat(obj, filter);
1418
+ let entries = entryComparer.sort(arr);
1419
+ return new Deep(entries);
1420
+ }
1421
+
1422
+ /**
1423
+ * @template T
1424
+ * @param {{[_:string|number]:any}} obj
1425
+ * @returns {Deep<BehaviorSubject<T>>}
1426
+ */
1427
+ static fromBehaviorSubject(obj) {
1428
+ return Deep.fromObject(obj, v => (0,external_rxjs_namespaceObject.isObservable)(v) || v instanceof external_rxjs_namespaceObject.Subscription).filter(([k, v]) => v instanceof external_rxjs_namespaceObject.BehaviorSubject);
1429
+ }
1430
+
1431
+ /**
1432
+ * @template T
1433
+ * @param {{[_:string|number]:any}} obj
1434
+ * @returns
1435
+ */
1436
+ static fromObservable(obj) {
1437
+ return Deep.fromObject(obj, v => (0,external_rxjs_namespaceObject.isObservable)(v) || v instanceof external_rxjs_namespaceObject.Subscription).filter(([k, v]) => (0,external_rxjs_namespaceObject.isObservable)(v));
1438
+ }
1439
+ }
1440
+ ;// ./src/deep/0.js
1441
+
1442
+ ;// ./src/deep-rxjs/isRxType.js
1443
+
1444
+
1445
+ /**
1446
+ * 检查对象是否为 RxJS 类型。
1447
+ *
1448
+ * `isRxType` 函数用于判断给定的对象是否为 RxJS 的 `Observable` 或 `Subscription` 类型。
1449
+ *
1450
+ * @param {any} obj - 要检查的对象。
1451
+ * @returns {boolean} - 如果对象是 `Observable` 或 `Subscription`,返回 `true`;否则返回 `false`。
1452
+ *
1453
+ */
1454
+ function isRxType(obj) {
1455
+ return typeof obj === 'object' && obj && ((0,external_rxjs_namespaceObject.isObservable)(obj) || obj instanceof external_rxjs_namespaceObject.Subscription);
1456
+ }
1457
+ ;// ./src/deep-rxjs/ObservableArray.js
1458
+
1459
+
1460
+
1461
+
1462
+ /**
1463
+ * ObservableArray 是一个可观察的数组,支持 insertBefore、removeChild、replaceChild 操作,
1464
+ * 并通过 RxJS Subject 通知变化,适用于响应式 DOM 操作场景。
1465
+ *
1466
+ * @template T
1467
+ * @extends Array<T>
1468
+ */
1469
+ class ObservableArray extends Array {
1470
+ /**
1471
+ * @constructor 创建一个 ObservableArray 实例。禁止传参。
1472
+ * @param {()=>T} newItem
1473
+ * @throws {Error} 如果传入参数则抛出异常。
1474
+ */
1475
+ constructor(newItem) {
1476
+ super();
1477
+ this.newitem = newItem;
1478
+
1479
+ /**
1480
+ * 变化通知的 Subject。
1481
+ * @type {Subject<any[]>}
1482
+ */
1483
+ this.action$ = new external_rxjs_namespaceObject.Subject();
1484
+
1485
+ /**
1486
+ * 插入元素事件流,发出 [item, index]。
1487
+ * @type {import('rxjs').Observable<[T, number]>}
1488
+ */
1489
+ this.insertBefore$ = this.action$.pipe((0,external_rxjs_namespaceObject.filter)(([action]) => action === 'insertBefore'), (0,external_rxjs_namespaceObject.map)(([_, item, index]) => [item, index]));
1490
+
1491
+ /**
1492
+ * 删除元素事件流,发出 index。
1493
+ * @type {import('rxjs').Observable<number>}
1494
+ */
1495
+ this.removeChild$ = this.action$.pipe((0,external_rxjs_namespaceObject.filter)(([action]) => action === 'removeChild'), (0,external_rxjs_namespaceObject.map)(([_, index]) => index));
1496
+
1497
+ /**
1498
+ * 替换元素事件流,发出 [item, index]。
1499
+ * @type {import('rxjs').Observable<[T, number]>}
1500
+ */
1501
+ this.replaceChild$ = this.action$.pipe((0,external_rxjs_namespaceObject.filter)(([action]) => action === 'replaceChild'), (0,external_rxjs_namespaceObject.map)(([_, item, index]) => [item, index]));
1502
+ }
1503
+
1504
+ /**
1505
+ * 在指定位置插入元素,并通知变化。
1506
+ * @param {T} item 要插入的元素
1507
+ * @param {number} [index=this.length] 插入位置,默认为数组末尾
1508
+ */
1509
+ insertBefore(item, index = this.length) {
1510
+ arrayInsert(this, item, index);
1511
+ this.action$.next(['insertBefore', item, index]);
1512
+ }
1513
+
1514
+ /**
1515
+ * 删除指定位置的元素,并通知变化。
1516
+ * @param {number} [index=this.length-1] 删除位置,默认为数组末尾
1517
+ */
1518
+ removeChild(index = this.length - 1) {
1519
+ arrayRemove(this, index);
1520
+ this.action$.next(['removeChild', index]);
1521
+ }
1522
+
1523
+ /**
1524
+ * 替换指定位置的元素,并通知变化。
1525
+ * @param {T} item 新元素
1526
+ * @param {number} index 替换位置
1527
+ */
1528
+ replaceChild(item, index) {
1529
+ this[index] = item;
1530
+ this.action$.next(['replaceChild', item, index]);
1531
+ }
1532
+ /**
1533
+ * 附加一个默认子元素
1534
+ */
1535
+ appendChild() {
1536
+ this.insertBefore(this.newitem(), this.length);
1537
+ }
1538
+ }
1539
+ ;// ./src/deep-rxjs/0.js
1540
+
1541
+
1542
+ ;// ./src/hyperscript-rxjs/displays/blockLevelFamily.js
1543
+ /**
1544
+ * 一个包含所有 HTML 块级元素标签名称的集合。
1545
+ *
1546
+ * 块级元素是 HTML 中的一类元素,它们通常会独占一行,并且可以包含内联元素或其他块级元素。
1547
+ * 该集合中的标签名称均为大写,便于快速判断某个元素是否为块级元素。
1548
+ *
1549
+ * 常见的块级元素包括:
1550
+ * - 文本结构元素:`P`、`H1`-`H6`、`ADDRESS` 等。
1551
+ * - 列表元素:`UL`、`OL`、`LI`、`DL`、`DT`、`DD`。
1552
+ * - 容器元素:`DIV`、`SECTION`、`ARTICLE`、`ASIDE`、`NAV` 等。
1553
+ * - 表单元素:`FORM`、`FIELDSET`。
1554
+ * - 表格元素:`TABLE`。
1555
+ * - 其他:`BLOCKQUOTE`、`PRE`、`FIGURE` 等。
1556
+ *
1557
+ * @constant {Set<string>} blockLevelFamily
1558
+ */
1559
+ const blockLevelFamily = new Set(['ADDRESS', 'ARTICLE', 'ASIDE', 'BLOCKQUOTE', 'DD', 'DETAILS', 'DIALOG', 'DIV', 'DL', 'DT', 'FIELDSET', 'FIGCAPTION', 'FIGURE', 'FOOTER', 'FORM', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'HEADER', 'HGROUP', 'HR', 'LI', 'MAIN', 'NAV', 'OL', 'P', 'PRE', 'SECTION', 'TABLE', 'UL']);
1560
+ ;// ./src/hyperscript-rxjs/displays/inlineFamily.js
1561
+ /**
1562
+ * 一个包含所有 HTML 内联元素标签名称的集合。
1563
+ *
1564
+ * 内联元素是 HTML 中的一类元素,它们不会独占一行,通常用于包裹文本或其他内联元素。
1565
+ * 该集合中的标签名称均为大写,便于快速判断某个元素是否为内联元素。
1566
+ *
1567
+ * 常见的内联元素包括:
1568
+ * - 文本样式:`B`、`I`、`U`、`STRONG`、`EM`、`MARK` 等。
1569
+ * - 链接和交互:`A`、`BUTTON`、`LABEL`、`INPUT`、`SELECT`、`TEXTAREA` 等。
1570
+ * - 媒体和嵌入:`IMG`、`SVG`、`VIDEO`、`AUDIO`、`CANVAS` 等。
1571
+ * - 其他:`SPAN`、`BR`、`WBR`、`CODE`、`Q` 等。
1572
+ *
1573
+ * @constant {Set<string>} inlineFamily
1574
+ */
1575
+ const inlineFamily = new Set(['A', 'ABBR', 'ACRONYM', 'AUDIO', 'B', 'BDI', 'BDO', 'BIG', 'BR', 'BUTTON', 'CANVAS', 'CITE', 'CODE', 'DATA', 'DATALIST', 'DEL', 'DFN', 'EM', 'EMBED', 'I', 'IFRAME', 'IMG', 'INPUT', 'INS', 'KBD', 'LABEL', 'MAP', 'MARK', 'METER', 'NOSCRIPT', 'OBJECT', 'OUTPUT', 'PICTURE', 'PROGRESS', 'Q', 'RUBY', 'S', 'SAMP', 'SCRIPT', 'SELECT', 'SLOT', 'SMALL', 'SPAN', 'STRONG', 'SUB', 'SUP', 'SVG', 'TEMPLATE', 'TEXTAREA', 'TIME', 'TT', 'U', 'VAR', 'VIDEO', 'WBR']);
1576
+
1577
+ // developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements
1578
+ ;// ./src/hyperscript-rxjs/displays/getDisplay.js
1579
+
1580
+
1581
+
1582
+ /**
1583
+ * 获取 HTML 元素的默认 CSS `display` 值。
1584
+ *
1585
+ * 根据元素的标签名称 (`tagName`),返回其对应的默认 `display` 属性值。
1586
+ * 支持表格相关标签、块级元素、内联元素等常见 HTML 标签。
1587
+ *
1588
+ * @param {HTMLElement} elem - 要获取 `display` 值的 HTML 元素。
1589
+ * @returns {string} - 元素的默认 `display` 值:
1590
+ * - 表格相关标签:
1591
+ * - `TBODY` -> `'table-row-group'`
1592
+ * - `THEAD` -> `'table-header-group'`
1593
+ * - `TFOOT` -> `'table-footer-group'`
1594
+ * - `TR` -> `'table-row'`
1595
+ * - `TD`、`TH` -> `'table-cell'`
1596
+ * - `COLGROUP` -> `'table-column-group'`
1597
+ * - `COL` -> `'table-column'`
1598
+ * - `CAPTION` -> `'table-caption'`
1599
+ * - 块级元素 -> `'block'`
1600
+ * - 内联元素 -> `'inline'`
1601
+ * - 未知标签 -> `'unset'`
1602
+ *
1603
+ */
1604
+ function getDisplay(elem) {
1605
+ if (elem.tagName === 'TBODY') {
1606
+ return 'table-row-group';
1607
+ } else if (elem.tagName === 'THEAD') {
1608
+ return 'table-header-group';
1609
+ } else if (elem.tagName === 'TFOOT') {
1610
+ return 'table-footer-group';
1611
+ } else if (elem.tagName === 'TR') {
1612
+ return 'table-row';
1613
+ } else if (elem.tagName === 'TD' || elem.tagName === 'TH') {
1614
+ return 'table-cell';
1615
+ } else if (elem.tagName === 'COLGROUP') {
1616
+ return 'table-column-group';
1617
+ } else if (elem.tagName === 'COL') {
1618
+ return 'table-column';
1619
+ } else if (elem.tagName === 'CAPTION') {
1620
+ return 'table-caption';
1621
+ } else if (blockLevelFamily.has(elem.tagName)) {
1622
+ return 'block';
1623
+ } else if (inlineFamily.has(elem.tagName)) {
1624
+ return 'inline';
1625
+ } else {
1626
+ return 'unset';
1627
+ }
1628
+ }
1629
+ ;// ./src/hyperscript-rxjs/displays/0.js
1630
+
1631
+
1632
+
1633
+ ;// ./src/nodes/attachSubscriptionToNode.js
1634
+
1635
+
1636
+ /**
1637
+ * Attaches an RxJS subscription to a DOM node.
1638
+ * @param {Node & { subscription?: Subscription }} elem - DOM node to attach the subscription to.
1639
+ * @param {Subscription} subscription - RxJS subscription to attach.
1640
+ * @throws {Error} If parameters are invalid.
1641
+ */
1642
+ const attachSubscriptionToNode = (elem, subscription) => {
1643
+ if (!(elem instanceof Node)) {
1644
+ throw new Error('Valid DOM node required');
1645
+ }
1646
+ if (!(subscription instanceof external_rxjs_namespaceObject.Subscription)) {
1647
+ throw new Error('Valid RxJS subscription required');
1648
+ }
1649
+
1650
+ //新建或附加订阅
1651
+ if (!elem.subscription) {
1652
+ elem.subscription = subscription;
1653
+ } else {
1654
+ elem.subscription.add(subscription);
1655
+ }
1656
+ };
1657
+ ;// ./src/nodes/pipeEvent.js
1658
+
1659
+
1660
+
1661
+
1662
+ /**
1663
+ * 为指定的 DOM 元素订阅事件流,并通过 pipe 对事件流进行处理。
1664
+ *
1665
+ * @param {HTMLElement} elem - 要订阅事件的 DOM 元素。
1666
+ * @returns {(e:string,s:(event$: Observable<Event>) => Subscription)=>HTMLElement} - 返回一个函数,该函数接受事件名称和处理函数,用于订阅和处理事件。
1667
+ * @throws {Error} 如果参数无效。
1668
+ */
1669
+ function pipeEvent(elem) {
1670
+ // 参数检查,确保 elem 是一个有效的 DOM 元素
1671
+ if (!(elem instanceof HTMLElement)) {
1672
+ throw new Error('参数 "elem" 必须是一个有效的 DOM 元素。');
1673
+ }
1674
+ return (
1675
+ /**
1676
+ *
1677
+ * @param {string} event
1678
+ * @param {(event$: Observable<Event>) => Subscription} subscriber
1679
+ * @returns
1680
+ */
1681
+ function (event, subscriber) {
1682
+ // 参数检查,确保 event 是字符串,subscriber 是函数
1683
+ if (typeof event !== 'string') {
1684
+ throw new Error('参数 "event" 必须是一个字符串。');
1685
+ }
1686
+ if (typeof subscriber !== 'function') {
1687
+ throw new Error('参数 "subscriber" 必须是一个函数。');
1688
+ }
1689
+ let event$ = (0,external_rxjs_namespaceObject.fromEvent)(elem, event); // 创建事件流 Observable
1690
+
1691
+ try {
1692
+ let subscription = subscriber(event$); // 订阅事件流并处理
1693
+ attachSubscriptionToNode(elem, subscription); // 将订阅附加到 DOM 元素,便于管理
1694
+ } catch (error) {
1695
+ console.error(`处理事件 "${event}" 时发生错误:`, error);
1696
+ throw error;
1697
+ }
1698
+
1699
+ // 返回元素本身,支持链式调用
1700
+ return elem;
1701
+ }
1702
+ );
1703
+ }
1704
+ ;// ./src/nodes/subscribeEvent.js
1705
+
1706
+
1707
+
1708
+ /**
1709
+ * @template T
1710
+ * @typedef { import('rxjs').Observer<T> } Observer
1711
+ */
1712
+
1713
+ /**
1714
+ * 为指定的 DOM 元素订阅事件流,并将订阅与元素绑定,便于管理。
1715
+ *
1716
+ * @param {HTMLElement} elem - 要订阅事件的 DOM 元素。
1717
+ * @returns {(e:string, o:((value: Event) => void) | Partial<Observer<Event>>) => HTMLElement} - 返回一个函数,该函数接受事件名称和观察者,用于订阅事件。
1718
+ * @throws {Error} 如果参数无效。
1719
+ *
1720
+ */
1721
+ function subscribeEvent(elem) {
1722
+ // 参数检查,确保 elem 是一个有效的 DOM 元素
1723
+ if (!(elem instanceof HTMLElement)) {
1724
+ throw new Error('参数 "elem" 必须是一个有效的 DOM 元素。');
1725
+ }
1726
+ return (
1727
+ /**
1728
+ * @param {string} event
1729
+ * @param {((value: Event) => void) | Partial<Observer<Event>>} observer
1730
+ * @returns
1731
+ */
1732
+ (event, observer) => {
1733
+ // 参数检查,确保 event 是字符串,observer 是函数或观察者对象
1734
+ if (typeof event !== 'string') {
1735
+ throw new Error('参数 "event" 必须是一个字符串。');
1736
+ }
1737
+ if (typeof observer !== 'function' && typeof observer !== 'object' || observer === null) {
1738
+ throw new Error('参数 "observer" 必须是一个函数或观察者对象。');
1739
+ }
1740
+
1741
+ // 创建事件流 Observable
1742
+ let event$ = (0,external_rxjs_namespaceObject.fromEvent)(elem, event);
1743
+
1744
+ // 订阅事件流
1745
+ let subscription;
1746
+ try {
1747
+ subscription = event$.subscribe(observer);
1748
+ } catch (error) {
1749
+ console.error(`订阅事件 "${event}" 时发生错误:`, error);
1750
+ throw error;
1751
+ }
1752
+
1753
+ // 将订阅附加到 DOM 元素,便于管理
1754
+ attachSubscriptionToNode(elem, subscription);
1755
+
1756
+ // 返回元素本身,支持链式调用
1757
+ return elem;
1758
+ }
1759
+ );
1760
+ }
1761
+ ;// ./src/nodes/parseHyperscriptArgs.js
1762
+ /**
1763
+ * 解析 hyperscript 风格的参数,返回 props 和 childNodes。
1764
+ *
1765
+ * @param {any[]} args - hyperscript 风格的参数数组。
1766
+ * @returns {{ props: Record<string, any>, childNodes: any[] }} 包含 props(对象)和 childNodes(数组)的对象。
1767
+ * @throws 如果参数不是数组会抛出错误。
1768
+ */
1769
+
1770
+ function parseHyperscriptArgs(args) {
1771
+ // 参数验证,确保 args 是一个数组
1772
+ if (!Array.isArray(args)) {
1773
+ throw new Error('参数 "args" 必须是一个数组。');
1774
+ }
1775
+ if (args.length === 0) {
1776
+ return {
1777
+ props: {},
1778
+ childNodes: []
1779
+ };
1780
+ } else {
1781
+ let [first, ...rest] = args;
1782
+
1783
+ //
1784
+ if (isProps(first)) {
1785
+ return {
1786
+ props: first ? first : {},
1787
+ childNodes: rest
1788
+ };
1789
+ } else {
1790
+ // 如果第一个参数不是对象,则所有参数作为子节点
1791
+ return {
1792
+ props: {},
1793
+ childNodes: args
1794
+ };
1795
+ }
1796
+ }
1797
+ }
1798
+
1799
+ /**
1800
+ * 如果第一个参数是 undefined、null 或普通对象(非数组),则返回 true。
1801
+ * 否则返回 false。
1802
+ * @param {unknown} value - 要检查的值
1803
+ * @returns {boolean}
1804
+ *
1805
+ */
1806
+ function isProps(value) {
1807
+ //// 基本检查: 空作为props的占位符(不建议,作为兼容)
1808
+ if (value === undefined || value === null) {
1809
+ return true;
1810
+ }
1811
+
1812
+ // 基本检查:非对象直接返回false
1813
+ if (typeof value !== 'object') {
1814
+ return false;
1815
+ }
1816
+
1817
+ // 检查原型链
1818
+ const proto = Object.getPrototypeOf(value);
1819
+
1820
+ // 1. 原型为null(如Object.create(null)创建的对象)
1821
+ // 2. 原型等于Object.prototype(普通对象)
1822
+ return proto === null || proto === Object.prototype;
1823
+ }
1824
+ ;// ./src/nodes/normalizeChildNodes.js
1825
+
1826
+
1827
+ /**
1828
+ * 规范化子节点,将非节点转换为文本节点。
1829
+ *
1830
+ * @param {any[]} childNodes - 子节点数组。
1831
+ * @returns {Node[]} - 返回规范化后的节点数组。
1832
+ */
1833
+ function normalizeChildNodes(childNodes) {
1834
+ const normalizedNodes = unwrapArgs(childNodes); // 解构子节点数组
1835
+
1836
+ return normalizedNodes.map(child => child instanceof Node ? child : document.createTextNode(String(child)) // 将非节点转换为文本节点
1837
+ );
1838
+ }
1839
+ ;// ./src/object/splitObjectByObservable.js
1840
+
1841
+
1842
+ /**
1843
+ * 将对象属性按类型分为两部分:可观察对象(Observable)与普通值(非 Observable)。
1844
+ *
1845
+ * @param {Record<string,any>} obj - 要分割的对象,其属性值可能是 Observable 或普通值。
1846
+ * @returns {[Record<string, Observable<any>>, Record<string, any>]} - 返回一个数组,第一个对象包含所有 Observable 属性,第二个对象包含所有非 Observable 属性。
1847
+ * @throws {Error} 如果参数不是一个非空对象。
1848
+ */
1849
+ function splitObjectByObservable(obj) {
1850
+ // 参数检查,确保输入是一个非空对象
1851
+ if (typeof obj !== 'object' || Array.isArray(obj) || obj === null) {
1852
+ throw new Error('参数 "obj" 必须是一个非空对象。');
1853
+ }
1854
+
1855
+ /**
1856
+ * @type {Record<string, Observable<any>>}
1857
+ */
1858
+ let observables = {}; // 存储 Observable 属性
1859
+
1860
+ /**
1861
+ * @type {Record<string, any>}
1862
+ */
1863
+ let scalars = {}; // 存储非 Observable 属性
1864
+
1865
+ // 遍历对象的所有属性
1866
+ for (const key in obj) {
1867
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
1868
+ let value = obj[key];
1869
+
1870
+ // 根据值的类型分类
1871
+ if ((0,external_rxjs_namespaceObject.isObservable)(value)) {
1872
+ observables[key] = value; // 如果是 Observable,存入 observables
1873
+ } else {
1874
+ scalars[key] = value; // 否则存入 scalars
1875
+ }
1876
+ }
1877
+ }
1878
+ //可观察对象(Observable)与普通值(非 Observable)
1879
+ return [observables, scalars];
1880
+ }
1881
+ ;// ./src/props/getNestedProperty.js
1882
+ /**
1883
+ * 根据属性路径数组读取对象的嵌套属性值。
1884
+ * @param {Record<string | number, any>} obj - 要读取属性的对象。
1885
+ * @param {(string | number)[]} keyPath - 属性路径数组,例如 ['a', 'b'] 表示 obj.a.b。
1886
+ * @returns {any} - 返回目标属性的值,如果路径为空数组,则返回对象本身。
1887
+ * @throws {Error} 如果路径中的某一级属性不存在或输入无效。
1888
+ */
1889
+ function getNestedProperty(obj, keyPath) {
1890
+ if (!Array.isArray(keyPath)) {
1891
+ throw new Error('The "pathArray" parameter must be an array.');
1892
+ }
1893
+ if (!obj || typeof obj !== 'object') {
1894
+ throw new Error('The "obj" parameter must be a non-null object.');
1895
+ }
1896
+ return keyPath.reduce((currentObj, key) => {
1897
+ if (currentObj === null || currentObj === undefined) {
1898
+ throw new Error(`Cannot read property "${key}" of null or undefined.`);
1899
+ }
1900
+ if (typeof key === 'string' && typeof currentObj === 'object' && key in currentObj) {
1901
+ return /** @type {Record<string, any>} */currentObj[key];
1902
+ } else if (typeof key === 'number' && Array.isArray(currentObj) && key >= 0 && key < currentObj.length) {
1903
+ return currentObj[key];
1904
+ } else {
1905
+ throw new Error(`Property "${key}" does not exist on the object.`);
1906
+ }
1907
+ }, obj);
1908
+ }
1909
+ ;// ./src/props/parsePropName.js
1910
+
1911
+
1912
+ /**
1913
+ * 解析嵌套的 DOM 属性路径,并返回目标对象和属性名。
1914
+ *
1915
+ * @param {string} props - 属性路径,是 DOM API 的属性,不需要引号包裹,支持嵌套属性(如 "style.color")。
1916
+ * @param {Record<string, any>} obj - 起始对象,通常是一个 DOM 元素。
1917
+ * @returns {[Record<string, any>, string]} - 返回一个数组,表示叶节点,其中第一个元素是目标对象,第二个元素是属性名。(如 [obj.style, "color"])。
1918
+ * @throws {Error} 如果路径中的某一级属性不存在或输入无效。
1919
+ */
1920
+ function parsePropName(props, obj) {
1921
+ if (typeof props !== 'string') {
1922
+ throw new Error('The "prop" parameter must be a string.');
1923
+ }
1924
+
1925
+ /**
1926
+ * @param {any} target
1927
+ * @param {string} prop
1928
+ * @returns {[any, string]}
1929
+ */
1930
+ function getTargetAndProp(target, prop) {
1931
+ if (!target || typeof target !== 'object') {
1932
+ throw new Error('The "obj" parameter must be a non-null object.');
1933
+ }
1934
+ if (!(prop in target)) {
1935
+ throw new Error(`Property "${prop}" does not exist on the target object.`);
1936
+ }
1937
+ return [target, prop];
1938
+ }
1939
+ if (props.includes('.')) {
1940
+ const pathArray = props.split('.');
1941
+ const prop = pathArray.pop();
1942
+ if (!prop) {
1943
+ throw new Error('The "prop" parameter must be a non-empty string.');
1944
+ }
1945
+ const target = getNestedProperty(obj, pathArray);
1946
+ return getTargetAndProp(target, prop);
1947
+ } else {
1948
+ return getTargetAndProp(obj, props);
1949
+ }
1950
+ }
1951
+ ;// ./src/props/setProp.js
1952
+
1953
+
1954
+ /**
1955
+ *
1956
+ * 设置一个元素对象的任意嵌套路径属性的值,如果是CSS类名,值为真则添加类名,值为假则移除类名。如果是普通属性或嵌套属性则设置改属性值。
1957
+ *
1958
+ * @param {HTMLElement} root - 要设置属性的 DOM 元素。
1959
+ * @param {string} key - 属性名称,支持普通属性、嵌套属性(如 "style.color")或以 "." 开头的类名(如 ".active")。
1960
+ * @param {*} value - 要设置的属性值。如果是布尔值,用于控制类名的添加或移除。
1961
+ * @returns {HTMLElement} - 返回元素本身,支持链式调用。
1962
+ * @throws {Error} 如果参数无效或设置失败。
1963
+ *
1964
+ */
1965
+ function setProp(root, key, value) {
1966
+ if (!(root instanceof HTMLElement)) {
1967
+ throw new Error('The "element" parameter must be a valid DOM element.');
1968
+ }
1969
+ if (typeof key !== 'string') {
1970
+ throw new Error('The "key" parameter must be a string.');
1971
+ }
1972
+
1973
+ // CSS 类名操作
1974
+ if (key.charAt(0) === '.') {
1975
+ const className = key.substring(1);
1976
+ if (className.length === 0) {
1977
+ throw new Error('The class name cannot be empty.');
1978
+ }
1979
+ if (value) {
1980
+ root.classList.add(className); // 添加类名
1981
+ } else {
1982
+ root.classList.remove(className); // 移除类名
1983
+ }
1984
+ } else {
1985
+ // 普通属性或嵌套属性设置
1986
+ const [target, prop] = parsePropName(key, root); // 解析属性路径
1987
+ target[prop] = value; // 设置属性值
1988
+ }
1989
+ return root; // 返回元素本身,支持链式调用
1990
+ }
1991
+ ;// ./src/props/subscribeProp.js
1992
+
1993
+
1994
+
1995
+
1996
+
1997
+ /**
1998
+ *
1999
+ * 订阅一个 BehaviorSubject,将其发出的值动态设置为指定 DOM 元素的属性值。
2000
+ *
2001
+ * @template T
2002
+ * @param {HTMLElement} element - 要设置属性的 DOM 元素。
2003
+ * @param {string} key - 属性名称,支持普通属性、嵌套属性(如 "style.color")或以 "." 开头的类名(如 ".active")。
2004
+ * @param {Observable<T>} value$ - 一个 RxJS Observable ,用于发出属性值。
2005
+ * @returns {HTMLElement} - 返回元素本身,支持链式调用。
2006
+ * @throws {Error} 如果参数无效或订阅失败。
2007
+ */
2008
+ function subscribeProp(element, key, value$) {
2009
+ // 参数检查,确保输入有效
2010
+ if (!(element instanceof HTMLElement)) {
2011
+ throw new Error('参数 "element" 必须是一个有效的 DOM 元素。');
2012
+ }
2013
+ if (typeof key !== 'string') {
2014
+ throw new Error('参数 "key" 必须是一个字符串。');
2015
+ }
2016
+ if (!(0,external_rxjs_namespaceObject.isObservable)(value$)) {
2017
+ throw new Error('参数 "value$" 必须是一个有效的 Observable。');
2018
+ }
2019
+
2020
+ // 创建订阅,将 BehaviorSubject 的值动态设置为元素的属性
2021
+ const subscription = value$.pipe((0,external_rxjs_namespaceObject.startWith)(0)).subscribe({
2022
+ next: value => {
2023
+ setProp(element, key, value);
2024
+ },
2025
+ error: e => {
2026
+ setProp(element, key, e.message);
2027
+ }
2028
+ });
2029
+
2030
+ // 将订阅附加到 DOM 节点,便于统一管理
2031
+ attachSubscriptionToNode(element, subscription);
2032
+
2033
+ // 返回元素本身,支持链式调用
2034
+ return element;
2035
+ }
2036
+ ;// ./src/props/setProps.js
2037
+
2038
+
2039
+
2040
+
2041
+ /**
2042
+ * 为 DOM 元素设置属性,包括静态属性和动态属性(Observable)。
2043
+ *
2044
+ * @param {HTMLElement} element - 要设置属性的 DOM 元素。
2045
+ * @param {Object} props - 包含属性键值对的对象,其中值可以是普通值或 Observable。
2046
+ * @returns {HTMLElement} - 返回元素本身,支持链式调用。
2047
+ * @throws {Error} 如果参数无效或设置属性失败。
2048
+ */
2049
+ function setProps(element, props) {
2050
+ // 参数检查
2051
+ if (!(element instanceof HTMLElement)) {
2052
+ throw new Error('参数 "element" 必须是一个有效的 DOM 元素。');
2053
+ }
2054
+ if (typeof props !== 'object' || props === null) {
2055
+ throw new Error('参数 "props" 必须是一个非空对象。');
2056
+ }
2057
+
2058
+ // 将属性分为 Observable 和普通值
2059
+ const [observables, scalars] = splitObjectByObservable(props);
2060
+
2061
+ // 设置普通属性
2062
+ Object.entries(scalars).forEach(([key, value]) => {
2063
+ try {
2064
+ setProp(element, key, value);
2065
+ } catch (error) {
2066
+ console.error(`设置属性 "${key}" 时发生错误:`, error);
2067
+ }
2068
+ });
2069
+
2070
+ // 注意顺序,订阅动态属性要在设置静态属性之后
2071
+ Object.entries(observables).forEach(([key, value$]) => {
2072
+ try {
2073
+ subscribeProp(element, key, value$);
2074
+ } catch (error) {
2075
+ console.error(`订阅属性 "${key}" 时发生错误:`, error);
2076
+ }
2077
+ });
2078
+
2079
+ // 返回元素本身,支持链式调用
2080
+ return element;
2081
+ }
2082
+ ;// ./src/hyperscript-rxjs/hyperscript.js
2083
+
2084
+
2085
+
2086
+
2087
+
2088
+
2089
+
2090
+ /**
2091
+ * @typedef {import("./HyperscriptExtensions.d.ts").HyperscriptExtensions<HTMLElement>} HyperscriptElement
2092
+ */
2093
+
2094
+ /**
2095
+ * Creates an HTML element with extended event handling capabilities
2096
+ * @public
2097
+ * @param {string} elemName - The HTML element tag name
2098
+ * @param {...any} args - Optional properties and child nodes
2099
+ * @returns {HyperscriptElement} The created element with extended methods
2100
+ * @throws {Error} If elemName is not a valid HTML element tag name
2101
+ */
2102
+ function hyperscript(elemName, ...args) {
2103
+ // 参数验证,确保 elemName 是一个有效的字符串
2104
+ if (typeof elemName !== 'string' || !tagNames.has(elemName)) {
2105
+ throw new Error(`参数 elemName 不是一个有效的 HTML 元素标签名。`);
2106
+ }
2107
+
2108
+ // 创建 HTML 元素
2109
+
2110
+ let element = document.createElement(elemName);
2111
+
2112
+ // 解析传入的参数
2113
+ const {
2114
+ props,
2115
+ childNodes
2116
+ } = parseHyperscriptArgs(args);
2117
+
2118
+ // 设置元素属性
2119
+ setProps(element, props);
2120
+
2121
+ // 添加子节点
2122
+ normalizeChildNodes(childNodes).forEach(child => {
2123
+ element.appendChild(child); // 将子节点附加到元素
2124
+ });
2125
+ Object.assign(element, {
2126
+ /**
2127
+ *
2128
+ * @param {string} event
2129
+ * @param {(event$: Observable<Event>) => Subscription} subscriber
2130
+ */
2131
+ pipeEvent(event, subscriber) {
2132
+ return pipeEvent(element)(event, subscriber);
2133
+ },
2134
+ /**
2135
+ *
2136
+ * @param {string} event
2137
+ * @param {((value: Event) => void) | import('rxjs').Observer<Event>} observer
2138
+ */
2139
+ subscribeEvent(event, observer) {
2140
+ return subscribeEvent(element)(event, observer);
2141
+ },
2142
+ unsubscribe() {
2143
+ if ('subscription' in element && element.subscription instanceof external_rxjs_namespaceObject.Subscription) {
2144
+ element.subscription.unsubscribe(); // 取消订阅
2145
+ delete element.subscription; // 删除属性
2146
+ }
2147
+ }
2148
+ });
2149
+ return /** @type {HyperscriptElement} */element; // 返回创建的元素
2150
+ }
2151
+ const tagNames = new Set(["a", "abbr", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "blockquote", "br", "button", "caption", "cite", "code", "col", "colgroup", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "div", "dl", "dt", "em", "fieldset", "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "header", "hgroup", "hr", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "mark", "menu", "menuitem", "meter", "nav", "ol", "optgroup", "option", "output", "p", "pre", "progress", "q", "rb", "rp", "rt", "rtc", "ruby", "s", "samp", "section", "select", "small", "span", "strong", "sub", "summary", "sup", "table", "tbody", "td", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "video", "wbr"]);
2152
+ ;// ./src/hyperscript-rxjs/tags.js
2153
+
2154
+
2155
+ /**
2156
+ * @template {HTMLElement} T
2157
+ * @typedef {import("./HyperscriptExtensions.d.ts").HyperscriptExtensions<T>} HyperscriptExtensions
2158
+ */
2159
+
2160
+ /**
2161
+ * 创建 <a> 元素
2162
+ * @param {{ [_: string]: any }} [props] - 元素属性
2163
+ * @param {...any} childNodes - 子节点
2164
+ * @returns {HyperscriptExtensions<HTMLAnchorElement>}
2165
+ */
2166
+ const a = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLAnchorElement>} */hyperscript('a', props, ...childNodes));
2167
+
2168
+ /**
2169
+ * 创建 <abbr> 元素
2170
+ * @param {{ [_: string]: any }} [props] - 元素属性
2171
+ * @param {...any} childNodes - 子节点
2172
+ * @returns {HyperscriptExtensions<HTMLElement>}
2173
+ */
2174
+ const abbr = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('abbr', props, ...childNodes));
2175
+
2176
+ /**
2177
+ * 创建 <address> 元素
2178
+ * @param {{ [_: string]: any }} [props] - 元素属性
2179
+ * @param {...any} childNodes - 子节点
2180
+ * @returns {HyperscriptExtensions<HTMLElement>}
2181
+ */
2182
+ const address = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('address', props, ...childNodes));
2183
+
2184
+ /**
2185
+ * 创建 <area> 元素
2186
+ * @param {{ [_: string]: any }} [props] - 元素属性
2187
+ * @param {...any} childNodes - 子节点
2188
+ * @returns {HyperscriptExtensions<HTMLAreaElement>}
2189
+ */
2190
+ const tags_area = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLAreaElement>} */hyperscript('area', props, ...childNodes));
2191
+
2192
+ /**
2193
+ * 创建 <article> 元素
2194
+ * @param {{ [_: string]: any }} [props] - 元素属性
2195
+ * @param {...any} childNodes - 子节点
2196
+ * @returns {HyperscriptExtensions<HTMLElement>}
2197
+ */
2198
+ const article = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('article', props, ...childNodes));
2199
+
2200
+ /**
2201
+ * 创建 <aside> 元素
2202
+ * @param {{ [_: string]: any }} [props] - 元素属性
2203
+ * @param {...any} childNodes - 子节点
2204
+ * @returns {HyperscriptExtensions<HTMLElement>}
2205
+ */
2206
+ const aside = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('aside', props, ...childNodes));
2207
+
2208
+ /**
2209
+ * 创建 <audio> 元素
2210
+ * @param {{ [_: string]: any }} [props] - 元素属性
2211
+ * @param {...any} childNodes - 子节点
2212
+ * @returns {HyperscriptExtensions<HTMLAudioElement>}
2213
+ */
2214
+ const audio = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLAudioElement>} */hyperscript('audio', props, ...childNodes));
2215
+
2216
+ /**
2217
+ * 创建 <b> 元素
2218
+ * @param {{ [_: string]: any }} [props] - 元素属性
2219
+ * @param {...any} childNodes - 子节点
2220
+ * @returns {HyperscriptExtensions<HTMLElement>}
2221
+ */
2222
+ const b = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('b', props, ...childNodes));
2223
+
2224
+ /**
2225
+ * 创建 <bdi> 元素
2226
+ * @param {{ [_: string]: any }} [props] - 元素属性
2227
+ * @param {...any} childNodes - 子节点
2228
+ * @returns {HyperscriptExtensions<HTMLElement>}
2229
+ */
2230
+ const bdi = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('bdi', props, ...childNodes));
2231
+
2232
+ /**
2233
+ * 创建 <bdo> 元素
2234
+ * @param {{ [_: string]: any }} [props] - 元素属性
2235
+ * @param {...any} childNodes - 子节点
2236
+ * @returns {HyperscriptExtensions<HTMLElement>}
2237
+ */
2238
+ const bdo = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('bdo', props, ...childNodes));
2239
+
2240
+ /**
2241
+ * 创建 <blockquote> 元素
2242
+ * @param {{ [_: string]: any }} [props] - 元素属性
2243
+ * @param {...any} childNodes - 子节点
2244
+ * @returns {HyperscriptExtensions<HTMLQuoteElement>}
2245
+ */
2246
+ const blockquote = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLQuoteElement>} */hyperscript('blockquote', props, ...childNodes));
2247
+
2248
+ /**
2249
+ * 创建 <br> 元素
2250
+ * @param {{ [_: string]: any }} [props] - 元素属性
2251
+ * @param {...any} childNodes - 子节点
2252
+ * @returns {HyperscriptExtensions<HTMLBRElement>}
2253
+ */
2254
+ const br = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLBRElement>} */hyperscript('br', props, ...childNodes));
2255
+
2256
+ /**
2257
+ * 创建 <button> 元素
2258
+ * @param {{ [_: string]: any }} [props] - 元素属性
2259
+ * @param {...any} childNodes - 子节点
2260
+ * @returns {HyperscriptExtensions<HTMLButtonElement>}
2261
+ */
2262
+ const tags_button = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLButtonElement>} */hyperscript('button', props, ...childNodes));
2263
+
2264
+ /**
2265
+ * 创建 <caption> 元素
2266
+ * @param {{ [_: string]: any }} [props] - 元素属性
2267
+ * @param {...any} childNodes - 子节点
2268
+ * @returns {HyperscriptExtensions<HTMLElement>}
2269
+ */
2270
+ const caption = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('caption', props, ...childNodes));
2271
+
2272
+ /**
2273
+ * 创建 <cite> 元素
2274
+ * @param {{ [_: string]: any }} [props] - 元素属性
2275
+ * @param {...any} childNodes - 子节点
2276
+ * @returns {HyperscriptExtensions<HTMLElement>}
2277
+ */
2278
+ const cite = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('cite', props, ...childNodes));
2279
+
2280
+ /**
2281
+ * 创建 <code> 元素
2282
+ * @param {{ [_: string]: any }} [props] - 元素属性
2283
+ * @param {...any} childNodes - 子节点
2284
+ * @returns {HyperscriptExtensions<HTMLElement>}
2285
+ */
2286
+ const code = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('code', props, ...childNodes));
2287
+
2288
+ /**
2289
+ * 创建 <col> 元素
2290
+ * @param {{ [_: string]: any }} [props] - 元素属性
2291
+ * @param {...any} childNodes - 子节点
2292
+ * @returns {HyperscriptExtensions<HTMLTableColElement>}
2293
+ */
2294
+ const col = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLTableColElement>} */hyperscript('col', props, ...childNodes));
2295
+
2296
+ /**
2297
+ * 创建 <colgroup> 元素
2298
+ * @param {{ [_: string]: any }} [props] - 元素属性
2299
+ * @param {...any} childNodes - 子节点
2300
+ * @returns {HyperscriptExtensions<HTMLTableColElement>}
2301
+ */
2302
+ const colgroup = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLTableColElement>} */hyperscript('colgroup', props, ...childNodes));
2303
+
2304
+ /**
2305
+ * 创建 <data> 元素
2306
+ * @param {{ [_: string]: any }} [props] - 元素属性
2307
+ * @param {...any} childNodes - 子节点
2308
+ * @returns {HyperscriptExtensions<HTMLDataElement>}
2309
+ */
2310
+ const data = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLDataElement>} */hyperscript('data', props, ...childNodes));
2311
+
2312
+ /**
2313
+ * 创建 <datalist> 元素
2314
+ * @param {{ [_: string]: any }} [props] - 元素属性
2315
+ * @param {...any} childNodes - 子节点
2316
+ * @returns {HyperscriptExtensions<HTMLDataListElement>}
2317
+ */
2318
+ const datalist = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLDataListElement>} */hyperscript('datalist', props, ...childNodes));
2319
+
2320
+ /**
2321
+ * 创建 <dd> 元素
2322
+ * @param {{ [_: string]: any }} [props] - 元素属性
2323
+ * @param {...any} childNodes - 子节点
2324
+ * @returns {HyperscriptExtensions<HTMLElement>}
2325
+ */
2326
+ const dd = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('dd', props, ...childNodes));
2327
+
2328
+ /**
2329
+ * 创建 <del> 元素
2330
+ * @param {{ [_: string]: any }} [props] - 元素属性
2331
+ * @param {...any} childNodes - 子节点
2332
+ * @returns {HyperscriptExtensions<HTMLModElement>}
2333
+ */
2334
+ const del = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLModElement>} */hyperscript('del', props, ...childNodes));
2335
+
2336
+ /**
2337
+ * 创建 <details> 元素
2338
+ * @param {{ [_: string]: any }} [props] - 元素属性
2339
+ * @param {...any} childNodes - 子节点
2340
+ * @returns {HyperscriptExtensions<HTMLDetailsElement>}
2341
+ */
2342
+ const details = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLDetailsElement>} */hyperscript('details', props, ...childNodes));
2343
+
2344
+ /**
2345
+ * 创建 <dfn> 元素
2346
+ * @param {{ [_: string]: any }} [props] - 元素属性
2347
+ * @param {...any} childNodes - 子节点
2348
+ * @returns {HyperscriptExtensions<HTMLElement>}
2349
+ */
2350
+ const dfn = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('dfn', props, ...childNodes));
2351
+
2352
+ /**
2353
+ * 创建 <dialog> 元素
2354
+ * @param {{ [_: string]: any }} [props] - 元素属性
2355
+ * @param {...any} childNodes - 子节点
2356
+ * @returns {HyperscriptExtensions<HTMLDialogElement>}
2357
+ */
2358
+ const dialog = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLDialogElement>} */hyperscript('dialog', props, ...childNodes));
2359
+
2360
+ /**
2361
+ * 创建 <div> 元素
2362
+ * @param {{ [_: string]: any }} [props] - 元素属性
2363
+ * @param {...any} childNodes - 子节点
2364
+ * @returns {HyperscriptExtensions<HTMLDivElement>}
2365
+ */
2366
+ const div = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLDivElement>} */hyperscript('div', props, ...childNodes));
2367
+
2368
+ /**
2369
+ * 创建 <dl> 元素
2370
+ * @param {{ [_: string]: any }} [props] - 元素属性
2371
+ * @param {...any} childNodes - 子节点
2372
+ * @returns {HyperscriptExtensions<HTMLDListElement>}
2373
+ */
2374
+ const dl = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLDListElement>} */hyperscript('dl', props, ...childNodes));
2375
+
2376
+ /**
2377
+ * 创建 <dt> 元素
2378
+ * @param {{ [_: string]: any }} [props] - 元素属性
2379
+ * @param {...any} childNodes - 子节点
2380
+ * @returns {HyperscriptExtensions<HTMLElement>}
2381
+ */
2382
+ const dt = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('dt', props, ...childNodes));
2383
+
2384
+ /**
2385
+ * 创建 <em> 元素
2386
+ * @param {{ [_: string]: any }} [props] - 元素属性
2387
+ * @param {...any} childNodes - 子节点
2388
+ * @returns {HyperscriptExtensions<HTMLElement>}
2389
+ */
2390
+ const em = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('em', props, ...childNodes));
2391
+
2392
+ /**
2393
+ * 创建 <fieldset> 元素
2394
+ * @param {{ [_: string]: any }} [props] - 元素属性
2395
+ * @param {...any} childNodes - 子节点
2396
+ * @returns {HyperscriptExtensions<HTMLFieldSetElement>}
2397
+ */
2398
+ const fieldset = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLFieldSetElement>} */hyperscript('fieldset', props, ...childNodes));
2399
+
2400
+ /**
2401
+ * 创建 <figcaption> 元素
2402
+ * @param {{ [_: string]: any }} [props] - 元素属性
2403
+ * @param {...any} childNodes - 子节点
2404
+ * @returns {HyperscriptExtensions<HTMLElement>}
2405
+ */
2406
+ const figcaption = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('figcaption', props, ...childNodes));
2407
+
2408
+ /**
2409
+ * 创建 <figure> 元素
2410
+ * @param {{ [_: string]: any }} [props] - 元素属性
2411
+ * @param {...any} childNodes - 子节点
2412
+ * @returns {HyperscriptExtensions<HTMLElement>}
2413
+ */
2414
+ const figure = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('figure', props, ...childNodes));
2415
+
2416
+ /**
2417
+ * 创建 <footer> 元素
2418
+ * @param {{ [_: string]: any }} [props] - 元素属性
2419
+ * @param {...any} childNodes - 子节点
2420
+ * @returns {HyperscriptExtensions<HTMLElement>}
2421
+ */
2422
+ const footer = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('footer', props, ...childNodes));
2423
+
2424
+ /**
2425
+ * 创建 <form> 元素
2426
+ * @param {{ [_: string]: any }} [props] - 元素属性
2427
+ * @param {...any} childNodes - 子节点
2428
+ * @returns {HyperscriptExtensions<HTMLFormElement>}
2429
+ */
2430
+ const tags_form = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLFormElement>} */hyperscript('form', props, ...childNodes));
2431
+
2432
+ /**
2433
+ * 创建 <h1> 元素
2434
+ * @param {{ [_: string]: any }} [props] - 元素属性
2435
+ * @param {...any} childNodes - 子节点
2436
+ * @returns {HyperscriptExtensions<HTMLHeadingElement>}
2437
+ */
2438
+ const h1 = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLHeadingElement>} */hyperscript('h1', props, ...childNodes));
2439
+
2440
+ /**
2441
+ * 创建 <h2> 元素
2442
+ * @param {{ [_: string]: any }} [props] - 元素属性
2443
+ * @param {...any} childNodes - 子节点
2444
+ * @returns {HyperscriptExtensions<HTMLHeadingElement>}
2445
+ */
2446
+ const h2 = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLHeadingElement>} */hyperscript('h2', props, ...childNodes));
2447
+
2448
+ /**
2449
+ * 创建 <h3> 元素
2450
+ * @param {{ [_: string]: any }} [props] - 元素属性
2451
+ * @param {...any} childNodes - 子节点
2452
+ * @returns {HyperscriptExtensions<HTMLHeadingElement>}
2453
+ */
2454
+ const h3 = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLHeadingElement>} */hyperscript('h3', props, ...childNodes));
2455
+
2456
+ /**
2457
+ * 创建 <h4> 元素
2458
+ * @param {{ [_: string]: any }} [props] - 元素属性
2459
+ * @param {...any} childNodes - 子节点
2460
+ * @returns {HyperscriptExtensions<HTMLHeadingElement>}
2461
+ */
2462
+ const h4 = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLHeadingElement>} */hyperscript('h4', props, ...childNodes));
2463
+
2464
+ /**
2465
+ * 创建 <h5> 元素
2466
+ * @param {{ [_: string]: any }} [props] - 元素属性
2467
+ * @param {...any} childNodes - 子节点
2468
+ * @returns {HyperscriptExtensions<HTMLHeadingElement>}
2469
+ */
2470
+ const h5 = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLHeadingElement>} */hyperscript('h5', props, ...childNodes));
2471
+
2472
+ /**
2473
+ * 创建 <h6> 元素
2474
+ * @param {{ [_: string]: any }} [props] - 元素属性
2475
+ * @param {...any} childNodes - 子节点
2476
+ * @returns {HyperscriptExtensions<HTMLHeadingElement>}
2477
+ */
2478
+ const h6 = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLHeadingElement>} */hyperscript('h6', props, ...childNodes));
2479
+
2480
+ /**
2481
+ * 创建 <header> 元素
2482
+ * @param {{ [_: string]: any }} [props] - 元素属性
2483
+ * @param {...any} childNodes - 子节点
2484
+ * @returns {HyperscriptExtensions<HTMLElement>}
2485
+ */
2486
+ const header = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('header', props, ...childNodes));
2487
+
2488
+ /**
2489
+ * 创建 <hgroup> 元素
2490
+ * @param {{ [_: string]: any }} [props] - 元素属性
2491
+ * @param {...any} childNodes - 子节点
2492
+ * @returns {HyperscriptExtensions<HTMLElement>}
2493
+ */
2494
+ const hgroup = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('hgroup', props, ...childNodes));
2495
+
2496
+ /**
2497
+ * 创建 <hr> 元素
2498
+ * @param {{ [_: string]: any }} [props] - 元素属性
2499
+ * @param {...any} childNodes - 子节点
2500
+ * @returns {HyperscriptExtensions<HTMLHRElement>}
2501
+ */
2502
+ const hr = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLHRElement>} */hyperscript('hr', props, ...childNodes));
2503
+
2504
+ /**
2505
+ * 创建 <i> 元素
2506
+ * @param {{ [_: string]: any }} [props] - 元素属性
2507
+ * @param {...any} childNodes - 子节点
2508
+ * @returns {HyperscriptExtensions<HTMLElement>}
2509
+ */
2510
+ const i = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('i', props, ...childNodes));
2511
+
2512
+ /**
2513
+ * 创建 <img> 元素
2514
+ * @param {{ [_: string]: any }} [props] - 元素属性
2515
+ * @param {...any} childNodes - 子节点
2516
+ * @returns {HyperscriptExtensions<HTMLImageElement>}
2517
+ */
2518
+ const img = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLImageElement>} */hyperscript('img', props, ...childNodes));
2519
+
2520
+ /**
2521
+ * 创建 <input> 元素
2522
+ * @param {{ [_: string]: any }} [props] - 元素属性
2523
+ * @param {...any} childNodes - 子节点
2524
+ * @returns {HyperscriptExtensions<HTMLInputElement>}
2525
+ */
2526
+ const input = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLInputElement>} */hyperscript('input', props, ...childNodes));
2527
+
2528
+ /**
2529
+ * 创建 <ins> 元素
2530
+ * @param {{ [_: string]: any }} [props] - 元素属性
2531
+ * @param {...any} childNodes - 子节点
2532
+ * @returns {HyperscriptExtensions<HTMLModElement>}
2533
+ */
2534
+ const ins = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLModElement>} */hyperscript('ins', props, ...childNodes));
2535
+
2536
+ /**
2537
+ * 创建 <kbd> 元素
2538
+ * @param {{ [_: string]: any }} [props] - 元素属性
2539
+ * @param {...any} childNodes - 子节点
2540
+ * @returns {HyperscriptExtensions<HTMLElement>}
2541
+ */
2542
+ const kbd = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('kbd', props, ...childNodes));
2543
+
2544
+ /**
2545
+ * 创建 <label> 元素
2546
+ * @param {{ [_: string]: any }} [props] - 元素属性
2547
+ * @param {...any} childNodes - 子节点
2548
+ * @returns {HyperscriptExtensions<HTMLLabelElement>}
2549
+ */
2550
+ const label = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLLabelElement>} */hyperscript('label', props, ...childNodes));
2551
+
2552
+ /**
2553
+ * 创建 <legend> 元素
2554
+ * @param {{ [_: string]: any }} [props] - 元素属性
2555
+ * @param {...any} childNodes - 子节点
2556
+ * @returns {HyperscriptExtensions<HTMLLegendElement>}
2557
+ */
2558
+ const legend = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLLegendElement>} */hyperscript('legend', props, ...childNodes));
2559
+
2560
+ /**
2561
+ * 创建 <li> 元素
2562
+ * @param {{ [_: string]: any }} [props] - 元素属性
2563
+ * @param {...any} childNodes - 子节点
2564
+ * @returns {HyperscriptExtensions<HTMLLIElement>}
2565
+ */
2566
+ const li = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLLIElement>} */hyperscript('li', props, ...childNodes));
2567
+
2568
+ /**
2569
+ * 创建 <main> 元素
2570
+ * @param {{ [_: string]: any }} [props] - 元素属性
2571
+ * @param {...any} childNodes - 子节点
2572
+ * @returns {HyperscriptExtensions<HTMLElement>}
2573
+ */
2574
+ const main = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('main', props, ...childNodes));
2575
+
2576
+ /**
2577
+ * 创建 <mark> 元素
2578
+ * @param {{ [_: string]: any }} [props] - 元素属性
2579
+ * @param {...any} childNodes - 子节点
2580
+ * @returns {HyperscriptExtensions<HTMLElement>}
2581
+ */
2582
+ const mark = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('mark', props, ...childNodes));
2583
+
2584
+ /**
2585
+ * 创建 <menu> 元素
2586
+ * @param {{ [_: string]: any }} [props] - 元素属性
2587
+ * @param {...any} childNodes - 子节点
2588
+ * @returns {HyperscriptExtensions<HTMLMenuElement>}
2589
+ */
2590
+ const menu = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLMenuElement>} */hyperscript('menu', props, ...childNodes));
2591
+
2592
+ /**
2593
+ * 创建 <menuitem> 元素
2594
+ * @param {{ [_: string]: any }} [props] - 元素属性
2595
+ * @param {...any} childNodes - 子节点
2596
+ * @returns {HyperscriptExtensions<HTMLElement>}
2597
+ */
2598
+ const menuitem = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('menuitem', props, ...childNodes));
2599
+
2600
+ /**
2601
+ * 创建 <meter> 元素
2602
+ * @param {{ [_: string]: any }} [props] - 元素属性
2603
+ * @param {...any} childNodes - 子节点
2604
+ * @returns {HyperscriptExtensions<HTMLMeterElement>}
2605
+ */
2606
+ const meter = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLMeterElement>} */hyperscript('meter', props, ...childNodes));
2607
+
2608
+ /**
2609
+ * 创建 <nav> 元素
2610
+ * @param {{ [_: string]: any }} [props] - 元素属性
2611
+ * @param {...any} childNodes - 子节点
2612
+ * @returns {HyperscriptExtensions<HTMLElement>}
2613
+ */
2614
+ const nav = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('nav', props, ...childNodes));
2615
+
2616
+ /**
2617
+ * 创建 <ol> 元素
2618
+ * @param {{ [_: string]: any }} [props] - 元素属性
2619
+ * @param {...any} childNodes - 子节点
2620
+ * @returns {HyperscriptExtensions<HTMLOListElement>}
2621
+ */
2622
+ const ol = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLOListElement>} */hyperscript('ol', props, ...childNodes));
2623
+
2624
+ /**
2625
+ * 创建 <optgroup> 元素
2626
+ * @param {{ [_: string]: any }} [props] - 元素属性
2627
+ * @param {...any} childNodes - 子节点
2628
+ * @returns {HyperscriptExtensions<HTMLOptGroupElement>}
2629
+ */
2630
+ const optgroup = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLOptGroupElement>} */hyperscript('optgroup', props, ...childNodes));
2631
+
2632
+ /**
2633
+ * 创建 <option> 元素
2634
+ * @param {{ [_: string]: any }} [props] - 元素属性
2635
+ * @param {...any} childNodes - 子节点
2636
+ * @returns {HyperscriptExtensions<HTMLOptionElement>}
2637
+ */
2638
+ const tags_option = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLOptionElement>} */hyperscript('option', props, ...childNodes));
2639
+
2640
+ /**
2641
+ * 创建 <output> 元素
2642
+ * @param {{ [_: string]: any }} [props] - 元素属性
2643
+ * @param {...any} childNodes - 子节点
2644
+ * @returns {HyperscriptExtensions<HTMLOutputElement>}
2645
+ */
2646
+ const output = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLOutputElement>} */hyperscript('output', props, ...childNodes));
2647
+
2648
+ /**
2649
+ * 创建 <p> 元素
2650
+ * @param {{ [_: string]: any }} [props] - 元素属性
2651
+ * @param {...any} childNodes - 子节点
2652
+ * @returns {HyperscriptExtensions<HTMLParagraphElement>}
2653
+ */
2654
+ const p = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLParagraphElement>} */hyperscript('p', props, ...childNodes));
2655
+
2656
+ /**
2657
+ * 创建 <pre> 元素
2658
+ * @param {{ [_: string]: any }} [props] - 元素属性
2659
+ * @param {...any} childNodes - 子节点
2660
+ * @returns {HyperscriptExtensions<HTMLPreElement>}
2661
+ */
2662
+ const pre = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLPreElement>} */hyperscript('pre', props, ...childNodes));
2663
+
2664
+ /**
2665
+ * 创建 <progress> 元素
2666
+ * @param {{ [_: string]: any }} [props] - 元素属性
2667
+ * @param {...any} childNodes - 子节点
2668
+ * @returns {HyperscriptExtensions<HTMLProgressElement>}
2669
+ */
2670
+ const progress = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLProgressElement>} */hyperscript('progress', props, ...childNodes));
2671
+
2672
+ /**
2673
+ * 创建 <q> 元素
2674
+ * @param {{ [_: string]: any }} [props] - 元素属性
2675
+ * @param {...any} childNodes - 子节点
2676
+ * @returns {HyperscriptExtensions<HTMLQuoteElement>}
2677
+ */
2678
+ const q = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLQuoteElement>} */hyperscript('q', props, ...childNodes));
2679
+
2680
+ /**
2681
+ * 创建 <rb> 元素
2682
+ * @param {{ [_: string]: any }} [props] - 元素属性
2683
+ * @param {...any} childNodes - 子节点
2684
+ * @returns {HyperscriptExtensions<HTMLElement>}
2685
+ */
2686
+ const rb = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('rb', props, ...childNodes));
2687
+
2688
+ /**
2689
+ * 创建 <rp> 元素
2690
+ * @param {{ [_: string]: any }} [props] - 元素属性
2691
+ * @param {...any} childNodes - 子节点
2692
+ * @returns {HyperscriptExtensions<HTMLElement>}
2693
+ */
2694
+ const rp = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('rp', props, ...childNodes));
2695
+
2696
+ /**
2697
+ * 创建 <rt> 元素
2698
+ * @param {{ [_: string]: any }} [props] - 元素属性
2699
+ * @param {...any} childNodes - 子节点
2700
+ * @returns {HyperscriptExtensions<HTMLElement>}
2701
+ */
2702
+ const rt = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('rt', props, ...childNodes));
2703
+
2704
+ /**
2705
+ * 创建 <rtc> 元素
2706
+ * @param {{ [_: string]: any }} [props] - 元素属性
2707
+ * @param {...any} childNodes - 子节点
2708
+ * @returns {HyperscriptExtensions<HTMLElement>}
2709
+ */
2710
+ const rtc = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('rtc', props, ...childNodes));
2711
+
2712
+ /**
2713
+ * 创建 <ruby> 元素
2714
+ * @param {{ [_: string]: any }} [props] - 元素属性
2715
+ * @param {...any} childNodes - 子节点
2716
+ * @returns {HyperscriptExtensions<HTMLElement>}
2717
+ */
2718
+ const ruby = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('ruby', props, ...childNodes));
2719
+
2720
+ /**
2721
+ * 创建 <s> 元素
2722
+ * @param {{ [_: string]: any }} [props] - 元素属性
2723
+ * @param {...any} childNodes - 子节点
2724
+ * @returns {HyperscriptExtensions<HTMLElement>}
2725
+ */
2726
+ const s = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('s', props, ...childNodes));
2727
+
2728
+ /**
2729
+ * 创建 <samp> 元素
2730
+ * @param {{ [_: string]: any }} [props] - 元素属性
2731
+ * @param {...any} childNodes - 子节点
2732
+ * @returns {HyperscriptExtensions<HTMLElement>}
2733
+ */
2734
+ const samp = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('samp', props, ...childNodes));
2735
+
2736
+ /**
2737
+ * 创建 <section> 元素
2738
+ * @param {{ [_: string]: any }} [props] - 元素属性
2739
+ * @param {...any} childNodes - 子节点
2740
+ * @returns {HyperscriptExtensions<HTMLElement>}
2741
+ */
2742
+ const section = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('section', props, ...childNodes));
2743
+
2744
+ /**
2745
+ * 创建 <small> 元素
2746
+ * @param {{ [_: string]: any }} [props] - 元素属性
2747
+ * @param {...any} childNodes - 子节点
2748
+ * @returns {HyperscriptExtensions<HTMLElement>}
2749
+ */
2750
+ const small = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('small', props, ...childNodes));
2751
+
2752
+ /**
2753
+ * 创建 <span> 元素
2754
+ * @param {{ [_: string]: any }} [props] - 元素属性
2755
+ * @param {...any} childNodes - 子节点
2756
+ * @returns {HyperscriptExtensions<HTMLSpanElement>}
2757
+ */
2758
+ const span = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLSpanElement>} */hyperscript('span', props, ...childNodes));
2759
+
2760
+ /**
2761
+ * 创建 <strong> 元素
2762
+ * @param {{ [_: string]: any }} [props] - 元素属性
2763
+ * @param {...any} childNodes - 子节点
2764
+ * @returns {HyperscriptExtensions<HTMLElement>}
2765
+ */
2766
+ const strong = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('strong', props, ...childNodes));
2767
+
2768
+ /**
2769
+ * 创建 <sub> 元素
2770
+ * @param {{ [_: string]: any }} [props] - 元素属性
2771
+ * @param {...any} childNodes - 子节点
2772
+ * @returns {HyperscriptExtensions<HTMLElement>}
2773
+ */
2774
+ const sub = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('sub', props, ...childNodes));
2775
+
2776
+ /**
2777
+ * 创建 <summary> 元素
2778
+ * @param {{ [_: string]: any }} [props] - 元素属性
2779
+ * @param {...any} childNodes - 子节点
2780
+ * @returns {HyperscriptExtensions<HTMLElement>}
2781
+ */
2782
+ const summary = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('summary', props, ...childNodes));
2783
+
2784
+ /**
2785
+ * 创建 <sup> 元素
2786
+ * @param {{ [_: string]: any }} [props] - 元素属性
2787
+ * @param {...any} childNodes - 子节点
2788
+ * @returns {HyperscriptExtensions<HTMLElement>}
2789
+ */
2790
+ const sup = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('sup', props, ...childNodes));
2791
+
2792
+ /**
2793
+ * 创建 <table> 元素
2794
+ * @param {{ [_: string]: any }} [props] - 元素属性
2795
+ * @param {...any} childNodes - 子节点
2796
+ * @returns {HyperscriptExtensions<HTMLTableElement>}
2797
+ */
2798
+ const table = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLTableElement>} */hyperscript('table', props, ...childNodes));
2799
+
2800
+ /**
2801
+ * 创建 <tbody> 元素
2802
+ * @param {{ [_: string]: any }} [props] - 元素属性
2803
+ * @param {...any} childNodes - 子节点
2804
+ * @returns {HyperscriptExtensions<HTMLTableSectionElement>}
2805
+ */
2806
+ const tbody = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLTableSectionElement>} */hyperscript('tbody', props, ...childNodes));
2807
+
2808
+ /**
2809
+ * 创建 <td> 元素
2810
+ * @param {{ [_: string]: any }} [props] - 元素属性
2811
+ * @param {...any} childNodes - 子节点
2812
+ * @returns {HyperscriptExtensions<HTMLTableCellElement>}
2813
+ */
2814
+ const td = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLTableCellElement>} */hyperscript('td', props, ...childNodes));
2815
+
2816
+ /**
2817
+ * 创建 <tfoot> 元素
2818
+ * @param {{ [_: string]: any }} [props] - 元素属性
2819
+ * @param {...any} childNodes - 子节点
2820
+ * @returns {HyperscriptExtensions<HTMLTableSectionElement>}
2821
+ */
2822
+ const tfoot = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLTableSectionElement>} */hyperscript('tfoot', props, ...childNodes));
2823
+
2824
+ /**
2825
+ * 创建 <th> 元素
2826
+ * @param {{ [_: string]: any }} [props] - 元素属性
2827
+ * @param {...any} childNodes - 子节点
2828
+ * @returns {HyperscriptExtensions<HTMLTableCellElement>}
2829
+ */
2830
+ const th = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLTableCellElement>} */hyperscript('th', props, ...childNodes));
2831
+
2832
+ /**
2833
+ * 创建 <thead> 元素
2834
+ * @param {{ [_: string]: any }} [props] - 元素属性
2835
+ * @param {...any} childNodes - 子节点
2836
+ * @returns {HyperscriptExtensions<HTMLTableSectionElement>}
2837
+ */
2838
+ const thead = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLTableSectionElement>} */hyperscript('thead', props, ...childNodes));
2839
+
2840
+ /**
2841
+ * 创建 <time> 元素
2842
+ * @param {{ [_: string]: any }} [props] - 元素属性
2843
+ * @param {...any} childNodes - 子节点
2844
+ * @returns {HyperscriptExtensions<HTMLTimeElement>}
2845
+ */
2846
+ const time = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLTimeElement>} */hyperscript('time', props, ...childNodes));
2847
+
2848
+ /**
2849
+ * 创建 <tr> 元素
2850
+ * @param {{ [_: string]: any }} [props] - 元素属性
2851
+ * @param {...any} childNodes - 子节点
2852
+ * @returns {HyperscriptExtensions<HTMLTableRowElement>}
2853
+ */
2854
+ const tr = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLTableRowElement>} */hyperscript('tr', props, ...childNodes));
2855
+
2856
+ /**
2857
+ * 创建 <track> 元素
2858
+ * @param {{ [_: string]: any }} [props] - 元素属性
2859
+ * @param {...any} childNodes - 子节点
2860
+ * @returns {HyperscriptExtensions<HTMLTrackElement>}
2861
+ */
2862
+ const track = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLTrackElement>} */hyperscript('track', props, ...childNodes));
2863
+
2864
+ /**
2865
+ * 创建 <tt> 元素
2866
+ * @param {{ [_: string]: any }} [props] - 元素属性
2867
+ * @param {...any} childNodes - 子节点
2868
+ * @returns {HyperscriptExtensions<HTMLElement>}
2869
+ */
2870
+ const tt = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('tt', props, ...childNodes));
2871
+
2872
+ /**
2873
+ * 创建 <u> 元素
2874
+ * @param {{ [_: string]: any }} [props] - 元素属性
2875
+ * @param {...any} childNodes - 子节点
2876
+ * @returns {HyperscriptExtensions<HTMLElement>}
2877
+ */
2878
+ const u = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('u', props, ...childNodes));
2879
+
2880
+ /**
2881
+ * 创建 <ul> 元素
2882
+ * @param {{ [_: string]: any }} [props] - 元素属性
2883
+ * @param {...any} childNodes - 子节点
2884
+ * @returns {HyperscriptExtensions<HTMLUListElement>}
2885
+ */
2886
+ const ul = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLUListElement>} */hyperscript('ul', props, ...childNodes));
2887
+
2888
+ /**
2889
+ * 创建 <video> 元素
2890
+ * @param {{ [_: string]: any }} [props] - 元素属性
2891
+ * @param {...any} childNodes - 子节点
2892
+ * @returns {HyperscriptExtensions<HTMLVideoElement>}
2893
+ */
2894
+ const video = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLVideoElement>} */hyperscript('video', props, ...childNodes));
2895
+
2896
+ /**
2897
+ * 创建 <wbr> 元素
2898
+ * @param {{ [_: string]: any }} [props] - 元素属性
2899
+ * @param {...any} childNodes - 子节点
2900
+ * @returns {HyperscriptExtensions<HTMLElement>}
2901
+ */
2902
+ const wbr = (props, ...childNodes) => (/** @type {HyperscriptExtensions<HTMLElement>} */hyperscript('wbr', props, ...childNodes));
2903
+ ;// ./src/hyperscript-rxjs/tabControls/tabRoot.js
2904
+
2905
+
2906
+ /**
2907
+ * 选项卡组件的基础框架。
2908
+ *
2909
+ * `tabRoot` 函数生成一个包含导航栏和内容面板的容器结构,
2910
+ * 用于构建选项卡组件的基础部分。
2911
+ *
2912
+ * @param {Object} props - 传递给根容器 `<div>` 的属性(如 `id`、`className` 等)。
2913
+ * @returns {HTMLElement} - 返回一个包含导航栏和内容面板的 `<div>` 元素。
2914
+ *
2915
+ */
2916
+ function tabRoot(props) {
2917
+ // <div>
2918
+ // <ul class="nav nav-tabs"></ul>
2919
+ // <div class="tab-content"></div>
2920
+ // </div>
2921
+ return div(props, ul({
2922
+ className: 'nav nav-tabs'
2923
+ }), div({
2924
+ className: 'tab-content'
2925
+ }));
2926
+ }
2927
+ ;// ./src/hyperscript-rxjs/tabControls/tabNavItem.js
2928
+
2929
+
2930
+ /**
2931
+ * 选项卡的导航按钮。
2932
+ *
2933
+ * `tabNavItem` 函数生成一个选项卡的导航按钮,通常用于选项卡的导航栏中。
2934
+ *
2935
+ * @param {...(string|HTMLElement)} source - 按钮的内容,可以是字符串或 HTML 元素。
2936
+ * @returns {HTMLElement} - 返回一个带有 `nav-item` 样式类的 `<li>` 元素,内部包含一个按钮。
2937
+ *
2938
+ */
2939
+ function tabNavItem(...source) {
2940
+ // <li class="nav-item">
2941
+ // <button type="button" class="btn btn-link nav-link">
2942
+ // source
2943
+ // </button>
2944
+ // </li>
2945
+ return li({
2946
+ className: 'nav-item'
2947
+ }, tags_button({
2948
+ type: 'button',
2949
+ className: 'btn btn-link nav-link'
2950
+ }, ...source));
2951
+ }
2952
+ ;// ./src/hyperscript-rxjs/tabControls/tabPanel.js
2953
+
2954
+
2955
+ /**
2956
+ * 选项卡的内容面板。
2957
+ *
2958
+ * `tabPanel` 函数生成一个选项卡的内容区域,用于显示与选项卡对应的内容。
2959
+ *
2960
+ * @param {...(string|HTMLElement)} source - 面板的内容,可以是字符串或 HTML 元素。
2961
+ * @returns {HTMLElement} - 返回一个带有 `tab-pane` 样式类的 `<div>` 元素。
2962
+ *
2963
+ */
2964
+ function tabPanel(...source) {
2965
+ // <div class="tab-pane">
2966
+ // source
2967
+ // </div>
2968
+ return div({
2969
+ className: 'tab-pane'
2970
+ }, ...source);
2971
+ }
2972
+ ;// ./src/hyperscript-rxjs/tabControls/bindTabIndex.js
2973
+
2974
+
2975
+
2976
+ /**
2977
+ * 绑定选项卡的激活状态到 `tabIndex`。
2978
+ *
2979
+ * `bindTabIndex` 函数将选项卡的导航按钮和内容面板与 `tabIndex` 绑定,
2980
+ * 实现动态切换选项卡的功能。
2981
+ *
2982
+ * @param {HTMLElement} tabRoot - 选项卡的根容器,包含导航栏和内容面板。
2983
+ * @param {BehaviorSubject<number>} tabIndex$ - 表示当前激活选项卡索引的 BehaviorSubject。
2984
+ *
2985
+ */
2986
+ function bindTabIndex(tabRoot, tabIndex$) {
2987
+ /**
2988
+ * @typedef {import("../HyperscriptExtensions.d.ts").HyperscriptExtensions<HTMLElement>} HyperscriptElement
2989
+ */
2990
+
2991
+ const navs = /** @type {HyperscriptElement} */tabRoot.firstChild; // 导航栏容器
2992
+ const panels = /** @type {HyperscriptElement} */tabRoot.lastChild; // 内容面板容器
2993
+
2994
+ // 订阅 tabIndex,动态更新选项卡的激活状态
2995
+ tabIndex$.subscribe(i => {
2996
+ // 更新导航按钮的激活状态
2997
+ Array.from(navs.childNodes).forEach((li, j) => {
2998
+ const btn = /** @type {HTMLElement} */li.firstChild;
2999
+ if (i === j) {
3000
+ btn.classList.add('active');
3001
+ } else {
3002
+ btn.classList.remove('active');
3003
+ }
3004
+ });
3005
+
3006
+ // 更新内容面板的激活状态
3007
+ Array.from(panels.childNodes).forEach((panel, j) => {
3008
+ const classList = /** @type {HTMLElement} */panel.classList;
3009
+ if (i === j) {
3010
+ classList.add('active');
3011
+ } else {
3012
+ classList.remove('active');
3013
+ }
3014
+ });
3015
+ });
3016
+
3017
+ // 监听导航按钮的点击事件,更新 tabIndex
3018
+ navs.pipeEvent('click', click$ => click$.pipe((0,external_rxjs_namespaceObject.map)(e => Array.from(navs.childNodes).map(e => (/** @type {HTMLElement} */e.firstChild)).indexOf(/** @type {HTMLElement} */e.target)), (0,external_rxjs_namespaceObject.filter)(i => i > -1) // 过滤无效索引
3019
+ ).subscribe(tabIndex$));
3020
+ }
3021
+ ;// ./src/hyperscript-rxjs/tabControls/tabControl.js
3022
+
3023
+
3024
+
3025
+
3026
+
3027
+ /**
3028
+ * 创建静态选项卡组件。
3029
+ *
3030
+ * `tabControl` 函数生成一个静态选项卡组件,其中选项卡的数量和顺序是固定的。
3031
+ * 每个选项卡由一个导航按钮和一个对应的内容面板组成。
3032
+ *
3033
+ * @param {{ tabIndex: BehaviorSubject<number>, [key: string]: any}} props - 选项卡组件的属性。
3034
+ * @param {Array<string|HTMLElement>} tabs - 导航按钮的内容数组,可以是字符串或 HTML 元素。
3035
+ * @param {Array<string|HTMLElement>} panels - 内容面板的内容数组,可以是字符串或 HTML 元素。
3036
+ * @returns {HTMLElement} - 返回一个包含导航栏和内容面板的选项卡组件。
3037
+ */
3038
+ function tabControl(props, tabs, panels) {
3039
+ const {
3040
+ tabIndex,
3041
+ ...rootProps
3042
+ } = props;
3043
+
3044
+ // 创建选项卡的根容器
3045
+ const root = tabRoot(rootProps);
3046
+ const tablist = /** @type {HTMLElement} */root.firstChild; // 导航栏容器
3047
+ const tabcontent = /** @type {HTMLElement} */root.lastChild; // 内容面板容器
3048
+
3049
+ // 创建导航按钮并添加到导航栏
3050
+ tabs.map(tab => tabNavItem(tab)).forEach(item => tablist.appendChild(item));
3051
+
3052
+ // 创建内容面板并添加到内容区域
3053
+ panels.map(panel => tabPanel(panel)).forEach(panel => tabcontent.appendChild(panel));
3054
+
3055
+ // 绑定选项卡的激活状态
3056
+ bindTabIndex(root, tabIndex);
3057
+ return root;
3058
+ }
3059
+ ;// ./src/hyperscript-rxjs/tabControls/0.js
3060
+
3061
+
3062
+
3063
+
3064
+
3065
+ ;// ./src/hyperscript-rxjs/checkbox.js
3066
+
3067
+
3068
+
3069
+
3070
+ /**
3071
+ * @typedef {import("./HyperscriptExtensions.d.ts").HyperscriptExtensions<HTMLInputElement>} HyperscriptInputElement
3072
+ */
3073
+
3074
+ /**
3075
+ * 创建一个支持 RxJS 的复选框组件。
3076
+ *
3077
+ * @param {{checked?:BehaviorSubject<boolean>, [key: string]: any}} props - 复选框的属性对象。
3078
+ * @returns {HyperscriptInputElement} - 返回一个复选框元素。
3079
+ */
3080
+ function checkbox_checkbox(props) {
3081
+ if (typeof props !== 'object' || props === null) {
3082
+ throw new Error('`checkbox` requires a `props` object.');
3083
+ }
3084
+
3085
+ // 创建复选框元素,确保 type 为 'checkbox'
3086
+ const elem = /** @type {HyperscriptInputElement}*/input({
3087
+ ...props,
3088
+ type: 'checkbox'
3089
+ });
3090
+
3091
+ // 如果传入了 checked 属性
3092
+ if (props.checked && props.checked instanceof external_rxjs_namespaceObject.BehaviorSubject) {
3093
+ // 监听复选框的 input 事件,并将选中状态推送到 Observable/Subject
3094
+ let subscriber =
3095
+ /**
3096
+ *
3097
+ * @param {Observable<Event>} input$
3098
+ * @returns
3099
+ */
3100
+ input$ => input$.pipe((0,external_rxjs_namespaceObject.map)(e => /** @type {HTMLInputElement} */e.target.checked) // 提取复选框的选中状态
3101
+ ).subscribe(props.checked); // 推送选中状态到 Observable/Subject
3102
+
3103
+ elem.pipeEvent('input', subscriber); // 绑定事件处理器
3104
+ } else {
3105
+ throw new Error('`checkbox` requires a `checked` prop that is an instance of BehaviorSubject.');
3106
+ }
3107
+ return elem; // 返回复选框元素
3108
+ }
3109
+ ;// ./src/hyperscript-rxjs/collapse.js
3110
+
3111
+
3112
+
3113
+
3114
+ /**
3115
+ * 显示或隐藏包含的元素。
3116
+ *
3117
+ * `collapse` 函数通过绑定 `hidden` 属性,实现一组 HTML 元素的动态显示或隐藏。
3118
+ *
3119
+ * @param {Observable<boolean>} hidden$ - 一个可观察对象(如 BehaviorSubject),用于控制元素的 `hidden` 属性。
3120
+ * @param {...HTMLElement|HTMLElement[]} elements - 一个或多个 HTML 元素,或者包含 HTML 元素的数组。
3121
+ * @returns {HTMLElement[]} - 处理后的元素数组。
3122
+ *
3123
+ * @throws {Error} 如果 `elements` 中包含非元素节点(如 TextNode)。
3124
+ *
3125
+ */
3126
+ function collapse(hidden$, ...elements) {
3127
+ // 支持子元素包含在数组中:collapse([a, b, c]) 或 collapse(a, b, c)
3128
+ let elems = unwrapArgs(elements);
3129
+ elems.forEach(elem => {
3130
+ if (!(elem instanceof HTMLElement)) {
3131
+ throw new Error('`collapse` only supports HTMLElement nodes.');
3132
+ }
3133
+
3134
+ // 绑定 hidden 属性到可观察对象
3135
+ subscribeProp(elem, 'hidden', hidden$);
3136
+ });
3137
+ return elems;
3138
+ }
3139
+ ;// ./src/hyperscript-rxjs/choice.js
3140
+
3141
+
3142
+
3143
+
3144
+ /**
3145
+ * @param {Observable<string>} chosen$
3146
+ * @param {Record<string, HTMLElement | HTMLElement[]>} possibilities
3147
+ * @returns {HTMLElement[]}
3148
+ */
3149
+ function choice(chosen$, possibilities) {
3150
+ // 遍历 possibilities,将每个可能性绑定到 collapse
3151
+ const elems = Object.entries(possibilities).map(([key, possibility]) => {
3152
+ const hidden$ = chosen$.pipe((0,external_rxjs_namespaceObject.map)(selectedKey => selectedKey !== key) // 如果当前选中的键不是当前可能性,则隐藏
3153
+ );
3154
+ return collapse(hidden$, possibility); // 绑定 hidden 属性
3155
+ }).reduce((acc, cur) => [...acc, ...cur], []); // 扁平化数组
3156
+
3157
+ return elems;
3158
+ }
3159
+ ;// ./src/hyperscript-rxjs/flip.js
3160
+
3161
+
3162
+
3163
+
3164
+ /**
3165
+ * 动态切换两个元素或元素数组的显示状态。
3166
+ *
3167
+ * `flip` 函数根据 `yinHidden$` 的值动态控制 `yinElement` 和 `yangElement` 的显示状态:
3168
+ * - 当 `yinHidden$` 为 `true` 时,隐藏 `yinElement`,显示 `yangElement`。
3169
+ * - 当 `yinHidden$` 为 `false` 时,显示 `yinElement`,隐藏 `yangElement`。
3170
+ *
3171
+ * @param {Observable<boolean>} yinHidden$ - 一个 Observable,表示 `yinElement` 是否隐藏。
3172
+ * @param {HTMLElement|HTMLElement[]} yin - 需要动态控制显示状态的第一个元素或元素数组。
3173
+ * @param {HTMLElement|HTMLElement[]} yang - 需要动态控制显示状态的第二个元素或元素数组。
3174
+ * @returns {HTMLElement[]} - 包含所有元素的数组。
3175
+ *
3176
+ */
3177
+ function flip(yinHidden$, yin, yang) {
3178
+ // 创建一个 Observable,用于控制 yangElement 的隐藏状态
3179
+ const yangHidden$ = yinHidden$.pipe((0,external_rxjs_namespaceObject.map)(isHidden => !isHidden));
3180
+
3181
+ // 阴阳交叉
3182
+ return [...collapse(yangHidden$, yin), ...collapse(yinHidden$, yang)];
3183
+ }
3184
+ ;// ./src/hyperscript-rxjs/fragment.js
3185
+
3186
+
3187
+ /**
3188
+ * 用途:插入一组元素,不必使用循环语句,fragment 用后即弃。
3189
+ *
3190
+ * @param {...Node|Node[]} childNodes - 要插入的子节点,可以是单个节点、多个节点或节点数组。
3191
+ * @returns {DocumentFragment} - 返回包含所有子节点的 DocumentFragment。
3192
+ * @throws {Error} 如果传入的子节点不是有效的 DOM 节点。
3193
+ */
3194
+ function fragment(...childNodes) {
3195
+ // 创建一个 DocumentFragment
3196
+ const frag = new DocumentFragment();
3197
+
3198
+ // 验证并附加子节点
3199
+ normalizeChildNodes(childNodes).forEach(child => {
3200
+ frag.appendChild(child); // 将子节点附加到元素
3201
+ });
3202
+
3203
+ // 返回 DocumentFragment
3204
+ return frag;
3205
+ }
3206
+ ;// ./src/hyperscript-rxjs/multiselect.js
3207
+
3208
+
3209
+ /**
3210
+ * @typedef {import("./HyperscriptExtensions.d.ts").HyperscriptExtensions<HTMLSelectElement>} HyperscriptSelectElement
3211
+ */
3212
+
3213
+ /**
3214
+ * 创建一个支持多选功能的 <select> 元素,并绑定选项的选中状态。必须手动添加控件更新BehaviorSubject的事件。
3215
+ *
3216
+ * @param {{oninput?: (e:Event)=>void, onchange?: (e:Event)=>void, [key: string]: any}} props - 配置对象,包含 <select> 元素的属性。
3217
+ * @param {...HTMLOptionElement} options - 一个或多个 <option> 元素,必须是 HTMLOptionElement 类型。
3218
+ * 每个选项需要包含一个 `selected` 属性,该属性是一个 BehaviorSubject ,用于绑定选中状态。
3219
+ * @returns {HyperscriptSelectElement} - 创建的 <select> 元素。
3220
+ * @throws {Error} 如果 `props` 不是对象,或者 `options` 中的选项未正确定义 `selected` 属性。
3221
+ *
3222
+ */
3223
+ function multiselect(props, ...options) {
3224
+ if (typeof props !== 'object' || props === null) {
3225
+ throw new Error('`select` requires a `props` object.');
3226
+ }
3227
+ let {
3228
+ oninput,
3229
+ onchange,
3230
+ ...rest
3231
+ } = props;
3232
+ let elem = hyperscript('select', {
3233
+ ...rest,
3234
+ multiple: true
3235
+ }, ...options);
3236
+ if (typeof oninput === 'function') {
3237
+ elem.subscribeEvent('input', e => {
3238
+ oninput(e);
3239
+ });
3240
+ }
3241
+ if (typeof onchange === 'function') {
3242
+ elem.subscribeEvent('change', e => {
3243
+ onchange(e);
3244
+ });
3245
+ }
3246
+ return /** @type {HyperscriptSelectElement} */elem;
3247
+ }
3248
+ ;// ./src/hyperscript-rxjs/numberbox.js
3249
+
3250
+
3251
+
3252
+
3253
+ // import { fromEvent } from 'rxjs';
3254
+ // import { attachSubscriptionToNode } from '../../nodes/attachSubscriptionToNode';
3255
+
3256
+ /**
3257
+ * @internal
3258
+ * @typedef {import("./HyperscriptInputElement.d.ts").HyperscriptInputElement} HyperscriptInputElement
3259
+ */
3260
+
3261
+ /**
3262
+ * 创建一个支持双向绑定的数字输入框。
3263
+ *
3264
+ * `numberbox` 是一个自定义的输入框组件,支持通过 RxJS 的 `BehaviorSubject` 实现数字值的双向绑定。
3265
+ * @public
3266
+ * @param {{ number: BehaviorSubject<number>; [key: string]: any;}} props - 配置对象,包含输入框的属性。
3267
+ * @returns {HyperscriptInputElement} - 创建的数字输入框元素。
3268
+ * @throws {Error} 如果 `props` 不是对象,或者 `number` 不是 `BehaviorSubject` 实例。
3269
+ *
3270
+ */
3271
+ function numberbox(props) {
3272
+ if (typeof props !== 'object' || props === null) {
3273
+ throw new Error('`numberbox` requires a `props` object.');
3274
+ }
3275
+ let {
3276
+ number,
3277
+ ...rest
3278
+ } = props;
3279
+ let elem = /** @type {HyperscriptInputElement} */
3280
+ input({
3281
+ ...rest,
3282
+ type: 'text'
3283
+ });
3284
+ if (number && number instanceof external_rxjs_namespaceObject.BehaviorSubject) {
3285
+ let value = number.pipe((0,external_rxjs_namespaceObject.map)(n => String(n)));
3286
+ subscribeProp(elem, 'value', value);
3287
+ let subscriber =
3288
+ /**
3289
+ *
3290
+ * @param {Observable<Event>} blur$
3291
+ * @returns
3292
+ */
3293
+ blur$ => blur$.pipe((0,external_rxjs_namespaceObject.map)(e => Number(/** @type {HTMLInputElement} */
3294
+ e.target.value))).subscribe(newValue => {
3295
+ if (Number.isNaN(newValue)) {
3296
+ elem.select();
3297
+ } else if (number.value !== newValue) {
3298
+ number.next(newValue);
3299
+ }
3300
+ });
3301
+
3302
+ // 展开pipeEvent是为了正确生成测试代码
3303
+ // let event$ = fromEvent(elem, 'blur')// 创建事件流 Observable
3304
+ // let subscription = blurSubscriber(event$); // 订阅事件流并处理
3305
+ // attachSubscriptionToNode(elem, subscription); // 将订阅附加到 DOM 元素,便于管理
3306
+
3307
+ elem.pipeEvent('blur', subscriber);
3308
+ } else {
3309
+ throw new Error('`numberbox` requires a `number` prop that is an instance of BehaviorSubject. ');
3310
+ }
3311
+
3312
+ // 数字右对齐,用 style 可以获得最高优先级
3313
+ elem.style.textAlign = 'right';
3314
+ return elem;
3315
+ }
3316
+ ;// ./src/hyperscript-rxjs/radio.js
3317
+
3318
+
3319
+
3320
+
3321
+ // import { fromEvent } from 'rxjs';
3322
+ // import { attachSubscriptionToNode } from '../../nodes/attachSubscriptionToNode';
3323
+
3324
+ /**
3325
+ * @internal
3326
+ * @typedef {import("./HyperscriptInputElement.d.ts").HyperscriptInputElement} HyperscriptInputElement
3327
+ */
3328
+
3329
+ /**
3330
+ * 单选按钮
3331
+ * @public
3332
+ * @param {{checked: BehaviorSubject<boolean>; [key: string]: any}} props
3333
+ * @returns {HyperscriptInputElement}
3334
+ */
3335
+ function radio_radio(props) {
3336
+ if (typeof props !== 'object' || props === null) {
3337
+ throw new Error('`radio` requires a `props` object.');
3338
+ }
3339
+ const elem = /** @type {HyperscriptInputElement} */
3340
+ input({
3341
+ ...props,
3342
+ type: 'radio'
3343
+ });
3344
+ if (props.checked && props.checked instanceof external_rxjs_namespaceObject.BehaviorSubject) {
3345
+ const subscriber =
3346
+ /**
3347
+ *
3348
+ * @param {Observable<Event>} input$
3349
+ * @returns
3350
+ */
3351
+ input$ => input$.pipe((0,external_rxjs_namespaceObject.map)(e => /** @type {HTMLInputElement} */
3352
+ e.target.checked)).subscribe(props.checked);
3353
+ elem.pipeEvent('input', subscriber);
3354
+
3355
+ // 展开pipeEvent是为了正确生成测试代码
3356
+ // let event$ = fromEvent(elem, 'input')// 创建事件流 Observable
3357
+ // let subscription = subscriber(event$); // 订阅事件流并处理
3358
+ // attachSubscriptionToNode(elem, subscription); // 将订阅附加到 DOM 元素,便于管理
3359
+ } else {
3360
+ throw new Error('`radio` requires a `checked` prop that is an instance of BehaviorSubject. ');
3361
+ }
3362
+ return elem;
3363
+ }
3364
+ ;// ./src/hyperscript-rxjs/select.js
3365
+
3366
+
3367
+
3368
+
3369
+ // import { fromEvent } from 'rxjs';
3370
+ // import { attachSubscriptionToNode } from '../nodes/attachSubscriptionToNode';
3371
+
3372
+ /**
3373
+ * @internal
3374
+ * @typedef {import("./HyperscriptSelectElement.d.ts").HyperscriptSelectElement} HyperscriptSelectElement
3375
+ */
3376
+
3377
+ /**
3378
+ * 创建一个支持 RxJS 数据绑定的 <select> 元素。仅单选选择框。
3379
+ *
3380
+ * @param {{ selectedIndex?: BehaviorSubject<number>, value?: BehaviorSubject<string>, [key: string]: any }} props - 配置对象,包含 <select> 元素的属性。
3381
+ * @param {...HTMLOptionElement} options - 一个或多个 <option> 元素,必须是 HTMLOptionElement 类型。
3382
+ * @returns {HyperscriptSelectElement} - 创建的 <select> 元素。
3383
+ * @throws {Error} 如果 `props` 不是对象,或者 `selectedIndex` 或 `value` 不是 BehaviorSubject。
3384
+ */
3385
+ function select_select(props, ...options) {
3386
+ if (typeof props !== 'object' || props === null) {
3387
+ throw new Error('`select` requires a `props` object.');
3388
+ }
3389
+ let elem = /** @type {HyperscriptSelectElement} */
3390
+ hyperscript('select', {
3391
+ ...props,
3392
+ multiple: false
3393
+ }, ...options);
3394
+
3395
+ // todo: 显示判断属性是否传递了属性,('selectedIndex' in props)
3396
+ let {
3397
+ selectedIndex,
3398
+ value
3399
+ } = props;
3400
+
3401
+ // 确保至少有一个是 BehaviorSubject
3402
+ if (elem.options.length > 0 && !(selectedIndex instanceof external_rxjs_namespaceObject.BehaviorSubject) && !(value instanceof external_rxjs_namespaceObject.BehaviorSubject)) {
3403
+ throw new Error('`select` requires at least one of `selectedIndex` or `value` to be a BehaviorSubject.');
3404
+ }
3405
+ if (selectedIndex && selectedIndex instanceof external_rxjs_namespaceObject.BehaviorSubject) {
3406
+ selectedIndex.subscribe(i => {
3407
+ /** @type {HTMLOptionElement} */
3408
+ elem[i].selected = true;
3409
+ });
3410
+ let subscriber =
3411
+ /**
3412
+ * @param {Observable<Event>} input$
3413
+ */
3414
+ input$ => input$.pipe((0,external_rxjs_namespaceObject.map)(e => /** @type {HTMLSelectElement} */
3415
+ e.target.selectedIndex)).subscribe(selectedIndex);
3416
+ elem.pipeEvent('input', subscriber);
3417
+ // let event$ = fromEvent(elem, 'input');
3418
+ // let subscription = subscriber(event$);
3419
+ // attachSubscriptionToNode(elem, subscription);
3420
+ }
3421
+ if (value && value instanceof external_rxjs_namespaceObject.BehaviorSubject) {
3422
+ value.subscribe(value => {
3423
+ Array.from(elem.getElementsByTagName('option')).filter(opt => opt.value === value).forEach(opt => {
3424
+ opt.selected = true;
3425
+ });
3426
+ });
3427
+ let subscriber =
3428
+ /**
3429
+ * @param {Observable<Event>} input$
3430
+ */
3431
+
3432
+ input$ => input$.pipe((0,external_rxjs_namespaceObject.map)(e => /** @type {HTMLSelectElement} */
3433
+ e.target.value)).subscribe(value);
3434
+ elem.pipeEvent('input', subscriber);
3435
+ // let event$ = fromEvent(elem, 'input');
3436
+ // let subscription = subscriber(event$);
3437
+ // attachSubscriptionToNode(elem, subscription);
3438
+ }
3439
+ return elem;
3440
+ }
3441
+ ;// ./src/hyperscript-rxjs/textarea.js
3442
+
3443
+
3444
+
3445
+
3446
+ /**
3447
+ * @internal
3448
+ * @typedef {import("./HyperscriptExtensions.d.ts").HyperscriptExtensions<HTMLTextAreaElement>} HyperscriptTextAreaElement
3449
+ */
3450
+
3451
+ /**
3452
+ * 创建一个支持 RxJS 数据绑定的 <textarea> 元素。
3453
+ *
3454
+ * @param {{value:BehaviorSubject<string>, [key:string]:any}} props - 配置对象,包含 <textarea> 元素的属性。
3455
+ * @returns {HyperscriptTextAreaElement} - 创建的 <textarea> 元素。
3456
+ * @throws {Error} 如果 `props` 不是对象,或者 `value` 不是 BehaviorSubject。
3457
+ */
3458
+ function textarea_textarea(props) {
3459
+ if (typeof props !== 'object' || props === null) {
3460
+ throw new Error('`textarea` requires a `props` object.');
3461
+ }
3462
+ const {
3463
+ value
3464
+ } = props;
3465
+ if (!(value instanceof external_rxjs_namespaceObject.BehaviorSubject)) {
3466
+ throw new Error('`value` must be an instance of BehaviorSubject.');
3467
+ }
3468
+
3469
+ // 创建 <textarea> 元素
3470
+ const elem = /** @type {HyperscriptTextAreaElement} */hyperscript('textarea', props);
3471
+
3472
+ // 订阅输入事件并更新 BehaviorSubject
3473
+ const subscriber =
3474
+ /**
3475
+ *
3476
+ * @param {Observable<Event>} input$
3477
+ * @returns
3478
+ */
3479
+ input$ => input$.pipe((0,external_rxjs_namespaceObject.map)(e => /** @type {HTMLTextAreaElement} */e.target.value)).subscribe(value);
3480
+ elem.pipeEvent('input', subscriber);
3481
+ return elem;
3482
+ }
3483
+ ;// ./src/hyperscript-rxjs/textbox.js
3484
+
3485
+
3486
+
3487
+
3488
+ /**
3489
+ * @internal
3490
+ * @typedef {import("./HyperscriptInputElement.d.ts").HyperscriptInputElement} HyperscriptInputElement
3491
+ */
3492
+
3493
+ /**
3494
+ * 创建一个支持 RxJS 数据绑定的 <input type="text"> 元素。
3495
+ *
3496
+ * @param {{value: BehaviorSubject<string>, [key: string]: any}} props - 配置对象,包含 <input> 元素的属性。
3497
+ * @returns {HyperscriptInputElement} - 创建的 <input type="text"> 元素。
3498
+ * @throws {Error} 如果 `props` 不是对象,或者 `value` 不是 BehaviorSubject。
3499
+ */
3500
+ function textbox(props) {
3501
+ if (typeof props !== 'object' || props === null) {
3502
+ throw new Error('`textbox` requires a `props` object.');
3503
+ }
3504
+ const {
3505
+ value
3506
+ } = props;
3507
+ if (!(value instanceof external_rxjs_namespaceObject.BehaviorSubject)) {
3508
+ throw new Error('`value` must be an instance of BehaviorSubject.');
3509
+ }
3510
+
3511
+ // 创建 <input type="text"> 元素
3512
+ const elem = /** @type {HyperscriptInputElement} */input({
3513
+ ...props,
3514
+ type: 'text'
3515
+ });
3516
+
3517
+ // 订阅输入事件并更新 BehaviorSubject
3518
+ const subscriber =
3519
+ /**
3520
+ * @param {Observable<Event>} input$
3521
+ * @returns
3522
+ */
3523
+ input$ => input$.pipe((0,external_rxjs_namespaceObject.map)(e => /** @type {HTMLInputElement} */e.target.value)).subscribe(value);
3524
+ elem.pipeEvent('input', subscriber);
3525
+ return elem;
3526
+ }
3527
+ ;// ./src/hyperscript-rxjs/textNode.js
3528
+
3529
+
3530
+
3531
+ /**
3532
+ * @typedef {Text & {subscription?: Subscription, unsubscribe?: ()=>void}} ObservableTextNode
3533
+ */
3534
+
3535
+ /**
3536
+ * 创建一个文本节点。
3537
+ * 支持静态文本和动态更新的文本(通过 RxJS Observable)。
3538
+ *
3539
+ * - 如果传入的是字符串,则创建一个静态文本节点。
3540
+ * - 如果传入的是 RxJS Observable,则创建一个动态文本节点,并根据 Observable 的值实时更新文本内容。
3541
+ * - 动态文本节点支持通过 `unsubscribe` 方法取消订阅。
3542
+ *
3543
+ * @param {any} text Observable<any> | any。
3544
+ * @returns {ObservableTextNode}
3545
+ *
3546
+ */
3547
+ function textNode(text) {
3548
+ // 如果传入的是 Observable
3549
+ if ((0,external_rxjs_namespaceObject.isObservable)(text)) {
3550
+ const node = document.createTextNode("");
3551
+
3552
+ // 创建订阅并更新文本节点
3553
+ const subscription = text.pipe((0,external_rxjs_namespaceObject.map)(d => String(d))).subscribe({
3554
+ next(t) {
3555
+ node.nodeValue = t;
3556
+ },
3557
+ error(err) {
3558
+ node.nodeValue = `Error: ${err.message}`;
3559
+ }
3560
+ });
3561
+ return Object.assign(node, {
3562
+ subscription,
3563
+ /**
3564
+ * @this {ObservableTextNode}
3565
+ */
3566
+ unsubscribe() {
3567
+ if (this.subscription) {
3568
+ this.subscription.unsubscribe();
3569
+ delete this.subscription; // 删除 subscription 成员
3570
+ delete this.unsubscribe;
3571
+ }
3572
+ }
3573
+ });
3574
+ } else {
3575
+ return document.createTextNode(String(text)); // 转换为字符串
3576
+ }
3577
+ }
3578
+ ;// ./src/hyperscript-rxjs/0.js
3579
+
3580
+
3581
+
3582
+
3583
+
3584
+
3585
+
3586
+
3587
+
3588
+
3589
+
3590
+
3591
+
3592
+
3593
+
3594
+
3595
+ ;// ./src/nodes/0.js
3596
+
3597
+
3598
+
3599
+
3600
+
3601
+ ;// ./src/object/intersectObject.js
3602
+ /**
3603
+ * Creates an object composed of the picked object properties.
3604
+ * @param {Record<string,any>} obj - Source object
3605
+ * @param {string[]} keys - Array of property keys to pick
3606
+ * @returns {Record<string,any>} New object with picked properties
3607
+ * @throws {TypeError} If obj is not an object or keys is not an array
3608
+ */
3609
+ function intersectObject(obj, keys) {
3610
+ // 类型检查
3611
+ if (typeof obj !== 'object' || obj === null) {
3612
+ throw new TypeError('First argument must be an object');
3613
+ }
3614
+ if (!Array.isArray(keys)) {
3615
+ throw new TypeError('Second argument must be an array');
3616
+ }
3617
+ return Object.fromEntries(keys.filter(key => key in obj).map(key => [key, obj[key]]));
3618
+ }
3619
+ ;// ./src/object/isPlainObject.js
3620
+ /**
3621
+ * 检查一个值是否是普通对象(Plain Object)
3622
+ * @param {unknown} value - 要检查的值
3623
+ * @returns {value is object} - 返回是否是普通对象的类型谓词
3624
+ */
3625
+ function isPlainObject(value) {
3626
+ // 基本检查:非对象或为null的直接返回false
3627
+ if (typeof value !== 'object' || value === null) {
3628
+ return false;
3629
+ }
3630
+
3631
+ // 检查原型链
3632
+ const proto = Object.getPrototypeOf(value);
3633
+
3634
+ // 1. 原型为null(如Object.create(null)创建的对象)
3635
+ // 2. 原型等于Object.prototype(普通对象)
3636
+ return proto === null || proto === Object.prototype;
3637
+ }
3638
+ ;// ./src/object/isEmptyObject.js
3639
+
3640
+
3641
+ /**
3642
+ * 判断对象是否为空对象(非数组、非 null,且无自有属性)
3643
+ * @param {unknown} obj - 要判断的对象
3644
+ * @returns {obj is Record<never, never>} 类型谓词,确保类型收窄
3645
+ */
3646
+ const isEmptyObject = obj => {
3647
+ return isPlainObject(obj) && Object.keys(obj).length === 0;
3648
+ };
3649
+ ;// ./src/object/nestedCombineLatest.js
3650
+
3651
+
3652
+
3653
+
3654
+ ///对象格式的Observale,转化成扁平格式的数据后,整个数组外面Observable
3655
+ /**
3656
+ *
3657
+ * @param {Record<string|number, any>} model
3658
+ * @returns {Observable<Record<string|number, any>>}
3659
+ */
3660
+ function nestedCombineLatest(model) {
3661
+ let deep = Deep.fromObservable(model);
3662
+ return deep.combineLatest().pipe((0,external_rxjs_namespaceObject.map)(deep => deep.toObject()));
3663
+ }
3664
+ ;// ./src/object/nestedMerge.js
3665
+
3666
+
3667
+
3668
+ /**
3669
+ *
3670
+ * @param {Record<string|number, any>} model
3671
+ * @returns {Observable<[(string | number)[], any]>}
3672
+ */
3673
+ function nestedMerge(model) {
3674
+ return Deep.fromObservable(model).merge();
3675
+ }
3676
+ ;// ./src/object/pickBehaviorSubject.js
3677
+
3678
+
3679
+
3680
+
3681
+
3682
+ /**
3683
+ *
3684
+ * 拾取对象中的BehaviorSubject值,作爲葉子節點,忽略其他值。
3685
+ *
3686
+ * @param {Record<string|number,any> & { pickeys?: string [] }} model - 输入的数据结构,可以是对象、数组或BehaviorSubject
3687
+ * @returns {Record<string|number,any>} - 返回只包含BehaviorSubject当前值的结构
3688
+ * @throws {Error} 当输入不包含任何BehaviorSubject或结构不符合预期时抛出错误
3689
+ */
3690
+ function pickBehaviorSubject(model) {
3691
+ let x = loop(model, '', null);
3692
+ if (x.length === 1) {
3693
+ return x[0][1];
3694
+ } else {
3695
+ throw new Error('pickBehaviorSubject');
3696
+ }
3697
+ }
3698
+
3699
+ /**
3700
+ *
3701
+ * 递归遍历数据结构收集BehaviorSubject值
3702
+ *
3703
+ * @param {any} value - 当前遍历的值
3704
+ * @param {string|number} key - 当前键名
3705
+ * @param {object|null} parent - 父级对象
3706
+ * @returns {[string|number, any][]} - 返回收集到的键值对数组,每个元素是一个[key, value]元组
3707
+ * @throws {Error} 当遇到不符合要求的数据结构时抛出错误
3708
+ */
3709
+ function loop(value, key, parent) {
3710
+ if ((0,external_rxjs_namespaceObject.isObservable)(value) && value instanceof external_rxjs_namespaceObject.BehaviorSubject) {
3711
+ return [[key, value.value]]; //保存葉節點
3712
+ } else if (value === null || typeof value !== 'object' || isRxType(value)) {
3713
+ return [];
3714
+ } else if (value instanceof ObservableArray) {
3715
+ let v = [...value].map((e, i) => {
3716
+ let pelem = loop(e, i, value);
3717
+ if (pelem.length === 1) {
3718
+ return pelem[0][1]; //表示元素是正常叶节点
3719
+ } else {
3720
+ throw new Error('dense Array'); //非正常叶节点,有洞
3721
+ }
3722
+ });
3723
+ return [[key, v]];
3724
+ } else if (value instanceof Array) {
3725
+ if (value.length === 0) {
3726
+ return []; //空不可变数组,将丢弃。
3727
+ } else {
3728
+ let v = value.map((e, i) => {
3729
+ let pelem = loop(e, i, value);
3730
+ if (pelem.length === 1) {
3731
+ return pelem[0][1];
3732
+ } else {
3733
+ throw new Error('dense Array');
3734
+ }
3735
+ });
3736
+ return [[key, v]];
3737
+ }
3738
+ } else if ('pickeys' in value) {
3739
+ return loop(intersectObject(value, value.pickeys()), key, parent);
3740
+ } else {
3741
+ let entries = Object.entries(value);
3742
+ if (entries.length === 0) {
3743
+ return [];
3744
+ } else {
3745
+ let ee = entries.map(([k, v]) => loop(v, k, parent)).reduce((acc, val) => [...acc, ...val], []);
3746
+ if (ee.length === 0) {
3747
+ return [];
3748
+ } else {
3749
+ return [[key, Object.fromEntries(ee)]];
3750
+ }
3751
+ }
3752
+ }
3753
+ }
3754
+ ;// ./src/object/restore.js
3755
+
3756
+
3757
+
3758
+
3759
+ /**
3760
+ * Updates a reactive model with new values from a source object.
3761
+ * Recursively synchronizes BehaviorSubject, ObservableArray, array and object contents.
3762
+ *
3763
+ * @param {Record<string | number, any>} model - The reactive model to update (can be BehaviorSubject, ObservableArray, array or object)
3764
+ * @param {Record<string | number, any>} src - The new values to restore, should match the structure of the model
3765
+ * @returns
3766
+ */
3767
+ function restore(model, src) {
3768
+ restore_loop(model, src);
3769
+ // return model
3770
+ }
3771
+
3772
+ /**
3773
+ * Recursively updates model values from source
3774
+ * @param {any & {appendChild?: (c:any) => void }} o - Current model node to update
3775
+ * @param {any} src - Corresponding source value
3776
+ */
3777
+ function restore_loop(o, src) {
3778
+ if (o instanceof external_rxjs_namespaceObject.BehaviorSubject) {
3779
+ // Input value
3780
+ o.next(src);
3781
+ } else if (o === null || typeof o !== 'object' || isRxType(o)) {
3782
+ // noop
3783
+ } else if (o instanceof ObservableArray) {
3784
+ let len = o.length;
3785
+ let diffcount = len - src.length;
3786
+ if (diffcount > 0) {
3787
+ // Truncate if longer
3788
+ Array.from({
3789
+ length: diffcount
3790
+ }).map((e, i) => len - 1 - i).forEach(last => {
3791
+ o.removeChild(last);
3792
+ });
3793
+ } else if (diffcount < 0) {
3794
+ // Extend if shorter
3795
+ Array.from({
3796
+ length: -diffcount
3797
+ }).map((e, i) => len + i).forEach(i => {
3798
+ // Add an item to the end of an Array
3799
+ o.appendChild();
3800
+ });
3801
+ }
3802
+
3803
+ // After alignment, update each element's value
3804
+ for (let i of o.keys()) {
3805
+ restore_loop(o[i], src[i]);
3806
+ }
3807
+ } else if (o instanceof Array) {
3808
+ // Regular array, tuple
3809
+ let indexes = o.length < src.length ? o : src;
3810
+ // Ignore extra src elements, noop for missing elements
3811
+ for (let i of indexes.keys()) {
3812
+ // todo: Throw error when o[i] is not settable?
3813
+ restore_loop(o[i], src[i]);
3814
+ }
3815
+ } else if (typeof o === 'object') {
3816
+ // Recursively process object properties
3817
+ Object.entries(o).filter(([k, v]) => k in src) // Intersection
3818
+ .forEach(([k, v]) => {
3819
+ restore_loop(v, src[k]);
3820
+ });
3821
+ }
3822
+ }
3823
+ ;// ./src/object/0.js
3824
+
3825
+
3826
+
3827
+
3828
+
3829
+
3830
+
3831
+
3832
+
3833
+ ;// ./src/props/0.js
3834
+
3835
+
3836
+
3837
+
3838
+
3839
+ ;// ./src/ramda/compose.js
3840
+ /**
3841
+ * 函数优先的管道组合工具(从右向左执行)
3842
+ * @public
3843
+ * @param {...((arg: any) => any)} fns - 要组合的函数列表
3844
+ * @returns {(arg: any) => any} 组合后的函数(无参数时返回恒等函数 x => x)
3845
+ * @throws {TypeError} 当参数包含非函数时抛出错误
3846
+ */
3847
+ const compose = (...fns) => {
3848
+ if (!fns || fns.length === 0) {
3849
+ /** @param {*} x */
3850
+ return x => x;
3851
+ }
3852
+ const firstNonFunctionIndex = fns.findIndex(fn => typeof fn !== 'function');
3853
+ if (firstNonFunctionIndex !== -1) {
3854
+ const invalidFn = fns[firstNonFunctionIndex];
3855
+ const errorType = invalidFn === null ? 'null' : invalidFn === undefined ? 'undefined' : typeof invalidFn;
3856
+ throw new TypeError(`所有参数必须是函数,但第 ${firstNonFunctionIndex} 个参数是: ${errorType}`);
3857
+ }
3858
+ if (fns.length === 1) {
3859
+ return fns[0];
3860
+ }
3861
+
3862
+ // 标注 args 类型
3863
+ return fns.reduce((acc, fn) => /** @returns {*} */
3864
+ (...args) => acc(fn(...args)));
3865
+ };
3866
+ ;// ./src/ramda/cond.js
3867
+ /**
3868
+ * 条件分支函数,依次判断分支并返回第一个匹配的结果。
3869
+ *
3870
+ * @public
3871
+ * @param {Array<Function|[Function, Function]>} branches - 分支数组,每个分支可以是函数或 [谓词函数, 动作函数] 形式
3872
+ * @returns {function(...*): *} 组合后的条件函数
3873
+ */
3874
+ const cond = function cond(branches) {
3875
+ /**
3876
+ * @this any
3877
+ */
3878
+ return function () {
3879
+ for (const branch of branches) {
3880
+ if (typeof branch === 'function') {
3881
+ let tryAction = branch.apply(this, arguments);
3882
+ if (tryAction) {
3883
+ return tryAction;
3884
+ }
3885
+ } else if (Array.isArray(branch)) {
3886
+ let predicate = branch[0].apply(this, arguments);
3887
+ if (predicate) {
3888
+ let args = Array.from(arguments);
3889
+ args[args.length] = predicate;
3890
+ return branch[1].apply(this, args);
3891
+ }
3892
+ }
3893
+ }
3894
+ };
3895
+ };
3896
+ ;// ./src/ramda/fold.js
3897
+ /**
3898
+ * 通用折叠(递归归约)函数。
3899
+ *
3900
+ * @public
3901
+ * @param {(this:any, acc: any, seed: any) => [*, *]|[any]|[]|null|undefined} fn - 处理函数,返回 [新acc, 新seed] 或 [新acc]
3902
+ * @param {*} acc - 初始累加值
3903
+ * @param {*} seed - 初始种子
3904
+ * @returns {*} 折叠后的结果
3905
+ * @this *
3906
+ */
3907
+ function fold(fn, acc, seed) {
3908
+ while (seed != null) {
3909
+ let pair = fn.call(this, acc, seed);
3910
+ if (pair == null || pair.length === 0) break;
3911
+ acc = pair[0];
3912
+ if (pair.length === 1) break;
3913
+ seed = pair[1];
3914
+ }
3915
+ return acc;
3916
+ }
3917
+ ;// ./src/ramda/pipe.js
3918
+ /**
3919
+ * 数据优先的管道处理工具(从左向右执行)
3920
+ * 适合一次性数据处理流程
3921
+ * @public
3922
+ * @param {any} initialValue - 初始值
3923
+ * @param {...((arg: any) => any)} fns - 要应用的函数管道(从左向右执行)
3924
+ * @throws {TypeError} 当参数包含非函数时抛出错误
3925
+ */
3926
+ const pipe = (initialValue, ...fns) => {
3927
+ // 无函数时直接返回初始值
3928
+ if (fns.length === 0) return initialValue;
3929
+
3930
+ // 类型检查(遇到第一个错误就抛出)
3931
+ const firstNonFunctionIndex = fns.findIndex(fn => typeof fn !== 'function');
3932
+ if (firstNonFunctionIndex !== -1) {
3933
+ const invalidFn = fns[firstNonFunctionIndex];
3934
+ const errorType = invalidFn === null ? 'null' : invalidFn === undefined ? 'undefined' : typeof invalidFn;
3935
+ throw new TypeError(`所有管道函数必须是函数,但第 ${firstNonFunctionIndex} 个参数是: ${errorType}`);
3936
+ }
3937
+ return fns.reduce((acc, fn) => fn(acc), initialValue);
3938
+ };
3939
+ ;// ./src/ramda/unfold.js
3940
+ /**
3941
+ * 通过不断调用 fn 生成值,直到 fn 返回 falsy。
3942
+ *
3943
+ * @public
3944
+ * @template T, S
3945
+ * @param {(seed: S) => [T, S] | false | null | undefined} fn - 生成函数,接收当前 seed,返回 [value, nextSeed] 或 falsy。
3946
+ * @param {S} seed - 初始种子值。
3947
+ * @returns {Array<T>} 由 fn 生成的所有 value 组成的数组。
3948
+ * @this *
3949
+ */
3950
+ function unfold(fn, seed) {
3951
+ let result = [];
3952
+ let resultSeedPair = fn.call(this, seed);
3953
+ while (resultSeedPair && resultSeedPair.length) {
3954
+ result[result.length] = resultSeedPair[0];
3955
+ resultSeedPair = fn.call(this, resultSeedPair[1]);
3956
+ }
3957
+ return result;
3958
+ }
3959
+ ;// ./src/ramda/0.js
3960
+
3961
+
3962
+
3963
+
3964
+
3965
+ ;// ./src/structures/erectObject.js
3966
+
3967
+
3968
+
3969
+ /**
3970
+ * 从扁平化的数据集构建嵌套的 JavaScript 对象。
3971
+ *
3972
+ * @param {[ (string | number)[], any ][]} entries - 扁平化的键值对数组。
3973
+ * 每个键值对的格式为 `[keyPath, value]`,其中 `keyPath` 是一个表示嵌套路径的数组。
3974
+ * @returns {object | any[]} - 返回嵌套的 JavaScript 对象或数组。
3975
+ */
3976
+ function erectObject(entries) {
3977
+ // 排序以便分组,排序后不需要再次排序
3978
+ const flatEntries = entryComparer.sort(entries);
3979
+ return tojs(flatEntries);
3980
+ }
3981
+ ;// ./src/structures/0.js
3982
+
3983
+
3984
+
3985
+
3986
+ ;// ./src/unquoted-json/stringifyKey.js
3987
+ /**
3988
+ * 将键名字符串化,必要时加引号(如包含特殊字符或空字符串)。
3989
+ *
3990
+ * @public
3991
+ * @param {string} x - 要处理的键名
3992
+ * @returns {string} 处理后的键名
3993
+ */
3994
+ const stringifyKey = x => {
3995
+ if (x === "" || /(^\u0020)|[,:{}[\]"\u0000-\u001F\u007F]|(\u0020$)/.test(x)) return JSON.stringify(x);else return x;
3996
+ };
3997
+ ;// ./src/unquoted-json/stringifyStringValue.js
3998
+
3999
+
4000
+ /**
4001
+ * 将字符串值序列化为 JSON 字符串,必要时加引号(如布尔/null/数字字面量或特殊字符)。
4002
+ *
4003
+ * @public
4004
+ * @param {string} x - 要处理的字符串值
4005
+ * @returns {string} 处理后的字符串
4006
+ */
4007
+ const stringifyStringValue = x => {
4008
+ if (x === "true" || x === "false" || x === "null") return JSON.stringify(x);else if (/^[-+]?\d+(\.\d+)?([eE][-+]?\d+)?$/.test(x)) return JSON.stringify(x);else return stringifyKey(x);
4009
+ };
4010
+ ;// ./src/unquoted-json/unquotedJsonStringify.js
4011
+
4012
+
4013
+
4014
+ /**
4015
+ * 将任意 JS 值序列化为“无引号 JSON”字符串(仅对键名和部分字符串值去引号)。
4016
+ *
4017
+ * @public
4018
+ * @param {*} value - 要序列化的值
4019
+ * @returns {string} 序列化后的字符串
4020
+ */
4021
+ function unquotedJsonStringify(value) {
4022
+ if (value === null) {
4023
+ return 'null';
4024
+ } else if (typeof value === 'string') {
4025
+ return stringifyStringValue(value);
4026
+ } else if (typeof value === 'number') {
4027
+ return isFinite(value) ? value.toString() : 'null';
4028
+ } else if (typeof value === 'boolean') {
4029
+ return value ? 'true' : 'false';
4030
+ } else if (typeof value === 'bigint') {
4031
+ return value.toString();
4032
+ } else if (Array.isArray(value)) {
4033
+ let elems = value.map(e => unquotedJsonStringify(e)).join(',');
4034
+ return '[' + elems + ']';
4035
+ } else if (typeof value === 'object') {
4036
+ let fields = Object.entries(value).map(([k, v]) => stringifyKey(k) + ':' + unquotedJsonStringify(v)).join(',');
4037
+ return '{' + fields + '}';
4038
+ } else if (typeof value === 'undefined') {
4039
+ return 'null';
4040
+ } else if (typeof value === 'function') {
4041
+ return 'null';
4042
+ } else if (typeof value === 'symbol') {
4043
+ return 'null';
4044
+ } else {
4045
+ return 'null';
4046
+ }
4047
+ }
4048
+ ;// ./src/unquoted-json/queryStringify.js
4049
+
4050
+
4051
+ /**
4052
+ * 将对象序列化为 URL 查询字符串(支持嵌套对象和多类型字段)。
4053
+ *
4054
+ * @public
4055
+ * @param {Object} data - 要序列化的对象
4056
+ * @returns {string} 查询字符串(如 "?a=1&b=2"),无有效字段时返回空字符串
4057
+ */
4058
+ function queryStringify(data) {
4059
+ if (!isPlainObject(data)) {
4060
+ throw new Error("input should be a plain object.");
4061
+ }
4062
+ let pairs = Object.entries(data).filter(([k, v]) => supportedDataTypes.has(typeof v) && v !== '');
4063
+ if (pairs.length === 0) {
4064
+ return '';
4065
+ }
4066
+
4067
+ // 如果字段是对象,包括数组,则序列化字段值,否则不变。
4068
+ return pairs.map(([k, v]) => {
4069
+ let vv = typeof v === 'object' ? unquotedJsonStringify(v) : String(v);
4070
+ return queryStringify_escape(k) + '=' + queryStringify_escape(vv);
4071
+ }).join('&');
4072
+ }
4073
+ const supportedDataTypes = new Set(['string', 'number', 'boolean', 'bigint',
4074
+ // 'function',
4075
+ // 'symbol',
4076
+ // 'undefined',
4077
+ 'object']);
4078
+
4079
+ /**
4080
+ * 需要编码的ASCII字符及其百分比编码(键为字符本身,用\x或可打印形式)
4081
+ * @type {Map<string, string>}
4082
+ */
4083
+ const mp = new Map([['\x00', '%00'], ['\x01', '%01'], ['\x02', '%02'], ['\x03', '%03'], ['\x04', '%04'], ['\x05', '%05'], ['\x06', '%06'], ['\x07', '%07'], ['\x08', '%08'], ['\t', '%09'], ['\n', '%0A'], ['\x0B', '%0B'], ['\x0C', '%0C'], ['\r', '%0D'], ['\x0E', '%0E'], ['\x0F', '%0F'], ['\x10', '%10'], ['\x11', '%11'], ['\x12', '%12'], ['\x13', '%13'], ['\x14', '%14'], ['\x15', '%15'], ['\x16', '%16'], ['\x17', '%17'], ['\x18', '%18'], ['\x19', '%19'], ['\x1A', '%1A'], ['\x1B', '%1B'], ['\x1C', '%1C'], ['\x1D', '%1D'], ['\x1E', '%1E'], ['\x1F', '%1F'], ['\x20', '%20'], ['#', '%23'], ['%', '%25'],
4084
+ //浏览器能识别不是%dd格式的百分号为原义,这里冗余转义为了保险起见。
4085
+ ['&', '%26'], ['+', '%2B'],
4086
+ // 原义+有时候会被解析为空格
4087
+ ['=', '%3D'], ['\x7F', '%7F'] // DEL
4088
+ ]);
4089
+
4090
+ /**
4091
+ * 这是最小的转义函数,其他一概保持原义。
4092
+ * @param {string} str
4093
+ * @returns {string}
4094
+ */
4095
+ const queryStringify_escape = str => str.replace(/[\x00-\x20#%&+=\x7F]/g, c => mp.get(c) || c);
4096
+ ;// ./src/unquoted-json/0.js
4097
+
4098
+
4099
+ ;// ./src/index.js
4100
+
4101
+
4102
+
4103
+
4104
+
4105
+
4106
+
4107
+
4108
+
4109
+
4110
+
4111
+
4112
+ module.exports = __webpack_exports__;
4113
+ /******/ })()
4114
+ ;