svelte-origin 1.0.0-next.23 → 1.0.0-next.24

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 CHANGED
@@ -2255,6 +2255,79 @@ function transformStandaloneAttrsDefinition(content) {
2255
2255
  }`;
2256
2256
  }
2257
2257
 
2258
+ // src/transform/reserved-keywords.ts
2259
+ var RESERVED_KEYWORDS = new Set([
2260
+ "break",
2261
+ "case",
2262
+ "catch",
2263
+ "continue",
2264
+ "debugger",
2265
+ "default",
2266
+ "delete",
2267
+ "do",
2268
+ "else",
2269
+ "finally",
2270
+ "for",
2271
+ "function",
2272
+ "if",
2273
+ "in",
2274
+ "instanceof",
2275
+ "new",
2276
+ "return",
2277
+ "switch",
2278
+ "this",
2279
+ "throw",
2280
+ "try",
2281
+ "typeof",
2282
+ "var",
2283
+ "void",
2284
+ "while",
2285
+ "with",
2286
+ "class",
2287
+ "const",
2288
+ "enum",
2289
+ "export",
2290
+ "extends",
2291
+ "import",
2292
+ "super",
2293
+ "implements",
2294
+ "interface",
2295
+ "let",
2296
+ "package",
2297
+ "private",
2298
+ "protected",
2299
+ "public",
2300
+ "static",
2301
+ "yield",
2302
+ "await",
2303
+ "async",
2304
+ "true",
2305
+ "false",
2306
+ "null",
2307
+ "undefined",
2308
+ "arguments",
2309
+ "eval"
2310
+ ]);
2311
+ function getInternalVarName(propName, forcePrefix = true) {
2312
+ return `___${propName}`;
2313
+ }
2314
+ function generatePropDestructure(propName, defaultValue) {
2315
+ const internalName = getInternalVarName(propName);
2316
+ return `${propName}: ${internalName} = ${defaultValue}`;
2317
+ }
2318
+ function generatePropDestructureNoDefault(propName) {
2319
+ const internalName = getInternalVarName(propName);
2320
+ return `${propName}: ${internalName}`;
2321
+ }
2322
+ function generateGetter(propName) {
2323
+ const internalName = getInternalVarName(propName);
2324
+ return `get ${propName}() { return ${internalName} }`;
2325
+ }
2326
+ function generateSetter(propName) {
2327
+ const internalName = getInternalVarName(propName);
2328
+ return `set ${propName}(v) { ${internalName} = v }`;
2329
+ }
2330
+
2258
2331
  // src/transform/schema.ts
2259
2332
  function parseOriginSchemaFromSource(source, exportName) {
2260
2333
  const sourceResult = parseSourceOrigin(source, exportName);
@@ -2593,14 +2666,14 @@ function generatePropsDestructuring(attrs, factoryName) {
2593
2666
  for (const attr of attrs) {
2594
2667
  if (attr.bindable) {
2595
2668
  if (attr.hasDefault) {
2596
- parts.push(`${attr.key} = $bindable(${attr.defaultValue})`);
2669
+ parts.push(generatePropDestructure(attr.key, `$bindable(${attr.defaultValue})`));
2597
2670
  } else {
2598
- parts.push(`${attr.key} = $bindable()`);
2671
+ parts.push(generatePropDestructure(attr.key, "$bindable()"));
2599
2672
  }
2600
2673
  } else if (attr.hasDefault) {
2601
- parts.push(`${attr.key} = ${attr.defaultValue}`);
2674
+ parts.push(generatePropDestructure(attr.key, attr.defaultValue));
2602
2675
  } else {
2603
- parts.push(attr.key);
2676
+ parts.push(generatePropDestructureNoDefault(attr.key));
2604
2677
  }
2605
2678
  }
2606
2679
  return `let { ${parts.join(", ")} }: $attrs.Of<typeof ${factoryName}> = $props()`;
@@ -2608,9 +2681,9 @@ function generatePropsDestructuring(attrs, factoryName) {
2608
2681
  function generateFactoryCallFromAttrs(factoryName, attrs) {
2609
2682
  const parts = [];
2610
2683
  for (const attr of attrs) {
2611
- parts.push(`get ${attr.key}() { return ${attr.key} }`);
2684
+ parts.push(generateGetter(attr.key));
2612
2685
  if (attr.bindable) {
2613
- parts.push(`set ${attr.key}(v) { ${attr.key} = v }`);
2686
+ parts.push(generateSetter(attr.key));
2614
2687
  }
2615
2688
  }
2616
2689
  return `${factoryName}({ ${parts.join(", ")} })`;
@@ -2744,7 +2817,10 @@ function transformAttrsOriginCallsSync(s, source, neededImports) {
2744
2817
  let firstFactoryExpr = null;
2745
2818
  let propsTypeDeclaration = null;
2746
2819
  let isFirstDeclaration = true;
2747
- const needsPropsInjection = declarations.length > 0 && !hasExistingPropsDeclaration(source);
2820
+ const originInstances = new Map;
2821
+ const existingPropsMatch = source.match(/let\s*\{([^}]*)\}\s*(?::\s*[^=]+)?\s*=\s*\$props\s*\(\s*\)/);
2822
+ const hasExistingProps = !!existingPropsMatch;
2823
+ const needsPropsInjection = declarations.length > 0 && !hasExistingPropsDeclaration(source) && !hasExistingProps;
2748
2824
  for (const decl of declarations) {
2749
2825
  const { varName, startIndex, macroOpenParen } = decl;
2750
2826
  const closeParenIndex = findMatchingBracket(source, macroOpenParen);
@@ -2765,20 +2841,47 @@ function transformAttrsOriginCallsSync(s, source, neededImports) {
2765
2841
  expansionLines.push(`type $$Props = $attrs.Of<${typeExpr}>`);
2766
2842
  propsTypeDeclaration = "";
2767
2843
  }
2768
- expansionLines.push(`let ___attrs: $$Props = $props()`, `let ${varName} = ${normalizedFactoryCall}(__attrsFor(${normalizedFactoryCall}, ___attrs))`);
2844
+ if (hasExistingProps) {
2845
+ const existingContent = existingPropsMatch[1];
2846
+ const hasRestSpread = /\.\.\.\s*(\w+)\s*$/.test(existingContent);
2847
+ if (!hasRestSpread && isFirstDeclaration) {
2848
+ const restVarName = "___originAttrs";
2849
+ const newContent = existingContent.trimEnd() ? `${existingContent.trimEnd()}, ...${restVarName}` : `...${restVarName}`;
2850
+ const braceEnd = source.indexOf("}", existingPropsMatch.index + 5);
2851
+ if (braceEnd !== -1) {
2852
+ s.overwrite(existingPropsMatch.index + 5, braceEnd, ` ${newContent} `);
2853
+ }
2854
+ expansionLines.push(`let ${varName} = ${normalizedFactoryCall}(__attrsFor(${normalizedFactoryCall}, ${restVarName}))`);
2855
+ } else {
2856
+ const restMatch = existingContent.match(/\.\.\.\s*(\w+)\s*$/);
2857
+ const restVar = restMatch ? restMatch[1] : "___originAttrs";
2858
+ expansionLines.push(`let ${varName} = ${normalizedFactoryCall}(__attrsFor(${normalizedFactoryCall}, ${restVar}))`);
2859
+ }
2860
+ } else {
2861
+ expansionLines.push(`let ___attrs: $$Props = $props()`, `let ${varName} = ${normalizedFactoryCall}(__attrsFor(${normalizedFactoryCall}, ___attrs))`);
2862
+ }
2769
2863
  s.overwrite(startIndex, endIndex, expansionLines.join(`
