@torpor/view 0.3.1 → 0.3.2
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/CHANGELOG.md +9 -0
- package/dist/compile.cjs +128 -76
- package/dist/compile.cjs.map +1 -1
- package/dist/compile.d.cts +6 -0
- package/dist/compile.d.cts.map +1 -1
- package/dist/compile.d.ts +6 -0
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +128 -76
- package/dist/compile.js.map +1 -1
- package/dist/formatText-B0FXBdFT.js.map +1 -1
- package/dist/formatText-DufG5l83.cjs.map +1 -1
- package/package.json +1 -1
- package/src/compile/build/client/buildAwaitNode.ts +15 -7
- package/src/compile/build/client/buildCode.ts +8 -1
- package/src/compile/build/client/buildIfNode.ts +11 -5
- package/src/compile/build/client/buildSwitchNode.ts +12 -5
- package/src/compile/buildType.ts +11 -12
- package/src/compile/parse/ParseComponentStatus.ts +6 -0
- package/src/compile/parse/parseCode.ts +61 -7
- package/src/compile/parse/parseTag.ts +7 -0
- package/src/types/TemplateComponent.ts +6 -0
- package/src/watch/checkEffect.ts +2 -0
- package/test/attributes/components/output/Attributes-client.ts +3 -0
- package/test/attributes/components/output/Attributes-types.ts +10 -0
- package/test/attributes/components/temp/{Attributes-client-9b2935d7824ba501776fdc6c48861422c15b6a12.ts → Attributes-client-ffbdd4d85a50436c1a51a4499921304098c1b396.ts} +3 -0
- package/test/attributes/components/temp/Attributes-types-5892927754ac19a8b3a8560fa1c78ce653e5f318.ts +10 -0
- package/test/attributes/errors.test.ts +35 -0
- package/test/await/components/output/Await-client.ts +12 -5
- package/test/await/components/output/Await-types.ts +10 -0
- package/test/await/components/temp/{Await-client-e969f4bd0712acf259ddfaa5a3b3448307201fd2.ts → Await-client-4d2c318baf00e6fb8fea11e34189817ca8002a1f.ts} +12 -5
- package/test/await/components/temp/Await-types-355b335acd1c17a2271920d51e542ce1fc61eeef.ts +10 -0
- package/test/bench/components/output/Bench-client.ts +3 -0
- package/test/bench/components/output/Bench-types.ts +10 -0
- package/test/bench/components/temp/{Bench-client-7f31596dafc8077370d8d90b1bb9b6e0208154e7.ts → Bench-client-33b5a23562f6a00687449c5ffe72dc42ac7f766e.ts} +3 -0
- package/test/bench/components/temp/Bench-types-a798f6c7b7ec235754ff5fdd5d7020633253b042.ts +10 -0
- package/test/bind/components/output/BindComponent-client.ts +5 -0
- package/test/bind/components/output/BindComponent-types.ts +10 -0
- package/test/bind/components/output/BindText-client.ts +3 -0
- package/test/bind/components/output/BindText-types.ts +10 -0
- package/test/bind/components/temp/{BindComponent-client-22eccb5354a2b0267841e015f3a2a0baf534bf89.ts → BindComponent-client-eb816edf9f83c19641ced9ecb1c2c5fc87e8e32c.ts} +5 -0
- package/test/bind/components/temp/BindComponent-types-8a10f6efddd92990ed5390f3c89ba17db179d801.ts +10 -0
- package/test/bind/components/temp/{BindText-client-7692ae1570533cc17e2186e9c7d4768529e4a2fe.ts → BindText-client-63e98b4407a8f0f22f4766d029567ac0aac7dba8.ts} +3 -0
- package/test/bind/components/temp/BindText-types-5892d9ef33c61a0de524b74323ba135accee8175.ts +10 -0
- package/test/build-server/components/output/IfNested-client.ts +17 -8
- package/test/build-server/components/output/IfNested-types.ts +10 -0
- package/test/build-server/components/temp/{IfNested-client-eefdd449fa700b2e7326bc72df8b32ddcadf9d21.ts → IfNested-client-2af78cceff5dbce510db31fd5b8bb4da5d30d53a.ts} +17 -8
- package/test/build-server/components/temp/IfNested-types-692d58ca98f3534102193a44aa358994f798ca7b.ts +10 -0
- package/test/buildOutputFiles.ts +16 -4
- package/test/child-component/components/output/ParentChild-client.ts +5 -0
- package/test/child-component/components/output/ParentChild-types.ts +10 -0
- package/test/child-component/components/temp/{ParentChild-client-2dfd600f7d409630d429a1d2d18c038bd08b08da.ts → ParentChild-client-93ca4d2ac521ef996a6548bfacb3e36f6f71fcf9.ts} +5 -0
- package/test/child-component/components/temp/ParentChild-types-4d26850ef18600f398f7aa9c4502071349bf5624.ts +10 -0
- package/test/class/components/output/Class-client.ts +5 -0
- package/test/class/components/output/Class-types.ts +10 -0
- package/test/class/components/temp/{Class-client-5af6a50cd454ae019b2aa79457ba7ead83b8c056.ts → Class-client-284ac46628b2d3d6b4a4edbdbfd1700626d3fed0.ts} +5 -0
- package/test/class/components/temp/Class-types-38567e85c9ec17739c7c97e12281fc1818267190.ts +10 -0
- package/test/component/components/output/Component-client.ts +3 -0
- package/test/component/components/output/Component-types.ts +10 -0
- package/test/component/components/output/Header-client.ts +3 -0
- package/test/component/components/output/Header-types.ts +10 -0
- package/test/component/components/temp/{Component-client-fdc327499be0a01f987d0f2897baf022a247c77c.ts → Component-client-3cb873dd1782874af78544c1d8886bbfa4bef11b.ts} +3 -0
- package/test/component/components/temp/Component-types-3ef4f140ba29c98357caf0f2618785437b5804de.ts +10 -0
- package/test/component/components/temp/{Header-client-6beb5770e68e6b19595e53e20bc906765fc6c260.ts → Header-client-cb780b85ee6e0587eca3d9ad7a8b8c947075e394.ts} +3 -0
- package/test/component/components/temp/Header-types-c56a108c6fb5a22b8ae156936bc05e58eef199c2.ts +10 -0
- package/test/console/components/output/Console-client.ts +3 -0
- package/test/console/components/output/Console-types.ts +10 -0
- package/test/console/components/temp/{Console-client-2b58290ac407ebbe89a0613d64eb9cd141b99887.ts → Console-client-b0feb868a912138e8af01bd06902d28c536ebb87.ts} +3 -0
- package/test/console/components/temp/Console-types-93ad3f25ddc6280fcff2cf4db7c2913d3a474912.ts +10 -0
- package/test/const/components/output/Const-client.ts +3 -0
- package/test/const/components/output/Const-types.ts +10 -0
- package/test/const/components/temp/{Const-client-d1037557e7ef75a8fe06f56816e65883047e9421.ts → Const-client-149dbc44ee609c54a99bacb715d04034a1d33c9c.ts} +3 -0
- package/test/const/components/temp/Const-types-afba269310bd143aa325752d3cc7e0c598fd0de2.ts +10 -0
- package/test/context/components/output/ChildA-client.ts +3 -0
- package/test/context/components/output/ChildA-types.ts +10 -0
- package/test/context/components/output/ChildB-client.ts +3 -0
- package/test/context/components/output/ChildB-types.ts +10 -0
- package/test/context/components/{temp/Parent-client-9898b2e521527c86d69905053b6727ea8fd28166.ts → output/Parent-client.ts} +3 -0
- package/test/context/components/output/Parent-types.ts +10 -0
- package/test/context/components/temp/{ChildA-client-9dea3e29ffcb82ca1779f6ff671e19b1c106fc4a.ts → ChildA-client-b9ad03bb0c64e9fb27a38b85792df79dc3ebf7f1.ts} +3 -0
- package/test/context/components/temp/ChildA-types-2ee15b25e68166d1574582f08e2280cbae948e5d.ts +10 -0
- package/test/context/components/temp/{ChildB-client-4b801099936c8aa013a1220f291375f67eba1acb.ts → ChildB-client-f4e1a447378a9a9be05aa37c8b3eae7ca6be8411.ts} +3 -0
- package/test/context/components/temp/ChildB-types-531f67cfda5bd04468e827c14f9358a431853fc5.ts +10 -0
- package/test/context/components/temp/Parent-client-2ecf387911773f5cd74c7bf1d04f98da08bc4450.ts +44 -0
- package/test/context/components/temp/Parent-types-e6be7d1cf118d7a8927af59db780010392966d01.ts +10 -0
- package/test/effects/components/output/For-client.ts +3 -0
- package/test/effects/components/output/For-types.ts +10 -0
- package/test/effects/components/output/If-client.ts +10 -4
- package/test/effects/components/output/If-types.ts +10 -0
- package/test/effects/components/output/NestedIf-client.ts +17 -8
- package/test/effects/components/output/NestedIf-types.ts +10 -0
- package/test/effects/components/temp/{For-client-7c7d7c0dba2547f816b9bd9c6a95d6873ec00ffd.ts → For-client-af16b99099e237c988932845b79500dfc28c6642.ts} +3 -0
- package/test/effects/components/temp/For-types-cfec41b41b054674bf8b01ce0e0003c8a6640a82.ts +10 -0
- package/test/effects/components/temp/{If-client-f0480a98f80b32612d12765c6838ff6db5982e82.ts → If-client-7f0b171f29a1f1ff969b21c33b241cd35eb1ce0e.ts} +10 -4
- package/test/effects/components/temp/If-types-7b245b6e531e122e0d0cfb72903bb88223b98793.ts +10 -0
- package/test/effects/components/temp/{NestedIf-client-702deffd158f219c5da4199b563a62cd54385a7f.ts → NestedIf-client-e2dd594c8f77f5ce53265b234e72b7c2f29ba76d.ts} +17 -8
- package/test/effects/components/temp/NestedIf-types-0912466d777f52f3616557823a7e47f5901cb755.ts +10 -0
- package/test/events/components/output/Increment-client.ts +3 -0
- package/test/events/components/output/Increment-types.ts +10 -0
- package/test/events/components/temp/{Increment-client-84c09711baf098c82ee226598ba7a36913616b75.ts → Increment-client-aeee696f3a4363c5c4c1ecf86de8ec071342ba22.ts} +3 -0
- package/test/events/components/temp/Increment-types-f259dd221aa967b0426746303f1f2c33aeeaf068.ts +10 -0
- package/test/for/components/output/For-client.ts +3 -0
- package/test/for/components/output/For-types.ts +10 -0
- package/test/for/components/output/ForEscape-client.ts +3 -0
- package/test/for/components/output/ForEscape-types.ts +10 -0
- package/test/for/components/output/ForIn-client.ts +3 -0
- package/test/for/components/output/ForIn-types.ts +10 -0
- package/test/for/components/output/ForOf-client.ts +3 -0
- package/test/for/components/output/ForOf-types.ts +10 -0
- package/test/for/components/temp/{For-client-2f6b4b81670b0ba31b01176b4f61ebf321e945bb.ts → For-client-bc23ebc49e3cf710762bce7cd1b73244c94a3abb.ts} +3 -0
- package/test/for/components/temp/For-types-8bcd17ab2e0faebb340a19f56e052cc94820a29a.ts +10 -0
- package/test/for/components/temp/{ForEscape-client-8d0fcc940851e687173b6a9129c3d83e0fc771ef.ts → ForEscape-client-a475ec9bdab5d57d30c27124fcf9ce38110ddf75.ts} +3 -0
- package/test/for/components/temp/ForEscape-types-bb4f3457b02c2ad97a7b6cbc66f9097a37728ed2.ts +10 -0
- package/test/for/components/temp/{ForIn-client-fa0614a1c7b8aa6e8819ed91a518479fd80453ae.ts → ForIn-client-890cee3ac35ede73eafad4e935eefd2fe7ecb9e2.ts} +3 -0
- package/test/for/components/temp/ForIn-types-fb4f7b02e23a40d27376760b7e1d06f8ecaa13ba.ts +10 -0
- package/test/for/components/temp/{ForOf-client-11006c4239d9018363e582dc5b54b50477d652e7.ts → ForOf-client-309297e25afd249f1a3e27126af23b7329c5c727.ts} +3 -0
- package/test/for/components/temp/ForOf-types-6e2fbcd0fbfd3c0a2c3d8c458fdda7b05c2a19b1.ts +10 -0
- package/test/function/components/output/Function-client.ts +3 -0
- package/test/function/components/output/Function-types.ts +10 -0
- package/test/function/components/temp/{Function-client-ec5fe7d599d6099bdfab78c2a0c8edf77a23cd9b.ts → Function-client-8423f53837e6503cdcc0d997684dd3e208b5dd13.ts} +3 -0
- package/test/function/components/temp/Function-types-5479cb46b9bef3251b7961fb6e99a8c30cd4220f.ts +10 -0
- package/test/html/components/output/Html-client.ts +3 -0
- package/test/html/components/output/Html-types.ts +10 -0
- package/test/html/components/temp/{Html-client-82ff34dcdcbdf4be1112bcb1baac8027cdc32de7.ts → Html-client-83b1a1be5c4b8e9cc06a616acf8418c786804255.ts} +3 -0
- package/test/html/components/temp/Html-types-c5dc816f932e3fb021c006f266a7c9a2f2fb5353.ts +10 -0
- package/test/if/components/IfCache.torp +14 -0
- package/test/if/components/output/IfAfterIf-client.ts +17 -8
- package/test/if/components/output/IfAfterIf-types.ts +10 -0
- package/test/if/components/output/IfCache-client.ts +70 -0
- package/test/if/components/output/IfCache-server.ts +22 -0
- package/test/if/components/output/IfCache-types.ts +10 -0
- package/test/if/components/output/IfElse-client.ts +10 -4
- package/test/if/components/output/IfElse-types.ts +10 -0
- package/test/if/components/output/IfElseIf-client.ts +12 -5
- package/test/if/components/output/IfElseIf-types.ts +10 -0
- package/test/if/components/output/IfFalse-client.ts +10 -4
- package/test/if/components/output/IfFalse-types.ts +10 -0
- package/test/if/components/output/IfNested-client.ts +17 -8
- package/test/if/components/output/IfNested-types.ts +10 -0
- package/test/if/components/temp/{IfAfterIf-client-c1cfd21a6ace4945703ba8f46aada923a60265d9.ts → IfAfterIf-client-5aa5aac7099224e0ec1e8bff6162d729f89267ec.ts} +17 -8
- package/test/if/components/temp/IfAfterIf-types-c4bd4f93c103a618889f40c77d55fa7de454f70b.ts +10 -0
- package/test/if/components/temp/IfCache-client-8433b3b239bc225d616f12e8904c4f2ba530efb4.ts +70 -0
- package/test/if/components/temp/IfCache-server-8b35e6a2009d72083013cfb01b187a1d027fdcc9.ts +22 -0
- package/test/if/components/temp/IfCache-types-02f467ce9ebc23ae68c9e5f33c90ecc96b666452.ts +10 -0
- package/test/if/components/temp/{IfElse-client-06dfcacd3a5225dcb0947587bcd4fae9ec3d3c1e.ts → IfElse-client-8bd2aa123e050847fdf28172479f0cc1a3ddb01c.ts} +10 -4
- package/test/if/components/temp/IfElse-types-e81080227f8f69ac1d81141d97a07e0a0e9391c1.ts +10 -0
- package/test/if/components/temp/{IfElseIf-client-26df9a728c9cb712d5ac0235b4c99885f25545b8.ts → IfElseIf-client-a17e2408252495ef0e90ba303a2d9e076867b6fd.ts} +12 -5
- package/test/if/components/temp/IfElseIf-types-a492d2b6e8517f598befca7127cd514244239984.ts +10 -0
- package/test/if/components/temp/{IfFalse-client-de6fc8e9eb222153608490e6d172e9aae9000aa1.ts → IfFalse-client-00a24a722347d2c711064dd504db9443747e5099.ts} +10 -4
- package/test/if/components/temp/IfFalse-types-1d512c6d82e2af9efe0221a9929b05ad62fd97fb.ts +10 -0
- package/test/if/components/temp/{IfNested-client-eefdd449fa700b2e7326bc72df8b32ddcadf9d21.ts → IfNested-client-2af78cceff5dbce510db31fd5b8bb4da5d30d53a.ts} +17 -8
- package/test/if/components/temp/IfNested-types-692d58ca98f3534102193a44aa358994f798ca7b.ts +10 -0
- package/test/if/if-cache.test.ts +68 -0
- package/test/mount/components/output/Mount-client.ts +3 -0
- package/test/mount/components/output/Mount-types.ts +10 -0
- package/test/mount/components/temp/{Mount-client-29896228d7d0ef3692a9d13065c1bbfbe3198cdc.ts → Mount-client-f4dd3d5a21d287d3d22a797805816fe09528dfb6.ts} +3 -0
- package/test/mount/components/temp/Mount-types-2d88616243f860d43b8b7d74a6bbeff9b2c6f27b.ts +10 -0
- package/test/on-mount/components/output/OnMount-client.ts +3 -0
- package/test/on-mount/components/output/OnMount-types.ts +10 -0
- package/test/on-mount/components/temp/{OnMount-client-038f8c6bbcf0278406909d6ba5394f311924fda9.ts → OnMount-client-8afb8473b51815e9b0ba994f3476217506b41b1d.ts} +3 -0
- package/test/on-mount/components/temp/OnMount-types-d0f834addb351520cc75a589cb9ec5b6a5a787b4.ts +10 -0
- package/test/party/components/output/AnswerButton-client.ts +3 -0
- package/test/party/components/output/AnswerButton-types.ts +10 -0
- package/test/party/components/output/AnswerButtonApp-client.ts +3 -0
- package/test/party/components/output/AnswerButtonApp-types.ts +10 -0
- package/test/party/components/output/ColorSelect-client.ts +3 -0
- package/test/party/components/output/ColorSelect-types.ts +10 -0
- package/test/party/components/output/Colors-client.ts +3 -0
- package/test/party/components/output/Colors-types.ts +10 -0
- package/test/party/components/output/Counter-client.ts +3 -0
- package/test/party/components/output/Counter-types.ts +10 -0
- package/test/party/components/output/CssStyle-client.ts +3 -0
- package/test/party/components/output/CssStyle-types.ts +10 -0
- package/test/party/components/output/DoubleCount-client.ts +3 -0
- package/test/party/components/output/DoubleCount-types.ts +10 -0
- package/test/party/components/output/FunnyButton-client.ts +3 -0
- package/test/party/components/output/FunnyButton-types.ts +10 -0
- package/test/party/components/output/FunnyButtonApp-client.ts +3 -0
- package/test/party/components/output/FunnyButtonApp-types.ts +10 -0
- package/test/party/components/output/HelloWorld-client.ts +3 -0
- package/test/party/components/output/HelloWorld-types.ts +10 -0
- package/test/party/components/output/InputFocused-client.ts +3 -0
- package/test/party/components/output/InputFocused-types.ts +10 -0
- package/test/party/components/output/InputHello-client.ts +3 -0
- package/test/party/components/output/InputHello-types.ts +10 -0
- package/test/party/components/output/IsAvailable-client.ts +3 -0
- package/test/party/components/output/IsAvailable-types.ts +10 -0
- package/test/party/components/output/Name-client.ts +3 -0
- package/test/party/components/output/Name-types.ts +10 -0
- package/test/party/components/output/NameUpdate-client.ts +3 -0
- package/test/party/components/output/NameUpdate-types.ts +10 -0
- package/test/party/components/output/PageTitle-client.ts +3 -0
- package/test/party/components/output/PageTitle-types.ts +10 -0
- package/test/party/components/output/PickPill-client.ts +3 -0
- package/test/party/components/output/PickPill-types.ts +10 -0
- package/test/party/components/output/Time-client.ts +3 -0
- package/test/party/components/output/Time-types.ts +10 -0
- package/test/party/components/output/TrafficLight-client.ts +14 -6
- package/test/party/components/output/TrafficLight-types.ts +10 -0
- package/test/party/components/output/UserProfile-client.ts +3 -0
- package/test/party/components/output/UserProfile-types.ts +15 -0
- package/test/party/components/output/UserProfileApp-client.ts +3 -0
- package/test/party/components/output/UserProfileApp-types.ts +10 -0
- package/test/party/components/output/UserProfileContext-client.ts +3 -0
- package/test/party/components/output/UserProfileContext-types.ts +10 -0
- package/test/party/components/output/UserProfileContextApp-client.ts +3 -0
- package/test/party/components/output/UserProfileContextApp-types.ts +10 -0
- package/test/party/components/temp/{AnswerButton-client-df895c3e7a88fd7ede9f951fc9de2ed75c27a5cb.ts → AnswerButton-client-2119fa9523949bca3e8ef264eff7e72611d70bac.ts} +3 -0
- package/test/party/components/temp/AnswerButton-types-7dc4d046e52be1e6cb46d6235ce7540bd3e7b2a5.ts +10 -0
- package/test/party/components/temp/{AnswerButtonApp-client-4c05ef36b1c0e93370fb463643419928717fa701.ts → AnswerButtonApp-client-87979b0578066e637c4257d6a7dbc2bfa1542515.ts} +3 -0
- package/test/party/components/temp/AnswerButtonApp-types-10a6f55029e859366f9a3a73cdcdb3f63e89dbeb.ts +10 -0
- package/test/party/components/temp/{ColorSelect-client-5db8d1b0924361fdb5efb867c14491402ec9668c.ts → ColorSelect-client-d7eb9276031b613439d7bd6212c76b4a972ebcad.ts} +3 -0
- package/test/party/components/temp/ColorSelect-types-e652a36ebdd98e8c23a8de3156c4499023f09301.ts +10 -0
- package/test/party/components/temp/{Colors-client-6d3ac693e85bdda50b8742282915997063a32769.ts → Colors-client-42c890154b9a132ebd784cccc4f4f9962f400b3e.ts} +3 -0
- package/test/party/components/temp/Colors-types-075975e9b9074b49f96f99d660f0ee580546a630.ts +10 -0
- package/test/party/components/temp/{Counter-client-0c604a107c5b84cdbf725f307dfe29d34f8a2cc8.ts → Counter-client-ad5e891eaea79548afabef156b87fee5317319b2.ts} +3 -0
- package/test/party/components/temp/Counter-types-206b0704ee2e25f5f3198d716fa524295581c075.ts +10 -0
- package/test/party/components/temp/{CssStyle-client-2a642d115ad52539f97c051c34687b8d6d12b324.ts → CssStyle-client-5078b4c735f6273e2565c7d7688c41afa026a2c3.ts} +3 -0
- package/test/party/components/temp/CssStyle-types-f1ce4f0b03d404c70704f271ce9bfc5d5107346c.ts +10 -0
- package/test/party/components/temp/{DoubleCount-client-8c85c3af12c471ea23bb702bbf5a3e240420f3ec.ts → DoubleCount-client-9406fd993ae8d0efa1f87848ae6e952591b20c3d.ts} +3 -0
- package/test/party/components/temp/DoubleCount-types-436bd75fe7808c3a30389aeb1740aea361aa8681.ts +10 -0
- package/test/party/components/temp/{FunnyButton-client-850dd3da0fa803c1bce5c53e88fcd2d48d279eb8.ts → FunnyButton-client-f8dea087fd6e3f2d7d0697cd3c87444c6866daf5.ts} +3 -0
- package/test/party/components/temp/FunnyButton-types-7780d5c5dfe3ff2369f8e3c505616036cfcd3759.ts +10 -0
- package/test/party/components/temp/{FunnyButtonApp-client-00300846d11a3d0a5a620c2ade87b935b7f0ebf8.ts → FunnyButtonApp-client-22aa2ee00b25a3ee0bda442372da843828231242.ts} +3 -0
- package/test/party/components/temp/FunnyButtonApp-types-ea73d641565a4478759166f462206dd97c92cedd.ts +10 -0
- package/test/party/components/temp/{HelloWorld-client-890b311ad9a3919379acdc1d52807ea36cc9f489.ts → HelloWorld-client-84fa7bd70d75149892044f4a15fdbf9ac8c7fcff.ts} +3 -0
- package/test/party/components/temp/HelloWorld-types-3c153ac7af343dbce6cb081f1ae1b4f85d7f0b10.ts +10 -0
- package/test/party/components/temp/{InputFocused-client-03527f9ceb52f66ac53887dbc884a0aa83bb7a23.ts → InputFocused-client-504b10731a6c96079a0abd7bb4a8381634ff4a0d.ts} +3 -0
- package/test/party/components/temp/InputFocused-types-33da14c13216ca00edaa8f02508db21f5cd32d31.ts +10 -0
- package/test/party/components/temp/{InputHello-client-f65a477624975b68b7aaa3614fbf198d4476480f.ts → InputHello-client-b9dd846c4cc129749781955f645327cc3c0956ac.ts} +3 -0
- package/test/party/components/temp/InputHello-types-ab629048402441fde9a292bc2d376c0deea482a8.ts +10 -0
- package/test/party/components/temp/{IsAvailable-client-8767437fd92cf79713de5b00828e1502e38d79e3.ts → IsAvailable-client-3bd6d53a45c3dcda3e958bb4b5000fef78301b04.ts} +3 -0
- package/test/party/components/temp/IsAvailable-types-23d4e196c659901c347a7b3e5c9e4a6668234adb.ts +10 -0
- package/test/party/components/temp/{Name-client-08903a8df8bdff5288170d3c89658192956587a9.ts → Name-client-b2cd160fc076bb34c0421a673358e7b7f61e4b49.ts} +3 -0
- package/test/party/components/temp/Name-types-06f89338c785a1fd352ed7de3ebe02b30722760d.ts +10 -0
- package/test/party/components/temp/{NameUpdate-client-d65b2476c3721d2efddf9385a61433e2a2dd0d72.ts → NameUpdate-client-f2dfcab63d80c25681aa6b15a61c547a0aab2f96.ts} +3 -0
- package/test/party/components/temp/NameUpdate-types-9c69805006d2d3bb457c5d4d87db8baeb431aeb6.ts +10 -0
- package/test/party/components/temp/{PageTitle-client-c006df9a3e662488a1db089de53fd485c6b923e4.ts → PageTitle-client-f4094f4b23126a99a211f804ed7c4a97a34733b3.ts} +3 -0
- package/test/party/components/temp/PageTitle-types-dfb55ea9b607c89167dbd7538523a484a6eec300.ts +10 -0
- package/test/party/components/temp/{PickPill-client-af8357daf3f6633c7f451d0bddd72fefe786d5c3.ts → PickPill-client-0a4e095bc2c963a2f091ae2f69c8d075f7d9b5a5.ts} +3 -0
- package/test/party/components/temp/PickPill-types-526e2bb4c36ec1bed87eaf5722093a0eaefcd9d3.ts +10 -0
- package/test/party/components/temp/{Time-client-94380d45de7275a5cec98e5f58c15b74b13e9c3e.ts → Time-client-95ee134377911d1c1cddbf074b8f943cdcf2a966.ts} +3 -0
- package/test/party/components/temp/Time-types-2bf6facfbb2d6e7de472d18760029afaefbb93e1.ts +10 -0
- package/test/party/components/temp/{TrafficLight-client-12b20962b4146ef08fe0c37597441533c7699408.ts → TrafficLight-client-dc0248dc967afbbbce4873cd37677cd97cc4933c.ts} +14 -6
- package/test/party/components/temp/TrafficLight-types-d301a2317da01a215fc8e5222dc6ff87226fa250.ts +10 -0
- package/test/party/components/temp/{UserProfile-client-e5330b2c96bd8b225cb6291bc8b1d9f35c93307e.ts → UserProfile-client-352291dcaf115cc563ae3a07ec6aed901fcc2bc1.ts} +3 -0
- package/test/party/components/temp/UserProfile-types-412089462c8dcc757d2f53e7ff8030296d3100c2.ts +15 -0
- package/test/party/components/temp/{UserProfileApp-client-4c86e4f9a0d042f4f4811868f0146e872b17353c.ts → UserProfileApp-client-18ad0243fd853dac3c3f71bea21b021bbd5b35f4.ts} +3 -0
- package/test/party/components/temp/UserProfileApp-types-3e70c106e03c68b4aa06c2fe21dfeceffe7cc313.ts +10 -0
- package/test/party/components/temp/{UserProfileContext-client-424131db3cc89ae4babe127b9108ffc5696c9e1d.ts → UserProfileContext-client-a3f521facb10ae64007c362e34bce41d8144bf96.ts} +3 -0
- package/test/party/components/temp/UserProfileContext-types-076b9fa0a87d3ca098884a003284050b36172cc6.ts +10 -0
- package/test/party/components/temp/{UserProfileContextApp-client-5f94a7ccf3e4542ea40d8046ad75eeb21005c55f.ts → UserProfileContextApp-client-cccb3b8e819279cd7f729af61b84ad9801213597.ts} +3 -0
- package/test/party/components/temp/UserProfileContextApp-types-d04199ab7d43ecc12ceccb7a0bef7ff38ac1e8b1.ts +10 -0
- package/test/props/components/output/Reactive-client.ts +5 -0
- package/test/props/components/output/Reactive-types.ts +10 -0
- package/test/props/components/temp/{Reactive-client-9bc3643675fc563f96efb00bc3c4b843ba4b7f2e.ts → Reactive-client-644526502a3c5db2be797056d127a124f76976d5.ts} +5 -0
- package/test/props/components/temp/Reactive-types-bd642939107f1be06666bfce1ad97a94ccc21ee1.ts +10 -0
- package/test/replace/components/output/Replace-client.ts +3 -0
- package/test/replace/components/output/Replace-types.ts +10 -0
- package/test/replace/components/temp/{Replace-client-6f21ff3eb303bd5488d211087dc35fcf998d4e2a.ts → Replace-client-b80bc4591f8638cf125e8de9c1b25ea840dc75e9.ts} +3 -0
- package/test/replace/components/temp/Replace-types-9aedaa79e9b616ea1780ea97306f3428faa5d477.ts +10 -0
- package/test/slots/components/output/Article-client.ts +3 -0
- package/test/slots/components/output/Article-types.ts +10 -0
- package/test/slots/components/output/Basic-client.ts +3 -0
- package/test/slots/components/output/Basic-types.ts +10 -0
- package/test/slots/components/output/Header-client.ts +3 -0
- package/test/slots/components/output/Header-types.ts +10 -0
- package/test/slots/components/output/Let-client.ts +3 -0
- package/test/slots/components/output/Let-types.ts +10 -0
- package/test/slots/components/output/List-client.ts +3 -0
- package/test/slots/components/output/List-types.ts +10 -0
- package/test/slots/components/output/Named-client.ts +3 -0
- package/test/slots/components/output/Named-types.ts +10 -0
- package/test/slots/components/output/Unused-client.ts +3 -0
- package/test/slots/components/output/Unused-types.ts +10 -0
- package/test/slots/components/temp/{Article-client-0b674ee98ae7f85021bfb8b912f28e3c4b35e877.ts → Article-client-df86e549f8681f2329bffb4bc6bdf8ef60659d82.ts} +3 -0
- package/test/slots/components/temp/Article-types-d3d960fbab7644ec2d90dfe39d908fbb65abaaa2.ts +10 -0
- package/test/slots/components/temp/{Basic-client-196f7f0244dca0baeffb547eec55c089a108283d.ts → Basic-client-5bf137a656d5bc8739443df8e6876ac6ffdaeddd.ts} +3 -0
- package/test/slots/components/temp/Basic-types-709765786c453e34088db3e894a59fb3332d3ed1.ts +10 -0
- package/test/slots/components/temp/{Header-client-e5c784d60469523803898ee4d8b85fb82a7b7c0b.ts → Header-client-89439803e4de9b44da53fc051088ded2b4816a83.ts} +3 -0
- package/test/slots/components/temp/Header-types-c56a108c6fb5a22b8ae156936bc05e58eef199c2.ts +10 -0
- package/test/slots/components/temp/{Let-client-645271fcd63cd500001c75740b22b1b387330657.ts → Let-client-1e404c72bae5fe99bdced72d497dc3700d001112.ts} +3 -0
- package/test/slots/components/temp/Let-types-3d05614de77a23df63a3cc1873b27ce1b0148c58.ts +10 -0
- package/test/slots/components/temp/{List-client-ee6047ac396dc0b6fce5e38af51c38093fae83a2.ts → List-client-73ebb1a2d1364d807ca67c2b3008efb73e5bc74f.ts} +3 -0
- package/test/slots/components/temp/List-types-fd59ad7d85c06e67ee766a2cf14a637dd129569e.ts +10 -0
- package/test/slots/components/temp/{Named-client-559988562c5de1ae6017d2ad6de063f4363064b6.ts → Named-client-fae857376ae748995be367ea0b78c86cb778dcee.ts} +3 -0
- package/test/slots/components/temp/Named-types-ed10fb6338eb9bd67281b9658bd7b10b572d346a.ts +10 -0
- package/test/slots/components/temp/{Unused-client-52d1828bd28ebf7046a2e948a369563c0ea83b98.ts → Unused-client-715ddd9fa963f8185b11dd3725849dddc9b4a8e0.ts} +3 -0
- package/test/slots/components/temp/Unused-types-88f7e38611b4cae1067969cf702cde41422837ae.ts +10 -0
- package/test/source-maps/components/output/Source-client.ts +10 -4
- package/test/source-maps/components/output/Source-types.ts +10 -0
- package/test/source-maps/components/temp/{Source-client-ae8c4811ff658c13ee8c9b9e0e53fff1b83b178b.ts → Source-client-ea4254d629d7270203bf98ffae915e9b753a2fe2.ts} +10 -4
- package/test/source-maps/components/temp/Source-types-69770c124317e0a0fd6aeb3d4f331b50231452fa.ts +10 -0
- package/test/special-component/components/output/BigTitle-client.ts +3 -0
- package/test/special-component/components/output/BigTitle-types.ts +10 -0
- package/test/special-component/components/output/Component-client.ts +3 -0
- package/test/special-component/components/output/Component-types.ts +10 -0
- package/test/special-component/components/output/SmallTitle-client.ts +3 -0
- package/test/special-component/components/output/SmallTitle-types.ts +10 -0
- package/test/special-component/components/temp/{BigTitle-client-cb3055f809aaf17bd1fa82748d039ac3730a8d44.ts → BigTitle-client-d46e785f86a5daee62360043056359ca3e1cb7a0.ts} +3 -0
- package/test/special-component/components/temp/BigTitle-types-cb6363da78f853772d3408240f32030d5e826859.ts +10 -0
- package/test/special-component/components/temp/{Component-client-0eb9553b52acce2dfa564242295a4c57a38bd540.ts → Component-client-bd3af877909777431434a02fb77e751980a0b822.ts} +3 -0
- package/test/special-component/components/temp/Component-types-196e5e5c55f61a9d24837f8de1fb9e9eeb2dd3f1.ts +10 -0
- package/test/special-component/components/temp/{SmallTitle-client-5a65b233be29395e9650f57d9708a33de1279af3.ts → SmallTitle-client-28035d0154e3af173e9e3a1921be3a358e236cc5.ts} +3 -0
- package/test/special-component/components/temp/SmallTitle-types-629b435eb6f9a402ff576511db3e1d150f8c612b.ts +10 -0
- package/test/special-element/components/output/Element-client.ts +3 -0
- package/test/special-element/components/output/Element-types.ts +10 -0
- package/test/special-element/components/temp/{Element-client-745e610fbd5c652d327c8ac349d49d5ee4c8d9ea.ts → Element-client-83bfbaab3d8c85cce6b97675d8955e03ae99ba24.ts} +3 -0
- package/test/special-element/components/temp/Element-types-478aac6fcc8cc71dc587b534bb45ddcde069e2cb.ts +10 -0
- package/test/special-head/components/output/Head-client.ts +3 -0
- package/test/special-head/components/output/Head-types.ts +10 -0
- package/test/special-head/components/temp/{Head-client-bbbb5e712247ee41ca65a7ffd457987de5e99b3e.ts → Head-client-9e828c39f1930711e6c7db1d318b63f195e01e92.ts} +3 -0
- package/test/special-head/components/temp/Head-types-88772e6c9aefe7f65c342350ad45b29e7fa16604.ts +10 -0
- package/test/special-self/components/output/Self-client.ts +10 -4
- package/test/special-self/components/output/Self-types.ts +10 -0
- package/test/special-self/components/temp/{Self-client-dfe57df69e3677e94f7b5f3657c82602054ef19e.ts → Self-client-6846c5e6cdac15947ab4361f2e2b4ec900abd988.ts} +10 -4
- package/test/special-self/components/temp/Self-types-d438955d6f42951942dfa72ec1b79ad4ee95e966.ts +10 -0
- package/test/style/components/output/Style-client.ts +3 -0
- package/test/style/components/output/Style-types.ts +10 -0
- package/test/style/components/temp/{Style-client-9491a5aff97f118df542f976d7f7a21e7cc88c62.ts → Style-client-710dc4eba0e6a6ecbee26adc0d739ffdfb73ef10.ts} +3 -0
- package/test/style/components/temp/Style-types-d7ced2961f74be74eebaedfb98c492c6789d3cb8.ts +10 -0
- package/test/svg/components/output/Shape-client.ts +10 -4
- package/test/svg/components/output/Shape-types.ts +10 -0
- package/test/svg/components/temp/{Shape-client-4cc148d8b70d3750d2982360aad76b74d194b60e.ts → Shape-client-691decdc6064d94b0951c7a08da10feebd087324.ts} +10 -4
- package/test/svg/components/temp/Shape-types-70f9e311a005452b58286636c0dcb67a73e9fab4.ts +10 -0
- package/test/switch/components/Switch.torp +6 -4
- package/test/switch/components/output/Switch-client.ts +18 -9
- package/test/switch/components/output/Switch-server.ts +6 -4
- package/test/switch/components/output/Switch-types.ts +18 -0
- package/test/switch/components/temp/{Switch-client-5fc00f4d41300dc7587b113d8e53a102beca7558.ts → Switch-client-dcb3511bb3db12ad47e2237afc32a788184ad566.ts} +18 -9
- package/test/switch/components/temp/{Switch-server-440f7e852145b79656c0023ddc776e4d1d077d2a.ts → Switch-server-bbb3b40226e88388eb6f016cb0fd4be54f6139e7.ts} +6 -4
- package/test/switch/components/temp/Switch-types-fad2e2b194747eb6c06474c81de5f814c15e06aa.ts +18 -0
- package/test/text/components/output/Text-client.ts +3 -0
- package/test/text/components/output/Text-types.ts +16 -0
- package/test/text/components/temp/{Text-client-6c3be8a1a31a13eff86ce8b5330829cd15b07fab.ts → Text-client-e05d0c431475bf49349b4f6c162c9e78e0577b10.ts} +3 -0
- package/test/text/components/temp/Text-types-f9e6d77cf5a6def5aff78be41ebca3e8e6a54278.ts +16 -0
- package/test/watch-array/components/output/Array-client.ts +3 -0
- package/test/watch-array/components/output/Array-types.ts +10 -0
- package/test/watch-array/components/output/ArrayEntries-client.ts +3 -0
- package/test/watch-array/components/output/ArrayEntries-types.ts +10 -0
- package/test/watch-array/components/output/ArrayIndexes-client.ts +3 -0
- package/test/watch-array/components/output/ArrayIndexes-types.ts +10 -0
- package/test/watch-array/components/output/ArrayUnkeyed-client.ts +3 -0
- package/test/watch-array/components/output/ArrayUnkeyed-types.ts +10 -0
- package/test/watch-array/components/temp/{Array-client-552f81452d33fe6dc715c9f6bb7986f06475d761.ts → Array-client-3110972e940a678cc26316f5f38b9315a27559ee.ts} +3 -0
- package/test/watch-array/components/temp/Array-types-4afcc38999fa0a5d5b28b8c54ea8f25659d91165.ts +10 -0
- package/test/watch-array/components/temp/{ArrayEntries-client-736755fba2492e74812ff9c905202810de54e15a.ts → ArrayEntries-client-7f1e7bf740768a929f21e62f6b8ee31db8a50918.ts} +3 -0
- package/test/watch-array/components/temp/ArrayEntries-types-ae83cd05c68e5e6b7e8d31212035c14ec9ea6b85.ts +10 -0
- package/test/watch-array/components/temp/{ArrayIndexes-client-a496328fa92ffca676ab8893013a0cfec1734ad1.ts → ArrayIndexes-client-9861162934f1d779326d4d268cd95d765155a085.ts} +3 -0
- package/test/watch-array/components/temp/ArrayIndexes-types-5f02ec73d46553fd5730abfe022dba9a76a341f7.ts +10 -0
- package/test/watch-array/components/temp/{ArrayUnkeyed-client-5a2c5cb1fecba52653f7f35cfd07627682930c15.ts → ArrayUnkeyed-client-4ae3d9a74e763f8879458012de2a3c3837956c99.ts} +3 -0
- package/test/watch-array/components/temp/ArrayUnkeyed-types-6f544a6b354c46913b9ee0e843d0a6482af2745d.ts +10 -0
- package/test/watch-object/components/output/Watched-client.ts +3 -0
- package/test/watch-object/components/output/Watched-types.ts +10 -0
- package/test/watch-object/components/temp/{Watched-client-1f0409aa6e2c425d0319a23caec7d10ad313d579.ts → Watched-client-a7ddca317e29ef12d882d90e7b043d9c99a5f355.ts} +3 -0
- package/test/watch-object/components/temp/Watched-types-70c7bde732f624bfbb8e353bf9d1be8dbaea63e1.ts +10 -0
- package/test/attributes/components/Attributes.d.ts +0 -18
- package/test/await/components/Await.d.ts +0 -18
- package/test/bench/components/Bench.d.ts +0 -18
- package/test/bind/components/BindText.d.ts +0 -18
- package/test/child-component/components/ParentChild.d.ts +0 -34
- package/test/class/components/Class.d.ts +0 -18
- package/test/component/components/Component.d.ts +0 -18
- package/test/component/components/Header.d.ts +0 -18
- package/test/console/components/Console.d.ts +0 -18
- package/test/const/components/Const.d.ts +0 -18
- package/test/effects/components/For.d.ts +0 -18
- package/test/effects/components/If.d.ts +0 -18
- package/test/effects/components/NestedIf.d.ts +0 -18
- package/test/events/components/Increment.d.ts +0 -18
- package/test/for/components/For.d.ts +0 -18
- package/test/for/components/ForEscape.d.ts +0 -18
- package/test/for/components/ForIn.d.ts +0 -18
- package/test/for/components/ForOf.d.ts +0 -18
- package/test/function/components/Function.d.ts +0 -18
- package/test/html/components/Html.d.ts +0 -18
- package/test/if/components/IfAfterIf.d.ts +0 -18
- package/test/if/components/IfElse.d.ts +0 -18
- package/test/if/components/IfElseIf.d.ts +0 -18
- package/test/if/components/IfNested.d.ts +0 -18
- package/test/mount/components/Mount.d.ts +0 -18
- package/test/on-mount/components/OnMount.d.ts +0 -18
- package/test/party/components/AnswerButton.d.ts +0 -18
- package/test/party/components/AnswerButtonApp.d.ts +0 -18
- package/test/party/components/ColorSelect.d.ts +0 -18
- package/test/party/components/Colors.d.ts +0 -18
- package/test/party/components/Counter.d.ts +0 -18
- package/test/party/components/CssStyle.d.ts +0 -18
- package/test/party/components/DoubleCount.d.ts +0 -18
- package/test/party/components/FunnyButton.d.ts +0 -18
- package/test/party/components/FunnyButtonApp.d.ts +0 -18
- package/test/party/components/HelloWorld.d.ts +0 -18
- package/test/party/components/InputFocused.d.ts +0 -18
- package/test/party/components/InputHello.d.ts +0 -18
- package/test/party/components/IsAvailable.d.ts +0 -18
- package/test/party/components/Name.d.ts +0 -18
- package/test/party/components/NameUpdate.d.ts +0 -18
- package/test/party/components/PageTitle.d.ts +0 -18
- package/test/party/components/PickPill.d.ts +0 -18
- package/test/party/components/Time.d.ts +0 -18
- package/test/party/components/TrafficLight.d.ts +0 -18
- package/test/party/components/UserProfile.d.ts +0 -23
- package/test/party/components/UserProfileApp.d.ts +0 -18
- package/test/party/components/UserProfileContext.d.ts +0 -18
- package/test/party/components/UserProfileContextApp.d.ts +0 -18
- package/test/replace/components/Replace.d.ts +0 -18
- package/test/slots/components/Article.d.ts +0 -18
- package/test/slots/components/Basic.d.ts +0 -18
- package/test/slots/components/Header.d.ts +0 -18
- package/test/slots/components/Let.d.ts +0 -18
- package/test/slots/components/List.d.ts +0 -18
- package/test/slots/components/Named.d.ts +0 -18
- package/test/slots/components/Unused.d.ts +0 -18
- package/test/special-component/components/BigTitle.d.ts +0 -18
- package/test/special-component/components/Component.d.ts +0 -18
- package/test/special-component/components/SmallTitle.d.ts +0 -18
- package/test/special-element/components/Element.d.ts +0 -18
- package/test/special-head/components/Head.d.ts +0 -18
- package/test/special-self/components/Self.d.ts +0 -18
- package/test/style/components/Style.d.ts +0 -18
- package/test/svg/components/Shape.d.ts +0 -18
- package/test/switch/components/Switch.d.ts +0 -21
- package/test/text/components/Text.d.ts +0 -21
- package/test/watch-array/components/Array.d.ts +0 -18
- package/test/watch-array/components/ArrayEntries.d.ts +0 -18
- package/test/watch-array/components/ArrayIndexes.d.ts +0 -18
- package/test/watch-array/components/ArrayUnkeyed.d.ts +0 -18
- package/test/watch-object/components/Watched.d.ts +0 -18
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatText-B0FXBdFT.js","names":["context: Context","previousSub: Subscription | null","clearSub: Subscription | null","sourceSub: Subscription | null","context","sub: Subscription | null","lastSub: Subscription | null","nextSub: Subscription | null","context","targetSub: Subscription | null","sourceSub: Subscription | null","context","effectToClean: Effect | null","context","nextEffect: Effect","context","previousSub: Subscription | null","clearSub: Subscription | null","error: any","effect: Effect | null","context","signal: ProxySignal | null","context","context","context","computed: Computed","context","classes: string[]","styles: string[]"],"sources":["../src/render/context.ts","../src/types/constants.ts","../src/watch/clearSources.ts","../src/watch/deactivateSources.ts","../src/watch/trackEffect.ts","../src/watch/runComputed.ts","../src/watch/checkComputed.ts","../src/watch/checkSources.ts","../src/watch/runCleanups.ts","../src/watch/batchStart.ts","../src/watch/runEffect.ts","../src/watch/checkEffect.ts","../src/watch/clearTargets.ts","../src/watch/triggerEffects.ts","../src/watch/batchEnd.ts","../src/render/$batch.ts","../src/render/$cache.ts","../src/render/$peek.ts","../src/render/buildClasses.ts","../src/render/buildStyles.ts","../src/render/formatText.ts"],"sourcesContent":["import type Context from \"../types/Context\";\n\nconst context: Context = {\n\tactiveTarget: null,\n\tpreviousEffect: null,\n\textent: 0,\n\tbatch: 0,\n\tbatchOperation: 0,\n\tregisterComputed: null,\n\n\tfirstEffectToRun: null,\n\tfirstSignalToUpdate: null,\n\n\t// These will definitely be set, in mount or render\n\t// @ts-ignore\n\tactiveRange: null,\n\t// @ts-ignore\n\tpreviousRange: null,\n\t// @ts-ignore\n\trootRange: null,\n\n\tmountEffects: [],\n\tstashedEvents: [],\n\tstashedAnimations: [],\n\n\thydrationNode: null,\n\t//hn: null,\n\t//get hydrationNode() {\n\t//\treturn this.hn;\n\t//},\n\t//set hydrationNode(value) {\n\t//\tconsole.log(`set hydration ${printNode(value)}`);\n\t//\tthis.hn = value;\n\t//},\n};\n\nexport default context;\n","/**\n * The type of a Signal object.\n */\nexport const SIGNAL_TYPE = 0;\n\n/**\n * The type of a Computed object.\n */\nexport const COMPUTED_TYPE = 1;\n\n/**\n * The type of an Effect object.\n */\nexport const EFFECT_TYPE = 2;\n","import type Computed from \"../types/Computed\";\nimport type Effect from \"../types/Effect\";\nimport type Subscription from \"../types/Subscription\";\n\n/**\n * Clear unused source subscriptions after each Computed or Effect has been run.\n */\nexport default function clearSources(target: Computed | Effect): void {\n\tlet previousSub: Subscription | null = null;\n\tfor (\n\t\tlet clearSub: Subscription | null = target.firstSource;\n\t\tclearSub !== null;\n\t\tclearSub = clearSub.nextSource\n\t) {\n\t\tif (target.didError || !clearSub.active) {\n\t\t\t//console.log(\n\t\t\t//\t`clearing source sub ${clearSub.source.name} <-> ${clearSub.target.name} (${clearSub.name})`,\n\t\t\t//);\n\t\t\tif (previousSub === null) {\n\t\t\t\ttarget.firstSource = clearSub.nextSource;\n\t\t\t} else {\n\t\t\t\tpreviousSub.nextSource = clearSub.nextSource;\n\t\t\t}\n\n\t\t\t// Update the targets list too\n\t\t\tif (clearSub.previousTarget === null) {\n\t\t\t\tif (clearSub.source.firstTarget === clearSub) {\n\t\t\t\t\tclearSub.source.firstTarget = clearSub.nextTarget;\n\t\t\t\t}\n\t\t\t\t// TODO: else???\n\t\t\t} else {\n\t\t\t\tclearSub.previousTarget.nextTarget = clearSub.nextTarget;\n\t\t\t}\n\t\t} else {\n\t\t\tclearSub.recalc = false;\n\t\t\tpreviousSub = clearSub;\n\t\t}\n\t}\n}\n","import type Computed from \"../types/Computed\";\nimport type Effect from \"../types/Effect\";\nimport type Subscription from \"../types/Subscription\";\n\n/**\n * Sets source subscriptions to inactive for a Computed or Effect.\n */\nexport default function deactivateSources(target: Computed | Effect): void {\n\tfor (\n\t\tlet sourceSub: Subscription | null = target.firstSource;\n\t\tsourceSub !== null;\n\t\tsourceSub = sourceSub.nextSource\n\t) {\n\t\tsourceSub.active = false;\n\t\t//console.log(\n\t\t//\t`deactivating ${sourceSub.source.name} <-> ${sourceSub.target.name} (${sourceSub.name})`,\n\t\t//);\n\t}\n}\n","import context from \"../render/context\";\nimport type Computed from \"../types/Computed\";\nimport type ProxySignal from \"../types/ProxySignal\";\nimport type Subscription from \"../types/Subscription\";\n\n// TODO: Rename this to `subscribe` because its purpose has changed a bit\n\n/**\n * If there's an active target, subscribe it to this signal, so that it will be\n * run when the signal changes.\n */\nexport default function trackEffect(signal: ProxySignal | Computed): void {\n\tconst target = context.activeTarget;\n\tif (target !== null) {\n\t\tlet sub: Subscription | null = null;\n\t\tlet lastSub: Subscription | null = null;\n\n\t\t// Check if there's a sub we can re-use\n\t\t// TODO: Maybe we could be smarter with this\n\t\t// -- use the target sub instead?\n\t\t// -- do it differently on push vs pull??\n\t\tfor (\n\t\t\tlet nextSub: Subscription | null = signal.firstTarget;\n\t\t\tnextSub !== null;\n\t\t\tnextSub = nextSub.nextTarget\n\t\t) {\n\t\t\tlastSub = nextSub;\n\t\t\tif (nextSub.target === target) {\n\t\t\t\tsub = nextSub;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (sub === null) {\n\t\t\tsub = {\n\t\t\t\tsource: signal,\n\t\t\t\ttarget: target,\n\t\t\t\tpreviousTarget: lastSub,\n\t\t\t\tnextTarget: null,\n\t\t\t\tnextSource: null,\n\t\t\t\tactive: true,\n\t\t\t\trecalc: false,\n\t\t\t\t//name: dev.subName(),\n\t\t\t};\n\t\t\t//console.log(`creating sub '${signal.name}' => '${effect.name}' (${sub.name})`);\n\t\t\tif (lastSub === null) {\n\t\t\t\tsignal.firstTarget = sub;\n\t\t\t} else {\n\t\t\t\tlastSub.nextTarget = sub;\n\t\t\t}\n\n\t\t\tif (target.firstSource === null) {\n\t\t\t\ttarget.firstSource = sub;\n\t\t\t} else {\n\t\t\t\tlet lastEffectSub = target.firstSource;\n\t\t\t\tfor (\n\t\t\t\t\tlet nextSub: Subscription | null = lastEffectSub.nextSource;\n\t\t\t\t\tnextSub !== null;\n\t\t\t\t\tnextSub = nextSub.nextSource\n\t\t\t\t) {\n\t\t\t\t\tlastEffectSub = nextSub;\n\t\t\t\t}\n\t\t\t\tlastEffectSub.nextSource = sub;\n\t\t\t}\n\t\t} else {\n\t\t\t// We can re-use this subscription object\n\t\t\t//console.log(`re-using sub '${signal.name}' => '${effect.name}' (${sub.name})`);\n\t\t\tsub.active = true;\n\t\t}\n\t}\n}\n","import context from \"../render/context\";\nimport type Computed from \"../types/Computed\";\nimport trackEffect from \"./trackEffect\";\n\nexport default function runComputed<T>(computed: Computed<T>): T {\n\t//console.log(`running computed '${computed.name}'`);\n\n\t// Store the active target\n\tconst oldActiveTarget = context.activeTarget;\n\n\tcomputed.running = true;\n\tcomputed.didError = false;\n\n\ttry {\n\t\t// Set the active target, so that any properties accessed while running it\n\t\t// will trigger it in future\n\t\tcontext.activeTarget = computed;\n\n\t\t// Run the computed and gather its dependencies\n\t\tcomputed.value = computed.run();\n\t} catch (err) {\n\t\tcomputed.didError = true;\n\t\t// @ts-ignore\n\t\tcomputed.value = err;\n\t\tthrow err;\n\t} finally {\n\t\t// Set the active target back to what it was previously\n\t\tcontext.activeTarget = oldActiveTarget;\n\n\t\tcomputed.running = false;\n\t}\n\n\ttrackEffect(computed);\n\n\treturn computed.value;\n}\n","import type Computed from \"../types/Computed\";\nimport type Subscription from \"../types/Subscription\";\nimport checkSources from \"./checkSources\";\nimport clearSources from \"./clearSources\";\nimport deactivateSources from \"./deactivateSources\";\nimport runComputed from \"./runComputed\";\n\n/**\n * Checks whether a Computed value should be re-run (which will be true if any\n * of its sources have changed) and re-runs it if necessary.\n */\nexport default function checkComputed(computed: Computed): boolean {\n\tlet rerun = checkSources(computed);\n\n\tlet changed = false;\n\n\tif (rerun) {\n\t\t// Set source subscriptions to inactive\n\t\tdeactivateSources(computed);\n\n\t\t// Run the computed, which will reset subscriptions\n\t\tconst oldValue = computed.value;\n\t\trunComputed(computed);\n\t\tchanged = computed.value !== oldValue;\n\n\t\t// Clear unused source subscriptions\n\t\tclearSources(computed);\n\t}\n\n\tcomputed.recalc = false;\n\n\t// If it hasn't changed, all of its target subscriptions remain active and\n\t// don't need to be recalculated\n\tif (!changed) {\n\t\tfor (\n\t\t\tlet targetSub: Subscription | null = computed.firstTarget;\n\t\t\ttargetSub !== null;\n\t\t\ttargetSub = targetSub.nextTarget\n\t\t) {\n\t\t\ttargetSub.active = true;\n\t\t\ttargetSub.recalc = false;\n\t\t}\n\t}\n\n\treturn changed;\n}\n","import context from \"../render/context\";\nimport type Computed from \"../types/Computed\";\nimport type Effect from \"../types/Effect\";\nimport type Subscription from \"../types/Subscription\";\nimport { COMPUTED_TYPE, SIGNAL_TYPE } from \"../types/constants\";\nimport checkComputed from \"./checkComputed\";\n\n// RECURSIVE\n\n/**\n * Checks whether a Computed or Effect should be re-run (which will be true if\n * any of its sources have changed).\n */\nexport default function checkSources(target: Computed | Effect): boolean {\n\t// NOTE: We bail early if we know the target needs to be re-run; subsequent\n\t// computed values will be computed in the proxy getter\n\n\t// Check signals first as it's cheap, then computed values\n\tlet haveComputed = false;\n\n\tfor (\n\t\tlet sourceSub: Subscription | null = target.firstSource;\n\t\tsourceSub !== null;\n\t\tsourceSub = sourceSub.nextSource\n\t) {\n\t\t//console.log(`checking source sub '${sourceSub.source.name}' (${sourceSub.name})`);\n\t\tif (sourceSub.recalc) {\n\t\t\tif (sourceSub.source.type === SIGNAL_TYPE) {\n\t\t\t\treturn true;\n\t\t\t} /* else if (sourceSub.source.type === COMPUTED_TYPE) */ else {\n\t\t\t\tif (sourceSub.source.recalc) {\n\t\t\t\t\thaveComputed = true;\n\t\t\t\t} else {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (haveComputed) {\n\t\tfor (\n\t\t\tlet sourceSub: Subscription | null = target.firstSource;\n\t\t\tsourceSub !== null;\n\t\t\tsourceSub = sourceSub.nextSource\n\t\t) {\n\t\t\t//console.log(`checking source sub '${sourceSub.source.name}' (${sourceSub.name})`);\n\t\t\tif (sourceSub.recalc && sourceSub.source.type === COMPUTED_TYPE && sourceSub.source.recalc) {\n\t\t\t\tconst oldActiveTarget = context.activeTarget;\n\t\t\t\tcontext.activeTarget = target;\n\n\t\t\t\tconst recalc = checkComputed(sourceSub.source);\n\n\t\t\t\tcontext.activeTarget = oldActiveTarget;\n\n\t\t\t\tif (recalc) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn false;\n}\n","import context from \"../render/context\";\nimport type Effect from \"../types/Effect\";\nimport clearSources from \"./clearSources\";\n\n/**\n * Runs cleanup functions for the effect and its children.\n */\nexport default function runCleanups(effect: Effect): void {\n\tlet effectToClean: Effect | null = effect;\n\tfor (let i = 0; i < effect.extent; i++) {\n\t\tif (typeof effectToClean.cleanup === \"function\") {\n\t\t\t//console.log(`cleaning effect '${effectToClean.name}'`);\n\t\t\tconst oldActiveTarget = context.activeTarget;\n\t\t\tcontext.activeTarget = null;\n\n\t\t\ttry {\n\t\t\t\teffectToClean.cleanup();\n\t\t\t} catch (err) {\n\t\t\t\teffectToClean.didError = true;\n\t\t\t\tclearSources(effectToClean);\n\t\t\t\tthrow err;\n\t\t\t} finally {\n\t\t\t\teffectToClean.cleanup = undefined;\n\t\t\t\tcontext.activeTarget = oldActiveTarget;\n\t\t\t}\n\t\t}\n\n\t\tconst nextEffect: Effect = effectToClean.nextEffect!;\n\n\t\t// If it's a child effect that has been triggered, clean it up\n\t\t// and remove it from the list of effects to run (it may get\n\t\t// re-created with the parent)\n\t\tif (i !== 0 && effect.nextEffectToRun === effectToClean) {\n\t\t\teffect.nextEffectToRun = effectToClean.nextEffectToRun;\n\t\t\teffectToClean.nextEffect = effectToClean.nextEffectToRun = null;\n\t\t}\n\n\t\teffectToClean = nextEffect;\n\t}\n}\n","import context from \"../render/context\";\n\nexport default function batchStart(): void {\n\tcontext.batch++;\n}\n","import context from \"../render/context\";\nimport type Effect from \"../types/Effect\";\nimport batchEnd from \"./batchEnd\";\nimport batchStart from \"./batchStart\";\nimport clearSources from \"./clearSources\";\n\nexport default function runEffect(effect: Effect): void {\n\t//console.log(`running effect '${effect.name}'`);\n\n\t// Store the active target\n\tconst oldActiveTarget = context.activeTarget;\n\tconst oldExtent = context.extent;\n\n\teffect.didError = false;\n\n\tbatchStart();\n\n\ttry {\n\t\t// Set the next effect for navigating through\n\t\tif (context.previousEffect !== null) {\n\t\t\tcontext.previousEffect.nextEffect = effect;\n\t\t}\n\n\t\t// Set the active effect, so that any properties accessed while running it\n\t\t// will trigger it in future\n\t\tcontext.activeTarget = effect;\n\t\tcontext.previousEffect = effect;\n\t\tcontext.extent = 1;\n\n\t\t// Run the effect to register its subscriptions and get its (optional)\n\t\t// cleanup function\n\t\teffect.cleanup = effect.run();\n\n\t\teffect.extent = context.extent;\n\t} catch (err) {\n\t\teffect.didError = true;\n\t\tclearSources(effect);\n\t\tthrow err;\n\t} finally {\n\t\t// Set the active target back to what it was previously\n\t\tcontext.activeTarget = oldActiveTarget;\n\t\tcontext.extent += oldExtent - 1;\n\n\t\tbatchEnd();\n\t}\n}\n","import type Effect from \"../types/Effect\";\nimport checkSources from \"./checkSources\";\nimport clearSources from \"./clearSources\";\nimport deactivateSources from \"./deactivateSources\";\nimport runCleanups from \"./runCleanups\";\nimport runEffect from \"./runEffect\";\n\n/**\n * Checks whether an Effect should be re-run (which will be true if any\n * of its sources have changed) and re-runs it if necessary.\n */\nexport default function checkEffect(effect: Effect): void {\n\t//console.log(`checking effect '${effect.name}'`);\n\n\tlet rerun = checkSources(effect);\n\n\tif (rerun) {\n\t\t// Run cleanup functions for the effect and its children\n\t\trunCleanups(effect);\n\n\t\t// Set source subscriptions to inactive\n\t\tdeactivateSources(effect);\n\n\t\t// Run the effect, which will reset subscriptions\n\t\trunEffect(effect);\n\n\t\t// Clear unused source subscriptions\n\t\tclearSources(effect);\n\t}\n}\n","import type Computed from \"../types/Computed\";\nimport type ProxySignal from \"../types/ProxySignal\";\nimport type Subscription from \"../types/Subscription\";\n\n/**\n * Clear unused target subscriptions after all Effects have been run.\n */\nexport default function clearTargets(source: ProxySignal | Computed): void {\n\tlet previousSub: Subscription | null = null;\n\tfor (\n\t\tlet clearSub: Subscription | null = source.firstTarget;\n\t\tclearSub !== null;\n\t\tclearSub = clearSub.nextTarget\n\t) {\n\t\tif (!clearSub.active) {\n\t\t\t//console.log(\n\t\t\t//\t`clearing target sub ${clearSub.source.name} <-> ${clearSub.target.name} (${clearSub.name})`,\n\t\t\t//);\n\t\t\tif (previousSub === null) {\n\t\t\t\tsource.firstTarget = clearSub.nextTarget;\n\t\t\t} else {\n\t\t\t\tpreviousSub.nextTarget = clearSub.nextTarget;\n\t\t\t}\n\t\t} else {\n\t\t\tpreviousSub = clearSub;\n\t\t}\n\t}\n}\n","import context from \"../render/context\";\nimport type Effect from \"../types/Effect\";\nimport type ProxySignal from \"../types/ProxySignal\";\nimport checkEffect from \"./checkEffect\";\nimport clearTargets from \"./clearTargets\";\n\n/**\n * Runs the effects that have been collected during the batch.\n */\nexport default function triggerEffects(): void {\n\t//console.log(`triggering effects for '${String(key)}' on`, proxy);\n\t//console.log(\"===\");\n\t//console.log(`triggering effects for '${String(key)}'`);\n\n\tlet didError = false;\n\tlet error: any;\n\n\t// Run the effects\n\tlet effect: Effect | null = context.firstEffectToRun;\n\twhile (effect !== null) {\n\t\tcontext.batchOperation++;\n\n\t\ttry {\n\t\t\tcheckEffect(effect);\n\t\t} catch (err) {\n\t\t\tif (!didError) {\n\t\t\t\tdidError = true;\n\t\t\t\terror = err;\n\t\t\t}\n\t\t}\n\n\t\teffect = effect.nextEffectToRun;\n\t}\n\n\t// Clear the effects\n\teffect = context.firstEffectToRun;\n\tcontext.firstEffectToRun = null;\n\twhile (effect !== null) {\n\t\tlet nextEffect = effect.nextEffectToRun;\n\t\teffect.nextEffectToRun = null;\n\t\teffect = nextEffect;\n\t}\n\n\t// Clear unused target subscriptions for the signals that were updated\n\t// during the batch\n\tlet signal: ProxySignal | null = context.firstSignalToUpdate;\n\tcontext.firstSignalToUpdate = null;\n\twhile (signal !== null) {\n\t\tclearTargets(signal);\n\n\t\tconst nextSignal = signal.nextSignalToUpdate;\n\t\tsignal.nextSignalToUpdate = null;\n\t\tsignal = nextSignal;\n\t}\n\n\tif (didError) {\n\t\tthrow error;\n\t}\n}\n","import context from \"../render/context\";\nimport triggerEffects from \"./triggerEffects\";\n\nexport default function batchEnd(): void {\n\tif (context.batch > 1) {\n\t\tcontext.batch--;\n\t\treturn;\n\t}\n\n\ttry {\n\t\ttriggerEffects();\n\t} finally {\n\t\tcontext.batch = 0;\n\t\tcontext.batchOperation = 0;\n\t\tcontext.previousEffect = null;\n\t}\n}\n","import batchEnd from \"../watch/batchEnd\";\nimport batchStart from \"../watch/batchStart\";\nimport context from \"./context\";\n\n/**\n * Runs updates to proxy values in a batch, where the updates are stored in\n * context, and dependent effects are run all at once at the end.\n *\n * @param fn The function containing the batched updates to run.\n */\nexport default function $batch<T>(fn: () => T): T {\n\tif (context.batch > 0) {\n\t\treturn fn();\n\t}\n\n\tbatchStart();\n\ttry {\n\t\treturn fn();\n\t} finally {\n\t\tbatchEnd();\n\t}\n}\n","import type Computed from \"../types/Computed\";\nimport { COMPUTED_TYPE } from \"../types/constants\";\nimport runComputed from \"../watch/runComputed\";\nimport context from \"./context\";\n\n/**\n * Caches a computed value from signals accessed in a property getter.\n *\n * @param fn The function containing the signals to compute and cache.\n */\nexport default function $cache<T>(fn: () => T): T {\n\tif (context.registerComputed === null) {\n\t\tthrow new Error(\"$cache must be used in a getter\");\n\t}\n\n\tlet computed: Computed = {\n\t\ttype: COMPUTED_TYPE,\n\t\tvalue: null,\n\t\trun: fn,\n\t\tfirstSource: null,\n\t\tfirstTarget: null,\n\t\trecalc: false,\n\t\trunning: false,\n\t\tdidError: false,\n\t\trollback: null,\n\t\t//name: dev.effectName(fn),\n\t};\n\n\tcontext.registerComputed(computed);\n\n\trunComputed(computed);\n\n\treturn computed.value;\n}\n","import context from \"./context\";\n\n// Not sure if this is a good idea?\n\nexport default function $peek<T>(fn: () => T): T {\n\tconst oldActiveTarget = context.activeTarget;\n\tcontext.activeTarget = null;\n\n\tconst result = fn();\n\n\tcontext.activeTarget = oldActiveTarget;\n\n\treturn result;\n}\n","export default function buildClasses(value: unknown, styleHash?: string): string {\n\tif (typeof value === \"string\") {\n\t\tif (styleHash !== undefined) {\n\t\t\tvalue += \" \" + styleHash;\n\t\t}\n\t\treturn value;\n\t} else {\n\t\tlet classes: string[] = [];\n\t\tgatherNames(\"\", value, classes);\n\t\tif (styleHash !== undefined) {\n\t\t\tclasses.push(styleHash);\n\t\t}\n\t\treturn classes.join(\" \");\n\t}\n}\n\nfunction gatherNames(name: unknown, value: unknown, classes: string[]) {\n\tif (value) {\n\t\tif (Array.isArray(value)) {\n\t\t\tfor (let v of value) {\n\t\t\t\tgatherNames(v, v, classes);\n\t\t\t}\n\t\t} else if (typeof value === \"object\") {\n\t\t\tfor (let [n, v] of Object.entries(value)) {\n\t\t\t\tgatherNames(n, v, classes);\n\t\t\t}\n\t\t} else {\n\t\t\tclasses.push(name as string);\n\t\t}\n\t}\n}\n","export default function buildStyles(value: unknown): string {\n\tif (typeof value === \"string\") {\n\t\treturn value;\n\t} else {\n\t\tlet styles: string[] = [];\n\t\tif (value) {\n\t\t\tif (Array.isArray(value)) {\n\t\t\t\tfor (let v of value) {\n\t\t\t\t\tstyles.push(v);\n\t\t\t\t}\n\t\t\t} else if (typeof value === \"object\") {\n\t\t\t\tfor (let [n, v] of Object.entries(value)) {\n\t\t\t\t\tstyles.push(`${n}: ${v}`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn styles.join(\"; \");\n\t}\n}\n","export default function formatText(value: any): string {\n\treturn value ?? \"\";\n}\n"],"mappings":";AAEA,MAAMA,UAAmB;CACxB,cAAc;CACd,gBAAgB;CAChB,QAAQ;CACR,OAAO;CACP,gBAAgB;CAChB,kBAAkB;CAElB,kBAAkB;CAClB,qBAAqB;CAIrB,aAAa;CAEb,eAAe;CAEf,WAAW;CAEX,cAAc,EAAE;CAChB,eAAe,EAAE;CACjB,mBAAmB,EAAE;CAErB,eAAe;CASf;AAED,sBAAe;;;;;;;ACjCf,MAAa,cAAc;;;;AAK3B,MAAa,gBAAgB;;;;AAK7B,MAAa,cAAc;;;;;;;ACN3B,SAAwB,aAAa,QAAiC;CACrE,IAAIC,cAAmC;AACvC,MACC,IAAIC,WAAgC,OAAO,aAC3C,aAAa,MACb,WAAW,SAAS,WAEpB,KAAI,OAAO,YAAY,CAAC,SAAS,QAAQ;AAIxC,MAAI,gBAAgB,KACnB,QAAO,cAAc,SAAS;MAE9B,aAAY,aAAa,SAAS;AAInC,MAAI,SAAS,mBAAmB,MAC/B;OAAI,SAAS,OAAO,gBAAgB,SACnC,UAAS,OAAO,cAAc,SAAS;QAIxC,UAAS,eAAe,aAAa,SAAS;QAEzC;AACN,WAAS,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AAmB;AACtE,KAAI,MACH,KAAI,MAAM,QAAQ,MAAM,CACvB,MAAK,IAAI,KAAK,MACb,aAAY,GAAG,GAAG,QAAQ;UAEjB,OAAO,UAAU,SAC3B,MAAK,IAAI,CAAC,GAAG,MAAM,OAAO,QAAQ,MAAM,CACvC,aAAY,GAAG,GAAG,QAAQ;KAG3B,SAAQ,KAAK,KAAe;;;;;AC3B/B,SAAwB,YAAY,OAAwB;AAC3D,KAAI,OAAO,UAAU,SACpB,QAAO;MACD;EACN,IAAIC,SAAmB,EAAE;AACzB,MAAI,OACH;OAAI,MAAM,QAAQ,MAAM,CACvB,MAAK,IAAI,KAAK,MACb,QAAO,KAAK,EAAE;YAEL,OAAO,UAAU,SAC3B,MAAK,IAAI,CAAC,GAAG,MAAM,OAAO,QAAQ,MAAM,CACvC,QAAO,KAAK,GAAG,EAAE,IAAI,IAAI;;AAI5B,SAAO,OAAO,KAAK,KAAK;;;;;;AChB1B,SAAwB,WAAW,OAAoB;AACtD,QAAO,SAAS"}
|
|
1
|
+
{"version":3,"file":"formatText-B0FXBdFT.js","names":["context: Context","previousSub: Subscription | null","clearSub: Subscription | null","sourceSub: Subscription | null","context","sub: Subscription | null","lastSub: Subscription | null","nextSub: Subscription | null","context","targetSub: Subscription | null","sourceSub: Subscription | null","context","effectToClean: Effect | null","context","nextEffect: Effect","context","previousSub: Subscription | null","clearSub: Subscription | null","error: any","effect: Effect | null","context","signal: ProxySignal | null","context","context","context","computed: Computed","context","classes: string[]","styles: string[]"],"sources":["../src/render/context.ts","../src/types/constants.ts","../src/watch/clearSources.ts","../src/watch/deactivateSources.ts","../src/watch/trackEffect.ts","../src/watch/runComputed.ts","../src/watch/checkComputed.ts","../src/watch/checkSources.ts","../src/watch/runCleanups.ts","../src/watch/batchStart.ts","../src/watch/runEffect.ts","../src/watch/checkEffect.ts","../src/watch/clearTargets.ts","../src/watch/triggerEffects.ts","../src/watch/batchEnd.ts","../src/render/$batch.ts","../src/render/$cache.ts","../src/render/$peek.ts","../src/render/buildClasses.ts","../src/render/buildStyles.ts","../src/render/formatText.ts"],"sourcesContent":["import type Context from \"../types/Context\";\n\nconst context: Context = {\n\tactiveTarget: null,\n\tpreviousEffect: null,\n\textent: 0,\n\tbatch: 0,\n\tbatchOperation: 0,\n\tregisterComputed: null,\n\n\tfirstEffectToRun: null,\n\tfirstSignalToUpdate: null,\n\n\t// These will definitely be set, in mount or render\n\t// @ts-ignore\n\tactiveRange: null,\n\t// @ts-ignore\n\tpreviousRange: null,\n\t// @ts-ignore\n\trootRange: null,\n\n\tmountEffects: [],\n\tstashedEvents: [],\n\tstashedAnimations: [],\n\n\thydrationNode: null,\n\t//hn: null,\n\t//get hydrationNode() {\n\t//\treturn this.hn;\n\t//},\n\t//set hydrationNode(value) {\n\t//\tconsole.log(`set hydration ${printNode(value)}`);\n\t//\tthis.hn = value;\n\t//},\n};\n\nexport default context;\n","/**\n * The type of a Signal object.\n */\nexport const SIGNAL_TYPE = 0;\n\n/**\n * The type of a Computed object.\n */\nexport const COMPUTED_TYPE = 1;\n\n/**\n * The type of an Effect object.\n */\nexport const EFFECT_TYPE = 2;\n","import type Computed from \"../types/Computed\";\nimport type Effect from \"../types/Effect\";\nimport type Subscription from \"../types/Subscription\";\n\n/**\n * Clear unused source subscriptions after each Computed or Effect has been run.\n */\nexport default function clearSources(target: Computed | Effect): void {\n\tlet previousSub: Subscription | null = null;\n\tfor (\n\t\tlet clearSub: Subscription | null = target.firstSource;\n\t\tclearSub !== null;\n\t\tclearSub = clearSub.nextSource\n\t) {\n\t\tif (target.didError || !clearSub.active) {\n\t\t\t//console.log(\n\t\t\t//\t`clearing source sub ${clearSub.source.name} <-> ${clearSub.target.name} (${clearSub.name})`,\n\t\t\t//);\n\t\t\tif (previousSub === null) {\n\t\t\t\ttarget.firstSource = clearSub.nextSource;\n\t\t\t} else {\n\t\t\t\tpreviousSub.nextSource = clearSub.nextSource;\n\t\t\t}\n\n\t\t\t// Update the targets list too\n\t\t\tif (clearSub.previousTarget === null) {\n\t\t\t\tif (clearSub.source.firstTarget === clearSub) {\n\t\t\t\t\tclearSub.source.firstTarget = clearSub.nextTarget;\n\t\t\t\t}\n\t\t\t\t// TODO: else???\n\t\t\t} else {\n\t\t\t\tclearSub.previousTarget.nextTarget = clearSub.nextTarget;\n\t\t\t}\n\t\t} else {\n\t\t\tclearSub.recalc = false;\n\t\t\tpreviousSub = clearSub;\n\t\t}\n\t}\n}\n","import type Computed from \"../types/Computed\";\nimport type Effect from \"../types/Effect\";\nimport type Subscription from \"../types/Subscription\";\n\n/**\n * Sets source subscriptions to inactive for a Computed or Effect.\n */\nexport default function deactivateSources(target: Computed | Effect): void {\n\tfor (\n\t\tlet sourceSub: Subscription | null = target.firstSource;\n\t\tsourceSub !== null;\n\t\tsourceSub = sourceSub.nextSource\n\t) {\n\t\tsourceSub.active = false;\n\t\t//console.log(\n\t\t//\t`deactivating ${sourceSub.source.name} <-> ${sourceSub.target.name} (${sourceSub.name})`,\n\t\t//);\n\t}\n}\n","import context from \"../render/context\";\nimport type Computed from \"../types/Computed\";\nimport type ProxySignal from \"../types/ProxySignal\";\nimport type Subscription from \"../types/Subscription\";\n\n// TODO: Rename this to `subscribe` because its purpose has changed a bit\n\n/**\n * If there's an active target, subscribe it to this signal, so that it will be\n * run when the signal changes.\n */\nexport default function trackEffect(signal: ProxySignal | Computed): void {\n\tconst target = context.activeTarget;\n\tif (target !== null) {\n\t\tlet sub: Subscription | null = null;\n\t\tlet lastSub: Subscription | null = null;\n\n\t\t// Check if there's a sub we can re-use\n\t\t// TODO: Maybe we could be smarter with this\n\t\t// -- use the target sub instead?\n\t\t// -- do it differently on push vs pull??\n\t\tfor (\n\t\t\tlet nextSub: Subscription | null = signal.firstTarget;\n\t\t\tnextSub !== null;\n\t\t\tnextSub = nextSub.nextTarget\n\t\t) {\n\t\t\tlastSub = nextSub;\n\t\t\tif (nextSub.target === target) {\n\t\t\t\tsub = nextSub;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (sub === null) {\n\t\t\tsub = {\n\t\t\t\tsource: signal,\n\t\t\t\ttarget: target,\n\t\t\t\tpreviousTarget: lastSub,\n\t\t\t\tnextTarget: null,\n\t\t\t\tnextSource: null,\n\t\t\t\tactive: true,\n\t\t\t\trecalc: false,\n\t\t\t\t//name: dev.subName(),\n\t\t\t};\n\t\t\t//console.log(`creating sub '${signal.name}' => '${effect.name}' (${sub.name})`);\n\t\t\tif (lastSub === null) {\n\t\t\t\tsignal.firstTarget = sub;\n\t\t\t} else {\n\t\t\t\tlastSub.nextTarget = sub;\n\t\t\t}\n\n\t\t\tif (target.firstSource === null) {\n\t\t\t\ttarget.firstSource = sub;\n\t\t\t} else {\n\t\t\t\tlet lastEffectSub = target.firstSource;\n\t\t\t\tfor (\n\t\t\t\t\tlet nextSub: Subscription | null = lastEffectSub.nextSource;\n\t\t\t\t\tnextSub !== null;\n\t\t\t\t\tnextSub = nextSub.nextSource\n\t\t\t\t) {\n\t\t\t\t\tlastEffectSub = nextSub;\n\t\t\t\t}\n\t\t\t\tlastEffectSub.nextSource = sub;\n\t\t\t}\n\t\t} else {\n\t\t\t// We can re-use this subscription object\n\t\t\t//console.log(`re-using sub '${signal.name}' => '${effect.name}' (${sub.name})`);\n\t\t\tsub.active = true;\n\t\t}\n\t}\n}\n","import context from \"../render/context\";\nimport type Computed from \"../types/Computed\";\nimport trackEffect from \"./trackEffect\";\n\nexport default function runComputed<T>(computed: Computed<T>): T {\n\t//console.log(`running computed '${computed.name}'`);\n\n\t// Store the active target\n\tconst oldActiveTarget = context.activeTarget;\n\n\tcomputed.running = true;\n\tcomputed.didError = false;\n\n\ttry {\n\t\t// Set the active target, so that any properties accessed while running it\n\t\t// will trigger it in future\n\t\tcontext.activeTarget = computed;\n\n\t\t// Run the computed and gather its dependencies\n\t\tcomputed.value = computed.run();\n\t} catch (err) {\n\t\tcomputed.didError = true;\n\t\t// @ts-ignore\n\t\tcomputed.value = err;\n\t\tthrow err;\n\t} finally {\n\t\t// Set the active target back to what it was previously\n\t\tcontext.activeTarget = oldActiveTarget;\n\n\t\tcomputed.running = false;\n\t}\n\n\ttrackEffect(computed);\n\n\treturn computed.value;\n}\n","import type Computed from \"../types/Computed\";\nimport type Subscription from \"../types/Subscription\";\nimport checkSources from \"./checkSources\";\nimport clearSources from \"./clearSources\";\nimport deactivateSources from \"./deactivateSources\";\nimport runComputed from \"./runComputed\";\n\n/**\n * Checks whether a Computed value should be re-run (which will be true if any\n * of its sources have changed) and re-runs it if necessary.\n */\nexport default function checkComputed(computed: Computed): boolean {\n\tlet rerun = checkSources(computed);\n\n\tlet changed = false;\n\n\tif (rerun) {\n\t\t// Set source subscriptions to inactive\n\t\tdeactivateSources(computed);\n\n\t\t// Run the computed, which will reset subscriptions\n\t\tconst oldValue = computed.value;\n\t\trunComputed(computed);\n\t\tchanged = computed.value !== oldValue;\n\n\t\t// Clear unused source subscriptions\n\t\tclearSources(computed);\n\t}\n\n\tcomputed.recalc = false;\n\n\t// If it hasn't changed, all of its target subscriptions remain active and\n\t// don't need to be recalculated\n\tif (!changed) {\n\t\tfor (\n\t\t\tlet targetSub: Subscription | null = computed.firstTarget;\n\t\t\ttargetSub !== null;\n\t\t\ttargetSub = targetSub.nextTarget\n\t\t) {\n\t\t\ttargetSub.active = true;\n\t\t\ttargetSub.recalc = false;\n\t\t}\n\t}\n\n\treturn changed;\n}\n","import context from \"../render/context\";\nimport type Computed from \"../types/Computed\";\nimport type Effect from \"../types/Effect\";\nimport type Subscription from \"../types/Subscription\";\nimport { COMPUTED_TYPE, SIGNAL_TYPE } from \"../types/constants\";\nimport checkComputed from \"./checkComputed\";\n\n// RECURSIVE\n\n/**\n * Checks whether a Computed or Effect should be re-run (which will be true if\n * any of its sources have changed).\n */\nexport default function checkSources(target: Computed | Effect): boolean {\n\t// NOTE: We bail early if we know the target needs to be re-run; subsequent\n\t// computed values will be computed in the proxy getter\n\n\t// Check signals first as it's cheap, then computed values\n\tlet haveComputed = false;\n\n\tfor (\n\t\tlet sourceSub: Subscription | null = target.firstSource;\n\t\tsourceSub !== null;\n\t\tsourceSub = sourceSub.nextSource\n\t) {\n\t\t//console.log(`checking source sub '${sourceSub.source.name}' (${sourceSub.name})`);\n\t\tif (sourceSub.recalc) {\n\t\t\tif (sourceSub.source.type === SIGNAL_TYPE) {\n\t\t\t\treturn true;\n\t\t\t} /* else if (sourceSub.source.type === COMPUTED_TYPE) */ else {\n\t\t\t\tif (sourceSub.source.recalc) {\n\t\t\t\t\thaveComputed = true;\n\t\t\t\t} else {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (haveComputed) {\n\t\tfor (\n\t\t\tlet sourceSub: Subscription | null = target.firstSource;\n\t\t\tsourceSub !== null;\n\t\t\tsourceSub = sourceSub.nextSource\n\t\t) {\n\t\t\t//console.log(`checking source sub '${sourceSub.source.name}' (${sourceSub.name})`);\n\t\t\tif (sourceSub.recalc && sourceSub.source.type === COMPUTED_TYPE && sourceSub.source.recalc) {\n\t\t\t\tconst oldActiveTarget = context.activeTarget;\n\t\t\t\tcontext.activeTarget = target;\n\n\t\t\t\tconst recalc = checkComputed(sourceSub.source);\n\n\t\t\t\tcontext.activeTarget = oldActiveTarget;\n\n\t\t\t\tif (recalc) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn false;\n}\n","import context from \"../render/context\";\nimport type Effect from \"../types/Effect\";\nimport clearSources from \"./clearSources\";\n\n/**\n * Runs cleanup functions for the effect and its children.\n */\nexport default function runCleanups(effect: Effect): void {\n\tlet effectToClean: Effect | null = effect;\n\tfor (let i = 0; i < effect.extent; i++) {\n\t\tif (typeof effectToClean.cleanup === \"function\") {\n\t\t\t//console.log(`cleaning effect '${effectToClean.name}'`);\n\t\t\tconst oldActiveTarget = context.activeTarget;\n\t\t\tcontext.activeTarget = null;\n\n\t\t\ttry {\n\t\t\t\teffectToClean.cleanup();\n\t\t\t} catch (err) {\n\t\t\t\teffectToClean.didError = true;\n\t\t\t\tclearSources(effectToClean);\n\t\t\t\tthrow err;\n\t\t\t} finally {\n\t\t\t\teffectToClean.cleanup = undefined;\n\t\t\t\tcontext.activeTarget = oldActiveTarget;\n\t\t\t}\n\t\t}\n\n\t\tconst nextEffect: Effect = effectToClean.nextEffect!;\n\n\t\t// If it's a child effect that has been triggered, clean it up\n\t\t// and remove it from the list of effects to run (it may get\n\t\t// re-created with the parent)\n\t\tif (i !== 0 && effect.nextEffectToRun === effectToClean) {\n\t\t\teffect.nextEffectToRun = effectToClean.nextEffectToRun;\n\t\t\teffectToClean.nextEffect = effectToClean.nextEffectToRun = null;\n\t\t}\n\n\t\teffectToClean = nextEffect;\n\t}\n}\n","import context from \"../render/context\";\n\nexport default function batchStart(): void {\n\tcontext.batch++;\n}\n","import context from \"../render/context\";\nimport type Effect from \"../types/Effect\";\nimport batchEnd from \"./batchEnd\";\nimport batchStart from \"./batchStart\";\nimport clearSources from \"./clearSources\";\n\nexport default function runEffect(effect: Effect): void {\n\t//console.log(`running effect '${effect.name}'`);\n\n\t// Store the active target\n\tconst oldActiveTarget = context.activeTarget;\n\tconst oldExtent = context.extent;\n\n\teffect.didError = false;\n\n\tbatchStart();\n\n\ttry {\n\t\t// Set the next effect for navigating through\n\t\tif (context.previousEffect !== null) {\n\t\t\tcontext.previousEffect.nextEffect = effect;\n\t\t}\n\n\t\t// Set the active effect, so that any properties accessed while running it\n\t\t// will trigger it in future\n\t\tcontext.activeTarget = effect;\n\t\tcontext.previousEffect = effect;\n\t\tcontext.extent = 1;\n\n\t\t// Run the effect to register its subscriptions and get its (optional)\n\t\t// cleanup function\n\t\teffect.cleanup = effect.run();\n\n\t\teffect.extent = context.extent;\n\t} catch (err) {\n\t\teffect.didError = true;\n\t\tclearSources(effect);\n\t\tthrow err;\n\t} finally {\n\t\t// Set the active target back to what it was previously\n\t\tcontext.activeTarget = oldActiveTarget;\n\t\tcontext.extent += oldExtent - 1;\n\n\t\tbatchEnd();\n\t}\n}\n","import type Effect from \"../types/Effect\";\nimport checkSources from \"./checkSources\";\nimport clearSources from \"./clearSources\";\nimport deactivateSources from \"./deactivateSources\";\nimport runCleanups from \"./runCleanups\";\nimport runEffect from \"./runEffect\";\n\n/**\n * Checks whether an Effect should be re-run (which will be true if any\n * of its sources have changed) and re-runs it if necessary.\n */\nexport default function checkEffect(effect: Effect): void {\n\t//console.log(`checking effect '${effect.name}'`);\n\n\tlet rerun = checkSources(effect);\n\n\tif (rerun) {\n\t\t//console.log(`running effect '${String(effect.run)}'`);\n\n\t\t// Run cleanup functions for the effect and its children\n\t\trunCleanups(effect);\n\n\t\t// Set source subscriptions to inactive\n\t\tdeactivateSources(effect);\n\n\t\t// Run the effect, which will reset subscriptions\n\t\trunEffect(effect);\n\n\t\t// Clear unused source subscriptions\n\t\tclearSources(effect);\n\t}\n}\n","import type Computed from \"../types/Computed\";\nimport type ProxySignal from \"../types/ProxySignal\";\nimport type Subscription from \"../types/Subscription\";\n\n/**\n * Clear unused target subscriptions after all Effects have been run.\n */\nexport default function clearTargets(source: ProxySignal | Computed): void {\n\tlet previousSub: Subscription | null = null;\n\tfor (\n\t\tlet clearSub: Subscription | null = source.firstTarget;\n\t\tclearSub !== null;\n\t\tclearSub = clearSub.nextTarget\n\t) {\n\t\tif (!clearSub.active) {\n\t\t\t//console.log(\n\t\t\t//\t`clearing target sub ${clearSub.source.name} <-> ${clearSub.target.name} (${clearSub.name})`,\n\t\t\t//);\n\t\t\tif (previousSub === null) {\n\t\t\t\tsource.firstTarget = clearSub.nextTarget;\n\t\t\t} else {\n\t\t\t\tpreviousSub.nextTarget = clearSub.nextTarget;\n\t\t\t}\n\t\t} else {\n\t\t\tpreviousSub = clearSub;\n\t\t}\n\t}\n}\n","import context from \"../render/context\";\nimport type Effect from \"../types/Effect\";\nimport type ProxySignal from \"../types/ProxySignal\";\nimport checkEffect from \"./checkEffect\";\nimport clearTargets from \"./clearTargets\";\n\n/**\n * Runs the effects that have been collected during the batch.\n */\nexport default function triggerEffects(): void {\n\t//console.log(`triggering effects for '${String(key)}' on`, proxy);\n\t//console.log(\"===\");\n\t//console.log(`triggering effects for '${String(key)}'`);\n\n\tlet didError = false;\n\tlet error: any;\n\n\t// Run the effects\n\tlet effect: Effect | null = context.firstEffectToRun;\n\twhile (effect !== null) {\n\t\tcontext.batchOperation++;\n\n\t\ttry {\n\t\t\tcheckEffect(effect);\n\t\t} catch (err) {\n\t\t\tif (!didError) {\n\t\t\t\tdidError = true;\n\t\t\t\terror = err;\n\t\t\t}\n\t\t}\n\n\t\teffect = effect.nextEffectToRun;\n\t}\n\n\t// Clear the effects\n\teffect = context.firstEffectToRun;\n\tcontext.firstEffectToRun = null;\n\twhile (effect !== null) {\n\t\tlet nextEffect = effect.nextEffectToRun;\n\t\teffect.nextEffectToRun = null;\n\t\teffect = nextEffect;\n\t}\n\n\t// Clear unused target subscriptions for the signals that were updated\n\t// during the batch\n\tlet signal: ProxySignal | null = context.firstSignalToUpdate;\n\tcontext.firstSignalToUpdate = null;\n\twhile (signal !== null) {\n\t\tclearTargets(signal);\n\n\t\tconst nextSignal = signal.nextSignalToUpdate;\n\t\tsignal.nextSignalToUpdate = null;\n\t\tsignal = nextSignal;\n\t}\n\n\tif (didError) {\n\t\tthrow error;\n\t}\n}\n","import context from \"../render/context\";\nimport triggerEffects from \"./triggerEffects\";\n\nexport default function batchEnd(): void {\n\tif (context.batch > 1) {\n\t\tcontext.batch--;\n\t\treturn;\n\t}\n\n\ttry {\n\t\ttriggerEffects();\n\t} finally {\n\t\tcontext.batch = 0;\n\t\tcontext.batchOperation = 0;\n\t\tcontext.previousEffect = null;\n\t}\n}\n","import batchEnd from \"../watch/batchEnd\";\nimport batchStart from \"../watch/batchStart\";\nimport context from \"./context\";\n\n/**\n * Runs updates to proxy values in a batch, where the updates are stored in\n * context, and dependent effects are run all at once at the end.\n *\n * @param fn The function containing the batched updates to run.\n */\nexport default function $batch<T>(fn: () => T): T {\n\tif (context.batch > 0) {\n\t\treturn fn();\n\t}\n\n\tbatchStart();\n\ttry {\n\t\treturn fn();\n\t} finally {\n\t\tbatchEnd();\n\t}\n}\n","import type Computed from \"../types/Computed\";\nimport { COMPUTED_TYPE } from \"../types/constants\";\nimport runComputed from \"../watch/runComputed\";\nimport context from \"./context\";\n\n/**\n * Caches a computed value from signals accessed in a property getter.\n *\n * @param fn The function containing the signals to compute and cache.\n */\nexport default function $cache<T>(fn: () => T): T {\n\tif (context.registerComputed === null) {\n\t\tthrow new Error(\"$cache must be used in a getter\");\n\t}\n\n\tlet computed: Computed = {\n\t\ttype: COMPUTED_TYPE,\n\t\tvalue: null,\n\t\trun: fn,\n\t\tfirstSource: null,\n\t\tfirstTarget: null,\n\t\trecalc: false,\n\t\trunning: false,\n\t\tdidError: false,\n\t\trollback: null,\n\t\t//name: dev.effectName(fn),\n\t};\n\n\tcontext.registerComputed(computed);\n\n\trunComputed(computed);\n\n\treturn computed.value;\n}\n","import context from \"./context\";\n\n// Not sure if this is a good idea?\n\nexport default function $peek<T>(fn: () => T): T {\n\tconst oldActiveTarget = context.activeTarget;\n\tcontext.activeTarget = null;\n\n\tconst result = fn();\n\n\tcontext.activeTarget = oldActiveTarget;\n\n\treturn result;\n}\n","export default function buildClasses(value: unknown, styleHash?: string): string {\n\tif (typeof value === \"string\") {\n\t\tif (styleHash !== undefined) {\n\t\t\tvalue += \" \" + styleHash;\n\t\t}\n\t\treturn value;\n\t} else {\n\t\tlet classes: string[] = [];\n\t\tgatherNames(\"\", value, classes);\n\t\tif (styleHash !== undefined) {\n\t\t\tclasses.push(styleHash);\n\t\t}\n\t\treturn classes.join(\" \");\n\t}\n}\n\nfunction gatherNames(name: unknown, value: unknown, classes: string[]) {\n\tif (value) {\n\t\tif (Array.isArray(value)) {\n\t\t\tfor (let v of value) {\n\t\t\t\tgatherNames(v, v, classes);\n\t\t\t}\n\t\t} else if (typeof value === \"object\") {\n\t\t\tfor (let [n, v] of Object.entries(value)) {\n\t\t\t\tgatherNames(n, v, classes);\n\t\t\t}\n\t\t} else {\n\t\t\tclasses.push(name as string);\n\t\t}\n\t}\n}\n","export default function buildStyles(value: unknown): string {\n\tif (typeof value === \"string\") {\n\t\treturn value;\n\t} else {\n\t\tlet styles: string[] = [];\n\t\tif (value) {\n\t\t\tif (Array.isArray(value)) {\n\t\t\t\tfor (let v of value) {\n\t\t\t\t\tstyles.push(v);\n\t\t\t\t}\n\t\t\t} else if (typeof value === \"object\") {\n\t\t\t\tfor (let [n, v] of Object.entries(value)) {\n\t\t\t\t\tstyles.push(`${n}: ${v}`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn styles.join(\"; \");\n\t}\n}\n","export default function formatText(value: any): string {\n\treturn value ?? \"\";\n}\n"],"mappings":";AAEA,MAAMA,UAAmB;CACxB,cAAc;CACd,gBAAgB;CAChB,QAAQ;CACR,OAAO;CACP,gBAAgB;CAChB,kBAAkB;CAElB,kBAAkB;CAClB,qBAAqB;CAIrB,aAAa;CAEb,eAAe;CAEf,WAAW;CAEX,cAAc,EAAE;CAChB,eAAe,EAAE;CACjB,mBAAmB,EAAE;CAErB,eAAe;CASf;AAED,sBAAe;;;;;;;ACjCf,MAAa,cAAc;;;;AAK3B,MAAa,gBAAgB;;;;AAK7B,MAAa,cAAc;;;;;;;ACN3B,SAAwB,aAAa,QAAiC;CACrE,IAAIC,cAAmC;AACvC,MACC,IAAIC,WAAgC,OAAO,aAC3C,aAAa,MACb,WAAW,SAAS,WAEpB,KAAI,OAAO,YAAY,CAAC,SAAS,QAAQ;AAIxC,MAAI,gBAAgB,KACnB,QAAO,cAAc,SAAS;MAE9B,aAAY,aAAa,SAAS;AAInC,MAAI,SAAS,mBAAmB,MAC/B;OAAI,SAAS,OAAO,gBAAgB,SACnC,UAAS,OAAO,cAAc,SAAS;QAIxC,UAAS,eAAe,aAAa,SAAS;QAEzC;AACN,WAAS,SAAS;AAClB,gBAAc;;;;;;;;;AC5BjB,SAAwB,kBAAkB,QAAiC;AA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AI,KAAK,MACb,aAAY,GAAG,GAAG,QAAQ;UAEjB,OAAO,UAAU,SAC3B,MAAK,IAAI,CAAC,GAAG,MAAM,OAAO,QAAQ,MAAM,CACvC,aAAY,GAAG,GAAG,QAAQ;KAG3B,SAAQ,KAAK,KAAe;;;;;AC3B/B,SAAwB,YAAY,OAAwB;AAC3D,KAAI,OAAO,UAAU,SACpB,QAAO;MACD;EACN,IAAIC,SAAmB,EAAE;AACzB,MAAI,OACH;OAAI,MAAM,QAAQ,MAAM,CACvB,MAAK,IAAI,KAAK,MACb,QAAO,KAAK,EAAE;YAEL,OAAO,UAAU,SAC3B,MAAK,IAAI,CAAC,GAAG,MAAM,OAAO,QAAQ,MAAM,CACvC,QAAO,KAAK,GAAG,EAAE,IAAI,IAAI;;AAI5B,SAAO,OAAO,KAAK,KAAK;;;;;;AChB1B,SAAwB,WAAW,OAAoB;AACtD,QAAO,SAAS"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatText-DufG5l83.cjs","names":["context: Context","previousSub: Subscription | null","clearSub: Subscription | null","sourceSub: Subscription | null","context","sub: Subscription | null","lastSub: Subscription | null","nextSub: Subscription | null","context","targetSub: Subscription | null","sourceSub: Subscription | null","context","effectToClean: Effect | null","context","nextEffect: Effect","context","previousSub: Subscription | null","clearSub: Subscription | null","error: any","effect: Effect | null","context","signal: ProxySignal | null","context","context","context","computed: Computed","context","classes: string[]","styles: string[]"],"sources":["../src/render/context.ts","../src/types/constants.ts","../src/watch/clearSources.ts","../src/watch/deactivateSources.ts","../src/watch/trackEffect.ts","../src/watch/runComputed.ts","../src/watch/checkComputed.ts","../src/watch/checkSources.ts","../src/watch/runCleanups.ts","../src/watch/batchStart.ts","../src/watch/runEffect.ts","../src/watch/checkEffect.ts","../src/watch/clearTargets.ts","../src/watch/triggerEffects.ts","../src/watch/batchEnd.ts","../src/render/$batch.ts","../src/render/$cache.ts","../src/render/$peek.ts","../src/render/buildClasses.ts","../src/render/buildStyles.ts","../src/render/formatText.ts"],"sourcesContent":["import type Context from \"../types/Context\";\n\nconst context: Context = {\n\tactiveTarget: null,\n\tpreviousEffect: null,\n\textent: 0,\n\tbatch: 0,\n\tbatchOperation: 0,\n\tregisterComputed: null,\n\n\tfirstEffectToRun: null,\n\tfirstSignalToUpdate: null,\n\n\t// These will definitely be set, in mount or render\n\t// @ts-ignore\n\tactiveRange: null,\n\t// @ts-ignore\n\tpreviousRange: null,\n\t// @ts-ignore\n\trootRange: null,\n\n\tmountEffects: [],\n\tstashedEvents: [],\n\tstashedAnimations: [],\n\n\thydrationNode: null,\n\t//hn: null,\n\t//get hydrationNode() {\n\t//\treturn this.hn;\n\t//},\n\t//set hydrationNode(value) {\n\t//\tconsole.log(`set hydration ${printNode(value)}`);\n\t//\tthis.hn = value;\n\t//},\n};\n\nexport default context;\n","/**\n * The type of a Signal object.\n */\nexport const SIGNAL_TYPE = 0;\n\n/**\n * The type of a Computed object.\n */\nexport const COMPUTED_TYPE = 1;\n\n/**\n * The type of an Effect object.\n */\nexport const EFFECT_TYPE = 2;\n","import type Computed from \"../types/Computed\";\nimport type Effect from \"../types/Effect\";\nimport type Subscription from \"../types/Subscription\";\n\n/**\n * Clear unused source subscriptions after each Computed or Effect has been run.\n */\nexport default function clearSources(target: Computed | Effect): void {\n\tlet previousSub: Subscription | null = null;\n\tfor (\n\t\tlet clearSub: Subscription | null = target.firstSource;\n\t\tclearSub !== null;\n\t\tclearSub = clearSub.nextSource\n\t) {\n\t\tif (target.didError || !clearSub.active) {\n\t\t\t//console.log(\n\t\t\t//\t`clearing source sub ${clearSub.source.name} <-> ${clearSub.target.name} (${clearSub.name})`,\n\t\t\t//);\n\t\t\tif (previousSub === null) {\n\t\t\t\ttarget.firstSource = clearSub.nextSource;\n\t\t\t} else {\n\t\t\t\tpreviousSub.nextSource = clearSub.nextSource;\n\t\t\t}\n\n\t\t\t// Update the targets list too\n\t\t\tif (clearSub.previousTarget === null) {\n\t\t\t\tif (clearSub.source.firstTarget === clearSub) {\n\t\t\t\t\tclearSub.source.firstTarget = clearSub.nextTarget;\n\t\t\t\t}\n\t\t\t\t// TODO: else???\n\t\t\t} else {\n\t\t\t\tclearSub.previousTarget.nextTarget = clearSub.nextTarget;\n\t\t\t}\n\t\t} else {\n\t\t\tclearSub.recalc = false;\n\t\t\tpreviousSub = clearSub;\n\t\t}\n\t}\n}\n","import type Computed from \"../types/Computed\";\nimport type Effect from \"../types/Effect\";\nimport type Subscription from \"../types/Subscription\";\n\n/**\n * Sets source subscriptions to inactive for a Computed or Effect.\n */\nexport default function deactivateSources(target: Computed | Effect): void {\n\tfor (\n\t\tlet sourceSub: Subscription | null = target.firstSource;\n\t\tsourceSub !== null;\n\t\tsourceSub = sourceSub.nextSource\n\t) {\n\t\tsourceSub.active = false;\n\t\t//console.log(\n\t\t//\t`deactivating ${sourceSub.source.name} <-> ${sourceSub.target.name} (${sourceSub.name})`,\n\t\t//);\n\t}\n}\n","import context from \"../render/context\";\nimport type Computed from \"../types/Computed\";\nimport type ProxySignal from \"../types/ProxySignal\";\nimport type Subscription from \"../types/Subscription\";\n\n// TODO: Rename this to `subscribe` because its purpose has changed a bit\n\n/**\n * If there's an active target, subscribe it to this signal, so that it will be\n * run when the signal changes.\n */\nexport default function trackEffect(signal: ProxySignal | Computed): void {\n\tconst target = context.activeTarget;\n\tif (target !== null) {\n\t\tlet sub: Subscription | null = null;\n\t\tlet lastSub: Subscription | null = null;\n\n\t\t// Check if there's a sub we can re-use\n\t\t// TODO: Maybe we could be smarter with this\n\t\t// -- use the target sub instead?\n\t\t// -- do it differently on push vs pull??\n\t\tfor (\n\t\t\tlet nextSub: Subscription | null = signal.firstTarget;\n\t\t\tnextSub !== null;\n\t\t\tnextSub = nextSub.nextTarget\n\t\t) {\n\t\t\tlastSub = nextSub;\n\t\t\tif (nextSub.target === target) {\n\t\t\t\tsub = nextSub;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (sub === null) {\n\t\t\tsub = {\n\t\t\t\tsource: signal,\n\t\t\t\ttarget: target,\n\t\t\t\tpreviousTarget: lastSub,\n\t\t\t\tnextTarget: null,\n\t\t\t\tnextSource: null,\n\t\t\t\tactive: true,\n\t\t\t\trecalc: false,\n\t\t\t\t//name: dev.subName(),\n\t\t\t};\n\t\t\t//console.log(`creating sub '${signal.name}' => '${effect.name}' (${sub.name})`);\n\t\t\tif (lastSub === null) {\n\t\t\t\tsignal.firstTarget = sub;\n\t\t\t} else {\n\t\t\t\tlastSub.nextTarget = sub;\n\t\t\t}\n\n\t\t\tif (target.firstSource === null) {\n\t\t\t\ttarget.firstSource = sub;\n\t\t\t} else {\n\t\t\t\tlet lastEffectSub = target.firstSource;\n\t\t\t\tfor (\n\t\t\t\t\tlet nextSub: Subscription | null = lastEffectSub.nextSource;\n\t\t\t\t\tnextSub !== null;\n\t\t\t\t\tnextSub = nextSub.nextSource\n\t\t\t\t) {\n\t\t\t\t\tlastEffectSub = nextSub;\n\t\t\t\t}\n\t\t\t\tlastEffectSub.nextSource = sub;\n\t\t\t}\n\t\t} else {\n\t\t\t// We can re-use this subscription object\n\t\t\t//console.log(`re-using sub '${signal.name}' => '${effect.name}' (${sub.name})`);\n\t\t\tsub.active = true;\n\t\t}\n\t}\n}\n","import context from \"../render/context\";\nimport type Computed from \"../types/Computed\";\nimport trackEffect from \"./trackEffect\";\n\nexport default function runComputed<T>(computed: Computed<T>): T {\n\t//console.log(`running computed '${computed.name}'`);\n\n\t// Store the active target\n\tconst oldActiveTarget = context.activeTarget;\n\n\tcomputed.running = true;\n\tcomputed.didError = false;\n\n\ttry {\n\t\t// Set the active target, so that any properties accessed while running it\n\t\t// will trigger it in future\n\t\tcontext.activeTarget = computed;\n\n\t\t// Run the computed and gather its dependencies\n\t\tcomputed.value = computed.run();\n\t} catch (err) {\n\t\tcomputed.didError = true;\n\t\t// @ts-ignore\n\t\tcomputed.value = err;\n\t\tthrow err;\n\t} finally {\n\t\t// Set the active target back to what it was previously\n\t\tcontext.activeTarget = oldActiveTarget;\n\n\t\tcomputed.running = false;\n\t}\n\n\ttrackEffect(computed);\n\n\treturn computed.value;\n}\n","import type Computed from \"../types/Computed\";\nimport type Subscription from \"../types/Subscription\";\nimport checkSources from \"./checkSources\";\nimport clearSources from \"./clearSources\";\nimport deactivateSources from \"./deactivateSources\";\nimport runComputed from \"./runComputed\";\n\n/**\n * Checks whether a Computed value should be re-run (which will be true if any\n * of its sources have changed) and re-runs it if necessary.\n */\nexport default function checkComputed(computed: Computed): boolean {\n\tlet rerun = checkSources(computed);\n\n\tlet changed = false;\n\n\tif (rerun) {\n\t\t// Set source subscriptions to inactive\n\t\tdeactivateSources(computed);\n\n\t\t// Run the computed, which will reset subscriptions\n\t\tconst oldValue = computed.value;\n\t\trunComputed(computed);\n\t\tchanged = computed.value !== oldValue;\n\n\t\t// Clear unused source subscriptions\n\t\tclearSources(computed);\n\t}\n\n\tcomputed.recalc = false;\n\n\t// If it hasn't changed, all of its target subscriptions remain active and\n\t// don't need to be recalculated\n\tif (!changed) {\n\t\tfor (\n\t\t\tlet targetSub: Subscription | null = computed.firstTarget;\n\t\t\ttargetSub !== null;\n\t\t\ttargetSub = targetSub.nextTarget\n\t\t) {\n\t\t\ttargetSub.active = true;\n\t\t\ttargetSub.recalc = false;\n\t\t}\n\t}\n\n\treturn changed;\n}\n","import context from \"../render/context\";\nimport type Computed from \"../types/Computed\";\nimport type Effect from \"../types/Effect\";\nimport type Subscription from \"../types/Subscription\";\nimport { COMPUTED_TYPE, SIGNAL_TYPE } from \"../types/constants\";\nimport checkComputed from \"./checkComputed\";\n\n// RECURSIVE\n\n/**\n * Checks whether a Computed or Effect should be re-run (which will be true if\n * any of its sources have changed).\n */\nexport default function checkSources(target: Computed | Effect): boolean {\n\t// NOTE: We bail early if we know the target needs to be re-run; subsequent\n\t// computed values will be computed in the proxy getter\n\n\t// Check signals first as it's cheap, then computed values\n\tlet haveComputed = false;\n\n\tfor (\n\t\tlet sourceSub: Subscription | null = target.firstSource;\n\t\tsourceSub !== null;\n\t\tsourceSub = sourceSub.nextSource\n\t) {\n\t\t//console.log(`checking source sub '${sourceSub.source.name}' (${sourceSub.name})`);\n\t\tif (sourceSub.recalc) {\n\t\t\tif (sourceSub.source.type === SIGNAL_TYPE) {\n\t\t\t\treturn true;\n\t\t\t} /* else if (sourceSub.source.type === COMPUTED_TYPE) */ else {\n\t\t\t\tif (sourceSub.source.recalc) {\n\t\t\t\t\thaveComputed = true;\n\t\t\t\t} else {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (haveComputed) {\n\t\tfor (\n\t\t\tlet sourceSub: Subscription | null = target.firstSource;\n\t\t\tsourceSub !== null;\n\t\t\tsourceSub = sourceSub.nextSource\n\t\t) {\n\t\t\t//console.log(`checking source sub '${sourceSub.source.name}' (${sourceSub.name})`);\n\t\t\tif (sourceSub.recalc && sourceSub.source.type === COMPUTED_TYPE && sourceSub.source.recalc) {\n\t\t\t\tconst oldActiveTarget = context.activeTarget;\n\t\t\t\tcontext.activeTarget = target;\n\n\t\t\t\tconst recalc = checkComputed(sourceSub.source);\n\n\t\t\t\tcontext.activeTarget = oldActiveTarget;\n\n\t\t\t\tif (recalc) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn false;\n}\n","import context from \"../render/context\";\nimport type Effect from \"../types/Effect\";\nimport clearSources from \"./clearSources\";\n\n/**\n * Runs cleanup functions for the effect and its children.\n */\nexport default function runCleanups(effect: Effect): void {\n\tlet effectToClean: Effect | null = effect;\n\tfor (let i = 0; i < effect.extent; i++) {\n\t\tif (typeof effectToClean.cleanup === \"function\") {\n\t\t\t//console.log(`cleaning effect '${effectToClean.name}'`);\n\t\t\tconst oldActiveTarget = context.activeTarget;\n\t\t\tcontext.activeTarget = null;\n\n\t\t\ttry {\n\t\t\t\teffectToClean.cleanup();\n\t\t\t} catch (err) {\n\t\t\t\teffectToClean.didError = true;\n\t\t\t\tclearSources(effectToClean);\n\t\t\t\tthrow err;\n\t\t\t} finally {\n\t\t\t\teffectToClean.cleanup = undefined;\n\t\t\t\tcontext.activeTarget = oldActiveTarget;\n\t\t\t}\n\t\t}\n\n\t\tconst nextEffect: Effect = effectToClean.nextEffect!;\n\n\t\t// If it's a child effect that has been triggered, clean it up\n\t\t// and remove it from the list of effects to run (it may get\n\t\t// re-created with the parent)\n\t\tif (i !== 0 && effect.nextEffectToRun === effectToClean) {\n\t\t\teffect.nextEffectToRun = effectToClean.nextEffectToRun;\n\t\t\teffectToClean.nextEffect = effectToClean.nextEffectToRun = null;\n\t\t}\n\n\t\teffectToClean = nextEffect;\n\t}\n}\n","import context from \"../render/context\";\n\nexport default function batchStart(): void {\n\tcontext.batch++;\n}\n","import context from \"../render/context\";\nimport type Effect from \"../types/Effect\";\nimport batchEnd from \"./batchEnd\";\nimport batchStart from \"./batchStart\";\nimport clearSources from \"./clearSources\";\n\nexport default function runEffect(effect: Effect): void {\n\t//console.log(`running effect '${effect.name}'`);\n\n\t// Store the active target\n\tconst oldActiveTarget = context.activeTarget;\n\tconst oldExtent = context.extent;\n\n\teffect.didError = false;\n\n\tbatchStart();\n\n\ttry {\n\t\t// Set the next effect for navigating through\n\t\tif (context.previousEffect !== null) {\n\t\t\tcontext.previousEffect.nextEffect = effect;\n\t\t}\n\n\t\t// Set the active effect, so that any properties accessed while running it\n\t\t// will trigger it in future\n\t\tcontext.activeTarget = effect;\n\t\tcontext.previousEffect = effect;\n\t\tcontext.extent = 1;\n\n\t\t// Run the effect to register its subscriptions and get its (optional)\n\t\t// cleanup function\n\t\teffect.cleanup = effect.run();\n\n\t\teffect.extent = context.extent;\n\t} catch (err) {\n\t\teffect.didError = true;\n\t\tclearSources(effect);\n\t\tthrow err;\n\t} finally {\n\t\t// Set the active target back to what it was previously\n\t\tcontext.activeTarget = oldActiveTarget;\n\t\tcontext.extent += oldExtent - 1;\n\n\t\tbatchEnd();\n\t}\n}\n","import type Effect from \"../types/Effect\";\nimport checkSources from \"./checkSources\";\nimport clearSources from \"./clearSources\";\nimport deactivateSources from \"./deactivateSources\";\nimport runCleanups from \"./runCleanups\";\nimport runEffect from \"./runEffect\";\n\n/**\n * Checks whether an Effect should be re-run (which will be true if any\n * of its sources have changed) and re-runs it if necessary.\n */\nexport default function checkEffect(effect: Effect): void {\n\t//console.log(`checking effect '${effect.name}'`);\n\n\tlet rerun = checkSources(effect);\n\n\tif (rerun) {\n\t\t// Run cleanup functions for the effect and its children\n\t\trunCleanups(effect);\n\n\t\t// Set source subscriptions to inactive\n\t\tdeactivateSources(effect);\n\n\t\t// Run the effect, which will reset subscriptions\n\t\trunEffect(effect);\n\n\t\t// Clear unused source subscriptions\n\t\tclearSources(effect);\n\t}\n}\n","import type Computed from \"../types/Computed\";\nimport type ProxySignal from \"../types/ProxySignal\";\nimport type Subscription from \"../types/Subscription\";\n\n/**\n * Clear unused target subscriptions after all Effects have been run.\n */\nexport default function clearTargets(source: ProxySignal | Computed): void {\n\tlet previousSub: Subscription | null = null;\n\tfor (\n\t\tlet clearSub: Subscription | null = source.firstTarget;\n\t\tclearSub !== null;\n\t\tclearSub = clearSub.nextTarget\n\t) {\n\t\tif (!clearSub.active) {\n\t\t\t//console.log(\n\t\t\t//\t`clearing target sub ${clearSub.source.name} <-> ${clearSub.target.name} (${clearSub.name})`,\n\t\t\t//);\n\t\t\tif (previousSub === null) {\n\t\t\t\tsource.firstTarget = clearSub.nextTarget;\n\t\t\t} else {\n\t\t\t\tpreviousSub.nextTarget = clearSub.nextTarget;\n\t\t\t}\n\t\t} else {\n\t\t\tpreviousSub = clearSub;\n\t\t}\n\t}\n}\n","import context from \"../render/context\";\nimport type Effect from \"../types/Effect\";\nimport type ProxySignal from \"../types/ProxySignal\";\nimport checkEffect from \"./checkEffect\";\nimport clearTargets from \"./clearTargets\";\n\n/**\n * Runs the effects that have been collected during the batch.\n */\nexport default function triggerEffects(): void {\n\t//console.log(`triggering effects for '${String(key)}' on`, proxy);\n\t//console.log(\"===\");\n\t//console.log(`triggering effects for '${String(key)}'`);\n\n\tlet didError = false;\n\tlet error: any;\n\n\t// Run the effects\n\tlet effect: Effect | null = context.firstEffectToRun;\n\twhile (effect !== null) {\n\t\tcontext.batchOperation++;\n\n\t\ttry {\n\t\t\tcheckEffect(effect);\n\t\t} catch (err) {\n\t\t\tif (!didError) {\n\t\t\t\tdidError = true;\n\t\t\t\terror = err;\n\t\t\t}\n\t\t}\n\n\t\teffect = effect.nextEffectToRun;\n\t}\n\n\t// Clear the effects\n\teffect = context.firstEffectToRun;\n\tcontext.firstEffectToRun = null;\n\twhile (effect !== null) {\n\t\tlet nextEffect = effect.nextEffectToRun;\n\t\teffect.nextEffectToRun = null;\n\t\teffect = nextEffect;\n\t}\n\n\t// Clear unused target subscriptions for the signals that were updated\n\t// during the batch\n\tlet signal: ProxySignal | null = context.firstSignalToUpdate;\n\tcontext.firstSignalToUpdate = null;\n\twhile (signal !== null) {\n\t\tclearTargets(signal);\n\n\t\tconst nextSignal = signal.nextSignalToUpdate;\n\t\tsignal.nextSignalToUpdate = null;\n\t\tsignal = nextSignal;\n\t}\n\n\tif (didError) {\n\t\tthrow error;\n\t}\n}\n","import context from \"../render/context\";\nimport triggerEffects from \"./triggerEffects\";\n\nexport default function batchEnd(): void {\n\tif (context.batch > 1) {\n\t\tcontext.batch--;\n\t\treturn;\n\t}\n\n\ttry {\n\t\ttriggerEffects();\n\t} finally {\n\t\tcontext.batch = 0;\n\t\tcontext.batchOperation = 0;\n\t\tcontext.previousEffect = null;\n\t}\n}\n","import batchEnd from \"../watch/batchEnd\";\nimport batchStart from \"../watch/batchStart\";\nimport context from \"./context\";\n\n/**\n * Runs updates to proxy values in a batch, where the updates are stored in\n * context, and dependent effects are run all at once at the end.\n *\n * @param fn The function containing the batched updates to run.\n */\nexport default function $batch<T>(fn: () => T): T {\n\tif (context.batch > 0) {\n\t\treturn fn();\n\t}\n\n\tbatchStart();\n\ttry {\n\t\treturn fn();\n\t} finally {\n\t\tbatchEnd();\n\t}\n}\n","import type Computed from \"../types/Computed\";\nimport { COMPUTED_TYPE } from \"../types/constants\";\nimport runComputed from \"../watch/runComputed\";\nimport context from \"./context\";\n\n/**\n * Caches a computed value from signals accessed in a property getter.\n *\n * @param fn The function containing the signals to compute and cache.\n */\nexport default function $cache<T>(fn: () => T): T {\n\tif (context.registerComputed === null) {\n\t\tthrow new Error(\"$cache must be used in a getter\");\n\t}\n\n\tlet computed: Computed = {\n\t\ttype: COMPUTED_TYPE,\n\t\tvalue: null,\n\t\trun: fn,\n\t\tfirstSource: null,\n\t\tfirstTarget: null,\n\t\trecalc: false,\n\t\trunning: false,\n\t\tdidError: false,\n\t\trollback: null,\n\t\t//name: dev.effectName(fn),\n\t};\n\n\tcontext.registerComputed(computed);\n\n\trunComputed(computed);\n\n\treturn computed.value;\n}\n","import context from \"./context\";\n\n// Not sure if this is a good idea?\n\nexport default function $peek<T>(fn: () => T): T {\n\tconst oldActiveTarget = context.activeTarget;\n\tcontext.activeTarget = null;\n\n\tconst result = fn();\n\n\tcontext.activeTarget = oldActiveTarget;\n\n\treturn result;\n}\n","export default function buildClasses(value: unknown, styleHash?: string): string {\n\tif (typeof value === \"string\") {\n\t\tif (styleHash !== undefined) {\n\t\t\tvalue += \" \" + styleHash;\n\t\t}\n\t\treturn value;\n\t} else {\n\t\tlet classes: string[] = [];\n\t\tgatherNames(\"\", value, classes);\n\t\tif (styleHash !== undefined) {\n\t\t\tclasses.push(styleHash);\n\t\t}\n\t\treturn classes.join(\" \");\n\t}\n}\n\nfunction gatherNames(name: unknown, value: unknown, classes: string[]) {\n\tif (value) {\n\t\tif (Array.isArray(value)) {\n\t\t\tfor (let v of value) {\n\t\t\t\tgatherNames(v, v, classes);\n\t\t\t}\n\t\t} else if (typeof value === \"object\") {\n\t\t\tfor (let [n, v] of Object.entries(value)) {\n\t\t\t\tgatherNames(n, v, classes);\n\t\t\t}\n\t\t} else {\n\t\t\tclasses.push(name as string);\n\t\t}\n\t}\n}\n","export default function buildStyles(value: unknown): string {\n\tif (typeof value === \"string\") {\n\t\treturn value;\n\t} else {\n\t\tlet styles: string[] = [];\n\t\tif (value) {\n\t\t\tif (Array.isArray(value)) {\n\t\t\t\tfor (let v of value) {\n\t\t\t\t\tstyles.push(v);\n\t\t\t\t}\n\t\t\t} else if (typeof value === \"object\") {\n\t\t\t\tfor (let [n, v] of Object.entries(value)) {\n\t\t\t\t\tstyles.push(`${n}: ${v}`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn styles.join(\"; \");\n\t}\n}\n","export default function formatText(value: any): string {\n\treturn value ?? \"\";\n}\n"],"mappings":";;AAEA,MAAMA,UAAmB;CACxB,cAAc;CACd,gBAAgB;CAChB,QAAQ;CACR,OAAO;CACP,gBAAgB;CAChB,kBAAkB;CAElB,kBAAkB;CAClB,qBAAqB;CAIrB,aAAa;CAEb,eAAe;CAEf,WAAW;CAEX,cAAc,EAAE;CAChB,eAAe,EAAE;CACjB,mBAAmB,EAAE;CAErB,eAAe;CASf;AAED,sBAAe;;;;;;;ACjCf,MAAa,cAAc;;;;AAK3B,MAAa,gBAAgB;;;;AAK7B,MAAa,cAAc;;;;;;;ACN3B,SAAwB,aAAa,QAAiC;CACrE,IAAIC,cAAmC;AACvC,MACC,IAAIC,WAAgC,OAAO,aAC3C,aAAa,MACb,WAAW,SAAS,WAEpB,KAAI,OAAO,YAAY,CAAC,SAAS,QAAQ;AAIxC,MAAI,gBAAgB,KACnB,QAAO,cAAc,SAAS;MAE9B,aAAY,aAAa,SAAS;AAInC,MAAI,SAAS,mBAAmB,MAC/B;OAAI,SAAS,OAAO,gBAAgB,SACnC,UAAS,OAAO,cAAc,SAAS;QAIxC,UAAS,eAAe,aAAa,SAAS;QAEzC;AACN,WAAS,SAAS;AAClB,gBAAc;;;;;;;;;AC5BjB,SAAwB,kBAAkB,QAAiC;AAC1E,MACC,IAAIC,YAAiC,OAAO,aAC5C,cAAc,MACd,YAAY,UAAU,WAEtB,WAAU,SA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I,CAAC,GAAG,MAAM,OAAO,QAAQ,MAAM,CACvC,aAAY,GAAG,GAAG,QAAQ;KAG3B,SAAQ,KAAK,KAAe;;;;;AC3B/B,SAAwB,YAAY,OAAwB;AAC3D,KAAI,OAAO,UAAU,SACpB,QAAO;MACD;EACN,IAAIC,SAAmB,EAAE;AACzB,MAAI,OACH;OAAI,MAAM,QAAQ,MAAM,CACvB,MAAK,IAAI,KAAK,MACb,QAAO,KAAK,EAAE;YAEL,OAAO,UAAU,SAC3B,MAAK,IAAI,CAAC,GAAG,MAAM,OAAO,QAAQ,MAAM,CACvC,QAAO,KAAK,GAAG,EAAE,IAAI,IAAI;;AAI5B,SAAO,OAAO,KAAK,KAAK;;;;;;AChB1B,SAAwB,WAAW,OAAoB;AACtD,QAAO,SAAS"}
|
|
1
|
+
{"version":3,"file":"formatText-DufG5l83.cjs","names":["context: Context","previousSub: Subscription | null","clearSub: Subscription | null","sourceSub: Subscription | null","context","sub: Subscription | null","lastSub: Subscription | null","nextSub: Subscription | null","context","targetSub: Subscription | null","sourceSub: Subscription | null","context","effectToClean: Effect | null","context","nextEffect: Effect","context","previousSub: Subscription | null","clearSub: Subscription | null","error: any","effect: Effect | null","context","signal: ProxySignal | null","context","context","context","computed: Computed","context","classes: string[]","styles: string[]"],"sources":["../src/render/context.ts","../src/types/constants.ts","../src/watch/clearSources.ts","../src/watch/deactivateSources.ts","../src/watch/trackEffect.ts","../src/watch/runComputed.ts","../src/watch/checkComputed.ts","../src/watch/checkSources.ts","../src/watch/runCleanups.ts","../src/watch/batchStart.ts","../src/watch/runEffect.ts","../src/watch/checkEffect.ts","../src/watch/clearTargets.ts","../src/watch/triggerEffects.ts","../src/watch/batchEnd.ts","../src/render/$batch.ts","../src/render/$cache.ts","../src/render/$peek.ts","../src/render/buildClasses.ts","../src/render/buildStyles.ts","../src/render/formatText.ts"],"sourcesContent":["import type Context from \"../types/Context\";\n\nconst context: Context = {\n\tactiveTarget: null,\n\tpreviousEffect: null,\n\textent: 0,\n\tbatch: 0,\n\tbatchOperation: 0,\n\tregisterComputed: null,\n\n\tfirstEffectToRun: null,\n\tfirstSignalToUpdate: null,\n\n\t// These will definitely be set, in mount or render\n\t// @ts-ignore\n\tactiveRange: null,\n\t// @ts-ignore\n\tpreviousRange: null,\n\t// @ts-ignore\n\trootRange: null,\n\n\tmountEffects: [],\n\tstashedEvents: [],\n\tstashedAnimations: [],\n\n\thydrationNode: null,\n\t//hn: null,\n\t//get hydrationNode() {\n\t//\treturn this.hn;\n\t//},\n\t//set hydrationNode(value) {\n\t//\tconsole.log(`set hydration ${printNode(value)}`);\n\t//\tthis.hn = value;\n\t//},\n};\n\nexport default context;\n","/**\n * The type of a Signal object.\n */\nexport const SIGNAL_TYPE = 0;\n\n/**\n * The type of a Computed object.\n */\nexport const COMPUTED_TYPE = 1;\n\n/**\n * The type of an Effect object.\n */\nexport const EFFECT_TYPE = 2;\n","import type Computed from \"../types/Computed\";\nimport type Effect from \"../types/Effect\";\nimport type Subscription from \"../types/Subscription\";\n\n/**\n * Clear unused source subscriptions after each Computed or Effect has been run.\n */\nexport default function clearSources(target: Computed | Effect): void {\n\tlet previousSub: Subscription | null = null;\n\tfor (\n\t\tlet clearSub: Subscription | null = target.firstSource;\n\t\tclearSub !== null;\n\t\tclearSub = clearSub.nextSource\n\t) {\n\t\tif (target.didError || !clearSub.active) {\n\t\t\t//console.log(\n\t\t\t//\t`clearing source sub ${clearSub.source.name} <-> ${clearSub.target.name} (${clearSub.name})`,\n\t\t\t//);\n\t\t\tif (previousSub === null) {\n\t\t\t\ttarget.firstSource = clearSub.nextSource;\n\t\t\t} else {\n\t\t\t\tpreviousSub.nextSource = clearSub.nextSource;\n\t\t\t}\n\n\t\t\t// Update the targets list too\n\t\t\tif (clearSub.previousTarget === null) {\n\t\t\t\tif (clearSub.source.firstTarget === clearSub) {\n\t\t\t\t\tclearSub.source.firstTarget = clearSub.nextTarget;\n\t\t\t\t}\n\t\t\t\t// TODO: else???\n\t\t\t} else {\n\t\t\t\tclearSub.previousTarget.nextTarget = clearSub.nextTarget;\n\t\t\t}\n\t\t} else {\n\t\t\tclearSub.recalc = false;\n\t\t\tpreviousSub = clearSub;\n\t\t}\n\t}\n}\n","import type Computed from \"../types/Computed\";\nimport type Effect from \"../types/Effect\";\nimport type Subscription from \"../types/Subscription\";\n\n/**\n * Sets source subscriptions to inactive for a Computed or Effect.\n */\nexport default function deactivateSources(target: Computed | Effect): void {\n\tfor (\n\t\tlet sourceSub: Subscription | null = target.firstSource;\n\t\tsourceSub !== null;\n\t\tsourceSub = sourceSub.nextSource\n\t) {\n\t\tsourceSub.active = false;\n\t\t//console.log(\n\t\t//\t`deactivating ${sourceSub.source.name} <-> ${sourceSub.target.name} (${sourceSub.name})`,\n\t\t//);\n\t}\n}\n","import context from \"../render/context\";\nimport type Computed from \"../types/Computed\";\nimport type ProxySignal from \"../types/ProxySignal\";\nimport type Subscription from \"../types/Subscription\";\n\n// TODO: Rename this to `subscribe` because its purpose has changed a bit\n\n/**\n * If there's an active target, subscribe it to this signal, so that it will be\n * run when the signal changes.\n */\nexport default function trackEffect(signal: ProxySignal | Computed): void {\n\tconst target = context.activeTarget;\n\tif (target !== null) {\n\t\tlet sub: Subscription | null = null;\n\t\tlet lastSub: Subscription | null = null;\n\n\t\t// Check if there's a sub we can re-use\n\t\t// TODO: Maybe we could be smarter with this\n\t\t// -- use the target sub instead?\n\t\t// -- do it differently on push vs pull??\n\t\tfor (\n\t\t\tlet nextSub: Subscription | null = signal.firstTarget;\n\t\t\tnextSub !== null;\n\t\t\tnextSub = nextSub.nextTarget\n\t\t) {\n\t\t\tlastSub = nextSub;\n\t\t\tif (nextSub.target === target) {\n\t\t\t\tsub = nextSub;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (sub === null) {\n\t\t\tsub = {\n\t\t\t\tsource: signal,\n\t\t\t\ttarget: target,\n\t\t\t\tpreviousTarget: lastSub,\n\t\t\t\tnextTarget: null,\n\t\t\t\tnextSource: null,\n\t\t\t\tactive: true,\n\t\t\t\trecalc: false,\n\t\t\t\t//name: dev.subName(),\n\t\t\t};\n\t\t\t//console.log(`creating sub '${signal.name}' => '${effect.name}' (${sub.name})`);\n\t\t\tif (lastSub === null) {\n\t\t\t\tsignal.firstTarget = sub;\n\t\t\t} else {\n\t\t\t\tlastSub.nextTarget = sub;\n\t\t\t}\n\n\t\t\tif (target.firstSource === null) {\n\t\t\t\ttarget.firstSource = sub;\n\t\t\t} else {\n\t\t\t\tlet lastEffectSub = target.firstSource;\n\t\t\t\tfor (\n\t\t\t\t\tlet nextSub: Subscription | null = lastEffectSub.nextSource;\n\t\t\t\t\tnextSub !== null;\n\t\t\t\t\tnextSub = nextSub.nextSource\n\t\t\t\t) {\n\t\t\t\t\tlastEffectSub = nextSub;\n\t\t\t\t}\n\t\t\t\tlastEffectSub.nextSource = sub;\n\t\t\t}\n\t\t} else {\n\t\t\t// We can re-use this subscription object\n\t\t\t//console.log(`re-using sub '${signal.name}' => '${effect.name}' (${sub.name})`);\n\t\t\tsub.active = true;\n\t\t}\n\t}\n}\n","import context from \"../render/context\";\nimport type Computed from \"../types/Computed\";\nimport trackEffect from \"./trackEffect\";\n\nexport default function runComputed<T>(computed: Computed<T>): T {\n\t//console.log(`running computed '${computed.name}'`);\n\n\t// Store the active target\n\tconst oldActiveTarget = context.activeTarget;\n\n\tcomputed.running = true;\n\tcomputed.didError = false;\n\n\ttry {\n\t\t// Set the active target, so that any properties accessed while running it\n\t\t// will trigger it in future\n\t\tcontext.activeTarget = computed;\n\n\t\t// Run the computed and gather its dependencies\n\t\tcomputed.value = computed.run();\n\t} catch (err) {\n\t\tcomputed.didError = true;\n\t\t// @ts-ignore\n\t\tcomputed.value = err;\n\t\tthrow err;\n\t} finally {\n\t\t// Set the active target back to what it was previously\n\t\tcontext.activeTarget = oldActiveTarget;\n\n\t\tcomputed.running = false;\n\t}\n\n\ttrackEffect(computed);\n\n\treturn computed.value;\n}\n","import type Computed from \"../types/Computed\";\nimport type Subscription from \"../types/Subscription\";\nimport checkSources from \"./checkSources\";\nimport clearSources from \"./clearSources\";\nimport deactivateSources from \"./deactivateSources\";\nimport runComputed from \"./runComputed\";\n\n/**\n * Checks whether a Computed value should be re-run (which will be true if any\n * of its sources have changed) and re-runs it if necessary.\n */\nexport default function checkComputed(computed: Computed): boolean {\n\tlet rerun = checkSources(computed);\n\n\tlet changed = false;\n\n\tif (rerun) {\n\t\t// Set source subscriptions to inactive\n\t\tdeactivateSources(computed);\n\n\t\t// Run the computed, which will reset subscriptions\n\t\tconst oldValue = computed.value;\n\t\trunComputed(computed);\n\t\tchanged = computed.value !== oldValue;\n\n\t\t// Clear unused source subscriptions\n\t\tclearSources(computed);\n\t}\n\n\tcomputed.recalc = false;\n\n\t// If it hasn't changed, all of its target subscriptions remain active and\n\t// don't need to be recalculated\n\tif (!changed) {\n\t\tfor (\n\t\t\tlet targetSub: Subscription | null = computed.firstTarget;\n\t\t\ttargetSub !== null;\n\t\t\ttargetSub = targetSub.nextTarget\n\t\t) {\n\t\t\ttargetSub.active = true;\n\t\t\ttargetSub.recalc = false;\n\t\t}\n\t}\n\n\treturn changed;\n}\n","import context from \"../render/context\";\nimport type Computed from \"../types/Computed\";\nimport type Effect from \"../types/Effect\";\nimport type Subscription from \"../types/Subscription\";\nimport { COMPUTED_TYPE, SIGNAL_TYPE } from \"../types/constants\";\nimport checkComputed from \"./checkComputed\";\n\n// RECURSIVE\n\n/**\n * Checks whether a Computed or Effect should be re-run (which will be true if\n * any of its sources have changed).\n */\nexport default function checkSources(target: Computed | Effect): boolean {\n\t// NOTE: We bail early if we know the target needs to be re-run; subsequent\n\t// computed values will be computed in the proxy getter\n\n\t// Check signals first as it's cheap, then computed values\n\tlet haveComputed = false;\n\n\tfor (\n\t\tlet sourceSub: Subscription | null = target.firstSource;\n\t\tsourceSub !== null;\n\t\tsourceSub = sourceSub.nextSource\n\t) {\n\t\t//console.log(`checking source sub '${sourceSub.source.name}' (${sourceSub.name})`);\n\t\tif (sourceSub.recalc) {\n\t\t\tif (sourceSub.source.type === SIGNAL_TYPE) {\n\t\t\t\treturn true;\n\t\t\t} /* else if (sourceSub.source.type === COMPUTED_TYPE) */ else {\n\t\t\t\tif (sourceSub.source.recalc) {\n\t\t\t\t\thaveComputed = true;\n\t\t\t\t} else {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (haveComputed) {\n\t\tfor (\n\t\t\tlet sourceSub: Subscription | null = target.firstSource;\n\t\t\tsourceSub !== null;\n\t\t\tsourceSub = sourceSub.nextSource\n\t\t) {\n\t\t\t//console.log(`checking source sub '${sourceSub.source.name}' (${sourceSub.name})`);\n\t\t\tif (sourceSub.recalc && sourceSub.source.type === COMPUTED_TYPE && sourceSub.source.recalc) {\n\t\t\t\tconst oldActiveTarget = context.activeTarget;\n\t\t\t\tcontext.activeTarget = target;\n\n\t\t\t\tconst recalc = checkComputed(sourceSub.source);\n\n\t\t\t\tcontext.activeTarget = oldActiveTarget;\n\n\t\t\t\tif (recalc) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn false;\n}\n","import context from \"../render/context\";\nimport type Effect from \"../types/Effect\";\nimport clearSources from \"./clearSources\";\n\n/**\n * Runs cleanup functions for the effect and its children.\n */\nexport default function runCleanups(effect: Effect): void {\n\tlet effectToClean: Effect | null = effect;\n\tfor (let i = 0; i < effect.extent; i++) {\n\t\tif (typeof effectToClean.cleanup === \"function\") {\n\t\t\t//console.log(`cleaning effect '${effectToClean.name}'`);\n\t\t\tconst oldActiveTarget = context.activeTarget;\n\t\t\tcontext.activeTarget = null;\n\n\t\t\ttry {\n\t\t\t\teffectToClean.cleanup();\n\t\t\t} catch (err) {\n\t\t\t\teffectToClean.didError = true;\n\t\t\t\tclearSources(effectToClean);\n\t\t\t\tthrow err;\n\t\t\t} finally {\n\t\t\t\teffectToClean.cleanup = undefined;\n\t\t\t\tcontext.activeTarget = oldActiveTarget;\n\t\t\t}\n\t\t}\n\n\t\tconst nextEffect: Effect = effectToClean.nextEffect!;\n\n\t\t// If it's a child effect that has been triggered, clean it up\n\t\t// and remove it from the list of effects to run (it may get\n\t\t// re-created with the parent)\n\t\tif (i !== 0 && effect.nextEffectToRun === effectToClean) {\n\t\t\teffect.nextEffectToRun = effectToClean.nextEffectToRun;\n\t\t\teffectToClean.nextEffect = effectToClean.nextEffectToRun = null;\n\t\t}\n\n\t\teffectToClean = nextEffect;\n\t}\n}\n","import context from \"../render/context\";\n\nexport default function batchStart(): void {\n\tcontext.batch++;\n}\n","import context from \"../render/context\";\nimport type Effect from \"../types/Effect\";\nimport batchEnd from \"./batchEnd\";\nimport batchStart from \"./batchStart\";\nimport clearSources from \"./clearSources\";\n\nexport default function runEffect(effect: Effect): void {\n\t//console.log(`running effect '${effect.name}'`);\n\n\t// Store the active target\n\tconst oldActiveTarget = context.activeTarget;\n\tconst oldExtent = context.extent;\n\n\teffect.didError = false;\n\n\tbatchStart();\n\n\ttry {\n\t\t// Set the next effect for navigating through\n\t\tif (context.previousEffect !== null) {\n\t\t\tcontext.previousEffect.nextEffect = effect;\n\t\t}\n\n\t\t// Set the active effect, so that any properties accessed while running it\n\t\t// will trigger it in future\n\t\tcontext.activeTarget = effect;\n\t\tcontext.previousEffect = effect;\n\t\tcontext.extent = 1;\n\n\t\t// Run the effect to register its subscriptions and get its (optional)\n\t\t// cleanup function\n\t\teffect.cleanup = effect.run();\n\n\t\teffect.extent = context.extent;\n\t} catch (err) {\n\t\teffect.didError = true;\n\t\tclearSources(effect);\n\t\tthrow err;\n\t} finally {\n\t\t// Set the active target back to what it was previously\n\t\tcontext.activeTarget = oldActiveTarget;\n\t\tcontext.extent += oldExtent - 1;\n\n\t\tbatchEnd();\n\t}\n}\n","import type Effect from \"../types/Effect\";\nimport checkSources from \"./checkSources\";\nimport clearSources from \"./clearSources\";\nimport deactivateSources from \"./deactivateSources\";\nimport runCleanups from \"./runCleanups\";\nimport runEffect from \"./runEffect\";\n\n/**\n * Checks whether an Effect should be re-run (which will be true if any\n * of its sources have changed) and re-runs it if necessary.\n */\nexport default function checkEffect(effect: Effect): void {\n\t//console.log(`checking effect '${effect.name}'`);\n\n\tlet rerun = checkSources(effect);\n\n\tif (rerun) {\n\t\t//console.log(`running effect '${String(effect.run)}'`);\n\n\t\t// Run cleanup functions for the effect and its children\n\t\trunCleanups(effect);\n\n\t\t// Set source subscriptions to inactive\n\t\tdeactivateSources(effect);\n\n\t\t// Run the effect, which will reset subscriptions\n\t\trunEffect(effect);\n\n\t\t// Clear unused source subscriptions\n\t\tclearSources(effect);\n\t}\n}\n","import type Computed from \"../types/Computed\";\nimport type ProxySignal from \"../types/ProxySignal\";\nimport type Subscription from \"../types/Subscription\";\n\n/**\n * Clear unused target subscriptions after all Effects have been run.\n */\nexport default function clearTargets(source: ProxySignal | Computed): void {\n\tlet previousSub: Subscription | null = null;\n\tfor (\n\t\tlet clearSub: Subscription | null = source.firstTarget;\n\t\tclearSub !== null;\n\t\tclearSub = clearSub.nextTarget\n\t) {\n\t\tif (!clearSub.active) {\n\t\t\t//console.log(\n\t\t\t//\t`clearing target sub ${clearSub.source.name} <-> ${clearSub.target.name} (${clearSub.name})`,\n\t\t\t//);\n\t\t\tif (previousSub === null) {\n\t\t\t\tsource.firstTarget = clearSub.nextTarget;\n\t\t\t} else {\n\t\t\t\tpreviousSub.nextTarget = clearSub.nextTarget;\n\t\t\t}\n\t\t} else {\n\t\t\tpreviousSub = clearSub;\n\t\t}\n\t}\n}\n","import context from \"../render/context\";\nimport type Effect from \"../types/Effect\";\nimport type ProxySignal from \"../types/ProxySignal\";\nimport checkEffect from \"./checkEffect\";\nimport clearTargets from \"./clearTargets\";\n\n/**\n * Runs the effects that have been collected during the batch.\n */\nexport default function triggerEffects(): void {\n\t//console.log(`triggering effects for '${String(key)}' on`, proxy);\n\t//console.log(\"===\");\n\t//console.log(`triggering effects for '${String(key)}'`);\n\n\tlet didError = false;\n\tlet error: any;\n\n\t// Run the effects\n\tlet effect: Effect | null = context.firstEffectToRun;\n\twhile (effect !== null) {\n\t\tcontext.batchOperation++;\n\n\t\ttry {\n\t\t\tcheckEffect(effect);\n\t\t} catch (err) {\n\t\t\tif (!didError) {\n\t\t\t\tdidError = true;\n\t\t\t\terror = err;\n\t\t\t}\n\t\t}\n\n\t\teffect = effect.nextEffectToRun;\n\t}\n\n\t// Clear the effects\n\teffect = context.firstEffectToRun;\n\tcontext.firstEffectToRun = null;\n\twhile (effect !== null) {\n\t\tlet nextEffect = effect.nextEffectToRun;\n\t\teffect.nextEffectToRun = null;\n\t\teffect = nextEffect;\n\t}\n\n\t// Clear unused target subscriptions for the signals that were updated\n\t// during the batch\n\tlet signal: ProxySignal | null = context.firstSignalToUpdate;\n\tcontext.firstSignalToUpdate = null;\n\twhile (signal !== null) {\n\t\tclearTargets(signal);\n\n\t\tconst nextSignal = signal.nextSignalToUpdate;\n\t\tsignal.nextSignalToUpdate = null;\n\t\tsignal = nextSignal;\n\t}\n\n\tif (didError) {\n\t\tthrow error;\n\t}\n}\n","import context from \"../render/context\";\nimport triggerEffects from \"./triggerEffects\";\n\nexport default function batchEnd(): void {\n\tif (context.batch > 1) {\n\t\tcontext.batch--;\n\t\treturn;\n\t}\n\n\ttry {\n\t\ttriggerEffects();\n\t} finally {\n\t\tcontext.batch = 0;\n\t\tcontext.batchOperation = 0;\n\t\tcontext.previousEffect = null;\n\t}\n}\n","import batchEnd from \"../watch/batchEnd\";\nimport batchStart from \"../watch/batchStart\";\nimport context from \"./context\";\n\n/**\n * Runs updates to proxy values in a batch, where the updates are stored in\n * context, and dependent effects are run all at once at the end.\n *\n * @param fn The function containing the batched updates to run.\n */\nexport default function $batch<T>(fn: () => T): T {\n\tif (context.batch > 0) {\n\t\treturn fn();\n\t}\n\n\tbatchStart();\n\ttry {\n\t\treturn fn();\n\t} finally {\n\t\tbatchEnd();\n\t}\n}\n","import type Computed from \"../types/Computed\";\nimport { COMPUTED_TYPE } from \"../types/constants\";\nimport runComputed from \"../watch/runComputed\";\nimport context from \"./context\";\n\n/**\n * Caches a computed value from signals accessed in a property getter.\n *\n * @param fn The function containing the signals to compute and cache.\n */\nexport default function $cache<T>(fn: () => T): T {\n\tif (context.registerComputed === null) {\n\t\tthrow new Error(\"$cache must be used in a getter\");\n\t}\n\n\tlet computed: Computed = {\n\t\ttype: COMPUTED_TYPE,\n\t\tvalue: null,\n\t\trun: fn,\n\t\tfirstSource: null,\n\t\tfirstTarget: null,\n\t\trecalc: false,\n\t\trunning: false,\n\t\tdidError: false,\n\t\trollback: null,\n\t\t//name: dev.effectName(fn),\n\t};\n\n\tcontext.registerComputed(computed);\n\n\trunComputed(computed);\n\n\treturn computed.value;\n}\n","import context from \"./context\";\n\n// Not sure if this is a good idea?\n\nexport default function $peek<T>(fn: () => T): T {\n\tconst oldActiveTarget = context.activeTarget;\n\tcontext.activeTarget = null;\n\n\tconst result = fn();\n\n\tcontext.activeTarget = oldActiveTarget;\n\n\treturn result;\n}\n","export default function buildClasses(value: unknown, styleHash?: string): string {\n\tif (typeof value === \"string\") {\n\t\tif (styleHash !== undefined) {\n\t\t\tvalue += \" \" + styleHash;\n\t\t}\n\t\treturn value;\n\t} else {\n\t\tlet classes: string[] = [];\n\t\tgatherNames(\"\", value, classes);\n\t\tif (styleHash !== undefined) {\n\t\t\tclasses.push(styleHash);\n\t\t}\n\t\treturn classes.join(\" \");\n\t}\n}\n\nfunction gatherNames(name: unknown, value: unknown, classes: string[]) {\n\tif (value) {\n\t\tif (Array.isArray(value)) {\n\t\t\tfor (let v of value) {\n\t\t\t\tgatherNames(v, v, classes);\n\t\t\t}\n\t\t} else if (typeof value === \"object\") {\n\t\t\tfor (let [n, v] of Object.entries(value)) {\n\t\t\t\tgatherNames(n, v, classes);\n\t\t\t}\n\t\t} else {\n\t\t\tclasses.push(name as string);\n\t\t}\n\t}\n}\n","export default function buildStyles(value: unknown): string {\n\tif (typeof value === \"string\") {\n\t\treturn value;\n\t} else {\n\t\tlet styles: string[] = [];\n\t\tif (value) {\n\t\t\tif (Array.isArray(value)) {\n\t\t\t\tfor (let v of value) {\n\t\t\t\t\tstyles.push(v);\n\t\t\t\t}\n\t\t\t} else if (typeof value === \"object\") {\n\t\t\t\tfor (let [n, v] of Object.entries(value)) {\n\t\t\t\t\tstyles.push(`${n}: ${v}`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn styles.join(\"; \");\n\t}\n}\n","export default function formatText(value: any): string {\n\treturn value ?? \"\";\n}\n"],"mappings":";;AAEA,MAAMA,UAAmB;CACxB,cAAc;CACd,gBAAgB;CAChB,QAAQ;CACR,OAAO;CACP,gBAAgB;CAChB,kBAAkB;CAElB,kBAAkB;CAClB,qBAAqB;CAIrB,aAAa;CAEb,eAAe;CAEf,WAAW;CAEX,cAAc,EAAE;CAChB,eAAe,EAAE;CACjB,mBAAmB,EAAE;CAErB,eAAe;CASf;AAED,sBAAe;;;;;;;ACjCf,MAAa,cAAc;;;;AAK3B,MAAa,gBAAgB;;;;AAK7B,MAAa,cAAc;;;;;;;ACN3B,SAAwB,aAAa,QAAiC;CACrE,IAAIC,cAAmC;AACvC,MACC,IAAIC,WAAgC,OAAO,aAC3C,aAAa,MACb,WAAW,SAAS,WAEpB,KAAI,OAAO,YAAY,CAAC,SAAS,QAAQ;AAIxC,MAAI,gBAAgB,KACnB,QAAO,cAAc,SAAS;MAE9B,aAAY,aAAa,SAAS;AAInC,MAAI,SAAS,mBAAmB,MAC/B;OAAI,SAAS,OAAO,gBAAgB,SACnC,UAAS,OAAO,cAAc,SAAS;QAIxC,UAAS,eAAe,aAAa,SAAS;QAEzC;AACN,WAAS,SAAS;AAClB,gBAAc;;;;;;;;;AC5BjB,SAAwB,kBAAkB,QAAiC;AAC1E,MACC,IAAIC,YAAiC,OAAO,aAC5C,cAAc,MACd,YAAY,UAAU,WAEtB,WAAU,SAAS;;;;;;;;;ACFrB,SAAwB,YAAY,QAAsC;CACzE,MAAM,SAASC,gB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G,QAAQ;KAG3B,SAAQ,KAAK,KAAe;;;;;AC3B/B,SAAwB,YAAY,OAAwB;AAC3D,KAAI,OAAO,UAAU,SACpB,QAAO;MACD;EACN,IAAIC,SAAmB,EAAE;AACzB,MAAI,OACH;OAAI,MAAM,QAAQ,MAAM,CACvB,MAAK,IAAI,KAAK,MACb,QAAO,KAAK,EAAE;YAEL,OAAO,UAAU,SAC3B,MAAK,IAAI,CAAC,GAAG,MAAM,OAAO,QAAQ,MAAM,CACvC,QAAO,KAAK,GAAG,EAAE,IAAI,IAAI;;AAI5B,SAAO,OAAO,KAAK,KAAK;;;;;;AChB1B,SAAwB,WAAW,OAAoB;AACtD,QAAO,SAAS"}
|
package/package.json
CHANGED
|
@@ -15,6 +15,7 @@ export default function buildAwaitNode(node: ControlNode, status: BuildStatus, b
|
|
|
15
15
|
const parentName = node.parentName!;
|
|
16
16
|
const rangeName = nextVarName("await_range", status);
|
|
17
17
|
const stateName = "$" + nextVarName("await_state", status);
|
|
18
|
+
const creatorsName = nextVarName("await_creators", status);
|
|
18
19
|
const awaitVarsName = nextVarName("await_vars", status);
|
|
19
20
|
|
|
20
21
|
// Filter non-control branches (spaces)
|
|
@@ -62,14 +63,17 @@ export default function buildAwaitNode(node: ControlNode, status: BuildStatus, b
|
|
|
62
63
|
b.append(`
|
|
63
64
|
/* @await */
|
|
64
65
|
const ${rangeName} = t_range();
|
|
65
|
-
let ${stateName} = $watch({
|
|
66
|
+
let ${stateName} = $watch({ index: -1 });
|
|
67
|
+
let ${creatorsName}: ((t_before: Node | null) => void)[] = [];`);
|
|
66
68
|
|
|
67
69
|
b.append(`
|
|
68
70
|
let ${awaitVarsName} = { t_token: 0 };
|
|
69
71
|
$run(function runAwait() {`);
|
|
70
72
|
|
|
73
|
+
let index = 0;
|
|
74
|
+
|
|
71
75
|
// Build the waiting branch before anything happens
|
|
72
|
-
buildAwaitBranch(awaitBranch, status, b, parentName, stateName);
|
|
76
|
+
buildAwaitBranch(awaitBranch, status, b, parentName, stateName, creatorsName, index++);
|
|
73
77
|
|
|
74
78
|
b.append(`${awaitVarsName}.t_token++;
|
|
75
79
|
((t_token) => {`);
|
|
@@ -90,7 +94,7 @@ export default function buildAwaitNode(node: ControlNode, status: BuildStatus, b
|
|
|
90
94
|
);
|
|
91
95
|
|
|
92
96
|
b.append(`if (t_token === ${awaitVarsName}.t_token) {`);
|
|
93
|
-
buildAwaitBranch(thenBranch, status, b, parentName, stateName);
|
|
97
|
+
buildAwaitBranch(thenBranch, status, b, parentName, stateName, creatorsName, index++);
|
|
94
98
|
b.append(`}
|
|
95
99
|
})`);
|
|
96
100
|
|
|
@@ -107,7 +111,7 @@ export default function buildAwaitNode(node: ControlNode, status: BuildStatus, b
|
|
|
107
111
|
|
|
108
112
|
b.append(`
|
|
109
113
|
if (t_token === ${awaitVarsName}.t_token) {`);
|
|
110
|
-
buildAwaitBranch(catchBranch, status, b, parentName, stateName);
|
|
114
|
+
buildAwaitBranch(catchBranch, status, b, parentName, stateName, creatorsName, index++);
|
|
111
115
|
b.append(`}
|
|
112
116
|
});
|
|
113
117
|
})(${awaitVarsName}.t_token);
|
|
@@ -115,7 +119,7 @@ export default function buildAwaitNode(node: ControlNode, status: BuildStatus, b
|
|
|
115
119
|
|
|
116
120
|
b.append(`
|
|
117
121
|
t_run_control(${rangeName}, ${anchorName}, (t_before) => {
|
|
118
|
-
t_run_branch(${rangeName}, () => ${stateName}.
|
|
122
|
+
t_run_branch(${rangeName}, () => ${creatorsName}[${stateName}.index](t_before));
|
|
119
123
|
});`);
|
|
120
124
|
b.append("");
|
|
121
125
|
}
|
|
@@ -126,9 +130,11 @@ function buildAwaitBranch(
|
|
|
126
130
|
b: Builder,
|
|
127
131
|
parentName: string,
|
|
128
132
|
stateName: string,
|
|
133
|
+
creatorsName: string,
|
|
134
|
+
index: number,
|
|
129
135
|
) {
|
|
130
136
|
if (node.children.length > 0) {
|
|
131
|
-
b.append(`${
|
|
137
|
+
b.append(`${creatorsName}[${index}] = (t_before) => {`);
|
|
132
138
|
|
|
133
139
|
buildFragment(node, status, b, parentName, "t_before");
|
|
134
140
|
|
|
@@ -145,6 +151,8 @@ function buildAwaitBranch(
|
|
|
145
151
|
|
|
146
152
|
b.append("};");
|
|
147
153
|
} else {
|
|
148
|
-
b.append(`${
|
|
154
|
+
b.append(`${creatorsName}[${index}] = (_) => {};`);
|
|
149
155
|
}
|
|
156
|
+
|
|
157
|
+
b.append(`${stateName}.index = ${index};`);
|
|
150
158
|
}
|
|
@@ -101,7 +101,7 @@ function buildTemplate(
|
|
|
101
101
|
if (/\$run\b/.test(script)) imports.add("$run");
|
|
102
102
|
if (/\$mount\b/.test(script)) imports.add("$mount");
|
|
103
103
|
if (/\$unwrap\b/.test(script)) imports.add("$unwrap");
|
|
104
|
-
if (/\$peek\b/.test(script)) imports.add("$peek");
|
|
104
|
+
/*if (/\$peek\b/.test(script))*/ imports.add("$peek");
|
|
105
105
|
if (/\$batch\b/.test(script)) imports.add("$batch");
|
|
106
106
|
|
|
107
107
|
let currentIndex = 0;
|
|
@@ -127,6 +127,12 @@ function buildTemplate(
|
|
|
127
127
|
b.append(`$context = Object.assign({}, $context);`);
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
+
// NOTE: We're isolating the user script by setting `context.activeTarget =
|
|
131
|
+
// null` and then setting it back at the end, but maybe it would be better to
|
|
132
|
+
// make it so that signals only affect effects that they are under e.g. so
|
|
133
|
+
// that creating a $state in a component doesn't affect any $runs outside
|
|
134
|
+
// the component?
|
|
135
|
+
b.append("$peek(() => { /**/");
|
|
130
136
|
b.append("");
|
|
131
137
|
} else if (chunk.script === "/* @render */") {
|
|
132
138
|
if (current.markup) {
|
|
@@ -151,6 +157,7 @@ function buildTemplate(
|
|
|
151
157
|
} else if (chunk.script === "/* @style */") {
|
|
152
158
|
// No styles in the client
|
|
153
159
|
} else if (chunk.script === "/* @end */") {
|
|
160
|
+
b.append("/**/ });");
|
|
154
161
|
currentIndex += 1;
|
|
155
162
|
current = template.components[currentIndex];
|
|
156
163
|
} else {
|
|
@@ -16,6 +16,7 @@ export default function buildIfNode(node: ControlNode, status: BuildStatus, b: B
|
|
|
16
16
|
const parentName = node.parentName || anchorName + ".parentNode";
|
|
17
17
|
const rangeName = nextVarName("if_range", status);
|
|
18
18
|
const stateName = "$" + nextVarName("if_state", status);
|
|
19
|
+
const creatorsName = nextVarName("if_creators", status);
|
|
19
20
|
|
|
20
21
|
// Filter non-control branches (spaces)
|
|
21
22
|
const branches = node.children.filter((n) => isControlNode(n)) as ControlNode[];
|
|
@@ -42,17 +43,19 @@ export default function buildIfNode(node: ControlNode, status: BuildStatus, b: B
|
|
|
42
43
|
b.append(`
|
|
43
44
|
/* @if */
|
|
44
45
|
const ${rangeName} = t_range();
|
|
45
|
-
let ${stateName} = $watch({
|
|
46
|
+
let ${stateName} = $watch({ index: -1 });
|
|
47
|
+
let ${creatorsName}: ((t_before: Node | null) => void)[] = [];`);
|
|
46
48
|
|
|
47
49
|
b.append(`$run(function runIf() {`);
|
|
50
|
+
let index = 0;
|
|
48
51
|
for (let branch of branches) {
|
|
49
|
-
buildIfBranch(branch, status, b, parentName, stateName);
|
|
52
|
+
buildIfBranch(branch, status, b, parentName, stateName, creatorsName, index++);
|
|
50
53
|
}
|
|
51
54
|
b.append(`});`);
|
|
52
55
|
|
|
53
56
|
b.append(`
|
|
54
57
|
t_run_control(${rangeName}, ${anchorName}, (t_before) => {
|
|
55
|
-
t_run_branch(${rangeName}, () => ${stateName}.
|
|
58
|
+
t_run_branch(${rangeName}, () => ${creatorsName}[${stateName}.index](t_before));
|
|
56
59
|
});`);
|
|
57
60
|
b.append("");
|
|
58
61
|
}
|
|
@@ -63,12 +66,14 @@ function buildIfBranch(
|
|
|
63
66
|
b: Builder,
|
|
64
67
|
parentName: string,
|
|
65
68
|
stateName: string,
|
|
69
|
+
creatorsName: string,
|
|
70
|
+
index: number,
|
|
66
71
|
) {
|
|
67
72
|
// TODO: replaceForVarNames is going to throw mapping out
|
|
68
73
|
addMappedText("", `${replaceForVarNames(node.statement, status)}`, " {", node.range, status, b);
|
|
69
74
|
|
|
70
75
|
if (node.children.length > 0) {
|
|
71
|
-
b.append(`${
|
|
76
|
+
b.append(`${creatorsName}[${index}] = (t_before) => {`);
|
|
72
77
|
|
|
73
78
|
buildFragment(node, status, b, parentName, "t_before");
|
|
74
79
|
|
|
@@ -85,8 +90,9 @@ function buildIfBranch(
|
|
|
85
90
|
|
|
86
91
|
b.append("};");
|
|
87
92
|
} else {
|
|
88
|
-
b.append(`${
|
|
93
|
+
b.append(`${creatorsName}[${index}] = (_) => {};`);
|
|
89
94
|
}
|
|
90
95
|
|
|
96
|
+
b.append(`${stateName}.index = ${index};`);
|
|
91
97
|
b.append("}");
|
|
92
98
|
}
|
|
@@ -14,6 +14,7 @@ export default function buildSwitchNode(node: ControlNode, status: BuildStatus,
|
|
|
14
14
|
const parentName = node.parentName!;
|
|
15
15
|
const rangeName = nextVarName("switch_range", status);
|
|
16
16
|
const stateName = "$" + nextVarName("switch_state", status);
|
|
17
|
+
const creatorsName = nextVarName("switch_creators", status);
|
|
17
18
|
|
|
18
19
|
// Filter non-control branches (spaces)
|
|
19
20
|
const branches = node.children.filter((n) => isControlNode(n)) as ControlNode[];
|
|
@@ -40,16 +41,19 @@ export default function buildSwitchNode(node: ControlNode, status: BuildStatus,
|
|
|
40
41
|
b.append(`
|
|
41
42
|
/* @switch */
|
|
42
43
|
const ${rangeName} = t_range();
|
|
43
|
-
let ${stateName} = $watch({
|
|
44
|
+
let ${stateName} = $watch({ index: -1 });
|
|
45
|
+
let ${creatorsName}: ((t_before: Node | null) => void)[] = [];`);
|
|
44
46
|
|
|
45
47
|
b.append(`
|
|
46
48
|
$run(function runSwitch() {`);
|
|
47
49
|
|
|
50
|
+
let index = 0;
|
|
51
|
+
|
|
48
52
|
// TODO: replaceForVarNames is going to throw mapping out
|
|
49
53
|
addMappedText("", `${replaceForVarNames(node.statement, status)}`, " {", node.range, status, b);
|
|
50
54
|
|
|
51
55
|
for (let branch of branches) {
|
|
52
|
-
buildSwitchBranch(branch, status, b, parentName, stateName);
|
|
56
|
+
buildSwitchBranch(branch, status, b, parentName, stateName, creatorsName, index++);
|
|
53
57
|
}
|
|
54
58
|
b.append(`
|
|
55
59
|
}
|
|
@@ -57,7 +61,7 @@ export default function buildSwitchNode(node: ControlNode, status: BuildStatus,
|
|
|
57
61
|
|
|
58
62
|
b.append(`
|
|
59
63
|
t_run_control(${rangeName}, ${anchorName}, (t_before) => {
|
|
60
|
-
t_run_branch(${rangeName}, () => ${stateName}.
|
|
64
|
+
t_run_branch(${rangeName}, () => ${creatorsName}[${stateName}.index](t_before));
|
|
61
65
|
});`);
|
|
62
66
|
b.append("");
|
|
63
67
|
}
|
|
@@ -68,12 +72,14 @@ function buildSwitchBranch(
|
|
|
68
72
|
b: Builder,
|
|
69
73
|
parentName: string,
|
|
70
74
|
stateName: string,
|
|
75
|
+
creatorsName: string,
|
|
76
|
+
index: number,
|
|
71
77
|
) {
|
|
72
78
|
// TODO: replaceForVarNames is going to throw mapping out
|
|
73
79
|
addMappedText("", `${replaceForVarNames(node.statement, status)}`, " {", node.range, status, b);
|
|
74
80
|
|
|
75
81
|
if (node.children.length > 0) {
|
|
76
|
-
b.append(`${
|
|
82
|
+
b.append(`${creatorsName}[${index}] = (t_before) => {`);
|
|
77
83
|
|
|
78
84
|
buildFragment(node, status, b, parentName, "t_before");
|
|
79
85
|
|
|
@@ -90,9 +96,10 @@ function buildSwitchBranch(
|
|
|
90
96
|
|
|
91
97
|
b.append("};");
|
|
92
98
|
} else {
|
|
93
|
-
b.append(`${
|
|
99
|
+
b.append(`${creatorsName}[${index}] = (_) => {};`);
|
|
94
100
|
}
|
|
95
101
|
|
|
102
|
+
b.append(`${stateName}.index = ${index};`);
|
|
96
103
|
b.append(`
|
|
97
104
|
break;
|
|
98
105
|
}`);
|
package/src/compile/buildType.ts
CHANGED
|
@@ -16,16 +16,14 @@ export default function buildType(template: Template, options?: BuildOptions): s
|
|
|
16
16
|
b.append(`import { type SlotRender } from "${options?.renderFolder || "@torpor/view"}";`);
|
|
17
17
|
|
|
18
18
|
for (let component of template.components) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
* @param $slots -- Functions for rendering children into slot nodes within the component.
|
|
28
|
-
*/
|
|
19
|
+
if (component.exported) {
|
|
20
|
+
b.append("");
|
|
21
|
+
if (component.propsType) {
|
|
22
|
+
b.append(component.propsType);
|
|
23
|
+
b.append("");
|
|
24
|
+
}
|
|
25
|
+
b.append(`
|
|
26
|
+
${component.documentation ?? ""}
|
|
29
27
|
${component.default ? "declare" : "export declare"} function ${component.name}(
|
|
30
28
|
$parent: ParentNode,
|
|
31
29
|
$anchor: Node | null,
|
|
@@ -34,8 +32,9 @@ export default function buildType(template: Template, options?: BuildOptions): s
|
|
|
34
32
|
$slots?: Record<string, SlotRender>,
|
|
35
33
|
): void;
|
|
36
34
|
`);
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
if (component.default) {
|
|
36
|
+
b.append(`export default ${component.name};`);
|
|
37
|
+
}
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
40
|
|
|
@@ -6,14 +6,20 @@ export default interface ParseComponentStatus {
|
|
|
6
6
|
start?: number;
|
|
7
7
|
/** The component's name */
|
|
8
8
|
name?: string;
|
|
9
|
+
/** Whether the component is exported from the file */
|
|
10
|
+
exported?: boolean;
|
|
9
11
|
/** Whether the component is defined in a default function */
|
|
10
12
|
default?: boolean;
|
|
13
|
+
/** The component's documentation comments */
|
|
14
|
+
documentation?: string;
|
|
11
15
|
/** Params declared by the user in the component's function */
|
|
12
16
|
params?: string;
|
|
13
17
|
markup?: RootNode;
|
|
14
18
|
head?: RootNode;
|
|
15
19
|
stack?: ElementNode[];
|
|
16
20
|
style?: Style;
|
|
21
|
+
/** The type or interface that is used for the $props param */
|
|
22
|
+
propsType?: string;
|
|
17
23
|
/** $props that are used in the component's function */
|
|
18
24
|
props?: string[];
|
|
19
25
|
/** $context props that are used in the component's function */
|