ripple 0.3.13 → 0.3.14

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 (66) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/package.json +5 -30
  3. package/src/runtime/array.js +38 -38
  4. package/src/runtime/create-subscriber.js +2 -2
  5. package/src/runtime/internal/client/bindings.js +4 -6
  6. package/src/runtime/internal/client/events.js +8 -3
  7. package/src/runtime/internal/client/hmr.js +5 -17
  8. package/src/runtime/internal/client/runtime.js +1 -0
  9. package/src/runtime/internal/server/blocks.js +7 -9
  10. package/src/runtime/internal/server/index.js +14 -22
  11. package/src/runtime/media-query.js +34 -33
  12. package/src/runtime/object.js +7 -10
  13. package/src/runtime/proxy.js +2 -3
  14. package/src/runtime/reactive-value.js +23 -21
  15. package/src/utils/ast.js +1 -1
  16. package/src/utils/attributes.js +43 -0
  17. package/src/utils/builders.js +2 -2
  18. package/tests/client/basic/basic.errors.test.rsrx +1 -1
  19. package/tests/client/basic/basic.styling.test.rsrx +1 -1
  20. package/tests/client/compiler/compiler.assignments.test.rsrx +1 -1
  21. package/tests/client/compiler/compiler.attributes.test.rsrx +1 -1
  22. package/tests/client/compiler/compiler.basic.test.rsrx +13 -13
  23. package/tests/client/compiler/compiler.tracked-access.test.rsrx +1 -1
  24. package/tests/client/compiler/compiler.try-in-function.test.rsrx +1 -1
  25. package/tests/client/compiler/compiler.typescript.test.rsrx +1 -1
  26. package/tests/client/css/global-additional-cases.test.rsrx +1 -1
  27. package/tests/client/css/global-advanced-selectors.test.rsrx +1 -1
  28. package/tests/client/css/global-at-rules.test.rsrx +1 -1
  29. package/tests/client/css/global-basic.test.rsrx +1 -1
  30. package/tests/client/css/global-classes-ids.test.rsrx +1 -1
  31. package/tests/client/css/global-combinators.test.rsrx +1 -1
  32. package/tests/client/css/global-complex-nesting.test.rsrx +1 -1
  33. package/tests/client/css/global-edge-cases.test.rsrx +1 -1
  34. package/tests/client/css/global-keyframes.test.rsrx +1 -1
  35. package/tests/client/css/global-nested.test.rsrx +1 -1
  36. package/tests/client/css/global-pseudo.test.rsrx +1 -1
  37. package/tests/client/css/global-scoping.test.rsrx +1 -1
  38. package/tests/client/css/style-identifier.test.rsrx +1 -1
  39. package/tests/client/return.test.rsrx +1 -1
  40. package/tests/hydration/build-components.js +1 -1
  41. package/tests/server/style-identifier.test.rsrx +1 -1
  42. package/tests/setup-server.js +1 -1
  43. package/tests/utils/compiler-compat-config.test.js +1 -1
  44. package/src/compiler/comment-utils.js +0 -91
  45. package/src/compiler/errors.js +0 -77
  46. package/src/compiler/identifier-utils.js +0 -80
  47. package/src/compiler/index.d.ts +0 -127
  48. package/src/compiler/index.js +0 -89
  49. package/src/compiler/phases/1-parse/index.js +0 -3007
  50. package/src/compiler/phases/1-parse/style.js +0 -704
  51. package/src/compiler/phases/2-analyze/css-analyze.js +0 -160
  52. package/src/compiler/phases/2-analyze/index.js +0 -2208
  53. package/src/compiler/phases/2-analyze/prune.js +0 -1131
  54. package/src/compiler/phases/2-analyze/validation.js +0 -168
  55. package/src/compiler/phases/3-transform/client/index.js +0 -5264
  56. package/src/compiler/phases/3-transform/segments.js +0 -2125
  57. package/src/compiler/phases/3-transform/server/index.js +0 -1749
  58. package/src/compiler/phases/3-transform/stylesheet.js +0 -545
  59. package/src/compiler/scope.js +0 -476
  60. package/src/compiler/source-map-utils.js +0 -358
  61. package/src/compiler/types/acorn.d.ts +0 -11
  62. package/src/compiler/types/estree-jsx.d.ts +0 -11
  63. package/src/compiler/types/estree.d.ts +0 -11
  64. package/src/compiler/types/index.d.ts +0 -1411
  65. package/src/compiler/types/parse.d.ts +0 -1723
  66. package/src/compiler/utils.js +0 -1258
