fastapi-rtk 0.2.23 → 0.2.24

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.
Files changed (27) hide show
  1. package/dist/.external/cjs/ajv@8.17.1/ajv/dist/runtime/uri.cjs +1 -1
  2. package/dist/.external/cjs/{fast-uri@3.0.6 → fast-uri@3.1.0}/fast-uri/index.cjs +51 -53
  3. package/dist/.external/cjs/fast-uri@3.1.0/fast-uri/lib/schemes.cjs +214 -0
  4. package/dist/.external/cjs/fast-uri@3.1.0/fast-uri/lib/utils.cjs +260 -0
  5. package/dist/.external/esm/ajv@8.17.1/ajv/dist/runtime/uri.mjs +1 -1
  6. package/dist/.external/esm/{fast-uri@3.0.6 → fast-uri@3.1.0}/fast-uri/index.mjs +51 -53
  7. package/dist/.external/esm/fast-uri@3.1.0/fast-uri/lib/schemes.mjs +214 -0
  8. package/dist/.external/esm/fast-uri@3.1.0/fast-uri/lib/utils.mjs +260 -0
  9. package/dist/core/cjs/Tables/NextGenDataGrid/NextGenDataGrid.cjs +1 -1
  10. package/dist/core/cjs/Tables/NextGenDataGrid/hooks/useColumns/FilterModeDescription.cjs +1 -1
  11. package/dist/core/cjs/Tables/NextGenDataGrid/hooks/useColumns/utils.cjs +8 -2
  12. package/dist/core/cjs/Tables/NextGenDataGrid/hooks/useToolbar/basicToolbars.cjs +1 -1
  13. package/dist/core/cjs/Tables/NextGenDataGrid/hooks/useToolbarAlertBanner/FASTAPI_RTK_ToolbarAlertBanner.cjs +1 -1
  14. package/dist/core/esm/Tables/NextGenDataGrid/NextGenDataGrid.mjs +1 -1
  15. package/dist/core/esm/Tables/NextGenDataGrid/hooks/useColumns/FilterModeDescription.mjs +1 -1
  16. package/dist/core/esm/Tables/NextGenDataGrid/hooks/useColumns/utils.mjs +8 -2
  17. package/dist/core/esm/Tables/NextGenDataGrid/hooks/useToolbar/basicToolbars.mjs +1 -1
  18. package/dist/core/esm/Tables/NextGenDataGrid/hooks/useToolbarAlertBanner/FASTAPI_RTK_ToolbarAlertBanner.mjs +1 -1
  19. package/package.json +1 -1
  20. package/dist/.external/cjs/fast-uri@3.0.6/fast-uri/lib/schemes.cjs +0 -149
  21. package/dist/.external/cjs/fast-uri@3.0.6/fast-uri/lib/scopedChars.cjs +0 -37
  22. package/dist/.external/cjs/fast-uri@3.0.6/fast-uri/lib/utils.cjs +0 -235
  23. package/dist/.external/esm/fast-uri@3.0.6/fast-uri/lib/schemes.mjs +0 -149
  24. package/dist/.external/esm/fast-uri@3.0.6/fast-uri/lib/scopedChars.mjs +0 -37
  25. package/dist/.external/esm/fast-uri@3.0.6/fast-uri/lib/utils.mjs +0 -235
  26. /package/dist/.external/cjs/{mantine-react-table@2.0.0-beta.9_@mantine_core@7.17.8_@mantine_dates@7.17.8_@mantine_hooks@7._ll5dfnmvjphm4bajaxt6oy7mty → mantine-react-table@2.0.0-beta.9_@mantine_core@7.17.8_@mantine_dates@7.17.8_@mantine_hooks@7._ug2uc7gqobpur37t5xiwwwh6ay}/mantine-react-table/dist/index.esm.cjs +0 -0
  27. /package/dist/.external/esm/{mantine-react-table@2.0.0-beta.9_@mantine_core@7.17.8_@mantine_dates@7.17.8_@mantine_hooks@7._ll5dfnmvjphm4bajaxt6oy7mty → mantine-react-table@2.0.0-beta.9_@mantine_core@7.17.8_@mantine_dates@7.17.8_@mantine_hooks@7._ug2uc7gqobpur37t5xiwwwh6ay}/mantine-react-table/dist/index.esm.mjs +0 -0
