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

@salesforce/acorn-visualforce

Package Overview
Dependencies
Maintainers
5
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@salesforce/acorn-visualforce - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

22

dist/index.js

@@ -67,7 +67,8 @@ module.exports =

/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 2);
/******/ return __webpack_require__(__webpack_require__.s = 4);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/* 0 */,
/* 1 */
/***/ (function(module, exports) {

@@ -78,3 +79,3 @@

/***/ }),
/* 1 */
/* 2 */
/***/ (function(module, exports) {

@@ -85,3 +86,9 @@

/***/ }),
/* 2 */
/* 3 */
/***/ (function(module, exports) {
module.exports = require("acorn-jsx/inject");
/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {

@@ -99,8 +106,9 @@

var acorn = __webpack_require__(1);
var acornInjector = __webpack_require__(0);
var acorn = __webpack_require__(2);
var acornJSXInjector = __webpack_require__(3);
var acornVFELInjector = __webpack_require__(1);
module.exports = acornInjector(acorn);
module.exports = acornVFELInjector(acornJSXInjector(acorn), true);
/***/ })
/******/ ]);

@@ -67,3 +67,3 @@ module.exports =

/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 3);
/******/ return __webpack_require__(__webpack_require__.s = 5);
/******/ })

@@ -73,3 +73,3 @@ /************************************************************************/

/***/ 3:
/***/ 0:
/***/ (function(module, exports, __webpack_require__) {

@@ -80,2 +80,28 @@

/**
* @author Marat Vyshegorodtsev
* @license BSD-3-Clause
* For full license text, see LICENSE file in the repo root
* or https://opensource.org/licenses/BSD-3-Clause
*/
module.exports = {
// this code is borrowed from acorn-jsx/inject.js under MIT license
getQualifiedJSXName(object) {
if (object.type === 'JSXIdentifier') return object.name;
if (object.type === 'JSXNamespacedName') return object.namespace.name + ':' + object.name.name;
if (object.type === 'JSXMemberExpression') return getQualifiedJSXName(object.object) + '.' + getQualifiedJSXName(object.property);
}
};
/***/ }),
/***/ 5:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();

@@ -92,2 +118,5 @@

var _require = __webpack_require__(0),
getQualifiedJSXName = _require.getQualifiedJSXName;
module.exports = function (acorn) {

@@ -110,2 +139,26 @@ var forceInject = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;

tt.vfelExpressionStart.updateContext = function vfelExprStartUpdateContext() {
this.context.push(tc.vfel_expr); // Now everything is a VFEL expression tokens
};
tt.vfelExpressionEnd.updateContext = function vfelExprEndUpdateContext() {
this.context.pop();
};
// override JSX behavior to support <apex:*> tags
if (tt.jsxTagEnd && typeof tt.jsxTagEnd.updateContext === 'function') tt.jsxTagEnd.updateContext = function vfelJSXTagEndUpdateContext(prevType) {
var out = this.context.pop(); // popping out of j_oTag or j_cTag context
if (out === tc.j_oTag) if (prevType === tt.slash) // self-closing tag
this.context.pop(); // popping out of j_expr started by this tag
else this.context.push(tc.b_stat); // after opening tag everything is just another code block
if (out === tc.j_cTag) {
this.context.pop(); // popping out of b_stat started by the corresponding opening tag
this.context.pop(); // popping out of j_expr started by the corresponding opening tag
}
this.exprAllowed = true;
};
/* eslint-disable no-underscore-dangle */

@@ -156,9 +209,2 @@ /* Underscore dangle keywords are used by acorn */

tt.vfelExpressionStart.updateContext = function vfelExprStartUpdateContext() {
this.context.push(tc.vfel_expr); // Now everything is a VFEL expression tokens
};
tt.vfelExpressionEnd.updateContext = function vfelExprEndUpdateContext() {
this.context.pop();
};
var vfelParser = {

@@ -400,2 +446,34 @@ vfel_readToken() {

return p.vfel_parseExpressionOnly();
},
jsx_parseElementAt(startPos, startLoc) {
var node = this.startNodeAt(startPos, startLoc);
var children = [];
var openingElement = this.jsx_parseOpeningElementAt(startPos, startLoc);
var closingElement = null;
if (!openingElement.selfClosing) {
contents: for (;;) {
switch (this.type) {
case tt.jsxTagStart:
startPos = this.start;startLoc = this.startLoc;
this.next();
if (this.eat(tt.slash)) {
closingElement = this.jsx_parseClosingElementAt(startPos, startLoc);
break contents;
}
children.push(this.jsx_parseElementAt(startPos, startLoc));
break;
default:
children.push(this.parseStatement(true)); // declaration = true
}
}if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name)) this.raiseRecoverable(closingElement.start, 'Expected corresponding closing tag for <' + getQualifiedJSXName(openingElement.name) + '>');
}
node.openingElement = openingElement;
node.closingElement = closingElement;
node.children = children;
return this.finishNode(node, 'JSXElement');
}

