Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vue/reactivity-transform

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vue/reactivity-transform - npm Package Compare versions

Comparing version 3.2.45 to 3.2.46

120

dist/reactivity-transform.cjs.js
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var MagicString = require('magic-string');

@@ -11,6 +9,2 @@ var estreeWalker = require('estree-walker');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; }
var MagicString__default = /*#__PURE__*/_interopDefaultLegacy(MagicString);
const CONVERT_SYMBOL = '$';

@@ -38,3 +32,3 @@ const ESCAPE_SYMBOL = '$$';

});
const s = new MagicString__default(src);
const s = new MagicString(src);
const res = transformAST(ast.program, s, 0);

@@ -101,3 +95,3 @@ // inject helper imports

for (const key of knownRefs) {
rootScope[key] = true;
rootScope[key] = {};
}

@@ -107,4 +101,7 @@ }

for (const key in knownProps) {
const { local } = knownProps[key];
rootScope[local] = 'prop';
const { local, isConst } = knownProps[key];
rootScope[local] = {
isProp: true,
isConst: !!isConst
};
propsLocalToPublicMap[local] = key;

@@ -153,6 +150,6 @@ }

}
function registerBinding(id, isRef = false) {
function registerBinding(id, binding) {
excludedIds.add(id);
if (currentScope) {
currentScope[id.name] = isRef;
currentScope[id.name] = binding ? binding : false;
}

@@ -163,3 +160,3 @@ else {

}
const registerRefBinding = (id) => registerBinding(id, true);
const registerRefBinding = (id, isConst = false) => registerBinding(id, { isConst });
let tempVarCount = 0;

@@ -209,3 +206,3 @@ function genTempVar() {

(refCall = isRefCreationCall(decl.init.callee.name))) {
processRefDeclaration(refCall, decl.id, decl.init);
processRefDeclaration(refCall, decl.id, decl.init, stmt.kind === 'const');
}

@@ -227,3 +224,3 @@ else {

}
function processRefDeclaration(method, id, call) {
function processRefDeclaration(method, id, call, isConst) {
excludedIds.add(call.callee);

@@ -236,9 +233,9 @@ if (method === convertSymbol) {

// single variable
registerRefBinding(id);
registerRefBinding(id, isConst);
}
else if (id.type === 'ObjectPattern') {
processRefObjectPattern(id, call);
processRefObjectPattern(id, call, isConst);
}
else if (id.type === 'ArrayPattern') {
processRefArrayPattern(id, call);
processRefArrayPattern(id, call, isConst);
}

@@ -249,3 +246,3 @@ }

if (id.type === 'Identifier') {
registerRefBinding(id);
registerRefBinding(id, isConst);
// replace call

@@ -259,3 +256,3 @@ s.overwrite(call.start + offset, call.start + method.length + offset, helper(method.slice(1)));

}
function processRefObjectPattern(pattern, call, tempVar, path = []) {
function processRefObjectPattern(pattern, call, isConst, tempVar, path = []) {
if (!tempVar) {

@@ -292,6 +289,12 @@ tempVar = genTempVar();

else if (p.value.type === 'ObjectPattern') {
processRefObjectPattern(p.value, call, tempVar, [...path, key]);
processRefObjectPattern(p.value, call, isConst, tempVar, [
...path,
key
]);
}
else if (p.value.type === 'ArrayPattern') {
processRefArrayPattern(p.value, call, tempVar, [...path, key]);
processRefArrayPattern(p.value, call, isConst, tempVar, [
...path,
key
]);
}

@@ -305,3 +308,3 @@ else if (p.value.type === 'AssignmentPattern') {

else if (p.value.left.type === 'ObjectPattern') {
processRefObjectPattern(p.value.left, call, tempVar, [
processRefObjectPattern(p.value.left, call, isConst, tempVar, [
...path,

@@ -312,3 +315,3 @@ [key, p.value.right]

else if (p.value.left.type === 'ArrayPattern') {
processRefArrayPattern(p.value.left, call, tempVar, [
processRefArrayPattern(p.value.left, call, isConst, tempVar, [
...path,

@@ -327,3 +330,3 @@ [key, p.value.right]

if (nameId) {
registerRefBinding(nameId);
registerRefBinding(nameId, isConst);
// inject toRef() after original replaced pattern

@@ -344,3 +347,3 @@ const source = pathToString(tempVar, path);

}
function processRefArrayPattern(pattern, call, tempVar, path = []) {
function processRefArrayPattern(pattern, call, isConst, tempVar, path = []) {
if (!tempVar) {

@@ -371,9 +374,9 @@ // const [x] = $(useFoo()) --> const __$temp_1 = useFoo()

else if (e.type === 'ObjectPattern') {
processRefObjectPattern(e, call, tempVar, [...path, i]);
processRefObjectPattern(e, call, isConst, tempVar, [...path, i]);
}
else if (e.type === 'ArrayPattern') {
processRefArrayPattern(e, call, tempVar, [...path, i]);
processRefArrayPattern(e, call, isConst, tempVar, [...path, i]);
}
if (nameId) {
registerRefBinding(nameId);
registerRefBinding(nameId, isConst);
// inject toRef() after original replaced pattern

@@ -415,5 +418,10 @@ const source = pathToString(tempVar, path);

if (shared.hasOwn(scope, id.name)) {
const bindingType = scope[id.name];
if (bindingType) {
const isProp = bindingType === 'prop';
const binding = scope[id.name];
if (binding) {
if (binding.isConst &&
((parent.type === 'AssignmentExpression' && id === parent.left) ||
parent.type === 'UpdateExpression')) {
error(`Assignment to constant variable.`, id);
}
const { isProp } = binding;
if (compilerCore.isStaticProperty(parent) && parent.shorthand) {

@@ -509,12 +517,15 @@ // let binding used in a property shorthand

}
if (node.type === 'Identifier' &&
if (node.type === 'Identifier') {
const binding = rootScope[node.name];
if (
// if inside $$(), skip unless this is a destructured prop binding
!(escapeScope && rootScope[node.name] !== 'prop') &&
compilerCore.isReferencedIdentifier(node, parent, parentStack) &&
!excludedIds.has(node)) {
// walk up the scope chain to check if id should be appended .value
let i = scopeStack.length;
while (i--) {
if (rewriteId(scopeStack[i], node, parent, parentStack)) {
return;
!(escapeScope && (!binding || !binding.isProp)) &&
compilerCore.isReferencedIdentifier(node, parent, parentStack) &&
!excludedIds.has(node)) {
// walk up the scope chain to check if id should be appended .value
let i = scopeStack.length;
while (i--) {
if (rewriteId(scopeStack[i], node, parent, parentStack)) {
return;
}
}

@@ -533,4 +544,24 @@ }

callee === escapeSymbol) {
escapeScope = node;
s.remove(node.callee.start + offset, node.callee.end + offset);
escapeScope = node;
if ((parent === null || parent === void 0 ? void 0 : parent.type) === 'ExpressionStatement') {
// edge case where the call expression is an expression statement
// if its own - prepend semicolon to avoid it being parsed as
// function invocation of previous line
let i = (node.leadingComments
? node.leadingComments[0].start
: node.start) + offset;
while (i--) {
const char = s.original.charAt(i);
if (char === '\n') {
// only insert semi if it's actually the fisrt thign after
// newline
s.prependRight(node.start + offset, ';');
break;
}
else if (!/\s/.test(char)) {
break;
}
}
}
}

@@ -561,3 +592,6 @@ // TODO remove when out of experimental

return {
rootRefs: Object.keys(rootScope).filter(key => rootScope[key] === true),
rootRefs: Object.keys(rootScope).filter(key => {
const binding = rootScope[key];
return binding && !binding.isProp;
}),
importedHelpers: [...importedHelpers]

@@ -564,0 +598,0 @@ };

@@ -38,2 +38,3 @@ import { ImportDefaultSpecifier } from '@babel/types';

default?: any;
isConst?: boolean;
}>): {

@@ -40,0 +41,0 @@ rootRefs: string[];

{
"name": "@vue/reactivity-transform",
"version": "3.2.45",
"version": "3.2.46",
"description": "@vue/reactivity-transform",

@@ -32,4 +32,4 @@ "main": "dist/reactivity-transform.cjs.js",

"@babel/parser": "^7.16.4",
"@vue/compiler-core": "3.2.45",
"@vue/shared": "3.2.45",
"@vue/compiler-core": "3.2.46",
"@vue/shared": "3.2.46",
"estree-walker": "^2.0.2",

@@ -36,0 +36,0 @@ "magic-string": "^0.25.7"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc