ripple 0.3.28 → 0.3.30
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 +38 -0
- package/package.json +4 -4
- package/src/runtime/internal/server/index.js +1 -1
- package/src/runtime/proxy.js +182 -180
- package/tests/client/compiler/compiler.basic.test.tsrx +1 -1
- package/tests/client/tsconfig.json +1 -7
- package/tests/client/tsx.test.tsrx +50 -0
- package/tests/hydration/compiled/client/head.js +11 -11
- package/tests/hydration/compiled/server/head.js +11 -11
- package/tests/hydration/compiled/server/html-in-template.js +2 -2
- package/tests/hydration/compiled/server/html.js +30 -30
- package/tests/hydration/components/for.tsrx +3 -1
- package/tests/hydration/tsconfig.json +1 -8
- package/tests/server/basic.attributes.test.tsrx +67 -7
- package/tests/server/tsconfig.json +1 -8
- package/tsconfig.json +1 -8
- package/tsconfig.typecheck.json +1 -2
- package/types/index.d.ts +1 -1
- package/src/utils/hashing.js +0 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# ripple
|
|
2
2
|
|
|
3
|
+
## 0.3.30
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`7f59ed8`](https://github.com/Ripple-TS/ripple/commit/7f59ed80d7b44c847fb9eb8bf00d4fe9835c3136)
|
|
8
|
+
Thanks [@leonidaz](https://github.com/leonidaz)! - Replace `node:crypto` usage
|
|
9
|
+
in the compiler with a pure-JS implementation so Ripple can be compiled inside
|
|
10
|
+
browser workers (e.g. the Monaco-based playground) where `crypto.createHash` is
|
|
11
|
+
not available.
|
|
12
|
+
|
|
13
|
+
The hashing utility is split into two functions:
|
|
14
|
+
- `simple_hash` — fast non-cryptographic djb2 (base36). Used for CSS class-name
|
|
15
|
+
prefixes and runtime `{html}` hydration markers where the input is user
|
|
16
|
+
content and the output multiplies across the shipped bundle.
|
|
17
|
+
- `strong_hash` — preimage-resistant SHA-256 prefix (pure-JS via
|
|
18
|
+
`@noble/hashes`). Used everywhere a hash is derived from a server-only
|
|
19
|
+
filesystem path (`#server` RPC ids, `track`/`trackAsync` ids, head-element
|
|
20
|
+
hydration markers) so the hash can't be inverted to reveal the original path.
|
|
21
|
+
|
|
22
|
+
The runtime `ripple` package no longer ships its own `hashing.js` — it
|
|
23
|
+
re-exports `simple_hash`/`strong_hash` from `@tsrx/core`, and the compiler emits
|
|
24
|
+
`_$_.simple_hash` (previously `_$_.hash`) for dynamic `{html}` hydration
|
|
25
|
+
markers.
|
|
26
|
+
|
|
27
|
+
- Updated dependencies
|
|
28
|
+
[[`7f59ed8`](https://github.com/Ripple-TS/ripple/commit/7f59ed80d7b44c847fb9eb8bf00d4fe9835c3136)]:
|
|
29
|
+
- @tsrx/ripple@0.0.12
|
|
30
|
+
- ripple@0.3.30
|
|
31
|
+
|
|
32
|
+
## 0.3.29
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- Updated dependencies
|
|
37
|
+
[[`4543794`](https://github.com/Ripple-TS/ripple/commit/45437944a99decfb4bc56f7171772614a7f5691a)]:
|
|
38
|
+
- @tsrx/ripple@0.0.11
|
|
39
|
+
- ripple@0.3.29
|
|
40
|
+
|
|
3
41
|
## 0.3.28
|
|
4
42
|
|
|
5
43
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Ripple is an elegant TypeScript UI framework",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Dominic Gannaway",
|
|
6
|
-
"version": "0.3.
|
|
6
|
+
"version": "0.3.30",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"module": "src/runtime/index-client.js",
|
|
9
9
|
"main": "src/runtime/index-client.js",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"esm-env": "^1.2.2",
|
|
77
77
|
"@types/estree": "^1.0.8",
|
|
78
78
|
"@types/estree-jsx": "^1.0.5",
|
|
79
|
-
"@tsrx/ripple": "0.0.
|
|
79
|
+
"@tsrx/ripple": "0.0.12"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@types/node": "^24.3.0",
|
|
@@ -84,9 +84,9 @@
|
|
|
84
84
|
"typescript": "^5.9.3",
|
|
85
85
|
"@volar/language-core": "~2.4.28",
|
|
86
86
|
"vscode-languageserver-types": "^3.17.5",
|
|
87
|
-
"@tsrx/core": "0.0.
|
|
87
|
+
"@tsrx/core": "0.0.10"
|
|
88
88
|
},
|
|
89
89
|
"peerDependencies": {
|
|
90
|
-
"ripple": "0.3.
|
|
90
|
+
"ripple": "0.3.30"
|
|
91
91
|
}
|
|
92
92
|
}
|
|
@@ -51,7 +51,7 @@ import { COMPONENT_BLOCK, TRY_BLOCK } from './constants.js';
|
|
|
51
51
|
|
|
52
52
|
export { escape };
|
|
53
53
|
export { register_component_css as register_css } from './css-registry.js';
|
|
54
|
-
export {
|
|
54
|
+
export { simpleHash as simple_hash, strongHash as strong_hash } from '@tsrx/core';
|
|
55
55
|
export { context } from './context.js';
|
|
56
56
|
export { try_block, component_block, regular_block } from './blocks.js';
|
|
57
57
|
export { array_slice };
|
package/src/runtime/proxy.js
CHANGED
|
@@ -30,13 +30,13 @@ export function proxy(value, block) {
|
|
|
30
30
|
TRACKED_ARRAY in value ||
|
|
31
31
|
TRACKED_OBJECT in value
|
|
32
32
|
) {
|
|
33
|
-
return value;
|
|
33
|
+
return /** @type {RippleArray<T> | RippleObject<T>} */ (value);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
const prototype = get_prototype_of(value);
|
|
37
37
|
|
|
38
38
|
if (prototype !== object_prototype && prototype !== array_prototype) {
|
|
39
|
-
return value;
|
|
39
|
+
return /** @type {RippleArray<T> | RippleObject<T>} */ (value);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
/** @type {Map<any,Tracked>} */
|
|
@@ -50,222 +50,224 @@ export function proxy(value, block) {
|
|
|
50
50
|
tracked_elements.set('length', tracked_len);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
return
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (t === undefined && (!exists || get_descriptor(target, prop)?.writable)) {
|
|
62
|
-
t = tracked(exists ? /** @type {any} */ (target)[prop] : UNINITIALIZED, block);
|
|
63
|
-
tracked_elements.set(prop, t);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (t !== undefined) {
|
|
67
|
-
var v = get(t);
|
|
68
|
-
return v === UNINITIALIZED ? undefined : v;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
var result = Reflect.get(target, prop, receiver);
|
|
72
|
-
|
|
73
|
-
if (typeof result === 'function') {
|
|
74
|
-
if (methods_returning_arrays.has(prop)) {
|
|
75
|
-
/** @type {(this: any, ...args: any[]) => any} */
|
|
76
|
-
return function (...args) {
|
|
77
|
-
var output = Reflect.apply(result, receiver, args);
|
|
78
|
-
|
|
79
|
-
if (Array.isArray(output) && output !== target) {
|
|
80
|
-
return array_proxy({ elements: output, block, use_array: true });
|
|
81
|
-
}
|
|
53
|
+
return /** @type {RippleArray<T> | RippleObject<T>} */ (
|
|
54
|
+
new Proxy(value, {
|
|
55
|
+
/**
|
|
56
|
+
* @param {PropertyKey} prop
|
|
57
|
+
*/
|
|
58
|
+
get(target, prop, receiver) {
|
|
59
|
+
var t = tracked_elements.get(prop);
|
|
60
|
+
var exists = prop in target;
|
|
82
61
|
|
|
83
|
-
|
|
84
|
-
};
|
|
62
|
+
if (t === undefined && (!exists || get_descriptor(target, prop)?.writable)) {
|
|
63
|
+
t = tracked(exists ? /** @type {any} */ (target)[prop] : UNINITIALIZED, block);
|
|
64
|
+
tracked_elements.set(prop, t);
|
|
85
65
|
}
|
|
86
66
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
67
|
+
if (t !== undefined) {
|
|
68
|
+
var v = get(t);
|
|
69
|
+
return v === UNINITIALIZED ? undefined : v;
|
|
90
70
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
// If the item exists in the original, we need to create a uninitialized tracked,
|
|
107
|
-
// else a later read of the property would result in a tracked being created with
|
|
108
|
-
// the value of the original item at that index.
|
|
109
|
-
other_t = tracked(UNINITIALIZED, block);
|
|
110
|
-
tracked_elements.set(i + '', other_t);
|
|
71
|
+
|
|
72
|
+
var result = Reflect.get(target, prop, receiver);
|
|
73
|
+
|
|
74
|
+
if (typeof result === 'function') {
|
|
75
|
+
if (methods_returning_arrays.has(prop)) {
|
|
76
|
+
/** @type {(this: any, ...args: any[]) => any} */
|
|
77
|
+
return function (...args) {
|
|
78
|
+
var output = Reflect.apply(result, receiver, args);
|
|
79
|
+
|
|
80
|
+
if (Array.isArray(output) && output !== target) {
|
|
81
|
+
return array_proxy({ elements: output, block, use_array: true });
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return output;
|
|
85
|
+
};
|
|
111
86
|
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// If we haven't yet created a tracked for this property, we need to ensure
|
|
116
|
-
// we do so otherwise if we read it later, then the write won't be tracked and
|
|
117
|
-
// the heuristics of effects will be different vs if we had read the proxied
|
|
118
|
-
// object property before writing to that property.
|
|
119
|
-
if (t === undefined) {
|
|
120
|
-
if (!exists || get_descriptor(target, prop)?.writable) {
|
|
121
|
-
t = tracked(undefined, block);
|
|
122
|
-
set(t, value);
|
|
123
87
|
|
|
124
|
-
|
|
88
|
+
// When generating an iterator, we need to ensure that length is tracked
|
|
89
|
+
if (is_proxied_array && (prop === 'entries' || prop === 'values' || prop === 'keys')) {
|
|
90
|
+
receiver.length;
|
|
91
|
+
}
|
|
125
92
|
}
|
|
126
|
-
} else {
|
|
127
|
-
exists = t.__v !== UNINITIALIZED;
|
|
128
93
|
|
|
129
|
-
|
|
130
|
-
}
|
|
94
|
+
return result;
|
|
95
|
+
},
|
|
131
96
|
|
|
132
|
-
|
|
97
|
+
set(target, prop, value, receiver) {
|
|
98
|
+
var t = tracked_elements.get(prop);
|
|
99
|
+
var exists = prop in target;
|
|
100
|
+
|
|
101
|
+
if (is_proxied_array && prop === 'length' && t !== undefined) {
|
|
102
|
+
for (var i = value; i < t.__v; i += 1) {
|
|
103
|
+
var other_t = tracked_elements.get(i + '');
|
|
104
|
+
if (other_t !== undefined) {
|
|
105
|
+
set(other_t, UNINITIALIZED);
|
|
106
|
+
} else if (i in target) {
|
|
107
|
+
// If the item exists in the original, we need to create a uninitialized tracked,
|
|
108
|
+
// else a later read of the property would result in a tracked being created with
|
|
109
|
+
// the value of the original item at that index.
|
|
110
|
+
other_t = tracked(UNINITIALIZED, block);
|
|
111
|
+
tracked_elements.set(i + '', other_t);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
133
115
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
116
|
+
// If we haven't yet created a tracked for this property, we need to ensure
|
|
117
|
+
// we do so otherwise if we read it later, then the write won't be tracked and
|
|
118
|
+
// the heuristics of effects will be different vs if we had read the proxied
|
|
119
|
+
// object property before writing to that property.
|
|
120
|
+
if (t === undefined) {
|
|
121
|
+
if (!exists || get_descriptor(target, prop)?.writable) {
|
|
122
|
+
t = tracked(undefined, block);
|
|
123
|
+
set(t, value);
|
|
138
124
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
// will not cause the length to be out of sync.
|
|
144
|
-
var n = Number(prop);
|
|
125
|
+
tracked_elements.set(prop, t);
|
|
126
|
+
}
|
|
127
|
+
} else {
|
|
128
|
+
exists = t.__v !== UNINITIALIZED;
|
|
145
129
|
|
|
146
|
-
|
|
147
|
-
set(tracked_len, n + 1);
|
|
130
|
+
set(t, value);
|
|
148
131
|
}
|
|
149
|
-
}
|
|
150
132
|
|
|
151
|
-
|
|
152
|
-
},
|
|
133
|
+
var descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
|
|
153
134
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
},
|
|
135
|
+
// Set the new value before updating any tracked's so that any listeners get the new value
|
|
136
|
+
if (descriptor?.set) {
|
|
137
|
+
descriptor.set.call(receiver, value);
|
|
138
|
+
}
|
|
159
139
|
|
|
160
|
-
|
|
161
|
-
|
|
140
|
+
if (!exists && is_proxied_array && typeof prop === 'string') {
|
|
141
|
+
// If we have mutated an array directly, we might need to
|
|
142
|
+
// signal that length has also changed. Do it before updating metadata
|
|
143
|
+
// to ensure that iterating over the array as a result of a metadata update
|
|
144
|
+
// will not cause the length to be out of sync.
|
|
145
|
+
var n = Number(prop);
|
|
162
146
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
tracked_elements.set(prop, t);
|
|
147
|
+
if (Number.isInteger(n) && n >= tracked_len.__v) {
|
|
148
|
+
set(tracked_len, n + 1);
|
|
149
|
+
}
|
|
167
150
|
}
|
|
168
|
-
} else {
|
|
169
|
-
set(t, UNINITIALIZED);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
return Reflect.deleteProperty(target, prop);
|
|
173
|
-
},
|
|
174
151
|
|
|
175
|
-
has(target, prop) {
|
|
176
|
-
if (is_proxied_array && prop === TRACKED_ARRAY) {
|
|
177
152
|
return true;
|
|
178
|
-
}
|
|
153
|
+
},
|
|
179
154
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
155
|
+
setPrototypeOf() {
|
|
156
|
+
throw new Error(
|
|
157
|
+
`Cannot set prototype of ${is_proxied_array ? '\`RippleArray\`' : '\`RippleObject\`'}`,
|
|
158
|
+
);
|
|
159
|
+
},
|
|
183
160
|
|
|
184
|
-
|
|
185
|
-
|
|
161
|
+
deleteProperty(target, prop) {
|
|
162
|
+
var t = tracked_elements.get(prop);
|
|
186
163
|
|
|
187
|
-
if (t !== undefined || !exists || get_descriptor(target, prop)?.writable) {
|
|
188
164
|
if (t === undefined) {
|
|
189
|
-
|
|
165
|
+
if (prop in target) {
|
|
166
|
+
const t = tracked(UNINITIALIZED, block);
|
|
167
|
+
tracked_elements.set(prop, t);
|
|
168
|
+
}
|
|
169
|
+
} else {
|
|
170
|
+
set(t, UNINITIALIZED);
|
|
171
|
+
}
|
|
190
172
|
|
|
191
|
-
|
|
173
|
+
return Reflect.deleteProperty(target, prop);
|
|
174
|
+
},
|
|
175
|
+
|
|
176
|
+
has(target, prop) {
|
|
177
|
+
if (is_proxied_array && prop === TRACKED_ARRAY) {
|
|
178
|
+
return true;
|
|
192
179
|
}
|
|
193
180
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
return false;
|
|
181
|
+
if (prop === TRACKED_OBJECT) {
|
|
182
|
+
return true;
|
|
197
183
|
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return exists;
|
|
201
|
-
},
|
|
202
|
-
|
|
203
|
-
defineProperty(_, prop, descriptor) {
|
|
204
|
-
if (
|
|
205
|
-
!('value' in descriptor) ||
|
|
206
|
-
descriptor.configurable === false ||
|
|
207
|
-
descriptor.enumerable === false ||
|
|
208
|
-
descriptor.writable === false
|
|
209
|
-
) {
|
|
210
|
-
// we disallow non-basic descriptors, because unless they are applied to the
|
|
211
|
-
// target object — which we avoid, so that state can be forked — we will run
|
|
212
|
-
// afoul of the various invariants
|
|
213
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/Proxy/getOwnPropertyDescriptor#invariants
|
|
214
|
-
throw new Error(
|
|
215
|
-
'Only basic property descriptors are supported with value and configurable, enumerable, and writable set to true',
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
184
|
|
|
219
|
-
|
|
185
|
+
var t = tracked_elements.get(prop);
|
|
186
|
+
var exists = (t !== undefined && t.__v !== UNINITIALIZED) || Reflect.has(target, prop);
|
|
220
187
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
} else {
|
|
225
|
-
set(t, descriptor.value);
|
|
226
|
-
}
|
|
188
|
+
if (t !== undefined || !exists || get_descriptor(target, prop)?.writable) {
|
|
189
|
+
if (t === undefined) {
|
|
190
|
+
t = tracked(exists ? /** @type {any} */ (target)[prop] : UNINITIALIZED, block);
|
|
227
191
|
|
|
228
|
-
|
|
229
|
-
|
|
192
|
+
tracked_elements.set(prop, t);
|
|
193
|
+
}
|
|
230
194
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
195
|
+
var value = get(t);
|
|
196
|
+
if (value === UNINITIALIZED) {
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
236
200
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
201
|
+
return exists;
|
|
202
|
+
},
|
|
203
|
+
|
|
204
|
+
defineProperty(_, prop, descriptor) {
|
|
205
|
+
if (
|
|
206
|
+
!('value' in descriptor) ||
|
|
207
|
+
descriptor.configurable === false ||
|
|
208
|
+
descriptor.enumerable === false ||
|
|
209
|
+
descriptor.writable === false
|
|
210
|
+
) {
|
|
211
|
+
// we disallow non-basic descriptors, because unless they are applied to the
|
|
212
|
+
// target object — which we avoid, so that state can be forked — we will run
|
|
213
|
+
// afoul of the various invariants
|
|
214
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/Proxy/getOwnPropertyDescriptor#invariants
|
|
215
|
+
throw new Error(
|
|
216
|
+
'Only basic property descriptors are supported with value and configurable, enumerable, and writable set to true',
|
|
217
|
+
);
|
|
240
218
|
}
|
|
241
|
-
}
|
|
242
219
|
|
|
243
|
-
|
|
244
|
-
},
|
|
220
|
+
var t = tracked_elements.get(prop);
|
|
245
221
|
|
|
246
|
-
|
|
247
|
-
|
|
222
|
+
if (t === undefined) {
|
|
223
|
+
t = tracked(descriptor.value, block);
|
|
224
|
+
tracked_elements.set(prop, t);
|
|
225
|
+
} else {
|
|
226
|
+
set(t, descriptor.value);
|
|
227
|
+
}
|
|
248
228
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
var
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
229
|
+
return true;
|
|
230
|
+
},
|
|
231
|
+
|
|
232
|
+
ownKeys(target) {
|
|
233
|
+
var own_keys = Reflect.ownKeys(target).filter((key) => {
|
|
234
|
+
var t = tracked_elements.get(key);
|
|
235
|
+
return t === undefined || t.__v !== UNINITIALIZED;
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
for (var [key, t] of tracked_elements) {
|
|
239
|
+
if (t.__v !== UNINITIALIZED && !(key in target)) {
|
|
240
|
+
own_keys.push(key);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return own_keys;
|
|
245
|
+
},
|
|
246
|
+
|
|
247
|
+
getOwnPropertyDescriptor(target, prop) {
|
|
248
|
+
var descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
|
|
249
|
+
|
|
250
|
+
if (descriptor && 'value' in descriptor) {
|
|
251
|
+
var t = tracked_elements.get(prop);
|
|
252
|
+
if (t) descriptor.value = get(t);
|
|
253
|
+
} else if (descriptor === undefined) {
|
|
254
|
+
var t = tracked_elements.get(prop);
|
|
255
|
+
var value = t?.__v;
|
|
256
|
+
|
|
257
|
+
if (t !== undefined && value !== UNINITIALIZED) {
|
|
258
|
+
return {
|
|
259
|
+
enumerable: true,
|
|
260
|
+
configurable: true,
|
|
261
|
+
value,
|
|
262
|
+
writable: true,
|
|
263
|
+
};
|
|
264
|
+
}
|
|
263
265
|
}
|
|
264
|
-
}
|
|
265
266
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
267
|
+
return descriptor;
|
|
268
|
+
},
|
|
269
|
+
})
|
|
270
|
+
);
|
|
269
271
|
}
|
|
270
272
|
|
|
271
273
|
/**
|
|
@@ -304,7 +306,7 @@ export function array_proxy({ elements, block, from_static = false, use_array =
|
|
|
304
306
|
* @returns {RippleObject<T>}
|
|
305
307
|
*/
|
|
306
308
|
export function object_proxy(obj, block) {
|
|
307
|
-
return proxy(obj, block);
|
|
309
|
+
return /** @type {RippleObject<T>} */ (proxy(obj, block));
|
|
308
310
|
}
|
|
309
311
|
|
|
310
312
|
/** @type {Set<PropertyKey>} */
|
|
@@ -74,7 +74,7 @@ describe('compiler > basics', () => {
|
|
|
74
74
|
}`;
|
|
75
75
|
|
|
76
76
|
expect(() => parse(invalid_source)).toThrow(
|
|
77
|
-
'"text" is a
|
|
77
|
+
'"text" is a TSRX keyword and must be used in the form {text some_value}',
|
|
78
78
|
);
|
|
79
79
|
});
|
|
80
80
|
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": "../../tsconfig.json",
|
|
3
3
|
"include": ["../../src/**/*", "../**/*"],
|
|
4
|
-
"exclude": [
|
|
5
|
-
"../server",
|
|
6
|
-
"../server.d.ts",
|
|
7
|
-
"../setup-server.js",
|
|
8
|
-
"../hydration",
|
|
9
|
-
"../setup-hydration.js"
|
|
10
|
-
]
|
|
4
|
+
"exclude": ["../server", "../setup-server.js", "../hydration", "../setup-hydration.js"]
|
|
11
5
|
}
|
|
@@ -11,6 +11,56 @@ describe('tsx expression', () => {
|
|
|
11
11
|
expect(container.querySelector('div')).toBeTruthy();
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
+
it('applies scoped classes inside tsx blocks and fragment shorthand', () => {
|
|
15
|
+
component App() {
|
|
16
|
+
<tsx>
|
|
17
|
+
<div class="card">
|
|
18
|
+
<h2>
|
|
19
|
+
{'tsx block'}
|
|
20
|
+
</h2>
|
|
21
|
+
</div>
|
|
22
|
+
</tsx>
|
|
23
|
+
|
|
24
|
+
<>
|
|
25
|
+
<div class="card">
|
|
26
|
+
<h2>
|
|
27
|
+
{'fragment shorthand'}
|
|
28
|
+
</h2>
|
|
29
|
+
</div>
|
|
30
|
+
</>
|
|
31
|
+
|
|
32
|
+
<style>
|
|
33
|
+
.card {
|
|
34
|
+
padding: 1rem;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
h2 {
|
|
38
|
+
color: red;
|
|
39
|
+
}
|
|
40
|
+
</style>
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
render(App);
|
|
44
|
+
|
|
45
|
+
const cards = Array.from(container.querySelectorAll('.card'));
|
|
46
|
+
const headings = Array.from(container.querySelectorAll('h2'));
|
|
47
|
+
|
|
48
|
+
expect(cards).toHaveLength(2);
|
|
49
|
+
expect(headings).toHaveLength(2);
|
|
50
|
+
|
|
51
|
+
cards.forEach((card) => {
|
|
52
|
+
expect(
|
|
53
|
+
Array.from(card.classList).filter((className) => className.startsWith('tsrx-')),
|
|
54
|
+
).toHaveLength(1);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
headings.forEach((heading) => {
|
|
58
|
+
expect(
|
|
59
|
+
Array.from(heading.classList).filter((className) => className.startsWith('tsrx-')),
|
|
60
|
+
).toHaveLength(1);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
14
64
|
it('renders a tsx element assigned to a variable', () => {
|
|
15
65
|
component App() {
|
|
16
66
|
const el = <tsx><span class="test">content</span></tsx>;
|
|
@@ -22,7 +22,7 @@ export function StaticTitle(__anchor, _, __block) {
|
|
|
22
22
|
|
|
23
23
|
var div_1 = root();
|
|
24
24
|
|
|
25
|
-
_$_.head('
|
|
25
|
+
_$_.head('c8908187', (__anchor) => {
|
|
26
26
|
_$_.document.title = 'Static Test Title';
|
|
27
27
|
});
|
|
28
28
|
|
|
@@ -47,7 +47,7 @@ export function ReactiveTitle(__anchor, _, __block) {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
_$_.head('
|
|
50
|
+
_$_.head('8af28792', (__anchor) => {
|
|
51
51
|
_$_.render(() => {
|
|
52
52
|
_$_.document.title = _$_.get(lazy);
|
|
53
53
|
});
|
|
@@ -62,7 +62,7 @@ export function MultipleHeadElements(__anchor, _, __block) {
|
|
|
62
62
|
|
|
63
63
|
var div_3 = root_2();
|
|
64
64
|
|
|
65
|
-
_$_.head('
|
|
65
|
+
_$_.head('3a79945b', (__anchor) => {
|
|
66
66
|
var fragment = root_3();
|
|
67
67
|
|
|
68
68
|
_$_.document.title = 'Page Title';
|
|
@@ -87,7 +87,7 @@ export function ReactiveMetaTags(__anchor, _, __block) {
|
|
|
87
87
|
_$_.pop(div_4);
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
_$_.head('
|
|
90
|
+
_$_.head('c9fd7b0f', (__anchor) => {
|
|
91
91
|
var meta_1 = root_5();
|
|
92
92
|
|
|
93
93
|
_$_.document.title = 'My Page';
|
|
@@ -112,7 +112,7 @@ export function TitleWithTemplate(__anchor, _, __block) {
|
|
|
112
112
|
_$_.pop(div_5);
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
_$_.head('
|
|
115
|
+
_$_.head('72f81455', (__anchor) => {
|
|
116
116
|
_$_.render(() => {
|
|
117
117
|
_$_.document.title = `Hello ${_$_.get(lazy_2)}!`;
|
|
118
118
|
});
|
|
@@ -127,7 +127,7 @@ export function EmptyTitle(__anchor, _, __block) {
|
|
|
127
127
|
|
|
128
128
|
var div_6 = root_7();
|
|
129
129
|
|
|
130
|
-
_$_.head('
|
|
130
|
+
_$_.head('35a7fe4a', (__anchor) => {
|
|
131
131
|
_$_.document.title = '';
|
|
132
132
|
});
|
|
133
133
|
|
|
@@ -149,7 +149,7 @@ export function ConditionalTitle(__anchor, _, __block) {
|
|
|
149
149
|
_$_.pop(div_7);
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
_$_.head('
|
|
152
|
+
_$_.head('453e9ed4', (__anchor) => {
|
|
153
153
|
_$_.render(() => {
|
|
154
154
|
_$_.document.title = _$_.get(lazy_3) ? 'App - ' + _$_.get(lazy_4) : _$_.get(lazy_4);
|
|
155
155
|
});
|
|
@@ -177,7 +177,7 @@ export function ComputedTitle(__anchor, _, __block) {
|
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
-
_$_.head('
|
|
180
|
+
_$_.head('63888c83', (__anchor) => {
|
|
181
181
|
_$_.render(() => {
|
|
182
182
|
_$_.document.title = prefix + _$_.get(lazy_5);
|
|
183
183
|
});
|
|
@@ -192,11 +192,11 @@ export function MultipleHeadBlocks(__anchor, _, __block) {
|
|
|
192
192
|
|
|
193
193
|
var div_9 = root_10();
|
|
194
194
|
|
|
195
|
-
_$_.head('
|
|
195
|
+
_$_.head('43cf39fd', (__anchor) => {
|
|
196
196
|
_$_.document.title = 'First Head';
|
|
197
197
|
});
|
|
198
198
|
|
|
199
|
-
_$_.head('
|
|
199
|
+
_$_.head('e9abd92f', (__anchor) => {
|
|
200
200
|
var meta_2 = root_11();
|
|
201
201
|
|
|
202
202
|
_$_.append(__anchor, meta_2);
|
|
@@ -211,7 +211,7 @@ export function HeadWithStyle(__anchor, _, __block) {
|
|
|
211
211
|
|
|
212
212
|
var div_10 = root_12();
|
|
213
213
|
|
|
214
|
-
_$_.head('
|
|
214
|
+
_$_.head('d246667e', (__anchor) => {
|
|
215
215
|
_$_.document.title = 'Styled Page';
|
|
216
216
|
});
|
|
217
217
|
|
|
@@ -18,7 +18,7 @@ export function StaticTitle() {
|
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
_$_.set_output_target('head');
|
|
21
|
-
_$_.output_push('<!--
|
|
21
|
+
_$_.output_push('<!--c8908187-->');
|
|
22
22
|
_$_.output_push('<title');
|
|
23
23
|
_$_.output_push('>');
|
|
24
24
|
|
|
@@ -55,7 +55,7 @@ export function ReactiveTitle() {
|
|
|
55
55
|
});
|
|
56
56
|
|
|
57
57
|
_$_.set_output_target('head');
|
|
58
|
-
_$_.output_push('<!--
|
|
58
|
+
_$_.output_push('<!--8af28792-->');
|
|
59
59
|
_$_.output_push('<title');
|
|
60
60
|
_$_.output_push('>');
|
|
61
61
|
|
|
@@ -83,7 +83,7 @@ export function MultipleHeadElements() {
|
|
|
83
83
|
});
|
|
84
84
|
|
|
85
85
|
_$_.set_output_target('head');
|
|
86
|
-
_$_.output_push('<!--
|
|
86
|
+
_$_.output_push('<!--3a79945b-->');
|
|
87
87
|
_$_.output_push('<title');
|
|
88
88
|
_$_.output_push('>');
|
|
89
89
|
|
|
@@ -121,7 +121,7 @@ export function ReactiveMetaTags() {
|
|
|
121
121
|
});
|
|
122
122
|
|
|
123
123
|
_$_.set_output_target('head');
|
|
124
|
-
_$_.output_push('<!--
|
|
124
|
+
_$_.output_push('<!--c9fd7b0f-->');
|
|
125
125
|
_$_.output_push('<title');
|
|
126
126
|
_$_.output_push('>');
|
|
127
127
|
|
|
@@ -155,7 +155,7 @@ export function TitleWithTemplate() {
|
|
|
155
155
|
});
|
|
156
156
|
|
|
157
157
|
_$_.set_output_target('head');
|
|
158
|
-
_$_.output_push('<!--
|
|
158
|
+
_$_.output_push('<!--72f81455-->');
|
|
159
159
|
_$_.output_push('<title');
|
|
160
160
|
_$_.output_push('>');
|
|
161
161
|
|
|
@@ -183,7 +183,7 @@ export function EmptyTitle() {
|
|
|
183
183
|
});
|
|
184
184
|
|
|
185
185
|
_$_.set_output_target('head');
|
|
186
|
-
_$_.output_push('<!--
|
|
186
|
+
_$_.output_push('<!--35a7fe4a-->');
|
|
187
187
|
_$_.output_push('<title');
|
|
188
188
|
_$_.output_push('>');
|
|
189
189
|
|
|
@@ -214,7 +214,7 @@ export function ConditionalTitle() {
|
|
|
214
214
|
});
|
|
215
215
|
|
|
216
216
|
_$_.set_output_target('head');
|
|
217
|
-
_$_.output_push('<!--
|
|
217
|
+
_$_.output_push('<!--453e9ed4-->');
|
|
218
218
|
_$_.output_push('<title');
|
|
219
219
|
_$_.output_push('>');
|
|
220
220
|
|
|
@@ -252,7 +252,7 @@ export function ComputedTitle() {
|
|
|
252
252
|
});
|
|
253
253
|
|
|
254
254
|
_$_.set_output_target('head');
|
|
255
|
-
_$_.output_push('<!--
|
|
255
|
+
_$_.output_push('<!--63888c83-->');
|
|
256
256
|
_$_.output_push('<title');
|
|
257
257
|
_$_.output_push('>');
|
|
258
258
|
|
|
@@ -280,7 +280,7 @@ export function MultipleHeadBlocks() {
|
|
|
280
280
|
});
|
|
281
281
|
|
|
282
282
|
_$_.set_output_target('head');
|
|
283
|
-
_$_.output_push('<!--
|
|
283
|
+
_$_.output_push('<!--43cf39fd-->');
|
|
284
284
|
_$_.output_push('<title');
|
|
285
285
|
_$_.output_push('>');
|
|
286
286
|
|
|
@@ -289,7 +289,7 @@ export function MultipleHeadBlocks() {
|
|
|
289
289
|
}
|
|
290
290
|
|
|
291
291
|
_$_.output_push('</title>');
|
|
292
|
-
_$_.output_push('<!--
|
|
292
|
+
_$_.output_push('<!--e9abd92f-->');
|
|
293
293
|
_$_.output_push('<meta');
|
|
294
294
|
_$_.output_push(' name="author"');
|
|
295
295
|
_$_.output_push(' content="Test Author"');
|
|
@@ -313,7 +313,7 @@ export function HeadWithStyle() {
|
|
|
313
313
|
});
|
|
314
314
|
|
|
315
315
|
_$_.set_output_target('head');
|
|
316
|
-
_$_.output_push('<!--
|
|
316
|
+
_$_.output_push('<!--d246667e-->');
|
|
317
317
|
_$_.output_push('<title');
|
|
318
318
|
_$_.output_push('>');
|
|
319
319
|
|
|
@@ -14,7 +14,7 @@ export function SimpleTemplateHtml() {
|
|
|
14
14
|
{
|
|
15
15
|
const html_value = String(data ?? '');
|
|
16
16
|
|
|
17
|
-
_$_.output_push('<!--' + _$_.
|
|
17
|
+
_$_.output_push('<!--' + _$_.simple_hash(html_value) + '-->');
|
|
18
18
|
_$_.output_push(html_value);
|
|
19
19
|
_$_.output_push('<!---->');
|
|
20
20
|
}
|
|
@@ -38,7 +38,7 @@ export function TemplateWithJSON() {
|
|
|
38
38
|
{
|
|
39
39
|
const html_value_1 = String(jsonData ?? '');
|
|
40
40
|
|
|
41
|
-
_$_.output_push('<!--' + _$_.
|
|
41
|
+
_$_.output_push('<!--' + _$_.simple_hash(html_value_1) + '-->');
|
|
42
42
|
_$_.output_push(html_value_1);
|
|
43
43
|
_$_.output_push('<!---->');
|
|
44
44
|
}
|
|
@@ -15,7 +15,7 @@ export function StaticHtml() {
|
|
|
15
15
|
{
|
|
16
16
|
const html_value = String(html ?? '');
|
|
17
17
|
|
|
18
|
-
_$_.output_push('<!--' + _$_.
|
|
18
|
+
_$_.output_push('<!--' + _$_.simple_hash(html_value) + '-->');
|
|
19
19
|
_$_.output_push(html_value);
|
|
20
20
|
_$_.output_push('<!---->');
|
|
21
21
|
}
|
|
@@ -38,7 +38,7 @@ export function DynamicHtml() {
|
|
|
38
38
|
{
|
|
39
39
|
const html_value_1 = String(content ?? '');
|
|
40
40
|
|
|
41
|
-
_$_.output_push('<!--' + _$_.
|
|
41
|
+
_$_.output_push('<!--' + _$_.simple_hash(html_value_1) + '-->');
|
|
42
42
|
_$_.output_push(html_value_1);
|
|
43
43
|
_$_.output_push('<!---->');
|
|
44
44
|
}
|
|
@@ -61,7 +61,7 @@ export function EmptyHtml() {
|
|
|
61
61
|
{
|
|
62
62
|
const html_value_2 = String(html ?? '');
|
|
63
63
|
|
|
64
|
-
_$_.output_push('<!--' + _$_.
|
|
64
|
+
_$_.output_push('<!--' + _$_.simple_hash(html_value_2) + '-->');
|
|
65
65
|
_$_.output_push(html_value_2);
|
|
66
66
|
_$_.output_push('<!---->');
|
|
67
67
|
}
|
|
@@ -84,7 +84,7 @@ export function ComplexHtml() {
|
|
|
84
84
|
{
|
|
85
85
|
const html_value_3 = String(html ?? '');
|
|
86
86
|
|
|
87
|
-
_$_.output_push('<!--' + _$_.
|
|
87
|
+
_$_.output_push('<!--' + _$_.simple_hash(html_value_3) + '-->');
|
|
88
88
|
_$_.output_push(html_value_3);
|
|
89
89
|
_$_.output_push('<!---->');
|
|
90
90
|
}
|
|
@@ -108,13 +108,13 @@ export function MultipleHtml() {
|
|
|
108
108
|
{
|
|
109
109
|
const html_value_4 = String(html1 ?? '');
|
|
110
110
|
|
|
111
|
-
_$_.output_push('<!--' + _$_.
|
|
111
|
+
_$_.output_push('<!--' + _$_.simple_hash(html_value_4) + '-->');
|
|
112
112
|
_$_.output_push(html_value_4);
|
|
113
113
|
_$_.output_push('<!---->');
|
|
114
114
|
|
|
115
115
|
const html_value_5 = String(html2 ?? '');
|
|
116
116
|
|
|
117
|
-
_$_.output_push('<!--' + _$_.
|
|
117
|
+
_$_.output_push('<!--' + _$_.simple_hash(html_value_5) + '-->');
|
|
118
118
|
_$_.output_push(html_value_5);
|
|
119
119
|
_$_.output_push('<!---->');
|
|
120
120
|
}
|
|
@@ -198,7 +198,7 @@ export function HtmlInChildren() {
|
|
|
198
198
|
{
|
|
199
199
|
const html_value_6 = String(content ?? '');
|
|
200
200
|
|
|
201
|
-
_$_.output_push('<!--' + _$_.
|
|
201
|
+
_$_.output_push('<!--' + _$_.simple_hash(html_value_6) + '-->');
|
|
202
202
|
_$_.output_push(html_value_6);
|
|
203
203
|
_$_.output_push('<!---->');
|
|
204
204
|
}
|
|
@@ -244,7 +244,7 @@ export function HtmlInChildrenWithSiblings() {
|
|
|
244
244
|
{
|
|
245
245
|
const html_value_7 = String(content ?? '');
|
|
246
246
|
|
|
247
|
-
_$_.output_push('<!--' + _$_.
|
|
247
|
+
_$_.output_push('<!--' + _$_.simple_hash(html_value_7) + '-->');
|
|
248
248
|
_$_.output_push(html_value_7);
|
|
249
249
|
_$_.output_push('<!---->');
|
|
250
250
|
}
|
|
@@ -283,13 +283,13 @@ export function MultipleHtmlInChildren() {
|
|
|
283
283
|
{
|
|
284
284
|
const html_value_8 = String(html1 ?? '');
|
|
285
285
|
|
|
286
|
-
_$_.output_push('<!--' + _$_.
|
|
286
|
+
_$_.output_push('<!--' + _$_.simple_hash(html_value_8) + '-->');
|
|
287
287
|
_$_.output_push(html_value_8);
|
|
288
288
|
_$_.output_push('<!---->');
|
|
289
289
|
|
|
290
290
|
const html_value_9 = String(html2 ?? '');
|
|
291
291
|
|
|
292
|
-
_$_.output_push('<!--' + _$_.
|
|
292
|
+
_$_.output_push('<!--' + _$_.simple_hash(html_value_9) + '-->');
|
|
293
293
|
_$_.output_push(html_value_9);
|
|
294
294
|
_$_.output_push('<!---->');
|
|
295
295
|
}
|
|
@@ -319,7 +319,7 @@ export function HtmlWithComments() {
|
|
|
319
319
|
{
|
|
320
320
|
const html_value_10 = String(content ?? '');
|
|
321
321
|
|
|
322
|
-
_$_.output_push('<!--' + _$_.
|
|
322
|
+
_$_.output_push('<!--' + _$_.simple_hash(html_value_10) + '-->');
|
|
323
323
|
_$_.output_push(html_value_10);
|
|
324
324
|
_$_.output_push('<!---->');
|
|
325
325
|
}
|
|
@@ -342,7 +342,7 @@ export function HtmlWithEmptyComment() {
|
|
|
342
342
|
{
|
|
343
343
|
const html_value_11 = String(content ?? '');
|
|
344
344
|
|
|
345
|
-
_$_.output_push('<!--' + _$_.
|
|
345
|
+
_$_.output_push('<!--' + _$_.simple_hash(html_value_11) + '-->');
|
|
346
346
|
_$_.output_push(html_value_11);
|
|
347
347
|
_$_.output_push('<!---->');
|
|
348
348
|
}
|
|
@@ -373,7 +373,7 @@ export function HtmlWithCommentsInChildren() {
|
|
|
373
373
|
{
|
|
374
374
|
const html_value_12 = String(content ?? '');
|
|
375
375
|
|
|
376
|
-
_$_.output_push('<!--' + _$_.
|
|
376
|
+
_$_.output_push('<!--' + _$_.simple_hash(html_value_12) + '-->');
|
|
377
377
|
_$_.output_push(html_value_12);
|
|
378
378
|
_$_.output_push('<!---->');
|
|
379
379
|
}
|
|
@@ -579,7 +579,7 @@ export function HtmlWithServerData() {
|
|
|
579
579
|
{
|
|
580
580
|
const html_value_13 = String(content ?? '');
|
|
581
581
|
|
|
582
|
-
_$_.output_push('<!--' + _$_.
|
|
582
|
+
_$_.output_push('<!--' + _$_.simple_hash(html_value_13) + '-->');
|
|
583
583
|
_$_.output_push(html_value_13);
|
|
584
584
|
_$_.output_push('<!---->');
|
|
585
585
|
}
|
|
@@ -617,7 +617,7 @@ export function HtmlWithClientDefaults() {
|
|
|
617
617
|
{
|
|
618
618
|
const html_value_14 = String(content ?? '');
|
|
619
619
|
|
|
620
|
-
_$_.output_push('<!--' + _$_.
|
|
620
|
+
_$_.output_push('<!--' + _$_.simple_hash(html_value_14) + '-->');
|
|
621
621
|
_$_.output_push(html_value_14);
|
|
622
622
|
_$_.output_push('<!---->');
|
|
623
623
|
}
|
|
@@ -655,7 +655,7 @@ export function HtmlWithUndefinedContent() {
|
|
|
655
655
|
{
|
|
656
656
|
const html_value_15 = String(content ?? '');
|
|
657
657
|
|
|
658
|
-
_$_.output_push('<!--' + _$_.
|
|
658
|
+
_$_.output_push('<!--' + _$_.simple_hash(html_value_15) + '-->');
|
|
659
659
|
_$_.output_push(html_value_15);
|
|
660
660
|
_$_.output_push('<!---->');
|
|
661
661
|
}
|
|
@@ -748,7 +748,7 @@ function CodeBlock({ code }) {
|
|
|
748
748
|
{
|
|
749
749
|
const html_value_16 = String(highlighted ?? '');
|
|
750
750
|
|
|
751
|
-
_$_.output_push('<!--' + _$_.
|
|
751
|
+
_$_.output_push('<!--' + _$_.simple_hash(html_value_16) + '-->');
|
|
752
752
|
_$_.output_push(html_value_16);
|
|
753
753
|
_$_.output_push('<!---->');
|
|
754
754
|
}
|
|
@@ -1393,7 +1393,7 @@ export function ArticleWithHtmlChildThenSibling() {
|
|
|
1393
1393
|
{
|
|
1394
1394
|
const html_value_17 = String(htmlContent ?? '');
|
|
1395
1395
|
|
|
1396
|
-
_$_.output_push('<!--' + _$_.
|
|
1396
|
+
_$_.output_push('<!--' + _$_.simple_hash(html_value_17) + '-->');
|
|
1397
1397
|
_$_.output_push(html_value_17);
|
|
1398
1398
|
_$_.output_push('<!---->');
|
|
1399
1399
|
}
|
|
@@ -1528,7 +1528,7 @@ export function InlineArticleWithHtmlChild() {
|
|
|
1528
1528
|
{
|
|
1529
1529
|
const html_value_18 = String(htmlContent ?? '');
|
|
1530
1530
|
|
|
1531
|
-
_$_.output_push('<!--' + _$_.
|
|
1531
|
+
_$_.output_push('<!--' + _$_.simple_hash(html_value_18) + '-->');
|
|
1532
1532
|
_$_.output_push(html_value_18);
|
|
1533
1533
|
_$_.output_push('<!---->');
|
|
1534
1534
|
}
|
|
@@ -1762,7 +1762,7 @@ export function DocsLayoutWithData() {
|
|
|
1762
1762
|
{
|
|
1763
1763
|
const html_value_19 = String(htmlContent ?? '');
|
|
1764
1764
|
|
|
1765
|
-
_$_.output_push('<!--' + _$_.
|
|
1765
|
+
_$_.output_push('<!--' + _$_.simple_hash(html_value_19) + '-->');
|
|
1766
1766
|
_$_.output_push(html_value_19);
|
|
1767
1767
|
_$_.output_push('<!---->');
|
|
1768
1768
|
}
|
|
@@ -1800,7 +1800,7 @@ export function DocsLayoutWithoutData() {
|
|
|
1800
1800
|
{
|
|
1801
1801
|
const html_value_20 = String(htmlContent ?? '');
|
|
1802
1802
|
|
|
1803
|
-
_$_.output_push('<!--' + _$_.
|
|
1803
|
+
_$_.output_push('<!--' + _$_.simple_hash(html_value_20) + '-->');
|
|
1804
1804
|
_$_.output_push(html_value_20);
|
|
1805
1805
|
_$_.output_push('<!---->');
|
|
1806
1806
|
}
|
|
@@ -2082,7 +2082,7 @@ export function DocsLayoutExactWithData() {
|
|
|
2082
2082
|
{
|
|
2083
2083
|
const html_value_21 = String(htmlContent ?? '');
|
|
2084
2084
|
|
|
2085
|
-
_$_.output_push('<!--' + _$_.
|
|
2085
|
+
_$_.output_push('<!--' + _$_.simple_hash(html_value_21) + '-->');
|
|
2086
2086
|
_$_.output_push(html_value_21);
|
|
2087
2087
|
_$_.output_push('<!---->');
|
|
2088
2088
|
}
|
|
@@ -2128,7 +2128,7 @@ export function DocsLayoutExactWithoutData() {
|
|
|
2128
2128
|
{
|
|
2129
2129
|
const html_value_22 = String(htmlContent ?? '');
|
|
2130
2130
|
|
|
2131
|
-
_$_.output_push('<!--' + _$_.
|
|
2131
|
+
_$_.output_push('<!--' + _$_.simple_hash(html_value_22) + '-->');
|
|
2132
2132
|
_$_.output_push(html_value_22);
|
|
2133
2133
|
_$_.output_push('<!---->');
|
|
2134
2134
|
}
|
|
@@ -2163,7 +2163,7 @@ export function TemplateWithHtmlContent() {
|
|
|
2163
2163
|
{
|
|
2164
2164
|
const html_value_23 = String(JSON.stringify(data) ?? '');
|
|
2165
2165
|
|
|
2166
|
-
_$_.output_push('<!--' + _$_.
|
|
2166
|
+
_$_.output_push('<!--' + _$_.simple_hash(html_value_23) + '-->');
|
|
2167
2167
|
_$_.output_push(html_value_23);
|
|
2168
2168
|
_$_.output_push('<!---->');
|
|
2169
2169
|
}
|
|
@@ -2212,7 +2212,7 @@ export function TemplateWithHtmlAndSiblings() {
|
|
|
2212
2212
|
{
|
|
2213
2213
|
const html_value_24 = String(JSON.stringify(data) ?? '');
|
|
2214
2214
|
|
|
2215
|
-
_$_.output_push('<!--' + _$_.
|
|
2215
|
+
_$_.output_push('<!--' + _$_.simple_hash(html_value_24) + '-->');
|
|
2216
2216
|
_$_.output_push(html_value_24);
|
|
2217
2217
|
_$_.output_push('<!---->');
|
|
2218
2218
|
}
|
|
@@ -2251,7 +2251,7 @@ function LayoutWithTemplate({ children, data }) {
|
|
|
2251
2251
|
{
|
|
2252
2252
|
const html_value_25 = String(JSON.stringify(data) ?? '');
|
|
2253
2253
|
|
|
2254
|
-
_$_.output_push('<!--' + _$_.
|
|
2254
|
+
_$_.output_push('<!--' + _$_.simple_hash(html_value_25) + '-->');
|
|
2255
2255
|
_$_.output_push(html_value_25);
|
|
2256
2256
|
_$_.output_push('<!---->');
|
|
2257
2257
|
}
|
|
@@ -2294,7 +2294,7 @@ export function NestedTemplateInLayout() {
|
|
|
2294
2294
|
{
|
|
2295
2295
|
const html_value_26 = String(doc.html ?? '');
|
|
2296
2296
|
|
|
2297
|
-
_$_.output_push('<!--' + _$_.
|
|
2297
|
+
_$_.output_push('<!--' + _$_.simple_hash(html_value_26) + '-->');
|
|
2298
2298
|
_$_.output_push(html_value_26);
|
|
2299
2299
|
_$_.output_push('<!---->');
|
|
2300
2300
|
}
|
|
@@ -2368,7 +2368,7 @@ export function HtmlCodeBlocksWithSiblingChain() {
|
|
|
2368
2368
|
{
|
|
2369
2369
|
const html_value_27 = String(html1 ?? '');
|
|
2370
2370
|
|
|
2371
|
-
_$_.output_push('<!--' + _$_.
|
|
2371
|
+
_$_.output_push('<!--' + _$_.simple_hash(html_value_27) + '-->');
|
|
2372
2372
|
_$_.output_push(html_value_27);
|
|
2373
2373
|
_$_.output_push('<!---->');
|
|
2374
2374
|
}
|
|
@@ -2396,7 +2396,7 @@ export function HtmlCodeBlocksWithSiblingChain() {
|
|
|
2396
2396
|
{
|
|
2397
2397
|
const html_value_28 = String(html2 ?? '');
|
|
2398
2398
|
|
|
2399
|
-
_$_.output_push('<!--' + _$_.
|
|
2399
|
+
_$_.output_push('<!--' + _$_.simple_hash(html_value_28) + '-->');
|
|
2400
2400
|
_$_.output_push(html_value_28);
|
|
2401
2401
|
_$_.output_push('<!---->');
|
|
2402
2402
|
}
|
|
@@ -2424,7 +2424,7 @@ export function HtmlCodeBlocksWithSiblingChain() {
|
|
|
2424
2424
|
{
|
|
2425
2425
|
const html_value_29 = String(html3 ?? '');
|
|
2426
2426
|
|
|
2427
|
-
_$_.output_push('<!--' + _$_.
|
|
2427
|
+
_$_.output_push('<!--' + _$_.simple_hash(html_value_29) + '-->');
|
|
2428
2428
|
_$_.output_push(html_value_29);
|
|
2429
2429
|
_$_.output_push('<!---->');
|
|
2430
2430
|
}
|
|
@@ -413,7 +413,9 @@ component TodoItem(props: { id: number; text: string }) {
|
|
|
413
413
|
done = (e.target as HTMLInputElement).checked;
|
|
414
414
|
}}
|
|
415
415
|
/>
|
|
416
|
-
<span class={done ? 'completed' : 'pending'}>
|
|
416
|
+
<span class={done ? 'completed' : 'pending'}>
|
|
417
|
+
{props.text}
|
|
418
|
+
</span>
|
|
417
419
|
</div>
|
|
418
420
|
}
|
|
419
421
|
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": "../../tsconfig.json",
|
|
3
3
|
"include": ["../../src/**/*", "../**/*"],
|
|
4
|
-
"exclude": [
|
|
5
|
-
"../client",
|
|
6
|
-
"../client.d.ts",
|
|
7
|
-
"../setup-client.js",
|
|
8
|
-
"../server",
|
|
9
|
-
"../server.d.ts",
|
|
10
|
-
"../setup-server.js"
|
|
11
|
-
]
|
|
4
|
+
"exclude": ["../client", "../setup-client.js", "../server", "../setup-server.js"]
|
|
12
5
|
}
|
|
@@ -35,7 +35,9 @@ describe('basic server > attribute rendering', () => {
|
|
|
35
35
|
|
|
36
36
|
const div = document.querySelector('div');
|
|
37
37
|
|
|
38
|
-
expect(
|
|
38
|
+
expect(
|
|
39
|
+
Array.from(div.classList).filter((className) => className.startsWith('tsrx-')),
|
|
40
|
+
).toHaveLength(1);
|
|
39
41
|
expect(div.classList.contains('inactive')).toBe(true);
|
|
40
42
|
});
|
|
41
43
|
|
|
@@ -70,7 +72,9 @@ describe('basic server > attribute rendering', () => {
|
|
|
70
72
|
|
|
71
73
|
const div = document.querySelector('div');
|
|
72
74
|
|
|
73
|
-
expect(
|
|
75
|
+
expect(
|
|
76
|
+
Array.from(div.classList).filter((className) => className.startsWith('tsrx-')),
|
|
77
|
+
).toHaveLength(1);
|
|
74
78
|
|
|
75
79
|
expect(div.classList.contains('foo')).toBe(true);
|
|
76
80
|
expect(div.classList.contains('bar')).toBe(true);
|
|
@@ -83,6 +87,57 @@ describe('basic server > attribute rendering', () => {
|
|
|
83
87
|
expect(div.classList.contains('fff')).toBe(false);
|
|
84
88
|
});
|
|
85
89
|
|
|
90
|
+
it('applies scoped classes inside tsx blocks and fragment shorthand', async () => {
|
|
91
|
+
component App() {
|
|
92
|
+
<tsx>
|
|
93
|
+
<div class="card">
|
|
94
|
+
<h2>
|
|
95
|
+
{'tsx block'}
|
|
96
|
+
</h2>
|
|
97
|
+
</div>
|
|
98
|
+
</tsx>
|
|
99
|
+
|
|
100
|
+
<>
|
|
101
|
+
<div class="card">
|
|
102
|
+
<h2>
|
|
103
|
+
{'fragment shorthand'}
|
|
104
|
+
</h2>
|
|
105
|
+
</div>
|
|
106
|
+
</>
|
|
107
|
+
|
|
108
|
+
<style>
|
|
109
|
+
.card {
|
|
110
|
+
padding: 1rem;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
h2 {
|
|
114
|
+
color: red;
|
|
115
|
+
}
|
|
116
|
+
</style>
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const { body } = await render(App);
|
|
120
|
+
const { document } = parseHtml(body);
|
|
121
|
+
|
|
122
|
+
const cards = Array.from(document.querySelectorAll('.card'));
|
|
123
|
+
const headings = Array.from(document.querySelectorAll('h2'));
|
|
124
|
+
|
|
125
|
+
expect(cards).toHaveLength(2);
|
|
126
|
+
expect(headings).toHaveLength(2);
|
|
127
|
+
|
|
128
|
+
cards.forEach((card) => {
|
|
129
|
+
expect(
|
|
130
|
+
Array.from(card.classList).filter((className) => className.startsWith('tsrx-')),
|
|
131
|
+
).toHaveLength(1);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
headings.forEach((heading) => {
|
|
135
|
+
expect(
|
|
136
|
+
Array.from(heading.classList).filter((className) => className.startsWith('tsrx-')),
|
|
137
|
+
).toHaveLength(1);
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
|
|
86
141
|
it('render dynamic class object', async () => {
|
|
87
142
|
component Basic() {
|
|
88
143
|
let &[active] = track(false);
|
|
@@ -101,7 +156,9 @@ describe('basic server > attribute rendering', () => {
|
|
|
101
156
|
|
|
102
157
|
const div = document.querySelector('div');
|
|
103
158
|
|
|
104
|
-
expect(
|
|
159
|
+
expect(
|
|
160
|
+
Array.from(div.classList).filter((className) => className.startsWith('tsrx-')),
|
|
161
|
+
).toHaveLength(1);
|
|
105
162
|
expect(div.classList.contains('inactive')).toBe(true);
|
|
106
163
|
expect(div.classList.contains('active')).toBe(false);
|
|
107
164
|
});
|
|
@@ -132,9 +189,9 @@ describe('basic server > attribute rendering', () => {
|
|
|
132
189
|
const divs = document.querySelectorAll('div');
|
|
133
190
|
|
|
134
191
|
divs.forEach((div) => {
|
|
135
|
-
expect(
|
|
136
|
-
|
|
137
|
-
);
|
|
192
|
+
expect(
|
|
193
|
+
Array.from(div.classList).filter((className) => className.startsWith('tsrx-')),
|
|
194
|
+
).toHaveLength(1);
|
|
138
195
|
});
|
|
139
196
|
},
|
|
140
197
|
);
|
|
@@ -204,7 +261,10 @@ describe('basic server > attribute rendering', () => {
|
|
|
204
261
|
|
|
205
262
|
it('render tracked object as style attribute', async () => {
|
|
206
263
|
component Basic() {
|
|
207
|
-
let style = new RippleObject({
|
|
264
|
+
let style = new RippleObject({
|
|
265
|
+
color: 'red',
|
|
266
|
+
fontWeight: 'bold',
|
|
267
|
+
});
|
|
208
268
|
|
|
209
269
|
<div style={{ color: style.color, fontWeight: style.fontWeight }}>{'Dynamic Style'}</div>
|
|
210
270
|
}
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": "../../tsconfig.json",
|
|
3
3
|
"include": ["../../src/**/*", "../**/*"],
|
|
4
|
-
"exclude": [
|
|
5
|
-
"../client",
|
|
6
|
-
"../client.d.ts",
|
|
7
|
-
"../setup-client.js",
|
|
8
|
-
"../hydration",
|
|
9
|
-
"../hydration.d.ts",
|
|
10
|
-
"../setup-hydration.js"
|
|
11
|
-
]
|
|
4
|
+
"exclude": ["../client", "../setup-client.js", "../hydration", "../setup-hydration.js"]
|
|
12
5
|
}
|
package/tsconfig.json
CHANGED
|
@@ -22,13 +22,6 @@
|
|
|
22
22
|
"rollup/*": ["./shims/rollup-estree-types.d.ts"]
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
|
-
"include": [
|
|
26
|
-
"./*.js",
|
|
27
|
-
"./src/",
|
|
28
|
-
"./tests/**/*.test.tsrx",
|
|
29
|
-
"./tests/**/*.tsrx",
|
|
30
|
-
"./tests/**/*.d.ts",
|
|
31
|
-
"./tests/**/*.js"
|
|
32
|
-
],
|
|
25
|
+
"include": ["./*.js", "./src/"],
|
|
33
26
|
"exclude": ["node_modules", "dist"]
|
|
34
27
|
}
|
package/tsconfig.typecheck.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -285,7 +285,7 @@ export interface RippleObjectCallable {
|
|
|
285
285
|
export interface RippleObjectConstructor {
|
|
286
286
|
new <T extends Object>(obj: T): RippleObject<T>;
|
|
287
287
|
}
|
|
288
|
-
export
|
|
288
|
+
export type RippleObject<T> = { [K in keyof T]: T[K] };
|
|
289
289
|
export const RippleObject: RippleObjectConstructor;
|
|
290
290
|
|
|
291
291
|
export interface RippleDateCallable {
|
package/src/utils/hashing.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const regex_return_characters = /\r/g;
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Hashes a string to a base36 value
|
|
5
|
-
* @param {string} str
|
|
6
|
-
* @returns {string}
|
|
7
|
-
*/
|
|
8
|
-
export function hash(str) {
|
|
9
|
-
str = str.replace(regex_return_characters, '');
|
|
10
|
-
let hash = 5381;
|
|
11
|
-
let i = str.length;
|
|
12
|
-
|
|
13
|
-
while (i--) hash = ((hash << 5) - hash) ^ str.charCodeAt(i);
|
|
14
|
-
return (hash >>> 0).toString(36);
|
|
15
|
-
}
|