@@ -442,9 +520,19 @@

return function vfelExtendedReadToken(code) {
var curContext = this.curContext();
var nextCharCode = this.input.charCodeAt(this.pos + 1);
// we are parsing a VFEL expression at the moment, use our own tokenizer
if (this.curContext() === tc.vfel_expr) return this.vfel_readToken();
if (curContext === tc.vfel_expr) return this.vfel_readToken();
if (tc.j_oTag && curContext === tc.j_oTag) {
if (code === 123) // {
this.raise(this.pos, "Unexpected '{' inside of a tag (apex tags do not support JSX expressions)");
if (code === 34 || code === 39) // " and '
return this.readString(code); // reverting it back from jsx_readString
}
// if we read '{!' in Javascript context, then
// we switch context to VFEL, otherwise it is still JS
var next = this.input.charCodeAt(this.pos + 1);
if (code === 123 && next === 33) {
if (code === 123 && nextCharCode === 33) {
// got '{!', it means it is a VFEL expression start, taking over

@@ -462,4 +550,6 @@ this.pos += 2;

return function vfelExtendedUpdateContext(prevType) {
var curContext = this.curContext();
// disallow switching to other contexts inside of vfel_expr context
if (this.curContext() === tc.vfel_expr && this.type !== tt.vfelExpressionEnd) return;
if (curContext === tc.vfel_expr && this.type !== tt.vfelExpressionEnd) return;
inner.call(this, prevType);

@@ -477,3 +567,3 @@ };

var ch = this.input.charCodeAt(this.pos);
if (ch === 10 || ch === 13 || ch === 0x2028 || ch === 0x2029) this.raise(this.start, 'Unterminated string constant');
if (ch === 10 || ch === 13 || ch === 0x2028 || ch === 0x2029) this.raise(this.start, 'Unterminated string constant: new line found');

@@ -550,3 +640,9 @@ // Found closing quote, done reading string

acorn.Parser.prototype.loadPlugins = function loadPlugins(pluginConfigs) {
originalLoadPlugins.call(this, Object.assign(pluginConfigs, { vfel: true }));
// load all other plugins first, make sure we don't load vfel
var originalPluginConfigs = Object.assign({}, pluginConfigs);
delete originalPluginConfigs.vfel;
originalLoadPlugins.call(this, originalPluginConfigs);
// load VFEL separately last so all overrides are at the top level
originalLoadPlugins.call(this, { vfel: true });
};

@@ -553,0 +649,0 @@ }

{
"name": "@salesforce/acorn-visualforce",
"version": "1.2.1",
"version": "1.3.0",
"description": "acorn extension for Salesforce js dialect with merge fields",

@@ -28,3 +28,4 @@ "main": "dist/index.js",

"peerDependencies": {
"acorn": "^5.0.3"
"acorn": "^5.0.3",
"acorn-jsx": "^3.0.1"
},

@@ -57,3 +58,4 @@ "devDependencies": {

"plugins": [
["transform-object-rest-spread",
[
"transform-object-rest-spread",
{

@@ -60,0 +62,0 @@ "useBuiltIns": true

@@ -29,3 +29,6 @@ # Acorn-VisualForce

const ast = acorn.parse(code, {
plugins: { vfel: true }
plugins: {
jsx: true, // make sure that jsx appears BEFORE vfel to work correctly
vfel: true,
}
});

@@ -32,0 +35,0 @@ ```

Sorry, the diff of this file is not supported yet

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