ripple 0.3.12 → 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.
- package/CHANGELOG.md +57 -0
- package/package.json +11 -30
- package/src/compiler/types/import.d.ts +0 -12
- package/src/helpers.d.ts +2 -0
- package/src/runtime/array.js +38 -38
- package/src/runtime/create-subscriber.js +2 -2
- package/src/runtime/index-client.js +15 -13
- package/src/runtime/index-server.js +18 -11
- package/src/runtime/internal/client/bindings.js +4 -6
- package/src/runtime/internal/client/blocks.js +19 -23
- package/src/runtime/internal/client/constants.js +20 -9
- package/src/runtime/internal/client/events.js +8 -3
- package/src/runtime/internal/client/hmr.js +5 -17
- package/src/runtime/internal/client/index.js +14 -4
- package/src/runtime/internal/client/runtime.js +436 -173
- package/src/runtime/internal/client/try.js +334 -156
- package/src/runtime/internal/client/types.d.ts +26 -0
- package/src/runtime/internal/server/blocks.js +181 -0
- package/src/runtime/internal/server/constants.js +7 -0
- package/src/runtime/internal/server/index.js +774 -150
- package/src/runtime/internal/server/types.d.ts +35 -0
- package/src/runtime/media-query.js +34 -33
- package/src/runtime/object.js +7 -10
- package/src/runtime/proxy.js +2 -3
- package/src/runtime/reactive-value.js +23 -21
- package/src/server/index.js +1 -1
- package/src/utils/ast.js +1 -1
- package/src/utils/async.js +35 -0
- package/src/utils/attributes.js +43 -0
- package/src/utils/builders.js +5 -3
- package/tests/client/__snapshots__/computed-properties.test.rsrx.snap +49 -0
- package/tests/client/__snapshots__/for.test.rsrx.snap +319 -0
- package/tests/client/__snapshots__/html.test.rsrx.snap +40 -0
- package/tests/client/_etc.test.rsrx +7 -0
- package/tests/client/array/{array.static.test.ripple → array.static.test.rsrx} +18 -20
- package/tests/client/async-suspend.test.rsrx +662 -0
- package/tests/client/basic/__snapshots__/basic.attributes.test.rsrx.snap +60 -0
- package/tests/client/basic/__snapshots__/basic.rendering.test.rsrx.snap +59 -0
- package/tests/client/basic/{basic.errors.test.ripple → basic.errors.test.rsrx} +3 -3
- package/tests/client/basic/{basic.styling.test.ripple → basic.styling.test.rsrx} +1 -1
- package/tests/client/compiler/__snapshots__/compiler.assignments.test.rsrx.snap +12 -0
- package/tests/client/compiler/__snapshots__/compiler.typescript.test.rsrx.snap +46 -0
- package/tests/client/compiler/{compiler.assignments.test.ripple → compiler.assignments.test.rsrx} +1 -1
- package/tests/client/compiler/{compiler.attributes.test.ripple → compiler.attributes.test.rsrx} +1 -1
- package/tests/client/compiler/{compiler.basic.test.ripple → compiler.basic.test.rsrx} +13 -13
- package/tests/client/compiler/{compiler.tracked-access.test.ripple → compiler.tracked-access.test.rsrx} +1 -1
- package/tests/client/compiler/{compiler.try-in-function.test.ripple → compiler.try-in-function.test.rsrx} +9 -7
- package/tests/client/compiler/{compiler.typescript.test.ripple → compiler.typescript.test.rsrx} +1 -1
- package/tests/client/composite/__snapshots__/composite.render.test.rsrx.snap +37 -0
- package/tests/client/css/{global-additional-cases.test.ripple → global-additional-cases.test.rsrx} +1 -1
- package/tests/client/css/{global-advanced-selectors.test.ripple → global-advanced-selectors.test.rsrx} +1 -1
- package/tests/client/css/{global-at-rules.test.ripple → global-at-rules.test.rsrx} +1 -1
- package/tests/client/css/{global-basic.test.ripple → global-basic.test.rsrx} +1 -1
- package/tests/client/css/{global-classes-ids.test.ripple → global-classes-ids.test.rsrx} +1 -1
- package/tests/client/css/{global-combinators.test.ripple → global-combinators.test.rsrx} +1 -1
- package/tests/client/css/{global-complex-nesting.test.ripple → global-complex-nesting.test.rsrx} +1 -1
- package/tests/client/css/{global-edge-cases.test.ripple → global-edge-cases.test.rsrx} +1 -1
- package/tests/client/css/{global-keyframes.test.ripple → global-keyframes.test.rsrx} +1 -1
- package/tests/client/css/{global-nested.test.ripple → global-nested.test.rsrx} +1 -1
- package/tests/client/css/{global-pseudo.test.ripple → global-pseudo.test.rsrx} +1 -1
- package/tests/client/css/{global-scoping.test.ripple → global-scoping.test.rsrx} +1 -1
- package/tests/client/css/{style-identifier.test.ripple → style-identifier.test.rsrx} +1 -1
- package/tests/client/{function-overload.test.ripple → function-overload.test.rsrx} +1 -1
- package/tests/client/{return.test.ripple → return.test.rsrx} +1 -1
- package/tests/client/try.test.rsrx +1702 -0
- package/tests/hydration/build-components.js +6 -4
- package/tests/hydration/compiled/client/head.js +11 -11
- package/tests/hydration/compiled/client/mixed-control-flow.js +55 -70
- package/tests/hydration/compiled/client/nested-control-flow.js +72 -88
- package/tests/hydration/compiled/client/try.js +42 -54
- package/tests/hydration/compiled/server/basic.js +491 -369
- package/tests/hydration/compiled/server/composite.js +153 -128
- package/tests/hydration/compiled/server/events.js +166 -145
- package/tests/hydration/compiled/server/for.js +821 -677
- package/tests/hydration/compiled/server/head.js +200 -165
- package/tests/hydration/compiled/server/hmr.js +62 -54
- package/tests/hydration/compiled/server/html-in-template.js +64 -55
- package/tests/hydration/compiled/server/html.js +1477 -1360
- package/tests/hydration/compiled/server/if-children.js +448 -408
- package/tests/hydration/compiled/server/if.js +204 -171
- package/tests/hydration/compiled/server/mixed-control-flow.js +237 -195
- package/tests/hydration/compiled/server/nested-control-flow.js +533 -467
- package/tests/hydration/compiled/server/portal.js +94 -107
- package/tests/hydration/compiled/server/reactivity.js +87 -64
- package/tests/hydration/compiled/server/return.js +1424 -1174
- package/tests/hydration/compiled/server/switch.js +268 -238
- package/tests/hydration/compiled/server/try.js +98 -87
- package/tests/hydration/components/{mixed-control-flow.ripple → mixed-control-flow.rsrx} +2 -2
- package/tests/hydration/components/{try.ripple → try.rsrx} +4 -2
- package/tests/hydration/mixed-control-flow.test.js +14 -0
- package/tests/hydration/nested-control-flow.test.js +50 -48
- package/tests/hydration/try.test.js +25 -0
- package/tests/server/__snapshots__/compiler.test.ripple.snap +0 -32
- package/tests/server/__snapshots__/compiler.test.rsrx.snap +95 -0
- package/tests/server/{compiler.test.ripple → compiler.test.rsrx} +0 -17
- package/tests/server/{html-nesting-validation.test.ripple → html-nesting-validation.test.rsrx} +3 -3
- package/tests/server/streaming-ssr.test.rsrx +115 -0
- package/tests/server/{style-identifier.test.ripple → style-identifier.test.rsrx} +1 -1
- package/tests/server/try.test.rsrx +503 -0
- package/tests/setup-server.js +1 -1
- package/tests/utils/compiler-compat-config.test.js +4 -4
- package/tests/utils/vite-plugin-config.test.js +1 -1
- package/tests/utils/vite-plugin-hmr.test.js +5 -5
- package/tsconfig.json +2 -0
- package/types/index.d.ts +13 -23
- package/types/server.d.ts +43 -16
- package/src/compiler/comment-utils.js +0 -91
- package/src/compiler/errors.js +0 -77
- package/src/compiler/identifier-utils.js +0 -80
- package/src/compiler/index.d.ts +0 -127
- package/src/compiler/index.js +0 -89
- package/src/compiler/phases/1-parse/index.js +0 -2964
- package/src/compiler/phases/1-parse/style.js +0 -704
- package/src/compiler/phases/2-analyze/css-analyze.js +0 -160
- package/src/compiler/phases/2-analyze/index.js +0 -2238
- package/src/compiler/phases/2-analyze/prune.js +0 -1131
- package/src/compiler/phases/2-analyze/validation.js +0 -168
- package/src/compiler/phases/3-transform/client/index.js +0 -5301
- package/src/compiler/phases/3-transform/segments.js +0 -2129
- package/src/compiler/phases/3-transform/server/index.js +0 -1899
- package/src/compiler/phases/3-transform/stylesheet.js +0 -545
- package/src/compiler/scope.js +0 -476
- package/src/compiler/source-map-utils.js +0 -358
- package/src/compiler/types/acorn.d.ts +0 -11
- package/src/compiler/types/estree-jsx.d.ts +0 -11
- package/src/compiler/types/estree.d.ts +0 -11
- package/src/compiler/types/index.d.ts +0 -1404
- package/src/compiler/types/parse.d.ts +0 -1721
- package/src/compiler/utils.js +0 -1263
- package/tests/client/_etc.test.ripple +0 -5
- package/tests/client/async-suspend.test.ripple +0 -94
- package/tests/client/try.test.ripple +0 -196
- package/tests/server/streaming-ssr.test.ripple +0 -68
- package/tests/server/try.test.ripple +0 -82
- /package/tests/client/array/{array.copy-within.test.ripple → array.copy-within.test.rsrx} +0 -0
- /package/tests/client/array/{array.derived.test.ripple → array.derived.test.rsrx} +0 -0
- /package/tests/client/array/{array.iteration.test.ripple → array.iteration.test.rsrx} +0 -0
- /package/tests/client/array/{array.mutations.test.ripple → array.mutations.test.rsrx} +0 -0
- /package/tests/client/array/{array.to-methods.test.ripple → array.to-methods.test.rsrx} +0 -0
- /package/tests/client/basic/{basic.attributes.test.ripple → basic.attributes.test.rsrx} +0 -0
- /package/tests/client/basic/{basic.collections.test.ripple → basic.collections.test.rsrx} +0 -0
- /package/tests/client/basic/{basic.components.test.ripple → basic.components.test.rsrx} +0 -0
- /package/tests/client/basic/{basic.events.test.ripple → basic.events.test.rsrx} +0 -0
- /package/tests/client/basic/{basic.get-set.test.ripple → basic.get-set.test.rsrx} +0 -0
- /package/tests/client/basic/{basic.hmr.test.ripple → basic.hmr.test.rsrx} +0 -0
- /package/tests/client/basic/{basic.reactivity.test.ripple → basic.reactivity.test.rsrx} +0 -0
- /package/tests/client/basic/{basic.rendering.test.ripple → basic.rendering.test.rsrx} +0 -0
- /package/tests/client/basic/{basic.utilities.test.ripple → basic.utilities.test.rsrx} +0 -0
- /package/tests/client/{boundaries.test.ripple → boundaries.test.rsrx} +0 -0
- /package/tests/client/compiler/{compiler.regex.test.ripple → compiler.regex.test.rsrx} +0 -0
- /package/tests/client/composite/{composite.dynamic-components.test.ripple → composite.dynamic-components.test.rsrx} +0 -0
- /package/tests/client/composite/{composite.generics.test.ripple → composite.generics.test.rsrx} +0 -0
- /package/tests/client/composite/{composite.props.test.ripple → composite.props.test.rsrx} +0 -0
- /package/tests/client/composite/{composite.reactivity.test.ripple → composite.reactivity.test.rsrx} +0 -0
- /package/tests/client/composite/{composite.render.test.ripple → composite.render.test.rsrx} +0 -0
- /package/tests/client/{computed-properties.test.ripple → computed-properties.test.rsrx} +0 -0
- /package/tests/client/{context.test.ripple → context.test.rsrx} +0 -0
- /package/tests/client/{date.test.ripple → date.test.rsrx} +0 -0
- /package/tests/client/{dynamic-elements.test.ripple → dynamic-elements.test.rsrx} +0 -0
- /package/tests/client/{events.test.ripple → events.test.rsrx} +0 -0
- /package/tests/client/{for.test.ripple → for.test.rsrx} +0 -0
- /package/tests/client/{function-overload-import.ripple → function-overload-import.rsrx} +0 -0
- /package/tests/client/{head.test.ripple → head.test.rsrx} +0 -0
- /package/tests/client/{html.test.ripple → html.test.rsrx} +0 -0
- /package/tests/client/{input-value.test.ripple → input-value.test.rsrx} +0 -0
- /package/tests/client/{lazy-destructuring.test.ripple → lazy-destructuring.test.rsrx} +0 -0
- /package/tests/client/{map.test.ripple → map.test.rsrx} +0 -0
- /package/tests/client/{media-query.test.ripple → media-query.test.rsrx} +0 -0
- /package/tests/client/{object.test.ripple → object.test.rsrx} +0 -0
- /package/tests/client/{portal.test.ripple → portal.test.rsrx} +0 -0
- /package/tests/client/{ref.test.ripple → ref.test.rsrx} +0 -0
- /package/tests/client/{set.test.ripple → set.test.rsrx} +0 -0
- /package/tests/client/{svg.test.ripple → svg.test.rsrx} +0 -0
- /package/tests/client/{switch.test.ripple → switch.test.rsrx} +0 -0
- /package/tests/client/{tsx.test.ripple → tsx.test.rsrx} +0 -0
- /package/tests/client/{typescript-generics.test.ripple → typescript-generics.test.rsrx} +0 -0
- /package/tests/client/url/{url.derived.test.ripple → url.derived.test.rsrx} +0 -0
- /package/tests/client/url/{url.parsing.test.ripple → url.parsing.test.rsrx} +0 -0
- /package/tests/client/url/{url.partial-removal.test.ripple → url.partial-removal.test.rsrx} +0 -0
- /package/tests/client/url/{url.reactivity.test.ripple → url.reactivity.test.rsrx} +0 -0
- /package/tests/client/url/{url.serialization.test.ripple → url.serialization.test.rsrx} +0 -0
- /package/tests/client/url-search-params/{url-search-params.derived.test.ripple → url-search-params.derived.test.rsrx} +0 -0
- /package/tests/client/url-search-params/{url-search-params.initialization.test.ripple → url-search-params.initialization.test.rsrx} +0 -0
- /package/tests/client/url-search-params/{url-search-params.iteration.test.ripple → url-search-params.iteration.test.rsrx} +0 -0
- /package/tests/client/url-search-params/{url-search-params.mutation.test.ripple → url-search-params.mutation.test.rsrx} +0 -0
- /package/tests/client/url-search-params/{url-search-params.retrieval.test.ripple → url-search-params.retrieval.test.rsrx} +0 -0
- /package/tests/client/url-search-params/{url-search-params.serialization.test.ripple → url-search-params.serialization.test.rsrx} +0 -0
- /package/tests/client/url-search-params/{url-search-params.tracked-url.test.ripple → url-search-params.tracked-url.test.rsrx} +0 -0
- /package/tests/hydration/components/{basic.ripple → basic.rsrx} +0 -0
- /package/tests/hydration/components/{composite.ripple → composite.rsrx} +0 -0
- /package/tests/hydration/components/{events.ripple → events.rsrx} +0 -0
- /package/tests/hydration/components/{for.ripple → for.rsrx} +0 -0
- /package/tests/hydration/components/{head.ripple → head.rsrx} +0 -0
- /package/tests/hydration/components/{hmr.ripple → hmr.rsrx} +0 -0
- /package/tests/hydration/components/{html-in-template.ripple → html-in-template.rsrx} +0 -0
- /package/tests/hydration/components/{html.ripple → html.rsrx} +0 -0
- /package/tests/hydration/components/{if-children.ripple → if-children.rsrx} +0 -0
- /package/tests/hydration/components/{if.ripple → if.rsrx} +0 -0
- /package/tests/hydration/components/{nested-control-flow.ripple → nested-control-flow.rsrx} +0 -0
- /package/tests/hydration/components/{portal.ripple → portal.rsrx} +0 -0
- /package/tests/hydration/components/{reactivity.ripple → reactivity.rsrx} +0 -0
- /package/tests/hydration/components/{return.ripple → return.rsrx} +0 -0
- /package/tests/hydration/components/{switch.ripple → switch.rsrx} +0 -0
- /package/tests/server/{await.test.ripple → await.test.rsrx} +0 -0
- /package/tests/server/{basic.attributes.test.ripple → basic.attributes.test.rsrx} +0 -0
- /package/tests/server/{basic.components.test.ripple → basic.components.test.rsrx} +0 -0
- /package/tests/server/{basic.test.ripple → basic.test.rsrx} +0 -0
- /package/tests/server/{composite.props.test.ripple → composite.props.test.rsrx} +0 -0
- /package/tests/server/{composite.test.ripple → composite.test.rsrx} +0 -0
- /package/tests/server/{context.test.ripple → context.test.rsrx} +0 -0
- /package/tests/server/{dynamic-elements.test.ripple → dynamic-elements.test.rsrx} +0 -0
- /package/tests/server/{for.test.ripple → for.test.rsrx} +0 -0
- /package/tests/server/{head.test.ripple → head.test.rsrx} +0 -0
- /package/tests/server/{if.test.ripple → if.test.rsrx} +0 -0
- /package/tests/server/{lazy-destructuring.test.ripple → lazy-destructuring.test.rsrx} +0 -0
- /package/tests/server/{return.test.ripple → return.test.rsrx} +0 -0
- /package/tests/server/{switch.test.ripple → switch.test.rsrx} +0 -0
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { Context } from './context.js';
|
|
2
|
+
import type { OutputInterface } from './index.js';
|
|
3
|
+
import type { BlockFunction, CatchFunction, PendingFunction } from './blocks.js';
|
|
2
4
|
|
|
3
5
|
export type Component = {
|
|
4
6
|
c: null | Map<Context<any>, any>;
|
|
@@ -13,6 +15,7 @@ export type Dependency = {
|
|
|
13
15
|
|
|
14
16
|
export type Derived = {
|
|
15
17
|
a: { get?: Function; set?: Function };
|
|
18
|
+
b: Block;
|
|
16
19
|
c: number;
|
|
17
20
|
co: null | Component;
|
|
18
21
|
d: null | Dependency;
|
|
@@ -31,9 +34,41 @@ export type Tracked = {
|
|
|
31
34
|
c: number;
|
|
32
35
|
f: number;
|
|
33
36
|
v: any;
|
|
37
|
+
aa: AbortController | null;
|
|
38
|
+
ap: PromiseLike<any> | null;
|
|
34
39
|
readonly [0]: any;
|
|
35
40
|
[1]: Tracked;
|
|
36
41
|
value: any;
|
|
37
42
|
readonly length: 2;
|
|
38
43
|
[Symbol.iterator](): Iterator<any | Tracked>;
|
|
39
44
|
};
|
|
45
|
+
|
|
46
|
+
export type Block = {
|
|
47
|
+
co: Component | null;
|
|
48
|
+
f: number;
|
|
49
|
+
fn: BlockFunction;
|
|
50
|
+
o: OutputInterface;
|
|
51
|
+
p: Block | null;
|
|
52
|
+
s: any;
|
|
53
|
+
first: Block | null;
|
|
54
|
+
last: Block | null;
|
|
55
|
+
next: Block | null;
|
|
56
|
+
prev: Block | null;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export type TryBlockState = {
|
|
60
|
+
p?: PendingFunction | null;
|
|
61
|
+
c?: CatchFunction | null;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export type TryBlock = Block & {
|
|
65
|
+
s: TryBlockState;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export type TryBlockWithCatch = TryBlock & {
|
|
69
|
+
s: TryBlockState & { c: CatchFunction };
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export type TryBlockWithPending = TryBlock & {
|
|
73
|
+
s: TryBlockState & { p: PendingFunction };
|
|
74
|
+
};
|
|
@@ -2,47 +2,48 @@ import { on } from './internal/client/events.js';
|
|
|
2
2
|
import { get, safe_scope, set, tracked, with_scope } from './internal/client/index.js';
|
|
3
3
|
import { ReactiveValue } from './reactive-value.js';
|
|
4
4
|
|
|
5
|
+
/** @typedef {import('#public').ReactiveValue<boolean>} ReactiveValueBoolean */
|
|
6
|
+
|
|
5
7
|
const parenthesis_regex = /\(.+\)/;
|
|
6
8
|
const non_parenthesized_keywords = new Set(['all', 'print', 'screen', 'and', 'or', 'not', 'only']);
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
|
-
* @
|
|
10
|
-
* @param {string} query
|
|
11
|
-
* @param {boolean | undefined} [fallback]
|
|
12
|
-
* @returns {ReactiveValue<boolean>}
|
|
11
|
+
* @type {new (query: string, fallback?: boolean | undefined) => ReactiveValueBoolean}
|
|
13
12
|
*/
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
export const MediaQuery = /** @type {any} */ (
|
|
14
|
+
function MediaQuery(/** @type {string} */ query, /** @type {boolean | undefined} */ fallback) {
|
|
15
|
+
if (!new.target) {
|
|
16
|
+
throw new TypeError('MediaQuery must be called with new');
|
|
17
|
+
}
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
var block = safe_scope();
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
let final_query =
|
|
22
|
+
parenthesis_regex.test(query) ||
|
|
23
|
+
// we need to use `some` here because technically this `window.matchMedia('random,screen')` still returns true
|
|
24
|
+
query.split(/[\s,]+/).some((keyword) => non_parenthesized_keywords.has(keyword.trim()))
|
|
25
|
+
? query
|
|
26
|
+
: `(${query})`;
|
|
27
|
+
const q = window.matchMedia(final_query);
|
|
28
|
+
const matches = tracked(q.matches, block);
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
30
|
+
return new ReactiveValue(
|
|
31
|
+
() => get(matches),
|
|
32
|
+
() =>
|
|
33
|
+
on(
|
|
34
|
+
q,
|
|
35
|
+
'change',
|
|
36
|
+
() => {
|
|
37
|
+
// skip wrapping in untrack as createSubscriber already does it
|
|
38
|
+
if (q.matches !== get(matches)) {
|
|
39
|
+
set(matches, q.matches);
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
{ delegated: false },
|
|
43
|
+
),
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
);
|
|
46
47
|
|
|
47
48
|
/**
|
|
48
49
|
* @param {import('#client').Block} block
|
package/src/runtime/object.js
CHANGED
|
@@ -4,18 +4,15 @@ import { object_proxy } from './proxy.js';
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @template {object} T
|
|
7
|
-
* @constructor
|
|
8
|
-
* @param {T} obj
|
|
9
|
-
* @returns {RippleObject<T>}
|
|
10
7
|
*/
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
export class RippleObject {
|
|
9
|
+
/**
|
|
10
|
+
* @param {T} obj
|
|
11
|
+
*/
|
|
12
|
+
constructor(obj) {
|
|
13
|
+
var block = safe_scope();
|
|
14
|
+
return /** @type {RippleObject<any>} */ (/** @type {unknown} */ (ripple_object(block, obj)));
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
-
var block = safe_scope();
|
|
17
|
-
|
|
18
|
-
return ripple_object(block, obj);
|
|
19
16
|
}
|
|
20
17
|
|
|
21
18
|
/**
|
package/src/runtime/proxy.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/** @import { Block, Tracked } from '#client' */
|
|
2
|
-
/** @import { RippleArray } from '
|
|
3
|
-
/** @import { RippleObject } from './object.js' */
|
|
2
|
+
/** @import { RippleArray, RippleObject } from '#public' */
|
|
4
3
|
|
|
5
4
|
import { get, set, tracked } from './internal/client/runtime.js';
|
|
6
5
|
import {
|
|
@@ -295,7 +294,7 @@ export function array_proxy({ elements, block, from_static = false, use_array =
|
|
|
295
294
|
arr = new Array(...elements);
|
|
296
295
|
}
|
|
297
296
|
|
|
298
|
-
return proxy(arr, block);
|
|
297
|
+
return /** @type {RippleArray<T>} */ (proxy(arr, block));
|
|
299
298
|
}
|
|
300
299
|
|
|
301
300
|
/**
|
|
@@ -1,29 +1,31 @@
|
|
|
1
1
|
/** @import { Derived } from '#client' */
|
|
2
|
+
/** @import { ReactiveValue as ReactiveValueT } from '#public' */
|
|
2
3
|
import { createSubscriber } from './create-subscriber.js';
|
|
3
4
|
import { safe_scope, derived } from './internal/client/runtime.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
|
-
* @
|
|
7
|
-
* @constructor
|
|
8
|
-
* @param {() => V} fn
|
|
9
|
-
* @param {() => void | (() => void)} start
|
|
10
|
-
* @returns {Derived}
|
|
7
|
+
* @type {new <V>(fn: () => V, start: () => void | (() => void)) => ReactiveValueT<V>}
|
|
11
8
|
*/
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
export const ReactiveValue = /** @type {any} */ (
|
|
10
|
+
function ReactiveValue(
|
|
11
|
+
/** @type {() => any} */ fn,
|
|
12
|
+
/** @type {() => void | (() => void)} */ start,
|
|
13
|
+
) {
|
|
14
|
+
if (!new.target) {
|
|
15
|
+
throw new TypeError('`ReactiveValue` must be called with new');
|
|
16
|
+
}
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
const s = createSubscriber(start);
|
|
19
|
+
const block = safe_scope();
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
21
|
+
return derived(
|
|
22
|
+
fn,
|
|
23
|
+
block,
|
|
24
|
+
() => {
|
|
25
|
+
s();
|
|
26
|
+
return fn();
|
|
27
|
+
},
|
|
28
|
+
(/** @type {any} */ _, /** @type {any} */ prev) => prev,
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
);
|
package/src/server/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SSR helpers
|
|
2
|
-
export {
|
|
2
|
+
export { create_ssr_stream, render } from '../runtime/internal/server/index.js';
|
|
3
3
|
export { get_css_for_hashes } from '../runtime/internal/server/css-registry.js';
|
|
4
4
|
export { executeServerFunction } from '../runtime/internal/server/rpc.js';
|
|
5
5
|
|
package/src/utils/ast.js
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {any} value
|
|
3
|
+
* @returns {value is PromiseLike<any>}
|
|
4
|
+
*/
|
|
5
|
+
export function is_promise_like(value) {
|
|
6
|
+
return (
|
|
7
|
+
(typeof value === 'object' || typeof value === 'function') &&
|
|
8
|
+
value !== null &&
|
|
9
|
+
typeof value.then === 'function'
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {any} value
|
|
15
|
+
* @param {'deferred'} [type]
|
|
16
|
+
* @returns {{ promise: PromiseLike<any>, abort_controller: AbortController | null, type?: 'deferred' } | null}
|
|
17
|
+
*/
|
|
18
|
+
export function get_async_track_result(value, type) {
|
|
19
|
+
if (is_promise_like(value)) {
|
|
20
|
+
return { promise: value, abort_controller: null, type: type };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (typeof value === 'object' && value !== null && is_promise_like(value.promise)) {
|
|
24
|
+
return {
|
|
25
|
+
promise: value.promise,
|
|
26
|
+
abort_controller:
|
|
27
|
+
typeof value.abortController === 'object' && value.abortController !== null
|
|
28
|
+
? value.abortController
|
|
29
|
+
: null,
|
|
30
|
+
type: type,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Attributes that are boolean, i.e. they are present or not present.
|
|
3
|
+
*/
|
|
4
|
+
const DOM_BOOLEAN_ATTRIBUTES = [
|
|
5
|
+
'allowfullscreen',
|
|
6
|
+
'async',
|
|
7
|
+
'autofocus',
|
|
8
|
+
'autoplay',
|
|
9
|
+
'checked',
|
|
10
|
+
'controls',
|
|
11
|
+
'default',
|
|
12
|
+
'disabled',
|
|
13
|
+
'formnovalidate',
|
|
14
|
+
'hidden',
|
|
15
|
+
'indeterminate',
|
|
16
|
+
'inert',
|
|
17
|
+
'ismap',
|
|
18
|
+
'loop',
|
|
19
|
+
'multiple',
|
|
20
|
+
'muted',
|
|
21
|
+
'nomodule',
|
|
22
|
+
'novalidate',
|
|
23
|
+
'open',
|
|
24
|
+
'playsinline',
|
|
25
|
+
'readonly',
|
|
26
|
+
'required',
|
|
27
|
+
'reversed',
|
|
28
|
+
'seamless',
|
|
29
|
+
'selected',
|
|
30
|
+
'webkitdirectory',
|
|
31
|
+
'defer',
|
|
32
|
+
'disablepictureinpicture',
|
|
33
|
+
'disableremoteplayback',
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Returns true if name is a boolean DOM attribute
|
|
38
|
+
* @param {string} name
|
|
39
|
+
* @returns {boolean}
|
|
40
|
+
*/
|
|
41
|
+
export function is_boolean_attribute(name) {
|
|
42
|
+
return DOM_BOOLEAN_ATTRIBUTES.includes(name);
|
|
43
|
+
}
|
package/src/utils/builders.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/** @import * as AST from 'estree' */
|
|
2
|
-
/** @import * as ESTreeJSX from 'estree-jsx' */
|
|
1
|
+
/** @import * as AST from '@tsrx/core/types/estree' */
|
|
2
|
+
/** @import * as ESTreeJSX from '@tsrx/core/types/estree-jsx' */
|
|
3
3
|
|
|
4
4
|
import { regex_is_valid_identifier } from './patterns.js';
|
|
5
5
|
import { sanitize_template_string } from './sanitize_template_string.js';
|
|
@@ -1051,15 +1051,17 @@ export function try_builder(block, handler = null, finalizer = null, pending = n
|
|
|
1051
1051
|
|
|
1052
1052
|
/**
|
|
1053
1053
|
* @param {AST.Pattern | null} param
|
|
1054
|
+
* @param {AST.Pattern | null} reset_param
|
|
1054
1055
|
* @param {AST.BlockStatement} body
|
|
1055
1056
|
* @param {AST.NodeWithLocation} [loc_info]
|
|
1056
1057
|
* @return {AST.CatchClause}
|
|
1057
1058
|
*/
|
|
1058
|
-
export function catch_clause_builder(param, body, loc_info) {
|
|
1059
|
+
export function catch_clause_builder(param, reset_param, body, loc_info) {
|
|
1059
1060
|
/** @type {AST.CatchClause} */
|
|
1060
1061
|
const node = {
|
|
1061
1062
|
type: 'CatchClause',
|
|
1062
1063
|
param,
|
|
1064
|
+
resetParam: reset_param,
|
|
1063
1065
|
body,
|
|
1064
1066
|
metadata: { path: [] },
|
|
1065
1067
|
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`computed tracked properties > should update a property using assignment 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<div>
|
|
6
|
+
0
|
|
7
|
+
</div>
|
|
8
|
+
<button>
|
|
9
|
+
Increment
|
|
10
|
+
</button>
|
|
11
|
+
|
|
12
|
+
</div>
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
exports[`computed tracked properties > should update a property using assignment 2`] = `
|
|
16
|
+
<div>
|
|
17
|
+
<div>
|
|
18
|
+
1
|
|
19
|
+
</div>
|
|
20
|
+
<button>
|
|
21
|
+
Increment
|
|
22
|
+
</button>
|
|
23
|
+
|
|
24
|
+
</div>
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
exports[`computed tracked properties > should update a property using update expressions 1`] = `
|
|
28
|
+
<div>
|
|
29
|
+
<div>
|
|
30
|
+
0
|
|
31
|
+
</div>
|
|
32
|
+
<button>
|
|
33
|
+
Increment
|
|
34
|
+
</button>
|
|
35
|
+
|
|
36
|
+
</div>
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
exports[`computed tracked properties > should update a property using update expressions 2`] = `
|
|
40
|
+
<div>
|
|
41
|
+
<div>
|
|
42
|
+
1
|
|
43
|
+
</div>
|
|
44
|
+
<button>
|
|
45
|
+
Increment
|
|
46
|
+
</button>
|
|
47
|
+
|
|
48
|
+
</div>
|
|
49
|
+
`;
|