@@ -1,168 +0,0 @@
1
- /**
2
- @import * as AST from 'estree';
3
- @import {AnalysisContext} from '#compiler';
4
- @import { RippleCompileError } from 'ripple/compiler';
5
- */
6
-
7
- import { error } from '../../errors.js';
8
-
9
- const invalid_nestings = {
10
- // <p> cannot contain block-level elements
11
- p: new Set([
12
- 'address',
13
- 'article',
14
- 'aside',
15
- 'blockquote',
16
- 'details',
17
- 'div',
18
- 'dl',
19
- 'fieldset',
20
- 'figcaption',
21
- 'figure',
22
- 'footer',
23
- 'form',
24
- 'h1',
25
- 'h2',
26
- 'h3',
27
- 'h4',
28
- 'h5',
29
- 'h6',
30
- 'header',
31
- 'hgroup',
32
- 'hr',
33
- 'main',
34
- 'menu',
35
- 'nav',
36
- 'ol',
37
- 'p',
38
- 'pre',
39
- 'section',
40
- 'table',
41
- 'ul',
42
- ]),
43
- // <span> cannot contain block-level elements
44
- span: new Set([
45
- 'address',
46
- 'article',
47
- 'aside',
48
- 'blockquote',
49
- 'details',
50
- 'div',
51
- 'dl',
52
- 'fieldset',
53
- 'figcaption',
54
- 'figure',
55
- 'footer',
56
- 'form',
57
- 'h1',
58
- 'h2',
59
- 'h3',
60
- 'h4',
61
- 'h5',
62
- 'h6',
63
- 'header',
64
- 'hgroup',
65
- 'hr',
66
- 'main',
67
- 'menu',
68
- 'nav',
69
- 'ol',
70
- 'p',
71
- 'pre',
72
- 'section',
73
- 'table',
74
- 'ul',
75
- ]),
76
- // Interactive elements cannot be nested
77
- a: new Set(['a', 'button']),
78
- button: new Set(['a', 'button']),
79
- // Form elements
80
- label: new Set(['label']),
81
- form: new Set(['form']),
82
- // Headings cannot be nested within each other
83
- h1: new Set(['h1', 'h2', 'h3', 'h4', 'h5', 'h6']),
84
- h2: new Set(['h1', 'h2', 'h3', 'h4', 'h5', 'h6']),
85
- h3: new Set(['h1', 'h2', 'h3', 'h4', 'h5', 'h6']),
86
- h4: new Set(['h1', 'h2', 'h3', 'h4', 'h5', 'h6']),
87
- h5: new Set(['h1', 'h2', 'h3', 'h4', 'h5', 'h6']),
88
- h6: new Set(['h1', 'h2', 'h3', 'h4', 'h5', 'h6']),
89
- // Table structure
90
- table: new Set(['table', 'tr', 'td', 'th']), // Can only contain caption, colgroup, thead, tbody, tfoot
91
- thead: new Set(['caption', 'colgroup', 'thead', 'tbody', 'tfoot', 'td', 'th']), // Can only contain tr
92
- tbody: new Set(['caption', 'colgroup', 'thead', 'tbody', 'tfoot', 'td', 'th']), // Can only contain tr
93
- tfoot: new Set(['caption', 'colgroup', 'thead', 'tbody', 'tfoot', 'td', 'th']), // Can only contain tr
94
- tr: new Set(['caption', 'colgroup', 'thead', 'tbody', 'tfoot', 'tr']), // Can only contain td and th
95
- td: new Set(['td', 'th']), // Cannot nest td/th elements
96
- th: new Set(['td', 'th']), // Cannot nest td/th elements
97
- // Media elements
98
- picture: new Set(['picture']),
99
- // Main landmark - only one per document, cannot be nested
100
- main: new Set(['main']),
101
- // Other semantic restrictions
102
- figcaption: new Set(['figcaption']),
103
- dt: new Set([
104
- 'header',
105
- 'footer',
106
- 'article',
107
- 'aside',
108
- 'nav',
109
- 'section',
110
- 'h1',
111
- 'h2',
112
- 'h3',
113
- 'h4',
114
- 'h5',
115
- 'h6',
116
- ]),
117
- // No interactive content inside summary
118
- summary: new Set(['summary']),
119
- };
120
-
121
- /**
122
- * @param {AST.Element} element
123
- * @returns {string | null}
124
- */
125
- function get_element_tag(element) {
126
- return element.id.type === 'Identifier' ? element.id.name : null;
127
- }
128
-
129
- /**
130
- * @param {AST.Element} element
131
- * @param {AnalysisContext} context
132
- * @param {RippleCompileError[]} [errors]
133
- */
134
- export function validate_nesting(element, context, errors) {
135
- const tag = get_element_tag(element);
136
-
137
- if (tag === null) {
138
- return;
139
- }
140
-
141
- for (let i = context.path.length - 1; i >= 0; i--) {
142
- const parent = context.path[i];
143
- if (parent.type === 'Element') {
144
- const parent_tag = get_element_tag(parent);
145
- if (parent_tag === null) {
146
- continue;
147
- }
148
-
149
- if (parent_tag in invalid_nestings) {
150
- const validation_set =
151
- invalid_nestings[/** @type {keyof typeof invalid_nestings} */ (parent_tag)];
152
- if (validation_set.has(tag)) {
153
- error(
154
- `Invalid HTML nesting: <${tag}> cannot be a descendant of <${parent_tag}>.`,
155
- context.state.analysis.module.filename,
156
- element,
157
- errors,
158
- context.state.analysis.comments,
159
- );
160
- } else {
161
- // if my parent has a set of invalid children
162
- // and i'm not in it, then i'm valid
163
- return;
164
- }
165
- }
166
- }
167
- }
168
- }