fumadocs-openapi 10.10.3 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/generated/shared.css +1 -1159
- package/css/preset.css +1 -0
- package/dist/.translations/index.d.ts +80 -0
- package/dist/.translations/keys.js +80 -0
- package/dist/_virtual/_rolldown/runtime.js +1 -10
- package/dist/generate-file.d.ts +0 -4
- package/dist/generate-file.js +4 -5
- package/dist/i18n.d.ts +5 -100
- package/dist/i18n.js +8 -108
- package/dist/index.d.ts +4 -4
- package/dist/node_modules/.pnpm/{@scalar_openapi-upgrader@0.2.8 → @scalar_openapi-upgrader@0.2.9}/node_modules/@scalar/openapi-upgrader/dist/2.0-to-3.0/upgrade-from-two-to-three.js +1 -1
- package/dist/node_modules/.pnpm/{@scalar_openapi-upgrader@0.2.8 → @scalar_openapi-upgrader@0.2.9}/node_modules/@scalar/openapi-upgrader/dist/3.0-to-3.1/upgrade-from-three-to-three-one.js +1 -1
- package/dist/node_modules/.pnpm/{@scalar_openapi-upgrader@0.2.8 → @scalar_openapi-upgrader@0.2.9}/node_modules/@scalar/openapi-upgrader/dist/3.1-to-3.2/upgrade-from-three-one-to-three-two.js +1 -1
- package/dist/node_modules/.pnpm/{@scalar_openapi-upgrader@0.2.8 → @scalar_openapi-upgrader@0.2.9}/node_modules/@scalar/openapi-upgrader/dist/helpers/traverse.js +1 -1
- package/dist/node_modules/.pnpm/{@scalar_openapi-upgrader@0.2.8 → @scalar_openapi-upgrader@0.2.9}/node_modules/@scalar/openapi-upgrader/dist/upgrade.js +1 -1
- package/dist/playground/auth.js +4 -4
- package/dist/playground/client.d.ts +12 -21
- package/dist/playground/client.js +80 -59
- package/dist/playground/components/oauth-dialog.js +33 -33
- package/dist/playground/components/result-display.d.ts +1 -2
- package/dist/playground/components/result-display.js +7 -8
- package/dist/playground/components/server-select.js +11 -11
- package/dist/playground/status-info.js +29 -37
- package/dist/requests/generators/csharp.js +3 -3
- package/dist/requests/generators/curl.js +2 -2
- package/dist/requests/generators/go.js +2 -2
- package/dist/requests/generators/index.d.ts +28 -41
- package/dist/requests/generators/index.js +18 -35
- package/dist/requests/generators/java.js +2 -2
- package/dist/requests/generators/javascript.js +2 -2
- package/dist/requests/generators/python.js +2 -2
- package/dist/scalar/client.js +3 -2
- package/dist/scalar/index.d.ts +2 -2
- package/dist/scalar/index.js +10 -9
- package/dist/server/index.d.ts +23 -27
- package/dist/server/index.js +42 -38
- package/dist/server/proxy.d.ts +0 -6
- package/dist/server/proxy.js +2 -4
- package/dist/{_openapi/types.d.ts → types/openapi.d.ts} +127 -136
- package/dist/types.d.ts +14 -18
- package/dist/ui/base.d.ts +15 -162
- package/dist/ui/base.js +148 -107
- package/dist/ui/components/codeblock.js +6 -14
- package/dist/ui/components/heading.js +8 -4
- package/dist/ui/components/markdown.js +12 -0
- package/dist/ui/contexts/api.js +8 -26
- package/dist/ui/index.d.ts +204 -7
- package/dist/ui/index.js +10 -15
- package/dist/ui/operation/context.js +48 -0
- package/dist/ui/operation/index.js +168 -126
- package/dist/ui/operation/request-tabs.d.ts +10 -5
- package/dist/ui/operation/request-tabs.js +35 -22
- package/dist/ui/operation/response-tabs.d.ts +5 -2
- package/dist/ui/operation/response-tabs.js +22 -15
- package/dist/ui/operation/usage-tabs.js +144 -0
- package/dist/utils/document/dereference.d.ts +1 -1
- package/dist/utils/document/dereference.js +5 -8
- package/dist/utils/document/load.js +17 -0
- package/dist/utils/get-example-requests.d.ts +13 -0
- package/dist/{ui/operation → utils}/get-example-requests.js +31 -20
- package/dist/utils/pages/builder.d.ts +38 -10
- package/dist/utils/pages/builder.js +12 -10
- package/dist/utils/pages/preset-auto.d.ts +1 -2
- package/dist/utils/pages/preset-auto.js +15 -15
- package/dist/utils/pages/to-static-data.js +5 -4
- package/dist/utils/pages/to-text.d.ts +1 -0
- package/dist/utils/pages/to-text.js +21 -11
- package/dist/utils/remove-undefined.js +14 -9
- package/dist/utils/schema.d.ts +2 -0
- package/dist/utils/{schema/index.js → schema.js} +3 -30
- package/dist/{ui/client → utils}/storage-key.js +3 -3
- package/package.json +15 -28
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/bundle.js +0 -239
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/dereference.js +0 -187
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/index.js +0 -136
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/normalize-args.js +0 -41
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/options.js +0 -124
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parse.js +0 -109
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/binary.js +0 -30
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/json.js +0 -46
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/text.js +0 -36
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/yaml.js +0 -49
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/pointer.js +0 -242
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/ref.js +0 -247
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/refs.js +0 -210
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolve-external.js +0 -100
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolvers/file.js +0 -41
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolvers/http.js +0 -112
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/convert-path-to-posix.js +0 -8
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/errors.js +0 -146
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/is-windows.js +0 -5
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/maybe.js +0 -18
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/next.js +0 -11
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/plugins.js +0 -99
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/schema-resources.js +0 -30
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/url.js +0 -315
- package/dist/node_modules/.pnpm/@fastify_deepmerge@3.2.1/node_modules/@fastify/deepmerge/index.js +0 -108
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/2020.js +0 -110
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/code.js +0 -138
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/index.js +0 -674
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/scope.js +0 -141
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/errors.js +0 -102
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/index.js +0 -223
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/names.js +0 -28
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/ref_error.js +0 -18
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/resolve.js +0 -133
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/rules.js +0 -61
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/util.js +0 -146
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/applicability.js +0 -23
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/boolSchema.js +0 -48
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/dataType.js +0 -172
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/defaults.js +0 -31
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/index.js +0 -433
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/keyword.js +0 -113
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/subschema.js +0 -72
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/core.js +0 -583
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/data.js +0 -18
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/index.js +0 -42
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/applicator.js +0 -50
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/content.js +0 -20
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/core.js +0 -51
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/format-annotation.js +0 -16
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/meta-data.js +0 -36
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/unevaluated.js +0 -19
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/validation.js +0 -85
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/schema.js +0 -59
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/equal.js +0 -12
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/ucs2length.js +0 -25
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/uri.js +0 -12
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/validation_error.js +0 -16
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +0 -57
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +0 -96
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/allOf.js +0 -29
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +0 -16
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/contains.js +0 -89
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +0 -87
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/dependentSchemas.js +0 -16
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/if.js +0 -62
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/index.js +0 -60
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/items.js +0 -59
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/items2020.js +0 -34
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/not.js +0 -31
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +0 -51
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +0 -61
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +0 -17
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/properties.js +0 -52
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +0 -41
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +0 -17
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/code.js +0 -130
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/id.js +0 -14
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/index.js +0 -22
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/ref.js +0 -112
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/discriminator/index.js +0 -101
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/discriminator/types.js +0 -14
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/draft2020.js +0 -35
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/dynamicAnchor.js +0 -46
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/dynamicRef.js +0 -45
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/index.js +0 -22
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/recursiveAnchor.js +0 -20
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/recursiveRef.js +0 -15
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/format/format.js +0 -92
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/format/index.js +0 -10
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/metadata.js +0 -23
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/next.js +0 -19
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/unevaluated/index.js +0 -13
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedItems.js +0 -46
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.js +0 -59
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/const.js +0 -27
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/dependentRequired.js +0 -17
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/enum.js +0 -49
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/index.js +0 -48
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitContains.js +0 -18
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitItems.js +0 -28
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitLength.js +0 -33
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +0 -47
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +0 -28
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +0 -27
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/pattern.js +0 -38
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/required.js +0 -72
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +0 -70
- package/dist/node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js +0 -33
- package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/index.js +0 -236
- package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/schemes.js +0 -187
- package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/utils.js +0 -282
- package/dist/node_modules/.pnpm/json-schema-traverse@1.0.0/node_modules/json-schema-traverse/index.js +0 -78
- package/dist/playground/components/inputs.js +0 -419
- package/dist/playground/components/spinner.js +0 -15
- package/dist/playground/schema.d.ts +0 -15
- package/dist/playground/schema.js +0 -144
- package/dist/ui/api-page.d.ts +0 -31
- package/dist/ui/api-page.js +0 -59
- package/dist/ui/client/boundary.d.ts +0 -11
- package/dist/ui/client/boundary.js +0 -17
- package/dist/ui/client/boundary.lazy.js +0 -19
- package/dist/ui/client/full.js +0 -13
- package/dist/ui/client/i18n.js +0 -16
- package/dist/ui/client/index.d.ts +0 -42
- package/dist/ui/client/index.js +0 -7
- package/dist/ui/components/accordion.js +0 -67
- package/dist/ui/components/codeblock.d.ts +0 -14
- package/dist/ui/components/dialog.js +0 -56
- package/dist/ui/components/input.js +0 -17
- package/dist/ui/components/select-tab.js +0 -56
- package/dist/ui/components/select.js +0 -71
- package/dist/ui/contexts/api.d.ts +0 -29
- package/dist/ui/create-client.d.ts +0 -26
- package/dist/ui/create-client.js +0 -125
- package/dist/ui/operation/client.js +0 -78
- package/dist/ui/operation/get-example-requests.d.ts +0 -11
- package/dist/ui/operation/usage-tabs/client.d.ts +0 -14
- package/dist/ui/operation/usage-tabs/client.js +0 -91
- package/dist/ui/operation/usage-tabs/index.js +0 -54
- package/dist/ui/schema/client.d.ts +0 -18
- package/dist/ui/schema/client.js +0 -410
- package/dist/ui/schema/index.d.ts +0 -61
- package/dist/ui/schema/index.js +0 -256
- package/dist/utils/auto-anchor.client.js +0 -20
- package/dist/utils/auto-anchor.js +0 -17
- package/dist/utils/deep-equal.js +0 -21
- package/dist/utils/document/process.d.ts +0 -6
- package/dist/utils/document/process.js +0 -18
- package/dist/utils/id-to-title.js +0 -12
- package/dist/utils/is-plain-object.js +0 -8
- package/dist/utils/merge-refs.js +0 -11
- package/dist/utils/schema/dereference.js +0 -45
- package/dist/utils/schema/index.d.ts +0 -18
- package/dist/utils/schema/merge.js +0 -156
- package/dist/utils/schema/pick.js +0 -44
- package/dist/utils/schema/ref.js +0 -35
- package/dist/utils/schema/resolve-ref.js +0 -11
- package/dist/utils/schema/sample.js +0 -442
- package/dist/utils/schema/to-string.d.ts +0 -1
- package/dist/utils/schema/to-string.js +0 -53
- package/dist/utils/url.js +0 -39
|
@@ -1,674 +0,0 @@
|
|
|
1
|
-
import { __commonJSMin } from "../../../../../../../../_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { require_code } from "./code.js";
|
|
3
|
-
import { require_scope } from "./scope.js";
|
|
4
|
-
//#region ../../node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/index.js
|
|
5
|
-
var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.or = exports.and = exports.not = exports.CodeGen = exports.operators = exports.varKinds = exports.ValueScopeName = exports.ValueScope = exports.Scope = exports.Name = exports.regexpCode = exports.stringify = exports.getProperty = exports.nil = exports.strConcat = exports.str = exports._ = void 0;
|
|
8
|
-
const code_1 = require_code();
|
|
9
|
-
const scope_1 = require_scope();
|
|
10
|
-
var code_2 = require_code();
|
|
11
|
-
Object.defineProperty(exports, "_", {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: function() {
|
|
14
|
-
return code_2._;
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
Object.defineProperty(exports, "str", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function() {
|
|
20
|
-
return code_2.str;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
Object.defineProperty(exports, "strConcat", {
|
|
24
|
-
enumerable: true,
|
|
25
|
-
get: function() {
|
|
26
|
-
return code_2.strConcat;
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
Object.defineProperty(exports, "nil", {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
get: function() {
|
|
32
|
-
return code_2.nil;
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
Object.defineProperty(exports, "getProperty", {
|
|
36
|
-
enumerable: true,
|
|
37
|
-
get: function() {
|
|
38
|
-
return code_2.getProperty;
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
Object.defineProperty(exports, "stringify", {
|
|
42
|
-
enumerable: true,
|
|
43
|
-
get: function() {
|
|
44
|
-
return code_2.stringify;
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
Object.defineProperty(exports, "regexpCode", {
|
|
48
|
-
enumerable: true,
|
|
49
|
-
get: function() {
|
|
50
|
-
return code_2.regexpCode;
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
Object.defineProperty(exports, "Name", {
|
|
54
|
-
enumerable: true,
|
|
55
|
-
get: function() {
|
|
56
|
-
return code_2.Name;
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
var scope_2 = require_scope();
|
|
60
|
-
Object.defineProperty(exports, "Scope", {
|
|
61
|
-
enumerable: true,
|
|
62
|
-
get: function() {
|
|
63
|
-
return scope_2.Scope;
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
Object.defineProperty(exports, "ValueScope", {
|
|
67
|
-
enumerable: true,
|
|
68
|
-
get: function() {
|
|
69
|
-
return scope_2.ValueScope;
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
Object.defineProperty(exports, "ValueScopeName", {
|
|
73
|
-
enumerable: true,
|
|
74
|
-
get: function() {
|
|
75
|
-
return scope_2.ValueScopeName;
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
Object.defineProperty(exports, "varKinds", {
|
|
79
|
-
enumerable: true,
|
|
80
|
-
get: function() {
|
|
81
|
-
return scope_2.varKinds;
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
exports.operators = {
|
|
85
|
-
GT: new code_1._Code(">"),
|
|
86
|
-
GTE: new code_1._Code(">="),
|
|
87
|
-
LT: new code_1._Code("<"),
|
|
88
|
-
LTE: new code_1._Code("<="),
|
|
89
|
-
EQ: new code_1._Code("==="),
|
|
90
|
-
NEQ: new code_1._Code("!=="),
|
|
91
|
-
NOT: new code_1._Code("!"),
|
|
92
|
-
OR: new code_1._Code("||"),
|
|
93
|
-
AND: new code_1._Code("&&"),
|
|
94
|
-
ADD: new code_1._Code("+")
|
|
95
|
-
};
|
|
96
|
-
var Node = class {
|
|
97
|
-
optimizeNodes() {
|
|
98
|
-
return this;
|
|
99
|
-
}
|
|
100
|
-
optimizeNames(_names, _constants) {
|
|
101
|
-
return this;
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
var Def = class extends Node {
|
|
105
|
-
constructor(varKind, name, rhs) {
|
|
106
|
-
super();
|
|
107
|
-
this.varKind = varKind;
|
|
108
|
-
this.name = name;
|
|
109
|
-
this.rhs = rhs;
|
|
110
|
-
}
|
|
111
|
-
render({ es5, _n }) {
|
|
112
|
-
const varKind = es5 ? scope_1.varKinds.var : this.varKind;
|
|
113
|
-
const rhs = this.rhs === void 0 ? "" : ` = ${this.rhs}`;
|
|
114
|
-
return `${varKind} ${this.name}${rhs};` + _n;
|
|
115
|
-
}
|
|
116
|
-
optimizeNames(names, constants) {
|
|
117
|
-
if (!names[this.name.str]) return;
|
|
118
|
-
if (this.rhs) this.rhs = optimizeExpr(this.rhs, names, constants);
|
|
119
|
-
return this;
|
|
120
|
-
}
|
|
121
|
-
get names() {
|
|
122
|
-
return this.rhs instanceof code_1._CodeOrName ? this.rhs.names : {};
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
var Assign = class extends Node {
|
|
126
|
-
constructor(lhs, rhs, sideEffects) {
|
|
127
|
-
super();
|
|
128
|
-
this.lhs = lhs;
|
|
129
|
-
this.rhs = rhs;
|
|
130
|
-
this.sideEffects = sideEffects;
|
|
131
|
-
}
|
|
132
|
-
render({ _n }) {
|
|
133
|
-
return `${this.lhs} = ${this.rhs};` + _n;
|
|
134
|
-
}
|
|
135
|
-
optimizeNames(names, constants) {
|
|
136
|
-
if (this.lhs instanceof code_1.Name && !names[this.lhs.str] && !this.sideEffects) return;
|
|
137
|
-
this.rhs = optimizeExpr(this.rhs, names, constants);
|
|
138
|
-
return this;
|
|
139
|
-
}
|
|
140
|
-
get names() {
|
|
141
|
-
return addExprNames(this.lhs instanceof code_1.Name ? {} : { ...this.lhs.names }, this.rhs);
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
var AssignOp = class extends Assign {
|
|
145
|
-
constructor(lhs, op, rhs, sideEffects) {
|
|
146
|
-
super(lhs, rhs, sideEffects);
|
|
147
|
-
this.op = op;
|
|
148
|
-
}
|
|
149
|
-
render({ _n }) {
|
|
150
|
-
return `${this.lhs} ${this.op}= ${this.rhs};` + _n;
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
var Label = class extends Node {
|
|
154
|
-
constructor(label) {
|
|
155
|
-
super();
|
|
156
|
-
this.label = label;
|
|
157
|
-
this.names = {};
|
|
158
|
-
}
|
|
159
|
-
render({ _n }) {
|
|
160
|
-
return `${this.label}:` + _n;
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
var Break = class extends Node {
|
|
164
|
-
constructor(label) {
|
|
165
|
-
super();
|
|
166
|
-
this.label = label;
|
|
167
|
-
this.names = {};
|
|
168
|
-
}
|
|
169
|
-
render({ _n }) {
|
|
170
|
-
return `break${this.label ? ` ${this.label}` : ""};` + _n;
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
var Throw = class extends Node {
|
|
174
|
-
constructor(error) {
|
|
175
|
-
super();
|
|
176
|
-
this.error = error;
|
|
177
|
-
}
|
|
178
|
-
render({ _n }) {
|
|
179
|
-
return `throw ${this.error};` + _n;
|
|
180
|
-
}
|
|
181
|
-
get names() {
|
|
182
|
-
return this.error.names;
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
var AnyCode = class extends Node {
|
|
186
|
-
constructor(code) {
|
|
187
|
-
super();
|
|
188
|
-
this.code = code;
|
|
189
|
-
}
|
|
190
|
-
render({ _n }) {
|
|
191
|
-
return `${this.code};` + _n;
|
|
192
|
-
}
|
|
193
|
-
optimizeNodes() {
|
|
194
|
-
return `${this.code}` ? this : void 0;
|
|
195
|
-
}
|
|
196
|
-
optimizeNames(names, constants) {
|
|
197
|
-
this.code = optimizeExpr(this.code, names, constants);
|
|
198
|
-
return this;
|
|
199
|
-
}
|
|
200
|
-
get names() {
|
|
201
|
-
return this.code instanceof code_1._CodeOrName ? this.code.names : {};
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
var ParentNode = class extends Node {
|
|
205
|
-
constructor(nodes = []) {
|
|
206
|
-
super();
|
|
207
|
-
this.nodes = nodes;
|
|
208
|
-
}
|
|
209
|
-
render(opts) {
|
|
210
|
-
return this.nodes.reduce((code, n) => code + n.render(opts), "");
|
|
211
|
-
}
|
|
212
|
-
optimizeNodes() {
|
|
213
|
-
const { nodes } = this;
|
|
214
|
-
let i = nodes.length;
|
|
215
|
-
while (i--) {
|
|
216
|
-
const n = nodes[i].optimizeNodes();
|
|
217
|
-
if (Array.isArray(n)) nodes.splice(i, 1, ...n);
|
|
218
|
-
else if (n) nodes[i] = n;
|
|
219
|
-
else nodes.splice(i, 1);
|
|
220
|
-
}
|
|
221
|
-
return nodes.length > 0 ? this : void 0;
|
|
222
|
-
}
|
|
223
|
-
optimizeNames(names, constants) {
|
|
224
|
-
const { nodes } = this;
|
|
225
|
-
let i = nodes.length;
|
|
226
|
-
while (i--) {
|
|
227
|
-
const n = nodes[i];
|
|
228
|
-
if (n.optimizeNames(names, constants)) continue;
|
|
229
|
-
subtractNames(names, n.names);
|
|
230
|
-
nodes.splice(i, 1);
|
|
231
|
-
}
|
|
232
|
-
return nodes.length > 0 ? this : void 0;
|
|
233
|
-
}
|
|
234
|
-
get names() {
|
|
235
|
-
return this.nodes.reduce((names, n) => addNames(names, n.names), {});
|
|
236
|
-
}
|
|
237
|
-
};
|
|
238
|
-
var BlockNode = class extends ParentNode {
|
|
239
|
-
render(opts) {
|
|
240
|
-
return "{" + opts._n + super.render(opts) + "}" + opts._n;
|
|
241
|
-
}
|
|
242
|
-
};
|
|
243
|
-
var Root = class extends ParentNode {};
|
|
244
|
-
var Else = class extends BlockNode {};
|
|
245
|
-
Else.kind = "else";
|
|
246
|
-
var If = class If extends BlockNode {
|
|
247
|
-
constructor(condition, nodes) {
|
|
248
|
-
super(nodes);
|
|
249
|
-
this.condition = condition;
|
|
250
|
-
}
|
|
251
|
-
render(opts) {
|
|
252
|
-
let code = `if(${this.condition})` + super.render(opts);
|
|
253
|
-
if (this.else) code += "else " + this.else.render(opts);
|
|
254
|
-
return code;
|
|
255
|
-
}
|
|
256
|
-
optimizeNodes() {
|
|
257
|
-
super.optimizeNodes();
|
|
258
|
-
const cond = this.condition;
|
|
259
|
-
if (cond === true) return this.nodes;
|
|
260
|
-
let e = this.else;
|
|
261
|
-
if (e) {
|
|
262
|
-
const ns = e.optimizeNodes();
|
|
263
|
-
e = this.else = Array.isArray(ns) ? new Else(ns) : ns;
|
|
264
|
-
}
|
|
265
|
-
if (e) {
|
|
266
|
-
if (cond === false) return e instanceof If ? e : e.nodes;
|
|
267
|
-
if (this.nodes.length) return this;
|
|
268
|
-
return new If(not(cond), e instanceof If ? [e] : e.nodes);
|
|
269
|
-
}
|
|
270
|
-
if (cond === false || !this.nodes.length) return void 0;
|
|
271
|
-
return this;
|
|
272
|
-
}
|
|
273
|
-
optimizeNames(names, constants) {
|
|
274
|
-
var _a;
|
|
275
|
-
this.else = (_a = this.else) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants);
|
|
276
|
-
if (!(super.optimizeNames(names, constants) || this.else)) return;
|
|
277
|
-
this.condition = optimizeExpr(this.condition, names, constants);
|
|
278
|
-
return this;
|
|
279
|
-
}
|
|
280
|
-
get names() {
|
|
281
|
-
const names = super.names;
|
|
282
|
-
addExprNames(names, this.condition);
|
|
283
|
-
if (this.else) addNames(names, this.else.names);
|
|
284
|
-
return names;
|
|
285
|
-
}
|
|
286
|
-
};
|
|
287
|
-
If.kind = "if";
|
|
288
|
-
var For = class extends BlockNode {};
|
|
289
|
-
For.kind = "for";
|
|
290
|
-
var ForLoop = class extends For {
|
|
291
|
-
constructor(iteration) {
|
|
292
|
-
super();
|
|
293
|
-
this.iteration = iteration;
|
|
294
|
-
}
|
|
295
|
-
render(opts) {
|
|
296
|
-
return `for(${this.iteration})` + super.render(opts);
|
|
297
|
-
}
|
|
298
|
-
optimizeNames(names, constants) {
|
|
299
|
-
if (!super.optimizeNames(names, constants)) return;
|
|
300
|
-
this.iteration = optimizeExpr(this.iteration, names, constants);
|
|
301
|
-
return this;
|
|
302
|
-
}
|
|
303
|
-
get names() {
|
|
304
|
-
return addNames(super.names, this.iteration.names);
|
|
305
|
-
}
|
|
306
|
-
};
|
|
307
|
-
var ForRange = class extends For {
|
|
308
|
-
constructor(varKind, name, from, to) {
|
|
309
|
-
super();
|
|
310
|
-
this.varKind = varKind;
|
|
311
|
-
this.name = name;
|
|
312
|
-
this.from = from;
|
|
313
|
-
this.to = to;
|
|
314
|
-
}
|
|
315
|
-
render(opts) {
|
|
316
|
-
const varKind = opts.es5 ? scope_1.varKinds.var : this.varKind;
|
|
317
|
-
const { name, from, to } = this;
|
|
318
|
-
return `for(${varKind} ${name}=${from}; ${name}<${to}; ${name}++)` + super.render(opts);
|
|
319
|
-
}
|
|
320
|
-
get names() {
|
|
321
|
-
return addExprNames(addExprNames(super.names, this.from), this.to);
|
|
322
|
-
}
|
|
323
|
-
};
|
|
324
|
-
var ForIter = class extends For {
|
|
325
|
-
constructor(loop, varKind, name, iterable) {
|
|
326
|
-
super();
|
|
327
|
-
this.loop = loop;
|
|
328
|
-
this.varKind = varKind;
|
|
329
|
-
this.name = name;
|
|
330
|
-
this.iterable = iterable;
|
|
331
|
-
}
|
|
332
|
-
render(opts) {
|
|
333
|
-
return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
|
|
334
|
-
}
|
|
335
|
-
optimizeNames(names, constants) {
|
|
336
|
-
if (!super.optimizeNames(names, constants)) return;
|
|
337
|
-
this.iterable = optimizeExpr(this.iterable, names, constants);
|
|
338
|
-
return this;
|
|
339
|
-
}
|
|
340
|
-
get names() {
|
|
341
|
-
return addNames(super.names, this.iterable.names);
|
|
342
|
-
}
|
|
343
|
-
};
|
|
344
|
-
var Func = class extends BlockNode {
|
|
345
|
-
constructor(name, args, async) {
|
|
346
|
-
super();
|
|
347
|
-
this.name = name;
|
|
348
|
-
this.args = args;
|
|
349
|
-
this.async = async;
|
|
350
|
-
}
|
|
351
|
-
render(opts) {
|
|
352
|
-
return `${this.async ? "async " : ""}function ${this.name}(${this.args})` + super.render(opts);
|
|
353
|
-
}
|
|
354
|
-
};
|
|
355
|
-
Func.kind = "func";
|
|
356
|
-
var Return = class extends ParentNode {
|
|
357
|
-
render(opts) {
|
|
358
|
-
return "return " + super.render(opts);
|
|
359
|
-
}
|
|
360
|
-
};
|
|
361
|
-
Return.kind = "return";
|
|
362
|
-
var Try = class extends BlockNode {
|
|
363
|
-
render(opts) {
|
|
364
|
-
let code = "try" + super.render(opts);
|
|
365
|
-
if (this.catch) code += this.catch.render(opts);
|
|
366
|
-
if (this.finally) code += this.finally.render(opts);
|
|
367
|
-
return code;
|
|
368
|
-
}
|
|
369
|
-
optimizeNodes() {
|
|
370
|
-
var _a, _b;
|
|
371
|
-
super.optimizeNodes();
|
|
372
|
-
(_a = this.catch) === null || _a === void 0 || _a.optimizeNodes();
|
|
373
|
-
(_b = this.finally) === null || _b === void 0 || _b.optimizeNodes();
|
|
374
|
-
return this;
|
|
375
|
-
}
|
|
376
|
-
optimizeNames(names, constants) {
|
|
377
|
-
var _a, _b;
|
|
378
|
-
super.optimizeNames(names, constants);
|
|
379
|
-
(_a = this.catch) === null || _a === void 0 || _a.optimizeNames(names, constants);
|
|
380
|
-
(_b = this.finally) === null || _b === void 0 || _b.optimizeNames(names, constants);
|
|
381
|
-
return this;
|
|
382
|
-
}
|
|
383
|
-
get names() {
|
|
384
|
-
const names = super.names;
|
|
385
|
-
if (this.catch) addNames(names, this.catch.names);
|
|
386
|
-
if (this.finally) addNames(names, this.finally.names);
|
|
387
|
-
return names;
|
|
388
|
-
}
|
|
389
|
-
};
|
|
390
|
-
var Catch = class extends BlockNode {
|
|
391
|
-
constructor(error) {
|
|
392
|
-
super();
|
|
393
|
-
this.error = error;
|
|
394
|
-
}
|
|
395
|
-
render(opts) {
|
|
396
|
-
return `catch(${this.error})` + super.render(opts);
|
|
397
|
-
}
|
|
398
|
-
};
|
|
399
|
-
Catch.kind = "catch";
|
|
400
|
-
var Finally = class extends BlockNode {
|
|
401
|
-
render(opts) {
|
|
402
|
-
return "finally" + super.render(opts);
|
|
403
|
-
}
|
|
404
|
-
};
|
|
405
|
-
Finally.kind = "finally";
|
|
406
|
-
var CodeGen = class {
|
|
407
|
-
constructor(extScope, opts = {}) {
|
|
408
|
-
this._values = {};
|
|
409
|
-
this._blockStarts = [];
|
|
410
|
-
this._constants = {};
|
|
411
|
-
this.opts = {
|
|
412
|
-
...opts,
|
|
413
|
-
_n: opts.lines ? "\n" : ""
|
|
414
|
-
};
|
|
415
|
-
this._extScope = extScope;
|
|
416
|
-
this._scope = new scope_1.Scope({ parent: extScope });
|
|
417
|
-
this._nodes = [new Root()];
|
|
418
|
-
}
|
|
419
|
-
toString() {
|
|
420
|
-
return this._root.render(this.opts);
|
|
421
|
-
}
|
|
422
|
-
name(prefix) {
|
|
423
|
-
return this._scope.name(prefix);
|
|
424
|
-
}
|
|
425
|
-
scopeName(prefix) {
|
|
426
|
-
return this._extScope.name(prefix);
|
|
427
|
-
}
|
|
428
|
-
scopeValue(prefixOrName, value) {
|
|
429
|
-
const name = this._extScope.value(prefixOrName, value);
|
|
430
|
-
(this._values[name.prefix] || (this._values[name.prefix] = /* @__PURE__ */ new Set())).add(name);
|
|
431
|
-
return name;
|
|
432
|
-
}
|
|
433
|
-
getScopeValue(prefix, keyOrRef) {
|
|
434
|
-
return this._extScope.getValue(prefix, keyOrRef);
|
|
435
|
-
}
|
|
436
|
-
scopeRefs(scopeName) {
|
|
437
|
-
return this._extScope.scopeRefs(scopeName, this._values);
|
|
438
|
-
}
|
|
439
|
-
scopeCode() {
|
|
440
|
-
return this._extScope.scopeCode(this._values);
|
|
441
|
-
}
|
|
442
|
-
_def(varKind, nameOrPrefix, rhs, constant) {
|
|
443
|
-
const name = this._scope.toName(nameOrPrefix);
|
|
444
|
-
if (rhs !== void 0 && constant) this._constants[name.str] = rhs;
|
|
445
|
-
this._leafNode(new Def(varKind, name, rhs));
|
|
446
|
-
return name;
|
|
447
|
-
}
|
|
448
|
-
const(nameOrPrefix, rhs, _constant) {
|
|
449
|
-
return this._def(scope_1.varKinds.const, nameOrPrefix, rhs, _constant);
|
|
450
|
-
}
|
|
451
|
-
let(nameOrPrefix, rhs, _constant) {
|
|
452
|
-
return this._def(scope_1.varKinds.let, nameOrPrefix, rhs, _constant);
|
|
453
|
-
}
|
|
454
|
-
var(nameOrPrefix, rhs, _constant) {
|
|
455
|
-
return this._def(scope_1.varKinds.var, nameOrPrefix, rhs, _constant);
|
|
456
|
-
}
|
|
457
|
-
assign(lhs, rhs, sideEffects) {
|
|
458
|
-
return this._leafNode(new Assign(lhs, rhs, sideEffects));
|
|
459
|
-
}
|
|
460
|
-
add(lhs, rhs) {
|
|
461
|
-
return this._leafNode(new AssignOp(lhs, exports.operators.ADD, rhs));
|
|
462
|
-
}
|
|
463
|
-
code(c) {
|
|
464
|
-
if (typeof c == "function") c();
|
|
465
|
-
else if (c !== code_1.nil) this._leafNode(new AnyCode(c));
|
|
466
|
-
return this;
|
|
467
|
-
}
|
|
468
|
-
object(...keyValues) {
|
|
469
|
-
const code = ["{"];
|
|
470
|
-
for (const [key, value] of keyValues) {
|
|
471
|
-
if (code.length > 1) code.push(",");
|
|
472
|
-
code.push(key);
|
|
473
|
-
if (key !== value || this.opts.es5) {
|
|
474
|
-
code.push(":");
|
|
475
|
-
(0, code_1.addCodeArg)(code, value);
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
code.push("}");
|
|
479
|
-
return new code_1._Code(code);
|
|
480
|
-
}
|
|
481
|
-
if(condition, thenBody, elseBody) {
|
|
482
|
-
this._blockNode(new If(condition));
|
|
483
|
-
if (thenBody && elseBody) this.code(thenBody).else().code(elseBody).endIf();
|
|
484
|
-
else if (thenBody) this.code(thenBody).endIf();
|
|
485
|
-
else if (elseBody) throw new Error("CodeGen: \"else\" body without \"then\" body");
|
|
486
|
-
return this;
|
|
487
|
-
}
|
|
488
|
-
elseIf(condition) {
|
|
489
|
-
return this._elseNode(new If(condition));
|
|
490
|
-
}
|
|
491
|
-
else() {
|
|
492
|
-
return this._elseNode(new Else());
|
|
493
|
-
}
|
|
494
|
-
endIf() {
|
|
495
|
-
return this._endBlockNode(If, Else);
|
|
496
|
-
}
|
|
497
|
-
_for(node, forBody) {
|
|
498
|
-
this._blockNode(node);
|
|
499
|
-
if (forBody) this.code(forBody).endFor();
|
|
500
|
-
return this;
|
|
501
|
-
}
|
|
502
|
-
for(iteration, forBody) {
|
|
503
|
-
return this._for(new ForLoop(iteration), forBody);
|
|
504
|
-
}
|
|
505
|
-
forRange(nameOrPrefix, from, to, forBody, varKind = this.opts.es5 ? scope_1.varKinds.var : scope_1.varKinds.let) {
|
|
506
|
-
const name = this._scope.toName(nameOrPrefix);
|
|
507
|
-
return this._for(new ForRange(varKind, name, from, to), () => forBody(name));
|
|
508
|
-
}
|
|
509
|
-
forOf(nameOrPrefix, iterable, forBody, varKind = scope_1.varKinds.const) {
|
|
510
|
-
const name = this._scope.toName(nameOrPrefix);
|
|
511
|
-
if (this.opts.es5) {
|
|
512
|
-
const arr = iterable instanceof code_1.Name ? iterable : this.var("_arr", iterable);
|
|
513
|
-
return this.forRange("_i", 0, (0, code_1._)`${arr}.length`, (i) => {
|
|
514
|
-
this.var(name, (0, code_1._)`${arr}[${i}]`);
|
|
515
|
-
forBody(name);
|
|
516
|
-
});
|
|
517
|
-
}
|
|
518
|
-
return this._for(new ForIter("of", varKind, name, iterable), () => forBody(name));
|
|
519
|
-
}
|
|
520
|
-
forIn(nameOrPrefix, obj, forBody, varKind = this.opts.es5 ? scope_1.varKinds.var : scope_1.varKinds.const) {
|
|
521
|
-
if (this.opts.ownProperties) return this.forOf(nameOrPrefix, (0, code_1._)`Object.keys(${obj})`, forBody);
|
|
522
|
-
const name = this._scope.toName(nameOrPrefix);
|
|
523
|
-
return this._for(new ForIter("in", varKind, name, obj), () => forBody(name));
|
|
524
|
-
}
|
|
525
|
-
endFor() {
|
|
526
|
-
return this._endBlockNode(For);
|
|
527
|
-
}
|
|
528
|
-
label(label) {
|
|
529
|
-
return this._leafNode(new Label(label));
|
|
530
|
-
}
|
|
531
|
-
break(label) {
|
|
532
|
-
return this._leafNode(new Break(label));
|
|
533
|
-
}
|
|
534
|
-
return(value) {
|
|
535
|
-
const node = new Return();
|
|
536
|
-
this._blockNode(node);
|
|
537
|
-
this.code(value);
|
|
538
|
-
if (node.nodes.length !== 1) throw new Error("CodeGen: \"return\" should have one node");
|
|
539
|
-
return this._endBlockNode(Return);
|
|
540
|
-
}
|
|
541
|
-
try(tryBody, catchCode, finallyCode) {
|
|
542
|
-
if (!catchCode && !finallyCode) throw new Error("CodeGen: \"try\" without \"catch\" and \"finally\"");
|
|
543
|
-
const node = new Try();
|
|
544
|
-
this._blockNode(node);
|
|
545
|
-
this.code(tryBody);
|
|
546
|
-
if (catchCode) {
|
|
547
|
-
const error = this.name("e");
|
|
548
|
-
this._currNode = node.catch = new Catch(error);
|
|
549
|
-
catchCode(error);
|
|
550
|
-
}
|
|
551
|
-
if (finallyCode) {
|
|
552
|
-
this._currNode = node.finally = new Finally();
|
|
553
|
-
this.code(finallyCode);
|
|
554
|
-
}
|
|
555
|
-
return this._endBlockNode(Catch, Finally);
|
|
556
|
-
}
|
|
557
|
-
throw(error) {
|
|
558
|
-
return this._leafNode(new Throw(error));
|
|
559
|
-
}
|
|
560
|
-
block(body, nodeCount) {
|
|
561
|
-
this._blockStarts.push(this._nodes.length);
|
|
562
|
-
if (body) this.code(body).endBlock(nodeCount);
|
|
563
|
-
return this;
|
|
564
|
-
}
|
|
565
|
-
endBlock(nodeCount) {
|
|
566
|
-
const len = this._blockStarts.pop();
|
|
567
|
-
if (len === void 0) throw new Error("CodeGen: not in self-balancing block");
|
|
568
|
-
const toClose = this._nodes.length - len;
|
|
569
|
-
if (toClose < 0 || nodeCount !== void 0 && toClose !== nodeCount) throw new Error(`CodeGen: wrong number of nodes: ${toClose} vs ${nodeCount} expected`);
|
|
570
|
-
this._nodes.length = len;
|
|
571
|
-
return this;
|
|
572
|
-
}
|
|
573
|
-
func(name, args = code_1.nil, async, funcBody) {
|
|
574
|
-
this._blockNode(new Func(name, args, async));
|
|
575
|
-
if (funcBody) this.code(funcBody).endFunc();
|
|
576
|
-
return this;
|
|
577
|
-
}
|
|
578
|
-
endFunc() {
|
|
579
|
-
return this._endBlockNode(Func);
|
|
580
|
-
}
|
|
581
|
-
optimize(n = 1) {
|
|
582
|
-
while (n-- > 0) {
|
|
583
|
-
this._root.optimizeNodes();
|
|
584
|
-
this._root.optimizeNames(this._root.names, this._constants);
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
_leafNode(node) {
|
|
588
|
-
this._currNode.nodes.push(node);
|
|
589
|
-
return this;
|
|
590
|
-
}
|
|
591
|
-
_blockNode(node) {
|
|
592
|
-
this._currNode.nodes.push(node);
|
|
593
|
-
this._nodes.push(node);
|
|
594
|
-
}
|
|
595
|
-
_endBlockNode(N1, N2) {
|
|
596
|
-
const n = this._currNode;
|
|
597
|
-
if (n instanceof N1 || N2 && n instanceof N2) {
|
|
598
|
-
this._nodes.pop();
|
|
599
|
-
return this;
|
|
600
|
-
}
|
|
601
|
-
throw new Error(`CodeGen: not in block "${N2 ? `${N1.kind}/${N2.kind}` : N1.kind}"`);
|
|
602
|
-
}
|
|
603
|
-
_elseNode(node) {
|
|
604
|
-
const n = this._currNode;
|
|
605
|
-
if (!(n instanceof If)) throw new Error("CodeGen: \"else\" without \"if\"");
|
|
606
|
-
this._currNode = n.else = node;
|
|
607
|
-
return this;
|
|
608
|
-
}
|
|
609
|
-
get _root() {
|
|
610
|
-
return this._nodes[0];
|
|
611
|
-
}
|
|
612
|
-
get _currNode() {
|
|
613
|
-
const ns = this._nodes;
|
|
614
|
-
return ns[ns.length - 1];
|
|
615
|
-
}
|
|
616
|
-
set _currNode(node) {
|
|
617
|
-
const ns = this._nodes;
|
|
618
|
-
ns[ns.length - 1] = node;
|
|
619
|
-
}
|
|
620
|
-
};
|
|
621
|
-
exports.CodeGen = CodeGen;
|
|
622
|
-
function addNames(names, from) {
|
|
623
|
-
for (const n in from) names[n] = (names[n] || 0) + (from[n] || 0);
|
|
624
|
-
return names;
|
|
625
|
-
}
|
|
626
|
-
function addExprNames(names, from) {
|
|
627
|
-
return from instanceof code_1._CodeOrName ? addNames(names, from.names) : names;
|
|
628
|
-
}
|
|
629
|
-
function optimizeExpr(expr, names, constants) {
|
|
630
|
-
if (expr instanceof code_1.Name) return replaceName(expr);
|
|
631
|
-
if (!canOptimize(expr)) return expr;
|
|
632
|
-
return new code_1._Code(expr._items.reduce((items, c) => {
|
|
633
|
-
if (c instanceof code_1.Name) c = replaceName(c);
|
|
634
|
-
if (c instanceof code_1._Code) items.push(...c._items);
|
|
635
|
-
else items.push(c);
|
|
636
|
-
return items;
|
|
637
|
-
}, []));
|
|
638
|
-
function replaceName(n) {
|
|
639
|
-
const c = constants[n.str];
|
|
640
|
-
if (c === void 0 || names[n.str] !== 1) return n;
|
|
641
|
-
delete names[n.str];
|
|
642
|
-
return c;
|
|
643
|
-
}
|
|
644
|
-
function canOptimize(e) {
|
|
645
|
-
return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants[c.str] !== void 0);
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
function subtractNames(names, from) {
|
|
649
|
-
for (const n in from) names[n] = (names[n] || 0) - (from[n] || 0);
|
|
650
|
-
}
|
|
651
|
-
function not(x) {
|
|
652
|
-
return typeof x == "boolean" || typeof x == "number" || x === null ? !x : (0, code_1._)`!${par(x)}`;
|
|
653
|
-
}
|
|
654
|
-
exports.not = not;
|
|
655
|
-
const andCode = mappend(exports.operators.AND);
|
|
656
|
-
function and(...args) {
|
|
657
|
-
return args.reduce(andCode);
|
|
658
|
-
}
|
|
659
|
-
exports.and = and;
|
|
660
|
-
const orCode = mappend(exports.operators.OR);
|
|
661
|
-
function or(...args) {
|
|
662
|
-
return args.reduce(orCode);
|
|
663
|
-
}
|
|
664
|
-
exports.or = or;
|
|
665
|
-
function mappend(op) {
|
|
666
|
-
return (x, y) => x === code_1.nil ? y : y === code_1.nil ? x : (0, code_1._)`${par(x)} ${op} ${par(y)}`;
|
|
667
|
-
}
|
|
668
|
-
function par(x) {
|
|
669
|
-
return x instanceof code_1.Name ? x : (0, code_1._)`(${x})`;
|
|
670
|
-
}
|
|
671
|
-
}));
|
|
672
|
-
//#endregion
|
|
673
|
-
export default require_codegen();
|
|
674
|
-
export { require_codegen };
|