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

@tarojs/shared

Package Overview
Dependencies
Maintainers
10
Versions
649
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tarojs/shared - npm Package Compare versions

Comparing version 4.0.6 to 4.0.7-alpha.0

1

dist/components.js

@@ -321,2 +321,3 @@ const DEFAULT_EMPTY_ARRAY = '[]';

['catch-view', -1],
['click-view', -1],
['cover-view', -1],

@@ -323,0 +324,0 @@ ['static-view', -1],

13

dist/index.cjs.js

@@ -323,2 +323,3 @@ 'use strict';

['catch-view', -1],
['click-view', -1],
['cover-view', -1],

@@ -841,3 +842,4 @@ ['static-view', -1],

PureView: viewAttrs,
CatchView: viewAttrs
CatchView: viewAttrs,
ClickView: viewAttrs,
};

@@ -847,3 +849,3 @@ origin = Object.assign(Object.assign({}, origin), extraList);

.sort((a, b) => {
const reg = /^(Static|Pure|Catch)*(View|Image|Text)$/;
const reg = /^(Static|Pure|Catch|Click)*(View|Image|Text)$/;
const isACommonly = reg.test(a);

@@ -1282,10 +1284,11 @@ const isBCommonly = reg.test(b);

Shortcuts["Container"] = "container";
Shortcuts["Childnodes"] = "cn";
Shortcuts["Childnodes"] = "c";
Shortcuts["Text"] = "v";
Shortcuts["NodeType"] = "nt";
Shortcuts["NodeName"] = "nn";
Shortcuts["NodeName"] = "n";
// Attrtibutes
Shortcuts["Style"] = "st";
Shortcuts["Class"] = "cl";
Shortcuts["Class"] = "l";
Shortcuts["Src"] = "src";
Shortcuts["Sid"] = "s";
})(exports.Shortcuts || (exports.Shortcuts = {}));

@@ -1292,0 +1295,0 @@

@@ -39,3 +39,3 @@ import { Events } from './event-emitter';

uid?: string;
sid: string;
[Shortcuts.Sid]: string;
[key: string]: unknown;

@@ -42,0 +42,0 @@ }

@@ -321,2 +321,3 @@ const DEFAULT_EMPTY_ARRAY = '[]';

['catch-view', -1],
['click-view', -1],
['cover-view', -1],

@@ -839,3 +840,4 @@ ['static-view', -1],

PureView: viewAttrs,
CatchView: viewAttrs
CatchView: viewAttrs,
ClickView: viewAttrs,
};

@@ -845,3 +847,3 @@ origin = Object.assign(Object.assign({}, origin), extraList);

.sort((a, b) => {
const reg = /^(Static|Pure|Catch)*(View|Image|Text)$/;
const reg = /^(Static|Pure|Catch|Click)*(View|Image|Text)$/;
const isACommonly = reg.test(a);

@@ -1280,10 +1282,11 @@ const isBCommonly = reg.test(b);

Shortcuts["Container"] = "container";
Shortcuts["Childnodes"] = "cn";
Shortcuts["Childnodes"] = "c";
Shortcuts["Text"] = "v";
Shortcuts["NodeType"] = "nt";
Shortcuts["NodeName"] = "nn";
Shortcuts["NodeName"] = "n";
// Attrtibutes
Shortcuts["Style"] = "st";
Shortcuts["Class"] = "cl";
Shortcuts["Class"] = "l";
Shortcuts["Src"] = "src";
Shortcuts["Sid"] = "s";
})(Shortcuts || (Shortcuts = {}));

@@ -1290,0 +1293,0 @@

export declare const enum Shortcuts {
Container = "container",
Childnodes = "cn",
Childnodes = "c",
Text = "v",
NodeType = "nt",
NodeName = "nn",
NodeName = "n",
Style = "st",
Class = "cl",
Src = "src"
Class = "l",
Src = "src",
Sid = "s"
}

@@ -5,10 +5,11 @@ // 字符串简写

