@torpor/view 0.0.11 → 0.0.13

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.
Files changed (174) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/{ServerSlotRender-AWF3bD5B.d.cts → ServerSlotRender-t1sOutne.d.cts} +1 -1
  3. package/dist/{ServerSlotRender-AWF3bD5B.d.ts → ServerSlotRender-t1sOutne.d.ts} +1 -1
  4. package/dist/{chunk-GO2L324Q.js → chunk-T6JGCJ5T.js} +5 -2
  5. package/dist/chunk-T6JGCJ5T.js.map +1 -0
  6. package/dist/compile.cjs +42 -31
  7. package/dist/compile.cjs.map +1 -1
  8. package/dist/compile.d.cts +1 -0
  9. package/dist/compile.d.ts +1 -0
  10. package/dist/compile.js +42 -31
  11. package/dist/compile.js.map +1 -1
  12. package/dist/index.cjs +4 -1
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +2 -2
  15. package/dist/index.d.ts +2 -2
  16. package/dist/index.js +1 -1
  17. package/dist/index.js.map +1 -1
  18. package/dist/metafile-cjs.json +1 -1
  19. package/dist/metafile-esm.json +1 -1
  20. package/dist/ssr.cjs +4 -1
  21. package/dist/ssr.cjs.map +1 -1
  22. package/dist/ssr.d.cts +2 -2
  23. package/dist/ssr.d.ts +2 -2
  24. package/dist/ssr.js +1 -1
  25. package/dist/ssr.js.map +1 -1
  26. package/package.json +6 -6
  27. package/scripts/buildTestOutput.ts +2 -121
  28. package/src/compile/build/client/buildAddFragment.ts +1 -1
  29. package/src/compile/build/client/buildAwaitNode.ts +1 -1
  30. package/src/compile/build/client/buildComponentNode.ts +1 -1
  31. package/src/compile/build/client/buildControlNode.ts +1 -1
  32. package/src/compile/build/client/buildElementNode.ts +7 -1
  33. package/src/compile/build/client/buildForNode.ts +1 -1
  34. package/src/compile/build/client/buildFragment.ts +1 -1
  35. package/src/compile/build/client/buildFragmentText.ts +7 -1
  36. package/src/compile/build/client/buildHeadNode.ts +1 -1
  37. package/src/compile/build/client/buildHtmlNode.ts +1 -1
  38. package/src/compile/build/client/buildIfNode.ts +1 -1
  39. package/src/compile/build/client/buildMount.ts +1 -1
  40. package/src/compile/build/client/buildNode.ts +1 -1
  41. package/src/compile/build/client/buildReplaceNode.ts +1 -1
  42. package/src/compile/build/client/buildRootNode.ts +1 -1
  43. package/src/compile/build/client/buildRun.ts +1 -1
  44. package/src/compile/build/client/buildScriptNode.ts +1 -1
  45. package/src/compile/build/client/buildSlotNode.ts +1 -1
  46. package/src/compile/build/client/buildSwitchNode.ts +1 -1
  47. package/src/compile/build/client/buildTextNode.ts +1 -1
  48. package/src/compile/build/client/replaceForVarNames.ts +1 -1
  49. package/src/compile/build/server/buildServerAwaitNode.ts +1 -1
  50. package/src/compile/build/server/buildServerComponentNode.ts +1 -1
  51. package/src/compile/build/server/buildServerControlNode.ts +1 -1
  52. package/src/compile/build/server/buildServerElementNode.ts +9 -1
  53. package/src/compile/build/server/buildServerForNode.ts +1 -1
  54. package/src/compile/build/server/buildServerHtmlNode.ts +1 -1
  55. package/src/compile/build/server/buildServerIfNode.ts +1 -1
  56. package/src/compile/build/server/buildServerNode.ts +5 -1
  57. package/src/compile/build/server/buildServerReplaceNode.ts +1 -1
  58. package/src/compile/build/server/buildServerRootNode.ts +5 -1
  59. package/src/compile/build/server/buildServerScriptNode.ts +1 -1
  60. package/src/compile/build/server/buildServerSlotNode.ts +1 -1
  61. package/src/compile/build/server/buildServerSpecialNode.ts +1 -1
  62. package/src/compile/build/server/buildServerSwitchNode.ts +1 -1
  63. package/src/compile/build/server/buildServerTextNode.ts +1 -1
  64. package/src/compile/build/utils/isFullyReactive.ts +1 -1
  65. package/src/compile/build/utils/isReactive.ts +1 -1
  66. package/src/compile/build/utils/isReactiveAttribute.ts +1 -1
  67. package/src/compile/parse/addSpaceElement.ts +4 -1
  68. package/src/compile/parse/parseCode.ts +4 -0
  69. package/src/compile/parse/parseControl.ts +4 -1
  70. package/src/compile/parse/parseImports.ts +1 -1
  71. package/src/compile/parse/parseMarkup.ts +1 -1
  72. package/src/compile/parse/parseStyles.ts +1 -1
  73. package/src/compile/parse/scopeStyles.ts +13 -21
  74. package/src/compile/parse/slottifyChildNodes.ts +1 -1
  75. package/src/compile/parse/utils/addError.ts +5 -1
  76. package/src/compile/parse/utils/consumeUntil.ts +1 -1
  77. package/src/compile/parse/utils/isAlphaNumeric.ts +1 -1
  78. package/src/compile/parse/utils/isAlphaNumericChar.ts +1 -1
  79. package/src/compile/parse/utils/isSpace.ts +1 -1
  80. package/src/compile/parse/utils/isSpaceChar.ts +1 -1
  81. package/src/compile/types/nodes/TemplateNode.ts +3 -0
  82. package/src/compile/utils/Builder.ts +3 -3
  83. package/src/compile/utils/trimEnd.ts +1 -1
  84. package/src/compile/utils/trimMatched.ts +1 -1
  85. package/src/compile/utils/trimQuotes.ts +1 -1
  86. package/src/compile/utils/trimStart.ts +1 -1
  87. package/src/compile/utils/trimStartAndEnd.ts +1 -1
  88. package/src/compile/utils/voidTags.ts +1 -1
  89. package/src/debug/printHtml.ts +1 -1
  90. package/src/motion/animate.ts +1 -1
  91. package/src/render/$mount.ts +1 -1
  92. package/src/render/$run.ts +1 -1
  93. package/src/render/$serverMount.ts +1 -1
  94. package/src/render/$serverRun.ts +1 -1
  95. package/src/render/$stream.ts +1 -1
  96. package/src/render/addAnimation.ts +1 -1
  97. package/src/render/addEvent.ts +1 -1
  98. package/src/render/addFragment.ts +1 -1
  99. package/src/render/applyProps.ts +1 -1
  100. package/src/render/clearRange.ts +1 -1
  101. package/src/render/createComment.ts +1 -1
  102. package/src/render/createElement.ts +1 -1
  103. package/src/render/createFragment.ts +1 -1
  104. package/src/render/createText.ts +1 -1
  105. package/src/render/flushMountEffects.ts +1 -1
  106. package/src/render/getClasses.ts +4 -1
  107. package/src/render/hydrate.ts +1 -1
  108. package/src/render/hydrateRoot.ts +1 -1
  109. package/src/render/mount.ts +1 -1
  110. package/src/render/moveRange.ts +1 -1
  111. package/src/render/popRange.ts +1 -1
  112. package/src/render/runControl.ts +1 -1
  113. package/src/render/runControlBranch.ts +1 -1
  114. package/src/render/runList.ts +1 -1
  115. package/src/render/runListItems.ts +1 -1
  116. package/src/render/setAttribute.ts +1 -1
  117. package/src/render/setDynamicElement.ts +1 -1
  118. package/src/watch/proxyGet.ts +1 -1
  119. package/src/watch/removeEffect.ts +1 -1
  120. package/src/watch/runEffect.ts +1 -1
  121. package/src/watch/symbols.ts +1 -1
  122. package/src/watch/trackEffect.ts +1 -1
  123. package/src/watch/transferEffects.ts +1 -1
  124. package/src/watch/triggerEffects.ts +1 -1
  125. package/test/bench/components/output/Bench-client.ts +0 -204
  126. package/test/bench/components/output/Bench-server.ts +0 -130
  127. package/test/bench/components/temp/Bench-client-5fee290225ae4771aa847360006123671e8f17f1.ts +208 -0
  128. package/test/bench/components/temp/Bench-server-00cefa588803c01ca4f2741c595e4f045cdd101e.ts +130 -0
  129. package/test/build-server/components/{output/IfNested-client.ts → temp/IfNested-client-979db97eea5b4595550b9b46f297f3fbc31796d2.ts} +11 -0
  130. package/test/buildHtml.ts +1 -1
  131. package/test/buildOutputFiles.ts +47 -12
  132. package/test/class/class.test.ts +29 -6
  133. package/test/class/components/Class.torp +15 -1
  134. package/test/class/components/output/Class-client.ts +10 -6
  135. package/test/class/components/output/Class-server.ts +1 -1
  136. package/test/class/components/temp/{Class-client-600bf865c14f1052d24e1c79242f837aaf5ae5e8.ts → Class-client-8c3f9e0257cc2b687e9bb7106cccbab94a4b5adf.ts} +10 -6
  137. package/test/class/components/temp/Class-server-2218c3284845fdab80d1a41ebace9a9e2ddd6fc1.ts +17 -0
  138. package/test/component/components/temp/Header-client-ac151eea86e3f6b058fab101661e13ae73864968.ts +34 -0
  139. package/test/component/components/temp/Header-server-4f10f2332f3ca7a097517cfb938ab1e6f31d68ac.ts +17 -0
  140. package/test/console/components/temp/{Console-client-254d7d4799471401334d698b1631ab1cb5b70558.ts → Console-client-2f206752ce59e59fba9bb91263b4102fd515951e.ts} +1 -1
  141. package/test/console/components/temp/Console-server-b4b15f7a0d1d2b50d87bad4870e1b8d368707c04.ts +17 -0
  142. package/test/globalSetup.ts +1 -1
  143. package/test/helpers.ts +6 -2
  144. package/test/hydrateComponent.ts +1 -1
  145. package/test/importComponent.ts +12 -40
  146. package/test/mountComponent.ts +5 -1
  147. package/test/party/components/temp/AnswerButton-client-243454cd7bf84c648f244b3587e60d01a0401039.ts +33 -0
  148. package/test/party/components/temp/AnswerButton-server-938e46c1d2510ea37454854ef527e4aa64eb8e52.ts +16 -0
  149. package/test/party/components/temp/FunnyButton-client-2e6bec8259065b5bc9ae16d1ca93dd1bd0c56b7c.ts +40 -0
  150. package/test/party/components/temp/FunnyButton-server-e8ab55e47c735f7e42c55d2b7504dfa4190a1b40.ts +32 -0
  151. package/test/party/components/temp/Time-client-7ba4ca9322af2cb88a873c812fc776760c337c64.ts +47 -0
  152. package/test/party/components/temp/Time-server-08f66c7f3f32b13de06d75fe679cf58b5727c473.ts +31 -0
  153. package/test/party/components/temp/UserProfile-client-938bcef20a2555de22aca939022a32742ac5e729.ts +51 -0
  154. package/test/party/components/temp/UserProfile-server-9df5c59b8797fa67c479bc76450104d45e6076f9.ts +22 -0
  155. package/test/party/components/temp/UserProfileContext-client-93211cdba795b8baf926f60f5b17da90701743b3.ts +44 -0
  156. package/test/party/components/temp/UserProfileContext-server-cf58767df1e2d1dde919f59de73cdd9764bbc006.ts +20 -0
  157. package/test/slots/components/temp/Article-client-741f94eab2e96655f4c9d69ccd7d9c7cc998f4ce.ts +41 -0
  158. package/test/slots/components/temp/Article-server-a6bd47a621cc213db4313eb775a52246541dd203.ts +28 -0
  159. package/test/slots/components/temp/Header-client-e2e1e7d60b48b0841cd0c20224f520330ca96458.ts +38 -0
  160. package/test/slots/components/temp/Header-server-1c195508a91c32822da22a08576c8a30c9070636.ts +22 -0
  161. package/test/slots/components/temp/List-client-0659d999cfb48b865fe5b8aaaf2a4ddac3a8a8b6.ts +76 -0
  162. package/test/slots/components/temp/List-server-4b76485a259d054187edad8aa691d80ac918ad86.ts +25 -0
  163. package/test/special-component/components/temp/BigTitle-client-881a9f84876fb3f6d994736edb253b96e71de926.ts +32 -0
  164. package/test/special-component/components/temp/BigTitle-server-9efc738f5eb131a4b859c4a99a8e255d93834e9a.ts +20 -0
  165. package/test/special-component/components/temp/SmallTitle-client-25b3097b7ae47848dd82967403faf7745fc43388.ts +32 -0
  166. package/test/special-component/components/temp/SmallTitle-server-fc105db9a91b83644d67e049ce583a3d1a61f50c.ts +20 -0
  167. package/tsconfig.json +1 -1
  168. package/tsup.config.ts +7 -2
  169. package/vitest.config.ts +2 -2
  170. package/dist/chunk-GO2L324Q.js.map +0 -1
  171. package/test/bench/components/temp/Bench-client-3efcd3b6c03c7a51368df3b8b1bdf2e7fa722432.ts +0 -126
  172. package/test/build-server/components/IfNested.d.ts +0 -18
  173. package/test/class/components/temp/Class-server-082505b03612c762384ffff329472db3f55b8097.ts +0 -17
  174. /package/test/build-server/components/{output/IfNested-server.ts → temp/IfNested-server-3c4e4b6f2162c0906cef685830219b9ea9ee985c.ts} +0 -0
