@spotlightjs/spotlight 4.11.3 → 4.11.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/ajv.js +6 -3
- package/dist/_virtual/ajv2.js +13 -0
- package/dist/_virtual/index.js +6 -3
- package/dist/_virtual/index10.js +3 -3
- package/dist/_virtual/index11.js +3 -3
- package/dist/_virtual/index12.js +13 -0
- package/dist/_virtual/index2.js +3 -3
- package/dist/_virtual/index4.js +3 -3
- package/dist/_virtual/index5.js +3 -3
- package/dist/_virtual/index6.js +3 -3
- package/dist/_virtual/index7.js +3 -3
- package/dist/_virtual/index8.js +3 -3
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js +1 -1
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js.map +1 -1
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js +3 -3
- package/dist/node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/formats.js +203 -194
- package/dist/node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/formats.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/index.js +47 -47
- package/dist/node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/index.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/limit.js +77 -69
- package/dist/node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/limit.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/ajv.js +80 -85
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/ajv.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/code.js +145 -136
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/code.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/index.js +692 -685
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/index.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/scope.js +143 -135
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/scope.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/errors.js +122 -116
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/errors.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/index.js +218 -218
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/index.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/names.js +43 -35
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/names.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/ref_error.js +19 -11
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/ref_error.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/resolve.js +149 -144
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/resolve.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/rules.js +31 -25
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/rules.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/util.js +164 -160
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/util.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/applicability.js +23 -17
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/applicability.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/boolSchema.js +52 -49
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/boolSchema.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/dataType.js +174 -173
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/dataType.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/defaults.js +36 -32
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/defaults.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/index.js +473 -478
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/index.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/keyword.js +113 -111
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/keyword.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/subschema.js +81 -77
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/subschema.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.js +573 -574
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/refs/data.json.js +3 -17
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/refs/data.json.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/refs/json-schema-draft-07.json.js +4 -236
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/refs/json-schema-draft-07.json.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/equal.js +16 -7
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/equal.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/ucs2length.js +27 -18
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/ucs2length.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/uri.js +16 -7
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/uri.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/validation_error.js +17 -8
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/validation_error.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +55 -48
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +104 -99
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/allOf.js +30 -22
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/allOf.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +20 -12
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/anyOf.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/contains.js +95 -88
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/contains.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +94 -88
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/dependencies.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/if.js +71 -64
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/if.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/index.js +66 -73
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/index.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/items.js +60 -54
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/items.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/items2020.js +41 -36
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/items2020.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/not.js +34 -26
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/not.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +60 -53
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/oneOf.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +73 -67
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +20 -12
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/properties.js +62 -57
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/properties.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +46 -39
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +21 -13
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/thenElse.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/code.js +132 -129
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/code.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/id.js +17 -8
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/id.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/index.js +27 -20
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/index.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/ref.js +121 -118
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/ref.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/discriminator/index.js +103 -99
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/discriminator/index.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/discriminator/types.js +15 -9
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/discriminator/types.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/draft7.js +30 -26
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/draft7.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/format/format.js +84 -76
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/format/format.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/format/index.js +16 -8
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/format/index.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/metadata.js +24 -18
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/metadata.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/const.js +33 -27
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/const.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/enum.js +53 -47
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/enum.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/index.js +52 -53
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/index.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitItems.js +32 -24
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitItems.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitLength.js +37 -31
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitLength.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +35 -27
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitNumber.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +32 -24
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitProperties.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +31 -23
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/multipleOf.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/pattern.js +41 -35
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/pattern.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/required.js +80 -74
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/required.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +71 -66
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js.map +1 -1
- package/dist/node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js +34 -27
- package/dist/node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js.map +1 -1
- package/dist/node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/index.js +300 -0
- package/dist/node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/index.js.map +1 -0
- package/dist/node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/lib/schemes.js +223 -0
- package/dist/node_modules/.pnpm/{fast-uri@3.1.0 → fast-uri@3.1.2}/node_modules/fast-uri/lib/schemes.js.map +1 -1
- package/dist/node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/lib/utils.js +325 -0
- package/dist/node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/lib/utils.js.map +1 -0
- package/dist/node_modules/.pnpm/hono@4.12.18/node_modules/hono/dist/helper/streaming/sse.js.map +1 -0
- package/dist/node_modules/.pnpm/{hono@4.12.8 → hono@4.12.18}/node_modules/hono/dist/middleware/cors/index.js +8 -8
- package/dist/node_modules/.pnpm/hono@4.12.18/node_modules/hono/dist/middleware/cors/index.js.map +1 -0
- package/dist/node_modules/.pnpm/hono@4.12.18/node_modules/hono/dist/utils/html.js.map +1 -0
- package/dist/node_modules/.pnpm/hono@4.12.18/node_modules/hono/dist/utils/stream.js.map +1 -0
- package/dist/node_modules/.pnpm/json-schema-traverse@1.0.0/node_modules/json-schema-traverse/index.js +83 -78
- package/dist/node_modules/.pnpm/json-schema-traverse@1.0.0/node_modules/json-schema-traverse/index.js.map +1 -1
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@4.1.13/node_modules/zod-to-json-schema/dist/esm/Options.js +1 -1
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@4.1.13/node_modules/zod-to-json-schema/dist/esm/Options.js.map +1 -1
- package/dist/node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/core/util.js +1 -1
- package/dist/node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/core/util.js.map +1 -1
- package/dist/sentry-config.js +2 -2
- package/dist/server/cli/run.js +2 -2
- package/dist/server/cli.js +2 -2
- package/dist/server/main.js +2 -2
- package/dist/server/mcp/mcp.js +2 -2
- package/dist/server/routes/stream/streaming.js +2 -2
- package/dist/ui/assets/index.js +61 -70
- package/dist/ui/assets/index2.js +1 -1
- package/dist/ui/assets/instrumentation.js +18 -18
- package/dist/ui/assets/main.css +1 -1
- package/dist/ui/assets/main.js +1 -1
- package/dist/ui/assets/serverTimingMeta.js +23 -30
- package/package.json +9 -9
- package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/index.js +0 -264
- package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/index.js.map +0 -1
- package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/schemes.js +0 -197
- package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/utils.js +0 -261
- package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/utils.js.map +0 -1
- package/dist/node_modules/.pnpm/hono@4.12.8/node_modules/hono/dist/helper/streaming/sse.js.map +0 -1
- package/dist/node_modules/.pnpm/hono@4.12.8/node_modules/hono/dist/middleware/cors/index.js.map +0 -1
- package/dist/node_modules/.pnpm/hono@4.12.8/node_modules/hono/dist/utils/html.js.map +0 -1
- package/dist/node_modules/.pnpm/hono@4.12.8/node_modules/hono/dist/utils/stream.js.map +0 -1
- /package/dist/node_modules/.pnpm/{hono@4.12.8 → hono@4.12.18}/node_modules/hono/dist/helper/streaming/sse.js +0 -0
- /package/dist/node_modules/.pnpm/{hono@4.12.8 → hono@4.12.18}/node_modules/hono/dist/utils/html.js +0 -0
- /package/dist/node_modules/.pnpm/{hono@4.12.8 → hono@4.12.18}/node_modules/hono/dist/utils/stream.js +0 -0
|
@@ -2,728 +2,735 @@
|
|
|
2
2
|
!(function() {
|
|
3
3
|
try {
|
|
4
4
|
var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
|
|
5
|
-
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "
|
|
5
|
+
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "e71d1ec0-d827-4bff-be63-38bacca88075", e._sentryDebugIdIdentifier = "sentry-dbid-e71d1ec0-d827-4bff-be63-38bacca88075");
|
|
6
6
|
} catch (e2) {
|
|
7
7
|
}
|
|
8
8
|
})();
|
|
9
|
-
import { __exports as codegen } from "../../../../../../../../_virtual/
|
|
10
|
-
import "./code.js";
|
|
11
|
-
import "./scope.js";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
(
|
|
15
|
-
|
|
16
|
-
exports$1
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
constructor(varKind, name, rhs) {
|
|
79
|
-
super();
|
|
80
|
-
this.varKind = varKind;
|
|
81
|
-
this.name = name;
|
|
82
|
-
this.rhs = rhs;
|
|
83
|
-
}
|
|
84
|
-
render({ es5, _n }) {
|
|
85
|
-
const varKind = es5 ? scope_1.varKinds.var : this.varKind;
|
|
86
|
-
const rhs = this.rhs === void 0 ? "" : ` = ${this.rhs}`;
|
|
87
|
-
return `${varKind} ${this.name}${rhs};` + _n;
|
|
88
|
-
}
|
|
89
|
-
optimizeNames(names, constants) {
|
|
90
|
-
if (!names[this.name.str])
|
|
91
|
-
return;
|
|
92
|
-
if (this.rhs)
|
|
93
|
-
this.rhs = optimizeExpr(this.rhs, names, constants);
|
|
94
|
-
return this;
|
|
95
|
-
}
|
|
96
|
-
get names() {
|
|
97
|
-
return this.rhs instanceof code_1._CodeOrName ? this.rhs.names : {};
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
class Assign extends Node {
|
|
101
|
-
constructor(lhs, rhs, sideEffects) {
|
|
102
|
-
super();
|
|
103
|
-
this.lhs = lhs;
|
|
104
|
-
this.rhs = rhs;
|
|
105
|
-
this.sideEffects = sideEffects;
|
|
106
|
-
}
|
|
107
|
-
render({ _n }) {
|
|
108
|
-
return `${this.lhs} = ${this.rhs};` + _n;
|
|
109
|
-
}
|
|
110
|
-
optimizeNames(names, constants) {
|
|
111
|
-
if (this.lhs instanceof code_1.Name && !names[this.lhs.str] && !this.sideEffects)
|
|
112
|
-
return;
|
|
113
|
-
this.rhs = optimizeExpr(this.rhs, names, constants);
|
|
114
|
-
return this;
|
|
115
|
-
}
|
|
116
|
-
get names() {
|
|
117
|
-
const names = this.lhs instanceof code_1.Name ? {} : { ...this.lhs.names };
|
|
118
|
-
return addExprNames(names, this.rhs);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
class AssignOp extends Assign {
|
|
122
|
-
constructor(lhs, op, rhs, sideEffects) {
|
|
123
|
-
super(lhs, rhs, sideEffects);
|
|
124
|
-
this.op = op;
|
|
125
|
-
}
|
|
126
|
-
render({ _n }) {
|
|
127
|
-
return `${this.lhs} ${this.op}= ${this.rhs};` + _n;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
class Label extends Node {
|
|
131
|
-
constructor(label) {
|
|
132
|
-
super();
|
|
133
|
-
this.label = label;
|
|
134
|
-
this.names = {};
|
|
135
|
-
}
|
|
136
|
-
render({ _n }) {
|
|
137
|
-
return `${this.label}:` + _n;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
class Break extends Node {
|
|
141
|
-
constructor(label) {
|
|
142
|
-
super();
|
|
143
|
-
this.label = label;
|
|
144
|
-
this.names = {};
|
|
145
|
-
}
|
|
146
|
-
render({ _n }) {
|
|
147
|
-
const label = this.label ? ` ${this.label}` : "";
|
|
148
|
-
return `break${label};` + _n;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
class Throw extends Node {
|
|
152
|
-
constructor(error) {
|
|
153
|
-
super();
|
|
154
|
-
this.error = error;
|
|
9
|
+
import { __exports as codegen } from "../../../../../../../../_virtual/index5.js";
|
|
10
|
+
import { __require as requireCode } from "./code.js";
|
|
11
|
+
import { __require as requireScope } from "./scope.js";
|
|
12
|
+
var hasRequiredCodegen;
|
|
13
|
+
function requireCodegen() {
|
|
14
|
+
if (hasRequiredCodegen) return codegen;
|
|
15
|
+
hasRequiredCodegen = 1;
|
|
16
|
+
(function(exports$1) {
|
|
17
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
18
|
+
exports$1.or = exports$1.and = exports$1.not = exports$1.CodeGen = exports$1.operators = exports$1.varKinds = exports$1.ValueScopeName = exports$1.ValueScope = exports$1.Scope = exports$1.Name = exports$1.regexpCode = exports$1.stringify = exports$1.getProperty = exports$1.nil = exports$1.strConcat = exports$1.str = exports$1._ = void 0;
|
|
19
|
+
const code_1 = /* @__PURE__ */ requireCode();
|
|
20
|
+
const scope_1 = /* @__PURE__ */ requireScope();
|
|
21
|
+
var code_2 = /* @__PURE__ */ requireCode();
|
|
22
|
+
Object.defineProperty(exports$1, "_", { enumerable: true, get: function() {
|
|
23
|
+
return code_2._;
|
|
24
|
+
} });
|
|
25
|
+
Object.defineProperty(exports$1, "str", { enumerable: true, get: function() {
|
|
26
|
+
return code_2.str;
|
|
27
|
+
} });
|
|
28
|
+
Object.defineProperty(exports$1, "strConcat", { enumerable: true, get: function() {
|
|
29
|
+
return code_2.strConcat;
|
|
30
|
+
} });
|
|
31
|
+
Object.defineProperty(exports$1, "nil", { enumerable: true, get: function() {
|
|
32
|
+
return code_2.nil;
|
|
33
|
+
} });
|
|
34
|
+
Object.defineProperty(exports$1, "getProperty", { enumerable: true, get: function() {
|
|
35
|
+
return code_2.getProperty;
|
|
36
|
+
} });
|
|
37
|
+
Object.defineProperty(exports$1, "stringify", { enumerable: true, get: function() {
|
|
38
|
+
return code_2.stringify;
|
|
39
|
+
} });
|
|
40
|
+
Object.defineProperty(exports$1, "regexpCode", { enumerable: true, get: function() {
|
|
41
|
+
return code_2.regexpCode;
|
|
42
|
+
} });
|
|
43
|
+
Object.defineProperty(exports$1, "Name", { enumerable: true, get: function() {
|
|
44
|
+
return code_2.Name;
|
|
45
|
+
} });
|
|
46
|
+
var scope_2 = /* @__PURE__ */ requireScope();
|
|
47
|
+
Object.defineProperty(exports$1, "Scope", { enumerable: true, get: function() {
|
|
48
|
+
return scope_2.Scope;
|
|
49
|
+
} });
|
|
50
|
+
Object.defineProperty(exports$1, "ValueScope", { enumerable: true, get: function() {
|
|
51
|
+
return scope_2.ValueScope;
|
|
52
|
+
} });
|
|
53
|
+
Object.defineProperty(exports$1, "ValueScopeName", { enumerable: true, get: function() {
|
|
54
|
+
return scope_2.ValueScopeName;
|
|
55
|
+
} });
|
|
56
|
+
Object.defineProperty(exports$1, "varKinds", { enumerable: true, get: function() {
|
|
57
|
+
return scope_2.varKinds;
|
|
58
|
+
} });
|
|
59
|
+
exports$1.operators = {
|
|
60
|
+
GT: new code_1._Code(">"),
|
|
61
|
+
GTE: new code_1._Code(">="),
|
|
62
|
+
LT: new code_1._Code("<"),
|
|
63
|
+
LTE: new code_1._Code("<="),
|
|
64
|
+
EQ: new code_1._Code("==="),
|
|
65
|
+
NEQ: new code_1._Code("!=="),
|
|
66
|
+
NOT: new code_1._Code("!"),
|
|
67
|
+
OR: new code_1._Code("||"),
|
|
68
|
+
AND: new code_1._Code("&&"),
|
|
69
|
+
ADD: new code_1._Code("+")
|
|
70
|
+
};
|
|
71
|
+
class Node {
|
|
72
|
+
optimizeNodes() {
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
optimizeNames(_names, _constants) {
|
|
76
|
+
return this;
|
|
77
|
+
}
|
|
155
78
|
}
|
|
156
|
-
|
|
157
|
-
|
|
79
|
+
class Def extends Node {
|
|
80
|
+
constructor(varKind, name, rhs) {
|
|
81
|
+
super();
|
|
82
|
+
this.varKind = varKind;
|
|
83
|
+
this.name = name;
|
|
84
|
+
this.rhs = rhs;
|
|
85
|
+
}
|
|
86
|
+
render({ es5, _n }) {
|
|
87
|
+
const varKind = es5 ? scope_1.varKinds.var : this.varKind;
|
|
88
|
+
const rhs = this.rhs === void 0 ? "" : ` = ${this.rhs}`;
|
|
89
|
+
return `${varKind} ${this.name}${rhs};` + _n;
|
|
90
|
+
}
|
|
91
|
+
optimizeNames(names, constants) {
|
|
92
|
+
if (!names[this.name.str])
|
|
93
|
+
return;
|
|
94
|
+
if (this.rhs)
|
|
95
|
+
this.rhs = optimizeExpr(this.rhs, names, constants);
|
|
96
|
+
return this;
|
|
97
|
+
}
|
|
98
|
+
get names() {
|
|
99
|
+
return this.rhs instanceof code_1._CodeOrName ? this.rhs.names : {};
|
|
100
|
+
}
|
|
158
101
|
}
|
|
159
|
-
|
|
160
|
-
|
|
102
|
+
class Assign extends Node {
|
|
103
|
+
constructor(lhs, rhs, sideEffects) {
|
|
104
|
+
super();
|
|
105
|
+
this.lhs = lhs;
|
|
106
|
+
this.rhs = rhs;
|
|
107
|
+
this.sideEffects = sideEffects;
|
|
108
|
+
}
|
|
109
|
+
render({ _n }) {
|
|
110
|
+
return `${this.lhs} = ${this.rhs};` + _n;
|
|
111
|
+
}
|
|
112
|
+
optimizeNames(names, constants) {
|
|
113
|
+
if (this.lhs instanceof code_1.Name && !names[this.lhs.str] && !this.sideEffects)
|
|
114
|
+
return;
|
|
115
|
+
this.rhs = optimizeExpr(this.rhs, names, constants);
|
|
116
|
+
return this;
|
|
117
|
+
}
|
|
118
|
+
get names() {
|
|
119
|
+
const names = this.lhs instanceof code_1.Name ? {} : { ...this.lhs.names };
|
|
120
|
+
return addExprNames(names, this.rhs);
|
|
121
|
+
}
|
|
161
122
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
123
|
+
class AssignOp extends Assign {
|
|
124
|
+
constructor(lhs, op, rhs, sideEffects) {
|
|
125
|
+
super(lhs, rhs, sideEffects);
|
|
126
|
+
this.op = op;
|
|
127
|
+
}
|
|
128
|
+
render({ _n }) {
|
|
129
|
+
return `${this.lhs} ${this.op}= ${this.rhs};` + _n;
|
|
130
|
+
}
|
|
167
131
|
}
|
|
168
|
-
|
|
169
|
-
|
|
132
|
+
class Label extends Node {
|
|
133
|
+
constructor(label) {
|
|
134
|
+
super();
|
|
135
|
+
this.label = label;
|
|
136
|
+
this.names = {};
|
|
137
|
+
}
|
|
138
|
+
render({ _n }) {
|
|
139
|
+
return `${this.label}:` + _n;
|
|
140
|
+
}
|
|
170
141
|
}
|
|
171
|
-
|
|
172
|
-
|
|
142
|
+
class Break extends Node {
|
|
143
|
+
constructor(label) {
|
|
144
|
+
super();
|
|
145
|
+
this.label = label;
|
|
146
|
+
this.names = {};
|
|
147
|
+
}
|
|
148
|
+
render({ _n }) {
|
|
149
|
+
const label = this.label ? ` ${this.label}` : "";
|
|
150
|
+
return `break${label};` + _n;
|
|
151
|
+
}
|
|
173
152
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
153
|
+
class Throw extends Node {
|
|
154
|
+
constructor(error) {
|
|
155
|
+
super();
|
|
156
|
+
this.error = error;
|
|
157
|
+
}
|
|
158
|
+
render({ _n }) {
|
|
159
|
+
return `throw ${this.error};` + _n;
|
|
160
|
+
}
|
|
161
|
+
get names() {
|
|
162
|
+
return this.error.names;
|
|
163
|
+
}
|
|
177
164
|
}
|
|
178
|
-
|
|
179
|
-
|
|
165
|
+
class AnyCode extends Node {
|
|
166
|
+
constructor(code) {
|
|
167
|
+
super();
|
|
168
|
+
this.code = code;
|
|
169
|
+
}
|
|
170
|
+
render({ _n }) {
|
|
171
|
+
return `${this.code};` + _n;
|
|
172
|
+
}
|
|
173
|
+
optimizeNodes() {
|
|
174
|
+
return `${this.code}` ? this : void 0;
|
|
175
|
+
}
|
|
176
|
+
optimizeNames(names, constants) {
|
|
177
|
+
this.code = optimizeExpr(this.code, names, constants);
|
|
178
|
+
return this;
|
|
179
|
+
}
|
|
180
|
+
get names() {
|
|
181
|
+
return this.code instanceof code_1._CodeOrName ? this.code.names : {};
|
|
182
|
+
}
|
|
180
183
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
184
|
+
class ParentNode extends Node {
|
|
185
|
+
constructor(nodes = []) {
|
|
186
|
+
super();
|
|
187
|
+
this.nodes = nodes;
|
|
188
|
+
}
|
|
189
|
+
render(opts) {
|
|
190
|
+
return this.nodes.reduce((code, n) => code + n.render(opts), "");
|
|
191
|
+
}
|
|
192
|
+
optimizeNodes() {
|
|
193
|
+
const { nodes } = this;
|
|
194
|
+
let i = nodes.length;
|
|
195
|
+
while (i--) {
|
|
196
|
+
const n = nodes[i].optimizeNodes();
|
|
197
|
+
if (Array.isArray(n))
|
|
198
|
+
nodes.splice(i, 1, ...n);
|
|
199
|
+
else if (n)
|
|
200
|
+
nodes[i] = n;
|
|
201
|
+
else
|
|
202
|
+
nodes.splice(i, 1);
|
|
203
|
+
}
|
|
204
|
+
return nodes.length > 0 ? this : void 0;
|
|
205
|
+
}
|
|
206
|
+
optimizeNames(names, constants) {
|
|
207
|
+
const { nodes } = this;
|
|
208
|
+
let i = nodes.length;
|
|
209
|
+
while (i--) {
|
|
210
|
+
const n = nodes[i];
|
|
211
|
+
if (n.optimizeNames(names, constants))
|
|
212
|
+
continue;
|
|
213
|
+
subtractNames(names, n.names);
|
|
200
214
|
nodes.splice(i, 1);
|
|
215
|
+
}
|
|
216
|
+
return nodes.length > 0 ? this : void 0;
|
|
201
217
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
optimizeNames(names, constants) {
|
|
205
|
-
const { nodes } = this;
|
|
206
|
-
let i = nodes.length;
|
|
207
|
-
while (i--) {
|
|
208
|
-
const n = nodes[i];
|
|
209
|
-
if (n.optimizeNames(names, constants))
|
|
210
|
-
continue;
|
|
211
|
-
subtractNames(names, n.names);
|
|
212
|
-
nodes.splice(i, 1);
|
|
218
|
+
get names() {
|
|
219
|
+
return this.nodes.reduce((names, n) => addNames(names, n.names), {});
|
|
213
220
|
}
|
|
214
|
-
return nodes.length > 0 ? this : void 0;
|
|
215
|
-
}
|
|
216
|
-
get names() {
|
|
217
|
-
return this.nodes.reduce((names, n) => addNames(names, n.names), {});
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
class BlockNode extends ParentNode {
|
|
221
|
-
render(opts) {
|
|
222
|
-
return "{" + opts._n + super.render(opts) + "}" + opts._n;
|
|
223
221
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
229
|
-
Else.kind = "else";
|
|
230
|
-
class If extends BlockNode {
|
|
231
|
-
constructor(condition, nodes) {
|
|
232
|
-
super(nodes);
|
|
233
|
-
this.condition = condition;
|
|
234
|
-
}
|
|
235
|
-
render(opts) {
|
|
236
|
-
let code2 = `if(${this.condition})` + super.render(opts);
|
|
237
|
-
if (this.else)
|
|
238
|
-
code2 += "else " + this.else.render(opts);
|
|
239
|
-
return code2;
|
|
240
|
-
}
|
|
241
|
-
optimizeNodes() {
|
|
242
|
-
super.optimizeNodes();
|
|
243
|
-
const cond = this.condition;
|
|
244
|
-
if (cond === true)
|
|
245
|
-
return this.nodes;
|
|
246
|
-
let e = this.else;
|
|
247
|
-
if (e) {
|
|
248
|
-
const ns = e.optimizeNodes();
|
|
249
|
-
e = this.else = Array.isArray(ns) ? new Else(ns) : ns;
|
|
250
|
-
}
|
|
251
|
-
if (e) {
|
|
252
|
-
if (cond === false)
|
|
253
|
-
return e instanceof If ? e : e.nodes;
|
|
254
|
-
if (this.nodes.length)
|
|
255
|
-
return this;
|
|
256
|
-
return new If(not(cond), e instanceof If ? [e] : e.nodes);
|
|
257
|
-
}
|
|
258
|
-
if (cond === false || !this.nodes.length)
|
|
259
|
-
return void 0;
|
|
260
|
-
return this;
|
|
261
|
-
}
|
|
262
|
-
optimizeNames(names, constants) {
|
|
263
|
-
var _a;
|
|
264
|
-
this.else = (_a = this.else) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants);
|
|
265
|
-
if (!(super.optimizeNames(names, constants) || this.else))
|
|
266
|
-
return;
|
|
267
|
-
this.condition = optimizeExpr(this.condition, names, constants);
|
|
268
|
-
return this;
|
|
269
|
-
}
|
|
270
|
-
get names() {
|
|
271
|
-
const names = super.names;
|
|
272
|
-
addExprNames(names, this.condition);
|
|
273
|
-
if (this.else)
|
|
274
|
-
addNames(names, this.else.names);
|
|
275
|
-
return names;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
If.kind = "if";
|
|
279
|
-
class For extends BlockNode {
|
|
280
|
-
}
|
|
281
|
-
For.kind = "for";
|
|
282
|
-
class ForLoop extends For {
|
|
283
|
-
constructor(iteration) {
|
|
284
|
-
super();
|
|
285
|
-
this.iteration = iteration;
|
|
222
|
+
class BlockNode extends ParentNode {
|
|
223
|
+
render(opts) {
|
|
224
|
+
return "{" + opts._n + super.render(opts) + "}" + opts._n;
|
|
225
|
+
}
|
|
286
226
|
}
|
|
287
|
-
|
|
288
|
-
return `for(${this.iteration})` + super.render(opts);
|
|
227
|
+
class Root extends ParentNode {
|
|
289
228
|
}
|
|
290
|
-
|
|
291
|
-
if (!super.optimizeNames(names, constants))
|
|
292
|
-
return;
|
|
293
|
-
this.iteration = optimizeExpr(this.iteration, names, constants);
|
|
294
|
-
return this;
|
|
229
|
+
class Else extends BlockNode {
|
|
295
230
|
}
|
|
296
|
-
|
|
297
|
-
|
|
231
|
+
Else.kind = "else";
|
|
232
|
+
class If extends BlockNode {
|
|
233
|
+
constructor(condition, nodes) {
|
|
234
|
+
super(nodes);
|
|
235
|
+
this.condition = condition;
|
|
236
|
+
}
|
|
237
|
+
render(opts) {
|
|
238
|
+
let code = `if(${this.condition})` + super.render(opts);
|
|
239
|
+
if (this.else)
|
|
240
|
+
code += "else " + this.else.render(opts);
|
|
241
|
+
return code;
|
|
242
|
+
}
|
|
243
|
+
optimizeNodes() {
|
|
244
|
+
super.optimizeNodes();
|
|
245
|
+
const cond = this.condition;
|
|
246
|
+
if (cond === true)
|
|
247
|
+
return this.nodes;
|
|
248
|
+
let e = this.else;
|
|
249
|
+
if (e) {
|
|
250
|
+
const ns = e.optimizeNodes();
|
|
251
|
+
e = this.else = Array.isArray(ns) ? new Else(ns) : ns;
|
|
252
|
+
}
|
|
253
|
+
if (e) {
|
|
254
|
+
if (cond === false)
|
|
255
|
+
return e instanceof If ? e : e.nodes;
|
|
256
|
+
if (this.nodes.length)
|
|
257
|
+
return this;
|
|
258
|
+
return new If(not(cond), e instanceof If ? [e] : e.nodes);
|
|
259
|
+
}
|
|
260
|
+
if (cond === false || !this.nodes.length)
|
|
261
|
+
return void 0;
|
|
262
|
+
return this;
|
|
263
|
+
}
|
|
264
|
+
optimizeNames(names, constants) {
|
|
265
|
+
var _a;
|
|
266
|
+
this.else = (_a = this.else) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants);
|
|
267
|
+
if (!(super.optimizeNames(names, constants) || this.else))
|
|
268
|
+
return;
|
|
269
|
+
this.condition = optimizeExpr(this.condition, names, constants);
|
|
270
|
+
return this;
|
|
271
|
+
}
|
|
272
|
+
get names() {
|
|
273
|
+
const names = super.names;
|
|
274
|
+
addExprNames(names, this.condition);
|
|
275
|
+
if (this.else)
|
|
276
|
+
addNames(names, this.else.names);
|
|
277
|
+
return names;
|
|
278
|
+
}
|
|
298
279
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
constructor(varKind, name, from, to) {
|
|
302
|
-
super();
|
|
303
|
-
this.varKind = varKind;
|
|
304
|
-
this.name = name;
|
|
305
|
-
this.from = from;
|
|
306
|
-
this.to = to;
|
|
307
|
-
}
|
|
308
|
-
render(opts) {
|
|
309
|
-
const varKind = opts.es5 ? scope_1.varKinds.var : this.varKind;
|
|
310
|
-
const { name, from, to } = this;
|
|
311
|
-
return `for(${varKind} ${name}=${from}; ${name}<${to}; ${name}++)` + super.render(opts);
|
|
312
|
-
}
|
|
313
|
-
get names() {
|
|
314
|
-
const names = addExprNames(super.names, this.from);
|
|
315
|
-
return addExprNames(names, this.to);
|
|
280
|
+
If.kind = "if";
|
|
281
|
+
class For extends BlockNode {
|
|
316
282
|
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
get names() {
|
|
336
|
-
return addNames(super.names, this.iterable.names);
|
|
283
|
+
For.kind = "for";
|
|
284
|
+
class ForLoop extends For {
|
|
285
|
+
constructor(iteration) {
|
|
286
|
+
super();
|
|
287
|
+
this.iteration = iteration;
|
|
288
|
+
}
|
|
289
|
+
render(opts) {
|
|
290
|
+
return `for(${this.iteration})` + super.render(opts);
|
|
291
|
+
}
|
|
292
|
+
optimizeNames(names, constants) {
|
|
293
|
+
if (!super.optimizeNames(names, constants))
|
|
294
|
+
return;
|
|
295
|
+
this.iteration = optimizeExpr(this.iteration, names, constants);
|
|
296
|
+
return this;
|
|
297
|
+
}
|
|
298
|
+
get names() {
|
|
299
|
+
return addNames(super.names, this.iteration.names);
|
|
300
|
+
}
|
|
337
301
|
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
302
|
+
class ForRange extends For {
|
|
303
|
+
constructor(varKind, name, from, to) {
|
|
304
|
+
super();
|
|
305
|
+
this.varKind = varKind;
|
|
306
|
+
this.name = name;
|
|
307
|
+
this.from = from;
|
|
308
|
+
this.to = to;
|
|
309
|
+
}
|
|
310
|
+
render(opts) {
|
|
311
|
+
const varKind = opts.es5 ? scope_1.varKinds.var : this.varKind;
|
|
312
|
+
const { name, from, to } = this;
|
|
313
|
+
return `for(${varKind} ${name}=${from}; ${name}<${to}; ${name}++)` + super.render(opts);
|
|
314
|
+
}
|
|
315
|
+
get names() {
|
|
316
|
+
const names = addExprNames(super.names, this.from);
|
|
317
|
+
return addExprNames(names, this.to);
|
|
318
|
+
}
|
|
345
319
|
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
320
|
+
class ForIter extends For {
|
|
321
|
+
constructor(loop, varKind, name, iterable) {
|
|
322
|
+
super();
|
|
323
|
+
this.loop = loop;
|
|
324
|
+
this.varKind = varKind;
|
|
325
|
+
this.name = name;
|
|
326
|
+
this.iterable = iterable;
|
|
327
|
+
}
|
|
328
|
+
render(opts) {
|
|
329
|
+
return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
|
|
330
|
+
}
|
|
331
|
+
optimizeNames(names, constants) {
|
|
332
|
+
if (!super.optimizeNames(names, constants))
|
|
333
|
+
return;
|
|
334
|
+
this.iterable = optimizeExpr(this.iterable, names, constants);
|
|
335
|
+
return this;
|
|
336
|
+
}
|
|
337
|
+
get names() {
|
|
338
|
+
return addNames(super.names, this.iterable.names);
|
|
339
|
+
}
|
|
349
340
|
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
341
|
+
class Func extends BlockNode {
|
|
342
|
+
constructor(name, args, async) {
|
|
343
|
+
super();
|
|
344
|
+
this.name = name;
|
|
345
|
+
this.args = args;
|
|
346
|
+
this.async = async;
|
|
347
|
+
}
|
|
348
|
+
render(opts) {
|
|
349
|
+
const _async = this.async ? "async " : "";
|
|
350
|
+
return `${_async}function ${this.name}(${this.args})` + super.render(opts);
|
|
351
|
+
}
|
|
355
352
|
}
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
if (this.catch)
|
|
362
|
-
code2 += this.catch.render(opts);
|
|
363
|
-
if (this.finally)
|
|
364
|
-
code2 += this.finally.render(opts);
|
|
365
|
-
return code2;
|
|
366
|
-
}
|
|
367
|
-
optimizeNodes() {
|
|
368
|
-
var _a, _b;
|
|
369
|
-
super.optimizeNodes();
|
|
370
|
-
(_a = this.catch) === null || _a === void 0 ? void 0 : _a.optimizeNodes();
|
|
371
|
-
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNodes();
|
|
372
|
-
return this;
|
|
373
|
-
}
|
|
374
|
-
optimizeNames(names, constants) {
|
|
375
|
-
var _a, _b;
|
|
376
|
-
super.optimizeNames(names, constants);
|
|
377
|
-
(_a = this.catch) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants);
|
|
378
|
-
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants);
|
|
379
|
-
return this;
|
|
380
|
-
}
|
|
381
|
-
get names() {
|
|
382
|
-
const names = super.names;
|
|
383
|
-
if (this.catch)
|
|
384
|
-
addNames(names, this.catch.names);
|
|
385
|
-
if (this.finally)
|
|
386
|
-
addNames(names, this.finally.names);
|
|
387
|
-
return names;
|
|
353
|
+
Func.kind = "func";
|
|
354
|
+
class Return extends ParentNode {
|
|
355
|
+
render(opts) {
|
|
356
|
+
return "return " + super.render(opts);
|
|
357
|
+
}
|
|
388
358
|
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
359
|
+
Return.kind = "return";
|
|
360
|
+
class Try extends BlockNode {
|
|
361
|
+
render(opts) {
|
|
362
|
+
let code = "try" + super.render(opts);
|
|
363
|
+
if (this.catch)
|
|
364
|
+
code += this.catch.render(opts);
|
|
365
|
+
if (this.finally)
|
|
366
|
+
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 ? void 0 : _a.optimizeNodes();
|
|
373
|
+
(_b = this.finally) === null || _b === void 0 ? 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 ? void 0 : _a.optimizeNames(names, constants);
|
|
380
|
+
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants);
|
|
381
|
+
return this;
|
|
382
|
+
}
|
|
383
|
+
get names() {
|
|
384
|
+
const names = super.names;
|
|
385
|
+
if (this.catch)
|
|
386
|
+
addNames(names, this.catch.names);
|
|
387
|
+
if (this.finally)
|
|
388
|
+
addNames(names, this.finally.names);
|
|
389
|
+
return names;
|
|
390
|
+
}
|
|
394
391
|
}
|
|
395
|
-
|
|
396
|
-
|
|
392
|
+
class Catch extends BlockNode {
|
|
393
|
+
constructor(error) {
|
|
394
|
+
super();
|
|
395
|
+
this.error = error;
|
|
396
|
+
}
|
|
397
|
+
render(opts) {
|
|
398
|
+
return `catch(${this.error})` + super.render(opts);
|
|
399
|
+
}
|
|
397
400
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
401
|
+
Catch.kind = "catch";
|
|
402
|
+
class Finally extends BlockNode {
|
|
403
|
+
render(opts) {
|
|
404
|
+
return "finally" + super.render(opts);
|
|
405
|
+
}
|
|
403
406
|
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
this.
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
c
|
|
476
|
-
|
|
477
|
-
this
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
407
|
+
Finally.kind = "finally";
|
|
408
|
+
class CodeGen {
|
|
409
|
+
constructor(extScope, opts = {}) {
|
|
410
|
+
this._values = {};
|
|
411
|
+
this._blockStarts = [];
|
|
412
|
+
this._constants = {};
|
|
413
|
+
this.opts = { ...opts, _n: opts.lines ? "\n" : "" };
|
|
414
|
+
this._extScope = extScope;
|
|
415
|
+
this._scope = new scope_1.Scope({ parent: extScope });
|
|
416
|
+
this._nodes = [new Root()];
|
|
417
|
+
}
|
|
418
|
+
toString() {
|
|
419
|
+
return this._root.render(this.opts);
|
|
420
|
+
}
|
|
421
|
+
// returns unique name in the internal scope
|
|
422
|
+
name(prefix) {
|
|
423
|
+
return this._scope.name(prefix);
|
|
424
|
+
}
|
|
425
|
+
// reserves unique name in the external scope
|
|
426
|
+
scopeName(prefix) {
|
|
427
|
+
return this._extScope.name(prefix);
|
|
428
|
+
}
|
|
429
|
+
// reserves unique name in the external scope and assigns value to it
|
|
430
|
+
scopeValue(prefixOrName, value) {
|
|
431
|
+
const name = this._extScope.value(prefixOrName, value);
|
|
432
|
+
const vs = this._values[name.prefix] || (this._values[name.prefix] = /* @__PURE__ */ new Set());
|
|
433
|
+
vs.add(name);
|
|
434
|
+
return name;
|
|
435
|
+
}
|
|
436
|
+
getScopeValue(prefix, keyOrRef) {
|
|
437
|
+
return this._extScope.getValue(prefix, keyOrRef);
|
|
438
|
+
}
|
|
439
|
+
// return code that assigns values in the external scope to the names that are used internally
|
|
440
|
+
// (same names that were returned by gen.scopeName or gen.scopeValue)
|
|
441
|
+
scopeRefs(scopeName) {
|
|
442
|
+
return this._extScope.scopeRefs(scopeName, this._values);
|
|
443
|
+
}
|
|
444
|
+
scopeCode() {
|
|
445
|
+
return this._extScope.scopeCode(this._values);
|
|
446
|
+
}
|
|
447
|
+
_def(varKind, nameOrPrefix, rhs, constant) {
|
|
448
|
+
const name = this._scope.toName(nameOrPrefix);
|
|
449
|
+
if (rhs !== void 0 && constant)
|
|
450
|
+
this._constants[name.str] = rhs;
|
|
451
|
+
this._leafNode(new Def(varKind, name, rhs));
|
|
452
|
+
return name;
|
|
453
|
+
}
|
|
454
|
+
// `const` declaration (`var` in es5 mode)
|
|
455
|
+
const(nameOrPrefix, rhs, _constant) {
|
|
456
|
+
return this._def(scope_1.varKinds.const, nameOrPrefix, rhs, _constant);
|
|
457
|
+
}
|
|
458
|
+
// `let` declaration with optional assignment (`var` in es5 mode)
|
|
459
|
+
let(nameOrPrefix, rhs, _constant) {
|
|
460
|
+
return this._def(scope_1.varKinds.let, nameOrPrefix, rhs, _constant);
|
|
461
|
+
}
|
|
462
|
+
// `var` declaration with optional assignment
|
|
463
|
+
var(nameOrPrefix, rhs, _constant) {
|
|
464
|
+
return this._def(scope_1.varKinds.var, nameOrPrefix, rhs, _constant);
|
|
465
|
+
}
|
|
466
|
+
// assignment code
|
|
467
|
+
assign(lhs, rhs, sideEffects) {
|
|
468
|
+
return this._leafNode(new Assign(lhs, rhs, sideEffects));
|
|
469
|
+
}
|
|
470
|
+
// `+=` code
|
|
471
|
+
add(lhs, rhs) {
|
|
472
|
+
return this._leafNode(new AssignOp(lhs, exports$1.operators.ADD, rhs));
|
|
473
|
+
}
|
|
474
|
+
// appends passed SafeExpr to code or executes Block
|
|
475
|
+
code(c) {
|
|
476
|
+
if (typeof c == "function")
|
|
477
|
+
c();
|
|
478
|
+
else if (c !== code_1.nil)
|
|
479
|
+
this._leafNode(new AnyCode(c));
|
|
480
|
+
return this;
|
|
481
|
+
}
|
|
482
|
+
// returns code for object literal for the passed argument list of key-value pairs
|
|
483
|
+
object(...keyValues) {
|
|
484
|
+
const code = ["{"];
|
|
485
|
+
for (const [key, value] of keyValues) {
|
|
486
|
+
if (code.length > 1)
|
|
487
|
+
code.push(",");
|
|
488
|
+
code.push(key);
|
|
489
|
+
if (key !== value || this.opts.es5) {
|
|
490
|
+
code.push(":");
|
|
491
|
+
(0, code_1.addCodeArg)(code, value);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
code.push("}");
|
|
495
|
+
return new code_1._Code(code);
|
|
496
|
+
}
|
|
497
|
+
// `if` clause (or statement if `thenBody` and, optionally, `elseBody` are passed)
|
|
498
|
+
if(condition, thenBody, elseBody) {
|
|
499
|
+
this._blockNode(new If(condition));
|
|
500
|
+
if (thenBody && elseBody) {
|
|
501
|
+
this.code(thenBody).else().code(elseBody).endIf();
|
|
502
|
+
} else if (thenBody) {
|
|
503
|
+
this.code(thenBody).endIf();
|
|
504
|
+
} else if (elseBody) {
|
|
505
|
+
throw new Error('CodeGen: "else" body without "then" body');
|
|
506
|
+
}
|
|
507
|
+
return this;
|
|
508
|
+
}
|
|
509
|
+
// `else if` clause - invalid without `if` or after `else` clauses
|
|
510
|
+
elseIf(condition) {
|
|
511
|
+
return this._elseNode(new If(condition));
|
|
512
|
+
}
|
|
513
|
+
// `else` clause - only valid after `if` or `else if` clauses
|
|
514
|
+
else() {
|
|
515
|
+
return this._elseNode(new Else());
|
|
516
|
+
}
|
|
517
|
+
// end `if` statement (needed if gen.if was used only with condition)
|
|
518
|
+
endIf() {
|
|
519
|
+
return this._endBlockNode(If, Else);
|
|
520
|
+
}
|
|
521
|
+
_for(node, forBody) {
|
|
522
|
+
this._blockNode(node);
|
|
523
|
+
if (forBody)
|
|
524
|
+
this.code(forBody).endFor();
|
|
525
|
+
return this;
|
|
526
|
+
}
|
|
527
|
+
// a generic `for` clause (or statement if `forBody` is passed)
|
|
528
|
+
for(iteration, forBody) {
|
|
529
|
+
return this._for(new ForLoop(iteration), forBody);
|
|
530
|
+
}
|
|
531
|
+
// `for` statement for a range of values
|
|
532
|
+
forRange(nameOrPrefix, from, to, forBody, varKind = this.opts.es5 ? scope_1.varKinds.var : scope_1.varKinds.let) {
|
|
533
|
+
const name = this._scope.toName(nameOrPrefix);
|
|
534
|
+
return this._for(new ForRange(varKind, name, from, to), () => forBody(name));
|
|
535
|
+
}
|
|
536
|
+
// `for-of` statement (in es5 mode replace with a normal for loop)
|
|
537
|
+
forOf(nameOrPrefix, iterable, forBody, varKind = scope_1.varKinds.const) {
|
|
538
|
+
const name = this._scope.toName(nameOrPrefix);
|
|
539
|
+
if (this.opts.es5) {
|
|
540
|
+
const arr = iterable instanceof code_1.Name ? iterable : this.var("_arr", iterable);
|
|
541
|
+
return this.forRange("_i", 0, (0, code_1._)`${arr}.length`, (i) => {
|
|
542
|
+
this.var(name, (0, code_1._)`${arr}[${i}]`);
|
|
543
|
+
forBody(name);
|
|
544
|
+
});
|
|
490
545
|
}
|
|
546
|
+
return this._for(new ForIter("of", varKind, name, iterable), () => forBody(name));
|
|
491
547
|
}
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
this.
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
return
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
this._currNode
|
|
586
|
-
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
this.code(body).endBlock(nodeCount);
|
|
603
|
-
return this;
|
|
604
|
-
}
|
|
605
|
-
// end the current self-balancing block
|
|
606
|
-
endBlock(nodeCount) {
|
|
607
|
-
const len = this._blockStarts.pop();
|
|
608
|
-
if (len === void 0)
|
|
609
|
-
throw new Error("CodeGen: not in self-balancing block");
|
|
610
|
-
const toClose = this._nodes.length - len;
|
|
611
|
-
if (toClose < 0 || nodeCount !== void 0 && toClose !== nodeCount) {
|
|
612
|
-
throw new Error(`CodeGen: wrong number of nodes: ${toClose} vs ${nodeCount} expected`);
|
|
613
|
-
}
|
|
614
|
-
this._nodes.length = len;
|
|
615
|
-
return this;
|
|
616
|
-
}
|
|
617
|
-
// `function` heading (or definition if funcBody is passed)
|
|
618
|
-
func(name, args = code_1.nil, async, funcBody) {
|
|
619
|
-
this._blockNode(new Func(name, args, async));
|
|
620
|
-
if (funcBody)
|
|
621
|
-
this.code(funcBody).endFunc();
|
|
622
|
-
return this;
|
|
623
|
-
}
|
|
624
|
-
// end function definition
|
|
625
|
-
endFunc() {
|
|
626
|
-
return this._endBlockNode(Func);
|
|
627
|
-
}
|
|
628
|
-
optimize(n = 1) {
|
|
629
|
-
while (n-- > 0) {
|
|
630
|
-
this._root.optimizeNodes();
|
|
631
|
-
this._root.optimizeNames(this._root.names, this._constants);
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
_leafNode(node) {
|
|
635
|
-
this._currNode.nodes.push(node);
|
|
636
|
-
return this;
|
|
637
|
-
}
|
|
638
|
-
_blockNode(node) {
|
|
639
|
-
this._currNode.nodes.push(node);
|
|
640
|
-
this._nodes.push(node);
|
|
641
|
-
}
|
|
642
|
-
_endBlockNode(N1, N2) {
|
|
643
|
-
const n = this._currNode;
|
|
644
|
-
if (n instanceof N1 || N2 && n instanceof N2) {
|
|
645
|
-
this._nodes.pop();
|
|
548
|
+
// `for-in` statement.
|
|
549
|
+
// With option `ownProperties` replaced with a `for-of` loop for object keys
|
|
550
|
+
forIn(nameOrPrefix, obj, forBody, varKind = this.opts.es5 ? scope_1.varKinds.var : scope_1.varKinds.const) {
|
|
551
|
+
if (this.opts.ownProperties) {
|
|
552
|
+
return this.forOf(nameOrPrefix, (0, code_1._)`Object.keys(${obj})`, forBody);
|
|
553
|
+
}
|
|
554
|
+
const name = this._scope.toName(nameOrPrefix);
|
|
555
|
+
return this._for(new ForIter("in", varKind, name, obj), () => forBody(name));
|
|
556
|
+
}
|
|
557
|
+
// end `for` loop
|
|
558
|
+
endFor() {
|
|
559
|
+
return this._endBlockNode(For);
|
|
560
|
+
}
|
|
561
|
+
// `label` statement
|
|
562
|
+
label(label) {
|
|
563
|
+
return this._leafNode(new Label(label));
|
|
564
|
+
}
|
|
565
|
+
// `break` statement
|
|
566
|
+
break(label) {
|
|
567
|
+
return this._leafNode(new Break(label));
|
|
568
|
+
}
|
|
569
|
+
// `return` statement
|
|
570
|
+
return(value) {
|
|
571
|
+
const node = new Return();
|
|
572
|
+
this._blockNode(node);
|
|
573
|
+
this.code(value);
|
|
574
|
+
if (node.nodes.length !== 1)
|
|
575
|
+
throw new Error('CodeGen: "return" should have one node');
|
|
576
|
+
return this._endBlockNode(Return);
|
|
577
|
+
}
|
|
578
|
+
// `try` statement
|
|
579
|
+
try(tryBody, catchCode, finallyCode) {
|
|
580
|
+
if (!catchCode && !finallyCode)
|
|
581
|
+
throw new Error('CodeGen: "try" without "catch" and "finally"');
|
|
582
|
+
const node = new Try();
|
|
583
|
+
this._blockNode(node);
|
|
584
|
+
this.code(tryBody);
|
|
585
|
+
if (catchCode) {
|
|
586
|
+
const error = this.name("e");
|
|
587
|
+
this._currNode = node.catch = new Catch(error);
|
|
588
|
+
catchCode(error);
|
|
589
|
+
}
|
|
590
|
+
if (finallyCode) {
|
|
591
|
+
this._currNode = node.finally = new Finally();
|
|
592
|
+
this.code(finallyCode);
|
|
593
|
+
}
|
|
594
|
+
return this._endBlockNode(Catch, Finally);
|
|
595
|
+
}
|
|
596
|
+
// `throw` statement
|
|
597
|
+
throw(error) {
|
|
598
|
+
return this._leafNode(new Throw(error));
|
|
599
|
+
}
|
|
600
|
+
// start self-balancing block
|
|
601
|
+
block(body, nodeCount) {
|
|
602
|
+
this._blockStarts.push(this._nodes.length);
|
|
603
|
+
if (body)
|
|
604
|
+
this.code(body).endBlock(nodeCount);
|
|
605
|
+
return this;
|
|
606
|
+
}
|
|
607
|
+
// end the current self-balancing block
|
|
608
|
+
endBlock(nodeCount) {
|
|
609
|
+
const len = this._blockStarts.pop();
|
|
610
|
+
if (len === void 0)
|
|
611
|
+
throw new Error("CodeGen: not in self-balancing block");
|
|
612
|
+
const toClose = this._nodes.length - len;
|
|
613
|
+
if (toClose < 0 || nodeCount !== void 0 && toClose !== nodeCount) {
|
|
614
|
+
throw new Error(`CodeGen: wrong number of nodes: ${toClose} vs ${nodeCount} expected`);
|
|
615
|
+
}
|
|
616
|
+
this._nodes.length = len;
|
|
617
|
+
return this;
|
|
618
|
+
}
|
|
619
|
+
// `function` heading (or definition if funcBody is passed)
|
|
620
|
+
func(name, args = code_1.nil, async, funcBody) {
|
|
621
|
+
this._blockNode(new Func(name, args, async));
|
|
622
|
+
if (funcBody)
|
|
623
|
+
this.code(funcBody).endFunc();
|
|
624
|
+
return this;
|
|
625
|
+
}
|
|
626
|
+
// end function definition
|
|
627
|
+
endFunc() {
|
|
628
|
+
return this._endBlockNode(Func);
|
|
629
|
+
}
|
|
630
|
+
optimize(n = 1) {
|
|
631
|
+
while (n-- > 0) {
|
|
632
|
+
this._root.optimizeNodes();
|
|
633
|
+
this._root.optimizeNames(this._root.names, this._constants);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
_leafNode(node) {
|
|
637
|
+
this._currNode.nodes.push(node);
|
|
638
|
+
return this;
|
|
639
|
+
}
|
|
640
|
+
_blockNode(node) {
|
|
641
|
+
this._currNode.nodes.push(node);
|
|
642
|
+
this._nodes.push(node);
|
|
643
|
+
}
|
|
644
|
+
_endBlockNode(N1, N2) {
|
|
645
|
+
const n = this._currNode;
|
|
646
|
+
if (n instanceof N1 || N2 && n instanceof N2) {
|
|
647
|
+
this._nodes.pop();
|
|
648
|
+
return this;
|
|
649
|
+
}
|
|
650
|
+
throw new Error(`CodeGen: not in block "${N2 ? `${N1.kind}/${N2.kind}` : N1.kind}"`);
|
|
651
|
+
}
|
|
652
|
+
_elseNode(node) {
|
|
653
|
+
const n = this._currNode;
|
|
654
|
+
if (!(n instanceof If)) {
|
|
655
|
+
throw new Error('CodeGen: "else" without "if"');
|
|
656
|
+
}
|
|
657
|
+
this._currNode = n.else = node;
|
|
646
658
|
return this;
|
|
647
659
|
}
|
|
648
|
-
|
|
660
|
+
get _root() {
|
|
661
|
+
return this._nodes[0];
|
|
662
|
+
}
|
|
663
|
+
get _currNode() {
|
|
664
|
+
const ns = this._nodes;
|
|
665
|
+
return ns[ns.length - 1];
|
|
666
|
+
}
|
|
667
|
+
set _currNode(node) {
|
|
668
|
+
const ns = this._nodes;
|
|
669
|
+
ns[ns.length - 1] = node;
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
exports$1.CodeGen = CodeGen;
|
|
673
|
+
function addNames(names, from) {
|
|
674
|
+
for (const n in from)
|
|
675
|
+
names[n] = (names[n] || 0) + (from[n] || 0);
|
|
676
|
+
return names;
|
|
649
677
|
}
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
678
|
+
function addExprNames(names, from) {
|
|
679
|
+
return from instanceof code_1._CodeOrName ? addNames(names, from.names) : names;
|
|
680
|
+
}
|
|
681
|
+
function optimizeExpr(expr, names, constants) {
|
|
682
|
+
if (expr instanceof code_1.Name)
|
|
683
|
+
return replaceName(expr);
|
|
684
|
+
if (!canOptimize(expr))
|
|
685
|
+
return expr;
|
|
686
|
+
return new code_1._Code(expr._items.reduce((items, c) => {
|
|
687
|
+
if (c instanceof code_1.Name)
|
|
688
|
+
c = replaceName(c);
|
|
689
|
+
if (c instanceof code_1._Code)
|
|
690
|
+
items.push(...c._items);
|
|
691
|
+
else
|
|
692
|
+
items.push(c);
|
|
693
|
+
return items;
|
|
694
|
+
}, []));
|
|
695
|
+
function replaceName(n) {
|
|
696
|
+
const c = constants[n.str];
|
|
697
|
+
if (c === void 0 || names[n.str] !== 1)
|
|
698
|
+
return n;
|
|
699
|
+
delete names[n.str];
|
|
700
|
+
return c;
|
|
701
|
+
}
|
|
702
|
+
function canOptimize(e) {
|
|
703
|
+
return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants[c.str] !== void 0);
|
|
654
704
|
}
|
|
655
|
-
this._currNode = n.else = node;
|
|
656
|
-
return this;
|
|
657
705
|
}
|
|
658
|
-
|
|
659
|
-
|
|
706
|
+
function subtractNames(names, from) {
|
|
707
|
+
for (const n in from)
|
|
708
|
+
names[n] = (names[n] || 0) - (from[n] || 0);
|
|
660
709
|
}
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
return ns[ns.length - 1];
|
|
710
|
+
function not(x) {
|
|
711
|
+
return typeof x == "boolean" || typeof x == "number" || x === null ? !x : (0, code_1._)`!${par(x)}`;
|
|
664
712
|
}
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
713
|
+
exports$1.not = not;
|
|
714
|
+
const andCode = mappend(exports$1.operators.AND);
|
|
715
|
+
function and(...args) {
|
|
716
|
+
return args.reduce(andCode);
|
|
668
717
|
}
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
names[n] = (names[n] || 0) + (from[n] || 0);
|
|
674
|
-
return names;
|
|
675
|
-
}
|
|
676
|
-
function addExprNames(names, from) {
|
|
677
|
-
return from instanceof code_1._CodeOrName ? addNames(names, from.names) : names;
|
|
678
|
-
}
|
|
679
|
-
function optimizeExpr(expr, names, constants) {
|
|
680
|
-
if (expr instanceof code_1.Name)
|
|
681
|
-
return replaceName(expr);
|
|
682
|
-
if (!canOptimize(expr))
|
|
683
|
-
return expr;
|
|
684
|
-
return new code_1._Code(expr._items.reduce((items, c) => {
|
|
685
|
-
if (c instanceof code_1.Name)
|
|
686
|
-
c = replaceName(c);
|
|
687
|
-
if (c instanceof code_1._Code)
|
|
688
|
-
items.push(...c._items);
|
|
689
|
-
else
|
|
690
|
-
items.push(c);
|
|
691
|
-
return items;
|
|
692
|
-
}, []));
|
|
693
|
-
function replaceName(n) {
|
|
694
|
-
const c = constants[n.str];
|
|
695
|
-
if (c === void 0 || names[n.str] !== 1)
|
|
696
|
-
return n;
|
|
697
|
-
delete names[n.str];
|
|
698
|
-
return c;
|
|
699
|
-
}
|
|
700
|
-
function canOptimize(e) {
|
|
701
|
-
return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants[c.str] !== void 0);
|
|
718
|
+
exports$1.and = and;
|
|
719
|
+
const orCode = mappend(exports$1.operators.OR);
|
|
720
|
+
function or(...args) {
|
|
721
|
+
return args.reduce(orCode);
|
|
702
722
|
}
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
exports$1.and = and;
|
|
717
|
-
const orCode = mappend(exports$1.operators.OR);
|
|
718
|
-
function or(...args) {
|
|
719
|
-
return args.reduce(orCode);
|
|
720
|
-
}
|
|
721
|
-
exports$1.or = or;
|
|
722
|
-
function mappend(op) {
|
|
723
|
-
return (x, y) => x === code_1.nil ? y : y === code_1.nil ? x : (0, code_1._)`${par(x)} ${op} ${par(y)}`;
|
|
724
|
-
}
|
|
725
|
-
function par(x) {
|
|
726
|
-
return x instanceof code_1.Name ? x : (0, code_1._)`(${x})`;
|
|
727
|
-
}
|
|
728
|
-
})(codegen);
|
|
723
|
+
exports$1.or = or;
|
|
724
|
+
function mappend(op) {
|
|
725
|
+
return (x, y) => x === code_1.nil ? y : y === code_1.nil ? x : (0, code_1._)`${par(x)} ${op} ${par(y)}`;
|
|
726
|
+
}
|
|
727
|
+
function par(x) {
|
|
728
|
+
return x instanceof code_1.Name ? x : (0, code_1._)`(${x})`;
|
|
729
|
+
}
|
|
730
|
+
})(codegen);
|
|
731
|
+
return codegen;
|
|
732
|
+
}
|
|
733
|
+
export {
|
|
734
|
+
requireCodegen as __require
|
|
735
|
+
};
|
|
729
736
|
//# sourceMappingURL=index.js.map
|