Shortcuts["Container"] = "container";
Shortcuts["Childnodes"] = "cn";
Shortcuts["Childnodes"] = "c";
Shortcuts["Text"] = "v";
Shortcuts["NodeType"] = "nt";
Shortcuts["NodeName"] = "nn";
Shortcuts["NodeName"] = "n";
// Attrtibutes
Shortcuts["Style"] = "st";
Shortcuts["Class"] = "cl";
Shortcuts["Class"] = "l";
Shortcuts["Src"] = "src";
Shortcuts["Sid"] = "s";
})(Shortcuts || (Shortcuts = {}));

@@ -15,0 +16,0 @@

@@ -52,2 +52,3 @@ /**

protected _baseLevel: number;
protected _isUseXS: boolean;
protected exportExpr: string;

@@ -76,2 +77,4 @@ protected isSupportRecursive: boolean;

get baseLevel(): number;
set isUseXS(isUse: boolean);
get isUseXS(): boolean;
private buildAttribute;

@@ -94,2 +97,3 @@ protected replacePropName(name: string, value: string, _componentName?: string, _componentAlias?: any): string;

buildXsTemplate(_filePath?: string): string;
buildXsImportTemplate(_filePath?: string): string;
buildPageTemplate: (baseTempPath: string, _page?: {

@@ -105,3 +109,3 @@ content: Record<string, any>;

protected buildXSTmplName(): string;
protected buildXSTepFocus(nn: string): string;
protected buildXSTepFocus(n: string): string;
protected buildXSTmpExtra(): string;

@@ -108,0 +112,0 @@ }

@@ -313,2 +313,3 @@ 'use strict';

['catch-view', -1],
['click-view', -1],
['cover-view', -1],

@@ -346,10 +347,11 @@ ['static-view', -1],

Shortcuts["Container"] = "container";
Shortcuts["Childnodes"] = "cn";
Shortcuts["Childnodes"] = "c";
Shortcuts["Text"] = "v";
Shortcuts["NodeType"] = "nt";
Shortcuts["NodeName"] = "nn";
Shortcuts["NodeName"] = "n";
// Attrtibutes
Shortcuts["Style"] = "st";
Shortcuts["Class"] = "cl";
Shortcuts["Class"] = "l";
Shortcuts["Src"] = "src";
Shortcuts["Sid"] = "s";
})(exports.Shortcuts || (exports.Shortcuts = {}));

@@ -687,3 +689,4 @@

PureView: viewAttrs,
CatchView: viewAttrs
CatchView: viewAttrs,
ClickView: viewAttrs,
};

@@ -693,3 +696,3 @@ origin = Object.assign(Object.assign({}, origin), extraList);

.sort((a, b) => {
const reg = /^(Static|Pure|Catch)*(View|Image|Text)$/;
const reg = /^(Static|Pure|Catch|Click)*(View|Image|Text)$/;
const isACommonly = reg.test(a);

@@ -748,3 +751,3 @@ const isBCommonly = reg.test(b);

style: `i.${"st" /* Shortcuts.Style */}`,
class: `i.${"cl" /* Shortcuts.Class */}`
class: `i.${"l" /* Shortcuts.Class */}`
};

@@ -768,2 +771,3 @@ const events = {

this._baseLevel = 0;
this._isUseXS = true;
this.exportExpr = 'module.exports =';

@@ -788,4 +792,4 @@ this.thirdPartyPatcher = {};

this.buildBaseComponentTemplate = (ext) => {
const data = !this.isSupportRecursive && this.supportXS
? this.dataKeymap(`i:i,c:1,l:xs.f('',i.${"nn" /* Shortcuts.NodeName */})`)
const data = !this.isSupportRecursive && this.isUseXS
? this.dataKeymap(`i:i,c:1,l:xs.f('',i.${"n" /* Shortcuts.NodeName */})`)
: this.isSupportRecursive

@@ -796,9 +800,8 @@ ? this.dataKeymap('i:i')

return `<import src="./base${ext}" />
${this.buildXsTemplate()}
<template is="{{'tmpl_0_' + i.nn}}" data="{{${data}}}" />`;
${this.buildXsImportTemplate()}<template is="{{'tmpl_0_' + i.${"n" /* Shortcuts.NodeName */}}}" data="{{${data}}}" />`;
};
this.buildCustomComponentTemplate = (ext) => {
const Adapter = this.Adapter;
const data = !this.isSupportRecursive && this.supportXS
? `${this.dataKeymap(`i:item,c:1,l:xs.f('',item.${"nn" /* Shortcuts.NodeName */})`)}`
const data = !this.isSupportRecursive && this.isUseXS
? `${this.dataKeymap(`i:item,c:1,l:xs.f('',item.${"n" /* Shortcuts.NodeName */})`)}`
: this.isSupportRecursive

@@ -809,6 +812,4 @@ ? this.dataKeymap('i:item')

return `<import src="./base${ext}" />
${this.buildXsTemplate()}
<block ${Adapter.for}="{{i.${"cn" /* Shortcuts.Childnodes */}}}" ${Adapter.key}="sid">
<template is="{{'tmpl_0_' + item.nn}}" data="{{${data}}}" />
</block>`;
${this.buildXsImportTemplate()}<template is="{{'tmpl_0_' + item.${"n" /* Shortcuts.NodeName */}}}" data="{{${data}}}" ${Adapter.for}="{{i.${"c" /* Shortcuts.Childnodes */}}}" ${Adapter.key}="${"s" /* Shortcuts.Sid */}" />
`;
};

@@ -821,3 +822,3 @@ this.buildXScript = () => {

},
c: ${this.buildXSTepFocus("nn" /* Shortcuts.NodeName */)},
c: ${this.buildXSTepFocus("n" /* Shortcuts.NodeName */)},
e: function (n) {

@@ -836,2 +837,8 @@ return 'tmpl_' + n + '_${"container" /* Shortcuts.Container */}'

}
set isUseXS(isUse) {
this._isUseXS = this.supportXS && isUse;
}
get isUseXS() {
return this._isUseXS;
}
buildAttribute(attrs, nodeName) {

@@ -876,3 +883,3 @@ return Object.keys(attrs)

}
propValue = this.supportXS
propValue = this.isUseXS
? `xs.b(i.${propAlias},${propValue})`

@@ -921,2 +928,7 @@ : `i.${propAlias}===undefined?${propValue}:i.${propAlias}`;

};
result['click-view'] = {
style: comp.style,
class: comp.class,
bindtap: 'eh'
};
}

@@ -941,17 +953,14 @@ }

const Adapter = this.Adapter;
const data = !this.isSupportRecursive && this.supportXS
? `${this.dataKeymap(`i:item,c:1,l:xs.f('',item.${"nn" /* Shortcuts.NodeName */})`)}`
const data = !this.isSupportRecursive && this.isUseXS
? `${this.dataKeymap(`i:item,c:1,l:xs.f('',item.${"n" /* Shortcuts.NodeName */})`)}`
: this.isSupportRecursive
? this.dataKeymap('i:item')
: this.dataKeymap('i:item,c:1');
const xs = this.supportXS
const xs = this.isUseXS
? (this.isSupportRecursive
? `xs.a(0, item.${"nn" /* Shortcuts.NodeName */})`
: `xs.a(0, item.${"nn" /* Shortcuts.NodeName */}, '')`)
: "'tmpl_0_' + item.nn";
return `${this.buildXsTemplate()}
<template name="taro_tmpl">
<block ${Adapter.for}="{{root.cn}}" ${Adapter.key}="sid">
<template is="{{${xs}}}" data="{{${data}}}" />
</block>
? `xs.a(0, item.${"n" /* Shortcuts.NodeName */})`
: `xs.a(0, item.${"n" /* Shortcuts.NodeName */}, '')`)
: `'tmpl_0_' + item.${"n" /* Shortcuts.NodeName */}`;
return `${this.buildXsImportTemplate()}<template name="taro_tmpl">
<template is="{{${xs}}}" data="{{${data}}}" ${Adapter.for}="{{root.${"c" /* Shortcuts.Childnodes */}}}" ${Adapter.key}="${"s" /* Shortcuts.Sid */}" />
</template>

@@ -983,3 +992,3 @@ `;

