fumadocs-openapi 10.8.4 → 10.8.6
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/css/generated/shared.css +22 -1
- package/dist/generate-file.d.ts +1 -1
- package/dist/generate-file.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/node_modules/.pnpm/{@scalar_helpers@0.6.0 → @scalar_helpers@0.8.0}/node_modules/@scalar/helpers/dist/general/create-limiter.js +1 -1
- package/dist/node_modules/.pnpm/{@scalar_helpers@0.6.0 → @scalar_helpers@0.8.0}/node_modules/@scalar/helpers/dist/object/is-object.js +1 -1
- package/dist/node_modules/.pnpm/{@scalar_helpers@0.6.0 → @scalar_helpers@0.8.0}/node_modules/@scalar/helpers/dist/object/prevent-pollution.js +1 -1
- package/dist/node_modules/.pnpm/{@scalar_helpers@0.6.0 → @scalar_helpers@0.8.0}/node_modules/@scalar/helpers/dist/queue/queue.js +1 -1
- package/dist/node_modules/.pnpm/{@scalar_helpers@0.6.0 → @scalar_helpers@0.8.0}/node_modules/@scalar/helpers/dist/string/generate-hash.js +1 -1
- package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/bundle/bundle.js +2 -2
- package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/bundle/plugins/fetch-urls/index.js +2 -2
- package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/bundle/plugins/read-files/index.js +1 -1
- package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/bundle/value-generator.js +2 -2
- package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/helpers/convert-to-local-ref.js +1 -1
- package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/helpers/escape-json-pointer.js +1 -1
- package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/helpers/get-schemas.js +1 -1
- package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/helpers/get-segments-from-path.js +1 -1
- package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/helpers/get-value-by-path.js +1 -1
- package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/helpers/is-file-path.js +1 -1
- package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/helpers/is-http-url.js +1 -1
- package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/helpers/is-json-object.js +2 -2
- package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/helpers/is-yaml.js +1 -1
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/normalize.js +33 -0
- package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/helpers/resolve-reference-path.js +1 -1
- package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/helpers/set-value-at-path.js +2 -2
- package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/helpers/to-relative-path.js +1 -1
- package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/helpers/unescape-json-pointer.js +1 -1
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/2020.js +110 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/code.js +138 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/index.js +674 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/scope.js +141 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/errors.js +102 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/index.js +223 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/names.js +28 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/ref_error.js +18 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/resolve.js +133 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/rules.js +61 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/util.js +146 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/applicability.js +23 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/boolSchema.js +48 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/dataType.js +172 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/defaults.js +31 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/index.js +433 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/keyword.js +113 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/subschema.js +72 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/core.js +583 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/data.js +18 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/index.js +42 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/applicator.js +50 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/content.js +20 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/core.js +51 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/format-annotation.js +16 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/meta-data.js +36 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/unevaluated.js +19 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/validation.js +85 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/schema.js +59 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/equal.js +12 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/ucs2length.js +25 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/uri.js +12 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/validation_error.js +16 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +57 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +96 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/allOf.js +29 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +16 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/contains.js +89 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +87 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/dependentSchemas.js +16 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/if.js +62 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/index.js +60 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/items.js +59 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/items2020.js +34 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/not.js +31 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +51 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +61 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +17 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/properties.js +52 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +41 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +17 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/code.js +130 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/id.js +14 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/index.js +22 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/ref.js +112 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/discriminator/index.js +101 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/discriminator/types.js +14 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/draft2020.js +35 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/dynamicAnchor.js +46 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/dynamicRef.js +45 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/index.js +22 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/recursiveAnchor.js +20 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/recursiveRef.js +15 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/format/format.js +92 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/format/index.js +10 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/metadata.js +23 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/next.js +19 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/unevaluated/index.js +13 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedItems.js +46 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.js +59 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/const.js +27 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/dependentRequired.js +17 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/enum.js +49 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/index.js +48 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitContains.js +18 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitItems.js +28 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitLength.js +33 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +47 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +28 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +27 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/pattern.js +38 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/required.js +72 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +70 -0
- package/dist/node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js +33 -0
- package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/index.js +236 -0
- package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/schemes.js +187 -0
- package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/utils.js +282 -0
- package/dist/node_modules/.pnpm/json-schema-traverse@1.0.0/node_modules/json-schema-traverse/index.js +78 -0
- package/dist/playground/client.js +1 -1
- package/dist/playground/schema.d.ts +0 -2
- package/dist/playground/schema.js +3 -2
- package/dist/server/index.d.ts +108 -3
- package/dist/server/index.js +181 -2
- package/dist/server/proxy.d.ts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/ui/base.d.ts +1 -1
- package/dist/ui/components/method-label.js +1 -4
- package/dist/ui/index.d.ts +1 -1
- package/dist/utils/document/process.js +4 -4
- package/dist/utils/pages/builder.d.ts +4 -3
- package/dist/utils/pages/builder.js +20 -1
- package/dist/utils/pages/to-text.d.ts +1 -1
- package/dist/utils/pages/to-text.js +23 -42
- package/package.json +12 -8
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.12/node_modules/@scalar/json-magic/dist/helpers/normalize.js +0 -26
- package/dist/server/create.d.ts +0 -40
- package/dist/server/create.js +0 -42
- package/dist/server/source-api.d.ts +0 -55
- package/dist/server/source-api.js +0 -149
- /package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/bundle/plugins/node.js +0 -0
- /package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/bundle/plugins/parse-yaml/index.js +0 -0
package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/required.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { __commonJSMin } from "../../../../../../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { require_codegen } from "../../compile/codegen/index.js";
|
|
3
|
+
import { require_util } from "../../compile/util.js";
|
|
4
|
+
import { require_code } from "../code.js";
|
|
5
|
+
//#region ../../node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/required.js
|
|
6
|
+
var require_required = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
const code_1 = require_code();
|
|
9
|
+
const codegen_1 = require_codegen();
|
|
10
|
+
const util_1 = require_util();
|
|
11
|
+
exports.default = {
|
|
12
|
+
keyword: "required",
|
|
13
|
+
type: "object",
|
|
14
|
+
schemaType: "array",
|
|
15
|
+
$data: true,
|
|
16
|
+
error: {
|
|
17
|
+
message: ({ params: { missingProperty } }) => (0, codegen_1.str)`must have required property '${missingProperty}'`,
|
|
18
|
+
params: ({ params: { missingProperty } }) => (0, codegen_1._)`{missingProperty: ${missingProperty}}`
|
|
19
|
+
},
|
|
20
|
+
code(cxt) {
|
|
21
|
+
const { gen, schema, schemaCode, data, $data, it } = cxt;
|
|
22
|
+
const { opts } = it;
|
|
23
|
+
if (!$data && schema.length === 0) return;
|
|
24
|
+
const useLoop = schema.length >= opts.loopRequired;
|
|
25
|
+
if (it.allErrors) allErrorsMode();
|
|
26
|
+
else exitOnErrorMode();
|
|
27
|
+
if (opts.strictRequired) {
|
|
28
|
+
const props = cxt.parentSchema.properties;
|
|
29
|
+
const { definedProperties } = cxt.it;
|
|
30
|
+
for (const requiredKey of schema) if ((props === null || props === void 0 ? void 0 : props[requiredKey]) === void 0 && !definedProperties.has(requiredKey)) {
|
|
31
|
+
const msg = `required property "${requiredKey}" is not defined at "${it.schemaEnv.baseId + it.errSchemaPath}" (strictRequired)`;
|
|
32
|
+
(0, util_1.checkStrictMode)(it, msg, it.opts.strictRequired);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function allErrorsMode() {
|
|
36
|
+
if (useLoop || $data) cxt.block$data(codegen_1.nil, loopAllRequired);
|
|
37
|
+
else for (const prop of schema) (0, code_1.checkReportMissingProp)(cxt, prop);
|
|
38
|
+
}
|
|
39
|
+
function exitOnErrorMode() {
|
|
40
|
+
const missing = gen.let("missing");
|
|
41
|
+
if (useLoop || $data) {
|
|
42
|
+
const valid = gen.let("valid", true);
|
|
43
|
+
cxt.block$data(valid, () => loopUntilMissing(missing, valid));
|
|
44
|
+
cxt.ok(valid);
|
|
45
|
+
} else {
|
|
46
|
+
gen.if((0, code_1.checkMissingProp)(cxt, schema, missing));
|
|
47
|
+
(0, code_1.reportMissingProp)(cxt, missing);
|
|
48
|
+
gen.else();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function loopAllRequired() {
|
|
52
|
+
gen.forOf("prop", schemaCode, (prop) => {
|
|
53
|
+
cxt.setParams({ missingProperty: prop });
|
|
54
|
+
gen.if((0, code_1.noPropertyInData)(gen, data, prop, opts.ownProperties), () => cxt.error());
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function loopUntilMissing(missing, valid) {
|
|
58
|
+
cxt.setParams({ missingProperty: missing });
|
|
59
|
+
gen.forOf(missing, schemaCode, () => {
|
|
60
|
+
gen.assign(valid, (0, code_1.propertyInData)(gen, data, missing, opts.ownProperties));
|
|
61
|
+
gen.if((0, codegen_1.not)(valid), () => {
|
|
62
|
+
cxt.error();
|
|
63
|
+
gen.break();
|
|
64
|
+
});
|
|
65
|
+
}, codegen_1.nil);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}));
|
|
70
|
+
//#endregion
|
|
71
|
+
export default require_required();
|
|
72
|
+
export { require_required };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { __commonJSMin } from "../../../../../../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { require_codegen } from "../../compile/codegen/index.js";
|
|
3
|
+
import { require_util } from "../../compile/util.js";
|
|
4
|
+
import { require_dataType } from "../../compile/validate/dataType.js";
|
|
5
|
+
import { require_equal } from "../../runtime/equal.js";
|
|
6
|
+
//#region ../../node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js
|
|
7
|
+
var require_uniqueItems = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const dataType_1 = require_dataType();
|
|
10
|
+
const codegen_1 = require_codegen();
|
|
11
|
+
const util_1 = require_util();
|
|
12
|
+
const equal_1 = require_equal();
|
|
13
|
+
exports.default = {
|
|
14
|
+
keyword: "uniqueItems",
|
|
15
|
+
type: "array",
|
|
16
|
+
schemaType: "boolean",
|
|
17
|
+
$data: true,
|
|
18
|
+
error: {
|
|
19
|
+
message: ({ params: { i, j } }) => (0, codegen_1.str)`must NOT have duplicate items (items ## ${j} and ${i} are identical)`,
|
|
20
|
+
params: ({ params: { i, j } }) => (0, codegen_1._)`{i: ${i}, j: ${j}}`
|
|
21
|
+
},
|
|
22
|
+
code(cxt) {
|
|
23
|
+
const { gen, data, $data, schema, parentSchema, schemaCode, it } = cxt;
|
|
24
|
+
if (!$data && !schema) return;
|
|
25
|
+
const valid = gen.let("valid");
|
|
26
|
+
const itemTypes = parentSchema.items ? (0, dataType_1.getSchemaTypes)(parentSchema.items) : [];
|
|
27
|
+
cxt.block$data(valid, validateUniqueItems, (0, codegen_1._)`${schemaCode} === false`);
|
|
28
|
+
cxt.ok(valid);
|
|
29
|
+
function validateUniqueItems() {
|
|
30
|
+
const i = gen.let("i", (0, codegen_1._)`${data}.length`);
|
|
31
|
+
const j = gen.let("j");
|
|
32
|
+
cxt.setParams({
|
|
33
|
+
i,
|
|
34
|
+
j
|
|
35
|
+
});
|
|
36
|
+
gen.assign(valid, true);
|
|
37
|
+
gen.if((0, codegen_1._)`${i} > 1`, () => (canOptimize() ? loopN : loopN2)(i, j));
|
|
38
|
+
}
|
|
39
|
+
function canOptimize() {
|
|
40
|
+
return itemTypes.length > 0 && !itemTypes.some((t) => t === "object" || t === "array");
|
|
41
|
+
}
|
|
42
|
+
function loopN(i, j) {
|
|
43
|
+
const item = gen.name("item");
|
|
44
|
+
const wrongType = (0, dataType_1.checkDataTypes)(itemTypes, item, it.opts.strictNumbers, dataType_1.DataType.Wrong);
|
|
45
|
+
const indices = gen.const("indices", (0, codegen_1._)`{}`);
|
|
46
|
+
gen.for((0, codegen_1._)`;${i}--;`, () => {
|
|
47
|
+
gen.let(item, (0, codegen_1._)`${data}[${i}]`);
|
|
48
|
+
gen.if(wrongType, (0, codegen_1._)`continue`);
|
|
49
|
+
if (itemTypes.length > 1) gen.if((0, codegen_1._)`typeof ${item} == "string"`, (0, codegen_1._)`${item} += "_"`);
|
|
50
|
+
gen.if((0, codegen_1._)`typeof ${indices}[${item}] == "number"`, () => {
|
|
51
|
+
gen.assign(j, (0, codegen_1._)`${indices}[${item}]`);
|
|
52
|
+
cxt.error();
|
|
53
|
+
gen.assign(valid, false).break();
|
|
54
|
+
}).code((0, codegen_1._)`${indices}[${item}] = ${i}`);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function loopN2(i, j) {
|
|
58
|
+
const eql = (0, util_1.useFunc)(gen, equal_1.default);
|
|
59
|
+
const outer = gen.name("outer");
|
|
60
|
+
gen.label(outer).for((0, codegen_1._)`;${i}--;`, () => gen.for((0, codegen_1._)`${j} = ${i}; ${j}--;`, () => gen.if((0, codegen_1._)`${eql}(${data}[${i}], ${data}[${j}])`, () => {
|
|
61
|
+
cxt.error();
|
|
62
|
+
gen.assign(valid, false).break(outer);
|
|
63
|
+
})));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}));
|
|
68
|
+
//#endregion
|
|
69
|
+
export default require_uniqueItems();
|
|
70
|
+
export { require_uniqueItems };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { __commonJSMin } from "../../../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
//#region ../../node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js
|
|
3
|
+
var require_fast_deep_equal = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
4
|
+
module.exports = function equal(a, b) {
|
|
5
|
+
if (a === b) return true;
|
|
6
|
+
if (a && b && typeof a == "object" && typeof b == "object") {
|
|
7
|
+
if (a.constructor !== b.constructor) return false;
|
|
8
|
+
var length, i, keys;
|
|
9
|
+
if (Array.isArray(a)) {
|
|
10
|
+
length = a.length;
|
|
11
|
+
if (length != b.length) return false;
|
|
12
|
+
for (i = length; i-- !== 0;) if (!equal(a[i], b[i])) return false;
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
|
|
16
|
+
if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
|
|
17
|
+
if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
|
|
18
|
+
keys = Object.keys(a);
|
|
19
|
+
length = keys.length;
|
|
20
|
+
if (length !== Object.keys(b).length) return false;
|
|
21
|
+
for (i = length; i-- !== 0;) if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
|
22
|
+
for (i = length; i-- !== 0;) {
|
|
23
|
+
var key = keys[i];
|
|
24
|
+
if (!equal(a[key], b[key])) return false;
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
return a !== a && b !== b;
|
|
29
|
+
};
|
|
30
|
+
}));
|
|
31
|
+
//#endregion
|
|
32
|
+
export default require_fast_deep_equal();
|
|
33
|
+
export { require_fast_deep_equal };
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { __commonJSMin } from "../../../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { require_utils } from "./lib/utils.js";
|
|
3
|
+
import { require_schemes } from "./lib/schemes.js";
|
|
4
|
+
//#region ../../node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/index.js
|
|
5
|
+
var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
6
|
+
const { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizeComponentEncoding, isIPv4, nonSimpleDomain } = require_utils();
|
|
7
|
+
const { SCHEMES, getSchemeHandler } = require_schemes();
|
|
8
|
+
/**
|
|
9
|
+
* @template {import('./types/index').URIComponent|string} T
|
|
10
|
+
* @param {T} uri
|
|
11
|
+
* @param {import('./types/index').Options} [options]
|
|
12
|
+
* @returns {T}
|
|
13
|
+
*/
|
|
14
|
+
function normalize(uri, options) {
|
|
15
|
+
if (typeof uri === "string") uri = serialize(parse(uri, options), options);
|
|
16
|
+
else if (typeof uri === "object") uri = parse(serialize(uri, options), options);
|
|
17
|
+
return uri;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* @param {string} baseURI
|
|
21
|
+
* @param {string} relativeURI
|
|
22
|
+
* @param {import('./types/index').Options} [options]
|
|
23
|
+
* @returns {string}
|
|
24
|
+
*/
|
|
25
|
+
function resolve(baseURI, relativeURI, options) {
|
|
26
|
+
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
27
|
+
const resolved = resolveComponent(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
28
|
+
schemelessOptions.skipEscape = true;
|
|
29
|
+
return serialize(resolved, schemelessOptions);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* @param {import ('./types/index').URIComponent} base
|
|
33
|
+
* @param {import ('./types/index').URIComponent} relative
|
|
34
|
+
* @param {import('./types/index').Options} [options]
|
|
35
|
+
* @param {boolean} [skipNormalization=false]
|
|
36
|
+
* @returns {import ('./types/index').URIComponent}
|
|
37
|
+
*/
|
|
38
|
+
function resolveComponent(base, relative, options, skipNormalization) {
|
|
39
|
+
/** @type {import('./types/index').URIComponent} */
|
|
40
|
+
const target = {};
|
|
41
|
+
if (!skipNormalization) {
|
|
42
|
+
base = parse(serialize(base, options), options);
|
|
43
|
+
relative = parse(serialize(relative, options), options);
|
|
44
|
+
}
|
|
45
|
+
options = options || {};
|
|
46
|
+
if (!options.tolerant && relative.scheme) {
|
|
47
|
+
target.scheme = relative.scheme;
|
|
48
|
+
target.userinfo = relative.userinfo;
|
|
49
|
+
target.host = relative.host;
|
|
50
|
+
target.port = relative.port;
|
|
51
|
+
target.path = removeDotSegments(relative.path || "");
|
|
52
|
+
target.query = relative.query;
|
|
53
|
+
} else {
|
|
54
|
+
if (relative.userinfo !== void 0 || relative.host !== void 0 || relative.port !== void 0) {
|
|
55
|
+
target.userinfo = relative.userinfo;
|
|
56
|
+
target.host = relative.host;
|
|
57
|
+
target.port = relative.port;
|
|
58
|
+
target.path = removeDotSegments(relative.path || "");
|
|
59
|
+
target.query = relative.query;
|
|
60
|
+
} else {
|
|
61
|
+
if (!relative.path) {
|
|
62
|
+
target.path = base.path;
|
|
63
|
+
if (relative.query !== void 0) target.query = relative.query;
|
|
64
|
+
else target.query = base.query;
|
|
65
|
+
} else {
|
|
66
|
+
if (relative.path[0] === "/") target.path = removeDotSegments(relative.path);
|
|
67
|
+
else {
|
|
68
|
+
if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) target.path = "/" + relative.path;
|
|
69
|
+
else if (!base.path) target.path = relative.path;
|
|
70
|
+
else target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative.path;
|
|
71
|
+
target.path = removeDotSegments(target.path);
|
|
72
|
+
}
|
|
73
|
+
target.query = relative.query;
|
|
74
|
+
}
|
|
75
|
+
target.userinfo = base.userinfo;
|
|
76
|
+
target.host = base.host;
|
|
77
|
+
target.port = base.port;
|
|
78
|
+
}
|
|
79
|
+
target.scheme = base.scheme;
|
|
80
|
+
}
|
|
81
|
+
target.fragment = relative.fragment;
|
|
82
|
+
return target;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* @param {import ('./types/index').URIComponent|string} uriA
|
|
86
|
+
* @param {import ('./types/index').URIComponent|string} uriB
|
|
87
|
+
* @param {import ('./types/index').Options} options
|
|
88
|
+
* @returns {boolean}
|
|
89
|
+
*/
|
|
90
|
+
function equal(uriA, uriB, options) {
|
|
91
|
+
if (typeof uriA === "string") {
|
|
92
|
+
uriA = unescape(uriA);
|
|
93
|
+
uriA = serialize(normalizeComponentEncoding(parse(uriA, options), true), {
|
|
94
|
+
...options,
|
|
95
|
+
skipEscape: true
|
|
96
|
+
});
|
|
97
|
+
} else if (typeof uriA === "object") uriA = serialize(normalizeComponentEncoding(uriA, true), {
|
|
98
|
+
...options,
|
|
99
|
+
skipEscape: true
|
|
100
|
+
});
|
|
101
|
+
if (typeof uriB === "string") {
|
|
102
|
+
uriB = unescape(uriB);
|
|
103
|
+
uriB = serialize(normalizeComponentEncoding(parse(uriB, options), true), {
|
|
104
|
+
...options,
|
|
105
|
+
skipEscape: true
|
|
106
|
+
});
|
|
107
|
+
} else if (typeof uriB === "object") uriB = serialize(normalizeComponentEncoding(uriB, true), {
|
|
108
|
+
...options,
|
|
109
|
+
skipEscape: true
|
|
110
|
+
});
|
|
111
|
+
return uriA.toLowerCase() === uriB.toLowerCase();
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* @param {Readonly<import('./types/index').URIComponent>} cmpts
|
|
115
|
+
* @param {import('./types/index').Options} [opts]
|
|
116
|
+
* @returns {string}
|
|
117
|
+
*/
|
|
118
|
+
function serialize(cmpts, opts) {
|
|
119
|
+
const component = {
|
|
120
|
+
host: cmpts.host,
|
|
121
|
+
scheme: cmpts.scheme,
|
|
122
|
+
userinfo: cmpts.userinfo,
|
|
123
|
+
port: cmpts.port,
|
|
124
|
+
path: cmpts.path,
|
|
125
|
+
query: cmpts.query,
|
|
126
|
+
nid: cmpts.nid,
|
|
127
|
+
nss: cmpts.nss,
|
|
128
|
+
uuid: cmpts.uuid,
|
|
129
|
+
fragment: cmpts.fragment,
|
|
130
|
+
reference: cmpts.reference,
|
|
131
|
+
resourceName: cmpts.resourceName,
|
|
132
|
+
secure: cmpts.secure,
|
|
133
|
+
error: ""
|
|
134
|
+
};
|
|
135
|
+
const options = Object.assign({}, opts);
|
|
136
|
+
const uriTokens = [];
|
|
137
|
+
const schemeHandler = getSchemeHandler(options.scheme || component.scheme);
|
|
138
|
+
if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options);
|
|
139
|
+
if (component.path !== void 0) if (!options.skipEscape) {
|
|
140
|
+
component.path = escape(component.path);
|
|
141
|
+
if (component.scheme !== void 0) component.path = component.path.split("%3A").join(":");
|
|
142
|
+
} else component.path = unescape(component.path);
|
|
143
|
+
if (options.reference !== "suffix" && component.scheme) uriTokens.push(component.scheme, ":");
|
|
144
|
+
const authority = recomposeAuthority(component);
|
|
145
|
+
if (authority !== void 0) {
|
|
146
|
+
if (options.reference !== "suffix") uriTokens.push("//");
|
|
147
|
+
uriTokens.push(authority);
|
|
148
|
+
if (component.path && component.path[0] !== "/") uriTokens.push("/");
|
|
149
|
+
}
|
|
150
|
+
if (component.path !== void 0) {
|
|
151
|
+
let s = component.path;
|
|
152
|
+
if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) s = removeDotSegments(s);
|
|
153
|
+
if (authority === void 0 && s[0] === "/" && s[1] === "/") s = "/%2F" + s.slice(2);
|
|
154
|
+
uriTokens.push(s);
|
|
155
|
+
}
|
|
156
|
+
if (component.query !== void 0) uriTokens.push("?", component.query);
|
|
157
|
+
if (component.fragment !== void 0) uriTokens.push("#", component.fragment);
|
|
158
|
+
return uriTokens.join("");
|
|
159
|
+
}
|
|
160
|
+
const URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
|
|
161
|
+
/**
|
|
162
|
+
* @param {string} uri
|
|
163
|
+
* @param {import('./types/index').Options} [opts]
|
|
164
|
+
* @returns
|
|
165
|
+
*/
|
|
166
|
+
function parse(uri, opts) {
|
|
167
|
+
const options = Object.assign({}, opts);
|
|
168
|
+
/** @type {import('./types/index').URIComponent} */
|
|
169
|
+
const parsed = {
|
|
170
|
+
scheme: void 0,
|
|
171
|
+
userinfo: void 0,
|
|
172
|
+
host: "",
|
|
173
|
+
port: void 0,
|
|
174
|
+
path: "",
|
|
175
|
+
query: void 0,
|
|
176
|
+
fragment: void 0
|
|
177
|
+
};
|
|
178
|
+
let isIP = false;
|
|
179
|
+
if (options.reference === "suffix") if (options.scheme) uri = options.scheme + ":" + uri;
|
|
180
|
+
else uri = "//" + uri;
|
|
181
|
+
const matches = uri.match(URI_PARSE);
|
|
182
|
+
if (matches) {
|
|
183
|
+
parsed.scheme = matches[1];
|
|
184
|
+
parsed.userinfo = matches[3];
|
|
185
|
+
parsed.host = matches[4];
|
|
186
|
+
parsed.port = parseInt(matches[5], 10);
|
|
187
|
+
parsed.path = matches[6] || "";
|
|
188
|
+
parsed.query = matches[7];
|
|
189
|
+
parsed.fragment = matches[8];
|
|
190
|
+
if (isNaN(parsed.port)) parsed.port = matches[5];
|
|
191
|
+
if (parsed.host) if (isIPv4(parsed.host) === false) {
|
|
192
|
+
const ipv6result = normalizeIPv6(parsed.host);
|
|
193
|
+
parsed.host = ipv6result.host.toLowerCase();
|
|
194
|
+
isIP = ipv6result.isIPV6;
|
|
195
|
+
} else isIP = true;
|
|
196
|
+
if (parsed.scheme === void 0 && parsed.userinfo === void 0 && parsed.host === void 0 && parsed.port === void 0 && parsed.query === void 0 && !parsed.path) parsed.reference = "same-document";
|
|
197
|
+
else if (parsed.scheme === void 0) parsed.reference = "relative";
|
|
198
|
+
else if (parsed.fragment === void 0) parsed.reference = "absolute";
|
|
199
|
+
else parsed.reference = "uri";
|
|
200
|
+
if (options.reference && options.reference !== "suffix" && options.reference !== parsed.reference) parsed.error = parsed.error || "URI is not a " + options.reference + " reference.";
|
|
201
|
+
const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme);
|
|
202
|
+
if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
|
|
203
|
+
if (parsed.host && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) try {
|
|
204
|
+
parsed.host = URL.domainToASCII(parsed.host.toLowerCase());
|
|
205
|
+
} catch (e) {
|
|
206
|
+
parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
|
|
210
|
+
if (uri.indexOf("%") !== -1) {
|
|
211
|
+
if (parsed.scheme !== void 0) parsed.scheme = unescape(parsed.scheme);
|
|
212
|
+
if (parsed.host !== void 0) parsed.host = unescape(parsed.host);
|
|
213
|
+
}
|
|
214
|
+
if (parsed.path) parsed.path = escape(unescape(parsed.path));
|
|
215
|
+
if (parsed.fragment) parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment));
|
|
216
|
+
}
|
|
217
|
+
if (schemeHandler && schemeHandler.parse) schemeHandler.parse(parsed, options);
|
|
218
|
+
} else parsed.error = parsed.error || "URI can not be parsed.";
|
|
219
|
+
return parsed;
|
|
220
|
+
}
|
|
221
|
+
const fastUri = {
|
|
222
|
+
SCHEMES,
|
|
223
|
+
normalize,
|
|
224
|
+
resolve,
|
|
225
|
+
resolveComponent,
|
|
226
|
+
equal,
|
|
227
|
+
serialize,
|
|
228
|
+
parse
|
|
229
|
+
};
|
|
230
|
+
module.exports = fastUri;
|
|
231
|
+
module.exports.default = fastUri;
|
|
232
|
+
module.exports.fastUri = fastUri;
|
|
233
|
+
}));
|
|
234
|
+
//#endregion
|
|
235
|
+
export default require_fast_uri();
|
|
236
|
+
export { require_fast_uri };
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { __commonJSMin } from "../../../../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { require_utils } from "./utils.js";
|
|
3
|
+
//#region ../../node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/schemes.js
|
|
4
|
+
var require_schemes = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
5
|
+
const { isUUID } = require_utils();
|
|
6
|
+
const URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;
|
|
7
|
+
const supportedSchemeNames = [
|
|
8
|
+
"http",
|
|
9
|
+
"https",
|
|
10
|
+
"ws",
|
|
11
|
+
"wss",
|
|
12
|
+
"urn",
|
|
13
|
+
"urn:uuid"
|
|
14
|
+
];
|
|
15
|
+
/** @typedef {supportedSchemeNames[number]} SchemeName */
|
|
16
|
+
/**
|
|
17
|
+
* @param {string} name
|
|
18
|
+
* @returns {name is SchemeName}
|
|
19
|
+
*/
|
|
20
|
+
function isValidSchemeName(name) {
|
|
21
|
+
return supportedSchemeNames.indexOf(name) !== -1;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @callback SchemeFn
|
|
25
|
+
* @param {import('../types/index').URIComponent} component
|
|
26
|
+
* @param {import('../types/index').Options} options
|
|
27
|
+
* @returns {import('../types/index').URIComponent}
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* @typedef {Object} SchemeHandler
|
|
31
|
+
* @property {SchemeName} scheme - The scheme name.
|
|
32
|
+
* @property {boolean} [domainHost] - Indicates if the scheme supports domain hosts.
|
|
33
|
+
* @property {SchemeFn} parse - Function to parse the URI component for this scheme.
|
|
34
|
+
* @property {SchemeFn} serialize - Function to serialize the URI component for this scheme.
|
|
35
|
+
* @property {boolean} [skipNormalize] - Indicates if normalization should be skipped for this scheme.
|
|
36
|
+
* @property {boolean} [absolutePath] - Indicates if the scheme uses absolute paths.
|
|
37
|
+
* @property {boolean} [unicodeSupport] - Indicates if the scheme supports Unicode.
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* @param {import('../types/index').URIComponent} wsComponent
|
|
41
|
+
* @returns {boolean}
|
|
42
|
+
*/
|
|
43
|
+
function wsIsSecure(wsComponent) {
|
|
44
|
+
if (wsComponent.secure === true) return true;
|
|
45
|
+
else if (wsComponent.secure === false) return false;
|
|
46
|
+
else if (wsComponent.scheme) return wsComponent.scheme.length === 3 && (wsComponent.scheme[0] === "w" || wsComponent.scheme[0] === "W") && (wsComponent.scheme[1] === "s" || wsComponent.scheme[1] === "S") && (wsComponent.scheme[2] === "s" || wsComponent.scheme[2] === "S");
|
|
47
|
+
else return false;
|
|
48
|
+
}
|
|
49
|
+
/** @type {SchemeFn} */
|
|
50
|
+
function httpParse(component) {
|
|
51
|
+
if (!component.host) component.error = component.error || "HTTP URIs must have a host.";
|
|
52
|
+
return component;
|
|
53
|
+
}
|
|
54
|
+
/** @type {SchemeFn} */
|
|
55
|
+
function httpSerialize(component) {
|
|
56
|
+
const secure = String(component.scheme).toLowerCase() === "https";
|
|
57
|
+
if (component.port === (secure ? 443 : 80) || component.port === "") component.port = void 0;
|
|
58
|
+
if (!component.path) component.path = "/";
|
|
59
|
+
return component;
|
|
60
|
+
}
|
|
61
|
+
/** @type {SchemeFn} */
|
|
62
|
+
function wsParse(wsComponent) {
|
|
63
|
+
wsComponent.secure = wsIsSecure(wsComponent);
|
|
64
|
+
wsComponent.resourceName = (wsComponent.path || "/") + (wsComponent.query ? "?" + wsComponent.query : "");
|
|
65
|
+
wsComponent.path = void 0;
|
|
66
|
+
wsComponent.query = void 0;
|
|
67
|
+
return wsComponent;
|
|
68
|
+
}
|
|
69
|
+
/** @type {SchemeFn} */
|
|
70
|
+
function wsSerialize(wsComponent) {
|
|
71
|
+
if (wsComponent.port === (wsIsSecure(wsComponent) ? 443 : 80) || wsComponent.port === "") wsComponent.port = void 0;
|
|
72
|
+
if (typeof wsComponent.secure === "boolean") {
|
|
73
|
+
wsComponent.scheme = wsComponent.secure ? "wss" : "ws";
|
|
74
|
+
wsComponent.secure = void 0;
|
|
75
|
+
}
|
|
76
|
+
if (wsComponent.resourceName) {
|
|
77
|
+
const [path, query] = wsComponent.resourceName.split("?");
|
|
78
|
+
wsComponent.path = path && path !== "/" ? path : void 0;
|
|
79
|
+
wsComponent.query = query;
|
|
80
|
+
wsComponent.resourceName = void 0;
|
|
81
|
+
}
|
|
82
|
+
wsComponent.fragment = void 0;
|
|
83
|
+
return wsComponent;
|
|
84
|
+
}
|
|
85
|
+
/** @type {SchemeFn} */
|
|
86
|
+
function urnParse(urnComponent, options) {
|
|
87
|
+
if (!urnComponent.path) {
|
|
88
|
+
urnComponent.error = "URN can not be parsed";
|
|
89
|
+
return urnComponent;
|
|
90
|
+
}
|
|
91
|
+
const matches = urnComponent.path.match(URN_REG);
|
|
92
|
+
if (matches) {
|
|
93
|
+
const scheme = options.scheme || urnComponent.scheme || "urn";
|
|
94
|
+
urnComponent.nid = matches[1].toLowerCase();
|
|
95
|
+
urnComponent.nss = matches[2];
|
|
96
|
+
const schemeHandler = getSchemeHandler(`${scheme}:${options.nid || urnComponent.nid}`);
|
|
97
|
+
urnComponent.path = void 0;
|
|
98
|
+
if (schemeHandler) urnComponent = schemeHandler.parse(urnComponent, options);
|
|
99
|
+
} else urnComponent.error = urnComponent.error || "URN can not be parsed.";
|
|
100
|
+
return urnComponent;
|
|
101
|
+
}
|
|
102
|
+
/** @type {SchemeFn} */
|
|
103
|
+
function urnSerialize(urnComponent, options) {
|
|
104
|
+
if (urnComponent.nid === void 0) throw new Error("URN without nid cannot be serialized");
|
|
105
|
+
const scheme = options.scheme || urnComponent.scheme || "urn";
|
|
106
|
+
const nid = urnComponent.nid.toLowerCase();
|
|
107
|
+
const schemeHandler = getSchemeHandler(`${scheme}:${options.nid || nid}`);
|
|
108
|
+
if (schemeHandler) urnComponent = schemeHandler.serialize(urnComponent, options);
|
|
109
|
+
const uriComponent = urnComponent;
|
|
110
|
+
const nss = urnComponent.nss;
|
|
111
|
+
uriComponent.path = `${nid || options.nid}:${nss}`;
|
|
112
|
+
options.skipEscape = true;
|
|
113
|
+
return uriComponent;
|
|
114
|
+
}
|
|
115
|
+
/** @type {SchemeFn} */
|
|
116
|
+
function urnuuidParse(urnComponent, options) {
|
|
117
|
+
const uuidComponent = urnComponent;
|
|
118
|
+
uuidComponent.uuid = uuidComponent.nss;
|
|
119
|
+
uuidComponent.nss = void 0;
|
|
120
|
+
if (!options.tolerant && (!uuidComponent.uuid || !isUUID(uuidComponent.uuid))) uuidComponent.error = uuidComponent.error || "UUID is not valid.";
|
|
121
|
+
return uuidComponent;
|
|
122
|
+
}
|
|
123
|
+
/** @type {SchemeFn} */
|
|
124
|
+
function urnuuidSerialize(uuidComponent) {
|
|
125
|
+
const urnComponent = uuidComponent;
|
|
126
|
+
urnComponent.nss = (uuidComponent.uuid || "").toLowerCase();
|
|
127
|
+
return urnComponent;
|
|
128
|
+
}
|
|
129
|
+
const http = {
|
|
130
|
+
scheme: "http",
|
|
131
|
+
domainHost: true,
|
|
132
|
+
parse: httpParse,
|
|
133
|
+
serialize: httpSerialize
|
|
134
|
+
};
|
|
135
|
+
const https = {
|
|
136
|
+
scheme: "https",
|
|
137
|
+
domainHost: http.domainHost,
|
|
138
|
+
parse: httpParse,
|
|
139
|
+
serialize: httpSerialize
|
|
140
|
+
};
|
|
141
|
+
const ws = {
|
|
142
|
+
scheme: "ws",
|
|
143
|
+
domainHost: true,
|
|
144
|
+
parse: wsParse,
|
|
145
|
+
serialize: wsSerialize
|
|
146
|
+
};
|
|
147
|
+
const SCHEMES = {
|
|
148
|
+
http,
|
|
149
|
+
https,
|
|
150
|
+
ws,
|
|
151
|
+
wss: {
|
|
152
|
+
scheme: "wss",
|
|
153
|
+
domainHost: ws.domainHost,
|
|
154
|
+
parse: ws.parse,
|
|
155
|
+
serialize: ws.serialize
|
|
156
|
+
},
|
|
157
|
+
urn: {
|
|
158
|
+
scheme: "urn",
|
|
159
|
+
parse: urnParse,
|
|
160
|
+
serialize: urnSerialize,
|
|
161
|
+
skipNormalize: true
|
|
162
|
+
},
|
|
163
|
+
"urn:uuid": {
|
|
164
|
+
scheme: "urn:uuid",
|
|
165
|
+
parse: urnuuidParse,
|
|
166
|
+
serialize: urnuuidSerialize,
|
|
167
|
+
skipNormalize: true
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
Object.setPrototypeOf(SCHEMES, null);
|
|
171
|
+
/**
|
|
172
|
+
* @param {string|undefined} scheme
|
|
173
|
+
* @returns {SchemeHandler|undefined}
|
|
174
|
+
*/
|
|
175
|
+
function getSchemeHandler(scheme) {
|
|
176
|
+
return scheme && (SCHEMES[scheme] || SCHEMES[scheme.toLowerCase()]) || void 0;
|
|
177
|
+
}
|
|
178
|
+
module.exports = {
|
|
179
|
+
wsIsSecure,
|
|
180
|
+
SCHEMES,
|
|
181
|
+
isValidSchemeName,
|
|
182
|
+
getSchemeHandler
|
|
183
|
+
};
|
|
184
|
+
}));
|
|
185
|
+
//#endregion
|
|
186
|
+
export default require_schemes();
|
|
187
|
+
export { require_schemes };
|