├── .npmrc ├── packages ├── jsx2mp-cli │ ├── .gitignore │ ├── .npmignore │ ├── demo │ │ ├── assets │ │ │ └── rax.png │ │ ├── package.json │ │ └── component.js │ ├── utils │ │ ├── removeExt.js │ │ ├── spinner.js │ │ ├── log.js │ │ └── platformConfig.js │ ├── default.js │ ├── bin │ │ └── jsx2mp.js │ ├── checkPkgVersion.js │ └── README.md ├── jsx-compiler │ ├── .npmignore │ ├── src │ │ ├── utils │ │ │ ├── createIncrement.js │ │ │ ├── generateId.js │ │ │ ├── createListKey.js │ │ │ ├── createListIndex.js │ │ │ ├── Expression.js │ │ │ ├── replaceComponentTagName.js │ │ │ ├── findIndex.js │ │ │ ├── checkModule.js │ │ │ ├── createBinding.js │ │ │ ├── getProgramPath.js │ │ │ ├── isSlotScopeNode.js │ │ │ ├── createJSXBinding.js │ │ │ ├── checkAttr.js │ │ │ ├── invokeModules.js │ │ │ ├── getReturnElementPath.js │ │ │ ├── getDefaultComponentFunctionPath.js │ │ │ ├── getListItem.js │ │ │ ├── createJSX.js │ │ │ ├── getParentListPath.js │ │ │ ├── isNativeComponent.js │ │ │ ├── CodeError.js │ │ │ ├── handleValidIdentifier.js │ │ │ ├── traverseNodePath.js │ │ │ ├── isFunctionComponent.js │ │ │ └── getDefaultExportedPath.js │ │ ├── options.js │ │ ├── baseComponents.js │ │ ├── getCompiledComponents.js │ │ ├── parser │ │ │ └── option.js │ │ ├── constants.js │ │ ├── codegen │ │ │ ├── genCode.js │ │ │ ├── genExpression.js │ │ │ └── index.js │ │ ├── index.js │ │ └── modules │ │ │ └── function.js │ ├── CHANGELOG.md │ └── package.json ├── eslint-plugin-rax-compile-time-miniapp │ ├── .gitignore │ ├── .npmignore │ ├── .eslintrc │ ├── docs │ │ └── rules │ │ │ ├── no_double_quotation.md │ │ │ ├── no_id_in_jsx.md │ │ │ ├── no_multiple_return.md │ │ │ ├── export_default_component.md │ │ │ ├── no_spread.md │ │ │ ├── no_multiple_component.md │ │ │ ├── no_import_next_export.md │ │ │ ├── no_hoc.md │ │ │ ├── no_return_arrays.md │ │ │ ├── return_jsx_in_map.md │ │ │ ├── no_multilevel_condition.md │ │ │ ├── no_temp_variable_in_loop_render.md │ │ │ └── no_multilevel_object.md │ ├── package.json │ ├── README.md │ ├── tests │ │ └── test_no_return_arrays.js │ └── src │ │ └── rules │ │ └── no_return_arrays.js ├── miniapp-render │ ├── src │ │ ├── builtInComponents │ │ │ ├── icon.js │ │ │ ├── label.js │ │ │ ├── cover-view.js │ │ │ ├── rich-text.js │ │ │ ├── movable-area.js │ │ │ ├── swiper-item.js │ │ │ ├── contact-button.js │ │ │ ├── picker-view-column.js │ │ │ ├── text.js │ │ │ ├── radio.js │ │ │ ├── checkbox.js │ │ │ ├── radio-group.js │ │ │ ├── progress.js │ │ │ ├── checkbox-group.js │ │ │ ├── form.js │ │ │ ├── image.js │ │ │ ├── cover-image.js │ │ │ ├── official-account.js │ │ │ ├── switch.js │ │ │ ├── web-view.js │ │ │ ├── navigator.js │ │ │ ├── editor.js │ │ │ ├── picker-view.js │ │ │ ├── slider.js │ │ │ ├── canvas.js │ │ │ ├── button.js │ │ │ ├── camera.js │ │ │ ├── picker.js │ │ │ ├── swiper.js │ │ │ ├── view.js │ │ │ └── live-pusher.js │ │ ├── bridge │ │ │ ├── events │ │ │ │ ├── getDomNodeFromEvt.js │ │ │ │ ├── callEvent.js │ │ │ │ ├── callSimpleEvent.js │ │ │ │ ├── baseEvents.js │ │ │ │ └── callSingleEvent.js │ │ │ └── lifeCycleAdapter.js │ │ ├── event │ │ │ └── custom-event.js │ │ ├── index.js │ │ ├── node │ │ │ └── comment.js │ │ └── utils │ │ │ ├── perf.js │ │ │ ├── tool.js │ │ │ └── tree.js │ ├── .npmignore │ ├── scripts │ │ └── build.js │ ├── babel.config.js │ └── __tests__ │ │ ├── util │ │ └── tool.test.js │ │ └── node │ │ └── comment.test.js ├── jsx2mp-runtime │ ├── src │ │ ├── host.js │ │ ├── forwardRef.js │ │ ├── kebabCase.js │ │ ├── version.js │ │ ├── memo.js │ │ ├── nextTick.js │ │ ├── adapter │ │ │ ├── getNativeEventBindTarget.js │ │ │ ├── getNativeAPI.js │ │ │ ├── getEventProps.js │ │ │ ├── index.js │ │ │ ├── getComponentBaseConfig.js │ │ │ └── attachRef.js │ │ ├── pageInstanceMap.js │ │ ├── valueEmitter.js │ │ ├── enqueueRender.js │ │ ├── getId.js │ │ ├── createContext.js │ │ ├── createRef.js │ │ ├── types.js │ │ ├── createStyle.js │ │ ├── scheduler.js │ │ └── classnames.js │ ├── CHANGELOG.md │ └── package.json ├── miniapp-history │ ├── src │ │ ├── constants.js │ │ ├── index.js │ │ ├── listeners.js │ │ └── History.js │ └── CHANGELOG.md ├── miniapp-runtime-config │ ├── src │ │ └── index.js │ └── CHANGELOG.md ├── driver-miniapp │ ├── CHANGELOG.md │ ├── src │ │ └── index.d.ts │ ├── package.json │ └── README.md ├── rax-miniapp-runtime-webpack-plugin │ ├── src │ │ ├── utils │ │ │ ├── addSingleQuote.js │ │ │ ├── isNpmModule.js │ │ │ ├── getSepProcessedPath.js │ │ │ ├── rmCurDirPathSymbol.js │ │ │ ├── isCSSFile.js │ │ │ ├── getAssetPath.js │ │ │ ├── getFinalRouteMap.js │ │ │ ├── addFileToCompilation.js │ │ │ └── minifyCode.js │ │ ├── static │ │ │ └── rax-default.css │ │ ├── platforms │ │ │ └── index.js │ │ ├── constants.js │ │ └── generators │ │ │ ├── pkg.js │ │ │ ├── index.js │ │ │ └── render.js │ └── package.json ├── rax-miniapp-babel-plugins │ ├── src │ │ ├── utils │ │ │ ├── getTagName.js │ │ │ ├── extMap.js │ │ │ ├── getFilePath.js │ │ │ ├── getPagePath.js │ │ │ └── CodeError.js │ │ ├── plugins │ │ │ ├── babel-plugin-external-module.js │ │ │ └── babel-plugin-remove-Function.js │ │ └── index.js │ ├── CHANGELOG.md │ ├── README-zh.md │ └── package.json ├── build-plugin-rax-miniapp-faas │ ├── tsconfig.json │ ├── README.md │ ├── package.json │ └── src │ │ └── package_process.ts ├── miniapp-compile-config │ ├── src │ │ ├── index.js │ │ └── plugins │ │ │ └── RemoveDefaultResult.js │ └── CHANGELOG.md ├── build-plugin-rax-miniapp-plugin │ ├── src │ │ ├── utils │ │ │ └── formatPath.js │ │ └── getOutputPath.js │ ├── CHANGELOG.md │ └── README.md ├── jsx2mp-loader │ ├── src │ │ ├── cached.js │ │ ├── defaultStyle.js │ │ ├── utils │ │ │ ├── addSourceMap.js │ │ │ ├── isMiniappComponent.js │ │ │ ├── parseRequest.js │ │ │ └── minifyCode.js │ │ └── file-loader.js │ └── CHANGELOG.md ├── miniapp-builder-shared │ ├── src │ │ ├── constants.js │ │ ├── index.js │ │ ├── utils │ │ │ └── getRouteName.js │ │ └── filterNativePages.js │ ├── package.json │ └── README.md ├── miniapp-lifecycles │ ├── src │ │ ├── index.d.ts │ │ └── index.js │ └── package.json └── rax-miniapp-config-webpack-plugin │ ├── package.json │ ├── src │ ├── safeWriteFile.js │ ├── handleIcon.js │ └── transformNativeConfig.js │ └── CHANGELOG.md ├── examples ├── with-miniapp-native-page │ ├── src │ │ ├── pages │ │ │ ├── NativeHome │ │ │ │ ├── index.acss │ │ │ │ ├── index.js │ │ │ │ ├── index.axml │ │ │ │ └── index.json │ │ │ └── Home │ │ │ │ ├── index.css │ │ │ │ └── index.jsx │ │ ├── public │ │ │ └── components │ │ │ │ ├── comp1 │ │ │ │ ├── index.js │ │ │ │ ├── index.axml │ │ │ │ └── index.json │ │ │ │ └── comp2 │ │ │ │ ├── index.js │ │ │ │ ├── index.axml │ │ │ │ └── index.json │ │ ├── components │ │ │ └── Logo │ │ │ │ ├── index.css │ │ │ │ └── index.jsx │ │ ├── app.js │ │ ├── app.json │ │ └── document │ │ │ └── index.jsx │ ├── .eslintrc.js │ ├── .gitignore │ ├── README.md │ └── build.json ├── app-lifecycle │ ├── .eslintrc.js │ ├── src │ │ ├── components │ │ │ └── Logo │ │ │ │ ├── index.css │ │ │ │ └── index.jsx │ │ ├── app.json │ │ ├── pages │ │ │ └── Home │ │ │ │ ├── index.css │ │ │ │ └── index.jsx │ │ ├── app.js │ │ └── document │ │ │ └── index.jsx │ ├── .gitignore │ ├── README.md │ ├── build.json │ └── package.json ├── event-handler │ ├── .eslintrc.js │ ├── src │ │ ├── app.js │ │ ├── components │ │ │ └── CustomComp │ │ │ │ ├── index.css │ │ │ │ └── index.jsx │ │ ├── app.json │ │ ├── pages │ │ │ └── Home │ │ │ │ └── index.css │ │ └── document │ │ │ └── index.jsx │ ├── .gitignore │ ├── README.md │ ├── build.json │ └── package.json ├── get-element │ ├── .eslintrc.js │ ├── src │ │ ├── components │ │ │ └── Logo │ │ │ │ ├── index.css │ │ │ │ └── index.jsx │ │ ├── app.json │ │ ├── pages │ │ │ └── Home │ │ │ │ └── index.css │ │ ├── app.js │ │ └── document │ │ │ └── index.jsx │ ├── abc.json │ ├── .gitignore │ ├── README.md │ ├── build.json │ └── package.json ├── use-input │ ├── .eslintrc.js │ ├── src │ │ ├── components │ │ │ └── Logo │ │ │ │ ├── index.css │ │ │ │ └── index.jsx │ │ ├── app.json │ │ ├── pages │ │ │ └── Home │ │ │ │ └── index.css │ │ ├── app.js │ │ └── document │ │ │ └── index.jsx │ ├── .gitignore │ ├── README.md │ └── build.json ├── with-miniapp-plugin-component │ ├── ali-miniapp-plugin │ │ ├── pages │ │ │ └── index │ │ │ │ ├── index.acss │ │ │ │ ├── index.json │ │ │ │ ├── index.js │ │ │ │ └── index.axml │ │ ├── components │ │ │ └── test │ │ │ │ ├── index.acss │ │ │ │ ├── index.json │ │ │ │ ├── index.axml │ │ │ │ └── index.js │ │ ├── index.js │ │ ├── api │ │ │ └── data.js │ │ └── plugin.json │ ├── .eslintrc.js │ ├── wechat-miniprogram-plugin │ │ ├── pages │ │ │ ├── hello-page.wxss │ │ │ ├── hello-page.json │ │ │ ├── hello-page.wxml │ │ │ └── hello-page.js │ │ ├── components │ │ │ ├── hello-component.json │ │ │ ├── hello-component.wxss │ │ │ ├── hello-component.wxml │ │ │ └── hello-component.js │ │ ├── index.js │ │ ├── plugin.json │ │ └── api │ │ │ └── data.js │ ├── src │ │ ├── app.js │ │ ├── pages │ │ │ └── Home │ │ │ │ ├── index.css │ │ │ │ └── index.jsx │ │ ├── app.json │ │ ├── components │ │ │ └── Test │ │ │ │ ├── index.jsx │ │ │ │ ├── index.ali.jsx │ │ │ │ └── index.wechat.jsx │ │ └── document │ │ │ └── index.jsx │ ├── mini.project.json │ ├── .gitignore │ ├── README.md │ └── build.json ├── use-scrollview │ ├── .eslintrc.js │ ├── src │ │ ├── components │ │ │ └── Logo │ │ │ │ ├── index.css │ │ │ │ └── index.jsx │ │ ├── app.json │ │ ├── pages │ │ │ └── Home │ │ │ │ └── index.css │ │ ├── app.js │ │ └── document │ │ │ └── index.jsx │ ├── .gitignore │ ├── README.md │ └── build.json ├── page-lifecycle-with-router │ ├── .eslintrc.js │ ├── src │ │ ├── app.js │ │ ├── components │ │ │ └── Logo │ │ │ │ ├── index.css │ │ │ │ └── index.jsx │ │ ├── pages │ │ │ ├── About │ │ │ │ └── index.css │ │ │ └── Home │ │ │ │ └── index.css │ │ ├── document │ │ │ └── index.jsx │ │ └── app.json │ ├── .gitignore │ ├── README.md │ ├── build.json │ └── package.json ├── with-miniapp-native-custom-component │ ├── .eslintrc.js │ ├── src │ │ ├── public │ │ │ ├── AliNativeComp │ │ │ │ ├── index.json │ │ │ │ ├── index.acss │ │ │ │ ├── index.js │ │ │ │ └── index.axml │ │ │ └── WechatNativeComp │ │ │ │ ├── index.json │ │ │ │ ├── index.wxss │ │ │ │ ├── index.wxml │ │ │ │ └── index.js │ │ ├── app.js │ │ ├── app.json │ │ ├── pages │ │ │ └── Home │ │ │ │ ├── index.css │ │ │ │ └── index.jsx │ │ ├── components │ │ │ └── Test │ │ │ │ ├── index.wechat.jsx │ │ │ │ └── index.ali.jsx │ │ └── document │ │ │ └── index.jsx │ ├── .gitignore │ ├── README.md │ └── build.json ├── use-rax-compiled-component-in-runtime-miniapp │ ├── build.json │ ├── .eslintignore │ ├── src │ │ ├── miniapp-compiled │ │ │ ├── CompiledComp2 │ │ │ │ ├── index.module.less │ │ │ │ └── index.jsx │ │ │ ├── index.jsx │ │ │ └── CompiledComp1.jsx │ │ ├── app.js │ │ ├── app.json │ │ └── pages │ │ │ └── Home │ │ │ ├── index.css │ │ │ └── index.jsx │ ├── .prettierignore │ ├── .stylelintignore │ ├── .prettierrc.js │ ├── .stylelintrc.js │ ├── abc.json │ ├── .eslintrc.js │ ├── .gitignore │ ├── README.md │ └── tsconfig.json └── README.md ├── .eslintrc.js ├── tsconfig.json ├── .eslintignore ├── scripts ├── fn │ └── shell.ts ├── compile-packages.js ├── build.ts └── release.ts ├── .gitignore ├── tsconfig.settings.json ├── .github └── workflows │ ├── ci.yml │ ├── auto-publisher.yml │ └── release-report.yml ├── .editorconfig ├── lerna.json ├── CHANGELOG.md └── babel.config.js /.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false -------------------------------------------------------------------------------- /packages/jsx2mp-cli/.gitignore: -------------------------------------------------------------------------------- 1 | example 2 | -------------------------------------------------------------------------------- /examples/with-miniapp-native-page/src/pages/NativeHome/index.acss: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/jsx-compiler/.npmignore: -------------------------------------------------------------------------------- 1 | example 2 | .idea 3 | coverage 4 | -------------------------------------------------------------------------------- /packages/eslint-plugin-rax-compile-time-miniapp/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /examples/with-miniapp-native-page/src/pages/NativeHome/index.js: -------------------------------------------------------------------------------- 1 | Page({}); 2 | -------------------------------------------------------------------------------- /examples/app-lifecycle/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['rax'] 3 | }; -------------------------------------------------------------------------------- /examples/event-handler/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['rax'] 3 | }; -------------------------------------------------------------------------------- /examples/get-element/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['rax'] 3 | }; -------------------------------------------------------------------------------- /examples/use-input/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['rax'] 3 | }; -------------------------------------------------------------------------------- /examples/with-miniapp-plugin-component/ali-miniapp-plugin/pages/index/index.acss: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/with-miniapp-plugin-component/ali-miniapp-plugin/pages/index/index.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /examples/use-scrollview/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['rax'] 3 | }; -------------------------------------------------------------------------------- /examples/with-miniapp-plugin-component/ali-miniapp-plugin/components/test/index.acss: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/eslint-plugin-rax-compile-time-miniapp/.npmignore: -------------------------------------------------------------------------------- 1 | docs 2 | node_modules 3 | test -------------------------------------------------------------------------------- /examples/with-miniapp-native-page/src/public/components/comp1/index.js: -------------------------------------------------------------------------------- 1 | Component({}); 2 | -------------------------------------------------------------------------------- /examples/with-miniapp-native-page/src/public/components/comp2/index.js: -------------------------------------------------------------------------------- 1 | Component({}); 2 | -------------------------------------------------------------------------------- /examples/with-miniapp-plugin-component/ali-miniapp-plugin/pages/index/index.js: -------------------------------------------------------------------------------- 1 | Page({}); 2 | -------------------------------------------------------------------------------- /examples/page-lifecycle-with-router/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['rax'] 3 | }; -------------------------------------------------------------------------------- /examples/with-miniapp-native-page/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['rax'] 3 | }; -------------------------------------------------------------------------------- /examples/with-miniapp-native-page/src/public/components/comp1/index.axml: -------------------------------------------------------------------------------- 1 | 我是 comp1 2 | -------------------------------------------------------------------------------- /examples/with-miniapp-native-page/src/public/components/comp2/index.axml: -------------------------------------------------------------------------------- 1 | 我是 comp2 2 | -------------------------------------------------------------------------------- /examples/with-miniapp-plugin-component/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['rax'] 3 | }; -------------------------------------------------------------------------------- /packages/miniapp-render/src/builtInComponents/icon.js: -------------------------------------------------------------------------------- 1 | export default { 2 | name: 'icon' 3 | }; 4 | -------------------------------------------------------------------------------- /packages/miniapp-render/src/builtInComponents/label.js: -------------------------------------------------------------------------------- 1 | export default { 2 | name: 'label' 3 | }; 4 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'extends': [ 3 | 'rax' 4 | ], 5 | 'root': true, 6 | }; 7 | -------------------------------------------------------------------------------- /examples/with-miniapp-native-custom-component/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['rax'] 3 | }; -------------------------------------------------------------------------------- /examples/with-miniapp-native-page/src/public/components/comp1/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /examples/with-miniapp-native-page/src/public/components/comp2/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /packages/jsx2mp-cli/.npmignore: -------------------------------------------------------------------------------- 1 | coverage 2 | .idea 3 | example 4 | __tests__ 5 | demo 6 | es/* 7 | lib/* 8 | -------------------------------------------------------------------------------- /examples/with-miniapp-plugin-component/wechat-miniprogram-plugin/pages/hello-page.wxss: -------------------------------------------------------------------------------- 1 | /* pages/hello-page.wxss */ -------------------------------------------------------------------------------- /packages/miniapp-render/src/builtInComponents/cover-view.js: -------------------------------------------------------------------------------- 1 | export default { 2 | name: 'cover-view' 3 | }; 4 | -------------------------------------------------------------------------------- /packages/miniapp-render/src/builtInComponents/rich-text.js: -------------------------------------------------------------------------------- 1 | export default { 2 | name: 'rich-text' 3 | }; 4 | -------------------------------------------------------------------------------- /examples/with-miniapp-native-custom-component/src/public/AliNativeComp/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /examples/with-miniapp-plugin-component/ali-miniapp-plugin/pages/index/index.axml: -------------------------------------------------------------------------------- 1 | Hello from plugin page -------------------------------------------------------------------------------- /packages/miniapp-render/src/builtInComponents/movable-area.js: -------------------------------------------------------------------------------- 1 | export default { 2 | name: 'movable-area' 3 | }; 4 | -------------------------------------------------------------------------------- /packages/miniapp-render/src/builtInComponents/swiper-item.js: -------------------------------------------------------------------------------- 1 | export default { 2 | name: 'swiper-item' 3 | }; 4 | -------------------------------------------------------------------------------- /examples/use-rax-compiled-component-in-runtime-miniapp/build.json: -------------------------------------------------------------------------------- 1 | { 2 | "targets": [ 3 | "miniapp" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /examples/with-miniapp-native-custom-component/src/public/AliNativeComp/index.acss: -------------------------------------------------------------------------------- 1 | .test { 2 | color: #F3BF37; 3 | } 4 | -------------------------------------------------------------------------------- /examples/with-miniapp-native-custom-component/src/public/WechatNativeComp/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /examples/with-miniapp-plugin-component/ali-miniapp-plugin/components/test/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /examples/with-miniapp-plugin-component/wechat-miniprogram-plugin/pages/hello-page.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /packages/miniapp-render/src/builtInComponents/contact-button.js: -------------------------------------------------------------------------------- 1 | export default { 2 | name: 'contact-button' 3 | }; 4 | -------------------------------------------------------------------------------- /examples/with-miniapp-native-custom-component/src/public/WechatNativeComp/index.wxss: -------------------------------------------------------------------------------- 1 | .test { 2 | color: #F3BF37; 3 | } 4 | -------------------------------------------------------------------------------- /packages/miniapp-render/src/builtInComponents/picker-view-column.js: -------------------------------------------------------------------------------- 1 | export default { 2 | name: 'picker-view-column' 3 | }; 4 | -------------------------------------------------------------------------------- /packages/miniapp-render/src/builtInComponents/text.js: -------------------------------------------------------------------------------- 1 | const text = { 2 | name: 'text' 3 | }; 4 | 5 | export default text; 6 | -------------------------------------------------------------------------------- /examples/use-input/src/components/Logo/index.css: -------------------------------------------------------------------------------- 1 | .logo { 2 | width: 200rpx; 3 | height: 180rpx; 4 | margin-bottom: 20rpx; 5 | } -------------------------------------------------------------------------------- /packages/jsx2mp-cli/demo/assets/rax.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hirokith/miniapp/master/packages/jsx2mp-cli/demo/assets/rax.png -------------------------------------------------------------------------------- /packages/jsx2mp-runtime/src/host.js: -------------------------------------------------------------------------------- 1 | const Host = { 2 | current: null, 3 | isUpdating: false, 4 | }; 5 | export default Host; 6 | -------------------------------------------------------------------------------- /examples/app-lifecycle/src/components/Logo/index.css: -------------------------------------------------------------------------------- 1 | .logo { 2 | width: 200rpx; 3 | height: 180rpx; 4 | margin-bottom: 20rpx; 5 | } -------------------------------------------------------------------------------- /examples/get-element/src/components/Logo/index.css: -------------------------------------------------------------------------------- 1 | .logo { 2 | width: 200rpx; 3 | height: 180rpx; 4 | margin-bottom: 20rpx; 5 | } -------------------------------------------------------------------------------- /examples/use-scrollview/src/components/Logo/index.css: -------------------------------------------------------------------------------- 1 | .logo { 2 | width: 200rpx; 3 | height: 180rpx; 4 | margin-bottom: 20rpx; 5 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [], 3 | "references": [ 4 | { "path": "packages/build-plugin-rax-miniapp-faas" } 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /examples/event-handler/src/app.js: -------------------------------------------------------------------------------- 1 | import { runApp } from 'rax-app'; 2 | import appConfig from './app.json'; 3 | 4 | runApp(appConfig); 5 | -------------------------------------------------------------------------------- /examples/event-handler/src/components/CustomComp/index.css: -------------------------------------------------------------------------------- 1 | .logo { 2 | width: 200rpx; 3 | height: 180rpx; 4 | margin-bottom: 20rpx; 5 | } -------------------------------------------------------------------------------- /packages/eslint-plugin-rax-compile-time-miniapp/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "import/no-extraneous-dependencies": "off" 4 | } 5 | } -------------------------------------------------------------------------------- /packages/jsx-compiler/src/utils/createIncrement.js: -------------------------------------------------------------------------------- 1 | let id = 0; 2 | 3 | module.exports = function() { 4 | return String(id++); 5 | }; 6 | -------------------------------------------------------------------------------- /packages/jsx2mp-runtime/src/forwardRef.js: -------------------------------------------------------------------------------- 1 | export default function(render) { 2 | render._forwardRef = true; 3 | return render; 4 | } 5 | -------------------------------------------------------------------------------- /packages/miniapp-history/src/constants.js: -------------------------------------------------------------------------------- 1 | export const PUSH = 'PUSH'; 2 | export const POP = 'POP'; 3 | export const REPLACE = 'REPLACE'; 4 | -------------------------------------------------------------------------------- /examples/with-miniapp-native-page/src/components/Logo/index.css: -------------------------------------------------------------------------------- 1 | .logo { 2 | width: 200rpx; 3 | height: 180rpx; 4 | margin-bottom: 20rpx; 5 | } -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | lib 3 | es 4 | dist 5 | build 6 | coverage 7 | expected 8 | website 9 | gh-pages 10 | vendors 11 | *.ejs 12 | -------------------------------------------------------------------------------- /examples/page-lifecycle-with-router/src/app.js: -------------------------------------------------------------------------------- 1 | import { runApp } from 'rax-app'; 2 | import appConfig from './app.json'; 3 | 4 | runApp(appConfig); 5 | -------------------------------------------------------------------------------- /examples/page-lifecycle-with-router/src/components/Logo/index.css: -------------------------------------------------------------------------------- 1 | .logo { 2 | width: 200rpx; 3 | height: 180rpx; 4 | margin-bottom: 20rpx; 5 | } -------------------------------------------------------------------------------- /examples/with-miniapp-native-page/src/app.js: -------------------------------------------------------------------------------- 1 | import { runApp } from 'rax-app'; 2 | import appConfig from './app.json'; 3 | 4 | runApp(appConfig); 5 | -------------------------------------------------------------------------------- /packages/miniapp-runtime-config/src/index.js: -------------------------------------------------------------------------------- 1 | exports.setConfig = require('./setConfig'); 2 | exports.setPluginConfig = require('./setPluginConfig'); 3 | -------------------------------------------------------------------------------- /examples/get-element/abc.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "rax", 3 | "builder": "@ali/builder-rax-v1", 4 | "info": { 5 | "raxVersion": "1.x" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /examples/use-rax-compiled-component-in-runtime-miniapp/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | lib/ 3 | dist/ 4 | build/ 5 | coverage/ 6 | demo/ 7 | es/ 8 | .rax/ 9 | -------------------------------------------------------------------------------- /examples/use-rax-compiled-component-in-runtime-miniapp/src/miniapp-compiled/CompiledComp2/index.module.less: -------------------------------------------------------------------------------- 1 | .compiledComp2{ 2 | color: orange; 3 | } 4 | -------------------------------------------------------------------------------- /examples/with-miniapp-plugin-component/ali-miniapp-plugin/components/test/index.axml: -------------------------------------------------------------------------------- 1 | 2 | {{pluginName}} 3 | 4 | -------------------------------------------------------------------------------- /examples/with-miniapp-plugin-component/src/app.js: -------------------------------------------------------------------------------- 1 | import { runApp } from 'rax-app'; 2 | import appConfig from './app.json'; 3 | 4 | runApp(appConfig); 5 | -------------------------------------------------------------------------------- /examples/with-miniapp-plugin-component/wechat-miniprogram-plugin/components/hello-component.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": {} 4 | } -------------------------------------------------------------------------------- /examples/with-miniapp-plugin-component/wechat-miniprogram-plugin/pages/hello-page.wxml: -------------------------------------------------------------------------------- 1 | 2 | pages/hello-page.wxml 3 | -------------------------------------------------------------------------------- /packages/driver-miniapp/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [0.1.4] - 2021-04-27 4 | 5 | ### Changed 6 | 7 | - Update homepage url in `package.json` 8 | -------------------------------------------------------------------------------- /examples/use-rax-compiled-component-in-runtime-miniapp/.prettierignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | lib/ 3 | dist/ 4 | build/ 5 | coverage/ 6 | demo/ 7 | es/ 8 | .rax/ 9 | -------------------------------------------------------------------------------- /examples/use-rax-compiled-component-in-runtime-miniapp/.stylelintignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | lib/ 3 | dist/ 4 | build/ 5 | coverage/ 6 | demo/ 7 | es/ 8 | .rax/ 9 | -------------------------------------------------------------------------------- /examples/with-miniapp-native-custom-component/src/app.js: -------------------------------------------------------------------------------- 1 | import { runApp } from 'rax-app'; 2 | import appConfig from './app.json'; 3 | 4 | runApp(appConfig); 5 | -------------------------------------------------------------------------------- /packages/driver-miniapp/src/index.d.ts: -------------------------------------------------------------------------------- 1 | // Driver spec: https://github.com/alibaba/rax/blob/master/docs/en-US/driver-spec.md 2 | export * from 'driver-dom'; 3 | -------------------------------------------------------------------------------- /packages/miniapp-history/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [0.1.5] - 2021-07-20 4 | 5 | ### Added 6 | 7 | - Support bytedance/baidu/kuaishou miniapp 8 | 9 | -------------------------------------------------------------------------------- /examples/with-miniapp-native-page/src/pages/NativeHome/index.axml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 这里是原生页面 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /packages/jsx-compiler/src/utils/generateId.js: -------------------------------------------------------------------------------- 1 | let count = 0; 2 | 3 | // Generate id selector 4 | module.exports = function() { 5 | return `id_${count++}`; 6 | }; 7 | -------------------------------------------------------------------------------- /examples/use-rax-compiled-component-in-runtime-miniapp/src/app.js: -------------------------------------------------------------------------------- 1 | import { runApp } from 'rax-app'; 2 | import appConfig from './app.json'; 3 | 4 | runApp(appConfig); 5 | -------------------------------------------------------------------------------- /packages/rax-miniapp-runtime-webpack-plugin/src/utils/addSingleQuote.js: -------------------------------------------------------------------------------- 1 | function addSingleQuote(s) { 2 | return `'${s}'`; 3 | } 4 | 5 | module.exports = addSingleQuote; 6 | -------------------------------------------------------------------------------- /examples/use-rax-compiled-component-in-runtime-miniapp/.prettierrc.js: -------------------------------------------------------------------------------- 1 | const { getPrettierConfig } = require('@iceworks/spec'); 2 | 3 | module.exports = getPrettierConfig('rax'); 4 | -------------------------------------------------------------------------------- /packages/rax-miniapp-runtime-webpack-plugin/src/utils/isNpmModule.js: -------------------------------------------------------------------------------- 1 | module.exports = function isNpmModule(value) { 2 | return !(value[0] === '.' || value[0] === '/'); 3 | }; 4 | -------------------------------------------------------------------------------- /examples/use-rax-compiled-component-in-runtime-miniapp/.stylelintrc.js: -------------------------------------------------------------------------------- 1 | const { getStylelintConfig } = require('@iceworks/spec'); 2 | 3 | module.exports = getStylelintConfig('rax'); 4 | -------------------------------------------------------------------------------- /examples/use-rax-compiled-component-in-runtime-miniapp/abc.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "rax", 3 | "builder": "@ali/builder-rax-v1", 4 | "info": { 5 | "raxVersion": "1.x" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/rax-miniapp-babel-plugins/src/utils/getTagName.js: -------------------------------------------------------------------------------- 1 | const md5 = require('md5'); 2 | 3 | module.exports = function getTagName(str) { 4 | return 'c' + md5(str).slice(0, 6); 5 | }; 6 | -------------------------------------------------------------------------------- /examples/with-miniapp-plugin-component/ali-miniapp-plugin/index.js: -------------------------------------------------------------------------------- 1 | var data = require('./api/data'); 2 | 3 | module.exports = { 4 | getData: data.getData, 5 | setData: data.setData 6 | }; 7 | -------------------------------------------------------------------------------- /examples/with-miniapp-plugin-component/wechat-miniprogram-plugin/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | sayHello: function() { 3 | console.log('Hello plugin!'); 4 | }, 5 | answer: 42 6 | }; 7 | -------------------------------------------------------------------------------- /packages/miniapp-render/src/builtInComponents/radio.js: -------------------------------------------------------------------------------- 1 | export default { 2 | name: 'radio', 3 | singleEvents: [{ 4 | name: 'onRadioChange', 5 | eventName: 'change' 6 | }] 7 | }; 8 | -------------------------------------------------------------------------------- /packages/rax-miniapp-runtime-webpack-plugin/src/utils/getSepProcessedPath.js: -------------------------------------------------------------------------------- 1 | module.exports = function(filePath) { 2 | return filePath.replace(/\\/g, '/'); // Avoid path error in Windows 3 | }; 4 | -------------------------------------------------------------------------------- /packages/miniapp-render/src/builtInComponents/checkbox.js: -------------------------------------------------------------------------------- 1 | export default { 2 | name: 'checkbox', 3 | singleEvents: [{ 4 | name: 'onCheckboxItemChange', 5 | eventName: 'change' 6 | }] 7 | }; 8 | -------------------------------------------------------------------------------- /packages/miniapp-render/src/builtInComponents/radio-group.js: -------------------------------------------------------------------------------- 1 | export default { 2 | name: 'radio-group', 3 | singleEvents: [{ 4 | name: 'onRadioChange', 5 | eventName: 'change' 6 | }] 7 | }; 8 | -------------------------------------------------------------------------------- /packages/rax-miniapp-babel-plugins/src/utils/extMap.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'miniapp': 'axml', 3 | 'wechat-miniprogram': 'wxml', 4 | 'bytedance-microapp': 'ttml', 5 | 'quickapp': 'ux', 6 | }; 7 | -------------------------------------------------------------------------------- /examples/with-miniapp-native-custom-component/src/public/AliNativeComp/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | methods: { 3 | onClick() { 4 | this.props.onClick && this.props.onClick(); 5 | } 6 | } 7 | }); 8 | -------------------------------------------------------------------------------- /examples/with-miniapp-plugin-component/mini.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "miniprogramRoot": "build/miniapp", 3 | "pluginRoot": "ali-miniapp-plugin", 4 | "compileType": "plugin", 5 | "component2": false 6 | } 7 | -------------------------------------------------------------------------------- /packages/miniapp-render/src/builtInComponents/progress.js: -------------------------------------------------------------------------------- 1 | export default { 2 | name: 'progress', 3 | singleEvents: [{ 4 | name: 'onProgressActiveEnd', 5 | eventName: 'activeend' 6 | }] 7 | }; 8 | -------------------------------------------------------------------------------- /examples/use-input/src/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "routes": [ 3 | { 4 | "path": "/", 5 | "source": "pages/Home/index" 6 | } 7 | ], 8 | "window": { 9 | "title": "Rax App" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/miniapp-render/.npmignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .DS_Store 3 | package-lock.json 4 | 5 | logs 6 | *.log 7 | npm-debug.log* 8 | yarn-debug.log* 9 | yarn-error.log* 10 | 11 | test 12 | node_modules 13 | coverage -------------------------------------------------------------------------------- /packages/miniapp-render/src/builtInComponents/checkbox-group.js: -------------------------------------------------------------------------------- 1 | export default { 2 | name: 'checkbox-group', 3 | singleEvents: [{ 4 | name: 'onCheckboxChange', 5 | eventName: 'change' 6 | }] 7 | }; 8 | -------------------------------------------------------------------------------- /packages/rax-miniapp-runtime-webpack-plugin/src/utils/rmCurDirPathSymbol.js: -------------------------------------------------------------------------------- 1 | module.exports = function rmCurDirPathSymbol(filePath) { 2 | return filePath.indexOf('./') === 0 ? filePath.slice(2) : filePath; 3 | }; 4 | -------------------------------------------------------------------------------- /scripts/fn/shell.ts: -------------------------------------------------------------------------------- 1 | import * as execa from 'execa'; 2 | 3 | export async function run(command: string) { 4 | console.log(`[RUN]: ${command}`); 5 | return execa.command(command, { stdio: 'inherit' }); 6 | } 7 | -------------------------------------------------------------------------------- /examples/app-lifecycle/src/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "routes": [ 3 | { 4 | "path": "/", 5 | "source": "pages/Home/index" 6 | } 7 | ], 8 | "window": { 9 | "title": "Rax App" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /examples/event-handler/src/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "routes": [ 3 | { 4 | "path": "/", 5 | "source": "pages/Home/index" 6 | } 7 | ], 8 | "window": { 9 | "title": "Rax App" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /examples/get-element/src/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "routes": [ 3 | { 4 | "path": "/", 5 | "source": "pages/Home/index" 6 | } 7 | ], 8 | "window": { 9 | "title": "Rax App" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /examples/use-scrollview/src/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "routes": [ 3 | { 4 | "path": "/", 5 | "source": "pages/Home/index" 6 | } 7 | ], 8 | "window": { 9 | "title": "Rax App" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /examples/with-miniapp-native-custom-component/src/public/AliNativeComp/index.axml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 我是小程序原生自定义组件 4 | 5 | 6 | -------------------------------------------------------------------------------- /examples/with-miniapp-native-page/src/pages/NativeHome/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": { 3 | "comp1": "../../public/components/comp1/index", 4 | "comp2": "../../public/components/comp2/index" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/rax-miniapp-babel-plugins/src/utils/getFilePath.js: -------------------------------------------------------------------------------- 1 | const { extname } = require('path'); 2 | 3 | module.exports = function(resourcePath) { 4 | return resourcePath.replace(extname(resourcePath), ''); 5 | }; 6 | -------------------------------------------------------------------------------- /examples/use-rax-compiled-component-in-runtime-miniapp/.eslintrc.js: -------------------------------------------------------------------------------- 1 | const { getESLintConfig } = require('@iceworks/spec'); 2 | 3 | // https://www.npmjs.com/package/@iceworks/spec 4 | module.exports = getESLintConfig('rax'); 5 | -------------------------------------------------------------------------------- /examples/with-miniapp-native-custom-component/src/public/WechatNativeComp/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 我是小程序原生自定义组件 4 | 5 | 6 | -------------------------------------------------------------------------------- /examples/with-miniapp-plugin-component/wechat-miniprogram-plugin/components/hello-component.wxss: -------------------------------------------------------------------------------- 1 | /* plugin/components/hello-component.wxss */ 2 | .container { 3 | margin: 1em; 4 | } 5 | .item { 6 | display: block; 7 | } -------------------------------------------------------------------------------- /packages/build-plugin-rax-miniapp-faas/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.settings.json", 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "rootDir": "src", 6 | "outDir": "lib" 7 | }, 8 | } 9 | -------------------------------------------------------------------------------- /examples/use-rax-compiled-component-in-runtime-miniapp/src/miniapp-compiled/index.jsx: -------------------------------------------------------------------------------- 1 | import CompiledComp1 from './CompiledComp1'; 2 | import CompiledComp2 from './CompiledComp2'; 3 | 4 | export { CompiledComp1, CompiledComp2 }; 5 | -------------------------------------------------------------------------------- /packages/jsx-compiler/src/options.js: -------------------------------------------------------------------------------- 1 | exports.baseOptions = { 2 | cwd: process.cwd(), 3 | modules: require('./modules'), 4 | /** 5 | * Whether add whitespace between tags. 6 | */ 7 | preserveWhitespace: false, 8 | }; 9 | -------------------------------------------------------------------------------- /packages/miniapp-compile-config/src/index.js: -------------------------------------------------------------------------------- 1 | exports.setAppConfig = require('./setAppConfig'); 2 | exports.setComponentConfig = require('./setComponentConfig'); 3 | exports.setPluginConfig = require('./setPluginConfig'); 4 | 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.swp 3 | .DS_Store 4 | npm-debug.log 5 | lerna-debug.log 6 | npm-debug.log* 7 | lib/ 8 | es/ 9 | dist/ 10 | build/ 11 | coverage/ 12 | node_modules/ 13 | examples/test 14 | yarn.lock 15 | package-lock.json 16 | -------------------------------------------------------------------------------- /examples/with-miniapp-native-custom-component/src/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "routes": [ 3 | { 4 | "path": "/", 5 | "source": "pages/Home/index" 6 | } 7 | ], 8 | "window": { 9 | "title": "Rax App" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/jsx2mp-cli/utils/removeExt.js: -------------------------------------------------------------------------------- 1 | const { extname } = require('path'); 2 | 3 | function removeExt(path) { 4 | const ext = extname(path); 5 | return path.slice(0, path.length - ext.length); 6 | } 7 | 8 | module.exports = removeExt; 9 | -------------------------------------------------------------------------------- /examples/use-rax-compiled-component-in-runtime-miniapp/src/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "routes": [ 3 | { 4 | "path": "/", 5 | "source": "pages/Home/index" 6 | } 7 | ], 8 | "window": { 9 | "title": "Rax App" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/build-plugin-rax-miniapp-plugin/src/utils/formatPath.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | module.exports = function formatPath(pathStr) { 4 | return process.platform === 'win32' ? pathStr.split(path.sep).join('/') : pathStr; 5 | }; 6 | -------------------------------------------------------------------------------- /packages/jsx-compiler/src/utils/createListKey.js: -------------------------------------------------------------------------------- 1 | const t = require('@babel/types'); 2 | 3 | let listKeyCount = 0; 4 | 5 | // Create increasing index node 6 | module.exports = function() { 7 | return t.identifier('_key' + listKeyCount++); 8 | }; 9 | -------------------------------------------------------------------------------- /packages/jsx2mp-loader/src/cached.js: -------------------------------------------------------------------------------- 1 | module.exports = function cached(fn) { 2 | const cache = Object.create(null); 3 | return function cachedFn(str) { 4 | const hit = cache[str]; 5 | return hit || (cache[str] = fn(str)); 6 | }; 7 | }; 8 | -------------------------------------------------------------------------------- /packages/miniapp-history/src/index.js: -------------------------------------------------------------------------------- 1 | import MiniAppHistory from './History'; 2 | 3 | let history; 4 | 5 | export function createMiniAppHistory(routes) { 6 | if (history) return history; 7 | return history = new MiniAppHistory(routes); 8 | } 9 | -------------------------------------------------------------------------------- /packages/jsx-compiler/src/utils/createListIndex.js: -------------------------------------------------------------------------------- 1 | const t = require('@babel/types'); 2 | 3 | let listIndexCount = 0; 4 | 5 | // Create increasing index node 6 | module.exports = function() { 7 | return t.identifier('index' + listIndexCount++); 8 | }; 9 | -------------------------------------------------------------------------------- /examples/with-miniapp-native-custom-component/src/public/WechatNativeComp/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | options: { 3 | multipleSlots: true 4 | }, 5 | methods: { 6 | onClick() { 7 | this.triggerEvent('click'); 8 | } 9 | } 10 | }); 11 | -------------------------------------------------------------------------------- /examples/with-miniapp-plugin-component/wechat-miniprogram-plugin/plugin.json: -------------------------------------------------------------------------------- 1 | { 2 | "publicComponents": { 3 | "hello-component": "components/hello-component" 4 | }, 5 | "pages": { 6 | "hello-page": "pages/hello-page" 7 | }, 8 | "main": "index.js" 9 | } -------------------------------------------------------------------------------- /packages/eslint-plugin-rax-compile-time-miniapp/docs/rules/no_double_quotation.md: -------------------------------------------------------------------------------- 1 | # no-double-quotation 2 | 由于小程序中变量绑定需要通过 "{{}}",双引号来包裹,所以在 JSX 中尽量不要使用双引号,以至于产生冲突。 3 | 4 | ## more 5 | https://rax.js.org/docs/guide/compile-miniapp-syntax-constraints#%E5%BC%95%E5%8F%B7 -------------------------------------------------------------------------------- /packages/jsx2mp-cli/default.js: -------------------------------------------------------------------------------- 1 | exports.DEFAULT_TYPE = 'project'; 2 | exports.DEFAULT_PLATFORM = 'ali'; 3 | exports.DEFAULT_ENTRY = 'src/app'; 4 | exports.DEFAULT_DIST = 'dist'; 5 | exports.DEFAULT_CONSTANT_DIR = ''; 6 | exports.DEFAULT_CONSTANT_DIR_ARR = []; 7 | 8 | -------------------------------------------------------------------------------- /packages/jsx2mp-runtime/src/kebabCase.js: -------------------------------------------------------------------------------- 1 | const KEBAB_REGEX = /[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g; 2 | 3 | export default function kebabCase(str) { 4 | return str.replace(KEBAB_REGEX, function(match) { 5 | return '-' + match.toLowerCase(); 6 | }); 7 | }; 8 | -------------------------------------------------------------------------------- /packages/miniapp-render/src/builtInComponents/form.js: -------------------------------------------------------------------------------- 1 | export default { 2 | name: 'form', 3 | singleEvents: [{ 4 | name: 'onFormSubmit', 5 | eventName: 'submit' 6 | }, 7 | { 8 | name: 'onFormReset', 9 | eventName: 'reset' 10 | }] 11 | }; 12 | -------------------------------------------------------------------------------- /packages/miniapp-render/src/builtInComponents/image.js: -------------------------------------------------------------------------------- 1 | export default { 2 | name: 'image', 3 | singleEvents: [{ 4 | name: 'onImageLoad', 5 | eventName: 'load' 6 | }, 7 | { 8 | name: 'onImageError', 9 | eventName: 'error' 10 | }] 11 | }; 12 | -------------------------------------------------------------------------------- /examples/with-miniapp-plugin-component/wechat-miniprogram-plugin/components/hello-component.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{ item }} 4 | 5 | -------------------------------------------------------------------------------- /packages/miniapp-render/src/bridge/events/getDomNodeFromEvt.js: -------------------------------------------------------------------------------- 1 | import cache from '../../utils/cache'; 2 | 3 | export default function(evt) { 4 | if (!evt) return; 5 | const target = evt.currentTarget; 6 | return cache.getNode(target && target.dataset.privateNodeId); 7 | } 8 | -------------------------------------------------------------------------------- /packages/jsx-compiler/src/utils/Expression.js: -------------------------------------------------------------------------------- 1 | module.exports = class Expression { 2 | constructor(descriptor) { 3 | this.isExpression = true; 4 | this.descriptor = descriptor || ''; 5 | } 6 | 7 | toString() { 8 | return this.descriptor; 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /examples/use-scrollview/src/pages/Home/index.css: -------------------------------------------------------------------------------- 1 | .home { 2 | margin-top: 200rpx; 3 | } 4 | 5 | .title { 6 | font-size: 45rpx; 7 | font-weight: bold; 8 | margin: 20rpx 0; 9 | } 10 | 11 | .info { 12 | font-size: 36rpx; 13 | margin: 8rpx 0; 14 | color: #555; 15 | } 16 | -------------------------------------------------------------------------------- /packages/jsx2mp-cli/demo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "name": "jsx2mp-cli-demo", 4 | "version": "1.0.0", 5 | "main": "component.js", 6 | "dependencies": { 7 | "rax": "^1.0.8", 8 | "rax-image": "^1.1.1", 9 | "rax-view": "^1.0.2" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/rax-miniapp-runtime-webpack-plugin/src/utils/isCSSFile.js: -------------------------------------------------------------------------------- 1 | const extRegex = /\.(css|js|wxss|acss)(\?|$)/; 2 | 3 | module.exports = function(filePath) { 4 | const extMatch = extRegex.exec(filePath); 5 | return extMatch && ['wxss', 'acss', 'css'].includes(extMatch[1]); 6 | }; 7 | -------------------------------------------------------------------------------- /packages/miniapp-render/src/builtInComponents/cover-image.js: -------------------------------------------------------------------------------- 1 | export default { 2 | name: 'cover-image', 3 | singleEvents: [{ 4 | name: 'onCoverImageLoad', 5 | eventName: 'load' 6 | }, 7 | { 8 | name: 'onCoverImageError', 9 | eventName: 'error' 10 | }] 11 | }; 12 | -------------------------------------------------------------------------------- /examples/app-lifecycle/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | *~ 4 | *.swp 5 | *.log 6 | 7 | .DS_Store 8 | .idea/ 9 | .temp/ 10 | 11 | build/ 12 | dist/ 13 | lib/ 14 | coverage/ 15 | node_modules/ 16 | 17 | template.yml 18 | -------------------------------------------------------------------------------- /examples/event-handler/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | *~ 4 | *.swp 5 | *.log 6 | 7 | .DS_Store 8 | .idea/ 9 | .temp/ 10 | 11 | build/ 12 | dist/ 13 | lib/ 14 | coverage/ 15 | node_modules/ 16 | 17 | template.yml 18 | -------------------------------------------------------------------------------- /examples/get-element/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | *~ 4 | *.swp 5 | *.log 6 | 7 | .DS_Store 8 | .idea/ 9 | .temp/ 10 | 11 | build/ 12 | dist/ 13 | lib/ 14 | coverage/ 15 | node_modules/ 16 | 17 | template.yml 18 | -------------------------------------------------------------------------------- /examples/use-input/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | *~ 4 | *.swp 5 | *.log 6 | 7 | .DS_Store 8 | .idea/ 9 | .temp/ 10 | 11 | build/ 12 | dist/ 13 | lib/ 14 | coverage/ 15 | node_modules/ 16 | 17 | template.yml 18 | -------------------------------------------------------------------------------- /packages/jsx-compiler/src/utils/replaceComponentTagName.js: -------------------------------------------------------------------------------- 1 | module.exports = function replaceComponentTagName(path, tagNameNode) { 2 | const { node, parent } = path; 3 | node.name = tagNameNode; 4 | if (parent.closingElement) { 5 | parent.closingElement.name = tagNameNode; 6 | } 7 | }; 8 | -------------------------------------------------------------------------------- /packages/miniapp-render/src/event/custom-event.js: -------------------------------------------------------------------------------- 1 | import Event from './event'; 2 | 3 | class CustomEvent extends Event { 4 | constructor(name = '', options = {}) { 5 | super({ 6 | name, 7 | ...options, 8 | }); 9 | } 10 | } 11 | 12 | export default CustomEvent; 13 | -------------------------------------------------------------------------------- /examples/use-scrollview/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | *~ 4 | *.swp 5 | *.log 6 | 7 | .DS_Store 8 | .idea/ 9 | .temp/ 10 | 11 | build/ 12 | dist/ 13 | lib/ 14 | coverage/ 15 | node_modules/ 16 | 17 | template.yml 18 | -------------------------------------------------------------------------------- /packages/jsx-compiler/src/utils/findIndex.js: -------------------------------------------------------------------------------- 1 | module.exports = function(arr, checkFn) { 2 | let idx = -1; 3 | arr.some((item, index) => { 4 | if (checkFn(item, index)) { 5 | idx = index; 6 | return true; 7 | } 8 | return false; 9 | }); 10 | return idx; 11 | }; 12 | -------------------------------------------------------------------------------- /tsconfig.settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "jsx": "react", 5 | "experimentalDecorators": true, 6 | "declaration": true, 7 | "sourceMap": false, 8 | "skipLibCheck": true, 9 | "forceConsistentCasingInFileNames": true 10 | }, 11 | } 12 | -------------------------------------------------------------------------------- /examples/with-miniapp-plugin-component/ali-miniapp-plugin/api/data.js: -------------------------------------------------------------------------------- 1 | var data = 'init data'; 2 | 3 | function getData() { 4 | return data; 5 | } 6 | 7 | function setData(value) { 8 | data = value; 9 | } 10 | 11 | module.exports = { 12 | getData: getData, 13 | setData: setData 14 | }; 15 | -------------------------------------------------------------------------------- /examples/get-element/src/pages/Home/index.css: -------------------------------------------------------------------------------- 1 | .home { 2 | align-items: center; 3 | margin-top: 200rpx; 4 | } 5 | 6 | .title { 7 | font-size: 45rpx; 8 | font-weight: bold; 9 | margin: 20rpx 0; 10 | } 11 | 12 | .info { 13 | font-size: 36rpx; 14 | margin: 8rpx 0; 15 | color: #555; 16 | } 17 | -------------------------------------------------------------------------------- /examples/page-lifecycle-with-router/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | *~ 4 | *.swp 5 | *.log 6 | 7 | .DS_Store 8 | .idea/ 9 | .temp/ 10 | 11 | build/ 12 | dist/ 13 | lib/ 14 | coverage/ 15 | node_modules/ 16 | 17 | template.yml 18 | -------------------------------------------------------------------------------- /examples/use-input/src/pages/Home/index.css: -------------------------------------------------------------------------------- 1 | .home { 2 | align-items: center; 3 | margin-top: 200rpx; 4 | } 5 | 6 | .title { 7 | font-size: 45rpx; 8 | font-weight: bold; 9 | margin: 20rpx 0; 10 | } 11 | 12 | .info { 13 | font-size: 36rpx; 14 | margin: 8rpx 0; 15 | color: #555; 16 | } 17 | -------------------------------------------------------------------------------- /examples/with-miniapp-native-page/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | *~ 4 | *.swp 5 | *.log 6 | 7 | .DS_Store 8 | .idea/ 9 | .temp/ 10 | 11 | build/ 12 | dist/ 13 | lib/ 14 | coverage/ 15 | node_modules/ 16 | 17 | template.yml 18 | -------------------------------------------------------------------------------- /examples/with-miniapp-plugin-component/wechat-miniprogram-plugin/api/data.js: -------------------------------------------------------------------------------- 1 | var data = 'init data'; 2 | 3 | function getData() { 4 | return data; 5 | } 6 | 7 | function setData(value) { 8 | data = value; 9 | } 10 | 11 | module.exports = { 12 | getData: getData, 13 | setData: setData 14 | }; 15 | -------------------------------------------------------------------------------- /packages/jsx-compiler/src/baseComponents.js: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | 'rax-scrollview', 3 | 'rax-recyclerview', 4 | 'rax-textinput', 5 | 'rax-picture', 6 | 'rax-slider', 7 | 'rax-icon', 8 | 'rax-link', 9 | 'rax-video', 10 | 'rax-image', 11 | 'rax-modal', 12 | 'rax-countdown' 13 | ]; 14 | -------------------------------------------------------------------------------- /packages/miniapp-render/src/builtInComponents/official-account.js: -------------------------------------------------------------------------------- 1 | export default { 2 | name: 'official-account', 3 | singleEvents: [{ 4 | name: 'onOfficialAccountLoad', 5 | eventName: 'load' 6 | }, 7 | { 8 | name: 'onOfficialAccountError', 9 | eventName: 'error' 10 | }] 11 | }; 12 | -------------------------------------------------------------------------------- /examples/app-lifecycle/src/pages/Home/index.css: -------------------------------------------------------------------------------- 1 | .home { 2 | align-items: center; 3 | margin-top: 200rpx; 4 | } 5 | 6 | .title { 7 | font-size: 45rpx; 8 | font-weight: bold; 9 | margin: 20rpx 0; 10 | } 11 | 12 | .info { 13 | font-size: 36rpx; 14 | margin: 8rpx 0; 15 | color: #555; 16 | } 17 | -------------------------------------------------------------------------------- /examples/event-handler/src/pages/Home/index.css: -------------------------------------------------------------------------------- 1 | .home { 2 | align-items: center; 3 | margin-top: 200rpx; 4 | } 5 | 6 | .title { 7 | font-size: 45rpx; 8 | font-weight: bold; 9 | margin: 20rpx 0; 10 | } 11 | 12 | .info { 13 | font-size: 36rpx; 14 | margin: 8rpx 0; 15 | color: #555; 16 | } 17 | -------------------------------------------------------------------------------- /examples/with-miniapp-plugin-component/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | *~ 4 | *.swp 5 | *.log 6 | 7 | .DS_Store 8 | .idea/ 9 | .temp/ 10 | 11 | build/ 12 | dist/ 13 | lib/ 14 | coverage/ 15 | node_modules/ 16 | 17 | template.yml 18 | -------------------------------------------------------------------------------- /examples/with-miniapp-plugin-component/ali-miniapp-plugin/plugin.json: -------------------------------------------------------------------------------- 1 | { 2 | "publicComponents": { 3 | "test": "components/test/index" 4 | }, 5 | "publicPages": { 6 | "hello-page": "pages/index/index" 7 | }, 8 | "pages": [ 9 | "pages/index/index" 10 | ], 11 | "main": "index" 12 | } 13 | -------------------------------------------------------------------------------- /examples/with-miniapp-native-custom-component/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | *~ 4 | *.swp 5 | *.log 6 | 7 | .DS_Store 8 | .idea/ 9 | .temp/ 10 | 11 | build/ 12 | dist/ 13 | lib/ 14 | coverage/ 15 | node_modules/ 16 | 17 | template.yml 18 | -------------------------------------------------------------------------------- /packages/miniapp-builder-shared/src/constants.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | MINIAPP: 'miniapp', 3 | WECHAT_MINIPROGRAM: 'wechat-miniprogram', 4 | BYTEDANCE_MICROAPP: 'bytedance-microapp', 5 | QUICKAPP: 'quickapp', 6 | BAIDU_SMARTPROGRAM: 'baidu-smartprogram', 7 | KUAISHOU_MINIPROGRAM: 'kuaishou-miniprogram' 8 | }; 9 | -------------------------------------------------------------------------------- /examples/page-lifecycle-with-router/src/pages/About/index.css: -------------------------------------------------------------------------------- 1 | .home { 2 | align-items: center; 3 | margin-top: 200rpx; 4 | } 5 | 6 | .title { 7 | font-size: 45rpx; 8 | font-weight: bold; 9 | margin: 20rpx 0; 10 | } 11 | 12 | .info { 13 | font-size: 36rpx; 14 | margin: 8rpx 0; 15 | color: #555; 16 | } 17 | -------------------------------------------------------------------------------- /examples/page-lifecycle-with-router/src/pages/Home/index.css: -------------------------------------------------------------------------------- 1 | .home { 2 | align-items: center; 3 | margin-top: 200rpx; 4 | } 5 | 6 | .title { 7 | font-size: 45rpx; 8 | font-weight: bold; 9 | margin: 20rpx 0; 10 | } 11 | 12 | .info { 13 | font-size: 36rpx; 14 | margin: 8rpx 0; 15 | color: #555; 16 | } 17 | -------------------------------------------------------------------------------- /examples/with-miniapp-native-page/src/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "routes": [ 3 | { 4 | "path": "/", 5 | "source": "pages/Home/index" 6 | }, 7 | { 8 | "path": "/native", 9 | "source": "pages/NativeHome/index" 10 | } 11 | ], 12 | "window": { 13 | "title": "Rax App" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /examples/with-miniapp-native-page/src/pages/Home/index.css: -------------------------------------------------------------------------------- 1 | .home { 2 | align-items: center; 3 | margin-top: 200rpx; 4 | } 5 | 6 | .title { 7 | font-size: 45rpx; 8 | font-weight: bold; 9 | margin: 20rpx 0; 10 | } 11 | 12 | .info { 13 | font-size: 36rpx; 14 | margin: 8rpx 0; 15 | color: #555; 16 | } 17 | -------------------------------------------------------------------------------- /examples/with-miniapp-plugin-component/ali-miniapp-plugin/components/test/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | props: { 3 | pluginName: 'plugin' 4 | }, 5 | methods: { 6 | onClick() { 7 | const { pluginName } = this.props; 8 | this.props.onTest && this.props.onTest(pluginName); 9 | } 10 | } 11 | }); 12 | -------------------------------------------------------------------------------- /packages/rax-miniapp-runtime-webpack-plugin/src/utils/getAssetPath.js: -------------------------------------------------------------------------------- 1 | const { relative, dirname } = require('path'); 2 | // Get dependency file path 3 | module.exports = function(filePath, selfFilePath) { 4 | return `./${relative(dirname(selfFilePath), filePath)}`.replace(/\\/g, '/'); // Avoid path error in Windows 5 | }; 6 | -------------------------------------------------------------------------------- /examples/with-miniapp-plugin-component/src/pages/Home/index.css: -------------------------------------------------------------------------------- 1 | .home { 2 | align-items: center; 3 | margin-top: 200rpx; 4 | } 5 | 6 | .title { 7 | font-size: 45rpx; 8 | font-weight: bold; 9 | margin: 20rpx 0; 10 | } 11 | 12 | .info { 13 | font-size: 36rpx; 14 | margin: 8rpx 0; 15 | color: #555; 16 | } 17 | -------------------------------------------------------------------------------- /packages/miniapp-lifecycles/src/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'miniapp-lifecycles' { 2 | export function registerNativeEventListeners(Klass: any, events: string[]); 3 | export function addNativeEventListener(eventName: string, callback: any); 4 | export function removeNativeEventListener(eventName: string, callback: any); 5 | } 6 | -------------------------------------------------------------------------------- /examples/use-rax-compiled-component-in-runtime-miniapp/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | *~ 4 | *.swp 5 | *.log 6 | 7 | .DS_Store 8 | .idea/ 9 | .temp/ 10 | 11 | build/ 12 | dist/ 13 | lib/ 14 | coverage/ 15 | node_modules/ 16 | .rax/ 17 | 18 | template.yml -------------------------------------------------------------------------------- /examples/with-miniapp-native-custom-component/src/pages/Home/index.css: -------------------------------------------------------------------------------- 1 | .home { 2 | align-items: center; 3 | margin-top: 200rpx; 4 | } 5 | 6 | .title { 7 | font-size: 45rpx; 8 | font-weight: bold; 9 | margin: 20rpx 0; 10 | } 11 | 12 | .info { 13 | font-size: 36rpx; 14 | margin: 8rpx 0; 15 | color: #555; 16 | } 17 | -------------------------------------------------------------------------------- /examples/use-rax-compiled-component-in-runtime-miniapp/src/pages/Home/index.css: -------------------------------------------------------------------------------- 1 | .home { 2 | align-items: center; 3 | margin-top: 200rpx; 4 | } 5 | 6 | .title { 7 | font-size: 45rpx; 8 | font-weight: bold; 9 | margin: 20rpx 0; 10 | } 11 | 12 | .info { 13 | font-size: 36rpx; 14 | margin: 8rpx 0; 15 | color: #555; 16 | } 17 | -------------------------------------------------------------------------------- /packages/jsx-compiler/src/utils/checkModule.js: -------------------------------------------------------------------------------- 1 | const WEEX_MODULE_REG = /^@?weex-/; 2 | 3 | function isWeexModule(value) { 4 | return WEEX_MODULE_REG.test(value); 5 | } 6 | 7 | function isNpmModule(value) { 8 | return !(value[0] === '.' || value[0] === '/'); 9 | } 10 | 11 | module.exports = { 12 | isWeexModule, 13 | isNpmModule 14 | }; 15 | -------------------------------------------------------------------------------- /packages/jsx-compiler/src/utils/createBinding.js: -------------------------------------------------------------------------------- 1 | module.exports = function createBinding(key) { 2 | key = String(key).trim(); 3 | if (key[0] === '{' && key[key.length - 1] === '}') { 4 | key = key.slice(1, -1); // Remove first and last char. MiniApp use {{ a: 1 }} to represent an bindging object. 5 | } 6 | 7 | return '{{' + key + '}}'; 8 | }; 9 | -------------------------------------------------------------------------------- /packages/miniapp-render/scripts/build.js: -------------------------------------------------------------------------------- 1 | const { join } = require('path'); 2 | const { existsSync } = require('fs-extra'); 3 | const spawn = require('cross-spawn'); 4 | 5 | const dist = join(__dirname, '..', 'dist'); 6 | const cwd = join(__dirname, '..'); 7 | 8 | if (!existsSync(dist)) { 9 | spawn.sync('npm', ['run', 'build'], { cwd }); 10 | } 11 | -------------------------------------------------------------------------------- /examples/use-rax-compiled-component-in-runtime-miniapp/src/miniapp-compiled/CompiledComp1.jsx: -------------------------------------------------------------------------------- 1 | import { createElement } from 'rax'; 2 | import View from 'rax-view'; 3 | 4 | const CompiledComp1 = (props) => { 5 | const { name } = props; 6 | return ( 7 | 我是 CompiledComp1 {name} 8 | ); 9 | }; 10 | 11 | export default CompiledComp1; 12 | -------------------------------------------------------------------------------- /packages/jsx2mp-loader/src/defaultStyle.js: -------------------------------------------------------------------------------- 1 | module.exports = `.__rax-view { 2 | border: 0 solid black; 3 | display:flex; 4 | flex-direction:column; 5 | align-content:flex-start; 6 | flex-shrink:0; 7 | box-sizing:border-box; 8 | } 9 | .__rax-text { 10 | box-sizing: border-box; 11 | display: block; 12 | font-size: 32rpx; 13 | } 14 | `; 15 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: ci 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build-and-publish: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v1 10 | - uses: actions/setup-node@v1 11 | with: 12 | node-version: 14 13 | registry-url: https://registry.npmjs.org/ 14 | - run: npm run ci 15 | -------------------------------------------------------------------------------- /packages/miniapp-render/src/builtInComponents/switch.js: -------------------------------------------------------------------------------- 1 | export default { 2 | name: 'switch', 3 | functionalSingleEvents: [ 4 | { 5 | name: 'onSwitchChange', 6 | eventName: 'change', 7 | middleware(evt, domNode) { 8 | domNode._setAttributeWithDelayUpdate('checked', evt.detail.value); 9 | } 10 | } 11 | ] 12 | }; 13 | -------------------------------------------------------------------------------- /packages/miniapp-render/src/builtInComponents/web-view.js: -------------------------------------------------------------------------------- 1 | export default { 2 | name: 'web-view', 3 | singleEvents: [{ 4 | name: 'onWebViewMessage', 5 | eventName: 'message' 6 | }, 7 | { 8 | name: 'onWebViewLoad', 9 | eventName: 'load' 10 | }, 11 | { 12 | name: 'onWebViewError', 13 | eventName: 'error' 14 | }] 15 | }; 16 | -------------------------------------------------------------------------------- /examples/use-input/src/components/Logo/index.jsx: -------------------------------------------------------------------------------- 1 | import { createElement } from 'rax'; 2 | import Image from 'rax-image'; 3 | 4 | import './index.css'; 5 | 6 | export default (props) => { 7 | const { uri } = props; 8 | const source = { uri }; 9 | return ( 10 | 14 | ); 15 | }; 16 | -------------------------------------------------------------------------------- /examples/with-miniapp-native-custom-component/src/pages/Home/index.jsx: -------------------------------------------------------------------------------- 1 | import { createElement } from 'rax'; 2 | import View from 'rax-view'; 3 | 4 | import './index.css'; 5 | import Test from '../../components/Test'; 6 | 7 | export default function Home() { 8 | return ( 9 | 10 | 11 | 12 | ); 13 | } 14 | -------------------------------------------------------------------------------- /examples/with-miniapp-plugin-component/src/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "routes": [ 3 | { 4 | "path": "/", 5 | "source": "pages/Home/index" 6 | } 7 | ], 8 | "plugins": { 9 | "myPlugin": { 10 | "version": "dev", 11 | "provider": "{{currentPluginId}}" 12 | } 13 | }, 14 | "window": { 15 | "title": "Rax App" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/rax-miniapp-runtime-webpack-plugin/src/static/rax-default.css: -------------------------------------------------------------------------------- 1 | .__rax-view { 2 | border: 0 solid black; 3 | display:flex; 4 | flex-direction:column; 5 | align-content:flex-start; 6 | flex-shrink:0; 7 | box-sizing:border-box; 8 | } 9 | 10 | .__rax-text { 11 | box-sizing: border-box; 12 | display: block; 13 | font-size: 32rpx; 14 | } 15 | -------------------------------------------------------------------------------- /examples/app-lifecycle/src/components/Logo/index.jsx: -------------------------------------------------------------------------------- 1 | import { createElement } from 'rax'; 2 | import Image from 'rax-image'; 3 | 4 | import './index.css'; 5 | 6 | export default (props) => { 7 | const { uri } = props; 8 | const source = { uri }; 9 | return ( 10 | 14 | ); 15 | }; 16 | -------------------------------------------------------------------------------- /examples/get-element/src/components/Logo/index.jsx: -------------------------------------------------------------------------------- 1 | import { createElement } from 'rax'; 2 | import Image from 'rax-image'; 3 | 4 | import './index.css'; 5 | 6 | export default (props) => { 7 | const { uri } = props; 8 | const source = { uri }; 9 | return ( 10 | 14 | ); 15 | }; 16 | -------------------------------------------------------------------------------- /examples/use-scrollview/src/components/Logo/index.jsx: -------------------------------------------------------------------------------- 1 | import { createElement } from 'rax'; 2 | import Image from 'rax-image'; 3 | 4 | import './index.css'; 5 | 6 | export default (props) => { 7 | const { uri } = props; 8 | const source = { uri }; 9 | return ( 10 | 14 | ); 15 | }; 16 | -------------------------------------------------------------------------------- /examples/with-miniapp-plugin-component/src/pages/Home/index.jsx: -------------------------------------------------------------------------------- 1 | import { createElement } from 'rax'; 2 | import View from 'rax-view'; 3 | 4 | import './index.css'; 5 | 6 | import Test from '../../components/Test'; 7 | 8 | 9 | export default function Home() { 10 | return ( 11 | 12 | 13 | 14 | ); 15 | } 16 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # Unix-style newlines with a newline ending every file 7 | [*] 8 | end_of_line = lf 9 | insert_final_newline = true 10 | indent_style = space 11 | indent_size = 2 12 | trim_trailing_whitespace = true 13 | 14 | [*.gradle] 15 | indent_size = 4 16 | -------------------------------------------------------------------------------- /examples/event-handler/src/components/CustomComp/index.jsx: -------------------------------------------------------------------------------- 1 | import { createElement } from 'rax'; 2 | import Image from 'rax-image'; 3 | 4 | import './index.css'; 5 | 6 | export default (props) => { 7 | const { uri } = props; 8 | const source = { uri }; 9 | return ( 10 | 14 | ); 15 | }; 16 | -------------------------------------------------------------------------------- /packages/jsx2mp-runtime/src/version.js: -------------------------------------------------------------------------------- 1 | export default '0.4.0 (Warning: The current version in miniapp belongs to jsx2mp-runtime rather than Rax. Please pay attention to the difference.)'; 2 | 3 | let modernMode = false; 4 | 5 | export function setModernMode(val) { 6 | modernMode = val; 7 | } 8 | 9 | export function getModernMode() { 10 | return modernMode; 11 | } 12 | -------------------------------------------------------------------------------- /packages/miniapp-render/src/builtInComponents/navigator.js: -------------------------------------------------------------------------------- 1 | export default { 2 | name: 'navigator', 3 | singleEvents: [{ 4 | name: 'onNavigatorSuccess', 5 | eventName: 'success' 6 | }, 7 | { 8 | name: 'onNavigatorFail', 9 | eventName: 'fail' 10 | }, 11 | { 12 | name: 'onNavigatorComplete', 13 | eventName: 'complete' 14 | }] 15 | }; 16 | -------------------------------------------------------------------------------- /examples/with-miniapp-native-page/src/components/Logo/index.jsx: -------------------------------------------------------------------------------- 1 | import { createElement } from 'rax'; 2 | import Image from 'rax-image'; 3 | 4 | import './index.css'; 5 | 6 | export default (props) => { 7 | const { uri } = props; 8 | const source = { uri }; 9 | return ( 10 | 14 | ); 15 | }; 16 | -------------------------------------------------------------------------------- /packages/jsx-compiler/src/utils/getProgramPath.js: -------------------------------------------------------------------------------- 1 | const traverse = require('./traverseNodePath'); 2 | 3 | /** 4 | * Get program path. 5 | * @param ast 6 | */ 7 | module.exports = function getProgramPath(ast) { 8 | let programPath = null; 9 | traverse(ast, { 10 | Program(path) { 11 | programPath = path; 12 | }, 13 | }); 14 | return programPath; 15 | }; 16 | -------------------------------------------------------------------------------- /examples/page-lifecycle-with-router/src/components/Logo/index.jsx: -------------------------------------------------------------------------------- 1 | import { createElement } from 'rax'; 2 | import Image from 'rax-image'; 3 | 4 | import './index.css'; 5 | 6 | export default (props) => { 7 | const { uri } = props; 8 | const source = { uri }; 9 | return ( 10 | 14 | ); 15 | }; 16 | -------------------------------------------------------------------------------- /packages/jsx-compiler/src/utils/isSlotScopeNode.js: -------------------------------------------------------------------------------- 1 | const traverse = require('./traverseNodePath'); 2 | 3 | module.exports = function(ast) { 4 | let isSlotScopeNode = false; 5 | traverse(ast, { 6 | Identifier(innerPath) { 7 | if (innerPath.node.__slotScope) { 8 | isSlotScopeNode = true; 9 | } 10 | } 11 | }); 12 | return isSlotScopeNode; 13 | }; 14 | -------------------------------------------------------------------------------- /packages/rax-miniapp-runtime-webpack-plugin/src/utils/getFinalRouteMap.js: -------------------------------------------------------------------------------- 1 | module.exports = (finalStaticConfig) => { 2 | const routeMap = {}; 3 | finalStaticConfig.routes.forEach(({ source, pageSource }) => { 4 | if (pageSource) { 5 | routeMap[source] = pageSource; 6 | } else { 7 | routeMap[source] = source; 8 | } 9 | }); 10 | return routeMap; 11 | }; 12 | -------------------------------------------------------------------------------- /examples/use-input/README.md: -------------------------------------------------------------------------------- 1 | # rax-materials-basic-app 2 | 3 | ## Getting Started 4 | 5 | ### `npm run start` 6 | 7 | Runs the app in development mode. 8 | 9 | Open [http://localhost:9999](http://localhost:9999) to view it in the browser. 10 | 11 | The page will reload if you make edits. 12 | 13 | ### `npm run build` 14 | 15 | Builds the app for production to the `build` folder. 16 | -------------------------------------------------------------------------------- /packages/jsx2mp-runtime/src/memo.js: -------------------------------------------------------------------------------- 1 | import shallowEqual from './shallowEqual'; 2 | 3 | export default function(Component, compare) { 4 | compare = compare || shallowEqual; 5 | // Memo could composed 6 | if (Component.__compares) { 7 | Component.__compares.push(compare); 8 | } else { 9 | Component.__compares = [compare]; 10 | } 11 | 12 | return Component; 13 | } 14 | -------------------------------------------------------------------------------- /examples/app-lifecycle/README.md: -------------------------------------------------------------------------------- 1 | # rax-materials-basic-app 2 | 3 | ## Getting Started 4 | 5 | ### `npm run start` 6 | 7 | Runs the app in development mode. 8 | 9 | Open [http://localhost:9999](http://localhost:9999) to view it in the browser. 10 | 11 | The page will reload if you make edits. 12 | 13 | ### `npm run build` 14 | 15 | Builds the app for production to the `build` folder. 16 | -------------------------------------------------------------------------------- /examples/event-handler/README.md: -------------------------------------------------------------------------------- 1 | # rax-materials-basic-app 2 | 3 | ## Getting Started 4 | 5 | ### `npm run start` 6 | 7 | Runs the app in development mode. 8 | 9 | Open [http://localhost:9999](http://localhost:9999) to view it in the browser. 10 | 11 | The page will reload if you make edits. 12 | 13 | ### `npm run build` 14 | 15 | Builds the app for production to the `build` folder. 16 | -------------------------------------------------------------------------------- /examples/get-element/README.md: -------------------------------------------------------------------------------- 1 | # rax-materials-basic-app 2 | 3 | ## Getting Started 4 | 5 | ### `npm run start` 6 | 7 | Runs the app in development mode. 8 | 9 | Open [http://localhost:9999](http://localhost:9999) to view it in the browser. 10 | 11 | The page will reload if you make edits. 12 | 13 | ### `npm run build` 14 | 15 | Builds the app for production to the `build` folder. 16 | -------------------------------------------------------------------------------- /examples/use-scrollview/README.md: -------------------------------------------------------------------------------- 1 | # rax-materials-basic-app 2 | 3 | ## Getting Started 4 | 5 | ### `npm run start` 6 | 7 | Runs the app in development mode. 8 | 9 | Open [http://localhost:9999](http://localhost:9999) to view it in the browser. 10 | 11 | The page will reload if you make edits. 12 | 13 | ### `npm run build` 14 | 15 | Builds the app for production to the `build` folder. 16 | -------------------------------------------------------------------------------- /packages/rax-miniapp-babel-plugins/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [0.1.15] - 2021-05-11 4 | 5 | ### Changed 6 | 7 | - Update miniapp-builder-shared version to 0.2.x 8 | 9 | ## [0.1.14] - 2021-05-10 10 | 11 | ### Changed 12 | 13 | - Use constants from miniapp-builder-shared 14 | 15 | ## [0.1.13] - 2021-04-27 16 | 17 | ### Changed 18 | 19 | - Update homepage url in `package.json` 20 | -------------------------------------------------------------------------------- /examples/with-miniapp-native-page/README.md: -------------------------------------------------------------------------------- 1 | # rax-materials-basic-app 2 | 3 | ## Getting Started 4 | 5 | ### `npm run start` 6 | 7 | Runs the app in development mode. 8 | 9 | Open [http://localhost:9999](http://localhost:9999) to view it in the browser. 10 | 11 | The page will reload if you make edits. 12 | 13 | ### `npm run build` 14 | 15 | Builds the app for production to the `build` folder. 16 | -------------------------------------------------------------------------------- /examples/page-lifecycle-with-router/README.md: -------------------------------------------------------------------------------- 1 | # rax-materials-basic-app 2 | 3 | ## Getting Started 4 | 5 | ### `npm run start` 6 | 7 | Runs the app in development mode. 8 | 9 | Open [http://localhost:9999](http://localhost:9999) to view it in the browser. 10 | 11 | The page will reload if you make edits. 12 | 13 | ### `npm run build` 14 | 15 | Builds the app for production to the `build` folder. 16 | -------------------------------------------------------------------------------- /examples/with-miniapp-plugin-component/README.md: -------------------------------------------------------------------------------- 1 | # rax-materials-basic-app 2 | 3 | ## Getting Started 4 | 5 | ### `npm run start` 6 | 7 | Runs the app in development mode. 8 | 9 | Open [http://localhost:9999](http://localhost:9999) to view it in the browser. 10 | 11 | The page will reload if you make edits. 12 | 13 | ### `npm run build` 14 | 15 | Builds the app for production to the `build` folder. 16 | -------------------------------------------------------------------------------- /examples/with-miniapp-plugin-component/src/components/Test/index.jsx: -------------------------------------------------------------------------------- 1 | import { createElement } from 'rax'; 2 | import { isWeb, isMiniApp } from 'universal-env'; 3 | import View from 'rax-view'; 4 | import Text from 'rax-text'; 5 | 6 | 7 | export default function Home() { 8 | return ( 9 | 10 | 这是 web 组件 11 | 12 | ); 13 | } 14 | -------------------------------------------------------------------------------- /packages/build-plugin-rax-miniapp-plugin/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## v1.0.1 4 | 5 | - fix: make compile mode as default mode 6 | 7 | ## v1.0.0 8 | 9 | - feat: Support runtime mode 10 | 11 | ## v0.1.4 12 | 13 | - fix: Can't copy __app_css of build result to demo folder 14 | 15 | ## v0.1.3 16 | 17 | - feat: Copy bundle to demo folder in build mode to match alibaba miniapp cloud build demand 18 | -------------------------------------------------------------------------------- /packages/jsx-compiler/src/utils/createJSXBinding.js: -------------------------------------------------------------------------------- 1 | const t = require('@babel/types'); 2 | 3 | module.exports = function createJSXBinding(string) { 4 | const id = t.identifier(string); 5 | const jsxExp = t.jsxExpressionContainer(t.objectExpression([ 6 | t.objectProperty(id, id, false, true) 7 | ])); 8 | jsxExp.__transformed = true; // In case of loop transform. 9 | return jsxExp; 10 | }; 11 | -------------------------------------------------------------------------------- /packages/jsx2mp-runtime/src/nextTick.js: -------------------------------------------------------------------------------- 1 | /* global nextTick */ 2 | let nextTick = typeof my === 'object' && my.nextTick 3 | ? my.nextTick 4 | : setTimeout; 5 | 6 | if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production') { 7 | // Wrapper timer for hijack timers in jest 8 | nextTick = (callback) => { 9 | setTimeout(callback, 0); 10 | }; 11 | } 12 | 13 | export default nextTick; 14 | -------------------------------------------------------------------------------- /packages/miniapp-render/src/bridge/events/callEvent.js: -------------------------------------------------------------------------------- 1 | import EventTarget from '../../event/event-target'; 2 | import cache from '../../utils/cache'; 3 | 4 | export default function(eventName, evt, extra, nodeId) { 5 | const originNode = cache.getNode(nodeId); 6 | 7 | if (!originNode) return; 8 | EventTarget._process( 9 | originNode, 10 | eventName, 11 | evt, 12 | extra 13 | ); 14 | } 15 | -------------------------------------------------------------------------------- /examples/with-miniapp-native-custom-component/README.md: -------------------------------------------------------------------------------- 1 | # rax-materials-basic-app 2 | 3 | ## Getting Started 4 | 5 | ### `npm run start` 6 | 7 | Runs the app in development mode. 8 | 9 | Open [http://localhost:9999](http://localhost:9999) to view it in the browser. 10 | 11 | The page will reload if you make edits. 12 | 13 | ### `npm run build` 14 | 15 | Builds the app for production to the `build` folder. 16 | -------------------------------------------------------------------------------- /examples/use-rax-compiled-component-in-runtime-miniapp/README.md: -------------------------------------------------------------------------------- 1 | # rax-materials-basic-app 2 | 3 | ## Getting Started 4 | 5 | ### `npm run start` 6 | 7 | Runs the app in development mode. 8 | 9 | Open [http://localhost:3333](http://localhost:3333) to view it in the browser. 10 | 11 | The page will reload if you make edits. 12 | 13 | ### `npm run build` 14 | 15 | Builds the app for production to the `build` folder. 16 | -------------------------------------------------------------------------------- /examples/with-miniapp-native-page/build.json: -------------------------------------------------------------------------------- 1 | { 2 | "inlineStyle": false, 3 | "plugins": [ 4 | [ 5 | "build-plugin-rax-app", 6 | { 7 | "targets": [ 8 | "miniapp" 9 | ], 10 | "miniapp": { 11 | "buildType": "runtime" 12 | }, 13 | "wechat-miniprogram": { 14 | "buildType": "runtime" 15 | } 16 | } 17 | ] 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.7.0", 3 | "npmClient": "yarn", 4 | "useWorkspaces": true, 5 | "packages": [ 6 | "packages/*" 7 | ], 8 | "command": { 9 | "bootstrap": { 10 | "npmClientArgs": ["--no-lockfile"] 11 | }, 12 | "publish": { 13 | "skipGit": true, 14 | "allowBranch": "master", 15 | "ignoreChanges": [ 16 | "*.md" 17 | ] 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /packages/jsx2mp-loader/src/utils/addSourceMap.js: -------------------------------------------------------------------------------- 1 | const convertSourceMap = require('convert-source-map'); 2 | 3 | function addSourceMap(code, rawCode, originalMap) { 4 | const map = Object.assign(originalMap, { 5 | sourcesContent: [rawCode] 6 | }); 7 | const sourceMapString = convertSourceMap.fromObject(map).toComment(); 8 | return code + '\n' + sourceMapString; 9 | } 10 | 11 | module.exports = addSourceMap; 12 | -------------------------------------------------------------------------------- /packages/jsx2mp-runtime/src/adapter/getNativeEventBindTarget.js: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line import/no-extraneous-dependencies 2 | import { isMiniApp } from 'universal-env'; 3 | 4 | export default function(Klass, shouldReturnConfig) { 5 | // For alibaba miniapp 6 | if (isMiniApp) { 7 | return shouldReturnConfig ? Klass.__config : Klass.__config.events; 8 | } else { 9 | return Klass.__config; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/build-plugin-rax-miniapp-faas/README.md: -------------------------------------------------------------------------------- 1 | # build-plugin-rax-miniapp-faas [![npm](https://img.shields.io/npm/v/build-plugin-rax-miniapp-faas.svg)](https://www.npmjs.com/package/build-plugin-rax-miniapp-faas) 2 | 3 | `build-scripts` plugin which contains base configuration of rax miniapp faas 4 | 5 | ## Usage 6 | 7 | ```json 8 | { 9 | "plugins": [ 10 | "build-plugin-rax-miniapp-faas" 11 | ] 12 | } 13 | ``` 14 | -------------------------------------------------------------------------------- /packages/build-plugin-rax-miniapp-plugin/README.md: -------------------------------------------------------------------------------- 1 | # build-plugin-rax-miniapp-plugin [![npm](https://img.shields.io/npm/v/build-plugin-rax-miniapp-plugin.svg)](https://www.npmjs.com/package/build-plugin-rax-miniapp-plugin) 2 | 3 | `build-scripts` plugin which contains base configuration of rax miniapp plugin 4 | 5 | ## Usage 6 | 7 | ```json 8 | { 9 | "plugins": [ 10 | "build-plugin-rax-miniapp-plugin" 11 | ] 12 | } 13 | ``` 14 | -------------------------------------------------------------------------------- /packages/miniapp-lifecycles/src/index.js: -------------------------------------------------------------------------------- 1 | export function registerNativeEventListeners(Klass, events) { 2 | // For rax miniapp runtime babel plugins prev compile 3 | } 4 | 5 | export function addNativeEventListener(eventName, callback) { 6 | document.addEventListener(eventName, callback); 7 | } 8 | 9 | export function removeNativeEventListener(eventName, callback) { 10 | document.removeEventListener(eventName, callback); 11 | } 12 | -------------------------------------------------------------------------------- /examples/use-rax-compiled-component-in-runtime-miniapp/src/miniapp-compiled/CompiledComp2/index.jsx: -------------------------------------------------------------------------------- 1 | import { createElement } from 'rax'; 2 | import View from 'rax-view'; 3 | import styles from './index.module.less'; 4 | 5 | const CompiledComp2 = (props) => { 6 | const { name } = props; 7 | return ( 8 | 我是 CompiledComp2 {name} 9 | ); 10 | }; 11 | 12 | export default CompiledComp2; 13 | -------------------------------------------------------------------------------- /packages/miniapp-render/src/index.js: -------------------------------------------------------------------------------- 1 | import createAppConfig from './createConfig/app'; 2 | import createPageConfig from './createConfig/page'; 3 | import createElementConfig from './createConfig/element'; 4 | import createDocument from './document'; 5 | import createWindow from './window'; 6 | 7 | export default { 8 | createAppConfig, 9 | createPageConfig, 10 | createElementConfig, 11 | createDocument, 12 | createWindow 13 | }; 14 | -------------------------------------------------------------------------------- /examples/app-lifecycle/build.json: -------------------------------------------------------------------------------- 1 | { 2 | "inlineStyle": false, 3 | "plugins": [ 4 | [ 5 | "build-plugin-rax-app", 6 | { 7 | "targets": [ 8 | "miniapp", 9 | "wechat-miniprogram" 10 | ], 11 | "miniapp": { 12 | "buildType": "runtime" 13 | }, 14 | "wechat-miniprogram": { 15 | "buildType": "runtime" 16 | } 17 | } 18 | ] 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /examples/event-handler/build.json: -------------------------------------------------------------------------------- 1 | { 2 | "inlineStyle": false, 3 | "plugins": [ 4 | [ 5 | "build-plugin-rax-app", 6 | { 7 | "targets": [ 8 | "miniapp", 9 | "wechat-miniprogram" 10 | ], 11 | "miniapp": { 12 | "buildType": "compile" 13 | }, 14 | "wechat-miniprogram": { 15 | "buildType": "compile" 16 | } 17 | } 18 | ] 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /examples/get-element/build.json: -------------------------------------------------------------------------------- 1 | { 2 | "inlineStyle": false, 3 | "plugins": [ 4 | [ 5 | "build-plugin-rax-app", 6 | { 7 | "targets": [ 8 | "miniapp", 9 | "wechat-miniprogram" 10 | ], 11 | "miniapp": { 12 | "buildType": "runtime" 13 | }, 14 | "wechat-miniprogram": { 15 | "buildType": "runtime" 16 | } 17 | } 18 | ] 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /examples/use-input/build.json: -------------------------------------------------------------------------------- 1 | { 2 | "inlineStyle": false, 3 | "plugins": [ 4 | [ 5 | "build-plugin-rax-app", 6 | { 7 | "targets": [ 8 | "miniapp", 9 | "wechat-miniprogram" 10 | ], 11 | "miniapp": { 12 | "buildType": "runtime" 13 | }, 14 | "wechat-miniprogram": { 15 | "buildType": "runtime" 16 | } 17 | } 18 | ] 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /examples/use-scrollview/build.json: -------------------------------------------------------------------------------- 1 | { 2 | "inlineStyle": false, 3 | "plugins": [ 4 | [ 5 | "build-plugin-rax-app", 6 | { 7 | "targets": [ 8 | "miniapp", 9 | "wechat-miniprogram" 10 | ], 11 | "miniapp": { 12 | "buildType": "runtime" 13 | }, 14 | "wechat-miniprogram": { 15 | "buildType": "runtime" 16 | } 17 | } 18 | ] 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /packages/jsx2mp-cli/demo/component.js: -------------------------------------------------------------------------------- 1 | import { createElement } from 'rax'; 2 | import View, { custom } from 'rax-view'; 3 | import Image from 'rax-image'; 4 | import img from './assets/rax.png'; 5 | 6 | const a = 0; 7 | const b = 1; 8 | 9 | export default function Index() { 10 | custom(); 11 | return ( 12 | 13 | Hello World! 14 | 15 | 16 | ); 17 | } 18 | -------------------------------------------------------------------------------- /examples/page-lifecycle-with-router/build.json: -------------------------------------------------------------------------------- 1 | { 2 | "inlineStyle": false, 3 | "plugins": [ 4 | [ 5 | "build-plugin-rax-app", 6 | { 7 | "targets": [ 8 | "miniapp", 9 | "wechat-miniprogram" 10 | ], 11 | "miniapp": { 12 | "buildType": "runtime" 13 | }, 14 | "wechat-miniprogram": { 15 | "buildType": "runtime" 16 | } 17 | } 18 | ] 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /packages/eslint-plugin-rax-compile-time-miniapp/docs/rules/no_id_in_jsx.md: -------------------------------------------------------------------------------- 1 | # no-id-in-jsx 2 | 如果在自定义组件上写 `id` 会造成在组件中无法通过 `props.id` 获取。 3 | 4 | 例如:`` ,此时在 Child 中是无法通过 props.id 获取到值的。因此,Rax 在编译时做了转化,当开发者 `` 这样写的时候,不仅会保留外层的 id,还会添加一个等值的 componentId,开发者在自定义组件中可以通过 props.componentId 获取到想要的值。 5 | 6 | 此条规则目前只是 `warning` 7 | 8 | ## More 9 | https://rax.js.org/docs/guide/compile-miniapp-syntax-constraints#%E5%85%B3%E9%94%AE%E8%AF%8D -------------------------------------------------------------------------------- /packages/jsx-compiler/src/getCompiledComponents.js: -------------------------------------------------------------------------------- 1 | module.exports = function(platform) { 2 | switch (platform) { 3 | case 'ali': 4 | return { 5 | 'rax-view': 'view' 6 | }; 7 | case 'wechat': 8 | return { 9 | 'rax-view': 'view', 10 | 'rax-text': 'text' 11 | }; 12 | case 'bytedance': 13 | return { 14 | 'rax-view': 'view', 15 | 'rax-text': 'text' 16 | }; 17 | } 18 | }; 19 | -------------------------------------------------------------------------------- /packages/jsx2mp-runtime/src/pageInstanceMap.js: -------------------------------------------------------------------------------- 1 | // pageId -> rax page instance 2 | const pageInstanceMap = {}; 3 | 4 | 5 | export function setPageInstance(pageInstance) { 6 | const pageId = pageInstance.instanceId; 7 | pageInstanceMap[pageId] = pageInstance; 8 | } 9 | 10 | 11 | export function getPageInstanceById(pageId) { 12 | if (pageInstanceMap.hasOwnProperty(pageId)) { 13 | return pageInstanceMap[pageId]; 14 | } 15 | return null; 16 | } 17 | -------------------------------------------------------------------------------- /examples/with-miniapp-plugin-component/build.json: -------------------------------------------------------------------------------- 1 | { 2 | "inlineStyle": false, 3 | "plugins": [ 4 | [ 5 | "build-plugin-rax-app", 6 | { 7 | "targets": [ 8 | "miniapp", 9 | "wechat-miniprogram" 10 | ], 11 | "miniapp": { 12 | "buildType": "runtime" 13 | }, 14 | "wechat-miniprogram": { 15 | "buildType": "runtime" 16 | } 17 | } 18 | ] 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /packages/jsx2mp-runtime/src/adapter/getNativeAPI.js: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line import/no-extraneous-dependencies 2 | import { isMiniApp, isWeChatMiniProgram, isByteDanceMicroApp } from 'universal-env'; 3 | /* global my, wx, tt */ 4 | 5 | let apiCore; 6 | 7 | if (isMiniApp) { 8 | apiCore = my; 9 | } else if (isWeChatMiniProgram) { 10 | apiCore = wx; 11 | } else if (isByteDanceMicroApp) { 12 | apiCore = tt; 13 | } 14 | 15 | export default apiCore; 16 | 17 | -------------------------------------------------------------------------------- /packages/rax-miniapp-babel-plugins/README-zh.md: -------------------------------------------------------------------------------- 1 | # rax-miniapp-babel-plugins 2 | 3 | [英文](./README.md) 4 | 5 | 🚀 我们可以在通过这些 babel 插件更大程度上优化生成的小程序代码。 6 | 7 | ## 为什么需要预编译? 8 | 9 | ### Rax 小程序运行时方案 10 | 11 | #### 原生生命周期 12 | 13 | 在 Rax 小程序运行时解决方案中,我们可以提前知道开发者使用了哪个原生生命周期。过去,我们将注册整个小程序的原生生命周期。这将对性能产生一定影响,甚至导致内存泄漏。 14 | 15 | #### 使用内置组件 16 | 17 | 在此解决方案中,我们必须遍历小程序的所有内置组件。这将对性能产生一定影响,并生成大量无效代码。但是现在,我们可以在预编译阶段获取此信息。 18 | 19 | ## 更多的 20 | 预编译可以为我们带来更多的优化可能性。我们将继续补充。 21 | -------------------------------------------------------------------------------- /examples/with-miniapp-native-custom-component/build.json: -------------------------------------------------------------------------------- 1 | { 2 | "inlineStyle": false, 3 | "plugins": [ 4 | [ 5 | "build-plugin-rax-app", 6 | { 7 | "targets": [ 8 | "miniapp", 9 | "wechat-miniprogram" 10 | ], 11 | "miniapp": { 12 | "buildType": "runtime" 13 | }, 14 | "wechat-miniprogram": { 15 | "buildType": "runtime" 16 | } 17 | } 18 | ] 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /packages/eslint-plugin-rax-compile-time-miniapp/docs/rules/no_multiple_return.md: -------------------------------------------------------------------------------- 1 | # no-multiple-return 2 | 一个渲染函数中只能存在一个 `return` 3 | 4 | ## Rule Details 5 | 6 | Examples of **incorrect** code for this rule: 7 | 8 | ```js 9 | 10 | function App() { 11 | if (false) { 12 | return b; 13 | } 14 | return a; 15 | } 16 | 17 | ``` 18 | 19 | ## More 20 | https://rax.js.org/docs/guide/compile-miniapp-syntax-constraints#%E5%A4%9A%E4%B8%AA%20return -------------------------------------------------------------------------------- /packages/jsx-compiler/src/parser/option.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Babel parser option. 3 | */ 4 | module.exports = { 5 | sourceType: 'module', 6 | plugins: [ 7 | 'classProperties', 8 | 'jsx', 9 | 'typescript', 10 | 'trailingFunctionCommas', 11 | 'asyncFunctions', 12 | 'exponentiationOperator', 13 | 'asyncGenerators', 14 | 'objectRestSpread', 15 | ['decorators', { decoratorsBeforeExport: false }], 16 | 'dynamicImport' 17 | ], 18 | }; 19 | -------------------------------------------------------------------------------- /packages/jsx-compiler/src/utils/checkAttr.js: -------------------------------------------------------------------------------- 1 | const isDirectiveAttr = attr => /^(a:|wx:|x-)/.test(attr); 2 | const isEventHandlerAttr = propKey => /^on[A-Z]/.test(propKey) || /^bind[a-z:]/.test(propKey) || /^catch[A-Za-z:]/.test(propKey); 3 | const isRenderPropsAttr = propKey => /^render[A-Z]/.test(propKey); 4 | const BINDING_REG = /{{|}}/g; 5 | 6 | module.exports = { 7 | isDirectiveAttr, 8 | isEventHandlerAttr, 9 | isRenderPropsAttr, 10 | BINDING_REG 11 | }; 12 | -------------------------------------------------------------------------------- /packages/rax-miniapp-babel-plugins/src/utils/getPagePath.js: -------------------------------------------------------------------------------- 1 | const { sep } = require('path'); 2 | const getFilePath = require('./getFilePath'); 3 | 4 | /** 5 | * @param {string} filename - Current handled file name 6 | * @return {string|undefined} 7 | */ 8 | module.exports = function(filename) { 9 | const nodeModulesReg = new RegExp(`\\${sep}node_modules\\${sep}`); 10 | if (!nodeModulesReg.exec(filename)) { 11 | return getFilePath(filename); 12 | } 13 | }; 14 | -------------------------------------------------------------------------------- /packages/jsx-compiler/src/utils/invokeModules.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Invoke modules. 3 | * @param modules 4 | * @param key 5 | * @param args Remain arguments. 6 | */ 7 | module.exports = function invokeModules(modules, key, ...args) { 8 | if (Array.isArray(modules)) { 9 | for (let i = 0, l = modules.length; i < l; i ++) { 10 | if (typeof modules[i][key] === 'function') { 11 | modules[i][key].apply(modules[i], args); 12 | } 13 | } 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /packages/miniapp-compile-config/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [0.2.4] - 2021-08-05 4 | 5 | ### Added 6 | 7 | - Support generating multiple package.json file in subpackages mode 8 | 9 | ## [0.2.3] - 2021-07-20 10 | 11 | ### Added 12 | 13 | - Support config miniapp plugin project 14 | 15 | ### Changed 16 | 17 | - Use copy-webpack-plugin v5 18 | 19 | ## [0.2.2] - 2021-03-30 20 | 21 | ### Added 22 | 23 | - Support config native miniapp dependencies in build.json 24 | -------------------------------------------------------------------------------- /packages/rax-miniapp-config-webpack-plugin/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rax-miniapp-config-webpack-plugin", 3 | "version": "2.1.2", 4 | "description": "miniapp config webpack plugin", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Rax Team", 10 | "license": "MIT", 11 | "dependencies": { 12 | "fs-extra": "^8.1.0", 13 | "miniapp-builder-shared": "^0.2.0" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/build-plugin-rax-miniapp-plugin/src/getOutputPath.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs-extra'); 2 | const path = require('path'); 3 | const { constants: { MINIAPP } } = require('miniapp-builder-shared'); 4 | 5 | module.exports = (context, { target = MINIAPP, demoClientFolder = false}) => { 6 | const { rootDir } = context; 7 | if (demoClientFolder) { 8 | return path.resolve(rootDir, 'demo', target); 9 | } 10 | return path.resolve(rootDir, 'demo', target, 'plugin'); 11 | }; 12 | -------------------------------------------------------------------------------- /packages/jsx-compiler/src/utils/getReturnElementPath.js: -------------------------------------------------------------------------------- 1 | const traverse = require('./traverseNodePath'); 2 | 3 | /** 4 | * Get reutrn statement element. 5 | */ 6 | function getReturnElementPath(ast) { 7 | let result = null; 8 | 9 | traverse(ast, { 10 | ReturnStatement: { 11 | exit(returnStatementPath) { 12 | result = returnStatementPath; 13 | } 14 | }, 15 | }); 16 | 17 | return result; 18 | } 19 | 20 | module.exports = getReturnElementPath; 21 | -------------------------------------------------------------------------------- /packages/miniapp-compile-config/src/plugins/RemoveDefaultResult.js: -------------------------------------------------------------------------------- 1 | const { compilation } = require('webpack'); 2 | 3 | module.exports = class RemoveDefaultResultPlugin { 4 | apply(compiler) { 5 | compiler.hooks.compilation.tap('RemoveDefaultResultPlugin', (compilation) => { 6 | compilation.hooks.shouldGenerateChunkAssets.tap( 7 | 'disableGenerateChunkAssets', 8 | () => { 9 | return false; 10 | } 11 | ); 12 | }); 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## Changelog 2 | 3 | ### 2021-04-22 4 | 5 | - [fixed] Can't get correct window in subpackages mode 6 | - [fixed] Can't use rax miniapp compile components in subpackages mode 7 | - [fixed] Can't config button style in css files 8 | 9 | ### 2021-04-08 10 | 11 | - [feature] Grade view/text/image/h-element into static/pure/no-touch/no-appear/no-appear-touch level 12 | - [fixed] Miss props in wechat picker template 13 | - [fixed] Miss native component npm in subpackages mode 14 | -------------------------------------------------------------------------------- /packages/rax-miniapp-runtime-webpack-plugin/src/utils/addFileToCompilation.js: -------------------------------------------------------------------------------- 1 | const { extname } = require('path'); 2 | const { minify } = require('./minifyCode'); 3 | 4 | // Add file to compilation 5 | module.exports = function(compilation, { filename, content, command = 'build', target }) { 6 | compilation.assets[`${filename}`] = { 7 | source: () => command === 'build' ? minify(content, extname(filename)) : content, 8 | size: () => Buffer.from(content).length 9 | }; 10 | }; 11 | -------------------------------------------------------------------------------- /packages/eslint-plugin-rax-compile-time-miniapp/docs/rules/export_default_component.md: -------------------------------------------------------------------------------- 1 | # export-default-component 2 | 3 | 为了方便编译器找到导出的组件,我们对导出组件做了如下限制: 4 | 默认导出的必须是组件,即 5 | 6 | ```js 7 | 8 | export default MyComponent; 9 | 10 | ``` 11 | 12 | 当导出的组件需要被某个函数处理的时候,函数的第一个参数必须是组件,即 13 | 14 | ```js 15 | export default handleComponent(MyComponent); 16 | ``` 17 | 18 | ## More 19 | https://rax.js.org/docs/guide/compile-miniapp-syntax-constraints#%E7%BB%84%E4%BB%B6%E5%AF%BC%E5%87%BA%E6%96%B9%E5%BC%8F -------------------------------------------------------------------------------- /packages/eslint-plugin-rax-compile-time-miniapp/docs/rules/no_spread.md: -------------------------------------------------------------------------------- 1 | # no-spread 2 | 不支持直接在组件上使用扩展运算符 3 | 4 | ## Rule Details 5 | 6 | Examples of **incorrect** code for this rule: 7 | 8 | ```jsx 9 | 10 | 11 | 12 | ``` 13 | 14 | Examples of **correct** code for this rule: 15 | 16 | ```jsx 17 | 18 | 19 | 20 | ``` 21 | 22 | ## More 23 | https://rax.js.org/docs/guide/compile-miniapp-syntax-constraints#%E6%89%A9%E5%B1%95%E8%BF%90%E7%AE%97%E7%AC%A6 -------------------------------------------------------------------------------- /packages/jsx2mp-runtime/src/adapter/getEventProps.js: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line import/no-extraneous-dependencies 2 | import { isQuickApp } from 'universal-env'; 3 | 4 | export default function() { 5 | // For quickapp 6 | if (isQuickApp) { 7 | return { 8 | TYPE: '_type', 9 | TARGET: '_target', 10 | TIMESTAMP: '_timeStamp', 11 | }; 12 | } else { 13 | return { 14 | TYPE: 'type', 15 | TARGET: 'target', 16 | TIMESTAMP: 'timeStamp', 17 | }; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/miniapp-render/src/builtInComponents/editor.js: -------------------------------------------------------------------------------- 1 | export default { 2 | name: 'editor', 3 | singleEvents: [{ 4 | name: 'onEditorReady', 5 | eventName: 'ready' 6 | }, 7 | { 8 | name: 'onEditorFocus', 9 | eventName: 'focus' 10 | }, 11 | { 12 | name: 'onEditorBlur', 13 | eventName: 'blur' 14 | }, 15 | { 16 | name: 'onEditorInput', 17 | eventName: 'input' 18 | }, 19 | { 20 | name: 'onEditorStatusChange', 21 | eventName: 'statuschange' 22 | }] 23 | }; 24 | -------------------------------------------------------------------------------- /packages/jsx2mp-runtime/src/valueEmitter.js: -------------------------------------------------------------------------------- 1 | import Event from './events'; 2 | 3 | let count = 0; 4 | 5 | export default class ValueEmitter extends Event { 6 | constructor(defaultValue) { 7 | super(); 8 | this.id = `valueEmitter_${count++}`; 9 | this.value = defaultValue; 10 | } 11 | 12 | on(handler) { 13 | super.on(this.id, handler); 14 | } 15 | 16 | off(handler) { 17 | super.off(this.id, handler); 18 | } 19 | 20 | emit() { 21 | super.emit(this.id, this.value); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /examples/with-miniapp-plugin-component/wechat-miniprogram-plugin/components/hello-component.js: -------------------------------------------------------------------------------- 1 | // plugin/components/hello-component.js 2 | Component({ 3 | properties: { 4 | list: { 5 | type: Array, 6 | value: [], 7 | observer: function(newVal, oldVal, changedPath) { 8 | this.setData({ list: newVal }); 9 | } 10 | } 11 | }, 12 | 13 | data: { 14 | list: [] 15 | }, 16 | 17 | methods: { 18 | onClick() { 19 | this.triggerEvent('Test'); 20 | } 21 | } 22 | }); 23 | -------------------------------------------------------------------------------- /packages/jsx2mp-loader/src/utils/isMiniappComponent.js: -------------------------------------------------------------------------------- 1 | const { 2 | existsSync 3 | } = require('fs-extra'); 4 | const { removeExt } = require('./pathHelper'); 5 | 6 | const suffix = { 7 | ali: ['.js', '.json', '.axml'], 8 | wechat: ['.js', '.json', '.wxml'], 9 | bytedance: ['.js', '.json', '.ttml'], 10 | quickapp: ['.ux'], 11 | }; 12 | // e.g file: /root/lib/miniapp/index 13 | module.exports = function(filename, platform = 'ali') { 14 | return suffix[platform].every(s => existsSync(removeExt(filename) + s)); 15 | }; 16 | -------------------------------------------------------------------------------- /packages/jsx2mp-runtime/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [0.4.23] - 2021-08-19 4 | 5 | - Support list key 6 | 7 | ## [0.4.22] - 2021-07-6 8 | 9 | ### Fixed 10 | 11 | - Can't share successfully when user doesn't config app.onShareAppMessage 12 | 13 | ### Added 14 | 15 | - Support pass variables in runApp to app instance 16 | 17 | ## [0.4.21] - 2021-03-30 18 | 19 | ### Added 20 | 21 | - Support merging virtualHost config into component config 22 | 23 | ### Fixed 24 | 25 | - Render props can't work in wechat miniprogram 26 | -------------------------------------------------------------------------------- /examples/with-miniapp-native-custom-component/src/components/Test/index.wechat.jsx: -------------------------------------------------------------------------------- 1 | import { createElement } from 'rax'; 2 | import View from 'rax-view'; 3 | 4 | import Test from '../../public/WechatNativeComp/index'; 5 | 6 | export default function Home() { 7 | return ( 8 | 9 | { 10 | console.log('我被击中了'); 11 | }}> 12 | 我是 header 13 | 我是 footer 14 | 15 | 16 | ); 17 | } 18 | -------------------------------------------------------------------------------- /packages/miniapp-render/src/bridge/events/callSimpleEvent.js: -------------------------------------------------------------------------------- 1 | import Event from '../../event/event'; 2 | import EventTarget from '../../event/event-target'; 3 | 4 | // Call simple node event, no bubbling 5 | export default function(eventName, evt, domNode) { 6 | if (!domNode) return; 7 | 8 | EventTarget._process(domNode, new Event({ 9 | name: eventName, 10 | target: domNode, 11 | eventPhase: Event.AT_TARGET, 12 | detail: evt && evt.detail, 13 | __extra: evt && evt.extra, 14 | bubbles: false, 15 | })); 16 | } 17 | -------------------------------------------------------------------------------- /packages/jsx2mp-runtime/src/adapter/index.js: -------------------------------------------------------------------------------- 1 | import getNativePageLifecycle from './getNativePageLifecycle'; 2 | import getNativeComponentLifecycle from './getNativeComponentLifecycle'; 3 | import getComponentBaseConfig from './getComponentBaseConfig'; 4 | import getNativeEventBindTarget from './getNativeEventBindTarget'; 5 | import getEventProps from './getEventProps'; 6 | 7 | export { 8 | getNativePageLifecycle, 9 | getNativeComponentLifecycle, 10 | getComponentBaseConfig, 11 | getNativeEventBindTarget, 12 | getEventProps, 13 | }; 14 | -------------------------------------------------------------------------------- /packages/jsx-compiler/src/constants.js: -------------------------------------------------------------------------------- 1 | const { sep } = require('path'); 2 | 3 | const RELATIVE_COMPONENTS_REG = /^\..*(\.jsx?)?$/i; 4 | const MINIAPP_PLUGIN_COMPONENTS_REG = /^plugin\:\/\//; 5 | 6 | const PKG_NAME_REG = new RegExp(`^.*\\${sep}node_modules\\${sep}([^\\${sep}]*).*$`); 7 | const GROUP_PKG_NAME_REG = new RegExp(`^.*\\${sep}node_modules\\${sep}([^\\${sep}]*?\\${sep}[^\\${sep}]*).*$`); 8 | 9 | module.exports = { 10 | RELATIVE_COMPONENTS_REG, 11 | MINIAPP_PLUGIN_COMPONENTS_REG, 12 | PKG_NAME_REG, 13 | GROUP_PKG_NAME_REG 14 | }; 15 | -------------------------------------------------------------------------------- /packages/jsx2mp-cli/utils/spinner.js: -------------------------------------------------------------------------------- 1 | const ora = require('ora'); 2 | const consoleClear = require('console-clear'); 3 | 4 | const methods = ['start', 'succeed']; 5 | const spinner = ora({ spinner: 'arc' }); 6 | 7 | // Default to clear screen each time. 8 | spinner.shouldClear = true; 9 | 10 | for (let method of methods) { 11 | const tempMethod = spinner[method]; 12 | spinner[method] = function(...arg) { 13 | if (spinner.shouldClear) consoleClear(true); 14 | tempMethod.apply(this, arg); 15 | }; 16 | } 17 | 18 | module.exports = spinner; 19 | -------------------------------------------------------------------------------- /packages/miniapp-render/src/builtInComponents/picker-view.js: -------------------------------------------------------------------------------- 1 | export default { 2 | name: 'picker-view', 3 | singleEvents: [{ 4 | name: 'onPickerViewPickstart', 5 | eventName: 'pickstart' 6 | }, 7 | { 8 | name: 'onPickerViewPickend', 9 | eventName: 'pickend' 10 | }], 11 | functionalSingleEvents: [ 12 | { 13 | name: 'onPickerViewChange', 14 | eventName: 'change', 15 | middleware(evt, domNode) { 16 | domNode._setAttributeWithDelayUpdate('value', evt.detail.value); 17 | } 18 | } 19 | ] 20 | }; 21 | -------------------------------------------------------------------------------- /packages/eslint-plugin-rax-compile-time-miniapp/docs/rules/no_multiple_component.md: -------------------------------------------------------------------------------- 1 | # no-multiple-component 2 | Rax 小程序目前不支持在同一个文件中定义两个组件 3 | 4 | ## Rule Details 5 | 6 | Examples of **incorrect** code for this rule: 7 | 8 | ```js 9 | 10 | function Child() { 11 | return Child; 12 | } 13 | 14 | function NewsItem(props) { 15 | const { content } = props; 16 | return ; 17 | } 18 | 19 | ``` 20 | 21 | ## More 22 | https://rax.js.org/docs/guide/compile-miniapp-syntax-constraints#%E6%99%AE%E9%80%9A%E5%87%BD%E6%95%B0%E7%BB%84%E4%BB%B6 -------------------------------------------------------------------------------- /packages/miniapp-render/src/builtInComponents/slider.js: -------------------------------------------------------------------------------- 1 | export default { 2 | name: 'slider', 3 | singleEvents: [{ 4 | name: 'onSliderChanging', 5 | eventName: 'changing' 6 | }], 7 | functionalSingleEvents: [ 8 | { 9 | name: 'onSliderChange', 10 | eventName: 'change', 11 | middleware(evt, domNode) { 12 | domNode._setAttributeWithDelayUpdate('value', evt.detail.value); 13 | domNode.__oldValues = domNode.__oldValues || {}; 14 | domNode.__oldValues.value = evt.detail.value; 15 | } 16 | } 17 | ] 18 | }; 19 | -------------------------------------------------------------------------------- /packages/eslint-plugin-rax-compile-time-miniapp/docs/rules/no_import_next_export.md: -------------------------------------------------------------------------------- 1 | # no-import-next-export 2 | Rax 小程序目前不支持 import 一个组件后直接 export。 3 | 4 | ## Rule Details 5 | 6 | Examples of **incorrect** code for this rule: 7 | 8 | ```jsx 9 | 10 | // Child.jsx 11 | export default function Child() { 12 | return Child; 13 | } 14 | 15 | // index.jsx 16 | import Child from './Child'; 17 | export default Child; 18 | 19 | ``` 20 | 21 | ## More 22 | https://rax.js.org/docs/guide/compile-miniapp-syntax-constraints#%E6%99%AE%E9%80%9A%E5%87%BD%E6%95%B0%E7%BB%84%E4%BB%B6 -------------------------------------------------------------------------------- /packages/jsx-compiler/src/codegen/genCode.js: -------------------------------------------------------------------------------- 1 | const generate = require('@babel/generator').default; 2 | 3 | const generateOptions = { 4 | sourceFileName: '', 5 | sourceMaps: true, 6 | jsescOption: { 7 | minimal: true // To avoid Chinese characters escaped 8 | } 9 | }; 10 | 11 | /** 12 | * Generate code and map from babel ast. 13 | * @param ast 14 | */ 15 | function genCode(ast, options = {}) { 16 | options.sourceMaps = !options.turnOffSourceMap; 17 | return generate(ast, Object.assign({}, generateOptions, options)); 18 | } 19 | 20 | module.exports = genCode; 21 | -------------------------------------------------------------------------------- /packages/jsx-compiler/src/codegen/genExpression.js: -------------------------------------------------------------------------------- 1 | const generate = require('@babel/generator').default; 2 | 3 | /** 4 | * @param expression {Expression} 5 | * @param overridesOption {Object} 6 | * @return {String} 7 | */ 8 | function generateExpression(expression, overridesOption = {}) { 9 | const { code } = generate( 10 | expression, 11 | Object.assign({ 12 | jsescOption: { 13 | minimal: true // To avoid Chinese characters escaped 14 | } 15 | }, overridesOption) 16 | ); 17 | return code; 18 | } 19 | 20 | module.exports = generateExpression; 21 | -------------------------------------------------------------------------------- /scripts/compile-packages.js: -------------------------------------------------------------------------------- 1 | /** 2 | * script to build (transpile) files. 3 | * By default it transpiles all files for all packages and writes them 4 | * into `lib/` directory. 5 | * Non-js or files matching IGNORE_PATTERN will be copied without transpiling. 6 | * 7 | * Example: 8 | * compile all packages: node ./scripts/compile-packages.js 9 | * watch compile some packages: node ./scripts/compile-packages.js --watch --packages rax,rax-cli 10 | */ 11 | 'use strict'; 12 | 13 | const compile = require('./compile'); 14 | 15 | compile('packages'); 16 | compile('packages', true); 17 | -------------------------------------------------------------------------------- /packages/eslint-plugin-rax-compile-time-miniapp/docs/rules/no_hoc.md: -------------------------------------------------------------------------------- 1 | # no-hoc 2 | 不能使用高阶组件 3 | 4 | ## Rule Details 5 | Examples of **incorrect** code for this rule: 6 | 7 | ```jsx 8 | function handleComponent(Com) { 9 | function Wrapper() { 10 | return 11 | } 12 | return 13 | } 14 | ``` 15 | 16 | Examples of **correct** code for this rule: 17 | ```jsx 18 | function handleComponent() { 19 | return 20 | } 21 | ``` 22 | 23 | ## More 24 | https://rax.js.org/docs/guide/compile-miniapp-syntax-constraints#%E7%BB%84%E4%BB%B6%E5%AF%BC%E5%87%BA%E6%96%B9%E5%BC%8F -------------------------------------------------------------------------------- /packages/jsx-compiler/src/utils/getDefaultComponentFunctionPath.js: -------------------------------------------------------------------------------- 1 | const traverse = require('./traverseNodePath'); 2 | 3 | module.exports = function getDefaultComponentFunctionPath(path) { 4 | let defaultComponentFunctionPath = null; 5 | traverse(path, { 6 | ExportDefaultDeclaration(exportDefaultPath) { 7 | const declarationPath = exportDefaultPath.get('declaration'); 8 | if (declarationPath.isFunctionDeclaration()) { 9 | defaultComponentFunctionPath = declarationPath; 10 | } 11 | } 12 | }); 13 | 14 | return defaultComponentFunctionPath; 15 | }; 16 | -------------------------------------------------------------------------------- /packages/miniapp-builder-shared/src/index.js: -------------------------------------------------------------------------------- 1 | const filterNativePages = require('./filterNativePages'); 2 | const getAppConfig = require('./getAppConfig'); 3 | const getPluginConfig = require('./getPluginConfig'); 4 | const pathHelper = require('./pathHelper'); 5 | const platformMap = require('./platformMap'); 6 | const constants = require('./constants'); 7 | const autoInstallNpm = require('./autoInstallNpm'); 8 | 9 | module.exports = { 10 | filterNativePages, 11 | getAppConfig, 12 | getPluginConfig, 13 | pathHelper, 14 | platformMap, 15 | constants, 16 | autoInstallNpm 17 | }; 18 | -------------------------------------------------------------------------------- /packages/jsx-compiler/src/codegen/index.js: -------------------------------------------------------------------------------- 1 | const invokeModules = require('../utils/invokeModules'); 2 | const genCode = require('./genCode'); 3 | const { baseOptions } = require('../options'); 4 | 5 | function generate(parsed, options = baseOptions) { 6 | const { code, map } = genCode(parsed.ast, options); 7 | const ret = { 8 | code, map, 9 | // config, template, style and others should be generated in plugin modules. 10 | }; 11 | 12 | invokeModules(options.modules, 'generate', ret, parsed, options); 13 | 14 | return ret; 15 | } 16 | 17 | 18 | exports.generate = generate; 19 | -------------------------------------------------------------------------------- /packages/rax-miniapp-babel-plugins/src/utils/CodeError.js: -------------------------------------------------------------------------------- 1 | const { codeFrameColumns } = require('@babel/code-frame'); 2 | 3 | function createErrorMessage(sourceCode, loc, extraMessage) { 4 | try { 5 | return codeFrameColumns(sourceCode, loc, { highlightCode: true, message: extraMessage }); 6 | } catch (err) { 7 | return 'Failed to locate source code position.'; 8 | } 9 | } 10 | 11 | class CodeError extends Error { 12 | constructor(sourceCode, loc, message) { 13 | super('\n' + createErrorMessage(sourceCode, loc, message)); 14 | } 15 | } 16 | 17 | module.exports = CodeError; 18 | -------------------------------------------------------------------------------- /packages/jsx-compiler/src/utils/getListItem.js: -------------------------------------------------------------------------------- 1 | const traverse = require('./traverseNodePath'); 2 | const t = require('@babel/types'); 3 | 4 | module.exports = function getListItem(ast) { 5 | let listItem = null; 6 | if (t.isIdentifier(ast)) { 7 | if (ast.__listItem) { 8 | return ast; 9 | } 10 | return null; 11 | } 12 | // List item has been replaced in list module 13 | traverse(ast, { 14 | Identifier(path) { 15 | const { node } = path; 16 | if (node.__listItem) { 17 | listItem = node; 18 | } 19 | } 20 | }); 21 | return listItem; 22 | }; 23 | -------------------------------------------------------------------------------- /packages/miniapp-render/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | [ 4 | '@babel/preset-env', 5 | { 6 | targets: 'iOS >= 8', 7 | loose: true, 8 | include: ['transform-computed-properties'] 9 | } 10 | ] 11 | ], 12 | plugins: [ 13 | '@babel/plugin-proposal-class-properties', 14 | [ 15 | '@babel/plugin-transform-runtime', 16 | { 17 | absoluteRuntime: false, 18 | corejs: false, 19 | helpers: true, 20 | regenerator: true, 21 | useESModules: false 22 | } 23 | ] 24 | ] 25 | }; 26 | -------------------------------------------------------------------------------- /packages/jsx-compiler/src/utils/createJSX.js: -------------------------------------------------------------------------------- 1 | const t = require('@babel/types'); 2 | 3 | module.exports = function createJSX(tag, attrs = {}, children = []) { 4 | const attributes = []; 5 | Object.keys(attrs).forEach((key) => { 6 | attributes.push(t.jsxAttribute( 7 | t.jsxIdentifier(key), 8 | attrs[key], 9 | )); 10 | }); 11 | const jsxOpeningElement = t.jsxOpeningElement( 12 | t.jsxIdentifier(tag), 13 | attributes 14 | ); 15 | const jsxClosingElement = t.jsxClosingElement(t.jsxIdentifier(tag)); 16 | return t.jsxElement(jsxOpeningElement, jsxClosingElement, children); 17 | }; 18 | -------------------------------------------------------------------------------- /.github/workflows/auto-publisher.yml: -------------------------------------------------------------------------------- 1 | name: Auto Publisher 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | - 'releases/**' 8 | 9 | jobs: 10 | build-and-publish: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v1 14 | - uses: actions/setup-node@v1 15 | with: 16 | node-version: 14 17 | registry-url: https://registry.npmjs.org/ 18 | - run: npm i 19 | - run: npm run setup 20 | - run: npm run build 21 | - run: npm run check-and-publish 22 | env: 23 | NODE_AUTH_TOKEN: ${{secrets.npm_token}} 24 | -------------------------------------------------------------------------------- /packages/jsx2mp-runtime/src/enqueueRender.js: -------------------------------------------------------------------------------- 1 | import nextTick from './nextTick'; 2 | 3 | let queue = []; 4 | 5 | export function enqueueRender(component) { 6 | if (!component.__isQueued && (component.__isQueued = true) && queue.push(component) === 1) { 7 | nextTick(rerender); 8 | } 9 | } 10 | 11 | export function rerender() { 12 | const list = queue; 13 | queue = []; 14 | let component; 15 | // eslint-disable-next-line 16 | while (component = list.pop()) { 17 | if (component.__isQueued) { 18 | component._updateComponent(); 19 | component.__isQueued = false; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /packages/jsx-compiler/src/utils/getParentListPath.js: -------------------------------------------------------------------------------- 1 | const genExpression = require('../codegen/genExpression'); 2 | 3 | /** 4 | * Get parent list path 5 | * @param {NodePath} path - current node path 6 | * @param {object} adapter 7 | * @return {NodePath} parent list path 8 | */ 9 | module.exports = function(path, adapter) { 10 | return path.findParent(parentPath => { 11 | if (parentPath.isJSXElement()) { 12 | const attributes = parentPath.node.openingElement.attributes; 13 | return attributes.some(attr => genExpression(attr.name) === adapter.for); 14 | } 15 | return false; 16 | }); 17 | }; 18 | -------------------------------------------------------------------------------- /packages/rax-miniapp-config-webpack-plugin/src/safeWriteFile.js: -------------------------------------------------------------------------------- 1 | const { dirname } = require('path'); 2 | const { writeFileSync, writeJSONSync, ensureDirSync } = require('fs-extra'); 3 | 4 | /** 5 | * @param {string} outputPath - file outputPath 6 | * @param {string} content - file content 7 | * @param {boolean} isJSON - wheater json file 8 | */ 9 | module.exports = function(outputPath, content, isJSON) { 10 | ensureDirSync(dirname(outputPath)); 11 | if (isJSON) { 12 | writeJSONSync(outputPath, content, { 13 | spaces: 2 14 | }); 15 | } else { 16 | writeFileSync(outputPath, content); 17 | } 18 | }; 19 | -------------------------------------------------------------------------------- /packages/miniapp-render/src/bridge/events/baseEvents.js: -------------------------------------------------------------------------------- 1 | // Events which should bubble 2 | 3 | export default [ 4 | { 5 | name: 'onTap', 6 | eventName: 'click', 7 | extra: { 8 | button: 0 9 | } 10 | }, 11 | { 12 | name: 'onLongTap', 13 | eventName: 'longtap' 14 | }, 15 | { 16 | name: 'onTouchStart', 17 | eventName: 'touchstart' 18 | }, 19 | { 20 | name: 'onTouchMove', 21 | eventName: 'touchmove' 22 | }, 23 | { 24 | name: 'onTouchEnd', 25 | eventName: 'touchend' 26 | }, 27 | { 28 | name: 'onTouchCancel', 29 | eventName: 'touchcancel' 30 | } 31 | ]; 32 | -------------------------------------------------------------------------------- /packages/rax-miniapp-runtime-webpack-plugin/src/platforms/index.js: -------------------------------------------------------------------------------- 1 | const ali = require('./ali'); 2 | const wechat = require('./wechat'); 3 | const bytedance = require('./bytedance'); 4 | const baidu = require('./baidu'); 5 | const kuaishou = require('./kuaishou'); 6 | 7 | const { constants: { MINIAPP, WECHAT_MINIPROGRAM, BYTEDANCE_MICROAPP, BAIDU_SMARTPROGRAM, KUAISHOU_MINIPROGRAM }} = require('miniapp-builder-shared'); 8 | 9 | module.exports = { 10 | [MINIAPP]: ali, 11 | [WECHAT_MINIPROGRAM]: wechat, 12 | [BYTEDANCE_MICROAPP]: bytedance, 13 | [BAIDU_SMARTPROGRAM]: baidu, 14 | [KUAISHOU_MINIPROGRAM]: kuaishou 15 | }; 16 | -------------------------------------------------------------------------------- /packages/driver-miniapp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "driver-miniapp", 3 | "version": "0.1.4", 4 | "description": "MiniApp (runtime) driver for Rax", 5 | "license": "BSD-3-Clause", 6 | "main": "lib/index.js", 7 | "module": "es/index.js", 8 | "repository": { 9 | "type": "git", 10 | "url": "git+https://github.com/raxjs/miniapp.git" 11 | }, 12 | "bugs": { 13 | "url": "https://github.com/raxjs/miniapp/issues" 14 | }, 15 | "homepage": "https://github.com/raxjs/miniapp#readme", 16 | "devDependencies": { 17 | "rax": "^1.0.0" 18 | }, 19 | "dependencies": { 20 | "driver-dom": "^2.0.6" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /examples/app-lifecycle/src/pages/Home/index.jsx: -------------------------------------------------------------------------------- 1 | import { createElement } from 'rax'; 2 | import View from 'rax-view'; 3 | import Text from 'rax-text'; 4 | 5 | import './index.css'; 6 | 7 | import Logo from '../../components/Logo'; 8 | 9 | export default function Home() { 10 | return ( 11 | 12 | 13 | Welcome to Your Rax App 14 | More information about Rax 15 | Visit https://rax.js.org 16 | 17 | ); 18 | } 19 | -------------------------------------------------------------------------------- /examples/with-miniapp-native-page/src/pages/Home/index.jsx: -------------------------------------------------------------------------------- 1 | import { createElement } from 'rax'; 2 | import View from 'rax-view'; 3 | import Text from 'rax-text'; 4 | 5 | import './index.css'; 6 | 7 | import Logo from '../../components/Logo'; 8 | 9 | export default function Home() { 10 | return ( 11 | 12 | 13 | Welcome to Your Rax App 14 | More information about Rax 15 | Visit https://rax.js.org 16 | 17 | ); 18 | } 19 | -------------------------------------------------------------------------------- /packages/jsx-compiler/src/utils/isNativeComponent.js: -------------------------------------------------------------------------------- 1 | const getCompiledComponents = require('../getCompiledComponents'); 2 | 3 | /** 4 | * Judge whether node is native component 5 | * @param {Object} node 6 | * @param {string} platform 7 | */ 8 | module.exports = function isNativeComponent(node, platform) { 9 | // Compiled rax components and native base components are recognized as native components 10 | // If a component is not imported, then it is recognized as native base components (according to the tag isCustom in JSXOpeningElement node.name) 11 | return !!getCompiledComponents(platform)[node.name] || node && !node.isCustom; 12 | }; 13 | -------------------------------------------------------------------------------- /packages/jsx2mp-loader/src/file-loader.js: -------------------------------------------------------------------------------- 1 | const { join, relative, dirname } = require('path'); 2 | const { copySync } = require('fs-extra'); 3 | 4 | const loaderUtils = require('loader-utils'); 5 | 6 | module.exports = function fileLoader(content) { 7 | const { entryPath, outputPath } = loaderUtils.getOptions(this) || {}; 8 | const rootContext = this.rootContext; 9 | 10 | const relativeFilePath = relative( 11 | join(rootContext, dirname(entryPath)), 12 | this.resourcePath 13 | ); 14 | const distSourcePath = join(outputPath, relativeFilePath); 15 | copySync(this.resourcePath, distSourcePath); 16 | 17 | return ''; 18 | }; 19 | 20 | -------------------------------------------------------------------------------- /packages/miniapp-render/src/builtInComponents/canvas.js: -------------------------------------------------------------------------------- 1 | const canvas = { 2 | name: 'canvas', 3 | singleEvents: [{ 4 | name: 'onCanvasTouchStart', 5 | eventName: 'touchstart' 6 | }, 7 | { 8 | name: 'onCanvasTouchMove', 9 | eventName: 'touchmove' 10 | }, 11 | { 12 | name: 'onCanvasTouchEnd', 13 | eventName: 'touchend' 14 | }, 15 | { 16 | name: 'onCanvasTouchCancel', 17 | eventName: 'touchcancel' 18 | }, 19 | { 20 | name: 'onCanvasLongTap', 21 | eventName: 'longtap' 22 | }, 23 | { 24 | name: 'onCanvasError', 25 | eventName: 'error' 26 | }] 27 | }; 28 | 29 | export default canvas; 30 | -------------------------------------------------------------------------------- /packages/miniapp-render/src/node/comment.js: -------------------------------------------------------------------------------- 1 | import Node from './node'; 2 | 3 | class Comment extends Node { 4 | constructor(options) { 5 | options.type = 'comment'; 6 | super(options); 7 | this.data = options.data; 8 | } 9 | 10 | get _renderInfo() { 11 | return { 12 | nodeType: 'h-' + this.__type, 13 | }; 14 | } 15 | 16 | get nodeName() { 17 | return '#comment'; 18 | } 19 | 20 | get nodeType() { 21 | return Node.COMMENT_NODE; 22 | } 23 | 24 | cloneNode() { 25 | return this.ownerDocument.createComment({ 26 | data: this.data 27 | }); 28 | } 29 | } 30 | 31 | export default Comment; 32 | -------------------------------------------------------------------------------- /examples/get-element/src/app.js: -------------------------------------------------------------------------------- 1 | import { runApp, useAppLaunch, useAppShow, useAppHide, useAppShare, useAppError } from 'rax-app'; 2 | import appConfig from './app.json'; 3 | 4 | useAppLaunch((options) => { 5 | console.log('app launch', options); 6 | }); 7 | 8 | useAppShow((options) => { 9 | console.log('app show', options); 10 | }); 11 | 12 | useAppHide(() => { 13 | console.log('app hide'); 14 | }); 15 | 16 | useAppShare(() => { 17 | return { 18 | title: '分享标题', 19 | desc: '分享详细说明', 20 | path: 'pages/Home/index' 21 | }; 22 | }); 23 | 24 | useAppError(() => { 25 | console.log('app error'); 26 | }); 27 | 28 | runApp(appConfig); 29 | -------------------------------------------------------------------------------- /examples/use-input/src/app.js: -------------------------------------------------------------------------------- 1 | import { runApp, useAppLaunch, useAppShow, useAppHide, useAppShare, useAppError } from 'rax-app'; 2 | import appConfig from './app.json'; 3 | 4 | useAppLaunch((options) => { 5 | console.log('app launch', options); 6 | }); 7 | 8 | useAppShow((options) => { 9 | console.log('app show', options); 10 | }); 11 | 12 | useAppHide(() => { 13 | console.log('app hide'); 14 | }); 15 | 16 | useAppShare(() => { 17 | return { 18 | title: '分享标题', 19 | desc: '分享详细说明', 20 | path: 'pages/Home/index' 21 | }; 22 | }); 23 | 24 | useAppError(() => { 25 | console.log('app error'); 26 | }); 27 | 28 | runApp(appConfig); 29 | -------------------------------------------------------------------------------- /packages/eslint-plugin-rax-compile-time-miniapp/docs/rules/no_return_arrays.md: -------------------------------------------------------------------------------- 1 | # no-return-arrays 2 | 渲染函数暂不支持返回一个 JSX Element array。如有需要,可使用 Fragment 进行包裹。 3 | 4 | ## Rule Details 5 | 6 | Examples of **incorrect** code for this rule: 7 | 8 | ```jsx 9 | function App() { 10 | return [ 11 | a, 12 | b 13 | ] 14 | } 15 | ``` 16 | 17 | Examples of **correct** code for this rule: 18 | 19 | ```jsx 20 | function App() { 21 | return ( 22 | <> 23 | a 24 | b 25 | 26 | ) 27 | } 28 | ``` 29 | 30 | ## More 31 | https://rax.js.org/docs/guide/compile-miniapp-syntax-constraints#return%20array -------------------------------------------------------------------------------- /packages/jsx2mp-cli/utils/log.js: -------------------------------------------------------------------------------- 1 | const inquirer = require('inquirer'); 2 | 3 | /** 4 | * Standard method to print logs. 5 | * @param logs 6 | */ 7 | const printLog = function(...logs) { 8 | console.log.apply(console, logs); 9 | }; 10 | 11 | /** 12 | * Create an ask prase. 13 | * @param message {String} 14 | * @return {Promise} Answer true or false. 15 | */ 16 | const ask = function(message, defaultVal = true) { 17 | const name = '_NAME_'; 18 | return inquirer.prompt([ 19 | { type: 'confirm', name, message, default: defaultVal } 20 | ]).then(answers => answers[name]); 21 | }; 22 | 23 | module.exports = { 24 | printLog, 25 | ask 26 | }; -------------------------------------------------------------------------------- /packages/miniapp-render/__tests__/util/tool.test.js: -------------------------------------------------------------------------------- 1 | import mock from '../../renderMock'; 2 | import { toDash, toCamel, getId } from '../../src/utils/tool'; 3 | 4 | test('tool: toDash', () => { 5 | expect(toDash('abcD12kKD;saS')).toBe('abc-d12k-k-d;sa-s'); 6 | expect(toDash('ABC')).toBe('-a-b-c'); 7 | }); 8 | 9 | test('tool: toCamel', () => { 10 | expect(toCamel('abc-d12k-k-d;sa-s')).toBe('abcD12kKD;saS'); 11 | expect(toCamel('-a-b-c')).toBe('ABC'); 12 | }); 13 | 14 | test('tool: getId', () => { 15 | expect(getId().toString()).toEqual('0'); 16 | expect(getId().toString()).toEqual('1'); 17 | expect(getId().toString()).toEqual('2'); 18 | }); 19 | -------------------------------------------------------------------------------- /examples/app-lifecycle/src/app.js: -------------------------------------------------------------------------------- 1 | import { runApp, useAppLaunch, useAppShow, useAppHide, useAppShare, useAppError } from 'rax-app'; 2 | import appConfig from './app.json'; 3 | 4 | useAppLaunch((options) => { 5 | console.log('app launch', options); 6 | }); 7 | 8 | useAppShow((options) => { 9 | console.log('app show', options); 10 | }); 11 | 12 | useAppHide(() => { 13 | console.log('app hide'); 14 | }); 15 | 16 | useAppShare(() => { 17 | return { 18 | title: '分享标题', 19 | desc: '分享详细说明', 20 | path: 'pages/Home/index' 21 | }; 22 | }); 23 | 24 | useAppError(() => { 25 | console.log('app error'); 26 | }); 27 | 28 | runApp(appConfig); 29 | -------------------------------------------------------------------------------- /examples/use-scrollview/src/app.js: -------------------------------------------------------------------------------- 1 | import { runApp, useAppLaunch, useAppShow, useAppHide, useAppShare, useAppError } from 'rax-app'; 2 | import appConfig from './app.json'; 3 | 4 | useAppLaunch((options) => { 5 | console.log('app launch', options); 6 | }); 7 | 8 | useAppShow((options) => { 9 | console.log('app show', options); 10 | }); 11 | 12 | useAppHide(() => { 13 | console.log('app hide'); 14 | }); 15 | 16 | useAppShare(() => { 17 | return { 18 | title: '分享标题', 19 | desc: '分享详细说明', 20 | path: 'pages/Home/index' 21 | }; 22 | }); 23 | 24 | useAppError(() => { 25 | console.log('app error'); 26 | }); 27 | 28 | runApp(appConfig); 29 | -------------------------------------------------------------------------------- /packages/eslint-plugin-rax-compile-time-miniapp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "eslint-plugin-rax-compile-time-miniapp", 3 | "version": "1.0.0", 4 | "description": "for rax-compile-time-miniapp", 5 | "keywords": [ 6 | "eslint", 7 | "eslintplugin", 8 | "eslint-plugin" 9 | ], 10 | "author": "hirra", 11 | "main": "src/index.js", 12 | "scripts": { 13 | "test": "mocha tests --recursive" 14 | }, 15 | "dependencies": { 16 | "requireindex": "~1.1.0" 17 | }, 18 | "devDependencies": { 19 | "eslint": "^7.1.0", 20 | "mocha": "^7.2.0" 21 | }, 22 | "engines": { 23 | "node": ">=0.10.0" 24 | }, 25 | "license": "ISC" 26 | } 27 | -------------------------------------------------------------------------------- /examples/app-lifecycle/src/document/index.jsx: -------------------------------------------------------------------------------- 1 | import { createElement } from 'rax'; 2 | import { Root, Style, Script} from 'rax-document'; 3 | 4 | function Document() { 5 | return ( 6 | 7 | 8 | 9 | 10 | rax-materials-basic-app 11 |