@ktjs/shared 0.23.6 → 0.23.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +17 -1
- package/dist/index.iife.js +63 -52
- package/dist/index.legacy.js +116 -105
- package/dist/index.mjs +62 -53
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
/**
|
|
3
|
+
* Extend Comment interface to include properties for fragment handling.
|
|
4
|
+
*/
|
|
5
|
+
interface Comment {
|
|
6
|
+
kisFragmentAnchor: boolean;
|
|
7
|
+
kFragmentList: Node[];
|
|
8
|
+
kredraw: () => void;
|
|
9
|
+
kchildrenRef: {
|
|
10
|
+
value: any[];
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
1
15
|
/**
|
|
2
16
|
* Mark the attribute as SVG to handle special cases during rendering.
|
|
3
17
|
*/
|
|
@@ -128,6 +142,8 @@ declare const $applyModel: (element: HTMLElementTagNameMap[InputElementTag], val
|
|
|
128
142
|
* Default empty function
|
|
129
143
|
*/
|
|
130
144
|
declare const $emptyFn: (...args: any[]) => any;
|
|
145
|
+
declare const $emptyArray: any[];
|
|
146
|
+
declare const $emptyObject: any;
|
|
131
147
|
declare const $isSame: (a: unknown, b: unknown) => boolean;
|
|
132
148
|
/**
|
|
133
149
|
* Safe and quick forEach implementation that works with array-like objects and handles sparse arrays.
|
|
@@ -173,5 +189,5 @@ declare global {
|
|
|
173
189
|
const $debug: typeof console.debug;
|
|
174
190
|
}
|
|
175
191
|
|
|
176
|
-
export { $ArrayFrom, $append, $appendChild, $applyModel, $assign, $buttonDisabledGetter, $buttonDisabledSetter, $define, $defines, $emptyFn, $entries, $forEach, $forEachAsync, $hasOwn, $is, $isArray, $isNode, $isSame, $isThenable, $keys, $parseStyle, $random, $replaceNode, $toString, DIRV_TYPE, MATHML_ATTR_FLAG, SVG_ATTR_FLAG, buildQuery, emplaceParams, extractParams, normalizePath, parseQuery };
|
|
192
|
+
export { $ArrayFrom, $append, $appendChild, $applyModel, $assign, $buttonDisabledGetter, $buttonDisabledSetter, $define, $defines, $emptyArray, $emptyFn, $emptyObject, $entries, $forEach, $forEachAsync, $hasOwn, $is, $isArray, $isNode, $isSame, $isThenable, $keys, $parseStyle, $random, $replaceNode, $toString, DIRV_TYPE, MATHML_ATTR_FLAG, SVG_ATTR_FLAG, buildQuery, emplaceParams, extractParams, normalizePath, parseQuery };
|
|
177
193
|
export type { ChangeHandler, ChangeTriggerField, HTMLTag, InputElementTag, MathMLTag, NoTextNodeTag, NonSpecialTags, SVGTag, otherstring };
|
package/dist/index.iife.js
CHANGED
|
@@ -1,6 +1,65 @@
|
|
|
1
1
|
var __ktjs_shared__ = (function (exports) {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
+
// Cached native methods for performance optimization
|
|
5
|
+
const $isArray = Array.isArray;
|
|
6
|
+
const $ArrayFrom = Array.from;
|
|
7
|
+
const $is = Object.is;
|
|
8
|
+
const $assign = Object.assign;
|
|
9
|
+
const $hasOwn = Object.prototype.hasOwnProperty;
|
|
10
|
+
const $toString = Object.prototype.toString;
|
|
11
|
+
const $keys = Object.keys;
|
|
12
|
+
const $defines = Object.defineProperties;
|
|
13
|
+
const $define = Object.defineProperty;
|
|
14
|
+
const $entries = Object.entries;
|
|
15
|
+
const $random = Math.random;
|
|
16
|
+
const $isThenable = (o) => typeof o?.then === 'function';
|
|
17
|
+
|
|
18
|
+
if (typeof Symbol === 'undefined') {
|
|
19
|
+
window.Symbol = function Symbol(description) {
|
|
20
|
+
return `@@SYMBOL_${description || ''}_${$random().toString(36).slice(2)}`;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// String manipulation utilities
|
|
25
|
+
/**
|
|
26
|
+
* Default empty function
|
|
27
|
+
*/
|
|
28
|
+
const $emptyFn = (() => true);
|
|
29
|
+
const $emptyArray = [];
|
|
30
|
+
const $emptyObject = Object.create(null);
|
|
31
|
+
const $isSame = (a, b) => {
|
|
32
|
+
if ($isArray(a)) {
|
|
33
|
+
return true; // always trigger an array
|
|
34
|
+
}
|
|
35
|
+
return $is(a, b);
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Safe and quick forEach implementation that works with array-like objects and handles sparse arrays.
|
|
39
|
+
*/
|
|
40
|
+
const $forEach = (array, callback) => {
|
|
41
|
+
const len = array.length;
|
|
42
|
+
for (let i = 0; i < len; i++) {
|
|
43
|
+
callback(array[i], i, array);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Async version of $forEach that allows for asynchronous callbacks. It processes items sequentially, awaiting each callback before moving to the next.
|
|
48
|
+
*/
|
|
49
|
+
const $forEachAsync = async (array, callback) => {
|
|
50
|
+
const len = array.length;
|
|
51
|
+
for (let i = 0; i < len; i++) {
|
|
52
|
+
await callback(array[i], i, array);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const $emptyChildrenRef = { value: $emptyArray };
|
|
57
|
+
// each instance shares the same empty array, but it will be replaced when used
|
|
58
|
+
Comment.prototype.kisFragmentAnchor = false;
|
|
59
|
+
Comment.prototype.kFragmentList = $emptyArray;
|
|
60
|
+
Comment.prototype.kredraw = $emptyFn;
|
|
61
|
+
Comment.prototype.kchildrenRef = $emptyChildrenRef;
|
|
62
|
+
|
|
4
63
|
// Shared constants
|
|
5
64
|
// Empty for now - can be extended with framework-wide constants
|
|
6
65
|
/**
|
|
@@ -16,20 +75,6 @@ var __ktjs_shared__ = (function (exports) {
|
|
|
16
75
|
*/
|
|
17
76
|
const DIRV_TYPE = Symbol('kt-directive-type');
|
|
18
77
|
|
|
19
|
-
// Cached native methods for performance optimization
|
|
20
|
-
const $isArray = Array.isArray;
|
|
21
|
-
const $ArrayFrom = Array.from;
|
|
22
|
-
const $is = Object.is;
|
|
23
|
-
const $assign = Object.assign;
|
|
24
|
-
const $hasOwn = Object.prototype.hasOwnProperty;
|
|
25
|
-
const $toString = Object.prototype.toString;
|
|
26
|
-
const $keys = Object.keys;
|
|
27
|
-
const $defines = Object.defineProperties;
|
|
28
|
-
const $define = Object.defineProperty;
|
|
29
|
-
const $entries = Object.entries;
|
|
30
|
-
const $random = Math.random;
|
|
31
|
-
const $isThenable = (o) => typeof o?.then === 'function';
|
|
32
|
-
|
|
33
78
|
// DOM manipulation utilities
|
|
34
79
|
// # dom natives
|
|
35
80
|
const $isNode = (x) => x?.nodeType > 0;
|
|
@@ -109,36 +154,6 @@ var __ktjs_shared__ = (function (exports) {
|
|
|
109
154
|
element.addEventListener(eventName, () => (valueRef.value = element[propName]));
|
|
110
155
|
};
|
|
111
156
|
|
|
112
|
-
// String manipulation utilities
|
|
113
|
-
/**
|
|
114
|
-
* Default empty function
|
|
115
|
-
*/
|
|
116
|
-
const $emptyFn = (() => true);
|
|
117
|
-
const $isSame = (a, b) => {
|
|
118
|
-
if ($isArray(a)) {
|
|
119
|
-
return true; // always trigger an array
|
|
120
|
-
}
|
|
121
|
-
return $is(a, b);
|
|
122
|
-
};
|
|
123
|
-
/**
|
|
124
|
-
* Safe and quick forEach implementation that works with array-like objects and handles sparse arrays.
|
|
125
|
-
*/
|
|
126
|
-
const $forEach = (array, callback) => {
|
|
127
|
-
const len = array.length;
|
|
128
|
-
for (let i = 0; i < len; i++) {
|
|
129
|
-
callback(array[i], i, array);
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
/**
|
|
133
|
-
* Async version of $forEach that allows for asynchronous callbacks. It processes items sequentially, awaiting each callback before moving to the next.
|
|
134
|
-
*/
|
|
135
|
-
const $forEachAsync = async (array, callback) => {
|
|
136
|
-
const len = array.length;
|
|
137
|
-
for (let i = 0; i < len; i++) {
|
|
138
|
-
await callback(array[i], i, array);
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
|
|
142
157
|
/**
|
|
143
158
|
* Normalize path by joining parts and ensuring leading slash
|
|
144
159
|
*/
|
|
@@ -212,14 +227,8 @@ var __ktjs_shared__ = (function (exports) {
|
|
|
212
227
|
return params;
|
|
213
228
|
};
|
|
214
229
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
return `@@SYMBOL_${description || ''}_${$random().toString(36).slice(2)}`;
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
// Shared utilities and cached native methods for kt.js framework
|
|
222
|
-
Object.defineProperty(window, '__ktjs__', { value: '0.23.6' });
|
|
230
|
+
// incase that symbol is not supported
|
|
231
|
+
Object.defineProperty(window, '__ktjs__', { value: '0.23.10' });
|
|
223
232
|
|
|
224
233
|
exports.$ArrayFrom = $ArrayFrom;
|
|
225
234
|
exports.$append = $append;
|
|
@@ -230,7 +239,9 @@ var __ktjs_shared__ = (function (exports) {
|
|
|
230
239
|
exports.$buttonDisabledSetter = $buttonDisabledSetter;
|
|
231
240
|
exports.$define = $define;
|
|
232
241
|
exports.$defines = $defines;
|
|
242
|
+
exports.$emptyArray = $emptyArray;
|
|
233
243
|
exports.$emptyFn = $emptyFn;
|
|
244
|
+
exports.$emptyObject = $emptyObject;
|
|
234
245
|
exports.$entries = $entries;
|
|
235
246
|
exports.$forEach = $forEach;
|
|
236
247
|
exports.$forEachAsync = $forEachAsync;
|
package/dist/index.legacy.js
CHANGED
|
@@ -1,21 +1,6 @@
|
|
|
1
1
|
var __ktjs_shared__ = (function (exports) {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
// Shared constants
|
|
5
|
-
// Empty for now - can be extended with framework-wide constants
|
|
6
|
-
/**
|
|
7
|
-
* Mark the attribute as SVG to handle special cases during rendering.
|
|
8
|
-
*/
|
|
9
|
-
var SVG_ATTR_FLAG = '__kt_svg__';
|
|
10
|
-
/**
|
|
11
|
-
* Mark the attribute as MathML to handle special cases during rendering.
|
|
12
|
-
*/
|
|
13
|
-
var MATHML_ATTR_FLAG = '__kt_mathml__';
|
|
14
|
-
/**
|
|
15
|
-
* Can be if, else, else-if.
|
|
16
|
-
*/
|
|
17
|
-
var DIRV_TYPE = Symbol('kt-directive-type');
|
|
18
|
-
|
|
19
4
|
// Cached native methods for performance optimization
|
|
20
5
|
var $isArray = Array.isArray;
|
|
21
6
|
var $ArrayFrom = Array.from;
|
|
@@ -30,89 +15,11 @@ var __ktjs_shared__ = (function (exports) {
|
|
|
30
15
|
var $random = Math.random;
|
|
31
16
|
var $isThenable = function (o) { return typeof (o === null || o === void 0 ? void 0 : o.then) === 'function'; };
|
|
32
17
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var $isNode = function (x) { return (x === null || x === void 0 ? void 0 : x.nodeType) > 0; };
|
|
37
|
-
/**
|
|
38
|
-
* Safe replace `oldNode` With `newNode`
|
|
39
|
-
*/
|
|
40
|
-
var $replaceNode = function (oldNode, newNode) {
|
|
41
|
-
if ($isNode(oldNode) && $isNode(newNode)) {
|
|
42
|
-
if (newNode.contains(oldNode)) {
|
|
43
|
-
newNode.remove();
|
|
44
|
-
}
|
|
45
|
-
oldNode.replaceWith(newNode);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* & Remove `bind` because it is shockingly slower than wrapper
|
|
50
|
-
* & `window.document` is safe because it is not configurable and its setter is undefined
|
|
51
|
-
*/
|
|
52
|
-
var $appendChild = HTMLElement.prototype.appendChild;
|
|
53
|
-
var originAppend = HTMLElement.prototype.append;
|
|
54
|
-
var $append = // for ie 9/10/11
|
|
55
|
-
typeof originAppend === 'function'
|
|
56
|
-
? originAppend
|
|
57
|
-
: function () {
|
|
58
|
-
var nodes = [];
|
|
59
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
60
|
-
nodes[_i] = arguments[_i];
|
|
61
|
-
}
|
|
62
|
-
if (nodes.length < 50) {
|
|
63
|
-
for (var i = 0; i < nodes.length; i++) {
|
|
64
|
-
var node = nodes[i];
|
|
65
|
-
if (typeof node === 'string') {
|
|
66
|
-
$appendChild.call(this, document.createTextNode(node));
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
$appendChild.call(this, node);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
var fragment = document.createDocumentFragment();
|
|
75
|
-
for (var i = 0; i < nodes.length; i++) {
|
|
76
|
-
var node = nodes[i];
|
|
77
|
-
if (typeof node === 'string') {
|
|
78
|
-
$appendChild.call(fragment, document.createTextNode(node));
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
$appendChild.call(fragment, node);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
$appendChild.call(this, fragment);
|
|
85
|
-
}
|
|
18
|
+
if (typeof Symbol === 'undefined') {
|
|
19
|
+
window.Symbol = function Symbol(description) {
|
|
20
|
+
return "@@SYMBOL_".concat(description || '', "_").concat($random().toString(36).slice(2));
|
|
86
21
|
};
|
|
87
|
-
|
|
88
|
-
var $parseStyle = function (style) {
|
|
89
|
-
if (!style) {
|
|
90
|
-
return '';
|
|
91
|
-
}
|
|
92
|
-
if (typeof style === 'string') {
|
|
93
|
-
return style;
|
|
94
|
-
}
|
|
95
|
-
if (style && typeof style === 'object') {
|
|
96
|
-
if (style.isKT) {
|
|
97
|
-
return $parseStyle(style.value);
|
|
98
|
-
}
|
|
99
|
-
return $entries(style)
|
|
100
|
-
.map(function (entry) {
|
|
101
|
-
var cssKey = entry[0].replace(/[A-Z]/g, function (m) { return "-".concat(m.toLowerCase()); });
|
|
102
|
-
return "".concat(cssKey, ":").concat(entry[1]);
|
|
103
|
-
})
|
|
104
|
-
.join(';');
|
|
105
|
-
}
|
|
106
|
-
return '';
|
|
107
|
-
};
|
|
108
|
-
/**
|
|
109
|
-
* Used for `k-model`
|
|
110
|
-
*/
|
|
111
|
-
var $applyModel = function (element, valueRef, propName, eventName) {
|
|
112
|
-
element[propName] = valueRef.value; // initialize
|
|
113
|
-
valueRef.addOnChange(function (newValue) { return (element[propName] = newValue); });
|
|
114
|
-
element.addEventListener(eventName, function () { return (valueRef.value = element[propName]); });
|
|
115
|
-
};
|
|
22
|
+
}
|
|
116
23
|
|
|
117
24
|
/******************************************************************************
|
|
118
25
|
Copyright (c) Microsoft Corporation.
|
|
@@ -179,6 +86,8 @@ var __ktjs_shared__ = (function (exports) {
|
|
|
179
86
|
* Default empty function
|
|
180
87
|
*/
|
|
181
88
|
var $emptyFn = (function () { return true; });
|
|
89
|
+
var $emptyArray = [];
|
|
90
|
+
var $emptyObject = Object.create(null);
|
|
182
91
|
var $isSame = function (a, b) {
|
|
183
92
|
if ($isArray(a)) {
|
|
184
93
|
return true; // always trigger an array
|
|
@@ -219,6 +128,112 @@ var __ktjs_shared__ = (function (exports) {
|
|
|
219
128
|
});
|
|
220
129
|
}); };
|
|
221
130
|
|
|
131
|
+
var $emptyChildrenRef = { value: $emptyArray };
|
|
132
|
+
// each instance shares the same empty array, but it will be replaced when used
|
|
133
|
+
Comment.prototype.kisFragmentAnchor = false;
|
|
134
|
+
Comment.prototype.kFragmentList = $emptyArray;
|
|
135
|
+
Comment.prototype.kredraw = $emptyFn;
|
|
136
|
+
Comment.prototype.kchildrenRef = $emptyChildrenRef;
|
|
137
|
+
|
|
138
|
+
// Shared constants
|
|
139
|
+
// Empty for now - can be extended with framework-wide constants
|
|
140
|
+
/**
|
|
141
|
+
* Mark the attribute as SVG to handle special cases during rendering.
|
|
142
|
+
*/
|
|
143
|
+
var SVG_ATTR_FLAG = '__kt_svg__';
|
|
144
|
+
/**
|
|
145
|
+
* Mark the attribute as MathML to handle special cases during rendering.
|
|
146
|
+
*/
|
|
147
|
+
var MATHML_ATTR_FLAG = '__kt_mathml__';
|
|
148
|
+
/**
|
|
149
|
+
* Can be if, else, else-if.
|
|
150
|
+
*/
|
|
151
|
+
var DIRV_TYPE = Symbol('kt-directive-type');
|
|
152
|
+
|
|
153
|
+
// DOM manipulation utilities
|
|
154
|
+
var _a;
|
|
155
|
+
// # dom natives
|
|
156
|
+
var $isNode = function (x) { return (x === null || x === void 0 ? void 0 : x.nodeType) > 0; };
|
|
157
|
+
/**
|
|
158
|
+
* Safe replace `oldNode` With `newNode`
|
|
159
|
+
*/
|
|
160
|
+
var $replaceNode = function (oldNode, newNode) {
|
|
161
|
+
if ($isNode(oldNode) && $isNode(newNode)) {
|
|
162
|
+
if (newNode.contains(oldNode)) {
|
|
163
|
+
newNode.remove();
|
|
164
|
+
}
|
|
165
|
+
oldNode.replaceWith(newNode);
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* & Remove `bind` because it is shockingly slower than wrapper
|
|
170
|
+
* & `window.document` is safe because it is not configurable and its setter is undefined
|
|
171
|
+
*/
|
|
172
|
+
var $appendChild = HTMLElement.prototype.appendChild;
|
|
173
|
+
var originAppend = HTMLElement.prototype.append;
|
|
174
|
+
var $append = // for ie 9/10/11
|
|
175
|
+
typeof originAppend === 'function'
|
|
176
|
+
? originAppend
|
|
177
|
+
: function () {
|
|
178
|
+
var nodes = [];
|
|
179
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
180
|
+
nodes[_i] = arguments[_i];
|
|
181
|
+
}
|
|
182
|
+
if (nodes.length < 50) {
|
|
183
|
+
for (var i = 0; i < nodes.length; i++) {
|
|
184
|
+
var node = nodes[i];
|
|
185
|
+
if (typeof node === 'string') {
|
|
186
|
+
$appendChild.call(this, document.createTextNode(node));
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
$appendChild.call(this, node);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
var fragment = document.createDocumentFragment();
|
|
195
|
+
for (var i = 0; i < nodes.length; i++) {
|
|
196
|
+
var node = nodes[i];
|
|
197
|
+
if (typeof node === 'string') {
|
|
198
|
+
$appendChild.call(fragment, document.createTextNode(node));
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
$appendChild.call(fragment, node);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
$appendChild.call(this, fragment);
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
var $buttonDisabledGetter = (_a = Object.getOwnPropertyDescriptor(HTMLButtonElement.prototype, 'disabled'), _a.get), $buttonDisabledSetter = _a.set;
|
|
208
|
+
var $parseStyle = function (style) {
|
|
209
|
+
if (!style) {
|
|
210
|
+
return '';
|
|
211
|
+
}
|
|
212
|
+
if (typeof style === 'string') {
|
|
213
|
+
return style;
|
|
214
|
+
}
|
|
215
|
+
if (style && typeof style === 'object') {
|
|
216
|
+
if (style.isKT) {
|
|
217
|
+
return $parseStyle(style.value);
|
|
218
|
+
}
|
|
219
|
+
return $entries(style)
|
|
220
|
+
.map(function (entry) {
|
|
221
|
+
var cssKey = entry[0].replace(/[A-Z]/g, function (m) { return "-".concat(m.toLowerCase()); });
|
|
222
|
+
return "".concat(cssKey, ":").concat(entry[1]);
|
|
223
|
+
})
|
|
224
|
+
.join(';');
|
|
225
|
+
}
|
|
226
|
+
return '';
|
|
227
|
+
};
|
|
228
|
+
/**
|
|
229
|
+
* Used for `k-model`
|
|
230
|
+
*/
|
|
231
|
+
var $applyModel = function (element, valueRef, propName, eventName) {
|
|
232
|
+
element[propName] = valueRef.value; // initialize
|
|
233
|
+
valueRef.addOnChange(function (newValue) { return (element[propName] = newValue); });
|
|
234
|
+
element.addEventListener(eventName, function () { return (valueRef.value = element[propName]); });
|
|
235
|
+
};
|
|
236
|
+
|
|
222
237
|
/**
|
|
223
238
|
* Normalize path by joining parts and ensuring leading slash
|
|
224
239
|
*/
|
|
@@ -297,14 +312,8 @@ var __ktjs_shared__ = (function (exports) {
|
|
|
297
312
|
return params;
|
|
298
313
|
};
|
|
299
314
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
return "@@SYMBOL_".concat(description || '', "_").concat($random().toString(36).slice(2));
|
|
303
|
-
};
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
// Shared utilities and cached native methods for kt.js framework
|
|
307
|
-
Object.defineProperty(window, '__ktjs__', { value: '0.23.6' });
|
|
315
|
+
// incase that symbol is not supported
|
|
316
|
+
Object.defineProperty(window, '__ktjs__', { value: '0.23.10' });
|
|
308
317
|
|
|
309
318
|
exports.$ArrayFrom = $ArrayFrom;
|
|
310
319
|
exports.$append = $append;
|
|
@@ -315,7 +324,9 @@ var __ktjs_shared__ = (function (exports) {
|
|
|
315
324
|
exports.$buttonDisabledSetter = $buttonDisabledSetter;
|
|
316
325
|
exports.$define = $define;
|
|
317
326
|
exports.$defines = $defines;
|
|
327
|
+
exports.$emptyArray = $emptyArray;
|
|
318
328
|
exports.$emptyFn = $emptyFn;
|
|
329
|
+
exports.$emptyObject = $emptyObject;
|
|
319
330
|
exports.$entries = $entries;
|
|
320
331
|
exports.$forEach = $forEach;
|
|
321
332
|
exports.$forEachAsync = $forEachAsync;
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,62 @@
|
|
|
1
|
+
// Cached native methods for performance optimization
|
|
2
|
+
const $isArray = Array.isArray;
|
|
3
|
+
const $ArrayFrom = Array.from;
|
|
4
|
+
const $is = Object.is;
|
|
5
|
+
const $assign = Object.assign;
|
|
6
|
+
const $hasOwn = Object.prototype.hasOwnProperty;
|
|
7
|
+
const $toString = Object.prototype.toString;
|
|
8
|
+
const $keys = Object.keys;
|
|
9
|
+
const $defines = Object.defineProperties;
|
|
10
|
+
const $define = Object.defineProperty;
|
|
11
|
+
const $entries = Object.entries;
|
|
12
|
+
const $random = Math.random;
|
|
13
|
+
const $isThenable = (o) => typeof o?.then === 'function';
|
|
14
|
+
|
|
15
|
+
if (typeof Symbol === 'undefined') {
|
|
16
|
+
window.Symbol = function Symbol(description) {
|
|
17
|
+
return `@@SYMBOL_${description || ''}_${$random().toString(36).slice(2)}`;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// String manipulation utilities
|
|
22
|
+
/**
|
|
23
|
+
* Default empty function
|
|
24
|
+
*/
|
|
25
|
+
const $emptyFn = (() => true);
|
|
26
|
+
const $emptyArray = [];
|
|
27
|
+
const $emptyObject = Object.create(null);
|
|
28
|
+
const $isSame = (a, b) => {
|
|
29
|
+
if ($isArray(a)) {
|
|
30
|
+
return true; // always trigger an array
|
|
31
|
+
}
|
|
32
|
+
return $is(a, b);
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Safe and quick forEach implementation that works with array-like objects and handles sparse arrays.
|
|
36
|
+
*/
|
|
37
|
+
const $forEach = (array, callback) => {
|
|
38
|
+
const len = array.length;
|
|
39
|
+
for (let i = 0; i < len; i++) {
|
|
40
|
+
callback(array[i], i, array);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Async version of $forEach that allows for asynchronous callbacks. It processes items sequentially, awaiting each callback before moving to the next.
|
|
45
|
+
*/
|
|
46
|
+
const $forEachAsync = async (array, callback) => {
|
|
47
|
+
const len = array.length;
|
|
48
|
+
for (let i = 0; i < len; i++) {
|
|
49
|
+
await callback(array[i], i, array);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const $emptyChildrenRef = { value: $emptyArray };
|
|
54
|
+
// each instance shares the same empty array, but it will be replaced when used
|
|
55
|
+
Comment.prototype.kisFragmentAnchor = false;
|
|
56
|
+
Comment.prototype.kFragmentList = $emptyArray;
|
|
57
|
+
Comment.prototype.kredraw = $emptyFn;
|
|
58
|
+
Comment.prototype.kchildrenRef = $emptyChildrenRef;
|
|
59
|
+
|
|
1
60
|
// Shared constants
|
|
2
61
|
// Empty for now - can be extended with framework-wide constants
|
|
3
62
|
/**
|
|
@@ -13,20 +72,6 @@ const MATHML_ATTR_FLAG = '__kt_mathml__';
|
|
|
13
72
|
*/
|
|
14
73
|
const DIRV_TYPE = Symbol('kt-directive-type');
|
|
15
74
|
|
|
16
|
-
// Cached native methods for performance optimization
|
|
17
|
-
const $isArray = Array.isArray;
|
|
18
|
-
const $ArrayFrom = Array.from;
|
|
19
|
-
const $is = Object.is;
|
|
20
|
-
const $assign = Object.assign;
|
|
21
|
-
const $hasOwn = Object.prototype.hasOwnProperty;
|
|
22
|
-
const $toString = Object.prototype.toString;
|
|
23
|
-
const $keys = Object.keys;
|
|
24
|
-
const $defines = Object.defineProperties;
|
|
25
|
-
const $define = Object.defineProperty;
|
|
26
|
-
const $entries = Object.entries;
|
|
27
|
-
const $random = Math.random;
|
|
28
|
-
const $isThenable = (o) => typeof o?.then === 'function';
|
|
29
|
-
|
|
30
75
|
// DOM manipulation utilities
|
|
31
76
|
// # dom natives
|
|
32
77
|
const $isNode = (x) => x?.nodeType > 0;
|
|
@@ -106,36 +151,6 @@ const $applyModel = (element, valueRef, propName, eventName) => {
|
|
|
106
151
|
element.addEventListener(eventName, () => (valueRef.value = element[propName]));
|
|
107
152
|
};
|
|
108
153
|
|
|
109
|
-
// String manipulation utilities
|
|
110
|
-
/**
|
|
111
|
-
* Default empty function
|
|
112
|
-
*/
|
|
113
|
-
const $emptyFn = (() => true);
|
|
114
|
-
const $isSame = (a, b) => {
|
|
115
|
-
if ($isArray(a)) {
|
|
116
|
-
return true; // always trigger an array
|
|
117
|
-
}
|
|
118
|
-
return $is(a, b);
|
|
119
|
-
};
|
|
120
|
-
/**
|
|
121
|
-
* Safe and quick forEach implementation that works with array-like objects and handles sparse arrays.
|
|
122
|
-
*/
|
|
123
|
-
const $forEach = (array, callback) => {
|
|
124
|
-
const len = array.length;
|
|
125
|
-
for (let i = 0; i < len; i++) {
|
|
126
|
-
callback(array[i], i, array);
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
/**
|
|
130
|
-
* Async version of $forEach that allows for asynchronous callbacks. It processes items sequentially, awaiting each callback before moving to the next.
|
|
131
|
-
*/
|
|
132
|
-
const $forEachAsync = async (array, callback) => {
|
|
133
|
-
const len = array.length;
|
|
134
|
-
for (let i = 0; i < len; i++) {
|
|
135
|
-
await callback(array[i], i, array);
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
|
|
139
154
|
/**
|
|
140
155
|
* Normalize path by joining parts and ensuring leading slash
|
|
141
156
|
*/
|
|
@@ -209,13 +224,7 @@ const extractParams = (pattern, path) => {
|
|
|
209
224
|
return params;
|
|
210
225
|
};
|
|
211
226
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
return `@@SYMBOL_${description || ''}_${$random().toString(36).slice(2)}`;
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// Shared utilities and cached native methods for kt.js framework
|
|
219
|
-
Object.defineProperty(window, '__ktjs__', { value: '0.23.6' });
|
|
227
|
+
// incase that symbol is not supported
|
|
228
|
+
Object.defineProperty(window, '__ktjs__', { value: '0.23.10' });
|
|
220
229
|
|
|
221
|
-
export { $ArrayFrom, $append, $appendChild, $applyModel, $assign, $buttonDisabledGetter, $buttonDisabledSetter, $define, $defines, $emptyFn, $entries, $forEach, $forEachAsync, $hasOwn, $is, $isArray, $isNode, $isSame, $isThenable, $keys, $parseStyle, $random, $replaceNode, $toString, DIRV_TYPE, MATHML_ATTR_FLAG, SVG_ATTR_FLAG, buildQuery, emplaceParams, extractParams, normalizePath, parseQuery };
|
|
230
|
+
export { $ArrayFrom, $append, $appendChild, $applyModel, $assign, $buttonDisabledGetter, $buttonDisabledSetter, $define, $defines, $emptyArray, $emptyFn, $emptyObject, $entries, $forEach, $forEachAsync, $hasOwn, $is, $isArray, $isNode, $isSame, $isThenable, $keys, $parseStyle, $random, $replaceNode, $toString, DIRV_TYPE, MATHML_ATTR_FLAG, SVG_ATTR_FLAG, buildQuery, emplaceParams, extractParams, normalizePath, parseQuery };
|