@sprlab/wccompiler 0.7.2 → 0.7.3
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/lib/codegen.js +6 -2
- package/lib/parser-extractors.js +4 -4
- package/package.json +1 -1
package/lib/codegen.js
CHANGED
|
@@ -1186,7 +1186,9 @@ export function generateComponent(parseResult, options = {}) {
|
|
|
1186
1186
|
lines.push(' this.__disposers.push(__effect(() => {');
|
|
1187
1187
|
lines.push(` const ${w.newParam} = ${watchRef};`);
|
|
1188
1188
|
lines.push(` if (this.__prev_${w.target} !== undefined && this.__prev_${w.target} !== ${w.newParam}) {`);
|
|
1189
|
-
|
|
1189
|
+
if (w.oldParam) {
|
|
1190
|
+
lines.push(` const ${w.oldParam} = this.__prev_${w.target};`);
|
|
1191
|
+
}
|
|
1190
1192
|
lines.push(' __untrack(() => {');
|
|
1191
1193
|
const bodyLines = body.split('\n');
|
|
1192
1194
|
for (const line of bodyLines) {
|
|
@@ -1203,7 +1205,9 @@ export function generateComponent(parseResult, options = {}) {
|
|
|
1203
1205
|
lines.push(' this.__disposers.push(__effect(() => {');
|
|
1204
1206
|
lines.push(` const ${w.newParam} = ${getterExpr};`);
|
|
1205
1207
|
lines.push(` if (this.${prevName} !== undefined && this.${prevName} !== ${w.newParam}) {`);
|
|
1206
|
-
|
|
1208
|
+
if (w.oldParam) {
|
|
1209
|
+
lines.push(` const ${w.oldParam} = this.${prevName};`);
|
|
1210
|
+
}
|
|
1207
1211
|
lines.push(' __untrack(() => {');
|
|
1208
1212
|
const bodyLines2 = body.split('\n');
|
|
1209
1213
|
for (const line of bodyLines2) {
|
package/lib/parser-extractors.js
CHANGED
|
@@ -782,10 +782,10 @@ export function extractWatchers(source) {
|
|
|
782
782
|
while (i < lines.length) {
|
|
783
783
|
const line = lines[i];
|
|
784
784
|
|
|
785
|
-
// Form 2 — Getter function: watch(() => expr, (newVal, oldVal) => {
|
|
786
|
-
const mGetter = line.match(/\bwatch\s*\(\s*\(\)\s*=>\s*(.+?)\s*,\s*\((\w+)
|
|
787
|
-
// Form 1 — Signal direct: watch(identifier, (newVal, oldVal) => {
|
|
788
|
-
const mSignal = !mGetter ? line.match(/\bwatch\s*\(\s*(\w+)\s*,\s*\((\w+)
|
|
785
|
+
// Form 2 — Getter function: watch(() => expr, (newVal, oldVal) => { OR watch(() => expr, (newVal) => {
|
|
786
|
+
const mGetter = line.match(/\bwatch\s*\(\s*\(\)\s*=>\s*(.+?)\s*,\s*\((\w+)(?:\s*,\s*(\w+))?\)\s*=>\s*\{/);
|
|
787
|
+
// Form 1 — Signal direct: watch(identifier, (newVal, oldVal) => { OR watch(identifier, (newVal) => {
|
|
788
|
+
const mSignal = !mGetter ? line.match(/\bwatch\s*\(\s*(\w+)\s*,\s*\((\w+)(?:\s*,\s*(\w+))?\)\s*=>\s*\{/) : null;
|
|
789
789
|
|
|
790
790
|
const m = mGetter || mSignal;
|
|
791
791
|
|
package/package.json
CHANGED