@@ -0,0 +1,32 @@
1
+ import { type SlotRender } from "../../../../src/types/SlotRender";
2
+ import t_add_fragment from "../../../../src/render/addFragment";
3
+ import t_anchor from "../../../../src/render/nodeAnchor";
4
+ import t_child from "../../../../src/render/nodeChild";
5
+ import t_fragment from "../../../../src/render/getFragment";
6
+ import t_next from "../../../../src/render/nodeNext";
7
+ import t_root from "../../../../src/render/nodeRoot";
8
+
9
+ export default function BigTitle(
10
+ $parent: ParentNode,
11
+ $anchor: Node | null,
12
+ // @ts-ignore
13
+ $props?: Record<PropertyKey, any>,
14
+ // @ts-ignore
15
+ $context?: Record<PropertyKey, any>,
16
+ $slots?: Record<string, SlotRender>
17
+ ) {
18
+
19
+ /* User interface */
20
+ const t_fragments: DocumentFragment[] = [];
21
+
22
+ const t_fragment_0 = t_fragment($parent.ownerDocument!, t_fragments, 0, `<h2> <!> </h2>`);
23
+ // @ts-ignore
24
+ const t_h2_1 = t_root(t_fragment_0) as HTMLElement;
25
+ const t_slot_anchor_1 = t_anchor(t_next(t_child(t_h2_1))) as HTMLElement;
26
+ if ($slots && $slots["_"]) {
27
+ $slots["_"](t_h2_1, t_slot_anchor_1, undefined, $context)
28
+ }
29
+ t_add_fragment(t_fragment_0, $parent, $anchor);
30
+ t_next(t_h2_1);
31
+
32
+ }
@@ -0,0 +1,20 @@
1
+ import { type ServerSlotRender } from "../../../../src/types/ServerSlotRender";
2
+
3
+ export default function BigTitle(
4
+ // @ts-ignore
5
+ $props?: Record<PropertyKey, any>,
6
+ // @ts-ignore
7
+ $context?: Record<PropertyKey, any>,
8
+ $slots?: Record<string, ServerSlotRender>
9
+ ) {
10
+
11
+ /* User interface */
12
+ let $output = "";
13
+ $output += `<h2> <![>`;
14
+ if ($slots && $slots["_"]) {
15
+ $output += $slots["_"](undefined, $context);
16
+ }
17
+ $output += `<!]><!> </h2>`;
18
+
19
+ return $output;
20
+ }
@@ -0,0 +1,32 @@
1
+ import { type SlotRender } from "../../../../src/types/SlotRender";
2
+ import t_add_fragment from "../../../../src/render/addFragment";
3
+ import t_anchor from "../../../../src/render/nodeAnchor";
4
+ import t_child from "../../../../src/render/nodeChild";
5
+ import t_fragment from "../../../../src/render/getFragment";
6
+ import t_next from "../../../../src/render/nodeNext";
7
+ import t_root from "../../../../src/render/nodeRoot";
8
+
9
+ export default function SmallTitle(
10
+ $parent: ParentNode,
11
+ $anchor: Node | null,
12
+ // @ts-ignore
13
+ $props?: Record<PropertyKey, any>,
14
+ // @ts-ignore
15
+ $context?: Record<PropertyKey, any>,
16
+ $slots?: Record<string, SlotRender>
17
+ ) {
18
+
19
+ /* User interface */
20
+ const t_fragments: DocumentFragment[] = [];
21
+
22
+ const t_fragment_0 = t_fragment($parent.ownerDocument!, t_fragments, 0, `<h6> <!> </h6>`);
23
+ // @ts-ignore
24
+ const t_h6_1 = t_root(t_fragment_0) as HTMLElement;
25
+ const t_slot_anchor_1 = t_anchor(t_next(t_child(t_h6_1))) as HTMLElement;
26
+ if ($slots && $slots["_"]) {
27
+ $slots["_"](t_h6_1, t_slot_anchor_1, undefined, $context)
28
+ }
29
+ t_add_fragment(t_fragment_0, $parent, $anchor);
30
+ t_next(t_h6_1);
31
+
32
+ }
@@ -0,0 +1,20 @@
1
+ import { type ServerSlotRender } from "../../../../src/types/ServerSlotRender";
2
+
3
+ export default function SmallTitle(
4
+ // @ts-ignore
5
+ $props?: Record<PropertyKey, any>,
6
+ // @ts-ignore
7
+ $context?: Record<PropertyKey, any>,
8
+ $slots?: Record<string, ServerSlotRender>
9
+ ) {
10
+
11
+ /* User interface */
12
+ let $output = "";
13
+ $output += `<h6> <![>`;
14
+ if ($slots && $slots["_"]) {
15
+ $output += $slots["_"](undefined, $context);
16
+ }
17
+ $output += `<!]><!> </h6>`;
18
+
19
+ return $output;
20
+ }
package/tsconfig.json CHANGED
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "extends": "../../tsconfig.json",
3
- "exclude": ["dist", "node_modules", "test/*/components"]
3
+ "include": ["src/**/*"]
4
4
  }
