ripple 0.3.13 → 0.3.15

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 (70) hide show
  1. package/CHANGELOG.md +35 -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.components.test.rsrx +103 -1
  19. package/tests/client/basic/basic.errors.test.rsrx +1 -1
  20. package/tests/client/basic/basic.styling.test.rsrx +1 -1
  21. package/tests/client/compiler/compiler.assignments.test.rsrx +1 -1
  22. package/tests/client/compiler/compiler.attributes.test.rsrx +1 -1
  23. package/tests/client/compiler/compiler.basic.test.rsrx +51 -14
  24. package/tests/client/compiler/compiler.tracked-access.test.rsrx +1 -1
  25. package/tests/client/compiler/compiler.try-in-function.test.rsrx +1 -1
  26. package/tests/client/compiler/compiler.typescript.test.rsrx +1 -1
  27. package/tests/client/css/global-additional-cases.test.rsrx +1 -1
  28. package/tests/client/css/global-advanced-selectors.test.rsrx +1 -1
  29. package/tests/client/css/global-at-rules.test.rsrx +1 -1
  30. package/tests/client/css/global-basic.test.rsrx +1 -1
  31. package/tests/client/css/global-classes-ids.test.rsrx +1 -1
  32. package/tests/client/css/global-combinators.test.rsrx +1 -1
  33. package/tests/client/css/global-complex-nesting.test.rsrx +1 -1
  34. package/tests/client/css/global-edge-cases.test.rsrx +1 -1
  35. package/tests/client/css/global-keyframes.test.rsrx +1 -1
  36. package/tests/client/css/global-nested.test.rsrx +1 -1
  37. package/tests/client/css/global-pseudo.test.rsrx +1 -1
  38. package/tests/client/css/global-scoping.test.rsrx +1 -1
  39. package/tests/client/css/style-identifier.test.rsrx +1 -1
  40. package/tests/client/return.test.rsrx +1 -1
  41. package/tests/hydration/build-components.js +1 -1
  42. package/tests/server/basic.components.test.rsrx +114 -0
  43. package/tests/server/compiler.test.rsrx +38 -1
  44. package/tests/server/style-identifier.test.rsrx +1 -1
  45. package/tests/setup-server.js +1 -1
  46. package/tests/utils/compiler-compat-config.test.js +1 -1
  47. package/types/index.d.ts +1 -1
  48. package/src/compiler/comment-utils.js +0 -91
  49. package/src/compiler/errors.js +0 -77
  50. package/src/compiler/identifier-utils.js +0 -80
  51. package/src/compiler/index.d.ts +0 -127
  52. package/src/compiler/index.js +0 -89
  53. package/src/compiler/phases/1-parse/index.js +0 -3007
  54. package/src/compiler/phases/1-parse/style.js +0 -704
  55. package/src/compiler/phases/2-analyze/css-analyze.js +0 -160
  56. package/src/compiler/phases/2-analyze/index.js +0 -2208
  57. package/src/compiler/phases/2-analyze/prune.js +0 -1131
  58. package/src/compiler/phases/2-analyze/validation.js +0 -168
  59. package/src/compiler/phases/3-transform/client/index.js +0 -5264
  60. package/src/compiler/phases/3-transform/segments.js +0 -2125
  61. package/src/compiler/phases/3-transform/server/index.js +0 -1749
  62. package/src/compiler/phases/3-transform/stylesheet.js +0 -545
  63. package/src/compiler/scope.js +0 -476
  64. package/src/compiler/source-map-utils.js +0 -358
  65. package/src/compiler/types/acorn.d.ts +0 -11
  66. package/src/compiler/types/estree-jsx.d.ts +0 -11
  67. package/src/compiler/types/estree.d.ts +0 -11
  68. package/src/compiler/types/index.d.ts +0 -1411
  69. package/src/compiler/types/parse.d.ts +0 -1723
  70. package/src/compiler/utils.js +0 -1258
