@kubb/agent 5.0.0-alpha.34 → 5.0.0-alpha.36
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/.output/nitro.json +1 -1
- package/.output/server/chunks/nitro/nitro.mjs +1790 -20812
- package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
- package/.output/server/chunks/routes/api/health.get.mjs +16 -14
- package/.output/server/chunks/routes/api/health.get.mjs.map +1 -1
- package/.output/server/index.mjs +16 -14
- package/.output/server/index.mjs.map +1 -1
- package/.output/server/node_modules/.nitro/ws@8.18.0/lib/constants.js +18 -0
- package/.output/server/node_modules/.nitro/ws@8.18.0/lib/permessage-deflate.js +514 -0
- package/.output/server/node_modules/.nitro/ws@8.18.0/lib/sender.js +602 -0
- package/.output/server/node_modules/.nitro/ws@8.18.0/lib/stream.js +159 -0
- package/.output/server/node_modules/.nitro/ws@8.18.0/lib/websocket-server.js +540 -0
- package/.output/server/node_modules/.nitro/ws@8.18.0/lib/websocket.js +1388 -0
- package/.output/server/node_modules/.nitro/ws@8.18.0/package.json +69 -0
- package/.output/server/node_modules/.nitro/ws@8.18.0/wrapper.mjs +8 -0
- package/.output/server/node_modules/.nitro/ws@8.20.0/lib/buffer-util.js +131 -0
- package/.output/server/node_modules/.nitro/ws@8.20.0/lib/event-target.js +292 -0
- package/.output/server/node_modules/.nitro/ws@8.20.0/lib/extension.js +203 -0
- package/.output/server/node_modules/.nitro/ws@8.20.0/lib/limiter.js +55 -0
- package/.output/server/node_modules/.nitro/ws@8.20.0/lib/receiver.js +706 -0
- package/.output/server/node_modules/.nitro/ws@8.20.0/lib/subprotocol.js +62 -0
- package/.output/server/node_modules/.nitro/ws@8.20.0/lib/validation.js +152 -0
- package/.output/server/node_modules/@clack/core/dist/index.mjs +11 -0
- package/.output/server/node_modules/@clack/core/package.json +60 -0
- package/.output/server/node_modules/@clack/prompts/dist/index.mjs +137 -0
- package/.output/server/node_modules/@clack/prompts/package.json +65 -0
- package/.output/server/node_modules/@kubb/ast/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/ast/dist/index.js +423 -0
- package/.output/server/node_modules/@kubb/ast/package.json +70 -0
- package/.output/server/node_modules/@kubb/core/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/core/dist/hooks.js +23 -0
- package/.output/server/node_modules/@kubb/core/dist/index.js +2311 -0
- package/.output/server/node_modules/@kubb/core/package.json +109 -0
- package/.output/server/node_modules/@kubb/fabric-core/dist/chunk-O_arW02_.js +17 -0
- package/.output/server/node_modules/@kubb/fabric-core/dist/defaultParser-iCpMSYCp.js +15 -0
- package/.output/server/node_modules/@kubb/fabric-core/dist/getRelativePath-NAm_Y-vp.js +55 -0
- package/.output/server/node_modules/@kubb/fabric-core/dist/index.js +653 -0
- package/.output/server/node_modules/@kubb/fabric-core/dist/onProcessExit-Cput7j2c.js +742 -0
- package/.output/server/node_modules/@kubb/fabric-core/dist/parsers/typescript.js +101 -0
- package/.output/server/node_modules/@kubb/fabric-core/dist/parsers.js +17 -0
- package/.output/server/node_modules/@kubb/fabric-core/dist/plugins.js +375 -0
- package/.output/server/node_modules/@kubb/fabric-core/package.json +111 -0
- package/.output/server/node_modules/@kubb/oas/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/oas/dist/index.js +918 -0
- package/.output/server/node_modules/@kubb/oas/package.json +94 -0
- package/.output/server/node_modules/@kubb/plugin-client/dist/StaticClassClient-bCe7RG_w.js +636 -0
- package/.output/server/node_modules/@kubb/plugin-client/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-client/dist/components.js +2 -0
- package/.output/server/node_modules/@kubb/plugin-client/dist/generators-BffddRNu.js +723 -0
- package/.output/server/node_modules/@kubb/plugin-client/dist/index.js +124 -0
- package/.output/server/node_modules/@kubb/plugin-client/dist/templates/clients/axios.source.js +6 -0
- package/.output/server/node_modules/@kubb/plugin-client/dist/templates/clients/fetch.source.js +6 -0
- package/.output/server/node_modules/@kubb/plugin-client/dist/templates/config.source.js +6 -0
- package/.output/server/node_modules/@kubb/plugin-client/package.json +153 -0
- package/.output/server/node_modules/@kubb/plugin-cypress/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-cypress/dist/components-BK_6GU4v.js +257 -0
- package/.output/server/node_modules/@kubb/plugin-cypress/dist/generators-D5YFtyyC.js +71 -0
- package/.output/server/node_modules/@kubb/plugin-cypress/dist/index.js +79 -0
- package/.output/server/node_modules/@kubb/plugin-cypress/package.json +108 -0
- package/.output/server/node_modules/@kubb/plugin-faker/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-faker/dist/components-BkBIov4R.js +419 -0
- package/.output/server/node_modules/@kubb/plugin-faker/dist/fakerGenerator-BztogaeO.js +200 -0
- package/.output/server/node_modules/@kubb/plugin-faker/dist/index.js +141 -0
- package/.output/server/node_modules/@kubb/plugin-faker/package.json +103 -0
- package/.output/server/node_modules/@kubb/plugin-mcp/dist/Server-H3SwqhwF.js +178 -0
- package/.output/server/node_modules/@kubb/plugin-mcp/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-mcp/dist/generators-BqkMrcs9.js +274 -0
- package/.output/server/node_modules/@kubb/plugin-mcp/dist/index.js +122 -0
- package/.output/server/node_modules/@kubb/plugin-mcp/package.json +107 -0
- package/.output/server/node_modules/@kubb/plugin-msw/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-msw/dist/components-DgtTZkWX.js +277 -0
- package/.output/server/node_modules/@kubb/plugin-msw/dist/generators-C34kqa1L.js +161 -0
- package/.output/server/node_modules/@kubb/plugin-msw/dist/index.js +84 -0
- package/.output/server/node_modules/@kubb/plugin-msw/package.json +109 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/SchemaMapper-CqMkO2T1.js +58 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/generators-D7C3CXsN.js +79 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/generators.js +2 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/getFooter-Pw3tLCiV.js +112 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/hooks.js +200 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/index.js +408 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/requestBody-pRavthCw.js +1336 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/utils.js +268 -0
- package/.output/server/node_modules/@kubb/plugin-oas/package.json +122 -0
- package/.output/server/node_modules/@kubb/plugin-react-query/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-react-query/dist/components-CpyHYGOw.js +1520 -0
- package/.output/server/node_modules/@kubb/plugin-react-query/dist/generators-CpiBv5eE.js +1427 -0
- package/.output/server/node_modules/@kubb/plugin-react-query/dist/index.js +166 -0
- package/.output/server/node_modules/@kubb/plugin-react-query/package.json +112 -0
- package/.output/server/node_modules/@kubb/plugin-redoc/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-redoc/dist/index.js +65 -0
- package/.output/server/node_modules/@kubb/plugin-redoc/package.json +85 -0
- package/.output/server/node_modules/@kubb/plugin-redoc/static/redoc.hbs +22 -0
- package/.output/server/node_modules/@kubb/plugin-solid-query/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-solid-query/dist/components-BhStIi1M.js +665 -0
- package/.output/server/node_modules/@kubb/plugin-solid-query/dist/generators-CQClzsST.js +415 -0
- package/.output/server/node_modules/@kubb/plugin-solid-query/dist/index.js +145 -0
- package/.output/server/node_modules/@kubb/plugin-solid-query/package.json +113 -0
- package/.output/server/node_modules/@kubb/plugin-svelte-query/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-svelte-query/dist/components-DntKBsnB.js +666 -0
- package/.output/server/node_modules/@kubb/plugin-svelte-query/dist/generators-BtTsGGrM.js +414 -0
- package/.output/server/node_modules/@kubb/plugin-svelte-query/dist/index.js +145 -0
- package/.output/server/node_modules/@kubb/plugin-svelte-query/package.json +113 -0
- package/.output/server/node_modules/@kubb/plugin-swr/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-swr/dist/components-DRDGvgXG.js +702 -0
- package/.output/server/node_modules/@kubb/plugin-swr/dist/generators-ClWZJ-YG.js +399 -0
- package/.output/server/node_modules/@kubb/plugin-swr/dist/index.js +144 -0
- package/.output/server/node_modules/@kubb/plugin-swr/package.json +115 -0
- package/.output/server/node_modules/@kubb/plugin-ts/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-ts/dist/components-C7fu-sK1.js +723 -0
- package/.output/server/node_modules/@kubb/plugin-ts/dist/index.js +2 -0
- package/.output/server/node_modules/@kubb/plugin-ts/dist/plugin-CYC-FGXe.js +479 -0
- package/.output/server/node_modules/@kubb/plugin-ts/package.json +105 -0
- package/.output/server/node_modules/@kubb/plugin-vue-query/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-vue-query/dist/components-_AMBl0g-.js +1029 -0
- package/.output/server/node_modules/@kubb/plugin-vue-query/dist/generators-Zb1s5Wmb.js +661 -0
- package/.output/server/node_modules/@kubb/plugin-vue-query/dist/index.js +157 -0
- package/.output/server/node_modules/@kubb/plugin-vue-query/package.json +114 -0
- package/.output/server/node_modules/@kubb/plugin-zod/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-zod/dist/components-eECfXVou.js +842 -0
- package/.output/server/node_modules/@kubb/plugin-zod/dist/generators-D1R6NNf2.js +290 -0
- package/.output/server/node_modules/@kubb/plugin-zod/dist/index.js +175 -0
- package/.output/server/node_modules/@kubb/plugin-zod/dist/templates/ToZod.source.js +6 -0
- package/.output/server/node_modules/@kubb/plugin-zod/package.json +112 -0
- package/.output/server/node_modules/@kubb/react-fabric/dist/chunk-BGCRLu6H.js +38 -0
- package/.output/server/node_modules/@kubb/react-fabric/dist/index.js +525 -0
- package/.output/server/node_modules/@kubb/react-fabric/dist/jsx-runtime-Bl0DfUmV.js +1448 -0
- package/.output/server/node_modules/@kubb/react-fabric/dist/jsx-runtime.js +12 -0
- package/.output/server/node_modules/@kubb/react-fabric/dist/parsers.js +2 -0
- package/.output/server/node_modules/@kubb/react-fabric/dist/plugins.js +4 -0
- package/.output/server/node_modules/@kubb/react-fabric/dist/reactPlugin-QQPrjNuQ.js +17813 -0
- package/.output/server/node_modules/@kubb/react-fabric/package.json +143 -0
- package/.output/server/node_modules/@redocly/config/lib/root-config-schema.js +11 -1
- package/.output/server/node_modules/@redocly/config/package.json +1 -1
- package/.output/server/node_modules/@redocly/openapi-core/lib/bundle/bundle-document.js +25 -10
- package/.output/server/node_modules/@redocly/openapi-core/lib/bundle/bundle-visitor.js +32 -29
- package/.output/server/node_modules/@redocly/openapi-core/lib/config/config.js +5 -0
- package/.output/server/node_modules/@redocly/openapi-core/lib/decorators/oas2/index.js +1 -1
- package/.output/server/node_modules/@redocly/openapi-core/lib/decorators/oas2/remove-unused-components.js +47 -38
- package/.output/server/node_modules/@redocly/openapi-core/lib/decorators/oas3/index.js +1 -1
- package/.output/server/node_modules/@redocly/openapi-core/lib/decorators/oas3/remove-unused-components.js +45 -41
- package/.output/server/node_modules/@redocly/openapi-core/lib/rules/common/no-http-verbs-in-paths.js +3 -1
- package/.output/server/node_modules/@redocly/openapi-core/lib/rules/common/no-required-schema-properties-undefined.js +41 -55
- package/.output/server/node_modules/@redocly/openapi-core/lib/walk.js +28 -16
- package/.output/server/node_modules/@redocly/openapi-core/package.json +2 -2
- package/.output/server/node_modules/buffer-from/index.js +72 -0
- package/.output/server/node_modules/buffer-from/package.json +19 -0
- package/.output/server/node_modules/fast-string-truncated-width/dist/index.js +171 -0
- package/.output/server/node_modules/fast-string-truncated-width/dist/utils.js +15 -0
- package/.output/server/node_modules/fast-string-truncated-width/package.json +35 -0
- package/.output/server/node_modules/fast-string-width/dist/index.js +14 -0
- package/.output/server/node_modules/fast-string-width/package.json +34 -0
- package/.output/server/node_modules/fast-wrap-ansi/lib/main.js +216 -0
- package/.output/server/node_modules/fast-wrap-ansi/package.json +51 -0
- package/.output/server/node_modules/p-limit/index.js +127 -0
- package/.output/server/node_modules/p-limit/package.json +58 -0
- package/.output/server/node_modules/react-devtools-core/dist/backend.js +18302 -0
- package/.output/server/node_modules/react-devtools-core/package.json +38 -0
- package/.output/server/node_modules/sisteransi/package.json +34 -0
- package/.output/server/node_modules/sisteransi/src/index.js +58 -0
- package/.output/server/node_modules/source-map-support/package.json +31 -0
- package/.output/server/node_modules/source-map-support/source-map-support.js +625 -0
- package/.output/server/node_modules/typescript/lib/typescript.js +200276 -0
- package/.output/server/node_modules/typescript/package.json +120 -0
- package/.output/server/node_modules/yocto-queue/index.js +90 -0
- package/.output/server/node_modules/yocto-queue/package.json +48 -0
- package/.output/server/package.json +35 -4
- package/package.json +20 -20
- /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/buffer-util.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/event-target.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/extension.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/limiter.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/receiver.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/subprotocol.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/validation.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/constants.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/permessage-deflate.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/sender.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/stream.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/websocket-server.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/websocket.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/package.json +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/wrapper.mjs +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { isRef } from '../../ref-utils.js';
|
|
2
1
|
import { getOwn } from '../../utils/get-own.js';
|
|
2
|
+
import { isNotEmptyArray } from '../../utils/is-not-empty-array.js';
|
|
3
|
+
import { resolveSchema } from '../utils.js';
|
|
3
4
|
export const NoRequiredSchemaPropertiesUndefined = () => {
|
|
4
5
|
const parents = [];
|
|
5
6
|
return {
|
|
@@ -7,67 +8,52 @@ export const NoRequiredSchemaPropertiesUndefined = () => {
|
|
|
7
8
|
leave(_) {
|
|
8
9
|
parents.pop();
|
|
9
10
|
},
|
|
10
|
-
enter(
|
|
11
|
-
parents.push(
|
|
12
|
-
if (!
|
|
11
|
+
enter(currentSchema, ctx) {
|
|
12
|
+
parents.push(currentSchema);
|
|
13
|
+
if (!currentSchema.required)
|
|
13
14
|
return;
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
const hasProperty = (schemaOrRef, propertyName, visited, resolveFrom) => {
|
|
16
|
+
const { schema, location } = resolveSchema(schemaOrRef, ctx, resolveFrom);
|
|
17
|
+
if (!schema || visited.has(schema))
|
|
18
|
+
return false;
|
|
19
|
+
visited.add(schema);
|
|
20
|
+
if (schema.properties && getOwn(schema.properties, propertyName) !== undefined) {
|
|
21
|
+
return true;
|
|
19
22
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const resolved = resolve(schema, from);
|
|
23
|
-
if (!resolved.node) {
|
|
24
|
-
return {};
|
|
25
|
-
}
|
|
26
|
-
return elevateProperties(resolved.node, resolved.location?.source.absoluteRef);
|
|
23
|
+
if (schema.allOf?.some((s) => hasProperty(s, propertyName, visited, location))) {
|
|
24
|
+
return true;
|
|
27
25
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
if (isNotEmptyArray(schema.anyOf) &&
|
|
27
|
+
schema.anyOf.every((s) => hasProperty(s, propertyName, new Set(visited), location))) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
if (isNotEmptyArray(schema.oneOf) &&
|
|
31
|
+
schema.oneOf.every((s) => hasProperty(s, propertyName, new Set(visited), location))) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
33
35
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const getParentSchema = (lookupIndex) => {
|
|
40
|
-
lookupIndex++;
|
|
41
|
-
if (!parents || parents.length < lookupIndex)
|
|
42
|
-
return undefined;
|
|
43
|
-
const parent = parents[parents.length - lookupIndex];
|
|
44
|
-
return parent;
|
|
36
|
+
const isCompositionChild = (parent, child) => {
|
|
37
|
+
const matchesChild = (s) => resolveSchema(s, ctx).schema === child;
|
|
38
|
+
return !!(parent.allOf?.some(matchesChild) ||
|
|
39
|
+
parent.anyOf?.some(matchesChild) ||
|
|
40
|
+
parent.oneOf?.some(matchesChild));
|
|
45
41
|
};
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
?
|
|
52
|
-
: undefined;
|
|
53
|
-
const grandParentProperties = splitLocation.length >= locationLookupIndex + locationLookupIndex
|
|
54
|
-
? recursivelyGetParentProperties(splitLocation.slice(0, -locationLookupIndex), parentLookupIndex)
|
|
55
|
-
: {};
|
|
56
|
-
return parentSchema
|
|
57
|
-
? {
|
|
58
|
-
...elevateProperties(parentSchema, undefined, false),
|
|
59
|
-
...grandParentProperties,
|
|
60
|
-
}
|
|
42
|
+
const findCompositionRoot = (i, child) => {
|
|
43
|
+
if (i < 0)
|
|
44
|
+
return undefined;
|
|
45
|
+
const parent = parents[i];
|
|
46
|
+
return isCompositionChild(parent, child)
|
|
47
|
+
? (findCompositionRoot(i - 1, parent) ?? parent)
|
|
61
48
|
: undefined;
|
|
62
49
|
};
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
location: location.child(['required', i]),
|
|
50
|
+
const compositionRoot = findCompositionRoot(parents.length - 2, currentSchema);
|
|
51
|
+
for (const [i, requiredProperty] of currentSchema.required.entries()) {
|
|
52
|
+
if (!hasProperty(currentSchema, requiredProperty, new Set()) &&
|
|
53
|
+
!hasProperty(compositionRoot, requiredProperty, new Set())) {
|
|
54
|
+
ctx.report({
|
|
55
|
+
message: `Required property '${requiredProperty}' is not defined.`,
|
|
56
|
+
location: ctx.location.child(['required', i]),
|
|
71
57
|
});
|
|
72
58
|
}
|
|
73
59
|
}
|
|
@@ -27,6 +27,17 @@ export function walkDocument(opts) {
|
|
|
27
27
|
const { document, rootType, normalizedVisitors, resolvedRefMap, ctx } = opts;
|
|
28
28
|
const seenNodesPerType = {};
|
|
29
29
|
const ignoredNodes = new Set();
|
|
30
|
+
// Pre-compute combined enter/leave arrays per type to avoid per-node array allocations
|
|
31
|
+
const anyEnter = normalizedVisitors.any.enter;
|
|
32
|
+
const anyLeave = normalizedVisitors.any.leave;
|
|
33
|
+
const combinedEnter = {};
|
|
34
|
+
const combinedLeave = {};
|
|
35
|
+
for (const typeName of Object.keys(normalizedVisitors)) {
|
|
36
|
+
if (typeName === 'any' || typeName === 'ref')
|
|
37
|
+
continue;
|
|
38
|
+
combinedEnter[typeName] = anyEnter.concat(normalizedVisitors[typeName]?.enter || []);
|
|
39
|
+
combinedLeave[typeName] = (normalizedVisitors[typeName]?.leave || []).concat(anyLeave);
|
|
40
|
+
}
|
|
30
41
|
walkNode(document.parsed, rootType, new Location(document.source, '#/'), undefined, '');
|
|
31
42
|
function walkNode(node, type, location, parent, key) {
|
|
32
43
|
const resolve = (ref, from = currentLocation.source.absoluteRef) => {
|
|
@@ -50,13 +61,14 @@ export function walkDocument(opts) {
|
|
|
50
61
|
};
|
|
51
62
|
const rawLocation = location;
|
|
52
63
|
let currentLocation = location;
|
|
64
|
+
const nodeIsRef = isRef(node);
|
|
53
65
|
const { node: resolvedNode, location: resolvedLocation, error } = resolve(node);
|
|
54
66
|
const enteredContexts = new Set();
|
|
55
|
-
if (
|
|
67
|
+
if (nodeIsRef) {
|
|
56
68
|
const refEnterVisitors = normalizedVisitors.ref.enter;
|
|
57
69
|
for (const { visit: visitor, ruleId, severity, message, context } of refEnterVisitors) {
|
|
58
70
|
enteredContexts.add(context);
|
|
59
|
-
const report = reportFn
|
|
71
|
+
const report = (opts) => reportFn(ruleId, severity, message, opts);
|
|
60
72
|
visitor(node, {
|
|
61
73
|
report,
|
|
62
74
|
resolve,
|
|
@@ -69,7 +81,7 @@ export function walkDocument(opts) {
|
|
|
69
81
|
parentLocations: {},
|
|
70
82
|
specVersion: ctx.specVersion,
|
|
71
83
|
config: ctx.config,
|
|
72
|
-
getVisitorData: getVisitorDataFn
|
|
84
|
+
getVisitorData: () => getVisitorDataFn(ruleId),
|
|
73
85
|
}, { node: resolvedNode, location: resolvedLocation, error });
|
|
74
86
|
if (resolvedLocation?.source.absoluteRef && ctx.refTypes) {
|
|
75
87
|
ctx.refTypes.set(resolvedLocation?.source.absoluteRef, type);
|
|
@@ -80,11 +92,11 @@ export function walkDocument(opts) {
|
|
|
80
92
|
currentLocation = resolvedLocation;
|
|
81
93
|
const isNodeSeen = seenNodesPerType[type.name]?.has?.(resolvedNode);
|
|
82
94
|
let visitedBySome = false;
|
|
83
|
-
const
|
|
84
|
-
const currentEnterVisitors = anyEnterVisitors.concat(normalizedVisitors[type.name]?.enter || []);
|
|
95
|
+
const currentEnterVisitors = combinedEnter[type.name] || anyEnter.concat(normalizedVisitors[type.name]?.enter || []);
|
|
85
96
|
const activatedContexts = [];
|
|
97
|
+
const ignoreKey = `${currentLocation.absolutePointer}${currentLocation.pointer}`;
|
|
86
98
|
for (const { context, visit, skip, ruleId, severity, message } of currentEnterVisitors) {
|
|
87
|
-
if (ignoredNodes.has(
|
|
99
|
+
if (ignoredNodes.has(ignoreKey))
|
|
88
100
|
break;
|
|
89
101
|
if (context.isSkippedLevel) {
|
|
90
102
|
if (context.parent.activatedOn &&
|
|
@@ -141,8 +153,9 @@ export function walkDocument(opts) {
|
|
|
141
153
|
if (itemsType !== undefined) {
|
|
142
154
|
const isTypeAFunction = typeof itemsType === 'function';
|
|
143
155
|
for (let i = 0; i < resolvedNode.length; i++) {
|
|
156
|
+
const itemLocation = resolvedLocation.child([i]);
|
|
144
157
|
let itemType = isTypeAFunction
|
|
145
|
-
? itemsType(resolvedNode[i],
|
|
158
|
+
? itemsType(resolvedNode[i], itemLocation.absolutePointer)
|
|
146
159
|
: itemsType;
|
|
147
160
|
let itemValue = resolvedNode[i];
|
|
148
161
|
if (itemType?.directResolveAs) {
|
|
@@ -150,7 +163,7 @@ export function walkDocument(opts) {
|
|
|
150
163
|
itemValue = { $ref: itemValue };
|
|
151
164
|
}
|
|
152
165
|
if (isNamedType(itemType)) {
|
|
153
|
-
walkNode(itemValue, itemType,
|
|
166
|
+
walkNode(itemValue, itemType, itemLocation, resolvedNode, i);
|
|
154
167
|
}
|
|
155
168
|
}
|
|
156
169
|
}
|
|
@@ -164,7 +177,7 @@ export function walkDocument(opts) {
|
|
|
164
177
|
else if (type.extensionsPrefix) {
|
|
165
178
|
props.push(...Object.keys(resolvedNode).filter((k) => k.startsWith(type.extensionsPrefix)));
|
|
166
179
|
}
|
|
167
|
-
if (
|
|
180
|
+
if (nodeIsRef) {
|
|
168
181
|
props.push(...Object.keys(node).filter((k) => k !== '$ref' && !props.includes(k))); // properties on the same level as $ref
|
|
169
182
|
}
|
|
170
183
|
for (const propName of props) {
|
|
@@ -202,8 +215,7 @@ export function walkDocument(opts) {
|
|
|
202
215
|
}
|
|
203
216
|
}
|
|
204
217
|
}
|
|
205
|
-
const
|
|
206
|
-
const currentLeaveVisitors = (normalizedVisitors[type.name]?.leave || []).concat(anyLeaveVisitors);
|
|
218
|
+
const currentLeaveVisitors = combinedLeave[type.name] || (normalizedVisitors[type.name]?.leave || []).concat(anyLeave);
|
|
207
219
|
for (const context of activatedContexts.reverse()) {
|
|
208
220
|
if (context.isSkippedLevel) {
|
|
209
221
|
context.seen.delete(resolvedNode);
|
|
@@ -226,11 +238,11 @@ export function walkDocument(opts) {
|
|
|
226
238
|
}
|
|
227
239
|
}
|
|
228
240
|
currentLocation = location;
|
|
229
|
-
if (
|
|
241
|
+
if (nodeIsRef) {
|
|
230
242
|
const refLeaveVisitors = normalizedVisitors.ref.leave;
|
|
231
243
|
for (const { visit: visitor, ruleId, severity, context, message } of refLeaveVisitors) {
|
|
232
244
|
if (enteredContexts.has(context)) {
|
|
233
|
-
const report = reportFn
|
|
245
|
+
const report = (opts) => reportFn(ruleId, severity, message, opts);
|
|
234
246
|
visitor(node, {
|
|
235
247
|
report,
|
|
236
248
|
resolve,
|
|
@@ -243,14 +255,14 @@ export function walkDocument(opts) {
|
|
|
243
255
|
parentLocations: {},
|
|
244
256
|
specVersion: ctx.specVersion,
|
|
245
257
|
config: ctx.config,
|
|
246
|
-
getVisitorData: getVisitorDataFn
|
|
258
|
+
getVisitorData: () => getVisitorDataFn(ruleId),
|
|
247
259
|
}, { node: resolvedNode, location: resolvedLocation, error });
|
|
248
260
|
}
|
|
249
261
|
}
|
|
250
262
|
}
|
|
251
263
|
// returns true ignores all the next visitors on the specific node
|
|
252
264
|
function visitWithContext(visit, resolvedNode, node, context, ruleId, severity, customMessage) {
|
|
253
|
-
const report = reportFn
|
|
265
|
+
const report = (opts) => reportFn(ruleId, severity, customMessage, opts);
|
|
254
266
|
visit(resolvedNode, {
|
|
255
267
|
report,
|
|
256
268
|
resolve,
|
|
@@ -266,7 +278,7 @@ export function walkDocument(opts) {
|
|
|
266
278
|
ignoreNextVisitorsOnNode: () => {
|
|
267
279
|
ignoredNodes.add(`${currentLocation.absolutePointer}${currentLocation.pointer}`);
|
|
268
280
|
},
|
|
269
|
-
getVisitorData: getVisitorDataFn
|
|
281
|
+
getVisitorData: () => getVisitorDataFn(ruleId),
|
|
270
282
|
}, collectParents(context), context);
|
|
271
283
|
}
|
|
272
284
|
function reportFn(ruleId, severity, customMessage, opts) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/openapi-core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.28.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
],
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@redocly/ajv": "^8.18.0",
|
|
56
|
-
"@redocly/config": "^0.
|
|
56
|
+
"@redocly/config": "^0.48.0",
|
|
57
57
|
"ajv": "npm:@redocly/ajv@8.18.0",
|
|
58
58
|
"ajv-formats": "^3.0.1",
|
|
59
59
|
"colorette": "^1.2.0",
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/* eslint-disable node/no-deprecated-api */
|
|
2
|
+
|
|
3
|
+
var toString = Object.prototype.toString
|
|
4
|
+
|
|
5
|
+
var isModern = (
|
|
6
|
+
typeof Buffer !== 'undefined' &&
|
|
7
|
+
typeof Buffer.alloc === 'function' &&
|
|
8
|
+
typeof Buffer.allocUnsafe === 'function' &&
|
|
9
|
+
typeof Buffer.from === 'function'
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
function isArrayBuffer (input) {
|
|
13
|
+
return toString.call(input).slice(8, -1) === 'ArrayBuffer'
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function fromArrayBuffer (obj, byteOffset, length) {
|
|
17
|
+
byteOffset >>>= 0
|
|
18
|
+
|
|
19
|
+
var maxLength = obj.byteLength - byteOffset
|
|
20
|
+
|
|
21
|
+
if (maxLength < 0) {
|
|
22
|
+
throw new RangeError("'offset' is out of bounds")
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (length === undefined) {
|
|
26
|
+
length = maxLength
|
|
27
|
+
} else {
|
|
28
|
+
length >>>= 0
|
|
29
|
+
|
|
30
|
+
if (length > maxLength) {
|
|
31
|
+
throw new RangeError("'length' is out of bounds")
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return isModern
|
|
36
|
+
? Buffer.from(obj.slice(byteOffset, byteOffset + length))
|
|
37
|
+
: new Buffer(new Uint8Array(obj.slice(byteOffset, byteOffset + length)))
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function fromString (string, encoding) {
|
|
41
|
+
if (typeof encoding !== 'string' || encoding === '') {
|
|
42
|
+
encoding = 'utf8'
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!Buffer.isEncoding(encoding)) {
|
|
46
|
+
throw new TypeError('"encoding" must be a valid string encoding')
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return isModern
|
|
50
|
+
? Buffer.from(string, encoding)
|
|
51
|
+
: new Buffer(string, encoding)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function bufferFrom (value, encodingOrOffset, length) {
|
|
55
|
+
if (typeof value === 'number') {
|
|
56
|
+
throw new TypeError('"value" argument must not be a number')
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (isArrayBuffer(value)) {
|
|
60
|
+
return fromArrayBuffer(value, encodingOrOffset, length)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (typeof value === 'string') {
|
|
64
|
+
return fromString(value, encodingOrOffset)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return isModern
|
|
68
|
+
? Buffer.from(value)
|
|
69
|
+
: new Buffer(value)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
module.exports = bufferFrom
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "buffer-from",
|
|
3
|
+
"version": "1.1.2",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"repository": "LinusU/buffer-from",
|
|
6
|
+
"files": [
|
|
7
|
+
"index.js"
|
|
8
|
+
],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "standard && node test"
|
|
11
|
+
},
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"standard": "^12.0.1"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"buffer",
|
|
17
|
+
"buffer from"
|
|
18
|
+
]
|
|
19
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/* IMPORT */
|
|
2
|
+
import { isAmbiguous, isFullWidth, isWide } from './utils.js';
|
|
3
|
+
/* HELPERS */
|
|
4
|
+
const ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
|
|
5
|
+
const CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
|
|
6
|
+
const TAB_RE = /\t{1,1000}/y;
|
|
7
|
+
const EMOJI_RE = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu;
|
|
8
|
+
const LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
|
|
9
|
+
const MODIFIER_RE = /\p{M}+/gu;
|
|
10
|
+
const NO_TRUNCATION = { limit: Infinity, ellipsis: '' };
|
|
11
|
+
/* MAIN */
|
|
12
|
+
//TODO: Optimize matching non-latin letters
|
|
13
|
+
const getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
|
|
14
|
+
/* CONSTANTS */
|
|
15
|
+
const LIMIT = truncationOptions.limit ?? Infinity;
|
|
16
|
+
const ELLIPSIS = truncationOptions.ellipsis ?? '';
|
|
17
|
+
const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION, widthOptions).width : 0);
|
|
18
|
+
const ANSI_WIDTH = widthOptions.ansiWidth ?? 0;
|
|
19
|
+
const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
|
|
20
|
+
const TAB_WIDTH = widthOptions.tabWidth ?? 8;
|
|
21
|
+
const AMBIGUOUS_WIDTH = widthOptions.ambiguousWidth ?? 1;
|
|
22
|
+
const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
|
|
23
|
+
const FULL_WIDTH_WIDTH = widthOptions.fullWidthWidth ?? 2;
|
|
24
|
+
const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
|
|
25
|
+
const WIDE_WIDTH = widthOptions.wideWidth ?? 2;
|
|
26
|
+
/* STATE */
|
|
27
|
+
let indexPrev = 0;
|
|
28
|
+
let index = 0;
|
|
29
|
+
let length = input.length;
|
|
30
|
+
let lengthExtra = 0;
|
|
31
|
+
let truncationEnabled = false;
|
|
32
|
+
let truncationIndex = length;
|
|
33
|
+
let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
|
|
34
|
+
let unmatchedStart = 0;
|
|
35
|
+
let unmatchedEnd = 0;
|
|
36
|
+
let width = 0;
|
|
37
|
+
let widthExtra = 0;
|
|
38
|
+
/* PARSE LOOP */
|
|
39
|
+
outer: while (true) {
|
|
40
|
+
/* UNMATCHED */
|
|
41
|
+
if ((unmatchedEnd > unmatchedStart) || (index >= length && index > indexPrev)) {
|
|
42
|
+
const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
|
|
43
|
+
lengthExtra = 0;
|
|
44
|
+
for (const char of unmatched.replaceAll(MODIFIER_RE, '')) {
|
|
45
|
+
const codePoint = char.codePointAt(0) || 0;
|
|
46
|
+
if (isFullWidth(codePoint)) {
|
|
47
|
+
widthExtra = FULL_WIDTH_WIDTH;
|
|
48
|
+
}
|
|
49
|
+
else if (isWide(codePoint)) {
|
|
50
|
+
widthExtra = WIDE_WIDTH;
|
|
51
|
+
}
|
|
52
|
+
else if (AMBIGUOUS_WIDTH !== REGULAR_WIDTH && isAmbiguous(codePoint)) {
|
|
53
|
+
widthExtra = AMBIGUOUS_WIDTH;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
widthExtra = REGULAR_WIDTH;
|
|
57
|
+
}
|
|
58
|
+
if ((width + widthExtra) > truncationLimit) {
|
|
59
|
+
truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
|
|
60
|
+
}
|
|
61
|
+
if ((width + widthExtra) > LIMIT) {
|
|
62
|
+
truncationEnabled = true;
|
|
63
|
+
break outer;
|
|
64
|
+
}
|
|
65
|
+
lengthExtra += char.length;
|
|
66
|
+
width += widthExtra;
|
|
67
|
+
}
|
|
68
|
+
unmatchedStart = unmatchedEnd = 0;
|
|
69
|
+
}
|
|
70
|
+
/* EXITING */
|
|
71
|
+
if (index >= length)
|
|
72
|
+
break;
|
|
73
|
+
/* LATIN */
|
|
74
|
+
LATIN_RE.lastIndex = index;
|
|
75
|
+
if (LATIN_RE.test(input)) {
|
|
76
|
+
lengthExtra = LATIN_RE.lastIndex - index;
|
|
77
|
+
widthExtra = lengthExtra * REGULAR_WIDTH;
|
|
78
|
+
if ((width + widthExtra) > truncationLimit) {
|
|
79
|
+
truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / REGULAR_WIDTH));
|
|
80
|
+
}
|
|
81
|
+
if ((width + widthExtra) > LIMIT) {
|
|
82
|
+
truncationEnabled = true;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
width += widthExtra;
|
|
86
|
+
unmatchedStart = indexPrev;
|
|
87
|
+
unmatchedEnd = index;
|
|
88
|
+
index = indexPrev = LATIN_RE.lastIndex;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
/* ANSI */
|
|
92
|
+
ANSI_RE.lastIndex = index;
|
|
93
|
+
if (ANSI_RE.test(input)) {
|
|
94
|
+
if ((width + ANSI_WIDTH) > truncationLimit) {
|
|
95
|
+
truncationIndex = Math.min(truncationIndex, index);
|
|
96
|
+
}
|
|
97
|
+
if ((width + ANSI_WIDTH) > LIMIT) {
|
|
98
|
+
truncationEnabled = true;
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
width += ANSI_WIDTH;
|
|
102
|
+
unmatchedStart = indexPrev;
|
|
103
|
+
unmatchedEnd = index;
|
|
104
|
+
index = indexPrev = ANSI_RE.lastIndex;
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
/* CONTROL */
|
|
108
|
+
CONTROL_RE.lastIndex = index;
|
|
109
|
+
if (CONTROL_RE.test(input)) {
|
|
110
|
+
lengthExtra = CONTROL_RE.lastIndex - index;
|
|
111
|
+
widthExtra = lengthExtra * CONTROL_WIDTH;
|
|
112
|
+
if ((width + widthExtra) > truncationLimit) {
|
|
113
|
+
truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / CONTROL_WIDTH));
|
|
114
|
+
}
|
|
115
|
+
if ((width + widthExtra) > LIMIT) {
|
|
116
|
+
truncationEnabled = true;
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
width += widthExtra;
|
|
120
|
+
unmatchedStart = indexPrev;
|
|
121
|
+
unmatchedEnd = index;
|
|
122
|
+
index = indexPrev = CONTROL_RE.lastIndex;
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
/* TAB */
|
|
126
|
+
TAB_RE.lastIndex = index;
|
|
127
|
+
if (TAB_RE.test(input)) {
|
|
128
|
+
lengthExtra = TAB_RE.lastIndex - index;
|
|
129
|
+
widthExtra = lengthExtra * TAB_WIDTH;
|
|
130
|
+
if ((width + widthExtra) > truncationLimit) {
|
|
131
|
+
truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / TAB_WIDTH));
|
|
132
|
+
}
|
|
133
|
+
if ((width + widthExtra) > LIMIT) {
|
|
134
|
+
truncationEnabled = true;
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
width += widthExtra;
|
|
138
|
+
unmatchedStart = indexPrev;
|
|
139
|
+
unmatchedEnd = index;
|
|
140
|
+
index = indexPrev = TAB_RE.lastIndex;
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
/* EMOJI */
|
|
144
|
+
EMOJI_RE.lastIndex = index;
|
|
145
|
+
if (EMOJI_RE.test(input)) {
|
|
146
|
+
if ((width + EMOJI_WIDTH) > truncationLimit) {
|
|
147
|
+
truncationIndex = Math.min(truncationIndex, index);
|
|
148
|
+
}
|
|
149
|
+
if ((width + EMOJI_WIDTH) > LIMIT) {
|
|
150
|
+
truncationEnabled = true;
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
width += EMOJI_WIDTH;
|
|
154
|
+
unmatchedStart = indexPrev;
|
|
155
|
+
unmatchedEnd = index;
|
|
156
|
+
index = indexPrev = EMOJI_RE.lastIndex;
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
/* UNMATCHED INDEX */
|
|
160
|
+
index += 1;
|
|
161
|
+
}
|
|
162
|
+
/* RETURN */
|
|
163
|
+
return {
|
|
164
|
+
width: truncationEnabled ? truncationLimit : width,
|
|
165
|
+
index: truncationEnabled ? truncationIndex : length,
|
|
166
|
+
truncated: truncationEnabled,
|
|
167
|
+
ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
/* EXPORT */
|
|
171
|
+
export default getStringTruncatedWidth;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* MAIN */
|
|
2
|
+
//URL: https://github.com/sindresorhus/get-east-asian-width/blob/main/lookup.js
|
|
3
|
+
//LICENSE: https://github.com/sindresorhus/get-east-asian-width/blob/main/license
|
|
4
|
+
//TODO: Replace these with some unicode property classes, if the ones we need exist
|
|
5
|
+
const isAmbiguous = (x) => {
|
|
6
|
+
return x === 0xA1 || x === 0xA4 || x === 0xA7 || x === 0xA8 || x === 0xAA || x === 0xAD || x === 0xAE || x >= 0xB0 && x <= 0xB4 || x >= 0xB6 && x <= 0xBA || x >= 0xBC && x <= 0xBF || x === 0xC6 || x === 0xD0 || x === 0xD7 || x === 0xD8 || x >= 0xDE && x <= 0xE1 || x === 0xE6 || x >= 0xE8 && x <= 0xEA || x === 0xEC || x === 0xED || x === 0xF0 || x === 0xF2 || x === 0xF3 || x >= 0xF7 && x <= 0xFA || x === 0xFC || x === 0xFE || x === 0x101 || x === 0x111 || x === 0x113 || x === 0x11B || x === 0x126 || x === 0x127 || x === 0x12B || x >= 0x131 && x <= 0x133 || x === 0x138 || x >= 0x13F && x <= 0x142 || x === 0x144 || x >= 0x148 && x <= 0x14B || x === 0x14D || x === 0x152 || x === 0x153 || x === 0x166 || x === 0x167 || x === 0x16B || x === 0x1CE || x === 0x1D0 || x === 0x1D2 || x === 0x1D4 || x === 0x1D6 || x === 0x1D8 || x === 0x1DA || x === 0x1DC || x === 0x251 || x === 0x261 || x === 0x2C4 || x === 0x2C7 || x >= 0x2C9 && x <= 0x2CB || x === 0x2CD || x === 0x2D0 || x >= 0x2D8 && x <= 0x2DB || x === 0x2DD || x === 0x2DF || x >= 0x300 && x <= 0x36F || x >= 0x391 && x <= 0x3A1 || x >= 0x3A3 && x <= 0x3A9 || x >= 0x3B1 && x <= 0x3C1 || x >= 0x3C3 && x <= 0x3C9 || x === 0x401 || x >= 0x410 && x <= 0x44F || x === 0x451 || x === 0x2010 || x >= 0x2013 && x <= 0x2016 || x === 0x2018 || x === 0x2019 || x === 0x201C || x === 0x201D || x >= 0x2020 && x <= 0x2022 || x >= 0x2024 && x <= 0x2027 || x === 0x2030 || x === 0x2032 || x === 0x2033 || x === 0x2035 || x === 0x203B || x === 0x203E || x === 0x2074 || x === 0x207F || x >= 0x2081 && x <= 0x2084 || x === 0x20AC || x === 0x2103 || x === 0x2105 || x === 0x2109 || x === 0x2113 || x === 0x2116 || x === 0x2121 || x === 0x2122 || x === 0x2126 || x === 0x212B || x === 0x2153 || x === 0x2154 || x >= 0x215B && x <= 0x215E || x >= 0x2160 && x <= 0x216B || x >= 0x2170 && x <= 0x2179 || x === 0x2189 || x >= 0x2190 && x <= 0x2199 || x === 0x21B8 || x === 0x21B9 || x === 0x21D2 || x === 0x21D4 || x === 0x21E7 || x === 0x2200 || x === 0x2202 || x === 0x2203 || x === 0x2207 || x === 0x2208 || x === 0x220B || x === 0x220F || x === 0x2211 || x === 0x2215 || x === 0x221A || x >= 0x221D && x <= 0x2220 || x === 0x2223 || x === 0x2225 || x >= 0x2227 && x <= 0x222C || x === 0x222E || x >= 0x2234 && x <= 0x2237 || x === 0x223C || x === 0x223D || x === 0x2248 || x === 0x224C || x === 0x2252 || x === 0x2260 || x === 0x2261 || x >= 0x2264 && x <= 0x2267 || x === 0x226A || x === 0x226B || x === 0x226E || x === 0x226F || x === 0x2282 || x === 0x2283 || x === 0x2286 || x === 0x2287 || x === 0x2295 || x === 0x2299 || x === 0x22A5 || x === 0x22BF || x === 0x2312 || x >= 0x2460 && x <= 0x24E9 || x >= 0x24EB && x <= 0x254B || x >= 0x2550 && x <= 0x2573 || x >= 0x2580 && x <= 0x258F || x >= 0x2592 && x <= 0x2595 || x === 0x25A0 || x === 0x25A1 || x >= 0x25A3 && x <= 0x25A9 || x === 0x25B2 || x === 0x25B3 || x === 0x25B6 || x === 0x25B7 || x === 0x25BC || x === 0x25BD || x === 0x25C0 || x === 0x25C1 || x >= 0x25C6 && x <= 0x25C8 || x === 0x25CB || x >= 0x25CE && x <= 0x25D1 || x >= 0x25E2 && x <= 0x25E5 || x === 0x25EF || x === 0x2605 || x === 0x2606 || x === 0x2609 || x === 0x260E || x === 0x260F || x === 0x261C || x === 0x261E || x === 0x2640 || x === 0x2642 || x === 0x2660 || x === 0x2661 || x >= 0x2663 && x <= 0x2665 || x >= 0x2667 && x <= 0x266A || x === 0x266C || x === 0x266D || x === 0x266F || x === 0x269E || x === 0x269F || x === 0x26BF || x >= 0x26C6 && x <= 0x26CD || x >= 0x26CF && x <= 0x26D3 || x >= 0x26D5 && x <= 0x26E1 || x === 0x26E3 || x === 0x26E8 || x === 0x26E9 || x >= 0x26EB && x <= 0x26F1 || x === 0x26F4 || x >= 0x26F6 && x <= 0x26F9 || x === 0x26FB || x === 0x26FC || x === 0x26FE || x === 0x26FF || x === 0x273D || x >= 0x2776 && x <= 0x277F || x >= 0x2B56 && x <= 0x2B59 || x >= 0x3248 && x <= 0x324F || x >= 0xE000 && x <= 0xF8FF || x >= 0xFE00 && x <= 0xFE0F || x === 0xFFFD || x >= 0x1F100 && x <= 0x1F10A || x >= 0x1F110 && x <= 0x1F12D || x >= 0x1F130 && x <= 0x1F169 || x >= 0x1F170 && x <= 0x1F18D || x === 0x1F18F || x === 0x1F190 || x >= 0x1F19B && x <= 0x1F1AC || x >= 0xE0100 && x <= 0xE01EF || x >= 0xF0000 && x <= 0xFFFFD || x >= 0x100000 && x <= 0x10FFFD;
|
|
7
|
+
};
|
|
8
|
+
const isFullWidth = (x) => {
|
|
9
|
+
return x === 0x3000 || x >= 0xFF01 && x <= 0xFF60 || x >= 0xFFE0 && x <= 0xFFE6;
|
|
10
|
+
};
|
|
11
|
+
const isWide = (x) => {
|
|
12
|
+
return x >= 0x1100 && x <= 0x115F || x === 0x231A || x === 0x231B || x === 0x2329 || x === 0x232A || x >= 0x23E9 && x <= 0x23EC || x === 0x23F0 || x === 0x23F3 || x === 0x25FD || x === 0x25FE || x === 0x2614 || x === 0x2615 || x >= 0x2648 && x <= 0x2653 || x === 0x267F || x === 0x2693 || x === 0x26A1 || x === 0x26AA || x === 0x26AB || x === 0x26BD || x === 0x26BE || x === 0x26C4 || x === 0x26C5 || x === 0x26CE || x === 0x26D4 || x === 0x26EA || x === 0x26F2 || x === 0x26F3 || x === 0x26F5 || x === 0x26FA || x === 0x26FD || x === 0x2705 || x === 0x270A || x === 0x270B || x === 0x2728 || x === 0x274C || x === 0x274E || x >= 0x2753 && x <= 0x2755 || x === 0x2757 || x >= 0x2795 && x <= 0x2797 || x === 0x27B0 || x === 0x27BF || x === 0x2B1B || x === 0x2B1C || x === 0x2B50 || x === 0x2B55 || x >= 0x2E80 && x <= 0x2E99 || x >= 0x2E9B && x <= 0x2EF3 || x >= 0x2F00 && x <= 0x2FD5 || x >= 0x2FF0 && x <= 0x2FFF || x >= 0x3001 && x <= 0x303E || x >= 0x3041 && x <= 0x3096 || x >= 0x3099 && x <= 0x30FF || x >= 0x3105 && x <= 0x312F || x >= 0x3131 && x <= 0x318E || x >= 0x3190 && x <= 0x31E3 || x >= 0x31EF && x <= 0x321E || x >= 0x3220 && x <= 0x3247 || x >= 0x3250 && x <= 0x4DBF || x >= 0x4E00 && x <= 0xA48C || x >= 0xA490 && x <= 0xA4C6 || x >= 0xA960 && x <= 0xA97C || x >= 0xAC00 && x <= 0xD7A3 || x >= 0xF900 && x <= 0xFAFF || x >= 0xFE10 && x <= 0xFE19 || x >= 0xFE30 && x <= 0xFE52 || x >= 0xFE54 && x <= 0xFE66 || x >= 0xFE68 && x <= 0xFE6B || x >= 0x16FE0 && x <= 0x16FE4 || x === 0x16FF0 || x === 0x16FF1 || x >= 0x17000 && x <= 0x187F7 || x >= 0x18800 && x <= 0x18CD5 || x >= 0x18D00 && x <= 0x18D08 || x >= 0x1AFF0 && x <= 0x1AFF3 || x >= 0x1AFF5 && x <= 0x1AFFB || x === 0x1AFFD || x === 0x1AFFE || x >= 0x1B000 && x <= 0x1B122 || x === 0x1B132 || x >= 0x1B150 && x <= 0x1B152 || x === 0x1B155 || x >= 0x1B164 && x <= 0x1B167 || x >= 0x1B170 && x <= 0x1B2FB || x === 0x1F004 || x === 0x1F0CF || x === 0x1F18E || x >= 0x1F191 && x <= 0x1F19A || x >= 0x1F200 && x <= 0x1F202 || x >= 0x1F210 && x <= 0x1F23B || x >= 0x1F240 && x <= 0x1F248 || x === 0x1F250 || x === 0x1F251 || x >= 0x1F260 && x <= 0x1F265 || x >= 0x1F300 && x <= 0x1F320 || x >= 0x1F32D && x <= 0x1F335 || x >= 0x1F337 && x <= 0x1F37C || x >= 0x1F37E && x <= 0x1F393 || x >= 0x1F3A0 && x <= 0x1F3CA || x >= 0x1F3CF && x <= 0x1F3D3 || x >= 0x1F3E0 && x <= 0x1F3F0 || x === 0x1F3F4 || x >= 0x1F3F8 && x <= 0x1F43E || x === 0x1F440 || x >= 0x1F442 && x <= 0x1F4FC || x >= 0x1F4FF && x <= 0x1F53D || x >= 0x1F54B && x <= 0x1F54E || x >= 0x1F550 && x <= 0x1F567 || x === 0x1F57A || x === 0x1F595 || x === 0x1F596 || x === 0x1F5A4 || x >= 0x1F5FB && x <= 0x1F64F || x >= 0x1F680 && x <= 0x1F6C5 || x === 0x1F6CC || x >= 0x1F6D0 && x <= 0x1F6D2 || x >= 0x1F6D5 && x <= 0x1F6D7 || x >= 0x1F6DC && x <= 0x1F6DF || x === 0x1F6EB || x === 0x1F6EC || x >= 0x1F6F4 && x <= 0x1F6FC || x >= 0x1F7E0 && x <= 0x1F7EB || x === 0x1F7F0 || x >= 0x1F90C && x <= 0x1F93A || x >= 0x1F93C && x <= 0x1F945 || x >= 0x1F947 && x <= 0x1F9FF || x >= 0x1FA70 && x <= 0x1FA7C || x >= 0x1FA80 && x <= 0x1FA88 || x >= 0x1FA90 && x <= 0x1FABD || x >= 0x1FABF && x <= 0x1FAC5 || x >= 0x1FACE && x <= 0x1FADB || x >= 0x1FAE0 && x <= 0x1FAE8 || x >= 0x1FAF0 && x <= 0x1FAF8 || x >= 0x20000 && x <= 0x2FFFD || x >= 0x30000 && x <= 0x3FFFD;
|
|
13
|
+
};
|
|
14
|
+
/* EXPORT */
|
|
15
|
+
export { isAmbiguous, isFullWidth, isWide };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "fast-string-truncated-width",
|
|
3
|
+
"repository": "github:fabiospampinato/fast-string-truncated-width",
|
|
4
|
+
"description": "A fast function for calculating where a string should be truncated, given an optional width limit and an ellipsis string.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"version": "1.2.1",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"exports": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"benchmark": "tsex benchmark",
|
|
13
|
+
"benchmark:watch": "tsex benchmark --watch",
|
|
14
|
+
"clean": "tsex clean",
|
|
15
|
+
"compile": "tsex compile",
|
|
16
|
+
"compile:watch": "tsex compile --watch",
|
|
17
|
+
"test": "tsex test",
|
|
18
|
+
"test:watch": "tsex test --watch",
|
|
19
|
+
"prepublishOnly": "tsex prepare"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"fast",
|
|
23
|
+
"string",
|
|
24
|
+
"truncated",
|
|
25
|
+
"width",
|
|
26
|
+
"cli",
|
|
27
|
+
"terminal"
|
|
28
|
+
],
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"benchloop": "^2.1.1",
|
|
31
|
+
"fava": "^0.3.4",
|
|
32
|
+
"tsex": "^4.0.2",
|
|
33
|
+
"typescript": "^5.7.3"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* IMPORT */
|
|
2
|
+
import fastStringTruncatedWidth from 'fast-string-truncated-width';
|
|
3
|
+
/* HELPERS */
|
|
4
|
+
const NO_TRUNCATION = {
|
|
5
|
+
limit: Infinity,
|
|
6
|
+
ellipsis: '',
|
|
7
|
+
ellipsisWidth: 0,
|
|
8
|
+
};
|
|
9
|
+
/* MAIN */
|
|
10
|
+
const fastStringWidth = (input, options = {}) => {
|
|
11
|
+
return fastStringTruncatedWidth(input, NO_TRUNCATION, options).width;
|
|
12
|
+
};
|
|
13
|
+
/* EXPORT */
|
|
14
|
+
export default fastStringWidth;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "fast-string-width",
|
|
3
|
+
"repository": "github:fabiospampinato/fast-string-width",
|
|
4
|
+
"description": "A fast function for calculating the visual width of a string once printed to the terminal.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"version": "1.1.0",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"exports": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"clean": "tsex clean",
|
|
13
|
+
"compile": "tsex compile",
|
|
14
|
+
"compile:watch": "tsex compile --watch",
|
|
15
|
+
"test": "tsex test",
|
|
16
|
+
"test:watch": "tsex test --watch",
|
|
17
|
+
"prepublishOnly": "tsex prepare"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"fast",
|
|
21
|
+
"string",
|
|
22
|
+
"width",
|
|
23
|
+
"cli",
|
|
24
|
+
"terminal"
|
|
25
|
+
],
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"fast-string-truncated-width": "^1.2.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"fava": "^0.3.4",
|
|
31
|
+
"tsex": "^4.0.2",
|
|
32
|
+
"typescript": "^5.7.3"
|
|
33
|
+
}
|
|
34
|
+
}
|