@ktjs/shared 0.23.10 → 0.23.11
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 +0 -14
- package/dist/index.iife.js +33 -40
- package/dist/index.legacy.js +100 -107
- package/dist/index.mjs +33 -40
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,3 @@
|
|
|
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
|
-
|
|
15
1
|
/**
|
|
16
2
|
* Mark the attribute as SVG to handle special cases during rendering.
|
|
17
3
|
*/
|
package/dist/index.iife.js
CHANGED
|
@@ -21,45 +21,6 @@ var __ktjs_shared__ = (function (exports) {
|
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
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
|
-
|
|
63
24
|
// Shared constants
|
|
64
25
|
// Empty for now - can be extended with framework-wide constants
|
|
65
26
|
/**
|
|
@@ -154,6 +115,38 @@ var __ktjs_shared__ = (function (exports) {
|
|
|
154
115
|
element.addEventListener(eventName, () => (valueRef.value = element[propName]));
|
|
155
116
|
};
|
|
156
117
|
|
|
118
|
+
// String manipulation utilities
|
|
119
|
+
/**
|
|
120
|
+
* Default empty function
|
|
121
|
+
*/
|
|
122
|
+
const $emptyFn = (() => true);
|
|
123
|
+
const $emptyArray = [];
|
|
124
|
+
const $emptyObject = Object.create(null);
|
|
125
|
+
const $isSame = (a, b) => {
|
|
126
|
+
if ($isArray(a)) {
|
|
127
|
+
return true; // always trigger an array
|
|
128
|
+
}
|
|
129
|
+
return $is(a, b);
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Safe and quick forEach implementation that works with array-like objects and handles sparse arrays.
|
|
133
|
+
*/
|
|
134
|
+
const $forEach = (array, callback) => {
|
|
135
|
+
const len = array.length;
|
|
136
|
+
for (let i = 0; i < len; i++) {
|
|
137
|
+
callback(array[i], i, array);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* Async version of $forEach that allows for asynchronous callbacks. It processes items sequentially, awaiting each callback before moving to the next.
|
|
142
|
+
*/
|
|
143
|
+
const $forEachAsync = async (array, callback) => {
|
|
144
|
+
const len = array.length;
|
|
145
|
+
for (let i = 0; i < len; i++) {
|
|
146
|
+
await callback(array[i], i, array);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
157
150
|
/**
|
|
158
151
|
* Normalize path by joining parts and ensuring leading slash
|
|
159
152
|
*/
|
|
@@ -228,7 +221,7 @@ var __ktjs_shared__ = (function (exports) {
|
|
|
228
221
|
};
|
|
229
222
|
|
|
230
223
|
// incase that symbol is not supported
|
|
231
|
-
Object.defineProperty(window, '__ktjs__', { value: '0.23.
|
|
224
|
+
Object.defineProperty(window, '__ktjs__', { value: '0.23.11' });
|
|
232
225
|
|
|
233
226
|
exports.$ArrayFrom = $ArrayFrom;
|
|
234
227
|
exports.$append = $append;
|
package/dist/index.legacy.js
CHANGED
|
@@ -21,6 +21,105 @@ var __ktjs_shared__ = (function (exports) {
|
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
// Shared constants
|
|
25
|
+
// Empty for now - can be extended with framework-wide constants
|
|
26
|
+
/**
|
|
27
|
+
* Mark the attribute as SVG to handle special cases during rendering.
|
|
28
|
+
*/
|
|
29
|
+
var SVG_ATTR_FLAG = '__kt_svg__';
|
|
30
|
+
/**
|
|
31
|
+
* Mark the attribute as MathML to handle special cases during rendering.
|
|
32
|
+
*/
|
|
33
|
+
var MATHML_ATTR_FLAG = '__kt_mathml__';
|
|
34
|
+
/**
|
|
35
|
+
* Can be if, else, else-if.
|
|
36
|
+
*/
|
|
37
|
+
var DIRV_TYPE = Symbol('kt-directive-type');
|
|
38
|
+
|
|
39
|
+
// DOM manipulation utilities
|
|
40
|
+
var _a;
|
|
41
|
+
// # dom natives
|
|
42
|
+
var $isNode = function (x) { return (x === null || x === void 0 ? void 0 : x.nodeType) > 0; };
|
|
43
|
+
/**
|
|
44
|
+
* Safe replace `oldNode` With `newNode`
|
|
45
|
+
*/
|
|
46
|
+
var $replaceNode = function (oldNode, newNode) {
|
|
47
|
+
if ($isNode(oldNode) && $isNode(newNode)) {
|
|
48
|
+
if (newNode.contains(oldNode)) {
|
|
49
|
+
newNode.remove();
|
|
50
|
+
}
|
|
51
|
+
oldNode.replaceWith(newNode);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* & Remove `bind` because it is shockingly slower than wrapper
|
|
56
|
+
* & `window.document` is safe because it is not configurable and its setter is undefined
|
|
57
|
+
*/
|
|
58
|
+
var $appendChild = HTMLElement.prototype.appendChild;
|
|
59
|
+
var originAppend = HTMLElement.prototype.append;
|
|
60
|
+
var $append = // for ie 9/10/11
|
|
61
|
+
typeof originAppend === 'function'
|
|
62
|
+
? originAppend
|
|
63
|
+
: function () {
|
|
64
|
+
var nodes = [];
|
|
65
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
66
|
+
nodes[_i] = arguments[_i];
|
|
67
|
+
}
|
|
68
|
+
if (nodes.length < 50) {
|
|
69
|
+
for (var i = 0; i < nodes.length; i++) {
|
|
70
|
+
var node = nodes[i];
|
|
71
|
+
if (typeof node === 'string') {
|
|
72
|
+
$appendChild.call(this, document.createTextNode(node));
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
$appendChild.call(this, node);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
var fragment = document.createDocumentFragment();
|
|
81
|
+
for (var i = 0; i < nodes.length; i++) {
|
|
82
|
+
var node = nodes[i];
|
|
83
|
+
if (typeof node === 'string') {
|
|
84
|
+
$appendChild.call(fragment, document.createTextNode(node));
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
$appendChild.call(fragment, node);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
$appendChild.call(this, fragment);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
var $buttonDisabledGetter = (_a = Object.getOwnPropertyDescriptor(HTMLButtonElement.prototype, 'disabled'), _a.get), $buttonDisabledSetter = _a.set;
|
|
94
|
+
var $parseStyle = function (style) {
|
|
95
|
+
if (!style) {
|
|
96
|
+
return '';
|
|
97
|
+
}
|
|
98
|
+
if (typeof style === 'string') {
|
|
99
|
+
return style;
|
|
100
|
+
}
|
|
101
|
+
if (style && typeof style === 'object') {
|
|
102
|
+
if (style.isKT) {
|
|
103
|
+
return $parseStyle(style.value);
|
|
104
|
+
}
|
|
105
|
+
return $entries(style)
|
|
106
|
+
.map(function (entry) {
|
|
107
|
+
var cssKey = entry[0].replace(/[A-Z]/g, function (m) { return "-".concat(m.toLowerCase()); });
|
|
108
|
+
return "".concat(cssKey, ":").concat(entry[1]);
|
|
109
|
+
})
|
|
110
|
+
.join(';');
|
|
111
|
+
}
|
|
112
|
+
return '';
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Used for `k-model`
|
|
116
|
+
*/
|
|
117
|
+
var $applyModel = function (element, valueRef, propName, eventName) {
|
|
118
|
+
element[propName] = valueRef.value; // initialize
|
|
119
|
+
valueRef.addOnChange(function (newValue) { return (element[propName] = newValue); });
|
|
120
|
+
element.addEventListener(eventName, function () { return (valueRef.value = element[propName]); });
|
|
121
|
+
};
|
|
122
|
+
|
|
24
123
|
/******************************************************************************
|
|
25
124
|
Copyright (c) Microsoft Corporation.
|
|
26
125
|
|
|
@@ -128,112 +227,6 @@ var __ktjs_shared__ = (function (exports) {
|
|
|
128
227
|
});
|
|
129
228
|
}); };
|
|
130
229
|
|
|
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
|
-
|
|
237
230
|
/**
|
|
238
231
|
* Normalize path by joining parts and ensuring leading slash
|
|
239
232
|
*/
|
|
@@ -313,7 +306,7 @@ var __ktjs_shared__ = (function (exports) {
|
|
|
313
306
|
};
|
|
314
307
|
|
|
315
308
|
// incase that symbol is not supported
|
|
316
|
-
Object.defineProperty(window, '__ktjs__', { value: '0.23.
|
|
309
|
+
Object.defineProperty(window, '__ktjs__', { value: '0.23.11' });
|
|
317
310
|
|
|
318
311
|
exports.$ArrayFrom = $ArrayFrom;
|
|
319
312
|
exports.$append = $append;
|
package/dist/index.mjs
CHANGED
|
@@ -18,45 +18,6 @@ if (typeof Symbol === 'undefined') {
|
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
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
|
-
|
|
60
21
|
// Shared constants
|
|
61
22
|
// Empty for now - can be extended with framework-wide constants
|
|
62
23
|
/**
|
|
@@ -151,6 +112,38 @@ const $applyModel = (element, valueRef, propName, eventName) => {
|
|
|
151
112
|
element.addEventListener(eventName, () => (valueRef.value = element[propName]));
|
|
152
113
|
};
|
|
153
114
|
|
|
115
|
+
// String manipulation utilities
|
|
116
|
+
/**
|
|
117
|
+
* Default empty function
|
|
118
|
+
*/
|
|
119
|
+
const $emptyFn = (() => true);
|
|
120
|
+
const $emptyArray = [];
|
|
121
|
+
const $emptyObject = Object.create(null);
|
|
122
|
+
const $isSame = (a, b) => {
|
|
123
|
+
if ($isArray(a)) {
|
|
124
|
+
return true; // always trigger an array
|
|
125
|
+
}
|
|
126
|
+
return $is(a, b);
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Safe and quick forEach implementation that works with array-like objects and handles sparse arrays.
|
|
130
|
+
*/
|
|
131
|
+
const $forEach = (array, callback) => {
|
|
132
|
+
const len = array.length;
|
|
133
|
+
for (let i = 0; i < len; i++) {
|
|
134
|
+
callback(array[i], i, array);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Async version of $forEach that allows for asynchronous callbacks. It processes items sequentially, awaiting each callback before moving to the next.
|
|
139
|
+
*/
|
|
140
|
+
const $forEachAsync = async (array, callback) => {
|
|
141
|
+
const len = array.length;
|
|
142
|
+
for (let i = 0; i < len; i++) {
|
|
143
|
+
await callback(array[i], i, array);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
|
|
154
147
|
/**
|
|
155
148
|
* Normalize path by joining parts and ensuring leading slash
|
|
156
149
|
*/
|
|
@@ -225,6 +218,6 @@ const extractParams = (pattern, path) => {
|
|
|
225
218
|
};
|
|
226
219
|
|
|
227
220
|
// incase that symbol is not supported
|
|
228
|
-
Object.defineProperty(window, '__ktjs__', { value: '0.23.
|
|
221
|
+
Object.defineProperty(window, '__ktjs__', { value: '0.23.11' });
|
|
229
222
|
|
|
230
223
|
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 };
|