├── .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 [](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 [](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 |
12 |
13 |
14 | {/* root container */}
15 |
16 |
17 |
18 |
19 | );
20 | }
21 | export default Document;
22 |
--------------------------------------------------------------------------------
/examples/event-handler/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 |
12 |
13 |
14 | {/* root container */}
15 |
16 |
17 |
18 |
19 | );
20 | }
21 | export default Document;
22 |
--------------------------------------------------------------------------------
/examples/get-element/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 |
12 |
13 |
14 | {/* root container */}
15 |
16 |
17 |
18 |
19 | );
20 | }
21 | export default Document;
22 |
--------------------------------------------------------------------------------
/examples/use-input/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 |
12 |
13 |
14 | {/* root container */}
15 |
16 |
17 |
18 |
19 | );
20 | }
21 | export default Document;
22 |
--------------------------------------------------------------------------------
/packages/miniapp-render/src/bridge/events/callSingleEvent.js:
--------------------------------------------------------------------------------
1 | import Event from '../../event/event';
2 |
3 |
4 | export default function(eventName, evt) {
5 | const domNode = this.getDomNodeFromEvt(evt);
6 | if (!domNode) return;
7 |
8 | domNode._trigger(eventName, {
9 | event: new Event({
10 | timeStamp: evt && evt.timeStamp,
11 | touches: evt && evt.touches,
12 | changedTouches: evt && evt.changedTouches,
13 | name: eventName,
14 | target: domNode,
15 | eventPhase: Event.AT_TARGET,
16 | detail: evt && evt.detail,
17 | __extra: evt && evt.extra,
18 | }),
19 | currentTarget: domNode,
20 | });
21 | }
22 |
--------------------------------------------------------------------------------
/examples/use-scrollview/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 |
12 |
13 |
14 | {/* root container */}
15 |
16 |
17 |
18 |
19 | );
20 | }
21 | export default Document;
22 |
--------------------------------------------------------------------------------
/examples/page-lifecycle-with-router/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 |
12 |
13 |
14 | {/* root container */}
15 |
16 |
17 |
18 |
19 | );
20 | }
21 | export default Document;
22 |
--------------------------------------------------------------------------------
/examples/with-miniapp-native-page/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 |
12 |
13 |
14 | {/* root container */}
15 |
16 |
17 |
18 |
19 | );
20 | }
21 | export default Document;
22 |
--------------------------------------------------------------------------------
/examples/with-miniapp-plugin-component/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 |
12 |
13 |
14 | {/* root container */}
15 |
16 |
17 |
18 |
19 | );
20 | }
21 | export default Document;
22 |
--------------------------------------------------------------------------------
/examples/with-miniapp-native-custom-component/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 |
12 |
13 |
14 | {/* root container */}
15 |
16 |
17 |
18 |
19 | );
20 | }
21 | export default Document;
22 |
--------------------------------------------------------------------------------
/packages/rax-miniapp-runtime-webpack-plugin/src/constants.js:
--------------------------------------------------------------------------------
1 | const { constants: { MINIAPP, WECHAT_MINIPROGRAM, BYTEDANCE_MICROAPP, BAIDU_SMARTPROGRAM, KUAISHOU_MINIPROGRAM }} = require('miniapp-builder-shared');
2 |
3 | const RECURSIVE_TEMPLATE_TYPE = new Set([MINIAPP, BYTEDANCE_MICROAPP, BAIDU_SMARTPROGRAM, KUAISHOU_MINIPROGRAM ]);
4 | const UNRECURSIVE_TEMPLATE_TYPE = new Set([WECHAT_MINIPROGRAM]);
5 | const NEED_REPLACE_ROOT_TARGET = new Set([WECHAT_MINIPROGRAM, BYTEDANCE_MICROAPP, BAIDU_SMARTPROGRAM, KUAISHOU_MINIPROGRAM]); // Replace :root -> page in css files
6 |
7 | module.exports = {
8 | RECURSIVE_TEMPLATE_TYPE,
9 | UNRECURSIVE_TEMPLATE_TYPE,
10 | NEED_REPLACE_ROOT_TARGET
11 | };
12 |
--------------------------------------------------------------------------------
/packages/jsx2mp-cli/utils/platformConfig.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | 'ali': {
3 | type: 'ali',
4 | name: 'Alibaba MiniApp',
5 | extension: {
6 | xml: '.axml',
7 | css: '.acss',
8 | }
9 | },
10 | 'wechat': {
11 | type: 'wechat',
12 | name: 'WeChat MiniProgram',
13 | extension: {
14 | xml: '.wxml',
15 | css: '.wxss',
16 | }
17 | },
18 | 'baidu': {
19 | type: 'baidu',
20 | name: 'Baidu SmartProgram',
21 | extension: {
22 | xml: '.swan',
23 | css: '.css',
24 | }
25 | },
26 | 'tt': {
27 | type: 'ByteDance MicroApp',
28 | extension: {
29 | xml: '.ttml',
30 | css: '.ttss'
31 | }
32 | }
33 | };
34 |
--------------------------------------------------------------------------------
/packages/rax-miniapp-config-webpack-plugin/src/handleIcon.js:
--------------------------------------------------------------------------------
1 | const { dirname, join } = require('path');
2 | const { copy, existsSync, ensureDirSync, unlinkSync } = require('fs-extra');
3 |
4 | function isUrl(src) {
5 | return /^(https?:)?\/\//.test(src);
6 | }
7 |
8 | module.exports = function(path, outputPath) {
9 | if (!isUrl(path)) {
10 | const sourcePath = join(process.cwd(), 'src', path);
11 | if (existsSync(sourcePath)) {
12 | const distPath = join(outputPath, path);
13 | ensureDirSync(dirname(distPath));
14 | if (existsSync(distPath)) {
15 | unlinkSync(distPath);
16 | }
17 | copy(sourcePath, distPath);
18 | }
19 | }
20 | return path;
21 | };
22 |
--------------------------------------------------------------------------------
/packages/rax-miniapp-babel-plugins/src/plugins/babel-plugin-external-module.js:
--------------------------------------------------------------------------------
1 | module.exports = function visitor({ types: t }) {
2 | return {
3 | visitor: {
4 | CallExpression(path) {
5 | const { node } = path;
6 | if (
7 | node.callee.name === 'require' &&
8 | node.arguments &&
9 | node.arguments.length === 1 &&
10 | t.isStringLiteral(node.arguments[0]) &&
11 | (node.arguments[0].value.indexOf('@weex-module') > -1 || node.arguments[0].value.indexOf('@system') > -1)
12 | ) {
13 | // Avoid weex and quickapp module effect
14 | path.replaceWith(t.nullLiteral());
15 | }
16 | }
17 | }
18 | };
19 | };
20 |
--------------------------------------------------------------------------------
/packages/driver-miniapp/README.md:
--------------------------------------------------------------------------------
1 | # driver-miniapp
2 |
3 | > MiniApp (runtime) driver for Rax, extended from driver-dom.
4 |
5 | ## Install
6 |
7 | ```bash
8 | $ npm install --save driver-miniapp
9 | ```
10 |
11 | ## Use
12 |
13 | ```jsx
14 | import {createElement, render} from 'rax';
15 | import DriverMiniApp from 'driver-miniapp';
16 | import View from 'rax-view';
17 | import Image from 'rax-view';
18 |
19 |
20 | function Example() {
21 | return (
22 |
23 |
26 |
27 | );
28 | }
29 |
30 | render(, null, {
31 | driver: DriverMiniApp
32 | });
33 | ```
34 |
--------------------------------------------------------------------------------
/packages/jsx2mp-runtime/src/getId.js:
--------------------------------------------------------------------------------
1 | /* global PROPS, TAGID */
2 | // eslint-disable-next-line import/no-extraneous-dependencies
3 | import { isQuickApp } from 'universal-env';
4 |
5 | let _customId = 0;
6 |
7 | /**
8 | * Get instance TAGID
9 | * */
10 | export default function(type, internal) {
11 | switch (type) {
12 | case 'tag':
13 | if (isQuickApp && internal.tagId) {
14 | // there's no inner props in quickapp
15 | return internal.tagId;
16 | }
17 | if (internal[PROPS][TAGID]) {
18 | return internal[PROPS][TAGID];
19 | }
20 | return `t_${_customId++}`;
21 | default:
22 | // For troubleshoot
23 | return `d_${_customId++}`;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/packages/miniapp-render/src/builtInComponents/button.js:
--------------------------------------------------------------------------------
1 | export default {
2 | name: 'button',
3 | singleEvents: [{
4 | name: 'onButtonGetUserInfo',
5 | eventName: 'getuserinfo'
6 | },
7 | {
8 | name: 'onButtonContact',
9 | eventName: 'contact'
10 | },
11 | {
12 | name: 'onButtonGetPhoneNumber',
13 | eventName: 'getphonenumber'
14 | },
15 | {
16 | name: 'onButtonError',
17 | eventName: 'error'
18 | },
19 | {
20 | name: 'onButtonOpenSetting',
21 | eventName: 'opensetting'
22 | },
23 | {
24 | name: 'onButtonLaunchApp',
25 | eventName: 'launchapp'
26 | },
27 | {
28 | name: 'onButtonGetAuthorize',
29 | eventName: 'getauthorize'
30 | }]
31 | };
32 |
--------------------------------------------------------------------------------
/packages/miniapp-render/src/builtInComponents/camera.js:
--------------------------------------------------------------------------------
1 | // eslint-disable-next-line import/no-extraneous-dependencies
2 | import { isWeChatMiniProgram, isByteDanceMicroApp } from 'universal-env';
3 |
4 | const camera = {
5 | name: 'camera',
6 | singleEvents: [{
7 | name: 'onCameraStop',
8 | eventName: 'stop'
9 | },
10 | {
11 | name: 'onCameraError',
12 | eventName: 'error'
13 | },
14 | {
15 | name: 'onCameraScanCode',
16 | eventName: 'scancode'
17 | }]
18 | };
19 |
20 | if (isWeChatMiniProgram || isByteDanceMicroApp) {
21 | camera.singleEvents = camera.singleEvents.concat([{
22 | name: 'onCameraInitDone',
23 | eventName: 'initdone'
24 | }]);
25 | }
26 |
27 | export default camera;
28 |
--------------------------------------------------------------------------------
/packages/rax-miniapp-runtime-webpack-plugin/src/generators/pkg.js:
--------------------------------------------------------------------------------
1 | const { resolve, dirname, join } = require('path');
2 | const { readJSONSync } = require('fs-extra');
3 | const addFileToCompilation = require('../utils/addFileToCompilation');
4 |
5 | module.exports = function(compilation, { target, command, declaredDep, source = '' }) {
6 | const pkgPath = resolve(process.cwd(), 'package.json');
7 | const dependencies = declaredDep || readJSONSync(pkgPath, {
8 | encoding: 'utf-8'
9 | }).dependencies;
10 | addFileToCompilation(compilation, {
11 | filename: join(dirname(source), 'package.json'),
12 | content: JSON.stringify({
13 | dependencies
14 | }),
15 | command,
16 | target,
17 | });
18 | };
19 |
--------------------------------------------------------------------------------
/.github/workflows/release-report.yml:
--------------------------------------------------------------------------------
1 | name: ci
2 | on:
3 | release:
4 | types:
5 | - created
6 | jobs:
7 | build:
8 | runs-on: ubuntu-latest
9 | steps:
10 | - uses: actions/checkout@v1
11 | - name: Use Node.js 12.x
12 | uses: actions/setup-node@v2
13 | with:
14 | node-version: 12.x
15 | registry-url: https://registry.npmjs.org
16 | - name: Set branch name
17 | run: echo >>$GITHUB_ENV BRANCH_NAME=${GITHUB_REF#refs/heads/}
18 | - name: Output branch name
19 | run: echo ${BRANCH_NAME}
20 | - run: npm install
21 | - name: Publish And Notify
22 | run: npm run release
23 | env:
24 | DING_WEBHOOK: ${{secrets.DING_WEBHOOK}}
25 |
--------------------------------------------------------------------------------
/packages/jsx2mp-cli/bin/jsx2mp.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | const program = require('commander');
4 | const packageInfo = require('../package.json');
5 |
6 | program
7 | .description('Run JSX in mini-program. website: https://github.com/alibaba/rax')
8 | .version(packageInfo.version)
9 | .usage(' [options]')
10 | .command('start', 'Start a dev watch mode (hot-reload) to transform project.')
11 | .command('build', 'Build project in production mode')
12 | .on('command:*', (cmd) => {
13 | if (!program.commands.find(c => c._name == cmd[0])) {
14 | console.error(`Invalid command: ${program.args.join(' ')}\n`);
15 | program.outputHelp();
16 | process.exit(1);
17 | }
18 | })
19 | .parse(process.argv);
20 |
--------------------------------------------------------------------------------
/examples/with-miniapp-plugin-component/src/components/Test/index.ali.jsx:
--------------------------------------------------------------------------------
1 | import { createElement, useState } from 'rax';
2 | import View from 'rax-view';
3 | // eslint-disable-next-line
4 | import Test from 'plugin://myPlugin/test';
5 |
6 | export default function Home() {
7 | function test(pluginName) {
8 | console.log(`${pluginName}被触发`);
9 | }
10 | return (
11 |
12 | {
13 | [1, 2, 3, 4, 5, 6].map(item => {
14 | return (
15 |
16 |
20 |
21 | );
22 | })
23 | }
24 |
25 | );
26 | }
27 |
--------------------------------------------------------------------------------
/packages/miniapp-lifecycles/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "miniapp-lifecycles",
3 | "version": "1.0.0",
4 | "description": "Miniapp lifecycles registration for rax",
5 | "main": "lib/index.js",
6 | "module": "es/index.js",
7 | "types": "lib/index.d.ts",
8 | "author": "Rax Team",
9 | "files": [
10 | "es",
11 | "lib"
12 | ],
13 | "scripts": {},
14 | "repository": {
15 | "type": "git",
16 | "url": "git+https://github.com/raxjs/miniapp"
17 | },
18 | "bugs": {
19 | "url": "https://github.com/raxjs/miniapp/issues"
20 | },
21 | "homepage": "https://github.com/raxjs/miniapp#readme",
22 | "config": {
23 | "commitizen": {
24 | "path": "./node_modules/cz-conventional-changelog"
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/packages/miniapp-render/src/builtInComponents/picker.js:
--------------------------------------------------------------------------------
1 | // eslint-disable-next-line import/no-extraneous-dependencies
2 | import { isMiniApp } from 'universal-env';
3 |
4 | const picker = {
5 | name: 'picker',
6 | singleEvents: [{
7 | name: 'onPickerCancel',
8 | eventName: 'cancel'
9 | }],
10 | functionalSingleEvents: [
11 | {
12 | name: 'onPickerChange',
13 | eventName: 'change',
14 | middleware(evt, domNode) {
15 | domNode._setAttributeWithDelayUpdate('value', evt.detail.value);
16 | }
17 | }
18 | ]
19 | };
20 |
21 | if (!isMiniApp) {
22 | picker.singleEvents.push({
23 | name: 'onPickerColumnChange',
24 | eventName: 'columnchange'
25 | });
26 | }
27 |
28 | export default picker;
29 |
--------------------------------------------------------------------------------
/packages/jsx-compiler/src/utils/CodeError.js:
--------------------------------------------------------------------------------
1 | const { codeFrameColumns } = require('@babel/code-frame');
2 | const { default: generate } = require('@babel/generator');
3 |
4 | function createErrorMessage(sourceCode, node, loc, extraMessage) {
5 | const rawLines = sourceCode ? sourceCode : generate(node).code;
6 | try {
7 | return codeFrameColumns(rawLines, loc, { highlightCode: true, message: extraMessage });
8 | } catch (err) {
9 | return 'Failed to locate source code position.';
10 | }
11 | }
12 |
13 | class CodeError extends Error {
14 | constructor(sourceCode, node, loc, message) {
15 | super('\n' + createErrorMessage(sourceCode, node, loc, message));
16 | this.node = node;
17 | }
18 | }
19 |
20 | module.exports = CodeError;
21 |
--------------------------------------------------------------------------------
/packages/jsx-compiler/src/utils/handleValidIdentifier.js:
--------------------------------------------------------------------------------
1 | /**
2 | * If parent expression is a.b,
3 | * b is an invaild identifier, because it's the value of the MemberExpression
4 | */
5 | module.exports = function(identifierPath, callback) {
6 | switch (identifierPath.parent.type) {
7 | case 'ObjectProperty':
8 | if (identifierPath.parent.key !== identifierPath.node) {
9 | callback();
10 | }
11 | break;
12 | case 'MemberExpression':
13 | // For list[index]
14 | if (identifierPath.parent.computed) {
15 | callback();
16 | } else if (identifierPath.parent.property !== identifierPath.node) {
17 | callback();
18 | }
19 | break;
20 | default:
21 | callback();
22 | }
23 | };
24 |
--------------------------------------------------------------------------------
/packages/miniapp-runtime-config/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## [0.3.9] - 2021-07-21
4 |
5 | ### Fixed
6 |
7 | - Miss passing routes array in subpackages mode
8 |
9 | ## [0.3.8] - 2021-07-20
10 |
11 | ### Added
12 |
13 | - Support configuring miniapp plugin project
14 |
15 | ## [0.3.7] - 2021-07-12
16 |
17 | ### Changed
18 |
19 | - Remove copy-webpack-plugin dependency and inherit the config from build-plugin-rax-miniapp
20 |
21 | ## [0.3.6] - 2021-04-27
22 |
23 | ### Changed
24 |
25 | - Update homepage url in `package.json`
26 |
27 | ## [0.3.5] - 2021-03-23
28 |
29 | ### Added
30 |
31 | - Support distinguish end construction
32 | ## [0.3.4] - 2021-03-11
33 |
34 | ### Changed
35 |
36 | - Update rax-miniapp-runtime-webpack-plugin version to 4.x
37 |
--------------------------------------------------------------------------------
/packages/rax-miniapp-babel-plugins/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "rax-miniapp-babel-plugins",
3 | "version": "0.1.15",
4 | "description": "rax miniapp babel plugins",
5 | "main": "src/index.js",
6 | "repository": {
7 | "type": "git",
8 | "url": "git+https://github.com/raxjs/miniapp.git"
9 | },
10 | "keywords": [
11 | "rax",
12 | "babel",
13 | "babel-plugins"
14 | ],
15 | "author": "Rax Team",
16 | "license": "MIT",
17 | "bugs": {
18 | "url": "https://github.com/raxjs/miniapp/issues"
19 | },
20 | "homepage": "https://github.com/raxjs/miniapp#readme",
21 | "dependencies": {
22 | "@babel/code-frame": "^7.8.3",
23 | "fs-extra": "^9.0.1",
24 | "md5": "^2.2.1",
25 | "miniapp-builder-shared": "^0.2.0"
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/packages/eslint-plugin-rax-compile-time-miniapp/docs/rules/return_jsx_in_map.md:
--------------------------------------------------------------------------------
1 | # return-jsx-in-map
2 | map 的返回值目前限制必须为一个 JSX Element。如不想多一层标签嵌套,可使用 Fragment 包裹 map 返回的值。
3 |
4 | ## Rule Details
5 |
6 | Examples of **incorrect** code for this rule:
7 |
8 | ```jsx
9 |
10 |
11 | {list.map((item, index) => {
12 | return ( item > 1 ? 1 : 2);
13 | })}
14 |
15 |
16 | ```
17 |
18 | Examples of **correct** code for this rule:
19 |
20 | ```jsx
21 |
22 |
23 | {list.map((item, index) => {
24 | return <>{ item > 1 ? 1 : 2 } >
25 | );
26 | })}
27 |
28 |
29 | ```
30 |
31 | ## More
32 | https://rax.js.org/docs/guide/compile-miniapp-syntax-constraints#%E5%88%97%E8%A1%A8%E6%B8%B2%E6%9F%93
--------------------------------------------------------------------------------
/examples/README.md:
--------------------------------------------------------------------------------
1 | # Rax 示例
2 |
3 | 本文件夹提供了多个 Rax 小程序示例项目供用户参考。
4 |
5 | ## 快速开始
6 |
7 | ```shell
8 | npm install
9 |
10 | # dev mode
11 | npm run start
12 |
13 | # build mode
14 | npm run build
15 | ```
16 |
17 | ## 示例说明
18 |
19 | > 示例项目中小程序如无说明,均采用运行时方案
20 |
21 | * with-miniapp-native-custom-component: 使用小程序原生自定义组件(本地组件 + npm 组件)
22 | * with-miniapp-plugin-component: 使用小程序插件组件 + 分端构建
23 | * with-miniapp-native-page: 使用原生页面
24 | * use-rax-compiled-component-in-runtime-miniapp: Rax 小程序运行时项目使用 Rax 编译时组件
25 | * app-lifecycle: 使用 app 生命周期
26 | * page-lifecycle-with-router: 使用 page 生命周期 + 路由跳转
27 | * event-handler: 事件绑定(编译时小程序)
28 | * get-element: document/element getElementXXX 相关 API
29 | * use-input: 处理 input 值绑定及焦点获取
30 | * use-scrollview: 处理 scroll-view scroll-top/scroll-left 值变更
31 |
--------------------------------------------------------------------------------
/examples/with-miniapp-native-custom-component/src/components/Test/index.ali.jsx:
--------------------------------------------------------------------------------
1 | import { createElement } from 'rax';
2 | import View from 'rax-view';
3 |
4 | import Test from '../../public/AliNativeComp/index';
5 | import Title from 'mini-ali-ui/es/title/index';
6 |
7 | export default function Home() {
8 | return (
9 |
10 | {
14 | console.log('标题被击中了');
15 | }}
16 | >我是 mini-ali-ui 的 title 组件
17 | {
18 | console.log('我被击中了');
19 | }}>
20 | 我是 header
21 | 我是 footer
22 |
23 |
24 | );
25 | }
26 |
--------------------------------------------------------------------------------
/packages/miniapp-render/src/utils/perf.js:
--------------------------------------------------------------------------------
1 | import cache from './cache';
2 |
3 | class Performance {
4 | constructor() {
5 | this.recorder = new Map();
6 | }
7 |
8 | start(id) {
9 | const { debug } = cache.getConfig();
10 | if (!debug) {
11 | return;
12 | }
13 | this.recorder.set(id, Date.now());
14 | }
15 |
16 | stop(id) {
17 | const { debug } = cache.getConfig();
18 | if (!debug) {
19 | return;
20 | }
21 | const now = Date.now();
22 | const prev = this.recorder.get(id);
23 | if (!prev) {
24 | console.warn(`${id} hasn't invoke start method, please check your code!`);
25 | return;
26 | }
27 | const time = now - prev;
28 | console.log(`${id} Take: ${time}ms`);
29 | }
30 | }
31 |
32 | export default new Performance();
33 |
--------------------------------------------------------------------------------
/packages/jsx2mp-runtime/src/createContext.js:
--------------------------------------------------------------------------------
1 | import Emitter from './valueEmitter';
2 |
3 | let uniqueId = 0;
4 |
5 | export default function createContext(defaultValue) {
6 | const contextProp = '__ctx' + uniqueId++;
7 | let globalEmitter;
8 | const defaultEmitter = new Emitter(defaultValue);
9 |
10 | function Provider(passedVal = defaultValue) {
11 | const emitter = globalEmitter;
12 | if (!emitter) {
13 | globalEmitter = new Emitter(passedVal);
14 | } else {
15 | emitter.value = passedVal;
16 | emitter.emit();
17 | }
18 | }
19 |
20 | function readEmitter() {
21 | return globalEmitter || defaultEmitter;
22 | }
23 |
24 | Provider.readEmitter = readEmitter;
25 | Provider.contextProp = contextProp;
26 |
27 | return {
28 | Provider
29 | };
30 | }
31 |
--------------------------------------------------------------------------------
/packages/miniapp-render/src/bridge/lifeCycleAdapter.js:
--------------------------------------------------------------------------------
1 | // eslint-disable-next-line import/no-extraneous-dependencies
2 | import { isMiniApp } from 'universal-env';
3 |
4 | export function getComponentLifeCycle({ mount, unmount, update }) {
5 | if (isMiniApp) {
6 | return {
7 | didMount(...args) {
8 | mount && mount.apply(this, args);
9 | },
10 | didUpdate(...args) {
11 | update && update.apply(this, args);
12 | },
13 | didUnmount(...args) {
14 | unmount && unmount.apply(this, args);
15 | }
16 | };
17 | } else {
18 | return {
19 | attached(...args) {
20 | mount && mount.apply(this, args);
21 | },
22 | detached(...args) {
23 | unmount && unmount.apply(this, args);
24 | }
25 | };
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/examples/with-miniapp-plugin-component/src/components/Test/index.wechat.jsx:
--------------------------------------------------------------------------------
1 | import { createElement, useState } from 'rax';
2 | import View from 'rax-view';
3 | import Text from 'rax-text';
4 | // eslint-disable-next-line
5 | import Plugin from 'plugin://myPlugin/hello-component';
6 |
7 | export default function Home() {
8 | function test(pluginName) {
9 | console.log(`${pluginName}被触发`);
10 | }
11 | const list = [1, 2, 3];
12 | return (
13 |
14 | {
15 | [1, 2, 3, 4, 5, 6].map(item => {
16 | return (
17 |
18 | {
19 | test(item);
20 | }} />
21 |
22 | );
23 | })
24 | }
25 |
26 |
27 | );
28 | }
29 |
--------------------------------------------------------------------------------
/packages/rax-miniapp-config-webpack-plugin/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## [2.1.2] - 2021-07-27
4 |
5 | ### Fixed
6 |
7 | - route error in windows
8 |
9 | ## [2.1.1] - 2021-06-01
10 |
11 | - Support transform tabBar config
12 | - Remove custom tabBar logic
13 |
14 | ## [2.1.0] - 2021-05-19
15 |
16 | - Support bytedance microapp/baidu smartprogram/kuaishou miniprogram
17 |
18 | ## [2.0.4] - 2021-05-10
19 |
20 | - Use constants from miniapp-builder-shared
21 |
22 | ## [2.0.3] - 2021-03-31
23 |
24 | ### Feat
25 |
26 | - Add `subPackageBuildType` when `shareMemory`
27 |
28 | ## [2.0.2] - 2021-03-11
29 |
30 | ### Changed
31 |
32 | - Use constants from miniapp-builder-shared
33 |
34 | ## [2.0.1] - 2021-02-25
35 |
36 | ### Added
37 |
38 | - Generate project.config.json for wechat miniprogram defaultly
39 |
--------------------------------------------------------------------------------
/packages/jsx2mp-cli/checkPkgVersion.js:
--------------------------------------------------------------------------------
1 | const updateNotifier = require('update-notifier');
2 |
3 | const jsx2mpCliPkg = require('./package.json');
4 | const jsx2mpLoaderPkg = require('jsx2mp-loader/package.json');
5 | // eslint-disable-next-line
6 | const jsx2mpCompilerPkg = require('jsx-compiler/package.json');
7 | const jsx2mpRuntimePkg = require('jsx2mp-runtime/package.json');
8 |
9 | const pkgVersion = [
10 | jsx2mpCliPkg,
11 | jsx2mpLoaderPkg,
12 | jsx2mpCompilerPkg,
13 | jsx2mpRuntimePkg
14 | ];
15 |
16 | let needUpdate = false;
17 |
18 | pkgVersion.forEach(pkg => {
19 | const notifier = updateNotifier({
20 | pkg,
21 | updateCheckInterval: 1000 * 60 * 60 * 24 * 7 // 1 week
22 | });
23 | if (notifier.update) {
24 | needUpdate = true;
25 | }
26 | });
27 |
28 | module.exports = needUpdate;
29 |
--------------------------------------------------------------------------------
/packages/jsx-compiler/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## [0.4.33] - 2021-08-19
4 |
5 | - Support key in list (x-for, map)
6 |
7 | ## [0.4.32] - 2021-06-30
8 |
9 | ### Fixed
10 |
11 | - Miss basedir config in resolve
12 |
13 | ## [0.4.31] - 2021-06-29
14 |
15 | ### Changed
16 |
17 | - Use resolve to replace `require.resolve` to make exports field compatible
18 |
19 | ## [0.4.30] - 2021-03-30
20 |
21 | ### Added
22 |
23 | - Support compiling virtualHost config into code
24 |
25 | ## [0.4.29] - 2021-03-04
26 |
27 | ### Fixed
28 |
29 | - Can't judge variables derived from props correctly
30 | - Not judge variables whether derived from props in wechat
31 | - Can't delete css files in app.js in subPackages mode
32 | - Chinese characters are escaped by mistake
33 | - Compiling will crash if module column has package.json
34 |
--------------------------------------------------------------------------------
/packages/miniapp-render/__tests__/node/comment.test.js:
--------------------------------------------------------------------------------
1 | import mock from '../../renderMock';
2 | import Node from '../../src/node/node';
3 |
4 | let document;
5 |
6 | beforeAll(() => {
7 | const res = mock.createPage('home');
8 | document = res.document;
9 | });
10 |
11 | test('comment: nodeName/nodeType', () => {
12 | const node = document.createComment('haha e hehe');
13 | expect(node.nodeType).toBe(Node.COMMENT_NODE);
14 | expect(node.nodeName).toBe('#comment');
15 | });
16 |
17 | test('comment: cloneNode', () => {
18 | const node1 = document.createComment('abc cba');
19 | const node2 = node1.cloneNode();
20 | expect(node2).not.toBe(node1);
21 | expect(node2.__nodeId).not.toBe(node1.__nodeId);
22 | expect(node2.__pageId).toBe(node1.__pageId);
23 | expect(node2.nodeType).toBe(Node.COMMENT_NODE);
24 | });
25 |
--------------------------------------------------------------------------------
/packages/jsx2mp-cli/README.md:
--------------------------------------------------------------------------------
1 | # jsx2mp-cli
2 |
3 | A cli tool to transform Rax JSX based project to MiniApp.
4 |
5 | ## Usage as cli tool.
6 |
7 | 1. Create a miniapp based project using rax-cli.
8 | ```bash
9 | rax init myApp
10 | ```
11 |
12 | 2. Install jsx2mp-cli
13 | ```bash
14 | npm install jsx2mp-cli -g
15 | ```
16 |
17 | 3. Transform your project.
18 | ```bash
19 | cd myApp
20 | jsx2mp start
21 | ```
22 | The tool will keep watching your source files before being interpreted by `Ctrl + C`.
23 |
24 | 4. Use `小程序开发工具` to open `dist` directory under your project path.
25 |
26 | > You can also use rax-scripts to build miniapp, which intergrate the jsx2mp-cli.
27 |
28 | ## Integration Testing
29 |
30 | As project-based integration testing, the test includes the following cases:
31 |
32 | 1. import static assets
33 |
--------------------------------------------------------------------------------
/packages/jsx2mp-loader/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## [0.4.29] - 2021-07-12
4 |
5 | ### Fixed
6 |
7 | - Use file resourcePath as basedir
8 |
9 | ## [0.4.28] - 2021-06-30
10 |
11 | ### Fixed
12 |
13 | - Miss basedir config in resolve
14 |
15 | ## [0.4.27] - 2021-06-29
16 |
17 | ### Changed
18 |
19 | - Use resolve to replace `require.resolve` to make exports field compatible
20 |
21 | ## [0.4.25] - 2021-05-19
22 |
23 | ### Chore
24 |
25 | - Use constants in miniapp-builder-shared
26 |
27 | ## [0.4.25] - 2021-03-30
28 |
29 | ### Added
30 |
31 | - Support passing virtualHost config into jsx-compiler
32 | ## [0.4.24] - 2021-03-11
33 |
34 | ### Chore
35 |
36 | - Update less and stylesheet-loader version
37 |
38 | ## [0.4.23] - 2021-03-08
39 |
40 | ### Fixed
41 |
42 | - Miss custom component json file in copyNpm mode
43 |
44 |
--------------------------------------------------------------------------------
/packages/jsx2mp-runtime/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jsx2mp-runtime",
3 | "version": "0.4.23",
4 | "description": "Runtime for jsx2mp.",
5 | "miniprogram": ".",
6 | "files": [
7 | "dist"
8 | ],
9 | "scripts": {
10 | "build": "cross-env NODE_ENV=production rollup -c rollup.config.js",
11 | "prepublish": "npm run build"
12 | },
13 | "author": "Rax Team",
14 | "devDependencies": {
15 | "@babel/core": "^7.4.5",
16 | "@babel/plugin-proposal-class-properties": "^7.5.5",
17 | "@babel/preset-env": "^7.4.5",
18 | "@babel/types": "^7.8.3",
19 | "cross-env": "^5.2.0",
20 | "rollup": "^1.13.1",
21 | "rollup-plugin-babel": "^4.3.2",
22 | "rollup-plugin-cleanup": "^3.1.1",
23 | "rollup-plugin-filesize": "^6.1.0",
24 | "rollup-plugin-replace": "^2.2.0",
25 | "universal-env": "^3.0.0"
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/packages/miniapp-builder-shared/src/utils/getRouteName.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const fs = require('fs-extra');
3 |
4 | module.exports = (route, rootDir) => {
5 | if (route.name) {
6 | return route.name;
7 | }
8 |
9 | const appConfig = fs.readJsonSync(path.resolve(rootDir, 'src/app.json'));
10 |
11 | const routeName = appConfig.routeName ? appConfig.routeName : 'path';
12 |
13 | if (routeName === 'path') {
14 | return route.source.replace(/\//g, '_');
15 | }
16 |
17 | if (routeName === 'pages') {
18 | try {
19 | // get Home from pages/Home/index or pages/Home
20 | const name = route.source.match(/pages\/([^/]*)/);
21 | return name[1];
22 | } catch (e) {
23 | console.error('"routeName": "pages" mode request routes in /pages directory');
24 | process.exit(1);
25 | }
26 | }
27 | };
28 |
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = function(api) {
2 | // Cache the returned value forever and don't call this function again.
3 | if (api) api.cache(true);
4 |
5 | return {
6 | 'presets': [
7 | '@babel/preset-flow',
8 | ['@babel/preset-env', {
9 | 'loose': true,
10 | }],
11 | ['@babel/preset-react', {
12 | 'pragma': 'createElement'
13 | }]
14 | ],
15 | 'plugins': [
16 | '@babel/plugin-proposal-export-default-from',
17 | ['@babel/plugin-proposal-class-properties', { 'loose': false }],
18 | 'babel-plugin-transform-jsx-stylesheet',
19 | ['@babel/plugin-proposal-decorators', { 'legacy': true }],
20 | '@babel/plugin-syntax-dynamic-import',
21 | ],
22 | 'env': {
23 | 'test': {
24 | 'plugins': ['dynamic-import-node']
25 | }
26 | },
27 | };
28 | };
29 |
--------------------------------------------------------------------------------
/packages/miniapp-builder-shared/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "miniapp-builder-shared",
3 | "version": "0.2.10",
4 | "description": "miniapp project builder shared lib",
5 | "author": "Rax Team",
6 | "homepage": "https://github.com/raxjs/miniapp#readme",
7 | "license": "BSD-3-Clause",
8 | "main": "src/index.js",
9 | "directories": {
10 | "lib": "lib",
11 | "test": "__tests__"
12 | },
13 | "repository": {
14 | "type": "git",
15 | "url": "git+https://github.com/raxjs/miniapp.git"
16 | },
17 | "scripts": {
18 | "test": "echo \"Error: run tests from root\" && exit 1"
19 | },
20 | "bugs": {
21 | "url": "https://github.com/raxjs/miniapp/issues"
22 | },
23 | "dependencies": {
24 | "enhanced-resolve": "^4.3.0",
25 | "execa": "^5.0.0",
26 | "fs-extra": "^8.0.1",
27 | "ice-npm-utils": "^2.1.0"
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/packages/rax-miniapp-babel-plugins/src/index.js:
--------------------------------------------------------------------------------
1 | module.exports = function({ usingComponents, nativeLifeCycleMap, target, rootDir, usingPlugins, runtimeDependencies }) {
2 | return [
3 | require.resolve('./plugins/babel-plugin-remove-Function'),
4 | require.resolve('./plugins/babel-plugin-external-module'),
5 | [
6 | require.resolve('./plugins/babel-plugin-native-lifecycle'),
7 | {
8 | nativeLifeCycleMap,
9 | },
10 | ],
11 | [
12 | require.resolve('./plugins/babel-plugin-handle-native-component'),
13 | {
14 | usingComponents,
15 | target,
16 | rootDir,
17 | runtimeDependencies
18 | }
19 | ],
20 | [
21 | require.resolve('./plugins/babel-plugin-handle-plugin-component'),
22 | {
23 | usingPlugins
24 | }
25 | ],
26 |
27 | ];
28 | };
29 |
--------------------------------------------------------------------------------
/packages/rax-miniapp-runtime-webpack-plugin/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "rax-miniapp-runtime-webpack-plugin",
3 | "version": "4.9.0",
4 | "description": "A webpack plugin for miniapp runtime build",
5 | "main": "src/index.js",
6 | "homepage": "https://github.com/raxjs/miniapp#readme",
7 | "keywords": [
8 | "rax",
9 | "plugin",
10 | "webpack",
11 | "miniapp",
12 | "runtime"
13 | ],
14 | "license": "MIT",
15 | "dependencies": {
16 | "chalk": "^3.0.0",
17 | "colors": "^1.4.0",
18 | "csso": "^4.0.3",
19 | "fs-extra": "^8.1.0",
20 | "lodash.isequal": "^4.5.0",
21 | "miniapp-builder-shared": "^0.2.0",
22 | "path-to-regexp": "^3.0.0",
23 | "postcss": "^7.0.17",
24 | "pretty-data": "^0.40.0",
25 | "terser": "^4.6.10",
26 | "webpack": "^4.35.3",
27 | "webpack-sources": "^1.3.0"
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/scripts/build.ts:
--------------------------------------------------------------------------------
1 | import * as glob from 'glob';
2 | import * as path from 'path';
3 | import * as fs from 'fs-extra';
4 | import { run } from './fn/shell';
5 |
6 | (async () => {
7 | const filePatten = '*/src/**/!(*.ts|*.tsx)';
8 | console.log(`[COPY]: ${filePatten}`);
9 |
10 | const cwd = path.join(__dirname, '../packages');
11 | const files = glob.sync(filePatten, { cwd, nodir: true });
12 | // eslint-disable-next-line
13 | for (const file of files) {
14 | const from = path.join(cwd, file);
15 | const to = path.join(cwd, file.replace(/\/src\//, '/lib/'));
16 | // eslint-disable-next-line
17 | await fs.mkdirp(path.dirname(to));
18 | // eslint-disable-next-line
19 | await fs.copyFile(from, to);
20 | }
21 | await run('npx tsc --build ./tsconfig.json');
22 | })().catch((e) => {
23 | console.trace(e);
24 | process.exit(128);
25 | });
26 |
--------------------------------------------------------------------------------
/packages/eslint-plugin-rax-compile-time-miniapp/README.md:
--------------------------------------------------------------------------------
1 | # eslint-plugin-rax-compile-time-miniapp
2 |
3 | Eslint plugin for rax compiler miniapp.
4 |
5 | ## Installation
6 |
7 | You'll first need to install [ESLint](http://eslint.org):
8 |
9 | ```
10 | $ npm i eslint --save-dev
11 | ```
12 |
13 | Next, install `eslint-plugin-rax-compile-time-miniapp`:
14 |
15 | ```
16 | $ npm install eslint-plugin-rax-compile-time-miniapp --save-dev
17 | ```
18 |
19 |
20 | ## Usage
21 |
22 | Add `rax-compile-time-miniapp` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix:
23 |
24 | ```json
25 | {
26 | "extends": [
27 | "eslint-config-ali/typescript/rax",
28 | "plugin:rax-compile-time-miniapp/recommended"
29 | ],
30 | "plugins": [
31 | "rax-compile-time-miniapp"
32 | ]
33 | }
34 | ```
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/packages/jsx-compiler/src/index.js:
--------------------------------------------------------------------------------
1 | const { generate } = require('./codegen');
2 | const { parse } = require('./parser');
3 | const { baseOptions } = require('./options');
4 | const adapter = require('./adapter');
5 |
6 | /**
7 | * @param template {String} Template string.
8 | * @param options {Object} Compiler options.
9 | */
10 | function compile(template, options) {
11 | const type = options.platform && options.platform.type || 'ali';
12 | options.adapter = options.adapter || adapter[type];
13 | const parsed = parse(template.trim(), options);
14 | const generated = generate(parsed, options);
15 | const { ast, imported, exported } = parsed;
16 |
17 | return Object.assign({ ast, imported, exported }, generated);
18 | }
19 |
20 | module.exports = exports = compile;
21 | exports.parse = parse;
22 | exports.generate = generate;
23 | exports.baseOptions = baseOptions;
24 |
--------------------------------------------------------------------------------
/packages/rax-miniapp-babel-plugins/src/plugins/babel-plugin-remove-Function.js:
--------------------------------------------------------------------------------
1 | module.exports = function visitor() {
2 | return {
3 | visitor: {
4 | CallExpression(path) {
5 | const { node } = path;
6 | const callee = node.callee.callee;
7 | if (
8 | callee &&
9 | callee.name === 'Function' &&
10 | node.callee.arguments &&
11 | node.callee.arguments.length === 2 &&
12 | node.callee.arguments[0].value === 'r' &&
13 | node.callee.arguments[1].value === 'regeneratorRuntime = r'
14 | ) {
15 | // Remove `Function('r', 'regeneratorRuntime = r')(runtime)`
16 | // Because Alibaba Miniapp doesn't allow use `Function`
17 | try {
18 | path.parentPath.remove();
19 | } catch (err) {}
20 | }
21 | }
22 | }
23 | };
24 | };
25 |
--------------------------------------------------------------------------------
/scripts/release.ts:
--------------------------------------------------------------------------------
1 | import axios from 'axios';
2 |
3 | (async() => {
4 | const releasesInfo = await axios({
5 | url: ' https://api.github.com/repos/raxjs/miniapp/releases/latest',
6 | method: 'GET',
7 | headers: {
8 | 'Accept': 'application/vnd.github.v3+json'
9 | },
10 | });
11 | const response = await axios({
12 | url: process.env.DING_WEBHOOK,
13 | method: 'post',
14 | headers: {
15 | 'Content-Type': 'application/json;charset=utf-8',
16 | },
17 | data: {
18 | msgtype: 'markdown',
19 | "markdown": {
20 | "title": releasesInfo.data.name,
21 | "text": `### Rax Miniapp released ${releasesInfo.data.name}
22 | \n ${releasesInfo.data.body}
23 | \n ##### [Release 详情](${releasesInfo.data.html_url})`
24 | }
25 | },
26 | });
27 | console.log('notify success', response.data);
28 | })();
29 |
--------------------------------------------------------------------------------
/packages/jsx2mp-loader/src/utils/parseRequest.js:
--------------------------------------------------------------------------------
1 | function splitOnFirst(str = '', separator = '') {
2 | const separatorIndex = str.indexOf(separator);
3 | if (separatorIndex === -1) {
4 | return [];
5 | }
6 | return [ str.slice(0, separatorIndex), str.slice(separatorIndex + separator.length) ];
7 | }
8 |
9 | function parse(request = '') {
10 | const lastExclamationMark = request.lastIndexOf('!');
11 | if (lastExclamationMark) {
12 | const ret = {};
13 | const originalRequest = request.substr(lastExclamationMark + 1);
14 | const [, queryString] = splitOnFirst(originalRequest, '?');
15 | if (queryString) {
16 | for (const param of queryString.split('&')) {
17 | const [key, value] = splitOnFirst(param, '=');
18 | ret[key] = value;
19 | }
20 | }
21 | return ret;
22 | }
23 | return {};
24 | }
25 |
26 | module.exports = parse;
27 |
--------------------------------------------------------------------------------
/packages/miniapp-render/src/builtInComponents/swiper.js:
--------------------------------------------------------------------------------
1 | // eslint-disable-next-line import/no-extraneous-dependencies
2 | import { isMiniApp } from 'universal-env';
3 |
4 | const swiper = {
5 | name: 'swiper',
6 | singleEvents: [{
7 | name: 'onSwiperTransition',
8 | eventName: 'transition'
9 | }],
10 | functionalSingleEvents: [
11 | {
12 | name: 'onSwiperChange',
13 | eventName: 'change',
14 | middleware(evt, domNode) {
15 | domNode._setAttributeWithDelayUpdate('current', evt.detail.current);
16 | }
17 | }
18 | ]
19 | };
20 |
21 | if (isMiniApp) {
22 | swiper.singleEvents.push({
23 | name: 'onSwiperAnimationEnd',
24 | eventName: 'animationEnd'
25 | });
26 | } else {
27 | swiper.singleEvents.push({
28 | name: 'onSwiperAnimationFinish',
29 | eventName: 'animationfinish'
30 | });
31 | }
32 |
33 | export default swiper;
34 |
--------------------------------------------------------------------------------
/packages/jsx-compiler/src/modules/function.js:
--------------------------------------------------------------------------------
1 | const t = require('@babel/types');
2 | const traverse = require('../utils/traverseNodePath');
3 | const { isWeexModule } = require('../utils/checkModule');
4 |
5 | function transformFunction(ast) {
6 | traverse(ast, {
7 | CallExpression(path) {
8 | const { node } = path;
9 | if (node.callee.name === 'require' &&
10 | node.arguments &&
11 | node.arguments.length === 1 &&
12 | t.isStringLiteral(node.arguments[0])) {
13 | const moduleName = node.arguments[0].value;
14 | if (isWeexModule(moduleName)) {
15 | path.replaceWith(t.nullLiteral());
16 | }
17 | }
18 | }
19 | });
20 | }
21 |
22 | module.exports = {
23 | parse(parsed, code, options) {
24 | transformFunction(parsed.ast);
25 | },
26 |
27 | // For test cases.
28 | _transformFunction: transformFunction,
29 | };
30 |
--------------------------------------------------------------------------------
/packages/build-plugin-rax-miniapp-faas/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "build-plugin-rax-miniapp-faas",
3 | "version": "1.0.0",
4 | "description": "rax miniapp-faas base plugins",
5 | "main": "lib/index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "files": [
10 | "lib"
11 | ],
12 | "keywords": [
13 | "plugin",
14 | "rax",
15 | "miniapp",
16 | "faas"
17 | ],
18 | "author": "",
19 | "license": "MIT",
20 | "peerDependencies": {
21 | "@alib/build-scripts": "^0.1.0",
22 | "rax": "^1.0.0"
23 | },
24 | "dependencies": {
25 | "@midwayjs/command-core": "^1.2.76",
26 | "@midwayjs/fcli-plugin-package": "^1.2.78",
27 | "@midwayjs/fcli-plugin-wechat": "^1.2.78",
28 | "@midwayjs/serverless-spec-builder": "^1.2.78",
29 | "fs-extra": "^10.0.0",
30 | "miniapp-builder-shared": "^0.2.9"
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/packages/miniapp-history/src/listeners.js:
--------------------------------------------------------------------------------
1 | // Page id -> action callbacks
2 | const listeners = {};
3 |
4 | /**
5 | * Add history listener
6 | * @param {string} pageId page unique id
7 | * @param {function} callback history operate action callback
8 | * @return {Array} target page listener list
9 | */
10 | export function addListener(pageId, callback) {
11 | if (!listeners[pageId]) listeners[pageId] = [];
12 | listeners[pageId].push(callback);
13 | return listeners[pageId];
14 | }
15 |
16 | /**
17 | * Fire history listeners
18 | * @param {object} location router location object
19 | * @param {string} action history operate action
20 | */
21 | export function fireListeners(location, action) {
22 | const pageId = location._pageId;
23 | if (listeners[pageId]) {
24 | for (let index in listeners[pageId]) {
25 | listeners[pageId][index]({ location, action });
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/packages/miniapp-render/src/builtInComponents/view.js:
--------------------------------------------------------------------------------
1 | // eslint-disable-next-line import/no-extraneous-dependencies
2 | import { isMiniApp } from 'universal-env';
3 |
4 | const view = {
5 | name: 'view'
6 | };
7 |
8 | if (isMiniApp) {
9 | view.simpleEvents = [{
10 | name: 'onViewAppear',
11 | eventName: 'appear'
12 | },
13 | {
14 | name: 'onViewFirstAppear',
15 | eventName: 'firstappear'
16 | },
17 | {
18 | name: 'onViewDisappear',
19 | eventName: 'disappear'
20 | },
21 | {
22 | name: 'onViewTransitionEnd',
23 | eventName: 'transitionend'
24 | },
25 | {
26 | name: 'onViewAnimationIteration',
27 | eventName: 'animationiteration'
28 | },
29 | {
30 | name: 'onViewAnimationStart',
31 | eventName: 'animationstart'
32 | },
33 | {
34 | name: 'onViewAnimationEnd',
35 | eventName: 'animationend'
36 | }];
37 | }
38 |
39 | export default view;
40 |
--------------------------------------------------------------------------------
/packages/rax-miniapp-config-webpack-plugin/src/transformNativeConfig.js:
--------------------------------------------------------------------------------
1 | const { join } = require('path');
2 | const { constants: { WECHAT_MINIPROGRAM, BYTEDANCE_MICROAPP }, platformMap } = require('miniapp-builder-shared');
3 |
4 | const safeWriteFile = require('./safeWriteFile');
5 |
6 | const defaultConfig = {
7 | // project.config.json in wechat miniprogram is necessary without which the project won't bootstrap
8 | [WECHAT_MINIPROGRAM]: {
9 | appid: ''
10 | },
11 | // setting in bytedance microapp is necessary without which the project will compile error
12 | [BYTEDANCE_MICROAPP]: {
13 | setting: {}
14 | }
15 | };
16 |
17 | module.exports = function(outputPath, nativeConfig = {}, target) {
18 | const configContent = Object.assign(defaultConfig[target] || {}, nativeConfig);
19 | safeWriteFile(join(outputPath, platformMap[target].nativeConfigFileName), configContent, true);
20 | };
21 |
--------------------------------------------------------------------------------
/packages/rax-miniapp-runtime-webpack-plugin/src/generators/index.js:
--------------------------------------------------------------------------------
1 | const { generateAppJS, generateAppCSS } = require('./app');
2 | const generateConfig = require('./config');
3 | const {
4 | generatePageCSS,
5 | generatePageJS,
6 | generatePageJSON,
7 | generatePageXML,
8 | } = require('./page');
9 | const { generateRootTmpl } = require('./root');
10 | const {
11 | generateElementJS,
12 | generateElementJSON,
13 | generateElementTemplate,
14 | } = require('./element');
15 | const generateRender = require('./render');
16 | const generatePkg = require('./pkg');
17 |
18 | module.exports = {
19 | generateAppCSS,
20 | generateAppJS,
21 | generateConfig,
22 | generatePageCSS,
23 | generatePageJS,
24 | generatePageJSON,
25 | generatePageXML,
26 | generateRootTmpl,
27 | generateElementJS,
28 | generateElementJSON,
29 | generateElementTemplate,
30 | generateRender,
31 | generatePkg
32 | };
33 |
--------------------------------------------------------------------------------
/packages/miniapp-builder-shared/src/filterNativePages.js:
--------------------------------------------------------------------------------
1 | const { dirname, join } = require('path');
2 | const { getDepPath, isNativePage } = require('./pathHelper');
3 |
4 | /**
5 | * Filter native page
6 | * @param {Array} routes - user routes
7 | * @param {Array} needCopyList - need copy miniapp native pages
8 | * @param {object} options - function options
9 | * @param {string} options.rootDir - project root directory
10 | * @param {string} options.target - user platform
11 | * @returns {Array}
12 | */
13 | module.exports = (routes, needCopyList, { rootDir, target }) => {
14 | return routes.filter(({ source }) => {
15 | const pageEntry = getDepPath(rootDir, source);
16 | if (isNativePage(pageEntry, target)) {
17 | needCopyList.push({
18 | from: dirname(join('src', source)),
19 | to: dirname(source)
20 | });
21 | return false;
22 | }
23 | return true;
24 | });
25 | };
26 |
--------------------------------------------------------------------------------
/packages/jsx2mp-runtime/src/createRef.js:
--------------------------------------------------------------------------------
1 | // eslint-disable-next-line import/no-extraneous-dependencies
2 | import { isMiniApp, isWeChatMiniProgram, isByteDanceMicroApp } from 'universal-env';
3 |
4 | export default function(initialValue) {
5 | let created = false;
6 | const ref = {
7 | current: initialValue
8 | };
9 | ref.__proto__ = Function.prototype;
10 |
11 | const refFn = (instance, immobile) => {
12 | // Instance maybe component instance or triggered event object
13 | if (!created || !immobile) {
14 | if (isMiniApp) {
15 | ref.current = instance;
16 | } else if (isWeChatMiniProgram || isByteDanceMicroApp) {
17 | // If instance has detail, instance is event object
18 | ref.current = Object.hasOwnProperty.call(instance, 'detail') ? instance.detail : instance;
19 | }
20 | }
21 | created = true;
22 | };
23 | refFn.__proto__ = ref;
24 | return refFn;
25 | };
26 |
--------------------------------------------------------------------------------
/packages/eslint-plugin-rax-compile-time-miniapp/docs/rules/no_multilevel_condition.md:
--------------------------------------------------------------------------------
1 | # no-multilevel-condition
2 | 你不能通过嵌套 if 来实现条件渲染
3 |
4 | ## Rule Details
5 | Examples of **incorrect** code for this rule:
6 |
7 | ```js
8 |
9 | function Element(props) {
10 | let element;
11 | if (props.z > 20) {
12 | if (props.x > 1) {
13 | element = Hi;
14 | }
15 | }
16 | return <>{element}>
17 | }
18 |
19 | ```
20 |
21 | Examples of **correct** code for this rule:
22 |
23 | ```js
24 |
25 | function Element(props) {
26 | let element;
27 | if (props.x > 1) {
28 | element = Hi;
29 | } else if(props.y > 2) (
30 | element = Wow!;
31 | ) else {
32 | element = Hey!
33 | }
34 | return <>{element}>
35 | }
36 |
37 | ```
38 |
39 | ## More
40 | 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/rax-miniapp-runtime-webpack-plugin/src/generators/render.js:
--------------------------------------------------------------------------------
1 | const { resolve } = require('path');
2 | const { readFileSync } = require('fs-extra');
3 | const {
4 | pathHelper: { getHighestPriorityPackageJSON },
5 | platformMap
6 | } = require('miniapp-builder-shared');
7 |
8 | const addFileToCompilation = require('../utils/addFileToCompilation');
9 |
10 | module.exports = function(compilation, { target, command, rootDir }) {
11 | const miniappRenderPackageJsonFile = getHighestPriorityPackageJSON('miniapp-render', rootDir);
12 | const sourceMiniappRenderFile = resolve(
13 | miniappRenderPackageJsonFile,
14 | '..',
15 | 'dist',
16 | platformMap[target].type,
17 | command === 'build' ? 'index.min.js' : 'index.js'
18 | );
19 | addFileToCompilation(compilation, {
20 | filename: 'render.js',
21 | content: readFileSync(sourceMiniappRenderFile, 'utf-8'),
22 | command,
23 | target,
24 | });
25 | };
26 |
--------------------------------------------------------------------------------
/packages/jsx-compiler/src/utils/traverseNodePath.js:
--------------------------------------------------------------------------------
1 | const { default: traverse, NodePath } = require('@babel/traverse');
2 | const t = require('@babel/types');
3 |
4 | /**
5 | * Traverse a node path.
6 | * @param nodeOrPath
7 | * @param visitor
8 | */
9 | module.exports = function traverseNodePath(nodeOrPath, visitor) {
10 | if (nodeOrPath == null) return;
11 |
12 | if (nodeOrPath instanceof NodePath) {
13 | nodeOrPath.traverse(visitor);
14 | } else if (t.isFile(nodeOrPath)) {
15 | traverse(nodeOrPath, visitor);
16 | } else if (t.isStatement(nodeOrPath)) {
17 | // Only can traverse file path.
18 | const file = t.file(t.program([nodeOrPath]));
19 | traverse(file, visitor);
20 | } else {
21 | // Expression should be wrapped in expression statement.
22 | // Only can traverse file path.
23 | const file = t.file(t.program([t.expressionStatement(nodeOrPath)]));
24 | traverse(file, visitor);
25 | }
26 | };
27 |
--------------------------------------------------------------------------------
/packages/jsx2mp-runtime/src/types.js:
--------------------------------------------------------------------------------
1 | export function isNull(obj) {
2 | return obj === null;
3 | }
4 |
5 | export function isUndef(value) {
6 | return value === undefined;
7 | }
8 |
9 | export function isFunction(obj) {
10 | return typeof obj === 'function';
11 | }
12 |
13 | export function isObject(obj) {
14 | return typeof obj === 'object';
15 | }
16 |
17 | export function isPlainObject(obj) {
18 | return EMPTY_OBJECT.toString.call(obj) === '[object Object]';
19 | }
20 |
21 | export function isArray(array) {
22 | return Array.isArray(array);
23 | }
24 |
25 | export function isString(string) {
26 | return typeof string === 'string';
27 | }
28 |
29 | export function isNumber(string) {
30 | return typeof string === 'number';
31 | }
32 |
33 | export function isEmptyObj(obj) {
34 | for (let key in obj) {
35 | return false;
36 | }
37 | return true;
38 | }
39 |
40 | export const NOOP = () => {};
41 | export const EMPTY_OBJECT = {};
42 |
--------------------------------------------------------------------------------
/examples/use-rax-compiled-component-in-runtime-miniapp/src/pages/Home/index.jsx:
--------------------------------------------------------------------------------
1 | import { createElement, useState } from 'rax';
2 | import View from 'rax-view';
3 | import Text from 'rax-text';
4 | import Modal from 'rax-modal';
5 | import CompiledComp1 from '../../miniapp-compiled/CompiledComp1';
6 | import CompiledComp2 from '../../miniapp-compiled/CompiledComp2';
7 |
8 | import './index.css';
9 |
10 | const Home = () => {
11 | const [visible, setVisible] = useState(false);
12 | return (
13 |
14 | { setVisible(true); }}>
15 | open1
16 |
17 |
18 |
19 | {
22 | setVisible(false);
23 | }}
24 | >
25 | Hello, world
26 |
27 |
28 | );
29 | };
30 |
31 | export default Home;
32 |
--------------------------------------------------------------------------------
/packages/jsx-compiler/src/utils/isFunctionComponent.js:
--------------------------------------------------------------------------------
1 | const t = require('@babel/types');
2 |
3 | /**
4 | * Judge a NodePath is a Rax JSX function component.
5 | * @param path {NodePath}
6 | * eg:
7 | * 1. function foo(props) {
8 | * return ();
9 | * }
10 | * 2. const foo = function(props) {
11 | * return (view>)
12 | * }
13 | * 3. const foo = (props) => ()
14 | */
15 | module.exports = function isFunctionComponent(path) {
16 | if (!path) return false;
17 |
18 | const { node, scope } = path;
19 | if (t.isIdentifier(node)) {
20 | const binding = scope.getBinding(node.name);
21 | if (t.isVariableDeclarator(binding.path.node)) {
22 | return isFunctionComponent(binding.path.get('init'));
23 | } else {
24 | return isFunctionComponent(binding.path);
25 | }
26 | } else if (node == null) {
27 | return false;
28 | } else {
29 | return t.isFunction(node);
30 | }
31 | };
32 |
--------------------------------------------------------------------------------
/packages/miniapp-render/src/utils/tool.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Hump to hyphen
3 | */
4 | function toDash(str) {
5 | return str.replace(/[A-Z]/g, all => `-${all.toLowerCase()}`);
6 | }
7 |
8 | /**
9 | * Hyphen to hump
10 | */
11 | function toCamel(str) {
12 | return str.replace(/-([a-zA-Z])/g, (all, $1) => $1.toUpperCase());
13 | }
14 |
15 | /**
16 | * Get unique id
17 | */
18 | let seed = 0;
19 | function getId() {
20 | return seed++;
21 | }
22 |
23 | /**
24 | * Check whether the variable is undefined
25 | * @param {*} variable
26 | * @returns boolean
27 | */
28 | function isUndef(variable) {
29 | return variable === undefined;
30 | }
31 |
32 | /**
33 | * Check whether the variable is a function
34 | * @param {*} variable
35 | * @returns boolean
36 | */
37 | function isFunction(variable) {
38 | return typeof variable === 'function';
39 | }
40 |
41 | export {
42 | toDash,
43 | toCamel,
44 | getId,
45 | isUndef,
46 | isFunction
47 | };
48 |
--------------------------------------------------------------------------------
/packages/jsx2mp-runtime/src/adapter/getComponentBaseConfig.js:
--------------------------------------------------------------------------------
1 | // eslint-disable-next-line import/no-extraneous-dependencies
2 | import { isMiniApp, isWeChatMiniProgram, isQuickApp, isByteDanceMicroApp } from 'universal-env';
3 |
4 | export default function(baseConfig) {
5 | // For alibaba miniapp
6 | if (isMiniApp) {
7 | return {
8 | props: {},
9 | events: {}
10 | };
11 | }
12 |
13 | // For wechat miniprogram and bytedance microapp
14 | if (isWeChatMiniProgram || isByteDanceMicroApp) {
15 | return {
16 | properties: {
17 | __tagId: null,
18 | ref: null,
19 | // For native project
20 | outerProps: null
21 | },
22 | options: {
23 | styleIsolation: 'shared',
24 | multipleSlots: true,
25 | ...baseConfig
26 | }
27 | };
28 | }
29 |
30 | // For quickapp
31 | if (isQuickApp) {
32 | return {
33 | props: ['tagId'],
34 | };
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/packages/miniapp-history/src/History.js:
--------------------------------------------------------------------------------
1 | import generateActions, { __updateRouterMap } from './router';
2 | import Location from './Location';
3 | import { addListener } from './listeners';
4 |
5 | export default class MiniAppHistory {
6 | constructor(routes) {
7 | this.location = new Location();
8 | __updateRouterMap(routes);
9 | // Apply actions for history.
10 | Object.assign(this, generateActions(this.location));
11 | }
12 |
13 | get length() {
14 | // eslint-disable-next-line no-undef
15 | return getCurrentPages().length;
16 | }
17 |
18 | listen(callback) {
19 | const listeners = addListener(this.location._pageId, callback);
20 | return function() {
21 | let index = -1;
22 | for (let idx in listeners) {
23 | if (listeners[idx] === callback) {
24 | index = idx;
25 | break;
26 | }
27 | }
28 | if (index > -1) listeners.splice(index, 1);
29 | };
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/packages/jsx2mp-runtime/src/createStyle.js:
--------------------------------------------------------------------------------
1 | import kebabCase from './kebabCase';
2 | import { isArray, isObject, isString, isNull } from './types';
3 | /**
4 | * Create style string.
5 | * @param style {Object|Array} React like acceptable style props.
6 | * @return {String} Style expression string inline.
7 | */
8 | export default function createStyle(style) {
9 | if (isNull(style)) return '';
10 |
11 | let ret = '';
12 |
13 | if (isArray(style)) {
14 | style.forEach((s) => {
15 | ret += createStyle(s);
16 | });
17 | } else if (isObject(style)) {
18 | Object.keys(style).forEach((key, index, styleKeys) => {
19 | const isLast = styleKeys.length - 1 === index;
20 | ret += `${kebabCase(key)}: ${transformUnit(style[key])};${isLast ? '' : ' '}`;
21 | });
22 | } else if (isString(style)) {
23 | ret += style;
24 | }
25 |
26 | return ret; // Remove last space.
27 | }
28 |
29 | function transformUnit(val) {
30 | return val;
31 | }
32 |
--------------------------------------------------------------------------------
/packages/jsx2mp-runtime/src/scheduler.js:
--------------------------------------------------------------------------------
1 | import scheduler from './nextTick';
2 |
3 | let updateCallbacks = [];
4 | let effectCallbacks = [];
5 |
6 | // Schedule before next render
7 | export function schedule(callback) {
8 | if (updateCallbacks.length === 0) {
9 | scheduler(flush);
10 | }
11 | updateCallbacks.push(callback);
12 | }
13 |
14 | // Flush before next render
15 | export function flush() {
16 | let callbacks = updateCallbacks;
17 | if (callbacks.length !== 0) {
18 | updateCallbacks = [];
19 | callbacks.forEach(callback => callback());
20 | }
21 | }
22 |
23 | export function scheduleEffect(callback) {
24 | if (effectCallbacks.length === 0) {
25 | scheduler(invokeEffects);
26 | }
27 | effectCallbacks.push(callback);
28 | }
29 |
30 | export function invokeEffects() {
31 | let callbacks = effectCallbacks;
32 | if (callbacks.length !== 0) {
33 | effectCallbacks = [];
34 | callbacks.forEach(callback => callback());
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/packages/eslint-plugin-rax-compile-time-miniapp/docs/rules/no_temp_variable_in_loop_render.md:
--------------------------------------------------------------------------------
1 | # no-temp-variable-in-loop-render
2 | 在使用匿名函数的时候,不要在函数体内直接使用循环中产生的临时变量,如 `index` 等。
3 |
4 | ## Rule Details
5 |
6 | Examples of **incorrect** code for this rule:
7 |
8 | ```jsx
9 |
10 |
11 | {
12 | list.map((item, index) => {
13 | return {
15 | console.log(index);
16 | }
17 | }>Click!
18 | });
19 | }
20 |
21 |
22 | ```
23 |
24 | Examples of **correct** code for this rule:
25 |
26 | ```jsx
27 |
28 |
29 | {
30 | list.map((item, index) => {
31 | return handleClick(index)}>Click!
32 | });
33 | }
34 |
35 |
36 | ```
37 |
38 | ## More
39 | https://rax.js.org/docs/guide/compile-miniapp-syntax-constraints#%E5%9C%A8%E5%BE%AA%E7%8E%AF%E4%B8%AD%E5%90%91%E4%BA%8B%E4%BB%B6%E5%A4%84%E7%90%86%E7%A8%8B%E5%BA%8F%E4%BC%A0%E9%80%92%E5%8F%82%E6%95%B0
40 |
--------------------------------------------------------------------------------
/packages/jsx2mp-runtime/src/classnames.js:
--------------------------------------------------------------------------------
1 | import { isString, isNumber, isArray, isObject } from './types';
2 |
3 | /*!
4 | Copyright (c) 2017 Jed Watson.
5 | Licensed under the MIT License (MIT), see
6 | http://jedwatson.github.io/classnames
7 | */
8 | const hasOwn = {}.hasOwnProperty;
9 |
10 | export default function classNames() {
11 | const classes = [];
12 |
13 | for (let i = 0; i < arguments.length; i++) {
14 | const arg = arguments[i];
15 | if (!arg) continue;
16 |
17 | if (isString(arg) || isNumber(arg)) {
18 | classes.push(arg);
19 | } else if (isArray(arg) && arg.length) {
20 | const inner = classNames.apply(null, arg);
21 | if (inner) {
22 | classes.push(inner);
23 | }
24 | } else if (isObject(arg)) {
25 | for (let key in arg) {
26 | if (hasOwn.call(arg, key) && arg[key]) {
27 | classes.push(key);
28 | }
29 | }
30 | }
31 | }
32 |
33 | return classes.join(' ');
34 | }
35 |
--------------------------------------------------------------------------------
/packages/build-plugin-rax-miniapp-faas/src/package_process.ts:
--------------------------------------------------------------------------------
1 | import { CommandCore } from '@midwayjs/command-core';
2 | import { loadSpec } from '@midwayjs/serverless-spec-builder';
3 | import { PackagePlugin } from '@midwayjs/fcli-plugin-package';
4 | import { WeChatPlugin } from '@midwayjs/fcli-plugin-wechat';
5 |
6 | (async() => {
7 | const core = new CommandCore({
8 | config: {
9 | servicePath: process.env.baseDir,
10 | },
11 | options: {
12 | verbose: process.env.MIDWAY_FAAS_VERBOSE,
13 | },
14 | commands: ['package'],
15 | service: loadSpec(process.env.baseDir),
16 | provider: 'wechat',
17 | log: {
18 | ...console,
19 | log: (...args) => {
20 | if (process.env.MIDWAY_FAAS_VERBOSE) {
21 | console.log(...args);
22 | }
23 | },
24 | },
25 | });
26 | core.addPlugin(PackagePlugin);
27 | core.addPlugin(WeChatPlugin);
28 | await core.ready();
29 | await core.invoke(['package']);
30 | })();
31 |
--------------------------------------------------------------------------------
/packages/miniapp-builder-shared/README.md:
--------------------------------------------------------------------------------
1 | ## Shared lib for miniapp builder
2 |
3 | ### filterNativePages
4 |
5 | It will filter native miniapp pages and return a need copy native page files list.
6 |
7 | ### getAppConfig
8 |
9 | It will return a valid app config for miniapp.
10 |
11 | ### getPluginConfig
12 |
13 | It will return a valid plugin config for miniapp.
14 |
15 | ### pathHelper
16 |
17 | It will export the following methods:
18 | - `relativeModuleResolve`
19 | - `normalizeOutputFilePath`
20 | - `getRelativePath`
21 | - `getDepPath`
22 | - `absoluteModuleResolve`
23 | - `getPlatformExtensions`
24 | - `isNativePage`
25 | - `removeExt`
26 | - `getHighestPriorityPackageJSON`
27 | - `getBundlePath`
28 |
29 | ### platformMap
30 |
31 | It will return miniapp platform and suffix name correspondence.
32 |
33 | ### constants
34 |
35 | It will return miniapp related constants
36 |
37 | ### autoInstallNpm
38 |
39 | It will install npm for native miniapp automatically
40 |
--------------------------------------------------------------------------------
/examples/with-miniapp-plugin-component/wechat-miniprogram-plugin/pages/hello-page.js:
--------------------------------------------------------------------------------
1 | // pages/hello-page.js
2 | Page({
3 |
4 | /**
5 | * 页面的初始数据
6 | */
7 | data: {
8 |
9 | },
10 |
11 | /**
12 | * 生命周期函数--监听页面加载
13 | */
14 | onLoad: function(options) {
15 |
16 | },
17 |
18 | /**
19 | * 生命周期函数--监听页面初次渲染完成
20 | */
21 | onReady: function() {
22 |
23 | },
24 |
25 | /**
26 | * 生命周期函数--监听页面显示
27 | */
28 | onShow: function() {
29 |
30 | },
31 |
32 | /**
33 | * 生命周期函数--监听页面隐藏
34 | */
35 | onHide: function() {
36 |
37 | },
38 |
39 | /**
40 | * 生命周期函数--监听页面卸载
41 | */
42 | onUnload: function() {
43 |
44 | },
45 |
46 | /**
47 | * 页面相关事件处理函数--监听用户下拉动作
48 | */
49 | onPullDownRefresh: function() {
50 |
51 | },
52 |
53 | /**
54 | * 页面上拉触底事件的处理函数
55 | */
56 | onReachBottom: function() {
57 |
58 | },
59 |
60 | /**
61 | * 用户点击右上角分享
62 | */
63 | onShareAppMessage: function() {
64 |
65 | }
66 | });
67 |
--------------------------------------------------------------------------------
/packages/eslint-plugin-rax-compile-time-miniapp/docs/rules/no_multilevel_object.md:
--------------------------------------------------------------------------------
1 | # no-multilevel-object
2 | 在第二层循环的时候不能去循环子项更深层的属性
3 |
4 | ## Rule Details
5 |
6 | Examples of **incorrect** code for this rule:
7 |
8 | ```js
9 |
10 |
11 | {list.map((item, index) => {
12 | return (
13 |
14 | {item.detail.infoList.map((it, idx) => {
15 | return {it};
16 | })}
17 |
18 | );
19 | })}
20 |
21 |
22 | ```
23 |
24 | `item.detail.infoList` 的用法是错误的,如果一定要这么做,请您预先处理好数组的格式。
25 |
26 | Examples of **correct** code for this rule:
27 |
28 | ```js
29 |
30 |
31 | {list.map((item, index) => {
32 | return (
33 |
34 | {item.infoList.map((it, idx) => {
35 | return {it};
36 | })}
37 |
38 | );
39 | })}
40 |
41 |
42 | ```
43 |
44 | ## More
45 | https://rax.js.org/docs/guide/compile-miniapp-syntax-constraints#%E5%88%97%E8%A1%A8%E6%B8%B2%E6%9F%93
--------------------------------------------------------------------------------
/packages/jsx-compiler/src/utils/getDefaultExportedPath.js:
--------------------------------------------------------------------------------
1 | const t = require('@babel/types');
2 | const traverse = require('./traverseNodePath');
3 |
4 | /**
5 | * Get default exported path.
6 | * @param ast
7 | */
8 | module.exports = function getDefaultExportedPath(ast) {
9 | let exportedDeclaration = null;
10 | traverse(ast, {
11 | ExportDefaultDeclaration(path) {
12 | exportedDeclaration = path.get('declaration');
13 | if (t.isIdentifier(exportedDeclaration.node)) {
14 | const id = exportedDeclaration.node.name;
15 | const binding = exportedDeclaration.scope.getBinding(id);
16 | if (binding) {
17 | if (t.isVariableDeclarator(binding.path.node)) {
18 | exportedDeclaration = binding.path.get('init');
19 | } else {
20 | exportedDeclaration = binding.path;
21 | }
22 | } else {
23 | exportedDeclaration = null;
24 | }
25 | }
26 | },
27 | });
28 | return exportedDeclaration;
29 | };
30 |
--------------------------------------------------------------------------------
/examples/page-lifecycle-with-router/src/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "routes": [
3 | {
4 | "path": "/",
5 | "source": "pages/Home/index"
6 | },
7 | {
8 | "path": "/about",
9 | "source": "pages/About/index"
10 | }
11 | ],
12 | "window": {
13 | "title": "Rax App",
14 | "pullRefresh": true
15 | },
16 | "tabBar": {
17 | "textColor": "#999",
18 | "selectedColor": "#666",
19 | "backgroundColor": "#f8f8f8",
20 | "items": [
21 | {
22 | "name": "home",
23 | "path": "/",
24 | "icon": "https://gw.alicdn.com/tfs/TB1ypSMTcfpK1RjSZFOXXa6nFXa-144-144.png",
25 | "activeIcon": "https://gw.alicdn.com/tfs/TB1NBiCTgHqK1RjSZFPXXcwapXa-144-144.png"
26 | },
27 | {
28 | "name": "about",
29 | "path": "/about",
30 | "icon": "https://gw.alicdn.com/tfs/TB1ypSMTcfpK1RjSZFOXXa6nFXa-144-144.png",
31 | "activeIcon": "https://gw.alicdn.com/tfs/TB1NBiCTgHqK1RjSZFPXXcwapXa-144-144.png"
32 | }
33 | ]
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/packages/jsx2mp-runtime/src/adapter/attachRef.js:
--------------------------------------------------------------------------------
1 | // eslint-disable-next-line import/no-extraneous-dependencies
2 | import { isMiniApp, isWeChatMiniProgram, isByteDanceMicroApp } from 'universal-env';
3 |
4 | export default function(instance, bindComRef) {
5 | if (bindComRef) {
6 | if (instance.__isReactiveComponent && !instance._render._forwardRef) {
7 | console.warn('Warning: Do not attach ref to function component because they don’t have instances.');
8 | }
9 | triggerSetRef(instance, bindComRef);
10 | }
11 | }
12 |
13 | function triggerSetRef(instance, bindComRef) {
14 | // In function component, it shouldn't return component instance, so return null
15 | const current = instance.__isReactiveComponent ? null : instance;
16 | if (isMiniApp) {
17 | bindComRef(current);
18 | } else if (isWeChatMiniProgram || isByteDanceMicroApp) {
19 | // If is function component, it will use the triggerEvent in useImperativeHandle
20 | instance._internal.triggerEvent('ComRef', current);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/packages/miniapp-render/src/utils/tree.js:
--------------------------------------------------------------------------------
1 | function simplify(node) {
2 | return node._renderInfo;
3 | }
4 |
5 | export function traverse(node, action) {
6 | if (!node) {
7 | return;
8 | }
9 | let copiedNode;
10 | let queue = [];
11 | queue.push(node);
12 | while (queue.length) {
13 | let curNode = queue.shift();
14 | const result = action(curNode);
15 | if (!copiedNode) {
16 | copiedNode = result;
17 | copiedNode.children = [];
18 | } else {
19 | curNode.__parent.children = curNode.__parent.children || [];
20 | curNode.__parent.children.push(result);
21 | }
22 | if (curNode.childNodes && curNode.childNodes.length) {
23 | curNode.childNodes.forEach(n => n.__parent = result);
24 | queue = queue.concat(curNode.childNodes);
25 | }
26 | if (!result.children) {
27 | result.children = [];
28 | }
29 | }
30 | return copiedNode;
31 | }
32 |
33 | export function simplifyDomTree(node) {
34 | return traverse(node, simplify);
35 | }
36 |
37 |
38 |
--------------------------------------------------------------------------------
/packages/jsx-compiler/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jsx-compiler",
3 | "version": "0.4.33",
4 | "license": "BSD-3-Clause",
5 | "description": "Parser for Rax JSX Statements.",
6 | "files": [
7 | "src"
8 | ],
9 | "main": "src/index.js",
10 | "scripts": {
11 | "test": "jest --coverage --testPathIgnorePatterns=__modules__",
12 | "test:watch": "npm run test -- --watchAll"
13 | },
14 | "homepage": "https://github.com/raxjs/miniapp#readme",
15 | "engine": {
16 | "node": ">=8"
17 | },
18 | "author": "Rax Team",
19 | "dependencies": {
20 | "@babel/code-frame": "^7.0.0",
21 | "@babel/generator": "^7.3.4",
22 | "@babel/parser": "^7.3.4",
23 | "@babel/traverse": "^7.3.4",
24 | "@babel/types": "^7.3.4",
25 | "chalk": "^2.4.2",
26 | "css": "^2.2.4",
27 | "fs-extra": "^7.0.1",
28 | "kebab-case": "^1.0.0",
29 | "md5": "^2.2.1",
30 | "resolve": "^1.12.0"
31 | },
32 | "devDependencies": {
33 | "handlebars": "^4.5.0",
34 | "jest": "^24.5.0"
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/packages/miniapp-render/src/builtInComponents/live-pusher.js:
--------------------------------------------------------------------------------
1 | // eslint-disable-next-line import/no-extraneous-dependencies
2 | import { isMiniApp } from 'universal-env';
3 |
4 | const livePusher = {
5 | name: 'live-pusher',
6 | singleEvents: [{
7 | name: 'onLivePusherStateChange',
8 | eventName: 'statechange'
9 | }, {
10 | name: 'onLivePusherError',
11 | eventName: 'error'
12 | }, {
13 | name: 'onLivePusherNetStatus',
14 | eventName: 'netstatus'
15 | }]
16 | };
17 |
18 | if (!isMiniApp) {
19 | livePusher.singleEvents = livePusher.singleEvents.concat([
20 | {
21 | name: 'onLivePusherBgmStart',
22 | eventName: 'bgmstart'
23 | },
24 | {
25 | name: 'onLivePusherBgmProgress',
26 | eventName: 'bgmprogress'
27 | },
28 | {
29 | name: 'onLivePusherBgmComplete',
30 | eventName: 'bgmcomplete'
31 | },
32 | {
33 | name: 'onLivePusherAudioVolumeNofify',
34 | eventName: 'audiovolumenotify'
35 | }]);
36 | }
37 | export default livePusher;
38 |
--------------------------------------------------------------------------------
/examples/use-rax-compiled-component-in-runtime-miniapp/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "buildOnSave": false,
4 | "compilerOptions": {
5 | "baseUrl": ".",
6 | "outDir": "build",
7 | "module": "esnext",
8 | "target": "es6",
9 | "jsx": "preserve",
10 | "jsxFactory": "createElement",
11 | "moduleResolution": "node",
12 | "allowSyntheticDefaultImports": true,
13 | "lib": ["es6", "dom"],
14 | "sourceMap": true,
15 | "allowJs": true,
16 | "rootDir": "./",
17 | "forceConsistentCasingInFileNames": true,
18 | "noImplicitReturns": true,
19 | "noImplicitThis": true,
20 | "noImplicitAny": false,
21 | "importHelpers": true,
22 | "strictNullChecks": true,
23 | "suppressImplicitAnyIndexErrors": true,
24 | "noUnusedLocals": true,
25 | "skipLibCheck": true,
26 | "paths": {
27 | "@/*": ["./src/*"],
28 | "rax-app": [".rax/index.ts"]
29 | }
30 | },
31 | "include": ["src", ".rax"],
32 | "exclude": ["node_modules", "build", "public"]
33 | }
--------------------------------------------------------------------------------
/packages/jsx2mp-loader/src/utils/minifyCode.js:
--------------------------------------------------------------------------------
1 | const terser = require('terser');
2 | const csso = require('csso');
3 | const prettyData = require('pretty-data').pd;
4 |
5 | function minifyJS(source) {
6 | return terser.minify(source).code;
7 | }
8 |
9 | function minifyCSS(source) {
10 | return csso.minify(source, {
11 | restructure: false
12 | }).css;
13 | }
14 |
15 | function minifyXML(source) {
16 | return prettyData.xmlmin(source);
17 | }
18 |
19 | function minifyJSON(source) {
20 | return prettyData.json(source);
21 | }
22 |
23 | function minify(source, type = '.js') {
24 | if (type === '.js') {
25 | return minifyJS(source);
26 | }
27 | if (type === '.css') {
28 | return minifyCSS(source);
29 | }
30 | if (type === '.json') {
31 | return minifyJSON(source);
32 | }
33 | if (/\..*ml/.test(type)) {
34 | return minifyXML(source);
35 | }
36 |
37 | return source;
38 | }
39 |
40 | module.exports = {
41 | minify,
42 | minifyJS,
43 | minifyCSS,
44 | minifyXML,
45 | minifyJSON
46 | };
47 |
--------------------------------------------------------------------------------
/packages/eslint-plugin-rax-compile-time-miniapp/tests/test_no_return_arrays.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | // ------------------------------------------------------------------------------
4 | // Requirements
5 | // ------------------------------------------------------------------------------
6 |
7 | let rule = require('../src/rules/no_return_arrays');
8 |
9 | let RuleTester = require('eslint').RuleTester;
10 |
11 | let ruleTester = new RuleTester({
12 | parserOptions: {
13 | ecmaVersion: 10,
14 | ecmaFeatures: {
15 | jsx: true,
16 | },
17 | },
18 | });
19 |
20 | ruleTester.run('no-return-arrays', rule, {
21 | valid: [
22 | // 合法示例
23 | `function App(){
24 | return
25 | }`,
26 | ],
27 |
28 | invalid: [
29 | // 不合法示例
30 | {
31 | code: `
32 | function App(){
33 | return [, ]
34 | }`,
35 | errors: [
36 | {
37 | messageId: 'noReturnArrays',
38 | },
39 | ],
40 | },
41 | ],
42 | });
43 |
--------------------------------------------------------------------------------
/examples/get-element/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@rax-materials/scaffolds-app-js",
3 | "author": "rax",
4 | "description": "Rax 无线跨端应用工程,使用 JavaScript。",
5 | "version": "0.1.0",
6 | "scripts": {
7 | "build": "build-scripts build",
8 | "start": "build-scripts start",
9 | "lint": "eslint --ext .js --ext .jsx ./"
10 | },
11 | "dependencies": {
12 | "rax": "^1.1.0",
13 | "rax-app": "^2.0.0",
14 | "driver-universal": "^3.0.0",
15 | "rax-image": "^2.0.0",
16 | "rax-link": "^1.0.1",
17 | "rax-text": "^1.0.0",
18 | "rax-view": "^1.0.0",
19 | "rax-document": "^0.1.0"
20 | },
21 | "devDependencies": {
22 | "@alib/build-scripts": "^0.1.0",
23 | "babel-eslint": "^10.0.3",
24 | "build-plugin-rax-app": "^5.0.0",
25 | "eslint": "^6.8.0",
26 | "eslint-config-rax": "^0.1.0",
27 | "eslint-plugin-import": "^2.20.0",
28 | "eslint-plugin-module": "^0.1.0",
29 | "eslint-plugin-react": "^7.18.0"
30 | },
31 | "private": true,
32 | "originTemplate": "@rax-materials/scaffolds-app-js"
33 | }
34 |
--------------------------------------------------------------------------------
/packages/eslint-plugin-rax-compile-time-miniapp/src/rules/no_return_arrays.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @fileoverview no return arrays
3 | * @author hirra
4 | */
5 | 'use strict';
6 |
7 | const { docUrl } = require('../utils');
8 |
9 | module.exports = {
10 | meta: {
11 | docs: {
12 | description: 'no return arrays',
13 | url: docUrl('no_return_arrays'),
14 | recommended: false,
15 | },
16 | messages: {
17 | noReturnArrays: 'return jsx array is forbidden.',
18 | },
19 | },
20 |
21 | create: function(context) {
22 | return {
23 | ReturnStatement: (node) => {
24 | if (node.argument && node.argument.type == 'ArrayExpression') {
25 | if (
26 | node.argument.elements.filter((element) => {
27 | return element.type === 'JSXElement';
28 | }).length
29 | ) {
30 | context.report({
31 | node,
32 | messageId: 'noReturnArrays',
33 | });
34 | }
35 | }
36 | },
37 | };
38 | },
39 | };
40 |
--------------------------------------------------------------------------------
/packages/rax-miniapp-runtime-webpack-plugin/src/utils/minifyCode.js:
--------------------------------------------------------------------------------
1 | const terser = require('terser');
2 | const csso = require('csso');
3 | const prettyData = require('pretty-data').pd;
4 |
5 | function minifyJS(source) {
6 | return terser.minify(source).code;
7 | }
8 |
9 | function minifyCSS(source) {
10 | return csso.minify(source, {
11 | restructure: false
12 | }).css;
13 | }
14 |
15 | function minifyXML(source) {
16 | return prettyData.xmlmin(source);
17 | }
18 |
19 | function minifyJSON(source) {
20 | return prettyData.json(source);
21 | }
22 |
23 | function minify(source, type = '.js') {
24 | if (type === '.js') {
25 | return minifyJS(source);
26 | }
27 | if (type === '.css') {
28 | return minifyCSS(source);
29 | }
30 | if (type === '.json') {
31 | return minifyJSON(source);
32 | }
33 | if (/\..*ml/.test(type)) {
34 | return minifyXML(source);
35 | }
36 |
37 | return source;
38 | }
39 |
40 | module.exports = {
41 | minify,
42 | minifyJS,
43 | minifyCSS,
44 | minifyXML,
45 | minifyJSON
46 | };
47 |
--------------------------------------------------------------------------------
/examples/app-lifecycle/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@rax-materials/scaffolds-app-js",
3 | "author": "rax",
4 | "description": "Rax 无线跨端应用工程,使用 JavaScript。",
5 | "version": "0.1.0",
6 | "scripts": {
7 | "build": "build-scripts build",
8 | "start": "build-scripts start",
9 | "lint": "eslint --ext .js --ext .jsx ./"
10 | },
11 | "dependencies": {
12 | "rax": "^1.1.0",
13 | "rax-app": "^2.0.0",
14 | "driver-universal": "^3.0.0",
15 | "rax-image": "^2.0.0",
16 | "rax-link": "^1.0.1",
17 | "rax-text": "^1.0.0",
18 | "rax-view": "^1.0.0",
19 | "rax-document": "^0.1.0"
20 | },
21 | "devDependencies": {
22 | "@alib/build-scripts": "^0.1.0",
23 | "babel-eslint": "^10.0.3",
24 | "build-plugin-rax-app": "^5.0.0",
25 | "eslint": "^6.8.0",
26 | "eslint-config-rax": "^0.1.0",
27 | "eslint-plugin-import": "^2.20.0",
28 | "eslint-plugin-module": "^0.1.0",
29 | "eslint-plugin-react": "^7.18.0"
30 | },
31 | "private": true,
32 | "originTemplate": "@rax-materials/scaffolds-app-js"
33 | }
34 |
--------------------------------------------------------------------------------
/examples/event-handler/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@rax-materials/scaffolds-app-js",
3 | "author": "rax",
4 | "description": "Rax 无线跨端应用工程,使用 JavaScript。",
5 | "version": "0.1.0",
6 | "scripts": {
7 | "build": "build-scripts build",
8 | "start": "build-scripts start",
9 | "lint": "eslint --ext .js --ext .jsx ./"
10 | },
11 | "dependencies": {
12 | "rax": "^1.1.0",
13 | "rax-app": "^2.0.0",
14 | "driver-universal": "^3.0.0",
15 | "rax-image": "^2.0.0",
16 | "rax-link": "^1.0.1",
17 | "rax-text": "^1.0.0",
18 | "rax-view": "^1.0.0",
19 | "rax-document": "^0.1.0"
20 | },
21 | "devDependencies": {
22 | "@alib/build-scripts": "^0.1.0",
23 | "babel-eslint": "^10.0.3",
24 | "build-plugin-rax-app": "^5.0.0",
25 | "eslint": "^6.8.0",
26 | "eslint-config-rax": "^0.1.0",
27 | "eslint-plugin-import": "^2.20.0",
28 | "eslint-plugin-module": "^0.1.0",
29 | "eslint-plugin-react": "^7.18.0"
30 | },
31 | "private": true,
32 | "originTemplate": "@rax-materials/scaffolds-app-js"
33 | }
34 |
--------------------------------------------------------------------------------
/examples/page-lifecycle-with-router/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@rax-materials/scaffolds-app-js",
3 | "author": "rax",
4 | "description": "Rax 无线跨端应用工程,使用 JavaScript。",
5 | "version": "0.1.0",
6 | "scripts": {
7 | "build": "build-scripts build",
8 | "start": "build-scripts start",
9 | "lint": "eslint --ext .js --ext .jsx ./"
10 | },
11 | "dependencies": {
12 | "rax": "^1.1.0",
13 | "rax-app": "^2.0.0",
14 | "driver-universal": "^3.0.0",
15 | "rax-image": "^2.0.0",
16 | "rax-link": "^1.0.1",
17 | "rax-text": "^1.0.0",
18 | "rax-view": "^1.0.0",
19 | "rax-document": "^0.1.0"
20 | },
21 | "devDependencies": {
22 | "@alib/build-scripts": "^0.1.0",
23 | "babel-eslint": "^10.0.3",
24 | "build-plugin-rax-app": "^5.0.0",
25 | "eslint": "^6.8.0",
26 | "eslint-config-rax": "^0.1.0",
27 | "eslint-plugin-import": "^2.20.0",
28 | "eslint-plugin-module": "^0.1.0",
29 | "eslint-plugin-react": "^7.18.0"
30 | },
31 | "private": true,
32 | "originTemplate": "@rax-materials/scaffolds-app-js"
33 | }
34 |
--------------------------------------------------------------------------------