ripple 0.2.216 → 0.3.1
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 +52 -0
- package/package.json +16 -7
- package/src/compiler/errors.js +1 -1
- package/src/compiler/identifier-utils.js +2 -0
- package/src/compiler/index.d.ts +2 -6
- package/src/compiler/phases/1-parse/index.js +171 -233
- package/src/compiler/phases/2-analyze/index.js +192 -16
- package/src/compiler/phases/2-analyze/prune.js +2 -2
- package/src/compiler/phases/3-transform/client/index.js +308 -91
- package/src/compiler/phases/3-transform/segments.js +43 -15
- package/src/compiler/phases/3-transform/server/index.js +71 -21
- package/src/compiler/scope.js +31 -12
- package/src/compiler/source-map-utils.js +4 -6
- package/src/compiler/types/acorn.d.ts +11 -0
- package/src/compiler/types/estree-jsx.d.ts +11 -0
- package/src/compiler/types/estree.d.ts +11 -0
- package/src/compiler/types/import.d.ts +32 -18
- package/src/compiler/types/index.d.ts +75 -23
- package/src/compiler/types/parse.d.ts +7 -10
- package/src/compiler/utils.js +48 -0
- package/src/runtime/array.js +53 -22
- package/src/runtime/date.js +15 -5
- package/src/runtime/index-client.js +41 -7
- package/src/runtime/index-server.js +7 -7
- package/src/runtime/internal/client/bindings.js +2 -2
- package/src/runtime/internal/client/blocks.js +40 -1
- package/src/runtime/internal/client/context.js +8 -0
- package/src/runtime/internal/client/for.js +3 -3
- package/src/runtime/internal/client/index.js +27 -5
- package/src/runtime/internal/client/render.js +20 -8
- package/src/runtime/internal/client/runtime.js +9 -7
- package/src/runtime/internal/client/try.js +15 -22
- package/src/runtime/internal/client/utils.js +1 -1
- package/src/runtime/internal/server/context.js +8 -0
- package/src/runtime/internal/server/index.js +99 -6
- package/src/runtime/map.js +7 -7
- package/src/runtime/media-query.js +10 -1
- package/src/runtime/object.js +6 -6
- package/src/runtime/proxy.js +6 -6
- package/src/runtime/set.js +11 -11
- package/src/runtime/url-search-params.js +13 -2
- package/src/runtime/url.js +15 -5
- package/src/utils/builders.js +13 -3
- package/tests/client/array/array.copy-within.test.ripple +11 -11
- package/tests/client/array/array.derived.test.ripple +42 -42
- package/tests/client/array/array.iteration.test.ripple +12 -12
- package/tests/client/array/array.mutations.test.ripple +25 -25
- package/tests/client/array/array.static.test.ripple +103 -106
- package/tests/client/array/array.to-methods.test.ripple +8 -8
- package/tests/client/async-suspend.test.ripple +94 -0
- package/tests/client/basic/basic.attributes.test.ripple +31 -31
- package/tests/client/basic/basic.collections.test.ripple +7 -7
- package/tests/client/basic/basic.components.test.ripple +48 -10
- package/tests/client/basic/basic.errors.test.ripple +46 -31
- package/tests/client/basic/basic.events.test.ripple +11 -11
- package/tests/client/basic/basic.get-set.test.ripple +18 -18
- package/tests/client/basic/basic.reactivity.test.ripple +47 -42
- package/tests/client/basic/basic.rendering.test.ripple +7 -7
- package/tests/client/basic/basic.utilities.test.ripple +4 -4
- package/tests/client/boundaries.test.ripple +7 -7
- package/tests/client/compiler/__snapshots__/compiler.assignments.test.ripple.snap +2 -2
- package/tests/client/compiler/compiler.assignments.test.ripple +21 -21
- package/tests/client/compiler/compiler.basic.test.ripple +223 -82
- package/tests/client/compiler/compiler.tracked-access.test.ripple +8 -9
- package/tests/client/composite/composite.dynamic-components.test.ripple +8 -8
- package/tests/client/composite/composite.generics.test.ripple +4 -4
- package/tests/client/composite/composite.props.test.ripple +9 -9
- package/tests/client/composite/composite.reactivity.test.ripple +32 -26
- package/tests/client/composite/composite.render.test.ripple +13 -4
- package/tests/client/computed-properties.test.ripple +3 -3
- package/tests/client/context.test.ripple +3 -3
- package/tests/client/css/global-additional-cases.test.ripple +4 -4
- package/tests/client/css/style-identifier.test.ripple +49 -41
- package/tests/client/date.test.ripple +40 -40
- package/tests/client/dynamic-elements.test.ripple +165 -30
- package/tests/client/events.test.ripple +25 -25
- package/tests/client/for.test.ripple +76 -8
- package/tests/client/function-overload.test.ripple +0 -1
- package/tests/client/head.test.ripple +7 -7
- package/tests/client/html.test.ripple +2 -2
- package/tests/client/input-value.test.ripple +174 -176
- package/tests/client/map.test.ripple +21 -21
- package/tests/client/media-query.test.ripple +4 -4
- package/tests/client/object.test.ripple +12 -12
- package/tests/client/portal.test.ripple +4 -4
- package/tests/client/ref.test.ripple +5 -5
- package/tests/client/return.test.ripple +17 -17
- package/tests/client/set.test.ripple +16 -16
- package/tests/client/svg.test.ripple +6 -7
- package/tests/client/switch.test.ripple +10 -10
- package/tests/client/tracked-expression.test.ripple +1 -3
- package/tests/client/try.test.ripple +33 -4
- package/tests/client/url/url.derived.test.ripple +10 -9
- package/tests/client/url/url.parsing.test.ripple +10 -10
- package/tests/client/url/url.partial-removal.test.ripple +10 -10
- package/tests/client/url/url.reactivity.test.ripple +17 -17
- package/tests/client/url/url.serialization.test.ripple +4 -4
- package/tests/client/url-search-params/url-search-params.derived.test.ripple +11 -10
- package/tests/client/url-search-params/url-search-params.initialization.test.ripple +5 -7
- package/tests/client/url-search-params/url-search-params.iteration.test.ripple +13 -13
- package/tests/client/url-search-params/url-search-params.mutation.test.ripple +19 -19
- package/tests/client/url-search-params/url-search-params.retrieval.test.ripple +17 -17
- package/tests/client/url-search-params/url-search-params.serialization.test.ripple +5 -5
- package/tests/client/url-search-params/url-search-params.tracked-url.test.ripple +5 -5
- package/tests/hydration/compiled/client/events.js +8 -11
- package/tests/hydration/compiled/client/for.js +20 -23
- package/tests/hydration/compiled/client/head.js +17 -19
- package/tests/hydration/compiled/client/hmr.js +1 -3
- package/tests/hydration/compiled/client/html.js +1 -15
- package/tests/hydration/compiled/client/if-children.js +7 -9
- package/tests/hydration/compiled/client/if.js +5 -7
- package/tests/hydration/compiled/client/mixed-control-flow.js +3 -5
- package/tests/hydration/compiled/client/portal.js +1 -1
- package/tests/hydration/compiled/client/reactivity.js +9 -11
- package/tests/hydration/compiled/client/return.js +11 -13
- package/tests/hydration/compiled/client/switch.js +4 -6
- package/tests/hydration/compiled/server/basic.js +0 -1
- package/tests/hydration/compiled/server/composite.js +0 -3
- package/tests/hydration/compiled/server/events.js +8 -12
- package/tests/hydration/compiled/server/for.js +20 -23
- package/tests/hydration/compiled/server/head.js +17 -19
- package/tests/hydration/compiled/server/hmr.js +1 -4
- package/tests/hydration/compiled/server/html.js +1 -35
- package/tests/hydration/compiled/server/if-children.js +7 -11
- package/tests/hydration/compiled/server/if.js +5 -7
- package/tests/hydration/compiled/server/mixed-control-flow.js +3 -5
- package/tests/hydration/compiled/server/portal.js +1 -9
- package/tests/hydration/compiled/server/reactivity.js +9 -11
- package/tests/hydration/compiled/server/return.js +11 -13
- package/tests/hydration/compiled/server/switch.js +4 -6
- package/tests/hydration/components/events.ripple +8 -9
- package/tests/hydration/components/for.ripple +20 -21
- package/tests/hydration/components/head.ripple +6 -8
- package/tests/hydration/components/hmr.ripple +1 -2
- package/tests/hydration/components/html.ripple +1 -3
- package/tests/hydration/components/if-children.ripple +7 -8
- package/tests/hydration/components/if.ripple +5 -6
- package/tests/hydration/components/mixed-control-flow.ripple +4 -6
- package/tests/hydration/components/portal.ripple +1 -1
- package/tests/hydration/components/reactivity.ripple +9 -10
- package/tests/hydration/components/return.ripple +11 -12
- package/tests/hydration/components/switch.ripple +6 -8
- package/tests/server/await.test.ripple +2 -2
- package/tests/server/basic.attributes.test.ripple +19 -21
- package/tests/server/basic.components.test.ripple +13 -7
- package/tests/server/basic.test.ripple +20 -21
- package/tests/server/compiler.test.ripple +5 -5
- package/tests/server/composite.props.test.ripple +6 -7
- package/tests/server/composite.test.ripple +4 -4
- package/tests/server/context.test.ripple +1 -3
- package/tests/server/dynamic-elements.test.ripple +24 -24
- package/tests/server/head.test.ripple +5 -7
- package/tests/server/style-identifier.test.ripple +16 -17
- package/types/index.d.ts +266 -62
- package/types/server.d.ts +6 -6
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { compile } from 'ripple/compiler';
|
|
2
|
-
import { track } from 'ripple';
|
|
3
2
|
|
|
4
|
-
describe('#style identifier', () => {
|
|
3
|
+
describe('#ripple.style identifier', () => {
|
|
5
4
|
describe('basic usage with components', () => {
|
|
6
|
-
it('passes scoped class to a child component via #style', () => {
|
|
5
|
+
it('passes scoped class to a child component via #ripple.style', () => {
|
|
7
6
|
component Child({ className }: { className: string }) {
|
|
8
7
|
<div class={className}>{'styled child'}</div>
|
|
9
8
|
}
|
|
10
9
|
|
|
11
10
|
component Parent() {
|
|
12
|
-
<Child className={#style.highlight} />
|
|
11
|
+
<Child className={#ripple.style.highlight} />
|
|
13
12
|
|
|
14
13
|
<style>
|
|
15
14
|
.highlight {
|
|
@@ -28,14 +27,14 @@ describe('#style identifier', () => {
|
|
|
28
27
|
expect(classes.some((cls: string) => cls === 'highlight')).toBe(true);
|
|
29
28
|
});
|
|
30
29
|
|
|
31
|
-
it('passes multiple #style classes to a child component', () => {
|
|
30
|
+
it('passes multiple #ripple.style classes to a child component', () => {
|
|
32
31
|
component Child({ primary, secondary }: { primary: string; secondary: string }) {
|
|
33
32
|
<div class={primary}>{'primary'}</div>
|
|
34
33
|
<span class={secondary}>{'secondary'}</span>
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
component Parent() {
|
|
38
|
-
<Child primary={#style.primary} secondary={#style.secondary} />
|
|
37
|
+
<Child primary={#ripple.style.primary} secondary={#ripple.style.secondary} />
|
|
39
38
|
|
|
40
39
|
<style>
|
|
41
40
|
.primary {
|
|
@@ -64,15 +63,15 @@ describe('#style identifier', () => {
|
|
|
64
63
|
expect(spanClasses.some((cls: string) => cls === 'secondary')).toBe(true);
|
|
65
64
|
});
|
|
66
65
|
|
|
67
|
-
it('passes scoped class to a dynamic child component via #style', () => {
|
|
66
|
+
it('passes scoped class to a dynamic child component via #ripple.style', () => {
|
|
68
67
|
component Child({ cls }: { cls: string }) {
|
|
69
68
|
<span class={cls}>{'text'}</span>
|
|
70
69
|
}
|
|
71
70
|
|
|
72
71
|
component Parent() {
|
|
73
|
-
let dynamic = track(() => Child);
|
|
72
|
+
let dynamic = #ripple.track(() => Child);
|
|
74
73
|
<div class="wrapper">
|
|
75
|
-
<@dynamic cls={#style.text} />
|
|
74
|
+
<@dynamic cls={#ripple.style.text} />
|
|
76
75
|
</div>
|
|
77
76
|
|
|
78
77
|
<style>
|
|
@@ -91,7 +90,7 @@ describe('#style identifier', () => {
|
|
|
91
90
|
expect(classes.some((cls: string) => cls === 'text')).toBe(true);
|
|
92
91
|
});
|
|
93
92
|
|
|
94
|
-
it('child can combine its own classes with parent #style class', () => {
|
|
93
|
+
it('child can combine its own classes with parent #ripple.style class', () => {
|
|
95
94
|
component Card({ className }: { className?: string }) {
|
|
96
95
|
<div class={['card-base', className ?? '']}>{'card content'}</div>
|
|
97
96
|
|
|
@@ -103,7 +102,7 @@ describe('#style identifier', () => {
|
|
|
103
102
|
}
|
|
104
103
|
|
|
105
104
|
component App() {
|
|
106
|
-
<Card className={#style.themed} />
|
|
105
|
+
<Card className={#ripple.style.themed} />
|
|
107
106
|
|
|
108
107
|
<style>
|
|
109
108
|
.themed {
|
|
@@ -128,7 +127,7 @@ describe('#style identifier', () => {
|
|
|
128
127
|
|
|
129
128
|
component App() {
|
|
130
129
|
<div class="parent">
|
|
131
|
-
<Child cls={#style.dual} />
|
|
130
|
+
<Child cls={#ripple.style.dual} />
|
|
132
131
|
</div>
|
|
133
132
|
|
|
134
133
|
<style>
|
|
@@ -152,10 +151,10 @@ describe('#style identifier', () => {
|
|
|
152
151
|
});
|
|
153
152
|
|
|
154
153
|
describe('compile errors', () => {
|
|
155
|
-
it('errors when #style is used directly on a DOM element', () => {
|
|
154
|
+
it('errors when #ripple.style is used directly on a DOM element', () => {
|
|
156
155
|
const source = `
|
|
157
156
|
component App() {
|
|
158
|
-
<div class={#style.box}>{'content'}</div>
|
|
157
|
+
<div class={#ripple.style.box}>{'content'}</div>
|
|
159
158
|
|
|
160
159
|
<style>
|
|
161
160
|
.box {
|
|
@@ -168,10 +167,10 @@ component App() {
|
|
|
168
167
|
);
|
|
169
168
|
});
|
|
170
169
|
|
|
171
|
-
it('errors when #style bracket notation is used directly on a DOM element', () => {
|
|
170
|
+
it('errors when #ripple.style bracket notation is used directly on a DOM element', () => {
|
|
172
171
|
const source = `
|
|
173
172
|
component App() {
|
|
174
|
-
<div class={#style['container']}>{'content'}</div>
|
|
173
|
+
<div class={#ripple.style['container']}>{'content'}</div>
|
|
175
174
|
|
|
176
175
|
<style>
|
|
177
176
|
.container {
|
|
@@ -184,13 +183,15 @@ component App() {
|
|
|
184
183
|
);
|
|
185
184
|
});
|
|
186
185
|
|
|
187
|
-
it(
|
|
188
|
-
|
|
186
|
+
it(
|
|
187
|
+
'errors when #ripple.style references a class in a compound selector passed to component',
|
|
188
|
+
() => {
|
|
189
|
+
const source = `
|
|
189
190
|
component Child({ cls }) {
|
|
190
191
|
<span class={cls}>{'text'}</span>
|
|
191
192
|
}
|
|
192
193
|
component App() {
|
|
193
|
-
<Child cls={#style.special} />
|
|
194
|
+
<Child cls={#ripple.style.special} />
|
|
194
195
|
|
|
195
196
|
<style>
|
|
196
197
|
span.special {
|
|
@@ -198,8 +199,11 @@ component App() {
|
|
|
198
199
|
}
|
|
199
200
|
</style>
|
|
200
201
|
}`;
|
|
201
|
-
|
|
202
|
-
|
|
202
|
+
expect(() => compile(source, 'test.ripple')).toThrow(
|
|
203
|
+
/does not exist as a stand-alone class/,
|
|
204
|
+
);
|
|
205
|
+
},
|
|
206
|
+
);
|
|
203
207
|
|
|
204
208
|
it('errors if descendant class is attempted to be passed in to child component', () => {
|
|
205
209
|
const source = `
|
|
@@ -210,7 +214,7 @@ component App() {
|
|
|
210
214
|
component App() {
|
|
211
215
|
<div class="wrapper">
|
|
212
216
|
<Child
|
|
213
|
-
cls={#style.nested}
|
|
217
|
+
cls={#ripple.style.nested}
|
|
214
218
|
/>
|
|
215
219
|
</div>
|
|
216
220
|
|
|
@@ -238,7 +242,7 @@ component App() {
|
|
|
238
242
|
<Child
|
|
239
243
|
// @ts-expect-error - cannot use child combinator class as standalone
|
|
240
244
|
// @ripple-expect-error - cannot use child combinator class as standalone
|
|
241
|
-
cls={#style.child}
|
|
245
|
+
cls={#ripple.style.child}
|
|
242
246
|
/>
|
|
243
247
|
</div>
|
|
244
248
|
|
|
@@ -265,7 +269,7 @@ component App() {
|
|
|
265
269
|
<Child
|
|
266
270
|
// @ts-expect-error - cannot use compound class as standalone
|
|
267
271
|
// @ripple-expect-error - cannot use compound class as standalone
|
|
268
|
-
cls={#style.child}
|
|
272
|
+
cls={#ripple.style.child}
|
|
269
273
|
/>
|
|
270
274
|
</div>
|
|
271
275
|
|
|
@@ -281,18 +285,17 @@ component App() {
|
|
|
281
285
|
expect(() => compile(source, 'test.ripple')).toThrow(/does not exist as a stand-alone class/);
|
|
282
286
|
});
|
|
283
287
|
|
|
284
|
-
it('errors if descendant #style class is used on a dynamic component', () => {
|
|
288
|
+
it('errors if descendant #ripple.style class is used on a dynamic component', () => {
|
|
285
289
|
const source = `
|
|
286
|
-
import { track } from 'ripple';
|
|
287
290
|
|
|
288
291
|
component Child({ cls }) {
|
|
289
292
|
<span class={cls}>{'text'}</span>
|
|
290
293
|
}
|
|
291
294
|
|
|
292
295
|
component App() {
|
|
293
|
-
let dynamic = track(() => Child);
|
|
296
|
+
let dynamic = #ripple.track(() => Child);
|
|
294
297
|
<div class="wrapper">
|
|
295
|
-
<@dynamic cls={#style.nested} />
|
|
298
|
+
<@dynamic cls={#ripple.style.nested} />
|
|
296
299
|
</div>
|
|
297
300
|
|
|
298
301
|
<style>
|
|
@@ -307,13 +310,15 @@ component App() {
|
|
|
307
310
|
expect(() => compile(source, 'test.ripple')).toThrow(/does not exist as a stand-alone class/);
|
|
308
311
|
});
|
|
309
312
|
|
|
310
|
-
it(
|
|
311
|
-
|
|
313
|
+
it(
|
|
314
|
+
'errors when #ripple.style references a class that does not exist in the style block',
|
|
315
|
+
() => {
|
|
316
|
+
const source = `
|
|
312
317
|
component Child({ cls }) {
|
|
313
318
|
<div class={cls}>{'text'}</div>
|
|
314
319
|
}
|
|
315
320
|
component App() {
|
|
316
|
-
<Child cls={#style.missing} />
|
|
321
|
+
<Child cls={#ripple.style.missing} />
|
|
317
322
|
|
|
318
323
|
<style>
|
|
319
324
|
.other {
|
|
@@ -321,17 +326,20 @@ component App() {
|
|
|
321
326
|
}
|
|
322
327
|
</style>
|
|
323
328
|
}`;
|
|
324
|
-
|
|
325
|
-
|
|
329
|
+
expect(() => compile(source, 'test.ripple')).toThrow(
|
|
330
|
+
/does not exist as a stand-alone class/,
|
|
331
|
+
);
|
|
332
|
+
},
|
|
333
|
+
);
|
|
326
334
|
|
|
327
|
-
it('errors when #style is used with a dynamic expression', () => {
|
|
335
|
+
it('errors when #ripple.style is used with a dynamic expression', () => {
|
|
328
336
|
const source = `
|
|
329
337
|
component Child({ cls }) {
|
|
330
338
|
<div class={cls}>{'text'}</div>
|
|
331
339
|
}
|
|
332
340
|
component App() {
|
|
333
341
|
const key = 'highlight';
|
|
334
|
-
<Child cls={#style[key]} />
|
|
342
|
+
<Child cls={#ripple.style[key]} />
|
|
335
343
|
|
|
336
344
|
<style>
|
|
337
345
|
.highlight {
|
|
@@ -344,22 +352,22 @@ component App() {
|
|
|
344
352
|
);
|
|
345
353
|
});
|
|
346
354
|
|
|
347
|
-
it('errors when #style is used outside of a component', () => {
|
|
355
|
+
it('errors when #ripple.style is used outside of a component', () => {
|
|
348
356
|
const source = `function notAComponent() {
|
|
349
|
-
const cls = #style.foo;
|
|
357
|
+
const cls = #ripple.style.foo;
|
|
350
358
|
}`;
|
|
351
359
|
expect(() => compile(source, 'test.ripple')).toThrow(/can only be used within a component/);
|
|
352
360
|
});
|
|
353
361
|
});
|
|
354
362
|
|
|
355
363
|
describe('compiler output', () => {
|
|
356
|
-
it('generates #style object with standalone classes for client mode', () => {
|
|
364
|
+
it('generates #ripple.style object with standalone classes for client mode', () => {
|
|
357
365
|
const source = `
|
|
358
366
|
component Child({ cls }) {
|
|
359
367
|
<div class={cls}>{'text'}</div>
|
|
360
368
|
}
|
|
361
369
|
export component App() {
|
|
362
|
-
<Child cls={#style.highlight} />
|
|
370
|
+
<Child cls={#ripple.style.highlight} />
|
|
363
371
|
|
|
364
372
|
<style>
|
|
365
373
|
.highlight {
|
|
@@ -373,13 +381,13 @@ export component App() {
|
|
|
373
381
|
expect(js.code).toMatch(/ripple-[a-z0-9]+/);
|
|
374
382
|
});
|
|
375
383
|
|
|
376
|
-
it('generates #style object with standalone classes for server mode', () => {
|
|
384
|
+
it('generates #ripple.style object with standalone classes for server mode', () => {
|
|
377
385
|
const source = `
|
|
378
386
|
component Child({ cls }) {
|
|
379
387
|
<div class={cls}>{'text'}</div>
|
|
380
388
|
}
|
|
381
389
|
export component App() {
|
|
382
|
-
<Child cls={#style.highlight} />
|
|
390
|
+
<Child cls={#ripple.style.highlight} />
|
|
383
391
|
|
|
384
392
|
<style>
|
|
385
393
|
.highlight {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { flushSync
|
|
1
|
+
import { flushSync } from 'ripple';
|
|
2
2
|
|
|
3
|
-
describe('
|
|
3
|
+
describe('RippleDate', () => {
|
|
4
4
|
it('handles getTime() with reactive updates', () => {
|
|
5
5
|
component DateTest() {
|
|
6
|
-
let date =
|
|
7
|
-
let time = track(() => date.getTime());
|
|
6
|
+
let date = #ripple.date(2025, 0, 1);
|
|
7
|
+
let time = #ripple.track(() => date.getTime());
|
|
8
8
|
|
|
9
9
|
<button onClick={() => date.setFullYear(2026)}>{'Change Year'}</button>
|
|
10
10
|
<pre>{@time}</pre>
|
|
@@ -25,8 +25,8 @@ describe('TrackedDate', () => {
|
|
|
25
25
|
|
|
26
26
|
it('handles getFullYear() with reactive updates', () => {
|
|
27
27
|
component DateTest() {
|
|
28
|
-
let date =
|
|
29
|
-
let year = track(() => date.getFullYear());
|
|
28
|
+
let date = #ripple.date(2025, 5, 15);
|
|
29
|
+
let year = #ripple.track(() => date.getFullYear());
|
|
30
30
|
|
|
31
31
|
<button onClick={() => date.setFullYear(2030)}>{'Change Year'}</button>
|
|
32
32
|
<pre>{@year}</pre>
|
|
@@ -46,8 +46,8 @@ describe('TrackedDate', () => {
|
|
|
46
46
|
|
|
47
47
|
it('handles getMonth() with reactive updates', () => {
|
|
48
48
|
component DateTest() {
|
|
49
|
-
let date =
|
|
50
|
-
let month = track(() => date.getMonth());
|
|
49
|
+
let date = #ripple.date(2025, 0, 15);
|
|
50
|
+
let month = #ripple.track(() => date.getMonth());
|
|
51
51
|
|
|
52
52
|
<button onClick={() => date.setMonth(11)}>{'Change to December'}</button>
|
|
53
53
|
<pre>{@month}</pre>
|
|
@@ -67,8 +67,8 @@ describe('TrackedDate', () => {
|
|
|
67
67
|
|
|
68
68
|
it('handles getDate() with reactive updates', () => {
|
|
69
69
|
component DateTest() {
|
|
70
|
-
let date =
|
|
71
|
-
let day = track(() => date.getDate());
|
|
70
|
+
let date = #ripple.date(2025, 0, 1);
|
|
71
|
+
let day = #ripple.track(() => date.getDate());
|
|
72
72
|
|
|
73
73
|
<button onClick={() => date.setDate(15)}>{'Change Day'}</button>
|
|
74
74
|
<pre>{@day}</pre>
|
|
@@ -88,8 +88,8 @@ describe('TrackedDate', () => {
|
|
|
88
88
|
|
|
89
89
|
it('handles getDay() with reactive updates', () => {
|
|
90
90
|
component DateTest() {
|
|
91
|
-
let date =
|
|
92
|
-
let dayOfWeek = track(() => date.getDay());
|
|
91
|
+
let date = #ripple.date(2025, 0, 1);
|
|
92
|
+
let dayOfWeek = #ripple.track(() => date.getDay());
|
|
93
93
|
|
|
94
94
|
<button onClick={() => date.setDate(2)}>{'Next Day'}</button>
|
|
95
95
|
<pre>{@dayOfWeek}</pre>
|
|
@@ -109,8 +109,8 @@ describe('TrackedDate', () => {
|
|
|
109
109
|
|
|
110
110
|
it('handles getHours() with reactive updates', () => {
|
|
111
111
|
component DateTest() {
|
|
112
|
-
let date =
|
|
113
|
-
let hours = track(() => date.getHours());
|
|
112
|
+
let date = #ripple.date(2025, 0, 1, 10, 30, 0);
|
|
113
|
+
let hours = #ripple.track(() => date.getHours());
|
|
114
114
|
|
|
115
115
|
<button onClick={() => date.setHours(15)}>{'Change to 3 PM'}</button>
|
|
116
116
|
<pre>{@hours}</pre>
|
|
@@ -130,8 +130,8 @@ describe('TrackedDate', () => {
|
|
|
130
130
|
|
|
131
131
|
it('handles getMinutes() with reactive updates', () => {
|
|
132
132
|
component DateTest() {
|
|
133
|
-
let date =
|
|
134
|
-
let minutes = track(() => date.getMinutes());
|
|
133
|
+
let date = #ripple.date(2025, 0, 1, 10, 15, 0);
|
|
134
|
+
let minutes = #ripple.track(() => date.getMinutes());
|
|
135
135
|
|
|
136
136
|
<button onClick={() => date.setMinutes(45)}>{'Change Minutes'}</button>
|
|
137
137
|
<pre>{@minutes}</pre>
|
|
@@ -151,8 +151,8 @@ describe('TrackedDate', () => {
|
|
|
151
151
|
|
|
152
152
|
it('handles getSeconds() with reactive updates', () => {
|
|
153
153
|
component DateTest() {
|
|
154
|
-
let date =
|
|
155
|
-
let seconds = track(() => date.getSeconds());
|
|
154
|
+
let date = #ripple.date(2025, 0, 1, 10, 15, 30);
|
|
155
|
+
let seconds = #ripple.track(() => date.getSeconds());
|
|
156
156
|
|
|
157
157
|
<button onClick={() => date.setSeconds(45)}>{'Change Seconds'}</button>
|
|
158
158
|
<pre>{@seconds}</pre>
|
|
@@ -172,8 +172,8 @@ describe('TrackedDate', () => {
|
|
|
172
172
|
|
|
173
173
|
it('handles toISOString() with reactive updates', () => {
|
|
174
174
|
component DateTest() {
|
|
175
|
-
let date =
|
|
176
|
-
let isoString = track(() => date.toISOString());
|
|
175
|
+
let date = #ripple.date(2025, 0, 1, 12, 0, 0);
|
|
176
|
+
let isoString = #ripple.track(() => date.toISOString());
|
|
177
177
|
|
|
178
178
|
<button onClick={() => date.setFullYear(2026)}>{'Change Year'}</button>
|
|
179
179
|
<pre>{@isoString}</pre>
|
|
@@ -198,8 +198,8 @@ describe('TrackedDate', () => {
|
|
|
198
198
|
|
|
199
199
|
it('handles toDateString() with reactive updates', () => {
|
|
200
200
|
component DateTest() {
|
|
201
|
-
let date =
|
|
202
|
-
let dateString = track(() => date.toDateString());
|
|
201
|
+
let date = #ripple.date(2025, 0, 1);
|
|
202
|
+
let dateString = #ripple.track(() => date.toDateString());
|
|
203
203
|
|
|
204
204
|
<button onClick={() => date.setMonth(11)}>{'Change to December'}</button>
|
|
205
205
|
<pre>{@dateString}</pre>
|
|
@@ -222,8 +222,8 @@ describe('TrackedDate', () => {
|
|
|
222
222
|
|
|
223
223
|
it('handles valueOf() with reactive updates', () => {
|
|
224
224
|
component DateTest() {
|
|
225
|
-
let date =
|
|
226
|
-
let valueOf = track(() => date.valueOf());
|
|
225
|
+
let date = #ripple.date(2025, 0, 1);
|
|
226
|
+
let valueOf = #ripple.track(() => date.valueOf());
|
|
227
227
|
|
|
228
228
|
<button onClick={() => date.setDate(2)}>{'Next Day'}</button>
|
|
229
229
|
<pre>{@valueOf}</pre>
|
|
@@ -244,11 +244,11 @@ describe('TrackedDate', () => {
|
|
|
244
244
|
|
|
245
245
|
it('handles multiple get methods reacting to same setTime change', () => {
|
|
246
246
|
component DateTest() {
|
|
247
|
-
let date =
|
|
248
|
-
let year = track(() => date.getFullYear());
|
|
249
|
-
let month = track(() => date.getMonth());
|
|
250
|
-
let day = track(() => date.getDate());
|
|
251
|
-
let hours = track(() => date.getHours());
|
|
247
|
+
let date = #ripple.date(2025, 0, 1, 10, 30, 15);
|
|
248
|
+
let year = #ripple.track(() => date.getFullYear());
|
|
249
|
+
let month = #ripple.track(() => date.getMonth());
|
|
250
|
+
let day = #ripple.track(() => date.getDate());
|
|
251
|
+
let hours = #ripple.track(() => date.getHours());
|
|
252
252
|
|
|
253
253
|
<button onClick={() => date.setTime(new Date(2026, 5, 15, 14, 45, 30).getTime())}>
|
|
254
254
|
{'Change All'}
|
|
@@ -292,15 +292,15 @@ describe('TrackedDate', () => {
|
|
|
292
292
|
|
|
293
293
|
it('handles constructor with different parameter combinations', () => {
|
|
294
294
|
component DateTest() {
|
|
295
|
-
let dateNow =
|
|
296
|
-
let dateFromString =
|
|
297
|
-
let dateFromNumbers =
|
|
298
|
-
let dateFromTimestamp =
|
|
295
|
+
let dateNow = #ripple.date();
|
|
296
|
+
let dateFromString = #ripple.date('2025-01-01');
|
|
297
|
+
let dateFromNumbers = #ripple.date(2025, 0, 1);
|
|
298
|
+
let dateFromTimestamp = #ripple.date(1735689600000);
|
|
299
299
|
|
|
300
|
-
let nowYear = track(() => dateNow.getFullYear());
|
|
301
|
-
let stringYear = track(() => dateFromString.getFullYear());
|
|
302
|
-
let numbersYear = track(() => dateFromNumbers.getFullYear());
|
|
303
|
-
let timestampYear = track(() => dateFromTimestamp.getFullYear());
|
|
300
|
+
let nowYear = #ripple.track(() => dateNow.getFullYear());
|
|
301
|
+
let stringYear = #ripple.track(() => dateFromString.getFullYear());
|
|
302
|
+
let numbersYear = #ripple.track(() => dateFromNumbers.getFullYear());
|
|
303
|
+
let timestampYear = #ripple.track(() => dateFromTimestamp.getFullYear());
|
|
304
304
|
|
|
305
305
|
<div>
|
|
306
306
|
{'Now: '}
|
|
@@ -341,9 +341,9 @@ describe('TrackedDate', () => {
|
|
|
341
341
|
|
|
342
342
|
it('handles get methods with arguments non-memoized', () => {
|
|
343
343
|
component DateTest() {
|
|
344
|
-
let date =
|
|
345
|
-
let localeDateString = track(() => date.toLocaleDateString('en-US'));
|
|
346
|
-
let localeTimeString = track(() => date.toLocaleTimeString('en-US'));
|
|
344
|
+
let date = #ripple.date();
|
|
345
|
+
let localeDateString = #ripple.track(() => date.toLocaleDateString('en-US'));
|
|
346
|
+
let localeTimeString = #ripple.track(() => date.toLocaleTimeString('en-US'));
|
|
347
347
|
|
|
348
348
|
<button onClick={() => date.setFullYear(date.getFullYear() + 1)}>{'Next Year'}</button>
|
|
349
349
|
<div>
|