@typespec/html-program-viewer 0.74.0-dev.0 → 0.74.0
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/manifest-CRrj_9sQ.js +6 -0
- package/dist/react/index.js +471 -301
- package/package.json +6 -6
- package/dist/manifest-DzlnSCzh.js +0 -6
package/dist/react/index.js
CHANGED
|
@@ -22393,44 +22393,6 @@ var uri = {};
|
|
|
22393
22393
|
|
|
22394
22394
|
var fastUri = {exports: {}};
|
|
22395
22395
|
|
|
22396
|
-
var scopedChars;
|
|
22397
|
-
var hasRequiredScopedChars;
|
|
22398
|
-
|
|
22399
|
-
function requireScopedChars () {
|
|
22400
|
-
if (hasRequiredScopedChars) return scopedChars;
|
|
22401
|
-
hasRequiredScopedChars = 1;
|
|
22402
|
-
|
|
22403
|
-
const HEX = {
|
|
22404
|
-
0: 0,
|
|
22405
|
-
1: 1,
|
|
22406
|
-
2: 2,
|
|
22407
|
-
3: 3,
|
|
22408
|
-
4: 4,
|
|
22409
|
-
5: 5,
|
|
22410
|
-
6: 6,
|
|
22411
|
-
7: 7,
|
|
22412
|
-
8: 8,
|
|
22413
|
-
9: 9,
|
|
22414
|
-
a: 10,
|
|
22415
|
-
A: 10,
|
|
22416
|
-
b: 11,
|
|
22417
|
-
B: 11,
|
|
22418
|
-
c: 12,
|
|
22419
|
-
C: 12,
|
|
22420
|
-
d: 13,
|
|
22421
|
-
D: 13,
|
|
22422
|
-
e: 14,
|
|
22423
|
-
E: 14,
|
|
22424
|
-
f: 15,
|
|
22425
|
-
F: 15
|
|
22426
|
-
};
|
|
22427
|
-
|
|
22428
|
-
scopedChars = {
|
|
22429
|
-
HEX
|
|
22430
|
-
};
|
|
22431
|
-
return scopedChars;
|
|
22432
|
-
}
|
|
22433
|
-
|
|
22434
22396
|
var utils$1;
|
|
22435
22397
|
var hasRequiredUtils;
|
|
22436
22398
|
|
|
@@ -22438,62 +22400,100 @@ function requireUtils () {
|
|
|
22438
22400
|
if (hasRequiredUtils) return utils$1;
|
|
22439
22401
|
hasRequiredUtils = 1;
|
|
22440
22402
|
|
|
22441
|
-
|
|
22403
|
+
/** @type {(value: string) => boolean} */
|
|
22404
|
+
const isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
|
|
22442
22405
|
|
|
22443
|
-
|
|
22406
|
+
/** @type {(value: string) => boolean} */
|
|
22407
|
+
const isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
|
|
22444
22408
|
|
|
22445
|
-
|
|
22446
|
-
|
|
22447
|
-
|
|
22448
|
-
|
|
22449
|
-
|
|
22450
|
-
|
|
22451
|
-
|
|
22452
|
-
|
|
22409
|
+
/**
|
|
22410
|
+
* @param {Array<string>} input
|
|
22411
|
+
* @returns {string}
|
|
22412
|
+
*/
|
|
22413
|
+
function stringArrayToHexStripped (input) {
|
|
22414
|
+
let acc = '';
|
|
22415
|
+
let code = 0;
|
|
22416
|
+
let i = 0;
|
|
22417
|
+
|
|
22418
|
+
for (i = 0; i < input.length; i++) {
|
|
22419
|
+
code = input[i].charCodeAt(0);
|
|
22420
|
+
if (code === 48) {
|
|
22421
|
+
continue
|
|
22422
|
+
}
|
|
22423
|
+
if (!((code >= 48 && code <= 57) || (code >= 65 && code <= 70) || (code >= 97 && code <= 102))) {
|
|
22424
|
+
return ''
|
|
22425
|
+
}
|
|
22426
|
+
acc += input[i];
|
|
22427
|
+
break
|
|
22428
|
+
}
|
|
22429
|
+
|
|
22430
|
+
for (i += 1; i < input.length; i++) {
|
|
22431
|
+
code = input[i].charCodeAt(0);
|
|
22432
|
+
if (!((code >= 48 && code <= 57) || (code >= 65 && code <= 70) || (code >= 97 && code <= 102))) {
|
|
22433
|
+
return ''
|
|
22434
|
+
}
|
|
22435
|
+
acc += input[i];
|
|
22453
22436
|
}
|
|
22437
|
+
return acc
|
|
22454
22438
|
}
|
|
22455
22439
|
|
|
22456
22440
|
/**
|
|
22457
|
-
* @
|
|
22458
|
-
* @
|
|
22459
|
-
* @
|
|
22441
|
+
* @typedef {Object} GetIPV6Result
|
|
22442
|
+
* @property {boolean} error - Indicates if there was an error parsing the IPv6 address.
|
|
22443
|
+
* @property {string} address - The parsed IPv6 address.
|
|
22444
|
+
* @property {string} [zone] - The zone identifier, if present.
|
|
22460
22445
|
*/
|
|
22461
|
-
|
|
22462
|
-
|
|
22463
|
-
|
|
22464
|
-
|
|
22465
|
-
|
|
22466
|
-
|
|
22467
|
-
|
|
22446
|
+
|
|
22447
|
+
/**
|
|
22448
|
+
* @param {string} value
|
|
22449
|
+
* @returns {boolean}
|
|
22450
|
+
*/
|
|
22451
|
+
const nonSimpleDomain = RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);
|
|
22452
|
+
|
|
22453
|
+
/**
|
|
22454
|
+
* @param {Array<string>} buffer
|
|
22455
|
+
* @returns {boolean}
|
|
22456
|
+
*/
|
|
22457
|
+
function consumeIsZone (buffer) {
|
|
22458
|
+
buffer.length = 0;
|
|
22459
|
+
return true
|
|
22460
|
+
}
|
|
22461
|
+
|
|
22462
|
+
/**
|
|
22463
|
+
* @param {Array<string>} buffer
|
|
22464
|
+
* @param {Array<string>} address
|
|
22465
|
+
* @param {GetIPV6Result} output
|
|
22466
|
+
* @returns {boolean}
|
|
22467
|
+
*/
|
|
22468
|
+
function consumeHextets (buffer, address, output) {
|
|
22469
|
+
if (buffer.length) {
|
|
22470
|
+
const hex = stringArrayToHexStripped(buffer);
|
|
22471
|
+
if (hex !== '') {
|
|
22472
|
+
address.push(hex);
|
|
22473
|
+
} else {
|
|
22474
|
+
output.error = true;
|
|
22475
|
+
return false
|
|
22476
|
+
}
|
|
22477
|
+
buffer.length = 0;
|
|
22468
22478
|
}
|
|
22469
|
-
|
|
22470
|
-
return acc
|
|
22479
|
+
return true
|
|
22471
22480
|
}
|
|
22472
22481
|
|
|
22482
|
+
/**
|
|
22483
|
+
* @param {string} input
|
|
22484
|
+
* @returns {GetIPV6Result}
|
|
22485
|
+
*/
|
|
22473
22486
|
function getIPV6 (input) {
|
|
22474
22487
|
let tokenCount = 0;
|
|
22475
22488
|
const output = { error: false, address: '', zone: '' };
|
|
22489
|
+
/** @type {Array<string>} */
|
|
22476
22490
|
const address = [];
|
|
22491
|
+
/** @type {Array<string>} */
|
|
22477
22492
|
const buffer = [];
|
|
22478
|
-
let isZone = false;
|
|
22479
22493
|
let endipv6Encountered = false;
|
|
22480
22494
|
let endIpv6 = false;
|
|
22481
22495
|
|
|
22482
|
-
|
|
22483
|
-
if (buffer.length) {
|
|
22484
|
-
if (isZone === false) {
|
|
22485
|
-
const hex = stringArrayToHexStripped(buffer);
|
|
22486
|
-
if (hex !== undefined) {
|
|
22487
|
-
address.push(hex);
|
|
22488
|
-
} else {
|
|
22489
|
-
output.error = true;
|
|
22490
|
-
return false
|
|
22491
|
-
}
|
|
22492
|
-
}
|
|
22493
|
-
buffer.length = 0;
|
|
22494
|
-
}
|
|
22495
|
-
return true
|
|
22496
|
-
}
|
|
22496
|
+
let consume = consumeHextets;
|
|
22497
22497
|
|
|
22498
22498
|
for (let i = 0; i < input.length; i++) {
|
|
22499
22499
|
const cursor = input[i];
|
|
@@ -22502,29 +22502,28 @@ function requireUtils () {
|
|
|
22502
22502
|
if (endipv6Encountered === true) {
|
|
22503
22503
|
endIpv6 = true;
|
|
22504
22504
|
}
|
|
22505
|
-
if (!consume()) { break }
|
|
22506
|
-
tokenCount
|
|
22507
|
-
address.push(':');
|
|
22508
|
-
if (tokenCount > 7) {
|
|
22505
|
+
if (!consume(buffer, address, output)) { break }
|
|
22506
|
+
if (++tokenCount > 7) {
|
|
22509
22507
|
// not valid
|
|
22510
22508
|
output.error = true;
|
|
22511
22509
|
break
|
|
22512
22510
|
}
|
|
22513
|
-
if (i
|
|
22511
|
+
if (i > 0 && input[i - 1] === ':') {
|
|
22514
22512
|
endipv6Encountered = true;
|
|
22515
22513
|
}
|
|
22514
|
+
address.push(':');
|
|
22516
22515
|
continue
|
|
22517
22516
|
} else if (cursor === '%') {
|
|
22518
|
-
if (!consume()) { break }
|
|
22517
|
+
if (!consume(buffer, address, output)) { break }
|
|
22519
22518
|
// switch to zone detection
|
|
22520
|
-
|
|
22519
|
+
consume = consumeIsZone;
|
|
22521
22520
|
} else {
|
|
22522
22521
|
buffer.push(cursor);
|
|
22523
22522
|
continue
|
|
22524
22523
|
}
|
|
22525
22524
|
}
|
|
22526
22525
|
if (buffer.length) {
|
|
22527
|
-
if (
|
|
22526
|
+
if (consume === consumeIsZone) {
|
|
22528
22527
|
output.zone = buffer.join('');
|
|
22529
22528
|
} else if (endIpv6) {
|
|
22530
22529
|
address.push(buffer.join(''));
|
|
@@ -22536,6 +22535,17 @@ function requireUtils () {
|
|
|
22536
22535
|
return output
|
|
22537
22536
|
}
|
|
22538
22537
|
|
|
22538
|
+
/**
|
|
22539
|
+
* @typedef {Object} NormalizeIPv6Result
|
|
22540
|
+
* @property {string} host - The normalized host.
|
|
22541
|
+
* @property {string} [escapedHost] - The escaped host.
|
|
22542
|
+
* @property {boolean} isIPV6 - Indicates if the host is an IPv6 address.
|
|
22543
|
+
*/
|
|
22544
|
+
|
|
22545
|
+
/**
|
|
22546
|
+
* @param {string} host
|
|
22547
|
+
* @returns {NormalizeIPv6Result}
|
|
22548
|
+
*/
|
|
22539
22549
|
function normalizeIPv6 (host) {
|
|
22540
22550
|
if (findToken(host, ':') < 2) { return { host, isIPV6: false } }
|
|
22541
22551
|
const ipv6 = getIPV6(host);
|
|
@@ -22547,35 +22557,17 @@ function requireUtils () {
|
|
|
22547
22557
|
newHost += '%' + ipv6.zone;
|
|
22548
22558
|
escapedHost += '%25' + ipv6.zone;
|
|
22549
22559
|
}
|
|
22550
|
-
return { host: newHost,
|
|
22560
|
+
return { host: newHost, isIPV6: true, escapedHost }
|
|
22551
22561
|
} else {
|
|
22552
22562
|
return { host, isIPV6: false }
|
|
22553
22563
|
}
|
|
22554
22564
|
}
|
|
22555
22565
|
|
|
22556
|
-
|
|
22557
|
-
|
|
22558
|
-
|
|
22559
|
-
|
|
22560
|
-
|
|
22561
|
-
const c = str[i];
|
|
22562
|
-
if (c === '0' && skip) {
|
|
22563
|
-
if ((i + 1 <= l && str[i + 1] === token) || i + 1 === l) {
|
|
22564
|
-
out += c;
|
|
22565
|
-
skip = false;
|
|
22566
|
-
}
|
|
22567
|
-
} else {
|
|
22568
|
-
if (c === token) {
|
|
22569
|
-
skip = true;
|
|
22570
|
-
} else {
|
|
22571
|
-
skip = false;
|
|
22572
|
-
}
|
|
22573
|
-
out += c;
|
|
22574
|
-
}
|
|
22575
|
-
}
|
|
22576
|
-
return out
|
|
22577
|
-
}
|
|
22578
|
-
|
|
22566
|
+
/**
|
|
22567
|
+
* @param {string} str
|
|
22568
|
+
* @param {string} token
|
|
22569
|
+
* @returns {number}
|
|
22570
|
+
*/
|
|
22579
22571
|
function findToken (str, token) {
|
|
22580
22572
|
let ind = 0;
|
|
22581
22573
|
for (let i = 0; i < str.length; i++) {
|
|
@@ -22584,98 +22576,160 @@ function requireUtils () {
|
|
|
22584
22576
|
return ind
|
|
22585
22577
|
}
|
|
22586
22578
|
|
|
22587
|
-
|
|
22588
|
-
|
|
22589
|
-
|
|
22590
|
-
|
|
22591
|
-
|
|
22592
|
-
|
|
22579
|
+
/**
|
|
22580
|
+
* @param {string} path
|
|
22581
|
+
* @returns {string}
|
|
22582
|
+
*
|
|
22583
|
+
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-5.2.4
|
|
22584
|
+
*/
|
|
22585
|
+
function removeDotSegments (path) {
|
|
22586
|
+
let input = path;
|
|
22593
22587
|
const output = [];
|
|
22588
|
+
let nextSlash = -1;
|
|
22589
|
+
let len = 0;
|
|
22594
22590
|
|
|
22595
|
-
|
|
22596
|
-
|
|
22597
|
-
|
|
22598
|
-
|
|
22599
|
-
|
|
22600
|
-
|
|
22601
|
-
|
|
22602
|
-
|
|
22603
|
-
} else if (input === '.' || input === '..') {
|
|
22604
|
-
input = '';
|
|
22605
|
-
} else {
|
|
22606
|
-
const im = input.match(RDS5);
|
|
22607
|
-
if (im) {
|
|
22608
|
-
const s = im[0];
|
|
22609
|
-
input = input.slice(s.length);
|
|
22610
|
-
output.push(s);
|
|
22591
|
+
// eslint-disable-next-line no-cond-assign
|
|
22592
|
+
while (len = input.length) {
|
|
22593
|
+
if (len === 1) {
|
|
22594
|
+
if (input === '.') {
|
|
22595
|
+
break
|
|
22596
|
+
} else if (input === '/') {
|
|
22597
|
+
output.push('/');
|
|
22598
|
+
break
|
|
22611
22599
|
} else {
|
|
22612
|
-
|
|
22600
|
+
output.push(input);
|
|
22601
|
+
break
|
|
22602
|
+
}
|
|
22603
|
+
} else if (len === 2) {
|
|
22604
|
+
if (input[0] === '.') {
|
|
22605
|
+
if (input[1] === '.') {
|
|
22606
|
+
break
|
|
22607
|
+
} else if (input[1] === '/') {
|
|
22608
|
+
input = input.slice(2);
|
|
22609
|
+
continue
|
|
22610
|
+
}
|
|
22611
|
+
} else if (input[0] === '/') {
|
|
22612
|
+
if (input[1] === '.' || input[1] === '/') {
|
|
22613
|
+
output.push('/');
|
|
22614
|
+
break
|
|
22615
|
+
}
|
|
22616
|
+
}
|
|
22617
|
+
} else if (len === 3) {
|
|
22618
|
+
if (input === '/..') {
|
|
22619
|
+
if (output.length !== 0) {
|
|
22620
|
+
output.pop();
|
|
22621
|
+
}
|
|
22622
|
+
output.push('/');
|
|
22623
|
+
break
|
|
22624
|
+
}
|
|
22625
|
+
}
|
|
22626
|
+
if (input[0] === '.') {
|
|
22627
|
+
if (input[1] === '.') {
|
|
22628
|
+
if (input[2] === '/') {
|
|
22629
|
+
input = input.slice(3);
|
|
22630
|
+
continue
|
|
22631
|
+
}
|
|
22632
|
+
} else if (input[1] === '/') {
|
|
22633
|
+
input = input.slice(2);
|
|
22634
|
+
continue
|
|
22635
|
+
}
|
|
22636
|
+
} else if (input[0] === '/') {
|
|
22637
|
+
if (input[1] === '.') {
|
|
22638
|
+
if (input[2] === '/') {
|
|
22639
|
+
input = input.slice(2);
|
|
22640
|
+
continue
|
|
22641
|
+
} else if (input[2] === '.') {
|
|
22642
|
+
if (input[3] === '/') {
|
|
22643
|
+
input = input.slice(3);
|
|
22644
|
+
if (output.length !== 0) {
|
|
22645
|
+
output.pop();
|
|
22646
|
+
}
|
|
22647
|
+
continue
|
|
22648
|
+
}
|
|
22649
|
+
}
|
|
22613
22650
|
}
|
|
22614
22651
|
}
|
|
22652
|
+
|
|
22653
|
+
// Rule 2E: Move normal path segment to output
|
|
22654
|
+
if ((nextSlash = input.indexOf('/', 1)) === -1) {
|
|
22655
|
+
output.push(input);
|
|
22656
|
+
break
|
|
22657
|
+
} else {
|
|
22658
|
+
output.push(input.slice(0, nextSlash));
|
|
22659
|
+
input = input.slice(nextSlash);
|
|
22660
|
+
}
|
|
22615
22661
|
}
|
|
22662
|
+
|
|
22616
22663
|
return output.join('')
|
|
22617
22664
|
}
|
|
22618
22665
|
|
|
22619
|
-
|
|
22666
|
+
/**
|
|
22667
|
+
* @param {import('../types/index').URIComponent} component
|
|
22668
|
+
* @param {boolean} esc
|
|
22669
|
+
* @returns {import('../types/index').URIComponent}
|
|
22670
|
+
*/
|
|
22671
|
+
function normalizeComponentEncoding (component, esc) {
|
|
22620
22672
|
const func = esc !== true ? escape : unescape;
|
|
22621
|
-
if (
|
|
22622
|
-
|
|
22673
|
+
if (component.scheme !== undefined) {
|
|
22674
|
+
component.scheme = func(component.scheme);
|
|
22623
22675
|
}
|
|
22624
|
-
if (
|
|
22625
|
-
|
|
22676
|
+
if (component.userinfo !== undefined) {
|
|
22677
|
+
component.userinfo = func(component.userinfo);
|
|
22626
22678
|
}
|
|
22627
|
-
if (
|
|
22628
|
-
|
|
22679
|
+
if (component.host !== undefined) {
|
|
22680
|
+
component.host = func(component.host);
|
|
22629
22681
|
}
|
|
22630
|
-
if (
|
|
22631
|
-
|
|
22682
|
+
if (component.path !== undefined) {
|
|
22683
|
+
component.path = func(component.path);
|
|
22632
22684
|
}
|
|
22633
|
-
if (
|
|
22634
|
-
|
|
22685
|
+
if (component.query !== undefined) {
|
|
22686
|
+
component.query = func(component.query);
|
|
22635
22687
|
}
|
|
22636
|
-
if (
|
|
22637
|
-
|
|
22688
|
+
if (component.fragment !== undefined) {
|
|
22689
|
+
component.fragment = func(component.fragment);
|
|
22638
22690
|
}
|
|
22639
|
-
return
|
|
22691
|
+
return component
|
|
22640
22692
|
}
|
|
22641
22693
|
|
|
22642
|
-
|
|
22694
|
+
/**
|
|
22695
|
+
* @param {import('../types/index').URIComponent} component
|
|
22696
|
+
* @returns {string|undefined}
|
|
22697
|
+
*/
|
|
22698
|
+
function recomposeAuthority (component) {
|
|
22643
22699
|
const uriTokens = [];
|
|
22644
22700
|
|
|
22645
|
-
if (
|
|
22646
|
-
uriTokens.push(
|
|
22701
|
+
if (component.userinfo !== undefined) {
|
|
22702
|
+
uriTokens.push(component.userinfo);
|
|
22647
22703
|
uriTokens.push('@');
|
|
22648
22704
|
}
|
|
22649
22705
|
|
|
22650
|
-
if (
|
|
22651
|
-
let host = unescape(
|
|
22652
|
-
|
|
22653
|
-
|
|
22654
|
-
if (ipV4res.isIPV4) {
|
|
22655
|
-
host = ipV4res.host;
|
|
22656
|
-
} else {
|
|
22657
|
-
const ipV6res = normalizeIPv6(ipV4res.host);
|
|
22706
|
+
if (component.host !== undefined) {
|
|
22707
|
+
let host = unescape(component.host);
|
|
22708
|
+
if (!isIPv4(host)) {
|
|
22709
|
+
const ipV6res = normalizeIPv6(host);
|
|
22658
22710
|
if (ipV6res.isIPV6 === true) {
|
|
22659
22711
|
host = `[${ipV6res.escapedHost}]`;
|
|
22660
22712
|
} else {
|
|
22661
|
-
host =
|
|
22713
|
+
host = component.host;
|
|
22662
22714
|
}
|
|
22663
22715
|
}
|
|
22664
22716
|
uriTokens.push(host);
|
|
22665
22717
|
}
|
|
22666
22718
|
|
|
22667
|
-
if (typeof
|
|
22719
|
+
if (typeof component.port === 'number' || typeof component.port === 'string') {
|
|
22668
22720
|
uriTokens.push(':');
|
|
22669
|
-
uriTokens.push(String(
|
|
22721
|
+
uriTokens.push(String(component.port));
|
|
22670
22722
|
}
|
|
22671
22723
|
|
|
22672
22724
|
return uriTokens.length ? uriTokens.join('') : undefined
|
|
22673
22725
|
}
|
|
22674
22726
|
utils$1 = {
|
|
22727
|
+
nonSimpleDomain,
|
|
22675
22728
|
recomposeAuthority,
|
|
22676
22729
|
normalizeComponentEncoding,
|
|
22677
22730
|
removeDotSegments,
|
|
22678
|
-
|
|
22731
|
+
isIPv4,
|
|
22732
|
+
isUUID,
|
|
22679
22733
|
normalizeIPv6,
|
|
22680
22734
|
stringArrayToHexStripped
|
|
22681
22735
|
};
|
|
@@ -22689,192 +22743,271 @@ function requireSchemes () {
|
|
|
22689
22743
|
if (hasRequiredSchemes) return schemes;
|
|
22690
22744
|
hasRequiredSchemes = 1;
|
|
22691
22745
|
|
|
22692
|
-
const
|
|
22746
|
+
const { isUUID } = requireUtils();
|
|
22693
22747
|
const URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;
|
|
22694
22748
|
|
|
22695
|
-
|
|
22696
|
-
|
|
22749
|
+
const supportedSchemeNames = /** @type {const} */ (['http', 'https', 'ws',
|
|
22750
|
+
'wss', 'urn', 'urn:uuid']);
|
|
22751
|
+
|
|
22752
|
+
/** @typedef {supportedSchemeNames[number]} SchemeName */
|
|
22753
|
+
|
|
22754
|
+
/**
|
|
22755
|
+
* @param {string} name
|
|
22756
|
+
* @returns {name is SchemeName}
|
|
22757
|
+
*/
|
|
22758
|
+
function isValidSchemeName (name) {
|
|
22759
|
+
return supportedSchemeNames.indexOf(/** @type {*} */ (name)) !== -1
|
|
22697
22760
|
}
|
|
22698
22761
|
|
|
22699
|
-
|
|
22700
|
-
|
|
22701
|
-
|
|
22762
|
+
/**
|
|
22763
|
+
* @callback SchemeFn
|
|
22764
|
+
* @param {import('../types/index').URIComponent} component
|
|
22765
|
+
* @param {import('../types/index').Options} options
|
|
22766
|
+
* @returns {import('../types/index').URIComponent}
|
|
22767
|
+
*/
|
|
22768
|
+
|
|
22769
|
+
/**
|
|
22770
|
+
* @typedef {Object} SchemeHandler
|
|
22771
|
+
* @property {SchemeName} scheme - The scheme name.
|
|
22772
|
+
* @property {boolean} [domainHost] - Indicates if the scheme supports domain hosts.
|
|
22773
|
+
* @property {SchemeFn} parse - Function to parse the URI component for this scheme.
|
|
22774
|
+
* @property {SchemeFn} serialize - Function to serialize the URI component for this scheme.
|
|
22775
|
+
* @property {boolean} [skipNormalize] - Indicates if normalization should be skipped for this scheme.
|
|
22776
|
+
* @property {boolean} [absolutePath] - Indicates if the scheme uses absolute paths.
|
|
22777
|
+
* @property {boolean} [unicodeSupport] - Indicates if the scheme supports Unicode.
|
|
22778
|
+
*/
|
|
22779
|
+
|
|
22780
|
+
/**
|
|
22781
|
+
* @param {import('../types/index').URIComponent} wsComponent
|
|
22782
|
+
* @returns {boolean}
|
|
22783
|
+
*/
|
|
22784
|
+
function wsIsSecure (wsComponent) {
|
|
22785
|
+
if (wsComponent.secure === true) {
|
|
22786
|
+
return true
|
|
22787
|
+
} else if (wsComponent.secure === false) {
|
|
22788
|
+
return false
|
|
22789
|
+
} else if (wsComponent.scheme) {
|
|
22790
|
+
return (
|
|
22791
|
+
wsComponent.scheme.length === 3 &&
|
|
22792
|
+
(wsComponent.scheme[0] === 'w' || wsComponent.scheme[0] === 'W') &&
|
|
22793
|
+
(wsComponent.scheme[1] === 's' || wsComponent.scheme[1] === 'S') &&
|
|
22794
|
+
(wsComponent.scheme[2] === 's' || wsComponent.scheme[2] === 'S')
|
|
22795
|
+
)
|
|
22796
|
+
} else {
|
|
22797
|
+
return false
|
|
22702
22798
|
}
|
|
22799
|
+
}
|
|
22703
22800
|
|
|
22704
|
-
|
|
22801
|
+
/** @type {SchemeFn} */
|
|
22802
|
+
function httpParse (component) {
|
|
22803
|
+
if (!component.host) {
|
|
22804
|
+
component.error = component.error || 'HTTP URIs must have a host.';
|
|
22805
|
+
}
|
|
22806
|
+
|
|
22807
|
+
return component
|
|
22705
22808
|
}
|
|
22706
22809
|
|
|
22707
|
-
|
|
22708
|
-
|
|
22810
|
+
/** @type {SchemeFn} */
|
|
22811
|
+
function httpSerialize (component) {
|
|
22812
|
+
const secure = String(component.scheme).toLowerCase() === 'https';
|
|
22709
22813
|
|
|
22710
22814
|
// normalize the default port
|
|
22711
|
-
if (
|
|
22712
|
-
|
|
22815
|
+
if (component.port === (secure ? 443 : 80) || component.port === '') {
|
|
22816
|
+
component.port = undefined;
|
|
22713
22817
|
}
|
|
22714
22818
|
|
|
22715
22819
|
// normalize the empty path
|
|
22716
|
-
if (!
|
|
22717
|
-
|
|
22820
|
+
if (!component.path) {
|
|
22821
|
+
component.path = '/';
|
|
22718
22822
|
}
|
|
22719
22823
|
|
|
22720
22824
|
// NOTE: We do not parse query strings for HTTP URIs
|
|
22721
22825
|
// as WWW Form Url Encoded query strings are part of the HTML4+ spec,
|
|
22722
22826
|
// and not the HTTP spec.
|
|
22723
22827
|
|
|
22724
|
-
return
|
|
22828
|
+
return component
|
|
22725
22829
|
}
|
|
22726
22830
|
|
|
22727
|
-
|
|
22831
|
+
/** @type {SchemeFn} */
|
|
22832
|
+
function wsParse (wsComponent) {
|
|
22728
22833
|
// indicate if the secure flag is set
|
|
22729
|
-
|
|
22834
|
+
wsComponent.secure = wsIsSecure(wsComponent);
|
|
22730
22835
|
|
|
22731
22836
|
// construct resouce name
|
|
22732
|
-
|
|
22733
|
-
|
|
22734
|
-
|
|
22837
|
+
wsComponent.resourceName = (wsComponent.path || '/') + (wsComponent.query ? '?' + wsComponent.query : '');
|
|
22838
|
+
wsComponent.path = undefined;
|
|
22839
|
+
wsComponent.query = undefined;
|
|
22735
22840
|
|
|
22736
|
-
return
|
|
22841
|
+
return wsComponent
|
|
22737
22842
|
}
|
|
22738
22843
|
|
|
22739
|
-
|
|
22844
|
+
/** @type {SchemeFn} */
|
|
22845
|
+
function wsSerialize (wsComponent) {
|
|
22740
22846
|
// normalize the default port
|
|
22741
|
-
if (
|
|
22742
|
-
|
|
22847
|
+
if (wsComponent.port === (wsIsSecure(wsComponent) ? 443 : 80) || wsComponent.port === '') {
|
|
22848
|
+
wsComponent.port = undefined;
|
|
22743
22849
|
}
|
|
22744
22850
|
|
|
22745
22851
|
// ensure scheme matches secure flag
|
|
22746
|
-
if (typeof
|
|
22747
|
-
|
|
22748
|
-
|
|
22852
|
+
if (typeof wsComponent.secure === 'boolean') {
|
|
22853
|
+
wsComponent.scheme = (wsComponent.secure ? 'wss' : 'ws');
|
|
22854
|
+
wsComponent.secure = undefined;
|
|
22749
22855
|
}
|
|
22750
22856
|
|
|
22751
22857
|
// reconstruct path from resource name
|
|
22752
|
-
if (
|
|
22753
|
-
const [path, query] =
|
|
22754
|
-
|
|
22755
|
-
|
|
22756
|
-
|
|
22858
|
+
if (wsComponent.resourceName) {
|
|
22859
|
+
const [path, query] = wsComponent.resourceName.split('?');
|
|
22860
|
+
wsComponent.path = (path && path !== '/' ? path : undefined);
|
|
22861
|
+
wsComponent.query = query;
|
|
22862
|
+
wsComponent.resourceName = undefined;
|
|
22757
22863
|
}
|
|
22758
22864
|
|
|
22759
22865
|
// forbid fragment component
|
|
22760
|
-
|
|
22866
|
+
wsComponent.fragment = undefined;
|
|
22761
22867
|
|
|
22762
|
-
return
|
|
22868
|
+
return wsComponent
|
|
22763
22869
|
}
|
|
22764
22870
|
|
|
22765
|
-
|
|
22766
|
-
|
|
22767
|
-
|
|
22768
|
-
|
|
22871
|
+
/** @type {SchemeFn} */
|
|
22872
|
+
function urnParse (urnComponent, options) {
|
|
22873
|
+
if (!urnComponent.path) {
|
|
22874
|
+
urnComponent.error = 'URN can not be parsed';
|
|
22875
|
+
return urnComponent
|
|
22769
22876
|
}
|
|
22770
|
-
const matches =
|
|
22877
|
+
const matches = urnComponent.path.match(URN_REG);
|
|
22771
22878
|
if (matches) {
|
|
22772
|
-
const scheme = options.scheme ||
|
|
22773
|
-
|
|
22774
|
-
|
|
22775
|
-
const urnScheme = `${scheme}:${options.nid ||
|
|
22776
|
-
const schemeHandler =
|
|
22777
|
-
|
|
22879
|
+
const scheme = options.scheme || urnComponent.scheme || 'urn';
|
|
22880
|
+
urnComponent.nid = matches[1].toLowerCase();
|
|
22881
|
+
urnComponent.nss = matches[2];
|
|
22882
|
+
const urnScheme = `${scheme}:${options.nid || urnComponent.nid}`;
|
|
22883
|
+
const schemeHandler = getSchemeHandler(urnScheme);
|
|
22884
|
+
urnComponent.path = undefined;
|
|
22778
22885
|
|
|
22779
22886
|
if (schemeHandler) {
|
|
22780
|
-
|
|
22887
|
+
urnComponent = schemeHandler.parse(urnComponent, options);
|
|
22781
22888
|
}
|
|
22782
22889
|
} else {
|
|
22783
|
-
|
|
22890
|
+
urnComponent.error = urnComponent.error || 'URN can not be parsed.';
|
|
22784
22891
|
}
|
|
22785
22892
|
|
|
22786
|
-
return
|
|
22893
|
+
return urnComponent
|
|
22787
22894
|
}
|
|
22788
22895
|
|
|
22789
|
-
|
|
22790
|
-
|
|
22791
|
-
|
|
22896
|
+
/** @type {SchemeFn} */
|
|
22897
|
+
function urnSerialize (urnComponent, options) {
|
|
22898
|
+
if (urnComponent.nid === undefined) {
|
|
22899
|
+
throw new Error('URN without nid cannot be serialized')
|
|
22900
|
+
}
|
|
22901
|
+
const scheme = options.scheme || urnComponent.scheme || 'urn';
|
|
22902
|
+
const nid = urnComponent.nid.toLowerCase();
|
|
22792
22903
|
const urnScheme = `${scheme}:${options.nid || nid}`;
|
|
22793
|
-
const schemeHandler =
|
|
22904
|
+
const schemeHandler = getSchemeHandler(urnScheme);
|
|
22794
22905
|
|
|
22795
22906
|
if (schemeHandler) {
|
|
22796
|
-
|
|
22907
|
+
urnComponent = schemeHandler.serialize(urnComponent, options);
|
|
22797
22908
|
}
|
|
22798
22909
|
|
|
22799
|
-
const
|
|
22800
|
-
const nss =
|
|
22801
|
-
|
|
22910
|
+
const uriComponent = urnComponent;
|
|
22911
|
+
const nss = urnComponent.nss;
|
|
22912
|
+
uriComponent.path = `${nid || options.nid}:${nss}`;
|
|
22802
22913
|
|
|
22803
22914
|
options.skipEscape = true;
|
|
22804
|
-
return
|
|
22915
|
+
return uriComponent
|
|
22805
22916
|
}
|
|
22806
22917
|
|
|
22807
|
-
|
|
22808
|
-
|
|
22809
|
-
|
|
22810
|
-
|
|
22918
|
+
/** @type {SchemeFn} */
|
|
22919
|
+
function urnuuidParse (urnComponent, options) {
|
|
22920
|
+
const uuidComponent = urnComponent;
|
|
22921
|
+
uuidComponent.uuid = uuidComponent.nss;
|
|
22922
|
+
uuidComponent.nss = undefined;
|
|
22811
22923
|
|
|
22812
|
-
if (!options.tolerant && (!
|
|
22813
|
-
|
|
22924
|
+
if (!options.tolerant && (!uuidComponent.uuid || !isUUID(uuidComponent.uuid))) {
|
|
22925
|
+
uuidComponent.error = uuidComponent.error || 'UUID is not valid.';
|
|
22814
22926
|
}
|
|
22815
22927
|
|
|
22816
|
-
return
|
|
22928
|
+
return uuidComponent
|
|
22817
22929
|
}
|
|
22818
22930
|
|
|
22819
|
-
|
|
22820
|
-
|
|
22931
|
+
/** @type {SchemeFn} */
|
|
22932
|
+
function urnuuidSerialize (uuidComponent) {
|
|
22933
|
+
const urnComponent = uuidComponent;
|
|
22821
22934
|
// normalize UUID
|
|
22822
|
-
|
|
22823
|
-
return
|
|
22935
|
+
urnComponent.nss = (uuidComponent.uuid || '').toLowerCase();
|
|
22936
|
+
return urnComponent
|
|
22824
22937
|
}
|
|
22825
22938
|
|
|
22826
|
-
const http = {
|
|
22939
|
+
const http = /** @type {SchemeHandler} */ ({
|
|
22827
22940
|
scheme: 'http',
|
|
22828
22941
|
domainHost: true,
|
|
22829
22942
|
parse: httpParse,
|
|
22830
22943
|
serialize: httpSerialize
|
|
22831
|
-
};
|
|
22944
|
+
});
|
|
22832
22945
|
|
|
22833
|
-
const https = {
|
|
22946
|
+
const https = /** @type {SchemeHandler} */ ({
|
|
22834
22947
|
scheme: 'https',
|
|
22835
22948
|
domainHost: http.domainHost,
|
|
22836
22949
|
parse: httpParse,
|
|
22837
22950
|
serialize: httpSerialize
|
|
22838
|
-
};
|
|
22951
|
+
});
|
|
22839
22952
|
|
|
22840
|
-
const ws = {
|
|
22953
|
+
const ws = /** @type {SchemeHandler} */ ({
|
|
22841
22954
|
scheme: 'ws',
|
|
22842
22955
|
domainHost: true,
|
|
22843
22956
|
parse: wsParse,
|
|
22844
22957
|
serialize: wsSerialize
|
|
22845
|
-
};
|
|
22958
|
+
});
|
|
22846
22959
|
|
|
22847
|
-
const wss = {
|
|
22960
|
+
const wss = /** @type {SchemeHandler} */ ({
|
|
22848
22961
|
scheme: 'wss',
|
|
22849
22962
|
domainHost: ws.domainHost,
|
|
22850
22963
|
parse: ws.parse,
|
|
22851
22964
|
serialize: ws.serialize
|
|
22852
|
-
};
|
|
22965
|
+
});
|
|
22853
22966
|
|
|
22854
|
-
const urn = {
|
|
22967
|
+
const urn = /** @type {SchemeHandler} */ ({
|
|
22855
22968
|
scheme: 'urn',
|
|
22856
22969
|
parse: urnParse,
|
|
22857
22970
|
serialize: urnSerialize,
|
|
22858
22971
|
skipNormalize: true
|
|
22859
|
-
};
|
|
22972
|
+
});
|
|
22860
22973
|
|
|
22861
|
-
const urnuuid = {
|
|
22974
|
+
const urnuuid = /** @type {SchemeHandler} */ ({
|
|
22862
22975
|
scheme: 'urn:uuid',
|
|
22863
22976
|
parse: urnuuidParse,
|
|
22864
22977
|
serialize: urnuuidSerialize,
|
|
22865
22978
|
skipNormalize: true
|
|
22866
|
-
};
|
|
22979
|
+
});
|
|
22867
22980
|
|
|
22868
|
-
const SCHEMES = {
|
|
22981
|
+
const SCHEMES = /** @type {Record<SchemeName, SchemeHandler>} */ ({
|
|
22869
22982
|
http,
|
|
22870
22983
|
https,
|
|
22871
22984
|
ws,
|
|
22872
22985
|
wss,
|
|
22873
22986
|
urn,
|
|
22874
22987
|
'urn:uuid': urnuuid
|
|
22875
|
-
};
|
|
22988
|
+
});
|
|
22989
|
+
|
|
22990
|
+
Object.setPrototypeOf(SCHEMES, null);
|
|
22991
|
+
|
|
22992
|
+
/**
|
|
22993
|
+
* @param {string|undefined} scheme
|
|
22994
|
+
* @returns {SchemeHandler|undefined}
|
|
22995
|
+
*/
|
|
22996
|
+
function getSchemeHandler (scheme) {
|
|
22997
|
+
return (
|
|
22998
|
+
scheme && (
|
|
22999
|
+
SCHEMES[/** @type {SchemeName} */ (scheme)] ||
|
|
23000
|
+
SCHEMES[/** @type {SchemeName} */(scheme.toLowerCase())])
|
|
23001
|
+
) ||
|
|
23002
|
+
undefined
|
|
23003
|
+
}
|
|
22876
23004
|
|
|
22877
|
-
schemes =
|
|
23005
|
+
schemes = {
|
|
23006
|
+
wsIsSecure,
|
|
23007
|
+
SCHEMES,
|
|
23008
|
+
isValidSchemeName,
|
|
23009
|
+
getSchemeHandler,
|
|
23010
|
+
};
|
|
22878
23011
|
return schemes;
|
|
22879
23012
|
}
|
|
22880
23013
|
|
|
@@ -22884,29 +23017,50 @@ function requireFastUri () {
|
|
|
22884
23017
|
if (hasRequiredFastUri) return fastUri.exports;
|
|
22885
23018
|
hasRequiredFastUri = 1;
|
|
22886
23019
|
|
|
22887
|
-
const { normalizeIPv6,
|
|
22888
|
-
const SCHEMES = requireSchemes();
|
|
23020
|
+
const { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizeComponentEncoding, isIPv4, nonSimpleDomain } = requireUtils();
|
|
23021
|
+
const { SCHEMES, getSchemeHandler } = requireSchemes();
|
|
22889
23022
|
|
|
23023
|
+
/**
|
|
23024
|
+
* @template {import('./types/index').URIComponent|string} T
|
|
23025
|
+
* @param {T} uri
|
|
23026
|
+
* @param {import('./types/index').Options} [options]
|
|
23027
|
+
* @returns {T}
|
|
23028
|
+
*/
|
|
22890
23029
|
function normalize (uri, options) {
|
|
22891
23030
|
if (typeof uri === 'string') {
|
|
22892
|
-
uri = serialize(parse(uri, options), options);
|
|
23031
|
+
uri = /** @type {T} */ (serialize(parse(uri, options), options));
|
|
22893
23032
|
} else if (typeof uri === 'object') {
|
|
22894
|
-
uri = parse(serialize(uri, options), options);
|
|
23033
|
+
uri = /** @type {T} */ (parse(serialize(uri, options), options));
|
|
22895
23034
|
}
|
|
22896
23035
|
return uri
|
|
22897
23036
|
}
|
|
22898
23037
|
|
|
23038
|
+
/**
|
|
23039
|
+
* @param {string} baseURI
|
|
23040
|
+
* @param {string} relativeURI
|
|
23041
|
+
* @param {import('./types/index').Options} [options]
|
|
23042
|
+
* @returns {string}
|
|
23043
|
+
*/
|
|
22899
23044
|
function resolve (baseURI, relativeURI, options) {
|
|
22900
|
-
const schemelessOptions = Object.assign({ scheme: 'null' }, options);
|
|
22901
|
-
const resolved =
|
|
22902
|
-
|
|
23045
|
+
const schemelessOptions = options ? Object.assign({ scheme: 'null' }, options) : { scheme: 'null' };
|
|
23046
|
+
const resolved = resolveComponent(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
23047
|
+
schemelessOptions.skipEscape = true;
|
|
23048
|
+
return serialize(resolved, schemelessOptions)
|
|
22903
23049
|
}
|
|
22904
23050
|
|
|
22905
|
-
|
|
23051
|
+
/**
|
|
23052
|
+
* @param {import ('./types/index').URIComponent} base
|
|
23053
|
+
* @param {import ('./types/index').URIComponent} relative
|
|
23054
|
+
* @param {import('./types/index').Options} [options]
|
|
23055
|
+
* @param {boolean} [skipNormalization=false]
|
|
23056
|
+
* @returns {import ('./types/index').URIComponent}
|
|
23057
|
+
*/
|
|
23058
|
+
function resolveComponent (base, relative, options, skipNormalization) {
|
|
23059
|
+
/** @type {import('./types/index').URIComponent} */
|
|
22906
23060
|
const target = {};
|
|
22907
23061
|
if (!skipNormalization) {
|
|
22908
|
-
base = parse(serialize(base, options), options); // normalize base
|
|
22909
|
-
relative = parse(serialize(relative, options), options); // normalize relative
|
|
23062
|
+
base = parse(serialize(base, options), options); // normalize base component
|
|
23063
|
+
relative = parse(serialize(relative, options), options); // normalize relative component
|
|
22910
23064
|
}
|
|
22911
23065
|
options = options || {};
|
|
22912
23066
|
|
|
@@ -22935,7 +23089,7 @@ function requireFastUri () {
|
|
|
22935
23089
|
target.query = base.query;
|
|
22936
23090
|
}
|
|
22937
23091
|
} else {
|
|
22938
|
-
if (relative.path
|
|
23092
|
+
if (relative.path[0] === '/') {
|
|
22939
23093
|
target.path = removeDotSegments(relative.path);
|
|
22940
23094
|
} else {
|
|
22941
23095
|
if ((base.userinfo !== undefined || base.host !== undefined || base.port !== undefined) && !base.path) {
|
|
@@ -22962,6 +23116,12 @@ function requireFastUri () {
|
|
|
22962
23116
|
return target
|
|
22963
23117
|
}
|
|
22964
23118
|
|
|
23119
|
+
/**
|
|
23120
|
+
* @param {import ('./types/index').URIComponent|string} uriA
|
|
23121
|
+
* @param {import ('./types/index').URIComponent|string} uriB
|
|
23122
|
+
* @param {import ('./types/index').Options} options
|
|
23123
|
+
* @returns {boolean}
|
|
23124
|
+
*/
|
|
22965
23125
|
function equal (uriA, uriB, options) {
|
|
22966
23126
|
if (typeof uriA === 'string') {
|
|
22967
23127
|
uriA = unescape(uriA);
|
|
@@ -22980,8 +23140,13 @@ function requireFastUri () {
|
|
|
22980
23140
|
return uriA.toLowerCase() === uriB.toLowerCase()
|
|
22981
23141
|
}
|
|
22982
23142
|
|
|
23143
|
+
/**
|
|
23144
|
+
* @param {Readonly<import('./types/index').URIComponent>} cmpts
|
|
23145
|
+
* @param {import('./types/index').Options} [opts]
|
|
23146
|
+
* @returns {string}
|
|
23147
|
+
*/
|
|
22983
23148
|
function serialize (cmpts, opts) {
|
|
22984
|
-
const
|
|
23149
|
+
const component = {
|
|
22985
23150
|
host: cmpts.host,
|
|
22986
23151
|
scheme: cmpts.scheme,
|
|
22987
23152
|
userinfo: cmpts.userinfo,
|
|
@@ -23001,28 +23166,28 @@ function requireFastUri () {
|
|
|
23001
23166
|
const uriTokens = [];
|
|
23002
23167
|
|
|
23003
23168
|
// find scheme handler
|
|
23004
|
-
const schemeHandler =
|
|
23169
|
+
const schemeHandler = getSchemeHandler(options.scheme || component.scheme);
|
|
23005
23170
|
|
|
23006
23171
|
// perform scheme specific serialization
|
|
23007
|
-
if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(
|
|
23172
|
+
if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options);
|
|
23008
23173
|
|
|
23009
|
-
if (
|
|
23174
|
+
if (component.path !== undefined) {
|
|
23010
23175
|
if (!options.skipEscape) {
|
|
23011
|
-
|
|
23176
|
+
component.path = escape(component.path);
|
|
23012
23177
|
|
|
23013
|
-
if (
|
|
23014
|
-
|
|
23178
|
+
if (component.scheme !== undefined) {
|
|
23179
|
+
component.path = component.path.split('%3A').join(':');
|
|
23015
23180
|
}
|
|
23016
23181
|
} else {
|
|
23017
|
-
|
|
23182
|
+
component.path = unescape(component.path);
|
|
23018
23183
|
}
|
|
23019
23184
|
}
|
|
23020
23185
|
|
|
23021
|
-
if (options.reference !== 'suffix' &&
|
|
23022
|
-
uriTokens.push(
|
|
23186
|
+
if (options.reference !== 'suffix' && component.scheme) {
|
|
23187
|
+
uriTokens.push(component.scheme, ':');
|
|
23023
23188
|
}
|
|
23024
23189
|
|
|
23025
|
-
const authority = recomposeAuthority(
|
|
23190
|
+
const authority = recomposeAuthority(component);
|
|
23026
23191
|
if (authority !== undefined) {
|
|
23027
23192
|
if (options.reference !== 'suffix') {
|
|
23028
23193
|
uriTokens.push('//');
|
|
@@ -23030,51 +23195,49 @@ function requireFastUri () {
|
|
|
23030
23195
|
|
|
23031
23196
|
uriTokens.push(authority);
|
|
23032
23197
|
|
|
23033
|
-
if (
|
|
23198
|
+
if (component.path && component.path[0] !== '/') {
|
|
23034
23199
|
uriTokens.push('/');
|
|
23035
23200
|
}
|
|
23036
23201
|
}
|
|
23037
|
-
if (
|
|
23038
|
-
let s =
|
|
23202
|
+
if (component.path !== undefined) {
|
|
23203
|
+
let s = component.path;
|
|
23039
23204
|
|
|
23040
23205
|
if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
|
|
23041
23206
|
s = removeDotSegments(s);
|
|
23042
23207
|
}
|
|
23043
23208
|
|
|
23044
|
-
if (
|
|
23045
|
-
|
|
23209
|
+
if (
|
|
23210
|
+
authority === undefined &&
|
|
23211
|
+
s[0] === '/' &&
|
|
23212
|
+
s[1] === '/'
|
|
23213
|
+
) {
|
|
23214
|
+
// don't allow the path to start with "//"
|
|
23215
|
+
s = '/%2F' + s.slice(2);
|
|
23046
23216
|
}
|
|
23047
23217
|
|
|
23048
23218
|
uriTokens.push(s);
|
|
23049
23219
|
}
|
|
23050
23220
|
|
|
23051
|
-
if (
|
|
23052
|
-
uriTokens.push('?',
|
|
23221
|
+
if (component.query !== undefined) {
|
|
23222
|
+
uriTokens.push('?', component.query);
|
|
23053
23223
|
}
|
|
23054
23224
|
|
|
23055
|
-
if (
|
|
23056
|
-
uriTokens.push('#',
|
|
23225
|
+
if (component.fragment !== undefined) {
|
|
23226
|
+
uriTokens.push('#', component.fragment);
|
|
23057
23227
|
}
|
|
23058
23228
|
return uriTokens.join('')
|
|
23059
23229
|
}
|
|
23060
23230
|
|
|
23061
|
-
const hexLookUp = Array.from({ length: 127 }, (_v, k) => /[^!"$&'()*+,\-.;=_`a-z{}~]/u.test(String.fromCharCode(k)));
|
|
23062
|
-
|
|
23063
|
-
function nonSimpleDomain (value) {
|
|
23064
|
-
let code = 0;
|
|
23065
|
-
for (let i = 0, len = value.length; i < len; ++i) {
|
|
23066
|
-
code = value.charCodeAt(i);
|
|
23067
|
-
if (code > 126 || hexLookUp[code]) {
|
|
23068
|
-
return true
|
|
23069
|
-
}
|
|
23070
|
-
}
|
|
23071
|
-
return false
|
|
23072
|
-
}
|
|
23073
|
-
|
|
23074
23231
|
const URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
|
|
23075
23232
|
|
|
23233
|
+
/**
|
|
23234
|
+
* @param {string} uri
|
|
23235
|
+
* @param {import('./types/index').Options} [opts]
|
|
23236
|
+
* @returns
|
|
23237
|
+
*/
|
|
23076
23238
|
function parse (uri, opts) {
|
|
23077
23239
|
const options = Object.assign({}, opts);
|
|
23240
|
+
/** @type {import('./types/index').URIComponent} */
|
|
23078
23241
|
const parsed = {
|
|
23079
23242
|
scheme: undefined,
|
|
23080
23243
|
userinfo: undefined,
|
|
@@ -23084,9 +23247,15 @@ function requireFastUri () {
|
|
|
23084
23247
|
query: undefined,
|
|
23085
23248
|
fragment: undefined
|
|
23086
23249
|
};
|
|
23087
|
-
|
|
23250
|
+
|
|
23088
23251
|
let isIP = false;
|
|
23089
|
-
if (options.reference === 'suffix')
|
|
23252
|
+
if (options.reference === 'suffix') {
|
|
23253
|
+
if (options.scheme) {
|
|
23254
|
+
uri = options.scheme + ':' + uri;
|
|
23255
|
+
} else {
|
|
23256
|
+
uri = '//' + uri;
|
|
23257
|
+
}
|
|
23258
|
+
}
|
|
23090
23259
|
|
|
23091
23260
|
const matches = uri.match(URI_PARSE);
|
|
23092
23261
|
|
|
@@ -23105,13 +23274,12 @@ function requireFastUri () {
|
|
|
23105
23274
|
parsed.port = matches[5];
|
|
23106
23275
|
}
|
|
23107
23276
|
if (parsed.host) {
|
|
23108
|
-
const ipv4result =
|
|
23109
|
-
if (ipv4result
|
|
23110
|
-
const ipv6result = normalizeIPv6(
|
|
23277
|
+
const ipv4result = isIPv4(parsed.host);
|
|
23278
|
+
if (ipv4result === false) {
|
|
23279
|
+
const ipv6result = normalizeIPv6(parsed.host);
|
|
23111
23280
|
parsed.host = ipv6result.host.toLowerCase();
|
|
23112
23281
|
isIP = ipv6result.isIPV6;
|
|
23113
23282
|
} else {
|
|
23114
|
-
parsed.host = ipv4result.host;
|
|
23115
23283
|
isIP = true;
|
|
23116
23284
|
}
|
|
23117
23285
|
}
|
|
@@ -23131,7 +23299,7 @@ function requireFastUri () {
|
|
|
23131
23299
|
}
|
|
23132
23300
|
|
|
23133
23301
|
// find scheme handler
|
|
23134
|
-
const schemeHandler =
|
|
23302
|
+
const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme);
|
|
23135
23303
|
|
|
23136
23304
|
// check if scheme can't handle IRIs
|
|
23137
23305
|
if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
|
|
@@ -23148,11 +23316,13 @@ function requireFastUri () {
|
|
|
23148
23316
|
}
|
|
23149
23317
|
|
|
23150
23318
|
if (!schemeHandler || (schemeHandler && !schemeHandler.skipNormalize)) {
|
|
23151
|
-
if (
|
|
23152
|
-
parsed.scheme
|
|
23153
|
-
|
|
23154
|
-
|
|
23155
|
-
parsed.host
|
|
23319
|
+
if (uri.indexOf('%') !== -1) {
|
|
23320
|
+
if (parsed.scheme !== undefined) {
|
|
23321
|
+
parsed.scheme = unescape(parsed.scheme);
|
|
23322
|
+
}
|
|
23323
|
+
if (parsed.host !== undefined) {
|
|
23324
|
+
parsed.host = unescape(parsed.host);
|
|
23325
|
+
}
|
|
23156
23326
|
}
|
|
23157
23327
|
if (parsed.path) {
|
|
23158
23328
|
parsed.path = escape(unescape(parsed.path));
|
|
@@ -23176,7 +23346,7 @@ function requireFastUri () {
|
|
|
23176
23346
|
SCHEMES,
|
|
23177
23347
|
normalize,
|
|
23178
23348
|
resolve,
|
|
23179
|
-
|
|
23349
|
+
resolveComponent,
|
|
23180
23350
|
equal,
|
|
23181
23351
|
serialize,
|
|
23182
23352
|
parse
|
|
@@ -26898,7 +27068,7 @@ function blockString({ comment, type, value }, ctx, onComment, onChompKeep) {
|
|
|
26898
27068
|
const { blockQuote, commentString, lineWidth } = ctx.options;
|
|
26899
27069
|
// 1. Block can't end in whitespace unless the last line is non-empty.
|
|
26900
27070
|
// 2. Strings consisting of only whitespace are best rendered explicitly.
|
|
26901
|
-
if (!blockQuote || /\n[\t ]+$/.test(value)
|
|
27071
|
+
if (!blockQuote || /\n[\t ]+$/.test(value)) {
|
|
26902
27072
|
return quotedString(value, ctx);
|
|
26903
27073
|
}
|
|
26904
27074
|
const indent = ctx.indent ||
|
|
@@ -34187,7 +34357,7 @@ let manifest;
|
|
|
34187
34357
|
try {
|
|
34188
34358
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
34189
34359
|
// @ts-ignore
|
|
34190
|
-
manifest = (await import('../manifest-
|
|
34360
|
+
manifest = (await import('../manifest-CRrj_9sQ.js')).default;
|
|
34191
34361
|
}
|
|
34192
34362
|
catch {
|
|
34193
34363
|
const name = "../dist/manifest.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typespec/html-program-viewer",
|
|
3
|
-
"version": "0.74.0
|
|
3
|
+
"version": "0.74.0",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
5
|
"description": "TypeSpec library for emitting an html view of the program.",
|
|
6
6
|
"homepage": "https://typespec.io",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"!dist/test/**"
|
|
37
37
|
],
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@typespec/compiler": "^1.
|
|
39
|
+
"@typespec/compiler": "^1.4.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@fluentui/react-components": "~9.
|
|
42
|
+
"@fluentui/react-components": "~9.69.0",
|
|
43
43
|
"@fluentui/react-icons": "^2.0.292",
|
|
44
44
|
"@fluentui/react-list": "^9.1.2",
|
|
45
45
|
"react": "~18.3.1",
|
|
@@ -51,21 +51,21 @@
|
|
|
51
51
|
"@testing-library/dom": "^10.4.0",
|
|
52
52
|
"@testing-library/jest-dom": "^6.6.3",
|
|
53
53
|
"@testing-library/react": "^16.2.0",
|
|
54
|
-
"@types/node": "~24.
|
|
54
|
+
"@types/node": "~24.3.0",
|
|
55
55
|
"@types/react": "~18.3.11",
|
|
56
56
|
"@types/react-dom": "~18.3.0",
|
|
57
|
-
"@typespec/compiler": "^1.3.0",
|
|
58
57
|
"@vitejs/plugin-react": "~4.7.0",
|
|
59
58
|
"@vitest/coverage-v8": "^3.1.2",
|
|
60
59
|
"@vitest/ui": "^3.1.2",
|
|
61
60
|
"c8": "^10.1.3",
|
|
62
61
|
"rimraf": "~6.0.1",
|
|
63
|
-
"typescript": "~5.
|
|
62
|
+
"typescript": "~5.9.2",
|
|
64
63
|
"vite": "^7.0.5",
|
|
65
64
|
"vite-plugin-checker": "^0.10.1",
|
|
66
65
|
"vite-plugin-dts": "4.5.4",
|
|
67
66
|
"vite-plugin-node-polyfills": "^0.24.0",
|
|
68
67
|
"vitest": "^3.1.2",
|
|
68
|
+
"@typespec/compiler": "^1.4.0",
|
|
69
69
|
"@typespec/react-components": "^0.57.0"
|
|
70
70
|
},
|
|
71
71
|
"scripts": {
|