@pithyjs/core 0.1.0-beta.0

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 (255) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +513 -0
  3. package/dist/a11y/focus-trap.d.ts +109 -0
  4. package/dist/a11y/focus-trap.d.ts.map +1 -0
  5. package/dist/a11y/focus-trap.js +246 -0
  6. package/dist/a11y/focus-trap.js.map +1 -0
  7. package/dist/a11y/index.d.ts +12 -0
  8. package/dist/a11y/index.d.ts.map +1 -0
  9. package/dist/a11y/index.js +16 -0
  10. package/dist/a11y/index.js.map +1 -0
  11. package/dist/a11y/keyboard-utils.d.ts +165 -0
  12. package/dist/a11y/keyboard-utils.d.ts.map +1 -0
  13. package/dist/a11y/keyboard-utils.js +321 -0
  14. package/dist/a11y/keyboard-utils.js.map +1 -0
  15. package/dist/a11y/roving-tabindex.d.ts +118 -0
  16. package/dist/a11y/roving-tabindex.d.ts.map +1 -0
  17. package/dist/a11y/roving-tabindex.js +249 -0
  18. package/dist/a11y/roving-tabindex.js.map +1 -0
  19. package/dist/a11y/skip-link.d.ts +55 -0
  20. package/dist/a11y/skip-link.d.ts.map +1 -0
  21. package/dist/a11y/skip-link.js +164 -0
  22. package/dist/a11y/skip-link.js.map +1 -0
  23. package/dist/compile/bindSwitchCases.d.ts +16 -0
  24. package/dist/compile/bindSwitchCases.d.ts.map +1 -0
  25. package/dist/compile/bindSwitchCases.js +323 -0
  26. package/dist/compile/bindSwitchCases.js.map +1 -0
  27. package/dist/compile/binds/bindBoundAttributes.d.ts +14 -0
  28. package/dist/compile/binds/bindBoundAttributes.d.ts.map +1 -0
  29. package/dist/compile/binds/bindBoundAttributes.js +57 -0
  30. package/dist/compile/binds/bindBoundAttributes.js.map +1 -0
  31. package/dist/compile/binds/bindClassDirectives.d.ts +20 -0
  32. package/dist/compile/binds/bindClassDirectives.d.ts.map +1 -0
  33. package/dist/compile/binds/bindClassDirectives.js +94 -0
  34. package/dist/compile/binds/bindClassDirectives.js.map +1 -0
  35. package/dist/compile/binds/bindComponentsTags.d.ts +17 -0
  36. package/dist/compile/binds/bindComponentsTags.d.ts.map +1 -0
  37. package/dist/compile/binds/bindComponentsTags.js +355 -0
  38. package/dist/compile/binds/bindComponentsTags.js.map +1 -0
  39. package/dist/compile/binds/bindConditionals.d.ts +16 -0
  40. package/dist/compile/binds/bindConditionals.d.ts.map +1 -0
  41. package/dist/compile/binds/bindConditionals.js +102 -0
  42. package/dist/compile/binds/bindConditionals.js.map +1 -0
  43. package/dist/compile/binds/bindDefaultTwoWay.d.ts +35 -0
  44. package/dist/compile/binds/bindDefaultTwoWay.d.ts.map +1 -0
  45. package/dist/compile/binds/bindDefaultTwoWay.js +128 -0
  46. package/dist/compile/binds/bindDefaultTwoWay.js.map +1 -0
  47. package/dist/compile/binds/bindDeferDirectives.d.ts +21 -0
  48. package/dist/compile/binds/bindDeferDirectives.d.ts.map +1 -0
  49. package/dist/compile/binds/bindDeferDirectives.js +465 -0
  50. package/dist/compile/binds/bindDeferDirectives.js.map +1 -0
  51. package/dist/compile/binds/bindErrorBoundary.d.ts +71 -0
  52. package/dist/compile/binds/bindErrorBoundary.d.ts.map +1 -0
  53. package/dist/compile/binds/bindErrorBoundary.js +389 -0
  54. package/dist/compile/binds/bindErrorBoundary.js.map +1 -0
  55. package/dist/compile/binds/bindEventHandlers.d.ts +17 -0
  56. package/dist/compile/binds/bindEventHandlers.d.ts.map +1 -0
  57. package/dist/compile/binds/bindEventHandlers.js +174 -0
  58. package/dist/compile/binds/bindEventHandlers.js.map +1 -0
  59. package/dist/compile/binds/bindRefDirectives.d.ts +14 -0
  60. package/dist/compile/binds/bindRefDirectives.d.ts.map +1 -0
  61. package/dist/compile/binds/bindRefDirectives.js +35 -0
  62. package/dist/compile/binds/bindRefDirectives.js.map +1 -0
  63. package/dist/compile/binds/bindTextInterpolations.d.ts +16 -0
  64. package/dist/compile/binds/bindTextInterpolations.d.ts.map +1 -0
  65. package/dist/compile/binds/bindTextInterpolations.js +408 -0
  66. package/dist/compile/binds/bindTextInterpolations.js.map +1 -0
  67. package/dist/compile/binds/directiveRegistry.d.ts +46 -0
  68. package/dist/compile/binds/directiveRegistry.d.ts.map +1 -0
  69. package/dist/compile/binds/directiveRegistry.js +50 -0
  70. package/dist/compile/binds/directiveRegistry.js.map +1 -0
  71. package/dist/compile/compileExpression.d.ts +10 -0
  72. package/dist/compile/compileExpression.d.ts.map +1 -0
  73. package/dist/compile/compileExpression.js +26 -0
  74. package/dist/compile/compileExpression.js.map +1 -0
  75. package/dist/compile/compileNodes.d.ts +32 -0
  76. package/dist/compile/compileNodes.d.ts.map +1 -0
  77. package/dist/compile/compileNodes.js +104 -0
  78. package/dist/compile/compileNodes.js.map +1 -0
  79. package/dist/compile/compileTemplate.d.ts +64 -0
  80. package/dist/compile/compileTemplate.d.ts.map +1 -0
  81. package/dist/compile/compileTemplate.js +157 -0
  82. package/dist/compile/compileTemplate.js.map +1 -0
  83. package/dist/compile/contentProjection.d.ts +29 -0
  84. package/dist/compile/contentProjection.d.ts.map +1 -0
  85. package/dist/compile/contentProjection.js +210 -0
  86. package/dist/compile/contentProjection.js.map +1 -0
  87. package/dist/compile/forLoops/bindForLoops.d.ts +21 -0
  88. package/dist/compile/forLoops/bindForLoops.d.ts.map +1 -0
  89. package/dist/compile/forLoops/bindForLoops.js +151 -0
  90. package/dist/compile/forLoops/bindForLoops.js.map +1 -0
  91. package/dist/compile/forLoops/createLoopManager.d.ts +51 -0
  92. package/dist/compile/forLoops/createLoopManager.d.ts.map +1 -0
  93. package/dist/compile/forLoops/createLoopManager.js +429 -0
  94. package/dist/compile/forLoops/createLoopManager.js.map +1 -0
  95. package/dist/compile/forLoops/index.d.ts +6 -0
  96. package/dist/compile/forLoops/index.d.ts.map +1 -0
  97. package/dist/compile/forLoops/index.js +8 -0
  98. package/dist/compile/forLoops/index.js.map +1 -0
  99. package/dist/compile/forLoops/loopHelpers.d.ts +33 -0
  100. package/dist/compile/forLoops/loopHelpers.d.ts.map +1 -0
  101. package/dist/compile/forLoops/loopHelpers.js +69 -0
  102. package/dist/compile/forLoops/loopHelpers.js.map +1 -0
  103. package/dist/compile/forLoops/loopSignals.d.ts +36 -0
  104. package/dist/compile/forLoops/loopSignals.d.ts.map +1 -0
  105. package/dist/compile/forLoops/loopSignals.js +64 -0
  106. package/dist/compile/forLoops/loopSignals.js.map +1 -0
  107. package/dist/compile/forLoops/loopTraversal.d.ts +18 -0
  108. package/dist/compile/forLoops/loopTraversal.d.ts.map +1 -0
  109. package/dist/compile/forLoops/loopTraversal.js +38 -0
  110. package/dist/compile/forLoops/loopTraversal.js.map +1 -0
  111. package/dist/compile/handleConditionalChain.d.ts +15 -0
  112. package/dist/compile/handleConditionalChain.d.ts.map +1 -0
  113. package/dist/compile/handleConditionalChain.js +181 -0
  114. package/dist/compile/handleConditionalChain.js.map +1 -0
  115. package/dist/compile/index.d.ts +15 -0
  116. package/dist/compile/index.d.ts.map +1 -0
  117. package/dist/compile/index.js +19 -0
  118. package/dist/compile/index.js.map +1 -0
  119. package/dist/compile/injectScopedStyle.d.ts +16 -0
  120. package/dist/compile/injectScopedStyle.d.ts.map +1 -0
  121. package/dist/compile/injectScopedStyle.js +50 -0
  122. package/dist/compile/injectScopedStyle.js.map +1 -0
  123. package/dist/compile/nodeExpando.d.ts +12 -0
  124. package/dist/compile/nodeExpando.d.ts.map +1 -0
  125. package/dist/compile/nodeExpando.js +4 -0
  126. package/dist/compile/nodeExpando.js.map +1 -0
  127. package/dist/compile/parseHtml.d.ts +70 -0
  128. package/dist/compile/parseHtml.d.ts.map +1 -0
  129. package/dist/compile/parseHtml.js +164 -0
  130. package/dist/compile/parseHtml.js.map +1 -0
  131. package/dist/compile/pithyTreeToDom.d.ts +16 -0
  132. package/dist/compile/pithyTreeToDom.d.ts.map +1 -0
  133. package/dist/compile/pithyTreeToDom.js +118 -0
  134. package/dist/compile/pithyTreeToDom.js.map +1 -0
  135. package/dist/compile/renderChildren.d.ts +50 -0
  136. package/dist/compile/renderChildren.d.ts.map +1 -0
  137. package/dist/compile/renderChildren.js +76 -0
  138. package/dist/compile/renderChildren.js.map +1 -0
  139. package/dist/compile/ssrMode.d.ts +17 -0
  140. package/dist/compile/ssrMode.d.ts.map +1 -0
  141. package/dist/compile/ssrMode.js +20 -0
  142. package/dist/compile/ssrMode.js.map +1 -0
  143. package/dist/compile/textValue.d.ts +28 -0
  144. package/dist/compile/textValue.d.ts.map +1 -0
  145. package/dist/compile/textValue.js +30 -0
  146. package/dist/compile/textValue.js.map +1 -0
  147. package/dist/config/index.d.ts +37 -0
  148. package/dist/config/index.d.ts.map +1 -0
  149. package/dist/config/index.js +16 -0
  150. package/dist/config/index.js.map +1 -0
  151. package/dist/index.d.ts +7 -0
  152. package/dist/index.d.ts.map +1 -0
  153. package/dist/index.js +7 -0
  154. package/dist/index.js.map +1 -0
  155. package/dist/interfaces/index.d.ts +3 -0
  156. package/dist/interfaces/index.d.ts.map +1 -0
  157. package/dist/interfaces/index.js +3 -0
  158. package/dist/interfaces/index.js.map +1 -0
  159. package/dist/interfaces/ref-signal.interface.d.ts +6 -0
  160. package/dist/interfaces/ref-signal.interface.d.ts.map +1 -0
  161. package/dist/interfaces/ref-signal.interface.js +2 -0
  162. package/dist/interfaces/ref-signal.interface.js.map +1 -0
  163. package/dist/interfaces/ref.interface.d.ts +5 -0
  164. package/dist/interfaces/ref.interface.d.ts.map +1 -0
  165. package/dist/interfaces/ref.interface.js +2 -0
  166. package/dist/interfaces/ref.interface.js.map +1 -0
  167. package/dist/runtime/applyBindings.d.ts +36 -0
  168. package/dist/runtime/applyBindings.d.ts.map +1 -0
  169. package/dist/runtime/applyBindings.js +165 -0
  170. package/dist/runtime/applyBindings.js.map +1 -0
  171. package/dist/runtime/bindings/applyComponent.d.ts +3 -0
  172. package/dist/runtime/bindings/applyComponent.d.ts.map +1 -0
  173. package/dist/runtime/bindings/applyComponent.js +190 -0
  174. package/dist/runtime/bindings/applyComponent.js.map +1 -0
  175. package/dist/runtime/bindings/applyDefer.d.ts +11 -0
  176. package/dist/runtime/bindings/applyDefer.d.ts.map +1 -0
  177. package/dist/runtime/bindings/applyDefer.js +422 -0
  178. package/dist/runtime/bindings/applyDefer.js.map +1 -0
  179. package/dist/runtime/bindings/applySimple.d.ts +11 -0
  180. package/dist/runtime/bindings/applySimple.d.ts.map +1 -0
  181. package/dist/runtime/bindings/applySimple.js +346 -0
  182. package/dist/runtime/bindings/applySimple.js.map +1 -0
  183. package/dist/runtime/bindings/applyStructural.d.ts +5 -0
  184. package/dist/runtime/bindings/applyStructural.d.ts.map +1 -0
  185. package/dist/runtime/bindings/applyStructural.js +312 -0
  186. package/dist/runtime/bindings/applyStructural.js.map +1 -0
  187. package/dist/runtime/bindings/helpers.d.ts +56 -0
  188. package/dist/runtime/bindings/helpers.d.ts.map +1 -0
  189. package/dist/runtime/bindings/helpers.js +121 -0
  190. package/dist/runtime/bindings/helpers.js.map +1 -0
  191. package/dist/runtime/bindings/index.d.ts +7 -0
  192. package/dist/runtime/bindings/index.d.ts.map +1 -0
  193. package/dist/runtime/bindings/index.js +6 -0
  194. package/dist/runtime/bindings/index.js.map +1 -0
  195. package/dist/runtime/bindings/types.d.ts +105 -0
  196. package/dist/runtime/bindings/types.d.ts.map +1 -0
  197. package/dist/runtime/bindings/types.js +5 -0
  198. package/dist/runtime/bindings/types.js.map +1 -0
  199. package/dist/runtime/bootstrap.d.ts +59 -0
  200. package/dist/runtime/bootstrap.d.ts.map +1 -0
  201. package/dist/runtime/bootstrap.js +82 -0
  202. package/dist/runtime/bootstrap.js.map +1 -0
  203. package/dist/runtime/createContextProxy.d.ts +10 -0
  204. package/dist/runtime/createContextProxy.d.ts.map +1 -0
  205. package/dist/runtime/createContextProxy.js +45 -0
  206. package/dist/runtime/createContextProxy.js.map +1 -0
  207. package/dist/runtime/deferHelpers.d.ts +49 -0
  208. package/dist/runtime/deferHelpers.d.ts.map +1 -0
  209. package/dist/runtime/deferHelpers.js +65 -0
  210. package/dist/runtime/deferHelpers.js.map +1 -0
  211. package/dist/runtime/html.d.ts +23 -0
  212. package/dist/runtime/html.d.ts.map +1 -0
  213. package/dist/runtime/html.js +97 -0
  214. package/dist/runtime/html.js.map +1 -0
  215. package/dist/runtime/index.d.ts +8 -0
  216. package/dist/runtime/index.d.ts.map +1 -0
  217. package/dist/runtime/index.js +21 -0
  218. package/dist/runtime/index.js.map +1 -0
  219. package/dist/runtime/lazy.d.ts +144 -0
  220. package/dist/runtime/lazy.d.ts.map +1 -0
  221. package/dist/runtime/lazy.js +295 -0
  222. package/dist/runtime/lazy.js.map +1 -0
  223. package/dist/runtime/module-cache.d.ts +78 -0
  224. package/dist/runtime/module-cache.d.ts.map +1 -0
  225. package/dist/runtime/module-cache.js +109 -0
  226. package/dist/runtime/module-cache.js.map +1 -0
  227. package/dist/runtime/onDestroy.d.ts +29 -0
  228. package/dist/runtime/onDestroy.d.ts.map +1 -0
  229. package/dist/runtime/onDestroy.js +66 -0
  230. package/dist/runtime/onDestroy.js.map +1 -0
  231. package/dist/runtime/parseIdentifiersFromTemplate.d.ts +17 -0
  232. package/dist/runtime/parseIdentifiersFromTemplate.d.ts.map +1 -0
  233. package/dist/runtime/parseIdentifiersFromTemplate.js +68 -0
  234. package/dist/runtime/parseIdentifiersFromTemplate.js.map +1 -0
  235. package/dist/types/globals.d.ts +18 -0
  236. package/dist/types/globals.d.ts.map +1 -0
  237. package/dist/types/globals.js +4 -0
  238. package/dist/types/globals.js.map +1 -0
  239. package/dist/types/index.d.ts +11 -0
  240. package/dist/types/index.d.ts.map +1 -0
  241. package/dist/types/index.js +2 -0
  242. package/dist/types/index.js.map +1 -0
  243. package/dist/utilities/index.d.ts +3 -0
  244. package/dist/utilities/index.d.ts.map +1 -0
  245. package/dist/utilities/index.js +3 -0
  246. package/dist/utilities/index.js.map +1 -0
  247. package/dist/utilities/ref-signal.utility.d.ts +32 -0
  248. package/dist/utilities/ref-signal.utility.d.ts.map +1 -0
  249. package/dist/utilities/ref-signal.utility.js +46 -0
  250. package/dist/utilities/ref-signal.utility.js.map +1 -0
  251. package/dist/utilities/ref.untility.d.ts +37 -0
  252. package/dist/utilities/ref.untility.d.ts.map +1 -0
  253. package/dist/utilities/ref.untility.js +47 -0
  254. package/dist/utilities/ref.untility.js.map +1 -0
  255. package/package.json +55 -0