2770
2864
  `));
2865
+ originInstances.set(varName, {
2866
+ varName,
2867
+ factoryExpr,
2868
+ startPos: startIndex,
2869
+ endPos: endIndex
2870
+ });
2771
2871
  neededImports.add("__attrsFor");
2772
2872
  changed = true;
2773
2873
  isFirstDeclaration = false;
2774
2874
  }
2775
- return { changed, propsTypeDeclaration };
2875
+ return { changed, propsTypeDeclaration, originInstances };
2776
2876
  }
2777
2877
  async function transformAttrsOriginCalls(s, source, neededImports, schemaResolver) {
2778
2878
  const declarations = findVariableDeclarationsWithMacro(source, "$attrs.origin");
2779
2879
  let changed = false;
2780
2880
  let propsTypeDeclaration = null;
2781
- const needsPropsInjection = declarations.length > 0 && !hasExistingPropsDeclaration(source);
2881
+ const originInstances = new Map;
2882
+ const existingPropsMatch = source.match(/let\s*\{([^}]*)\}\s*(?::\s*[^=]+)?\s*=\s*\$props\s*\(\s*\)/);
2883
+ const hasExistingProps = !!existingPropsMatch;
2884
+ const needsPropsInjection = declarations.length > 0 && !hasExistingPropsDeclaration(source) && !hasExistingProps;
2782
2885
  const matches = [];
2783
2886
  for (const decl of declarations) {
2784
2887
  const { varName, startIndex, macroOpenParen } = decl;
@@ -2798,6 +2901,7 @@ async function transformAttrsOriginCalls(s, source, neededImports, schemaResolve
2798
2901
  }
2799
2902
  let firstFactoryExpr = null;
2800
2903
  let isFirstDeclaration = true;
2904
+ let restVarInjected = false;
2801
2905
  for (const { varName, factoryExpr, startIndex, endIndex, isGeneric } of matches) {
2802
2906
  const expansionLines = [];
2803
2907
  let usesFallback = true;
@@ -2825,15 +2929,40 @@ async function transformAttrsOriginCalls(s, source, neededImports, schemaResolve
2825
2929
  }
2826
2930
  if (usesFallback) {
2827
2931
  const normalizedFactoryCall = normalizeFactoryCall(factoryExpr);
2828
- expansionLines.push(`let ___attrs: $$Props = $props()`, `let ${varName} = ${normalizedFactoryCall}(__attrsFor(${normalizedFactoryCall}, ___attrs))`);
2932
+ if (hasExistingProps) {
2933
+ const existingContent = existingPropsMatch[1];
2934
+ const hasRestSpread = /\.\.\.\s*(\w+)\s*$/.test(existingContent);
2935
+ if (!hasRestSpread && !restVarInjected) {
2936
+ const restVarName = "___originAttrs";
2937
+ const newContent = existingContent.trimEnd() ? `${existingContent.trimEnd()}, ...${restVarName}` : `...${restVarName}`;
2938
+ const braceEnd = source.indexOf("}", existingPropsMatch.index + 5);
2939
+ if (braceEnd !== -1) {
2940
+ s.overwrite(existingPropsMatch.index + 5, braceEnd, ` ${newContent} `);
2941
+ restVarInjected = true;
2942
+ }
2943
+ expansionLines.push(`let ${varName} = ${normalizedFactoryCall}(__attrsFor(${normalizedFactoryCall}, ${restVarName}))`);
2944
+ } else {
2945
+ const restMatch = existingContent.match(/\.\.\.\s*(\w+)\s*$/);
2946
+ const restVar = restMatch ? restMatch[1] : "___originAttrs";
2947
+ expansionLines.push(`let ${varName} = ${normalizedFactoryCall}(__attrsFor(${normalizedFactoryCall}, ${restVar}))`);
2948
+ }
2949
+ } else {
2950
+ expansionLines.push(`let ___attrs: $$Props = $props()`, `let ${varName} = ${normalizedFactoryCall}(__attrsFor(${normalizedFactoryCall}, ___attrs))`);
2951
+ }
2829
2952
  neededImports.add("__attrsFor");
2830
2953
  }
2831
2954
  s.overwrite(startIndex, endIndex, expansionLines.join(`
