@torpor/view 0.4.15 → 0.4.16
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/package.json +4 -1
- package/.oxlintrc.json +0 -3
- package/CHANGELOG.md +0 -356
- package/scripts/buildTestOutput.ts +0 -15
- package/scripts/copyToRepl.ts +0 -36
- package/src/ambient.d.ts +0 -24
- package/src/compile/build/client/BuildStatus.ts +0 -22
- package/src/compile/build/client/addMappedText.ts +0 -25
- package/src/compile/build/client/addMappedTextWithOffsets.ts +0 -31
- package/src/compile/build/client/addPopDevBoundary.ts +0 -10
- package/src/compile/build/client/addPushDevBoundary.ts +0 -28
- package/src/compile/build/client/buildAddFragment.ts +0 -51
- package/src/compile/build/client/buildAwaitNode.ts +0 -166
- package/src/compile/build/client/buildCode.ts +0 -202
- package/src/compile/build/client/buildComponentNode.ts +0 -266
- package/src/compile/build/client/buildControlNode.ts +0 -86
- package/src/compile/build/client/buildElementNode.ts +0 -431
- package/src/compile/build/client/buildForNode.ts +0 -180
- package/src/compile/build/client/buildFragment.ts +0 -800
- package/src/compile/build/client/buildFragmentText.ts +0 -239
- package/src/compile/build/client/buildHtmlNode.ts +0 -73
- package/src/compile/build/client/buildIfNode.ts +0 -102
- package/src/compile/build/client/buildMount.ts +0 -19
- package/src/compile/build/client/buildNode.ts +0 -60
- package/src/compile/build/client/buildReplaceNode.ts +0 -69
- package/src/compile/build/client/buildRootNode.ts +0 -29
- package/src/compile/build/client/buildRun.ts +0 -23
- package/src/compile/build/client/buildScriptNode.ts +0 -16
- package/src/compile/build/client/buildSlotNode.ts +0 -83
- package/src/compile/build/client/buildSpecialNode.ts +0 -38
- package/src/compile/build/client/buildStyles.ts +0 -85
- package/src/compile/build/client/buildSwitchNode.ts +0 -107
- package/src/compile/build/client/buildTextNode.ts +0 -106
- package/src/compile/build/client/getAttributeOffsets.ts +0 -90
- package/src/compile/build/client/replaceForVarNames.ts +0 -16
- package/src/compile/build/client/stashRun.ts +0 -22
- package/src/compile/build/client/stashRunWithOffsets.ts +0 -38
- package/src/compile/build/server/BuildServerStatus.ts +0 -10
- package/src/compile/build/server/buildServerAwaitNode.ts +0 -49
- package/src/compile/build/server/buildServerCode.ts +0 -148
- package/src/compile/build/server/buildServerComponentNode.ts +0 -141
- package/src/compile/build/server/buildServerControlNode.ts +0 -103
- package/src/compile/build/server/buildServerElementNode.ts +0 -128
- package/src/compile/build/server/buildServerForNode.ts +0 -57
- package/src/compile/build/server/buildServerHtmlNode.ts +0 -27
- package/src/compile/build/server/buildServerIfNode.ts +0 -57
- package/src/compile/build/server/buildServerNode.ts +0 -50
- package/src/compile/build/server/buildServerReplaceNode.ts +0 -51
- package/src/compile/build/server/buildServerRootNode.ts +0 -14
- package/src/compile/build/server/buildServerScriptNode.ts +0 -13
- package/src/compile/build/server/buildServerSlotNode.ts +0 -79
- package/src/compile/build/server/buildServerSpecialNode.ts +0 -35
- package/src/compile/build/server/buildServerSwitchNode.ts +0 -60
- package/src/compile/build/server/buildServerTextNode.ts +0 -70
- package/src/compile/build/utils/nextVarName.ts +0 -20
- package/src/compile/build.ts +0 -31
- package/src/compile/buildType.ts +0 -42
- package/src/compile/parse/ParseStatus.ts +0 -20
- package/src/compile/parse/addSpaceElement.ts +0 -26
- package/src/compile/parse/parseCode.ts +0 -466
- package/src/compile/parse/parseControl.ts +0 -314
- package/src/compile/parse/parseElement.ts +0 -197
- package/src/compile/parse/parseImports.ts +0 -66
- package/src/compile/parse/parseInlineScript.ts +0 -36
- package/src/compile/parse/parseMarkup.ts +0 -49
- package/src/compile/parse/parseStyles.ts +0 -94
- package/src/compile/parse/parseTag.ts +0 -156
- package/src/compile/parse/parseText.ts +0 -96
- package/src/compile/parse/scopeStyles.ts +0 -57
- package/src/compile/parse/slottifyChildNodes.ts +0 -32
- package/src/compile/parse/utils/accept.ts +0 -21
- package/src/compile/parse/utils/addError.ts +0 -44
- package/src/compile/parse/utils/consumeAlphaNumeric.ts +0 -21
- package/src/compile/parse/utils/consumeNonSpace.ts +0 -21
- package/src/compile/parse/utils/consumeSpace.ts +0 -21
- package/src/compile/parse/utils/consumeUntil.ts +0 -21
- package/src/compile/parse/utils/expect.ts +0 -27
- package/src/compile/parse/utils/isAlphaNumeric.ts +0 -17
- package/src/compile/parse/utils/isAlphaNumericChar.ts +0 -19
- package/src/compile/parse/utils/isSpace.ts +0 -17
- package/src/compile/parse/utils/isSpaceChar.ts +0 -12
- package/src/compile/parse.ts +0 -14
- package/src/compile/types/BuildOptions.ts +0 -25
- package/src/compile/types/BuildResult.ts +0 -10
- package/src/compile/types/CompileError.ts +0 -9
- package/src/compile/types/Import.ts +0 -7
- package/src/compile/types/ParseResult.ts +0 -8
- package/src/compile/types/ScriptChunk.ts +0 -6
- package/src/compile/types/SourceMapping.ts +0 -7
- package/src/compile/types/SourceSpan.ts +0 -4
- package/src/compile/types/comments.ts +0 -6
- package/src/compile/types/nodes/Attribute.ts +0 -9
- package/src/compile/types/nodes/ControlNode.ts +0 -19
- package/src/compile/types/nodes/ElementNode.ts +0 -22
- package/src/compile/types/nodes/Fragment.ts +0 -20
- package/src/compile/types/nodes/NodeType.ts +0 -3
- package/src/compile/types/nodes/OperationType.ts +0 -26
- package/src/compile/types/nodes/ParentNode.ts +0 -7
- package/src/compile/types/nodes/RootNode.ts +0 -11
- package/src/compile/types/nodes/TemplateNode.ts +0 -18
- package/src/compile/types/nodes/TextNode.ts +0 -9
- package/src/compile/types/styles/Attribute.ts +0 -4
- package/src/compile/types/styles/Style.ts +0 -7
- package/src/compile/types/styles/StyleBlock.ts +0 -7
- package/src/compile/utils/Builder.ts +0 -89
- package/src/compile/utils/endOfString.ts +0 -8
- package/src/compile/utils/endOfTemplateString.ts +0 -14
- package/src/compile/utils/hash.ts +0 -13
- package/src/compile/utils/isComponentNode.ts +0 -6
- package/src/compile/utils/isControlNode.ts +0 -6
- package/src/compile/utils/isElementNode.ts +0 -6
- package/src/compile/utils/isFullyReactive.ts +0 -11
- package/src/compile/utils/isParentNode.ts +0 -6
- package/src/compile/utils/isReactive.ts +0 -11
- package/src/compile/utils/isSpaceNode.ts +0 -8
- package/src/compile/utils/isSpecialNode.ts +0 -6
- package/src/compile/utils/isTextNode.ts +0 -6
- package/src/compile/utils/trimAny.ts +0 -19
- package/src/compile/utils/trimEnd.ts +0 -15
- package/src/compile/utils/trimMatched.ts +0 -16
- package/src/compile/utils/trimQuotes.ts +0 -20
- package/src/compile/utils/trimStart.ts +0 -15
- package/src/compile/utils/trimStartAndEnd.ts +0 -15
- package/src/compile/utils/voidTags.ts +0 -18
- package/src/compile.ts +0 -10
- package/src/debug/printNode.ts +0 -65
- package/src/debug/printRegions.ts +0 -74
- package/src/debug/printSignalDiagram.ts +0 -139
- package/src/debug/printSimpleDiagram.ts +0 -88
- package/src/dev/devContext.ts +0 -31
- package/src/dev/popDevBoundary.ts +0 -5
- package/src/dev/pushDevBoundary.ts +0 -25
- package/src/dev/setDevMode.ts +0 -235
- package/src/dev/types/DevBoundary.ts +0 -7
- package/src/dev/types/DevContext.ts +0 -28
- package/src/dev.ts +0 -6
- package/src/index.ts +0 -77
- package/src/render/addAnimation.ts +0 -15
- package/src/render/addEvent.ts +0 -15
- package/src/render/addFragment.ts +0 -85
- package/src/render/animate.ts +0 -52
- package/src/render/applyProps.ts +0 -22
- package/src/render/buildClasses.ts +0 -33
- package/src/render/buildStyles.ts +0 -23
- package/src/render/clearLayoutSlot.ts +0 -8
- package/src/render/clearRegion.ts +0 -71
- package/src/render/context.ts +0 -42
- package/src/render/createComment.ts +0 -3
- package/src/render/createElement.ts +0 -27
- package/src/render/createFragment.ts +0 -7
- package/src/render/createText.ts +0 -8
- package/src/render/fillLayoutSlot.ts +0 -27
- package/src/render/formatAttributeText.ts +0 -3
- package/src/render/formatText.ts +0 -3
- package/src/render/getFragment.ts +0 -30
- package/src/render/hydrate.ts +0 -41
- package/src/render/hydrateRoot.ts +0 -32
- package/src/render/hydrationMarkers.ts +0 -5
- package/src/render/isCommentNode.ts +0 -3
- package/src/render/isFragmentNode.ts +0 -3
- package/src/render/isTextNode.ts +0 -3
- package/src/render/mount.ts +0 -41
- package/src/render/moveRegion.ts +0 -14
- package/src/render/newListItem.ts +0 -19
- package/src/render/newRegion.ts +0 -13
- package/src/render/nodeAnchor.ts +0 -66
- package/src/render/nodeCheckHydrationBreak.ts +0 -25
- package/src/render/nodeChild.ts +0 -23
- package/src/render/nodeNext.ts +0 -24
- package/src/render/nodeRoot.ts +0 -50
- package/src/render/nodeSkip.ts +0 -20
- package/src/render/popRegion.ts +0 -9
- package/src/render/pushRegion.ts +0 -30
- package/src/render/runControl.ts +0 -36
- package/src/render/runControlBranch.ts +0 -18
- package/src/render/runList.ts +0 -52
- package/src/render/runListItems.ts +0 -198
- package/src/render/setAttribute.ts +0 -7
- package/src/render/setDynamicElement.ts +0 -16
- package/src/ssr/$serverBatch.ts +0 -3
- package/src/ssr/$serverCache.ts +0 -3
- package/src/ssr/$serverMount.ts +0 -3
- package/src/ssr/$serverPeek.ts +0 -3
- package/src/ssr/$serverRun.ts +0 -3
- package/src/ssr/$serverUnwrap.ts +0 -3
- package/src/ssr/$serverWatch.ts +0 -3
- package/src/ssr.ts +0 -17
- package/src/types/Animation.ts +0 -4
- package/src/types/ClassValue.ts +0 -8
- package/src/types/Cleanup.ts +0 -7
- package/src/types/Component.ts +0 -14
- package/src/types/Computed.ts +0 -62
- package/src/types/Context.ts +0 -99
- package/src/types/Effect.ts +0 -54
- package/src/types/ListItem.ts +0 -6
- package/src/types/ProxyData.ts +0 -10
- package/src/types/ProxySignal.ts +0 -28
- package/src/types/Region.ts +0 -19
- package/src/types/ServerComponent.ts +0 -12
- package/src/types/ServerSlotRender.ts +0 -6
- package/src/types/SlotRender.ts +0 -8
- package/src/types/StyleValue.ts +0 -8
- package/src/types/Subscription.ts +0 -57
- package/src/types/Template.ts +0 -12
- package/src/types/TemplateComponent.ts +0 -27
- package/src/types/WatchOptions.ts +0 -9
- package/src/types/constants.ts +0 -14
- package/src/watch/$batch.ts +0 -22
- package/src/watch/$cache.ts +0 -34
- package/src/watch/$mount.ts +0 -11
- package/src/watch/$peek.ts +0 -14
- package/src/watch/$run.ts +0 -33
- package/src/watch/$stream.ts +0 -1
- package/src/watch/$unwrap.ts +0 -12
- package/src/watch/$watch.ts +0 -49
- package/src/watch/batchEnd.ts +0 -17
- package/src/watch/batchStart.ts +0 -5
- package/src/watch/checkComputed.ts +0 -46
- package/src/watch/checkEffect.ts +0 -32
- package/src/watch/checkSources.ts +0 -63
- package/src/watch/clearSources.ts +0 -39
- package/src/watch/clearTargets.ts +0 -28
- package/src/watch/deactivateSources.ts +0 -19
- package/src/watch/propagateSignal.ts +0 -99
- package/src/watch/proxyGet.ts +0 -134
- package/src/watch/proxySet.ts +0 -51
- package/src/watch/runCleanups.ts +0 -40
- package/src/watch/runComputed.ts +0 -36
- package/src/watch/runEffect.ts +0 -50
- package/src/watch/symbols.ts +0 -5
- package/src/watch/trackProxySignal.ts +0 -21
- package/src/watch/trackSignal.ts +0 -69
- package/src/watch/transferEffects.ts +0 -67
- package/src/watch/triggerEffects.ts +0 -59
- package/src/wrappers/ReactiveDate.ts +0 -68
- package/test/attributes/attributes.test.ts +0 -70
- package/test/attributes/components/output/Attributes-client.ts +0 -35
- package/test/attributes/components/output/Attributes-server.ts +0 -18
- package/test/attributes/components/output/Attributes-types.ts +0 -10
- package/test/attributes/components/output/Disappearing-client.ts +0 -35
- package/test/attributes/components/output/Disappearing-server.ts +0 -18
- package/test/attributes/components/output/Disappearing-types.ts +0 -10
- package/test/attributes/components/temp/Attributes-client-881ae1bc8de5b8b63c416dea9e11bffcf28b2e8e.ts +0 -35
- package/test/attributes/components/temp/Attributes-server-439da9a70f565053da8581652250142a12f4a7d3.ts +0 -18
- package/test/attributes/components/temp/Attributes-types-5892927754ac19a8b3a8560fa1c78ce653e5f318.ts +0 -10
- package/test/attributes/components/temp/Disappearing-client-881ae1bc8de5b8b63c416dea9e11bffcf28b2e8e.ts +0 -35
- package/test/attributes/components/temp/Disappearing-server-439da9a70f565053da8581652250142a12f4a7d3.ts +0 -18
- package/test/attributes/components/temp/Disappearing-types-5892927754ac19a8b3a8560fa1c78ce653e5f318.ts +0 -10
- package/test/attributes/disappearing.test.ts +0 -78
- package/test/attributes/errors.test.ts +0 -35
- package/test/attributes/parse.test.ts +0 -297
- package/test/await/await.test.ts +0 -88
- package/test/await/components/output/Await-client.ts +0 -120
- package/test/await/components/output/Await-server.ts +0 -40
- package/test/await/components/output/Await-types.ts +0 -10
- package/test/await/components/temp/Await-client-973bd47c40dcbc9622a278e5519c341656505fc0.ts +0 -120
- package/test/await/components/temp/Await-server-1f8c2fd1781b769d00312410ca22d1f8e2def3e2.ts +0 -40
- package/test/await/components/temp/Await-types-355b335acd1c17a2271920d51e542ce1fc61eeef.ts +0 -10
- package/test/bench/bench.bench.ts +0 -33
- package/test/bench/components/Bench.torp +0 -170
- package/test/bench/components/output/Bench-client.ts +0 -214
- package/test/bench/components/output/Bench-server.ts +0 -132
- package/test/bench/components/output/Bench-types.ts +0 -10
- package/test/bench/components/temp/Bench-client-4ceb87d3dcd31fc9f176994c53b864b4128540cb.ts +0 -214
- package/test/bench/components/temp/Bench-server-84e241e91b2dd1790ea86b4a3af78d04fa9dd9f0.ts +0 -132
- package/test/bench/components/temp/Bench-types-a798f6c7b7ec235754ff5fdd5d7020633253b042.ts +0 -10
- package/test/bind/bind-component.test.ts +0 -55
- package/test/bind/bind-text.test.ts +0 -65
- package/test/bind/components/output/BindComponent-client.ts +0 -79
- package/test/bind/components/output/BindComponent-server.ts +0 -46
- package/test/bind/components/output/BindComponent-types.ts +0 -10
- package/test/bind/components/output/BindText-client.ts +0 -50
- package/test/bind/components/output/BindText-server.ts +0 -23
- package/test/bind/components/output/BindText-types.ts +0 -10
- package/test/bind/components/temp/BindComponent-client-45295d08bc4570c2d059d880dabc052656c80311.ts +0 -79
- package/test/bind/components/temp/BindComponent-server-5ac3ae9fff9117e8a62c1f8a6333b64e50ccad26.ts +0 -46
- package/test/bind/components/temp/BindComponent-types-8a10f6efddd92990ed5390f3c89ba17db179d801.ts +0 -10
- package/test/bind/components/temp/BindText-client-228eeb9b0fccd8baf7aea4fb8e9678e0537fb506.ts +0 -50
- package/test/bind/components/temp/BindText-server-d23c19942047551a7be16220d24aeb95cf7ff16e.ts +0 -23
- package/test/bind/components/temp/BindText-types-5892d9ef33c61a0de524b74323ba135accee8175.ts +0 -10
- package/test/build-server/build-server-element-node.test.ts +0 -61
- package/test/build-server/build-server.test.ts +0 -42
- package/test/build-server/components/IfNested.torp +0 -19
- package/test/build-server/components/output/IfNested-client.ts +0 -101
- package/test/build-server/components/output/IfNested-server.ts +0 -31
- package/test/build-server/components/output/IfNested-types.ts +0 -10
- package/test/build-server/components/temp/IfNested-client-50abd76ec9369ac6cf42f0264870914923f30b5c.ts +0 -101
- package/test/build-server/components/temp/IfNested-server-8a2513b704782704e7e184924c35e55958b15ae1.ts +0 -31
- package/test/build-server/components/temp/IfNested-types-692d58ca98f3534102193a44aa358994f798ca7b.ts +0 -10
- package/test/buildHtml.ts +0 -73
- package/test/buildOutputFiles.ts +0 -217
- package/test/child-component/child-component.test.ts +0 -41
- package/test/child-component/components/output/ChildComponent-client.ts +0 -65
- package/test/child-component/components/output/ChildComponent-server.ts +0 -42
- package/test/child-component/components/output/ChildComponent-types.ts +0 -10
- package/test/child-component/components/temp/ChildComponent-client-b32ac4d5bd6791f3c2c44457880554b416574bd5.ts +0 -65
- package/test/child-component/components/temp/ChildComponent-server-b7846325dc852d230821d741377a70cb654c6c58.ts +0 -42
- package/test/child-component/components/temp/ChildComponent-types-4d26850ef18600f398f7aa9c4502071349bf5624.ts +0 -10
- package/test/class/class.test.ts +0 -165
- package/test/class/components/output/Class-client.ts +0 -123
- package/test/class/components/output/Class-server.ts +0 -78
- package/test/class/components/output/Class-types.ts +0 -10
- package/test/class/components/temp/Class-client-c100fef7474dd892108c52b2cfed5825a3412e8b.ts +0 -123
- package/test/class/components/temp/Class-server-f42d0611a27002b493da55392baf7244d31e0d39.ts +0 -78
- package/test/class/components/temp/Class-types-38567e85c9ec17739c7c97e12281fc1818267190.ts +0 -10
- package/test/comments/html-comments.test.ts +0 -37
- package/test/comments/js-block-comments.test.ts +0 -42
- package/test/comments/js-line-comments.test.ts +0 -37
- package/test/component/component.test.ts +0 -41
- package/test/component/components/output/Component-client.ts +0 -65
- package/test/component/components/output/Component-server.ts +0 -42
- package/test/component/components/output/Component-types.ts +0 -10
- package/test/component/components/temp/Component-client-b96484e81ee8aaccbd0025155ff76a9b40d1b56a.ts +0 -65
- package/test/component/components/temp/Component-server-737acb88705af3ce16c74678df99b687be921b66.ts +0 -42
- package/test/component/components/temp/Component-types-3ef4f140ba29c98357caf0f2618785437b5804de.ts +0 -10
- package/test/console/components/output/Console-client.ts +0 -29
- package/test/console/components/output/Console-server.ts +0 -18
- package/test/console/components/output/Console-types.ts +0 -10
- package/test/console/components/temp/Console-client-8714c492e9017b582573e22b9be515bb7c70b2d9.ts +0 -29
- package/test/console/components/temp/Console-server-e5c69bad6cbc68c8d35b657d2df0605431c520df.ts +0 -18
- package/test/console/components/temp/Console-types-93ad3f25ddc6280fcff2cf4db7c2913d3a474912.ts +0 -10
- package/test/console/console.test.ts +0 -31
- package/test/const/components/output/Const-client.ts +0 -36
- package/test/const/components/output/Const-server.ts +0 -21
- package/test/const/components/output/Const-types.ts +0 -10
- package/test/const/components/temp/Const-client-0d9518b180ca43f6cf66e1a8467286ed5fed8e09.ts +0 -36
- package/test/const/components/temp/Const-server-26e98a80ebfd657bba9de8ef21443a65996c995b.ts +0 -21
- package/test/const/components/temp/Const-types-afba269310bd143aa325752d3cc7e0c598fd0de2.ts +0 -10
- package/test/const/const.test.ts +0 -37
- package/test/context/components/output/Context-client.ts +0 -99
- package/test/context/components/output/Context-server.ts +0 -67
- package/test/context/components/output/Context-types.ts +0 -10
- package/test/context/components/temp/Context-client-a07d9fff7f94993f639a12247527016d150e9b0f.ts +0 -99
- package/test/context/components/temp/Context-server-52193f64b90c8388a8a5d5dfe81bd68e3d4eada2.ts +0 -67
- package/test/context/components/temp/Context-types-e6be7d1cf118d7a8927af59db780010392966d01.ts +0 -10
- package/test/context/context.test.ts +0 -59
- package/test/effects/components/output/ForEffect-client.ts +0 -78
- package/test/effects/components/output/ForEffect-server.ts +0 -22
- package/test/effects/components/output/ForEffect-types.ts +0 -10
- package/test/effects/components/output/IfEffect-client.ts +0 -64
- package/test/effects/components/output/IfEffect-server.ts +0 -24
- package/test/effects/components/output/IfEffect-types.ts +0 -10
- package/test/effects/components/output/NestedIfEffect-client.ts +0 -88
- package/test/effects/components/output/NestedIfEffect-server.ts +0 -28
- package/test/effects/components/output/NestedIfEffect-types.ts +0 -10
- package/test/effects/components/temp/ForEffect-client-317189ae9a2569c0f4b9243ccfc3f580ad03c5e1.ts +0 -78
- package/test/effects/components/temp/ForEffect-server-a6306a1526624693d2b71ae1ecb13b658c95cbfc.ts +0 -22
- package/test/effects/components/temp/ForEffect-types-cfec41b41b054674bf8b01ce0e0003c8a6640a82.ts +0 -10
- package/test/effects/components/temp/IfEffect-client-5cac9165b868c2c3738c2aa498e754975baf7b3d.ts +0 -64
- package/test/effects/components/temp/IfEffect-server-a93ce34f749fc8eca2cb8fa9750622cf8ad1dade.ts +0 -24
- package/test/effects/components/temp/IfEffect-types-7b245b6e531e122e0d0cfb72903bb88223b98793.ts +0 -10
- package/test/effects/components/temp/NestedIfEffect-client-6d34eb573b43fc480ccbad626ebf3c6c3e8a29e8.ts +0 -88
- package/test/effects/components/temp/NestedIfEffect-server-7fbfcc91d32a454c2759d4dd2791bdd15393d470.ts +0 -28
- package/test/effects/components/temp/NestedIfEffect-types-0912466d777f52f3616557823a7e47f5901cb755.ts +0 -10
- package/test/effects/for-effect.test.ts +0 -73
- package/test/effects/if-effect.test.ts +0 -54
- package/test/effects/nested-if-effect.test.ts +0 -79
- package/test/events/components/output/Events-client.ts +0 -46
- package/test/events/components/output/Events-server.ts +0 -26
- package/test/events/components/output/Events-types.ts +0 -10
- package/test/events/components/temp/Events-client-ccab6c0f3bda2d4f18336c27aaa8ade40ea63a43.ts +0 -46
- package/test/events/components/temp/Events-server-3eeea257aecdf7e096c7feb9feb2e84703cfe38c.ts +0 -26
- package/test/events/components/temp/Events-types-f259dd221aa967b0426746303f1f2c33aeeaf068.ts +0 -10
- package/test/events/events.test.ts +0 -62
- package/test/for/components/output/For-client.ts +0 -80
- package/test/for/components/output/For-server.ts +0 -23
- package/test/for/components/output/For-types.ts +0 -10
- package/test/for/components/output/ForAfterFor-client.ts +0 -123
- package/test/for/components/output/ForAfterFor-server.ts +0 -27
- package/test/for/components/output/ForAfterFor-types.ts +0 -10
- package/test/for/components/output/ForContainingFor-client.ts +0 -118
- package/test/for/components/output/ForContainingFor-server.ts +0 -27
- package/test/for/components/output/ForContainingFor-types.ts +0 -10
- package/test/for/components/output/ForContainingFunction-client.ts +0 -88
- package/test/for/components/output/ForContainingFunction-server.ts +0 -29
- package/test/for/components/output/ForContainingFunction-types.ts +0 -10
- package/test/for/components/output/ForContainingIf-client.ts +0 -106
- package/test/for/components/output/ForContainingIf-server.ts +0 -27
- package/test/for/components/output/ForContainingIf-types.ts +0 -10
- package/test/for/components/output/ForEscape-client.ts +0 -99
- package/test/for/components/output/ForEscape-server.ts +0 -26
- package/test/for/components/output/ForEscape-types.ts +0 -10
- package/test/for/components/output/ForIn-client.ts +0 -79
- package/test/for/components/output/ForIn-server.ts +0 -22
- package/test/for/components/output/ForIn-types.ts +0 -10
- package/test/for/components/output/ForOf-client.ts +0 -79
- package/test/for/components/output/ForOf-server.ts +0 -22
- package/test/for/components/output/ForOf-types.ts +0 -10
- package/test/for/components/temp/For-client-6ef77eb2784d244c6591436da31b40c47ddde004.ts +0 -80
- package/test/for/components/temp/For-server-58c21b5e077266b759d017e7cb696dc0ae1d14f6.ts +0 -23
- package/test/for/components/temp/For-types-8bcd17ab2e0faebb340a19f56e052cc94820a29a.ts +0 -10
- package/test/for/components/temp/ForAfterFor-client-af52b59320b4e67714548b747f8aae7a5a15c93b.ts +0 -123
- package/test/for/components/temp/ForAfterFor-server-484aa0db27d3feff0e74ad88a369e35576e0ffe7.ts +0 -27
- package/test/for/components/temp/ForAfterFor-types-443c279cbffc1d07b01b09349cfddc6c081be6bb.ts +0 -10
- package/test/for/components/temp/ForContainingFor-client-361995d2d1a09c06265b6951b5577fc421a1ddcf.ts +0 -118
- package/test/for/components/temp/ForContainingFor-server-35e9268474f8fb887cb824d41b115957fac2ac46.ts +0 -27
- package/test/for/components/temp/ForContainingFor-types-e29bd72e1a1b98bbd196088afb0d6296b8eb9014.ts +0 -10
- package/test/for/components/temp/ForContainingFunction-client-0e704cc69989fb9da72c0528cbf5d0f66bcea224.ts +0 -88
- package/test/for/components/temp/ForContainingFunction-server-c97c0131eed62a1b1fd22da182825fcf717c160a.ts +0 -29
- package/test/for/components/temp/ForContainingFunction-types-16613a1611dfc0b949a78fadd771f6737de61703.ts +0 -10
- package/test/for/components/temp/ForContainingIf-client-97a42fb914e0a3c13509114d0c0cac135f303f16.ts +0 -106
- package/test/for/components/temp/ForContainingIf-server-ba43d99a0430bd211525168f199c5b6706526e08.ts +0 -27
- package/test/for/components/temp/ForContainingIf-types-16613a1611dfc0b949a78fadd771f6737de61703.ts +0 -10
- package/test/for/components/temp/ForEscape-client-af763615c118e3cfd0b3f4008e9a3c209ffbb2dd.ts +0 -99
- package/test/for/components/temp/ForEscape-server-ed5da041557c5ef2988e3e1bb1094340b8e86266.ts +0 -26
- package/test/for/components/temp/ForEscape-types-bb4f3457b02c2ad97a7b6cbc66f9097a37728ed2.ts +0 -10
- package/test/for/components/temp/ForIn-client-06be96d11abe3408aa72519b9eba9ea590327093.ts +0 -79
- package/test/for/components/temp/ForIn-server-8c9d8c3e2272731706b27a18ea4a7dc7c7b644ac.ts +0 -22
- package/test/for/components/temp/ForIn-types-fb4f7b02e23a40d27376760b7e1d06f8ecaa13ba.ts +0 -10
- package/test/for/components/temp/ForOf-client-cc2563ccd0d1b08dfc1b4ee3e1d5a66516009059.ts +0 -79
- package/test/for/components/temp/ForOf-server-5ed73f4ddb3cd32ced6d2d0d7d1db3c0e241a5d6.ts +0 -22
- package/test/for/components/temp/ForOf-types-6e2fbcd0fbfd3c0a2c3d8c458fdda7b05c2a19b1.ts +0 -10
- package/test/for/for-after-for.test.ts +0 -56
- package/test/for/for-containing-for.test.ts +0 -46
- package/test/for/for-containing-function.test.ts +0 -47
- package/test/for/for-containing-if.test.ts +0 -48
- package/test/for/for-escape.test.ts +0 -59
- package/test/for/for-in.test.ts +0 -61
- package/test/for/for-of.test.ts +0 -55
- package/test/for/for-with-key.test.ts +0 -50
- package/test/for/for.test.ts +0 -46
- package/test/function/components/output/Function-client.ts +0 -46
- package/test/function/components/output/Function-server.ts +0 -28
- package/test/function/components/output/Function-types.ts +0 -10
- package/test/function/components/temp/Function-client-a386620409f1dd3658c357fc574c96aa8dd9b9be.ts +0 -46
- package/test/function/components/temp/Function-server-9a4b3a772ac4b0ff50b6e7c6a6f83913412b134b.ts +0 -28
- package/test/function/components/temp/Function-types-5479cb46b9bef3251b7961fb6e99a8c30cd4220f.ts +0 -10
- package/test/function/function.test.ts +0 -50
- package/test/globalSetup.ts +0 -13
- package/test/helpers.ts +0 -170
- package/test/html/components/output/Html-client.ts +0 -50
- package/test/html/components/output/Html-server.ts +0 -17
- package/test/html/components/output/Html-types.ts +0 -10
- package/test/html/components/temp/Html-client-956231afa11be99d3fdc19a37817333b0d17e356.ts +0 -50
- package/test/html/components/temp/Html-server-8eeb3231f8863cca92099793eebb05a0c2d69110.ts +0 -17
- package/test/html/components/temp/Html-types-c5dc816f932e3fb021c006f266a7c9a2f2fb5353.ts +0 -10
- package/test/html/html.test.ts +0 -58
- package/test/hydrateComponent.ts +0 -16
- package/test/if/components/output/ElseIfTrue-client.ts +0 -76
- package/test/if/components/output/ElseIfTrue-server.ts +0 -27
- package/test/if/components/output/ElseIfTrue-types.ts +0 -10
- package/test/if/components/output/ElseTrue-client.ts +0 -76
- package/test/if/components/output/ElseTrue-server.ts +0 -27
- package/test/if/components/output/ElseTrue-types.ts +0 -10
- package/test/if/components/output/IfAfterIf-client.ts +0 -80
- package/test/if/components/output/IfAfterIf-server.ts +0 -25
- package/test/if/components/output/IfAfterIf-types.ts +0 -10
- package/test/if/components/output/IfCache-client.ts +0 -70
- package/test/if/components/output/IfCache-server.ts +0 -24
- package/test/if/components/output/IfCache-types.ts +0 -10
- package/test/if/components/output/IfContainingFor-client.ts +0 -104
- package/test/if/components/output/IfContainingFor-server.ts +0 -26
- package/test/if/components/output/IfContainingFor-types.ts +0 -10
- package/test/if/components/output/IfContainingFunction-client.ts +0 -64
- package/test/if/components/output/IfContainingFunction-server.ts +0 -27
- package/test/if/components/output/IfContainingFunction-types.ts +0 -10
- package/test/if/components/output/IfContainingIf-client.ts +0 -88
- package/test/if/components/output/IfContainingIf-server.ts +0 -28
- package/test/if/components/output/IfContainingIf-types.ts +0 -10
- package/test/if/components/output/IfElseFalse-client.ts +0 -64
- package/test/if/components/output/IfElseFalse-server.ts +0 -24
- package/test/if/components/output/IfElseFalse-types.ts +0 -10
- package/test/if/components/output/IfElseTrue-client.ts +0 -64
- package/test/if/components/output/IfElseTrue-server.ts +0 -24
- package/test/if/components/output/IfElseTrue-types.ts +0 -10
- package/test/if/components/output/IfFalse-client.ts +0 -56
- package/test/if/components/output/IfFalse-server.ts +0 -21
- package/test/if/components/output/IfFalse-types.ts +0 -10
- package/test/if/components/output/IfNested-client.ts +0 -96
- package/test/if/components/output/IfNested-server.ts +0 -31
- package/test/if/components/output/IfNested-types.ts +0 -10
- package/test/if/components/temp/ElseIfTrue-client-d16eee5a11582717355deb9781b3ba9695f496c0.ts +0 -76
- package/test/if/components/temp/ElseIfTrue-server-47a3f8077b1a8b0db5da756b1934e92f09ff4c13.ts +0 -27
- package/test/if/components/temp/ElseIfTrue-types-a492d2b6e8517f598befca7127cd514244239984.ts +0 -10
- package/test/if/components/temp/ElseTrue-client-d16eee5a11582717355deb9781b3ba9695f496c0.ts +0 -76
- package/test/if/components/temp/ElseTrue-server-47a3f8077b1a8b0db5da756b1934e92f09ff4c13.ts +0 -27
- package/test/if/components/temp/ElseTrue-types-a492d2b6e8517f598befca7127cd514244239984.ts +0 -10
- package/test/if/components/temp/IfAfterIf-client-70712848820e1bb593ee7c5f5d333d82a58f6a97.ts +0 -80
- package/test/if/components/temp/IfAfterIf-server-479ceb567eb7e771ecd0f2a370a99dfca28b36f7.ts +0 -25
- package/test/if/components/temp/IfAfterIf-types-c4bd4f93c103a618889f40c77d55fa7de454f70b.ts +0 -10
- package/test/if/components/temp/IfCache-client-470e5e1f0c2111d5756e55f3dcc0f5404a70bade.ts +0 -70
- package/test/if/components/temp/IfCache-server-4115f625d77b834c0d82f76dace5a29e9bf10683.ts +0 -24
- package/test/if/components/temp/IfCache-types-02f467ce9ebc23ae68c9e5f33c90ecc96b666452.ts +0 -10
- package/test/if/components/temp/IfContainingFor-client-500dab2db4653b0fc121a16f74b2cab8335c72f1.ts +0 -104
- package/test/if/components/temp/IfContainingFor-server-7dadac38399f1a22968fc16715b6647cf3e0729c.ts +0 -26
- package/test/if/components/temp/IfContainingFor-types-f93572daa0ecf537aabeba1277394d193fe39e9a.ts +0 -10
- package/test/if/components/temp/IfContainingFunction-client-3dbc7f995da90672bbbdaaecab3f6ce8e05830af.ts +0 -64
- package/test/if/components/temp/IfContainingFunction-server-a204a3f1dc468dd8dc783199eb73edb1d49e5775.ts +0 -27
- package/test/if/components/temp/IfContainingFunction-types-f93572daa0ecf537aabeba1277394d193fe39e9a.ts +0 -10
- package/test/if/components/temp/IfContainingIf-client-37ab307b4f6e316d79681b42f37649eeb7136798.ts +0 -88
- package/test/if/components/temp/IfContainingIf-server-4fbee02784b014175bcb5cc90c3c6246d15a6f5e.ts +0 -28
- package/test/if/components/temp/IfContainingIf-types-f93572daa0ecf537aabeba1277394d193fe39e9a.ts +0 -10
- package/test/if/components/temp/IfContainingIfAfterIf-client-f435f9bc464edfaf580ef7c1726a4be5ba8c6f6f.ts +0 -116
- package/test/if/components/temp/IfContainingIfAfterIf-server-2cfd604fd3a7187217437bd97dc89a4c6aeb8726.ts +0 -29
- package/test/if/components/temp/IfContainingIfAfterIf-types-805203b39332252a17996786ac79ece914bbea34.ts +0 -10
- package/test/if/components/temp/IfElseFalse-client-b2d08e03aee434b3758134b5cfb72bd2f18fa22e.ts +0 -64
- package/test/if/components/temp/IfElseFalse-server-52f6dac76bacbe350071957956cb282dba8cfbdd.ts +0 -24
- package/test/if/components/temp/IfElseFalse-types-e81080227f8f69ac1d81141d97a07e0a0e9391c1.ts +0 -10
- package/test/if/components/temp/IfElseTrue-client-b2d08e03aee434b3758134b5cfb72bd2f18fa22e.ts +0 -64
- package/test/if/components/temp/IfElseTrue-server-52f6dac76bacbe350071957956cb282dba8cfbdd.ts +0 -24
- package/test/if/components/temp/IfElseTrue-types-e81080227f8f69ac1d81141d97a07e0a0e9391c1.ts +0 -10
- package/test/if/components/temp/IfFalse-client-fbccb762d70b201b676b58c28e9c932e86c705cf.ts +0 -56
- package/test/if/components/temp/IfFalse-server-d13dc53aa5d556c19183947090657e045b6c32c5.ts +0 -21
- package/test/if/components/temp/IfFalse-types-1d512c6d82e2af9efe0221a9929b05ad62fd97fb.ts +0 -10
- package/test/if/components/temp/IfNested-client-8e7f7c3e3ea0058b3b4cbe702bd10a7f2a1fe5cd.ts +0 -96
- package/test/if/components/temp/IfNested-server-8a2513b704782704e7e184924c35e55958b15ae1.ts +0 -31
- package/test/if/components/temp/IfNested-types-692d58ca98f3534102193a44aa358994f798ca7b.ts +0 -10
- package/test/if/else-if-true.test.ts +0 -70
- package/test/if/else-true.test.ts +0 -70
- package/test/if/if-after-if.test.ts +0 -64
- package/test/if/if-cache.test.ts +0 -77
- package/test/if/if-containing-for.test.ts +0 -65
- package/test/if/if-containing-function.test.ts +0 -57
- package/test/if/if-containing-if.test.ts +0 -67
- package/test/if/if-else-false.test.ts +0 -66
- package/test/if/if-else-true.test.ts +0 -69
- package/test/if/if-false.test.ts +0 -56
- package/test/if/if-nested.test.ts +0 -72
- package/test/importComponent.ts +0 -34
- package/test/importComponentFromFile.ts +0 -19
- package/test/imports/commented-imports.test.ts +0 -30
- package/test/imports/imports.test.ts +0 -37
- package/test/imports/multiple-imports.test.ts +0 -182
- package/test/mount/components/output/Mount-client.ts +0 -36
- package/test/mount/components/output/Mount-server.ts +0 -25
- package/test/mount/components/output/Mount-types.ts +0 -10
- package/test/mount/components/temp/Mount-client-411fc5e02f2d296627d26b3b5004dcbae0d176d9.ts +0 -36
- package/test/mount/components/temp/Mount-server-26084a91839f500626771919e57ddefcd9b35af6.ts +0 -25
- package/test/mount/components/temp/Mount-types-2d88616243f860d43b8b7d74a6bbeff9b2c6f27b.ts +0 -10
- package/test/mount/mount.test.ts +0 -42
- package/test/mountComponent.ts +0 -11
- package/test/on-mount/components/output/OnMount-client.ts +0 -33
- package/test/on-mount/components/output/OnMount-server.ts +0 -18
- package/test/on-mount/components/output/OnMount-types.ts +0 -10
- package/test/on-mount/components/temp/OnMount-client-7fb23d48f5c93e7026b0aefe1488e678b5f91042.ts +0 -33
- package/test/on-mount/components/temp/OnMount-server-1b724b3d6b49bc7cc2416bead3e5fa481e91d504.ts +0 -18
- package/test/on-mount/components/temp/OnMount-types-d0f834addb351520cc75a589cb9ec5b6a5a787b4.ts +0 -10
- package/test/on-mount/on-mount.test.ts +0 -36
- package/test/party/1-declare-state.test.ts +0 -39
- package/test/party/10-on-mount.test.ts +0 -45
- package/test/party/12-props.test.ts +0 -59
- package/test/party/13-emit-to-parent.test.ts +0 -71
- package/test/party/14-slot.test.ts +0 -58
- package/test/party/15-slot-fallback.test.ts +0 -58
- package/test/party/16-context.test.ts +0 -67
- package/test/party/17-input-text.test.ts +0 -48
- package/test/party/18-input-checkbox.test.ts +0 -49
- package/test/party/19-input-radio.test.ts +0 -60
- package/test/party/2-update-state.test.ts +0 -40
- package/test/party/20-input-select.test.ts +0 -71
- package/test/party/3-computed-state.test.ts +0 -42
- package/test/party/4-minimal-template.test.ts +0 -35
- package/test/party/5-styling.test.ts +0 -43
- package/test/party/6-loop.test.ts +0 -44
- package/test/party/7-event-click.test.ts +0 -50
- package/test/party/8-dom-ref.test.ts +0 -43
- package/test/party/9-conditional.test.ts +0 -74
- package/test/party/components/output/ComputedState-client.ts +0 -42
- package/test/party/components/output/ComputedState-server.ts +0 -27
- package/test/party/components/output/ComputedState-types.ts +0 -10
- package/test/party/components/output/Conditional-client.ts +0 -105
- package/test/party/components/output/Conditional-server.ts +0 -42
- package/test/party/components/output/Conditional-types.ts +0 -10
- package/test/party/components/output/Context-client.ts +0 -83
- package/test/party/components/output/Context-server.ts +0 -52
- package/test/party/components/output/Context-types.ts +0 -10
- package/test/party/components/output/DeclareState-client.ts +0 -39
- package/test/party/components/output/DeclareState-server.ts +0 -24
- package/test/party/components/output/DeclareState-types.ts +0 -10
- package/test/party/components/output/DomRef-client.ts +0 -37
- package/test/party/components/output/DomRef-server.ts +0 -26
- package/test/party/components/output/DomRef-types.ts +0 -10
- package/test/party/components/output/EmitToParent-client.ts +0 -87
- package/test/party/components/output/EmitToParent-server.ts +0 -56
- package/test/party/components/output/EmitToParent-types.ts +0 -10
- package/test/party/components/output/EventClick-client.ts +0 -46
- package/test/party/components/output/EventClick-server.ts +0 -28
- package/test/party/components/output/EventClick-types.ts +0 -10
- package/test/party/components/output/InputCheckbox-client.ts +0 -45
- package/test/party/components/output/InputCheckbox-server.ts +0 -24
- package/test/party/components/output/InputCheckbox-types.ts +0 -10
- package/test/party/components/output/InputRadio-client.ts +0 -54
- package/test/party/components/output/InputRadio-server.ts +0 -25
- package/test/party/components/output/InputRadio-types.ts +0 -10
- package/test/party/components/output/InputSelect-client.ts +0 -105
- package/test/party/components/output/InputSelect-server.ts +0 -36
- package/test/party/components/output/InputSelect-types.ts +0 -10
- package/test/party/components/output/InputText-client.ts +0 -45
- package/test/party/components/output/InputText-server.ts +0 -25
- package/test/party/components/output/InputText-types.ts +0 -10
- package/test/party/components/output/Loop-client.ts +0 -83
- package/test/party/components/output/Loop-server.ts +0 -25
- package/test/party/components/output/Loop-types.ts +0 -10
- package/test/party/components/output/MinimalTemplate-client.ts +0 -27
- package/test/party/components/output/MinimalTemplate-server.ts +0 -18
- package/test/party/components/output/MinimalTemplate-types.ts +0 -10
- package/test/party/components/output/OnMount-client.ts +0 -43
- package/test/party/components/output/OnMount-server.ts +0 -29
- package/test/party/components/output/OnMount-types.ts +0 -10
- package/test/party/components/output/Props-client.ts +0 -83
- package/test/party/components/output/Props-server.ts +0 -50
- package/test/party/components/output/Props-types.ts +0 -10
- package/test/party/components/output/Slot-client.ts +0 -85
- package/test/party/components/output/Slot-server.ts +0 -69
- package/test/party/components/output/Slot-types.ts +0 -10
- package/test/party/components/output/SlotFallback-client.ts +0 -85
- package/test/party/components/output/SlotFallback-server.ts +0 -69
- package/test/party/components/output/SlotFallback-types.ts +0 -10
- package/test/party/components/output/Styling-client.ts +0 -27
- package/test/party/components/output/Styling-server.ts +0 -21
- package/test/party/components/output/Styling-types.ts +0 -10
- package/test/party/components/output/UpdateState-client.ts +0 -40
- package/test/party/components/output/UpdateState-server.ts +0 -25
- package/test/party/components/output/UpdateState-types.ts +0 -10
- package/test/party/components/temp/ComputedState-client-473e1fa90e27365be8f5ea1432977ac16c5ed586.ts +0 -42
- package/test/party/components/temp/ComputedState-server-ae1a02b6e98e8e4d37be20a37af002b29e54e259.ts +0 -27
- package/test/party/components/temp/ComputedState-types-436bd75fe7808c3a30389aeb1740aea361aa8681.ts +0 -10
- package/test/party/components/temp/Conditional-client-5c7921202718284dba4d3236219532564351ae43.ts +0 -105
- package/test/party/components/temp/Conditional-server-2b55ee76a71a9e697124cb93b6d3bb5b90709855.ts +0 -42
- package/test/party/components/temp/Conditional-types-d301a2317da01a215fc8e5222dc6ff87226fa250.ts +0 -10
- package/test/party/components/temp/Context-client-d38e35d2f851fa88938cc1758fd8820fa47dfe8e.ts +0 -83
- package/test/party/components/temp/Context-server-2a72df9fe275e376a358954d962ff05b22d2c8e9.ts +0 -52
- package/test/party/components/temp/Context-types-d04199ab7d43ecc12ceccb7a0bef7ff38ac1e8b1.ts +0 -10
- package/test/party/components/temp/DeclareState-client-44648d7db561c7e88021e076335475511b2d37fe.ts +0 -39
- package/test/party/components/temp/DeclareState-server-f941a9e5505c3e5125cbd5bcab99d74407b6b570.ts +0 -24
- package/test/party/components/temp/DeclareState-types-06f89338c785a1fd352ed7de3ebe02b30722760d.ts +0 -10
- package/test/party/components/temp/DomRef-client-cae57e146fc33eb104a6ada0476c07a434a65562.ts +0 -37
- package/test/party/components/temp/DomRef-server-a81201ce5b2987207ca9375370ff278bb51d12b0.ts +0 -26
- package/test/party/components/temp/DomRef-types-33da14c13216ca00edaa8f02508db21f5cd32d31.ts +0 -10
- package/test/party/components/temp/EmitToParent-client-d5379e6fa015e1e591f061852f5bcc35a80c584c.ts +0 -87
- package/test/party/components/temp/EmitToParent-server-79aabe3df7c5fd61144e53a71ab3833375cbd473.ts +0 -56
- package/test/party/components/temp/EmitToParent-types-10a6f55029e859366f9a3a73cdcdb3f63e89dbeb.ts +0 -10
- package/test/party/components/temp/EventClick-client-c7584b79c09e2545c81553e76233b9d07f286d06.ts +0 -46
- package/test/party/components/temp/EventClick-server-7ae082e9c92107b0f042f9b0877e7e4c7ad0fa38.ts +0 -28
- package/test/party/components/temp/EventClick-types-206b0704ee2e25f5f3198d716fa524295581c075.ts +0 -10
- package/test/party/components/temp/InputCheckbox-client-97f354e60679541174229d2b0ac71663023b008a.ts +0 -45
- package/test/party/components/temp/InputCheckbox-server-82f054fbabb357aa466b489bfdea76e582ff220e.ts +0 -24
- package/test/party/components/temp/InputCheckbox-types-23d4e196c659901c347a7b3e5c9e4a6668234adb.ts +0 -10
- package/test/party/components/temp/InputRadio-client-ba6fa665a594ba2ea291eaa211aa236be3ae1999.ts +0 -54
- package/test/party/components/temp/InputRadio-server-620981bdc7ab6d42ba08e04ba8c16f9ed477e1c0.ts +0 -25
- package/test/party/components/temp/InputRadio-types-526e2bb4c36ec1bed87eaf5722093a0eaefcd9d3.ts +0 -10
- package/test/party/components/temp/InputSelect-client-531d91c6bd0ef17dad8b40f0903138be3631025a.ts +0 -105
- package/test/party/components/temp/InputSelect-server-c36d8b8c533d2104122490dde64554f65cb15544.ts +0 -36
- package/test/party/components/temp/InputSelect-types-e652a36ebdd98e8c23a8de3156c4499023f09301.ts +0 -10
- package/test/party/components/temp/InputText-client-08763044ae40897bd697e9a62a23660853abd829.ts +0 -45
- package/test/party/components/temp/InputText-server-3546f8ce8a31bbe0869b9a351d6da7f649e7daf6.ts +0 -25
- package/test/party/components/temp/InputText-types-ab629048402441fde9a292bc2d376c0deea482a8.ts +0 -10
- package/test/party/components/temp/Loop-client-4f033ac051223f80ce4e8c82bd61641b6da94178.ts +0 -83
- package/test/party/components/temp/Loop-server-5bbcca21d3ec9a1f314aaf02d89d18cb08dcc7ee.ts +0 -25
- package/test/party/components/temp/Loop-types-075975e9b9074b49f96f99d660f0ee580546a630.ts +0 -10
- package/test/party/components/temp/MinimalTemplate-client-8163ab942acd62118fcbc955b14965fcccffdb4b.ts +0 -27
- package/test/party/components/temp/MinimalTemplate-server-5df0b3d954b992d75cc0de1ae65cfc48d1059422.ts +0 -18
- package/test/party/components/temp/MinimalTemplate-types-3c153ac7af343dbce6cb081f1ae1b4f85d7f0b10.ts +0 -10
- package/test/party/components/temp/OnMount-client-aa37e9cedf6353d464c0ed9d87d2edceb83069d3.ts +0 -43
- package/test/party/components/temp/OnMount-server-9c991ae9f8ab11a4b0343e9fffa8ce8b945bb056.ts +0 -29
- package/test/party/components/temp/OnMount-types-dfb55ea9b607c89167dbd7538523a484a6eec300.ts +0 -10
- package/test/party/components/temp/Props-client-760a5da0a852aea0c4d0f07a977e1a0e1b892782.ts +0 -83
- package/test/party/components/temp/Props-server-208bcc8cbc5c5e7ed0072c350cf96eb6b4754686.ts +0 -50
- package/test/party/components/temp/Props-types-3e70c106e03c68b4aa06c2fe21dfeceffe7cc313.ts +0 -10
- package/test/party/components/temp/Slot-client-e353ce6d73839cf111973dbd731ca0166f6d2c5c.ts +0 -85
- package/test/party/components/temp/Slot-server-9ffd9b714b531112129b5c826dd8586a5ea73209.ts +0 -69
- package/test/party/components/temp/Slot-types-ea73d641565a4478759166f462206dd97c92cedd.ts +0 -10
- package/test/party/components/temp/SlotFallback-client-e353ce6d73839cf111973dbd731ca0166f6d2c5c.ts +0 -85
- package/test/party/components/temp/SlotFallback-server-9ffd9b714b531112129b5c826dd8586a5ea73209.ts +0 -69
- package/test/party/components/temp/SlotFallback-types-ea73d641565a4478759166f462206dd97c92cedd.ts +0 -10
- package/test/party/components/temp/Styling-client-a85514d860d10fb97b83eea979c11aa7bef7dc23.ts +0 -27
- package/test/party/components/temp/Styling-server-32af1b2077f7979b0956904ee9e657a41f512a5c.ts +0 -21
- package/test/party/components/temp/Styling-types-f1ce4f0b03d404c70704f271ce9bfc5d5107346c.ts +0 -10
- package/test/party/components/temp/UpdateState-client-10e1582a52dd50d99cd0c48a76910ce9d5ae3fd1.ts +0 -40
- package/test/party/components/temp/UpdateState-server-9c6e94e88cd8b9032aeae0a2c4a6cd51f7d09c95.ts +0 -25
- package/test/party/components/temp/UpdateState-types-9c69805006d2d3bb457c5d4d87db8baeb431aeb6.ts +0 -10
- package/test/preact.test.ts +0 -2560
- package/test/props/components/output/Reactive-client.ts +0 -73
- package/test/props/components/output/Reactive-server.ts +0 -45
- package/test/props/components/output/Reactive-types.ts +0 -10
- package/test/props/components/temp/Reactive-client-f827f9bee0043cea318d45af4882792c2f5f0514.ts +0 -73
- package/test/props/components/temp/Reactive-server-6728168c7df78b8ebf94b53358cb8f6f5e7ce6e7.ts +0 -45
- package/test/props/components/temp/Reactive-types-f0238cd99c1271ff53705c40848ec94c8ca25e3a.ts +0 -10
- package/test/props/props.test.ts +0 -17
- package/test/props/reactive.test.ts +0 -52
- package/test/replace/components/output/Replace-client.ts +0 -58
- package/test/replace/components/output/Replace-server.ts +0 -23
- package/test/replace/components/output/Replace-types.ts +0 -10
- package/test/replace/components/temp/Replace-client-00856a163c5bf2c42ddda4f856461d1ac4d47bf9.ts +0 -58
- package/test/replace/components/temp/Replace-server-f415c96e5ea7c2f370fd3c55ef6b8b7e0cb7b3ee.ts +0 -23
- package/test/replace/components/temp/Replace-types-9aedaa79e9b616ea1780ea97306f3428faa5d477.ts +0 -10
- package/test/replace/replace.test.ts +0 -64
- package/test/run/watch-array.test.ts +0 -22
- package/test/run/watch-defined-property.test.ts +0 -25
- package/test/run/watch-effect.test.ts +0 -17
- package/test/run/watch-function.test.ts +0 -20
- package/test/run/watch-getter.test.ts +0 -20
- package/test/run/watch-set-same-value.test.ts +0 -28
- package/test/script/script-with-comments.test.ts +0 -34
- package/test/script/script-with-strings.test.ts +0 -28
- package/test/script/script.test.ts +0 -24
- package/test/slots/basic-slot.test.ts +0 -48
- package/test/slots/components/output/BasicSlot-client.ts +0 -79
- package/test/slots/components/output/BasicSlot-server.ts +0 -55
- package/test/slots/components/output/BasicSlot-types.ts +0 -10
- package/test/slots/components/output/LetSlot-client.ts +0 -135
- package/test/slots/components/output/LetSlot-server.ts +0 -61
- package/test/slots/components/output/LetSlot-types.ts +0 -10
- package/test/slots/components/output/NamedSlot-client.ts +0 -98
- package/test/slots/components/output/NamedSlot-server.ts +0 -71
- package/test/slots/components/output/NamedSlot-types.ts +0 -10
- package/test/slots/components/output/UnusedSlot-client.ts +0 -65
- package/test/slots/components/output/UnusedSlot-server.ts +0 -44
- package/test/slots/components/output/UnusedSlot-types.ts +0 -10
- package/test/slots/components/temp/BasicSlot-client-fb283dc3759b543cb0b4b5561a9c79b29d520fb9.ts +0 -79
- package/test/slots/components/temp/BasicSlot-server-a2deda4f03ac76f9bb924e01a9c04a82ef8c6576.ts +0 -55
- package/test/slots/components/temp/BasicSlot-types-709765786c453e34088db3e894a59fb3332d3ed1.ts +0 -10
- package/test/slots/components/temp/LetSlot-client-484681cc8921276d4f499153715954dbd1b5db33.ts +0 -135
- package/test/slots/components/temp/LetSlot-server-276bc0a6777f67cb357ec2cde625cdd81e1dc882.ts +0 -61
- package/test/slots/components/temp/LetSlot-types-10ae95da96dbe9990b06cbff94e7db0c8651d2b5.ts +0 -10
- package/test/slots/components/temp/NamedSlot-client-dbd42fb0e05da85cc4e5933adac770e63bcdf0e5.ts +0 -98
- package/test/slots/components/temp/NamedSlot-server-66508f6683c334a800d612ee55942e414ac13766.ts +0 -71
- package/test/slots/components/temp/NamedSlot-types-ed10fb6338eb9bd67281b9658bd7b10b572d346a.ts +0 -10
- package/test/slots/components/temp/UnusedSlot-client-eba6314df240becf0b8144e8a728c9c300311c97.ts +0 -65
- package/test/slots/components/temp/UnusedSlot-server-315be7277a95a1fb4c8e9519e4b796c57272ce9d.ts +0 -44
- package/test/slots/components/temp/UnusedSlot-types-88f7e38611b4cae1067969cf702cde41422837ae.ts +0 -10
- package/test/slots/let-slot.test.ts +0 -62
- package/test/slots/named-slot.test.ts +0 -55
- package/test/slots/unused-slot.test.ts +0 -45
- package/test/source-maps/interpolated.test.ts +0 -88
- package/test/source-maps/parse.test.ts +0 -62
- package/test/special-component/components/output/SpecialComponent-client.ts +0 -127
- package/test/special-component/components/output/SpecialComponent-server.ts +0 -83
- package/test/special-component/components/output/SpecialComponent-types.ts +0 -10
- package/test/special-component/components/temp/SpecialComponent-client-87b33f7abbaa5821348ac63491021bd8a994da07.ts +0 -127
- package/test/special-component/components/temp/SpecialComponent-server-cebe1ec049e2ce8303e94a1246acca40c64443c8.ts +0 -83
- package/test/special-component/components/temp/SpecialComponent-types-3ef4f140ba29c98357caf0f2618785437b5804de.ts +0 -10
- package/test/special-component/special-component.test.ts +0 -76
- package/test/special-element/components/output/SpecialElement-client.ts +0 -36
- package/test/special-element/components/output/SpecialElement-server.ts +0 -17
- package/test/special-element/components/output/SpecialElement-types.ts +0 -10
- package/test/special-element/components/temp/SpecialElement-client-6c11102dc76f11f2d437d78936651fe50b8ec97e.ts +0 -36
- package/test/special-element/components/temp/SpecialElement-server-254b4fb61873549a24d215891a9195ba008b6098.ts +0 -17
- package/test/special-element/components/temp/SpecialElement-types-478aac6fcc8cc71dc587b534bb45ddcde069e2cb.ts +0 -10
- package/test/special-element/special-element.test.ts +0 -55
- package/test/special-head/components/output/SpecialHead-client.ts +0 -22
- package/test/special-head/components/output/SpecialHead-server.ts +0 -15
- package/test/special-head/components/output/SpecialHead-types.ts +0 -10
- package/test/special-head/components/temp/SpecialHead-client-39c4f86e998309da6125f563bd4d45d89250f108.ts +0 -22
- package/test/special-head/components/temp/SpecialHead-server-702470ee8fabae38313dc532dd5f26995d2366f6.ts +0 -15
- package/test/special-head/components/temp/SpecialHead-types-88772e6c9aefe7f65c342350ad45b29e7fa16604.ts +0 -10
- package/test/special-head/special-head.test.ts +0 -49
- package/test/special-self/components/output/SpecialSelf-client.ts +0 -75
- package/test/special-self/components/output/SpecialSelf-server.ts +0 -29
- package/test/special-self/components/output/SpecialSelf-types.ts +0 -10
- package/test/special-self/components/temp/SpecialSelf-client-088aa4e2721c30b8be1538630250aee43fe5bd0d.ts +0 -75
- package/test/special-self/components/temp/SpecialSelf-server-b7f52c0bb10d507086e63a100cd1c7c705b1c014.ts +0 -29
- package/test/special-self/components/temp/SpecialSelf-types-d438955d6f42951942dfa72ec1b79ad4ee95e966.ts +0 -10
- package/test/special-self/special-self.test.ts +0 -54
- package/test/style/components/output/Style-client.ts +0 -32
- package/test/style/components/output/Style-server.ts +0 -18
- package/test/style/components/output/Style-types.ts +0 -10
- package/test/style/components/temp/Style-client-1a7f59c1a65f59b76e8c196d9ebd6524a9c88b59.ts +0 -32
- package/test/style/components/temp/Style-server-f789c9d022ece18ce7a5729284dd555ad874371d.ts +0 -18
- package/test/style/components/temp/Style-types-d7ced2961f74be74eebaedfb98c492c6789d3cb8.ts +0 -10
- package/test/style/parse.test.ts +0 -597
- package/test/style/style.test.ts +0 -56
- package/test/svg/components/output/Svg-client.ts +0 -72
- package/test/svg/components/output/Svg-server.ts +0 -25
- package/test/svg/components/output/Svg-types.ts +0 -10
- package/test/svg/components/temp/Svg-client-822c22abd8dc029cd16551cfaad5a5b996d6d90a.ts +0 -72
- package/test/svg/components/temp/Svg-server-1b0a6697637618fd25b59d5bf54babb1afeacf2e.ts +0 -25
- package/test/svg/components/temp/Svg-types-70f9e311a005452b58286636c0dcb67a73e9fab4.ts +0 -10
- package/test/svg/svg.test.ts +0 -57
- package/test/switch/components/output/Switch-client.ts +0 -89
- package/test/switch/components/output/Switch-server.ts +0 -40
- package/test/switch/components/output/Switch-types.ts +0 -18
- package/test/switch/components/temp/Switch-client-b818bdff1d68b371a4ddb02f2c980e2e076dbbcf.ts +0 -89
- package/test/switch/components/temp/Switch-server-9995e5e44b0a790ecdaa5e3c7367e3af85f1173b.ts +0 -40
- package/test/switch/components/temp/Switch-types-fad2e2b194747eb6c06474c81de5f814c15e06aa.ts +0 -18
- package/test/switch/switch.test.ts +0 -81
- package/test/template/basic-file.test.ts +0 -84
- package/test/template/empty-file.test.ts +0 -14
- package/test/template/errors.test.ts +0 -305
- package/test/text/components/output/Text-client.ts +0 -38
- package/test/text/components/output/Text-server.ts +0 -21
- package/test/text/components/output/Text-types.ts +0 -13
- package/test/text/components/temp/Text-client-5ae847f527793bc47cdc979746910e215fab7475.ts +0 -38
- package/test/text/components/temp/Text-server-fe60ab39cd9f3ec6e258ad77f4e86411038eb928.ts +0 -21
- package/test/text/components/temp/Text-types-8734fa84ea5e6d078b66a771ec48b821c954573f.ts +0 -13
- package/test/text/text.test.ts +0 -59
- package/test/watch/watch-nested-object.test.ts +0 -16
- package/test/watch/watch-null-object.test.ts +0 -9
- package/test/watch/watch-null-property.test.ts +0 -10
- package/test/watch/watch-simple-object.test.ts +0 -12
- package/test/watch/watch-undefined-object.test.ts +0 -9
- package/test/watch/watch-undefined-property.test.ts +0 -9
- package/test/watch-array/ArrayState.ts +0 -6
- package/test/watch-array/array-all-functions-unkeyed.test.ts +0 -99
- package/test/watch-array/array-all-functions.test.ts +0 -100
- package/test/watch-array/array-empty.test.ts +0 -53
- package/test/watch-array/array-entries.test.ts +0 -75
- package/test/watch-array/array-indexes.test.ts +0 -75
- package/test/watch-array/array-pop.test.ts +0 -68
- package/test/watch-array/array-push.test.ts +0 -68
- package/test/watch-array/array-reassign.test.ts +0 -77
- package/test/watch-array/array-reverse.test.ts +0 -68
- package/test/watch-array/array-set-object.test.ts +0 -68
- package/test/watch-array/array-set-property.test.ts +0 -68
- package/test/watch-array/array-shift.test.ts +0 -68
- package/test/watch-array/array-sort.test.ts +0 -72
- package/test/watch-array/array-splice-add.test.ts +0 -68
- package/test/watch-array/array-splice-delete-all.test.ts +0 -68
- package/test/watch-array/array-splice-delete-and-add.test.ts +0 -68
- package/test/watch-array/array-splice-delete-end.test.ts +0 -68
- package/test/watch-array/array-splice-delete.test.ts +0 -68
- package/test/watch-array/array-swap.test.ts +0 -72
- package/test/watch-array/array-unshift.test.ts +0 -68
- package/test/watch-array/array-update-assignment.test.ts +0 -73
- package/test/watch-array/components/output/ArrayAllFunctions-client.ts +0 -80
- package/test/watch-array/components/output/ArrayAllFunctions-server.ts +0 -22
- package/test/watch-array/components/output/ArrayAllFunctions-types.ts +0 -10
- package/test/watch-array/components/output/ArrayAllFunctionsUnkeyed-client.ts +0 -79
- package/test/watch-array/components/output/ArrayAllFunctionsUnkeyed-server.ts +0 -22
- package/test/watch-array/components/output/ArrayAllFunctionsUnkeyed-types.ts +0 -10
- package/test/watch-array/components/output/ArrayEmpty-client.ts +0 -80
- package/test/watch-array/components/output/ArrayEmpty-server.ts +0 -22
- package/test/watch-array/components/output/ArrayEmpty-types.ts +0 -10
- package/test/watch-array/components/output/ArrayEntries-client.ts +0 -81
- package/test/watch-array/components/output/ArrayEntries-server.ts +0 -22
- package/test/watch-array/components/output/ArrayEntries-types.ts +0 -10
- package/test/watch-array/components/output/ArrayIndexes-client.ts +0 -80
- package/test/watch-array/components/output/ArrayIndexes-server.ts +0 -22
- package/test/watch-array/components/output/ArrayIndexes-types.ts +0 -10
- package/test/watch-array/components/output/ArrayPop-client.ts +0 -80
- package/test/watch-array/components/output/ArrayPop-server.ts +0 -22
- package/test/watch-array/components/output/ArrayPop-types.ts +0 -10
- package/test/watch-array/components/output/ArrayPush-client.ts +0 -80
- package/test/watch-array/components/output/ArrayPush-server.ts +0 -22
- package/test/watch-array/components/output/ArrayPush-types.ts +0 -10
- package/test/watch-array/components/output/ArrayReassign-client.ts +0 -80
- package/test/watch-array/components/output/ArrayReassign-server.ts +0 -22
- package/test/watch-array/components/output/ArrayReassign-types.ts +0 -10
- package/test/watch-array/components/output/ArrayReverse-client.ts +0 -80
- package/test/watch-array/components/output/ArrayReverse-server.ts +0 -22
- package/test/watch-array/components/output/ArrayReverse-types.ts +0 -10
- package/test/watch-array/components/output/ArraySetObject-client.ts +0 -80
- package/test/watch-array/components/output/ArraySetObject-server.ts +0 -22
- package/test/watch-array/components/output/ArraySetObject-types.ts +0 -10
- package/test/watch-array/components/output/ArraySetProperty-client.ts +0 -80
- package/test/watch-array/components/output/ArraySetProperty-server.ts +0 -22
- package/test/watch-array/components/output/ArraySetProperty-types.ts +0 -10
- package/test/watch-array/components/output/ArrayShift-client.ts +0 -80
- package/test/watch-array/components/output/ArrayShift-server.ts +0 -22
- package/test/watch-array/components/output/ArrayShift-types.ts +0 -10
- package/test/watch-array/components/output/ArraySort-client.ts +0 -80
- package/test/watch-array/components/output/ArraySort-server.ts +0 -22
- package/test/watch-array/components/output/ArraySort-types.ts +0 -10
- package/test/watch-array/components/output/ArraySpliceAdd-client.ts +0 -80
- package/test/watch-array/components/output/ArraySpliceAdd-server.ts +0 -22
- package/test/watch-array/components/output/ArraySpliceAdd-types.ts +0 -10
- package/test/watch-array/components/output/ArraySpliceDelete-client.ts +0 -80
- package/test/watch-array/components/output/ArraySpliceDelete-server.ts +0 -22
- package/test/watch-array/components/output/ArraySpliceDelete-types.ts +0 -10
- package/test/watch-array/components/output/ArraySpliceDeleteAll-client.ts +0 -80
- package/test/watch-array/components/output/ArraySpliceDeleteAll-server.ts +0 -22
- package/test/watch-array/components/output/ArraySpliceDeleteAll-types.ts +0 -10
- package/test/watch-array/components/output/ArraySpliceDeleteAndAdd-client.ts +0 -80
- package/test/watch-array/components/output/ArraySpliceDeleteAndAdd-server.ts +0 -22
- package/test/watch-array/components/output/ArraySpliceDeleteAndAdd-types.ts +0 -10
- package/test/watch-array/components/output/ArraySpliceDeleteEnd-client.ts +0 -80
- package/test/watch-array/components/output/ArraySpliceDeleteEnd-server.ts +0 -22
- package/test/watch-array/components/output/ArraySpliceDeleteEnd-types.ts +0 -10
- package/test/watch-array/components/output/ArraySwap-client.ts +0 -80
- package/test/watch-array/components/output/ArraySwap-server.ts +0 -22
- package/test/watch-array/components/output/ArraySwap-types.ts +0 -10
- package/test/watch-array/components/output/ArrayUnshift-client.ts +0 -80
- package/test/watch-array/components/output/ArrayUnshift-server.ts +0 -22
- package/test/watch-array/components/output/ArrayUnshift-types.ts +0 -10
- package/test/watch-array/components/output/ArrayUpdateAssignment-client.ts +0 -80
- package/test/watch-array/components/output/ArrayUpdateAssignment-server.ts +0 -22
- package/test/watch-array/components/output/ArrayUpdateAssignment-types.ts +0 -10
- package/test/watch-array/components/temp/ArrayAllFunctions-client-544d5ee7280f204fab57094bc41652d4656104aa.ts +0 -80
- package/test/watch-array/components/temp/ArrayAllFunctions-server-d1a89cfb5dc28f027a56266feef2ede8e7ee8570.ts +0 -22
- package/test/watch-array/components/temp/ArrayAllFunctions-types-4afcc38999fa0a5d5b28b8c54ea8f25659d91165.ts +0 -10
- package/test/watch-array/components/temp/ArrayAllFunctionsUnkeyed-client-cdea644623ae3b5c005a990d70cc22864a81b4d7.ts +0 -79
- package/test/watch-array/components/temp/ArrayAllFunctionsUnkeyed-server-5a3dbdec1785a4b9ad02f5d877764257f28bc6dd.ts +0 -22
- package/test/watch-array/components/temp/ArrayAllFunctionsUnkeyed-types-6f544a6b354c46913b9ee0e843d0a6482af2745d.ts +0 -10
- package/test/watch-array/components/temp/ArrayEmpty-client-544d5ee7280f204fab57094bc41652d4656104aa.ts +0 -80
- package/test/watch-array/components/temp/ArrayEmpty-server-d1a89cfb5dc28f027a56266feef2ede8e7ee8570.ts +0 -22
- package/test/watch-array/components/temp/ArrayEmpty-types-4afcc38999fa0a5d5b28b8c54ea8f25659d91165.ts +0 -10
- package/test/watch-array/components/temp/ArrayEntries-client-c34e4ebcafc19fd07331a6637b1a21702c6b7e4c.ts +0 -81
- package/test/watch-array/components/temp/ArrayEntries-server-120529d0e96f1dd0c1cff0507f60e0e0b4fc0360.ts +0 -22
- package/test/watch-array/components/temp/ArrayEntries-types-ae83cd05c68e5e6b7e8d31212035c14ec9ea6b85.ts +0 -10
- package/test/watch-array/components/temp/ArrayIndexes-client-d6f07960e57bd1308a7923dc5e4b35c459c500ad.ts +0 -80
- package/test/watch-array/components/temp/ArrayIndexes-server-cf0648f9442836997c4d64fad5959f453ad5d77f.ts +0 -22
- package/test/watch-array/components/temp/ArrayIndexes-types-5f02ec73d46553fd5730abfe022dba9a76a341f7.ts +0 -10
- package/test/watch-array/components/temp/ArrayPop-client-544d5ee7280f204fab57094bc41652d4656104aa.ts +0 -80
- package/test/watch-array/components/temp/ArrayPop-server-d1a89cfb5dc28f027a56266feef2ede8e7ee8570.ts +0 -22
- package/test/watch-array/components/temp/ArrayPop-types-4afcc38999fa0a5d5b28b8c54ea8f25659d91165.ts +0 -10
- package/test/watch-array/components/temp/ArrayPush-client-544d5ee7280f204fab57094bc41652d4656104aa.ts +0 -80
- package/test/watch-array/components/temp/ArrayPush-server-d1a89cfb5dc28f027a56266feef2ede8e7ee8570.ts +0 -22
- package/test/watch-array/components/temp/ArrayPush-types-4afcc38999fa0a5d5b28b8c54ea8f25659d91165.ts +0 -10
- package/test/watch-array/components/temp/ArrayReassign-client-544d5ee7280f204fab57094bc41652d4656104aa.ts +0 -80
- package/test/watch-array/components/temp/ArrayReassign-server-d1a89cfb5dc28f027a56266feef2ede8e7ee8570.ts +0 -22
- package/test/watch-array/components/temp/ArrayReassign-types-4afcc38999fa0a5d5b28b8c54ea8f25659d91165.ts +0 -10
- package/test/watch-array/components/temp/ArrayReverse-client-544d5ee7280f204fab57094bc41652d4656104aa.ts +0 -80
- package/test/watch-array/components/temp/ArrayReverse-server-d1a89cfb5dc28f027a56266feef2ede8e7ee8570.ts +0 -22
- package/test/watch-array/components/temp/ArrayReverse-types-4afcc38999fa0a5d5b28b8c54ea8f25659d91165.ts +0 -10
- package/test/watch-array/components/temp/ArraySetObject-client-544d5ee7280f204fab57094bc41652d4656104aa.ts +0 -80
- package/test/watch-array/components/temp/ArraySetObject-server-d1a89cfb5dc28f027a56266feef2ede8e7ee8570.ts +0 -22
- package/test/watch-array/components/temp/ArraySetObject-types-4afcc38999fa0a5d5b28b8c54ea8f25659d91165.ts +0 -10
- package/test/watch-array/components/temp/ArraySetProperty-client-544d5ee7280f204fab57094bc41652d4656104aa.ts +0 -80
- package/test/watch-array/components/temp/ArraySetProperty-server-d1a89cfb5dc28f027a56266feef2ede8e7ee8570.ts +0 -22
- package/test/watch-array/components/temp/ArraySetProperty-types-4afcc38999fa0a5d5b28b8c54ea8f25659d91165.ts +0 -10
- package/test/watch-array/components/temp/ArrayShift-client-544d5ee7280f204fab57094bc41652d4656104aa.ts +0 -80
- package/test/watch-array/components/temp/ArrayShift-server-d1a89cfb5dc28f027a56266feef2ede8e7ee8570.ts +0 -22
- package/test/watch-array/components/temp/ArrayShift-types-4afcc38999fa0a5d5b28b8c54ea8f25659d91165.ts +0 -10
- package/test/watch-array/components/temp/ArraySort-client-544d5ee7280f204fab57094bc41652d4656104aa.ts +0 -80
- package/test/watch-array/components/temp/ArraySort-server-d1a89cfb5dc28f027a56266feef2ede8e7ee8570.ts +0 -22
- package/test/watch-array/components/temp/ArraySort-types-4afcc38999fa0a5d5b28b8c54ea8f25659d91165.ts +0 -10
- package/test/watch-array/components/temp/ArraySpliceAdd-client-544d5ee7280f204fab57094bc41652d4656104aa.ts +0 -80
- package/test/watch-array/components/temp/ArraySpliceAdd-server-d1a89cfb5dc28f027a56266feef2ede8e7ee8570.ts +0 -22
- package/test/watch-array/components/temp/ArraySpliceAdd-types-4afcc38999fa0a5d5b28b8c54ea8f25659d91165.ts +0 -10
- package/test/watch-array/components/temp/ArraySpliceDelete-client-544d5ee7280f204fab57094bc41652d4656104aa.ts +0 -80
- package/test/watch-array/components/temp/ArraySpliceDelete-server-d1a89cfb5dc28f027a56266feef2ede8e7ee8570.ts +0 -22
- package/test/watch-array/components/temp/ArraySpliceDelete-types-4afcc38999fa0a5d5b28b8c54ea8f25659d91165.ts +0 -10
- package/test/watch-array/components/temp/ArraySpliceDeleteAll-client-544d5ee7280f204fab57094bc41652d4656104aa.ts +0 -80
- package/test/watch-array/components/temp/ArraySpliceDeleteAll-server-d1a89cfb5dc28f027a56266feef2ede8e7ee8570.ts +0 -22
- package/test/watch-array/components/temp/ArraySpliceDeleteAll-types-4afcc38999fa0a5d5b28b8c54ea8f25659d91165.ts +0 -10
- package/test/watch-array/components/temp/ArraySpliceDeleteAndAdd-client-544d5ee7280f204fab57094bc41652d4656104aa.ts +0 -80
- package/test/watch-array/components/temp/ArraySpliceDeleteAndAdd-server-d1a89cfb5dc28f027a56266feef2ede8e7ee8570.ts +0 -22
- package/test/watch-array/components/temp/ArraySpliceDeleteAndAdd-types-4afcc38999fa0a5d5b28b8c54ea8f25659d91165.ts +0 -10
- package/test/watch-array/components/temp/ArraySpliceDeleteEnd-client-544d5ee7280f204fab57094bc41652d4656104aa.ts +0 -80
- package/test/watch-array/components/temp/ArraySpliceDeleteEnd-server-d1a89cfb5dc28f027a56266feef2ede8e7ee8570.ts +0 -22
- package/test/watch-array/components/temp/ArraySpliceDeleteEnd-types-4afcc38999fa0a5d5b28b8c54ea8f25659d91165.ts +0 -10
- package/test/watch-array/components/temp/ArraySwap-client-544d5ee7280f204fab57094bc41652d4656104aa.ts +0 -80
- package/test/watch-array/components/temp/ArraySwap-server-d1a89cfb5dc28f027a56266feef2ede8e7ee8570.ts +0 -22
- package/test/watch-array/components/temp/ArraySwap-types-4afcc38999fa0a5d5b28b8c54ea8f25659d91165.ts +0 -10
- package/test/watch-array/components/temp/ArrayUnshift-client-544d5ee7280f204fab57094bc41652d4656104aa.ts +0 -80
- package/test/watch-array/components/temp/ArrayUnshift-server-d1a89cfb5dc28f027a56266feef2ede8e7ee8570.ts +0 -22
- package/test/watch-array/components/temp/ArrayUnshift-types-4afcc38999fa0a5d5b28b8c54ea8f25659d91165.ts +0 -10
- package/test/watch-array/components/temp/ArrayUpdateAssignment-client-544d5ee7280f204fab57094bc41652d4656104aa.ts +0 -80
- package/test/watch-array/components/temp/ArrayUpdateAssignment-server-d1a89cfb5dc28f027a56266feef2ede8e7ee8570.ts +0 -22
- package/test/watch-array/components/temp/ArrayUpdateAssignment-types-4afcc38999fa0a5d5b28b8c54ea8f25659d91165.ts +0 -10
- package/test/watch-object/components/output/WatchObject-client.ts +0 -33
- package/test/watch-object/components/output/WatchObject-server.ts +0 -18
- package/test/watch-object/components/output/WatchObject-types.ts +0 -10
- package/test/watch-object/components/output/WatchUndefinedPropertyChange-client.ts +0 -33
- package/test/watch-object/components/output/WatchUndefinedPropertyChange-server.ts +0 -18
- package/test/watch-object/components/output/WatchUndefinedPropertyChange-types.ts +0 -10
- package/test/watch-object/components/temp/WatchObject-client-7068d8e33606a7a3e55a957fcab43bbc6e52d9ce.ts +0 -33
- package/test/watch-object/components/temp/WatchObject-server-b4a2dbff5525a2af64c1216cf6b6ecf800c03566.ts +0 -18
- package/test/watch-object/components/temp/WatchObject-types-05e791b7c4023f8ae6e8dd548fe3f16ea8c16d10.ts +0 -10
- package/test/watch-object/components/temp/WatchUndefinedPropertyChange-client-6c9b07c9055c68e1123a0ca0e34ffaf0bcfe0095.ts +0 -33
- package/test/watch-object/components/temp/WatchUndefinedPropertyChange-server-7af97c0938c3c851f60e86ef27188e0bcd432354.ts +0 -18
- package/test/watch-object/components/temp/WatchUndefinedPropertyChange-types-05e791b7c4023f8ae6e8dd548fe3f16ea8c16d10.ts +0 -10
- package/test/watch-object/watch-object.test.ts +0 -96
- package/test/watch-object/watch-undefined-property-change.test.ts +0 -51
- package/tsconfig.json +0 -4
- package/tsdown.config.ts +0 -6
- package/vitest.config.ts +0 -13
package/test/preact.test.ts
DELETED
|
@@ -1,2560 +0,0 @@
|
|
|
1
|
-
// eslint-disable no-unused-expressions
|
|
2
|
-
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
3
|
-
import context from "../src/render/context";
|
|
4
|
-
import $batch from "../src/watch/$batch";
|
|
5
|
-
import $cache from "../src/watch/$cache";
|
|
6
|
-
import $peek from "../src/watch/$peek";
|
|
7
|
-
import $run from "../src/watch/$run";
|
|
8
|
-
import $watch from "../src/watch/$watch";
|
|
9
|
-
|
|
10
|
-
//import checkState from "./checkState";
|
|
11
|
-
//import printDiagram from "./printDiagram";
|
|
12
|
-
//import printSimpleDiagram from "./printSimpleDiagram";
|
|
13
|
-
|
|
14
|
-
/*
|
|
15
|
-
let si = 1;
|
|
16
|
-
dev.subName = () => `S${si++}`;
|
|
17
|
-
dev.effectName = (fn: Function) => {
|
|
18
|
-
let name = String(fn);
|
|
19
|
-
if (name.startsWith("function ")) {
|
|
20
|
-
name = name.substring(9);
|
|
21
|
-
}
|
|
22
|
-
name = name.substring(0, name.indexOf("() {"));
|
|
23
|
-
return name;
|
|
24
|
-
};
|
|
25
|
-
dev.propName = (key: PropertyKey) => String(key);
|
|
26
|
-
*/
|
|
27
|
-
afterEach(() => {
|
|
28
|
-
//expect(context.activeTarget).toBe(null);
|
|
29
|
-
expect(context.batch, "POST TEST BATCH").toBe(0);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
describe("signal", () => {
|
|
33
|
-
it("should return value", () => {
|
|
34
|
-
const v = [1, 2];
|
|
35
|
-
let $state = $watch({ s: v });
|
|
36
|
-
expect($state.s).toEqual(v);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
// it("should inherit from Signal", () => {
|
|
40
|
-
// expect(signal(0)).to.be.instanceOf(Signal);
|
|
41
|
-
// });
|
|
42
|
-
//
|
|
43
|
-
// it("should support .toString()", () => {
|
|
44
|
-
// let $state = $watch({ s: 123 });
|
|
45
|
-
// expect(s.toString()).equal("123");
|
|
46
|
-
// });
|
|
47
|
-
//
|
|
48
|
-
// it("should support .toJSON()", () => {
|
|
49
|
-
// let $state = $watch({ s: 123 });
|
|
50
|
-
// expect(s.toJSON()).equal(123);
|
|
51
|
-
// });
|
|
52
|
-
//
|
|
53
|
-
// it("should support JSON.Stringify()", () => {
|
|
54
|
-
// let $state = $watch({ s: 123 });
|
|
55
|
-
// expect(JSON.stringify({ s })).equal(JSON.stringify({ s: 123 }));
|
|
56
|
-
// });
|
|
57
|
-
//
|
|
58
|
-
// it("should support .valueOf()", () => {
|
|
59
|
-
// let $state = $watch({ s: 123 });
|
|
60
|
-
// expect(s).to.have.property("valueOf");
|
|
61
|
-
// expect(s.valueOf).to.be.a("function");
|
|
62
|
-
// expect(s.valueOf()).equal(123);
|
|
63
|
-
// expect(+s).equal(123);
|
|
64
|
-
//
|
|
65
|
-
// let $state = $watch({ a: 1 });
|
|
66
|
-
// let $state = $watch({ b: 2 });
|
|
67
|
-
// // @ts-ignore-next-line
|
|
68
|
-
// expect(a + b).toEqual(3);
|
|
69
|
-
// });
|
|
70
|
-
//
|
|
71
|
-
// it("should notify other listeners of changes after one listener is disposed", () => {
|
|
72
|
-
// let $state = $watch({ s: 0 });
|
|
73
|
-
// let spy1 = vi.fn(() => {
|
|
74
|
-
// $state.s;
|
|
75
|
-
// });
|
|
76
|
-
// let spy2 = vi.fn(() => {
|
|
77
|
-
// $state.s;
|
|
78
|
-
// });
|
|
79
|
-
// let spy3 = vi.fn(() => {
|
|
80
|
-
// $state.s;
|
|
81
|
-
// });
|
|
82
|
-
//
|
|
83
|
-
// $run(spy1);
|
|
84
|
-
// const dispose = $run(spy2);
|
|
85
|
-
// $run(spy3);
|
|
86
|
-
//
|
|
87
|
-
// expect(spy1).toHaveBeenCalledOnce();
|
|
88
|
-
// expect(spy2).toHaveBeenCalledOnce();
|
|
89
|
-
// expect(spy3).toHaveBeenCalledOnce();
|
|
90
|
-
//
|
|
91
|
-
// dispose();
|
|
92
|
-
//
|
|
93
|
-
// $state.s = 1;
|
|
94
|
-
// expect(spy1).toHaveBeenCalledTimes(2);
|
|
95
|
-
// expect(spy2).toHaveBeenCalledOnce();
|
|
96
|
-
// expect(spy3).toHaveBeenCalledTimes(2);
|
|
97
|
-
// });
|
|
98
|
-
|
|
99
|
-
describe("$peek()", () => {
|
|
100
|
-
it("should get value", () => {
|
|
101
|
-
let $state = $watch({ s: 1 });
|
|
102
|
-
expect($peek(() => $state.s)).toEqual(1);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it("should get the updated value after a value change", () => {
|
|
106
|
-
let $state = $watch({ s: 1 });
|
|
107
|
-
$state.s = 2;
|
|
108
|
-
expect($peek(() => $state.s)).toEqual(2);
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it("should not make surrounding effect depend on the signal", () => {
|
|
112
|
-
let $state = $watch({ s: 1 });
|
|
113
|
-
let spy = vi.fn(() => {
|
|
114
|
-
$peek(() => $state.s);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
$run(spy);
|
|
118
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
119
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
120
|
-
|
|
121
|
-
$state.s = 2;
|
|
122
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it("should not make surrounding computed depend on the signal", () => {
|
|
126
|
-
let spy = vi.fn(() => {
|
|
127
|
-
$peek(() => $state.s);
|
|
128
|
-
});
|
|
129
|
-
let $state = $watch({
|
|
130
|
-
s: 1,
|
|
131
|
-
get d() {
|
|
132
|
-
return $cache(spy);
|
|
133
|
-
},
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
$state.d;
|
|
137
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
138
|
-
|
|
139
|
-
$state.s = 2;
|
|
140
|
-
$state.d;
|
|
141
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
describe("subscribe", () => {
|
|
146
|
-
it("should subscribe to a signal", () => {
|
|
147
|
-
let spy = vi.fn();
|
|
148
|
-
let $state = $watch({ a: 1 });
|
|
149
|
-
|
|
150
|
-
$run(() => {
|
|
151
|
-
spy($state.a);
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
expect(spy).toBeCalledWith(1);
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
it("should run the callback when the signal value changes", () => {
|
|
158
|
-
let spy = vi.fn();
|
|
159
|
-
let $state = $watch({ a: 1 });
|
|
160
|
-
|
|
161
|
-
$run(() => {
|
|
162
|
-
spy($state.a);
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
$state.a = 2;
|
|
166
|
-
expect(spy).toBeCalledWith(2);
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
// it("should unsubscribe from a signal", () => {
|
|
170
|
-
// let spy = vi.fn();
|
|
171
|
-
// let $state = $watch({ a: 1 });
|
|
172
|
-
//
|
|
173
|
-
// const dispose = a.subscribe(spy);
|
|
174
|
-
// dispose();
|
|
175
|
-
// spy.mockReset();
|
|
176
|
-
//
|
|
177
|
-
// $state.a = 2;
|
|
178
|
-
// expect(spy).not.toHaveBeenCalled();
|
|
179
|
-
// });
|
|
180
|
-
|
|
181
|
-
// it("should not start triggering on when a signal accessed in the callback changes", () => {
|
|
182
|
-
// let spy = vi.fn();
|
|
183
|
-
// let $state = $watch({ a: 0 });
|
|
184
|
-
// let $state = $watch({ b: 0 });
|
|
185
|
-
//
|
|
186
|
-
// a.subscribe(() => {
|
|
187
|
-
// $state.b;
|
|
188
|
-
// spy();
|
|
189
|
-
// });
|
|
190
|
-
// expect(spy).toHaveBeenCalledOnce();
|
|
191
|
-
// spy.mockReset();
|
|
192
|
-
//
|
|
193
|
-
// $state.b++;
|
|
194
|
-
// expect(spy).not.toHaveBeenCalled();
|
|
195
|
-
// });
|
|
196
|
-
|
|
197
|
-
it("should not cause surrounding effect to subscribe to changes to a signal accessed in the callback", () => {
|
|
198
|
-
let spy = vi.fn();
|
|
199
|
-
let $state = $watch({ a: 0, b: 0 });
|
|
200
|
-
|
|
201
|
-
$run(() => {
|
|
202
|
-
$state.a;
|
|
203
|
-
$run(() => {
|
|
204
|
-
$state.b;
|
|
205
|
-
});
|
|
206
|
-
spy();
|
|
207
|
-
});
|
|
208
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
209
|
-
spy.mockReset();
|
|
210
|
-
|
|
211
|
-
$state.b++;
|
|
212
|
-
expect(spy).not.toHaveBeenCalled();
|
|
213
|
-
});
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
// describe(".(un)watched()", () => {
|
|
217
|
-
// it("should call watched when first subscription occurs", () => {
|
|
218
|
-
// const watched = vi.fn();
|
|
219
|
-
// const unwatched = vi.fn();
|
|
220
|
-
// let $state = $watch({ s: 1, { watched, unwatched } });
|
|
221
|
-
// expect(watched).not.toHaveBeenCalled();
|
|
222
|
-
// const unsubscribe = s.subscribe(() => {});
|
|
223
|
-
// expect(watched).toHaveBeenCalledOnce();
|
|
224
|
-
// const unsubscribe2 = s.subscribe(() => {});
|
|
225
|
-
// expect(watched).toHaveBeenCalledOnce();
|
|
226
|
-
// unsubscribe();
|
|
227
|
-
// unsubscribe2();
|
|
228
|
-
// expect(unwatched).toHaveBeenCalledOnce();
|
|
229
|
-
// });
|
|
230
|
-
//
|
|
231
|
-
// it("should allow updating the signal from watched", async () => {
|
|
232
|
-
// const calls: number[] = [];
|
|
233
|
-
// const watched = vi.fn(() => {
|
|
234
|
-
// setTimeout(() => {
|
|
235
|
-
// $state.s = 2;
|
|
236
|
-
// });
|
|
237
|
-
// });
|
|
238
|
-
// const unwatched = vi.fn();
|
|
239
|
-
// let $state = $watch({ s: 1, { watched, unwatched } });
|
|
240
|
-
// expect(watched).not.toHaveBeenCalled();
|
|
241
|
-
// const unsubscribe = s.subscribe(() => {
|
|
242
|
-
// calls.push(s.value);
|
|
243
|
-
// });
|
|
244
|
-
// expect(watched).toHaveBeenCalledOnce();
|
|
245
|
-
// const unsubscribe2 = s.subscribe(() => {});
|
|
246
|
-
// expect(watched).toHaveBeenCalledOnce();
|
|
247
|
-
// await new Promise((resolve) => setTimeout(resolve));
|
|
248
|
-
// unsubscribe();
|
|
249
|
-
// unsubscribe2();
|
|
250
|
-
// expect(unwatched).toHaveBeenCalledOnce();
|
|
251
|
-
// expect(calls).to.deep.equal([1, 2]);
|
|
252
|
-
// });
|
|
253
|
-
// });
|
|
254
|
-
|
|
255
|
-
// it("signals should be identified with a symbol", () => {
|
|
256
|
-
// let $state = $watch({ a: 0 });
|
|
257
|
-
// expect(a.brand).toEqual(Symbol.for("preact-signals"));
|
|
258
|
-
// });
|
|
259
|
-
//
|
|
260
|
-
// it("should be identified with a symbol", () => {
|
|
261
|
-
// const a = $derive(() => {});
|
|
262
|
-
// expect(a.brand).toEqual(Symbol.for("preact-signals"));
|
|
263
|
-
// });
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
describe("$run()", () => {
|
|
267
|
-
it("should run the callback immediately", () => {
|
|
268
|
-
let $state = $watch({ s: 123 });
|
|
269
|
-
let spy = vi.fn(() => {
|
|
270
|
-
$state.s;
|
|
271
|
-
});
|
|
272
|
-
$run(spy);
|
|
273
|
-
expect(spy).toHaveBeenCalled();
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
it("should subscribe to signals", () => {
|
|
277
|
-
let $state = $watch({ s: 123 });
|
|
278
|
-
let spy = vi.fn(() => {
|
|
279
|
-
$state.s;
|
|
280
|
-
});
|
|
281
|
-
$run(spy);
|
|
282
|
-
spy.mockReset();
|
|
283
|
-
$state.s = 42;
|
|
284
|
-
expect(spy).toHaveBeenCalled();
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
it("should subscribe to multiple signals", () => {
|
|
288
|
-
let $state = $watch({ a: "a", b: "b" });
|
|
289
|
-
let spy = vi.fn(() => {
|
|
290
|
-
$state.a;
|
|
291
|
-
$state.b;
|
|
292
|
-
});
|
|
293
|
-
$run(spy);
|
|
294
|
-
spy.mockReset();
|
|
295
|
-
|
|
296
|
-
$state.a = "aa";
|
|
297
|
-
$state.b = "bb";
|
|
298
|
-
expect(spy).toHaveBeenCalledTimes(2);
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
// it("should dispose of subscriptions", () => {
|
|
302
|
-
// let $state = $watch({ a: "a" });
|
|
303
|
-
// let $state = $watch({ b: "b" });
|
|
304
|
-
// let spy = vi.fn(() => {
|
|
305
|
-
// $state.a + " " + $state.b;
|
|
306
|
-
// });
|
|
307
|
-
// const dispose = $run(spy);
|
|
308
|
-
// spy.mockReset();
|
|
309
|
-
//
|
|
310
|
-
// dispose();
|
|
311
|
-
// expect(spy).not.toHaveBeenCalled();
|
|
312
|
-
//
|
|
313
|
-
// $state.a = "aa";
|
|
314
|
-
// $state.b = "bb";
|
|
315
|
-
// expect(spy).not.toHaveBeenCalled();
|
|
316
|
-
// });
|
|
317
|
-
//
|
|
318
|
-
// it("should dispose of subscriptions", () => {
|
|
319
|
-
// let $state = $watch({ a: "a" });
|
|
320
|
-
// let $state = $watch({ b: "b" });
|
|
321
|
-
// let spy = vi.fn(() => {
|
|
322
|
-
// $state.a + " " + $state.b;
|
|
323
|
-
// });
|
|
324
|
-
// $run(function () {
|
|
325
|
-
// spy();
|
|
326
|
-
// if ($state.a === "aa") {
|
|
327
|
-
// this.dispose();
|
|
328
|
-
// }
|
|
329
|
-
// });
|
|
330
|
-
//
|
|
331
|
-
// expect(spy).toHaveBeenCalled();
|
|
332
|
-
//
|
|
333
|
-
// $state.a = "aa";
|
|
334
|
-
// expect(spy).toHaveBeenCalledTimes(2);
|
|
335
|
-
//
|
|
336
|
-
// $state.a = "aaa";
|
|
337
|
-
// expect(spy).toHaveBeenCalledTimes(2);
|
|
338
|
-
// });
|
|
339
|
-
//
|
|
340
|
-
// it("should dispose of subscriptions immediately", () => {
|
|
341
|
-
// let $state = $watch({ a: "a" });
|
|
342
|
-
// let $state = $watch({ b: "b" });
|
|
343
|
-
// let spy = vi.fn(() => {
|
|
344
|
-
// $state.a + " " + $state.b;
|
|
345
|
-
// });
|
|
346
|
-
// $run(function () {
|
|
347
|
-
// spy();
|
|
348
|
-
// this.dispose();
|
|
349
|
-
// });
|
|
350
|
-
//
|
|
351
|
-
// expect(spy).toHaveBeenCalledOnce();
|
|
352
|
-
//
|
|
353
|
-
// $state.a = "aa";
|
|
354
|
-
// expect(spy).toHaveBeenCalledOnce();
|
|
355
|
-
//
|
|
356
|
-
// $state.a = "aaa";
|
|
357
|
-
// expect(spy).toHaveBeenCalledOnce();
|
|
358
|
-
// });
|
|
359
|
-
//
|
|
360
|
-
// it("should dispose of subscriptions when called twice", () => {
|
|
361
|
-
// let $state = $watch({ a: "a" });
|
|
362
|
-
// let $state = $watch({ b: "b" });
|
|
363
|
-
// let spy = vi.fn(() => {
|
|
364
|
-
// $state.a + " " + $state.b;
|
|
365
|
-
// });
|
|
366
|
-
// const dispose = $run(function () {
|
|
367
|
-
// spy();
|
|
368
|
-
// if ($state.a === "aa") {
|
|
369
|
-
// this.dispose();
|
|
370
|
-
// }
|
|
371
|
-
// });
|
|
372
|
-
//
|
|
373
|
-
// expect(spy).toHaveBeenCalled();
|
|
374
|
-
//
|
|
375
|
-
// $state.a = "aa";
|
|
376
|
-
// expect(spy).toHaveBeenCalledTimes(2);
|
|
377
|
-
// dispose();
|
|
378
|
-
//
|
|
379
|
-
// $state.a = "aaa";
|
|
380
|
-
// expect(spy).toHaveBeenCalledTimes(2);
|
|
381
|
-
// });
|
|
382
|
-
//
|
|
383
|
-
// it("should dispose of subscriptions immediately and signals are read after disposing", () => {
|
|
384
|
-
// let $state = $watch({ a: "a" });
|
|
385
|
-
// let $state = $watch({ b: "b" });
|
|
386
|
-
// let spy = vi.fn(() => {
|
|
387
|
-
// $state.a + " " + $state.b;
|
|
388
|
-
// });
|
|
389
|
-
// $run(function () {
|
|
390
|
-
// this.dispose();
|
|
391
|
-
// spy();
|
|
392
|
-
// });
|
|
393
|
-
//
|
|
394
|
-
// expect(spy).toHaveBeenCalledOnce();
|
|
395
|
-
//
|
|
396
|
-
// $state.a = "aa";
|
|
397
|
-
// expect(spy).toHaveBeenCalledOnce();
|
|
398
|
-
//
|
|
399
|
-
// $state.a = "aaa";
|
|
400
|
-
// expect(spy).toHaveBeenCalledOnce();
|
|
401
|
-
// });
|
|
402
|
-
//
|
|
403
|
-
// it("should dispose of subscriptions immediately when called twice (deferred)", () => {
|
|
404
|
-
// let $state = $watch({ a: "a" });
|
|
405
|
-
// let $state = $watch({ b: "b" });
|
|
406
|
-
// let spy = vi.fn(() => {
|
|
407
|
-
// $state.a + " " + $state.b;
|
|
408
|
-
// });
|
|
409
|
-
// const dispose = $run(function () {
|
|
410
|
-
// spy();
|
|
411
|
-
// this.dispose();
|
|
412
|
-
// });
|
|
413
|
-
//
|
|
414
|
-
// expect(spy).toHaveBeenCalledOnce();
|
|
415
|
-
//
|
|
416
|
-
// $state.a = "aa";
|
|
417
|
-
// expect(spy).toHaveBeenCalledOnce();
|
|
418
|
-
// dispose();
|
|
419
|
-
//
|
|
420
|
-
// $state.a = "aaa";
|
|
421
|
-
// expect(spy).toHaveBeenCalledOnce();
|
|
422
|
-
// });
|
|
423
|
-
//
|
|
424
|
-
// it("should unsubscribe from signal", () => {
|
|
425
|
-
// let $state = $watch({ s: 123 });
|
|
426
|
-
// let spy = vi.fn(() => {
|
|
427
|
-
// $state.s;
|
|
428
|
-
// });
|
|
429
|
-
// const unsub = $run(spy);
|
|
430
|
-
// spy.mockReset();
|
|
431
|
-
//
|
|
432
|
-
// unsub();
|
|
433
|
-
// $state.s = 42;
|
|
434
|
-
// expect(spy).not.toHaveBeenCalled();
|
|
435
|
-
// });
|
|
436
|
-
|
|
437
|
-
it("should conditionally unsubscribe from signals", () => {
|
|
438
|
-
let $state = $watch({ a: "a", b: "b", cond: true });
|
|
439
|
-
|
|
440
|
-
let spy = vi.fn(() => {
|
|
441
|
-
$state.cond ? $state.a : $state.b;
|
|
442
|
-
});
|
|
443
|
-
|
|
444
|
-
$run(spy);
|
|
445
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
446
|
-
|
|
447
|
-
$state.b = "bb";
|
|
448
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
449
|
-
|
|
450
|
-
$state.cond = false;
|
|
451
|
-
expect(spy).toHaveBeenCalledTimes(2);
|
|
452
|
-
|
|
453
|
-
spy.mockReset();
|
|
454
|
-
|
|
455
|
-
$state.a = "aaa";
|
|
456
|
-
expect(spy).not.toHaveBeenCalled();
|
|
457
|
-
});
|
|
458
|
-
|
|
459
|
-
it("should batch writes", () => {
|
|
460
|
-
let $state = $watch({ a: "a" });
|
|
461
|
-
let spy = vi.fn(() => {
|
|
462
|
-
$state.a;
|
|
463
|
-
});
|
|
464
|
-
$run(spy);
|
|
465
|
-
spy.mockReset();
|
|
466
|
-
|
|
467
|
-
$run(() => {
|
|
468
|
-
$state.a = "aa";
|
|
469
|
-
$state.a = "aaa";
|
|
470
|
-
});
|
|
471
|
-
|
|
472
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
473
|
-
});
|
|
474
|
-
|
|
475
|
-
it("should call the cleanup callback before the next run", () => {
|
|
476
|
-
let $state = $watch({ a: 0 });
|
|
477
|
-
let spy = vi.fn();
|
|
478
|
-
|
|
479
|
-
$run(() => {
|
|
480
|
-
$state.a;
|
|
481
|
-
return spy;
|
|
482
|
-
});
|
|
483
|
-
expect(spy).not.toHaveBeenCalled();
|
|
484
|
-
$state.a = 1;
|
|
485
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
486
|
-
$state.a = 2;
|
|
487
|
-
expect(spy).toHaveBeenCalledTimes(2);
|
|
488
|
-
});
|
|
489
|
-
|
|
490
|
-
it("should call only the callback from the previous run", () => {
|
|
491
|
-
let spy1 = vi.fn();
|
|
492
|
-
let spy2 = vi.fn();
|
|
493
|
-
let spy3 = vi.fn();
|
|
494
|
-
let $state = $watch({ a: spy1 });
|
|
495
|
-
|
|
496
|
-
$run(() => {
|
|
497
|
-
return $state.a;
|
|
498
|
-
});
|
|
499
|
-
|
|
500
|
-
expect(spy1).not.toHaveBeenCalled();
|
|
501
|
-
expect(spy2).not.toHaveBeenCalled();
|
|
502
|
-
expect(spy3).not.toHaveBeenCalled();
|
|
503
|
-
|
|
504
|
-
$state.a = spy2;
|
|
505
|
-
expect(spy1).toHaveBeenCalledOnce();
|
|
506
|
-
expect(spy2).not.toHaveBeenCalled();
|
|
507
|
-
expect(spy3).not.toHaveBeenCalled();
|
|
508
|
-
|
|
509
|
-
$state.a = spy3;
|
|
510
|
-
expect(spy1).toHaveBeenCalledOnce();
|
|
511
|
-
expect(spy2).toHaveBeenCalledOnce();
|
|
512
|
-
expect(spy3).not.toHaveBeenCalled();
|
|
513
|
-
});
|
|
514
|
-
|
|
515
|
-
// it("should call the cleanup callback function when disposed", () => {
|
|
516
|
-
// let spy = vi.fn();
|
|
517
|
-
//
|
|
518
|
-
// const dispose = $run(() => {
|
|
519
|
-
// return spy;
|
|
520
|
-
// });
|
|
521
|
-
// expect(spy).not.toHaveBeenCalled();
|
|
522
|
-
// dispose();
|
|
523
|
-
// expect(spy).toHaveBeenCalledOnce();
|
|
524
|
-
// });
|
|
525
|
-
|
|
526
|
-
it("should not recompute if the effect has been notified about changes, but no direct dependency has actually changed", () => {
|
|
527
|
-
let $state = $watch({
|
|
528
|
-
s: 0,
|
|
529
|
-
get c() {
|
|
530
|
-
return $cache(() => {
|
|
531
|
-
$state.s;
|
|
532
|
-
return 0;
|
|
533
|
-
});
|
|
534
|
-
},
|
|
535
|
-
});
|
|
536
|
-
let spy = vi.fn(() => {
|
|
537
|
-
$state.c;
|
|
538
|
-
});
|
|
539
|
-
$run(spy);
|
|
540
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
541
|
-
spy.mockReset();
|
|
542
|
-
|
|
543
|
-
$state.s = 1;
|
|
544
|
-
expect(spy).not.toHaveBeenCalled();
|
|
545
|
-
});
|
|
546
|
-
|
|
547
|
-
it("should not recompute dependencies unnecessarily", () => {
|
|
548
|
-
let spy = vi.fn();
|
|
549
|
-
let $state = $watch({
|
|
550
|
-
a: 0,
|
|
551
|
-
b: 0,
|
|
552
|
-
get c() {
|
|
553
|
-
return $cache(() => {
|
|
554
|
-
spy();
|
|
555
|
-
return $state.b;
|
|
556
|
-
});
|
|
557
|
-
},
|
|
558
|
-
});
|
|
559
|
-
$run(() => {
|
|
560
|
-
if ($state.a === 0) {
|
|
561
|
-
$state.c;
|
|
562
|
-
}
|
|
563
|
-
});
|
|
564
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
565
|
-
|
|
566
|
-
$batch(() => {
|
|
567
|
-
$state.b = 1;
|
|
568
|
-
$state.a = 1;
|
|
569
|
-
});
|
|
570
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
571
|
-
});
|
|
572
|
-
|
|
573
|
-
it("should not recompute dependencies out of order", () => {
|
|
574
|
-
let spy = vi.fn();
|
|
575
|
-
let $state = $watch({
|
|
576
|
-
a: 1,
|
|
577
|
-
b: 1,
|
|
578
|
-
c: 1,
|
|
579
|
-
get d() {
|
|
580
|
-
return $cache(() => {
|
|
581
|
-
spy();
|
|
582
|
-
return $state.c;
|
|
583
|
-
});
|
|
584
|
-
},
|
|
585
|
-
});
|
|
586
|
-
|
|
587
|
-
$run(() => {
|
|
588
|
-
if ($state.a > 0) {
|
|
589
|
-
$state.b;
|
|
590
|
-
$state.d;
|
|
591
|
-
} else {
|
|
592
|
-
$state.b;
|
|
593
|
-
}
|
|
594
|
-
});
|
|
595
|
-
spy.mockReset();
|
|
596
|
-
|
|
597
|
-
$batch(() => {
|
|
598
|
-
$state.a = 2;
|
|
599
|
-
$state.b = 2;
|
|
600
|
-
$state.c = 2;
|
|
601
|
-
});
|
|
602
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
603
|
-
spy.mockReset();
|
|
604
|
-
|
|
605
|
-
$batch(() => {
|
|
606
|
-
$state.a = -1;
|
|
607
|
-
$state.b = -1;
|
|
608
|
-
$state.c = -1;
|
|
609
|
-
});
|
|
610
|
-
expect(spy).not.toHaveBeenCalled();
|
|
611
|
-
spy.mockReset();
|
|
612
|
-
});
|
|
613
|
-
|
|
614
|
-
it("should recompute if a dependency changes during computation after becoming a dependency", () => {
|
|
615
|
-
let $state = $watch({ a: 0 });
|
|
616
|
-
let spy = vi.fn(() => {
|
|
617
|
-
if ($state.a === 0) {
|
|
618
|
-
$state.a++;
|
|
619
|
-
}
|
|
620
|
-
});
|
|
621
|
-
$run(spy);
|
|
622
|
-
expect(spy).toHaveBeenCalledTimes(2);
|
|
623
|
-
});
|
|
624
|
-
|
|
625
|
-
it("should run the cleanup in an implicit batch", () => {
|
|
626
|
-
let $state = $watch({ a: 0, b: "a", c: "b" });
|
|
627
|
-
let spy = vi.fn();
|
|
628
|
-
|
|
629
|
-
$run(() => {
|
|
630
|
-
$state.b;
|
|
631
|
-
$state.c;
|
|
632
|
-
spy($state.b + $state.c);
|
|
633
|
-
});
|
|
634
|
-
|
|
635
|
-
$run(() => {
|
|
636
|
-
$state.a;
|
|
637
|
-
return () => {
|
|
638
|
-
$state.b = "x";
|
|
639
|
-
$state.c = "y";
|
|
640
|
-
};
|
|
641
|
-
});
|
|
642
|
-
|
|
643
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
644
|
-
spy.mockReset();
|
|
645
|
-
|
|
646
|
-
$state.a = 1;
|
|
647
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
648
|
-
expect(spy).toBeCalledWith("xy");
|
|
649
|
-
});
|
|
650
|
-
|
|
651
|
-
it("should not retrigger the effect if the cleanup modifies one of the dependencies", () => {
|
|
652
|
-
let $state = $watch({ a: 0 });
|
|
653
|
-
let spy = vi.fn();
|
|
654
|
-
|
|
655
|
-
$run(() => {
|
|
656
|
-
spy($state.a);
|
|
657
|
-
return () => {
|
|
658
|
-
$state.a = 2;
|
|
659
|
-
};
|
|
660
|
-
});
|
|
661
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
662
|
-
spy.mockReset();
|
|
663
|
-
|
|
664
|
-
$state.a = 1;
|
|
665
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
666
|
-
expect(spy).toBeCalledWith(2);
|
|
667
|
-
});
|
|
668
|
-
|
|
669
|
-
// it("should run the cleanup if the effect disposes itself", () => {
|
|
670
|
-
// let $state = $watch({ a: 0 });
|
|
671
|
-
// let spy = vi.fn();
|
|
672
|
-
//
|
|
673
|
-
// const dispose = $run(() => {
|
|
674
|
-
// if ($state.a > 0) {
|
|
675
|
-
// dispose();
|
|
676
|
-
// return spy;
|
|
677
|
-
// }
|
|
678
|
-
// });
|
|
679
|
-
// expect(spy).not.toHaveBeenCalled();
|
|
680
|
-
// $state.a = 1;
|
|
681
|
-
// expect(spy).toHaveBeenCalledOnce();
|
|
682
|
-
// $state.a = 2;
|
|
683
|
-
// expect(spy).toHaveBeenCalledOnce();
|
|
684
|
-
// });
|
|
685
|
-
//
|
|
686
|
-
// it("should not run the effect if the cleanup function disposes it", () => {
|
|
687
|
-
// let $state = $watch({ a: 0 });
|
|
688
|
-
// let spy = vi.fn();
|
|
689
|
-
//
|
|
690
|
-
// const dispose = $run(() => {
|
|
691
|
-
// $state.a;
|
|
692
|
-
// spy();
|
|
693
|
-
// return () => {
|
|
694
|
-
// dispose();
|
|
695
|
-
// };
|
|
696
|
-
// });
|
|
697
|
-
// expect(spy).toHaveBeenCalledOnce();
|
|
698
|
-
// $state.a = 1;
|
|
699
|
-
// expect(spy).toHaveBeenCalledOnce();
|
|
700
|
-
// });
|
|
701
|
-
|
|
702
|
-
it("should not subscribe to anything if first run throws", () => {
|
|
703
|
-
let $state = $watch({ s: 0 });
|
|
704
|
-
let spy = vi.fn(() => {
|
|
705
|
-
$state.s;
|
|
706
|
-
throw new Error("test");
|
|
707
|
-
});
|
|
708
|
-
expect(() => $run(spy)).toThrow("test");
|
|
709
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
710
|
-
|
|
711
|
-
$state.s++;
|
|
712
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
713
|
-
});
|
|
714
|
-
|
|
715
|
-
it("should reset the cleanup if the effect throws", () => {
|
|
716
|
-
let $state = $watch({ a: 0 });
|
|
717
|
-
let spy = vi.fn();
|
|
718
|
-
|
|
719
|
-
$run(() => {
|
|
720
|
-
if ($state.a === 0) {
|
|
721
|
-
return spy;
|
|
722
|
-
} else {
|
|
723
|
-
throw new Error("hello");
|
|
724
|
-
}
|
|
725
|
-
});
|
|
726
|
-
expect(spy).not.toHaveBeenCalled();
|
|
727
|
-
expect(() => ($state.a = 1)).toThrow("hello");
|
|
728
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
729
|
-
$state.a = 0;
|
|
730
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
731
|
-
});
|
|
732
|
-
|
|
733
|
-
it("should dispose the effect if the cleanup callback throws", () => {
|
|
734
|
-
let $state = $watch({ a: 0 });
|
|
735
|
-
let spy = vi.fn();
|
|
736
|
-
|
|
737
|
-
$run(() => {
|
|
738
|
-
if ($state.a === 0) {
|
|
739
|
-
return () => {
|
|
740
|
-
throw new Error("hello");
|
|
741
|
-
};
|
|
742
|
-
} else {
|
|
743
|
-
spy();
|
|
744
|
-
}
|
|
745
|
-
});
|
|
746
|
-
expect(spy).not.toHaveBeenCalled();
|
|
747
|
-
expect(() => $state.a++).toThrow("hello");
|
|
748
|
-
expect(spy).not.toHaveBeenCalled();
|
|
749
|
-
$state.a++;
|
|
750
|
-
expect(spy).not.toHaveBeenCalled();
|
|
751
|
-
});
|
|
752
|
-
|
|
753
|
-
it("should run cleanups outside any evaluation context", () => {
|
|
754
|
-
let spy = vi.fn();
|
|
755
|
-
let $state = $watch({
|
|
756
|
-
a: 0,
|
|
757
|
-
b: 0,
|
|
758
|
-
get c() {
|
|
759
|
-
return $cache(() => {
|
|
760
|
-
if ($state.a === 0) {
|
|
761
|
-
$run(() => {
|
|
762
|
-
return () => {
|
|
763
|
-
$state.b;
|
|
764
|
-
};
|
|
765
|
-
});
|
|
766
|
-
}
|
|
767
|
-
return $state.a;
|
|
768
|
-
});
|
|
769
|
-
},
|
|
770
|
-
});
|
|
771
|
-
|
|
772
|
-
$run(() => {
|
|
773
|
-
spy();
|
|
774
|
-
$state.c;
|
|
775
|
-
});
|
|
776
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
777
|
-
spy.mockReset();
|
|
778
|
-
|
|
779
|
-
$state.a = 1;
|
|
780
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
781
|
-
spy.mockReset();
|
|
782
|
-
|
|
783
|
-
$state.b = 1;
|
|
784
|
-
expect(spy).not.toHaveBeenCalled();
|
|
785
|
-
});
|
|
786
|
-
|
|
787
|
-
// NOTE: I don't think we can cycle in effects, because we don't add already
|
|
788
|
-
// running effects to the batch
|
|
789
|
-
|
|
790
|
-
it.skip("should throw on cycles", () => {
|
|
791
|
-
let $state = $watch({ a: 0 });
|
|
792
|
-
let i = 0;
|
|
793
|
-
|
|
794
|
-
const fn = () =>
|
|
795
|
-
$run(() => {
|
|
796
|
-
// Prevent test suite from spinning if limit is not hit
|
|
797
|
-
if (i++ > 200) {
|
|
798
|
-
throw new Error("test failed");
|
|
799
|
-
}
|
|
800
|
-
$state.a;
|
|
801
|
-
$state.a = NaN;
|
|
802
|
-
});
|
|
803
|
-
|
|
804
|
-
expect(fn).toThrow("Cycle detected");
|
|
805
|
-
});
|
|
806
|
-
|
|
807
|
-
it.skip("should throw on indirect cycles", () => {
|
|
808
|
-
let $state = $watch({
|
|
809
|
-
a: 0,
|
|
810
|
-
get c() {
|
|
811
|
-
return $cache(() => {
|
|
812
|
-
$state.a;
|
|
813
|
-
$state.a = NaN;
|
|
814
|
-
return NaN;
|
|
815
|
-
});
|
|
816
|
-
},
|
|
817
|
-
});
|
|
818
|
-
|
|
819
|
-
let i = 0;
|
|
820
|
-
const fn = () =>
|
|
821
|
-
$run(() => {
|
|
822
|
-
// Prevent test suite from spinning if limit is not hit
|
|
823
|
-
if (i++ > 200) {
|
|
824
|
-
throw new Error("test failed");
|
|
825
|
-
}
|
|
826
|
-
$state.c;
|
|
827
|
-
});
|
|
828
|
-
|
|
829
|
-
expect(fn).toThrow("Cycle detected");
|
|
830
|
-
});
|
|
831
|
-
|
|
832
|
-
// it("should allow disposing the effect multiple times", () => {
|
|
833
|
-
// const dispose = $run(() => undefined);
|
|
834
|
-
// dispose();
|
|
835
|
-
// expect(() => dispose()).not.toThrow();
|
|
836
|
-
// });
|
|
837
|
-
//
|
|
838
|
-
// it("should support resource management disposal", () => {
|
|
839
|
-
// //let $state = $watch({ a: 0 });
|
|
840
|
-
// //let spy = vi.fn();
|
|
841
|
-
// //{
|
|
842
|
-
// // // @ts-expect-error This is a test for the dispose API
|
|
843
|
-
// // using _dispose = $run(() => {
|
|
844
|
-
// // $state.a;
|
|
845
|
-
// // return spy;
|
|
846
|
-
// // });
|
|
847
|
-
// //}
|
|
848
|
-
// //expect(spy).toHaveBeenCalledOnce();
|
|
849
|
-
// });
|
|
850
|
-
//
|
|
851
|
-
// it("should allow disposing a running effect", () => {
|
|
852
|
-
// let $state = $watch({ a: 0 });
|
|
853
|
-
// let spy = vi.fn();
|
|
854
|
-
// const dispose = $run(() => {
|
|
855
|
-
// if ($state.a === 1) {
|
|
856
|
-
// dispose();
|
|
857
|
-
// spy();
|
|
858
|
-
// }
|
|
859
|
-
// });
|
|
860
|
-
// expect(spy).not.toHaveBeenCalled();
|
|
861
|
-
// $state.a = 1;
|
|
862
|
-
// expect(spy).toHaveBeenCalledOnce();
|
|
863
|
-
// $state.a = 2;
|
|
864
|
-
// expect(spy).toHaveBeenCalledOnce();
|
|
865
|
-
// });
|
|
866
|
-
//
|
|
867
|
-
// it("should not run if it's first been triggered and then disposed in a batch", () => {
|
|
868
|
-
// let $state = $watch({ a: 0 });
|
|
869
|
-
// let spy = vi.fn(() => {
|
|
870
|
-
// $state.a;
|
|
871
|
-
// });
|
|
872
|
-
// const dispose = $run(spy);
|
|
873
|
-
// spy.mockReset();
|
|
874
|
-
//
|
|
875
|
-
// $batch(() => {
|
|
876
|
-
// $state.a = 1;
|
|
877
|
-
// dispose();
|
|
878
|
-
// });
|
|
879
|
-
//
|
|
880
|
-
// expect(spy).not.toHaveBeenCalled();
|
|
881
|
-
// });
|
|
882
|
-
//
|
|
883
|
-
// it("should not run if it's been triggered, disposed and then triggered again in a batch", () => {
|
|
884
|
-
// let $state = $watch({ a: 0 });
|
|
885
|
-
// let spy = vi.fn(() => {
|
|
886
|
-
// $state.a;
|
|
887
|
-
// });
|
|
888
|
-
// const dispose = $run(spy);
|
|
889
|
-
// spy.mockReset();
|
|
890
|
-
//
|
|
891
|
-
// $batch(() => {
|
|
892
|
-
// $state.a = 1;
|
|
893
|
-
// dispose();
|
|
894
|
-
// $state.a = 2;
|
|
895
|
-
// });
|
|
896
|
-
//
|
|
897
|
-
// expect(spy).not.toHaveBeenCalled();
|
|
898
|
-
// });
|
|
899
|
-
|
|
900
|
-
it("should not rerun parent effect if a nested child effect's signal's value changes", () => {
|
|
901
|
-
let $state = $watch({
|
|
902
|
-
parentSignal: 0,
|
|
903
|
-
childSignal: 0,
|
|
904
|
-
independentSignal: 0,
|
|
905
|
-
});
|
|
906
|
-
|
|
907
|
-
const parent$run = vi.fn(() => {
|
|
908
|
-
$state.parentSignal;
|
|
909
|
-
});
|
|
910
|
-
const child$run = vi.fn(() => {
|
|
911
|
-
$state.childSignal;
|
|
912
|
-
//return () => console.log("CLEANUP CHILD");
|
|
913
|
-
});
|
|
914
|
-
const independent$run = vi.fn(() => {
|
|
915
|
-
$state.independentSignal;
|
|
916
|
-
//return () => console.log("CLEANUP INDEPENDENT");
|
|
917
|
-
});
|
|
918
|
-
|
|
919
|
-
$run(
|
|
920
|
-
() => {
|
|
921
|
-
parent$run();
|
|
922
|
-
$run(child$run /*, { name: "CHILD $run" }*/);
|
|
923
|
-
$run(independent$run /*, { name: "INDEPENDENT $run" }*/);
|
|
924
|
-
//return () => console.log("CLEANUP PARENT");
|
|
925
|
-
} /*,
|
|
926
|
-
{ name: "PARENT $run" },*/,
|
|
927
|
-
);
|
|
928
|
-
|
|
929
|
-
expect(parent$run).toHaveBeenCalledOnce();
|
|
930
|
-
expect(child$run).toHaveBeenCalledOnce();
|
|
931
|
-
expect(independent$run).toHaveBeenCalledOnce();
|
|
932
|
-
|
|
933
|
-
//console.log("===\nSETTING CHILD SIGNAL");
|
|
934
|
-
$state.childSignal = 1;
|
|
935
|
-
|
|
936
|
-
expect(parent$run).toHaveBeenCalledOnce();
|
|
937
|
-
expect(child$run).toHaveBeenCalledTimes(2);
|
|
938
|
-
expect(independent$run).toHaveBeenCalledOnce();
|
|
939
|
-
|
|
940
|
-
//console.log("===\nSETTING PARENT SIGNAL");
|
|
941
|
-
$state.parentSignal = 1;
|
|
942
|
-
|
|
943
|
-
expect(parent$run).toHaveBeenCalledTimes(2);
|
|
944
|
-
expect(child$run).toHaveBeenCalledTimes(3);
|
|
945
|
-
expect(independent$run).toHaveBeenCalledTimes(2);
|
|
946
|
-
});
|
|
947
|
-
|
|
948
|
-
// // Test internal behavior depended on by Preact & React integrations
|
|
949
|
-
// describe("internals", () => {
|
|
950
|
-
// it("should pass in the effect instance in callback's `this`", () => {
|
|
951
|
-
// let e: any;
|
|
952
|
-
// $run(function (this: any) {
|
|
953
|
-
// e = this;
|
|
954
|
-
// });
|
|
955
|
-
// expect(typeof e._start).toEqual("function");
|
|
956
|
-
// expect(typeof e._dispose).toEqual("function");
|
|
957
|
-
// });
|
|
958
|
-
//
|
|
959
|
-
// it("should allow setting _callback that replaces the default functionality", () => {
|
|
960
|
-
// let $state = $watch({ a: 0 });
|
|
961
|
-
// const oldSpy = vi.fn();
|
|
962
|
-
// const newSpy = vi.fn();
|
|
963
|
-
//
|
|
964
|
-
// let e: any;
|
|
965
|
-
// $run(function (this: any) {
|
|
966
|
-
// e = this;
|
|
967
|
-
// $state.a;
|
|
968
|
-
// oldSpy();
|
|
969
|
-
// });
|
|
970
|
-
// oldSpy.mockReset();
|
|
971
|
-
//
|
|
972
|
-
// e._callback = newSpy;
|
|
973
|
-
// $state.a = 1;
|
|
974
|
-
//
|
|
975
|
-
// expect(oldSpy).not.toHaveBeenCalled();
|
|
976
|
-
// expect(newSpy).toHaveBeenCalled();
|
|
977
|
-
// });
|
|
978
|
-
//
|
|
979
|
-
// it("should return a function for closing the effect scope from _start", () => {
|
|
980
|
-
// let $state = $watch({ s: 0 });
|
|
981
|
-
//
|
|
982
|
-
// let e: any;
|
|
983
|
-
// $run(function (this: any) {
|
|
984
|
-
// e = this;
|
|
985
|
-
// });
|
|
986
|
-
//
|
|
987
|
-
// let spy = vi.fn();
|
|
988
|
-
// e._callback = spy;
|
|
989
|
-
//
|
|
990
|
-
// const done1 = e._start();
|
|
991
|
-
// $state.s;
|
|
992
|
-
// done1();
|
|
993
|
-
// expect(spy).not.toHaveBeenCalled();
|
|
994
|
-
//
|
|
995
|
-
// $state.s = 2;
|
|
996
|
-
// expect(spy).toHaveBeenCalled();
|
|
997
|
-
// spy.mockReset();
|
|
998
|
-
//
|
|
999
|
-
// const done2 = e._start();
|
|
1000
|
-
// done2();
|
|
1001
|
-
//
|
|
1002
|
-
// $state.s = 3;
|
|
1003
|
-
// expect(spy).not.toHaveBeenCalled();
|
|
1004
|
-
// });
|
|
1005
|
-
//
|
|
1006
|
-
// it("should throw on out-of-order start1-start2-end1 sequences", () => {
|
|
1007
|
-
// let e1: any;
|
|
1008
|
-
// $run(function (this: any) {
|
|
1009
|
-
// e1 = this;
|
|
1010
|
-
// });
|
|
1011
|
-
//
|
|
1012
|
-
// let e2: any;
|
|
1013
|
-
// $run(function (this: any) {
|
|
1014
|
-
// e2 = this;
|
|
1015
|
-
// });
|
|
1016
|
-
//
|
|
1017
|
-
// const done1 = e1._start();
|
|
1018
|
-
// const done2 = e2._start();
|
|
1019
|
-
// try {
|
|
1020
|
-
// expect(() => done1()).toThrow(/Out-of-order/);
|
|
1021
|
-
// } finally {
|
|
1022
|
-
// done2();
|
|
1023
|
-
// done1();
|
|
1024
|
-
// }
|
|
1025
|
-
// });
|
|
1026
|
-
//
|
|
1027
|
-
// it("should throw a cycle detection error when _start is called while the effect is running", () => {
|
|
1028
|
-
// let e: any;
|
|
1029
|
-
// $run(function (this: any) {
|
|
1030
|
-
// e = this;
|
|
1031
|
-
// });
|
|
1032
|
-
//
|
|
1033
|
-
// const done = e._start();
|
|
1034
|
-
// try {
|
|
1035
|
-
// expect(() => e._start()).toThrow("Cycle detected");
|
|
1036
|
-
// } finally {
|
|
1037
|
-
// done();
|
|
1038
|
-
// }
|
|
1039
|
-
// });
|
|
1040
|
-
//
|
|
1041
|
-
// it("should dispose the effect on _dispose", () => {
|
|
1042
|
-
// let $state = $watch({ s: 0 });
|
|
1043
|
-
//
|
|
1044
|
-
// let e: any;
|
|
1045
|
-
// $run(function (this: any) {
|
|
1046
|
-
// e = this;
|
|
1047
|
-
// });
|
|
1048
|
-
//
|
|
1049
|
-
// let spy = vi.fn();
|
|
1050
|
-
// e._callback = spy;
|
|
1051
|
-
//
|
|
1052
|
-
// const done = e._start();
|
|
1053
|
-
// try {
|
|
1054
|
-
// $state.s;
|
|
1055
|
-
// } finally {
|
|
1056
|
-
// done();
|
|
1057
|
-
// }
|
|
1058
|
-
// expect(spy).not.toHaveBeenCalled();
|
|
1059
|
-
//
|
|
1060
|
-
// $state.s = 2;
|
|
1061
|
-
// expect(spy).toHaveBeenCalled();
|
|
1062
|
-
// spy.mockReset();
|
|
1063
|
-
//
|
|
1064
|
-
// e._dispose();
|
|
1065
|
-
// $state.s = 3;
|
|
1066
|
-
// expect(spy).not.toHaveBeenCalled();
|
|
1067
|
-
// });
|
|
1068
|
-
//
|
|
1069
|
-
// it("should allow reusing the effect after disposing it", () => {
|
|
1070
|
-
// let $state = $watch({ s: 0 });
|
|
1071
|
-
//
|
|
1072
|
-
// let e: any;
|
|
1073
|
-
// $run(function (this: any) {
|
|
1074
|
-
// e = this;
|
|
1075
|
-
// });
|
|
1076
|
-
//
|
|
1077
|
-
// let spy = vi.fn();
|
|
1078
|
-
// e._callback = spy;
|
|
1079
|
-
// e._dispose();
|
|
1080
|
-
//
|
|
1081
|
-
// const done = e._start();
|
|
1082
|
-
// try {
|
|
1083
|
-
// $state.s;
|
|
1084
|
-
// } finally {
|
|
1085
|
-
// done();
|
|
1086
|
-
// }
|
|
1087
|
-
// $state.s = 2;
|
|
1088
|
-
// expect(spy).toHaveBeenCalled();
|
|
1089
|
-
// });
|
|
1090
|
-
//
|
|
1091
|
-
// it("should have property _sources that is undefined when and only when the effect has no sources", () => {
|
|
1092
|
-
// let $state = $watch({ s: 0 });
|
|
1093
|
-
//
|
|
1094
|
-
// let e: any;
|
|
1095
|
-
// $run(function (this: any) {
|
|
1096
|
-
// e = this;
|
|
1097
|
-
// });
|
|
1098
|
-
// expect(e._sources).toBeUndefined();
|
|
1099
|
-
//
|
|
1100
|
-
// const done1 = e._start();
|
|
1101
|
-
// try {
|
|
1102
|
-
// $state.s;
|
|
1103
|
-
// } finally {
|
|
1104
|
-
// done1();
|
|
1105
|
-
// }
|
|
1106
|
-
// expect(e._sources).not.toBeUndefined();
|
|
1107
|
-
//
|
|
1108
|
-
// const done2 = e._start();
|
|
1109
|
-
// done2();
|
|
1110
|
-
// expect(e._sources).toBeUndefined();
|
|
1111
|
-
//
|
|
1112
|
-
// const done3 = e._start();
|
|
1113
|
-
// try {
|
|
1114
|
-
// $state.s;
|
|
1115
|
-
// } finally {
|
|
1116
|
-
// done3();
|
|
1117
|
-
// }
|
|
1118
|
-
// expect(e._sources).not.toBeUndefined();
|
|
1119
|
-
//
|
|
1120
|
-
// e._dispose();
|
|
1121
|
-
// expect(e._sources).toBeUndefined();
|
|
1122
|
-
// });
|
|
1123
|
-
// });
|
|
1124
|
-
});
|
|
1125
|
-
|
|
1126
|
-
describe("$derive()", () => {
|
|
1127
|
-
it("should return value", () => {
|
|
1128
|
-
let $state = $watch({
|
|
1129
|
-
a: "a",
|
|
1130
|
-
b: "b",
|
|
1131
|
-
get c() {
|
|
1132
|
-
return $cache(() => $state.a + $state.b);
|
|
1133
|
-
},
|
|
1134
|
-
});
|
|
1135
|
-
|
|
1136
|
-
expect($state.c).toEqual("ab");
|
|
1137
|
-
});
|
|
1138
|
-
|
|
1139
|
-
// it("should inherit from Signal", () => {
|
|
1140
|
-
// expect($derive(() => 0)).to.be.instanceOf(Signal);
|
|
1141
|
-
// });
|
|
1142
|
-
|
|
1143
|
-
it("should return updated value", () => {
|
|
1144
|
-
let $state = $watch({
|
|
1145
|
-
a: "a",
|
|
1146
|
-
b: "b",
|
|
1147
|
-
get c() {
|
|
1148
|
-
return $cache(() => $state.a + $state.b);
|
|
1149
|
-
},
|
|
1150
|
-
});
|
|
1151
|
-
expect($state.c).toEqual("ab");
|
|
1152
|
-
|
|
1153
|
-
$state.a = "aa";
|
|
1154
|
-
expect($state.c).toEqual("aab");
|
|
1155
|
-
});
|
|
1156
|
-
|
|
1157
|
-
it("should be lazily computed on demand", () => {
|
|
1158
|
-
let spy = vi.fn(() => $state.a + $state.b);
|
|
1159
|
-
let $state = $watch({
|
|
1160
|
-
a: "a",
|
|
1161
|
-
b: "b",
|
|
1162
|
-
get c() {
|
|
1163
|
-
return $cache(spy);
|
|
1164
|
-
},
|
|
1165
|
-
});
|
|
1166
|
-
expect(spy).not.toHaveBeenCalled();
|
|
1167
|
-
$state.c;
|
|
1168
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
1169
|
-
$state.a = "x";
|
|
1170
|
-
$state.b = "y";
|
|
1171
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
1172
|
-
$state.c;
|
|
1173
|
-
expect(spy).toHaveBeenCalledTimes(2);
|
|
1174
|
-
});
|
|
1175
|
-
|
|
1176
|
-
it("should be computed only when a dependency has changed at some point", () => {
|
|
1177
|
-
let spy = vi.fn(() => {
|
|
1178
|
-
return $state.a;
|
|
1179
|
-
});
|
|
1180
|
-
let $state = $watch({
|
|
1181
|
-
a: "a",
|
|
1182
|
-
get c() {
|
|
1183
|
-
return $cache(spy);
|
|
1184
|
-
},
|
|
1185
|
-
});
|
|
1186
|
-
$state.c;
|
|
1187
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
1188
|
-
$state.a = "a";
|
|
1189
|
-
$state.c;
|
|
1190
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
1191
|
-
});
|
|
1192
|
-
|
|
1193
|
-
it("should recompute if a dependency changes during computation after becoming a dependency", () => {
|
|
1194
|
-
let spy = vi.fn(() => {
|
|
1195
|
-
$state.a++;
|
|
1196
|
-
});
|
|
1197
|
-
let $state = $watch({
|
|
1198
|
-
a: 0,
|
|
1199
|
-
get c() {
|
|
1200
|
-
return $cache(spy);
|
|
1201
|
-
},
|
|
1202
|
-
});
|
|
1203
|
-
$state.c;
|
|
1204
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
1205
|
-
$state.c;
|
|
1206
|
-
expect(spy).toHaveBeenCalledTimes(2);
|
|
1207
|
-
});
|
|
1208
|
-
|
|
1209
|
-
it("should detect simple dependency cycles", () => {
|
|
1210
|
-
const $state = $watch({
|
|
1211
|
-
get a(): any {
|
|
1212
|
-
return $cache(() => $state.a);
|
|
1213
|
-
},
|
|
1214
|
-
});
|
|
1215
|
-
expect(() => $state.a).toThrow("Cycle detected");
|
|
1216
|
-
});
|
|
1217
|
-
|
|
1218
|
-
it("should detect deep dependency cycles", () => {
|
|
1219
|
-
const $state = $watch({
|
|
1220
|
-
get a(): any {
|
|
1221
|
-
return $cache(() => $state.b);
|
|
1222
|
-
},
|
|
1223
|
-
get b() {
|
|
1224
|
-
return $cache(() => $state.c);
|
|
1225
|
-
},
|
|
1226
|
-
get c() {
|
|
1227
|
-
return $cache(() => $state.d);
|
|
1228
|
-
},
|
|
1229
|
-
get d() {
|
|
1230
|
-
return $cache(() => $state.a);
|
|
1231
|
-
},
|
|
1232
|
-
});
|
|
1233
|
-
expect(() => $state.a).toThrow("Cycle detected");
|
|
1234
|
-
});
|
|
1235
|
-
|
|
1236
|
-
// it("should not allow a computed signal to become a direct dependency of itself", () => {
|
|
1237
|
-
// let spy = vi.fn(() => {
|
|
1238
|
-
// try {
|
|
1239
|
-
// $state.a;
|
|
1240
|
-
// } catch {
|
|
1241
|
-
// // pass
|
|
1242
|
-
// }
|
|
1243
|
-
// });
|
|
1244
|
-
// const a = $derive(spy);
|
|
1245
|
-
// $state.a;
|
|
1246
|
-
// expect(() => $run(() => $state.a)).to.not.throw();
|
|
1247
|
-
// });
|
|
1248
|
-
|
|
1249
|
-
it("should store thrown errors and recompute only after a dependency changes", () => {
|
|
1250
|
-
let spy = vi.fn(() => {
|
|
1251
|
-
$state.a;
|
|
1252
|
-
throw new Error();
|
|
1253
|
-
});
|
|
1254
|
-
let $state = $watch({
|
|
1255
|
-
a: 0,
|
|
1256
|
-
get c() {
|
|
1257
|
-
return $cache(spy);
|
|
1258
|
-
},
|
|
1259
|
-
});
|
|
1260
|
-
expect(() => $state.c).toThrow();
|
|
1261
|
-
expect(() => $state.c).toThrow();
|
|
1262
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
1263
|
-
$state.a = 1;
|
|
1264
|
-
expect(() => $state.c).toThrow();
|
|
1265
|
-
expect(spy).toHaveBeenCalledTimes(2);
|
|
1266
|
-
});
|
|
1267
|
-
|
|
1268
|
-
it("should store thrown non-errors and recompute only after a dependency changes", () => {
|
|
1269
|
-
let spy = vi.fn();
|
|
1270
|
-
let $state = $watch({
|
|
1271
|
-
a: 0,
|
|
1272
|
-
get c() {
|
|
1273
|
-
return $cache(() => {
|
|
1274
|
-
$state.a;
|
|
1275
|
-
spy();
|
|
1276
|
-
throw undefined;
|
|
1277
|
-
});
|
|
1278
|
-
},
|
|
1279
|
-
});
|
|
1280
|
-
try {
|
|
1281
|
-
$state.c;
|
|
1282
|
-
expect.fail();
|
|
1283
|
-
} catch (err) {
|
|
1284
|
-
expect(err).toBeUndefined();
|
|
1285
|
-
}
|
|
1286
|
-
try {
|
|
1287
|
-
$state.c;
|
|
1288
|
-
expect.fail();
|
|
1289
|
-
} catch (err) {
|
|
1290
|
-
expect(err).toBeUndefined();
|
|
1291
|
-
}
|
|
1292
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
1293
|
-
|
|
1294
|
-
$state.a = 1;
|
|
1295
|
-
try {
|
|
1296
|
-
$state.c;
|
|
1297
|
-
expect.fail();
|
|
1298
|
-
} catch (err) {
|
|
1299
|
-
expect(err).toBeUndefined();
|
|
1300
|
-
}
|
|
1301
|
-
expect(spy).toHaveBeenCalledTimes(2);
|
|
1302
|
-
});
|
|
1303
|
-
|
|
1304
|
-
it("should conditionally unsubscribe from signals", () => {
|
|
1305
|
-
let spy = vi.fn(() => {
|
|
1306
|
-
return $state.cond ? $state.a : $state.b;
|
|
1307
|
-
});
|
|
1308
|
-
|
|
1309
|
-
let $state = $watch({
|
|
1310
|
-
a: "a",
|
|
1311
|
-
b: "b",
|
|
1312
|
-
cond: true,
|
|
1313
|
-
get c() {
|
|
1314
|
-
return $cache(spy);
|
|
1315
|
-
},
|
|
1316
|
-
});
|
|
1317
|
-
|
|
1318
|
-
expect($state.c).toEqual("a");
|
|
1319
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
1320
|
-
|
|
1321
|
-
$state.b = "bb";
|
|
1322
|
-
expect($state.c).toEqual("a");
|
|
1323
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
1324
|
-
|
|
1325
|
-
$state.cond = false;
|
|
1326
|
-
expect($state.c).toEqual("bb");
|
|
1327
|
-
expect(spy).toHaveBeenCalledTimes(2);
|
|
1328
|
-
|
|
1329
|
-
spy.mockReset();
|
|
1330
|
-
|
|
1331
|
-
$state.a = "aaa";
|
|
1332
|
-
expect($state.c).toEqual("bb");
|
|
1333
|
-
expect(spy).not.toHaveBeenCalled();
|
|
1334
|
-
});
|
|
1335
|
-
|
|
1336
|
-
// describe(".(un)watched()", () => {
|
|
1337
|
-
// it("should call watched when first subscription occurs", () => {
|
|
1338
|
-
// const watched = vi.fn();
|
|
1339
|
-
// const unwatched = vi.fn();
|
|
1340
|
-
// const s = $derive(() => 1, { watched, unwatched });
|
|
1341
|
-
// expect(watched).not.toHaveBeenCalled();
|
|
1342
|
-
// const unsubscribe = s.subscribe(() => {});
|
|
1343
|
-
// expect(watched).toHaveBeenCalledOnce();
|
|
1344
|
-
// const unsubscribe2 = s.subscribe(() => {});
|
|
1345
|
-
// expect(watched).toHaveBeenCalledOnce();
|
|
1346
|
-
// unsubscribe();
|
|
1347
|
-
// unsubscribe2();
|
|
1348
|
-
// expect(unwatched).toHaveBeenCalledOnce();
|
|
1349
|
-
// });
|
|
1350
|
-
//
|
|
1351
|
-
// it("should call watched when first subscription occurs w/ nested signal", () => {
|
|
1352
|
-
// const watched = vi.fn();
|
|
1353
|
-
// const unwatched = vi.fn();
|
|
1354
|
-
// let $state = $watch({ s: 1, { watched, unwatched } });
|
|
1355
|
-
// const c = $derive(() => s.value + 1, { watched, unwatched });
|
|
1356
|
-
// expect(watched).not.toHaveBeenCalled();
|
|
1357
|
-
// const unsubscribe = c.subscribe(() => {});
|
|
1358
|
-
// expect(watched).toHaveBeenCalledTimes(2);
|
|
1359
|
-
// const unsubscribe2 = s.subscribe(() => {});
|
|
1360
|
-
// expect(watched).toHaveBeenCalledTimes(2);
|
|
1361
|
-
// unsubscribe2();
|
|
1362
|
-
// unsubscribe();
|
|
1363
|
-
// expect(unwatched).toHaveBeenCalledTimes(2);
|
|
1364
|
-
// });
|
|
1365
|
-
// });
|
|
1366
|
-
|
|
1367
|
-
it("should consider undefined value separate from uninitialized value", () => {
|
|
1368
|
-
let spy = vi.fn(() => undefined);
|
|
1369
|
-
let $state = $watch({
|
|
1370
|
-
a: 0,
|
|
1371
|
-
get c() {
|
|
1372
|
-
return $cache(spy);
|
|
1373
|
-
},
|
|
1374
|
-
});
|
|
1375
|
-
|
|
1376
|
-
expect($state.c).toBeUndefined();
|
|
1377
|
-
$state.a = 1;
|
|
1378
|
-
expect($state.c).toBeUndefined();
|
|
1379
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
1380
|
-
});
|
|
1381
|
-
|
|
1382
|
-
it("should not leak errors raised by dependencies", () => {
|
|
1383
|
-
let $state = $watch({
|
|
1384
|
-
a: 0,
|
|
1385
|
-
get b() {
|
|
1386
|
-
return $cache(() => {
|
|
1387
|
-
$state.a;
|
|
1388
|
-
throw new Error("error");
|
|
1389
|
-
});
|
|
1390
|
-
},
|
|
1391
|
-
get c() {
|
|
1392
|
-
return $cache(() => {
|
|
1393
|
-
try {
|
|
1394
|
-
return $state.b;
|
|
1395
|
-
} catch {
|
|
1396
|
-
return "ok";
|
|
1397
|
-
}
|
|
1398
|
-
});
|
|
1399
|
-
},
|
|
1400
|
-
});
|
|
1401
|
-
expect($state.c).toEqual("ok");
|
|
1402
|
-
$state.a = 1;
|
|
1403
|
-
expect($state.c).toEqual("ok");
|
|
1404
|
-
});
|
|
1405
|
-
|
|
1406
|
-
it("should propagate notifications even right after first subscription", () => {
|
|
1407
|
-
let $state = $watch({
|
|
1408
|
-
a: 0,
|
|
1409
|
-
get b() {
|
|
1410
|
-
return $cache(() => $state.a);
|
|
1411
|
-
},
|
|
1412
|
-
get c() {
|
|
1413
|
-
return $cache(() => $state.b);
|
|
1414
|
-
},
|
|
1415
|
-
});
|
|
1416
|
-
$state.c;
|
|
1417
|
-
|
|
1418
|
-
let spy = vi.fn(() => {
|
|
1419
|
-
$state.c;
|
|
1420
|
-
});
|
|
1421
|
-
|
|
1422
|
-
$run(spy);
|
|
1423
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
1424
|
-
spy.mockReset();
|
|
1425
|
-
|
|
1426
|
-
$state.a = 1;
|
|
1427
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
1428
|
-
});
|
|
1429
|
-
|
|
1430
|
-
it("should get marked as outdated right after first subscription", () => {
|
|
1431
|
-
let $state = $watch({
|
|
1432
|
-
s: 0,
|
|
1433
|
-
get c() {
|
|
1434
|
-
return $cache(() => $state.s);
|
|
1435
|
-
},
|
|
1436
|
-
});
|
|
1437
|
-
$state.c;
|
|
1438
|
-
|
|
1439
|
-
$state.s = 1;
|
|
1440
|
-
$run(() => {
|
|
1441
|
-
$state.c;
|
|
1442
|
-
});
|
|
1443
|
-
expect($state.c).toEqual(1);
|
|
1444
|
-
});
|
|
1445
|
-
|
|
1446
|
-
// it("should propagate notification to other listeners after one listener is disposed", () => {
|
|
1447
|
-
// let $state = $watch({ s: 0 });
|
|
1448
|
-
// const c = $derive(() => s.value);
|
|
1449
|
-
//
|
|
1450
|
-
// let spy1 = vi.fn(() => {
|
|
1451
|
-
// $state.c;
|
|
1452
|
-
// });
|
|
1453
|
-
// let spy2 = vi.fn(() => {
|
|
1454
|
-
// $state.c;
|
|
1455
|
-
// });
|
|
1456
|
-
// let spy3 = vi.fn(() => {
|
|
1457
|
-
// $state.c;
|
|
1458
|
-
// });
|
|
1459
|
-
//
|
|
1460
|
-
// $run(spy1);
|
|
1461
|
-
// const dispose = $run(spy2);
|
|
1462
|
-
// $run(spy3);
|
|
1463
|
-
//
|
|
1464
|
-
// expect(spy1).toHaveBeenCalledOnce();
|
|
1465
|
-
// expect(spy2).toHaveBeenCalledOnce();
|
|
1466
|
-
// expect(spy3).toHaveBeenCalledOnce();
|
|
1467
|
-
//
|
|
1468
|
-
// dispose();
|
|
1469
|
-
//
|
|
1470
|
-
// $state.s = 1;
|
|
1471
|
-
// expect(spy1).toHaveBeenCalledTimes(2);
|
|
1472
|
-
// expect(spy2).toHaveBeenCalledOnce();
|
|
1473
|
-
// expect(spy3).toHaveBeenCalledTimes(2);
|
|
1474
|
-
// });
|
|
1475
|
-
|
|
1476
|
-
it("should not recompute dependencies out of order", () => {
|
|
1477
|
-
let spy = vi.fn(() => $state.c);
|
|
1478
|
-
let $state = $watch({
|
|
1479
|
-
a: 1,
|
|
1480
|
-
b: 1,
|
|
1481
|
-
c: 1,
|
|
1482
|
-
get d() {
|
|
1483
|
-
return $cache(spy);
|
|
1484
|
-
},
|
|
1485
|
-
get e() {
|
|
1486
|
-
return $cache(() => {
|
|
1487
|
-
if ($state.a > 0) {
|
|
1488
|
-
$state.b;
|
|
1489
|
-
$state.d;
|
|
1490
|
-
} else {
|
|
1491
|
-
$state.b;
|
|
1492
|
-
}
|
|
1493
|
-
return true;
|
|
1494
|
-
});
|
|
1495
|
-
},
|
|
1496
|
-
});
|
|
1497
|
-
|
|
1498
|
-
$state.e;
|
|
1499
|
-
spy.mockReset();
|
|
1500
|
-
|
|
1501
|
-
$state.a = 2;
|
|
1502
|
-
$state.b = 2;
|
|
1503
|
-
$state.c = 2;
|
|
1504
|
-
$state.e;
|
|
1505
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
1506
|
-
spy.mockReset();
|
|
1507
|
-
|
|
1508
|
-
$state.a = -1;
|
|
1509
|
-
$state.b = -1;
|
|
1510
|
-
$state.c = -1;
|
|
1511
|
-
$state.e;
|
|
1512
|
-
expect(spy).not.toHaveBeenCalled();
|
|
1513
|
-
spy.mockReset();
|
|
1514
|
-
});
|
|
1515
|
-
|
|
1516
|
-
it("should not recompute dependencies unnecessarily", () => {
|
|
1517
|
-
let spy = vi.fn();
|
|
1518
|
-
let $state = $watch({
|
|
1519
|
-
a: 0,
|
|
1520
|
-
b: 0,
|
|
1521
|
-
get c() {
|
|
1522
|
-
return $cache(() => {
|
|
1523
|
-
$state.b;
|
|
1524
|
-
return spy();
|
|
1525
|
-
});
|
|
1526
|
-
},
|
|
1527
|
-
get d() {
|
|
1528
|
-
return $cache(() => {
|
|
1529
|
-
if ($state.a === 0) {
|
|
1530
|
-
return $state.c;
|
|
1531
|
-
}
|
|
1532
|
-
});
|
|
1533
|
-
},
|
|
1534
|
-
});
|
|
1535
|
-
|
|
1536
|
-
$state.d;
|
|
1537
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
1538
|
-
|
|
1539
|
-
$batch(() => {
|
|
1540
|
-
$state.b = 1;
|
|
1541
|
-
$state.a = 1;
|
|
1542
|
-
});
|
|
1543
|
-
$state.d;
|
|
1544
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
1545
|
-
});
|
|
1546
|
-
|
|
1547
|
-
describe("$peek()", () => {
|
|
1548
|
-
it("should get value", () => {
|
|
1549
|
-
let $state = $watch({
|
|
1550
|
-
s: 1,
|
|
1551
|
-
get c() {
|
|
1552
|
-
return $cache(() => $state.s);
|
|
1553
|
-
},
|
|
1554
|
-
});
|
|
1555
|
-
expect($peek(() => $state.c)).equal(1);
|
|
1556
|
-
});
|
|
1557
|
-
|
|
1558
|
-
it("should throw when evaluation throws", () => {
|
|
1559
|
-
let $state = $watch({
|
|
1560
|
-
get c() {
|
|
1561
|
-
return $cache(() => {
|
|
1562
|
-
throw Error("test");
|
|
1563
|
-
});
|
|
1564
|
-
},
|
|
1565
|
-
});
|
|
1566
|
-
expect(() => $peek(() => $state.c)).toThrow("test");
|
|
1567
|
-
});
|
|
1568
|
-
|
|
1569
|
-
it("should throw when previous evaluation threw and dependencies haven't changed", () => {
|
|
1570
|
-
let $state = $watch({
|
|
1571
|
-
get c() {
|
|
1572
|
-
return $cache(() => {
|
|
1573
|
-
throw Error("test");
|
|
1574
|
-
});
|
|
1575
|
-
},
|
|
1576
|
-
});
|
|
1577
|
-
expect(() => $state.c).toThrow("test");
|
|
1578
|
-
expect(() => $peek(() => $state.c)).toThrow("test");
|
|
1579
|
-
});
|
|
1580
|
-
|
|
1581
|
-
it("should refresh value if stale", () => {
|
|
1582
|
-
let $state = $watch({
|
|
1583
|
-
a: 1,
|
|
1584
|
-
get b() {
|
|
1585
|
-
return $cache(() => $state.a);
|
|
1586
|
-
},
|
|
1587
|
-
});
|
|
1588
|
-
expect($peek(() => $state.b)).toEqual(1);
|
|
1589
|
-
|
|
1590
|
-
$state.a = 2;
|
|
1591
|
-
expect($peek(() => $state.b)).toEqual(2);
|
|
1592
|
-
});
|
|
1593
|
-
|
|
1594
|
-
it("should detect simple dependency cycles", () => {
|
|
1595
|
-
const $state = $watch({
|
|
1596
|
-
get a(): any {
|
|
1597
|
-
return $cache(() => $peek(() => $state.a));
|
|
1598
|
-
},
|
|
1599
|
-
});
|
|
1600
|
-
expect(() => $peek(() => $state.a)).toThrow("Cycle detected");
|
|
1601
|
-
});
|
|
1602
|
-
|
|
1603
|
-
it("should detect deep dependency cycles", () => {
|
|
1604
|
-
const $state = $watch({
|
|
1605
|
-
get a(): any {
|
|
1606
|
-
return $cache(() => $state.b);
|
|
1607
|
-
},
|
|
1608
|
-
get b() {
|
|
1609
|
-
return $cache(() => $state.c);
|
|
1610
|
-
},
|
|
1611
|
-
get c() {
|
|
1612
|
-
return $cache(() => $state.d);
|
|
1613
|
-
},
|
|
1614
|
-
get d() {
|
|
1615
|
-
return $cache(() => $peek(() => $state.a));
|
|
1616
|
-
},
|
|
1617
|
-
});
|
|
1618
|
-
expect(() => $peek(() => $state.a)).toThrow("Cycle detected");
|
|
1619
|
-
});
|
|
1620
|
-
|
|
1621
|
-
it("should not make surrounding effect depend on the computed", () => {
|
|
1622
|
-
let $state = $watch({
|
|
1623
|
-
s: 1,
|
|
1624
|
-
get c() {
|
|
1625
|
-
return $cache(() => $state.s);
|
|
1626
|
-
},
|
|
1627
|
-
});
|
|
1628
|
-
let spy = vi.fn(() => {
|
|
1629
|
-
$peek(() => $state.c);
|
|
1630
|
-
});
|
|
1631
|
-
|
|
1632
|
-
$run(spy);
|
|
1633
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
1634
|
-
|
|
1635
|
-
$state.s = 2;
|
|
1636
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
1637
|
-
});
|
|
1638
|
-
|
|
1639
|
-
it("should not make surrounding computed depend on the $derive", () => {
|
|
1640
|
-
let spy = vi.fn(() => {
|
|
1641
|
-
$peek(() => $state.c);
|
|
1642
|
-
});
|
|
1643
|
-
|
|
1644
|
-
let $state = $watch({
|
|
1645
|
-
s: 1,
|
|
1646
|
-
get c() {
|
|
1647
|
-
return $cache(() => $state.s);
|
|
1648
|
-
},
|
|
1649
|
-
get d() {
|
|
1650
|
-
return $cache(spy);
|
|
1651
|
-
},
|
|
1652
|
-
});
|
|
1653
|
-
$state.d;
|
|
1654
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
1655
|
-
|
|
1656
|
-
$state.s = 2;
|
|
1657
|
-
$state.d;
|
|
1658
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
1659
|
-
});
|
|
1660
|
-
|
|
1661
|
-
it("should not make surrounding effect depend on the peeked computed's dependencies", () => {
|
|
1662
|
-
let $state = $watch({
|
|
1663
|
-
a: 1,
|
|
1664
|
-
get b() {
|
|
1665
|
-
return $cache(() => $state.a);
|
|
1666
|
-
},
|
|
1667
|
-
});
|
|
1668
|
-
|
|
1669
|
-
let spy = vi.fn();
|
|
1670
|
-
$run(() => {
|
|
1671
|
-
spy();
|
|
1672
|
-
$peek(() => $state.b);
|
|
1673
|
-
});
|
|
1674
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
1675
|
-
spy.mockReset();
|
|
1676
|
-
|
|
1677
|
-
$state.a = 1;
|
|
1678
|
-
expect(spy).not.toHaveBeenCalled();
|
|
1679
|
-
});
|
|
1680
|
-
|
|
1681
|
-
it("should not make surrounding computed depend on peeked $derive's dependencies", () => {
|
|
1682
|
-
let spy = vi.fn();
|
|
1683
|
-
let $state = $watch({
|
|
1684
|
-
a: 1,
|
|
1685
|
-
get b() {
|
|
1686
|
-
return $cache(() => $state.a);
|
|
1687
|
-
},
|
|
1688
|
-
get d() {
|
|
1689
|
-
spy();
|
|
1690
|
-
return $cache(() => $peek(() => $state.b));
|
|
1691
|
-
},
|
|
1692
|
-
});
|
|
1693
|
-
$state.d;
|
|
1694
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
1695
|
-
spy.mockReset();
|
|
1696
|
-
|
|
1697
|
-
$state.a = 1;
|
|
1698
|
-
$state.d;
|
|
1699
|
-
expect(spy).not.toHaveBeenCalled();
|
|
1700
|
-
});
|
|
1701
|
-
});
|
|
1702
|
-
|
|
1703
|
-
// describe("garbage collection", function () {
|
|
1704
|
-
// // Skip GC tests if window.gc/global.gc is not defined.
|
|
1705
|
-
// before(function () {
|
|
1706
|
-
// if (typeof gc === "undefined") {
|
|
1707
|
-
// this.skip();
|
|
1708
|
-
// }
|
|
1709
|
-
// });
|
|
1710
|
-
//
|
|
1711
|
-
// it("should be garbage collectable if nothing is listening to its changes", async () => {
|
|
1712
|
-
// let $state = $watch({ s: 0 });
|
|
1713
|
-
// const ref = new WeakRef($derive(() => s.value));
|
|
1714
|
-
//
|
|
1715
|
-
// (gc as () => void)();
|
|
1716
|
-
// await new Promise((resolve) => setTimeout(resolve, 0));
|
|
1717
|
-
// (gc as () => void)();
|
|
1718
|
-
// expect(ref.deref()).toBeUndefined();
|
|
1719
|
-
// });
|
|
1720
|
-
//
|
|
1721
|
-
// it("should be garbage collectable after it has lost all of its listeners", async () => {
|
|
1722
|
-
// let $state = $watch({ s: 0 });
|
|
1723
|
-
//
|
|
1724
|
-
// let ref: WeakRef<ReadonlySignal>;
|
|
1725
|
-
// let dispose: () => void;
|
|
1726
|
-
// (function () {
|
|
1727
|
-
// const c = $derive(() => s.value);
|
|
1728
|
-
// ref = new WeakRef(c);
|
|
1729
|
-
// dispose = $run(() => {
|
|
1730
|
-
// $state.c;
|
|
1731
|
-
// });
|
|
1732
|
-
// })();
|
|
1733
|
-
//
|
|
1734
|
-
// dispose();
|
|
1735
|
-
// (gc as () => void)();
|
|
1736
|
-
// await new Promise((resolve) => setTimeout(resolve, 0));
|
|
1737
|
-
// (gc as () => void)();
|
|
1738
|
-
// expect(ref.deref()).toBeUndefined();
|
|
1739
|
-
// });
|
|
1740
|
-
// });
|
|
1741
|
-
|
|
1742
|
-
describe("graph updates", () => {
|
|
1743
|
-
it("should run computeds once for multiple dep changes", async () => {
|
|
1744
|
-
const compute = vi.fn(() => {
|
|
1745
|
-
// debugger;
|
|
1746
|
-
return $state.a + $state.b;
|
|
1747
|
-
});
|
|
1748
|
-
let $state = $watch({
|
|
1749
|
-
a: "a",
|
|
1750
|
-
b: "b",
|
|
1751
|
-
get c() {
|
|
1752
|
-
return $cache(() => compute());
|
|
1753
|
-
},
|
|
1754
|
-
});
|
|
1755
|
-
|
|
1756
|
-
expect($state.c).toEqual("ab");
|
|
1757
|
-
expect(compute).toHaveBeenCalledOnce();
|
|
1758
|
-
compute.mockReset();
|
|
1759
|
-
|
|
1760
|
-
$state.a = "aa";
|
|
1761
|
-
$state.b = "bb";
|
|
1762
|
-
$state.c;
|
|
1763
|
-
expect(compute).toHaveBeenCalledOnce();
|
|
1764
|
-
});
|
|
1765
|
-
|
|
1766
|
-
it("should drop A->B->A updates", async () => {
|
|
1767
|
-
const compute = vi.fn(() => "d: " + $state.c);
|
|
1768
|
-
|
|
1769
|
-
// A
|
|
1770
|
-
// / |
|
|
1771
|
-
// B | <- Looks like a flag doesn't it? :D
|
|
1772
|
-
// \ |
|
|
1773
|
-
// C
|
|
1774
|
-
// |
|
|
1775
|
-
// D
|
|
1776
|
-
let $state = $watch({
|
|
1777
|
-
a: 2,
|
|
1778
|
-
get b() {
|
|
1779
|
-
return $cache(() => $state.a - 1);
|
|
1780
|
-
},
|
|
1781
|
-
get c() {
|
|
1782
|
-
return $cache(() => $state.a + $state.b);
|
|
1783
|
-
},
|
|
1784
|
-
get d() {
|
|
1785
|
-
return $cache(() => compute());
|
|
1786
|
-
},
|
|
1787
|
-
});
|
|
1788
|
-
|
|
1789
|
-
// Trigger read
|
|
1790
|
-
expect($state.d).toEqual("d: 3");
|
|
1791
|
-
expect(compute).toHaveBeenCalledOnce();
|
|
1792
|
-
compute.mockReset();
|
|
1793
|
-
|
|
1794
|
-
$state.a = 4;
|
|
1795
|
-
$state.d;
|
|
1796
|
-
expect(compute).toHaveBeenCalledOnce();
|
|
1797
|
-
});
|
|
1798
|
-
|
|
1799
|
-
it("should only update every signal once (diamond graph)", () => {
|
|
1800
|
-
let spy = vi.fn(() => $state.b + " " + $state.c);
|
|
1801
|
-
|
|
1802
|
-
// In this scenario "D" should only update once when "A" receives
|
|
1803
|
-
// an update. This is sometimes referred to as the "diamond" scenario.
|
|
1804
|
-
// A
|
|
1805
|
-
// / \
|
|
1806
|
-
// B C
|
|
1807
|
-
// \ /
|
|
1808
|
-
// D
|
|
1809
|
-
let $state = $watch({
|
|
1810
|
-
a: "a",
|
|
1811
|
-
get b() {
|
|
1812
|
-
return $cache(() => $state.a);
|
|
1813
|
-
},
|
|
1814
|
-
get c() {
|
|
1815
|
-
return $cache(() => $state.a);
|
|
1816
|
-
},
|
|
1817
|
-
get d() {
|
|
1818
|
-
return $cache(spy);
|
|
1819
|
-
},
|
|
1820
|
-
});
|
|
1821
|
-
|
|
1822
|
-
expect($state.d).toEqual("a a");
|
|
1823
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
1824
|
-
|
|
1825
|
-
$state.a = "aa";
|
|
1826
|
-
expect($state.d).toEqual("aa aa");
|
|
1827
|
-
expect(spy).toHaveBeenCalledTimes(2);
|
|
1828
|
-
});
|
|
1829
|
-
|
|
1830
|
-
it("should only update every signal once (diamond graph + tail)", () => {
|
|
1831
|
-
let spy = vi.fn(() => $state.d);
|
|
1832
|
-
|
|
1833
|
-
// "E" will be likely updated twice if our mark+sweep logic is buggy.
|
|
1834
|
-
// A
|
|
1835
|
-
// / \
|
|
1836
|
-
// B C
|
|
1837
|
-
// \ /
|
|
1838
|
-
// D
|
|
1839
|
-
// |
|
|
1840
|
-
// E
|
|
1841
|
-
let $state = $watch({
|
|
1842
|
-
a: "a",
|
|
1843
|
-
get b() {
|
|
1844
|
-
return $cache(() => $state.a);
|
|
1845
|
-
},
|
|
1846
|
-
get c() {
|
|
1847
|
-
return $cache(() => $state.a);
|
|
1848
|
-
},
|
|
1849
|
-
get d() {
|
|
1850
|
-
return $cache(() => $state.b + " " + $state.c);
|
|
1851
|
-
},
|
|
1852
|
-
get e() {
|
|
1853
|
-
return $cache(spy);
|
|
1854
|
-
},
|
|
1855
|
-
});
|
|
1856
|
-
|
|
1857
|
-
expect($state.e).toEqual("a a");
|
|
1858
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
1859
|
-
|
|
1860
|
-
$state.a = "aa";
|
|
1861
|
-
expect($state.e).toEqual("aa aa");
|
|
1862
|
-
expect(spy).toHaveBeenCalledTimes(2);
|
|
1863
|
-
});
|
|
1864
|
-
|
|
1865
|
-
it("should bail out if result is the same", () => {
|
|
1866
|
-
let spy = vi.fn(() => $state.b);
|
|
1867
|
-
|
|
1868
|
-
// Bail out if value of "B" never changes
|
|
1869
|
-
// A->B->C
|
|
1870
|
-
let $state = $watch({
|
|
1871
|
-
a: "a",
|
|
1872
|
-
get b() {
|
|
1873
|
-
return $cache(() => {
|
|
1874
|
-
$state.a;
|
|
1875
|
-
return "foo";
|
|
1876
|
-
});
|
|
1877
|
-
},
|
|
1878
|
-
get c() {
|
|
1879
|
-
return $cache(spy);
|
|
1880
|
-
},
|
|
1881
|
-
});
|
|
1882
|
-
|
|
1883
|
-
expect($state.c).toEqual("foo");
|
|
1884
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
1885
|
-
|
|
1886
|
-
$state.a = "aa";
|
|
1887
|
-
expect($state.c).toEqual("foo");
|
|
1888
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
1889
|
-
});
|
|
1890
|
-
|
|
1891
|
-
it("should only update every signal once (jagged diamond graph + tails)", () => {
|
|
1892
|
-
const eSpy = vi.fn();
|
|
1893
|
-
const fSpy = vi.fn();
|
|
1894
|
-
const gSpy = vi.fn();
|
|
1895
|
-
|
|
1896
|
-
// "F" and "G" will be likely updated twice if our mark+sweep logic is buggy.
|
|
1897
|
-
// A
|
|
1898
|
-
// / \
|
|
1899
|
-
// B C
|
|
1900
|
-
// | |
|
|
1901
|
-
// | D
|
|
1902
|
-
// \ /
|
|
1903
|
-
// E
|
|
1904
|
-
// / \
|
|
1905
|
-
// F G
|
|
1906
|
-
let $state = $watch({
|
|
1907
|
-
a: "a",
|
|
1908
|
-
get b() {
|
|
1909
|
-
return $cache(() => $state.a);
|
|
1910
|
-
},
|
|
1911
|
-
get c() {
|
|
1912
|
-
return $cache(() => $state.a);
|
|
1913
|
-
},
|
|
1914
|
-
get d() {
|
|
1915
|
-
return $cache(() => $state.c);
|
|
1916
|
-
},
|
|
1917
|
-
get e() {
|
|
1918
|
-
return $cache(() => {
|
|
1919
|
-
eSpy();
|
|
1920
|
-
return $state.b + " " + $state.d;
|
|
1921
|
-
});
|
|
1922
|
-
},
|
|
1923
|
-
get f() {
|
|
1924
|
-
return $cache(() => {
|
|
1925
|
-
fSpy();
|
|
1926
|
-
return $state.e;
|
|
1927
|
-
});
|
|
1928
|
-
},
|
|
1929
|
-
get g() {
|
|
1930
|
-
return $cache(() => {
|
|
1931
|
-
gSpy();
|
|
1932
|
-
return $state.e;
|
|
1933
|
-
});
|
|
1934
|
-
},
|
|
1935
|
-
});
|
|
1936
|
-
|
|
1937
|
-
expect($state.f).toEqual("a a");
|
|
1938
|
-
expect(fSpy).toHaveBeenCalledOnce();
|
|
1939
|
-
|
|
1940
|
-
expect($state.g).toEqual("a a");
|
|
1941
|
-
expect(gSpy).toHaveBeenCalledOnce();
|
|
1942
|
-
|
|
1943
|
-
eSpy.mockReset();
|
|
1944
|
-
fSpy.mockReset();
|
|
1945
|
-
gSpy.mockReset();
|
|
1946
|
-
|
|
1947
|
-
$state.a = "b";
|
|
1948
|
-
|
|
1949
|
-
expect($state.e).toEqual("b b");
|
|
1950
|
-
expect(eSpy).toHaveBeenCalledOnce();
|
|
1951
|
-
|
|
1952
|
-
expect($state.f).toEqual("b b");
|
|
1953
|
-
expect(fSpy).toHaveBeenCalledOnce();
|
|
1954
|
-
|
|
1955
|
-
expect($state.g).toEqual("b b");
|
|
1956
|
-
expect(gSpy).toHaveBeenCalledOnce();
|
|
1957
|
-
|
|
1958
|
-
eSpy.mockReset();
|
|
1959
|
-
fSpy.mockReset();
|
|
1960
|
-
gSpy.mockReset();
|
|
1961
|
-
|
|
1962
|
-
$state.a = "c";
|
|
1963
|
-
|
|
1964
|
-
expect($state.e).toEqual("c c");
|
|
1965
|
-
expect(eSpy).toHaveBeenCalledOnce();
|
|
1966
|
-
|
|
1967
|
-
expect($state.f).toEqual("c c");
|
|
1968
|
-
expect(fSpy).toHaveBeenCalledOnce();
|
|
1969
|
-
|
|
1970
|
-
expect($state.g).toEqual("c c");
|
|
1971
|
-
expect(gSpy).toHaveBeenCalledOnce();
|
|
1972
|
-
|
|
1973
|
-
// top to bottom
|
|
1974
|
-
expect(eSpy).toHaveBeenCalledBefore(fSpy);
|
|
1975
|
-
// left to right
|
|
1976
|
-
expect(fSpy).toHaveBeenCalledBefore(gSpy);
|
|
1977
|
-
});
|
|
1978
|
-
|
|
1979
|
-
it("should only subscribe to signals listened to", () => {
|
|
1980
|
-
let spy = vi.fn(() => $state.a);
|
|
1981
|
-
|
|
1982
|
-
// *A
|
|
1983
|
-
// / \
|
|
1984
|
-
// *B C <- we don't listen to C
|
|
1985
|
-
let $state = $watch({
|
|
1986
|
-
a: "a",
|
|
1987
|
-
get b() {
|
|
1988
|
-
return $cache(() => $state.a);
|
|
1989
|
-
},
|
|
1990
|
-
get c() {
|
|
1991
|
-
return $cache(spy);
|
|
1992
|
-
},
|
|
1993
|
-
});
|
|
1994
|
-
|
|
1995
|
-
expect($state.b).toEqual("a");
|
|
1996
|
-
expect(spy).not.toHaveBeenCalled();
|
|
1997
|
-
|
|
1998
|
-
$state.a = "aa";
|
|
1999
|
-
expect($state.b).toEqual("aa");
|
|
2000
|
-
expect(spy).not.toHaveBeenCalled();
|
|
2001
|
-
});
|
|
2002
|
-
|
|
2003
|
-
// it("should only subscribe to signals listened to", () => {
|
|
2004
|
-
// // Here both "B" and "C" are active in the beginning, but
|
|
2005
|
-
// // "B" becomes inactive later. At that point it should
|
|
2006
|
-
// // not receive any updates anymore.
|
|
2007
|
-
// // *A
|
|
2008
|
-
// // / \
|
|
2009
|
-
// // *B D <- we don't listen to C
|
|
2010
|
-
// // |
|
|
2011
|
-
// // *C
|
|
2012
|
-
// let $state = $watch({ a: "a" });
|
|
2013
|
-
// let spyB = vi.fn(() => $state.a);
|
|
2014
|
-
// const b = $derive(spyB);
|
|
2015
|
-
//
|
|
2016
|
-
// let spyC = vi.fn(() => $state.b);
|
|
2017
|
-
// const c = $derive(spyC);
|
|
2018
|
-
//
|
|
2019
|
-
// const d = $derive(() => $state.a);
|
|
2020
|
-
//
|
|
2021
|
-
// let result = "";
|
|
2022
|
-
// const unsub = $run(() => {
|
|
2023
|
-
// result = $state.c;
|
|
2024
|
-
// });
|
|
2025
|
-
//
|
|
2026
|
-
// expect(result).toEqual("a");
|
|
2027
|
-
// expect($state.d).toEqual("a");
|
|
2028
|
-
//
|
|
2029
|
-
// spyB.mockReset();
|
|
2030
|
-
// spyC.mockReset();
|
|
2031
|
-
// unsub();
|
|
2032
|
-
//
|
|
2033
|
-
// $state.a = "aa";
|
|
2034
|
-
//
|
|
2035
|
-
// expect(spyB).not.toHaveBeenCalled();
|
|
2036
|
-
// expect(spyC).not.toHaveBeenCalled();
|
|
2037
|
-
// expect($state.d).toEqual("aa");
|
|
2038
|
-
// });
|
|
2039
|
-
|
|
2040
|
-
it("should ensure subs update even if one dep unmarks it", () => {
|
|
2041
|
-
let spy = vi.fn(() => $state.b + " " + $state.c);
|
|
2042
|
-
|
|
2043
|
-
// In this scenario "C" always returns the same value. When "A"
|
|
2044
|
-
// changes, "B" will update, then "C" at which point its update
|
|
2045
|
-
// to "D" will be unmarked. But "D" must still update because
|
|
2046
|
-
// "B" marked it. If "D" isn't updated, then we have a bug.
|
|
2047
|
-
// A
|
|
2048
|
-
// / \
|
|
2049
|
-
// B *C <- returns same value every time
|
|
2050
|
-
// \ /
|
|
2051
|
-
// D
|
|
2052
|
-
let $state = $watch({
|
|
2053
|
-
a: "a",
|
|
2054
|
-
get b() {
|
|
2055
|
-
return $cache(() => $state.a);
|
|
2056
|
-
},
|
|
2057
|
-
get c() {
|
|
2058
|
-
return $cache(() => {
|
|
2059
|
-
$state.a;
|
|
2060
|
-
return "c";
|
|
2061
|
-
});
|
|
2062
|
-
},
|
|
2063
|
-
get d() {
|
|
2064
|
-
return $cache(spy);
|
|
2065
|
-
},
|
|
2066
|
-
});
|
|
2067
|
-
|
|
2068
|
-
expect($state.d).toEqual("a c");
|
|
2069
|
-
spy.mockReset();
|
|
2070
|
-
|
|
2071
|
-
$state.a = "aa";
|
|
2072
|
-
$state.d;
|
|
2073
|
-
expect(spy).toHaveLastReturnedWith("aa c");
|
|
2074
|
-
});
|
|
2075
|
-
|
|
2076
|
-
it("should ensure subs update even if two deps unmark it", () => {
|
|
2077
|
-
let spy = vi.fn(() => $state.b + " " + $state.c + " " + $state.d);
|
|
2078
|
-
|
|
2079
|
-
// In this scenario both "C" and "D" always return the same
|
|
2080
|
-
// value. But "E" must still update because "A" marked it.
|
|
2081
|
-
// If "E" isn't updated, then we have a bug.
|
|
2082
|
-
// A
|
|
2083
|
-
// / | \
|
|
2084
|
-
// B *C *D
|
|
2085
|
-
// \ | /
|
|
2086
|
-
// E
|
|
2087
|
-
let $state = $watch({
|
|
2088
|
-
a: "a",
|
|
2089
|
-
get b() {
|
|
2090
|
-
return $cache(() => $state.a);
|
|
2091
|
-
},
|
|
2092
|
-
get c() {
|
|
2093
|
-
return $cache(() => {
|
|
2094
|
-
$state.a;
|
|
2095
|
-
return "c";
|
|
2096
|
-
});
|
|
2097
|
-
},
|
|
2098
|
-
get d() {
|
|
2099
|
-
return $cache(() => {
|
|
2100
|
-
$state.a;
|
|
2101
|
-
return "d";
|
|
2102
|
-
});
|
|
2103
|
-
},
|
|
2104
|
-
get e() {
|
|
2105
|
-
return $cache(spy);
|
|
2106
|
-
},
|
|
2107
|
-
});
|
|
2108
|
-
expect($state.e).toEqual("a c d");
|
|
2109
|
-
spy.mockReset();
|
|
2110
|
-
|
|
2111
|
-
$state.a = "aa";
|
|
2112
|
-
$state.e;
|
|
2113
|
-
expect(spy).toHaveLastReturnedWith("aa c d");
|
|
2114
|
-
});
|
|
2115
|
-
});
|
|
2116
|
-
|
|
2117
|
-
describe("error handling", () => {
|
|
2118
|
-
// it("should throw when writing to computeds", () => {
|
|
2119
|
-
// let $state = $watch({ a: "a" });
|
|
2120
|
-
// const b = $derive(() => $state.a);
|
|
2121
|
-
// const fn = () => ((b as $state.Signal) = "aa");
|
|
2122
|
-
// expect(fn).toThrow(/Cannot set property value/);
|
|
2123
|
-
// });
|
|
2124
|
-
|
|
2125
|
-
it("should keep graph consistent on errors during activation", () => {
|
|
2126
|
-
let $state = $watch({
|
|
2127
|
-
a: 0,
|
|
2128
|
-
get b() {
|
|
2129
|
-
return $cache(() => {
|
|
2130
|
-
throw new Error("fail");
|
|
2131
|
-
});
|
|
2132
|
-
},
|
|
2133
|
-
get c() {
|
|
2134
|
-
return $cache(() => $state.a);
|
|
2135
|
-
},
|
|
2136
|
-
});
|
|
2137
|
-
expect(() => $state.b).toThrow("fail");
|
|
2138
|
-
|
|
2139
|
-
$state.a = 1;
|
|
2140
|
-
expect($state.c).toEqual(1);
|
|
2141
|
-
});
|
|
2142
|
-
|
|
2143
|
-
it("should keep graph consistent on errors in computeds", () => {
|
|
2144
|
-
let $state = $watch({
|
|
2145
|
-
a: 0,
|
|
2146
|
-
get b() {
|
|
2147
|
-
return $cache(() => {
|
|
2148
|
-
if ($state.a === 1) throw new Error("fail");
|
|
2149
|
-
return $state.a;
|
|
2150
|
-
});
|
|
2151
|
-
},
|
|
2152
|
-
get c() {
|
|
2153
|
-
return $cache(() => $state.b);
|
|
2154
|
-
},
|
|
2155
|
-
});
|
|
2156
|
-
expect($state.c).toEqual(0);
|
|
2157
|
-
|
|
2158
|
-
$state.a = 1;
|
|
2159
|
-
expect(() => $state.b).toThrow("fail");
|
|
2160
|
-
|
|
2161
|
-
$state.a = 2;
|
|
2162
|
-
expect($state.c).toEqual(2);
|
|
2163
|
-
});
|
|
2164
|
-
|
|
2165
|
-
it("should support lazy branches", () => {
|
|
2166
|
-
let $state = $watch({
|
|
2167
|
-
a: 0,
|
|
2168
|
-
get b() {
|
|
2169
|
-
return $cache(() => $state.a);
|
|
2170
|
-
},
|
|
2171
|
-
get c() {
|
|
2172
|
-
return $cache(() => ($state.a > 0 ? $state.a : $state.b));
|
|
2173
|
-
},
|
|
2174
|
-
});
|
|
2175
|
-
|
|
2176
|
-
expect($state.c).toEqual(0);
|
|
2177
|
-
$state.a = 1;
|
|
2178
|
-
expect($state.c).toEqual(1);
|
|
2179
|
-
|
|
2180
|
-
$state.a = 0;
|
|
2181
|
-
expect($state.c).toEqual(0);
|
|
2182
|
-
});
|
|
2183
|
-
|
|
2184
|
-
it("should not update a sub if all deps unmark it", () => {
|
|
2185
|
-
let spy = vi.fn(() => $state.b + " " + $state.c);
|
|
2186
|
-
|
|
2187
|
-
// In this scenario "B" and "C" always return the same value. When "A"
|
|
2188
|
-
// changes, "D" should not update.
|
|
2189
|
-
// A
|
|
2190
|
-
// / \
|
|
2191
|
-
// *B *C
|
|
2192
|
-
// \ /
|
|
2193
|
-
// D
|
|
2194
|
-
let $state = $watch({
|
|
2195
|
-
a: "a",
|
|
2196
|
-
get b() {
|
|
2197
|
-
return $cache(() => {
|
|
2198
|
-
$state.a;
|
|
2199
|
-
return "b";
|
|
2200
|
-
});
|
|
2201
|
-
},
|
|
2202
|
-
get c() {
|
|
2203
|
-
return $cache(() => {
|
|
2204
|
-
$state.a;
|
|
2205
|
-
return "c";
|
|
2206
|
-
});
|
|
2207
|
-
},
|
|
2208
|
-
get d() {
|
|
2209
|
-
return $cache(spy);
|
|
2210
|
-
},
|
|
2211
|
-
});
|
|
2212
|
-
|
|
2213
|
-
expect($state.d).toEqual("b c");
|
|
2214
|
-
spy.mockReset();
|
|
2215
|
-
|
|
2216
|
-
$state.a = "aa";
|
|
2217
|
-
expect(spy).not.toHaveBeenCalled();
|
|
2218
|
-
});
|
|
2219
|
-
});
|
|
2220
|
-
});
|
|
2221
|
-
|
|
2222
|
-
describe("$batch()", () => {
|
|
2223
|
-
// it("should return the value from the callback", () => {
|
|
2224
|
-
// expect($batch(() => 1)).toEqual(1);
|
|
2225
|
-
// });
|
|
2226
|
-
//
|
|
2227
|
-
// it("should throw errors thrown from the callback", () => {
|
|
2228
|
-
// expect(() =>
|
|
2229
|
-
// $batch(() => {
|
|
2230
|
-
// throw Error("hello");
|
|
2231
|
-
// }),
|
|
2232
|
-
// ).toThrow("hello");
|
|
2233
|
-
// });
|
|
2234
|
-
//
|
|
2235
|
-
// it("should throw non-errors thrown from the callback", () => {
|
|
2236
|
-
// try {
|
|
2237
|
-
// $batch(() => {
|
|
2238
|
-
// throw undefined;
|
|
2239
|
-
// });
|
|
2240
|
-
// expect.fail();
|
|
2241
|
-
// } catch (err) {
|
|
2242
|
-
// expect(err).toBeUndefined();
|
|
2243
|
-
// }
|
|
2244
|
-
// });
|
|
2245
|
-
|
|
2246
|
-
it("should delay writes", () => {
|
|
2247
|
-
let $state = $watch({ a: "a", b: "b" });
|
|
2248
|
-
let spy = vi.fn(() => {
|
|
2249
|
-
$state.a + " " + $state.b;
|
|
2250
|
-
});
|
|
2251
|
-
$run(spy);
|
|
2252
|
-
spy.mockReset();
|
|
2253
|
-
|
|
2254
|
-
$batch(() => {
|
|
2255
|
-
$state.a = "aa";
|
|
2256
|
-
$state.b = "bb";
|
|
2257
|
-
});
|
|
2258
|
-
|
|
2259
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
2260
|
-
});
|
|
2261
|
-
|
|
2262
|
-
it("should delay writes until outermost batch is complete", () => {
|
|
2263
|
-
let $state = $watch({ a: "a", b: "b" });
|
|
2264
|
-
let spy = vi.fn(() => {
|
|
2265
|
-
$state.a + ", " + $state.b;
|
|
2266
|
-
});
|
|
2267
|
-
$run(spy);
|
|
2268
|
-
spy.mockReset();
|
|
2269
|
-
|
|
2270
|
-
$batch(() => {
|
|
2271
|
-
$batch(() => {
|
|
2272
|
-
$state.a += " inner";
|
|
2273
|
-
$state.b += " inner";
|
|
2274
|
-
});
|
|
2275
|
-
$state.a += " outer";
|
|
2276
|
-
$state.b += " outer";
|
|
2277
|
-
});
|
|
2278
|
-
|
|
2279
|
-
// If the inner $batch() would have flushed the update
|
|
2280
|
-
// this spy would've been called twice.
|
|
2281
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
2282
|
-
});
|
|
2283
|
-
|
|
2284
|
-
it("should read signals written to", () => {
|
|
2285
|
-
let $state = $watch({ a: "a" });
|
|
2286
|
-
|
|
2287
|
-
let result = "";
|
|
2288
|
-
$batch(() => {
|
|
2289
|
-
$state.a = "aa";
|
|
2290
|
-
result = $state.a;
|
|
2291
|
-
});
|
|
2292
|
-
|
|
2293
|
-
expect(result).toEqual("aa");
|
|
2294
|
-
});
|
|
2295
|
-
|
|
2296
|
-
it("should read computed signals with updated source signals", () => {
|
|
2297
|
-
let spyC = vi.fn(() => $state.b);
|
|
2298
|
-
let spyD = vi.fn(() => $state.c);
|
|
2299
|
-
let spyE = vi.fn(() => $state.d);
|
|
2300
|
-
|
|
2301
|
-
// A->B->C->D->E
|
|
2302
|
-
let $state = $watch({
|
|
2303
|
-
a: "a",
|
|
2304
|
-
get b() {
|
|
2305
|
-
return $cache(() => $state.a);
|
|
2306
|
-
},
|
|
2307
|
-
get c() {
|
|
2308
|
-
return $cache(() => spyC());
|
|
2309
|
-
},
|
|
2310
|
-
get d() {
|
|
2311
|
-
return $cache(() => spyD());
|
|
2312
|
-
},
|
|
2313
|
-
get e() {
|
|
2314
|
-
return $cache(() => spyE());
|
|
2315
|
-
},
|
|
2316
|
-
});
|
|
2317
|
-
|
|
2318
|
-
spyC.mockReset();
|
|
2319
|
-
spyD.mockReset();
|
|
2320
|
-
spyE.mockReset();
|
|
2321
|
-
|
|
2322
|
-
let result = "";
|
|
2323
|
-
$batch(() => {
|
|
2324
|
-
$state.a = "aa";
|
|
2325
|
-
result = $state.c;
|
|
2326
|
-
|
|
2327
|
-
// Since "D" isn't accessed during batching, we should not
|
|
2328
|
-
// update it, only after batching has completed
|
|
2329
|
-
expect(spyD).not.toHaveBeenCalled();
|
|
2330
|
-
});
|
|
2331
|
-
|
|
2332
|
-
expect(result).toEqual("aa");
|
|
2333
|
-
expect($state.d).toEqual("aa");
|
|
2334
|
-
expect($state.e).toEqual("aa");
|
|
2335
|
-
expect(spyC).toHaveBeenCalledOnce();
|
|
2336
|
-
expect(spyD).toHaveBeenCalledOnce();
|
|
2337
|
-
expect(spyE).toHaveBeenCalledOnce();
|
|
2338
|
-
});
|
|
2339
|
-
|
|
2340
|
-
it("should not block writes after batching completed", () => {
|
|
2341
|
-
// If no further writes after $batch() are possible, than we
|
|
2342
|
-
// didn't restore state properly. Most likely "pending" still
|
|
2343
|
-
// holds elements that are already processed.
|
|
2344
|
-
let $state = $watch({
|
|
2345
|
-
a: "a",
|
|
2346
|
-
b: "b",
|
|
2347
|
-
c: "c",
|
|
2348
|
-
get d() {
|
|
2349
|
-
return $cache(() => $state.a + " " + $state.b + " " + $state.c);
|
|
2350
|
-
},
|
|
2351
|
-
});
|
|
2352
|
-
|
|
2353
|
-
let result;
|
|
2354
|
-
$run(() => {
|
|
2355
|
-
result = $state.d;
|
|
2356
|
-
});
|
|
2357
|
-
|
|
2358
|
-
$batch(() => {
|
|
2359
|
-
$state.a = "aa";
|
|
2360
|
-
$state.b = "bb";
|
|
2361
|
-
});
|
|
2362
|
-
|
|
2363
|
-
$state.c = "cc";
|
|
2364
|
-
expect(result).toEqual("aa bb cc");
|
|
2365
|
-
});
|
|
2366
|
-
|
|
2367
|
-
it("should not lead to stale signals with .value in batch", () => {
|
|
2368
|
-
const invokes: number[][] = [];
|
|
2369
|
-
let $state = $watch({
|
|
2370
|
-
counter: 0,
|
|
2371
|
-
get double() {
|
|
2372
|
-
return $cache(() => this.counter * 2);
|
|
2373
|
-
},
|
|
2374
|
-
get triple() {
|
|
2375
|
-
return $cache(() => this.counter * 3);
|
|
2376
|
-
},
|
|
2377
|
-
});
|
|
2378
|
-
|
|
2379
|
-
$run(() => {
|
|
2380
|
-
invokes.push([$state.double, $state.triple]);
|
|
2381
|
-
});
|
|
2382
|
-
|
|
2383
|
-
expect(invokes).to.deep.equal([[0, 0]]);
|
|
2384
|
-
|
|
2385
|
-
$batch(() => {
|
|
2386
|
-
$state.counter = 1;
|
|
2387
|
-
expect($state.double).toEqual(2);
|
|
2388
|
-
});
|
|
2389
|
-
|
|
2390
|
-
expect(invokes[1]).to.deep.equal([2, 3]);
|
|
2391
|
-
});
|
|
2392
|
-
|
|
2393
|
-
it("should not lead to stale signals with peek() in batch", () => {
|
|
2394
|
-
const invokes: number[][] = [];
|
|
2395
|
-
let $state = $watch({
|
|
2396
|
-
counter: 0,
|
|
2397
|
-
get double() {
|
|
2398
|
-
return $cache(() => this.counter * 2);
|
|
2399
|
-
},
|
|
2400
|
-
get triple() {
|
|
2401
|
-
return $cache(() => this.counter * 3);
|
|
2402
|
-
},
|
|
2403
|
-
});
|
|
2404
|
-
|
|
2405
|
-
$run(() => {
|
|
2406
|
-
invokes.push([$state.double, $state.triple]);
|
|
2407
|
-
});
|
|
2408
|
-
|
|
2409
|
-
expect(invokes).to.deep.equal([[0, 0]]);
|
|
2410
|
-
|
|
2411
|
-
$batch(() => {
|
|
2412
|
-
$state.counter = 1;
|
|
2413
|
-
expect($peek(() => $state.double)).toEqual(2);
|
|
2414
|
-
});
|
|
2415
|
-
|
|
2416
|
-
expect(invokes[1]).to.deep.equal([2, 3]);
|
|
2417
|
-
});
|
|
2418
|
-
|
|
2419
|
-
it("should run pending effects even if the callback throws", () => {
|
|
2420
|
-
let $state = $watch({ a: 0, b: 1 });
|
|
2421
|
-
let spy1 = vi.fn(() => {
|
|
2422
|
-
$state.a;
|
|
2423
|
-
});
|
|
2424
|
-
let spy2 = vi.fn(() => {
|
|
2425
|
-
$state.b;
|
|
2426
|
-
});
|
|
2427
|
-
$run(spy1);
|
|
2428
|
-
$run(spy2);
|
|
2429
|
-
spy1.mockReset();
|
|
2430
|
-
spy2.mockReset();
|
|
2431
|
-
|
|
2432
|
-
expect(() =>
|
|
2433
|
-
$batch(() => {
|
|
2434
|
-
$state.a++;
|
|
2435
|
-
$state.b++;
|
|
2436
|
-
throw Error("hello");
|
|
2437
|
-
}),
|
|
2438
|
-
).toThrow("hello");
|
|
2439
|
-
|
|
2440
|
-
expect(spy1).toHaveBeenCalledOnce();
|
|
2441
|
-
expect(spy2).toHaveBeenCalledOnce();
|
|
2442
|
-
});
|
|
2443
|
-
|
|
2444
|
-
it("should run pending effects even if some effects throw", () => {
|
|
2445
|
-
let $state = $watch({ a: 0 });
|
|
2446
|
-
let spy1 = vi.fn(() => {
|
|
2447
|
-
$state.a;
|
|
2448
|
-
});
|
|
2449
|
-
let spy2 = vi.fn(() => {
|
|
2450
|
-
$state.a;
|
|
2451
|
-
});
|
|
2452
|
-
$run(() => {
|
|
2453
|
-
if ($state.a === 1) {
|
|
2454
|
-
throw new Error("hello");
|
|
2455
|
-
}
|
|
2456
|
-
});
|
|
2457
|
-
$run(spy1);
|
|
2458
|
-
$run(() => {
|
|
2459
|
-
if ($state.a === 1) {
|
|
2460
|
-
throw new Error("hello");
|
|
2461
|
-
}
|
|
2462
|
-
});
|
|
2463
|
-
$run(spy2);
|
|
2464
|
-
$run(() => {
|
|
2465
|
-
if ($state.a === 1) {
|
|
2466
|
-
throw new Error("hello");
|
|
2467
|
-
}
|
|
2468
|
-
});
|
|
2469
|
-
spy1.mockReset();
|
|
2470
|
-
spy2.mockReset();
|
|
2471
|
-
|
|
2472
|
-
expect(() =>
|
|
2473
|
-
$batch(() => {
|
|
2474
|
-
$state.a++;
|
|
2475
|
-
}),
|
|
2476
|
-
).toThrow("hello");
|
|
2477
|
-
|
|
2478
|
-
expect(spy1).toHaveBeenCalledOnce();
|
|
2479
|
-
expect(spy2).toHaveBeenCalledOnce();
|
|
2480
|
-
});
|
|
2481
|
-
|
|
2482
|
-
it("should run effect's first run immediately even inside a batch", () => {
|
|
2483
|
-
//let callCount = 0;
|
|
2484
|
-
let spy = vi.fn();
|
|
2485
|
-
$batch(() => {
|
|
2486
|
-
$run(spy);
|
|
2487
|
-
//callCount = spy.callCount;
|
|
2488
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
2489
|
-
});
|
|
2490
|
-
//expect(callCount).toBe(1);
|
|
2491
|
-
});
|
|
2492
|
-
});
|
|
2493
|
-
|
|
2494
|
-
describe("untracked ($peek)", () => {
|
|
2495
|
-
it("should block tracking inside effects", () => {
|
|
2496
|
-
let $state = $watch({ a: 1, b: 2 });
|
|
2497
|
-
let spy = vi.fn(() => {
|
|
2498
|
-
$state.a + $state.b;
|
|
2499
|
-
});
|
|
2500
|
-
$run(() => $peek(spy));
|
|
2501
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
2502
|
-
|
|
2503
|
-
$state.a = 10;
|
|
2504
|
-
$state.b = 20;
|
|
2505
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
2506
|
-
});
|
|
2507
|
-
|
|
2508
|
-
it("should block tracking even when run inside effect run inside untracked", () => {
|
|
2509
|
-
let $state = $watch({ s: 1 });
|
|
2510
|
-
let spy = vi.fn(() => $state.s);
|
|
2511
|
-
|
|
2512
|
-
$peek(() =>
|
|
2513
|
-
$run(() => {
|
|
2514
|
-
$peek(spy);
|
|
2515
|
-
}),
|
|
2516
|
-
);
|
|
2517
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
2518
|
-
|
|
2519
|
-
$state.s = 2;
|
|
2520
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
2521
|
-
});
|
|
2522
|
-
|
|
2523
|
-
it("should not cause signal assignments throw", () => {
|
|
2524
|
-
let $state = $watch({ a: 1, aChangedTime: 0 });
|
|
2525
|
-
|
|
2526
|
-
/*const dispose =*/ $run(() => {
|
|
2527
|
-
//dev.log("RUNNING");
|
|
2528
|
-
$state.a;
|
|
2529
|
-
$peek(() => {
|
|
2530
|
-
$state.aChangedTime = $state.aChangedTime + 1;
|
|
2531
|
-
});
|
|
2532
|
-
});
|
|
2533
|
-
expect(() => ($state.a = 2)).not.toThrow();
|
|
2534
|
-
expect($state.aChangedTime).toEqual(2);
|
|
2535
|
-
$state.a = 3;
|
|
2536
|
-
expect($state.aChangedTime).toEqual(3);
|
|
2537
|
-
|
|
2538
|
-
//dispose();
|
|
2539
|
-
});
|
|
2540
|
-
|
|
2541
|
-
it("should block tracking inside computed signals", () => {
|
|
2542
|
-
let spy = vi.fn(() => $state.a + $state.b);
|
|
2543
|
-
let $state = $watch({
|
|
2544
|
-
a: 1,
|
|
2545
|
-
b: 2,
|
|
2546
|
-
get c() {
|
|
2547
|
-
return $cache(() => $peek(spy));
|
|
2548
|
-
},
|
|
2549
|
-
});
|
|
2550
|
-
|
|
2551
|
-
expect(spy).not.toHaveBeenCalled();
|
|
2552
|
-
expect($state.c).toEqual(3);
|
|
2553
|
-
$state.a = 10;
|
|
2554
|
-
$state.c;
|
|
2555
|
-
$state.b = 20;
|
|
2556
|
-
$state.c;
|
|
2557
|
-
expect(spy).toHaveBeenCalledOnce();
|
|
2558
|
-
expect($state.c).toEqual(3);
|
|
2559
|
-
});
|
|
2560
|
-
});
|