@@ -0,0 +1,68 @@
1
+ /** @codex
2
+ {
3
+ "id": "pithy.compiler.identifier-parser",
4
+ "title": "Template Identifier Parser",
5
+ "category": "compiler"
6
+ }
7
+ */
8
+ import { isJITLoaded, getParseFragmentFn } from '../compile/parseHtml';
9
+ import { escapeComponentTags } from '@pithyjs/compiler';
10
+ /**
11
+ * Extract variable identifiers from an HTML template string.
12
+ * DEV-only helper used by `html()` fallback when the Babel plugin hasn't
13
+ * injected identifiers. Returns an empty set if parse5 is not loaded
14
+ * (intentional — throwing would crash AOT apps in dev mode).
15
+ * @internal
16
+ */
17
+ /** @codexApi {"parent":"pithy.compiler.identifier-parser","name":"parseIdentifiersFromTemplate","stability":"internal","signature":"(template: string) => Set<string>"} */
18
+ export function parseIdentifiersFromTemplate(template) {
19
+ const identifiers = new Set();
20
+ // DEV-only fallback: if parse5 isn't loaded (AOT mode), return empty set
21
+ // gracefully. The Babel plugin handles identifier extraction at build time.
22
+ // Throwing here would crash AOT apps running in dev mode.
23
+ const parseFn = isJITLoaded() ? getParseFragmentFn() : null;
24
+ if (!parseFn) {
25
+ return identifiers;
26
+ }
27
+ // Escape PascalCase component tags so parse5 doesn't enter special
28
+ // insertion modes (e.g., "in select") that drop children from the tree.
29
+ const escaped = escapeComponentTags(template);
30
+ const fragment = parseFn(escaped, {
31
+ sourceCodeLocationInfo: false,
32
+ });
33
+ const walk = (node) => {
34
+ if (node.nodeName === '#text' && node.value) {
35
+ const text = node.value;
36
+ const matches = text.match(/{{\s*(.*?)\s*}}/g);
37
+ if (matches) {
38
+ matches.forEach((m) => {
39
+ const inner = m.replace(/{{|}}/g, '').trim();
40
+ const vars = inner.match(/\b[a-zA-Z_][a-zA-Z0-9_]*\b/g);
41
+ if (vars)
42
+ vars.forEach((v) => identifiers.add(v));
43
+ });
44
+ }
45
+ }
46
+ if (node.attrs) {
47
+ for (const attr of node.attrs) {
48
+ const expr = attr.value;
49
+ // Skip literal strings like 'Hello world'
50
+ if (!/^['"].*['"]$/.test(expr)) {
51
+ const vars = expr.match(/\b[a-zA-Z_][a-zA-Z0-9_]*\b/g);
52
+ if (vars)
53
+ vars.forEach((v) => identifiers.add(v));
54
+ }
55
+ }
56
+ }
57
+ if (node.childNodes) {
58
+ for (const child of node.childNodes) {
59
+ walk(child);
60
+ }
61
+ }
62
+ };
63
+ for (const child of fragment.childNodes ?? []) {
64
+ walk(child);
65
+ }
66
+ return identifiers;
67
+ }
68
+ //# sourceMappingURL=parseIdentifiersFromTemplate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseIdentifiersFromTemplate.js","sourceRoot":"","sources":["../../src/runtime/parseIdentifiersFromTemplate.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD;;;;;;GAMG;AACH,2KAA2K;AAC3K,MAAM,UAAU,4BAA4B,CAAC,QAAgB;IAC3D,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;IAEtC,yEAAyE;IACzE,4EAA4E;IAC5E,0DAA0D;IAC1D,MAAM,OAAO,GAAG,WAAW,EAAE,CAAC,CAAC,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAC5D,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,mEAAmE;IACnE,wEAAwE;IACxE,MAAM,OAAO,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAE9C,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,EAAE;QAChC,sBAAsB,EAAE,KAAK;KAC9B,CAAC,CAAC;IASH,MAAM,IAAI,GAAG,CAAC,IAAgB,EAAE,EAAE;QAChC,IAAI,IAAI,CAAC,QAAQ,KAAK,OAAO,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC5C,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC;YACxB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;YAC/C,IAAI,OAAO,EAAE,CAAC;gBACZ,OAAO,CAAC,OAAO,CAAC,CAAC,CAAS,EAAE,EAAE;oBAC5B,MAAM,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;oBAC7C,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;oBACxD,IAAI,IAAI;wBAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC5D,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;gBAC9B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC;gBAExB,0CAA0C;gBAC1C,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;oBAC/B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;oBACvD,IAAI,IAAI;wBAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC5D,CAAC;YACH,CAAC;QACH,CAAC;QAED,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;gBACpC,IAAI,CAAC,KAAK,CAAC,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IAEF,KAAK,MAAM,KAAK,IAAK,QAAuB,CAAC,UAAU,IAAI,EAAE,EAAE,CAAC;QAC9D,IAAI,CAAC,KAAK,CAAC,CAAC;IACd,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { SlotMap } from '../compile/contentProjection';
2
+ import type { PithyNode } from '@pithyjs/compiler';
3
+ export interface PithyComponentContext extends Record<string, unknown> {
4
+ __parentComponentContext?: PithyComponentContext;
5
+ __slotMap?: SlotMap;
6
+ __childAstNodes?: PithyNode[];
7
+ }
8
+ export interface PithyGlobals {
9
+ PITHY_DEBUG_PROJECTION?: boolean;
10
+ __PITHY_SSR__?: boolean;
11
+ __getComponentContext?: () => Record<string, unknown> | undefined;
12
+ __pithyComponentContext?: PithyComponentContext;
13
+ __pithyRenderingComponent?: boolean;
14
+ __pithyGetDestroyCallbacks?: () => (() => void)[] | undefined;
15
+ __pithySetDestroyCallbacks?: (cbs: (() => void)[]) => void;
16
+ }
17
+ export declare function pithyGlobals(): typeof globalThis & PithyGlobals;
18
+ //# sourceMappingURL=globals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globals.d.ts","sourceRoot":"","sources":["../../src/types/globals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,MAAM,WAAW,qBAAsB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACpE,wBAAwB,CAAC,EAAE,qBAAqB,CAAC;IACjD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,eAAe,CAAC,EAAE,SAAS,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,YAAY;IAC3B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,qBAAqB,CAAC,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAClE,uBAAuB,CAAC,EAAE,qBAAqB,CAAC;IAChD,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,0BAA0B,CAAC,EAAE,MAAM,CAAC,MAAM,IAAI,CAAC,EAAE,GAAG,SAAS,CAAC;IAC9D,0BAA0B,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC;CAC5D;AAED,wBAAgB,YAAY,IAAI,OAAO,UAAU,GAAG,YAAY,CAE/D"}
@@ -0,0 +1,4 @@
1
+ export function pithyGlobals() {
2
+ return globalThis;
3
+ }
4
+ //# sourceMappingURL=globals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globals.js","sourceRoot":"","sources":["../../src/types/globals.ts"],"names":[],"mappings":"AAmBA,MAAM,UAAU,YAAY;IAC1B,OAAO,UAA8C,CAAC;AACxD,CAAC"}
@@ -0,0 +1,11 @@
1
+ export type Component = () => {
2
+ el: HTMLElement | DocumentFragment;
3
+ destroy?: () => void;
4
+ };
5
+ declare global {
6
+ interface Window {
7
+ __pithyCapture?: Record<string, unknown>;
8
+ }
9
+ }
10
+ export {};
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,MAAM;IAC5B,EAAE,EAAE,WAAW,GAAG,gBAAgB,CAAC;IACnC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAEF,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAC1C;CACF;AAED,OAAO,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export * from './ref.untility';
2
+ export * from './ref-signal.utility';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './ref.untility';
2
+ export * from './ref-signal.utility';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,32 @@
1
+ import type { RefSignal } from '../interfaces/ref-signal.interface';
2
+ /**
3
+ * Creates a reactive reference signal for HTML elements.
4
+ *
5
+ * This function returns a RefSignal object that can be used to hold and manage
6
+ * references to DOM elements. It provides both function-style and object-style
7
+ * access to the referenced element.
8
+ *
9
+ * @template T - The type of HTML element being referenced, defaults to HTMLElement
10
+ *
11
+ * @returns {RefSignal<T>} A RefSignal object with the following capabilities:
12
+ * - Can be called as a function to get the current element
13
+ * - Has a `set` method to update the referenced element
14
+ * - Has a `current` property to access the referenced element (React-style)
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * const divRef = refSignal<HTMLDivElement>();
19
+ *
20
+ * // Function-style usage
21
+ * const element = divRef();
22
+ *
23
+ * // Setter usage
24
+ * divRef.set(someElement);
25
+ *
26
+ * // Property-style usage (React-like)
27
+ * const currentElement = divRef.current;
28
+ * ```
29
+ */
30
+ /** @codexApi {"parent":"pithy.feature.refs","name":"refSignal","stability":"stable","signature":"<T extends HTMLElement = HTMLElement>() => RefSignal<T>"} */
31
+ export declare function refSignal<T extends HTMLElement = HTMLElement>(): RefSignal<T>;
32
+ //# sourceMappingURL=ref-signal.utility.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ref-signal.utility.d.ts","sourceRoot":"","sources":["../../src/utilities/ref-signal.utility.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,8JAA8J;AAC9J,wBAAgB,SAAS,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,CAkB7E"}
@@ -0,0 +1,46 @@
1
+ import { signal } from '@pithyjs/signals';
2
+ /**
3
+ * Creates a reactive reference signal for HTML elements.
4
+ *
5
+ * This function returns a RefSignal object that can be used to hold and manage
6
+ * references to DOM elements. It provides both function-style and object-style
7
+ * access to the referenced element.
8
+ *
9
+ * @template T - The type of HTML element being referenced, defaults to HTMLElement
10
+ *
11
+ * @returns {RefSignal<T>} A RefSignal object with the following capabilities:
12
+ * - Can be called as a function to get the current element
13
+ * - Has a `set` method to update the referenced element
14
+ * - Has a `current` property to access the referenced element (React-style)
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * const divRef = refSignal<HTMLDivElement>();
19
+ *
20
+ * // Function-style usage
21
+ * const element = divRef();
22
+ *
23
+ * // Setter usage
24
+ * divRef.set(someElement);
25
+ *
26
+ * // Property-style usage (React-like)
27
+ * const currentElement = divRef.current;
28
+ * ```
29
+ */
30
+ /** @codexApi {"parent":"pithy.feature.refs","name":"refSignal","stability":"stable","signature":"<T extends HTMLElement = HTMLElement>() => RefSignal<T>"} */
31
+ export function refSignal() {
32
+ const r = signal(null);
33
+ const ref = function () {
34
+ return r();
35
+ };
36
+ ref.set = (el) => {
37
+ r.set(el);
38
+ };
39
+ Object.defineProperty(ref, 'current', {
40
+ get() {
41
+ return r();
42
+ },
43
+ });
44
+ return ref;
45
+ }
46
+ //# sourceMappingURL=ref-signal.utility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ref-signal.utility.js","sourceRoot":"","sources":["../../src/utilities/ref-signal.utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAU,MAAM,kBAAkB,CAAC;AAGlD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,8JAA8J;AAC9J,MAAM,UAAU,SAAS;IACvB,MAAM,CAAC,GAAqB,MAAM,CAAW,IAAI,CAAC,CAAC;IAEnD,MAAM,GAAG,GAAG;QACV,OAAO,CAAC,EAAE,CAAC;IACb,CAAiB,CAAC;IAElB,GAAG,CAAC,GAAG,GAAG,CAAC,EAAY,EAAQ,EAAE;QAC/B,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACZ,CAAC,CAAC;IAEF,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,SAAS,EAAE;QACpC,GAAG;YACD,OAAO,CAAC,EAAE,CAAC;QACb,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,37 @@
1
+ /** @codex
2
+ {
3
+ "id": "pithy.feature.refs",
4
+ "title": "Element Reference System",
5
+ "category": "feature"
6
+ }
7
+ */
8
+ import type { Ref } from '../interfaces/ref.interface';
9
+ /**
10
+ * Creates a non-reactive reference object for HTML elements.
11
+ *
12
+ * This function returns a Ref object that can be used to hold and manage
13
+ * references to DOM elements. It provides a React-like interface with
14
+ * a `current` property and a `set` method.
15
+ *
16
+ * @template T - The type of HTML element being referenced, defaults to HTMLElement
17
+ *
18
+ * @returns {Ref<T>} A Ref object with the following:
19
+ * - `current` - A getter property that returns the current element reference
20
+ * - `set` - A method to update the referenced element
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * const divRef = ref<HTMLDivElement>();
25
+ *
26
+ * // Update the reference
27
+ * divRef.set(someElement);
28
+ *
29
+ * // Access the current element
30
+ * const element = divRef.current;
31
+ * ```
32
+ *
33
+ * @see {@link RefSignal} for a reactive version of this reference
34
+ */
35
+ /** @codexApi {"parent":"pithy.feature.refs","name":"ref","stability":"stable","signature":"<T extends HTMLElement = HTMLElement>() => Ref<T>"} */
36
+ export declare function ref<T extends HTMLElement = HTMLElement>(): Ref<T>;
37
+ //# sourceMappingURL=ref.untility.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ref.untility.d.ts","sourceRoot":"","sources":["../../src/utilities/ref.untility.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,6BAA6B,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,kJAAkJ;AAClJ,wBAAgB,GAAG,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,KAAK,GAAG,CAAC,CAAC,CAAC,CAWjE"}
@@ -0,0 +1,47 @@
1
+ /** @codex
2
+ {
3
+ "id": "pithy.feature.refs",
4
+ "title": "Element Reference System",
5
+ "category": "feature"
6
+ }
7
+ */
8
+ /**
9
+ * Creates a non-reactive reference object for HTML elements.
10
+ *
11
+ * This function returns a Ref object that can be used to hold and manage
12
+ * references to DOM elements. It provides a React-like interface with
13
+ * a `current` property and a `set` method.
14
+ *
15
+ * @template T - The type of HTML element being referenced, defaults to HTMLElement
16
+ *
17
+ * @returns {Ref<T>} A Ref object with the following:
18
+ * - `current` - A getter property that returns the current element reference
19
+ * - `set` - A method to update the referenced element
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * const divRef = ref<HTMLDivElement>();
24
+ *
25
+ * // Update the reference
26
+ * divRef.set(someElement);
27
+ *
28
+ * // Access the current element
29
+ * const element = divRef.current;
30
+ * ```
31
+ *
32
+ * @see {@link RefSignal} for a reactive version of this reference
33
+ */
34
+ /** @codexApi {"parent":"pithy.feature.refs","name":"ref","stability":"stable","signature":"<T extends HTMLElement = HTMLElement>() => Ref<T>"} */
35
+ export function ref() {
36
+ let value = null;
37
+ const set = (el) => {
38
+ value = el;
39
+ };
40
+ return {
41
+ get current() {
42
+ return value;
43
+ },
44
+ set,
45
+ };
46
+ }
47
+ //# sourceMappingURL=ref.untility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ref.untility.js","sourceRoot":"","sources":["../../src/utilities/ref.untility.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAIF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,kJAAkJ;AAClJ,MAAM,UAAU,GAAG;IACjB,IAAI,KAAK,GAAa,IAAI,CAAC;IAC3B,MAAM,GAAG,GAAG,CAAC,EAAY,EAAE,EAAE;QAC3B,KAAK,GAAG,EAAE,CAAC;IACb,CAAC,CAAC;IACF,OAAO;QACL,IAAI,OAAO;YACT,OAAO,KAAK,CAAC;QACf,CAAC;QACD,GAAG;KACa,CAAC;AACrB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@pithyjs/core",
3
+ "version": "0.1.0-beta.0",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "type": "module",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/index.js",
10
+ "types": "./dist/index.d.ts"
11
+ },
12
+ "./runtime/applyBindings": {
13
+ "import": "./dist/runtime/applyBindings.js",
14
+ "types": "./dist/runtime/applyBindings.d.ts"
15
+ },
16
+ "./compile/parseHtml": {
17
+ "import": "./dist/compile/parseHtml.js",
18
+ "types": "./dist/compile/parseHtml.d.ts"
19
+ }
20
+ },
21
+ "dependencies": {
22
+ "@pithyjs/shared": "0.1.0-beta.0",
23
+ "@pithyjs/signals": "0.1.0-beta.0",
24
+ "@pithyjs/compiler": "0.1.0-beta.0",
25
+ "@pithyjs/design-system": "0.1.0-beta.0"
26
+ },
27
+ "peerDependencies": {
28
+ "parse5": ">=7.0.0"
29
+ },
30
+ "peerDependenciesMeta": {
31
+ "parse5": {
32
+ "optional": true
33
+ }
34
+ },
35
+ "devDependencies": {
36
+ "@vitest/ui": "^3.2.4",
37
+ "happy-dom": "^20.0.3",
38
+ "parse5": "^7.3.0",
39
+ "typescript": "^5.0.0",
40
+ "@vitest/coverage-v8": "^3.2.4",
41
+ "vitest": "^3.2.4"
42
+ },
43
+ "license": "MIT",
44
+ "publishConfig": {
45
+ "access": "public",
46
+ "tag": "beta"
47
+ },
48
+ "files": [
49
+ "dist"
50
+ ],
51
+ "scripts": {
52
+ "build": "tsc -p tsconfig.json",
53
+ "test": "vitest"
54
+ }
55
+ }