@cdklabs/cdk-ssm-documents 0.0.70 → 0.0.72
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/.jsii +34 -34
- package/lib/construct/synth-utils.js +1 -1
- package/lib/document/automation-document.js +1 -1
- package/lib/document/command-document.js +1 -1
- package/lib/document/document-builder.js +2 -2
- package/lib/document/ssm-document.js +1 -1
- package/lib/domain/aws-service.js +1 -1
- package/lib/domain/choice.js +1 -1
- package/lib/domain/data-type.js +1 -1
- package/lib/domain/enum/install-action.js +2 -2
- package/lib/domain/enum/install-uninstall-repair.js +2 -2
- package/lib/domain/enum/installation-type.js +2 -2
- package/lib/domain/enum/package-name.js +2 -2
- package/lib/domain/input.js +1 -1
- package/lib/domain/operation.js +1 -1
- package/lib/domain/platform.js +1 -1
- package/lib/domain/precondition.js +1 -1
- package/lib/incident-response/incident-response.js +3 -3
- package/lib/interface/approve-hook.js +2 -2
- package/lib/interface/auth-method.js +3 -3
- package/lib/interface/aws-invoker.js +2 -2
- package/lib/interface/downloadable-content.js +8 -8
- package/lib/interface/environment.js +3 -3
- package/lib/interface/execute-automation-hook/api-execute-automation-hook.js +1 -1
- package/lib/interface/observer.js +1 -1
- package/lib/interface/on-failure.js +6 -6
- package/lib/interface/pause-hook.js +2 -2
- package/lib/interface/run-command-hook/api-run-command-hook.js +1 -1
- package/lib/interface/run-document-location.js +2 -2
- package/lib/interface/sleep-hook.js +2 -2
- package/lib/interface/step-ref.js +1 -1
- package/lib/interface/variables/boolean-variable.js +2 -2
- package/lib/interface/variables/map-list-variable.js +2 -2
- package/lib/interface/variables/number-variable.js +2 -2
- package/lib/interface/variables/secure-string-variable.js +4 -4
- package/lib/interface/variables/string-list-variable.js +2 -2
- package/lib/interface/variables/string-map-variable.js +2 -2
- package/lib/interface/variables/string-variable.js +4 -4
- package/lib/interface/variables/variable.js +2 -2
- package/lib/interface/webhook.js +1 -1
- package/lib/parent-steps/automation/approve-step.js +1 -1
- package/lib/parent-steps/automation/assert-aws-resource-step.js +1 -1
- package/lib/parent-steps/automation/aws-api-step.js +1 -1
- package/lib/parent-steps/automation/branch-step.js +1 -1
- package/lib/parent-steps/automation/change-instance-state-step.js +3 -3
- package/lib/parent-steps/automation/copy-image-step.js +1 -1
- package/lib/parent-steps/automation/create-image-step.js +1 -1
- package/lib/parent-steps/automation/create-stack-step.js +3 -3
- package/lib/parent-steps/automation/create-tags-step.js +3 -3
- package/lib/parent-steps/automation/delete-image-step.js +1 -1
- package/lib/parent-steps/automation/delete-stack-step.js +1 -1
- package/lib/parent-steps/automation/execute-automation-step.js +1 -1
- package/lib/parent-steps/automation/execute-script-step.js +5 -5
- package/lib/parent-steps/automation/execute-state-machine-step.js +1 -1
- package/lib/parent-steps/automation/invoke-lambda-function-step.js +1 -1
- package/lib/parent-steps/automation/invoke-webhook-step.js +1 -1
- package/lib/parent-steps/automation/pause-step.js +1 -1
- package/lib/parent-steps/automation/run-command-step.js +3 -3
- package/lib/parent-steps/automation/run-instance-step.js +1 -1
- package/lib/parent-steps/automation/sleep-step.js +1 -1
- package/lib/parent-steps/automation/update-variable.js +1 -1
- package/lib/parent-steps/automation/wait-for-resource-step.js +1 -1
- package/lib/parent-steps/automation-step.js +1 -1
- package/lib/parent-steps/command/applications-step.js +1 -1
- package/lib/parent-steps/command/configure-docker-step.js +1 -1
- package/lib/parent-steps/command/configure-package-step.js +1 -1
- package/lib/parent-steps/command/domain-join-step.js +1 -1
- package/lib/parent-steps/command/download-content-step.js +1 -1
- package/lib/parent-steps/command/ps-module-step.js +1 -1
- package/lib/parent-steps/command/run-docker-action-step.js +1 -1
- package/lib/parent-steps/command/run-document-step.js +1 -1
- package/lib/parent-steps/command/run-powershell-script-step.js +1 -1
- package/lib/parent-steps/command/run-shell-script-step.js +1 -1
- package/lib/parent-steps/command/software-inventory-step.js +1 -1
- package/lib/parent-steps/command/update-agent-step.js +1 -1
- package/lib/parent-steps/command/update-ssm-agent-step.js +1 -1
- package/lib/parent-steps/command-step.js +1 -1
- package/lib/parent-steps/step.js +1 -1
- package/lib/patterns/automation/composite-step.js +2 -2
- package/lib/patterns/automation/reboot-instance-and-wait.js +1 -1
- package/lib/patterns/automation/string-step.js +1 -1
- package/lib/patterns/document/string-document.js +1 -1
- package/lib/patterns/document/timed-document.js +1 -1
- package/lib/samples/hello-world.js +1 -1
- package/lib/simulation/automation/approve-simulation.js +1 -1
- package/lib/simulation/automation/assert-aws-resource-simulation.js +4 -5
- package/lib/simulation/automation/automation-simulation-base.js +1 -1
- package/lib/simulation/automation/aws-api-simulation.js +1 -1
- package/lib/simulation/automation/branch-simulation.js +1 -1
- package/lib/simulation/automation/change-instance-state-simulation.js +1 -1
- package/lib/simulation/automation/copy-image-simulation.js +1 -1
- package/lib/simulation/automation/create-image-simulation.js +1 -1
- package/lib/simulation/automation/create-stack-simulation.js +1 -1
- package/lib/simulation/automation/create-tags-simulation.js +1 -1
- package/lib/simulation/automation/delete-image-simulation.js +1 -1
- package/lib/simulation/automation/delete-stack-simulation.js +1 -1
- package/lib/simulation/automation/execute-script-simulation.js +1 -1
- package/lib/simulation/automation/execute-state-machine-simulation.js +1 -1
- package/lib/simulation/automation/invoke-lambda-function-simulation.js +1 -1
- package/lib/simulation/automation/invoke-webhook-simulation.js +1 -1
- package/lib/simulation/automation/pause-simulation.js +1 -1
- package/lib/simulation/automation/run-command-simulation.js +1 -1
- package/lib/simulation/automation/run-instance-simulation.js +1 -1
- package/lib/simulation/automation/sleep-simulation.js +1 -1
- package/lib/simulation/automation/update-variable-simulation.js +1 -1
- package/lib/simulation/automation/wait-for-resource-simulation.js +1 -1
- package/lib/simulation/automation-step-simulation.js +4 -5
- package/lib/simulation/command/command-simulation-base.js +1 -1
- package/lib/simulation/command/ps-module-simulation.js +1 -1
- package/lib/simulation/command/run-powershell-script-simulation.js +1 -1
- package/lib/simulation/command/run-shell-script-simulation.js +1 -1
- package/lib/simulation/command-step-simulation.js +1 -1
- package/lib/simulation/document/automation-simulation.js +1 -1
- package/lib/simulation/document/command-simulation.js +1 -1
- package/lib/simulation/simulation.js +1 -1
- package/node_modules/@aws-sdk/checksums/package.json +3 -3
- package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-cloudformation/dist-types/runtimeConfig.browser.d.ts +2 -0
- package/node_modules/@aws-sdk/client-cloudformation/dist-types/runtimeConfig.d.ts +2 -0
- package/node_modules/@aws-sdk/client-cloudformation/dist-types/runtimeConfig.native.d.ts +2 -0
- package/node_modules/@aws-sdk/client-cloudformation/dist-types/ts3.4/runtimeConfig.browser.d.ts +2 -0
- package/node_modules/@aws-sdk/client-cloudformation/dist-types/ts3.4/runtimeConfig.d.ts +2 -0
- package/node_modules/@aws-sdk/client-cloudformation/dist-types/ts3.4/runtimeConfig.native.d.ts +2 -0
- package/node_modules/@aws-sdk/client-cloudformation/package.json +6 -6
- package/node_modules/@aws-sdk/client-cloudwatch/dist-cjs/index.js +2 -2
- package/node_modules/@aws-sdk/client-cloudwatch/dist-es/schemas/schemas_0.js +1 -1
- package/node_modules/@aws-sdk/client-cloudwatch/dist-types/commands/DescribeAlarmsCommand.d.ts +1 -1
- package/node_modules/@aws-sdk/client-cloudwatch/dist-types/commands/PutLogAlarmCommand.d.ts +1 -1
- package/node_modules/@aws-sdk/client-cloudwatch/dist-types/models/models_0.d.ts +1 -1
- package/node_modules/@aws-sdk/client-cloudwatch/dist-types/runtimeConfig.browser.d.ts +2 -0
- package/node_modules/@aws-sdk/client-cloudwatch/dist-types/runtimeConfig.d.ts +2 -0
- package/node_modules/@aws-sdk/client-cloudwatch/dist-types/runtimeConfig.native.d.ts +2 -0
- package/node_modules/@aws-sdk/client-cloudwatch/dist-types/ts3.4/models/models_0.d.ts +1 -1
- package/node_modules/@aws-sdk/client-cloudwatch/dist-types/ts3.4/runtimeConfig.browser.d.ts +2 -0
- package/node_modules/@aws-sdk/client-cloudwatch/dist-types/ts3.4/runtimeConfig.d.ts +2 -0
- package/node_modules/@aws-sdk/client-cloudwatch/dist-types/ts3.4/runtimeConfig.native.d.ts +2 -0
- package/node_modules/@aws-sdk/client-cloudwatch/package.json +8 -8
- package/node_modules/@aws-sdk/client-ec2/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-ec2/dist-types/runtimeConfig.browser.d.ts +2 -0
- package/node_modules/@aws-sdk/client-ec2/dist-types/runtimeConfig.d.ts +2 -0
- package/node_modules/@aws-sdk/client-ec2/dist-types/runtimeConfig.native.d.ts +2 -0
- package/node_modules/@aws-sdk/client-ec2/dist-types/ts3.4/runtimeConfig.browser.d.ts +2 -0
- package/node_modules/@aws-sdk/client-ec2/dist-types/ts3.4/runtimeConfig.d.ts +2 -0
- package/node_modules/@aws-sdk/client-ec2/dist-types/ts3.4/runtimeConfig.native.d.ts +2 -0
- package/node_modules/@aws-sdk/client-ec2/package.json +8 -8
- package/node_modules/@aws-sdk/client-iam/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-iam/dist-types/runtimeConfig.browser.d.ts +2 -0
- package/node_modules/@aws-sdk/client-iam/dist-types/runtimeConfig.d.ts +2 -0
- package/node_modules/@aws-sdk/client-iam/dist-types/runtimeConfig.native.d.ts +2 -0
- package/node_modules/@aws-sdk/client-iam/dist-types/ts3.4/runtimeConfig.browser.d.ts +2 -0
- package/node_modules/@aws-sdk/client-iam/dist-types/ts3.4/runtimeConfig.d.ts +2 -0
- package/node_modules/@aws-sdk/client-iam/dist-types/ts3.4/runtimeConfig.native.d.ts +2 -0
- package/node_modules/@aws-sdk/client-iam/package.json +7 -7
- package/node_modules/@aws-sdk/client-lambda/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-lambda/dist-types/runtimeConfig.browser.d.ts +2 -0
- package/node_modules/@aws-sdk/client-lambda/dist-types/runtimeConfig.d.ts +2 -0
- package/node_modules/@aws-sdk/client-lambda/dist-types/runtimeConfig.native.d.ts +2 -0
- package/node_modules/@aws-sdk/client-lambda/dist-types/ts3.4/runtimeConfig.browser.d.ts +2 -0
- package/node_modules/@aws-sdk/client-lambda/dist-types/ts3.4/runtimeConfig.d.ts +2 -0
- package/node_modules/@aws-sdk/client-lambda/dist-types/ts3.4/runtimeConfig.native.d.ts +2 -0
- package/node_modules/@aws-sdk/client-lambda/package.json +7 -7
- package/node_modules/@aws-sdk/client-s3/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-s3/dist-types/runtimeConfig.browser.d.ts +2 -0
- package/node_modules/@aws-sdk/client-s3/dist-types/runtimeConfig.d.ts +2 -0
- package/node_modules/@aws-sdk/client-s3/dist-types/runtimeConfig.native.d.ts +2 -0
- package/node_modules/@aws-sdk/client-s3/dist-types/ts3.4/runtimeConfig.browser.d.ts +2 -0
- package/node_modules/@aws-sdk/client-s3/dist-types/ts3.4/runtimeConfig.d.ts +2 -0
- package/node_modules/@aws-sdk/client-s3/dist-types/ts3.4/runtimeConfig.native.d.ts +2 -0
- package/node_modules/@aws-sdk/client-s3/package.json +11 -11
- package/node_modules/@aws-sdk/client-sns/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-sns/dist-types/runtimeConfig.browser.d.ts +2 -0
- package/node_modules/@aws-sdk/client-sns/dist-types/runtimeConfig.d.ts +2 -0
- package/node_modules/@aws-sdk/client-sns/dist-types/runtimeConfig.native.d.ts +2 -0
- package/node_modules/@aws-sdk/client-sns/dist-types/ts3.4/runtimeConfig.browser.d.ts +2 -0
- package/node_modules/@aws-sdk/client-sns/dist-types/ts3.4/runtimeConfig.d.ts +2 -0
- package/node_modules/@aws-sdk/client-sns/dist-types/ts3.4/runtimeConfig.native.d.ts +2 -0
- package/node_modules/@aws-sdk/client-sns/package.json +6 -6
- package/node_modules/@aws-sdk/client-sqs/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-sqs/dist-types/runtimeConfig.browser.d.ts +2 -0
- package/node_modules/@aws-sdk/client-sqs/dist-types/runtimeConfig.d.ts +2 -0
- package/node_modules/@aws-sdk/client-sqs/dist-types/runtimeConfig.native.d.ts +2 -0
- package/node_modules/@aws-sdk/client-sqs/dist-types/ts3.4/runtimeConfig.browser.d.ts +2 -0
- package/node_modules/@aws-sdk/client-sqs/dist-types/ts3.4/runtimeConfig.d.ts +2 -0
- package/node_modules/@aws-sdk/client-sqs/dist-types/ts3.4/runtimeConfig.native.d.ts +2 -0
- package/node_modules/@aws-sdk/client-sqs/package.json +8 -8
- package/node_modules/@aws-sdk/client-ssm/dist-cjs/index.js +8 -7
- package/node_modules/@aws-sdk/client-ssm/dist-es/schemas/schemas_0.js +7 -6
- package/node_modules/@aws-sdk/client-ssm/dist-types/commands/DescribeAutomationExecutionsCommand.d.ts +1 -0
- package/node_modules/@aws-sdk/client-ssm/dist-types/commands/DescribeAutomationStepExecutionsCommand.d.ts +1 -0
- package/node_modules/@aws-sdk/client-ssm/dist-types/commands/GetAutomationExecutionCommand.d.ts +2 -0
- package/node_modules/@aws-sdk/client-ssm/dist-types/models/models_0.d.ts +16 -1
- package/node_modules/@aws-sdk/client-ssm/dist-types/runtimeConfig.browser.d.ts +2 -0
- package/node_modules/@aws-sdk/client-ssm/dist-types/runtimeConfig.d.ts +2 -0
- package/node_modules/@aws-sdk/client-ssm/dist-types/runtimeConfig.native.d.ts +2 -0
- package/node_modules/@aws-sdk/client-ssm/dist-types/ts3.4/models/models_0.d.ts +3 -0
- package/node_modules/@aws-sdk/client-ssm/dist-types/ts3.4/runtimeConfig.browser.d.ts +2 -0
- package/node_modules/@aws-sdk/client-ssm/dist-types/ts3.4/runtimeConfig.d.ts +2 -0
- package/node_modules/@aws-sdk/client-ssm/dist-types/ts3.4/runtimeConfig.native.d.ts +2 -0
- package/node_modules/@aws-sdk/client-ssm/package.json +6 -6
- package/node_modules/@aws-sdk/core/dist-cjs/submodules/httpAuthSchemes/index.js +66 -28
- package/node_modules/@aws-sdk/core/dist-cjs/submodules/protocols/index.js +133 -15
- package/node_modules/@aws-sdk/core/dist-es/submodules/httpAuthSchemes/aws_sdk/AwsSdkSigV4ASigner.js +7 -2
- package/node_modules/@aws-sdk/core/dist-es/submodules/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.js +28 -14
- package/node_modules/@aws-sdk/core/dist-es/submodules/httpAuthSchemes/aws_sdk/clock-skew-defaults.browser.js +1 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/httpAuthSchemes/aws_sdk/clock-skew-defaults.js +3 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/httpAuthSchemes/aws_sdk/clock-skew-node-config.js +8 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/httpAuthSchemes/aws_sdk/index.js +1 -1
- package/node_modules/@aws-sdk/core/dist-es/submodules/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4Config.js +3 -3
- package/node_modules/@aws-sdk/core/dist-es/submodules/httpAuthSchemes/index.browser.js +9 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/httpAuthSchemes/index.js +5 -1
- package/node_modules/@aws-sdk/core/dist-es/submodules/httpAuthSchemes/utils/getDateHeader.js +1 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/httpAuthSchemes/utils/getUpdatedSystemClockOffset.js +12 -6
- package/node_modules/@aws-sdk/core/dist-es/submodules/httpAuthSchemes/utils/index.js +2 -1
- package/node_modules/@aws-sdk/core/dist-es/submodules/httpAuthSchemes/utils/isClockSkewed.js +1 -1
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/JsonShapeDeserializer.js +10 -1
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/JsonShapeSerializer.js +10 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/detectBufferParsing.js +18 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/experimental/BufferJsonShapeDeserializer.js +180 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/experimental/ByteJsonShapeSerializer.js +483 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/jsonReviver.js +22 -3
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/needsReviver.js +41 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/parseJsonBody.js +33 -13
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/writeKey.js +3 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/xml/XmlShapeDeserializer.js +4 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.d.ts +2 -1
- package/node_modules/@aws-sdk/core/dist-types/submodules/httpAuthSchemes/aws_sdk/clock-skew-defaults.browser.d.ts +6 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/httpAuthSchemes/aws_sdk/clock-skew-defaults.d.ts +7 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/httpAuthSchemes/aws_sdk/clock-skew-node-config.d.ts +13 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/httpAuthSchemes/aws_sdk/index.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/submodules/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4Config.d.ts +22 -6
- package/node_modules/@aws-sdk/core/dist-types/submodules/httpAuthSchemes/index.browser.d.ts +11 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/httpAuthSchemes/index.d.ts +7 -1
- package/node_modules/@aws-sdk/core/dist-types/submodules/httpAuthSchemes/utils/getDateHeader.d.ts +4 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/httpAuthSchemes/utils/getUpdatedSystemClockOffset.d.ts +22 -6
- package/node_modules/@aws-sdk/core/dist-types/submodules/httpAuthSchemes/utils/index.d.ts +2 -1
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/detectBufferParsing.d.ts +1 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/experimental/BufferJsonShapeDeserializer.d.ts +29 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/experimental/ByteJsonShapeSerializer.d.ts +57 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/needsReviver.d.ts +11 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/parseJsonBody.d.ts +7 -2
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/writeKey.d.ts +4 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/api-extractor-type-index.d.ts +7 -4
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/index.d.ts +21 -61
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/account-id-endpoint/AccountIdEndpointModeConfigResolver.d.ts +27 -13
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/account-id-endpoint/AccountIdEndpointModeConstants.d.ts +16 -4
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/account-id-endpoint/NodeAccountIdEndpointModeConfigOptions.d.ts +14 -5
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/account-id-endpoint/index.d.ts +5 -16
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/emitWarningIfUnsupportedVersion.d.ts +11 -4
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/index.browser.d.ts +47 -107
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/index.d.ts +39 -112
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/index.native.d.ts +48 -107
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/longPollMiddleware.d.ts +14 -13
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/middleware-host-header/hostHeaderMiddleware.d.ts +35 -25
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/middleware-logger/loggerMiddleware.d.ts +4 -14
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/middleware-recursion-detection/configuration.d.ts +6 -2
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/middleware-recursion-detection/getRecursionDetectionPlugin.browser.d.ts +5 -2
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/middleware-recursion-detection/getRecursionDetectionPlugin.d.ts +5 -2
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/middleware-recursion-detection/recursionDetectionMiddleware.browser.d.ts +6 -2
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/middleware-recursion-detection/recursionDetectionMiddleware.d.ts +10 -2
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/middleware-recursion-detection/recursionDetectionMiddleware.native.d.ts +6 -2
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/middleware-user-agent/check-features.d.ts +20 -16
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/middleware-user-agent/configurations.d.ts +44 -21
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/middleware-user-agent/constants.d.ts +7 -7
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/middleware-user-agent/encode-features.d.ts +5 -2
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/middleware-user-agent/user-agent-middleware.d.ts +18 -18
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/region-config-resolver/awsRegionConfig.d.ts +11 -8
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/region-config-resolver/extensions.d.ts +16 -14
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/region-config-resolver/stsRegionDefaultResolver.browser.d.ts +4 -1
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/region-config-resolver/stsRegionDefaultResolver.d.ts +14 -7
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/region-config-resolver/stsRegionDefaultResolver.native.d.ts +4 -1
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/setCredentialFeature.d.ts +7 -6
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/setFeature.d.ts +12 -6
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/setTokenFeature.d.ts +7 -6
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-endpoints/aws.d.ts +2 -2
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-endpoints/lib/aws/isVirtualHostableS3Bucket.d.ts +5 -4
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-endpoints/lib/aws/parseArn.d.ts +7 -2
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-endpoints/lib/aws/partition.d.ts +38 -28
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-endpoints/lib/aws/partitions.d.ts +638 -647
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-endpoints/lib/isIpAddress.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-endpoints/resolveDefaultAwsRegionalEndpointsConfig.d.ts +56 -29
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-endpoints/resolveEndpoint.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-endpoints/types/EndpointError.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-endpoints/types/EndpointRuleObject.d.ts +1 -6
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-endpoints/types/ErrorRuleObject.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-endpoints/types/RuleSetObject.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-endpoints/types/TreeRuleObject.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-endpoints/types/shared.d.ts +1 -12
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-user-agent-browser/configurations.d.ts +7 -4
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-user-agent-browser/createUserAgentStringParsingProvider.d.ts +14 -7
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-user-agent-browser/defaultUserAgent.browser.d.ts +2 -7
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-user-agent-browser/defaultUserAgent.d.ts +27 -18
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-user-agent-browser/defaultUserAgent.native.d.ts +18 -13
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-user-agent-node/crt-availability.d.ts +8 -3
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-user-agent-node/defaultUserAgent.d.ts +28 -17
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-user-agent-node/getRuntimeUserAgentPair.d.ts +6 -2
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-user-agent-node/is-crt-available.d.ts +5 -2
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-user-agent-node/nodeAppIdConfigOptions.d.ts +13 -4
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/AwsSdkSigV4ASigner.d.ts +10 -9
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.d.ts +44 -37
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/NODE_AUTH_SCHEME_PREFERENCE_OPTIONS.d.ts +5 -2
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/clock-skew-defaults.browser.d.ts +6 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/clock-skew-defaults.d.ts +7 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/clock-skew-node-config.d.ts +13 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/index.d.ts +7 -23
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4AConfig.d.ts +38 -13
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4Config.d.ts +133 -56
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/index.browser.d.ts +11 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/index.d.ts +9 -24
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/utils/getArrayForCommaSeparatedString.d.ts +8 -1
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/utils/getBearerTokenEnvKey.d.ts +6 -1
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/utils/getDateHeader.d.ts +8 -1
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/utils/getSkewCorrectedDate.d.ts +8 -1
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/utils/getUpdatedSystemClockOffset.d.ts +26 -4
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/utils/index.d.ts +4 -3
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/httpAuthSchemes/utils/isClockSkewed.d.ts +9 -1
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/ConfigurableSerdeContext.d.ts +8 -5
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/ProtocolLib.d.ts +74 -40
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/UnionSerde.d.ts +24 -9
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/cbor/AwsSmithyRpcV2CborProtocol.d.ts +25 -36
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/coercing-serializers.d.ts +18 -3
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/common.d.ts +2 -5
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/index.d.ts +22 -27
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsJson1_0Protocol.d.ts +22 -21
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsJson1_1Protocol.d.ts +22 -21
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsJsonRpcProtocol.d.ts +29 -49
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsRestJsonProtocol.d.ts +36 -49
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/JsonCodec.d.ts +19 -13
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/JsonShapeDeserializer.d.ts +13 -13
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/JsonShapeSerializer.d.ts +28 -18
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/awsExpectUnion.d.ts +7 -1
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/detectBufferParsing.d.ts +1 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/experimental/BufferJsonShapeDeserializer.d.ts +29 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/experimental/ByteJsonShapeSerializer.d.ts +57 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/jsonReplacer.d.ts +21 -7
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/jsonReviver.d.ts +15 -7
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/needsReviver.d.ts +11 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/parseJsonBody.d.ts +22 -9
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/query/AwsEc2QueryProtocol.d.ts +27 -18
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/query/AwsQueryProtocol.d.ts +49 -57
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/query/QuerySerializerSettings.d.ts +13 -7
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/query/QueryShapeSerializer.d.ts +16 -21
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/writeKey.d.ts +4 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/xml/AwsRestXmlProtocol.d.ts +31 -47
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/xml/XmlCodec.d.ts +14 -17
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/xml/XmlShapeDeserializer.d.ts +20 -15
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/xml/XmlShapeSerializer.d.ts +21 -21
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/xml/parseXmlBody.d.ts +13 -4
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/xml/simpleFormatXml.d.ts +6 -1
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/util/index.d.ts +3 -3
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/util/util-arn-parser/arn.d.ts +32 -14
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/util/util-format-url/format-url.d.ts +2 -4
- package/node_modules/@aws-sdk/core/package.json +11 -6
- package/node_modules/@aws-sdk/credential-provider-env/package.json +3 -3
- package/node_modules/@aws-sdk/credential-provider-http/package.json +5 -5
- package/node_modules/@aws-sdk/credential-provider-ini/package.json +11 -11
- package/node_modules/@aws-sdk/credential-provider-login/package.json +4 -4
- package/node_modules/@aws-sdk/credential-provider-node/package.json +9 -9
- package/node_modules/@aws-sdk/credential-provider-process/package.json +3 -3
- package/node_modules/@aws-sdk/credential-provider-sso/package.json +5 -5
- package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +4 -4
- package/node_modules/@aws-sdk/middleware-sdk-ec2/package.json +4 -4
- package/node_modules/@aws-sdk/middleware-sdk-s3/package.json +4 -4
- package/node_modules/@aws-sdk/middleware-sdk-sqs/package.json +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/cognito-identity/runtimeConfig.browser.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/cognito-identity/runtimeConfig.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/cognito-identity/runtimeConfig.native.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/signin/runtimeConfig.browser.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/signin/runtimeConfig.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/signin/runtimeConfig.native.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso/runtimeConfig.browser.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso/runtimeConfig.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso/runtimeConfig.native.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso-oidc/runtimeConfig.browser.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso-oidc/runtimeConfig.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso-oidc/runtimeConfig.native.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/runtimeConfig.browser.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/runtimeConfig.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/runtimeConfig.native.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/cognito-identity/runtimeConfig.browser.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/cognito-identity/runtimeConfig.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/cognito-identity/runtimeConfig.native.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/signin/runtimeConfig.browser.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/signin/runtimeConfig.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/signin/runtimeConfig.native.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso/runtimeConfig.browser.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso/runtimeConfig.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso/runtimeConfig.native.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso-oidc/runtimeConfig.browser.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso-oidc/runtimeConfig.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso-oidc/runtimeConfig.native.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/runtimeConfig.browser.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/runtimeConfig.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/runtimeConfig.native.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/package.json +6 -6
- package/node_modules/@aws-sdk/signature-v4-multi-region/package.json +2 -2
- package/node_modules/@aws-sdk/token-providers/package.json +4 -4
- package/node_modules/@aws-sdk/xml-builder/dist-cjs/index.js +14 -4
- package/node_modules/@aws-sdk/xml-builder/dist-es/xml-parser.js +14 -4
- package/node_modules/@aws-sdk/xml-builder/package.json +1 -1
- package/node_modules/@jsep-plugin/assignment/LICENSE +20 -0
- package/node_modules/@jsep-plugin/assignment/README.md +37 -0
- package/node_modules/@jsep-plugin/assignment/dist/cjs/index.cjs.js +95 -0
- package/node_modules/@jsep-plugin/assignment/dist/cjs/index.cjs.js.map +1 -0
- package/node_modules/@jsep-plugin/assignment/dist/cjs/index.cjs.min.js +2 -0
- package/node_modules/@jsep-plugin/assignment/dist/cjs/index.cjs.min.js.map +1 -0
- package/node_modules/@jsep-plugin/assignment/dist/cjs/package.json +3 -0
- package/node_modules/@jsep-plugin/assignment/dist/iife/index.iife.js +98 -0
- package/node_modules/@jsep-plugin/assignment/dist/iife/index.iife.js.map +1 -0
- package/node_modules/@jsep-plugin/assignment/dist/iife/index.iife.min.js +2 -0
- package/node_modules/@jsep-plugin/assignment/dist/iife/index.iife.min.js.map +1 -0
- package/node_modules/@jsep-plugin/assignment/dist/index.js +92 -0
- package/node_modules/@jsep-plugin/assignment/dist/index.min.js +2 -0
- package/node_modules/@jsep-plugin/assignment/dist/index.min.js.map +1 -0
- package/node_modules/@jsep-plugin/assignment/package.json +39 -0
- package/node_modules/@jsep-plugin/assignment/types/tsd.d.ts +39 -0
- package/node_modules/@jsep-plugin/regex/LICENSE +20 -0
- package/node_modules/@jsep-plugin/regex/README.md +36 -0
- package/node_modules/@jsep-plugin/regex/dist/cjs/index.cjs.js +66 -0
- package/node_modules/@jsep-plugin/regex/dist/cjs/index.cjs.js.map +1 -0
- package/node_modules/@jsep-plugin/regex/dist/cjs/index.cjs.min.js +2 -0
- package/node_modules/@jsep-plugin/regex/dist/cjs/index.cjs.min.js.map +1 -0
- package/node_modules/@jsep-plugin/regex/dist/cjs/package.json +3 -0
- package/node_modules/@jsep-plugin/regex/dist/iife/index.iife.js +69 -0
- package/node_modules/@jsep-plugin/regex/dist/iife/index.iife.js.map +1 -0
- package/node_modules/@jsep-plugin/regex/dist/iife/index.iife.min.js +2 -0
- package/node_modules/@jsep-plugin/regex/dist/iife/index.iife.min.js.map +1 -0
- package/node_modules/@jsep-plugin/regex/dist/index.js +63 -0
- package/node_modules/@jsep-plugin/regex/dist/index.min.js +2 -0
- package/node_modules/@jsep-plugin/regex/dist/index.min.js.map +1 -0
- package/node_modules/@jsep-plugin/regex/package.json +39 -0
- package/node_modules/@jsep-plugin/regex/types/tsd.d.ts +7 -0
- package/node_modules/@smithy/core/dist-cjs/submodules/cbor/index.js +1 -1
- package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.browser.js +34 -11
- package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.js +34 -11
- package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +1 -0
- package/node_modules/@smithy/core/dist-cjs/submodules/retry/index.browser.js +1 -0
- package/node_modules/@smithy/core/dist-cjs/submodules/retry/index.js +1 -0
- package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.browser.js +2 -2
- package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.js +2 -2
- package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.native.js +2 -2
- package/node_modules/@smithy/core/dist-es/submodules/cbor/cbor-decode.js +1 -1
- package/node_modules/@smithy/core/dist-es/submodules/event-streams/EventStreamSerde.js +34 -11
- package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpProtocol.js +1 -0
- package/node_modules/@smithy/core/dist-es/submodules/retry/service-error-classification/constants.js +1 -0
- package/node_modules/@smithy/core/dist-es/submodules/serde/value/NumericValue.js +2 -2
- package/node_modules/@smithy/core/dist-types/submodules/event-streams/EventStreamSerde.d.ts +10 -2
- package/node_modules/@smithy/core/dist-types/submodules/retry/service-error-classification/constants.d.ts +1 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/event-streams/EventStreamSerde.d.ts +10 -2
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/retry/service-error-classification/constants.d.ts +1 -0
- package/node_modules/@smithy/core/package.json +1 -1
- package/node_modules/@smithy/credential-provider-imds/package.json +2 -2
- package/node_modules/@smithy/fetch-http-handler/package.json +2 -2
- package/node_modules/@smithy/middleware-compression/package.json +2 -2
- package/node_modules/@smithy/node-http-handler/package.json +2 -2
- package/node_modules/@smithy/signature-v4/package.json +2 -2
- package/node_modules/jsep/LICENSE +20 -0
- package/node_modules/jsep/README.md +208 -0
- package/node_modules/jsep/dist/cjs/jsep.cjs.js +1129 -0
- package/node_modules/jsep/dist/cjs/jsep.cjs.js.map +1 -0
- package/node_modules/jsep/dist/cjs/jsep.cjs.min.js +2 -0
- package/node_modules/jsep/dist/cjs/jsep.cjs.min.js.map +1 -0
- package/node_modules/jsep/dist/cjs/package.json +3 -0
- package/node_modules/jsep/dist/iife/jsep.iife.js +1132 -0
- package/node_modules/jsep/dist/iife/jsep.iife.js.map +1 -0
- package/node_modules/jsep/dist/iife/jsep.iife.min.js +2 -0
- package/node_modules/jsep/dist/iife/jsep.iife.min.js.map +1 -0
- package/node_modules/jsep/dist/jsep.js +1126 -0
- package/node_modules/jsep/dist/jsep.min.js +2 -0
- package/node_modules/jsep/dist/jsep.min.js.map +1 -0
- package/node_modules/jsep/package.json +153 -0
- package/node_modules/jsep/typings/tsd.d.ts +180 -0
- package/node_modules/jsonpath-plus/.claude/settings.local.json +9 -0
- package/node_modules/jsonpath-plus/CHANGES.md +453 -0
- package/node_modules/jsonpath-plus/LICENSE +22 -0
- package/node_modules/jsonpath-plus/README.md +412 -0
- package/node_modules/jsonpath-plus/SECURITY.md +38 -0
- package/node_modules/jsonpath-plus/bin/jsonpath-cli.js +36 -0
- package/node_modules/jsonpath-plus/dist/index-browser-esm.js +2164 -0
- package/node_modules/jsonpath-plus/dist/index-browser-esm.min.js +2 -0
- package/node_modules/jsonpath-plus/dist/index-browser-esm.min.js.map +1 -0
- package/node_modules/jsonpath-plus/dist/index-browser-umd.cjs +2172 -0
- package/node_modules/jsonpath-plus/dist/index-browser-umd.min.cjs +2 -0
- package/node_modules/jsonpath-plus/dist/index-browser-umd.min.cjs.map +1 -0
- package/node_modules/jsonpath-plus/dist/index-node-cjs.cjs +2076 -0
- package/node_modules/jsonpath-plus/dist/index-node-esm.js +2074 -0
- package/node_modules/jsonpath-plus/package.json +141 -0
- package/node_modules/jsonpath-plus/pnpm-workspace.yaml +2 -0
- package/node_modules/jsonpath-plus/src/Safe-Script.js +208 -0
- package/node_modules/jsonpath-plus/src/jsonpath-browser.js +102 -0
- package/node_modules/jsonpath-plus/src/jsonpath-node.js +8 -0
- package/node_modules/jsonpath-plus/src/jsonpath.d.ts +226 -0
- package/node_modules/jsonpath-plus/src/jsonpath.js +784 -0
- package/package.json +12 -12
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/experimental/SinglePassJsonShapeSerializer.js +0 -135
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/experimental/SinglePassJsonShapeSerializer.d.ts +0 -27
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/experimental/SinglePassJsonShapeSerializer.d.ts +0 -17
- package/node_modules/escodegen/LICENSE.BSD +0 -21
- package/node_modules/escodegen/README.md +0 -84
- package/node_modules/escodegen/bin/escodegen.js +0 -77
- package/node_modules/escodegen/bin/esgenerate.js +0 -64
- package/node_modules/escodegen/escodegen.js +0 -2667
- package/node_modules/escodegen/package.json +0 -63
- package/node_modules/esprima/LICENSE.BSD +0 -21
- package/node_modules/esprima/README.md +0 -46
- package/node_modules/esprima/bin/esparse.js +0 -139
- package/node_modules/esprima/bin/esvalidate.js +0 -236
- package/node_modules/esprima/dist/esprima.js +0 -6709
- package/node_modules/esprima/package.json +0 -112
- package/node_modules/estraverse/.jshintrc +0 -16
- package/node_modules/estraverse/LICENSE.BSD +0 -19
- package/node_modules/estraverse/README.md +0 -153
- package/node_modules/estraverse/estraverse.js +0 -805
- package/node_modules/estraverse/gulpfile.js +0 -70
- package/node_modules/estraverse/package.json +0 -40
- package/node_modules/esutils/LICENSE.BSD +0 -19
- package/node_modules/esutils/README.md +0 -174
- package/node_modules/esutils/lib/ast.js +0 -144
- package/node_modules/esutils/lib/code.js +0 -135
- package/node_modules/esutils/lib/keyword.js +0 -165
- package/node_modules/esutils/lib/utils.js +0 -33
- package/node_modules/esutils/package.json +0 -44
- package/node_modules/jsonpath/.jscsrc +0 -60
- package/node_modules/jsonpath/.jshintrc +0 -9
- package/node_modules/jsonpath/.travis.yml +0 -3
- package/node_modules/jsonpath/Dockerfile +0 -1
- package/node_modules/jsonpath/Gruntfile.js +0 -83
- package/node_modules/jsonpath/LICENSE +0 -7
- package/node_modules/jsonpath/README.md +0 -216
- package/node_modules/jsonpath/bin/generate_parser.js +0 -8
- package/node_modules/jsonpath/fig.yml +0 -5
- package/node_modules/jsonpath/generated/parser.js +0 -721
- package/node_modules/jsonpath/include/action.js +0 -4
- package/node_modules/jsonpath/include/module.js +0 -34
- package/node_modules/jsonpath/index.js +0 -1
- package/node_modules/jsonpath/jsonpath.js +0 -7093
- package/node_modules/jsonpath/jsonpath.min.js +0 -4
- package/node_modules/jsonpath/lib/aesprim.js +0 -18
- package/node_modules/jsonpath/lib/dict.js +0 -6
- package/node_modules/jsonpath/lib/grammar.js +0 -106
- package/node_modules/jsonpath/lib/handlers.js +0 -409
- package/node_modules/jsonpath/lib/index.js +0 -304
- package/node_modules/jsonpath/lib/parser.js +0 -21
- package/node_modules/jsonpath/lib/slice.js +0 -41
- package/node_modules/jsonpath/node_modules/esprima/LICENSE.BSD +0 -19
- package/node_modules/jsonpath/node_modules/esprima/README.md +0 -24
- package/node_modules/jsonpath/node_modules/esprima/bin/esparse.js +0 -127
- package/node_modules/jsonpath/node_modules/esprima/bin/esvalidate.js +0 -199
- package/node_modules/jsonpath/node_modules/esprima/esprima.js +0 -3772
- package/node_modules/jsonpath/node_modules/esprima/package.json +0 -83
- package/node_modules/jsonpath/node_modules/esprima/test/compat.js +0 -241
- package/node_modules/jsonpath/node_modules/esprima/test/reflect.js +0 -422
- package/node_modules/jsonpath/node_modules/esprima/test/run.js +0 -67
- package/node_modules/jsonpath/node_modules/esprima/test/runner.js +0 -495
- package/node_modules/jsonpath/node_modules/esprima/test/test.js +0 -25593
- package/node_modules/jsonpath/package.json +0 -45
- package/node_modules/jsonpath/test/data/store.json +0 -31
- package/node_modules/jsonpath/test/lessons.js +0 -38
- package/node_modules/jsonpath/test/parse.js +0 -164
- package/node_modules/jsonpath/test/query.js +0 -359
- package/node_modules/jsonpath/test/security.js +0 -238
- package/node_modules/jsonpath/test/slice.js +0 -57
- package/node_modules/jsonpath/test/stringify.js +0 -54
- package/node_modules/jsonpath/test/sugar.js +0 -72
- package/node_modules/source-map/LICENSE +0 -28
- package/node_modules/source-map/README.md +0 -742
- package/node_modules/source-map/dist/source-map.debug.js +0 -3234
- package/node_modules/source-map/dist/source-map.js +0 -3233
- package/node_modules/source-map/dist/source-map.min.js +0 -2
- package/node_modules/source-map/dist/source-map.min.js.map +0 -1
- package/node_modules/source-map/lib/array-set.js +0 -121
- package/node_modules/source-map/lib/base64-vlq.js +0 -140
- package/node_modules/source-map/lib/base64.js +0 -67
- package/node_modules/source-map/lib/binary-search.js +0 -111
- package/node_modules/source-map/lib/mapping-list.js +0 -79
- package/node_modules/source-map/lib/quick-sort.js +0 -114
- package/node_modules/source-map/lib/source-map-consumer.js +0 -1145
- package/node_modules/source-map/lib/source-map-generator.js +0 -425
- package/node_modules/source-map/lib/source-node.js +0 -413
- package/node_modules/source-map/lib/util.js +0 -488
- package/node_modules/source-map/package.json +0 -73
- package/node_modules/source-map/source-map.d.ts +0 -98
- package/node_modules/source-map/source-map.js +0 -8
- package/node_modules/static-eval/.travis.yml +0 -18
- package/node_modules/static-eval/CHANGELOG.md +0 -21
- package/node_modules/static-eval/LICENSE +0 -20
- package/node_modules/static-eval/example/eval.js +0 -7
- package/node_modules/static-eval/example/vars.js +0 -11
- package/node_modules/static-eval/index.js +0 -209
- package/node_modules/static-eval/package.json +0 -54
- package/node_modules/static-eval/readme.markdown +0 -87
- package/node_modules/static-eval/security.md +0 -15
- package/node_modules/static-eval/test/eval.js +0 -177
- package/node_modules/static-eval/test/prop.js +0 -16
- package/node_modules/static-eval/test/template-strings.js +0 -33
- package/node_modules/underscore/LICENSE +0 -22
- package/node_modules/underscore/README.md +0 -34
- package/node_modules/underscore/amd/_baseCreate.js +0 -21
- package/node_modules/underscore/amd/_baseIteratee.js +0 -15
- package/node_modules/underscore/amd/_cb.js +0 -12
- package/node_modules/underscore/amd/_chainResult.js +0 -10
- package/node_modules/underscore/amd/_collectNonEnumProps.js +0 -42
- package/node_modules/underscore/amd/_createAssigner.js +0 -24
- package/node_modules/underscore/amd/_createEscaper.js +0 -21
- package/node_modules/underscore/amd/_createIndexFinder.js +0 -30
- package/node_modules/underscore/amd/_createPredicateIndexFinder.js +0 -18
- package/node_modules/underscore/amd/_createReduce.js +0 -30
- package/node_modules/underscore/amd/_createSizePropertyCheck.js +0 -13
- package/node_modules/underscore/amd/_deepGet.js +0 -15
- package/node_modules/underscore/amd/_escapeMap.js +0 -15
- package/node_modules/underscore/amd/_executeBound.js +0 -16
- package/node_modules/underscore/amd/_flatten.js +0 -32
- package/node_modules/underscore/amd/_getByteLength.js +0 -8
- package/node_modules/underscore/amd/_getLength.js +0 -8
- package/node_modules/underscore/amd/_group.js +0 -18
- package/node_modules/underscore/amd/_has.js +0 -10
- package/node_modules/underscore/amd/_hasObjectTag.js +0 -7
- package/node_modules/underscore/amd/_isArrayLike.js +0 -11
- package/node_modules/underscore/amd/_isBufferLike.js +0 -9
- package/node_modules/underscore/amd/_keyInObj.js +0 -11
- package/node_modules/underscore/amd/_methodFingerprint.js +0 -44
- package/node_modules/underscore/amd/_optimizeCb.js +0 -27
- package/node_modules/underscore/amd/_set.js +0 -21
- package/node_modules/underscore/amd/_setup.js +0 -70
- package/node_modules/underscore/amd/_shallowProperty.js +0 -12
- package/node_modules/underscore/amd/_stringTagBug.js +0 -16
- package/node_modules/underscore/amd/_tagTester.js +0 -13
- package/node_modules/underscore/amd/_toBufferView.js +0 -15
- package/node_modules/underscore/amd/_toPath.js +0 -11
- package/node_modules/underscore/amd/_unescapeMap.js +0 -8
- package/node_modules/underscore/amd/after.js +0 -14
- package/node_modules/underscore/amd/allKeys.js +0 -15
- package/node_modules/underscore/amd/before.js +0 -18
- package/node_modules/underscore/amd/bind.js +0 -15
- package/node_modules/underscore/amd/bindAll.js +0 -19
- package/node_modules/underscore/amd/chain.js +0 -12
- package/node_modules/underscore/amd/chunk.js +0 -17
- package/node_modules/underscore/amd/clone.js +0 -11
- package/node_modules/underscore/amd/compact.js +0 -10
- package/node_modules/underscore/amd/compose.js +0 -18
- package/node_modules/underscore/amd/constant.js +0 -12
- package/node_modules/underscore/amd/contains.js +0 -12
- package/node_modules/underscore/amd/countBy.js +0 -12
- package/node_modules/underscore/amd/create.js +0 -14
- package/node_modules/underscore/amd/debounce.js +0 -43
- package/node_modules/underscore/amd/defaults.js +0 -8
- package/node_modules/underscore/amd/defer.js +0 -9
- package/node_modules/underscore/amd/delay.js +0 -13
- package/node_modules/underscore/amd/difference.js +0 -14
- package/node_modules/underscore/amd/each.js +0 -25
- package/node_modules/underscore/amd/escape.js +0 -8
- package/node_modules/underscore/amd/every.js +0 -17
- package/node_modules/underscore/amd/extend.js +0 -8
- package/node_modules/underscore/amd/extendOwn.js +0 -10
- package/node_modules/underscore/amd/filter.js +0 -15
- package/node_modules/underscore/amd/find.js +0 -12
- package/node_modules/underscore/amd/findIndex.js +0 -8
- package/node_modules/underscore/amd/findKey.js +0 -15
- package/node_modules/underscore/amd/findLastIndex.js +0 -8
- package/node_modules/underscore/amd/findWhere.js +0 -11
- package/node_modules/underscore/amd/first.js +0 -13
- package/node_modules/underscore/amd/flatten.js +0 -11
- package/node_modules/underscore/amd/functions.js +0 -14
- package/node_modules/underscore/amd/get.js +0 -14
- package/node_modules/underscore/amd/groupBy.js +0 -11
- package/node_modules/underscore/amd/has.js +0 -19
- package/node_modules/underscore/amd/identity.js +0 -10
- package/node_modules/underscore/amd/index-default.js +0 -12
- package/node_modules/underscore/amd/index.js +0 -154
- package/node_modules/underscore/amd/indexBy.js +0 -11
- package/node_modules/underscore/amd/indexOf.js +0 -11
- package/node_modules/underscore/amd/initial.js +0 -12
- package/node_modules/underscore/amd/intersection.js +0 -22
- package/node_modules/underscore/amd/invert.js +0 -15
- package/node_modules/underscore/amd/invoke.js +0 -28
- package/node_modules/underscore/amd/isArguments.js +0 -19
- package/node_modules/underscore/amd/isArray.js +0 -9
- package/node_modules/underscore/amd/isArrayBuffer.js +0 -7
- package/node_modules/underscore/amd/isBoolean.js +0 -10
- package/node_modules/underscore/amd/isDataView.js +0 -15
- package/node_modules/underscore/amd/isDate.js +0 -7
- package/node_modules/underscore/amd/isElement.js +0 -10
- package/node_modules/underscore/amd/isEmpty.js +0 -18
- package/node_modules/underscore/amd/isEqual.js +0 -133
- package/node_modules/underscore/amd/isError.js +0 -7
- package/node_modules/underscore/amd/isFinite.js +0 -10
- package/node_modules/underscore/amd/isFunction.js +0 -18
- package/node_modules/underscore/amd/isMap.js +0 -7
- package/node_modules/underscore/amd/isMatch.js +0 -17
- package/node_modules/underscore/amd/isNaN.js +0 -10
- package/node_modules/underscore/amd/isNull.js +0 -10
- package/node_modules/underscore/amd/isNumber.js +0 -7
- package/node_modules/underscore/amd/isObject.js +0 -11
- package/node_modules/underscore/amd/isRegExp.js +0 -7
- package/node_modules/underscore/amd/isSet.js +0 -7
- package/node_modules/underscore/amd/isString.js +0 -7
- package/node_modules/underscore/amd/isSymbol.js +0 -7
- package/node_modules/underscore/amd/isTypedArray.js +0 -16
- package/node_modules/underscore/amd/isUndefined.js +0 -10
- package/node_modules/underscore/amd/isWeakMap.js +0 -7
- package/node_modules/underscore/amd/isWeakSet.js +0 -7
- package/node_modules/underscore/amd/iteratee.js +0 -13
- package/node_modules/underscore/amd/keys.js +0 -17
- package/node_modules/underscore/amd/last.js +0 -13
- package/node_modules/underscore/amd/lastIndexOf.js +0 -9
- package/node_modules/underscore/amd/map.js +0 -18
- package/node_modules/underscore/amd/mapObject.js +0 -19
- package/node_modules/underscore/amd/matcher.js +0 -14
- package/node_modules/underscore/amd/max.js +0 -30
- package/node_modules/underscore/amd/memoize.js +0 -17
- package/node_modules/underscore/amd/min.js +0 -30
- package/node_modules/underscore/amd/mixin.js +0 -18
- package/node_modules/underscore/amd/negate.js +0 -12
- package/node_modules/underscore/amd/noop.js +0 -8
- package/node_modules/underscore/amd/now.js +0 -10
- package/node_modules/underscore/amd/object.js +0 -20
- package/node_modules/underscore/amd/omit.js +0 -20
- package/node_modules/underscore/amd/once.js +0 -9
- package/node_modules/underscore/amd/pairs.js +0 -17
- package/node_modules/underscore/amd/partial.js +0 -25
- package/node_modules/underscore/amd/partition.js +0 -11
- package/node_modules/underscore/amd/pick.js +0 -25
- package/node_modules/underscore/amd/pluck.js +0 -10
- package/node_modules/underscore/amd/property.js +0 -14
- package/node_modules/underscore/amd/propertyOf.js +0 -13
- package/node_modules/underscore/amd/random.js +0 -14
- package/node_modules/underscore/amd/range.js +0 -27
- package/node_modules/underscore/amd/reduce.js +0 -9
- package/node_modules/underscore/amd/reduceRight.js +0 -8
- package/node_modules/underscore/amd/reject.js +0 -10
- package/node_modules/underscore/amd/rest.js +0 -12
- package/node_modules/underscore/amd/restArguments.js +0 -33
- package/node_modules/underscore/amd/result.js +0 -25
- package/node_modules/underscore/amd/sample.js +0 -27
- package/node_modules/underscore/amd/set.js +0 -15
- package/node_modules/underscore/amd/shuffle.js +0 -10
- package/node_modules/underscore/amd/size.js +0 -11
- package/node_modules/underscore/amd/some.js +0 -17
- package/node_modules/underscore/amd/sortBy.js +0 -26
- package/node_modules/underscore/amd/sortedIndex.js +0 -18
- package/node_modules/underscore/amd/tap.js +0 -13
- package/node_modules/underscore/amd/template.js +0 -103
- package/node_modules/underscore/amd/templateSettings.js +0 -13
- package/node_modules/underscore/amd/throttle.js +0 -51
- package/node_modules/underscore/amd/times.js +0 -13
- package/node_modules/underscore/amd/toArray.js +0 -18
- package/node_modules/underscore/amd/toPath.js +0 -12
- package/node_modules/underscore/amd/underscore-array-methods.js +0 -30
- package/node_modules/underscore/amd/underscore.js +0 -29
- package/node_modules/underscore/amd/unescape.js +0 -8
- package/node_modules/underscore/amd/union.js +0 -11
- package/node_modules/underscore/amd/uniq.js +0 -37
- package/node_modules/underscore/amd/uniqueId.js +0 -13
- package/node_modules/underscore/amd/unzip.js +0 -17
- package/node_modules/underscore/amd/values.js +0 -16
- package/node_modules/underscore/amd/where.js +0 -11
- package/node_modules/underscore/amd/without.js +0 -10
- package/node_modules/underscore/amd/wrap.js +0 -12
- package/node_modules/underscore/amd/zip.js +0 -9
- package/node_modules/underscore/cjs/_baseCreate.js +0 -20
- package/node_modules/underscore/cjs/_baseIteratee.js +0 -19
- package/node_modules/underscore/cjs/_cb.js +0 -12
- package/node_modules/underscore/cjs/_chainResult.js +0 -8
- package/node_modules/underscore/cjs/_collectNonEnumProps.js +0 -42
- package/node_modules/underscore/cjs/_createAssigner.js +0 -20
- package/node_modules/underscore/cjs/_createEscaper.js +0 -19
- package/node_modules/underscore/cjs/_createIndexFinder.js +0 -30
- package/node_modules/underscore/cjs/_createPredicateIndexFinder.js +0 -17
- package/node_modules/underscore/cjs/_createReduce.js +0 -30
- package/node_modules/underscore/cjs/_createSizePropertyCheck.js +0 -11
- package/node_modules/underscore/cjs/_deepGet.js +0 -11
- package/node_modules/underscore/cjs/_escapeMap.js +0 -11
- package/node_modules/underscore/cjs/_executeBound.js +0 -15
- package/node_modules/underscore/cjs/_flatten.js +0 -33
- package/node_modules/underscore/cjs/_getByteLength.js +0 -6
- package/node_modules/underscore/cjs/_getLength.js +0 -6
- package/node_modules/underscore/cjs/_group.js +0 -17
- package/node_modules/underscore/cjs/_has.js +0 -8
- package/node_modules/underscore/cjs/_hasObjectTag.js +0 -5
- package/node_modules/underscore/cjs/_isArrayLike.js +0 -10
- package/node_modules/underscore/cjs/_isBufferLike.js +0 -8
- package/node_modules/underscore/cjs/_keyInObj.js +0 -7
- package/node_modules/underscore/cjs/_methodFingerprint.js +0 -44
- package/node_modules/underscore/cjs/_optimizeCb.js +0 -23
- package/node_modules/underscore/cjs/_set.js +0 -21
- package/node_modules/underscore/cjs/_setup.js +0 -66
- package/node_modules/underscore/cjs/_shallowProperty.js +0 -8
- package/node_modules/underscore/cjs/_stringTagBug.js +0 -15
- package/node_modules/underscore/cjs/_tagTester.js +0 -11
- package/node_modules/underscore/cjs/_toBufferView.js +0 -13
- package/node_modules/underscore/cjs/_toPath.js +0 -10
- package/node_modules/underscore/cjs/_unescapeMap.js +0 -7
- package/node_modules/underscore/cjs/after.js +0 -10
- package/node_modules/underscore/cjs/allKeys.js +0 -15
- package/node_modules/underscore/cjs/before.js +0 -14
- package/node_modules/underscore/cjs/bind.js +0 -15
- package/node_modules/underscore/cjs/bindAll.js +0 -19
- package/node_modules/underscore/cjs/chain.js +0 -10
- package/node_modules/underscore/cjs/chunk.js +0 -15
- package/node_modules/underscore/cjs/clone.js +0 -11
- package/node_modules/underscore/cjs/compact.js +0 -8
- package/node_modules/underscore/cjs/compose.js +0 -14
- package/node_modules/underscore/cjs/constant.js +0 -8
- package/node_modules/underscore/cjs/contains.js +0 -12
- package/node_modules/underscore/cjs/countBy.js +0 -11
- package/node_modules/underscore/cjs/create.js +0 -13
- package/node_modules/underscore/cjs/debounce.js +0 -42
- package/node_modules/underscore/cjs/defaults.js +0 -7
- package/node_modules/underscore/cjs/defer.js +0 -9
- package/node_modules/underscore/cjs/delay.js +0 -11
- package/node_modules/underscore/cjs/difference.js +0 -15
- package/node_modules/underscore/cjs/each.js +0 -25
- package/node_modules/underscore/cjs/escape.js +0 -7
- package/node_modules/underscore/cjs/every.js +0 -17
- package/node_modules/underscore/cjs/extend.js +0 -7
- package/node_modules/underscore/cjs/extendOwn.js +0 -9
- package/node_modules/underscore/cjs/filter.js +0 -14
- package/node_modules/underscore/cjs/find.js +0 -12
- package/node_modules/underscore/cjs/findIndex.js +0 -6
- package/node_modules/underscore/cjs/findKey.js +0 -14
- package/node_modules/underscore/cjs/findLastIndex.js +0 -6
- package/node_modules/underscore/cjs/findWhere.js +0 -10
- package/node_modules/underscore/cjs/first.js +0 -11
- package/node_modules/underscore/cjs/flatten.js +0 -9
- package/node_modules/underscore/cjs/functions.js +0 -12
- package/node_modules/underscore/cjs/get.js +0 -14
- package/node_modules/underscore/cjs/groupBy.js +0 -10
- package/node_modules/underscore/cjs/has.js +0 -18
- package/node_modules/underscore/cjs/identity.js +0 -6
- package/node_modules/underscore/cjs/index-default.js +0 -11
- package/node_modules/underscore/cjs/index.js +0 -278
- package/node_modules/underscore/cjs/indexBy.js +0 -9
- package/node_modules/underscore/cjs/indexOf.js +0 -11
- package/node_modules/underscore/cjs/initial.js +0 -10
- package/node_modules/underscore/cjs/intersection.js +0 -21
- package/node_modules/underscore/cjs/invert.js +0 -13
- package/node_modules/underscore/cjs/invoke.js +0 -30
- package/node_modules/underscore/cjs/isArguments.js +0 -18
- package/node_modules/underscore/cjs/isArray.js +0 -8
- package/node_modules/underscore/cjs/isArrayBuffer.js +0 -5
- package/node_modules/underscore/cjs/isBoolean.js +0 -8
- package/node_modules/underscore/cjs/isDataView.js +0 -16
- package/node_modules/underscore/cjs/isDate.js +0 -5
- package/node_modules/underscore/cjs/isElement.js +0 -6
- package/node_modules/underscore/cjs/isEmpty.js +0 -20
- package/node_modules/underscore/cjs/isEqual.js +0 -140
- package/node_modules/underscore/cjs/isError.js +0 -5
- package/node_modules/underscore/cjs/isFinite.js +0 -9
- package/node_modules/underscore/cjs/isFunction.js +0 -17
- package/node_modules/underscore/cjs/isMap.js +0 -7
- package/node_modules/underscore/cjs/isMatch.js +0 -15
- package/node_modules/underscore/cjs/isNaN.js +0 -9
- package/node_modules/underscore/cjs/isNull.js +0 -6
- package/node_modules/underscore/cjs/isNumber.js +0 -5
- package/node_modules/underscore/cjs/isObject.js +0 -7
- package/node_modules/underscore/cjs/isRegExp.js +0 -5
- package/node_modules/underscore/cjs/isSet.js +0 -7
- package/node_modules/underscore/cjs/isString.js +0 -5
- package/node_modules/underscore/cjs/isSymbol.js +0 -5
- package/node_modules/underscore/cjs/isTypedArray.js +0 -17
- package/node_modules/underscore/cjs/isUndefined.js +0 -6
- package/node_modules/underscore/cjs/isWeakMap.js +0 -7
- package/node_modules/underscore/cjs/isWeakSet.js +0 -5
- package/node_modules/underscore/cjs/iteratee.js +0 -12
- package/node_modules/underscore/cjs/keys.js +0 -18
- package/node_modules/underscore/cjs/last.js +0 -11
- package/node_modules/underscore/cjs/lastIndexOf.js +0 -8
- package/node_modules/underscore/cjs/map.js +0 -18
- package/node_modules/underscore/cjs/mapObject.js +0 -18
- package/node_modules/underscore/cjs/matcher.js +0 -13
- package/node_modules/underscore/cjs/max.js +0 -31
- package/node_modules/underscore/cjs/memoize.js +0 -15
- package/node_modules/underscore/cjs/min.js +0 -31
- package/node_modules/underscore/cjs/mixin.js +0 -20
- package/node_modules/underscore/cjs/negate.js +0 -8
- package/node_modules/underscore/cjs/noop.js +0 -4
- package/node_modules/underscore/cjs/now.js +0 -6
- package/node_modules/underscore/cjs/object.js +0 -18
- package/node_modules/underscore/cjs/omit.js +0 -24
- package/node_modules/underscore/cjs/once.js +0 -8
- package/node_modules/underscore/cjs/pairs.js +0 -15
- package/node_modules/underscore/cjs/partial.js +0 -25
- package/node_modules/underscore/cjs/partition.js +0 -9
- package/node_modules/underscore/cjs/pick.js +0 -28
- package/node_modules/underscore/cjs/pluck.js +0 -9
- package/node_modules/underscore/cjs/property.js +0 -13
- package/node_modules/underscore/cjs/propertyOf.js +0 -12
- package/node_modules/underscore/cjs/random.js +0 -10
- package/node_modules/underscore/cjs/range.js +0 -23
- package/node_modules/underscore/cjs/reduce.js +0 -7
- package/node_modules/underscore/cjs/reduceRight.js +0 -6
- package/node_modules/underscore/cjs/reject.js +0 -10
- package/node_modules/underscore/cjs/rest.js +0 -10
- package/node_modules/underscore/cjs/restArguments.js +0 -29
- package/node_modules/underscore/cjs/result.js +0 -24
- package/node_modules/underscore/cjs/sample.js +0 -29
- package/node_modules/underscore/cjs/set.js +0 -15
- package/node_modules/underscore/cjs/shuffle.js +0 -8
- package/node_modules/underscore/cjs/size.js +0 -10
- package/node_modules/underscore/cjs/some.js +0 -17
- package/node_modules/underscore/cjs/sortBy.js +0 -26
- package/node_modules/underscore/cjs/sortedIndex.js +0 -17
- package/node_modules/underscore/cjs/tap.js +0 -9
- package/node_modules/underscore/cjs/template.js +0 -103
- package/node_modules/underscore/cjs/templateSettings.js +0 -11
- package/node_modules/underscore/cjs/throttle.js +0 -49
- package/node_modules/underscore/cjs/times.js +0 -11
- package/node_modules/underscore/cjs/toArray.js +0 -22
- package/node_modules/underscore/cjs/toPath.js +0 -11
- package/node_modules/underscore/cjs/underscore-array-methods.js +0 -31
- package/node_modules/underscore/cjs/underscore.js +0 -27
- package/node_modules/underscore/cjs/unescape.js +0 -7
- package/node_modules/underscore/cjs/union.js +0 -11
- package/node_modules/underscore/cjs/uniq.js +0 -38
- package/node_modules/underscore/cjs/uniqueId.js +0 -9
- package/node_modules/underscore/cjs/unzip.js +0 -17
- package/node_modules/underscore/cjs/values.js +0 -14
- package/node_modules/underscore/cjs/where.js +0 -10
- package/node_modules/underscore/cjs/without.js +0 -9
- package/node_modules/underscore/cjs/wrap.js +0 -10
- package/node_modules/underscore/cjs/zip.js +0 -8
- package/node_modules/underscore/modules/.eslintrc +0 -21
- package/node_modules/underscore/modules/_baseCreate.js +0 -18
- package/node_modules/underscore/modules/_baseIteratee.js +0 -17
- package/node_modules/underscore/modules/_cb.js +0 -10
- package/node_modules/underscore/modules/_chainResult.js +0 -6
- package/node_modules/underscore/modules/_collectNonEnumProps.js +0 -40
- package/node_modules/underscore/modules/_createAssigner.js +0 -18
- package/node_modules/underscore/modules/_createEscaper.js +0 -17
- package/node_modules/underscore/modules/_createIndexFinder.js +0 -28
- package/node_modules/underscore/modules/_createPredicateIndexFinder.js +0 -15
- package/node_modules/underscore/modules/_createReduce.js +0 -28
- package/node_modules/underscore/modules/_createSizePropertyCheck.js +0 -9
- package/node_modules/underscore/modules/_deepGet.js +0 -9
- package/node_modules/underscore/modules/_escapeMap.js +0 -9
- package/node_modules/underscore/modules/_executeBound.js +0 -13
- package/node_modules/underscore/modules/_flatten.js +0 -31
- package/node_modules/underscore/modules/_getByteLength.js +0 -4
- package/node_modules/underscore/modules/_getLength.js +0 -4
- package/node_modules/underscore/modules/_group.js +0 -15
- package/node_modules/underscore/modules/_has.js +0 -6
- package/node_modules/underscore/modules/_hasObjectTag.js +0 -3
- package/node_modules/underscore/modules/_isArrayLike.js +0 -8
- package/node_modules/underscore/modules/_isBufferLike.js +0 -6
- package/node_modules/underscore/modules/_keyInObj.js +0 -5
- package/node_modules/underscore/modules/_methodFingerprint.js +0 -37
- package/node_modules/underscore/modules/_optimizeCb.js +0 -21
- package/node_modules/underscore/modules/_setup.js +0 -43
- package/node_modules/underscore/modules/_shallowProperty.js +0 -6
- package/node_modules/underscore/modules/_stringTagBug.js +0 -10
- package/node_modules/underscore/modules/_tagTester.js +0 -9
- package/node_modules/underscore/modules/_toBufferView.js +0 -11
- package/node_modules/underscore/modules/_toPath.js +0 -8
- package/node_modules/underscore/modules/_unescapeMap.js +0 -5
- package/node_modules/underscore/modules/after.js +0 -8
- package/node_modules/underscore/modules/allKeys.js +0 -13
- package/node_modules/underscore/modules/before.js +0 -12
- package/node_modules/underscore/modules/bind.js +0 -13
- package/node_modules/underscore/modules/bindAll.js +0 -17
- package/node_modules/underscore/modules/chain.js +0 -8
- package/node_modules/underscore/modules/chunk.js +0 -13
- package/node_modules/underscore/modules/clone.js +0 -9
- package/node_modules/underscore/modules/compact.js +0 -6
- package/node_modules/underscore/modules/compose.js +0 -12
- package/node_modules/underscore/modules/constant.js +0 -6
- package/node_modules/underscore/modules/contains.js +0 -10
- package/node_modules/underscore/modules/countBy.js +0 -9
- package/node_modules/underscore/modules/create.js +0 -11
- package/node_modules/underscore/modules/debounce.js +0 -40
- package/node_modules/underscore/modules/defaults.js +0 -5
- package/node_modules/underscore/modules/defer.js +0 -7
- package/node_modules/underscore/modules/delay.js +0 -9
- package/node_modules/underscore/modules/difference.js +0 -13
- package/node_modules/underscore/modules/each.js +0 -23
- package/node_modules/underscore/modules/escape.js +0 -5
- package/node_modules/underscore/modules/every.js +0 -15
- package/node_modules/underscore/modules/extend.js +0 -5
- package/node_modules/underscore/modules/extendOwn.js +0 -7
- package/node_modules/underscore/modules/filter.js +0 -12
- package/node_modules/underscore/modules/find.js +0 -10
- package/node_modules/underscore/modules/findIndex.js +0 -4
- package/node_modules/underscore/modules/findKey.js +0 -12
- package/node_modules/underscore/modules/findLastIndex.js +0 -4
- package/node_modules/underscore/modules/findWhere.js +0 -8
- package/node_modules/underscore/modules/first.js +0 -9
- package/node_modules/underscore/modules/flatten.js +0 -7
- package/node_modules/underscore/modules/functions.js +0 -10
- package/node_modules/underscore/modules/get.js +0 -12
- package/node_modules/underscore/modules/groupBy.js +0 -8
- package/node_modules/underscore/modules/has.js +0 -16
- package/node_modules/underscore/modules/identity.js +0 -4
- package/node_modules/underscore/modules/index-all.js +0 -18
- package/node_modules/underscore/modules/index-default.js +0 -27
- package/node_modules/underscore/modules/index.js +0 -200
- package/node_modules/underscore/modules/indexBy.js +0 -7
- package/node_modules/underscore/modules/indexOf.js +0 -9
- package/node_modules/underscore/modules/initial.js +0 -8
- package/node_modules/underscore/modules/intersection.js +0 -19
- package/node_modules/underscore/modules/invert.js +0 -11
- package/node_modules/underscore/modules/invoke.js +0 -28
- package/node_modules/underscore/modules/isArguments.js +0 -16
- package/node_modules/underscore/modules/isArray.js +0 -6
- package/node_modules/underscore/modules/isArrayBuffer.js +0 -3
- package/node_modules/underscore/modules/isBoolean.js +0 -6
- package/node_modules/underscore/modules/isDataView.js +0 -14
- package/node_modules/underscore/modules/isDate.js +0 -3
- package/node_modules/underscore/modules/isElement.js +0 -4
- package/node_modules/underscore/modules/isEmpty.js +0 -18
- package/node_modules/underscore/modules/isEqual.js +0 -138
- package/node_modules/underscore/modules/isError.js +0 -3
- package/node_modules/underscore/modules/isFinite.js +0 -7
- package/node_modules/underscore/modules/isFunction.js +0 -15
- package/node_modules/underscore/modules/isMap.js +0 -5
- package/node_modules/underscore/modules/isMatch.js +0 -13
- package/node_modules/underscore/modules/isNaN.js +0 -7
- package/node_modules/underscore/modules/isNull.js +0 -4
- package/node_modules/underscore/modules/isNumber.js +0 -3
- package/node_modules/underscore/modules/isObject.js +0 -5
- package/node_modules/underscore/modules/isRegExp.js +0 -3
- package/node_modules/underscore/modules/isSet.js +0 -5
- package/node_modules/underscore/modules/isString.js +0 -3
- package/node_modules/underscore/modules/isSymbol.js +0 -3
- package/node_modules/underscore/modules/isTypedArray.js +0 -15
- package/node_modules/underscore/modules/isUndefined.js +0 -4
- package/node_modules/underscore/modules/isWeakMap.js +0 -5
- package/node_modules/underscore/modules/isWeakSet.js +0 -3
- package/node_modules/underscore/modules/iteratee.js +0 -10
- package/node_modules/underscore/modules/keys.js +0 -16
- package/node_modules/underscore/modules/last.js +0 -9
- package/node_modules/underscore/modules/lastIndexOf.js +0 -6
- package/node_modules/underscore/modules/map.js +0 -16
- package/node_modules/underscore/modules/mapObject.js +0 -16
- package/node_modules/underscore/modules/matcher.js +0 -11
- package/node_modules/underscore/modules/max.js +0 -29
- package/node_modules/underscore/modules/memoize.js +0 -13
- package/node_modules/underscore/modules/min.js +0 -29
- package/node_modules/underscore/modules/mixin.js +0 -18
- package/node_modules/underscore/modules/negate.js +0 -6
- package/node_modules/underscore/modules/noop.js +0 -2
- package/node_modules/underscore/modules/now.js +0 -4
- package/node_modules/underscore/modules/object.js +0 -16
- package/node_modules/underscore/modules/omit.js +0 -22
- package/node_modules/underscore/modules/once.js +0 -6
- package/node_modules/underscore/modules/package.json +0 -1
- package/node_modules/underscore/modules/pairs.js +0 -13
- package/node_modules/underscore/modules/partial.js +0 -24
- package/node_modules/underscore/modules/partition.js +0 -7
- package/node_modules/underscore/modules/pick.js +0 -26
- package/node_modules/underscore/modules/pluck.js +0 -7
- package/node_modules/underscore/modules/property.js +0 -11
- package/node_modules/underscore/modules/propertyOf.js +0 -10
- package/node_modules/underscore/modules/random.js +0 -8
- package/node_modules/underscore/modules/range.js +0 -21
- package/node_modules/underscore/modules/reduce.js +0 -5
- package/node_modules/underscore/modules/reduceRight.js +0 -4
- package/node_modules/underscore/modules/reject.js +0 -8
- package/node_modules/underscore/modules/rest.js +0 -8
- package/node_modules/underscore/modules/restArguments.js +0 -27
- package/node_modules/underscore/modules/result.js +0 -22
- package/node_modules/underscore/modules/sample.js +0 -27
- package/node_modules/underscore/modules/shuffle.js +0 -6
- package/node_modules/underscore/modules/size.js +0 -8
- package/node_modules/underscore/modules/some.js +0 -15
- package/node_modules/underscore/modules/sortBy.js +0 -24
- package/node_modules/underscore/modules/sortedIndex.js +0 -15
- package/node_modules/underscore/modules/tap.js +0 -7
- package/node_modules/underscore/modules/template.js +0 -101
- package/node_modules/underscore/modules/templateSettings.js +0 -9
- package/node_modules/underscore/modules/throttle.js +0 -47
- package/node_modules/underscore/modules/times.js +0 -9
- package/node_modules/underscore/modules/toArray.js +0 -20
- package/node_modules/underscore/modules/toPath.js +0 -9
- package/node_modules/underscore/modules/underscore-array-methods.js +0 -31
- package/node_modules/underscore/modules/underscore.js +0 -25
- package/node_modules/underscore/modules/unescape.js +0 -5
- package/node_modules/underscore/modules/union.js +0 -9
- package/node_modules/underscore/modules/uniq.js +0 -36
- package/node_modules/underscore/modules/uniqueId.js +0 -7
- package/node_modules/underscore/modules/unzip.js +0 -15
- package/node_modules/underscore/modules/values.js +0 -12
- package/node_modules/underscore/modules/where.js +0 -8
- package/node_modules/underscore/modules/without.js +0 -7
- package/node_modules/underscore/modules/wrap.js +0 -8
- package/node_modules/underscore/modules/zip.js +0 -6
- package/node_modules/underscore/package.json +0 -124
- package/node_modules/underscore/underscore-esm-min.js +0 -5
- package/node_modules/underscore/underscore-esm-min.js.map +0 -1
- package/node_modules/underscore/underscore-esm.js +0 -2034
- package/node_modules/underscore/underscore-esm.js.map +0 -1
- package/node_modules/underscore/underscore-min.js +0 -6
- package/node_modules/underscore/underscore-min.js.map +0 -1
- package/node_modules/underscore/underscore-node-f.cjs +0 -2158
- package/node_modules/underscore/underscore-node-f.cjs.map +0 -1
- package/node_modules/underscore/underscore-node.cjs +0 -11
- package/node_modules/underscore/underscore-node.cjs.map +0 -1
- package/node_modules/underscore/underscore-node.mjs +0 -7
- package/node_modules/underscore/underscore-node.mjs.map +0 -1
- package/node_modules/underscore/underscore-umd-min.js +0 -6
- package/node_modules/underscore/underscore-umd-min.js.map +0 -1
- package/node_modules/underscore/underscore-umd.js +0 -2042
- package/node_modules/underscore/underscore-umd.js.map +0 -1
- package/node_modules/underscore/underscore.js +0 -2042
|
@@ -0,0 +1,2164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @implements {IHooks}
|
|
3
|
+
*/
|
|
4
|
+
class Hooks {
|
|
5
|
+
/**
|
|
6
|
+
* @callback HookCallback
|
|
7
|
+
* @this {*|Jsep} this
|
|
8
|
+
* @param {Jsep} env
|
|
9
|
+
* @returns: void
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Adds the given callback to the list of callbacks for the given hook.
|
|
13
|
+
*
|
|
14
|
+
* The callback will be invoked when the hook it is registered for is run.
|
|
15
|
+
*
|
|
16
|
+
* One callback function can be registered to multiple hooks and the same hook multiple times.
|
|
17
|
+
*
|
|
18
|
+
* @param {string|object} name The name of the hook, or an object of callbacks keyed by name
|
|
19
|
+
* @param {HookCallback|boolean} callback The callback function which is given environment variables.
|
|
20
|
+
* @param {?boolean} [first=false] Will add the hook to the top of the list (defaults to the bottom)
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
add(name, callback, first) {
|
|
24
|
+
if (typeof arguments[0] != 'string') {
|
|
25
|
+
// Multiple hook callbacks, keyed by name
|
|
26
|
+
for (let name in arguments[0]) {
|
|
27
|
+
this.add(name, arguments[0][name], arguments[1]);
|
|
28
|
+
}
|
|
29
|
+
} else {
|
|
30
|
+
(Array.isArray(name) ? name : [name]).forEach(function (name) {
|
|
31
|
+
this[name] = this[name] || [];
|
|
32
|
+
if (callback) {
|
|
33
|
+
this[name][first ? 'unshift' : 'push'](callback);
|
|
34
|
+
}
|
|
35
|
+
}, this);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Runs a hook invoking all registered callbacks with the given environment variables.
|
|
41
|
+
*
|
|
42
|
+
* Callbacks will be invoked synchronously and in the order in which they were registered.
|
|
43
|
+
*
|
|
44
|
+
* @param {string} name The name of the hook.
|
|
45
|
+
* @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
|
|
46
|
+
* @public
|
|
47
|
+
*/
|
|
48
|
+
run(name, env) {
|
|
49
|
+
this[name] = this[name] || [];
|
|
50
|
+
this[name].forEach(function (callback) {
|
|
51
|
+
callback.call(env && env.context ? env.context : env, env);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @implements {IPlugins}
|
|
58
|
+
*/
|
|
59
|
+
class Plugins {
|
|
60
|
+
constructor(jsep) {
|
|
61
|
+
this.jsep = jsep;
|
|
62
|
+
this.registered = {};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @callback PluginSetup
|
|
67
|
+
* @this {Jsep} jsep
|
|
68
|
+
* @returns: void
|
|
69
|
+
*/
|
|
70
|
+
/**
|
|
71
|
+
* Adds the given plugin(s) to the registry
|
|
72
|
+
*
|
|
73
|
+
* @param {object} plugins
|
|
74
|
+
* @param {string} plugins.name The name of the plugin
|
|
75
|
+
* @param {PluginSetup} plugins.init The init function
|
|
76
|
+
* @public
|
|
77
|
+
*/
|
|
78
|
+
register() {
|
|
79
|
+
for (var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
80
|
+
plugins[_key] = arguments[_key];
|
|
81
|
+
}
|
|
82
|
+
plugins.forEach(plugin => {
|
|
83
|
+
if (typeof plugin !== 'object' || !plugin.name || !plugin.init) {
|
|
84
|
+
throw new Error('Invalid JSEP plugin format');
|
|
85
|
+
}
|
|
86
|
+
if (this.registered[plugin.name]) {
|
|
87
|
+
// already registered. Ignore.
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
plugin.init(this.jsep);
|
|
91
|
+
this.registered[plugin.name] = plugin;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// JavaScript Expression Parser (JSEP) 1.4.0
|
|
97
|
+
|
|
98
|
+
class Jsep {
|
|
99
|
+
/**
|
|
100
|
+
* @returns {string}
|
|
101
|
+
*/
|
|
102
|
+
static get version() {
|
|
103
|
+
// To be filled in by the template
|
|
104
|
+
return '1.4.0';
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* @returns {string}
|
|
109
|
+
*/
|
|
110
|
+
static toString() {
|
|
111
|
+
return 'JavaScript Expression Parser (JSEP) v' + Jsep.version;
|
|
112
|
+
}
|
|
113
|
+
// ==================== CONFIG ================================
|
|
114
|
+
/**
|
|
115
|
+
* @method addUnaryOp
|
|
116
|
+
* @param {string} op_name The name of the unary op to add
|
|
117
|
+
* @returns {Jsep}
|
|
118
|
+
*/
|
|
119
|
+
static addUnaryOp(op_name) {
|
|
120
|
+
Jsep.max_unop_len = Math.max(op_name.length, Jsep.max_unop_len);
|
|
121
|
+
Jsep.unary_ops[op_name] = 1;
|
|
122
|
+
return Jsep;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @method jsep.addBinaryOp
|
|
127
|
+
* @param {string} op_name The name of the binary op to add
|
|
128
|
+
* @param {number} precedence The precedence of the binary op (can be a float). Higher number = higher precedence
|
|
129
|
+
* @param {boolean} [isRightAssociative=false] whether operator is right-associative
|
|
130
|
+
* @returns {Jsep}
|
|
131
|
+
*/
|
|
132
|
+
static addBinaryOp(op_name, precedence, isRightAssociative) {
|
|
133
|
+
Jsep.max_binop_len = Math.max(op_name.length, Jsep.max_binop_len);
|
|
134
|
+
Jsep.binary_ops[op_name] = precedence;
|
|
135
|
+
if (isRightAssociative) {
|
|
136
|
+
Jsep.right_associative.add(op_name);
|
|
137
|
+
} else {
|
|
138
|
+
Jsep.right_associative.delete(op_name);
|
|
139
|
+
}
|
|
140
|
+
return Jsep;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* @method addIdentifierChar
|
|
145
|
+
* @param {string} char The additional character to treat as a valid part of an identifier
|
|
146
|
+
* @returns {Jsep}
|
|
147
|
+
*/
|
|
148
|
+
static addIdentifierChar(char) {
|
|
149
|
+
Jsep.additional_identifier_chars.add(char);
|
|
150
|
+
return Jsep;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* @method addLiteral
|
|
155
|
+
* @param {string} literal_name The name of the literal to add
|
|
156
|
+
* @param {*} literal_value The value of the literal
|
|
157
|
+
* @returns {Jsep}
|
|
158
|
+
*/
|
|
159
|
+
static addLiteral(literal_name, literal_value) {
|
|
160
|
+
Jsep.literals[literal_name] = literal_value;
|
|
161
|
+
return Jsep;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* @method removeUnaryOp
|
|
166
|
+
* @param {string} op_name The name of the unary op to remove
|
|
167
|
+
* @returns {Jsep}
|
|
168
|
+
*/
|
|
169
|
+
static removeUnaryOp(op_name) {
|
|
170
|
+
delete Jsep.unary_ops[op_name];
|
|
171
|
+
if (op_name.length === Jsep.max_unop_len) {
|
|
172
|
+
Jsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);
|
|
173
|
+
}
|
|
174
|
+
return Jsep;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* @method removeAllUnaryOps
|
|
179
|
+
* @returns {Jsep}
|
|
180
|
+
*/
|
|
181
|
+
static removeAllUnaryOps() {
|
|
182
|
+
Jsep.unary_ops = {};
|
|
183
|
+
Jsep.max_unop_len = 0;
|
|
184
|
+
return Jsep;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* @method removeIdentifierChar
|
|
189
|
+
* @param {string} char The additional character to stop treating as a valid part of an identifier
|
|
190
|
+
* @returns {Jsep}
|
|
191
|
+
*/
|
|
192
|
+
static removeIdentifierChar(char) {
|
|
193
|
+
Jsep.additional_identifier_chars.delete(char);
|
|
194
|
+
return Jsep;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* @method removeBinaryOp
|
|
199
|
+
* @param {string} op_name The name of the binary op to remove
|
|
200
|
+
* @returns {Jsep}
|
|
201
|
+
*/
|
|
202
|
+
static removeBinaryOp(op_name) {
|
|
203
|
+
delete Jsep.binary_ops[op_name];
|
|
204
|
+
if (op_name.length === Jsep.max_binop_len) {
|
|
205
|
+
Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);
|
|
206
|
+
}
|
|
207
|
+
Jsep.right_associative.delete(op_name);
|
|
208
|
+
return Jsep;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* @method removeAllBinaryOps
|
|
213
|
+
* @returns {Jsep}
|
|
214
|
+
*/
|
|
215
|
+
static removeAllBinaryOps() {
|
|
216
|
+
Jsep.binary_ops = {};
|
|
217
|
+
Jsep.max_binop_len = 0;
|
|
218
|
+
return Jsep;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* @method removeLiteral
|
|
223
|
+
* @param {string} literal_name The name of the literal to remove
|
|
224
|
+
* @returns {Jsep}
|
|
225
|
+
*/
|
|
226
|
+
static removeLiteral(literal_name) {
|
|
227
|
+
delete Jsep.literals[literal_name];
|
|
228
|
+
return Jsep;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* @method removeAllLiterals
|
|
233
|
+
* @returns {Jsep}
|
|
234
|
+
*/
|
|
235
|
+
static removeAllLiterals() {
|
|
236
|
+
Jsep.literals = {};
|
|
237
|
+
return Jsep;
|
|
238
|
+
}
|
|
239
|
+
// ==================== END CONFIG ============================
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* @returns {string}
|
|
243
|
+
*/
|
|
244
|
+
get char() {
|
|
245
|
+
return this.expr.charAt(this.index);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* @returns {number}
|
|
250
|
+
*/
|
|
251
|
+
get code() {
|
|
252
|
+
return this.expr.charCodeAt(this.index);
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* @param {string} expr a string with the passed in express
|
|
256
|
+
* @returns Jsep
|
|
257
|
+
*/
|
|
258
|
+
constructor(expr) {
|
|
259
|
+
// `index` stores the character number we are currently at
|
|
260
|
+
// All of the gobbles below will modify `index` as we move along
|
|
261
|
+
this.expr = expr;
|
|
262
|
+
this.index = 0;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* static top-level parser
|
|
267
|
+
* @returns {jsep.Expression}
|
|
268
|
+
*/
|
|
269
|
+
static parse(expr) {
|
|
270
|
+
return new Jsep(expr).parse();
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Get the longest key length of any object
|
|
275
|
+
* @param {object} obj
|
|
276
|
+
* @returns {number}
|
|
277
|
+
*/
|
|
278
|
+
static getMaxKeyLen(obj) {
|
|
279
|
+
return Math.max(0, ...Object.keys(obj).map(k => k.length));
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* `ch` is a character code in the next three functions
|
|
284
|
+
* @param {number} ch
|
|
285
|
+
* @returns {boolean}
|
|
286
|
+
*/
|
|
287
|
+
static isDecimalDigit(ch) {
|
|
288
|
+
return ch >= 48 && ch <= 57; // 0...9
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Returns the precedence of a binary operator or `0` if it isn't a binary operator. Can be float.
|
|
293
|
+
* @param {string} op_val
|
|
294
|
+
* @returns {number}
|
|
295
|
+
*/
|
|
296
|
+
static binaryPrecedence(op_val) {
|
|
297
|
+
return Jsep.binary_ops[op_val] || 0;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Looks for start of identifier
|
|
302
|
+
* @param {number} ch
|
|
303
|
+
* @returns {boolean}
|
|
304
|
+
*/
|
|
305
|
+
static isIdentifierStart(ch) {
|
|
306
|
+
return ch >= 65 && ch <= 90 ||
|
|
307
|
+
// A...Z
|
|
308
|
+
ch >= 97 && ch <= 122 ||
|
|
309
|
+
// a...z
|
|
310
|
+
ch >= 128 && !Jsep.binary_ops[String.fromCharCode(ch)] ||
|
|
311
|
+
// any non-ASCII that is not an operator
|
|
312
|
+
Jsep.additional_identifier_chars.has(String.fromCharCode(ch)); // additional characters
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* @param {number} ch
|
|
317
|
+
* @returns {boolean}
|
|
318
|
+
*/
|
|
319
|
+
static isIdentifierPart(ch) {
|
|
320
|
+
return Jsep.isIdentifierStart(ch) || Jsep.isDecimalDigit(ch);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* throw error at index of the expression
|
|
325
|
+
* @param {string} message
|
|
326
|
+
* @throws
|
|
327
|
+
*/
|
|
328
|
+
throwError(message) {
|
|
329
|
+
const error = new Error(message + ' at character ' + this.index);
|
|
330
|
+
error.index = this.index;
|
|
331
|
+
error.description = message;
|
|
332
|
+
throw error;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Run a given hook
|
|
337
|
+
* @param {string} name
|
|
338
|
+
* @param {jsep.Expression|false} [node]
|
|
339
|
+
* @returns {?jsep.Expression}
|
|
340
|
+
*/
|
|
341
|
+
runHook(name, node) {
|
|
342
|
+
if (Jsep.hooks[name]) {
|
|
343
|
+
const env = {
|
|
344
|
+
context: this,
|
|
345
|
+
node
|
|
346
|
+
};
|
|
347
|
+
Jsep.hooks.run(name, env);
|
|
348
|
+
return env.node;
|
|
349
|
+
}
|
|
350
|
+
return node;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Runs a given hook until one returns a node
|
|
355
|
+
* @param {string} name
|
|
356
|
+
* @returns {?jsep.Expression}
|
|
357
|
+
*/
|
|
358
|
+
searchHook(name) {
|
|
359
|
+
if (Jsep.hooks[name]) {
|
|
360
|
+
const env = {
|
|
361
|
+
context: this
|
|
362
|
+
};
|
|
363
|
+
Jsep.hooks[name].find(function (callback) {
|
|
364
|
+
callback.call(env.context, env);
|
|
365
|
+
return env.node;
|
|
366
|
+
});
|
|
367
|
+
return env.node;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Push `index` up to the next non-space character
|
|
373
|
+
*/
|
|
374
|
+
gobbleSpaces() {
|
|
375
|
+
let ch = this.code;
|
|
376
|
+
// Whitespace
|
|
377
|
+
while (ch === Jsep.SPACE_CODE || ch === Jsep.TAB_CODE || ch === Jsep.LF_CODE || ch === Jsep.CR_CODE) {
|
|
378
|
+
ch = this.expr.charCodeAt(++this.index);
|
|
379
|
+
}
|
|
380
|
+
this.runHook('gobble-spaces');
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Top-level method to parse all expressions and returns compound or single node
|
|
385
|
+
* @returns {jsep.Expression}
|
|
386
|
+
*/
|
|
387
|
+
parse() {
|
|
388
|
+
this.runHook('before-all');
|
|
389
|
+
const nodes = this.gobbleExpressions();
|
|
390
|
+
|
|
391
|
+
// If there's only one expression just try returning the expression
|
|
392
|
+
const node = nodes.length === 1 ? nodes[0] : {
|
|
393
|
+
type: Jsep.COMPOUND,
|
|
394
|
+
body: nodes
|
|
395
|
+
};
|
|
396
|
+
return this.runHook('after-all', node);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* top-level parser (but can be reused within as well)
|
|
401
|
+
* @param {number} [untilICode]
|
|
402
|
+
* @returns {jsep.Expression[]}
|
|
403
|
+
*/
|
|
404
|
+
gobbleExpressions(untilICode) {
|
|
405
|
+
let nodes = [],
|
|
406
|
+
ch_i,
|
|
407
|
+
node;
|
|
408
|
+
while (this.index < this.expr.length) {
|
|
409
|
+
ch_i = this.code;
|
|
410
|
+
|
|
411
|
+
// Expressions can be separated by semicolons, commas, or just inferred without any
|
|
412
|
+
// separators
|
|
413
|
+
if (ch_i === Jsep.SEMCOL_CODE || ch_i === Jsep.COMMA_CODE) {
|
|
414
|
+
this.index++; // ignore separators
|
|
415
|
+
} else {
|
|
416
|
+
// Try to gobble each expression individually
|
|
417
|
+
if (node = this.gobbleExpression()) {
|
|
418
|
+
nodes.push(node);
|
|
419
|
+
// If we weren't able to find a binary expression and are out of room, then
|
|
420
|
+
// the expression passed in probably has too much
|
|
421
|
+
} else if (this.index < this.expr.length) {
|
|
422
|
+
if (ch_i === untilICode) {
|
|
423
|
+
break;
|
|
424
|
+
}
|
|
425
|
+
this.throwError('Unexpected "' + this.char + '"');
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
return nodes;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* The main parsing function.
|
|
434
|
+
* @returns {?jsep.Expression}
|
|
435
|
+
*/
|
|
436
|
+
gobbleExpression() {
|
|
437
|
+
const node = this.searchHook('gobble-expression') || this.gobbleBinaryExpression();
|
|
438
|
+
this.gobbleSpaces();
|
|
439
|
+
return this.runHook('after-expression', node);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* Search for the operation portion of the string (e.g. `+`, `===`)
|
|
444
|
+
* Start by taking the longest possible binary operations (3 characters: `===`, `!==`, `>>>`)
|
|
445
|
+
* and move down from 3 to 2 to 1 character until a matching binary operation is found
|
|
446
|
+
* then, return that binary operation
|
|
447
|
+
* @returns {string|boolean}
|
|
448
|
+
*/
|
|
449
|
+
gobbleBinaryOp() {
|
|
450
|
+
this.gobbleSpaces();
|
|
451
|
+
let to_check = this.expr.substr(this.index, Jsep.max_binop_len);
|
|
452
|
+
let tc_len = to_check.length;
|
|
453
|
+
while (tc_len > 0) {
|
|
454
|
+
// Don't accept a binary op when it is an identifier.
|
|
455
|
+
// Binary ops that start with a identifier-valid character must be followed
|
|
456
|
+
// by a non identifier-part valid character
|
|
457
|
+
if (Jsep.binary_ops.hasOwnProperty(to_check) && (!Jsep.isIdentifierStart(this.code) || this.index + to_check.length < this.expr.length && !Jsep.isIdentifierPart(this.expr.charCodeAt(this.index + to_check.length)))) {
|
|
458
|
+
this.index += tc_len;
|
|
459
|
+
return to_check;
|
|
460
|
+
}
|
|
461
|
+
to_check = to_check.substr(0, --tc_len);
|
|
462
|
+
}
|
|
463
|
+
return false;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* This function is responsible for gobbling an individual expression,
|
|
468
|
+
* e.g. `1`, `1+2`, `a+(b*2)-Math.sqrt(2)`
|
|
469
|
+
* @returns {?jsep.BinaryExpression}
|
|
470
|
+
*/
|
|
471
|
+
gobbleBinaryExpression() {
|
|
472
|
+
let node, biop, prec, stack, biop_info, left, right, i, cur_biop;
|
|
473
|
+
|
|
474
|
+
// First, try to get the leftmost thing
|
|
475
|
+
// Then, check to see if there's a binary operator operating on that leftmost thing
|
|
476
|
+
// Don't gobbleBinaryOp without a left-hand-side
|
|
477
|
+
left = this.gobbleToken();
|
|
478
|
+
if (!left) {
|
|
479
|
+
return left;
|
|
480
|
+
}
|
|
481
|
+
biop = this.gobbleBinaryOp();
|
|
482
|
+
|
|
483
|
+
// If there wasn't a binary operator, just return the leftmost node
|
|
484
|
+
if (!biop) {
|
|
485
|
+
return left;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
// Otherwise, we need to start a stack to properly place the binary operations in their
|
|
489
|
+
// precedence structure
|
|
490
|
+
biop_info = {
|
|
491
|
+
value: biop,
|
|
492
|
+
prec: Jsep.binaryPrecedence(biop),
|
|
493
|
+
right_a: Jsep.right_associative.has(biop)
|
|
494
|
+
};
|
|
495
|
+
right = this.gobbleToken();
|
|
496
|
+
if (!right) {
|
|
497
|
+
this.throwError("Expected expression after " + biop);
|
|
498
|
+
}
|
|
499
|
+
stack = [left, biop_info, right];
|
|
500
|
+
|
|
501
|
+
// Properly deal with precedence using [recursive descent](http://www.engr.mun.ca/~theo/Misc/exp_parsing.htm)
|
|
502
|
+
while (biop = this.gobbleBinaryOp()) {
|
|
503
|
+
prec = Jsep.binaryPrecedence(biop);
|
|
504
|
+
if (prec === 0) {
|
|
505
|
+
this.index -= biop.length;
|
|
506
|
+
break;
|
|
507
|
+
}
|
|
508
|
+
biop_info = {
|
|
509
|
+
value: biop,
|
|
510
|
+
prec,
|
|
511
|
+
right_a: Jsep.right_associative.has(biop)
|
|
512
|
+
};
|
|
513
|
+
cur_biop = biop;
|
|
514
|
+
|
|
515
|
+
// Reduce: make a binary expression from the three topmost entries.
|
|
516
|
+
const comparePrev = prev => biop_info.right_a && prev.right_a ? prec > prev.prec : prec <= prev.prec;
|
|
517
|
+
while (stack.length > 2 && comparePrev(stack[stack.length - 2])) {
|
|
518
|
+
right = stack.pop();
|
|
519
|
+
biop = stack.pop().value;
|
|
520
|
+
left = stack.pop();
|
|
521
|
+
node = {
|
|
522
|
+
type: Jsep.BINARY_EXP,
|
|
523
|
+
operator: biop,
|
|
524
|
+
left,
|
|
525
|
+
right
|
|
526
|
+
};
|
|
527
|
+
stack.push(node);
|
|
528
|
+
}
|
|
529
|
+
node = this.gobbleToken();
|
|
530
|
+
if (!node) {
|
|
531
|
+
this.throwError("Expected expression after " + cur_biop);
|
|
532
|
+
}
|
|
533
|
+
stack.push(biop_info, node);
|
|
534
|
+
}
|
|
535
|
+
i = stack.length - 1;
|
|
536
|
+
node = stack[i];
|
|
537
|
+
while (i > 1) {
|
|
538
|
+
node = {
|
|
539
|
+
type: Jsep.BINARY_EXP,
|
|
540
|
+
operator: stack[i - 1].value,
|
|
541
|
+
left: stack[i - 2],
|
|
542
|
+
right: node
|
|
543
|
+
};
|
|
544
|
+
i -= 2;
|
|
545
|
+
}
|
|
546
|
+
return node;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* An individual part of a binary expression:
|
|
551
|
+
* e.g. `foo.bar(baz)`, `1`, `"abc"`, `(a % 2)` (because it's in parenthesis)
|
|
552
|
+
* @returns {boolean|jsep.Expression}
|
|
553
|
+
*/
|
|
554
|
+
gobbleToken() {
|
|
555
|
+
let ch, to_check, tc_len, node;
|
|
556
|
+
this.gobbleSpaces();
|
|
557
|
+
node = this.searchHook('gobble-token');
|
|
558
|
+
if (node) {
|
|
559
|
+
return this.runHook('after-token', node);
|
|
560
|
+
}
|
|
561
|
+
ch = this.code;
|
|
562
|
+
if (Jsep.isDecimalDigit(ch) || ch === Jsep.PERIOD_CODE) {
|
|
563
|
+
// Char code 46 is a dot `.` which can start off a numeric literal
|
|
564
|
+
return this.gobbleNumericLiteral();
|
|
565
|
+
}
|
|
566
|
+
if (ch === Jsep.SQUOTE_CODE || ch === Jsep.DQUOTE_CODE) {
|
|
567
|
+
// Single or double quotes
|
|
568
|
+
node = this.gobbleStringLiteral();
|
|
569
|
+
} else if (ch === Jsep.OBRACK_CODE) {
|
|
570
|
+
node = this.gobbleArray();
|
|
571
|
+
} else {
|
|
572
|
+
to_check = this.expr.substr(this.index, Jsep.max_unop_len);
|
|
573
|
+
tc_len = to_check.length;
|
|
574
|
+
while (tc_len > 0) {
|
|
575
|
+
// Don't accept an unary op when it is an identifier.
|
|
576
|
+
// Unary ops that start with a identifier-valid character must be followed
|
|
577
|
+
// by a non identifier-part valid character
|
|
578
|
+
if (Jsep.unary_ops.hasOwnProperty(to_check) && (!Jsep.isIdentifierStart(this.code) || this.index + to_check.length < this.expr.length && !Jsep.isIdentifierPart(this.expr.charCodeAt(this.index + to_check.length)))) {
|
|
579
|
+
this.index += tc_len;
|
|
580
|
+
const argument = this.gobbleToken();
|
|
581
|
+
if (!argument) {
|
|
582
|
+
this.throwError('missing unaryOp argument');
|
|
583
|
+
}
|
|
584
|
+
return this.runHook('after-token', {
|
|
585
|
+
type: Jsep.UNARY_EXP,
|
|
586
|
+
operator: to_check,
|
|
587
|
+
argument,
|
|
588
|
+
prefix: true
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
to_check = to_check.substr(0, --tc_len);
|
|
592
|
+
}
|
|
593
|
+
if (Jsep.isIdentifierStart(ch)) {
|
|
594
|
+
node = this.gobbleIdentifier();
|
|
595
|
+
if (Jsep.literals.hasOwnProperty(node.name)) {
|
|
596
|
+
node = {
|
|
597
|
+
type: Jsep.LITERAL,
|
|
598
|
+
value: Jsep.literals[node.name],
|
|
599
|
+
raw: node.name
|
|
600
|
+
};
|
|
601
|
+
} else if (node.name === Jsep.this_str) {
|
|
602
|
+
node = {
|
|
603
|
+
type: Jsep.THIS_EXP
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
} else if (ch === Jsep.OPAREN_CODE) {
|
|
607
|
+
// open parenthesis
|
|
608
|
+
node = this.gobbleGroup();
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
if (!node) {
|
|
612
|
+
return this.runHook('after-token', false);
|
|
613
|
+
}
|
|
614
|
+
node = this.gobbleTokenProperty(node);
|
|
615
|
+
return this.runHook('after-token', node);
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* Gobble properties of of identifiers/strings/arrays/groups.
|
|
620
|
+
* e.g. `foo`, `bar.baz`, `foo['bar'].baz`
|
|
621
|
+
* It also gobbles function calls:
|
|
622
|
+
* e.g. `Math.acos(obj.angle)`
|
|
623
|
+
* @param {jsep.Expression} node
|
|
624
|
+
* @returns {jsep.Expression}
|
|
625
|
+
*/
|
|
626
|
+
gobbleTokenProperty(node) {
|
|
627
|
+
this.gobbleSpaces();
|
|
628
|
+
let ch = this.code;
|
|
629
|
+
while (ch === Jsep.PERIOD_CODE || ch === Jsep.OBRACK_CODE || ch === Jsep.OPAREN_CODE || ch === Jsep.QUMARK_CODE) {
|
|
630
|
+
let optional;
|
|
631
|
+
if (ch === Jsep.QUMARK_CODE) {
|
|
632
|
+
if (this.expr.charCodeAt(this.index + 1) !== Jsep.PERIOD_CODE) {
|
|
633
|
+
break;
|
|
634
|
+
}
|
|
635
|
+
optional = true;
|
|
636
|
+
this.index += 2;
|
|
637
|
+
this.gobbleSpaces();
|
|
638
|
+
ch = this.code;
|
|
639
|
+
}
|
|
640
|
+
this.index++;
|
|
641
|
+
if (ch === Jsep.OBRACK_CODE) {
|
|
642
|
+
node = {
|
|
643
|
+
type: Jsep.MEMBER_EXP,
|
|
644
|
+
computed: true,
|
|
645
|
+
object: node,
|
|
646
|
+
property: this.gobbleExpression()
|
|
647
|
+
};
|
|
648
|
+
if (!node.property) {
|
|
649
|
+
this.throwError('Unexpected "' + this.char + '"');
|
|
650
|
+
}
|
|
651
|
+
this.gobbleSpaces();
|
|
652
|
+
ch = this.code;
|
|
653
|
+
if (ch !== Jsep.CBRACK_CODE) {
|
|
654
|
+
this.throwError('Unclosed [');
|
|
655
|
+
}
|
|
656
|
+
this.index++;
|
|
657
|
+
} else if (ch === Jsep.OPAREN_CODE) {
|
|
658
|
+
// A function call is being made; gobble all the arguments
|
|
659
|
+
node = {
|
|
660
|
+
type: Jsep.CALL_EXP,
|
|
661
|
+
'arguments': this.gobbleArguments(Jsep.CPAREN_CODE),
|
|
662
|
+
callee: node
|
|
663
|
+
};
|
|
664
|
+
} else if (ch === Jsep.PERIOD_CODE || optional) {
|
|
665
|
+
if (optional) {
|
|
666
|
+
this.index--;
|
|
667
|
+
}
|
|
668
|
+
this.gobbleSpaces();
|
|
669
|
+
node = {
|
|
670
|
+
type: Jsep.MEMBER_EXP,
|
|
671
|
+
computed: false,
|
|
672
|
+
object: node,
|
|
673
|
+
property: this.gobbleIdentifier()
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
if (optional) {
|
|
677
|
+
node.optional = true;
|
|
678
|
+
} // else leave undefined for compatibility with esprima
|
|
679
|
+
|
|
680
|
+
this.gobbleSpaces();
|
|
681
|
+
ch = this.code;
|
|
682
|
+
}
|
|
683
|
+
return node;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
/**
|
|
687
|
+
* Parse simple numeric literals: `12`, `3.4`, `.5`. Do this by using a string to
|
|
688
|
+
* keep track of everything in the numeric literal and then calling `parseFloat` on that string
|
|
689
|
+
* @returns {jsep.Literal}
|
|
690
|
+
*/
|
|
691
|
+
gobbleNumericLiteral() {
|
|
692
|
+
let number = '',
|
|
693
|
+
ch,
|
|
694
|
+
chCode;
|
|
695
|
+
while (Jsep.isDecimalDigit(this.code)) {
|
|
696
|
+
number += this.expr.charAt(this.index++);
|
|
697
|
+
}
|
|
698
|
+
if (this.code === Jsep.PERIOD_CODE) {
|
|
699
|
+
// can start with a decimal marker
|
|
700
|
+
number += this.expr.charAt(this.index++);
|
|
701
|
+
while (Jsep.isDecimalDigit(this.code)) {
|
|
702
|
+
number += this.expr.charAt(this.index++);
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
ch = this.char;
|
|
706
|
+
if (ch === 'e' || ch === 'E') {
|
|
707
|
+
// exponent marker
|
|
708
|
+
number += this.expr.charAt(this.index++);
|
|
709
|
+
ch = this.char;
|
|
710
|
+
if (ch === '+' || ch === '-') {
|
|
711
|
+
// exponent sign
|
|
712
|
+
number += this.expr.charAt(this.index++);
|
|
713
|
+
}
|
|
714
|
+
while (Jsep.isDecimalDigit(this.code)) {
|
|
715
|
+
// exponent itself
|
|
716
|
+
number += this.expr.charAt(this.index++);
|
|
717
|
+
}
|
|
718
|
+
if (!Jsep.isDecimalDigit(this.expr.charCodeAt(this.index - 1))) {
|
|
719
|
+
this.throwError('Expected exponent (' + number + this.char + ')');
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
chCode = this.code;
|
|
723
|
+
|
|
724
|
+
// Check to make sure this isn't a variable name that start with a number (123abc)
|
|
725
|
+
if (Jsep.isIdentifierStart(chCode)) {
|
|
726
|
+
this.throwError('Variable names cannot start with a number (' + number + this.char + ')');
|
|
727
|
+
} else if (chCode === Jsep.PERIOD_CODE || number.length === 1 && number.charCodeAt(0) === Jsep.PERIOD_CODE) {
|
|
728
|
+
this.throwError('Unexpected period');
|
|
729
|
+
}
|
|
730
|
+
return {
|
|
731
|
+
type: Jsep.LITERAL,
|
|
732
|
+
value: parseFloat(number),
|
|
733
|
+
raw: number
|
|
734
|
+
};
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
/**
|
|
738
|
+
* Parses a string literal, staring with single or double quotes with basic support for escape codes
|
|
739
|
+
* e.g. `"hello world"`, `'this is\nJSEP'`
|
|
740
|
+
* @returns {jsep.Literal}
|
|
741
|
+
*/
|
|
742
|
+
gobbleStringLiteral() {
|
|
743
|
+
let str = '';
|
|
744
|
+
const startIndex = this.index;
|
|
745
|
+
const quote = this.expr.charAt(this.index++);
|
|
746
|
+
let closed = false;
|
|
747
|
+
while (this.index < this.expr.length) {
|
|
748
|
+
let ch = this.expr.charAt(this.index++);
|
|
749
|
+
if (ch === quote) {
|
|
750
|
+
closed = true;
|
|
751
|
+
break;
|
|
752
|
+
} else if (ch === '\\') {
|
|
753
|
+
// Check for all of the common escape codes
|
|
754
|
+
ch = this.expr.charAt(this.index++);
|
|
755
|
+
switch (ch) {
|
|
756
|
+
case 'n':
|
|
757
|
+
str += '\n';
|
|
758
|
+
break;
|
|
759
|
+
case 'r':
|
|
760
|
+
str += '\r';
|
|
761
|
+
break;
|
|
762
|
+
case 't':
|
|
763
|
+
str += '\t';
|
|
764
|
+
break;
|
|
765
|
+
case 'b':
|
|
766
|
+
str += '\b';
|
|
767
|
+
break;
|
|
768
|
+
case 'f':
|
|
769
|
+
str += '\f';
|
|
770
|
+
break;
|
|
771
|
+
case 'v':
|
|
772
|
+
str += '\x0B';
|
|
773
|
+
break;
|
|
774
|
+
default:
|
|
775
|
+
str += ch;
|
|
776
|
+
}
|
|
777
|
+
} else {
|
|
778
|
+
str += ch;
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
if (!closed) {
|
|
782
|
+
this.throwError('Unclosed quote after "' + str + '"');
|
|
783
|
+
}
|
|
784
|
+
return {
|
|
785
|
+
type: Jsep.LITERAL,
|
|
786
|
+
value: str,
|
|
787
|
+
raw: this.expr.substring(startIndex, this.index)
|
|
788
|
+
};
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
/**
|
|
792
|
+
* Gobbles only identifiers
|
|
793
|
+
* e.g.: `foo`, `_value`, `$x1`
|
|
794
|
+
* Also, this function checks if that identifier is a literal:
|
|
795
|
+
* (e.g. `true`, `false`, `null`) or `this`
|
|
796
|
+
* @returns {jsep.Identifier}
|
|
797
|
+
*/
|
|
798
|
+
gobbleIdentifier() {
|
|
799
|
+
let ch = this.code,
|
|
800
|
+
start = this.index;
|
|
801
|
+
if (Jsep.isIdentifierStart(ch)) {
|
|
802
|
+
this.index++;
|
|
803
|
+
} else {
|
|
804
|
+
this.throwError('Unexpected ' + this.char);
|
|
805
|
+
}
|
|
806
|
+
while (this.index < this.expr.length) {
|
|
807
|
+
ch = this.code;
|
|
808
|
+
if (Jsep.isIdentifierPart(ch)) {
|
|
809
|
+
this.index++;
|
|
810
|
+
} else {
|
|
811
|
+
break;
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
return {
|
|
815
|
+
type: Jsep.IDENTIFIER,
|
|
816
|
+
name: this.expr.slice(start, this.index)
|
|
817
|
+
};
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
/**
|
|
821
|
+
* Gobbles a list of arguments within the context of a function call
|
|
822
|
+
* or array literal. This function also assumes that the opening character
|
|
823
|
+
* `(` or `[` has already been gobbled, and gobbles expressions and commas
|
|
824
|
+
* until the terminator character `)` or `]` is encountered.
|
|
825
|
+
* e.g. `foo(bar, baz)`, `my_func()`, or `[bar, baz]`
|
|
826
|
+
* @param {number} termination
|
|
827
|
+
* @returns {jsep.Expression[]}
|
|
828
|
+
*/
|
|
829
|
+
gobbleArguments(termination) {
|
|
830
|
+
const args = [];
|
|
831
|
+
let closed = false;
|
|
832
|
+
let separator_count = 0;
|
|
833
|
+
while (this.index < this.expr.length) {
|
|
834
|
+
this.gobbleSpaces();
|
|
835
|
+
let ch_i = this.code;
|
|
836
|
+
if (ch_i === termination) {
|
|
837
|
+
// done parsing
|
|
838
|
+
closed = true;
|
|
839
|
+
this.index++;
|
|
840
|
+
if (termination === Jsep.CPAREN_CODE && separator_count && separator_count >= args.length) {
|
|
841
|
+
this.throwError('Unexpected token ' + String.fromCharCode(termination));
|
|
842
|
+
}
|
|
843
|
+
break;
|
|
844
|
+
} else if (ch_i === Jsep.COMMA_CODE) {
|
|
845
|
+
// between expressions
|
|
846
|
+
this.index++;
|
|
847
|
+
separator_count++;
|
|
848
|
+
if (separator_count !== args.length) {
|
|
849
|
+
// missing argument
|
|
850
|
+
if (termination === Jsep.CPAREN_CODE) {
|
|
851
|
+
this.throwError('Unexpected token ,');
|
|
852
|
+
} else if (termination === Jsep.CBRACK_CODE) {
|
|
853
|
+
for (let arg = args.length; arg < separator_count; arg++) {
|
|
854
|
+
args.push(null);
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
} else if (args.length !== separator_count && separator_count !== 0) {
|
|
859
|
+
// NOTE: `&& separator_count !== 0` allows for either all commas, or all spaces as arguments
|
|
860
|
+
this.throwError('Expected comma');
|
|
861
|
+
} else {
|
|
862
|
+
const node = this.gobbleExpression();
|
|
863
|
+
if (!node || node.type === Jsep.COMPOUND) {
|
|
864
|
+
this.throwError('Expected comma');
|
|
865
|
+
}
|
|
866
|
+
args.push(node);
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
if (!closed) {
|
|
870
|
+
this.throwError('Expected ' + String.fromCharCode(termination));
|
|
871
|
+
}
|
|
872
|
+
return args;
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
/**
|
|
876
|
+
* Responsible for parsing a group of things within parentheses `()`
|
|
877
|
+
* that have no identifier in front (so not a function call)
|
|
878
|
+
* This function assumes that it needs to gobble the opening parenthesis
|
|
879
|
+
* and then tries to gobble everything within that parenthesis, assuming
|
|
880
|
+
* that the next thing it should see is the close parenthesis. If not,
|
|
881
|
+
* then the expression probably doesn't have a `)`
|
|
882
|
+
* @returns {boolean|jsep.Expression}
|
|
883
|
+
*/
|
|
884
|
+
gobbleGroup() {
|
|
885
|
+
this.index++;
|
|
886
|
+
let nodes = this.gobbleExpressions(Jsep.CPAREN_CODE);
|
|
887
|
+
if (this.code === Jsep.CPAREN_CODE) {
|
|
888
|
+
this.index++;
|
|
889
|
+
if (nodes.length === 1) {
|
|
890
|
+
return nodes[0];
|
|
891
|
+
} else if (!nodes.length) {
|
|
892
|
+
return false;
|
|
893
|
+
} else {
|
|
894
|
+
return {
|
|
895
|
+
type: Jsep.SEQUENCE_EXP,
|
|
896
|
+
expressions: nodes
|
|
897
|
+
};
|
|
898
|
+
}
|
|
899
|
+
} else {
|
|
900
|
+
this.throwError('Unclosed (');
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
/**
|
|
905
|
+
* Responsible for parsing Array literals `[1, 2, 3]`
|
|
906
|
+
* This function assumes that it needs to gobble the opening bracket
|
|
907
|
+
* and then tries to gobble the expressions as arguments.
|
|
908
|
+
* @returns {jsep.ArrayExpression}
|
|
909
|
+
*/
|
|
910
|
+
gobbleArray() {
|
|
911
|
+
this.index++;
|
|
912
|
+
return {
|
|
913
|
+
type: Jsep.ARRAY_EXP,
|
|
914
|
+
elements: this.gobbleArguments(Jsep.CBRACK_CODE)
|
|
915
|
+
};
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
// Static fields:
|
|
920
|
+
const hooks = new Hooks();
|
|
921
|
+
Object.assign(Jsep, {
|
|
922
|
+
hooks,
|
|
923
|
+
plugins: new Plugins(Jsep),
|
|
924
|
+
// Node Types
|
|
925
|
+
// ----------
|
|
926
|
+
// This is the full set of types that any JSEP node can be.
|
|
927
|
+
// Store them here to save space when minified
|
|
928
|
+
COMPOUND: 'Compound',
|
|
929
|
+
SEQUENCE_EXP: 'SequenceExpression',
|
|
930
|
+
IDENTIFIER: 'Identifier',
|
|
931
|
+
MEMBER_EXP: 'MemberExpression',
|
|
932
|
+
LITERAL: 'Literal',
|
|
933
|
+
THIS_EXP: 'ThisExpression',
|
|
934
|
+
CALL_EXP: 'CallExpression',
|
|
935
|
+
UNARY_EXP: 'UnaryExpression',
|
|
936
|
+
BINARY_EXP: 'BinaryExpression',
|
|
937
|
+
ARRAY_EXP: 'ArrayExpression',
|
|
938
|
+
TAB_CODE: 9,
|
|
939
|
+
LF_CODE: 10,
|
|
940
|
+
CR_CODE: 13,
|
|
941
|
+
SPACE_CODE: 32,
|
|
942
|
+
PERIOD_CODE: 46,
|
|
943
|
+
// '.'
|
|
944
|
+
COMMA_CODE: 44,
|
|
945
|
+
// ','
|
|
946
|
+
SQUOTE_CODE: 39,
|
|
947
|
+
// single quote
|
|
948
|
+
DQUOTE_CODE: 34,
|
|
949
|
+
// double quotes
|
|
950
|
+
OPAREN_CODE: 40,
|
|
951
|
+
// (
|
|
952
|
+
CPAREN_CODE: 41,
|
|
953
|
+
// )
|
|
954
|
+
OBRACK_CODE: 91,
|
|
955
|
+
// [
|
|
956
|
+
CBRACK_CODE: 93,
|
|
957
|
+
// ]
|
|
958
|
+
QUMARK_CODE: 63,
|
|
959
|
+
// ?
|
|
960
|
+
SEMCOL_CODE: 59,
|
|
961
|
+
// ;
|
|
962
|
+
COLON_CODE: 58,
|
|
963
|
+
// :
|
|
964
|
+
|
|
965
|
+
// Operations
|
|
966
|
+
// ----------
|
|
967
|
+
// Use a quickly-accessible map to store all of the unary operators
|
|
968
|
+
// Values are set to `1` (it really doesn't matter)
|
|
969
|
+
unary_ops: {
|
|
970
|
+
'-': 1,
|
|
971
|
+
'!': 1,
|
|
972
|
+
'~': 1,
|
|
973
|
+
'+': 1
|
|
974
|
+
},
|
|
975
|
+
// Also use a map for the binary operations but set their values to their
|
|
976
|
+
// binary precedence for quick reference (higher number = higher precedence)
|
|
977
|
+
// see [Order of operations](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence)
|
|
978
|
+
binary_ops: {
|
|
979
|
+
'||': 1,
|
|
980
|
+
'??': 1,
|
|
981
|
+
'&&': 2,
|
|
982
|
+
'|': 3,
|
|
983
|
+
'^': 4,
|
|
984
|
+
'&': 5,
|
|
985
|
+
'==': 6,
|
|
986
|
+
'!=': 6,
|
|
987
|
+
'===': 6,
|
|
988
|
+
'!==': 6,
|
|
989
|
+
'<': 7,
|
|
990
|
+
'>': 7,
|
|
991
|
+
'<=': 7,
|
|
992
|
+
'>=': 7,
|
|
993
|
+
'<<': 8,
|
|
994
|
+
'>>': 8,
|
|
995
|
+
'>>>': 8,
|
|
996
|
+
'+': 9,
|
|
997
|
+
'-': 9,
|
|
998
|
+
'*': 10,
|
|
999
|
+
'/': 10,
|
|
1000
|
+
'%': 10,
|
|
1001
|
+
'**': 11
|
|
1002
|
+
},
|
|
1003
|
+
// sets specific binary_ops as right-associative
|
|
1004
|
+
right_associative: new Set(['**']),
|
|
1005
|
+
// Additional valid identifier chars, apart from a-z, A-Z and 0-9 (except on the starting char)
|
|
1006
|
+
additional_identifier_chars: new Set(['$', '_']),
|
|
1007
|
+
// Literals
|
|
1008
|
+
// ----------
|
|
1009
|
+
// Store the values to return for the various literals we may encounter
|
|
1010
|
+
literals: {
|
|
1011
|
+
'true': true,
|
|
1012
|
+
'false': false,
|
|
1013
|
+
'null': null
|
|
1014
|
+
},
|
|
1015
|
+
// Except for `this`, which is special. This could be changed to something like `'self'` as well
|
|
1016
|
+
this_str: 'this'
|
|
1017
|
+
});
|
|
1018
|
+
Jsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);
|
|
1019
|
+
Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);
|
|
1020
|
+
|
|
1021
|
+
// Backward Compatibility:
|
|
1022
|
+
const jsep = expr => new Jsep(expr).parse();
|
|
1023
|
+
const stdClassProps = Object.getOwnPropertyNames(class Test {});
|
|
1024
|
+
Object.getOwnPropertyNames(Jsep).filter(prop => !stdClassProps.includes(prop) && jsep[prop] === undefined).forEach(m => {
|
|
1025
|
+
jsep[m] = Jsep[m];
|
|
1026
|
+
});
|
|
1027
|
+
jsep.Jsep = Jsep; // allows for const { Jsep } = require('jsep');
|
|
1028
|
+
|
|
1029
|
+
const CONDITIONAL_EXP = 'ConditionalExpression';
|
|
1030
|
+
var ternary = {
|
|
1031
|
+
name: 'ternary',
|
|
1032
|
+
init(jsep) {
|
|
1033
|
+
// Ternary expression: test ? consequent : alternate
|
|
1034
|
+
jsep.hooks.add('after-expression', function gobbleTernary(env) {
|
|
1035
|
+
if (env.node && this.code === jsep.QUMARK_CODE) {
|
|
1036
|
+
this.index++;
|
|
1037
|
+
const test = env.node;
|
|
1038
|
+
const consequent = this.gobbleExpression();
|
|
1039
|
+
if (!consequent) {
|
|
1040
|
+
this.throwError('Expected expression');
|
|
1041
|
+
}
|
|
1042
|
+
this.gobbleSpaces();
|
|
1043
|
+
if (this.code === jsep.COLON_CODE) {
|
|
1044
|
+
this.index++;
|
|
1045
|
+
const alternate = this.gobbleExpression();
|
|
1046
|
+
if (!alternate) {
|
|
1047
|
+
this.throwError('Expected expression');
|
|
1048
|
+
}
|
|
1049
|
+
env.node = {
|
|
1050
|
+
type: CONDITIONAL_EXP,
|
|
1051
|
+
test,
|
|
1052
|
+
consequent,
|
|
1053
|
+
alternate
|
|
1054
|
+
};
|
|
1055
|
+
|
|
1056
|
+
// check for operators of higher priority than ternary (i.e. assignment)
|
|
1057
|
+
// jsep sets || at 1, and assignment at 0.9, and conditional should be between them
|
|
1058
|
+
if (test.operator && jsep.binary_ops[test.operator] <= 0.9) {
|
|
1059
|
+
let newTest = test;
|
|
1060
|
+
while (newTest.right.operator && jsep.binary_ops[newTest.right.operator] <= 0.9) {
|
|
1061
|
+
newTest = newTest.right;
|
|
1062
|
+
}
|
|
1063
|
+
env.node.test = newTest.right;
|
|
1064
|
+
newTest.right = env.node;
|
|
1065
|
+
env.node = test;
|
|
1066
|
+
}
|
|
1067
|
+
} else {
|
|
1068
|
+
this.throwError('Expected :');
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
});
|
|
1072
|
+
}
|
|
1073
|
+
};
|
|
1074
|
+
|
|
1075
|
+
// Add default plugins:
|
|
1076
|
+
|
|
1077
|
+
jsep.plugins.register(ternary);
|
|
1078
|
+
|
|
1079
|
+
const FSLASH_CODE = 47; // '/'
|
|
1080
|
+
const BSLASH_CODE = 92; // '\\'
|
|
1081
|
+
|
|
1082
|
+
var index = {
|
|
1083
|
+
name: 'regex',
|
|
1084
|
+
init(jsep) {
|
|
1085
|
+
// Regex literal: /abc123/ig
|
|
1086
|
+
jsep.hooks.add('gobble-token', function gobbleRegexLiteral(env) {
|
|
1087
|
+
if (this.code === FSLASH_CODE) {
|
|
1088
|
+
const patternIndex = ++this.index;
|
|
1089
|
+
let inCharSet = false;
|
|
1090
|
+
while (this.index < this.expr.length) {
|
|
1091
|
+
if (this.code === FSLASH_CODE && !inCharSet) {
|
|
1092
|
+
const pattern = this.expr.slice(patternIndex, this.index);
|
|
1093
|
+
let flags = '';
|
|
1094
|
+
while (++this.index < this.expr.length) {
|
|
1095
|
+
const code = this.code;
|
|
1096
|
+
if (code >= 97 && code <= 122 // a...z
|
|
1097
|
+
|| code >= 65 && code <= 90 // A...Z
|
|
1098
|
+
|| code >= 48 && code <= 57) {
|
|
1099
|
+
// 0-9
|
|
1100
|
+
flags += this.char;
|
|
1101
|
+
} else {
|
|
1102
|
+
break;
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
let value;
|
|
1106
|
+
try {
|
|
1107
|
+
value = new RegExp(pattern, flags);
|
|
1108
|
+
} catch (e) {
|
|
1109
|
+
this.throwError(e.message);
|
|
1110
|
+
}
|
|
1111
|
+
env.node = {
|
|
1112
|
+
type: jsep.LITERAL,
|
|
1113
|
+
value,
|
|
1114
|
+
raw: this.expr.slice(patternIndex - 1, this.index)
|
|
1115
|
+
};
|
|
1116
|
+
|
|
1117
|
+
// allow . [] and () after regex: /regex/.test(a)
|
|
1118
|
+
env.node = this.gobbleTokenProperty(env.node);
|
|
1119
|
+
return env.node;
|
|
1120
|
+
}
|
|
1121
|
+
if (this.code === jsep.OBRACK_CODE) {
|
|
1122
|
+
inCharSet = true;
|
|
1123
|
+
} else if (inCharSet && this.code === jsep.CBRACK_CODE) {
|
|
1124
|
+
inCharSet = false;
|
|
1125
|
+
}
|
|
1126
|
+
this.index += this.code === BSLASH_CODE ? 2 : 1;
|
|
1127
|
+
}
|
|
1128
|
+
this.throwError('Unclosed Regex');
|
|
1129
|
+
}
|
|
1130
|
+
});
|
|
1131
|
+
}
|
|
1132
|
+
};
|
|
1133
|
+
|
|
1134
|
+
const PLUS_CODE = 43; // +
|
|
1135
|
+
const MINUS_CODE = 45; // -
|
|
1136
|
+
|
|
1137
|
+
const plugin = {
|
|
1138
|
+
name: 'assignment',
|
|
1139
|
+
assignmentOperators: new Set(['=', '*=', '**=', '/=', '%=', '+=', '-=', '<<=', '>>=', '>>>=', '&=', '^=', '|=', '||=', '&&=', '??=']),
|
|
1140
|
+
updateOperators: [PLUS_CODE, MINUS_CODE],
|
|
1141
|
+
assignmentPrecedence: 0.9,
|
|
1142
|
+
init(jsep) {
|
|
1143
|
+
const updateNodeTypes = [jsep.IDENTIFIER, jsep.MEMBER_EXP];
|
|
1144
|
+
plugin.assignmentOperators.forEach(op => jsep.addBinaryOp(op, plugin.assignmentPrecedence, true));
|
|
1145
|
+
jsep.hooks.add('gobble-token', function gobbleUpdatePrefix(env) {
|
|
1146
|
+
const code = this.code;
|
|
1147
|
+
if (plugin.updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) {
|
|
1148
|
+
this.index += 2;
|
|
1149
|
+
env.node = {
|
|
1150
|
+
type: 'UpdateExpression',
|
|
1151
|
+
operator: code === PLUS_CODE ? '++' : '--',
|
|
1152
|
+
argument: this.gobbleTokenProperty(this.gobbleIdentifier()),
|
|
1153
|
+
prefix: true
|
|
1154
|
+
};
|
|
1155
|
+
if (!env.node.argument || !updateNodeTypes.includes(env.node.argument.type)) {
|
|
1156
|
+
this.throwError(`Unexpected ${env.node.operator}`);
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
});
|
|
1160
|
+
jsep.hooks.add('after-token', function gobbleUpdatePostfix(env) {
|
|
1161
|
+
if (env.node) {
|
|
1162
|
+
const code = this.code;
|
|
1163
|
+
if (plugin.updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) {
|
|
1164
|
+
if (!updateNodeTypes.includes(env.node.type)) {
|
|
1165
|
+
this.throwError(`Unexpected ${env.node.operator}`);
|
|
1166
|
+
}
|
|
1167
|
+
this.index += 2;
|
|
1168
|
+
env.node = {
|
|
1169
|
+
type: 'UpdateExpression',
|
|
1170
|
+
operator: code === PLUS_CODE ? '++' : '--',
|
|
1171
|
+
argument: env.node,
|
|
1172
|
+
prefix: false
|
|
1173
|
+
};
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
});
|
|
1177
|
+
jsep.hooks.add('after-expression', function gobbleAssignment(env) {
|
|
1178
|
+
if (env.node) {
|
|
1179
|
+
// Note: Binaries can be chained in a single expression to respect
|
|
1180
|
+
// operator precedence (i.e. a = b = 1 + 2 + 3)
|
|
1181
|
+
// Update all binary assignment nodes in the tree
|
|
1182
|
+
updateBinariesToAssignments(env.node);
|
|
1183
|
+
}
|
|
1184
|
+
});
|
|
1185
|
+
function updateBinariesToAssignments(node) {
|
|
1186
|
+
if (plugin.assignmentOperators.has(node.operator)) {
|
|
1187
|
+
node.type = 'AssignmentExpression';
|
|
1188
|
+
updateBinariesToAssignments(node.left);
|
|
1189
|
+
updateBinariesToAssignments(node.right);
|
|
1190
|
+
} else if (!node.operator) {
|
|
1191
|
+
Object.values(node).forEach(val => {
|
|
1192
|
+
if (val && typeof val === 'object') {
|
|
1193
|
+
updateBinariesToAssignments(val);
|
|
1194
|
+
}
|
|
1195
|
+
});
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
};
|
|
1200
|
+
|
|
1201
|
+
/* eslint-disable no-bitwise -- Convenient */
|
|
1202
|
+
|
|
1203
|
+
// register plugins
|
|
1204
|
+
jsep.plugins.register(index, plugin);
|
|
1205
|
+
jsep.addUnaryOp('typeof');
|
|
1206
|
+
jsep.addUnaryOp('void');
|
|
1207
|
+
jsep.addLiteral('null', null);
|
|
1208
|
+
jsep.addLiteral('undefined', undefined);
|
|
1209
|
+
const BLOCKED_PROTO_PROPERTIES = new Set(['constructor', '__proto__', '__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__']);
|
|
1210
|
+
const SafeEval = {
|
|
1211
|
+
/**
|
|
1212
|
+
* @param {jsep.Expression} ast
|
|
1213
|
+
* @param {Record<string, any>} subs
|
|
1214
|
+
*/
|
|
1215
|
+
evalAst(ast, subs) {
|
|
1216
|
+
switch (ast.type) {
|
|
1217
|
+
case 'BinaryExpression':
|
|
1218
|
+
case 'LogicalExpression':
|
|
1219
|
+
return SafeEval.evalBinaryExpression(ast, subs);
|
|
1220
|
+
case 'Compound':
|
|
1221
|
+
return SafeEval.evalCompound(ast, subs);
|
|
1222
|
+
case 'ConditionalExpression':
|
|
1223
|
+
return SafeEval.evalConditionalExpression(ast, subs);
|
|
1224
|
+
case 'Identifier':
|
|
1225
|
+
return SafeEval.evalIdentifier(ast, subs);
|
|
1226
|
+
case 'Literal':
|
|
1227
|
+
return SafeEval.evalLiteral(ast, subs);
|
|
1228
|
+
case 'MemberExpression':
|
|
1229
|
+
return SafeEval.evalMemberExpression(ast, subs);
|
|
1230
|
+
case 'UnaryExpression':
|
|
1231
|
+
return SafeEval.evalUnaryExpression(ast, subs);
|
|
1232
|
+
case 'ArrayExpression':
|
|
1233
|
+
return SafeEval.evalArrayExpression(ast, subs);
|
|
1234
|
+
case 'CallExpression':
|
|
1235
|
+
return SafeEval.evalCallExpression(ast, subs);
|
|
1236
|
+
case 'AssignmentExpression':
|
|
1237
|
+
return SafeEval.evalAssignmentExpression(ast, subs);
|
|
1238
|
+
default:
|
|
1239
|
+
throw SyntaxError('Unexpected expression', ast);
|
|
1240
|
+
}
|
|
1241
|
+
},
|
|
1242
|
+
evalBinaryExpression(ast, subs) {
|
|
1243
|
+
const result = {
|
|
1244
|
+
'||': (a, b) => a || b(),
|
|
1245
|
+
'&&': (a, b) => a && b(),
|
|
1246
|
+
'|': (a, b) => a | b(),
|
|
1247
|
+
'^': (a, b) => a ^ b(),
|
|
1248
|
+
'&': (a, b) => a & b(),
|
|
1249
|
+
// eslint-disable-next-line eqeqeq -- API
|
|
1250
|
+
'==': (a, b) => a == b(),
|
|
1251
|
+
// eslint-disable-next-line eqeqeq -- API
|
|
1252
|
+
'!=': (a, b) => a != b(),
|
|
1253
|
+
'===': (a, b) => a === b(),
|
|
1254
|
+
'!==': (a, b) => a !== b(),
|
|
1255
|
+
'<': (a, b) => a < b(),
|
|
1256
|
+
'>': (a, b) => a > b(),
|
|
1257
|
+
'<=': (a, b) => a <= b(),
|
|
1258
|
+
'>=': (a, b) => a >= b(),
|
|
1259
|
+
'<<': (a, b) => a << b(),
|
|
1260
|
+
'>>': (a, b) => a >> b(),
|
|
1261
|
+
'>>>': (a, b) => a >>> b(),
|
|
1262
|
+
'+': (a, b) => a + b(),
|
|
1263
|
+
'-': (a, b) => a - b(),
|
|
1264
|
+
'*': (a, b) => a * b(),
|
|
1265
|
+
'/': (a, b) => a / b(),
|
|
1266
|
+
'%': (a, b) => a % b()
|
|
1267
|
+
}[ast.operator](SafeEval.evalAst(ast.left, subs), () => SafeEval.evalAst(ast.right, subs));
|
|
1268
|
+
return result;
|
|
1269
|
+
},
|
|
1270
|
+
evalCompound(ast, subs) {
|
|
1271
|
+
let last;
|
|
1272
|
+
for (let i = 0; i < ast.body.length; i++) {
|
|
1273
|
+
if (ast.body[i].type === 'Identifier' && ['var', 'let', 'const'].includes(ast.body[i].name) && ast.body[i + 1] && ast.body[i + 1].type === 'AssignmentExpression') {
|
|
1274
|
+
// var x=2; is detected as
|
|
1275
|
+
// [{Identifier var}, {AssignmentExpression x=2}]
|
|
1276
|
+
// eslint-disable-next-line @stylistic/max-len -- Long
|
|
1277
|
+
// eslint-disable-next-line sonarjs/updated-loop-counter -- Convenient
|
|
1278
|
+
i += 1;
|
|
1279
|
+
}
|
|
1280
|
+
const expr = ast.body[i];
|
|
1281
|
+
last = SafeEval.evalAst(expr, subs);
|
|
1282
|
+
}
|
|
1283
|
+
return last;
|
|
1284
|
+
},
|
|
1285
|
+
evalConditionalExpression(ast, subs) {
|
|
1286
|
+
if (SafeEval.evalAst(ast.test, subs)) {
|
|
1287
|
+
return SafeEval.evalAst(ast.consequent, subs);
|
|
1288
|
+
}
|
|
1289
|
+
return SafeEval.evalAst(ast.alternate, subs);
|
|
1290
|
+
},
|
|
1291
|
+
evalIdentifier(ast, subs) {
|
|
1292
|
+
if (Object.hasOwn(subs, ast.name)) {
|
|
1293
|
+
return subs[ast.name];
|
|
1294
|
+
}
|
|
1295
|
+
throw ReferenceError(`${ast.name} is not defined`);
|
|
1296
|
+
},
|
|
1297
|
+
evalLiteral(ast) {
|
|
1298
|
+
return ast.value;
|
|
1299
|
+
},
|
|
1300
|
+
evalMemberExpression(ast, subs) {
|
|
1301
|
+
const prop = String(
|
|
1302
|
+
// NOTE: `String(value)` throws error when
|
|
1303
|
+
// value has overwritten the toString method to return non-string
|
|
1304
|
+
// i.e. `value = {toString: () => []}`
|
|
1305
|
+
ast.computed ? SafeEval.evalAst(ast.property) // `object[property]`
|
|
1306
|
+
: ast.property.name // `object.property` property is Identifier
|
|
1307
|
+
);
|
|
1308
|
+
const obj = SafeEval.evalAst(ast.object, subs);
|
|
1309
|
+
if (obj === undefined || obj === null) {
|
|
1310
|
+
throw TypeError(`Cannot read properties of ${obj} (reading '${prop}')`);
|
|
1311
|
+
}
|
|
1312
|
+
if (!Object.hasOwn(obj, prop) && BLOCKED_PROTO_PROPERTIES.has(prop)) {
|
|
1313
|
+
throw TypeError(`Cannot read properties of ${obj} (reading '${prop}')`);
|
|
1314
|
+
}
|
|
1315
|
+
const result = obj[prop];
|
|
1316
|
+
if (typeof result === 'function') {
|
|
1317
|
+
return result.bind(obj); // arrow functions aren't affected by bind.
|
|
1318
|
+
}
|
|
1319
|
+
return result;
|
|
1320
|
+
},
|
|
1321
|
+
evalUnaryExpression(ast, subs) {
|
|
1322
|
+
const result = {
|
|
1323
|
+
'-': a => -SafeEval.evalAst(a, subs),
|
|
1324
|
+
'!': a => !SafeEval.evalAst(a, subs),
|
|
1325
|
+
'~': a => ~SafeEval.evalAst(a, subs),
|
|
1326
|
+
// eslint-disable-next-line no-implicit-coercion -- API
|
|
1327
|
+
'+': a => +SafeEval.evalAst(a, subs),
|
|
1328
|
+
typeof: a => typeof SafeEval.evalAst(a, subs),
|
|
1329
|
+
// eslint-disable-next-line no-void, sonarjs/void-use -- feature
|
|
1330
|
+
void: a => void SafeEval.evalAst(a, subs)
|
|
1331
|
+
}[ast.operator](ast.argument);
|
|
1332
|
+
return result;
|
|
1333
|
+
},
|
|
1334
|
+
evalArrayExpression(ast, subs) {
|
|
1335
|
+
return ast.elements.map(el => SafeEval.evalAst(el, subs));
|
|
1336
|
+
},
|
|
1337
|
+
evalCallExpression(ast, subs) {
|
|
1338
|
+
const args = ast.arguments.map(arg => SafeEval.evalAst(arg, subs));
|
|
1339
|
+
const func = SafeEval.evalAst(ast.callee, subs);
|
|
1340
|
+
/* c8 ignore start */
|
|
1341
|
+
if (func === Function) {
|
|
1342
|
+
// unreachable since BLOCKED_PROTO_PROPERTIES includes 'constructor'
|
|
1343
|
+
throw new Error('Function constructor is disabled');
|
|
1344
|
+
}
|
|
1345
|
+
/* c8 ignore end */
|
|
1346
|
+
return func(...args);
|
|
1347
|
+
},
|
|
1348
|
+
evalAssignmentExpression(ast, subs) {
|
|
1349
|
+
if (ast.left.type !== 'Identifier') {
|
|
1350
|
+
throw SyntaxError('Invalid left-hand side in assignment');
|
|
1351
|
+
}
|
|
1352
|
+
const id = ast.left.name;
|
|
1353
|
+
const value = SafeEval.evalAst(ast.right, subs);
|
|
1354
|
+
subs[id] = value;
|
|
1355
|
+
return subs[id];
|
|
1356
|
+
}
|
|
1357
|
+
};
|
|
1358
|
+
|
|
1359
|
+
/**
|
|
1360
|
+
* A replacement for NodeJS' VM.Script which is also {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP | Content Security Policy} friendly.
|
|
1361
|
+
*/
|
|
1362
|
+
class SafeScript {
|
|
1363
|
+
/**
|
|
1364
|
+
* @param {string} expr Expression to evaluate
|
|
1365
|
+
*/
|
|
1366
|
+
constructor(expr) {
|
|
1367
|
+
this.code = expr;
|
|
1368
|
+
this.ast = jsep(this.code);
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
/**
|
|
1372
|
+
* @param {object} context Object whose items will be added
|
|
1373
|
+
* to evaluation
|
|
1374
|
+
* @returns {EvaluatedResult} Result of evaluated code
|
|
1375
|
+
*/
|
|
1376
|
+
runInNewContext(context) {
|
|
1377
|
+
// `Object.create(null)` creates a prototypeless object
|
|
1378
|
+
const keyMap = Object.assign(Object.create(null), context);
|
|
1379
|
+
return SafeEval.evalAst(this.ast, keyMap);
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
/* eslint-disable camelcase -- Convenient for escaping */
|
|
1384
|
+
|
|
1385
|
+
|
|
1386
|
+
/**
|
|
1387
|
+
* @typedef {null|boolean|number|string|object|GenericArray} JSONObject
|
|
1388
|
+
*/
|
|
1389
|
+
|
|
1390
|
+
/**
|
|
1391
|
+
* @typedef {any} AnyItem
|
|
1392
|
+
*/
|
|
1393
|
+
|
|
1394
|
+
/**
|
|
1395
|
+
* @typedef {any} AnyResult
|
|
1396
|
+
*/
|
|
1397
|
+
|
|
1398
|
+
/**
|
|
1399
|
+
* Copies array and then pushes item into it.
|
|
1400
|
+
* @param {GenericArray} arr Array to copy and into which to push
|
|
1401
|
+
* @param {AnyItem} item Array item to add (to end)
|
|
1402
|
+
* @returns {GenericArray} Copy of the original array
|
|
1403
|
+
*/
|
|
1404
|
+
function push(arr, item) {
|
|
1405
|
+
arr = arr.slice();
|
|
1406
|
+
arr.push(item);
|
|
1407
|
+
return arr;
|
|
1408
|
+
}
|
|
1409
|
+
/**
|
|
1410
|
+
* Copies array and then unshifts item into it.
|
|
1411
|
+
* @param {AnyItem} item Array item to add (to beginning)
|
|
1412
|
+
* @param {GenericArray} arr Array to copy and into which to unshift
|
|
1413
|
+
* @returns {GenericArray} Copy of the original array
|
|
1414
|
+
*/
|
|
1415
|
+
function unshift(item, arr) {
|
|
1416
|
+
arr = arr.slice();
|
|
1417
|
+
arr.unshift(item);
|
|
1418
|
+
return arr;
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
/**
|
|
1422
|
+
* Caught when JSONPath is used without `new` but rethrown if with `new`
|
|
1423
|
+
* @extends Error
|
|
1424
|
+
*/
|
|
1425
|
+
class NewError extends Error {
|
|
1426
|
+
/**
|
|
1427
|
+
* @param {AnyResult} value The evaluated scalar value
|
|
1428
|
+
*/
|
|
1429
|
+
constructor(value) {
|
|
1430
|
+
super('JSONPath should not be called with "new" (it prevents return ' + 'of (unwrapped) scalar values)');
|
|
1431
|
+
this.avoidNew = true;
|
|
1432
|
+
this.value = value;
|
|
1433
|
+
this.name = 'NewError';
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
/**
|
|
1438
|
+
* @typedef {object} ReturnObject
|
|
1439
|
+
* @property {string} path
|
|
1440
|
+
* @property {JSONObject} value
|
|
1441
|
+
* @property {object|GenericArray} parent
|
|
1442
|
+
* @property {string} parentProperty
|
|
1443
|
+
*/
|
|
1444
|
+
|
|
1445
|
+
/**
|
|
1446
|
+
* @callback JSONPathCallback
|
|
1447
|
+
* @param {string|object} preferredOutput
|
|
1448
|
+
* @param {"value"|"property"} type
|
|
1449
|
+
* @param {ReturnObject} fullRetObj
|
|
1450
|
+
* @returns {void}
|
|
1451
|
+
*/
|
|
1452
|
+
|
|
1453
|
+
/**
|
|
1454
|
+
* @callback OtherTypeCallback
|
|
1455
|
+
* @param {JSONObject} val
|
|
1456
|
+
* @param {string} path
|
|
1457
|
+
* @param {object|GenericArray} parent
|
|
1458
|
+
* @param {string} parentPropName
|
|
1459
|
+
* @returns {boolean}
|
|
1460
|
+
*/
|
|
1461
|
+
|
|
1462
|
+
/**
|
|
1463
|
+
* @typedef {any} ContextItem
|
|
1464
|
+
*/
|
|
1465
|
+
|
|
1466
|
+
/**
|
|
1467
|
+
* @typedef {any} EvaluatedResult
|
|
1468
|
+
*/
|
|
1469
|
+
|
|
1470
|
+
/**
|
|
1471
|
+
* @callback EvalCallback
|
|
1472
|
+
* @param {string} code
|
|
1473
|
+
* @param {ContextItem} context
|
|
1474
|
+
* @returns {EvaluatedResult}
|
|
1475
|
+
*/
|
|
1476
|
+
|
|
1477
|
+
/**
|
|
1478
|
+
* @typedef {typeof SafeScript} EvalClass
|
|
1479
|
+
*/
|
|
1480
|
+
|
|
1481
|
+
/**
|
|
1482
|
+
* @typedef {object} JSONPathOptions
|
|
1483
|
+
* @property {JSON} json
|
|
1484
|
+
* @property {string|string[]} path
|
|
1485
|
+
* @property {"value"|"path"|"pointer"|"parent"|"parentProperty"|
|
|
1486
|
+
* "all"} [resultType="value"]
|
|
1487
|
+
* @property {boolean} [flatten=false]
|
|
1488
|
+
* @property {boolean} [wrap=true]
|
|
1489
|
+
* @property {object} [sandbox={}]
|
|
1490
|
+
* @property {EvalCallback|EvalClass|'safe'|'native'|
|
|
1491
|
+
* boolean} [eval = 'safe']
|
|
1492
|
+
* @property {object|GenericArray|null} [parent=null]
|
|
1493
|
+
* @property {string|null} [parentProperty=null]
|
|
1494
|
+
* @property {JSONPathCallback} [callback]
|
|
1495
|
+
* @property {OtherTypeCallback} [otherTypeCallback] Defaults to
|
|
1496
|
+
* function which throws on encountering `@other`
|
|
1497
|
+
* @property {boolean} [autostart=true]
|
|
1498
|
+
*/
|
|
1499
|
+
|
|
1500
|
+
/**
|
|
1501
|
+
* @param {string|JSONPathOptions} opts If a string, will be treated as `expr`
|
|
1502
|
+
* @param {string} [expr] JSON path to evaluate
|
|
1503
|
+
* @param {JSON} [obj] JSON object to evaluate against
|
|
1504
|
+
* @param {JSONPathCallback} [callback] Passed 3 arguments: 1) desired payload
|
|
1505
|
+
* per `resultType`, 2) `"value"|"property"`, 3) Full returned object with
|
|
1506
|
+
* all payloads
|
|
1507
|
+
* @param {OtherTypeCallback} [otherTypeCallback] If `@other()` is at the end
|
|
1508
|
+
* of one's query, this will be invoked with the value of the item, its
|
|
1509
|
+
* path, its parent, and its parent's property name, and it should return
|
|
1510
|
+
* a boolean indicating whether the supplied value belongs to the "other"
|
|
1511
|
+
* type or not (or it may handle transformations and return `false`).
|
|
1512
|
+
* @returns {JSONPath}
|
|
1513
|
+
* @class
|
|
1514
|
+
*/
|
|
1515
|
+
function JSONPath(opts, expr, obj, callback, otherTypeCallback) {
|
|
1516
|
+
// eslint-disable-next-line no-restricted-syntax -- Allow for pseudo-class
|
|
1517
|
+
if (!(this instanceof JSONPath)) {
|
|
1518
|
+
try {
|
|
1519
|
+
return new JSONPath(opts, expr, obj, callback, otherTypeCallback);
|
|
1520
|
+
} catch (e) {
|
|
1521
|
+
if (!e.avoidNew) {
|
|
1522
|
+
throw e;
|
|
1523
|
+
}
|
|
1524
|
+
return e.value;
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
if (typeof opts === 'string') {
|
|
1528
|
+
otherTypeCallback = callback;
|
|
1529
|
+
callback = obj;
|
|
1530
|
+
obj = expr;
|
|
1531
|
+
expr = opts;
|
|
1532
|
+
opts = null;
|
|
1533
|
+
}
|
|
1534
|
+
const optObj = opts && typeof opts === 'object';
|
|
1535
|
+
opts = opts || {};
|
|
1536
|
+
this.json = opts.json || obj;
|
|
1537
|
+
this.path = opts.path || expr;
|
|
1538
|
+
this.resultType = opts.resultType || 'value';
|
|
1539
|
+
this.flatten = opts.flatten || false;
|
|
1540
|
+
this.wrap = Object.hasOwn(opts, 'wrap') ? opts.wrap : true;
|
|
1541
|
+
this.sandbox = opts.sandbox || {};
|
|
1542
|
+
this.eval = opts.eval === undefined ? 'safe' : opts.eval;
|
|
1543
|
+
this.ignoreEvalErrors = typeof opts.ignoreEvalErrors === 'undefined' ? false : opts.ignoreEvalErrors;
|
|
1544
|
+
this.parent = opts.parent || null;
|
|
1545
|
+
this.parentProperty = opts.parentProperty || null;
|
|
1546
|
+
this.callback = opts.callback || callback || null;
|
|
1547
|
+
this.otherTypeCallback = opts.otherTypeCallback || otherTypeCallback || function () {
|
|
1548
|
+
throw new TypeError('You must supply an otherTypeCallback callback option ' + 'with the @other() operator.');
|
|
1549
|
+
};
|
|
1550
|
+
if (opts.autostart !== false) {
|
|
1551
|
+
const args = {
|
|
1552
|
+
path: optObj ? opts.path : expr
|
|
1553
|
+
};
|
|
1554
|
+
if (!optObj) {
|
|
1555
|
+
args.json = obj;
|
|
1556
|
+
} else if ('json' in opts) {
|
|
1557
|
+
args.json = opts.json;
|
|
1558
|
+
}
|
|
1559
|
+
const ret = this.evaluate(args);
|
|
1560
|
+
if (!ret || typeof ret !== 'object') {
|
|
1561
|
+
throw new NewError(ret);
|
|
1562
|
+
}
|
|
1563
|
+
return ret;
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
// PUBLIC METHODS
|
|
1568
|
+
JSONPath.prototype.evaluate = function (expr, json, callback, otherTypeCallback) {
|
|
1569
|
+
let currParent = this.parent,
|
|
1570
|
+
currParentProperty = this.parentProperty;
|
|
1571
|
+
let {
|
|
1572
|
+
flatten,
|
|
1573
|
+
wrap
|
|
1574
|
+
} = this;
|
|
1575
|
+
this.currResultType = this.resultType;
|
|
1576
|
+
this.currEval = this.eval;
|
|
1577
|
+
this.currSandbox = this.sandbox;
|
|
1578
|
+
callback = callback || this.callback;
|
|
1579
|
+
this.currOtherTypeCallback = otherTypeCallback || this.otherTypeCallback;
|
|
1580
|
+
json = json || this.json;
|
|
1581
|
+
expr = expr || this.path;
|
|
1582
|
+
if (expr && typeof expr === 'object' && !Array.isArray(expr)) {
|
|
1583
|
+
if (!expr.path && expr.path !== '') {
|
|
1584
|
+
throw new TypeError('You must supply a "path" property when providing an object ' + 'argument to JSONPath.evaluate().');
|
|
1585
|
+
}
|
|
1586
|
+
if (!Object.hasOwn(expr, 'json')) {
|
|
1587
|
+
throw new TypeError('You must supply a "json" property when providing an object ' + 'argument to JSONPath.evaluate().');
|
|
1588
|
+
}
|
|
1589
|
+
({
|
|
1590
|
+
json
|
|
1591
|
+
} = expr);
|
|
1592
|
+
flatten = Object.hasOwn(expr, 'flatten') ? expr.flatten : flatten;
|
|
1593
|
+
this.currResultType = Object.hasOwn(expr, 'resultType') ? expr.resultType : this.currResultType;
|
|
1594
|
+
this.currSandbox = Object.hasOwn(expr, 'sandbox') ? expr.sandbox : this.currSandbox;
|
|
1595
|
+
wrap = Object.hasOwn(expr, 'wrap') ? expr.wrap : wrap;
|
|
1596
|
+
this.currEval = Object.hasOwn(expr, 'eval') ? expr.eval : this.currEval;
|
|
1597
|
+
callback = Object.hasOwn(expr, 'callback') ? expr.callback : callback;
|
|
1598
|
+
this.currOtherTypeCallback = Object.hasOwn(expr, 'otherTypeCallback') ? expr.otherTypeCallback : this.currOtherTypeCallback;
|
|
1599
|
+
currParent = Object.hasOwn(expr, 'parent') ? expr.parent : currParent;
|
|
1600
|
+
currParentProperty = Object.hasOwn(expr, 'parentProperty') ? expr.parentProperty : currParentProperty;
|
|
1601
|
+
expr = expr.path;
|
|
1602
|
+
}
|
|
1603
|
+
currParent = currParent || null;
|
|
1604
|
+
currParentProperty = currParentProperty || null;
|
|
1605
|
+
if (Array.isArray(expr)) {
|
|
1606
|
+
expr = JSONPath.toPathString(expr);
|
|
1607
|
+
}
|
|
1608
|
+
if (!expr && expr !== '' || !json) {
|
|
1609
|
+
return undefined;
|
|
1610
|
+
}
|
|
1611
|
+
const exprList = JSONPath.toPathArray(expr);
|
|
1612
|
+
if (exprList[0] === '$' && exprList.length > 1) {
|
|
1613
|
+
exprList.shift();
|
|
1614
|
+
}
|
|
1615
|
+
this._hasParentSelector = null;
|
|
1616
|
+
const result = this._trace(exprList, json, ['$'], currParent, currParentProperty, callback).filter(function (ea) {
|
|
1617
|
+
return ea && !ea.isParentSelector;
|
|
1618
|
+
});
|
|
1619
|
+
if (!result.length) {
|
|
1620
|
+
return wrap ? [] : undefined;
|
|
1621
|
+
}
|
|
1622
|
+
if (!wrap && result.length === 1 && !result[0].hasArrExpr) {
|
|
1623
|
+
return this._getPreferredOutput(result[0]);
|
|
1624
|
+
}
|
|
1625
|
+
return result.reduce((rslt, ea) => {
|
|
1626
|
+
const valOrPath = this._getPreferredOutput(ea);
|
|
1627
|
+
if (flatten && Array.isArray(valOrPath)) {
|
|
1628
|
+
rslt = rslt.concat(valOrPath);
|
|
1629
|
+
} else {
|
|
1630
|
+
rslt.push(valOrPath);
|
|
1631
|
+
}
|
|
1632
|
+
return rslt;
|
|
1633
|
+
}, []);
|
|
1634
|
+
};
|
|
1635
|
+
|
|
1636
|
+
// PRIVATE METHODS
|
|
1637
|
+
|
|
1638
|
+
JSONPath.prototype._getPreferredOutput = function (ea) {
|
|
1639
|
+
const resultType = this.currResultType;
|
|
1640
|
+
switch (resultType) {
|
|
1641
|
+
case 'all':
|
|
1642
|
+
{
|
|
1643
|
+
const path = Array.isArray(ea.path) ? ea.path : JSONPath.toPathArray(ea.path);
|
|
1644
|
+
ea.pointer = JSONPath.toPointer(path);
|
|
1645
|
+
ea.path = typeof ea.path === 'string' ? ea.path : JSONPath.toPathString(ea.path);
|
|
1646
|
+
return ea;
|
|
1647
|
+
}
|
|
1648
|
+
case 'value':
|
|
1649
|
+
case 'parent':
|
|
1650
|
+
case 'parentProperty':
|
|
1651
|
+
return ea[resultType];
|
|
1652
|
+
case 'path':
|
|
1653
|
+
return JSONPath.toPathString(ea[resultType]);
|
|
1654
|
+
case 'pointer':
|
|
1655
|
+
return JSONPath.toPointer(ea.path);
|
|
1656
|
+
default:
|
|
1657
|
+
throw new TypeError('Unknown result type');
|
|
1658
|
+
}
|
|
1659
|
+
};
|
|
1660
|
+
JSONPath.prototype._handleCallback = function (fullRetObj, callback, type) {
|
|
1661
|
+
if (callback) {
|
|
1662
|
+
const preferredOutput = this._getPreferredOutput(fullRetObj);
|
|
1663
|
+
fullRetObj.path = typeof fullRetObj.path === 'string' ? fullRetObj.path : JSONPath.toPathString(fullRetObj.path);
|
|
1664
|
+
// eslint-disable-next-line n/callback-return -- No need to return
|
|
1665
|
+
callback(preferredOutput, type, fullRetObj);
|
|
1666
|
+
}
|
|
1667
|
+
};
|
|
1668
|
+
|
|
1669
|
+
/**
|
|
1670
|
+
*
|
|
1671
|
+
* @param {string} expr
|
|
1672
|
+
* @param {JSONObject} val
|
|
1673
|
+
* @param {string} path
|
|
1674
|
+
* @param {object|GenericArray} parent
|
|
1675
|
+
* @param {string} parentPropName
|
|
1676
|
+
* @param {JSONPathCallback} callback
|
|
1677
|
+
* @param {boolean} hasArrExpr
|
|
1678
|
+
* @param {boolean} literalPriority
|
|
1679
|
+
* @returns {ReturnObject|ReturnObject[]}
|
|
1680
|
+
*/
|
|
1681
|
+
JSONPath.prototype._trace = function (expr, val, path, parent, parentPropName, callback, hasArrExpr, literalPriority) {
|
|
1682
|
+
// No expr to follow? return path and value as the result of
|
|
1683
|
+
// this trace branch
|
|
1684
|
+
let retObj;
|
|
1685
|
+
if (!expr.length) {
|
|
1686
|
+
retObj = {
|
|
1687
|
+
path,
|
|
1688
|
+
value: val,
|
|
1689
|
+
parent,
|
|
1690
|
+
parentProperty: parentPropName,
|
|
1691
|
+
hasArrExpr
|
|
1692
|
+
};
|
|
1693
|
+
this._handleCallback(retObj, callback, 'value');
|
|
1694
|
+
return retObj;
|
|
1695
|
+
}
|
|
1696
|
+
const loc = expr[0],
|
|
1697
|
+
x = expr.slice(1);
|
|
1698
|
+
|
|
1699
|
+
// We need to gather the return value of recursive trace calls in order to
|
|
1700
|
+
// do the parent sel computation.
|
|
1701
|
+
const ret = [];
|
|
1702
|
+
/**
|
|
1703
|
+
*
|
|
1704
|
+
* @param {ReturnObject|ReturnObject[]} elems
|
|
1705
|
+
* @returns {void}
|
|
1706
|
+
*/
|
|
1707
|
+
function addRet(elems) {
|
|
1708
|
+
if (Array.isArray(elems)) {
|
|
1709
|
+
// This was causing excessive stack size in Node (with or
|
|
1710
|
+
// without Babel) against our performance test:
|
|
1711
|
+
// `ret.push(...elems);`
|
|
1712
|
+
elems.forEach(t => {
|
|
1713
|
+
ret.push(t);
|
|
1714
|
+
});
|
|
1715
|
+
} else {
|
|
1716
|
+
ret.push(elems);
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
if ((typeof loc !== 'string' || literalPriority) && val && Object.hasOwn(val, loc)) {
|
|
1720
|
+
// simple case--directly follow property
|
|
1721
|
+
addRet(this._trace(x, val[loc], push(path, loc), val, loc, callback, hasArrExpr));
|
|
1722
|
+
// eslint-disable-next-line unicorn/prefer-switch -- Part of larger `if`
|
|
1723
|
+
} else if (loc === '*') {
|
|
1724
|
+
// all child properties
|
|
1725
|
+
this._walk(val, m => {
|
|
1726
|
+
addRet(this._trace(x, val[m], push(path, m), val, m, callback, true, true));
|
|
1727
|
+
});
|
|
1728
|
+
} else if (loc === '..') {
|
|
1729
|
+
// all descendent parent properties
|
|
1730
|
+
// Check remaining expression with val's immediate children
|
|
1731
|
+
addRet(this._trace(x, val, path, parent, parentPropName, callback, hasArrExpr));
|
|
1732
|
+
this._walk(val, m => {
|
|
1733
|
+
// We don't join m and x here because we only want parents,
|
|
1734
|
+
// not scalar values
|
|
1735
|
+
if (typeof val[m] === 'object') {
|
|
1736
|
+
// Keep going with recursive descent on val's
|
|
1737
|
+
// object children
|
|
1738
|
+
addRet(this._trace(expr.slice(), val[m], push(path, m), val, m, callback, true));
|
|
1739
|
+
}
|
|
1740
|
+
});
|
|
1741
|
+
// The parent sel computation is handled in the frame above using the
|
|
1742
|
+
// ancestor object of val
|
|
1743
|
+
} else if (loc === '^') {
|
|
1744
|
+
// This is not a final endpoint, so we do not invoke the callback here
|
|
1745
|
+
this._hasParentSelector = true;
|
|
1746
|
+
return {
|
|
1747
|
+
path: path.slice(0, -1),
|
|
1748
|
+
expr: x,
|
|
1749
|
+
isParentSelector: true
|
|
1750
|
+
};
|
|
1751
|
+
} else if (loc === '~') {
|
|
1752
|
+
// property name
|
|
1753
|
+
retObj = {
|
|
1754
|
+
path: push(path, loc),
|
|
1755
|
+
value: parentPropName,
|
|
1756
|
+
parent,
|
|
1757
|
+
parentProperty: null
|
|
1758
|
+
};
|
|
1759
|
+
this._handleCallback(retObj, callback, 'property');
|
|
1760
|
+
return retObj;
|
|
1761
|
+
} else if (loc === '$') {
|
|
1762
|
+
// root only
|
|
1763
|
+
addRet(this._trace(x, val, path, null, null, callback, hasArrExpr));
|
|
1764
|
+
} else if (/^(-?\d*):(-?\d*):?(\d*)$/u.test(loc)) {
|
|
1765
|
+
// [start:end:step] Python slice syntax
|
|
1766
|
+
addRet(this._slice(loc, x, val, path, parent, parentPropName, callback));
|
|
1767
|
+
} else if (loc.indexOf('?(') === 0) {
|
|
1768
|
+
// [?(expr)] (filtering)
|
|
1769
|
+
if (this.currEval === false) {
|
|
1770
|
+
throw new Error('Eval [?(expr)] prevented in JSONPath expression.');
|
|
1771
|
+
}
|
|
1772
|
+
const safeLoc = loc.replace(/^\?\((.*?)\)$/u, '$1');
|
|
1773
|
+
// check for a nested filter expression
|
|
1774
|
+
const nested = /@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(safeLoc);
|
|
1775
|
+
if (nested) {
|
|
1776
|
+
// find if there are matches in the nested expression
|
|
1777
|
+
// add them to the result set if there is at least one match
|
|
1778
|
+
this._walk(val, m => {
|
|
1779
|
+
const npath = [nested[2]];
|
|
1780
|
+
const nvalue = nested[1] ? val[m][nested[1]] : val[m];
|
|
1781
|
+
const filterResults = this._trace(npath, nvalue, path, parent, parentPropName, callback, true);
|
|
1782
|
+
if (filterResults.length > 0) {
|
|
1783
|
+
addRet(this._trace(x, val[m], push(path, m), val, m, callback, true));
|
|
1784
|
+
}
|
|
1785
|
+
});
|
|
1786
|
+
} else {
|
|
1787
|
+
this._walk(val, m => {
|
|
1788
|
+
if (this._eval(safeLoc, val[m], m, path, parent, parentPropName)) {
|
|
1789
|
+
addRet(this._trace(x, val[m], push(path, m), val, m, callback, true));
|
|
1790
|
+
}
|
|
1791
|
+
});
|
|
1792
|
+
}
|
|
1793
|
+
} else if (loc[0] === '(') {
|
|
1794
|
+
// [(expr)] (dynamic property/index)
|
|
1795
|
+
if (this.currEval === false) {
|
|
1796
|
+
throw new Error('Eval [(expr)] prevented in JSONPath expression.');
|
|
1797
|
+
}
|
|
1798
|
+
// As this will resolve to a property name (but we don't know it
|
|
1799
|
+
// yet), property and parent information is relative to the
|
|
1800
|
+
// parent of the property to which this expression will resolve
|
|
1801
|
+
addRet(this._trace(unshift(this._eval(loc, val, path.at(-1), path.slice(0, -1), parent, parentPropName), x), val, path, parent, parentPropName, callback, hasArrExpr));
|
|
1802
|
+
} else if (loc[0] === '@') {
|
|
1803
|
+
// value type: @boolean(), etc.
|
|
1804
|
+
let addType = false;
|
|
1805
|
+
const valueType = loc.slice(1, -2);
|
|
1806
|
+
switch (valueType) {
|
|
1807
|
+
case 'scalar':
|
|
1808
|
+
if (!val || !['object', 'function'].includes(typeof val)) {
|
|
1809
|
+
addType = true;
|
|
1810
|
+
}
|
|
1811
|
+
break;
|
|
1812
|
+
case 'boolean':
|
|
1813
|
+
case 'string':
|
|
1814
|
+
case 'undefined':
|
|
1815
|
+
case 'function':
|
|
1816
|
+
if (typeof val === valueType) {
|
|
1817
|
+
addType = true;
|
|
1818
|
+
}
|
|
1819
|
+
break;
|
|
1820
|
+
case 'integer':
|
|
1821
|
+
if (Number.isFinite(val) && !(val % 1)) {
|
|
1822
|
+
addType = true;
|
|
1823
|
+
}
|
|
1824
|
+
break;
|
|
1825
|
+
case 'number':
|
|
1826
|
+
if (Number.isFinite(val)) {
|
|
1827
|
+
addType = true;
|
|
1828
|
+
}
|
|
1829
|
+
break;
|
|
1830
|
+
case 'nonFinite':
|
|
1831
|
+
if (typeof val === 'number' && !Number.isFinite(val)) {
|
|
1832
|
+
addType = true;
|
|
1833
|
+
}
|
|
1834
|
+
break;
|
|
1835
|
+
case 'object':
|
|
1836
|
+
if (val && typeof val === valueType) {
|
|
1837
|
+
addType = true;
|
|
1838
|
+
}
|
|
1839
|
+
break;
|
|
1840
|
+
case 'array':
|
|
1841
|
+
if (Array.isArray(val)) {
|
|
1842
|
+
addType = true;
|
|
1843
|
+
}
|
|
1844
|
+
break;
|
|
1845
|
+
case 'other':
|
|
1846
|
+
addType = this.currOtherTypeCallback(val, path, parent, parentPropName);
|
|
1847
|
+
break;
|
|
1848
|
+
case 'null':
|
|
1849
|
+
if (val === null) {
|
|
1850
|
+
addType = true;
|
|
1851
|
+
}
|
|
1852
|
+
break;
|
|
1853
|
+
/* c8 ignore next 2 */
|
|
1854
|
+
default:
|
|
1855
|
+
throw new TypeError('Unknown value type ' + valueType);
|
|
1856
|
+
}
|
|
1857
|
+
if (addType) {
|
|
1858
|
+
retObj = {
|
|
1859
|
+
path,
|
|
1860
|
+
value: val,
|
|
1861
|
+
parent,
|
|
1862
|
+
parentProperty: parentPropName
|
|
1863
|
+
};
|
|
1864
|
+
this._handleCallback(retObj, callback, 'value');
|
|
1865
|
+
return retObj;
|
|
1866
|
+
}
|
|
1867
|
+
// `-escaped property
|
|
1868
|
+
} else if (loc[0] === '`' && val && Object.hasOwn(val, loc.slice(1))) {
|
|
1869
|
+
const locProp = loc.slice(1);
|
|
1870
|
+
addRet(this._trace(x, val[locProp], push(path, locProp), val, locProp, callback, hasArrExpr, true));
|
|
1871
|
+
} else if (loc.includes(',')) {
|
|
1872
|
+
// [name1,name2,...]
|
|
1873
|
+
const parts = loc.split(',');
|
|
1874
|
+
for (const part of parts) {
|
|
1875
|
+
addRet(this._trace(unshift(part, x), val, path, parent, parentPropName, callback, true));
|
|
1876
|
+
}
|
|
1877
|
+
// simple case--directly follow property
|
|
1878
|
+
} else if (!literalPriority && val && Object.hasOwn(val, loc)) {
|
|
1879
|
+
addRet(this._trace(x, val[loc], push(path, loc), val, loc, callback, hasArrExpr, true));
|
|
1880
|
+
}
|
|
1881
|
+
|
|
1882
|
+
// We check the resulting values for parent selections. For parent
|
|
1883
|
+
// selections we discard the value object and continue the trace with the
|
|
1884
|
+
// current val object
|
|
1885
|
+
if (this._hasParentSelector) {
|
|
1886
|
+
for (let t = 0; t < ret.length; t++) {
|
|
1887
|
+
const rett = ret[t];
|
|
1888
|
+
if (rett && rett.isParentSelector) {
|
|
1889
|
+
const tmp = this._trace(rett.expr, val, rett.path, parent, parentPropName, callback, hasArrExpr);
|
|
1890
|
+
if (Array.isArray(tmp)) {
|
|
1891
|
+
ret[t] = tmp[0];
|
|
1892
|
+
const tl = tmp.length;
|
|
1893
|
+
for (let tt = 1; tt < tl; tt++) {
|
|
1894
|
+
// eslint-disable-next-line @stylistic/max-len -- Long
|
|
1895
|
+
// eslint-disable-next-line sonarjs/updated-loop-counter -- Convenient
|
|
1896
|
+
t++;
|
|
1897
|
+
ret.splice(t, 0, tmp[tt]);
|
|
1898
|
+
}
|
|
1899
|
+
} else {
|
|
1900
|
+
ret[t] = tmp;
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1905
|
+
return ret;
|
|
1906
|
+
};
|
|
1907
|
+
JSONPath.prototype._walk = function (val, f) {
|
|
1908
|
+
if (Array.isArray(val)) {
|
|
1909
|
+
const n = val.length;
|
|
1910
|
+
for (let i = 0; i < n; i++) {
|
|
1911
|
+
f(i);
|
|
1912
|
+
}
|
|
1913
|
+
} else if (val && typeof val === 'object') {
|
|
1914
|
+
Object.keys(val).forEach(m => {
|
|
1915
|
+
f(m);
|
|
1916
|
+
});
|
|
1917
|
+
}
|
|
1918
|
+
};
|
|
1919
|
+
JSONPath.prototype._slice = function (loc, expr, val, path, parent, parentPropName, callback) {
|
|
1920
|
+
if (!Array.isArray(val)) {
|
|
1921
|
+
return undefined;
|
|
1922
|
+
}
|
|
1923
|
+
const len = val.length,
|
|
1924
|
+
parts = loc.split(':'),
|
|
1925
|
+
step = parts[2] && Number.parseInt(parts[2]) || 1;
|
|
1926
|
+
let start = parts[0] && Number.parseInt(parts[0]) || 0,
|
|
1927
|
+
end = parts[1] && Number.parseInt(parts[1]) || len;
|
|
1928
|
+
start = start < 0 ? Math.max(0, start + len) : Math.min(len, start);
|
|
1929
|
+
end = end < 0 ? Math.max(0, end + len) : Math.min(len, end);
|
|
1930
|
+
const ret = [];
|
|
1931
|
+
for (let i = start; i < end; i += step) {
|
|
1932
|
+
const tmp = this._trace(unshift(i, expr), val, path, parent, parentPropName, callback, true);
|
|
1933
|
+
// Should only be possible to be an array here since first part of
|
|
1934
|
+
// ``unshift(i, expr)` passed in above would not be empty, nor `~`,
|
|
1935
|
+
// nor begin with `@` (as could return objects)
|
|
1936
|
+
// This was causing excessive stack size in Node (with or
|
|
1937
|
+
// without Babel) against our performance test: `ret.push(...tmp);`
|
|
1938
|
+
tmp.forEach(t => {
|
|
1939
|
+
ret.push(t);
|
|
1940
|
+
});
|
|
1941
|
+
}
|
|
1942
|
+
return ret;
|
|
1943
|
+
};
|
|
1944
|
+
JSONPath.prototype._eval = function (code, _v, _vname, path, parent, parentPropName) {
|
|
1945
|
+
this.currSandbox._$_parentProperty = parentPropName;
|
|
1946
|
+
this.currSandbox._$_parent = parent;
|
|
1947
|
+
this.currSandbox._$_property = _vname;
|
|
1948
|
+
this.currSandbox._$_root = this.json;
|
|
1949
|
+
this.currSandbox._$_v = _v;
|
|
1950
|
+
const containsPath = code.includes('@path');
|
|
1951
|
+
if (containsPath) {
|
|
1952
|
+
this.currSandbox._$_path = JSONPath.toPathString(path.concat([_vname]));
|
|
1953
|
+
}
|
|
1954
|
+
const scriptCacheKey = this.currEval + 'Script:' + code;
|
|
1955
|
+
if (!JSONPath.cache[scriptCacheKey]) {
|
|
1956
|
+
let script = code.replaceAll('@parentProperty', '_$_parentProperty').replaceAll('@parent', '_$_parent').replaceAll('@property', '_$_property').replaceAll('@root', '_$_root').replaceAll(/@([.\s)[])/gu, '_$_v$1');
|
|
1957
|
+
if (containsPath) {
|
|
1958
|
+
script = script.replaceAll('@path', '_$_path');
|
|
1959
|
+
}
|
|
1960
|
+
if (this.currEval === 'safe' || this.currEval === true || this.currEval === undefined) {
|
|
1961
|
+
JSONPath.cache[scriptCacheKey] = new this.safeVm.Script(script);
|
|
1962
|
+
} else if (this.currEval === 'native') {
|
|
1963
|
+
JSONPath.cache[scriptCacheKey] = new this.vm.Script(script);
|
|
1964
|
+
} else if (typeof this.currEval === 'function' && this.currEval.prototype && Object.hasOwn(this.currEval.prototype, 'runInNewContext')) {
|
|
1965
|
+
const CurrEval = this.currEval;
|
|
1966
|
+
JSONPath.cache[scriptCacheKey] = new CurrEval(script);
|
|
1967
|
+
} else if (typeof this.currEval === 'function') {
|
|
1968
|
+
JSONPath.cache[scriptCacheKey] = {
|
|
1969
|
+
runInNewContext: context => this.currEval(script, context)
|
|
1970
|
+
};
|
|
1971
|
+
} else {
|
|
1972
|
+
throw new TypeError(`Unknown "eval" property "${this.currEval}"`);
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
try {
|
|
1976
|
+
return JSONPath.cache[scriptCacheKey].runInNewContext(this.currSandbox);
|
|
1977
|
+
} catch (e) {
|
|
1978
|
+
if (this.ignoreEvalErrors) {
|
|
1979
|
+
return false;
|
|
1980
|
+
}
|
|
1981
|
+
throw new Error('jsonPath: ' + e.message + ': ' + code);
|
|
1982
|
+
}
|
|
1983
|
+
};
|
|
1984
|
+
|
|
1985
|
+
// PUBLIC CLASS PROPERTIES AND METHODS
|
|
1986
|
+
|
|
1987
|
+
// Could store the cache object itself
|
|
1988
|
+
JSONPath.cache = {};
|
|
1989
|
+
|
|
1990
|
+
/**
|
|
1991
|
+
* @param {string[]} pathArr Array to convert
|
|
1992
|
+
* @returns {string} The path string
|
|
1993
|
+
*/
|
|
1994
|
+
JSONPath.toPathString = function (pathArr) {
|
|
1995
|
+
const x = pathArr,
|
|
1996
|
+
n = x.length;
|
|
1997
|
+
let p = '$';
|
|
1998
|
+
for (let i = 1; i < n; i++) {
|
|
1999
|
+
if (!/^(~|\^|@.*?\(\))$/u.test(x[i])) {
|
|
2000
|
+
p += /^[0-9*]+$/u.test(x[i]) ? '[' + x[i] + ']' : "['" + x[i] + "']";
|
|
2001
|
+
}
|
|
2002
|
+
}
|
|
2003
|
+
return p;
|
|
2004
|
+
};
|
|
2005
|
+
|
|
2006
|
+
/**
|
|
2007
|
+
* @param {string} pointer JSON Path
|
|
2008
|
+
* @returns {string} JSON Pointer
|
|
2009
|
+
*/
|
|
2010
|
+
JSONPath.toPointer = function (pointer) {
|
|
2011
|
+
const x = pointer,
|
|
2012
|
+
n = x.length;
|
|
2013
|
+
let p = '';
|
|
2014
|
+
for (let i = 1; i < n; i++) {
|
|
2015
|
+
if (!/^(~|\^|@.*?\(\))$/u.test(x[i])) {
|
|
2016
|
+
p += '/' + x[i].toString().replaceAll('~', '~0').replaceAll('/', '~1');
|
|
2017
|
+
}
|
|
2018
|
+
}
|
|
2019
|
+
return p;
|
|
2020
|
+
};
|
|
2021
|
+
|
|
2022
|
+
/**
|
|
2023
|
+
* @param {string} expr Expression to convert
|
|
2024
|
+
* @returns {string[]}
|
|
2025
|
+
*/
|
|
2026
|
+
JSONPath.toPathArray = function (expr) {
|
|
2027
|
+
const {
|
|
2028
|
+
cache
|
|
2029
|
+
} = JSONPath;
|
|
2030
|
+
if (cache[expr]) {
|
|
2031
|
+
return cache[expr].concat();
|
|
2032
|
+
}
|
|
2033
|
+
const subx = [];
|
|
2034
|
+
const normalized = expr
|
|
2035
|
+
// Properties
|
|
2036
|
+
.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu, ';$&;')
|
|
2037
|
+
// Parenthetical evaluations (filtering and otherwise), directly
|
|
2038
|
+
// within brackets or single quotes
|
|
2039
|
+
.replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu, function ($0, $1) {
|
|
2040
|
+
return '[#' + (subx.push($1) - 1) + ']';
|
|
2041
|
+
})
|
|
2042
|
+
// Escape periods and tildes within properties
|
|
2043
|
+
.replaceAll(/\[['"]([^'\]]*)['"]\]/gu, function ($0, prop) {
|
|
2044
|
+
return "['" + prop.replaceAll('.', '%@%').replaceAll('~', '%%@@%%') + "']";
|
|
2045
|
+
})
|
|
2046
|
+
// Properties operator
|
|
2047
|
+
.replaceAll('~', ';~;')
|
|
2048
|
+
// Split by property boundaries
|
|
2049
|
+
.replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu, ';')
|
|
2050
|
+
// Reinsert periods within properties
|
|
2051
|
+
.replaceAll('%@%', '.')
|
|
2052
|
+
// Reinsert tildes within properties
|
|
2053
|
+
.replaceAll('%%@@%%', '~')
|
|
2054
|
+
// Parent
|
|
2055
|
+
.replaceAll(/(?:;)?(\^+)(?:;)?/gu, function ($0, ups) {
|
|
2056
|
+
return ';' + ups.split('').join(';') + ';';
|
|
2057
|
+
})
|
|
2058
|
+
// Descendents
|
|
2059
|
+
.replaceAll(/;;;|;;/gu, ';..;')
|
|
2060
|
+
// Remove trailing
|
|
2061
|
+
.replaceAll(/;$|'?\]|'$/gu, '');
|
|
2062
|
+
const exprList = normalized.split(';').map(function (exp) {
|
|
2063
|
+
const match = exp.match(/#(\d+)/u);
|
|
2064
|
+
return !match || !match[1] ? exp : subx[match[1]];
|
|
2065
|
+
});
|
|
2066
|
+
cache[expr] = exprList;
|
|
2067
|
+
return cache[expr].concat();
|
|
2068
|
+
};
|
|
2069
|
+
JSONPath.prototype.safeVm = {
|
|
2070
|
+
Script: SafeScript
|
|
2071
|
+
};
|
|
2072
|
+
|
|
2073
|
+
/**
|
|
2074
|
+
* @typedef {any} ContextItem
|
|
2075
|
+
*/
|
|
2076
|
+
|
|
2077
|
+
/**
|
|
2078
|
+
* @typedef {any} EvaluatedResult
|
|
2079
|
+
*/
|
|
2080
|
+
|
|
2081
|
+
/**
|
|
2082
|
+
* @callback ConditionCallback
|
|
2083
|
+
* @param {ContextItem} item
|
|
2084
|
+
* @returns {boolean}
|
|
2085
|
+
*/
|
|
2086
|
+
|
|
2087
|
+
/**
|
|
2088
|
+
* Copy items out of one array into another.
|
|
2089
|
+
* @param {GenericArray} source Array with items to copy
|
|
2090
|
+
* @param {GenericArray} target Array to which to copy
|
|
2091
|
+
* @param {ConditionCallback} conditionCb Callback passed the current item;
|
|
2092
|
+
* will move item if evaluates to `true`
|
|
2093
|
+
* @returns {void}
|
|
2094
|
+
*/
|
|
2095
|
+
const moveToAnotherArray = function (source, target, conditionCb) {
|
|
2096
|
+
const il = source.length;
|
|
2097
|
+
for (let i = 0; i < il; i++) {
|
|
2098
|
+
const item = source[i];
|
|
2099
|
+
if (conditionCb(item)) {
|
|
2100
|
+
// eslint-disable-next-line @stylistic/max-len -- Long
|
|
2101
|
+
// eslint-disable-next-line sonarjs/updated-loop-counter -- Convenient
|
|
2102
|
+
target.push(source.splice(i--, 1)[0]);
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
};
|
|
2106
|
+
|
|
2107
|
+
/**
|
|
2108
|
+
* In-browser replacement for NodeJS' VM.Script.
|
|
2109
|
+
*/
|
|
2110
|
+
class Script {
|
|
2111
|
+
/**
|
|
2112
|
+
* @param {string} expr Expression to evaluate
|
|
2113
|
+
*/
|
|
2114
|
+
constructor(expr) {
|
|
2115
|
+
this.code = expr;
|
|
2116
|
+
}
|
|
2117
|
+
|
|
2118
|
+
/**
|
|
2119
|
+
* @param {object} context Object whose items will be added
|
|
2120
|
+
* to evaluation
|
|
2121
|
+
* @returns {EvaluatedResult} Result of evaluated code
|
|
2122
|
+
*/
|
|
2123
|
+
runInNewContext(context) {
|
|
2124
|
+
let expr = this.code;
|
|
2125
|
+
const keys = Object.keys(context);
|
|
2126
|
+
const funcs = [];
|
|
2127
|
+
moveToAnotherArray(keys, funcs, key => {
|
|
2128
|
+
return typeof context[key] === 'function';
|
|
2129
|
+
});
|
|
2130
|
+
const values = keys.map(vr => {
|
|
2131
|
+
return context[vr];
|
|
2132
|
+
});
|
|
2133
|
+
const funcString = funcs.reduce((s, func) => {
|
|
2134
|
+
let fString = context[func].toString();
|
|
2135
|
+
if (!/function/u.test(fString)) {
|
|
2136
|
+
fString = 'function ' + fString;
|
|
2137
|
+
}
|
|
2138
|
+
return 'var ' + func + '=' + fString + ';' + s;
|
|
2139
|
+
}, '');
|
|
2140
|
+
expr = funcString + expr;
|
|
2141
|
+
|
|
2142
|
+
// Mitigate http://perfectionkills.com/global-eval-what-are-the-options/#new_function
|
|
2143
|
+
if (!/(['"])use strict\1/u.test(expr) && !keys.includes('arguments')) {
|
|
2144
|
+
expr = 'var arguments = undefined;' + expr;
|
|
2145
|
+
}
|
|
2146
|
+
|
|
2147
|
+
// Remove last semi so `return` will be inserted before
|
|
2148
|
+
// the previous one instead, allowing for the return
|
|
2149
|
+
// of a bare ending expression
|
|
2150
|
+
expr = expr.replace(/;\s*$/u, '');
|
|
2151
|
+
|
|
2152
|
+
// Insert `return`
|
|
2153
|
+
const lastStatementEnd = expr.lastIndexOf(';');
|
|
2154
|
+
const code = lastStatementEnd !== -1 ? expr.slice(0, lastStatementEnd + 1) + ' return ' + expr.slice(lastStatementEnd + 1) : ' return ' + expr;
|
|
2155
|
+
|
|
2156
|
+
// eslint-disable-next-line no-new-func -- User's choice
|
|
2157
|
+
return new Function(...keys, code)(...values);
|
|
2158
|
+
}
|
|
2159
|
+
}
|
|
2160
|
+
JSONPath.prototype.vm = {
|
|
2161
|
+
Script
|
|
2162
|
+
};
|
|
2163
|
+
|
|
2164
|
+
export { JSONPath };
|