2832
2955
  `));
2956
+ originInstances.set(varName, {
2957
+ varName,
2958
+ factoryExpr,
2959
+ startPos: startIndex,
2960
+ endPos: endIndex
2961
+ });
2833
2962
  changed = true;
2834
2963
  isFirstDeclaration = false;
2835
2964
  }
2836
- return { changed, propsTypeDeclaration };
2965
+ return { changed, propsTypeDeclaration, originInstances };
2837
2966
  }
2838
2967
 
2839
2968
  // src/transform/element-types.ts
@@ -2845,9 +2974,9 @@ function getElementTypeImport(element) {
2845
2974
  function generateReactiveAttrsWrapper(attrs) {
2846
2975
  const parts = [];
2847
2976
  for (const attr of attrs) {
2848
- parts.push(`get ${attr.key}() { return ${attr.key} }`);
2977
+ parts.push(generateGetter(attr.key));
2849
2978
  if (attr.bindable) {
2850
- parts.push(`set ${attr.key}(v) { ${attr.key} = v }`);
2979
+ parts.push(generateSetter(attr.key));
2851
2980
  }
2852
2981
  }
2853
2982
  return `{ ${parts.join(", ")} }`;
@@ -2857,14 +2986,14 @@ function generateAttrsForMerge(attrs) {
2857
2986
  for (const attr of attrs) {
2858
2987
  if (attr.bindable) {
2859
2988
  if (attr.hasDefault) {
2860
- parts.push(`${attr.key} = $bindable(${attr.defaultValue})`);
2989
+ parts.push(generatePropDestructure(attr.key, `$bindable(${attr.defaultValue})`));
2861
2990
  } else {
2862
- parts.push(`${attr.key} = $bindable()`);
2991
+ parts.push(generatePropDestructure(attr.key, "$bindable()"));
2863
2992
  }
2864
2993
  } else if (attr.hasDefault) {
2865
- parts.push(`${attr.key} = ${attr.defaultValue}`);
2994
+ parts.push(generatePropDestructure(attr.key, attr.defaultValue));
2866
2995
  } else {
2867
- parts.push(attr.key);
2996
+ parts.push(generatePropDestructureNoDefault(attr.key));
2868
2997
  }
2869
2998
  }
2870
2999
  return parts.join(", ");
@@ -3041,6 +3170,291 @@ async function transformAttrsForCalls(s, source, neededImports, schemaResolver)
3041
3170
  return changed;
3042
3171
  }
3043
3172
 
3173
+ // src/transform/origin-destructure-transform.ts
3174
+ function transformOriginDestructuring(s, source, originInstances) {
3175
+ let changed = false;
3176
+ const destructures = findOriginDestructures(source, originInstances);
3177
+ for (const d of destructures.reverse()) {
3178
+ const replacement = generateDestructureReplacement(d, originInstances);
3179
+ if (replacement) {
3180
+ s.overwrite(d.startPos, d.endPos, replacement);
3181
+ changed = true;
3182
+ }
3183
+ }
3184
+ return changed;
3185
+ }
3186
+ function findOriginDestructures(source, originInstances) {
3187
+ const results = [];
3188
+ const destructurePattern = /\b(let|const|var)\s*\{/g;
3189
+ let match;
3190
+ while ((match = destructurePattern.exec(source)) !== null) {
3191
+ if (isInsideStringOrComment(source, match.index))
3192
+ continue;
3193
+ const declKeyword = match[1];
3194
+ const braceStart = match.index + match[0].length - 1;
3195
+ const braceEnd = findMatchingBracket(source, braceStart, "{", "}");
3196
+ if (braceEnd === -1)
3197
+ continue;
3198
+ let i = braceEnd + 1;
3199
+ while (i < source.length && /\s/.test(source[i]))
3200
+ i++;
3201
+ if (source[i] !== "=")
3202
+ continue;
3203
+ i++;
3204
+ while (i < source.length && /\s/.test(source[i]))
3205
+ i++;
3206
+ const exprStart = i;
3207
+ let sourceVar = "";
3208
+ while (i < source.length && /[\w$]/.test(source[i])) {
3209
+ sourceVar += source[i];
3210
+ i++;
3211
+ }
3212
+ if (!sourceVar)
3213
+ continue;
3214
+ if (!originInstances.has(sourceVar))
3215
+ continue;
3216
+ let isPropsAccess = false;
3217
+ const afterVarPos = i;
3218
+ while (i < source.length && /\s/.test(source[i]))
3219
+ i++;
3220
+ if (source[i] === ".") {
3221
+ i++;
3222
+ while (i < source.length && /\s/.test(source[i]))
3223
+ i++;
3224
+ const propName = readIdentifier(source, i);
3225
+ if (propName === "props") {
3226
+ isPropsAccess = true;
3227
+ i += propName.length;
3228
+ } else {
3229
+ continue;
3230
+ }
3231
+ }
3232
+ let endPos = i;
3233
+ while (endPos < source.length && /\s/.test(source[endPos]) && source[endPos] !== `
3234
+ `)
3235
+ endPos++;
3236
+ if (source[endPos] === ";")
3237
+ endPos++;
3238
+ if (source[endPos] === `
3239
+ `)
3240
+ endPos++;
3241
+ const patternContent = source.slice(braceStart + 1, braceEnd);
3242
+ const parsed = parseDestructurePattern(patternContent, isPropsAccess);
3243
+ results.push({
3244
+ startPos: match.index,
3245
+ endPos,
3246
+ sourceVar,
3247
+ isPropsAccess,
3248
+ methods: parsed.methods,
3249
+ props: parsed.props,
3250
+ nestedPropsPattern: parsed.nestedProps
3251
+ });
3252
+ }
3253
+ return results;
3254
+ }
3255
+ function parseDestructurePattern(content, isPropsAccess) {
3256
+ const methods = [];
3257
+ const props = [];
3258
+ let nestedProps = null;
3259
+ const parts = splitByTopLevelCommas2(content);
3260
+ for (const part of parts) {
3261
+ const trimmed = part.trim();
3262
+ if (!trimmed)
3263
+ continue;
3264
+ const propsMatch = trimmed.match(/^props\s*:\s*\{/);
3265
+ if (propsMatch) {
3266
+ const braceStart = trimmed.indexOf("{");
3267
+ const braceEnd = findMatchingBracket(trimmed, braceStart, "{", "}");
3268
+ if (braceEnd !== -1) {
3269
+ const nestedContent = trimmed.slice(braceStart + 1, braceEnd);
3270
+ const nestedParts = splitByTopLevelCommas2(nestedContent);
3271
+ const nestedPropsList = [];
3272
+ for (const np of nestedParts) {
3273
+ const parsed = parseDestructuredProp(np.trim());
3274
+ if (parsed)
3275
+ nestedPropsList.push(parsed);
3276
+ }
3277
+ nestedProps = {
3278
+ startPos: 0,
3279
+ endPos: 0,
3280
+ props: nestedPropsList
3281
+ };
3282
+ }
3283
+ continue;
3284
+ }
3285
+ if (isPropsAccess) {
3286
+ const parsed = parseDestructuredProp(trimmed);
3287
+ if (parsed)
3288
+ props.push(parsed);
3289
+ } else {
3290
+ const parsed = parseDestructuredItem(trimmed);
3291
+ if (parsed)
3292
+ methods.push(parsed);
3293
+ }
3294
+ }
3295
+ return { methods, props, nestedProps };
3296
+ }
3297
+ function parseDestructuredItem(part) {
3298
+ const trimmed = part.trim();
3299
+ if (!trimmed)
3300
+ return null;
3301
+ const colonIdx = findTopLevelColon(trimmed);
3302
+ let key;
3303
+ let alias = null;
3304
+ let rest = trimmed;
3305
+ if (colonIdx !== -1) {
3306
+ key = trimmed.slice(0, colonIdx).trim();
3307
+ rest = trimmed.slice(colonIdx + 1).trim();
3308
+ const eqIdx2 = findTopLevelEquals(rest);
3309
+ if (eqIdx2 !== -1) {
3310
+ alias = rest.slice(0, eqIdx2).trim();
3311
+ return {
3312
+ key,
3313
+ alias,
3314
+ defaultValue: rest.slice(eqIdx2 + 1).trim()
3315
+ };
3316
+ } else {
3317
+ alias = rest;
3318
+ return { key, alias, defaultValue: null };
3319
+ }
3320
+ }
3321
+ const eqIdx = findTopLevelEquals(trimmed);
3322
+ if (eqIdx !== -1) {
3323
+ key = trimmed.slice(0, eqIdx).trim();
3324
+ return {
3325
+ key,
3326
+ alias: null,
3327
+ defaultValue: trimmed.slice(eqIdx + 1).trim()
3328
+ };
3329
+ }
3330
+ return { key: trimmed, alias: null, defaultValue: null };
3331
+ }
3332
+ function parseDestructuredProp(part) {
3333
+ const item = parseDestructuredItem(part);
3334
+ if (!item)
3335
+ return null;
3336
+ let isBindable = false;
3337
+ let bindableDefault = null;
3338
+ if (item.defaultValue) {
3339
+ const bindableMatch = item.defaultValue.match(/^\$bindable\s*\(/);
3340
+ if (bindableMatch) {
3341
+ isBindable = true;
3342
+ const parenStart = item.defaultValue.indexOf("(");
3343
+ const parenEnd = findMatchingBracket(item.defaultValue, parenStart, "(", ")");
3344
+ if (parenEnd !== -1) {
3345
+ bindableDefault = item.defaultValue.slice(parenStart + 1, parenEnd).trim() || null;
3346
+ }
3347
+ }
3348
+ }
3349
+ return {
3350
+ ...item,
3351
+ isBindable,
3352
+ bindableDefault
3353
+ };
3354
+ }
3355
+ function generateDestructureReplacement(d, originInstances) {
3356
+ const lines = [];
3357
+ const instance = originInstances.get(d.sourceVar);
3358
+ if (!instance)
3359
+ return null;
3360
+ for (const m of d.methods) {
3361
+ const varName = m.alias || m.key;
3362
+ if (m.defaultValue) {
3363
+ lines.push(`let ${varName} = ${d.sourceVar}.${m.key}?.bind(${d.sourceVar}) ?? ${m.defaultValue}`);
3364
+ } else {
3365
+ lines.push(`let ${varName} = ${d.sourceVar}.${m.key}.bind(${d.sourceVar})`);
3366
+ }
3367
+ }
3368
+ if (d.nestedPropsPattern) {
3369
+ for (const p of d.nestedPropsPattern.props) {
3370
+ lines.push(...generatePropAccessors(p, d.sourceVar));
3371
+ }
3372
+ }
3373
+ if (d.isPropsAccess) {
3374
+ for (const p of d.props) {
3375
+ lines.push(...generatePropAccessors(p, d.sourceVar));
3376
+ }
3377
+ }
3378
+ return lines.join(`
3379
+ `) + `
3380
+ `;
3381
+ }
3382
+ function generatePropAccessors(p, sourceVar) {
3383
+ const lines = [];
3384
+ const varName = p.alias || p.key;
3385
+ if (p.isBindable) {
3386
+ const defaultVal = p.bindableDefault || "undefined";
3387
+ lines.push(`let ${varName} = $derived(${sourceVar}.props.${p.key} ?? ${defaultVal})`);
3388
+ } else if (p.defaultValue) {
3389
+ lines.push(`let ${varName} = $derived(${sourceVar}.props.${p.key} ?? ${p.defaultValue})`);
3390
+ } else {
3391
+ lines.push(`let ${varName} = $derived(${sourceVar}.props.${p.key})`);
3392
+ }
3393
+ return lines;
3394
+ }
3395
+ function splitByTopLevelCommas2(content) {
3396
+ const parts = [];
3397
+ let current = "";
3398
+ let depth = 0;
3399
+ for (let i = 0;i < content.length; i++) {
3400
+ const char = content[i];
3401
+ if (char === "{" || char === "(" || char === "[" || char === "<") {
3402
+ depth++;
3403
+ current += char;
3404
+ } else if (char === "}" || char === ")" || char === "]" || char === ">") {
3405
+ depth--;
3406
+ current += char;
3407
+ } else if (char === "," && depth === 0) {
3408
+ parts.push(current);
3409
+ current = "";
3410
+ } else {
3411
+ current += char;
3412
+ }
3413
+ }
3414
+ if (current.trim()) {
3415
+ parts.push(current);
3416
+ }
3417
+ return parts;
3418
+ }
3419
+ function findTopLevelColon(str) {
3420
+ let depth = 0;
3421
+ for (let i = 0;i < str.length; i++) {
3422
+ const char = str[i];
3423
+ if (char === "{" || char === "(" || char === "[" || char === "<")
3424
+ depth++;
3425
+ else if (char === "}" || char === ")" || char === "]" || char === ">")
3426
+ depth--;
3427
+ else if (char === ":" && depth === 0)
3428
+ return i;
3429
+ }
3430
+ return -1;
3431
+ }
3432
+ function findTopLevelEquals(str) {
3433
+ let depth = 0;
3434
+ for (let i = 0;i < str.length; i++) {
3435
+ const char = str[i];
3436
+ if (char === "{" || char === "(" || char === "[" || char === "<")
3437
+ depth++;
3438
+ else if (char === "}" || char === ")" || char === "]" || char === ">")
3439
+ depth--;
3440
+ else if (char === "=" && depth === 0) {
3441
+ if (str[i + 1] !== "=" && str[i + 1] !== ">") {
3442
+ return i;
3443
+ }
3444
+ }
3445
+ }
3446
+ return -1;
3447
+ }
3448
+ function readIdentifier(str, start) {
3449
+ let result = "";
3450
+ let i = start;
3451
+ while (i < str.length && /[\w$]/.test(str[i])) {
3452
+ result += str[i];
3453
+ i++;
3454
+ }
3455
+ return result;
3456
+ }
3457
+
3044
3458
  // src/transform/core.ts
3045
3459
  function transformScript(source, options = {}) {
3046
3460
  if (options.schemaResolver) {
@@ -3063,6 +3477,9 @@ function transformScript(source, options = {}) {
3063
3477
  const result = transformAttrsOriginCallsSync(s, source, neededImports);
3064
3478
  changed = result.changed || changed;
3065
3479
  propsTypeDeclaration = result.propsTypeDeclaration;
3480
+ if (result.originInstances.size > 0) {
3481
+ changed = transformOriginDestructuring(s, source, result.originInstances) || changed;
3482
+ }
3066
3483
  }
3067
3484
  if (isComponent) {
3068
3485
  changed = transformAttrsForCallsSync(s, source, neededImports) || changed;
@@ -3134,6 +3551,9 @@ async function transformScriptAsync(source, options) {
3134
3551
  const result = await transformAttrsOriginCalls(s, source, neededImports, schemaResolver);
3135
3552
  changed = result.changed || changed;
3136
3553
  propsTypeDeclaration = result.propsTypeDeclaration;
3554
+ if (result.originInstances.size > 0) {
3555
+ changed = transformOriginDestructuring(s, source, result.originInstances) || changed;
3556
+ }
3137
3557
  }
3138
3558
  if (isComponent) {
3139
3559
  changed = await transformAttrsForCalls(s, source, neededImports, schemaResolver) || changed;
@@ -3204,6 +3624,9 @@ async function transformScriptContent(source, options) {
3204
3624
  const result = await transformAttrsOriginCalls(s, source, neededImports, schemaResolver);
3205
3625
  changed = result.changed || changed;
3206
3626
  propsTypeDeclaration = result.propsTypeDeclaration;
3627
+ if (result.originInstances.size > 0) {
3628
+ changed = transformOriginDestructuring(s, source, result.originInstances) || changed;
3629
+ }
3207
3630
  }
3208
3631
  if (isComponent) {
3209
3632
  changed = await transformAttrsForCalls(s, source, neededImports, schemaResolver) || changed;