svelte-origin 1.0.0-next.16 → 1.0.0-next.17
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/dist/cli.js +40 -30
- package/dist/index.js +97 -49
- package/dist/plugin.js +40 -30
- package/dist/post-process.js +40 -30
- package/dist/preprocess.js +40 -30
- package/dist/runtime/index.js +57 -19
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2027,38 +2027,48 @@ ${createFnBody}
|
|
|
2027
2027
|
}`;
|
|
2028
2028
|
return configCode;
|
|
2029
2029
|
}
|
|
2030
|
-
function transformOriginBody(content, parents = [], attrDetails = [], propName = "props",
|
|
2030
|
+
function transformOriginBody(content, parents = [], attrDetails = [], propName = "props", _svelteImports) {
|
|
2031
2031
|
let body = content.trim();
|
|
2032
2032
|
const hasParents = parents.length > 0;
|
|
2033
|
-
const
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
}
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2033
|
+
const propsLines = [];
|
|
2034
|
+
if (attrDetails.length > 0) {
|
|
2035
|
+
const initialProps = [];
|
|
2036
|
+
for (const attr of attrDetails) {
|
|
2037
|
+
const defaultExpr = attr.hasDefault ? ` ?? ${attr.defaultValue}` : "";
|
|
2038
|
+
initialProps.push(`${attr.key}: __inputAttrs.${attr.key}${defaultExpr}`);
|
|
2039
|
+
}
|
|
2040
|
+
propsLines.push(`let __props = $state({ ${initialProps.join(", ")} })`);
|
|
2041
|
+
for (const attr of attrDetails) {
|
|
2042
|
+
const defaultExpr = attr.hasDefault ? ` ?? ${attr.defaultValue}` : "";
|
|
2043
|
+
const parentLast = `__last_parent_${attr.key}`;
|
|
2044
|
+
const localLast = `__last_local_${attr.key}`;
|
|
2045
|
+
propsLines.push(`let ${parentLast} = __inputAttrs.${attr.key}`, `let ${localLast} = __props.${attr.key}`, `$effect(() => {
|
|
2046
|
+
` + ` const __parent = __inputAttrs.${attr.key}
|
|
2047
|
+
` + ` const __local = __props.${attr.key}
|
|
2048
|
+
|
|
2049
|
+
` + ` // Parent -> local
|
|
2050
|
+
` + ` if (__parent !== ${parentLast}) {
|
|
2051
|
+
` + ` ${parentLast} = __parent
|
|
2052
|
+
` + ` if (__local !== __parent) {
|
|
2053
|
+
` + ` __props.${attr.key} = __parent${defaultExpr}
|
|
2054
|
+
` + ` }
|
|
2055
|
+
` + ` ${localLast} = __props.${attr.key}
|
|
2056
|
+
` + ` return
|
|
2057
|
+
` + ` }
|
|
2058
|
+
|
|
2059
|
+
` + ` // Local -> parent
|
|
2060
|
+
` + ` if (__local !== ${localLast}) {
|
|
2061
|
+
` + ` ${localLast} = __local
|
|
2062
|
+
` + (attr.bindable ? ` try { __inputAttrs.${attr.key} = __local } catch {}
|
|
2063
|
+
${parentLast} = __inputAttrs.${attr.key}
|
|
2064
|
+
` : "") + ` }
|
|
2065
|
+
` + `})`);
|
|
2066
|
+
}
|
|
2067
|
+
} else {
|
|
2068
|
+
propsLines.push("const __props = __inputAttrs");
|
|
2069
|
+
}
|
|
2070
|
+
const propsObjectCode = "\t\t" + propsLines.join(`
|
|
2071
|
+
`);
|
|
2062
2072
|
if (!body) {
|
|
2063
2073
|
const baseMembers = [`get ${propName}() { return __props }`];
|
|
2064
2074
|
if (hasParents)
|
package/dist/index.js
CHANGED
|
@@ -3475,24 +3475,39 @@ function __attrsFor(factory, rawAttrs) {
|
|
|
3475
3475
|
const wrapper = {};
|
|
3476
3476
|
const localValues = {};
|
|
3477
3477
|
const hasLocalValue = {};
|
|
3478
|
-
|
|
3479
|
-
Object.
|
|
3478
|
+
const defineExposedProp = (key2, info) => {
|
|
3479
|
+
if (Object.prototype.hasOwnProperty.call(wrapper, key2))
|
|
3480
|
+
return;
|
|
3481
|
+
const base = {
|
|
3480
3482
|
get() {
|
|
3481
|
-
if (hasLocalValue[key2])
|
|
3483
|
+
if (hasLocalValue[key2])
|
|
3482
3484
|
return localValues[key2];
|
|
3483
|
-
}
|
|
3484
3485
|
return rawAttrs[key2];
|
|
3485
3486
|
},
|
|
3486
|
-
set(value) {
|
|
3487
|
-
localValues[key2] = value;
|
|
3488
|
-
hasLocalValue[key2] = true;
|
|
3489
|
-
try {
|
|
3490
|
-
rawAttrs[key2] = value;
|
|
3491
|
-
} catch {}
|
|
3492
|
-
},
|
|
3493
3487
|
enumerable: true,
|
|
3494
3488
|
configurable: true
|
|
3495
|
-
}
|
|
3489
|
+
};
|
|
3490
|
+
if (info.bindable) {
|
|
3491
|
+
Object.defineProperty(wrapper, key2, {
|
|
3492
|
+
...base,
|
|
3493
|
+
set(value) {
|
|
3494
|
+
localValues[key2] = value;
|
|
3495
|
+
hasLocalValue[key2] = true;
|
|
3496
|
+
try {
|
|
3497
|
+
rawAttrs[key2] = value;
|
|
3498
|
+
} catch {}
|
|
3499
|
+
}
|
|
3500
|
+
});
|
|
3501
|
+
} else {
|
|
3502
|
+
Object.defineProperty(wrapper, key2, base);
|
|
3503
|
+
}
|
|
3504
|
+
};
|
|
3505
|
+
for (const [key2, info] of Object.entries(schema)) {
|
|
3506
|
+
const parentValue = rawAttrs[key2];
|
|
3507
|
+
const shouldExpose = !info.bindable || !info.hasDefault || parentValue !== undefined;
|
|
3508
|
+
if (shouldExpose) {
|
|
3509
|
+
defineExposedProp(key2, info);
|
|
3510
|
+
}
|
|
3496
3511
|
}
|
|
3497
3512
|
for (const sym of Object.getOwnPropertySymbols(rawAttrs)) {
|
|
3498
3513
|
Object.defineProperty(wrapper, sym, {
|
|
@@ -3505,34 +3520,57 @@ function __attrsFor(factory, rawAttrs) {
|
|
|
3505
3520
|
}
|
|
3506
3521
|
return new Proxy(wrapper, {
|
|
3507
3522
|
get(target, prop2) {
|
|
3508
|
-
if (prop2 in
|
|
3509
|
-
|
|
3523
|
+
if (typeof prop2 === "string" && prop2 in schema) {
|
|
3524
|
+
if (hasLocalValue[prop2])
|
|
3525
|
+
return localValues[prop2];
|
|
3526
|
+
return rawAttrs[prop2];
|
|
3510
3527
|
}
|
|
3528
|
+
if (prop2 in target)
|
|
3529
|
+
return target[prop2];
|
|
3511
3530
|
return rawAttrs[prop2];
|
|
3512
3531
|
},
|
|
3513
3532
|
set(target, prop2, value) {
|
|
3533
|
+
if (typeof prop2 === "string" && prop2 in schema) {
|
|
3534
|
+
localValues[prop2] = value;
|
|
3535
|
+
hasLocalValue[prop2] = true;
|
|
3536
|
+
if (!Object.prototype.hasOwnProperty.call(wrapper, prop2)) {
|
|
3537
|
+
defineExposedProp(prop2, schema[prop2]);
|
|
3538
|
+
}
|
|
3539
|
+
if (schema[prop2].bindable) {
|
|
3540
|
+
try {
|
|
3541
|
+
rawAttrs[prop2] = value;
|
|
3542
|
+
} catch {}
|
|
3543
|
+
}
|
|
3544
|
+
return true;
|
|
3545
|
+
}
|
|
3514
3546
|
if (prop2 in target) {
|
|
3515
|
-
|
|
3547
|
+
try {
|
|
3548
|
+
target[prop2] = value;
|
|
3549
|
+
} catch {}
|
|
3516
3550
|
return true;
|
|
3517
3551
|
}
|
|
3518
3552
|
try {
|
|
3519
3553
|
rawAttrs[prop2] = value;
|
|
3520
3554
|
} catch {
|
|
3521
|
-
|
|
3522
|
-
|
|
3555
|
+
if (typeof prop2 === "string") {
|
|
3556
|
+
localValues[prop2] = value;
|
|
3557
|
+
hasLocalValue[prop2] = true;
|
|
3558
|
+
}
|
|
3523
3559
|
}
|
|
3524
3560
|
return true;
|
|
3525
3561
|
},
|
|
3526
3562
|
has(target, prop2) {
|
|
3563
|
+
if (typeof prop2 === "string" && prop2 in schema) {
|
|
3564
|
+
return prop2 in target || hasLocalValue[prop2];
|
|
3565
|
+
}
|
|
3527
3566
|
return prop2 in target || prop2 in rawAttrs;
|
|
3528
3567
|
},
|
|
3529
3568
|
ownKeys() {
|
|
3530
3569
|
return [...Object.keys(wrapper), ...Object.getOwnPropertySymbols(rawAttrs)];
|
|
3531
3570
|
},
|
|
3532
3571
|
getOwnPropertyDescriptor(target, prop2) {
|
|
3533
|
-
if (prop2 in target)
|
|
3572
|
+
if (prop2 in target)
|
|
3534
3573
|
return Object.getOwnPropertyDescriptor(target, prop2);
|
|
3535
|
-
}
|
|
3536
3574
|
return Object.getOwnPropertyDescriptor(rawAttrs, prop2);
|
|
3537
3575
|
}
|
|
3538
3576
|
});
|
|
@@ -6077,38 +6115,48 @@ ${createFnBody}
|
|
|
6077
6115
|
}`;
|
|
6078
6116
|
return configCode;
|
|
6079
6117
|
}
|
|
6080
|
-
function transformOriginBody(content, parents = [], attrDetails = [], propName = "props",
|
|
6118
|
+
function transformOriginBody(content, parents = [], attrDetails = [], propName = "props", _svelteImports) {
|
|
6081
6119
|
let body = content.trim();
|
|
6082
6120
|
const hasParents = parents.length > 0;
|
|
6083
|
-
const
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
|
-
|
|
6088
|
-
|
|
6089
|
-
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
|
|
6093
|
-
|
|
6094
|
-
|
|
6095
|
-
|
|
6096
|
-
|
|
6097
|
-
}
|
|
6098
|
-
|
|
6099
|
-
|
|
6100
|
-
|
|
6101
|
-
|
|
6102
|
-
|
|
6103
|
-
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
|
|
6121
|
+
const propsLines = [];
|
|
6122
|
+
if (attrDetails.length > 0) {
|
|
6123
|
+
const initialProps = [];
|
|
6124
|
+
for (const attr2 of attrDetails) {
|
|
6125
|
+
const defaultExpr = attr2.hasDefault ? ` ?? ${attr2.defaultValue}` : "";
|
|
6126
|
+
initialProps.push(`${attr2.key}: __inputAttrs.${attr2.key}${defaultExpr}`);
|
|
6127
|
+
}
|
|
6128
|
+
propsLines.push(`let __props = $state({ ${initialProps.join(", ")} })`);
|
|
6129
|
+
for (const attr2 of attrDetails) {
|
|
6130
|
+
const defaultExpr = attr2.hasDefault ? ` ?? ${attr2.defaultValue}` : "";
|
|
6131
|
+
const parentLast = `__last_parent_${attr2.key}`;
|
|
6132
|
+
const localLast = `__last_local_${attr2.key}`;
|
|
6133
|
+
propsLines.push(`let ${parentLast} = __inputAttrs.${attr2.key}`, `let ${localLast} = __props.${attr2.key}`, `$effect(() => {
|
|
6134
|
+
` + ` const __parent = __inputAttrs.${attr2.key}
|
|
6135
|
+
` + ` const __local = __props.${attr2.key}
|
|
6136
|
+
|
|
6137
|
+
` + ` // Parent -> local
|
|
6138
|
+
` + ` if (__parent !== ${parentLast}) {
|
|
6139
|
+
` + ` ${parentLast} = __parent
|
|
6140
|
+
` + ` if (__local !== __parent) {
|
|
6141
|
+
` + ` __props.${attr2.key} = __parent${defaultExpr}
|
|
6142
|
+
` + ` }
|
|
6143
|
+
` + ` ${localLast} = __props.${attr2.key}
|
|
6144
|
+
` + ` return
|
|
6145
|
+
` + ` }
|
|
6146
|
+
|
|
6147
|
+
` + ` // Local -> parent
|
|
6148
|
+
` + ` if (__local !== ${localLast}) {
|
|
6149
|
+
` + ` ${localLast} = __local
|
|
6150
|
+
` + (attr2.bindable ? ` try { __inputAttrs.${attr2.key} = __local } catch {}
|
|
6151
|
+
${parentLast} = __inputAttrs.${attr2.key}
|
|
6152
|
+
` : "") + ` }
|
|
6153
|
+
` + `})`);
|
|
6154
|
+
}
|
|
6155
|
+
} else {
|
|
6156
|
+
propsLines.push("const __props = __inputAttrs");
|
|
6157
|
+
}
|
|
6158
|
+
const propsObjectCode = "\t\t" + propsLines.join(`
|
|
6159
|
+
`);
|
|
6112
6160
|
if (!body) {
|
|
6113
6161
|
const baseMembers = [`get ${propName}() { return __props }`];
|
|
6114
6162
|
if (hasParents)
|
package/dist/plugin.js
CHANGED
|
@@ -2021,38 +2021,48 @@ ${createFnBody}
|
|
|
2021
2021
|
}`;
|
|
2022
2022
|
return configCode;
|
|
2023
2023
|
}
|
|
2024
|
-
function transformOriginBody(content, parents = [], attrDetails = [], propName = "props",
|
|
2024
|
+
function transformOriginBody(content, parents = [], attrDetails = [], propName = "props", _svelteImports) {
|
|
2025
2025
|
let body = content.trim();
|
|
2026
2026
|
const hasParents = parents.length > 0;
|
|
2027
|
-
const
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
}
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2027
|
+
const propsLines = [];
|
|
2028
|
+
if (attrDetails.length > 0) {
|
|
2029
|
+
const initialProps = [];
|
|
2030
|
+
for (const attr of attrDetails) {
|
|
2031
|
+
const defaultExpr = attr.hasDefault ? ` ?? ${attr.defaultValue}` : "";
|
|
2032
|
+
initialProps.push(`${attr.key}: __inputAttrs.${attr.key}${defaultExpr}`);
|
|
2033
|
+
}
|
|
2034
|
+
propsLines.push(`let __props = $state({ ${initialProps.join(", ")} })`);
|
|
2035
|
+
for (const attr of attrDetails) {
|
|
2036
|
+
const defaultExpr = attr.hasDefault ? ` ?? ${attr.defaultValue}` : "";
|
|
2037
|
+
const parentLast = `__last_parent_${attr.key}`;
|
|
2038
|
+
const localLast = `__last_local_${attr.key}`;
|
|
2039
|
+
propsLines.push(`let ${parentLast} = __inputAttrs.${attr.key}`, `let ${localLast} = __props.${attr.key}`, `$effect(() => {
|
|
2040
|
+
` + ` const __parent = __inputAttrs.${attr.key}
|
|
2041
|
+
` + ` const __local = __props.${attr.key}
|
|
2042
|
+
|
|
2043
|
+
` + ` // Parent -> local
|
|
2044
|
+
` + ` if (__parent !== ${parentLast}) {
|
|
2045
|
+
` + ` ${parentLast} = __parent
|
|
2046
|
+
` + ` if (__local !== __parent) {
|
|
2047
|
+
` + ` __props.${attr.key} = __parent${defaultExpr}
|
|
2048
|
+
` + ` }
|
|
2049
|
+
` + ` ${localLast} = __props.${attr.key}
|
|
2050
|
+
` + ` return
|
|
2051
|
+
` + ` }
|
|
2052
|
+
|
|
2053
|
+
` + ` // Local -> parent
|
|
2054
|
+
` + ` if (__local !== ${localLast}) {
|
|
2055
|
+
` + ` ${localLast} = __local
|
|
2056
|
+
` + (attr.bindable ? ` try { __inputAttrs.${attr.key} = __local } catch {}
|
|
2057
|
+
${parentLast} = __inputAttrs.${attr.key}
|
|
2058
|
+
` : "") + ` }
|
|
2059
|
+
` + `})`);
|
|
2060
|
+
}
|
|
2061
|
+
} else {
|
|
2062
|
+
propsLines.push("const __props = __inputAttrs");
|
|
2063
|
+
}
|
|
2064
|
+
const propsObjectCode = "\t\t" + propsLines.join(`
|
|
2065
|
+
`);
|
|
2056
2066
|
if (!body) {
|
|
2057
2067
|
const baseMembers = [`get ${propName}() { return __props }`];
|
|
2058
2068
|
if (hasParents)
|
package/dist/post-process.js
CHANGED
|
@@ -2025,38 +2025,48 @@ ${createFnBody}
|
|
|
2025
2025
|
}`;
|
|
2026
2026
|
return configCode;
|
|
2027
2027
|
}
|
|
2028
|
-
function transformOriginBody(content, parents = [], attrDetails = [], propName = "props",
|
|
2028
|
+
function transformOriginBody(content, parents = [], attrDetails = [], propName = "props", _svelteImports) {
|
|
2029
2029
|
let body = content.trim();
|
|
2030
2030
|
const hasParents = parents.length > 0;
|
|
2031
|
-
const
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
}
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2031
|
+
const propsLines = [];
|
|
2032
|
+
if (attrDetails.length > 0) {
|
|
2033
|
+
const initialProps = [];
|
|
2034
|
+
for (const attr of attrDetails) {
|
|
2035
|
+
const defaultExpr = attr.hasDefault ? ` ?? ${attr.defaultValue}` : "";
|
|
2036
|
+
initialProps.push(`${attr.key}: __inputAttrs.${attr.key}${defaultExpr}`);
|
|
2037
|
+
}
|
|
2038
|
+
propsLines.push(`let __props = $state({ ${initialProps.join(", ")} })`);
|
|
2039
|
+
for (const attr of attrDetails) {
|
|
2040
|
+
const defaultExpr = attr.hasDefault ? ` ?? ${attr.defaultValue}` : "";
|
|
2041
|
+
const parentLast = `__last_parent_${attr.key}`;
|
|
2042
|
+
const localLast = `__last_local_${attr.key}`;
|
|
2043
|
+
propsLines.push(`let ${parentLast} = __inputAttrs.${attr.key}`, `let ${localLast} = __props.${attr.key}`, `$effect(() => {
|
|
2044
|
+
` + ` const __parent = __inputAttrs.${attr.key}
|
|
2045
|
+
` + ` const __local = __props.${attr.key}
|
|
2046
|
+
|
|
2047
|
+
` + ` // Parent -> local
|
|
2048
|
+
` + ` if (__parent !== ${parentLast}) {
|
|
2049
|
+
` + ` ${parentLast} = __parent
|
|
2050
|
+
` + ` if (__local !== __parent) {
|
|
2051
|
+
` + ` __props.${attr.key} = __parent${defaultExpr}
|
|
2052
|
+
` + ` }
|
|
2053
|
+
` + ` ${localLast} = __props.${attr.key}
|
|
2054
|
+
` + ` return
|
|
2055
|
+
` + ` }
|
|
2056
|
+
|
|
2057
|
+
` + ` // Local -> parent
|
|
2058
|
+
` + ` if (__local !== ${localLast}) {
|
|
2059
|
+
` + ` ${localLast} = __local
|
|
2060
|
+
` + (attr.bindable ? ` try { __inputAttrs.${attr.key} = __local } catch {}
|
|
2061
|
+
${parentLast} = __inputAttrs.${attr.key}
|
|
2062
|
+
` : "") + ` }
|
|
2063
|
+
` + `})`);
|
|
2064
|
+
}
|
|
2065
|
+
} else {
|
|
2066
|
+
propsLines.push("const __props = __inputAttrs");
|
|
2067
|
+
}
|
|
2068
|
+
const propsObjectCode = "\t\t" + propsLines.join(`
|
|
2069
|
+
`);
|
|
2060
2070
|
if (!body) {
|
|
2061
2071
|
const baseMembers = [`get ${propName}() { return __props }`];
|
|
2062
2072
|
if (hasParents)
|
package/dist/preprocess.js
CHANGED
|
@@ -2021,38 +2021,48 @@ ${createFnBody}
|
|
|
2021
2021
|
}`;
|
|
2022
2022
|
return configCode;
|
|
2023
2023
|
}
|
|
2024
|
-
function transformOriginBody(content, parents = [], attrDetails = [], propName = "props",
|
|
2024
|
+
function transformOriginBody(content, parents = [], attrDetails = [], propName = "props", _svelteImports) {
|
|
2025
2025
|
let body = content.trim();
|
|
2026
2026
|
const hasParents = parents.length > 0;
|
|
2027
|
-
const
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
}
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2027
|
+
const propsLines = [];
|
|
2028
|
+
if (attrDetails.length > 0) {
|
|
2029
|
+
const initialProps = [];
|
|
2030
|
+
for (const attr of attrDetails) {
|
|
2031
|
+
const defaultExpr = attr.hasDefault ? ` ?? ${attr.defaultValue}` : "";
|
|
2032
|
+
initialProps.push(`${attr.key}: __inputAttrs.${attr.key}${defaultExpr}`);
|
|
2033
|
+
}
|
|
2034
|
+
propsLines.push(`let __props = $state({ ${initialProps.join(", ")} })`);
|
|
2035
|
+
for (const attr of attrDetails) {
|
|
2036
|
+
const defaultExpr = attr.hasDefault ? ` ?? ${attr.defaultValue}` : "";
|
|
2037
|
+
const parentLast = `__last_parent_${attr.key}`;
|
|
2038
|
+
const localLast = `__last_local_${attr.key}`;
|
|
2039
|
+
propsLines.push(`let ${parentLast} = __inputAttrs.${attr.key}`, `let ${localLast} = __props.${attr.key}`, `$effect(() => {
|
|
2040
|
+
` + ` const __parent = __inputAttrs.${attr.key}
|
|
2041
|
+
` + ` const __local = __props.${attr.key}
|
|
2042
|
+
|
|
2043
|
+
` + ` // Parent -> local
|
|
2044
|
+
` + ` if (__parent !== ${parentLast}) {
|
|
2045
|
+
` + ` ${parentLast} = __parent
|
|
2046
|
+
` + ` if (__local !== __parent) {
|
|
2047
|
+
` + ` __props.${attr.key} = __parent${defaultExpr}
|
|
2048
|
+
` + ` }
|
|
2049
|
+
` + ` ${localLast} = __props.${attr.key}
|
|
2050
|
+
` + ` return
|
|
2051
|
+
` + ` }
|
|
2052
|
+
|
|
2053
|
+
` + ` // Local -> parent
|
|
2054
|
+
` + ` if (__local !== ${localLast}) {
|
|
2055
|
+
` + ` ${localLast} = __local
|
|
2056
|
+
` + (attr.bindable ? ` try { __inputAttrs.${attr.key} = __local } catch {}
|
|
2057
|
+
${parentLast} = __inputAttrs.${attr.key}
|
|
2058
|
+
` : "") + ` }
|
|
2059
|
+
` + `})`);
|
|
2060
|
+
}
|
|
2061
|
+
} else {
|
|
2062
|
+
propsLines.push("const __props = __inputAttrs");
|
|
2063
|
+
}
|
|
2064
|
+
const propsObjectCode = "\t\t" + propsLines.join(`
|
|
2065
|
+
`);
|
|
2056
2066
|
if (!body) {
|
|
2057
2067
|
const baseMembers = [`get ${propName}() { return __props }`];
|
|
2058
2068
|
if (hasParents)
|
package/dist/runtime/index.js
CHANGED
|
@@ -3475,24 +3475,39 @@ function __attrsFor(factory, rawAttrs) {
|
|
|
3475
3475
|
const wrapper = {};
|
|
3476
3476
|
const localValues = {};
|
|
3477
3477
|
const hasLocalValue = {};
|
|
3478
|
-
|
|
3479
|
-
Object.
|
|
3478
|
+
const defineExposedProp = (key2, info) => {
|
|
3479
|
+
if (Object.prototype.hasOwnProperty.call(wrapper, key2))
|
|
3480
|
+
return;
|
|
3481
|
+
const base = {
|
|
3480
3482
|
get() {
|
|
3481
|
-
if (hasLocalValue[key2])
|
|
3483
|
+
if (hasLocalValue[key2])
|
|
3482
3484
|
return localValues[key2];
|
|
3483
|
-
}
|
|
3484
3485
|
return rawAttrs[key2];
|
|
3485
3486
|
},
|
|
3486
|
-
set(value) {
|
|
3487
|
-
localValues[key2] = value;
|
|
3488
|
-
hasLocalValue[key2] = true;
|
|
3489
|
-
try {
|
|
3490
|
-
rawAttrs[key2] = value;
|
|
3491
|
-
} catch {}
|
|
3492
|
-
},
|
|
3493
3487
|
enumerable: true,
|
|
3494
3488
|
configurable: true
|
|
3495
|
-
}
|
|
3489
|
+
};
|
|
3490
|
+
if (info.bindable) {
|
|
3491
|
+
Object.defineProperty(wrapper, key2, {
|
|
3492
|
+
...base,
|
|
3493
|
+
set(value) {
|
|
3494
|
+
localValues[key2] = value;
|
|
3495
|
+
hasLocalValue[key2] = true;
|
|
3496
|
+
try {
|
|
3497
|
+
rawAttrs[key2] = value;
|
|
3498
|
+
} catch {}
|
|
3499
|
+
}
|
|
3500
|
+
});
|
|
3501
|
+
} else {
|
|
3502
|
+
Object.defineProperty(wrapper, key2, base);
|
|
3503
|
+
}
|
|
3504
|
+
};
|
|
3505
|
+
for (const [key2, info] of Object.entries(schema)) {
|
|
3506
|
+
const parentValue = rawAttrs[key2];
|
|
3507
|
+
const shouldExpose = !info.bindable || !info.hasDefault || parentValue !== undefined;
|
|
3508
|
+
if (shouldExpose) {
|
|
3509
|
+
defineExposedProp(key2, info);
|
|
3510
|
+
}
|
|
3496
3511
|
}
|
|
3497
3512
|
for (const sym of Object.getOwnPropertySymbols(rawAttrs)) {
|
|
3498
3513
|
Object.defineProperty(wrapper, sym, {
|
|
@@ -3505,34 +3520,57 @@ function __attrsFor(factory, rawAttrs) {
|
|
|
3505
3520
|
}
|
|
3506
3521
|
return new Proxy(wrapper, {
|
|
3507
3522
|
get(target, prop2) {
|
|
3508
|
-
if (prop2 in
|
|
3509
|
-
|
|
3523
|
+
if (typeof prop2 === "string" && prop2 in schema) {
|
|
3524
|
+
if (hasLocalValue[prop2])
|
|
3525
|
+
return localValues[prop2];
|
|
3526
|
+
return rawAttrs[prop2];
|
|
3510
3527
|
}
|
|
3528
|
+
if (prop2 in target)
|
|
3529
|
+
return target[prop2];
|
|
3511
3530
|
return rawAttrs[prop2];
|
|
3512
3531
|
},
|
|
3513
3532
|
set(target, prop2, value) {
|
|
3533
|
+
if (typeof prop2 === "string" && prop2 in schema) {
|
|
3534
|
+
localValues[prop2] = value;
|
|
3535
|
+
hasLocalValue[prop2] = true;
|
|
3536
|
+
if (!Object.prototype.hasOwnProperty.call(wrapper, prop2)) {
|
|
3537
|
+
defineExposedProp(prop2, schema[prop2]);
|
|
3538
|
+
}
|
|
3539
|
+
if (schema[prop2].bindable) {
|
|
3540
|
+
try {
|
|
3541
|
+
rawAttrs[prop2] = value;
|
|
3542
|
+
} catch {}
|
|
3543
|
+
}
|
|
3544
|
+
return true;
|
|
3545
|
+
}
|
|
3514
3546
|
if (prop2 in target) {
|
|
3515
|
-
|
|
3547
|
+
try {
|
|
3548
|
+
target[prop2] = value;
|
|
3549
|
+
} catch {}
|
|
3516
3550
|
return true;
|
|
3517
3551
|
}
|
|
3518
3552
|
try {
|
|
3519
3553
|
rawAttrs[prop2] = value;
|
|
3520
3554
|
} catch {
|
|
3521
|
-
|
|
3522
|
-
|
|
3555
|
+
if (typeof prop2 === "string") {
|
|
3556
|
+
localValues[prop2] = value;
|
|
3557
|
+
hasLocalValue[prop2] = true;
|
|
3558
|
+
}
|
|
3523
3559
|
}
|
|
3524
3560
|
return true;
|
|
3525
3561
|
},
|
|
3526
3562
|
has(target, prop2) {
|
|
3563
|
+
if (typeof prop2 === "string" && prop2 in schema) {
|
|
3564
|
+
return prop2 in target || hasLocalValue[prop2];
|
|
3565
|
+
}
|
|
3527
3566
|
return prop2 in target || prop2 in rawAttrs;
|
|
3528
3567
|
},
|
|
3529
3568
|
ownKeys() {
|
|
3530
3569
|
return [...Object.keys(wrapper), ...Object.getOwnPropertySymbols(rawAttrs)];
|
|
3531
3570
|
},
|
|
3532
3571
|
getOwnPropertyDescriptor(target, prop2) {
|
|
3533
|
-
if (prop2 in target)
|
|
3572
|
+
if (prop2 in target)
|
|
3534
3573
|
return Object.getOwnPropertyDescriptor(target, prop2);
|
|
3535
|
-
}
|
|
3536
3574
|
return Object.getOwnPropertyDescriptor(rawAttrs, prop2);
|
|
3537
3575
|
}
|
|
3538
3576
|
});
|