lumen-plus 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Alert/Alert.svelte +1 -1
- package/dist/components/Autocomplete/Autocomplete.svelte +1 -1
- package/dist/components/Backtop/Backtop.svelte +1 -1
- package/dist/components/Breadcrumb/Breadcrumb.svelte +1 -1
- package/dist/components/Button/Button.svelte +1 -1
- package/dist/components/Calendar/Calendar.svelte +1 -1
- package/dist/components/Carousel/Carousel.svelte +1 -1
- package/dist/components/Cascader/Cascader.svelte +2 -2
- package/dist/components/Checkbox/Checkbox.svelte +1 -1
- package/dist/components/Collapse/CollapseItem.svelte +1 -1
- package/dist/components/ColorPicker/ColorPicker.svelte +2 -2
- package/dist/components/DatePicker/DatePicker.svelte +2 -2
- package/dist/components/DateTimePicker/DateTimePicker.svelte +2 -2
- package/dist/components/Dialog/Dialog.svelte +1 -1
- package/dist/components/Drawer/Drawer.svelte +1 -1
- package/dist/components/Dropdown/Dropdown.svelte +1 -1
- package/dist/components/Image/Image.svelte +1 -1
- package/dist/components/Input/Input.svelte +1 -1
- package/dist/components/InputNumber/InputNumber.svelte +1 -1
- package/dist/components/InputTag/InputTag.svelte +1 -1
- package/dist/components/Loading/Loading.svelte +1 -1
- package/dist/components/Menu/Menu.svelte +1 -1
- package/dist/components/Message/MessageBox.svelte +1 -1
- package/dist/components/MessageBox/MessageBox.svelte +2 -2
- package/dist/components/Notification/Notification.svelte +1 -1
- package/dist/components/Pagination/Pagination.svelte +4 -4
- package/dist/components/Popconfirm/Popconfirm.svelte +2 -2
- package/dist/components/Result/Result.svelte +1 -1
- package/dist/components/Select/Select.svelte +2 -2
- package/dist/components/Slider/Slider.svelte +1 -1
- package/dist/components/Steps/Step.svelte +1 -1
- package/dist/components/Switch/Switch.svelte +1 -1
- package/dist/components/Table/Table.svelte +5 -5
- package/dist/components/Tabs/Tabs.svelte +1 -1
- package/dist/components/Tag/Tag.svelte +1 -1
- package/dist/components/Textarea/Textarea.svelte +1 -1
- package/dist/components/TimePicker/TimePicker.svelte +2 -2
- package/dist/components/Transfer/Transfer.svelte +2 -2
- package/dist/components/Tree/TreeNode.svelte +2 -2
- package/dist/components/TreeSelect/TreeSelect.svelte +4 -4
- package/dist/components/Upload/Upload.svelte +1 -1
- package/package.json +1 -1
- package/dist/utils/node_modules/.bin/tsc +0 -2
- package/dist/utils/node_modules/.bin/tsserver +0 -2
- package/dist/utils/node_modules/svelte/LICENSE.md +0 -7
- package/dist/utils/node_modules/svelte/README.md +0 -41
- package/dist/utils/node_modules/svelte/compiler/index.js +0 -1
- package/dist/utils/node_modules/svelte/compiler/package.json +0 -3
- package/dist/utils/node_modules/svelte/package.json +0 -184
- package/dist/utils/node_modules/svelte/src/animate/index.js +0 -78
- package/dist/utils/node_modules/svelte/src/attachments/index.js +0 -113
- package/dist/utils/node_modules/svelte/src/compiler/errors.js +0 -1719
- package/dist/utils/node_modules/svelte/src/compiler/index.js +0 -198
- package/dist/utils/node_modules/svelte/src/compiler/legacy.js +0 -632
- package/dist/utils/node_modules/svelte/src/compiler/migrate/index.js +0 -1996
- package/dist/utils/node_modules/svelte/src/compiler/phases/1-parse/acorn.js +0 -198
- package/dist/utils/node_modules/svelte/src/compiler/phases/1-parse/index.js +0 -326
- package/dist/utils/node_modules/svelte/src/compiler/phases/1-parse/read/context.js +0 -116
- package/dist/utils/node_modules/svelte/src/compiler/phases/1-parse/read/expression.js +0 -93
- package/dist/utils/node_modules/svelte/src/compiler/phases/1-parse/read/options.js +0 -261
- package/dist/utils/node_modules/svelte/src/compiler/phases/1-parse/read/script.js +0 -97
- package/dist/utils/node_modules/svelte/src/compiler/phases/1-parse/read/style.js +0 -633
- package/dist/utils/node_modules/svelte/src/compiler/phases/1-parse/remove_typescript_nodes.js +0 -180
- package/dist/utils/node_modules/svelte/src/compiler/phases/1-parse/state/element.js +0 -877
- package/dist/utils/node_modules/svelte/src/compiler/phases/1-parse/state/fragment.js +0 -17
- package/dist/utils/node_modules/svelte/src/compiler/phases/1-parse/state/tag.js +0 -751
- package/dist/utils/node_modules/svelte/src/compiler/phases/1-parse/state/text.js +0 -23
- package/dist/utils/node_modules/svelte/src/compiler/phases/1-parse/utils/bracket.js +0 -213
- package/dist/utils/node_modules/svelte/src/compiler/phases/1-parse/utils/create.js +0 -16
- package/dist/utils/node_modules/svelte/src/compiler/phases/1-parse/utils/entities.js +0 -2234
- package/dist/utils/node_modules/svelte/src/compiler/phases/1-parse/utils/fuzzymatch.js +0 -280
- package/dist/utils/node_modules/svelte/src/compiler/phases/1-parse/utils/html.js +0 -127
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/css/css-analyze.js +0 -331
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/css/css-prune.js +0 -1160
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/css/css-warn.js +0 -47
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/css/utils.js +0 -177
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/index.js +0 -1283
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/utils/check_graph_for_cycles.js +0 -47
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/AnimateDirective.js +0 -15
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/ArrowFunctionExpression.js +0 -11
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/AssignmentExpression.js +0 -31
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/AttachTag.js +0 -17
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/Attribute.js +0 -66
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/AwaitBlock.js +0 -48
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/AwaitExpression.js +0 -150
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/BindDirective.js +0 -280
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/CallExpression.js +0 -339
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/ClassBody.js +0 -156
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/ClassDeclaration.js +0 -25
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/ClassDirective.js +0 -13
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/Component.js +0 -26
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/ConstTag.js +0 -45
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/DebugTag.js +0 -15
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/EachBlock.js +0 -97
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/ExportDefaultDeclaration.js +0 -20
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/ExportNamedDeclaration.js +0 -70
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/ExportSpecifier.js +0 -30
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/ExpressionStatement.js +0 -38
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/ExpressionTag.js +0 -26
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/Fragment.js +0 -10
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/FunctionDeclaration.js +0 -16
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/FunctionExpression.js +0 -11
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/HtmlTag.js +0 -19
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/Identifier.js +0 -193
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/IfBlock.js +0 -27
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/ImportDeclaration.js +0 -31
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/KeyBlock.js +0 -21
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/LabeledStatement.js +0 -95
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/LetDirective.js +0 -24
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/Literal.js +0 -14
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/MemberExpression.js +0 -28
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/NewExpression.js +0 -17
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/OnDirective.js +0 -28
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/PropertyDefinition.js +0 -21
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/RegularElement.js +0 -210
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/RenderTag.js +0 -68
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/SlotElement.js +0 -42
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/SnippetBlock.js +0 -113
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/SpreadAttribute.js +0 -13
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/SpreadElement.js +0 -16
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/StyleDirective.js +0 -39
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/SvelteBody.js +0 -22
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/SvelteBoundary.js +0 -30
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/SvelteComponent.js +0 -18
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/SvelteDocument.js +0 -24
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/SvelteElement.js +0 -78
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/SvelteFragment.js +0 -27
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/SvelteHead.js +0 -18
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/SvelteSelf.js +0 -36
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/SvelteWindow.js +0 -24
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/TaggedTemplateExpression.js +0 -16
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/TemplateElement.js +0 -12
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/Text.js +0 -52
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/TitleElement.js +0 -21
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/TransitionDirective.js +0 -19
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/UpdateExpression.js +0 -29
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/UseDirective.js +0 -18
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/VariableDeclarator.js +0 -160
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/shared/a11y/constants.js +0 -319
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/shared/a11y/index.js +0 -977
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/shared/attribute.js +0 -125
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/shared/component.js +0 -177
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/shared/element.js +0 -160
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/shared/fragment.js +0 -15
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/shared/function.js +0 -24
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/shared/snippets.js +0 -17
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/shared/special-element.js +0 -16
- package/dist/utils/node_modules/svelte/src/compiler/phases/2-analyze/visitors/shared/utils.js +0 -301
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/transform-client.js +0 -709
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/transform-template/fix-attribute-casing.js +0 -18
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/transform-template/index.js +0 -67
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/transform-template/template.js +0 -162
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/utils.js +0 -181
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/AnimateDirective.js +0 -38
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/ArrowFunctionExpression.js +0 -11
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/AssignmentExpression.js +0 -225
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/AttachTag.js +0 -26
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/Attribute.js +0 -14
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/AwaitBlock.js +0 -124
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/AwaitExpression.js +0 -25
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/BinaryExpression.js +0 -34
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/BindDirective.js +0 -290
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/BlockStatement.js +0 -32
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/BreakStatement.js +0 -20
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/CallExpression.js +0 -136
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/ClassBody.js +0 -111
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/Comment.js +0 -11
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/Component.js +0 -12
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/ConstTag.js +0 -134
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/DebugTag.js +0 -28
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/EachBlock.js +0 -367
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/ExportNamedDeclaration.js +0 -19
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/ExpressionStatement.js +0 -20
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/ForOfStatement.js +0 -25
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/Fragment.js +0 -181
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/FunctionDeclaration.js +0 -12
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/FunctionExpression.js +0 -11
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/HtmlTag.js +0 -49
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/Identifier.js +0 -45
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/IfBlock.js +0 -90
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/KeyBlock.js +0 -39
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/LabeledStatement.js +0 -64
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/LetDirective.js +0 -55
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/MemberExpression.js +0 -23
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/OnDirective.js +0 -38
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/Program.js +0 -153
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/RegularElement.js +0 -791
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/RenderTag.js +0 -91
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/SlotElement.js +0 -94
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/SnippetBlock.js +0 -94
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/SpreadAttribute.js +0 -10
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/SvelteBody.js +0 -11
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/SvelteBoundary.js +0 -126
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/SvelteComponent.js +0 -13
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/SvelteDocument.js +0 -11
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/SvelteElement.js +0 -157
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/SvelteFragment.js +0 -17
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/SvelteHead.js +0 -23
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/SvelteSelf.js +0 -13
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/SvelteWindow.js +0 -11
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/TitleElement.js +0 -48
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/TransitionDirective.js +0 -41
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/UpdateExpression.js +0 -55
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/UseDirective.js +0 -49
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/VariableDeclaration.js +0 -422
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/shared/component.js +0 -530
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/shared/declarations.js +0 -53
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/shared/element.js +0 -263
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/shared/events.js +0 -176
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/shared/fragment.js +0 -185
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/shared/function.js +0 -17
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/shared/special_element.js +0 -22
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/client/visitors/shared/utils.js +0 -513
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/css/index.js +0 -479
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/index.js +0 -118
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/transform-server.js +0 -423
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/AssignmentExpression.js +0 -107
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/AwaitBlock.js +0 -37
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/AwaitExpression.js +0 -40
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/CallExpression.js +0 -71
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/ClassBody.js +0 -81
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/Component.js +0 -12
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/ConstTag.js +0 -49
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/DebugTag.js +0 -24
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/EachBlock.js +0 -80
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/ExpressionStatement.js +0 -23
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/Fragment.js +0 -53
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/HtmlTag.js +0 -26
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/Identifier.js +0 -19
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/IfBlock.js +0 -39
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/KeyBlock.js +0 -22
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/LabeledStatement.js +0 -24
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/MemberExpression.js +0 -19
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/Program.js +0 -25
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/PropertyDefinition.js +0 -37
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/RegularElement.js +0 -255
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/RenderTag.js +0 -51
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/SlotElement.js +0 -77
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/SnippetBlock.js +0 -29
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/SpreadAttribute.js +0 -10
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/SvelteBoundary.js +0 -71
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/SvelteComponent.js +0 -12
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/SvelteElement.js +0 -102
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/SvelteFragment.js +0 -11
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/SvelteHead.js +0 -25
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/SvelteSelf.js +0 -12
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/TitleElement.js +0 -21
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/UpdateExpression.js +0 -26
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/VariableDeclaration.js +0 -212
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/shared/component.js +0 -360
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/shared/element.js +0 -563
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/server/visitors/shared/utils.js +0 -407
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/shared/assignments.js +0 -93
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/shared/transform-async.js +0 -114
- package/dist/utils/node_modules/svelte/src/compiler/phases/3-transform/utils.js +0 -451
- package/dist/utils/node_modules/svelte/src/compiler/phases/bindings.js +0 -227
- package/dist/utils/node_modules/svelte/src/compiler/phases/css.js +0 -14
- package/dist/utils/node_modules/svelte/src/compiler/phases/nodes.js +0 -245
- package/dist/utils/node_modules/svelte/src/compiler/phases/patterns.js +0 -27
- package/dist/utils/node_modules/svelte/src/compiler/phases/scope.js +0 -1412
- package/dist/utils/node_modules/svelte/src/compiler/preprocess/decode_sourcemap.js +0 -96
- package/dist/utils/node_modules/svelte/src/compiler/preprocess/index.js +0 -368
- package/dist/utils/node_modules/svelte/src/compiler/preprocess/replace_in_code.js +0 -72
- package/dist/utils/node_modules/svelte/src/compiler/print/index.js +0 -890
- package/dist/utils/node_modules/svelte/src/compiler/state.js +0 -144
- package/dist/utils/node_modules/svelte/src/compiler/utils/assert.js +0 -9
- package/dist/utils/node_modules/svelte/src/compiler/utils/ast.js +0 -639
- package/dist/utils/node_modules/svelte/src/compiler/utils/builders.js +0 -698
- package/dist/utils/node_modules/svelte/src/compiler/utils/compile_diagnostic.js +0 -107
- package/dist/utils/node_modules/svelte/src/compiler/utils/extract_svelte_ignore.js +0 -104
- package/dist/utils/node_modules/svelte/src/compiler/utils/mapped_code.js +0 -454
- package/dist/utils/node_modules/svelte/src/compiler/utils/push_array.js +0 -13
- package/dist/utils/node_modules/svelte/src/compiler/utils/sanitize_template_string.js +0 -7
- package/dist/utils/node_modules/svelte/src/compiler/utils/slot.js +0 -20
- package/dist/utils/node_modules/svelte/src/compiler/utils/string.js +0 -9
- package/dist/utils/node_modules/svelte/src/compiler/validate-options.js +0 -324
- package/dist/utils/node_modules/svelte/src/compiler/warnings.js +0 -845
- package/dist/utils/node_modules/svelte/src/constants.js +0 -64
- package/dist/utils/node_modules/svelte/src/easing/index.js +0 -286
- package/dist/utils/node_modules/svelte/src/escaping.js +0 -26
- package/dist/utils/node_modules/svelte/src/events/index.js +0 -1
- package/dist/utils/node_modules/svelte/src/html-tree-validation.js +0 -238
- package/dist/utils/node_modules/svelte/src/index-client.js +0 -255
- package/dist/utils/node_modules/svelte/src/index-server.js +0 -56
- package/dist/utils/node_modules/svelte/src/internal/client/constants.js +0 -73
- package/dist/utils/node_modules/svelte/src/internal/client/context.js +0 -258
- package/dist/utils/node_modules/svelte/src/internal/client/dev/assign.js +0 -78
- package/dist/utils/node_modules/svelte/src/internal/client/dev/console-log.js +0 -35
- package/dist/utils/node_modules/svelte/src/internal/client/dev/css.js +0 -31
- package/dist/utils/node_modules/svelte/src/internal/client/dev/debug.js +0 -500
- package/dist/utils/node_modules/svelte/src/internal/client/dev/elements.js +0 -63
- package/dist/utils/node_modules/svelte/src/internal/client/dev/equality.js +0 -101
- package/dist/utils/node_modules/svelte/src/internal/client/dev/hmr.js +0 -89
- package/dist/utils/node_modules/svelte/src/internal/client/dev/inspect.js +0 -72
- package/dist/utils/node_modules/svelte/src/internal/client/dev/legacy.js +0 -25
- package/dist/utils/node_modules/svelte/src/internal/client/dev/ownership.js +0 -81
- package/dist/utils/node_modules/svelte/src/internal/client/dev/tracing.js +0 -162
- package/dist/utils/node_modules/svelte/src/internal/client/dev/validation.js +0 -16
- package/dist/utils/node_modules/svelte/src/internal/client/dom/blocks/async.js +0 -64
- package/dist/utils/node_modules/svelte/src/internal/client/dom/blocks/await.js +0 -142
- package/dist/utils/node_modules/svelte/src/internal/client/dom/blocks/boundary.js +0 -507
- package/dist/utils/node_modules/svelte/src/internal/client/dom/blocks/branches.js +0 -227
- package/dist/utils/node_modules/svelte/src/internal/client/dom/blocks/css-props.js +0 -28
- package/dist/utils/node_modules/svelte/src/internal/client/dom/blocks/each.js +0 -666
- package/dist/utils/node_modules/svelte/src/internal/client/dom/blocks/html.js +0 -121
- package/dist/utils/node_modules/svelte/src/internal/client/dom/blocks/if.js +0 -70
- package/dist/utils/node_modules/svelte/src/internal/client/dom/blocks/key.js +0 -33
- package/dist/utils/node_modules/svelte/src/internal/client/dom/blocks/slot.js +0 -44
- package/dist/utils/node_modules/svelte/src/internal/client/dom/blocks/snippet.js +0 -103
- package/dist/utils/node_modules/svelte/src/internal/client/dom/blocks/svelte-component.js +0 -26
- package/dist/utils/node_modules/svelte/src/internal/client/dom/blocks/svelte-element.js +0 -152
- package/dist/utils/node_modules/svelte/src/internal/client/dom/blocks/svelte-head.js +0 -59
- package/dist/utils/node_modules/svelte/src/internal/client/dom/css.js +0 -32
- package/dist/utils/node_modules/svelte/src/internal/client/dom/elements/actions.js +0 -43
- package/dist/utils/node_modules/svelte/src/internal/client/dom/elements/attachments.js +0 -33
- package/dist/utils/node_modules/svelte/src/internal/client/dom/elements/attributes.js +0 -657
- package/dist/utils/node_modules/svelte/src/internal/client/dom/elements/bindings/document.js +0 -17
- package/dist/utils/node_modules/svelte/src/internal/client/dom/elements/bindings/input.js +0 -312
- package/dist/utils/node_modules/svelte/src/internal/client/dom/elements/bindings/media.js +0 -232
- package/dist/utils/node_modules/svelte/src/internal/client/dom/elements/bindings/navigator.js +0 -11
- package/dist/utils/node_modules/svelte/src/internal/client/dom/elements/bindings/props.js +0 -22
- package/dist/utils/node_modules/svelte/src/internal/client/dom/elements/bindings/select.js +0 -159
- package/dist/utils/node_modules/svelte/src/internal/client/dom/elements/bindings/shared.js +0 -76
- package/dist/utils/node_modules/svelte/src/internal/client/dom/elements/bindings/size.js +0 -108
- package/dist/utils/node_modules/svelte/src/internal/client/dom/elements/bindings/this.js +0 -61
- package/dist/utils/node_modules/svelte/src/internal/client/dom/elements/bindings/universal.js +0 -75
- package/dist/utils/node_modules/svelte/src/internal/client/dom/elements/bindings/window.js +0 -66
- package/dist/utils/node_modules/svelte/src/internal/client/dom/elements/class.js +0 -51
- package/dist/utils/node_modules/svelte/src/internal/client/dom/elements/custom-element.js +0 -338
- package/dist/utils/node_modules/svelte/src/internal/client/dom/elements/customizable-select.js +0 -98
- package/dist/utils/node_modules/svelte/src/internal/client/dom/elements/events.js +0 -338
- package/dist/utils/node_modules/svelte/src/internal/client/dom/elements/misc.js +0 -58
- package/dist/utils/node_modules/svelte/src/internal/client/dom/elements/style.js +0 -57
- package/dist/utils/node_modules/svelte/src/internal/client/dom/elements/transitions.js +0 -472
- package/dist/utils/node_modules/svelte/src/internal/client/dom/hydration.js +0 -120
- package/dist/utils/node_modules/svelte/src/internal/client/dom/legacy/event-modifiers.js +0 -127
- package/dist/utils/node_modules/svelte/src/internal/client/dom/legacy/lifecycle.js +0 -82
- package/dist/utils/node_modules/svelte/src/internal/client/dom/legacy/misc.js +0 -68
- package/dist/utils/node_modules/svelte/src/internal/client/dom/operations.js +0 -260
- package/dist/utils/node_modules/svelte/src/internal/client/dom/reconciler.js +0 -6
- package/dist/utils/node_modules/svelte/src/internal/client/dom/task.js +0 -42
- package/dist/utils/node_modules/svelte/src/internal/client/dom/template.js +0 -388
- package/dist/utils/node_modules/svelte/src/internal/client/error-handling.js +0 -116
- package/dist/utils/node_modules/svelte/src/internal/client/errors.js +0 -491
- package/dist/utils/node_modules/svelte/src/internal/client/hydratable.js +0 -33
- package/dist/utils/node_modules/svelte/src/internal/client/index.js +0 -184
- package/dist/utils/node_modules/svelte/src/internal/client/legacy.js +0 -46
- package/dist/utils/node_modules/svelte/src/internal/client/loop.js +0 -48
- package/dist/utils/node_modules/svelte/src/internal/client/proxy.js +0 -432
- package/dist/utils/node_modules/svelte/src/internal/client/reactivity/async.js +0 -302
- package/dist/utils/node_modules/svelte/src/internal/client/reactivity/batch.js +0 -988
- package/dist/utils/node_modules/svelte/src/internal/client/reactivity/deriveds.js +0 -394
- package/dist/utils/node_modules/svelte/src/internal/client/reactivity/effects.js +0 -717
- package/dist/utils/node_modules/svelte/src/internal/client/reactivity/equality.js +0 -31
- package/dist/utils/node_modules/svelte/src/internal/client/reactivity/props.js +0 -430
- package/dist/utils/node_modules/svelte/src/internal/client/reactivity/sources.js +0 -368
- package/dist/utils/node_modules/svelte/src/internal/client/reactivity/status.js +0 -25
- package/dist/utils/node_modules/svelte/src/internal/client/reactivity/store.js +0 -203
- package/dist/utils/node_modules/svelte/src/internal/client/reactivity/utils.js +0 -40
- package/dist/utils/node_modules/svelte/src/internal/client/render.js +0 -319
- package/dist/utils/node_modules/svelte/src/internal/client/runtime.js +0 -831
- package/dist/utils/node_modules/svelte/src/internal/client/timing.js +0 -16
- package/dist/utils/node_modules/svelte/src/internal/client/validate.js +0 -88
- package/dist/utils/node_modules/svelte/src/internal/client/warnings.js +0 -271
- package/dist/utils/node_modules/svelte/src/internal/disclose-version.js +0 -6
- package/dist/utils/node_modules/svelte/src/internal/flags/async.js +0 -3
- package/dist/utils/node_modules/svelte/src/internal/flags/index.js +0 -23
- package/dist/utils/node_modules/svelte/src/internal/flags/legacy.js +0 -3
- package/dist/utils/node_modules/svelte/src/internal/flags/tracing.js +0 -3
- package/dist/utils/node_modules/svelte/src/internal/index.js +0 -5
- package/dist/utils/node_modules/svelte/src/internal/server/abort-signal.js +0 -13
- package/dist/utils/node_modules/svelte/src/internal/server/blocks/html.js +0 -11
- package/dist/utils/node_modules/svelte/src/internal/server/blocks/snippet.js +0 -24
- package/dist/utils/node_modules/svelte/src/internal/server/context.js +0 -122
- package/dist/utils/node_modules/svelte/src/internal/server/crypto.js +0 -41
- package/dist/utils/node_modules/svelte/src/internal/server/dev.js +0 -115
- package/dist/utils/node_modules/svelte/src/internal/server/errors.js +0 -118
- package/dist/utils/node_modules/svelte/src/internal/server/hydratable.js +0 -142
- package/dist/utils/node_modules/svelte/src/internal/server/hydration.js +0 -6
- package/dist/utils/node_modules/svelte/src/internal/server/index.js +0 -490
- package/dist/utils/node_modules/svelte/src/internal/server/render-context.js +0 -86
- package/dist/utils/node_modules/svelte/src/internal/server/renderer.js +0 -770
- package/dist/utils/node_modules/svelte/src/internal/server/warnings.js +0 -29
- package/dist/utils/node_modules/svelte/src/internal/shared/attributes.js +0 -223
- package/dist/utils/node_modules/svelte/src/internal/shared/clone.js +0 -137
- package/dist/utils/node_modules/svelte/src/internal/shared/dev.js +0 -65
- package/dist/utils/node_modules/svelte/src/internal/shared/errors.js +0 -134
- package/dist/utils/node_modules/svelte/src/internal/shared/utils.js +0 -118
- package/dist/utils/node_modules/svelte/src/internal/shared/validate.js +0 -47
- package/dist/utils/node_modules/svelte/src/internal/shared/warnings.js +0 -40
- package/dist/utils/node_modules/svelte/src/legacy/legacy-client.js +0 -280
- package/dist/utils/node_modules/svelte/src/legacy/legacy-server.js +0 -112
- package/dist/utils/node_modules/svelte/src/motion/index.js +0 -32
- package/dist/utils/node_modules/svelte/src/motion/spring.js +0 -369
- package/dist/utils/node_modules/svelte/src/motion/tweened.js +0 -306
- package/dist/utils/node_modules/svelte/src/motion/utils.js +0 -7
- package/dist/utils/node_modules/svelte/src/reactivity/create-subscriber.js +0 -95
- package/dist/utils/node_modules/svelte/src/reactivity/date.js +0 -118
- package/dist/utils/node_modules/svelte/src/reactivity/index-client.js +0 -7
- package/dist/utils/node_modules/svelte/src/reactivity/index-server.js +0 -23
- package/dist/utils/node_modules/svelte/src/reactivity/map.js +0 -273
- package/dist/utils/node_modules/svelte/src/reactivity/media-query.js +0 -55
- package/dist/utils/node_modules/svelte/src/reactivity/reactive-value.js +0 -24
- package/dist/utils/node_modules/svelte/src/reactivity/set.js +0 -213
- package/dist/utils/node_modules/svelte/src/reactivity/url-search-params.js +0 -174
- package/dist/utils/node_modules/svelte/src/reactivity/url.js +0 -205
- package/dist/utils/node_modules/svelte/src/reactivity/window/index.js +0 -161
- package/dist/utils/node_modules/svelte/src/server/index.js +0 -1
- package/dist/utils/node_modules/svelte/src/store/index-client.js +0 -169
- package/dist/utils/node_modules/svelte/src/store/index-server.js +0 -101
- package/dist/utils/node_modules/svelte/src/store/shared/index.js +0 -209
- package/dist/utils/node_modules/svelte/src/store/utils.js +0 -36
- package/dist/utils/node_modules/svelte/src/transition/index.js +0 -300
- package/dist/utils/node_modules/svelte/src/utils.js +0 -491
- package/dist/utils/node_modules/svelte/src/version.js +0 -8
- package/dist/utils/node_modules/typescript/LICENSE.txt +0 -55
- package/dist/utils/node_modules/typescript/README.md +0 -50
- package/dist/utils/node_modules/typescript/SECURITY.md +0 -41
- package/dist/utils/node_modules/typescript/ThirdPartyNoticeText.txt +0 -193
- package/dist/utils/node_modules/typescript/bin/tsc +0 -2
- package/dist/utils/node_modules/typescript/bin/tsserver +0 -2
- package/dist/utils/node_modules/typescript/lib/_tsc.js +0 -133818
- package/dist/utils/node_modules/typescript/lib/_tsserver.js +0 -659
- package/dist/utils/node_modules/typescript/lib/_typingsInstaller.js +0 -222
- package/dist/utils/node_modules/typescript/lib/cs/diagnosticMessages.generated.json +0 -2122
- package/dist/utils/node_modules/typescript/lib/de/diagnosticMessages.generated.json +0 -2122
- package/dist/utils/node_modules/typescript/lib/es/diagnosticMessages.generated.json +0 -2122
- package/dist/utils/node_modules/typescript/lib/fr/diagnosticMessages.generated.json +0 -2122
- package/dist/utils/node_modules/typescript/lib/it/diagnosticMessages.generated.json +0 -2122
- package/dist/utils/node_modules/typescript/lib/ja/diagnosticMessages.generated.json +0 -2122
- package/dist/utils/node_modules/typescript/lib/ko/diagnosticMessages.generated.json +0 -2122
- package/dist/utils/node_modules/typescript/lib/pl/diagnosticMessages.generated.json +0 -2122
- package/dist/utils/node_modules/typescript/lib/pt-br/diagnosticMessages.generated.json +0 -2122
- package/dist/utils/node_modules/typescript/lib/ru/diagnosticMessages.generated.json +0 -2122
- package/dist/utils/node_modules/typescript/lib/tr/diagnosticMessages.generated.json +0 -2122
- package/dist/utils/node_modules/typescript/lib/tsc.js +0 -8
- package/dist/utils/node_modules/typescript/lib/tsserver.js +0 -8
- package/dist/utils/node_modules/typescript/lib/tsserverlibrary.js +0 -21
- package/dist/utils/node_modules/typescript/lib/typesMap.json +0 -497
- package/dist/utils/node_modules/typescript/lib/typescript.js +0 -200276
- package/dist/utils/node_modules/typescript/lib/typingsInstaller.js +0 -8
- package/dist/utils/node_modules/typescript/lib/watchGuard.js +0 -53
- package/dist/utils/node_modules/typescript/lib/zh-cn/diagnosticMessages.generated.json +0 -2122
- package/dist/utils/node_modules/typescript/lib/zh-tw/diagnosticMessages.generated.json +0 -2122
- package/dist/utils/node_modules/typescript/package.json +0 -120
- package/dist/utils/package.json +0 -27
|
@@ -1,1412 +0,0 @@
|
|
|
1
|
-
/** @import { BinaryOperator, ClassDeclaration, Expression, FunctionDeclaration, Identifier, ImportDeclaration, MemberExpression, LogicalOperator, Node, Pattern, UnaryOperator, VariableDeclarator, Super, SimpleLiteral, FunctionExpression, ArrowFunctionExpression } from 'estree' */
|
|
2
|
-
/** @import { Context, Visitor } from 'zimmerframe' */
|
|
3
|
-
/** @import { AST, BindingKind, DeclarationKind } from '#compiler' */
|
|
4
|
-
import is_reference from 'is-reference';
|
|
5
|
-
import { walk } from 'zimmerframe';
|
|
6
|
-
import { ExpressionMetadata } from './nodes.js';
|
|
7
|
-
import * as b from '#compiler/builders';
|
|
8
|
-
import * as e from '../errors.js';
|
|
9
|
-
import {
|
|
10
|
-
extract_identifiers,
|
|
11
|
-
extract_identifiers_from_destructuring,
|
|
12
|
-
object,
|
|
13
|
-
unwrap_pattern
|
|
14
|
-
} from '../utils/ast.js';
|
|
15
|
-
import { is_reserved, is_rune } from '../../utils.js';
|
|
16
|
-
import { determine_slot } from '../utils/slot.js';
|
|
17
|
-
import { validate_identifier_name } from './2-analyze/visitors/shared/utils.js';
|
|
18
|
-
|
|
19
|
-
const UNKNOWN = Symbol('unknown');
|
|
20
|
-
/** Includes `BigInt` */
|
|
21
|
-
const NUMBER = Symbol('number');
|
|
22
|
-
const STRING = Symbol('string');
|
|
23
|
-
const FUNCTION = Symbol('string');
|
|
24
|
-
|
|
25
|
-
/** @type {Record<string, [type: typeof NUMBER | typeof STRING | typeof UNKNOWN, fn?: Function]>} */
|
|
26
|
-
const globals = {
|
|
27
|
-
BigInt: [NUMBER],
|
|
28
|
-
'Math.min': [NUMBER, Math.min],
|
|
29
|
-
'Math.max': [NUMBER, Math.max],
|
|
30
|
-
'Math.random': [NUMBER],
|
|
31
|
-
'Math.floor': [NUMBER, Math.floor],
|
|
32
|
-
// @ts-ignore
|
|
33
|
-
'Math.f16round': [NUMBER, Math.f16round],
|
|
34
|
-
'Math.round': [NUMBER, Math.round],
|
|
35
|
-
'Math.abs': [NUMBER, Math.abs],
|
|
36
|
-
'Math.acos': [NUMBER, Math.acos],
|
|
37
|
-
'Math.asin': [NUMBER, Math.asin],
|
|
38
|
-
'Math.atan': [NUMBER, Math.atan],
|
|
39
|
-
'Math.atan2': [NUMBER, Math.atan2],
|
|
40
|
-
'Math.ceil': [NUMBER, Math.ceil],
|
|
41
|
-
'Math.cos': [NUMBER, Math.cos],
|
|
42
|
-
'Math.sin': [NUMBER, Math.sin],
|
|
43
|
-
'Math.tan': [NUMBER, Math.tan],
|
|
44
|
-
'Math.exp': [NUMBER, Math.exp],
|
|
45
|
-
'Math.log': [NUMBER, Math.log],
|
|
46
|
-
'Math.pow': [NUMBER, Math.pow],
|
|
47
|
-
'Math.sqrt': [NUMBER, Math.sqrt],
|
|
48
|
-
'Math.clz32': [NUMBER, Math.clz32],
|
|
49
|
-
'Math.imul': [NUMBER, Math.imul],
|
|
50
|
-
'Math.sign': [NUMBER, Math.sign],
|
|
51
|
-
'Math.log10': [NUMBER, Math.log10],
|
|
52
|
-
'Math.log2': [NUMBER, Math.log2],
|
|
53
|
-
'Math.log1p': [NUMBER, Math.log1p],
|
|
54
|
-
'Math.expm1': [NUMBER, Math.expm1],
|
|
55
|
-
'Math.cosh': [NUMBER, Math.cosh],
|
|
56
|
-
'Math.sinh': [NUMBER, Math.sinh],
|
|
57
|
-
'Math.tanh': [NUMBER, Math.tanh],
|
|
58
|
-
'Math.acosh': [NUMBER, Math.acosh],
|
|
59
|
-
'Math.asinh': [NUMBER, Math.asinh],
|
|
60
|
-
'Math.atanh': [NUMBER, Math.atanh],
|
|
61
|
-
'Math.trunc': [NUMBER, Math.trunc],
|
|
62
|
-
'Math.fround': [NUMBER, Math.fround],
|
|
63
|
-
'Math.cbrt': [NUMBER, Math.cbrt],
|
|
64
|
-
Number: [NUMBER, Number],
|
|
65
|
-
'Number.isInteger': [NUMBER, Number.isInteger],
|
|
66
|
-
'Number.isFinite': [NUMBER, Number.isFinite],
|
|
67
|
-
'Number.isNaN': [NUMBER, Number.isNaN],
|
|
68
|
-
'Number.isSafeInteger': [NUMBER, Number.isSafeInteger],
|
|
69
|
-
'Number.parseFloat': [NUMBER, Number.parseFloat],
|
|
70
|
-
'Number.parseInt': [NUMBER, Number.parseInt],
|
|
71
|
-
String: [STRING, String],
|
|
72
|
-
'String.fromCharCode': [STRING, String.fromCharCode],
|
|
73
|
-
'String.fromCodePoint': [STRING, String.fromCodePoint]
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
/** @type {Record<string, any>} */
|
|
77
|
-
const global_constants = {
|
|
78
|
-
'Math.PI': Math.PI,
|
|
79
|
-
'Math.E': Math.E,
|
|
80
|
-
'Math.LN10': Math.LN10,
|
|
81
|
-
'Math.LN2': Math.LN2,
|
|
82
|
-
'Math.LOG10E': Math.LOG10E,
|
|
83
|
-
'Math.LOG2E': Math.LOG2E,
|
|
84
|
-
'Math.SQRT2': Math.SQRT2,
|
|
85
|
-
'Math.SQRT1_2': Math.SQRT1_2
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
export class Binding {
|
|
89
|
-
/** @type {Scope} */
|
|
90
|
-
scope;
|
|
91
|
-
|
|
92
|
-
/** @type {Identifier} */
|
|
93
|
-
node;
|
|
94
|
-
|
|
95
|
-
/** @type {BindingKind} */
|
|
96
|
-
kind;
|
|
97
|
-
|
|
98
|
-
/** @type {DeclarationKind} */
|
|
99
|
-
declaration_kind;
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* What the value was initialized with.
|
|
103
|
-
* For destructured props such as `let { foo = 'bar' } = $props()` this is `'bar'` and not `$props()`
|
|
104
|
-
* @type {null | Expression | FunctionDeclaration | ClassDeclaration | ImportDeclaration | AST.EachBlock | AST.SnippetBlock}
|
|
105
|
-
*/
|
|
106
|
-
initial = null;
|
|
107
|
-
|
|
108
|
-
/** @type {Array<{ node: Identifier; path: AST.SvelteNode[] }>} */
|
|
109
|
-
references = [];
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* (Re)assignments of this binding. Includes declarations such as `function x() {}`.
|
|
113
|
-
* @type {Array<{ value: Expression; scope: Scope }>}
|
|
114
|
-
*/
|
|
115
|
-
assignments = [];
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* For `legacy_reactive`: its reactive dependencies
|
|
119
|
-
* @type {Binding[]}
|
|
120
|
-
*/
|
|
121
|
-
legacy_dependencies = [];
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Legacy props: the `class` in `{ export klass as class}`. $props(): The `class` in { class: klass } = $props()
|
|
125
|
-
* @type {string | null}
|
|
126
|
-
*/
|
|
127
|
-
prop_alias = null;
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Additional metadata, varies per binding type
|
|
131
|
-
* @type {null | { inside_rest?: boolean; is_template_declaration?: boolean; exclude_props?: string[] }}
|
|
132
|
-
*/
|
|
133
|
-
metadata = null;
|
|
134
|
-
|
|
135
|
-
mutated = false;
|
|
136
|
-
reassigned = false;
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Instance-level declarations may follow (or contain) a top-level `await`. In these cases,
|
|
140
|
-
* any reads that occur in the template must wait for the corresponding promise to resolve
|
|
141
|
-
* otherwise the initial value will not have been assigned.
|
|
142
|
-
* It is a member expression of the form `$$blockers[n]`.
|
|
143
|
-
* TODO the blocker is set during transform which feels a bit grubby
|
|
144
|
-
* @type {MemberExpression | null}
|
|
145
|
-
*/
|
|
146
|
-
blocker = null;
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
*
|
|
150
|
-
* @param {Scope} scope
|
|
151
|
-
* @param {Identifier} node
|
|
152
|
-
* @param {BindingKind} kind
|
|
153
|
-
* @param {DeclarationKind} declaration_kind
|
|
154
|
-
* @param {Binding['initial']} initial
|
|
155
|
-
*/
|
|
156
|
-
constructor(scope, node, kind, declaration_kind, initial) {
|
|
157
|
-
this.scope = scope;
|
|
158
|
-
this.node = node;
|
|
159
|
-
this.initial = initial;
|
|
160
|
-
this.kind = kind;
|
|
161
|
-
this.declaration_kind = declaration_kind;
|
|
162
|
-
|
|
163
|
-
if (initial) {
|
|
164
|
-
this.assignments.push({ value: /** @type {Expression} */ (initial), scope });
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
get updated() {
|
|
169
|
-
return this.mutated || this.reassigned;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* @returns {this is Binding & { initial: ArrowFunctionExpression | FunctionDeclaration | FunctionExpression }}
|
|
174
|
-
*/
|
|
175
|
-
is_function() {
|
|
176
|
-
if (this.updated) {
|
|
177
|
-
// even if it's reassigned to another function,
|
|
178
|
-
// we can't use it directly as e.g. an event handler
|
|
179
|
-
return false;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
const type = this.initial?.type;
|
|
183
|
-
|
|
184
|
-
return (
|
|
185
|
-
type === 'ArrowFunctionExpression' ||
|
|
186
|
-
type === 'FunctionExpression' ||
|
|
187
|
-
type === 'FunctionDeclaration'
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
class Evaluation {
|
|
193
|
-
/** @type {Set<any>} */
|
|
194
|
-
values;
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* True if there is exactly one possible value
|
|
198
|
-
* @readonly
|
|
199
|
-
* @type {boolean}
|
|
200
|
-
*/
|
|
201
|
-
is_known = true;
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* True if the possible values contains `UNKNOWN`
|
|
205
|
-
* @readonly
|
|
206
|
-
* @type {boolean}
|
|
207
|
-
*/
|
|
208
|
-
has_unknown = false;
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* True if the value is known to not be null/undefined
|
|
212
|
-
* @readonly
|
|
213
|
-
* @type {boolean}
|
|
214
|
-
*/
|
|
215
|
-
is_defined = true;
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* True if the value is known to be a string
|
|
219
|
-
* @readonly
|
|
220
|
-
* @type {boolean}
|
|
221
|
-
*/
|
|
222
|
-
is_string = true;
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* True if the value is known to be a number
|
|
226
|
-
* @readonly
|
|
227
|
-
* @type {boolean}
|
|
228
|
-
*/
|
|
229
|
-
is_number = true;
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* True if the value is known to be a function
|
|
233
|
-
* @readonly
|
|
234
|
-
* @type {boolean}
|
|
235
|
-
*/
|
|
236
|
-
is_function = true;
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* @readonly
|
|
240
|
-
* @type {any}
|
|
241
|
-
*/
|
|
242
|
-
value = undefined;
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
*
|
|
246
|
-
* @param {Scope} scope
|
|
247
|
-
* @param {Expression | FunctionDeclaration} expression
|
|
248
|
-
* @param {Set<any>} values
|
|
249
|
-
*/
|
|
250
|
-
constructor(scope, expression, values) {
|
|
251
|
-
current_evaluations.set(expression, this);
|
|
252
|
-
|
|
253
|
-
this.values = values;
|
|
254
|
-
|
|
255
|
-
switch (expression.type) {
|
|
256
|
-
case 'Literal': {
|
|
257
|
-
this.values.add(expression.value);
|
|
258
|
-
break;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
case 'Identifier': {
|
|
262
|
-
const binding = scope.get(expression.name);
|
|
263
|
-
|
|
264
|
-
if (binding) {
|
|
265
|
-
if (
|
|
266
|
-
binding.initial?.type === 'CallExpression' &&
|
|
267
|
-
get_rune(binding.initial, scope) === '$props.id'
|
|
268
|
-
) {
|
|
269
|
-
this.values.add(STRING);
|
|
270
|
-
break;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
const is_prop =
|
|
274
|
-
binding.kind === 'prop' ||
|
|
275
|
-
binding.kind === 'rest_prop' ||
|
|
276
|
-
binding.kind === 'bindable_prop';
|
|
277
|
-
|
|
278
|
-
if (binding.initial?.type === 'EachBlock' && binding.initial.index === expression.name) {
|
|
279
|
-
this.values.add(NUMBER);
|
|
280
|
-
break;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
if (binding.initial?.type === 'SnippetBlock') {
|
|
284
|
-
this.is_defined = true;
|
|
285
|
-
this.is_known = false;
|
|
286
|
-
this.values.add(UNKNOWN);
|
|
287
|
-
break;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
if (!binding.updated && binding.initial !== null && !is_prop) {
|
|
291
|
-
binding.scope.evaluate(/** @type {Expression} */ (binding.initial), this.values);
|
|
292
|
-
break;
|
|
293
|
-
}
|
|
294
|
-
} else if (expression.name === 'undefined') {
|
|
295
|
-
this.values.add(undefined);
|
|
296
|
-
break;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
// TODO glean what we can from reassignments
|
|
300
|
-
// TODO one day, expose props and imports somehow
|
|
301
|
-
|
|
302
|
-
this.values.add(UNKNOWN);
|
|
303
|
-
break;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
case 'BinaryExpression': {
|
|
307
|
-
const a = scope.evaluate(/** @type {Expression} */ (expression.left)); // `left` cannot be `PrivateIdentifier` unless operator is `in`
|
|
308
|
-
const b = scope.evaluate(expression.right);
|
|
309
|
-
|
|
310
|
-
if (a.is_known && b.is_known) {
|
|
311
|
-
this.values.add(binary[expression.operator](a.value, b.value));
|
|
312
|
-
break;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
switch (expression.operator) {
|
|
316
|
-
case '!=':
|
|
317
|
-
case '!==':
|
|
318
|
-
case '<':
|
|
319
|
-
case '<=':
|
|
320
|
-
case '>':
|
|
321
|
-
case '>=':
|
|
322
|
-
case '==':
|
|
323
|
-
case '===':
|
|
324
|
-
case 'in':
|
|
325
|
-
case 'instanceof':
|
|
326
|
-
this.values.add(true);
|
|
327
|
-
this.values.add(false);
|
|
328
|
-
break;
|
|
329
|
-
|
|
330
|
-
case '%':
|
|
331
|
-
case '&':
|
|
332
|
-
case '*':
|
|
333
|
-
case '**':
|
|
334
|
-
case '-':
|
|
335
|
-
case '/':
|
|
336
|
-
case '<<':
|
|
337
|
-
case '>>':
|
|
338
|
-
case '>>>':
|
|
339
|
-
case '^':
|
|
340
|
-
case '|':
|
|
341
|
-
this.values.add(NUMBER);
|
|
342
|
-
break;
|
|
343
|
-
|
|
344
|
-
case '+':
|
|
345
|
-
if (a.is_string || b.is_string) {
|
|
346
|
-
this.values.add(STRING);
|
|
347
|
-
} else if (a.is_number && b.is_number) {
|
|
348
|
-
this.values.add(NUMBER);
|
|
349
|
-
} else {
|
|
350
|
-
this.values.add(STRING);
|
|
351
|
-
this.values.add(NUMBER);
|
|
352
|
-
}
|
|
353
|
-
break;
|
|
354
|
-
|
|
355
|
-
default:
|
|
356
|
-
this.values.add(UNKNOWN);
|
|
357
|
-
}
|
|
358
|
-
break;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
case 'ConditionalExpression': {
|
|
362
|
-
const test = scope.evaluate(expression.test);
|
|
363
|
-
const consequent = scope.evaluate(expression.consequent);
|
|
364
|
-
const alternate = scope.evaluate(expression.alternate);
|
|
365
|
-
|
|
366
|
-
if (test.is_known) {
|
|
367
|
-
for (const value of (test.value ? consequent : alternate).values) {
|
|
368
|
-
this.values.add(value);
|
|
369
|
-
}
|
|
370
|
-
} else {
|
|
371
|
-
for (const value of consequent.values) {
|
|
372
|
-
this.values.add(value);
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
for (const value of alternate.values) {
|
|
376
|
-
this.values.add(value);
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
break;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
case 'LogicalExpression': {
|
|
383
|
-
const a = scope.evaluate(expression.left);
|
|
384
|
-
const b = scope.evaluate(expression.right);
|
|
385
|
-
|
|
386
|
-
if (a.is_known) {
|
|
387
|
-
if (b.is_known) {
|
|
388
|
-
this.values.add(logical[expression.operator](a.value, b.value));
|
|
389
|
-
break;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
if (
|
|
393
|
-
(expression.operator === '&&' && !a.value) ||
|
|
394
|
-
(expression.operator === '||' && a.value) ||
|
|
395
|
-
(expression.operator === '??' && a.value != null)
|
|
396
|
-
) {
|
|
397
|
-
this.values.add(a.value);
|
|
398
|
-
} else {
|
|
399
|
-
for (const value of b.values) {
|
|
400
|
-
this.values.add(value);
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
break;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
for (const value of a.values) {
|
|
408
|
-
this.values.add(value);
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
for (const value of b.values) {
|
|
412
|
-
this.values.add(value);
|
|
413
|
-
}
|
|
414
|
-
break;
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
case 'UnaryExpression': {
|
|
418
|
-
const argument = scope.evaluate(expression.argument);
|
|
419
|
-
|
|
420
|
-
if (argument.is_known) {
|
|
421
|
-
this.values.add(unary[expression.operator](argument.value));
|
|
422
|
-
break;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
switch (expression.operator) {
|
|
426
|
-
case '!':
|
|
427
|
-
case 'delete':
|
|
428
|
-
this.values.add(false);
|
|
429
|
-
this.values.add(true);
|
|
430
|
-
break;
|
|
431
|
-
|
|
432
|
-
case '+':
|
|
433
|
-
case '-':
|
|
434
|
-
case '~':
|
|
435
|
-
this.values.add(NUMBER);
|
|
436
|
-
break;
|
|
437
|
-
|
|
438
|
-
case 'typeof':
|
|
439
|
-
this.values.add(STRING);
|
|
440
|
-
break;
|
|
441
|
-
|
|
442
|
-
case 'void':
|
|
443
|
-
this.values.add(undefined);
|
|
444
|
-
break;
|
|
445
|
-
|
|
446
|
-
default:
|
|
447
|
-
this.values.add(UNKNOWN);
|
|
448
|
-
}
|
|
449
|
-
break;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
case 'CallExpression': {
|
|
453
|
-
const keypath = get_global_keypath(expression.callee, scope);
|
|
454
|
-
|
|
455
|
-
if (keypath) {
|
|
456
|
-
if (is_rune(keypath)) {
|
|
457
|
-
const arg = /** @type {Expression | undefined} */ (expression.arguments[0]);
|
|
458
|
-
|
|
459
|
-
switch (keypath) {
|
|
460
|
-
case '$state':
|
|
461
|
-
case '$state.raw':
|
|
462
|
-
case '$derived':
|
|
463
|
-
if (arg) {
|
|
464
|
-
scope.evaluate(arg, this.values);
|
|
465
|
-
} else {
|
|
466
|
-
this.values.add(undefined);
|
|
467
|
-
}
|
|
468
|
-
break;
|
|
469
|
-
|
|
470
|
-
case '$props.id':
|
|
471
|
-
this.values.add(STRING);
|
|
472
|
-
break;
|
|
473
|
-
|
|
474
|
-
case '$effect.tracking':
|
|
475
|
-
this.values.add(false);
|
|
476
|
-
this.values.add(true);
|
|
477
|
-
break;
|
|
478
|
-
|
|
479
|
-
case '$derived.by':
|
|
480
|
-
if (arg?.type === 'ArrowFunctionExpression' && arg.body.type !== 'BlockStatement') {
|
|
481
|
-
scope.evaluate(arg.body, this.values);
|
|
482
|
-
break;
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
this.values.add(UNKNOWN);
|
|
486
|
-
break;
|
|
487
|
-
|
|
488
|
-
default: {
|
|
489
|
-
this.values.add(UNKNOWN);
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
break;
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
if (
|
|
497
|
-
Object.hasOwn(globals, keypath) &&
|
|
498
|
-
expression.arguments.every((arg) => arg.type !== 'SpreadElement')
|
|
499
|
-
) {
|
|
500
|
-
const [type, fn] = globals[keypath];
|
|
501
|
-
const values = expression.arguments.map((arg) => scope.evaluate(arg));
|
|
502
|
-
|
|
503
|
-
if (fn && values.every((e) => e.is_known)) {
|
|
504
|
-
this.values.add(fn(...values.map((e) => e.value)));
|
|
505
|
-
} else {
|
|
506
|
-
this.values.add(type);
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
break;
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
this.values.add(UNKNOWN);
|
|
514
|
-
break;
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
case 'TemplateLiteral': {
|
|
518
|
-
let result = expression.quasis[0].value.cooked;
|
|
519
|
-
|
|
520
|
-
for (let i = 0; i < expression.expressions.length; i += 1) {
|
|
521
|
-
const e = scope.evaluate(expression.expressions[i]);
|
|
522
|
-
|
|
523
|
-
if (e.is_known) {
|
|
524
|
-
result += e.value + expression.quasis[i + 1].value.cooked;
|
|
525
|
-
} else {
|
|
526
|
-
this.values.add(STRING);
|
|
527
|
-
break;
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
this.values.add(result);
|
|
532
|
-
break;
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
case 'MemberExpression': {
|
|
536
|
-
const keypath = get_global_keypath(expression, scope);
|
|
537
|
-
|
|
538
|
-
if (keypath && Object.hasOwn(global_constants, keypath)) {
|
|
539
|
-
this.values.add(global_constants[keypath]);
|
|
540
|
-
break;
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
this.values.add(UNKNOWN);
|
|
544
|
-
break;
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
case 'ArrowFunctionExpression':
|
|
548
|
-
case 'FunctionExpression':
|
|
549
|
-
case 'FunctionDeclaration': {
|
|
550
|
-
this.values.add(FUNCTION);
|
|
551
|
-
break;
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
default: {
|
|
555
|
-
this.values.add(UNKNOWN);
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
for (const value of this.values) {
|
|
560
|
-
this.value = value; // saves having special logic for `size === 1`
|
|
561
|
-
|
|
562
|
-
if (value !== STRING && typeof value !== 'string') {
|
|
563
|
-
this.is_string = false;
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
if (value !== NUMBER && typeof value !== 'number') {
|
|
567
|
-
this.is_number = false;
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
if (value !== FUNCTION) {
|
|
571
|
-
this.is_function = false;
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
if (value == null || value === UNKNOWN) {
|
|
575
|
-
this.is_defined = false;
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
if (value === UNKNOWN) {
|
|
579
|
-
this.has_unknown = true;
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
if (this.values.size > 1 || typeof this.value === 'symbol') {
|
|
584
|
-
this.is_known = false;
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
current_evaluations.delete(expression);
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
export class Scope {
|
|
592
|
-
/** @type {ScopeRoot} */
|
|
593
|
-
root;
|
|
594
|
-
|
|
595
|
-
/**
|
|
596
|
-
* The immediate parent scope
|
|
597
|
-
* @type {Scope | null}
|
|
598
|
-
*/
|
|
599
|
-
parent;
|
|
600
|
-
|
|
601
|
-
/**
|
|
602
|
-
* Whether or not `var` declarations are contained by this scope
|
|
603
|
-
* @type {boolean}
|
|
604
|
-
*/
|
|
605
|
-
#porous;
|
|
606
|
-
|
|
607
|
-
/**
|
|
608
|
-
* A map of every identifier declared by this scope, and all the
|
|
609
|
-
* identifiers that reference it
|
|
610
|
-
* @type {Map<string, Binding>}
|
|
611
|
-
*/
|
|
612
|
-
declarations = new Map();
|
|
613
|
-
|
|
614
|
-
/**
|
|
615
|
-
* A map of declarators to the bindings they declare
|
|
616
|
-
* @type {Map<VariableDeclarator | AST.LetDirective, Binding[]>}
|
|
617
|
-
*/
|
|
618
|
-
declarators = new Map();
|
|
619
|
-
|
|
620
|
-
/**
|
|
621
|
-
* A set of all the names referenced with this scope
|
|
622
|
-
* — useful for generating unique names
|
|
623
|
-
* @type {Map<string, { node: Identifier; path: AST.SvelteNode[] }[]>}
|
|
624
|
-
*/
|
|
625
|
-
references = new Map();
|
|
626
|
-
|
|
627
|
-
/**
|
|
628
|
-
* The scope depth allows us to determine if a state variable is referenced in its own scope,
|
|
629
|
-
* which is usually an error. Block statements do not increase this value
|
|
630
|
-
*/
|
|
631
|
-
function_depth = 0;
|
|
632
|
-
|
|
633
|
-
/**
|
|
634
|
-
* If tracing of reactive dependencies is enabled for this scope
|
|
635
|
-
* @type {null | Expression}
|
|
636
|
-
*/
|
|
637
|
-
tracing = null;
|
|
638
|
-
|
|
639
|
-
/**
|
|
640
|
-
*
|
|
641
|
-
* @param {ScopeRoot} root
|
|
642
|
-
* @param {Scope | null} parent
|
|
643
|
-
* @param {boolean} porous
|
|
644
|
-
*/
|
|
645
|
-
constructor(root, parent, porous) {
|
|
646
|
-
this.root = root;
|
|
647
|
-
this.parent = parent;
|
|
648
|
-
this.#porous = porous;
|
|
649
|
-
this.function_depth = parent ? parent.function_depth + (porous ? 0 : 1) : 0;
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
/**
|
|
653
|
-
* @param {Identifier} node
|
|
654
|
-
* @param {Binding['kind']} kind
|
|
655
|
-
* @param {DeclarationKind} declaration_kind
|
|
656
|
-
* @param {null | Expression | FunctionDeclaration | ClassDeclaration | ImportDeclaration | AST.EachBlock | AST.SnippetBlock} initial
|
|
657
|
-
* @returns {Binding}
|
|
658
|
-
*/
|
|
659
|
-
declare(node, kind, declaration_kind, initial = null) {
|
|
660
|
-
if (this.parent) {
|
|
661
|
-
if (declaration_kind === 'var' && this.#porous) {
|
|
662
|
-
return this.parent.declare(node, kind, declaration_kind);
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
if (declaration_kind === 'import') {
|
|
666
|
-
return this.parent.declare(node, kind, declaration_kind, initial);
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
if (this.declarations.has(node.name)) {
|
|
671
|
-
const binding = this.declarations.get(node.name);
|
|
672
|
-
if (binding && binding.declaration_kind !== 'var' && declaration_kind !== 'var') {
|
|
673
|
-
// This also errors on function types, but that's arguably a good thing
|
|
674
|
-
// declaring function twice is also caught by acorn in the parse phase
|
|
675
|
-
e.declaration_duplicate(node, node.name);
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
const binding = new Binding(this, node, kind, declaration_kind, initial);
|
|
680
|
-
|
|
681
|
-
validate_identifier_name(binding, this.function_depth);
|
|
682
|
-
|
|
683
|
-
this.declarations.set(node.name, binding);
|
|
684
|
-
this.root.conflicts.add(node.name);
|
|
685
|
-
return binding;
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
child(porous = false) {
|
|
689
|
-
return new Scope(this.root, this, porous);
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
/**
|
|
693
|
-
* @param {string} preferred_name
|
|
694
|
-
* @returns {string}
|
|
695
|
-
*/
|
|
696
|
-
generate(preferred_name) {
|
|
697
|
-
if (this.#porous) {
|
|
698
|
-
return /** @type {Scope} */ (this.parent).generate(preferred_name);
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
preferred_name = preferred_name.replace(/[^a-zA-Z0-9_$]/g, '_').replace(/^[0-9]/, '_');
|
|
702
|
-
let name = preferred_name;
|
|
703
|
-
let n = 1;
|
|
704
|
-
|
|
705
|
-
while (
|
|
706
|
-
this.references.has(name) ||
|
|
707
|
-
this.declarations.has(name) ||
|
|
708
|
-
this.root.conflicts.has(name) ||
|
|
709
|
-
is_reserved(name)
|
|
710
|
-
) {
|
|
711
|
-
name = `${preferred_name}_${n++}`;
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
this.references.set(name, []);
|
|
715
|
-
this.root.conflicts.add(name);
|
|
716
|
-
return name;
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
/**
|
|
720
|
-
* @param {string} name
|
|
721
|
-
* @returns {Binding | null}
|
|
722
|
-
*/
|
|
723
|
-
get(name) {
|
|
724
|
-
return this.declarations.get(name) ?? this.parent?.get(name) ?? null;
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
/**
|
|
728
|
-
* @param {VariableDeclarator | AST.LetDirective} node
|
|
729
|
-
* @returns {Binding[]}
|
|
730
|
-
*/
|
|
731
|
-
get_bindings(node) {
|
|
732
|
-
const bindings = this.declarators.get(node);
|
|
733
|
-
if (!bindings) {
|
|
734
|
-
throw new Error('No binding found for declarator');
|
|
735
|
-
}
|
|
736
|
-
return bindings;
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
/**
|
|
740
|
-
* @param {string} name
|
|
741
|
-
* @returns {Scope | null}
|
|
742
|
-
*/
|
|
743
|
-
owner(name) {
|
|
744
|
-
return this.declarations.has(name) ? this : this.parent && this.parent.owner(name);
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
/**
|
|
748
|
-
* @param {Identifier} node
|
|
749
|
-
* @param {AST.SvelteNode[]} path
|
|
750
|
-
*/
|
|
751
|
-
reference(node, path) {
|
|
752
|
-
path = [...path]; // ensure that mutations to path afterwards don't affect this reference
|
|
753
|
-
let references = this.references.get(node.name);
|
|
754
|
-
|
|
755
|
-
if (!references) this.references.set(node.name, (references = []));
|
|
756
|
-
|
|
757
|
-
references.push({ node, path });
|
|
758
|
-
|
|
759
|
-
const binding = this.declarations.get(node.name);
|
|
760
|
-
if (binding) {
|
|
761
|
-
binding.references.push({ node, path });
|
|
762
|
-
} else if (this.parent) {
|
|
763
|
-
this.parent.reference(node, path);
|
|
764
|
-
} else {
|
|
765
|
-
// no binding was found, and this is the top level scope,
|
|
766
|
-
// which means this is a global
|
|
767
|
-
this.root.conflicts.add(node.name);
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
/**
|
|
772
|
-
* Does partial evaluation to find an exact value or at least the rough type of the expression.
|
|
773
|
-
* Only call this once scope has been fully generated in a first pass,
|
|
774
|
-
* else this evaluates on incomplete data and may yield wrong results.
|
|
775
|
-
* @param {Expression} expression
|
|
776
|
-
* @param {Set<any>} [values]
|
|
777
|
-
*/
|
|
778
|
-
evaluate(expression, values = new Set()) {
|
|
779
|
-
const current = current_evaluations.get(expression);
|
|
780
|
-
if (current) return current;
|
|
781
|
-
|
|
782
|
-
return new Evaluation(this, expression, values);
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
/**
|
|
787
|
-
* Track which expressions are currently being evaluated — this allows
|
|
788
|
-
* us to prevent cyclical evaluations without passing the map around
|
|
789
|
-
* @type {Map<Expression | FunctionDeclaration, Evaluation>}
|
|
790
|
-
*/
|
|
791
|
-
const current_evaluations = new Map();
|
|
792
|
-
|
|
793
|
-
/** @type {Record<BinaryOperator, (left: any, right: any) => any>} */
|
|
794
|
-
const binary = {
|
|
795
|
-
'!=': (left, right) => left != right,
|
|
796
|
-
'!==': (left, right) => left !== right,
|
|
797
|
-
'<': (left, right) => left < right,
|
|
798
|
-
'<=': (left, right) => left <= right,
|
|
799
|
-
'>': (left, right) => left > right,
|
|
800
|
-
'>=': (left, right) => left >= right,
|
|
801
|
-
'==': (left, right) => left == right,
|
|
802
|
-
'===': (left, right) => left === right,
|
|
803
|
-
in: (left, right) => left in right,
|
|
804
|
-
instanceof: (left, right) => left instanceof right,
|
|
805
|
-
'%': (left, right) => left % right,
|
|
806
|
-
'&': (left, right) => left & right,
|
|
807
|
-
'*': (left, right) => left * right,
|
|
808
|
-
'**': (left, right) => left ** right,
|
|
809
|
-
'+': (left, right) => left + right,
|
|
810
|
-
'-': (left, right) => left - right,
|
|
811
|
-
'/': (left, right) => left / right,
|
|
812
|
-
'<<': (left, right) => left << right,
|
|
813
|
-
'>>': (left, right) => left >> right,
|
|
814
|
-
'>>>': (left, right) => left >>> right,
|
|
815
|
-
'^': (left, right) => left ^ right,
|
|
816
|
-
'|': (left, right) => left | right
|
|
817
|
-
};
|
|
818
|
-
|
|
819
|
-
/** @type {Record<UnaryOperator, (argument: any) => any>} */
|
|
820
|
-
const unary = {
|
|
821
|
-
'-': (argument) => -argument,
|
|
822
|
-
'+': (argument) => +argument,
|
|
823
|
-
'!': (argument) => !argument,
|
|
824
|
-
'~': (argument) => ~argument,
|
|
825
|
-
typeof: (argument) => typeof argument,
|
|
826
|
-
void: () => undefined,
|
|
827
|
-
delete: () => true
|
|
828
|
-
};
|
|
829
|
-
|
|
830
|
-
/** @type {Record<LogicalOperator, (left: any, right: any) => any>} */
|
|
831
|
-
const logical = {
|
|
832
|
-
'||': (left, right) => left || right,
|
|
833
|
-
'&&': (left, right) => left && right,
|
|
834
|
-
'??': (left, right) => left ?? right
|
|
835
|
-
};
|
|
836
|
-
|
|
837
|
-
export class ScopeRoot {
|
|
838
|
-
/** @type {Set<string>} */
|
|
839
|
-
conflicts = new Set();
|
|
840
|
-
|
|
841
|
-
/**
|
|
842
|
-
* @param {string} preferred_name
|
|
843
|
-
*/
|
|
844
|
-
unique(preferred_name) {
|
|
845
|
-
preferred_name = preferred_name.replace(/[^a-zA-Z0-9_$]/g, '_');
|
|
846
|
-
let final_name = preferred_name;
|
|
847
|
-
let n = 1;
|
|
848
|
-
|
|
849
|
-
while (this.conflicts.has(final_name)) {
|
|
850
|
-
final_name = `${preferred_name}_${n++}`;
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
this.conflicts.add(final_name);
|
|
854
|
-
const id = b.id(final_name);
|
|
855
|
-
return id;
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
/**
|
|
860
|
-
* @param {AST.SvelteNode} ast
|
|
861
|
-
* @param {ScopeRoot} root
|
|
862
|
-
* @param {boolean} allow_reactive_declarations
|
|
863
|
-
* @param {Scope | null} parent
|
|
864
|
-
*/
|
|
865
|
-
export function create_scopes(ast, root, allow_reactive_declarations, parent) {
|
|
866
|
-
/** @typedef {{ scope: Scope }} State */
|
|
867
|
-
|
|
868
|
-
/**
|
|
869
|
-
* A map of node->associated scope. A node appearing in this map does not necessarily mean that it created a scope
|
|
870
|
-
* @type {Map<AST.SvelteNode, Scope>}
|
|
871
|
-
*/
|
|
872
|
-
const scopes = new Map();
|
|
873
|
-
const scope = new Scope(root, parent, false);
|
|
874
|
-
scopes.set(ast, scope);
|
|
875
|
-
|
|
876
|
-
/** @type {State} */
|
|
877
|
-
const state = { scope };
|
|
878
|
-
|
|
879
|
-
/** @type {[Scope, { node: Identifier; path: AST.SvelteNode[] }][]} */
|
|
880
|
-
const references = [];
|
|
881
|
-
|
|
882
|
-
/** @type {[Scope, Pattern | MemberExpression, Expression][]} */
|
|
883
|
-
const updates = [];
|
|
884
|
-
|
|
885
|
-
/**
|
|
886
|
-
* An array of reactive declarations, i.e. the `a` in `$: a = b * 2`
|
|
887
|
-
* @type {Identifier[]}
|
|
888
|
-
*/
|
|
889
|
-
const possible_implicit_declarations = [];
|
|
890
|
-
|
|
891
|
-
/**
|
|
892
|
-
* @param {Scope} scope
|
|
893
|
-
* @param {Pattern[]} params
|
|
894
|
-
*/
|
|
895
|
-
function add_params(scope, params) {
|
|
896
|
-
for (const param of params) {
|
|
897
|
-
for (const node of extract_identifiers(param)) {
|
|
898
|
-
scope.declare(node, 'normal', param.type === 'RestElement' ? 'rest_param' : 'param');
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
|
|
903
|
-
/**
|
|
904
|
-
* @type {Visitor<Node, State, AST.SvelteNode>}
|
|
905
|
-
*/
|
|
906
|
-
const create_block_scope = (node, { state, next }) => {
|
|
907
|
-
const scope = state.scope.child(true);
|
|
908
|
-
scopes.set(node, scope);
|
|
909
|
-
|
|
910
|
-
next({ scope });
|
|
911
|
-
};
|
|
912
|
-
|
|
913
|
-
/**
|
|
914
|
-
* @type {Visitor<AST.ElementLike, State, AST.SvelteNode>}
|
|
915
|
-
*/
|
|
916
|
-
const SvelteFragment = (node, { state, next }) => {
|
|
917
|
-
const scope = state.scope.child();
|
|
918
|
-
scopes.set(node, scope);
|
|
919
|
-
next({ scope });
|
|
920
|
-
};
|
|
921
|
-
|
|
922
|
-
/**
|
|
923
|
-
* @type {Visitor<AST.Component | AST.SvelteComponent | AST.SvelteSelf, State, AST.SvelteNode>}
|
|
924
|
-
*/
|
|
925
|
-
const Component = (node, context) => {
|
|
926
|
-
node.metadata.scopes = {
|
|
927
|
-
default: context.state.scope.child()
|
|
928
|
-
};
|
|
929
|
-
|
|
930
|
-
if (node.type === 'SvelteComponent') {
|
|
931
|
-
context.visit(node.expression);
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
const default_state = determine_slot(node)
|
|
935
|
-
? context.state
|
|
936
|
-
: { scope: node.metadata.scopes.default };
|
|
937
|
-
|
|
938
|
-
for (const attribute of node.attributes) {
|
|
939
|
-
if (attribute.type === 'LetDirective') {
|
|
940
|
-
context.visit(attribute, default_state);
|
|
941
|
-
} else {
|
|
942
|
-
context.visit(attribute);
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
for (const child of node.fragment.nodes) {
|
|
947
|
-
let state = default_state;
|
|
948
|
-
|
|
949
|
-
const slot_name = determine_slot(child);
|
|
950
|
-
|
|
951
|
-
if (slot_name !== null) {
|
|
952
|
-
node.metadata.scopes[slot_name] = context.state.scope.child();
|
|
953
|
-
|
|
954
|
-
state = {
|
|
955
|
-
scope: node.metadata.scopes[slot_name]
|
|
956
|
-
};
|
|
957
|
-
}
|
|
958
|
-
|
|
959
|
-
context.visit(child, state);
|
|
960
|
-
}
|
|
961
|
-
};
|
|
962
|
-
|
|
963
|
-
/**
|
|
964
|
-
* @type {Visitor<AST.AnimateDirective | AST.TransitionDirective | AST.UseDirective, State, AST.SvelteNode>}
|
|
965
|
-
*/
|
|
966
|
-
const SvelteDirective = (node, { state, path, visit }) => {
|
|
967
|
-
state.scope.reference(b.id(node.name.split('.')[0]), path);
|
|
968
|
-
|
|
969
|
-
if (node.expression) {
|
|
970
|
-
visit(node.expression);
|
|
971
|
-
}
|
|
972
|
-
};
|
|
973
|
-
|
|
974
|
-
let has_await = false;
|
|
975
|
-
|
|
976
|
-
walk(ast, state, {
|
|
977
|
-
AwaitExpression(node, context) {
|
|
978
|
-
// this doesn't _really_ belong here, but it allows us to
|
|
979
|
-
// automatically opt into runes mode on encountering
|
|
980
|
-
// blocking awaits, without doing an additional walk
|
|
981
|
-
// before the analysis occurs
|
|
982
|
-
// TODO remove this in Svelte 7.0 or whenever we get rid of legacy support
|
|
983
|
-
has_await ||= context.path.every(
|
|
984
|
-
({ type }) =>
|
|
985
|
-
type !== 'ArrowFunctionExpression' &&
|
|
986
|
-
type !== 'FunctionExpression' &&
|
|
987
|
-
type !== 'FunctionDeclaration'
|
|
988
|
-
);
|
|
989
|
-
|
|
990
|
-
context.next();
|
|
991
|
-
},
|
|
992
|
-
|
|
993
|
-
// references
|
|
994
|
-
Identifier(node, { path, state }) {
|
|
995
|
-
const parent = path.at(-1);
|
|
996
|
-
if (
|
|
997
|
-
parent &&
|
|
998
|
-
is_reference(node, /** @type {Node} */ (parent)) &&
|
|
999
|
-
// TSTypeAnnotation, TSInterfaceDeclaration etc - these are normally already filtered out,
|
|
1000
|
-
// but for the migration they aren't, so we need to filter them out here
|
|
1001
|
-
// TODO -> once migration script is gone we can remove this check
|
|
1002
|
-
!parent.type.startsWith('TS')
|
|
1003
|
-
) {
|
|
1004
|
-
references.push([state.scope, { node, path: path.slice() }]);
|
|
1005
|
-
}
|
|
1006
|
-
},
|
|
1007
|
-
LabeledStatement(node, { path, next }) {
|
|
1008
|
-
if (path.length > 1 || !allow_reactive_declarations) return next();
|
|
1009
|
-
if (node.label.name !== '$') return next();
|
|
1010
|
-
|
|
1011
|
-
// create a scope for the $: block
|
|
1012
|
-
const scope = state.scope.child();
|
|
1013
|
-
scopes.set(node, scope);
|
|
1014
|
-
|
|
1015
|
-
if (
|
|
1016
|
-
node.body.type === 'ExpressionStatement' &&
|
|
1017
|
-
node.body.expression.type === 'AssignmentExpression'
|
|
1018
|
-
) {
|
|
1019
|
-
for (const id of extract_identifiers(node.body.expression.left)) {
|
|
1020
|
-
if (!id.name.startsWith('$')) {
|
|
1021
|
-
possible_implicit_declarations.push(id);
|
|
1022
|
-
}
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
|
-
|
|
1026
|
-
next({ scope });
|
|
1027
|
-
},
|
|
1028
|
-
|
|
1029
|
-
SvelteFragment,
|
|
1030
|
-
SlotElement: SvelteFragment,
|
|
1031
|
-
SvelteElement: SvelteFragment,
|
|
1032
|
-
RegularElement: SvelteFragment,
|
|
1033
|
-
|
|
1034
|
-
LetDirective(node, context) {
|
|
1035
|
-
const scope = context.state.scope;
|
|
1036
|
-
|
|
1037
|
-
/** @type {Binding[]} */
|
|
1038
|
-
const bindings = [];
|
|
1039
|
-
scope.declarators.set(node, bindings);
|
|
1040
|
-
|
|
1041
|
-
if (node.expression) {
|
|
1042
|
-
for (const id of extract_identifiers_from_destructuring(node.expression)) {
|
|
1043
|
-
const binding = scope.declare(id, 'template', 'const');
|
|
1044
|
-
scope.reference(id, [context.path[context.path.length - 1], node]);
|
|
1045
|
-
bindings.push(binding);
|
|
1046
|
-
}
|
|
1047
|
-
} else {
|
|
1048
|
-
/** @type {Identifier} */
|
|
1049
|
-
const id = {
|
|
1050
|
-
name: node.name,
|
|
1051
|
-
type: 'Identifier',
|
|
1052
|
-
start: node.start,
|
|
1053
|
-
end: node.end
|
|
1054
|
-
};
|
|
1055
|
-
const binding = scope.declare(id, 'template', 'const');
|
|
1056
|
-
scope.reference(id, [context.path[context.path.length - 1], node]);
|
|
1057
|
-
bindings.push(binding);
|
|
1058
|
-
}
|
|
1059
|
-
},
|
|
1060
|
-
|
|
1061
|
-
Component: (node, context) => {
|
|
1062
|
-
context.state.scope.reference(b.id(node.name.split('.')[0]), context.path);
|
|
1063
|
-
Component(node, context);
|
|
1064
|
-
},
|
|
1065
|
-
SvelteSelf: Component,
|
|
1066
|
-
SvelteComponent: Component,
|
|
1067
|
-
|
|
1068
|
-
// updates
|
|
1069
|
-
AssignmentExpression(node, { state, next }) {
|
|
1070
|
-
updates.push([state.scope, node.left, node.right]);
|
|
1071
|
-
next();
|
|
1072
|
-
},
|
|
1073
|
-
|
|
1074
|
-
UpdateExpression(node, { state, next }) {
|
|
1075
|
-
const expression = /** @type {Identifier | MemberExpression} */ (node.argument);
|
|
1076
|
-
updates.push([state.scope, expression, expression]);
|
|
1077
|
-
next();
|
|
1078
|
-
},
|
|
1079
|
-
|
|
1080
|
-
ImportDeclaration(node, { state }) {
|
|
1081
|
-
for (const specifier of node.specifiers) {
|
|
1082
|
-
state.scope.declare(specifier.local, 'normal', 'import', node);
|
|
1083
|
-
}
|
|
1084
|
-
},
|
|
1085
|
-
|
|
1086
|
-
FunctionExpression(node, { state, next }) {
|
|
1087
|
-
const scope = state.scope.child();
|
|
1088
|
-
scopes.set(node, scope);
|
|
1089
|
-
|
|
1090
|
-
if (node.id) scope.declare(node.id, 'normal', 'function');
|
|
1091
|
-
|
|
1092
|
-
add_params(scope, node.params);
|
|
1093
|
-
next({ scope });
|
|
1094
|
-
},
|
|
1095
|
-
|
|
1096
|
-
FunctionDeclaration(node, { state, next }) {
|
|
1097
|
-
if (node.id) state.scope.declare(node.id, 'normal', 'function', node);
|
|
1098
|
-
|
|
1099
|
-
const scope = state.scope.child();
|
|
1100
|
-
scopes.set(node, scope);
|
|
1101
|
-
|
|
1102
|
-
add_params(scope, node.params);
|
|
1103
|
-
next({ scope });
|
|
1104
|
-
},
|
|
1105
|
-
|
|
1106
|
-
ArrowFunctionExpression(node, { state, next }) {
|
|
1107
|
-
const scope = state.scope.child();
|
|
1108
|
-
scopes.set(node, scope);
|
|
1109
|
-
|
|
1110
|
-
add_params(scope, node.params);
|
|
1111
|
-
next({ scope });
|
|
1112
|
-
},
|
|
1113
|
-
|
|
1114
|
-
ForStatement: create_block_scope,
|
|
1115
|
-
ForInStatement: create_block_scope,
|
|
1116
|
-
ForOfStatement: create_block_scope,
|
|
1117
|
-
SwitchStatement: create_block_scope,
|
|
1118
|
-
BlockStatement(node, context) {
|
|
1119
|
-
const parent = context.path.at(-1);
|
|
1120
|
-
if (
|
|
1121
|
-
parent?.type === 'FunctionDeclaration' ||
|
|
1122
|
-
parent?.type === 'FunctionExpression' ||
|
|
1123
|
-
parent?.type === 'ArrowFunctionExpression'
|
|
1124
|
-
) {
|
|
1125
|
-
// We already created a new scope for the function
|
|
1126
|
-
context.next();
|
|
1127
|
-
} else {
|
|
1128
|
-
create_block_scope(node, context);
|
|
1129
|
-
}
|
|
1130
|
-
},
|
|
1131
|
-
|
|
1132
|
-
ClassDeclaration(node, { state, next }) {
|
|
1133
|
-
if (node.id) state.scope.declare(node.id, 'normal', 'let', node);
|
|
1134
|
-
next();
|
|
1135
|
-
},
|
|
1136
|
-
|
|
1137
|
-
VariableDeclaration(node, { state, path, next }) {
|
|
1138
|
-
const is_parent_const_tag = path.at(-1)?.type === 'ConstTag';
|
|
1139
|
-
for (const declarator of node.declarations) {
|
|
1140
|
-
/** @type {Binding[]} */
|
|
1141
|
-
const bindings = [];
|
|
1142
|
-
|
|
1143
|
-
state.scope.declarators.set(declarator, bindings);
|
|
1144
|
-
|
|
1145
|
-
for (const id of extract_identifiers(declarator.id)) {
|
|
1146
|
-
const binding = state.scope.declare(
|
|
1147
|
-
id,
|
|
1148
|
-
is_parent_const_tag ? 'template' : 'normal',
|
|
1149
|
-
node.kind,
|
|
1150
|
-
declarator.init
|
|
1151
|
-
);
|
|
1152
|
-
binding.metadata = { is_template_declaration: true };
|
|
1153
|
-
bindings.push(binding);
|
|
1154
|
-
}
|
|
1155
|
-
}
|
|
1156
|
-
|
|
1157
|
-
next();
|
|
1158
|
-
},
|
|
1159
|
-
|
|
1160
|
-
CatchClause(node, { state, next }) {
|
|
1161
|
-
if (node.param) {
|
|
1162
|
-
const scope = state.scope.child(true);
|
|
1163
|
-
scopes.set(node, scope);
|
|
1164
|
-
|
|
1165
|
-
for (const id of extract_identifiers(node.param)) {
|
|
1166
|
-
scope.declare(id, 'normal', 'let');
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
|
-
next({ scope });
|
|
1170
|
-
} else {
|
|
1171
|
-
next();
|
|
1172
|
-
}
|
|
1173
|
-
},
|
|
1174
|
-
|
|
1175
|
-
EachBlock(node, { state, visit }) {
|
|
1176
|
-
visit(node.expression);
|
|
1177
|
-
|
|
1178
|
-
// context and children are a new scope
|
|
1179
|
-
const scope = state.scope.child();
|
|
1180
|
-
scopes.set(node, scope);
|
|
1181
|
-
|
|
1182
|
-
if (node.context) {
|
|
1183
|
-
// declarations
|
|
1184
|
-
for (const id of extract_identifiers(node.context)) {
|
|
1185
|
-
const binding = scope.declare(id, 'each', 'const');
|
|
1186
|
-
|
|
1187
|
-
let inside_rest = false;
|
|
1188
|
-
let is_rest_id = false;
|
|
1189
|
-
walk(node.context, null, {
|
|
1190
|
-
Identifier(node) {
|
|
1191
|
-
if (inside_rest && node === id) {
|
|
1192
|
-
is_rest_id = true;
|
|
1193
|
-
}
|
|
1194
|
-
},
|
|
1195
|
-
RestElement(_, { next }) {
|
|
1196
|
-
const prev = inside_rest;
|
|
1197
|
-
inside_rest = true;
|
|
1198
|
-
next();
|
|
1199
|
-
inside_rest = prev;
|
|
1200
|
-
}
|
|
1201
|
-
});
|
|
1202
|
-
|
|
1203
|
-
binding.metadata = { inside_rest: is_rest_id };
|
|
1204
|
-
}
|
|
1205
|
-
|
|
1206
|
-
// Visit to pick up references from default initializers
|
|
1207
|
-
visit(node.context, { scope });
|
|
1208
|
-
}
|
|
1209
|
-
|
|
1210
|
-
if (node.index) {
|
|
1211
|
-
const is_keyed =
|
|
1212
|
-
node.key &&
|
|
1213
|
-
(node.key.type !== 'Identifier' || !node.index || node.key.name !== node.index);
|
|
1214
|
-
scope.declare(b.id(node.index), is_keyed ? 'template' : 'static', 'const', node);
|
|
1215
|
-
}
|
|
1216
|
-
if (node.key) visit(node.key, { scope });
|
|
1217
|
-
|
|
1218
|
-
// children
|
|
1219
|
-
for (const child of node.body.nodes) {
|
|
1220
|
-
visit(child, { scope });
|
|
1221
|
-
}
|
|
1222
|
-
if (node.fallback) visit(node.fallback, { scope });
|
|
1223
|
-
|
|
1224
|
-
node.metadata = {
|
|
1225
|
-
expression: new ExpressionMetadata(),
|
|
1226
|
-
keyed: false,
|
|
1227
|
-
contains_group_binding: false,
|
|
1228
|
-
index: scope.root.unique('$$index'),
|
|
1229
|
-
declarations: scope.declarations,
|
|
1230
|
-
is_controlled: false,
|
|
1231
|
-
// filled in during analysis
|
|
1232
|
-
transitive_deps: new Set()
|
|
1233
|
-
};
|
|
1234
|
-
},
|
|
1235
|
-
|
|
1236
|
-
AwaitBlock(node, context) {
|
|
1237
|
-
context.visit(node.expression);
|
|
1238
|
-
|
|
1239
|
-
if (node.pending) {
|
|
1240
|
-
context.visit(node.pending);
|
|
1241
|
-
}
|
|
1242
|
-
|
|
1243
|
-
if (node.then) {
|
|
1244
|
-
context.visit(node.then);
|
|
1245
|
-
if (node.value) {
|
|
1246
|
-
const then_scope = /** @type {Scope} */ (scopes.get(node.then));
|
|
1247
|
-
const value_scope = context.state.scope.child();
|
|
1248
|
-
scopes.set(node.value, value_scope);
|
|
1249
|
-
context.visit(node.value, { scope: value_scope });
|
|
1250
|
-
for (const id of extract_identifiers(node.value)) {
|
|
1251
|
-
then_scope.declare(id, 'template', 'const');
|
|
1252
|
-
value_scope.declare(id, 'normal', 'const');
|
|
1253
|
-
}
|
|
1254
|
-
}
|
|
1255
|
-
}
|
|
1256
|
-
|
|
1257
|
-
if (node.catch) {
|
|
1258
|
-
context.visit(node.catch);
|
|
1259
|
-
if (node.error) {
|
|
1260
|
-
const catch_scope = /** @type {Scope} */ (scopes.get(node.catch));
|
|
1261
|
-
const error_scope = context.state.scope.child();
|
|
1262
|
-
scopes.set(node.error, error_scope);
|
|
1263
|
-
context.visit(node.error, { scope: error_scope });
|
|
1264
|
-
for (const id of extract_identifiers(node.error)) {
|
|
1265
|
-
catch_scope.declare(id, 'template', 'const');
|
|
1266
|
-
error_scope.declare(id, 'normal', 'const');
|
|
1267
|
-
}
|
|
1268
|
-
}
|
|
1269
|
-
}
|
|
1270
|
-
},
|
|
1271
|
-
|
|
1272
|
-
SnippetBlock(node, context) {
|
|
1273
|
-
const state = context.state;
|
|
1274
|
-
let scope = state.scope;
|
|
1275
|
-
|
|
1276
|
-
scope.declare(node.expression, 'normal', 'function', node);
|
|
1277
|
-
|
|
1278
|
-
const child_scope = state.scope.child();
|
|
1279
|
-
scopes.set(node, child_scope);
|
|
1280
|
-
|
|
1281
|
-
for (const param of node.parameters) {
|
|
1282
|
-
for (const id of extract_identifiers(param)) {
|
|
1283
|
-
child_scope.declare(id, 'snippet', 'let');
|
|
1284
|
-
}
|
|
1285
|
-
}
|
|
1286
|
-
|
|
1287
|
-
context.next({ scope: child_scope });
|
|
1288
|
-
},
|
|
1289
|
-
|
|
1290
|
-
Fragment: (node, context) => {
|
|
1291
|
-
const scope = context.state.scope.child(node.metadata.transparent);
|
|
1292
|
-
scopes.set(node, scope);
|
|
1293
|
-
context.next({ scope });
|
|
1294
|
-
},
|
|
1295
|
-
|
|
1296
|
-
BindDirective(node, context) {
|
|
1297
|
-
if (node.expression.type !== 'SequenceExpression') {
|
|
1298
|
-
const expression = /** @type {Identifier | MemberExpression} */ (node.expression);
|
|
1299
|
-
updates.push([context.state.scope, expression, expression]);
|
|
1300
|
-
}
|
|
1301
|
-
|
|
1302
|
-
context.next();
|
|
1303
|
-
},
|
|
1304
|
-
|
|
1305
|
-
TransitionDirective: SvelteDirective,
|
|
1306
|
-
AnimateDirective: SvelteDirective,
|
|
1307
|
-
UseDirective: SvelteDirective,
|
|
1308
|
-
// using it's own function instead of `SvelteDirective` because
|
|
1309
|
-
// StyleDirective doesn't have expressions and are generally already
|
|
1310
|
-
// handled by `Identifier`. This is the special case for the shorthand
|
|
1311
|
-
// eg <button style:height /> where the variable has the same name of
|
|
1312
|
-
// the css property
|
|
1313
|
-
StyleDirective(node, { path, state, next }) {
|
|
1314
|
-
if (node.value === true) {
|
|
1315
|
-
state.scope.reference(b.id(node.name), path.concat(node));
|
|
1316
|
-
}
|
|
1317
|
-
next();
|
|
1318
|
-
}
|
|
1319
|
-
|
|
1320
|
-
// TODO others
|
|
1321
|
-
});
|
|
1322
|
-
|
|
1323
|
-
for (const id of possible_implicit_declarations) {
|
|
1324
|
-
const binding = scope.get(id.name);
|
|
1325
|
-
if (binding) continue; // TODO can also be legacy_reactive if declared outside of reactive statement
|
|
1326
|
-
|
|
1327
|
-
scope.declare(id, 'legacy_reactive', 'let');
|
|
1328
|
-
}
|
|
1329
|
-
|
|
1330
|
-
// we do this after the fact, so that we don't need to worry
|
|
1331
|
-
// about encountering references before their declarations
|
|
1332
|
-
for (const [scope, { node, path }] of references) {
|
|
1333
|
-
scope.reference(node, path);
|
|
1334
|
-
}
|
|
1335
|
-
|
|
1336
|
-
for (const [scope, node, value] of updates) {
|
|
1337
|
-
for (const expression of unwrap_pattern(node)) {
|
|
1338
|
-
const left = object(expression);
|
|
1339
|
-
const binding = left && scope.get(left.name);
|
|
1340
|
-
|
|
1341
|
-
if (binding !== null && left !== binding.node) {
|
|
1342
|
-
if (left === expression) {
|
|
1343
|
-
binding.reassigned = true;
|
|
1344
|
-
binding.assignments.push({ value, scope });
|
|
1345
|
-
} else {
|
|
1346
|
-
binding.mutated = true;
|
|
1347
|
-
}
|
|
1348
|
-
}
|
|
1349
|
-
}
|
|
1350
|
-
}
|
|
1351
|
-
|
|
1352
|
-
return {
|
|
1353
|
-
has_await,
|
|
1354
|
-
scope,
|
|
1355
|
-
scopes
|
|
1356
|
-
};
|
|
1357
|
-
}
|
|
1358
|
-
|
|
1359
|
-
/**
|
|
1360
|
-
* @template {{ scope: Scope, scopes: Map<AST.SvelteNode, Scope> }} State
|
|
1361
|
-
* @param {AST.SvelteNode} node
|
|
1362
|
-
* @param {Context<AST.SvelteNode, State>} context
|
|
1363
|
-
*/
|
|
1364
|
-
export function set_scope(node, { next, state }) {
|
|
1365
|
-
const scope = state.scopes.get(node);
|
|
1366
|
-
next(scope !== undefined && scope !== state.scope ? { ...state, scope } : state);
|
|
1367
|
-
}
|
|
1368
|
-
|
|
1369
|
-
/**
|
|
1370
|
-
* Returns the name of the rune if the given expression is a `CallExpression` using a rune.
|
|
1371
|
-
* @param {Node | null | undefined} node
|
|
1372
|
-
* @param {Scope} scope
|
|
1373
|
-
*/
|
|
1374
|
-
export function get_rune(node, scope) {
|
|
1375
|
-
if (!node) return null;
|
|
1376
|
-
if (node.type !== 'CallExpression') return null;
|
|
1377
|
-
|
|
1378
|
-
const keypath = get_global_keypath(node.callee, scope);
|
|
1379
|
-
|
|
1380
|
-
if (!keypath || !is_rune(keypath)) return null;
|
|
1381
|
-
return keypath;
|
|
1382
|
-
}
|
|
1383
|
-
|
|
1384
|
-
/**
|
|
1385
|
-
* Returns the name of the rune if the given expression is a `CallExpression` using a rune.
|
|
1386
|
-
* @param {Expression | Super} node
|
|
1387
|
-
* @param {Scope} scope
|
|
1388
|
-
*/
|
|
1389
|
-
function get_global_keypath(node, scope) {
|
|
1390
|
-
let n = node;
|
|
1391
|
-
|
|
1392
|
-
let joined = '';
|
|
1393
|
-
|
|
1394
|
-
while (n.type === 'MemberExpression') {
|
|
1395
|
-
if (n.computed) return null;
|
|
1396
|
-
if (n.property.type !== 'Identifier') return null;
|
|
1397
|
-
joined = '.' + n.property.name + joined;
|
|
1398
|
-
n = n.object;
|
|
1399
|
-
}
|
|
1400
|
-
|
|
1401
|
-
if (n.type === 'CallExpression' && n.callee.type === 'Identifier') {
|
|
1402
|
-
joined = '()' + joined;
|
|
1403
|
-
n = n.callee;
|
|
1404
|
-
}
|
|
1405
|
-
|
|
1406
|
-
if (n.type !== 'Identifier') return null;
|
|
1407
|
-
|
|
1408
|
-
const binding = scope.get(n.name);
|
|
1409
|
-
if (binding !== null) return null; // rune name, but references a variable or store
|
|
1410
|
-
|
|
1411
|
-
return n.name + joined;
|
|
1412
|
-
}
|