Socket
Socket
Sign inDemoInstall

@tarojs/shared

Package Overview
Dependencies
Maintainers
10
Versions
634
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.0-canary.13 to 4.0.0

17

dist/components.d.ts

@@ -1,2 +0,2 @@

declare const touchEvents: {
export declare const touchEvents: {
bindTouchStart: string;

@@ -8,3 +8,3 @@ bindTouchMove: string;

};
declare const animation: {
export declare const animation: {
animation: string;

@@ -16,8 +16,7 @@ bindAnimationStart: string;

};
declare function singleQuote(s: string): string;
declare const internalComponents: Record<string, Record<string, string>>;
declare const controlledComponent: Set<string>;
declare const focusComponents: Set<string>;
declare const voidElements: Set<string>;
declare const nestElements: Map<string, number>;
export { touchEvents, animation, singleQuote, internalComponents, controlledComponent, focusComponents, voidElements, nestElements };
export declare function singleQuote(s: string): string;
export declare const internalComponents: Record<string, Record<string, string>>;
export declare const controlledComponent: Set<string>;
export declare const focusComponents: Set<string>;
export declare const voidElements: Set<string>;
export declare const nestElements: Map<string, number>;

@@ -1,2 +0,2 @@

declare enum PLATFORM_TYPE {
export declare enum PLATFORM_TYPE {
MINI = "mini",

@@ -8,3 +8,3 @@ WEB = "web",

}
declare const PLATFORM_CONFIG_MAP: {
export declare const PLATFORM_CONFIG_MAP: {
h5: {

@@ -26,2 +26,1 @@ type: PLATFORM_TYPE;

};
export { PLATFORM_TYPE, PLATFORM_CONFIG_MAP };

@@ -1,2 +0,2 @@

import { Events } from "./event-emitter.js";
import { Events } from './event-emitter';
interface RouteEvt extends Events {

@@ -10,6 +10,6 @@ addEvents: (events: any) => void;

}
declare const EventChannel: {
export declare const EventChannel: {
pageChannel: PageEvt;
routeChannel: RouteEvt;
};
export { EventChannel };
export {};
type EventName = string | symbol;
type EventCallbacks = Record<EventName, Record<'next' | 'tail', unknown>>;
declare class Events {
export declare class Events {
protected callbacks?: EventCallbacks;
static eventSplitter: string;
// Note: Harmony ACE API 8 开发板不支持使用正则 split 字符串 /\s+/
constructor(opts?: any);

@@ -13,2 +12,2 @@ on(eventName: EventName, callback: (...args: any[]) => void, context?: any): this;

}
export { Events };
export {};

@@ -553,3 +553,3 @@ 'use strict';

'onResize',
'defer:onTabItemTap',
'defer:onTabItemTap', // defer: 需要等页面组件挂载后再调用
'onTitleClick',

@@ -556,0 +556,0 @@ 'onOptionMenuClick',

@@ -1,9 +0,9 @@

export * from "./components.js";
export * from "./constants.js";
export * from "./event-channel.js";
export * from "./event-emitter.js";
export * from "./is.js";
export * from "./native-apis.js";
export * from "./runtime-hooks.js";
export { Shortcuts } from "./shortcuts.js";
export * from "./utils.js";
export * from './components';
export * from './constants';
export * from './event-channel';
export * from './event-emitter';
export * from './is';
export * from './native-apis';
export * from './runtime-hooks';
export { Shortcuts } from './shortcuts';
export * from './utils';

@@ -1,11 +0,10 @@

declare function isString(o: unknown): o is string;
declare function isUndefined(o: unknown): o is undefined;
declare function isNull(o: unknown): o is null;
declare function isObject<T>(o: unknown): o is T;
declare function isBoolean(o: unknown): o is boolean;
declare function isFunction(o: unknown): o is (...args: any[]) => any;
declare function isNumber(o: unknown): o is number;
declare function isBooleanStringLiteral(o: unknown): o is string;
declare const isArray: (arg: any) => arg is any[];
declare const isWebPlatform: () => boolean;
export { isString, isUndefined, isNull, isObject, isBoolean, isFunction, isNumber, isBooleanStringLiteral, isArray, isWebPlatform };
export declare function isString(o: unknown): o is string;
export declare function isUndefined(o: unknown): o is undefined;
export declare function isNull(o: unknown): o is null;
export declare function isObject<T>(o: unknown): o is T;
export declare function isBoolean(o: unknown): o is boolean;
export declare function isFunction(o: unknown): o is (...args: any[]) => any;
export declare function isNumber(o: unknown): o is number;
export declare function isBooleanStringLiteral(o: unknown): o is string;
export declare const isArray: (arg: any) => arg is any[];
export declare const isWebPlatform: () => boolean;

@@ -15,3 +15,3 @@ type IObject = Record<string, any>;

}
interface IApiDiff {
export interface IApiDiff {
[key: string]: {

@@ -35,2 +35,2 @@ /** API重命名 */

declare function processApis(taro: any, global: any, config?: IProcessApisIOptions): void;
export { IApiDiff, processApis };
export { processApis };

@@ -1,123 +0,5 @@

/**
* 这里我们需要关心的小程序种类有两类:
* 1. 模板递归:
* - 支持:tmpl0 套 tmpl0
* - 不支持:这就使得我们必须生成多级的模板,tmpl0 套 tmpl1,tmpl1 套 tmpl2……
* 直到超过阈值 N (N = config.miniapp.baseLevel) tmplN 会套组件 comp,组件 comp 重新再套 tmpl0。
* 2. 小程序脚本语言(wxs, sjs, etc...):
* - 支持:可以在模板使用函数缩减模板大小或提高性能(存疑),例如判断一个值是不是假值(falsy value)。
* 将来或许会把数据序列化^1 的操作也放到小程序脚本语言里。
* - 不支持:使用纯 *xml 语法
*
* ^1: packages/taro-runtime/src/hydrate.ts
*/
import { internalComponents } from "./components.js";
import { Shortcuts } from "./shortcuts.js";
import { capitalize, toCamelCase } from "./utils.js";
import { Events } from "./event-emitter.js";
interface Component {
nodeName: string;
nodeAlias: string;
attributes: Attributes;
}
interface Components {
[key: string]: Record<string, string>;
}
interface ComponentConfig {
includes: Set<string>;
exclude: Set<string>;
thirdPartyComponents: Map<string, Set<string>>;
includeAll: boolean;
}
interface IAdapter {
if: string;
else: string;
elseif: string;
for: string;
forItem: string;
forIndex: string;
key: string;
xs?: string;
type: string;
}
type Attributes = Record<string, string>;
declare const styles: {
style: string;
class: string;
};
declare const events: {
bindtap: string;
};
declare class BaseTemplate {
protected _baseLevel: number;
protected exportExpr: string;
protected isSupportRecursive: boolean;
protected miniComponents: Components;
protected thirdPartyPatcher: Record<string, Record<string, string>>;
protected modifyCompProps?: (compName: string, target: Record<string, string>) => Record<string, string>;
protected modifyLoopBody?: (child: string, nodeName: string) => string;
protected modifyLoopContainer?: (children: string, nodeName: string) => string;
protected modifyTemplateResult?: (res: string, nodeName: string, level: number, children: string) => string;
protected modifyThirdPartyLoopBody?: (child: string, nodeName: string) => string;
supportXS: boolean;
isXMLSupportRecursiveReference: boolean;
Adapter: IAdapter;
/** 组件列表 */
internalComponents: Record<string, Record<string, string>>;
/** 可以 focus 聚焦的组件 */
focusComponents: Set<string>;
/** 不需要渲染子节点的元素 */
voidElements: Set<string>;
/** 可以递归调用自身的组件 */
nestElements: Map<string, number>;
componentsAlias: any;
set baseLevel(lv: number);
get baseLevel(): number;
private buildAttribute;
protected replacePropName(name: string, value: string, _componentName?: string, _componentAlias?: any): string;
createMiniComponents(components: Components): Components;
protected buildBaseTemplate(): string;
protected buildThirdPartyAttr(attrs: Set<string>, patcher?: Record<string, string>): string;
protected buildComponentTemplate(comp: Component, level: number): string;
private getChildrenTemplate;
private getChildren;
protected buildFocusComponentTemplate(comp: Component, level: number): string;
protected buildStandardComponentTemplate(comp: Component, level: number): string;
protected buildPlainTextTemplate(level: number): string;
protected buildThirdPartyTemplate(level: number, componentConfig: ComponentConfig): string;
// 最后一层的 comp 需要引用 container 进行重新的模版循环,其他情况不需要 container
protected buildContainerTemplate(level: number): string;
protected dataKeymap(keymap: string): string;
protected getEvents(): any;
protected getAttrValue(value: string, _key: string, _nodeName: string): string;
buildXsTemplate(_filePath?: string): string;
buildPageTemplate: (baseTempPath: string, _page?: {
content: Record<string, any>;
path: string;
}) => string;
buildBaseComponentTemplate: (ext: string) => string;
buildCustomComponentTemplate: (ext: string) => string;
buildXScript: () => string;
mergeComponents(ctx: any, patch: Record<string, Record<string, string>>): void;
mergeThirdPartyComponents(patch: Record<string, Record<string, string>>): void;
protected buildXSTmplName(): string;
protected buildXSTepFocus(nn: string): string;
protected buildXSTmpExtra(): string;
}
declare class RecursiveTemplate extends BaseTemplate {
isSupportRecursive: boolean;
buildTemplate: (componentConfig: ComponentConfig) => string;
}
declare class UnRecursiveTemplate extends BaseTemplate {
isSupportRecursive: boolean;
protected _baseLevel: number;
private componentConfig;
buildTemplate: (componentConfig: ComponentConfig) => string;
protected buildFloor(level: number, components: string[], restart?: boolean): string;
protected buildOptimizeFloor(level: number, components: string[], restart?: boolean): string;
protected buildXSTmplName(): string;
protected buildXSTmpExtra(): string;
}
import { Events } from './event-emitter';
import type { Shortcuts } from './template';
type TFunc = (...args: any[]) => any;
declare enum HOOK_TYPE {
export declare enum HOOK_TYPE {
SINGLE = 0,

@@ -133,17 +15,17 @@ MULTI = 1,

app: [
string,
string,
string, /** onLaunch */
string, /** onShow */
string /** onHide */
];
page: [
string,
string,
string,
string,
string,
string[],
string, /** onLoad */
string, /** onUnload */
string, /** onReady */
string, /** onShow */
string, /** onHide */
string[], /** others */
string[] /** side-effects */
];
component: [
string,
string, /** attached */
string

@@ -180,4 +62,4 @@ ];

}
declare function TaroHook(type: HOOK_TYPE, initial?: TFunc): Hook;
declare class TaroHooks<T extends Record<string, TFunc> = any> extends Events {
export declare function TaroHook(type: HOOK_TYPE, initial?: TFunc): Hook;
export declare class TaroHooks<T extends Record<string, TFunc> = any> extends Events {
hooks: Record<keyof T, Hook>;

@@ -204,3 +86,2 @@ constructor(hooks: Record<keyof T, Hook>, opts?: any);

getSpecialNodes: () => string[];
/** 解决 Vue2 布尔值属性值的设置问题 */
onRemoveAttribute: (element: any, qualifiedName: string) => boolean;

@@ -264,3 +145,3 @@ /** 用于把 React 同一事件回调中的所有 setState 合并到同一个更新处理中 */

};
declare const hooks: TaroHooks<ITaroHooks>;
export { IAdapter, Attributes, styles, events, BaseTemplate, RecursiveTemplate, UnRecursiveTemplate, capitalize, internalComponents, Shortcuts, toCamelCase, HOOK_TYPE, TaroHook, TaroHooks, hooks };
export declare const hooks: TaroHooks<ITaroHooks>;
export {};

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

'onResize',
'defer:onTabItemTap',
'defer:onTabItemTap', // defer: 需要等页面组件挂载后再调用
'onTitleClick',

@@ -30,0 +30,0 @@ 'onOptionMenuClick',

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

'onResize',
'defer:onTabItemTap',
'defer:onTabItemTap', // defer: 需要等页面组件挂载后再调用
'onTitleClick',

@@ -554,0 +554,0 @@ 'onOptionMenuClick',

@@ -1,2 +0,2 @@

declare const enum Shortcuts {
export declare const enum Shortcuts {
Container = "container",

@@ -11,2 +11,1 @@ Childnodes = "cn",

}
export { Shortcuts };

@@ -1,16 +0,17 @@

declare const internalComponents: Record<string, Record<string, string>>;
// 字符串简写
declare const enum Shortcuts {
Container = "container",
Childnodes = "cn",
Text = "v",
NodeType = "nt",
NodeName = "nn",
// Attrtibutes
Style = "st",
Class = "cl",
Src = "src"
}
declare function toCamelCase(s: string): string;
declare function capitalize(s: string): string;
/**
* 这里我们需要关心的小程序种类有两类:
* 1. 模板递归:
* - 支持:tmpl0 套 tmpl0
* - 不支持:这就使得我们必须生成多级的模板,tmpl0 套 tmpl1,tmpl1 套 tmpl2……
* 直到超过阈值 N (N = config.miniapp.baseLevel) tmplN 会套组件 comp,组件 comp 重新再套 tmpl0。
* 2. 小程序脚本语言(wxs, sjs, etc...):
* - 支持:可以在模板使用函数缩减模板大小或提高性能(存疑),例如判断一个值是不是假值(falsy value)。
* 将来或许会把数据序列化^1 的操作也放到小程序脚本语言里。
* - 不支持:使用纯 *xml 语法
*
* ^1: packages/taro-runtime/src/hydrate.ts
*/
import { internalComponents } from './components';
import { Shortcuts } from './shortcuts';
import { capitalize, toCamelCase } from './utils';
interface Component {

@@ -30,3 +31,3 @@ nodeName: string;

}
interface IAdapter {
export interface IAdapter {
if: string;

@@ -42,11 +43,11 @@ else: string;

}
type Attributes = Record<string, string>;
declare const styles: {
export type Attributes = Record<string, string>;
export declare const styles: {
style: string;
class: string;
};
declare const events: {
export declare const events: {
bindtap: string;
};
declare class BaseTemplate {
export declare class BaseTemplate {
protected _baseLevel: number;

@@ -88,3 +89,2 @@ protected exportExpr: string;

protected buildThirdPartyTemplate(level: number, componentConfig: ComponentConfig): string;
// 最后一层的 comp 需要引用 container 进行重新的模版循环,其他情况不需要 container
protected buildContainerTemplate(level: number): string;

@@ -108,7 +108,7 @@ protected dataKeymap(keymap: string): string;

}
declare class RecursiveTemplate extends BaseTemplate {
export declare class RecursiveTemplate extends BaseTemplate {
isSupportRecursive: boolean;
buildTemplate: (componentConfig: ComponentConfig) => string;
}
declare class UnRecursiveTemplate extends BaseTemplate {
export declare class UnRecursiveTemplate extends BaseTemplate {
isSupportRecursive: boolean;

@@ -123,2 +123,2 @@ protected _baseLevel: number;

}
export { IAdapter, Attributes, styles, events, BaseTemplate, RecursiveTemplate, UnRecursiveTemplate, capitalize, internalComponents, Shortcuts, toCamelCase };
export { capitalize, internalComponents, Shortcuts, toCamelCase };

@@ -292,12 +292,2 @@ 'use strict';

};
new Set([
'input',
'checkbox',
'picker',
'picker-view',
'radio',
'slider',
'switch',
'textarea'
]);
const focusComponents = new Set([

@@ -510,3 +500,3 @@ 'input',

'onResize',
'defer:onTabItemTap',
'defer:onTabItemTap', // defer: 需要等页面组件挂载后再调用
'onTitleClick',

@@ -513,0 +503,0 @@ 'onOptionMenuClick',

@@ -1,6 +0,6 @@

import { internalComponents } from "./components.js";
import { PLATFORM_TYPE } from "./constants.js";
declare const EMPTY_OBJ: any;
declare const EMPTY_ARR: never[];
declare const noop: (..._: unknown[]) => void;
import { internalComponents } from './components';
import { PLATFORM_TYPE } from './constants';
export declare const EMPTY_OBJ: any;
export declare const EMPTY_ARR: never[];
export declare const noop: (..._: unknown[]) => void;
/**

@@ -11,3 +11,3 @@ * Boxed value.

*/
interface Box<T> {
export interface Box<T> {
v: T;

@@ -22,3 +22,3 @@ }

*/
declare const box: <T>(v: T) => {
export declare const box: <T>(v: T) => {
v: T;

@@ -33,8 +33,8 @@ };

*/
declare const unbox: <T>(b: Box<T>) => T;
declare function toDashed(s: string): string;
declare function toCamelCase(s: string): string;
declare const toKebabCase: (string: any) => any;
declare function capitalize(s: string): string;
declare const hasOwn: (val: Record<any, any>, key: string | symbol) => any;
export declare const unbox: <T>(b: Box<T>) => T;
export declare function toDashed(s: string): string;
export declare function toCamelCase(s: string): string;
export declare const toKebabCase: (string: any) => any;
export declare function capitalize(s: string): string;
export declare const hasOwn: (val: Record<any, any>, key: string | symbol) => any;
/**

@@ -46,16 +46,15 @@ * ensure takes a condition and throw a error if the condition fails,

*/
declare function ensure(condition: boolean, msg: string): asserts condition;
declare function warn(condition: boolean, msg: string): void;
declare function queryToJson(str: any): {};
declare function getUniqueKey(): string;
declare function cacheDataSet(key: any, val: any): void;
declare function cacheDataGet(key: any, delelteAfterGet?: any): any;
declare function cacheDataHas(key: any): boolean;
declare function mergeInternalComponents(components: any): Record<string, Record<string, string>>;
declare function getComponentsAlias(origin: typeof internalComponents): {};
declare function getPlatformType(platform?: string, configNameOrType?: string): PLATFORM_TYPE;
declare function mergeReconciler(hostConfig: any, hooksForTest?: any): void;
declare function nonsupport(api: any): () => void;
declare function setUniqueKeyToRoute(key: string, obj: any): void;
declare function indent(str: string, size: number): string;
export { EMPTY_OBJ, EMPTY_ARR, noop, Box, box, unbox, toDashed, toCamelCase, toKebabCase, capitalize, hasOwn, ensure, warn, queryToJson, getUniqueKey, cacheDataSet, cacheDataGet, cacheDataHas, mergeInternalComponents, getComponentsAlias, getPlatformType, mergeReconciler, nonsupport, setUniqueKeyToRoute, indent };
export declare function ensure(condition: boolean, msg: string): asserts condition;
export declare function warn(condition: boolean, msg: string): void;
export declare function queryToJson(str: any): {};
export declare function getUniqueKey(): string;
export declare function cacheDataSet(key: any, val: any): void;
export declare function cacheDataGet(key: any, delelteAfterGet?: any): any;
export declare function cacheDataHas(key: any): boolean;
export declare function mergeInternalComponents(components: any): Record<string, Record<string, string>>;
export declare function getComponentsAlias(origin: typeof internalComponents): {};
export declare function getPlatformType(platform?: string, configNameOrType?: string): PLATFORM_TYPE;
export declare function mergeReconciler(hostConfig: any, hooksForTest?: any): void;
export declare function nonsupport(api: any): () => void;
export declare function setUniqueKeyToRoute(key: string, obj: any): void;
export declare function indent(str: string, size: number): string;
{
"name": "@tarojs/shared",
"version": "4.0.0-canary.13",
"version": "4.0.0",
"description": "Taro utils internal use.",
"author": "yuche <i@yuche.me>",
"homepage": "https://github.com/nervjs/taro/tree/master/packages/shared#readme",
"author": "O2Team",
"license": "MIT",

@@ -24,18 +23,17 @@ "browser": "dist/index.js",

},
"engines": {
"node": ">= 18"
},
"devDependencies": {
"@rollup/plugin-typescript": "^11.1.0",
"jest": "^29.3.1",
"jest-cli": "^29.3.1",
"lodash": "^4.17.21",
"rollup": "^3.8.1",
"rollup-plugin-ts": "^3.0.2",
"ts-jest": "^29.0.5",
"typescript": "^4.7.4"
"lodash": "^4.17.21"
},
"scripts": {
"prod": "pnpm run build",
"prebuild": "pnpm run clean",
"clean": "rimraf --impl=move-remove ./dist",
"build": "pnpm run rollup --environment NODE_ENV:production",
"dev": "pnpm run rollup --environment NODE_ENV:development -w",
"rollup": "rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript --bundleConfigAsCjs",
"rollup": "rollup --config rollup.config.ts --configPlugin typescript",
"test": "jest"
}
}

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

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