@hkdigital/lib-core 0.5.40 → 0.5.42
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/logging/internal/test-errors.js +1 -1
- package/dist/network/http/http-status-codes.d.ts +3 -0
- package/dist/network/http/http-status-codes.js +3 -0
- package/dist/network/http.d.ts +5 -3
- package/dist/network/http.js +6 -4
- package/dist/ui/components/drag-drop/Draggable.svelte +8 -8
- package/dist/util/unique/index.d.ts +10 -3
- package/dist/util/unique/index.js +26 -7
- package/package.json +1 -1
- package/dist/network/http/index.d.ts +0 -6
- package/dist/network/http/index.js +0 -22
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as expect from '../../util/expect.js';
|
|
2
2
|
import { rethrow } from '../../util/exceptions.js';
|
|
3
3
|
import { HkPromise } from '../../generic/promises.js';
|
|
4
|
-
import { httpGet } from '../../network/http
|
|
4
|
+
import { httpGet } from '../../network/http.js';
|
|
5
5
|
import { v } from '../../valibot/valibot.js';
|
|
6
6
|
import { error } from '@sveltejs/kit';
|
|
7
7
|
|
package/dist/network/http.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
export * from "./http/
|
|
1
|
+
export * from "./http/caching.js";
|
|
2
2
|
export * from "./http/errors.js";
|
|
3
|
-
export * from "./http/
|
|
4
|
-
export * from "./http/response.js";
|
|
3
|
+
export * from "./http/headers.js";
|
|
5
4
|
export * from "./http/http-request.js";
|
|
5
|
+
export * from "./http/http-status-codes.js";
|
|
6
6
|
export * from "./http/json-request.js";
|
|
7
|
+
export * from "./http/response.js";
|
|
8
|
+
export * from "./http/url.js";
|
package/dist/network/http.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
export * from './http/
|
|
1
|
+
export * from './http/caching.js';
|
|
2
2
|
export * from './http/errors.js';
|
|
3
|
-
export * from './http/
|
|
4
|
-
export * from './http/response.js';
|
|
3
|
+
export * from './http/headers.js';
|
|
5
4
|
export * from './http/http-request.js';
|
|
6
|
-
export * from './http/
|
|
5
|
+
export * from './http/http-status-codes.js';
|
|
6
|
+
export * from './http/json-request.js';
|
|
7
|
+
export * from './http/response.js';
|
|
8
|
+
export * from './http/url.js';
|
|
@@ -162,13 +162,13 @@
|
|
|
162
162
|
* @param {DragEvent} event
|
|
163
163
|
*/
|
|
164
164
|
function handleDragStart(event) {
|
|
165
|
-
console.debug('handleDragStart called', {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
});
|
|
165
|
+
// console.debug('handleDragStart called', {
|
|
166
|
+
// target: event.target,
|
|
167
|
+
// currentTarget: event.currentTarget,
|
|
168
|
+
// disabled,
|
|
169
|
+
// canDrag: canDrag(item),
|
|
170
|
+
// dataTransfer: !!event.dataTransfer
|
|
171
|
+
// });
|
|
172
172
|
|
|
173
173
|
if (disabled || !canDrag(item)) {
|
|
174
174
|
console.debug('Drag prevented: disabled or cannot drag');
|
|
@@ -189,7 +189,7 @@
|
|
|
189
189
|
return;
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
console.debug('Starting drag operation');
|
|
192
|
+
// console.debug('Starting drag operation');
|
|
193
193
|
currentState = DRAGGING;
|
|
194
194
|
startDrag(event);
|
|
195
195
|
}
|
|
@@ -69,18 +69,25 @@ export function generateOrGetInstanceId(randomSize?: number, reset?: boolean): s
|
|
|
69
69
|
* @param {number} [timeMs]
|
|
70
70
|
* Custom time value to be used instead of Date.now()
|
|
71
71
|
*
|
|
72
|
-
* @returns {string}
|
|
72
|
+
* @returns {string}
|
|
73
|
+
* Global id (max 39 chars: 1 length prefix + 23 instance + 15 local)
|
|
73
74
|
*/
|
|
74
75
|
export function generateGlobalId(timeMs?: number): string;
|
|
75
76
|
/**
|
|
76
77
|
* Generates and returns a new unique local id
|
|
77
|
-
* - The generated id is
|
|
78
|
+
* - The generated id is guaranteed to be unique on the currently running
|
|
78
79
|
* local system
|
|
80
|
+
* - Format: <boot-prefix><length-indicator><time-based><count-based>
|
|
81
|
+
* - Boot prefix provides uniqueness across process restarts
|
|
82
|
+
* - Time-based component changes every 30 seconds
|
|
83
|
+
* - Counter resets every 30 seconds (656M IDs per 30s window = 5 chars)
|
|
84
|
+
* - Optimized for high-frequency generation (thousands per second)
|
|
79
85
|
*
|
|
80
86
|
* @param {number} [timeMs]
|
|
81
87
|
* Custom time value to be used instead of Date.now()
|
|
82
88
|
*
|
|
83
|
-
* @returns {string}
|
|
89
|
+
* @returns {string}
|
|
90
|
+
* Local id (max 15 chars: 3 boot prefix + 1 length + 6 time + 5 count)
|
|
84
91
|
*/
|
|
85
92
|
export function generateLocalId(timeMs?: number): string;
|
|
86
93
|
/**
|
|
@@ -141,8 +141,8 @@ export function generateClientSessionId() {
|
|
|
141
141
|
*/
|
|
142
142
|
export function generateOrGetInstanceId(randomSize = 16, reset = false) {
|
|
143
143
|
if (!vars.instanceId || reset) {
|
|
144
|
-
const timeBasedPart = getTimeBasedNumber30sBase58();
|
|
145
|
-
const lengthPrefix = base58fromNumber(timeBasedPart.length);
|
|
144
|
+
const timeBasedPart = getTimeBasedNumber30sBase58(); // max 6 chars
|
|
145
|
+
const lengthPrefix = base58fromNumber(timeBasedPart.length); // 1 char
|
|
146
146
|
|
|
147
147
|
vars.instanceId =
|
|
148
148
|
lengthPrefix +
|
|
@@ -166,25 +166,35 @@ export function generateOrGetInstanceId(randomSize = 16, reset = false) {
|
|
|
166
166
|
* @param {number} [timeMs]
|
|
167
167
|
* Custom time value to be used instead of Date.now()
|
|
168
168
|
*
|
|
169
|
-
* @returns {string}
|
|
169
|
+
* @returns {string}
|
|
170
|
+
* Global id (max 39 chars: 1 length prefix + 23 instance + 15 local)
|
|
170
171
|
*/
|
|
171
172
|
export function generateGlobalId(timeMs) {
|
|
172
|
-
const instanceId = generateOrGetInstanceId();
|
|
173
|
-
const localId = generateLocalId(timeMs);
|
|
173
|
+
const instanceId = generateOrGetInstanceId(); // max 1 + 6 + 16 = 23 chars
|
|
174
|
+
const localId = generateLocalId(timeMs); // max 15 chars
|
|
175
|
+
|
|
176
|
+
// Max 1 char (23 + 15 = 38)
|
|
174
177
|
const lengthPrefix = base58fromNumber(instanceId.length + localId.length);
|
|
175
178
|
|
|
179
|
+
// Max 39 chars (1 + 23 + 15 = 39)
|
|
176
180
|
return lengthPrefix + instanceId + localId;
|
|
177
181
|
}
|
|
178
182
|
|
|
179
183
|
/**
|
|
180
184
|
* Generates and returns a new unique local id
|
|
181
|
-
* - The generated id is
|
|
185
|
+
* - The generated id is guaranteed to be unique on the currently running
|
|
182
186
|
* local system
|
|
187
|
+
* - Format: <boot-prefix><length-indicator><time-based><count-based>
|
|
188
|
+
* - Boot prefix provides uniqueness across process restarts
|
|
189
|
+
* - Time-based component changes every 30 seconds
|
|
190
|
+
* - Counter resets every 30 seconds (656M IDs per 30s window = 5 chars)
|
|
191
|
+
* - Optimized for high-frequency generation (thousands per second)
|
|
183
192
|
*
|
|
184
193
|
* @param {number} [timeMs]
|
|
185
194
|
* Custom time value to be used instead of Date.now()
|
|
186
195
|
*
|
|
187
|
-
* @returns {string}
|
|
196
|
+
* @returns {string}
|
|
197
|
+
* Local id (max 15 chars: 3 boot prefix + 1 length + 6 time + 5 count)
|
|
188
198
|
*/
|
|
189
199
|
export function generateLocalId(timeMs) {
|
|
190
200
|
const timeBasedNumber = getTimeBasedNumber30s(timeMs);
|
|
@@ -222,6 +232,15 @@ export function generateLocalId(timeMs) {
|
|
|
222
232
|
//
|
|
223
233
|
// @note ALPHABET_BASE_58 is used because it is faster than
|
|
224
234
|
// base58fromNumber for single character encoding
|
|
235
|
+
|
|
236
|
+
//
|
|
237
|
+
// bootTimePrefix => 3 chars
|
|
238
|
+
// ALPHABET_BASE_58[timeBasedValue58.length] => 1 char
|
|
239
|
+
// timeBasedValue58 => max 6 chars
|
|
240
|
+
// countBasedValue58 => max 5 chars
|
|
241
|
+
// (resets every 30 seconds => 58^5 = 656.356.768)
|
|
242
|
+
//
|
|
243
|
+
// Realistic max length: 3 + 1 + 6 + 5 = 15 chars
|
|
225
244
|
//
|
|
226
245
|
const id =
|
|
227
246
|
// idFormatPrefix
|
package/package.json
CHANGED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// import * as expect from '../expect/index.js';
|
|
2
|
-
|
|
3
|
-
// import {
|
|
4
|
-
// ResponseError,
|
|
5
|
-
// AbortError,
|
|
6
|
-
// TimeoutError,
|
|
7
|
-
// TypeOrValueError
|
|
8
|
-
// } from '../../errors/index.js';
|
|
9
|
-
|
|
10
|
-
// import { setRequestHeaders } from './headers.js';
|
|
11
|
-
// import { getErrorFromResponse } from './errors.js';
|
|
12
|
-
|
|
13
|
-
export * from './headers.js';
|
|
14
|
-
export * from './errors.js';
|
|
15
|
-
export * from './url.js';
|
|
16
|
-
export * from './response.js';
|
|
17
|
-
export * from './http-request.js';
|
|
18
|
-
export * from './json-request.js';
|
|
19
|
-
|
|
20
|
-
// import { CONTENT_TYPE, METHOD_GET, METHOD_POST } from '../../constants/http.js';
|
|
21
|
-
|
|
22
|
-
// import { APPLICATION_JSON } from '../../constants/mime.js';
|