@torpor/view 0.1.4 → 0.1.6
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 +16 -0
- package/dist/compile.cjs +324 -270
- package/dist/compile.cjs.map +1 -1
- package/dist/compile.js +324 -270
- package/dist/compile.js.map +1 -1
- package/dist/index.cjs +145 -97
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +72 -29
- package/dist/index.d.ts +72 -29
- package/dist/index.js +142 -97
- package/dist/index.js.map +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/package.json +3 -3
- package/src/compile/build/client/buildAddFragment.ts +5 -1
- package/src/compile/build/client/buildCode.ts +2 -0
- package/src/compile/build/client/buildComponentNode.ts +1 -0
- package/src/compile/build/client/buildControlNode.ts +2 -1
- package/src/compile/build/client/buildFragment.ts +47 -21
- package/src/compile/build/client/buildRootNode.ts +5 -1
- package/src/compile/build/client/buildStyles.ts +18 -14
- package/src/compile/build/server/buildServerComponentNode.ts +2 -4
- package/src/compile/build/server/buildServerControlNode.ts +2 -1
- package/src/compile/build/server/buildServerForNode.ts +2 -2
- package/src/compile/build/server/buildServerIfNode.ts +4 -0
- package/src/compile/build/server/buildServerRootNode.ts +3 -1
- package/src/compile/build/server/buildServerSwitchNode.ts +4 -0
- package/src/compile/parse/ParseStatus.ts +2 -1
- package/src/compile/parse/parseCode.ts +5 -8
- package/src/compile/parse/parseControl.ts +19 -6
- package/src/compile/parse/parseMarkup.ts +15 -8
- package/src/compile/types/comments.ts +2 -2
- package/src/compile/types/nodes/OperationType.ts +2 -1
- package/src/debug/printNode.ts +54 -36
- package/src/index.ts +5 -1
- package/src/render/addFragment.ts +5 -4
- package/src/render/clearLayoutSlot.ts +6 -0
- package/src/render/clearRange.ts +1 -1
- package/src/render/hydrationMarkers.ts +2 -2
- package/src/render/isComment.ts +2 -2
- package/src/render/isText.ts +3 -0
- package/src/render/nodeAnchor.ts +62 -27
- package/src/render/nodeCheckHydrationBreak.ts +25 -0
- package/src/render/nodeChild.ts +12 -7
- package/src/render/nodeNext.ts +16 -25
- package/src/render/nodeRoot.ts +26 -9
- package/src/render/nodeSkip.ts +20 -0
- package/src/render/runLayoutSlot.ts +26 -0
- package/test/attributes/components/output/Attributes-client.ts +7 -4
- package/test/attributes/components/output/Attributes-server.ts +1 -1
- package/test/attributes/components/temp/{Attributes-client-7b8f7b9996208e8d2d0a12d4f4a40a73df63d9d8.ts → Attributes-client-4620a40099e57a7fdaab895b204d85881f6dbfb7.ts} +7 -4
- package/test/attributes/components/temp/{Attributes-server-a1289434a5a801be1d63bfc85b621579e06452f0.ts → Attributes-server-80f9f58fd6cb30df11867386d4f0b15b44401ebe.ts} +1 -1
- package/test/await/components/output/Await-client.ts +18 -15
- package/test/await/components/output/Await-server.ts +2 -2
- package/test/await/components/temp/{Await-client-a7bf000bf2b59a3d5251a0fa18ec79890a52a547.ts → Await-client-5d753441145fbac078393af24cccadb208453d69.ts} +18 -15
- package/test/await/components/temp/{Await-server-06cd2a3d8c7eb5bef026ffe2fb11793becf547c2.ts → Await-server-f02f39af3bb3344ca6b18a1d64d60b21913fba31.ts} +2 -2
- package/test/bind/components/output/BindComponent-client.ts +18 -12
- package/test/bind/components/output/BindComponent-server.ts +3 -3
- package/test/bind/components/output/BindText-client.ts +10 -8
- package/test/bind/components/output/BindText-server.ts +1 -1
- package/test/bind/components/temp/{BindComponent-client-a645474748485a878871c062ad69e6bcf35e6550.ts → BindComponent-client-aaeb489ce72b664c6372f8764f7e665994a751a7.ts} +18 -12
- package/test/bind/components/temp/{BindComponent-server-c557e7aa944517ab87415b8bb35b41b0034254e7.ts → BindComponent-server-c630dee0bee6cea49d5eb8bea04979a737bb8f5e.ts} +3 -3
- package/test/bind/components/temp/{BindText-client-d5f7d721df55020ef337f660e5d278eb80fcc330.ts → BindText-client-134676d616abbad6b8a7ec48df0a2e38cbfe3b87.ts} +10 -8
- package/test/bind/components/temp/{BindText-server-4b94cdf60d9c9a2088306c4407e2ae30785169b0.ts → BindText-server-807a1ddcb68410b30429cb088d2e204ed6f585b2.ts} +1 -1
- package/test/buildHtml.ts +1 -1
- package/test/buildOutputFiles.ts +8 -1
- package/test/child-component/components/output/ParentChild-client.ts +17 -11
- package/test/child-component/components/output/ParentChild-server.ts +3 -3
- package/test/child-component/components/temp/{ParentChild-client-eaefb0cbfd251badab3c57ae2037d973f785a1b8.ts → ParentChild-client-6cf4d156ea46338815270faf67f56472f1a4ccd4.ts} +17 -11
- package/test/child-component/components/temp/{ParentChild-server-8f2fc556f87867e6e3393e2e9e6d696cda107b69.ts → ParentChild-server-a34a8b5acf1c00d1990f8ab7433599506265a45a.ts} +3 -3
- package/test/class/class.test.ts +1 -1
- package/test/class/components/output/Class-client.ts +27 -20
- package/test/class/components/output/Class-server.ts +4 -4
- package/test/class/components/temp/{Class-client-12f09850a5f8c27de6cf94c23a2b17aadbf66f01.ts → Class-client-0405eff591f854c04e5728df0479014ef91efc61.ts} +27 -20
- package/test/class/components/temp/Class-server-daf30ffb1bacf9877e3385dc9a3eede61c972329.ts +40 -0
- package/test/component/components/output/Component-client.ts +9 -4
- package/test/component/components/output/Component-server.ts +2 -0
- package/test/component/components/output/Header-client.ts +7 -5
- package/test/component/components/output/Header-server.ts +1 -1
- package/test/component/components/temp/{Component-client-a2fb6f30fc340bac909b64cb4f5ac68cde376de3.ts → Component-client-355b42e5f7411c399e2f50fba3580f4f7c3fa943.ts} +9 -4
- package/test/component/components/temp/{Component-server-40be12cd528ccf768f1ad40ef2a435ad2b2a2d71.ts → Component-server-81012827b18e82d787d194a0a1a9d4e07311a336.ts} +2 -0
- package/test/component/components/temp/{Header-client-75cb4aa868295ac168c16ba7b275fbb5ab9256f9.ts → Header-client-903877003b220272b0cb5bfd62d7d748ad46c477.ts} +7 -5
- package/test/component/components/temp/{Header-server-f73307874bec34a95dcd152d7f83a3ad13a0f4ac.ts → Header-server-6969d20782edd8f99d4b5c5b7b5563ce26e6dc2d.ts} +1 -1
- package/test/console/components/output/Console-client.ts +6 -4
- package/test/console/components/output/Console-server.ts +1 -1
- package/test/console/components/temp/{Console-client-2f206752ce59e59fba9bb91263b4102fd515951e.ts → Console-client-4fa3b3679cee88bf6151185438e36d14010944b7.ts} +6 -4
- package/test/console/components/temp/{Console-server-b4b15f7a0d1d2b50d87bad4870e1b8d368707c04.ts → Console-server-cfb2208b130d5f15403df19ae8341aaa1c9ad33a.ts} +1 -1
- package/test/const/components/output/Const-client.ts +7 -5
- package/test/const/components/output/Const-server.ts +2 -2
- package/test/const/components/temp/{Const-client-536e8fdf18d6f4f7f23b2789de2330ecf62d7865.ts → Const-client-7dff2758c14bfbd208e301a702ae1781e6daba1b.ts} +7 -5
- package/test/const/components/temp/{Const-server-8f84096c03a19296425aee5d243af0734b70ca61.ts → Const-server-1cf6ed84f72d3b15b318b80937b8de1f2c0f188c.ts} +2 -2
- package/test/effects/components/output/For-client.ts +12 -9
- package/test/effects/components/output/For-server.ts +2 -2
- package/test/effects/components/output/If-client.ts +14 -11
- package/test/effects/components/output/If-server.ts +4 -4
- package/test/effects/components/output/NestedIf-client.ts +17 -14
- package/test/effects/components/output/NestedIf-server.ts +5 -5
- package/test/effects/components/temp/{For-client-d8d4e4424ec3238fe9f79cc907d673612b63bcdf.ts → For-client-fbe876286c0f99b8391ff0c06c92b58bf580218f.ts} +12 -9
- package/test/effects/components/temp/{For-server-1f853c161bea31a1a5b11b00d7a021b70c778066.ts → For-server-efe60939d185315f4c9b567b6867c6d5af14d9aa.ts} +2 -2
- package/test/effects/components/temp/{If-client-bb06988422395321bf298a75bf5563c6f750f776.ts → If-client-420a093f13de6ce07d2d4bc94705901809096cd9.ts} +14 -11
- package/test/effects/components/temp/{If-server-97e3cbe059306fc607985dcd1b187df3a278d979.ts → If-server-2424b7b812d350d7eb8ff9afb1146807217320cd.ts} +4 -4
- package/test/effects/components/temp/{NestedIf-client-dc880c1ec92e716ec730dfa0bac0e3d9265bdf27.ts → NestedIf-client-af88ec303b1a4184263bb370ef5b1f1e8aca8efc.ts} +17 -14
- package/test/effects/components/temp/{NestedIf-server-9f199a33bae5d5fe34920d6a419937537a2b18dc.ts → NestedIf-server-ab260586490cb5afed31377d2226bb5a1fc30e2d.ts} +5 -5
- package/test/events/components/output/Increment-client.ts +9 -7
- package/test/events/components/output/Increment-server.ts +1 -1
- package/test/events/components/temp/{Increment-client-41bd7bc91aac8c7a9bf73527c8f7ba1794b09ab3.ts → Increment-client-1b5f9e231c5c4fc059d77ca0da632719283e5ac4.ts} +9 -7
- package/test/events/components/temp/{Increment-server-bbf5ac93c4f73382c4262ae42f4cc836bcb8ac1b.ts → Increment-server-b084f43082e2ec31dbe5f9edc1cb6e37e4c8df9d.ts} +1 -1
- package/test/for/components/output/For-client.ts +12 -9
- package/test/for/components/output/For-server.ts +2 -2
- package/test/for/components/output/ForEscape-client.ts +16 -13
- package/test/for/components/output/ForEscape-server.ts +2 -2
- package/test/for/components/output/ForIn-client.ts +12 -9
- package/test/for/components/output/ForIn-server.ts +2 -2
- package/test/for/components/output/ForOf-client.ts +12 -9
- package/test/for/components/output/ForOf-server.ts +2 -2
- package/test/for/components/temp/{For-client-0be5994e98c07a3455cd8a18a2b1b8ef3605aba6.ts → For-client-421f2a6ca501d135c0aef9d1aaea25de0e1c00e4.ts} +12 -9
- package/test/for/components/temp/{For-server-8490f15d02ae76b218feb7fa266415f44b2a4ab9.ts → For-server-3b6ead39728c79206203c519a215390d07d80f7e.ts} +2 -2
- package/test/for/components/temp/{ForEscape-client-a973a145e28b32ca55fe3dca53d885fcf5e11c37.ts → ForEscape-client-72879c80f7544c2edfc224095740bdea20e1e12d.ts} +16 -13
- package/test/for/components/temp/{ForEscape-server-375744ca1e10e5c8ed7dd6420beef72107e55568.ts → ForEscape-server-ed906c8cd593a0b467073ada415734de31dc38d9.ts} +2 -2
- package/test/for/components/temp/{ForIn-client-5cc25a98e10826e8477fe6f931d5d2bbd0b13c9f.ts → ForIn-client-e12c45d7f53e50ea3ed456110138dfb95f6930e0.ts} +12 -9
- package/test/for/components/temp/{ForIn-server-d68e82c048f7e0f1525f74724b91e5cd01cdc6a6.ts → ForIn-server-c8f13304a2ba235e091685256909fbfa50bdd5fd.ts} +2 -2
- package/test/for/components/temp/{ForOf-client-70b0d59ff72f1cffe2e0ac8523dd7ccdca4ffe39.ts → ForOf-client-422d67d6c046f1d1de655719d061ea29f67d23f7.ts} +12 -9
- package/test/for/components/temp/{ForOf-server-ac08d98dd249a3e64a366b8488450e6ce0d18def.ts → ForOf-server-8c2c33ca6595bf0a5e952ca9971e595e18446623.ts} +2 -2
- package/test/function/components/output/Function-client.ts +8 -6
- package/test/function/components/output/Function-server.ts +2 -2
- package/test/function/components/temp/{Function-client-b3ff029a821d47e1a2249a52dfb681f4b2e96232.ts → Function-client-4e2168306756eb927d5ed4b673334b357eecaa74.ts} +8 -6
- package/test/function/components/temp/{Function-server-2d32fbe35260c0948a135f287f131c5520e8bce7.ts → Function-server-2b19d0cd881c31dc67132107c6e322a18701c318.ts} +2 -2
- package/test/html/components/output/Html-client.ts +9 -6
- package/test/html/components/output/Html-server.ts +1 -1
- package/test/html/components/temp/{Html-client-766ba4a63f28f929ca16cd7d1640fe92f9b30792.ts → Html-client-2f309b06c3304a952d249057dec058a514d52874.ts} +9 -6
- package/test/html/components/temp/{Html-server-0a41da8b81bf833f331f3becdbac14be7ddc6c8c.ts → Html-server-d159b0ef04b1f65ae4f9e05a7b44b21e7aa14cf9.ts} +1 -1
- package/test/hydrateComponent.ts +1 -0
- package/test/if/components/IfAfterIf.torp +10 -12
- package/test/if/components/IfElse.torp +12 -11
- package/test/if/components/IfElseIf.torp +13 -15
- package/test/if/components/IfFalse.torp +10 -0
- package/test/if/components/IfNested.torp +11 -13
- package/test/if/components/output/IfAfterIf-client.ts +14 -13
- package/test/if/components/output/IfAfterIf-server.ts +4 -4
- package/test/if/components/output/IfElse-client.ts +14 -13
- package/test/if/components/output/IfElse-server.ts +4 -4
- package/test/if/components/output/IfElseIf-client.ts +16 -15
- package/test/if/components/output/IfElseIf-server.ts +5 -5
- package/test/if/components/output/IfFalse-client.ts +56 -0
- package/test/if/components/output/IfFalse-server.ts +21 -0
- package/test/if/components/output/IfNested-client.ts +19 -18
- package/test/if/components/output/IfNested-server.ts +6 -6
- package/test/if/components/temp/{IfAfterIf-client-49b6b8c42b0a351561f9f5f22c2ae2e844bf3b58.ts → IfAfterIf-client-5ddfc6dc62ffbc9a518220458403008e88e69e6c.ts} +14 -13
- package/test/if/components/temp/{IfAfterIf-server-eb67cf1fcf6711882266219940a47bd4a66497f3.ts → IfAfterIf-server-a5005147e7902d1a5a048c9fe07feb9804eb6560.ts} +4 -4
- package/test/if/components/temp/{IfElse-client-e236d4a2e99262ff09675bc519c07e2826c0d70b.ts → IfElse-client-815057ffb2d9a1861bb316d445321947ddedbb65.ts} +14 -13
- package/test/if/components/temp/{IfElse-server-c077e0e30f4d2adec41ab779198362d21542d055.ts → IfElse-server-80d93e5fc4ceba7a645f7081fa11b177dbe730d0.ts} +4 -4
- package/test/if/components/temp/{IfElseIf-client-b92106861f0c7ec3d09e3a42bb93d8f5bd4e3bdf.ts → IfElseIf-client-a7b16a8af24fdd3caa7b9e8e56d4bdb6ad3ab855.ts} +16 -15
- package/test/if/components/temp/{IfElseIf-server-67991eee3f56dc687cda600511c31396438e0a77.ts → IfElseIf-server-ddc7348705d51b02538301e0aa704130748992cf.ts} +5 -5
- package/test/if/components/temp/IfFalse-client-6507ff8abd4842b78da27d8a9d4964abc1d9b727.ts +56 -0
- package/test/if/components/temp/IfFalse-server-e8385013cfdde584b43cc0d71311cbb417859116.ts +21 -0
- package/test/if/components/temp/{IfNested-client-f563ac1b16a2280e457557281c4925ed447a9cd7.ts → IfNested-client-e09f8af625b4e0b3e9eb210440f8edda720f0d53.ts} +19 -18
- package/test/if/components/temp/{IfNested-server-0a2a9643324ab73b02b310cad61ba87dab146ab2.ts → IfNested-server-285a5d8e0e0fcc8ccf421df152fdc00811782835.ts} +6 -6
- package/test/if/if-else-false.test.ts +54 -0
- package/test/if/{if-true.test.ts → if-else-true.test.ts} +5 -2
- package/test/if/if-false.test.ts +1 -4
- package/test/importComponent.ts +4 -0
- package/test/mount/components/output/Mount-client.ts +7 -4
- package/test/mount/components/output/Mount-server.ts +1 -1
- package/test/mount/components/temp/{Mount-client-36dbc95a61345a1b7dcf07e6b0c998af2afca691.ts → Mount-client-efa5c34fbfc7646e114a1a58f0814b6dff33e566.ts} +7 -4
- package/test/mount/components/temp/{Mount-server-8bef1924a731f3db63cb827be3938fec685e53af.ts → Mount-server-62f94f276c2d6c9048765a77b575cb21146917f1.ts} +1 -1
- package/test/on-mount/components/output/OnMount-client.ts +7 -4
- package/test/on-mount/components/output/OnMount-server.ts +1 -1
- package/test/on-mount/components/temp/{OnMount-client-21708a638d2939ee8b017f5dc819cee4748bde87.ts → OnMount-client-4bb62e8bf1fcd67798598fe03bf5455a57f0a6be.ts} +7 -4
- package/test/on-mount/components/temp/{OnMount-server-1758fe2b16972fca7d4b9bb49d9256fce99780eb.ts → OnMount-server-c531f718eb68754ea6c3001d5db9c07c511e434c.ts} +1 -1
- package/test/party/components/output/AnswerButton-client.ts +8 -6
- package/test/party/components/output/AnswerButton-server.ts +1 -1
- package/test/party/components/output/AnswerButtonApp-client.ts +11 -7
- package/test/party/components/output/AnswerButtonApp-server.ts +2 -2
- package/test/party/components/output/ColorSelect-client.ts +11 -9
- package/test/party/components/output/ColorSelect-server.ts +2 -2
- package/test/party/components/output/Colors-client.ts +12 -9
- package/test/party/components/output/Colors-server.ts +2 -2
- package/test/party/components/output/Counter-client.ts +8 -6
- package/test/party/components/output/Counter-server.ts +1 -1
- package/test/party/components/output/CssStyle-client.ts +6 -4
- package/test/party/components/output/CssStyle-server.ts +1 -1
- package/test/party/components/output/DoubleCount-client.ts +7 -5
- package/test/party/components/output/DoubleCount-server.ts +1 -1
- package/test/party/components/output/FunnyButton-client.ts +12 -9
- package/test/party/components/output/FunnyButton-server.ts +2 -2
- package/test/party/components/output/FunnyButtonApp-client.ts +15 -9
- package/test/party/components/output/FunnyButtonApp-server.ts +3 -3
- package/test/party/components/output/HelloWorld-client.ts +6 -4
- package/test/party/components/output/HelloWorld-server.ts +1 -1
- package/test/party/components/output/InputFocused-client.ts +7 -4
- package/test/party/components/output/InputFocused-server.ts +1 -1
- package/test/party/components/output/InputHello-client.ts +8 -6
- package/test/party/components/output/InputHello-server.ts +1 -1
- package/test/party/components/output/IsAvailable-client.ts +8 -6
- package/test/party/components/output/IsAvailable-server.ts +1 -1
- package/test/party/components/output/Name-client.ts +7 -5
- package/test/party/components/output/Name-server.ts +1 -1
- package/test/party/components/output/NameUpdate-client.ts +7 -5
- package/test/party/components/output/NameUpdate-server.ts +1 -1
- package/test/party/components/output/PageTitle-client.ts +7 -5
- package/test/party/components/output/PageTitle-server.ts +1 -1
- package/test/party/components/output/PickPill-client.ts +9 -7
- package/test/party/components/output/PickPill-server.ts +1 -1
- package/test/party/components/output/Time-client.ts +7 -5
- package/test/party/components/output/Time-server.ts +1 -1
- package/test/party/components/output/TrafficLight-client.ts +19 -17
- package/test/party/components/output/TrafficLight-server.ts +5 -5
- package/test/party/components/output/UserProfile-client.ts +10 -8
- package/test/party/components/output/UserProfile-server.ts +1 -1
- package/test/party/components/output/UserProfileApp-client.ts +9 -4
- package/test/party/components/output/UserProfileApp-server.ts +2 -0
- package/test/party/components/output/UserProfileContext-client.ts +9 -7
- package/test/party/components/output/UserProfileContext-server.ts +1 -1
- package/test/party/components/output/UserProfileContextApp-client.ts +11 -7
- package/test/party/components/output/UserProfileContextApp-server.ts +2 -2
- package/test/party/components/temp/{AnswerButton-client-c3dc7edbfff2db1ea111086002147d771ee12193.ts → AnswerButton-client-ad8f8db36b7aaa68d8de5898a324bacfbe9f20df.ts} +8 -6
- package/test/party/components/temp/{AnswerButton-server-427442fa8cfc0a18817c2d37f9cb5cbcb3a88a05.ts → AnswerButton-server-928b5d447afa865fa09e0142c79bb1f2c1b86875.ts} +1 -1
- package/test/party/components/temp/{AnswerButtonApp-client-3e0b63a6bbc1dee3e6cb715c0297cc2ce58d3e4e.ts → AnswerButtonApp-client-a2b16c738467742436b1a2ddaf2d767795a4d625.ts} +11 -7
- package/test/party/components/temp/{AnswerButtonApp-server-bbc8bb739d2060ccda77ce406aa6b15d8f90b91c.ts → AnswerButtonApp-server-16161f2c9062dd11b8b6b8c898f9f1249ae2400d.ts} +2 -2
- package/test/party/components/temp/{ColorSelect-client-5ffa6f9d77de967993088c9a01b9f976f3333176.ts → ColorSelect-client-4e848c296047911f4c0e3bc1447e5562ce06087c.ts} +11 -9
- package/test/party/components/temp/{ColorSelect-server-3ed19eff17bf10b31d03ec507974ff913932c97a.ts → ColorSelect-server-90f83722bd85155ebb2b8ccdaf053cd28d3152be.ts} +2 -2
- package/test/party/components/temp/{Colors-client-3dafffc5c2a72037f4419fc45d08963872a29958.ts → Colors-client-dde7bf60e2b16383ec981b08f8414b1ebeb349a5.ts} +12 -9
- package/test/party/components/temp/{Colors-server-f9b3037a5f25979f71b5f8f3e658140be7c27920.ts → Colors-server-e13d49ba57f7b0dc6fb10a333ec872f5207e1ff0.ts} +2 -2
- package/test/party/components/temp/{Counter-client-4d553521fcfc6c9a4e05dce89e70b2ecf8785c4e.ts → Counter-client-3b876c148f2b14da1766eff77eb6c494f7be6414.ts} +8 -6
- package/test/party/components/temp/{Counter-server-36d1137c519691f5b86a18a5c27b7cf615b7e37c.ts → Counter-server-7adf9376b38d97f1fd4b9c14108e6814e81f14ea.ts} +1 -1
- package/test/party/components/temp/{CssStyle-client-59c0f261f67bc04f2829a0371f655d146101cec6.ts → CssStyle-client-37465dd48d1479db1bae513eb0b92c4e9a15e9ea.ts} +6 -4
- package/test/party/components/temp/{CssStyle-server-3e58d7e2f5c381a251f593245d3d8bf4b50925ae.ts → CssStyle-server-90a950501a20bfa5feac84ca6d97898c25bce2ed.ts} +1 -1
- package/test/party/components/temp/{DoubleCount-client-0426f128507a8d4516ef7501cd180662112b6d1d.ts → DoubleCount-client-6d4cf1e54368e3c6082e37c1e04f9ecde90624f2.ts} +7 -5
- package/test/party/components/temp/{DoubleCount-server-40fc88156e52281b80fd6b12dd73d2469201fa29.ts → DoubleCount-server-62c94483ebe9661e5ecc4f489787e32448ddcafa.ts} +1 -1
- package/test/party/components/temp/{FunnyButton-client-45f2c5dd56f2cdb80102193a978df6b0cec822ab.ts → FunnyButton-client-61a1699da08e210375edff33f7b27d3cc0e99cc3.ts} +12 -9
- package/test/party/components/temp/{FunnyButton-server-e8ab55e47c735f7e42c55d2b7504dfa4190a1b40.ts → FunnyButton-server-e0adab2be2d283acb8a8b580479ade999dc918e9.ts} +2 -2
- package/test/party/components/temp/{FunnyButtonApp-client-ac7101af922dc6ba472b75a428f340caca6be74a.ts → FunnyButtonApp-client-cbce6a591bae38ab8b312551f8741d50ae6294bf.ts} +15 -9
- package/test/party/components/temp/{FunnyButtonApp-server-f1a98a946e0bb9d1bb76b01e26d6ead8f55d32bb.ts → FunnyButtonApp-server-48d37de0c755843a2be34d7c7cb5c730689dcc2f.ts} +3 -3
- package/test/party/components/temp/{HelloWorld-client-791e8b9a0bd4b01e87fbe70f2b28d4ac356e3624.ts → HelloWorld-client-7344e400b4adb975fa8263d3081a06de0a793e57.ts} +6 -4
- package/test/party/components/temp/{HelloWorld-server-3c4b9a995a78d652d9220a20124c9e0d18fc7101.ts → HelloWorld-server-e0ed80e7531f303952a4af30d646263ff2e4ead6.ts} +1 -1
- package/test/party/components/temp/{InputFocused-client-11a9cb08909b26945bbc2451ab4c1dac09e6d113.ts → InputFocused-client-20d755aea7dfaf1fd5e42dcade8fb7867f59ef28.ts} +7 -4
- package/test/party/components/temp/{InputFocused-server-82be1a63c80d1dd3f06efaf0bef349d58cf1d9af.ts → InputFocused-server-ee70758a515227c04788be0e298a79c277994ccd.ts} +1 -1
- package/test/party/components/temp/{InputHello-client-b0453caeae0d43dc1878039c6b49318d12624d48.ts → InputHello-client-2a4cbd980534fde14b9d3e8a2f8e4f59a4f15d64.ts} +8 -6
- package/test/party/components/temp/{InputHello-server-6c982438e58d3649ee3890efec636ca4590a5cdb.ts → InputHello-server-1b9dd5442ded022abe92a9075ca5a4bb90486cbe.ts} +1 -1
- package/test/party/components/temp/{IsAvailable-client-d789346a68b26fd3f5d9f7aebc4c7bd181c47cad.ts → IsAvailable-client-3949f85aea0e935c3b59ab1389baee836eff1866.ts} +8 -6
- package/test/party/components/temp/{IsAvailable-server-a35b7ec5f111472c76aa1b67c857b169fe363594.ts → IsAvailable-server-123daa1ae56b77defe6666faddb44ba4252dd0fb.ts} +1 -1
- package/test/party/components/temp/{Name-client-cb8bef7cfca1306386b65410a0bd7a8acfaed359.ts → Name-client-62f0dab96aff130e81882099d7c0a111ba99cebd.ts} +7 -5
- package/test/party/components/temp/{Name-server-9da0823f748e9751e017078f39717298be232636.ts → Name-server-a402418f1ca2d8a0e6403596ec03ec47b5ff40ec.ts} +1 -1
- package/test/party/components/temp/{NameUpdate-client-ebef69b0da12d640994099592ce06c7e4b5089d4.ts → NameUpdate-client-6ceb440637c99142bafcf8512eabf831c113b8c7.ts} +7 -5
- package/test/party/components/temp/{NameUpdate-server-1856bdb5e010f7d7e5e67f2a0d87ac3f92f4e0ee.ts → NameUpdate-server-b7dcc875e894a5606544fcd78bda575ea07632ca.ts} +1 -1
- package/test/party/components/temp/{PageTitle-client-403645e918294e5cdeea8cb3f602e0a2642b2650.ts → PageTitle-client-75fea3a37fb1213bc13f56160bb6779486b2e6e9.ts} +7 -5
- package/test/party/components/temp/{PageTitle-server-4d959183b7029b6817372abd1d60a7e996baeb15.ts → PageTitle-server-12dcb4e437aaef227c704a2ee8bbdee55ca323dc.ts} +1 -1
- package/test/party/components/temp/{PickPill-client-b47d371ae5f41d87c96b3cdeed0a8bc06fbfa9c7.ts → PickPill-client-0f13aa652cb1bd45f57d5a249f8364e80204441a.ts} +9 -7
- package/test/party/components/temp/{PickPill-server-49e033c5f97dd2f98e1498327e16eb9c8c9d2f66.ts → PickPill-server-f10dae4708e36775a5e1a5ad10c6c0c309335009.ts} +1 -1
- package/test/party/components/temp/{Time-client-7ba4ca9322af2cb88a873c812fc776760c337c64.ts → Time-client-2013f274e90b45be3138727f2298305e1951131f.ts} +7 -5
- package/test/party/components/temp/{Time-server-08f66c7f3f32b13de06d75fe679cf58b5727c473.ts → Time-server-8e0278a4b16925903f3c4ceedbf1332cde4921fa.ts} +1 -1
- package/test/party/components/temp/{TrafficLight-client-549f9fe3418c113fb240cfa17e09c42e1e7f346a.ts → TrafficLight-client-4010f51fde4c8c21e6c232eff974c86820dbad4f.ts} +19 -17
- package/test/party/components/temp/{TrafficLight-server-ed2a8640fd82cf381eee8f4fb83bb09d174a4557.ts → TrafficLight-server-04bb3b2f11322ccc97a9a8a8fbb26c3c99843042.ts} +5 -5
- package/test/party/components/temp/{UserProfile-client-2c13aac1ad915e51dc557f9af765669e636c0fea.ts → UserProfile-client-11c2a928de5a5ed4cab45186f08ca09f6161afb5.ts} +10 -8
- package/test/party/components/temp/{UserProfile-server-cc1162a4297f6163bfb86e7a8aeea08e8c0625c6.ts → UserProfile-server-a0576b8d9dd15b3fab6c11758984c686ddfe2f66.ts} +1 -1
- package/test/party/components/temp/{UserProfileApp-client-2be7a11319cca4d7bfa0f3d2205c441d7e203780.ts → UserProfileApp-client-32b5cc129b32af5cdd94f39c6fb09a2e4806b04e.ts} +9 -4
- package/test/party/components/temp/{UserProfileApp-server-ab9ff66f787f775aa8571314fee8bcbef85489ef.ts → UserProfileApp-server-97397c42aaac0ee3902218d02c0ce6884434cc5b.ts} +2 -0
- package/test/party/components/temp/{UserProfileContext-client-2aa36f436a5f20614d77f48963ec5ca442eebd90.ts → UserProfileContext-client-c97c077254210061b3c9ba561f681c0cf4f6167f.ts} +9 -7
- package/test/party/components/temp/{UserProfileContext-server-cf58767df1e2d1dde919f59de73cdd9764bbc006.ts → UserProfileContext-server-2d32476b00448bdec6c1c45aac5087a5152c2471.ts} +1 -1
- package/test/party/components/temp/{UserProfileContextApp-client-5099052fdcd8fb4c368c45090390947424a4e9b0.ts → UserProfileContextApp-client-c4b64ccf44069bcbf18acb585afa62ac9127aeb9.ts} +11 -7
- package/test/party/components/temp/{UserProfileContextApp-server-6be8dab2ed4f8911f26bef137e7dea164f2b894d.ts → UserProfileContextApp-server-95a4b12d30cef621db55d5de102a906ac7286fb2.ts} +2 -2
- package/test/props/components/output/Reactive-client.ts +18 -12
- package/test/props/components/output/Reactive-server.ts +3 -3
- package/test/props/components/temp/{Reactive-client-e3e5f6ee2f22c46337c6ab1df2f241133c7e2646.ts → Reactive-client-249382840865c9911857b89085bc85ff901b8e8f.ts} +18 -12
- package/test/props/components/temp/{Reactive-server-0914d91287a1bc6d32d7cc56d086624762dbfc04.ts → Reactive-server-770cd3df7c877c0c99e156b2ba6d1f8b35914027.ts} +3 -3
- package/test/replace/components/output/Replace-client.ts +11 -8
- package/test/replace/components/output/Replace-server.ts +2 -2
- package/test/replace/components/temp/{Replace-client-3fdab63871fa4bb792317caefd3539b1888325b1.ts → Replace-client-ef66f06bc0cfa91e800b185dbccbca6a98693c21.ts} +11 -8
- package/test/replace/components/temp/{Replace-server-857aca7a58deffc3a1c95ab9d31628b4051ca203.ts → Replace-server-9519943d193b681e1d7894a0d7952affdfb0660c.ts} +2 -2
- package/test/slots/components/output/Article-client.ts +13 -9
- package/test/slots/components/output/Article-server.ts +2 -2
- package/test/slots/components/output/Basic-client.ts +9 -5
- package/test/slots/components/output/Basic-server.ts +2 -0
- package/test/slots/components/output/Header-client.ts +10 -7
- package/test/slots/components/output/Header-server.ts +2 -2
- package/test/slots/components/output/Let-client.ts +9 -5
- package/test/slots/components/output/Let-server.ts +2 -0
- package/test/slots/components/output/List-client.ts +12 -9
- package/test/slots/components/output/List-server.ts +2 -2
- package/test/slots/components/output/Named-client.ts +12 -8
- package/test/slots/components/output/Named-server.ts +2 -0
- package/test/slots/components/output/Unused-client.ts +9 -4
- package/test/slots/components/output/Unused-server.ts +2 -0
- package/test/slots/components/temp/{Article-client-80848d6cadd8abac61865d14ddd35685844797e0.ts → Article-client-f7676836f5ded94222b11ef81e41dd675d1af04b.ts} +13 -9
- package/test/slots/components/temp/{Article-server-a6bd47a621cc213db4313eb775a52246541dd203.ts → Article-server-b84141b05064f5ea1e4b535faafe459df0d875fb.ts} +2 -2
- package/test/slots/components/temp/{Basic-client-97b18686412869e8c814fd4542dfe826b1f7669f.ts → Basic-client-e7650b8be5f6e50fa0f2f343a145f86edfe14ff4.ts} +9 -5
- package/test/slots/components/temp/{Basic-server-248392e2cd147b537cd44e9a5a71885ef20102e4.ts → Basic-server-aed46a5b459cce50e7ddb311c42a76b9e91c2dae.ts} +2 -0
- package/test/slots/components/temp/{Header-client-e2e1e7d60b48b0841cd0c20224f520330ca96458.ts → Header-client-127c27e6bfcd5b37cc871164cd665b740418dc82.ts} +10 -7
- package/test/slots/components/temp/{Header-server-1c195508a91c32822da22a08576c8a30c9070636.ts → Header-server-d8e8ccb129d84478f0c4f8dc8ad1d2091188cc7b.ts} +2 -2
- package/test/slots/components/temp/{Let-client-be69c1f5aa32faf16239050d7836db46cfdcba2f.ts → Let-client-c107eb0fe42f125996d2c9a83ab7b3c1916ca26d.ts} +9 -5
- package/test/slots/components/temp/{Let-server-c3293219ed27aec61a6af36d451ddf6609c40027.ts → Let-server-62727e5e2db3df405cdbe7a2d339a99113fc7f4a.ts} +2 -0
- package/test/slots/components/temp/{List-client-a829b33214de829de689a72d2e8703b2266ad7a4.ts → List-client-ca1d8f9a9cc8b513323de7c5531a4ec03898d920.ts} +12 -9
- package/test/slots/components/temp/{List-server-06503834c9bfae9b8c2b61742568b020a3de961c.ts → List-server-f4f63df4d19e15311da347284935a1bb530a8df4.ts} +2 -2
- package/test/slots/components/temp/{Named-client-2d9d88f5fdf74d81c3ed1d769a476f4ac36c8b99.ts → Named-client-636b6a18c25a27099f883cb9eeb04e182e248941.ts} +12 -8
- package/test/slots/components/temp/{Named-server-65a7bbf038111475c8f07dccb34040ab8c1392c4.ts → Named-server-829daa82c94fd7142a721cabac1b3402cca8fce6.ts} +2 -0
- package/test/slots/components/temp/{Unused-client-1b16491cb800bbbbd871d9fbf5966c7275244019.ts → Unused-client-0aefcc79e9ae050358fa049a35b7e8e0a6bc2d66.ts} +9 -4
- package/test/slots/components/temp/{Unused-server-e5d1e85116bebc7e1a2882cb8f2c9ae7975a1de7.ts → Unused-server-379b45ff313e82f8b2949385f50d8ea482094520.ts} +2 -0
- package/test/special-component/components/output/BigTitle-client.ts +9 -6
- package/test/special-component/components/output/BigTitle-server.ts +2 -2
- package/test/special-component/components/output/Component-client.ts +10 -4
- package/test/special-component/components/output/Component-server.ts +2 -2
- package/test/special-component/components/output/SmallTitle-client.ts +9 -6
- package/test/special-component/components/output/SmallTitle-server.ts +2 -2
- package/test/special-component/components/temp/{BigTitle-client-881a9f84876fb3f6d994736edb253b96e71de926.ts → BigTitle-client-04ca3c7b6aaf76b81baa5a3d3720fbd2a1760550.ts} +9 -6
- package/test/special-component/components/temp/{BigTitle-server-9efc738f5eb131a4b859c4a99a8e255d93834e9a.ts → BigTitle-server-d8919a4c975e022c936584bd668917cb89aa8e20.ts} +2 -2
- package/test/special-component/components/temp/{Component-client-22f7e1d0955fb3d90939e956a1f0f77118c259b6.ts → Component-client-24cd39596c4281ee2709e6aa482818d071825b4f.ts} +10 -4
- package/test/special-component/components/temp/{Component-server-ce596cd84dc11f67c9f0588060a5b672eddf9715.ts → Component-server-3564dfcef8d015cab4944a3c75cc6cf329f3fad6.ts} +2 -2
- package/test/special-component/components/temp/{SmallTitle-client-25b3097b7ae47848dd82967403faf7745fc43388.ts → SmallTitle-client-213b422377a30fe0b12f7256e654bf0313ac9cf9.ts} +9 -6
- package/test/special-component/components/temp/{SmallTitle-server-fc105db9a91b83644d67e049ce583a3d1a61f50c.ts → SmallTitle-server-0a9b5098e4dda96f8c1da30294d71b39997dd118.ts} +2 -2
- package/test/special-element/components/output/Element-client.ts +8 -6
- package/test/special-element/components/output/Element-server.ts +1 -1
- package/test/special-element/components/temp/{Element-client-21c92c04579b1d29e8813265a10897d069aad5c5.ts → Element-client-c5701ed44faa4ec8ae558505063684a84cada3f2.ts} +8 -6
- package/test/special-element/components/temp/{Element-server-4bed9653529f39e72754126147fe8618f328853a.ts → Element-server-166d672256ef4635168de0090e490e48b569c7d6.ts} +1 -1
- package/test/special-head/components/output/Head-client.ts +6 -4
- package/test/special-head/components/output/Head-server.ts +1 -1
- package/test/special-head/components/temp/{Head-client-07e8af6386d767a52667a4fdc978a335ec388302.ts → Head-client-18616689a7d6f83ca076c9d825606b049de9d3ef.ts} +6 -4
- package/test/special-head/components/temp/{Head-server-d80a0f1ee10e9942d9a631df35a24cb1cfb15555.ts → Head-server-c0956653b544ff632e36da15d5f7623fa285953a.ts} +1 -1
- package/test/special-self/components/output/Self-client.ts +12 -8
- package/test/special-self/components/output/Self-server.ts +4 -4
- package/test/special-self/components/temp/{Self-client-911c67194be1fdd997537310bcafe712161e8251.ts → Self-client-99b34229c85a477881299311f56f48686352c3b3.ts} +12 -8
- package/test/special-self/components/temp/{Self-server-49ba9be1f6255dd4daf490c640f5222a85960218.ts → Self-server-ee440757ca9772d7b4111451a9ee05a157302e7c.ts} +4 -4
- package/test/style/components/output/Style-client.ts +7 -4
- package/test/style/components/output/Style-server.ts +1 -1
- package/test/style/components/temp/{Style-client-cbfac1e255c33a867ccbd5f9d1484a855d91a2d7.ts → Style-client-bc13f8dbb5f754e4eebb2473fc63a139ebf1ba92.ts} +7 -4
- package/test/style/components/temp/{Style-server-763d82ee2296be3f7620814aed950b505329c04c.ts → Style-server-85720cb43e20ab000f98bc632c29454a51ae92d9.ts} +1 -1
- package/test/svg/components/output/Shape-client.ts +14 -11
- package/test/svg/components/output/Shape-server.ts +4 -4
- package/test/svg/components/temp/{Shape-client-cb98b36ab2a0d9f06b484a3c988fb43c3a71a4a0.ts → Shape-client-368789c592401c3e4c99ddcdb8fe6dded45eb34a.ts} +14 -11
- package/test/svg/components/temp/{Shape-server-500d7fe4556026234ce5379b8e90595ddd094edc.ts → Shape-server-9951ff1dcc7aa0827f28d3f8d970813767115ae3.ts} +4 -4
- package/test/switch/components/output/Switch-client.ts +17 -14
- package/test/switch/components/output/Switch-server.ts +5 -5
- package/test/switch/components/temp/{Switch-client-9980de45e3346b79525c445edec7cbc3b375e8a4.ts → Switch-client-5ef1937202adac7fd5aae866357d95beb4b5805f.ts} +17 -14
- package/test/switch/components/temp/{Switch-server-1c5690726f28008bb565966af69b6e4e019dea82.ts → Switch-server-c1b5e1c657438ee3d8afdbf2166c5295cafc5604.ts} +5 -5
- package/test/template/errors.test.ts +8 -6
- package/test/text/components/output/Text-client.ts +8 -6
- package/test/text/components/output/Text-server.ts +1 -1
- package/test/text/components/temp/{Text-client-63f1d3bf9b3bd145c7ce7058716640e27144055e.ts → Text-client-e335aae6d8aef389dfdbb5bee14e3dd3d41e86bd.ts} +8 -6
- package/test/text/components/temp/{Text-server-9d3dd6f51e893e63c1999ceafce19ca1697d76ea.ts → Text-server-e37d33aa182f36461927d8ce36040bfd05e2f227.ts} +1 -1
- package/test/watch-array/components/output/Array-client.ts +12 -9
- package/test/watch-array/components/output/Array-server.ts +2 -2
- package/test/watch-array/components/output/ArrayEntries-client.ts +12 -9
- package/test/watch-array/components/output/ArrayEntries-server.ts +2 -2
- package/test/watch-array/components/output/ArrayIndexes-client.ts +12 -9
- package/test/watch-array/components/output/ArrayIndexes-server.ts +2 -2
- package/test/watch-array/components/output/ArrayUnkeyed-client.ts +12 -9
- package/test/watch-array/components/output/ArrayUnkeyed-server.ts +2 -2
- package/test/watch-array/components/temp/{Array-client-ffd82188a45877d74053c82fb3616e4aed0fc2ad.ts → Array-client-24ccac431fa237432ec4875234773f36a9a5b120.ts} +12 -9
- package/test/watch-array/components/temp/{Array-server-3715e815af887e8487b214e7de324850fe99e312.ts → Array-server-c907209008ac6177f614b62931a2bb1f1c3a04e1.ts} +2 -2
- package/test/watch-array/components/temp/{ArrayEntries-client-b6e982660628576061dbb44539e970b9549bdcfa.ts → ArrayEntries-client-ebfb391a78325be4411f24a1ecfdc45ca3a6a621.ts} +12 -9
- package/test/watch-array/components/temp/{ArrayEntries-server-85cbe80fbb7f6885287825e2cc0dfc1cb9835d79.ts → ArrayEntries-server-57c1ab0045fa4a02de95f69a65de6f54efe9850c.ts} +2 -2
- package/test/watch-array/components/temp/{ArrayIndexes-client-39337aa43bd8c10a53db836c3be233d48dd39b91.ts → ArrayIndexes-client-0a4b3226862bb1de13fdbc7a14f689d9f7ade2a1.ts} +12 -9
- package/test/watch-array/components/temp/{ArrayIndexes-server-ec623c724af0c7212675d61ea68e9dee87f96caa.ts → ArrayIndexes-server-f093878b94a37617e2e697a786caa680f75630a7.ts} +2 -2
- package/test/watch-array/components/temp/{ArrayUnkeyed-client-7606f9a6a221c8cf6a8b51e4895d10a3d7bccc11.ts → ArrayUnkeyed-client-0966fa5ed460f4c627d8d619e493601098d6a33e.ts} +12 -9
- package/test/watch-array/components/temp/{ArrayUnkeyed-server-db21cd576a4c70973abe10f6c8ef5cecb3ead86c.ts → ArrayUnkeyed-server-c893fa024be07e5e7fce608c3ae456bdf2279dbe.ts} +2 -2
- package/test/watch-object/components/output/Watched-client.ts +7 -5
- package/test/watch-object/components/output/Watched-server.ts +1 -1
- package/test/watch-object/components/temp/{Watched-client-bbffbf2cede1a5c071b770670eb39c0f0be725af.ts → Watched-client-d26e846bbeb8271ec5dc2a1ceb75b362af44d3bd.ts} +7 -5
- package/test/watch-object/components/temp/{Watched-server-0252addaf92fb0f0c1e2937f42918a1c9f31d196.ts → Watched-server-312fca1e769d7594fc5bb6295ccf55b544dd2f4d.ts} +1 -1
- package/test/class/components/temp/Class-server-853a463d2ad1a1e3da4da5ad59ad1c75461d2431.ts +0 -40
package/dist/compile.cjs
CHANGED
|
@@ -89,7 +89,7 @@ var Builder = class {
|
|
|
89
89
|
var ANCHOR_COMMENT = "<!>";
|
|
90
90
|
var HYDRATION_START_COMMENT = "<![>";
|
|
91
91
|
var HYDRATION_END_COMMENT = "<!]>";
|
|
92
|
-
var
|
|
92
|
+
var HYDRATION_BREAK_COMMENT = "<!^>";
|
|
93
93
|
|
|
94
94
|
// src/compile/utils/trimQuotes.ts
|
|
95
95
|
function trimQuotes(text) {
|
|
@@ -307,7 +307,11 @@ function buildAddFragment(node, status, b, parentName, anchorName) {
|
|
|
307
307
|
const fragment = node.fragment;
|
|
308
308
|
const fragmentName = `t_fragment_${fragment.number}`;
|
|
309
309
|
status.imports.add("t_add_fragment");
|
|
310
|
-
|
|
310
|
+
let params = [fragmentName, parentName, anchorName];
|
|
311
|
+
if (fragment.endVarName) {
|
|
312
|
+
params.push(fragment.endVarName);
|
|
313
|
+
}
|
|
314
|
+
b.append(`t_add_fragment(${params.join(", ")});`);
|
|
311
315
|
if (fragment.endVarName) {
|
|
312
316
|
status.imports.add("t_next");
|
|
313
317
|
b.append(`t_next(${fragment.endVarName});`);
|
|
@@ -420,10 +424,15 @@ function maybeAddRootNodeDeclaration(node, fragment, fragmentName, status, b, va
|
|
|
420
424
|
} else {
|
|
421
425
|
status.imports.add("t_root");
|
|
422
426
|
const rootName = `t_root_${fragment.number}`;
|
|
423
|
-
const
|
|
427
|
+
const params = [fragmentName];
|
|
428
|
+
if (firstNode.type === "text") {
|
|
429
|
+
params.push("true");
|
|
430
|
+
}
|
|
431
|
+
const rootPath = `t_root(${params.join(", ")})`;
|
|
424
432
|
b.append("// @ts-ignore");
|
|
425
433
|
b.append(`const ${rootName} = ${rootPath};`);
|
|
426
|
-
varPaths.set(
|
|
434
|
+
varPaths.set(`t_root(${fragmentName})`, rootName);
|
|
435
|
+
printDebug(rootName, status, b);
|
|
427
436
|
}
|
|
428
437
|
}
|
|
429
438
|
function declareFragmentVars(fragment, node, path, status, b, parentName, anchorName, varPaths, lastChild, declare) {
|
|
@@ -623,6 +632,7 @@ function declareElementFragmentVars(fragment, node, path, status, b, parentName,
|
|
|
623
632
|
b.append("// @ts-ignore");
|
|
624
633
|
}
|
|
625
634
|
b.append(`const ${node.varName} = ${varPath} as ${elementTypeName(node)};`);
|
|
635
|
+
printDebug(node.varName, status, b);
|
|
626
636
|
}
|
|
627
637
|
}
|
|
628
638
|
}
|
|
@@ -701,6 +711,7 @@ function declareTextFragmentVars(fragment, node, path, status, b, varPaths, last
|
|
|
701
711
|
b.append("// @ts-ignore");
|
|
702
712
|
}
|
|
703
713
|
b.append(`const ${node.varName} = ${varPath};`);
|
|
714
|
+
printDebug(node.varName, status, b);
|
|
704
715
|
}
|
|
705
716
|
}
|
|
706
717
|
} else {
|
|
@@ -805,6 +816,7 @@ function declareParentAndAnchorFragmentVars(fragment, node, path, status, b, par
|
|
|
805
816
|
b.append(`let ${node.parentName} as HTMLElement;`);
|
|
806
817
|
} else {
|
|
807
818
|
b.append(`const ${node.parentName} = ${parentVarPath} as HTMLElement;`);
|
|
819
|
+
printDebug(node.parentName, status, b);
|
|
808
820
|
}
|
|
809
821
|
varPaths.set(parentVarPath, node.parentName);
|
|
810
822
|
} else {
|
|
@@ -815,12 +827,19 @@ function declareParentAndAnchorFragmentVars(fragment, node, path, status, b, par
|
|
|
815
827
|
const anchorPath = { parent: path, type: "#", children: [] };
|
|
816
828
|
path.children.push(anchorPath);
|
|
817
829
|
node.varName = nextVarName(`${name}_anchor`, status);
|
|
818
|
-
const anchorVarPath = getFragmentVarPath(
|
|
830
|
+
const anchorVarPath = getFragmentVarPath(
|
|
831
|
+
fragment,
|
|
832
|
+
status,
|
|
833
|
+
`t_anchor(${node.varName}, true)`,
|
|
834
|
+
anchorPath,
|
|
835
|
+
varPaths
|
|
836
|
+
);
|
|
819
837
|
if (status.options?.useCreateElement) {
|
|
820
838
|
b.append(`let ${node.varName};`);
|
|
821
839
|
} else {
|
|
822
840
|
status.imports.add("t_anchor");
|
|
823
841
|
b.append(`const ${node.varName} = t_anchor(${anchorVarPath}) as HTMLElement;`);
|
|
842
|
+
printDebug(node.varName, status, b);
|
|
824
843
|
}
|
|
825
844
|
} else {
|
|
826
845
|
status.imports.add("t_cmt");
|
|
@@ -846,6 +865,7 @@ function getFragmentVarPath(fragment, status, name, path, varPaths) {
|
|
|
846
865
|
varPaths.set(name, name);
|
|
847
866
|
}
|
|
848
867
|
while (varPath.includes("t_next(t_next(")) {
|
|
868
|
+
status.imports.add("t_skip");
|
|
849
869
|
const match = varPath.match(/(t_next\(){2,}/)[0];
|
|
850
870
|
const count = match.length / "t_next(".length;
|
|
851
871
|
const pos = varPath.indexOf("t_next(t_next(");
|
|
@@ -866,8 +886,9 @@ function getFragmentVarPath(fragment, status, name, path, varPaths) {
|
|
|
866
886
|
}
|
|
867
887
|
const tail = varPath.substring(end + count);
|
|
868
888
|
const param = varPath.substring(pos + match.length, end);
|
|
869
|
-
varPath = `${head}
|
|
889
|
+
varPath = `${head}t_skip(${param}, ${count})${tail}`;
|
|
870
890
|
}
|
|
891
|
+
varPath = varPath.replaceAll("t_next_text", "t_next");
|
|
871
892
|
return varPath;
|
|
872
893
|
}
|
|
873
894
|
function getFragmentVarPathPart(path, varPath, status, root = false) {
|
|
@@ -880,8 +901,12 @@ function getFragmentVarPathPart(path, varPath, status, root = false) {
|
|
|
880
901
|
}
|
|
881
902
|
for (let [i, child] of path.children.entries()) {
|
|
882
903
|
if (i > 0) {
|
|
883
|
-
|
|
884
|
-
|
|
904
|
+
if (child.type === "text" || child.type === "space") {
|
|
905
|
+
varPath = `t_next_text(${varPath}, true)`;
|
|
906
|
+
} else {
|
|
907
|
+
status.imports.add("t_next");
|
|
908
|
+
varPath = `t_next(${varPath})`;
|
|
909
|
+
}
|
|
885
910
|
}
|
|
886
911
|
if (i === path.children.length - 1 && child.children.length) {
|
|
887
912
|
varPath = getFragmentVarPathPart(child, varPath, status);
|
|
@@ -889,6 +914,13 @@ function getFragmentVarPathPart(path, varPath, status, root = false) {
|
|
|
889
914
|
}
|
|
890
915
|
return varPath;
|
|
891
916
|
}
|
|
917
|
+
var debug = false;
|
|
918
|
+
function printDebug(varName, status, b) {
|
|
919
|
+
if (debug) {
|
|
920
|
+
status.imports.add("t_print");
|
|
921
|
+
b.append(`console.log("${varName}:", t_print(${varName}));`);
|
|
922
|
+
}
|
|
923
|
+
}
|
|
892
924
|
|
|
893
925
|
// src/compile/build/client/replaceForVarNames.ts
|
|
894
926
|
function replaceForVarNames(value, status) {
|
|
@@ -1020,6 +1052,7 @@ ${slotParams.join(",\n")}
|
|
|
1020
1052
|
}
|
|
1021
1053
|
}
|
|
1022
1054
|
b.append(`${componentName}(${renderParams});`);
|
|
1055
|
+
b.append("");
|
|
1023
1056
|
}
|
|
1024
1057
|
|
|
1025
1058
|
// src/compile/build/client/buildAwaitNode.ts
|
|
@@ -1429,7 +1462,8 @@ function buildControlNode(node, status, b) {
|
|
|
1429
1462
|
buildScriptNode(node, b);
|
|
1430
1463
|
break;
|
|
1431
1464
|
}
|
|
1432
|
-
case "@function":
|
|
1465
|
+
case "@function":
|
|
1466
|
+
case "@async function": {
|
|
1433
1467
|
b.append("");
|
|
1434
1468
|
buildScriptNode(node, b);
|
|
1435
1469
|
b.append("");
|
|
@@ -1743,7 +1777,9 @@ function buildRootNode(node, status, b, parentName, anchorName) {
|
|
|
1743
1777
|
fragment: node.fragment,
|
|
1744
1778
|
path: "0:ch/"
|
|
1745
1779
|
});
|
|
1746
|
-
|
|
1780
|
+
for (let child of node.children) {
|
|
1781
|
+
buildNode(child, status, b, parentName, anchorName, true);
|
|
1782
|
+
}
|
|
1747
1783
|
status.fragmentStack.pop();
|
|
1748
1784
|
buildAddFragment(node, status, b, parentName, anchorName);
|
|
1749
1785
|
}
|
|
@@ -1988,10 +2024,12 @@ var importsMap = {
|
|
|
1988
2024
|
t_anchor: 'import { t_anchor } from "${folder}";',
|
|
1989
2025
|
t_child: 'import { t_child } from "${folder}";',
|
|
1990
2026
|
t_next: 'import { t_next } from "${folder}";',
|
|
2027
|
+
t_skip: 'import { t_skip } from "${folder}";',
|
|
1991
2028
|
t_frg: 'import { t_frg } from "${folder}";',
|
|
1992
2029
|
t_elm: 'import { t_elm } from "${folder}";',
|
|
1993
2030
|
t_txt: 'import { t_txt } from "${folder}";',
|
|
1994
2031
|
t_cmt: 'import { t_cmt } from "${folder}";',
|
|
2032
|
+
t_print: 'import { t_print } from "${folder}";',
|
|
1995
2033
|
ListItem: 'import { type ListItem } from "${folder}";',
|
|
1996
2034
|
SlotRender: 'import { type SlotRender } from "${folder}";'
|
|
1997
2035
|
};
|
|
@@ -2083,16 +2121,20 @@ function buildStyles(style, styleHash) {
|
|
|
2083
2121
|
}
|
|
2084
2122
|
var globalStyleRegex = /\:global\((.+)\)/;
|
|
2085
2123
|
function buildStyleBlock(block, b, styleHash) {
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2124
|
+
if (block.selector.startsWith("@")) {
|
|
2125
|
+
b.append(`${block.selector} {`);
|
|
2126
|
+
} else {
|
|
2127
|
+
const selectors = block.selector.split(/([\s*,>+~])/).filter((s) => !!s.trim()).map((s) => {
|
|
2128
|
+
if (s.length === 1 && "*,>+~".includes(s)) {
|
|
2129
|
+
return s;
|
|
2130
|
+
} else if (globalStyleRegex.test(s)) {
|
|
2131
|
+
return s.match(globalStyleRegex)[1];
|
|
2132
|
+
} else {
|
|
2133
|
+
return `${s}.torp-${styleHash}`;
|
|
2134
|
+
}
|
|
2135
|
+
});
|
|
2136
|
+
b.append(`${selectors.join(" ")} {`);
|
|
2137
|
+
}
|
|
2096
2138
|
for (let attribute of block.attributes) {
|
|
2097
2139
|
buildStyleAttribute(attribute, b);
|
|
2098
2140
|
}
|
|
@@ -2189,9 +2231,7 @@ ${slotParams.join(",\n")}
|
|
|
2189
2231
|
}
|
|
2190
2232
|
b.append("");
|
|
2191
2233
|
b.append(`$output += ${componentName}(${renderParams})`);
|
|
2192
|
-
|
|
2193
|
-
status.output += ANCHOR_COMMENT;
|
|
2194
|
-
}
|
|
2234
|
+
status.output += ANCHOR_COMMENT;
|
|
2195
2235
|
}
|
|
2196
2236
|
|
|
2197
2237
|
// src/compile/build/server/buildServerAwaitNode.ts
|
|
@@ -2236,7 +2276,7 @@ function buildServerForNode(node, status, b) {
|
|
|
2236
2276
|
}
|
|
2237
2277
|
function buildServerForBranch(node, status, b) {
|
|
2238
2278
|
b.append(`${node.statement} {`);
|
|
2239
|
-
status.output +=
|
|
2279
|
+
status.output += HYDRATION_BREAK_COMMENT;
|
|
2240
2280
|
for (let child of node.children) {
|
|
2241
2281
|
buildServerNode(child, status, b);
|
|
2242
2282
|
}
|
|
@@ -2276,6 +2316,7 @@ function buildServerIfNode(node, status, b) {
|
|
|
2276
2316
|
}
|
|
2277
2317
|
function buildServerIfBranch(node, status, b) {
|
|
2278
2318
|
b.append(`${node.statement} {`);
|
|
2319
|
+
status.output += HYDRATION_BREAK_COMMENT;
|
|
2279
2320
|
for (let child of node.children) {
|
|
2280
2321
|
buildServerNode(child, status, b);
|
|
2281
2322
|
}
|
|
@@ -2342,6 +2383,7 @@ function buildServerSwitchNode(node, status, b) {
|
|
|
2342
2383
|
}
|
|
2343
2384
|
function buildServerSwitchBranch(node, status, b) {
|
|
2344
2385
|
b.append(`${node.statement} {`);
|
|
2386
|
+
status.output += HYDRATION_BREAK_COMMENT;
|
|
2345
2387
|
for (let child of node.children) {
|
|
2346
2388
|
buildServerNode(child, status, b);
|
|
2347
2389
|
}
|
|
@@ -2412,7 +2454,8 @@ function buildServerControlNode(node, status, b) {
|
|
|
2412
2454
|
buildServerScriptNode(node, b);
|
|
2413
2455
|
break;
|
|
2414
2456
|
}
|
|
2415
|
-
case "@function":
|
|
2457
|
+
case "@function":
|
|
2458
|
+
case "@async function": {
|
|
2416
2459
|
if (status.output) {
|
|
2417
2460
|
b.append(`$output += \`${status.output}\`;`);
|
|
2418
2461
|
status.output = "";
|
|
@@ -2559,7 +2602,9 @@ function buildElementAttributes2(node, status) {
|
|
|
2559
2602
|
|
|
2560
2603
|
// src/compile/build/server/buildServerRootNode.ts
|
|
2561
2604
|
function buildServerRootNode(node, status, b) {
|
|
2562
|
-
|
|
2605
|
+
for (let child of node.children) {
|
|
2606
|
+
buildServerNode(child, status, b);
|
|
2607
|
+
}
|
|
2563
2608
|
}
|
|
2564
2609
|
|
|
2565
2610
|
// src/compile/build/server/buildServerSlotNode.ts
|
|
@@ -2877,6 +2922,15 @@ function isSpaceNode(node) {
|
|
|
2877
2922
|
return isTextNode(node) && isSpace(node.content);
|
|
2878
2923
|
}
|
|
2879
2924
|
|
|
2925
|
+
// src/compile/utils/trimStart.ts
|
|
2926
|
+
function trimStart(text, char) {
|
|
2927
|
+
let start = 0;
|
|
2928
|
+
while (text[start] === char) {
|
|
2929
|
+
start += 1;
|
|
2930
|
+
}
|
|
2931
|
+
return text.substring(start);
|
|
2932
|
+
}
|
|
2933
|
+
|
|
2880
2934
|
// src/compile/parse/utils/consumeSpace.ts
|
|
2881
2935
|
function consumeSpace(status) {
|
|
2882
2936
|
const start = status.i;
|
|
@@ -2905,15 +2959,6 @@ function addSpaceElement(parent, status) {
|
|
|
2905
2959
|
}
|
|
2906
2960
|
}
|
|
2907
2961
|
|
|
2908
|
-
// src/compile/utils/trimStart.ts
|
|
2909
|
-
function trimStart(text, char) {
|
|
2910
|
-
let start = 0;
|
|
2911
|
-
while (text[start] === char) {
|
|
2912
|
-
start += 1;
|
|
2913
|
-
}
|
|
2914
|
-
return text.substring(start);
|
|
2915
|
-
}
|
|
2916
|
-
|
|
2917
2962
|
// src/compile/parse/utils/accept.ts
|
|
2918
2963
|
function accept(value, status, advance = true) {
|
|
2919
2964
|
const check = status.source.substring(status.i, status.i + value.length);
|
|
@@ -2969,230 +3014,6 @@ function parseInlineScript(status) {
|
|
|
2969
3014
|
return "";
|
|
2970
3015
|
}
|
|
2971
3016
|
|
|
2972
|
-
// src/compile/parse/utils/addError.ts
|
|
2973
|
-
function addError(status, message, start = status.i) {
|
|
2974
|
-
let line = 1;
|
|
2975
|
-
let lastLineStart = 0;
|
|
2976
|
-
for (let i = 0; i < start; i++) {
|
|
2977
|
-
if (status.source[i] === "\n") {
|
|
2978
|
-
line += 1;
|
|
2979
|
-
lastLineStart = i + 1;
|
|
2980
|
-
}
|
|
2981
|
-
}
|
|
2982
|
-
let column = start - lastLineStart;
|
|
2983
|
-
status.errors.push({ message, start, line, column });
|
|
2984
|
-
}
|
|
2985
|
-
|
|
2986
|
-
// src/compile/parse/parseControl.ts
|
|
2987
|
-
var controlOperations = [
|
|
2988
|
-
"@if",
|
|
2989
|
-
"@else",
|
|
2990
|
-
"@for",
|
|
2991
|
-
"@key",
|
|
2992
|
-
"@switch",
|
|
2993
|
-
"@case",
|
|
2994
|
-
"@default",
|
|
2995
|
-
"@await",
|
|
2996
|
-
"@then",
|
|
2997
|
-
"@catch",
|
|
2998
|
-
"@replace",
|
|
2999
|
-
"@html",
|
|
3000
|
-
"@const",
|
|
3001
|
-
"@console",
|
|
3002
|
-
"@debugger",
|
|
3003
|
-
"@function"
|
|
3004
|
-
];
|
|
3005
|
-
var standaloneOperations = ["@key", "@html", "@const", "@console", "@debugger", "@function"];
|
|
3006
|
-
function parseControl(status, parentNode) {
|
|
3007
|
-
const node = parseControlOpen(status);
|
|
3008
|
-
if (!node) {
|
|
3009
|
-
return;
|
|
3010
|
-
}
|
|
3011
|
-
if (standaloneOperations.includes(node.operation)) {
|
|
3012
|
-
wrangleControlNode(node, parentNode);
|
|
3013
|
-
return;
|
|
3014
|
-
}
|
|
3015
|
-
while (status.i < status.source.length) {
|
|
3016
|
-
addSpaceElement(node, status);
|
|
3017
|
-
if (accept("}", status)) {
|
|
3018
|
-
break;
|
|
3019
|
-
} else if (accept("<", status, false)) {
|
|
3020
|
-
const child = parseElement(status);
|
|
3021
|
-
node.children.push(child);
|
|
3022
|
-
} else if (accept("@//", status)) {
|
|
3023
|
-
status.i = status.source.indexOf("\n", status.i) + 1;
|
|
3024
|
-
} else if (accept("@/*", status)) {
|
|
3025
|
-
status.i = status.source.indexOf("*/", status.i) + 2;
|
|
3026
|
-
} else if (accept("@", status, false)) {
|
|
3027
|
-
parseControl(status, node);
|
|
3028
|
-
} else if (accept("case", status, false) || accept("key", status, false)) {
|
|
3029
|
-
parseControl(status, node);
|
|
3030
|
-
} else {
|
|
3031
|
-
const char = status.source[status.i];
|
|
3032
|
-
addError(status, `Unexpected token in control block: ${char}`, status.i);
|
|
3033
|
-
break;
|
|
3034
|
-
}
|
|
3035
|
-
}
|
|
3036
|
-
wrangleControlNode(node, parentNode);
|
|
3037
|
-
parseControlBranches(status, parentNode);
|
|
3038
|
-
}
|
|
3039
|
-
function parseControlOpen(status) {
|
|
3040
|
-
const start = status.i;
|
|
3041
|
-
let operation = "";
|
|
3042
|
-
for (status.i; status.i < status.source.length; status.i++) {
|
|
3043
|
-
const char = status.source[status.i];
|
|
3044
|
-
if (isSpaceChar(status.source, status.i) || accept(":", status) && operation === "default" || accept(".", status) && operation === "@console" || accept("(", status, false) && operation === "@html") {
|
|
3045
|
-
break;
|
|
3046
|
-
}
|
|
3047
|
-
operation += char;
|
|
3048
|
-
}
|
|
3049
|
-
if (!operation.startsWith("@")) {
|
|
3050
|
-
operation = "@" + operation;
|
|
3051
|
-
}
|
|
3052
|
-
let statement = "";
|
|
3053
|
-
if (controlOperations.includes(operation)) {
|
|
3054
|
-
statement = parseControlStatement(start, operation, status);
|
|
3055
|
-
if (operation === "@function") {
|
|
3056
|
-
statement += ` {${parseInlineScript(status)}}`;
|
|
3057
|
-
accept("}", status);
|
|
3058
|
-
}
|
|
3059
|
-
if (operation === "@replace" || operation === "@html") {
|
|
3060
|
-
statement = trimMatched(statement.substring(statement.indexOf("(")).trim(), "(", ")");
|
|
3061
|
-
}
|
|
3062
|
-
} else {
|
|
3063
|
-
addError(status, `Unknown operation: ${operation}`, status.i);
|
|
3064
|
-
return null;
|
|
3065
|
-
}
|
|
3066
|
-
return {
|
|
3067
|
-
type: "control",
|
|
3068
|
-
operation,
|
|
3069
|
-
statement,
|
|
3070
|
-
children: []
|
|
3071
|
-
};
|
|
3072
|
-
}
|
|
3073
|
-
function parseControlStatement(start, operation, status) {
|
|
3074
|
-
let parenCount = 0;
|
|
3075
|
-
while (status.i < status.source.length) {
|
|
3076
|
-
if (accept("(", status)) {
|
|
3077
|
-
parenCount += 1;
|
|
3078
|
-
} else if (accept(")", status)) {
|
|
3079
|
-
parenCount -= 1;
|
|
3080
|
-
} else if (accept("{", status) || accept("\n", status) && standaloneOperations.includes(operation)) {
|
|
3081
|
-
if (parenCount === 0) {
|
|
3082
|
-
return trimStart(status.source.substring(start, status.i - 1).trim(), "@");
|
|
3083
|
-
}
|
|
3084
|
-
} else if (accept('"', status) || accept("'", status)) {
|
|
3085
|
-
const char = status.source[status.i - 1];
|
|
3086
|
-
for (let j = status.i + 1; j < status.source.length; j++) {
|
|
3087
|
-
if (status.source[j] === char && status.source[j - 1] !== "\\") {
|
|
3088
|
-
status.i = j + 1;
|
|
3089
|
-
break;
|
|
3090
|
-
}
|
|
3091
|
-
}
|
|
3092
|
-
} else if (accept("`", status)) {
|
|
3093
|
-
let level2 = 0;
|
|
3094
|
-
for (let j = status.i + 1; j < status.source.length; j++) {
|
|
3095
|
-
if (status.source[j] === "`" && status.source[j - 1] !== "\\" && level2 === 0) {
|
|
3096
|
-
status.i = j + 1;
|
|
3097
|
-
break;
|
|
3098
|
-
} else if (status.source[j] === "{" && (level2 > 0 || status.source[j - 1] === "$")) {
|
|
3099
|
-
level2 += 1;
|
|
3100
|
-
} else if (status.source[j] === "}" && level2 > 0) {
|
|
3101
|
-
level2 -= 1;
|
|
3102
|
-
}
|
|
3103
|
-
}
|
|
3104
|
-
} else if (accept("//", status)) {
|
|
3105
|
-
status.i = status.source.indexOf("\n", status.i) + 1;
|
|
3106
|
-
} else if (accept("/*", status)) {
|
|
3107
|
-
status.i = status.source.indexOf("*/", status.i) + 2;
|
|
3108
|
-
} else {
|
|
3109
|
-
status.i += 1;
|
|
3110
|
-
}
|
|
3111
|
-
}
|
|
3112
|
-
return "";
|
|
3113
|
-
}
|
|
3114
|
-
function wrangleControlNode(node, parentNode) {
|
|
3115
|
-
if (node.operation === "@if") {
|
|
3116
|
-
const ifGroup = {
|
|
3117
|
-
type: "control",
|
|
3118
|
-
operation: "@if group",
|
|
3119
|
-
statement: "",
|
|
3120
|
-
children: [node]
|
|
3121
|
-
};
|
|
3122
|
-
parentNode.children.push(ifGroup);
|
|
3123
|
-
} else if (node.operation === "@else") {
|
|
3124
|
-
if (/^else\s+if/.test(node.statement)) {
|
|
3125
|
-
node.operation = "@else if";
|
|
3126
|
-
}
|
|
3127
|
-
for (let i = parentNode.children.length - 1; i >= 0; i--) {
|
|
3128
|
-
const lastChild = parentNode.children[i];
|
|
3129
|
-
if (isControlNode(lastChild) && lastChild.operation === "@if group") {
|
|
3130
|
-
lastChild.children.push(node);
|
|
3131
|
-
break;
|
|
3132
|
-
}
|
|
3133
|
-
}
|
|
3134
|
-
} else if (node.operation === "@for") {
|
|
3135
|
-
const forGroup = {
|
|
3136
|
-
type: "control",
|
|
3137
|
-
operation: "@for group",
|
|
3138
|
-
statement: "",
|
|
3139
|
-
children: [node]
|
|
3140
|
-
};
|
|
3141
|
-
parentNode.children.push(forGroup);
|
|
3142
|
-
} else if (node.operation === "@switch") {
|
|
3143
|
-
node.operation = "@switch group";
|
|
3144
|
-
parentNode.children.push(node);
|
|
3145
|
-
} else if (node.operation === "@await") {
|
|
3146
|
-
const awaitGroup = {
|
|
3147
|
-
type: "control",
|
|
3148
|
-
operation: "@await group",
|
|
3149
|
-
statement: "",
|
|
3150
|
-
children: [node]
|
|
3151
|
-
};
|
|
3152
|
-
parentNode.children.push(awaitGroup);
|
|
3153
|
-
} else if (node.operation === "@then" || node.operation === "@catch") {
|
|
3154
|
-
for (let i = parentNode.children.length - 1; i >= 0; i--) {
|
|
3155
|
-
const lastChild = parentNode.children[i];
|
|
3156
|
-
if (isControlNode(lastChild) && lastChild.operation === "@await group") {
|
|
3157
|
-
lastChild.children.push(node);
|
|
3158
|
-
break;
|
|
3159
|
-
}
|
|
3160
|
-
}
|
|
3161
|
-
} else if (node.operation === "@replace") {
|
|
3162
|
-
const replaceGroup = {
|
|
3163
|
-
type: "control",
|
|
3164
|
-
operation: "@replace group",
|
|
3165
|
-
statement: "",
|
|
3166
|
-
children: [node]
|
|
3167
|
-
};
|
|
3168
|
-
parentNode.children.push(replaceGroup);
|
|
3169
|
-
} else if (node.operation === "@html") {
|
|
3170
|
-
const htmlGroup = {
|
|
3171
|
-
type: "control",
|
|
3172
|
-
operation: "@html group",
|
|
3173
|
-
statement: "",
|
|
3174
|
-
children: [node]
|
|
3175
|
-
};
|
|
3176
|
-
parentNode.children.push(htmlGroup);
|
|
3177
|
-
} else {
|
|
3178
|
-
parentNode.children.push(node);
|
|
3179
|
-
}
|
|
3180
|
-
}
|
|
3181
|
-
function parseControlBranches(status, parentNode) {
|
|
3182
|
-
let gotAnotherBranch = true;
|
|
3183
|
-
while (gotAnotherBranch) {
|
|
3184
|
-
let start = status.i;
|
|
3185
|
-
status.i += 1;
|
|
3186
|
-
consumeSpace(status);
|
|
3187
|
-
if (accept("else", status, false) || accept("case", status, false) || accept("default", status, false) || accept("then", status, false) || accept("catch", status, false)) {
|
|
3188
|
-
parseControl(status, parentNode);
|
|
3189
|
-
} else {
|
|
3190
|
-
gotAnotherBranch = false;
|
|
3191
|
-
status.i = start;
|
|
3192
|
-
}
|
|
3193
|
-
}
|
|
3194
|
-
}
|
|
3195
|
-
|
|
3196
3017
|
// src/compile/parse/utils/isAlphaNumericChar.ts
|
|
3197
3018
|
function isAlphaNumericChar(text, index) {
|
|
3198
3019
|
let code = text.charCodeAt(index);
|
|
@@ -3331,6 +3152,20 @@ function isFillNode(n) {
|
|
|
3331
3152
|
return isSpecialNode(n) && n.tagName === ":fill";
|
|
3332
3153
|
}
|
|
3333
3154
|
|
|
3155
|
+
// src/compile/parse/utils/addError.ts
|
|
3156
|
+
function addError(status, message, start = status.i) {
|
|
3157
|
+
let line = 1;
|
|
3158
|
+
let lastLineStart = 0;
|
|
3159
|
+
for (let i = 0; i < start; i++) {
|
|
3160
|
+
if (status.source[i] === "\n") {
|
|
3161
|
+
line += 1;
|
|
3162
|
+
lastLineStart = i + 1;
|
|
3163
|
+
}
|
|
3164
|
+
}
|
|
3165
|
+
let column = start - lastLineStart;
|
|
3166
|
+
status.errors.push({ message, start, line, column });
|
|
3167
|
+
}
|
|
3168
|
+
|
|
3334
3169
|
// src/compile/parse/parseElement.ts
|
|
3335
3170
|
function parseElement(status) {
|
|
3336
3171
|
const start = status.i;
|
|
@@ -3535,6 +3370,225 @@ function checkCloseTag(status, element, current) {
|
|
|
3535
3370
|
return found;
|
|
3536
3371
|
}
|
|
3537
3372
|
|
|
3373
|
+
// src/compile/parse/parseControl.ts
|
|
3374
|
+
var controlOperations = [
|
|
3375
|
+
"@if",
|
|
3376
|
+
"@else",
|
|
3377
|
+
"@for",
|
|
3378
|
+
"@key",
|
|
3379
|
+
"@switch",
|
|
3380
|
+
"@case",
|
|
3381
|
+
"@default",
|
|
3382
|
+
"@await",
|
|
3383
|
+
"@then",
|
|
3384
|
+
"@catch",
|
|
3385
|
+
"@replace",
|
|
3386
|
+
"@html",
|
|
3387
|
+
"@const",
|
|
3388
|
+
"@console",
|
|
3389
|
+
"@debugger",
|
|
3390
|
+
"@function",
|
|
3391
|
+
"@async function"
|
|
3392
|
+
];
|
|
3393
|
+
var standaloneOperations = [
|
|
3394
|
+
"@key",
|
|
3395
|
+
"@html",
|
|
3396
|
+
"@const",
|
|
3397
|
+
"@console",
|
|
3398
|
+
"@debugger",
|
|
3399
|
+
"@function",
|
|
3400
|
+
"@async function"
|
|
3401
|
+
];
|
|
3402
|
+
function parseControl(status, parentNode) {
|
|
3403
|
+
const node = parseControlOpen(status);
|
|
3404
|
+
if (!node) {
|
|
3405
|
+
return;
|
|
3406
|
+
}
|
|
3407
|
+
if (standaloneOperations.includes(node.operation)) {
|
|
3408
|
+
wrangleControlNode(node, parentNode);
|
|
3409
|
+
return;
|
|
3410
|
+
}
|
|
3411
|
+
while (status.i < status.source.length) {
|
|
3412
|
+
addSpaceElement(node, status);
|
|
3413
|
+
if (accept("}", status)) {
|
|
3414
|
+
break;
|
|
3415
|
+
} else if (accept("<", status, false)) {
|
|
3416
|
+
const child = parseElement(status);
|
|
3417
|
+
node.children.push(child);
|
|
3418
|
+
} else if (accept("@//", status)) {
|
|
3419
|
+
status.i = status.source.indexOf("\n", status.i) + 1;
|
|
3420
|
+
} else if (accept("@/*", status)) {
|
|
3421
|
+
status.i = status.source.indexOf("*/", status.i) + 2;
|
|
3422
|
+
} else if (accept("@", status, false)) {
|
|
3423
|
+
parseControl(status, node);
|
|
3424
|
+
} else if (accept("case", status, false) || accept("key", status, false)) {
|
|
3425
|
+
parseControl(status, node);
|
|
3426
|
+
} else {
|
|
3427
|
+
const char = status.source[status.i];
|
|
3428
|
+
addError(status, `Unexpected token in control block: ${char}`, status.i);
|
|
3429
|
+
break;
|
|
3430
|
+
}
|
|
3431
|
+
}
|
|
3432
|
+
wrangleControlNode(node, parentNode);
|
|
3433
|
+
parseControlBranches(status, parentNode);
|
|
3434
|
+
}
|
|
3435
|
+
function parseControlOpen(status) {
|
|
3436
|
+
const start = status.i;
|
|
3437
|
+
let operation = "";
|
|
3438
|
+
for (status.i; status.i < status.source.length; status.i++) {
|
|
3439
|
+
const char = status.source[status.i];
|
|
3440
|
+
if (isSpaceChar(status.source, status.i) && operation !== "@async" || accept(":", status) && operation === "default" || accept(".", status) && operation === "@console" || accept("(", status, false) && operation === "@html") {
|
|
3441
|
+
break;
|
|
3442
|
+
}
|
|
3443
|
+
operation += char;
|
|
3444
|
+
}
|
|
3445
|
+
if (!operation.startsWith("@")) {
|
|
3446
|
+
operation = "@" + operation;
|
|
3447
|
+
}
|
|
3448
|
+
let statement = "";
|
|
3449
|
+
if (controlOperations.includes(operation)) {
|
|
3450
|
+
statement = parseControlStatement(start, operation, status);
|
|
3451
|
+
if (operation === "@function" || operation === "@async function") {
|
|
3452
|
+
statement += ` {${parseInlineScript(status)}}`;
|
|
3453
|
+
accept("}", status);
|
|
3454
|
+
}
|
|
3455
|
+
if (operation === "@replace" || operation === "@html") {
|
|
3456
|
+
statement = trimMatched(statement.substring(statement.indexOf("(")).trim(), "(", ")");
|
|
3457
|
+
}
|
|
3458
|
+
} else {
|
|
3459
|
+
addError(status, `Unknown operation: ${operation}`, status.i);
|
|
3460
|
+
return null;
|
|
3461
|
+
}
|
|
3462
|
+
return {
|
|
3463
|
+
type: "control",
|
|
3464
|
+
operation,
|
|
3465
|
+
statement,
|
|
3466
|
+
children: []
|
|
3467
|
+
};
|
|
3468
|
+
}
|
|
3469
|
+
function parseControlStatement(start, operation, status) {
|
|
3470
|
+
let parenCount = 0;
|
|
3471
|
+
while (status.i < status.source.length) {
|
|
3472
|
+
if (accept("(", status)) {
|
|
3473
|
+
parenCount += 1;
|
|
3474
|
+
} else if (accept(")", status)) {
|
|
3475
|
+
parenCount -= 1;
|
|
3476
|
+
} else if (accept("{", status) || accept("\n", status) && standaloneOperations.includes(operation)) {
|
|
3477
|
+
if (parenCount === 0) {
|
|
3478
|
+
return trimStart(status.source.substring(start, status.i - 1).trim(), "@");
|
|
3479
|
+
}
|
|
3480
|
+
} else if (accept('"', status) || accept("'", status)) {
|
|
3481
|
+
const char = status.source[status.i - 1];
|
|
3482
|
+
for (let j = status.i + 1; j < status.source.length; j++) {
|
|
3483
|
+
if (status.source[j] === char && status.source[j - 1] !== "\\") {
|
|
3484
|
+
status.i = j + 1;
|
|
3485
|
+
break;
|
|
3486
|
+
}
|
|
3487
|
+
}
|
|
3488
|
+
} else if (accept("`", status)) {
|
|
3489
|
+
let level2 = 0;
|
|
3490
|
+
for (let j = status.i + 1; j < status.source.length; j++) {
|
|
3491
|
+
if (status.source[j] === "`" && status.source[j - 1] !== "\\" && level2 === 0) {
|
|
3492
|
+
status.i = j + 1;
|
|
3493
|
+
break;
|
|
3494
|
+
} else if (status.source[j] === "{" && (level2 > 0 || status.source[j - 1] === "$")) {
|
|
3495
|
+
level2 += 1;
|
|
3496
|
+
} else if (status.source[j] === "}" && level2 > 0) {
|
|
3497
|
+
level2 -= 1;
|
|
3498
|
+
}
|
|
3499
|
+
}
|
|
3500
|
+
} else if (accept("//", status)) {
|
|
3501
|
+
status.i = status.source.indexOf("\n", status.i) + 1;
|
|
3502
|
+
} else if (accept("/*", status)) {
|
|
3503
|
+
status.i = status.source.indexOf("*/", status.i) + 2;
|
|
3504
|
+
} else {
|
|
3505
|
+
status.i += 1;
|
|
3506
|
+
}
|
|
3507
|
+
}
|
|
3508
|
+
return "";
|
|
3509
|
+
}
|
|
3510
|
+
function wrangleControlNode(node, parentNode) {
|
|
3511
|
+
if (node.operation === "@if") {
|
|
3512
|
+
const ifGroup = {
|
|
3513
|
+
type: "control",
|
|
3514
|
+
operation: "@if group",
|
|
3515
|
+
statement: "",
|
|
3516
|
+
children: [node]
|
|
3517
|
+
};
|
|
3518
|
+
parentNode.children.push(ifGroup);
|
|
3519
|
+
} else if (node.operation === "@else") {
|
|
3520
|
+
if (/^else\s+if/.test(node.statement)) {
|
|
3521
|
+
node.operation = "@else if";
|
|
3522
|
+
}
|
|
3523
|
+
for (let i = parentNode.children.length - 1; i >= 0; i--) {
|
|
3524
|
+
const lastChild = parentNode.children[i];
|
|
3525
|
+
if (isControlNode(lastChild) && lastChild.operation === "@if group") {
|
|
3526
|
+
lastChild.children.push(node);
|
|
3527
|
+
break;
|
|
3528
|
+
}
|
|
3529
|
+
}
|
|
3530
|
+
} else if (node.operation === "@for") {
|
|
3531
|
+
const forGroup = {
|
|
3532
|
+
type: "control",
|
|
3533
|
+
operation: "@for group",
|
|
3534
|
+
statement: "",
|
|
3535
|
+
children: [node]
|
|
3536
|
+
};
|
|
3537
|
+
parentNode.children.push(forGroup);
|
|
3538
|
+
} else if (node.operation === "@switch") {
|
|
3539
|
+
node.operation = "@switch group";
|
|
3540
|
+
parentNode.children.push(node);
|
|
3541
|
+
} else if (node.operation === "@await") {
|
|
3542
|
+
const awaitGroup = {
|
|
3543
|
+
type: "control",
|
|
3544
|
+
operation: "@await group",
|
|
3545
|
+
statement: "",
|
|
3546
|
+
children: [node]
|
|
3547
|
+
};
|
|
3548
|
+
parentNode.children.push(awaitGroup);
|
|
3549
|
+
} else if (node.operation === "@then" || node.operation === "@catch") {
|
|
3550
|
+
for (let i = parentNode.children.length - 1; i >= 0; i--) {
|
|
3551
|
+
const lastChild = parentNode.children[i];
|
|
3552
|
+
if (isControlNode(lastChild) && lastChild.operation === "@await group") {
|
|
3553
|
+
lastChild.children.push(node);
|
|
3554
|
+
break;
|
|
3555
|
+
}
|
|
3556
|
+
}
|
|
3557
|
+
} else if (node.operation === "@replace") {
|
|
3558
|
+
const replaceGroup = {
|
|
3559
|
+
type: "control",
|
|
3560
|
+
operation: "@replace group",
|
|
3561
|
+
statement: "",
|
|
3562
|
+
children: [node]
|
|
3563
|
+
};
|
|
3564
|
+
parentNode.children.push(replaceGroup);
|
|
3565
|
+
} else if (node.operation === "@html") {
|
|
3566
|
+
const htmlGroup = {
|
|
3567
|
+
type: "control",
|
|
3568
|
+
operation: "@html group",
|
|
3569
|
+
statement: "",
|
|
3570
|
+
children: [node]
|
|
3571
|
+
};
|
|
3572
|
+
parentNode.children.push(htmlGroup);
|
|
3573
|
+
} else {
|
|
3574
|
+
parentNode.children.push(node);
|
|
3575
|
+
}
|
|
3576
|
+
}
|
|
3577
|
+
function parseControlBranches(status, parentNode) {
|
|
3578
|
+
let gotAnotherBranch = true;
|
|
3579
|
+
while (gotAnotherBranch) {
|
|
3580
|
+
let start = status.i;
|
|
3581
|
+
status.i += 1;
|
|
3582
|
+
consumeSpace(status);
|
|
3583
|
+
if (accept("else", status, false) || accept("case", status, false) || accept("default", status, false) || accept("then", status, false) || accept("catch", status, false)) {
|
|
3584
|
+
parseControl(status, parentNode);
|
|
3585
|
+
} else {
|
|
3586
|
+
gotAnotherBranch = false;
|
|
3587
|
+
status.i = start;
|
|
3588
|
+
}
|
|
3589
|
+
}
|
|
3590
|
+
}
|
|
3591
|
+
|
|
3538
3592
|
// src/compile/parse/parseMarkup.ts
|
|
3539
3593
|
function parseMarkup(status, source) {
|
|
3540
3594
|
const current = status.components.at(-1);
|
|
@@ -3548,14 +3602,17 @@ function parseMarkup(status, source) {
|
|
|
3548
3602
|
status.i = status.source.indexOf("\n", status.i) + 1;
|
|
3549
3603
|
} else if (accept("@/*", status)) {
|
|
3550
3604
|
status.i = status.source.indexOf("*/", status.i) + 2;
|
|
3605
|
+
} else if (isSpaceChar(status.source, status.i)) {
|
|
3606
|
+
current.markup ??= { type: "root", children: [] };
|
|
3607
|
+
const text = { type: "text", content: consumeSpace(status) };
|
|
3608
|
+
current.markup.children.push(text);
|
|
3551
3609
|
} else if (accept("<", status, false)) {
|
|
3552
|
-
|
|
3610
|
+
current.markup ??= { type: "root", children: [] };
|
|
3553
3611
|
const element = parseElement(status);
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
}
|
|
3612
|
+
current.markup.children.push(element);
|
|
3613
|
+
} else if (accept("@", status, false)) {
|
|
3614
|
+
current.markup ??= { type: "root", children: [] };
|
|
3615
|
+
parseControl(status, current.markup);
|
|
3559
3616
|
} else {
|
|
3560
3617
|
status.i += 1;
|
|
3561
3618
|
}
|
|
@@ -3796,10 +3853,7 @@ function parseCode(source) {
|
|
|
3796
3853
|
name: c.name,
|
|
3797
3854
|
default: c.default,
|
|
3798
3855
|
params: c.params,
|
|
3799
|
-
markup: c.markup
|
|
3800
|
-
type: "root",
|
|
3801
|
-
children: [c.markup]
|
|
3802
|
-
} : void 0,
|
|
3856
|
+
markup: c.markup,
|
|
3803
3857
|
style: c.style,
|
|
3804
3858
|
props: c.props,
|
|
3805
3859
|
contextProps: c.contextProps,
|
|
@@ -3951,7 +4005,7 @@ function parseComponentEnd(status) {
|
|
|
3951
4005
|
const componentSource = status.source.substring(current.start || 0, status.i);
|
|
3952
4006
|
current.props = getPropsUsage(componentSource);
|
|
3953
4007
|
current.contextProps = getContextUsage(componentSource);
|
|
3954
|
-
if (current.markup && current.markup.tagName === "html" && isSpaceNode(current.markup.children[0])) {
|
|
4008
|
+
if (current.markup && isElementNode(current.markup.children[0]) && current.markup.children[0].tagName === "html" && isSpaceNode(current.markup.children[0].children[0])) {
|
|
3955
4009
|
current.markup.children.splice(1, 1);
|
|
3956
4010
|
}
|
|
3957
4011
|
status.marker = status.i;
|