@ktjs/shared 0.22.5 → 0.22.7
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 +9 -3
- package/dist/index.iife.js +34 -18
- package/dist/index.legacy.js +34 -18
- package/dist/index.mjs +31 -18
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -40,6 +40,8 @@ declare const $isThenable: (o: any) => o is Promise<any>;
|
|
|
40
40
|
*/
|
|
41
41
|
declare const $throw: (message: string) => never;
|
|
42
42
|
declare const $warn: (message: string) => void;
|
|
43
|
+
declare const $error: (message: string) => void;
|
|
44
|
+
declare const $debug: (message: string) => void;
|
|
43
45
|
|
|
44
46
|
type otherstring = string & {};
|
|
45
47
|
|
|
@@ -107,7 +109,11 @@ type ChangeTriggerField = 'value' | 'checked' | 'selected' | 'valueAsDate' | 'va
|
|
|
107
109
|
|
|
108
110
|
type InputElementTag = 'input' | 'select' | 'textarea';
|
|
109
111
|
|
|
110
|
-
declare const $isNode: (x: any) =>
|
|
112
|
+
declare const $isNode: (x: any) => x is ChildNode;
|
|
113
|
+
/**
|
|
114
|
+
* Safe replace `oldNode` With `newNode`
|
|
115
|
+
*/
|
|
116
|
+
declare const $replaceNode: (oldNode: unknown, newNode: unknown) => void;
|
|
111
117
|
/**
|
|
112
118
|
* & Remove `bind` because it is shockingly slower than wrapper
|
|
113
119
|
* & `window.document` is safe because it is not configurable and its setter is undefined
|
|
@@ -119,7 +125,6 @@ declare const $buttonDisabledGetter: () => any;
|
|
|
119
125
|
declare const $buttonDisabledSetter: (v: any) => void;
|
|
120
126
|
declare const parseStyle: (style: string | Partial<CSSStyleDeclaration> | undefined) => string;
|
|
121
127
|
type ChangeHandler<T = string> = (value: T, ...args: any[]) => void;
|
|
122
|
-
declare const generateHandler: <T = string>(props: any, key: string) => ChangeHandler<T>;
|
|
123
128
|
/**
|
|
124
129
|
* Used for `k-model`
|
|
125
130
|
*/
|
|
@@ -132,6 +137,7 @@ declare const applyModel: (element: HTMLElementTagNameMap[InputElementTag], valu
|
|
|
132
137
|
* Default empty function
|
|
133
138
|
*/
|
|
134
139
|
declare const $emptyFn: (...args: any[]) => any;
|
|
140
|
+
declare const $isSame: (a: unknown, b: unknown) => boolean;
|
|
135
141
|
|
|
136
142
|
/**
|
|
137
143
|
* Normalize path by joining parts and ensuring leading slash
|
|
@@ -156,5 +162,5 @@ declare const emplaceParams: (path: string, params: Record<string, string>) => s
|
|
|
156
162
|
*/
|
|
157
163
|
declare const extractParams: (pattern: string, path: string) => Record<string, string> | null;
|
|
158
164
|
|
|
159
|
-
export { $ArrayFrom, $append, $appendChild, $assign, $buttonDisabledGetter, $buttonDisabledSetter, $define, $defines, $emptyFn, $entries, $hasOwn, $is, $isArray, $isNode, $isThenable, $keys, $random, $throw, $toString, $warn, DIRV_TYPE, MATHML_ATTR_FLAG, SVG_ATTR_FLAG, applyModel, buildQuery, emplaceParams, extractParams,
|
|
165
|
+
export { $ArrayFrom, $append, $appendChild, $assign, $buttonDisabledGetter, $buttonDisabledSetter, $debug, $define, $defines, $emptyFn, $entries, $error, $hasOwn, $is, $isArray, $isNode, $isSame, $isThenable, $keys, $random, $replaceNode, $throw, $toString, $warn, DIRV_TYPE, MATHML_ATTR_FLAG, SVG_ATTR_FLAG, applyModel, buildQuery, emplaceParams, extractParams, normalizePath, parseQuery, parseStyle };
|
|
160
166
|
export type { ChangeHandler, ChangeTriggerField, HTMLTag, InputElementTag, MathMLTag, NoTextNodeTag, NonSpecialTags, SVGTag, otherstring };
|
package/dist/index.iife.js
CHANGED
|
@@ -41,16 +41,27 @@ var __ktjs_shared__ = (function (exports) {
|
|
|
41
41
|
const $warn = (message) => {
|
|
42
42
|
console.warn('[kt.js warn] ' + message);
|
|
43
43
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
const $error = (message) => {
|
|
45
|
+
console.error('[kt.js error] ' + message);
|
|
46
|
+
};
|
|
47
|
+
const $debug = (message) => {
|
|
48
|
+
console.debug('[kt.js debug] ' + message);
|
|
49
|
+
};
|
|
50
50
|
|
|
51
51
|
// DOM manipulation utilities
|
|
52
52
|
// # dom natives
|
|
53
53
|
const $isNode = (x) => x?.nodeType > 0;
|
|
54
|
+
/**
|
|
55
|
+
* Safe replace `oldNode` With `newNode`
|
|
56
|
+
*/
|
|
57
|
+
const $replaceNode = (oldNode, newNode) => {
|
|
58
|
+
if ($isNode(oldNode) && $isNode(newNode)) {
|
|
59
|
+
if (newNode.contains(oldNode)) {
|
|
60
|
+
newNode.remove();
|
|
61
|
+
}
|
|
62
|
+
oldNode.replaceWith(newNode);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
54
65
|
/**
|
|
55
66
|
* & Remove `bind` because it is shockingly slower than wrapper
|
|
56
67
|
* & `window.document` is safe because it is not configurable and its setter is undefined
|
|
@@ -103,16 +114,6 @@ var __ktjs_shared__ = (function (exports) {
|
|
|
103
114
|
}
|
|
104
115
|
return '';
|
|
105
116
|
};
|
|
106
|
-
const generateHandler = (props, key) => {
|
|
107
|
-
const handler = props[key];
|
|
108
|
-
if (typeof handler === 'function') {
|
|
109
|
-
return handler;
|
|
110
|
-
}
|
|
111
|
-
else if (handler && typeof handler === 'object' && handler.isKT) {
|
|
112
|
-
return (value) => (handler.value = value);
|
|
113
|
-
}
|
|
114
|
-
return $emptyFn;
|
|
115
|
-
};
|
|
116
117
|
/**
|
|
117
118
|
* Used for `k-model`
|
|
118
119
|
*/
|
|
@@ -122,6 +123,18 @@ var __ktjs_shared__ = (function (exports) {
|
|
|
122
123
|
element.addEventListener(eventName, () => (valueRef.value = element[propName]));
|
|
123
124
|
};
|
|
124
125
|
|
|
126
|
+
// String manipulation utilities
|
|
127
|
+
/**
|
|
128
|
+
* Default empty function
|
|
129
|
+
*/
|
|
130
|
+
const $emptyFn = (() => true);
|
|
131
|
+
const $isSame = (a, b) => {
|
|
132
|
+
if ($isArray(a)) {
|
|
133
|
+
return true; // always trigger an array
|
|
134
|
+
}
|
|
135
|
+
return $is(a, b);
|
|
136
|
+
};
|
|
137
|
+
|
|
125
138
|
/**
|
|
126
139
|
* Normalize path by joining parts and ensuring leading slash
|
|
127
140
|
*/
|
|
@@ -202,7 +215,7 @@ var __ktjs_shared__ = (function (exports) {
|
|
|
202
215
|
}
|
|
203
216
|
|
|
204
217
|
// Shared utilities and cached native methods for kt.js framework
|
|
205
|
-
Object.defineProperty(window, '__ktjs__', { value: '0.22.
|
|
218
|
+
Object.defineProperty(window, '__ktjs__', { value: '0.22.7' });
|
|
206
219
|
|
|
207
220
|
exports.$ArrayFrom = $ArrayFrom;
|
|
208
221
|
exports.$append = $append;
|
|
@@ -210,17 +223,21 @@ var __ktjs_shared__ = (function (exports) {
|
|
|
210
223
|
exports.$assign = $assign;
|
|
211
224
|
exports.$buttonDisabledGetter = $buttonDisabledGetter;
|
|
212
225
|
exports.$buttonDisabledSetter = $buttonDisabledSetter;
|
|
226
|
+
exports.$debug = $debug;
|
|
213
227
|
exports.$define = $define;
|
|
214
228
|
exports.$defines = $defines;
|
|
215
229
|
exports.$emptyFn = $emptyFn;
|
|
216
230
|
exports.$entries = $entries;
|
|
231
|
+
exports.$error = $error;
|
|
217
232
|
exports.$hasOwn = $hasOwn;
|
|
218
233
|
exports.$is = $is;
|
|
219
234
|
exports.$isArray = $isArray;
|
|
220
235
|
exports.$isNode = $isNode;
|
|
236
|
+
exports.$isSame = $isSame;
|
|
221
237
|
exports.$isThenable = $isThenable;
|
|
222
238
|
exports.$keys = $keys;
|
|
223
239
|
exports.$random = $random;
|
|
240
|
+
exports.$replaceNode = $replaceNode;
|
|
224
241
|
exports.$throw = $throw;
|
|
225
242
|
exports.$toString = $toString;
|
|
226
243
|
exports.$warn = $warn;
|
|
@@ -231,7 +248,6 @@ var __ktjs_shared__ = (function (exports) {
|
|
|
231
248
|
exports.buildQuery = buildQuery;
|
|
232
249
|
exports.emplaceParams = emplaceParams;
|
|
233
250
|
exports.extractParams = extractParams;
|
|
234
|
-
exports.generateHandler = generateHandler;
|
|
235
251
|
exports.normalizePath = normalizePath;
|
|
236
252
|
exports.parseQuery = parseQuery;
|
|
237
253
|
exports.parseStyle = parseStyle;
|
package/dist/index.legacy.js
CHANGED
|
@@ -41,17 +41,28 @@ var __ktjs_shared__ = (function (exports) {
|
|
|
41
41
|
var $warn = function (message) {
|
|
42
42
|
console.warn('[kt.js warn] ' + message);
|
|
43
43
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
var $error = function (message) {
|
|
45
|
+
console.error('[kt.js error] ' + message);
|
|
46
|
+
};
|
|
47
|
+
var $debug = function (message) {
|
|
48
|
+
console.debug('[kt.js debug] ' + message);
|
|
49
|
+
};
|
|
50
50
|
|
|
51
51
|
// DOM manipulation utilities
|
|
52
52
|
var _a;
|
|
53
53
|
// # dom natives
|
|
54
54
|
var $isNode = function (x) { return (x === null || x === void 0 ? void 0 : x.nodeType) > 0; };
|
|
55
|
+
/**
|
|
56
|
+
* Safe replace `oldNode` With `newNode`
|
|
57
|
+
*/
|
|
58
|
+
var $replaceNode = function (oldNode, newNode) {
|
|
59
|
+
if ($isNode(oldNode) && $isNode(newNode)) {
|
|
60
|
+
if (newNode.contains(oldNode)) {
|
|
61
|
+
newNode.remove();
|
|
62
|
+
}
|
|
63
|
+
oldNode.replaceWith(newNode);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
55
66
|
/**
|
|
56
67
|
* & Remove `bind` because it is shockingly slower than wrapper
|
|
57
68
|
* & `window.document` is safe because it is not configurable and its setter is undefined
|
|
@@ -109,16 +120,6 @@ var __ktjs_shared__ = (function (exports) {
|
|
|
109
120
|
}
|
|
110
121
|
return '';
|
|
111
122
|
};
|
|
112
|
-
var generateHandler = function (props, key) {
|
|
113
|
-
var handler = props[key];
|
|
114
|
-
if (typeof handler === 'function') {
|
|
115
|
-
return handler;
|
|
116
|
-
}
|
|
117
|
-
else if (handler && typeof handler === 'object' && handler.isKT) {
|
|
118
|
-
return function (value) { return (handler.value = value); };
|
|
119
|
-
}
|
|
120
|
-
return $emptyFn;
|
|
121
|
-
};
|
|
122
123
|
/**
|
|
123
124
|
* Used for `k-model`
|
|
124
125
|
*/
|
|
@@ -128,6 +129,18 @@ var __ktjs_shared__ = (function (exports) {
|
|
|
128
129
|
element.addEventListener(eventName, function () { return (valueRef.value = element[propName]); });
|
|
129
130
|
};
|
|
130
131
|
|
|
132
|
+
// String manipulation utilities
|
|
133
|
+
/**
|
|
134
|
+
* Default empty function
|
|
135
|
+
*/
|
|
136
|
+
var $emptyFn = (function () { return true; });
|
|
137
|
+
var $isSame = function (a, b) {
|
|
138
|
+
if ($isArray(a)) {
|
|
139
|
+
return true; // always trigger an array
|
|
140
|
+
}
|
|
141
|
+
return $is(a, b);
|
|
142
|
+
};
|
|
143
|
+
|
|
131
144
|
/**
|
|
132
145
|
* Normalize path by joining parts and ensuring leading slash
|
|
133
146
|
*/
|
|
@@ -213,7 +226,7 @@ var __ktjs_shared__ = (function (exports) {
|
|
|
213
226
|
}
|
|
214
227
|
|
|
215
228
|
// Shared utilities and cached native methods for kt.js framework
|
|
216
|
-
Object.defineProperty(window, '__ktjs__', { value: '0.22.
|
|
229
|
+
Object.defineProperty(window, '__ktjs__', { value: '0.22.7' });
|
|
217
230
|
|
|
218
231
|
exports.$ArrayFrom = $ArrayFrom;
|
|
219
232
|
exports.$append = $append;
|
|
@@ -221,17 +234,21 @@ var __ktjs_shared__ = (function (exports) {
|
|
|
221
234
|
exports.$assign = $assign;
|
|
222
235
|
exports.$buttonDisabledGetter = $buttonDisabledGetter;
|
|
223
236
|
exports.$buttonDisabledSetter = $buttonDisabledSetter;
|
|
237
|
+
exports.$debug = $debug;
|
|
224
238
|
exports.$define = $define;
|
|
225
239
|
exports.$defines = $defines;
|
|
226
240
|
exports.$emptyFn = $emptyFn;
|
|
227
241
|
exports.$entries = $entries;
|
|
242
|
+
exports.$error = $error;
|
|
228
243
|
exports.$hasOwn = $hasOwn;
|
|
229
244
|
exports.$is = $is;
|
|
230
245
|
exports.$isArray = $isArray;
|
|
231
246
|
exports.$isNode = $isNode;
|
|
247
|
+
exports.$isSame = $isSame;
|
|
232
248
|
exports.$isThenable = $isThenable;
|
|
233
249
|
exports.$keys = $keys;
|
|
234
250
|
exports.$random = $random;
|
|
251
|
+
exports.$replaceNode = $replaceNode;
|
|
235
252
|
exports.$throw = $throw;
|
|
236
253
|
exports.$toString = $toString;
|
|
237
254
|
exports.$warn = $warn;
|
|
@@ -242,7 +259,6 @@ var __ktjs_shared__ = (function (exports) {
|
|
|
242
259
|
exports.buildQuery = buildQuery;
|
|
243
260
|
exports.emplaceParams = emplaceParams;
|
|
244
261
|
exports.extractParams = extractParams;
|
|
245
|
-
exports.generateHandler = generateHandler;
|
|
246
262
|
exports.normalizePath = normalizePath;
|
|
247
263
|
exports.parseQuery = parseQuery;
|
|
248
264
|
exports.parseStyle = parseStyle;
|
package/dist/index.mjs
CHANGED
|
@@ -38,16 +38,27 @@ const $throw = (message) => {
|
|
|
38
38
|
const $warn = (message) => {
|
|
39
39
|
console.warn('[kt.js warn] ' + message);
|
|
40
40
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
const $error = (message) => {
|
|
42
|
+
console.error('[kt.js error] ' + message);
|
|
43
|
+
};
|
|
44
|
+
const $debug = (message) => {
|
|
45
|
+
console.debug('[kt.js debug] ' + message);
|
|
46
|
+
};
|
|
47
47
|
|
|
48
48
|
// DOM manipulation utilities
|
|
49
49
|
// # dom natives
|
|
50
50
|
const $isNode = (x) => x?.nodeType > 0;
|
|
51
|
+
/**
|
|
52
|
+
* Safe replace `oldNode` With `newNode`
|
|
53
|
+
*/
|
|
54
|
+
const $replaceNode = (oldNode, newNode) => {
|
|
55
|
+
if ($isNode(oldNode) && $isNode(newNode)) {
|
|
56
|
+
if (newNode.contains(oldNode)) {
|
|
57
|
+
newNode.remove();
|
|
58
|
+
}
|
|
59
|
+
oldNode.replaceWith(newNode);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
51
62
|
/**
|
|
52
63
|
* & Remove `bind` because it is shockingly slower than wrapper
|
|
53
64
|
* & `window.document` is safe because it is not configurable and its setter is undefined
|
|
@@ -100,16 +111,6 @@ const parseStyle = (style) => {
|
|
|
100
111
|
}
|
|
101
112
|
return '';
|
|
102
113
|
};
|
|
103
|
-
const generateHandler = (props, key) => {
|
|
104
|
-
const handler = props[key];
|
|
105
|
-
if (typeof handler === 'function') {
|
|
106
|
-
return handler;
|
|
107
|
-
}
|
|
108
|
-
else if (handler && typeof handler === 'object' && handler.isKT) {
|
|
109
|
-
return (value) => (handler.value = value);
|
|
110
|
-
}
|
|
111
|
-
return $emptyFn;
|
|
112
|
-
};
|
|
113
114
|
/**
|
|
114
115
|
* Used for `k-model`
|
|
115
116
|
*/
|
|
@@ -119,6 +120,18 @@ const applyModel = (element, valueRef, propName, eventName) => {
|
|
|
119
120
|
element.addEventListener(eventName, () => (valueRef.value = element[propName]));
|
|
120
121
|
};
|
|
121
122
|
|
|
123
|
+
// String manipulation utilities
|
|
124
|
+
/**
|
|
125
|
+
* Default empty function
|
|
126
|
+
*/
|
|
127
|
+
const $emptyFn = (() => true);
|
|
128
|
+
const $isSame = (a, b) => {
|
|
129
|
+
if ($isArray(a)) {
|
|
130
|
+
return true; // always trigger an array
|
|
131
|
+
}
|
|
132
|
+
return $is(a, b);
|
|
133
|
+
};
|
|
134
|
+
|
|
122
135
|
/**
|
|
123
136
|
* Normalize path by joining parts and ensuring leading slash
|
|
124
137
|
*/
|
|
@@ -199,6 +212,6 @@ if (typeof Symbol === 'undefined') {
|
|
|
199
212
|
}
|
|
200
213
|
|
|
201
214
|
// Shared utilities and cached native methods for kt.js framework
|
|
202
|
-
Object.defineProperty(window, '__ktjs__', { value: '0.22.
|
|
215
|
+
Object.defineProperty(window, '__ktjs__', { value: '0.22.7' });
|
|
203
216
|
|
|
204
|
-
export { $ArrayFrom, $append, $appendChild, $assign, $buttonDisabledGetter, $buttonDisabledSetter, $define, $defines, $emptyFn, $entries, $hasOwn, $is, $isArray, $isNode, $isThenable, $keys, $random, $throw, $toString, $warn, DIRV_TYPE, MATHML_ATTR_FLAG, SVG_ATTR_FLAG, applyModel, buildQuery, emplaceParams, extractParams,
|
|
217
|
+
export { $ArrayFrom, $append, $appendChild, $assign, $buttonDisabledGetter, $buttonDisabledSetter, $debug, $define, $defines, $emptyFn, $entries, $error, $hasOwn, $is, $isArray, $isNode, $isSame, $isThenable, $keys, $random, $replaceNode, $throw, $toString, $warn, DIRV_TYPE, MATHML_ATTR_FLAG, SVG_ATTR_FLAG, applyModel, buildQuery, emplaceParams, extractParams, normalizePath, parseQuery, parseStyle };
|