@@ -1,160 +0,0 @@
1
- /** @import * as AST from 'estree' */
2
-
3
- import { walk } from 'zimmerframe';
4
-
5
- /**
6
- * True if is `:global` without arguments
7
- * @param {AST.CSS.SimpleSelector} simple_selector
8
- */
9
- function is_global_block_selector(simple_selector) {
10
- return (
11
- simple_selector.type === 'PseudoClassSelector' &&
12
- simple_selector.name === 'global' &&
13
- simple_selector.args === null
14
- );
15
- }
16
-
17
- /**
18
- * True if is `:global(...)` or `:global` and no pseudo class that is scoped.
19
- * @param {AST.CSS.RelativeSelector} relative_selector
20
- */
21
- function is_global(relative_selector) {
22
- const first = relative_selector.selectors[0];
23
-
24
- return (
25
- first?.type === 'PseudoClassSelector' &&
26
- first.name === 'global' &&
27
- (first.args === null ||
28
- // Only these two selector types keep the whole selector global, because e.g.
29
- // :global(button).x means that the selector is still scoped because of the .x
30
- relative_selector.selectors.every(
31
- (selector) =>
32
- selector.type === 'PseudoClassSelector' || selector.type === 'PseudoElementSelector',
33
- ))
34
- );
35
- }
36
-
37
- /**
38
- * Analyze CSS and set metadata for global selectors
39
- * @param {AST.CSS.Node} css - The CSS AST
40
- */
41
- export function analyze_css(css) {
42
- walk(css, /** @type {{ rule: AST.CSS.Rule | null }} */ ({ rule: null }), {
43
- Rule(node, context) {
44
- node.metadata.parent_rule = context.state.rule;
45
-
46
- // Check for :global blocks
47
- // A global block is when the selector starts with :global and has no local selectors before it
48
- for (const complex_selector of node.prelude.children) {
49
- let is_global_block = false;
50
-
51
- for (
52
- let selector_idx = 0;
53
- selector_idx < complex_selector.children.length;
54
- selector_idx++
55
- ) {
56
- const child = complex_selector.children[selector_idx];
57
- const idx = child.selectors.findIndex(is_global_block_selector);
58
-
59
- if (is_global_block) {
60
- // All selectors after :global are unscoped
61
- child.metadata.is_global_like = true;
62
- }
63
-
64
- // Only set is_global_block if this is the FIRST RelativeSelector and it starts with :global
65
- if (selector_idx === 0 && idx === 0) {
66
- // `child` starts with `:global` and is the first selector in the chain
67
- is_global_block = true;
68
- node.metadata.is_global_block = is_global_block;
69
- } else if (idx === 0) {
70
- // :global appears later in the selector chain (e.g., `div :global p`)
71
- // Set is_global_block for marking subsequent selectors as global-like
72
- is_global_block = true;
73
- } else if (idx !== -1) {
74
- // `:global` is not at the start - this is invalid but we'll let it through for now
75
- // The transform phase will handle removal
76
- }
77
- }
78
- }
79
-
80
- // Pass the current rule as state to nested nodes
81
- const state = { rule: node };
82
- context.visit(node.prelude, state);
83
- context.visit(node.block, state);
84
- },
85
-
86
- ComplexSelector(node, context) {
87
- // Set the rule metadata before analyzing children
88
- node.metadata.rule = context.state.rule;
89
-
90
- context.next(); // analyze relevant selectors first
91
-
92
- {
93
- const global = node.children.find(is_global);
94
-
95
- if (global) {
96
- const is_nested = context.path.at(-2)?.type === 'PseudoClassSelector';
97
- if (
98
- is_nested &&
99
- !(/** @type {AST.CSS.PseudoClassSelector} */ (global.selectors[0]).args)
100
- ) {
101
- throw new Error(`A :global selector cannot be inside a pseudoclass.`);
102
- }
103
-
104
- const idx = node.children.indexOf(global);
105
- const first = /** @type {AST.CSS.PseudoClassSelector} */ (global.selectors[0]);
106
- if (first.args !== null && idx !== 0 && idx !== node.children.length - 1) {
107
- // ensure `:global(...)` is not used in the middle of a selector (but multiple `global(...)` in sequence are ok)
108
- for (let i = idx + 1; i < node.children.length; i++) {
109
- if (!is_global(node.children[i])) {
110
- throw new Error(
111
- `:global(...) can be at the start or end of a selector sequence, but not in the middle.`,
112
- );
113
- }
114
- }
115
- }
116
- }
117
- }
118
-
119
- // Set is_global metadata
120
- node.metadata.is_global = node.children.every(
121
- ({ metadata }) => metadata.is_global || metadata.is_global_like,
122
- );
123
-
124
- node.metadata.used ||= node.metadata.is_global;
125
- },
126
-
127
- PseudoClassSelector(node, context) {
128
- // Walk into :is(), :where(), :has(), and :not() to initialize metadata for nested selectors
129
- if (
130
- (node.name === 'is' ||
131
- node.name === 'where' ||
132
- node.name === 'has' ||
133
- node.name === 'not') &&
134
- node.args
135
- ) {
136
- context.next();
137
- }
138
- },
139
- RelativeSelector(node, context) {
140
- // Check if this selector is a :global selector
141
- node.metadata.is_global = node.selectors.length >= 1 && is_global(node);
142
-
143
- // Check for :root and other global-like selectors
144
- if (
145
- node.selectors.length >= 1 &&
146
- node.selectors.every(
147
- (selector) =>
148
- selector.type === 'PseudoClassSelector' || selector.type === 'PseudoElementSelector',
149
- )
150
- ) {
151
- const first = node.selectors[0];
152
- node.metadata.is_global_like ||=
153
- (first.type === 'PseudoClassSelector' && first.name === 'host') ||
154
- (first.type === 'PseudoClassSelector' && first.name === 'root');
155
- }
156
-
157
- context.next();
158
- },
159
- });
160
- }