@@ -46,7 +46,10 @@ const getBasicInput = (opr, schema) => {
46
46
  return ({ componentProps }) => /* @__PURE__ */ jsxRuntime.jsx(
47
47
  HeaderSelectInput.HeaderSelectInput,
48
48
  {
49
- data: schema.values.map((item) => ({ value: String(utils.convertId(utils.getItemId(item))), label: item.value })),
49
+ data: schema.values.slice().sort((a, b) => a.value.localeCompare(b.value)).map((item) => ({
50
+ value: String(utils.convertId(utils.getItemId(item))),
51
+ label: item.value
52
+ })),
50
53
  ...componentProps
51
54
  }
52
55
  );
@@ -55,7 +58,10 @@ const getBasicInput = (opr, schema) => {
55
58
  return ({ componentProps }) => /* @__PURE__ */ jsxRuntime.jsx(
56
59
  HeaderMultiSelectInput.HeaderMultiSelectInput,
57
60
  {
58
- data: schema.values.map((item) => ({ value: String(utils.convertId(utils.getItemId(item))), label: item.value })),
61
+ data: schema.values.slice().sort((a, b) => a.value.localeCompare(b.value)).map((item) => ({
62
+ value: String(utils.convertId(utils.getItemId(item))),
63
+ label: item.value
64
+ })),
59
65
  ...componentProps
60
66
  }
61
67
  );
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
- const index_esm = require("../../../../../../.external/cjs/mantine-react-table@2.0.0-beta.9_@mantine_core@7.17.8_@mantine_dates@7.17.8_@mantine_hooks@7._ll5dfnmvjphm4bajaxt6oy7mty/mantine-react-table/dist/index.esm.cjs");
4
+ const index_esm = require("../../../../../../.external/cjs/mantine-react-table@2.0.0-beta.9_@mantine_core@7.17.8_@mantine_dates@7.17.8_@mantine_hooks@7._ug2uc7gqobpur37t5xiwwwh6ay/mantine-react-table/dist/index.esm.cjs");
5
5
  const Add = require("../../../../ActionIcons/Add/Add.cjs");
6
6
  const Download = require("../../../../ActionIcons/Download/Download.cjs");
7
7
  const Refresh = require("../../../../ActionIcons/Refresh/Refresh.cjs");
@@ -4,7 +4,7 @@ const jsxRuntime = require("react/jsx-runtime");
4
4
  const utils = require("fastapi-rtk/utils");
5
5
  const core = require("@mantine/core");
6
6
  const clsx = require("../../../../../../.external/cjs/clsx@2.1.1/clsx/dist/clsx.cjs");
7
- const index_esm = require("../../../../../../.external/cjs/mantine-react-table@2.0.0-beta.9_@mantine_core@7.17.8_@mantine_dates@7.17.8_@mantine_hooks@7._ll5dfnmvjphm4bajaxt6oy7mty/mantine-react-table/dist/index.esm.cjs");
7
+ const index_esm = require("../../../../../../.external/cjs/mantine-react-table@2.0.0-beta.9_@mantine_core@7.17.8_@mantine_dates@7.17.8_@mantine_hooks@7._ug2uc7gqobpur37t5xiwwwh6ay/mantine-react-table/dist/index.esm.cjs");
8
8
  const React = require("react");
9
9
  const FASTAPI_RTK_ToolbarAlertBanner_module = require("./FASTAPI_RTK_ToolbarAlertBanner.module.css.cjs");
10
10
  const FASTAPI_RTK_ToolbarAlertBanner = ({ alertBanner, table, ...rest }) => {
@@ -3,7 +3,7 @@ import { jsxs, jsx } from "react/jsx-runtime";
3
3
  /* empty css */
4
4
  import { deepMerge, mergeProps, getItemId } from "fastapi-rtk/utils";
5
5
  import { useProps, Box } from "@mantine/core";
6
- import { useMantineReactTable, MantineReactTable } from "../../../../.external/esm/mantine-react-table@2.0.0-beta.9_@mantine_core@7.17.8_@mantine_dates@7.17.8_@mantine_hooks@7._ll5dfnmvjphm4bajaxt6oy7mty/mantine-react-table/dist/index.esm.mjs";
6
+ import { useMantineReactTable, MantineReactTable } from "../../../../.external/esm/mantine-react-table@2.0.0-beta.9_@mantine_core@7.17.8_@mantine_dates@7.17.8_@mantine_hooks@7._ug2uc7gqobpur37t5xiwwwh6ay/mantine-react-table/dist/index.esm.mjs";
7
7
  import { forwardRef, useMemo, useEffect } from "react";
8
8
  import { AddDialog } from "../../ActionIcons/Add/AddDialog.mjs";
9
9
  import { EditDialog } from "../../ActionIcons/Edit/EditDialog.mjs";
@@ -1,7 +1,7 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { mergeProps } from "fastapi-rtk/utils";
3
3
  import { Input } from "@mantine/core";
4
- import { localizedFilterOption } from "../../../../../../.external/esm/mantine-react-table@2.0.0-beta.9_@mantine_core@7.17.8_@mantine_dates@7.17.8_@mantine_hooks@7._ll5dfnmvjphm4bajaxt6oy7mty/mantine-react-table/dist/index.esm.mjs";
4
+ import { localizedFilterOption } from "../../../../../../.external/esm/mantine-react-table@2.0.0-beta.9_@mantine_core@7.17.8_@mantine_dates@7.17.8_@mantine_hooks@7._ug2uc7gqobpur37t5xiwwwh6ay/mantine-react-table/dist/index.esm.mjs";
5
5
  import { useMemo } from "react";
6
6
  import { FallbackWrapper } from "../../FallbackWrapper.mjs";
7
7
  const FilterModeDescription = ({ table, column, opr, filters, filterModeDescription, functionProps }) => {
@@ -44,7 +44,10 @@ const getBasicInput = (opr, schema) => {
44
44
  return ({ componentProps }) => /* @__PURE__ */ jsx(
45
45
  HeaderSelectInput,
46
46
  {
47
- data: schema.values.map((item) => ({ value: String(convertId(getItemId(item))), label: item.value })),
47
+ data: schema.values.slice().sort((a, b) => a.value.localeCompare(b.value)).map((item) => ({
48
+ value: String(convertId(getItemId(item))),
49
+ label: item.value
50
+ })),
48
51
  ...componentProps
49
52
  }
50
53
  );
@@ -53,7 +56,10 @@ const getBasicInput = (opr, schema) => {
53
56
  return ({ componentProps }) => /* @__PURE__ */ jsx(
54
57
  HeaderMultiSelectInput,
55
58
  {
56
- data: schema.values.map((item) => ({ value: String(convertId(getItemId(item))), label: item.value })),
59
+ data: schema.values.slice().sort((a, b) => a.value.localeCompare(b.value)).map((item) => ({
60
+ value: String(convertId(getItemId(item))),
61
+ label: item.value
62
+ })),
57
63
  ...componentProps
58
64
  }
59
65
  );
@@ -1,5 +1,5 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { MRT_ToggleFullScreenButton, MRT_ToggleDensePaddingButton, MRT_ShowHideColumnsButton, MRT_ToggleFiltersButton, MRT_ToggleGlobalFilterButton } from "../../../../../../.external/esm/mantine-react-table@2.0.0-beta.9_@mantine_core@7.17.8_@mantine_dates@7.17.8_@mantine_hooks@7._ll5dfnmvjphm4bajaxt6oy7mty/mantine-react-table/dist/index.esm.mjs";
2
+ import { MRT_ToggleFullScreenButton, MRT_ToggleDensePaddingButton, MRT_ShowHideColumnsButton, MRT_ToggleFiltersButton, MRT_ToggleGlobalFilterButton } from "../../../../../../.external/esm/mantine-react-table@2.0.0-beta.9_@mantine_core@7.17.8_@mantine_dates@7.17.8_@mantine_hooks@7._ug2uc7gqobpur37t5xiwwwh6ay/mantine-react-table/dist/index.esm.mjs";
3
3
  import { Add } from "../../../../ActionIcons/Add/Add.mjs";
4
4
  import { Download } from "../../../../ActionIcons/Download/Download.mjs";
5
5
  import { Refresh } from "../../../../ActionIcons/Refresh/Refresh.mjs";
@@ -2,7 +2,7 @@ import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { parseFromValuesOrFunc, getValueOrDefault } from "fastapi-rtk/utils";
3
3
  import { Flex, Button, Group, Badge, ActionIcon, Stack } from "@mantine/core";
4
4
  import { clsx } from "../../../../../../.external/esm/clsx@2.1.1/clsx/dist/clsx.mjs";
5
- import { getMRT_SelectAllHandler, MRT_SelectCheckbox } from "../../../../../../.external/esm/mantine-react-table@2.0.0-beta.9_@mantine_core@7.17.8_@mantine_dates@7.17.8_@mantine_hooks@7._ll5dfnmvjphm4bajaxt6oy7mty/mantine-react-table/dist/index.esm.mjs";
5
+ import { getMRT_SelectAllHandler, MRT_SelectCheckbox } from "../../../../../../.external/esm/mantine-react-table@2.0.0-beta.9_@mantine_core@7.17.8_@mantine_dates@7.17.8_@mantine_hooks@7._ug2uc7gqobpur37t5xiwwwh6ay/mantine-react-table/dist/index.esm.mjs";
6
6
  import { useMemo, Fragment } from "react";
7
7
  import classes from "./FASTAPI_RTK_ToolbarAlertBanner.module.css.mjs";
8
8
  const FASTAPI_RTK_ToolbarAlertBanner = ({ alertBanner, table, ...rest }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fastapi-rtk",
3
- "version": "0.2.23",
3
+ "version": "0.2.24",
4
4
  "private": false,
5
5
  "description": "A React component library for FastAPI in combination with FastAPI React Toolkit backend, built with Mantine, JsonForms, and Zustand.",
6
6
  "license": "MIT",
@@ -1,149 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- var schemes;
4
- var hasRequiredSchemes;
5
- function requireSchemes() {
6
- if (hasRequiredSchemes) return schemes;
7
- hasRequiredSchemes = 1;
8
- const UUID_REG = /^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu;
9
- const URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;
10
- function isSecure(wsComponents) {
11
- return typeof wsComponents.secure === "boolean" ? wsComponents.secure : String(wsComponents.scheme).toLowerCase() === "wss";
12
- }
13
- function httpParse(components) {
14
- if (!components.host) {
15
- components.error = components.error || "HTTP URIs must have a host.";
16
- }
17
- return components;
18
- }
19
- function httpSerialize(components) {
20
- const secure = String(components.scheme).toLowerCase() === "https";
21
- if (components.port === (secure ? 443 : 80) || components.port === "") {
22
- components.port = void 0;
23
- }
24
- if (!components.path) {
25
- components.path = "/";
26
- }
27
- return components;
28
- }
29
- function wsParse(wsComponents) {
30
- wsComponents.secure = isSecure(wsComponents);
31
- wsComponents.resourceName = (wsComponents.path || "/") + (wsComponents.query ? "?" + wsComponents.query : "");
32
- wsComponents.path = void 0;
33
- wsComponents.query = void 0;
34
- return wsComponents;
35
- }
36
- function wsSerialize(wsComponents) {
37
- if (wsComponents.port === (isSecure(wsComponents) ? 443 : 80) || wsComponents.port === "") {
38
- wsComponents.port = void 0;
39
- }
40
- if (typeof wsComponents.secure === "boolean") {
41
- wsComponents.scheme = wsComponents.secure ? "wss" : "ws";
42
- wsComponents.secure = void 0;
43
- }
44
- if (wsComponents.resourceName) {
45
- const [path, query] = wsComponents.resourceName.split("?");
46
- wsComponents.path = path && path !== "/" ? path : void 0;
47
- wsComponents.query = query;
48
- wsComponents.resourceName = void 0;
49
- }
50
- wsComponents.fragment = void 0;
51
- return wsComponents;
52
- }
53
- function urnParse(urnComponents, options) {
54
- if (!urnComponents.path) {
55
- urnComponents.error = "URN can not be parsed";
56
- return urnComponents;
57
- }
58
- const matches = urnComponents.path.match(URN_REG);
59
- if (matches) {
60
- const scheme = options.scheme || urnComponents.scheme || "urn";
61
- urnComponents.nid = matches[1].toLowerCase();
62
- urnComponents.nss = matches[2];
63
- const urnScheme = `${scheme}:${options.nid || urnComponents.nid}`;
64
- const schemeHandler = SCHEMES[urnScheme];
65
- urnComponents.path = void 0;
66
- if (schemeHandler) {
67
- urnComponents = schemeHandler.parse(urnComponents, options);
68
- }
69
- } else {
70
- urnComponents.error = urnComponents.error || "URN can not be parsed.";
71
- }
72
- return urnComponents;
73
- }
74
- function urnSerialize(urnComponents, options) {
75
- const scheme = options.scheme || urnComponents.scheme || "urn";
76
- const nid = urnComponents.nid.toLowerCase();
77
- const urnScheme = `${scheme}:${options.nid || nid}`;
78
- const schemeHandler = SCHEMES[urnScheme];
79
- if (schemeHandler) {
80
- urnComponents = schemeHandler.serialize(urnComponents, options);
81
- }
82
- const uriComponents = urnComponents;
83
- const nss = urnComponents.nss;
84
- uriComponents.path = `${nid || options.nid}:${nss}`;
85
- options.skipEscape = true;
86
- return uriComponents;
87
- }
88
- function urnuuidParse(urnComponents, options) {
89
- const uuidComponents = urnComponents;
90
- uuidComponents.uuid = uuidComponents.nss;
91
- uuidComponents.nss = void 0;
92
- if (!options.tolerant && (!uuidComponents.uuid || !UUID_REG.test(uuidComponents.uuid))) {
93
- uuidComponents.error = uuidComponents.error || "UUID is not valid.";
94
- }
95
- return uuidComponents;
96
- }
97
- function urnuuidSerialize(uuidComponents) {
98
- const urnComponents = uuidComponents;
99
- urnComponents.nss = (uuidComponents.uuid || "").toLowerCase();
100
- return urnComponents;
101
- }
102
- const http = {
103
- scheme: "http",
104
- domainHost: true,
105
- parse: httpParse,
106
- serialize: httpSerialize
107
- };
108
- const https = {
109
- scheme: "https",
110
- domainHost: http.domainHost,
111
- parse: httpParse,
112
- serialize: httpSerialize
113
- };
114
- const ws = {
115
- scheme: "ws",
116
- domainHost: true,
117
- parse: wsParse,
118
- serialize: wsSerialize
119
- };
120
- const wss = {
121
- scheme: "wss",
122
- domainHost: ws.domainHost,
123
- parse: ws.parse,
124
- serialize: ws.serialize
125
- };
126
- const urn = {
127
- scheme: "urn",
128
- parse: urnParse,
129
- serialize: urnSerialize,
130
- skipNormalize: true
131
- };
132
- const urnuuid = {
133
- scheme: "urn:uuid",
134
- parse: urnuuidParse,
135
- serialize: urnuuidSerialize,
136
- skipNormalize: true
137
- };
138
- const SCHEMES = {
139
- http,
140
- https,
141
- ws,
142
- wss,
143
- urn,
144
- "urn:uuid": urnuuid
145
- };
146
- schemes = SCHEMES;
147
- return schemes;
148
- }
149
- exports.__require = requireSchemes;
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- var scopedChars;
4
- var hasRequiredScopedChars;
5
- function requireScopedChars() {
6
- if (hasRequiredScopedChars) return scopedChars;
7
- hasRequiredScopedChars = 1;
8
- const HEX = {
9
- 0: 0,
10
- 1: 1,
11
- 2: 2,
12
- 3: 3,
13
- 4: 4,
14
- 5: 5,
15
- 6: 6,
16
- 7: 7,
17
- 8: 8,
18
- 9: 9,
19
- a: 10,
20
- A: 10,
21
- b: 11,
22
- B: 11,
23
- c: 12,
24
- C: 12,
25
- d: 13,
26
- D: 13,
27
- e: 14,
28
- E: 14,
29
- f: 15,
30
- F: 15
31
- };
32
- scopedChars = {
33
- HEX
34
- };
35
- return scopedChars;
36
- }
37
- exports.__require = requireScopedChars;
@@ -1,235 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const scopedChars = require("./scopedChars.cjs");
4
- var utils;
5
- var hasRequiredUtils;
6
- function requireUtils() {
7
- if (hasRequiredUtils) return utils;
8
- hasRequiredUtils = 1;
9
- const { HEX } = scopedChars.__require();
10
- const IPV4_REG = /^(?:(?: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;
11
- function normalizeIPv4(host) {
12
- if (findToken(host, ".") < 3) {
13
- return { host, isIPV4: false };
14
- }
15
- const matches = host.match(IPV4_REG) || [];
16
- const [address] = matches;
17
- if (address) {
18
- return { host: stripLeadingZeros(address, "."), isIPV4: true };
19
- } else {
20
- return { host, isIPV4: false };
21
- }
22
- }
23
- function stringArrayToHexStripped(input, keepZero = false) {
24
- let acc = "";
25
- let strip = true;
26
- for (const c of input) {
27
- if (HEX[c] === void 0) return void 0;
28
- if (c !== "0" && strip === true) strip = false;
29
- if (!strip) acc += c;
30
- }
31
- if (keepZero && acc.length === 0) acc = "0";
32
- return acc;
33
- }
34
- function getIPV6(input) {
35
- let tokenCount = 0;
36
- const output = { error: false, address: "", zone: "" };
37
- const address = [];
38
- const buffer = [];
39
- let isZone = false;
40
- let endipv6Encountered = false;
41
- let endIpv6 = false;
42
- function consume() {
43
- if (buffer.length) {
44
- if (isZone === false) {
45
- const hex = stringArrayToHexStripped(buffer);
46
- if (hex !== void 0) {
47
- address.push(hex);
48
- } else {
49
- output.error = true;
50
- return false;
51
- }
52
- }
53
- buffer.length = 0;
54
- }
55
- return true;
56
- }
57
- for (let i = 0; i < input.length; i++) {
58
- const cursor = input[i];
59
- if (cursor === "[" || cursor === "]") {
60
- continue;
61
- }
62
- if (cursor === ":") {
63
- if (endipv6Encountered === true) {
64
- endIpv6 = true;
65
- }
66
- if (!consume()) {
67
- break;
68
- }
69
- tokenCount++;
70
- address.push(":");
71
- if (tokenCount > 7) {
72
- output.error = true;
73
- break;
74
- }
75
- if (i - 1 >= 0 && input[i - 1] === ":") {
76
- endipv6Encountered = true;
77
- }
78
- continue;
79
- } else if (cursor === "%") {
80
- if (!consume()) {
81
- break;
82
- }
83
- isZone = true;
84
- } else {
85
- buffer.push(cursor);
86
- continue;
87
- }
88
- }
89
- if (buffer.length) {
90
- if (isZone) {
91
- output.zone = buffer.join("");
92
- } else if (endIpv6) {
93
- address.push(buffer.join(""));
94
- } else {
95
- address.push(stringArrayToHexStripped(buffer));
96
- }
97
- }
98
- output.address = address.join("");
99
- return output;
100
- }
101
- function normalizeIPv6(host) {
102
- if (findToken(host, ":") < 2) {
103
- return { host, isIPV6: false };
104
- }
105
- const ipv6 = getIPV6(host);
106
- if (!ipv6.error) {
107
- let newHost = ipv6.address;
108
- let escapedHost = ipv6.address;
109
- if (ipv6.zone) {
110
- newHost += "%" + ipv6.zone;
111
- escapedHost += "%25" + ipv6.zone;
112
- }
113
- return { host: newHost, escapedHost, isIPV6: true };
114
- } else {
115
- return { host, isIPV6: false };
116
- }
117
- }
118
- function stripLeadingZeros(str, token) {
119
- let out = "";
120
- let skip = true;
121
- const l = str.length;
122
- for (let i = 0; i < l; i++) {
123
- const c = str[i];
124
- if (c === "0" && skip) {
125
- if (i + 1 <= l && str[i + 1] === token || i + 1 === l) {
126
- out += c;
127
- skip = false;
128
- }
129
- } else {
130
- if (c === token) {
131
- skip = true;
132
- } else {
133
- skip = false;
134
- }
135
- out += c;
136
- }
137
- }
138
- return out;
139
- }
140
- function findToken(str, token) {
141
- let ind = 0;
142
- for (let i = 0; i < str.length; i++) {
143
- if (str[i] === token) ind++;
144
- }
145
- return ind;
146
- }
147
- const RDS1 = /^\.\.?\//u;
148
- const RDS2 = /^\/\.(?:\/|$)/u;
149
- const RDS3 = /^\/\.\.(?:\/|$)/u;
150
- const RDS5 = /^\/?(?:.|\n)*?(?=\/|$)/u;
151
- function removeDotSegments(input) {
152
- const output = [];
153
- while (input.length) {
154
- if (input.match(RDS1)) {
155
- input = input.replace(RDS1, "");
156
- } else if (input.match(RDS2)) {
157
- input = input.replace(RDS2, "/");
158
- } else if (input.match(RDS3)) {
159
- input = input.replace(RDS3, "/");
160
- output.pop();
161
- } else if (input === "." || input === "..") {
162
- input = "";
163
- } else {
164
- const im = input.match(RDS5);
165
- if (im) {
166
- const s = im[0];
167
- input = input.slice(s.length);
168
- output.push(s);
169
- } else {
170
- throw new Error("Unexpected dot segment condition");
171
- }
172
- }
173
- }
174
- return output.join("");
175
- }
176
- function normalizeComponentEncoding(components, esc) {
177
- const func = esc !== true ? escape : unescape;
178
- if (components.scheme !== void 0) {
179
- components.scheme = func(components.scheme);
180
- }
181
- if (components.userinfo !== void 0) {
182
- components.userinfo = func(components.userinfo);
183
- }
184
- if (components.host !== void 0) {
185
- components.host = func(components.host);
186
- }
187
- if (components.path !== void 0) {
188
- components.path = func(components.path);
189
- }
190
- if (components.query !== void 0) {
191
- components.query = func(components.query);
192
- }
193
- if (components.fragment !== void 0) {
194
- components.fragment = func(components.fragment);
195
- }
196
- return components;
197
- }
198
- function recomposeAuthority(components) {
199
- const uriTokens = [];
200
- if (components.userinfo !== void 0) {
201
- uriTokens.push(components.userinfo);
202
- uriTokens.push("@");
203
- }
204
- if (components.host !== void 0) {
205
- let host = unescape(components.host);
206
- const ipV4res = normalizeIPv4(host);
207
- if (ipV4res.isIPV4) {
208
- host = ipV4res.host;
209
- } else {
210
- const ipV6res = normalizeIPv6(ipV4res.host);
211
- if (ipV6res.isIPV6 === true) {
212
- host = `[${ipV6res.escapedHost}]`;
213
- } else {
214
- host = components.host;
215
- }
216
- }
217
- uriTokens.push(host);
218
- }
219
- if (typeof components.port === "number" || typeof components.port === "string") {
220
- uriTokens.push(":");
221
- uriTokens.push(String(components.port));
222
- }
223
- return uriTokens.length ? uriTokens.join("") : void 0;
224
- }
225
- utils = {
226
- recomposeAuthority,
227
- normalizeComponentEncoding,
228
- removeDotSegments,
229
- normalizeIPv4,
230
- normalizeIPv6,
231
- stringArrayToHexStripped
232
- };
233
- return utils;
234
- }
235
- exports.__require = requireUtils;