else if (attr === 'class') {
return str + ` class="{{i.${"cl" /* Shortcuts.Class */}}}"`;
return str + ` class="{{i.${"l" /* Shortcuts.Class */}}}"`;
}

@@ -991,3 +1000,3 @@ else if (attr === 'style') {

if (isBooleanStringLiteral(patchValue) || isNumber(patchValue) || isString(patchValue)) {
const propValue = this.supportXS
const propValue = this.isUseXS
? `xs.b(i.${toCamelCase(attr)},${patchValue})`

@@ -1006,7 +1015,8 @@ : `i.${toCamelCase(attr)}===undefined?${patchValue}:i.${toCamelCase(attr)}`;

getChildrenTemplate(level) {
const { isSupportRecursive, supportXS } = this;
const { isSupportRecursive, isUseXS, Adapter } = this;
const isLastRecursiveComp = !isSupportRecursive && level + 1 === this.baseLevel;
const isUseXs = !this.isSupportRecursive && this.supportXS;
const isUnRecursiveXs = !this.isSupportRecursive && isUseXS;
const forAttribute = `${Adapter.for}="{{i.${"c" /* Shortcuts.Childnodes */}}}" ${Adapter.key}="${"s" /* Shortcuts.Sid */}"`;
if (isLastRecursiveComp) {
const data = isUseXs
const data = isUnRecursiveXs
? `${this.dataKeymap('i:item,c:c,l:l')}`

@@ -1016,11 +1026,11 @@ : this.isSupportRecursive

: this.dataKeymap('i:item,c:c');
return supportXS
? `<template is="{{xs.e(${level})}}" data="{{${data}}}" />`
: `<template is="tmpl_${level}_${"container" /* Shortcuts.Container */}" data="{{${data}}}" />`;
return isUseXS
? `<template is="{{xs.e(${level})}}" data="{{${data}}}" ${forAttribute} />`
: `<template is="tmpl_${level}_${"container" /* Shortcuts.Container */}" data="{{${data}}}" ${forAttribute} />`;
}
else {
const data = isUseXs
const data = isUnRecursiveXs
// TODO: 此处直接 c+1,不是最优解,变量 c 的作用是监测组件嵌套的层级是否大于 baselevel
// 但目前的监测方法用于所有组件嵌套的总和,应该分开组件计算,单个组件嵌套层级大于 baselevel 时,再进入 comp 组件中进行新的嵌套
? `${this.dataKeymap(`i:item,c:c+1,l:xs.f(l,item.${"nn" /* Shortcuts.NodeName */})`)}`
? `${this.dataKeymap(`i:item,c:c+1,l:xs.f(l,item.${"n" /* Shortcuts.NodeName */})`)}`
: this.isSupportRecursive

@@ -1030,13 +1040,13 @@ ? `${this.dataKeymap('i:item')}`

const xs = !this.isSupportRecursive
? `xs.a(c, item.${"nn" /* Shortcuts.NodeName */}, l)`
: `xs.a(0, item.${"nn" /* Shortcuts.NodeName */})`;
return supportXS
? `<template is="{{${xs}}}" data="{{${data}}}" />`
? `xs.a(c, item.${"n" /* Shortcuts.NodeName */}, l)`
: `xs.a(0, item.${"n" /* Shortcuts.NodeName */})`;
return isUseXS
? `<template is="{{${xs}}}" data="{{${data}}}" ${forAttribute} />`
: isSupportRecursive
? `<template is="{{'tmpl_0_' + item.nn}}" data="{{${data}}}" />`
: `<template is="{{'tmpl_' + c + '_' + item.nn}}" data="{{${data}}}" />`;
? `<template is="{{'tmpl_0_' + item.${"n" /* Shortcuts.NodeName */}}}" data="{{${data}}}" ${forAttribute} />`
: `<template is="{{'tmpl_' + c + '_' + item.${"n" /* Shortcuts.NodeName */}}}" data="{{${data}}}" ${forAttribute} />`;
}
}
getChildren(comp, level) {
const { isSupportRecursive, Adapter } = this;
const { isSupportRecursive } = this;
const nextLevel = isSupportRecursive ? 0 : level + 1;

@@ -1050,5 +1060,3 @@ let child = this.getChildrenTemplate(nextLevel);

: `
<block ${Adapter.for}="{{i.${"cn" /* Shortcuts.Childnodes */}}}" ${Adapter.key}="sid">
${indent(child, 6)}
</block>
${indent(child, 6)}
`;

@@ -1065,3 +1073,3 @@ if (isFunction(this.modifyLoopContainer)) {

const attrs = Object.assign({}, comp.attributes);
const templateName = this.supportXS
const templateName = this.isUseXS
? `xs.c(i, 'tmpl_${level}_')`

@@ -1076,7 +1084,7 @@ : `i.focus ? 'tmpl_${level}_${nodeAlias}_focus' : 'tmpl_${level}_${nodeAlias}_blur'`;

<template name="tmpl_${level}_${nodeAlias}_focus">
<${nodeName} ${this.buildAttribute(comp.attributes, nodeName)} id="{{i.uid||i.sid}}" data-sid="{{i.sid}}">${children}</${nodeName}>
<${nodeName} ${this.buildAttribute(comp.attributes, nodeName)} id="{{i.uid||i.${"s" /* Shortcuts.Sid */}}}" data-${"s" /* Shortcuts.Sid */}="{{i.${"s" /* Shortcuts.Sid */}}}">${children}</${nodeName}>
</template>
<template name="tmpl_${level}_${nodeAlias}_blur">
<${nodeName} ${this.buildAttribute(attrs, nodeName)} id="{{i.uid||i.sid}}" data-sid="{{i.sid}}">${children}</${nodeName}>
<${nodeName} ${this.buildAttribute(attrs, nodeName)} id="{{i.uid||i.${"s" /* Shortcuts.Sid */}}}" data-${"s" /* Shortcuts.Sid */}="{{i.${"s" /* Shortcuts.Sid */}}}">${children}</${nodeName}>
</template>

@@ -1097,2 +1105,3 @@ `;

case 'catch-view':
case 'click-view':
case 'static-view':

@@ -1117,3 +1126,3 @@ case 'pure-view':

<template name="tmpl_${level}_${nodeAlias}">
<${nodeName} ${this.buildAttribute(comp.attributes, comp.nodeName)} id="{{i.uid||i.sid}}" data-sid="{{i.sid}}">${children}</${nodeName}>
<${nodeName} ${this.buildAttribute(comp.attributes, comp.nodeName)} id="{{i.uid||i.${"s" /* Shortcuts.Sid */}}}" data-${"s" /* Shortcuts.Sid */}="{{i.${"s" /* Shortcuts.Sid */}}}">${children}</${nodeName}>
</template>

@@ -1134,3 +1143,3 @@ `;

buildThirdPartyTemplate(level, componentConfig) {
const { Adapter, isSupportRecursive, supportXS, nestElements } = this;
const { isSupportRecursive, isUseXS, nestElements } = this;
const nextLevel = isSupportRecursive ? 0 : level + 1;

@@ -1142,3 +1151,3 @@ let template = '';

<template name="tmpl_${level}_${compName}">
<${compName} i="{{i}}" l="{{l}}" id="{{i.uid||i.sid}}" data-sid="{{i.sid}}">
<${compName} i="{{i}}" l="{{l}}" id="{{i.uid||i.${"s" /* Shortcuts.Sid */}}}" data-${"s" /* Shortcuts.Sid */}="{{i.${"s" /* Shortcuts.Sid */}}}">
</${compName}>

@@ -1149,3 +1158,3 @@ </template>

else {
if (!isSupportRecursive && supportXS && nestElements.has(compName) && level + 1 > nestElements.get(compName))
if (!isSupportRecursive && isUseXS && nestElements.has(compName) && level + 1 > nestElements.get(compName))
return;

@@ -1159,9 +1168,7 @@ let child = this.getChildrenTemplate(nextLevel);

: `
<block ${Adapter.for}="{{i.${"cn" /* Shortcuts.Childnodes */}}}" ${Adapter.key}="sid">
${child}
</block>
${child}
`;
template += `
<template name="tmpl_${level}_${compName}">
<${compName} ${this.buildThirdPartyAttr(attrs, this.thirdPartyPatcher[compName] || {})} id="{{i.uid||i.sid}}" data-sid="{{i.sid}}">${children}</${compName}>
<${compName} ${this.buildThirdPartyAttr(attrs, this.thirdPartyPatcher[compName] || {})} id="{{i.uid||i.${"s" /* Shortcuts.Sid */}}}" data-${"s" /* Shortcuts.Sid */}="{{i.${"s" /* Shortcuts.Sid */}}}">${children}</${compName}>
</template>

@@ -1175,7 +1182,7 @@ `;

buildContainerTemplate(level) {
const tmpl = `<block ${this.Adapter.if}="{{i.nn === '${this.componentsAlias['#text']._num}'}}">
const tmpl = `<block ${this.Adapter.if}="{{i.${"n" /* Shortcuts.NodeName */} === '${this.componentsAlias['#text']._num}'}}">
<template is="tmpl_0_${this.componentsAlias['#text']._num}" data="{{${this.dataKeymap('i:i')}}}" />
</block>
<block ${this.Adapter.else}>
${!this.isSupportRecursive && this.supportXS ? '<comp i="{{i}}" l="{{l}}" />' : '<comp i="{{i}}" />'}
${!this.isSupportRecursive && this.isUseXS ? '<comp i="{{i}}" l="{{l}}" />' : '<comp i="{{i}}" />'}
</block>`;

@@ -1200,2 +1207,5 @@ return `

}
buildXsImportTemplate(_filePath) {
return this.isUseXS ? this.buildXsTemplate(_filePath) + '\n' : '';
}
mergeComponents(ctx, patch) {

@@ -1212,6 +1222,6 @@ ctx.helper.recursiveMerge(this.internalComponents, patch);

}
buildXSTepFocus(nn) {
buildXSTepFocus(n) {
return `function(i, prefix) {
var s = i.focus !== undefined ? 'focus' : 'blur'
return prefix + i.${nn} + '_' + s
return prefix + i.${n} + '_' + s
}`;

@@ -1262,3 +1272,3 @@ }

for (let i = 0; i < this.baseLevel; i++) {
template += this.supportXS
template += this.isUseXS
? this.buildOptimizeFloor(i, components, this.baseLevel === i + 1)

@@ -1265,0 +1275,0 @@ : this.buildFloor(i, components, this.baseLevel === i + 1);

@@ -141,3 +141,4 @@ import { internalComponents } from './components.js';

PureView: viewAttrs,
CatchView: viewAttrs
CatchView: viewAttrs,
ClickView: viewAttrs,
};

@@ -147,3 +148,3 @@ origin = Object.assign(Object.assign({}, origin), extraList);

.sort((a, b) => {
const reg = /^(Static|Pure|Catch)*(View|Image|Text)$/;
const reg = /^(Static|Pure|Catch|Click)*(View|Image|Text)$/;
const isACommonly = reg.test(a);

@@ -150,0 +151,0 @@ const isBCommonly = reg.test(b);

{
"name": "@tarojs/shared",
"version": "4.0.6",
"version": "4.0.7-alpha.0",
"description": "Taro utils internal use.",

@@ -5,0 +5,0 @@ "author": "O2Team",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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