@bytedance/mona-shared
Advanced tools
Comparing version 0.2.0-alpha.6 to 0.2.0-alpha.7
@@ -73,2 +73,5 @@ export declare const RENDER_NODE: { | ||
}; | ||
export declare const ComponentAliasMap: Record<string, string>; | ||
export declare const MiniComponentAliasMap: Record<string, string>; | ||
export declare const CUSTOM_REF = "__ref"; | ||
export declare const CUSTOM_COMPONENT_PROTOCOL = "native://"; | ||
export declare const GLOBAL_LIFECYCLE_STORE = "_mona_app_lifecycle"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ComponentAliasMap = exports.ComponentType = exports.webComponentType = exports.RENDER_NODE = void 0; | ||
exports.GLOBAL_LIFECYCLE_STORE = exports.CUSTOM_COMPONENT_PROTOCOL = exports.CUSTOM_REF = exports.MiniComponentAliasMap = exports.ComponentType = exports.webComponentType = exports.RENDER_NODE = void 0; | ||
exports.RENDER_NODE = { | ||
@@ -48,5 +48,18 @@ COMPLIER_KEY: 'k', | ||
'open-data': '35', | ||
// ptext的值不要随意改变, 改ptext需将base.ttml.ejs中 mona-36中的36做替换 | ||
ptext: '36', | ||
}; | ||
// TODO:开发模式语义化, 小程序运行时 build两份代码, index.production.js, index.development.js | ||
// if (process.env.NODE_ENV === 'production') { | ||
// RENDER_NODE = { | ||
// COMPLIER_KEY: 'key', | ||
// COMPLIER_TYPE: 'type', | ||
// COMPLIER_NODES: 'nodes', | ||
// COMPLIER_CHILDREN: 'children', | ||
// COMPLIER_TEXT: 'text', | ||
// COMPLIER_PROPS: 'props', | ||
// }; | ||
// for (const k in MiniComponentType) { | ||
// MiniComponentType[k as keyof typeof MiniComponentType] = k; | ||
// } | ||
// } | ||
exports.webComponentType = { | ||
@@ -67,6 +80,9 @@ span: MiniComponentType.text, | ||
exports.ComponentType = Object.assign(Object.assign({}, exports.webComponentType), MiniComponentType); | ||
exports.ComponentAliasMap = Object.keys(MiniComponentType).reduce((pre, item) => { | ||
exports.MiniComponentAliasMap = Object.keys(MiniComponentType).reduce((pre, item) => { | ||
pre[MiniComponentType[item]] = item; | ||
return pre; | ||
}, {}); | ||
exports.CUSTOM_REF = '__ref'; | ||
exports.CUSTOM_COMPONENT_PROTOCOL = 'native://'; | ||
exports.GLOBAL_LIFECYCLE_STORE = '_mona_app_lifecycle'; | ||
//# sourceMappingURL=constants.js.map |
@@ -22,3 +22,8 @@ "use strict"; | ||
exports.default = formatPath; | ||
// 参考reactV6 | ||
// MIT License | ||
// Copyright (c) React Training 2015-2019 Copyright (c) Remix Software 2020-2021 | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
// 参考react-routerV6 | ||
// 以下函数参考 https://github.com/remix-run/react-router | ||
@@ -28,5 +33,3 @@ function resolveLocation(to, fromPathname = '/') { | ||
const from = fromPathname.startsWith('/') ? fromPathname.split('/').slice(0, -1).join('/') : fromPathname; | ||
let pathname = toPathname | ||
? resolvePathname(toPathname, toPathname.startsWith('/') ? '/' : from) | ||
: from; | ||
let pathname = toPathname ? resolvePathname(toPathname, toPathname.startsWith('/') ? '/' : from) : from; | ||
return `${pathname}${search ? `?${search}` : ''}`; | ||
@@ -43,3 +46,2 @@ } | ||
if (segment === '..') { | ||
// Keep the root "" segment so the pathname starts at / | ||
if (segments.length > 1) | ||
@@ -46,0 +48,0 @@ segments.pop(); |
@@ -5,3 +5,5 @@ export { default as readConfig } from "./readConfig"; | ||
export { default as formatPath } from "./formatPath"; | ||
export { isClassComponent } from "./reactNode"; | ||
export * from "./domain"; | ||
export * from "./search"; | ||
export { RENDER_NODE, ComponentType, ComponentAliasMap } from "./constants"; | ||
export * from "./constants"; |
@@ -16,3 +16,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ComponentAliasMap = exports.ComponentType = exports.RENDER_NODE = exports.formatPath = exports.formatAppConfig = exports.searchScriptFile = exports.readConfig = void 0; | ||
exports.isClassComponent = exports.formatPath = exports.formatAppConfig = exports.searchScriptFile = exports.readConfig = void 0; | ||
// please copy web file to index.web.ts | ||
@@ -27,7 +27,7 @@ var readConfig_1 = require("./readConfig"); | ||
Object.defineProperty(exports, "formatPath", { enumerable: true, get: function () { return __importDefault(formatPath_1).default; } }); | ||
var reactNode_1 = require("./reactNode"); | ||
Object.defineProperty(exports, "isClassComponent", { enumerable: true, get: function () { return reactNode_1.isClassComponent; } }); | ||
__exportStar(require("./domain"), exports); | ||
__exportStar(require("./search"), exports); | ||
var constants_1 = require("./constants"); | ||
Object.defineProperty(exports, "RENDER_NODE", { enumerable: true, get: function () { return constants_1.RENDER_NODE; } }); | ||
Object.defineProperty(exports, "ComponentType", { enumerable: true, get: function () { return constants_1.ComponentType; } }); | ||
Object.defineProperty(exports, "ComponentAliasMap", { enumerable: true, get: function () { return constants_1.ComponentAliasMap; } }); | ||
__exportStar(require("./constants"), exports); | ||
//# sourceMappingURL=index.js.map |
export { default as formatPath } from "./formatPath"; | ||
export { isClassComponent } from "./reactNode"; | ||
export * from "./search"; | ||
export { RENDER_NODE, ComponentType, ComponentAliasMap } from "./constants"; | ||
export * from "./constants"; |
@@ -16,10 +16,9 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ComponentAliasMap = exports.ComponentType = exports.RENDER_NODE = exports.formatPath = void 0; | ||
exports.isClassComponent = exports.formatPath = void 0; | ||
var formatPath_1 = require("./formatPath"); | ||
Object.defineProperty(exports, "formatPath", { enumerable: true, get: function () { return __importDefault(formatPath_1).default; } }); | ||
var reactNode_1 = require("./reactNode"); | ||
Object.defineProperty(exports, "isClassComponent", { enumerable: true, get: function () { return reactNode_1.isClassComponent; } }); | ||
__exportStar(require("./search"), exports); | ||
var constants_1 = require("./constants"); | ||
Object.defineProperty(exports, "RENDER_NODE", { enumerable: true, get: function () { return constants_1.RENDER_NODE; } }); | ||
Object.defineProperty(exports, "ComponentType", { enumerable: true, get: function () { return constants_1.ComponentType; } }); | ||
Object.defineProperty(exports, "ComponentAliasMap", { enumerable: true, get: function () { return constants_1.ComponentAliasMap; } }); | ||
__exportStar(require("./constants"), exports); | ||
//# sourceMappingURL=index.web.js.map |
@@ -1,4 +0,4 @@ | ||
export declare function readTypescriptFile(filename: string): Record<string, any>; | ||
export declare function readTypescriptFile(filename: string): any; | ||
export declare function readJavascriptFile(filename: string): any; | ||
declare function readConfig<T = any>(filename: string): T; | ||
export default readConfig; |
@@ -10,26 +10,36 @@ "use strict"; | ||
function readTypescriptFile(filename) { | ||
require('@babel/register')({ | ||
presets: [ | ||
[require.resolve('@babel/preset-env'), { modules: 'commonjs' }], | ||
require.resolve('@babel/preset-typescript'), | ||
], | ||
extensions: ['.ts', '.tsx'], | ||
cache: false, | ||
}); | ||
delete require.cache[require.resolve(filename)]; | ||
const config = require(filename).default || require(filename); | ||
return config; | ||
try { | ||
require('@babel/register')({ | ||
presets: [ | ||
[require.resolve('@babel/preset-env'), { modules: 'commonjs' }], | ||
require.resolve('@babel/preset-typescript'), | ||
], | ||
extensions: ['.ts', '.tsx'], | ||
cache: false, | ||
}); | ||
delete require.cache[require.resolve(filename)]; | ||
const config = require(filename).default || require(filename); | ||
return config; | ||
} | ||
catch (_) { | ||
return null; | ||
} | ||
} | ||
exports.readTypescriptFile = readTypescriptFile; | ||
function readJavascriptFile(filename) { | ||
require('@babel/register')({ | ||
presets: [ | ||
[require.resolve('@babel/preset-env'), { modules: 'commonjs' }], | ||
], | ||
extensions: ['.js', 'jsx'], | ||
cache: false, | ||
}); | ||
delete require.cache[require.resolve(filename)]; | ||
const config = require(filename).default || require(filename); | ||
return config; | ||
try { | ||
require('@babel/register')({ | ||
presets: [ | ||
[require.resolve('@babel/preset-env'), { modules: 'commonjs' }], | ||
], | ||
extensions: ['.js', 'jsx'], | ||
cache: false, | ||
}); | ||
delete require.cache[require.resolve(filename)]; | ||
const config = require(filename).default || require(filename); | ||
return config; | ||
} | ||
catch (_) { | ||
return null; | ||
} | ||
} | ||
@@ -36,0 +46,0 @@ exports.readJavascriptFile = readJavascriptFile; |
export declare function parseSearch(search: string): Record<string, string>; | ||
export declare function stringifySearch(searchObj: Record<string, string>): string; | ||
export declare function stringifySearch(searchObj: Record<string, any>): string; |
{ | ||
"name": "@bytedance/mona-shared", | ||
"displayName": "mona-shared", | ||
"version": "0.2.0-alpha.6", | ||
"version": "0.2.0-alpha.7", | ||
"description": "mona shared utils", | ||
@@ -12,3 +12,4 @@ "main": "./dist/index.js", | ||
"start": "ttsc -b -w", | ||
"clean": "rm -rf dist" | ||
"clean": "rm -rf dist", | ||
"test": "jest" | ||
}, | ||
@@ -25,2 +26,3 @@ "files": [ | ||
"@types/node": "^16.4.5", | ||
"react": "^17.0.2", | ||
"ttypescript": "^1.5.12", | ||
@@ -34,3 +36,3 @@ "typescript-json-schema": "^0.43.0", | ||
}, | ||
"gitHead": "3d2361f23b3fbf0a1b6c885929851a2d3af1305f" | ||
"gitHead": "8cafcf9a9ec6a2c4ed7d3ca33468f426fb8a0467" | ||
} |
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
32235
35
511
5