package/tsup.config.ts CHANGED
@@ -1,4 +1,9 @@
1
- import { defineConfig } from "tsup";
1
+ import { type Options, defineConfig } from "tsup";
2
+
3
+ type Config =
4
+ | Options
5
+ | Options[]
6
+ | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
2
7
 
3
8
  export default defineConfig({
4
9
  entry: ["src/index.ts", "src/compile.ts", "src/ssr.ts"],
@@ -7,4 +12,4 @@ export default defineConfig({
7
12
  clean: true,
8
13
  metafile: true,
9
14
  sourcemap: true,
10
- });
15
+ }) satisfies Config as Config;
package/vitest.config.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { defineConfig } from "vitest/config";
1
+ import { type UserConfigFnObject, defineConfig } from "vitest/config";
2
2
  import torpor from "../unplugin/dist/vite";
3
3
 
4
4
  export default defineConfig(({ mode }) => ({
@@ -10,4 +10,4 @@ export default defineConfig(({ mode }) => ({
10
10
  environment: "jsdom",
11
11
  globalSetup: "./test/globalSetup.ts",
12
12
  },
13
- }));
13
+ })) satisfies UserConfigFnObject as UserConfigFnObject;
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/render/formatText.ts","../src/render/getClasses.ts","../src/render/getStyles.ts"],"sourcesContent":["export default function formatText(value: any): string {\n\treturn value ?? \"\";\n}\n","export default function getClasses(value: unknown): string {\n\tlet classes: string[] = [];\n\tgatherNames(\"\", value, classes);\n\treturn classes.join(\" \");\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 getStyles(value: Record<string, any>): string {\n\tlet styles: string[] = [];\n\tfor (let [n, v] of Object.entries(value)) {\n\t\tstyles.push(`${n}: ${v}`);\n\t}\n\treturn styles.join(\"; \");\n}\n"],"mappings":";AAAe,SAAR,WAA4B,OAAoB;AACtD,SAAO,SAAS;AACjB;;;ACFe,SAAR,WAA4B,OAAwB;AAC1D,MAAI,UAAoB,CAAC;AACzB,cAAY,IAAI,OAAO,OAAO;AAC9B,SAAO,QAAQ,KAAK,GAAG;AACxB;AAEA,SAAS,YAAY,MAAe,OAAgB,SAAmB;AACtE,MAAI,OAAO;AACV,QAAI,MAAM,QAAQ,KAAK,GAAG;AACzB,eAAS,KAAK,OAAO;AACpB,oBAAY,GAAG,GAAG,OAAO;AAAA,MAC1B;AAAA,IACD,WAAW,OAAO,UAAU,UAAU;AACrC,eAAS,CAAC,GAAG,CAAC,KAAK,OAAO,QAAQ,KAAK,GAAG;AACzC,oBAAY,GAAG,GAAG,OAAO;AAAA,MAC1B;AAAA,IACD,OAAO;AACN,cAAQ,KAAK,IAAc;AAAA,IAC5B;AAAA,EACD;AACD;;;ACpBe,SAAR,UAA2B,OAAoC;AACrE,MAAI,SAAmB,CAAC;AACxB,WAAS,CAAC,GAAG,CAAC,KAAK,OAAO,QAAQ,KAAK,GAAG;AACzC,WAAO,KAAK,GAAG,CAAC,KAAK,CAAC,EAAE;AAAA,EACzB;AACA,SAAO,OAAO,KAAK,IAAI;AACxB;","names":[]}
@@ -1,126 +0,0 @@
1
- import $watch from "../../../../src/render/$watch";
2
- import type SlotRender from "../../../../src/types/SlotRender";
3
-
4
- export default function Bench(
5
- $parent: ParentNode,
6
- $anchor: Node | null,
7
- $props?: Record<PropertyKey, any>,
8
- $context?: Record<PropertyKey, any>,
9
- $slots?: Record<string, SlotRender>
10
- ) {
11
-
12
- let rowId = 1;
13
- let $state = $watch({
14
- data: [],
15
- selected: null,
16
- });
17
-
18
- const adjectives = [
19
- "pretty",
20
- "large",
21
- "big",
22
- "small",
23
- "tall",
24
- "short",
25
- "long",
26
- "handsome",
27
- "plain",
28
- "quaint",
29
- "clean",
30
- "elegant",
31
- "easy",
32
- "angry",
33
- "crazy",
34
- "helpful",
35
- "mushy",
36
- "odd",
37
- "unsightly",
38
- "adorable",
39
- "important",
40
- "inexpensive",
41
- "cheap",
42
- "expensive",
43
- "fancy",
44
- ];
45
- const colours = ["red", "yellow", "blue", "green", "pink", "brown", "purple", "brown", "white", "black", "orange"];
46
- const nouns = [
47
- "table",
48
- "chair",
49
- "house",
50
- "bbq",
51
- "desk",
52
- "car",
53
- "pony",
54
- "cookie",
55
- "sandwich",
56
- "burger",
57
- "pizza",
58
- "mouse",
59
- "keyboard",
60
- ];
61
-
62
- function append() {
63
- $state.data = [...$state.data, ...buildData(1000)];
64
- }
65
-
66
- function clear() {
67
- $state.data = [];
68
- }
69
-
70
- function partialUpdate() {
71
- for (let i = 0; i < $state.data.length; i += 10) {
72
- const row = $state.data[i];
73
- row.label = row.label + " !!!";
74
- }
75
- }
76
-
77
- function remove(row) {
78
- const clone = $state.data.slice();
79
- clone.splice(clone.indexOf(row), 1);
80
- $state.data = clone;
81
- }
82
-
83
- function create() {
84
- // TODO: Build this up to 1000:
85
- $state.data = buildData(10);
86
- }
87
-
88
- function createLots() {
89
- $state.data = buildData(10000);
90
- }
91
-
92
- function swapRows() {
93
- if ($state.data.length > 998) {
94
- const clone = $state.data.slice();
95
- const tmp = clone[1];
96
- clone[1] = clone[998];
97
- clone[998] = tmp;
98
- $state.data = clone;
99
- }
100
- }
101
-
102
- function _random(
103
- $parent: ParentNode,
104
- $anchor: Node | null,
105
- $props?: Record<PropertyKey, any>,
106
- $context?: Record<PropertyKey, any>,
107
- $slots?: Record<string, SlotRender>
108
- ) {
109
-
110
- return Math.round(Math.random() * 1000) % max;
111
- }
112
-
113
- class Item {
114
- id = rowId++;
115
- label = `${adjectives[_random(adjectives.length)]} ${colours[_random(colours.length)]} ${nouns[_random(nouns.length)]}`;
116
- }
117
-
118
- function buildData(count = 1000) {
119
- const data = new Array(count);
120
- for (let i = 0; i < count; i++) {
121
- data[i] = $watch(new Item());
122
- }
123
- return data;
124
- }
125
-
126
- }
@@ -1,18 +0,0 @@
1
- import { type SlotRender } from "@torpor/view";
2
-
3
- /**
4
- * Mounts or hydrates the component into the supplied parent node.
5
- * @param $parent -- The parent node.
6
- * @param $anchor -- The node to mount the component before.
7
- * @param $props -- The values that have been passed into the component as properties.
8
- * @param $context -- Values that have been passed into the component from its ancestors.
9
- * @param $slots -- Functions for rendering children into slot nodes within the component.
10
- */
11
- declare function IfNested(
12
- $parent: ParentNode,
13
- $anchor: Node | null,
14
- $props: { counter: number },
15
- $context?: Record<PropertyKey, any>,
16
- $slots?: Record<string, SlotRender>,
17
- ): void;
18
- export default IfNested;
@@ -1,17 +0,0 @@
1
- import { type ServerSlotRender } from "../../../../src/types/ServerSlotRender";
2
- import t_class from "../../../../src/render/getClasses";
3
-
4
- export default function Class(
5
- $props: Record<PropertyKey, any>,
6
- // @ts-ignore
7
- $context?: Record<PropertyKey, any>,
8
- // @ts-ignore
9
- $slots?: Record<string, ServerSlotRender>
10
- ) {
11
-
12
- /* User interface */
13
- let $output = "";
14
- $output += `<div> <div class="${t_class({ hello: true, red: $props.red, green: $props.green, blue: $props.blue })}"> Hello! </div> <div class="${t_class({ foo: true, bar: false, baz: 5, qux: null })}"> Class object </div> <div class="${t_class([ "foo", false, true && "baz", undefined ])}"> Class array </div> <div class="${t_class([ "foo", 0, { bar: true }, "", [1 && "baz", ["qux"]] ])}"> Class nested </div> </div>`;
15
-
16
- return $output;
17
- }