├── .editorconfig ├── .fecsignore ├── .github └── issue_template.md ├── .gitignore ├── .npmrc ├── .travis.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── babel.config.js ├── commitlint.config.js ├── docs ├── .gitignore ├── .nojekyll ├── CHANGELOG.md ├── README.md ├── _navbar.md ├── _sidebar.md ├── advance │ ├── http.md │ ├── language.md │ ├── mock.md │ ├── platformSpecCode.md │ ├── redux.md │ ├── rpx.md │ ├── subPackages.md │ └── vuex.md ├── api │ ├── build.md │ └── global.md ├── app │ ├── entry.md │ ├── intercept.md │ ├── project.md │ └── promise.md ├── asset │ ├── docsify.min.js │ ├── search.min.js │ └── vue.css ├── build │ ├── implementation.md │ ├── index.md │ ├── plugin.md │ ├── processors.md │ └── transformTag.md ├── component │ ├── broadcast.md │ ├── component.md │ ├── filter.md │ ├── mixins.md │ ├── nativeComponent.md │ ├── nativeSupport.md │ ├── page.md │ ├── ref.md │ ├── setData.md │ ├── sfc.md │ ├── transform.md │ └── ui.md ├── favicon.ico ├── img │ ├── my.showToast.png │ ├── qr │ │ ├── ems.png │ │ ├── jiandanfanyi.jpg │ │ └── jianjianya.png │ ├── template_demo.png │ ├── wx.showToast.png │ ├── wx_async_default_error.png │ ├── wx_multiple_pages_error.png │ └── wx_regnerator_runtime_error.png ├── index.html ├── intro │ ├── compare.md │ ├── index.md │ └── quickStart.md ├── plugins │ └── imgCompress.md ├── questions │ ├── index.md │ └── problems.md └── template │ ├── condition.md │ ├── event.md │ ├── for.md │ ├── styleBinding.md │ ├── syntax.md │ ├── use.md │ ├── v-html.md │ ├── v-model.md │ └── vueSyntax.md ├── lerna.json ├── package-lock.json ├── package.json ├── packages ├── okam-build │ ├── .babelrc.js │ ├── .fecsignore │ ├── .fecsrc │ ├── .gitignore │ ├── .npmignore │ ├── README.md │ ├── example │ │ ├── base │ │ │ ├── .frameworkinfo │ │ │ ├── README.md │ │ │ ├── dep │ │ │ │ └── a.js │ │ │ ├── package.json │ │ │ ├── project.json5 │ │ │ ├── scripts │ │ │ │ ├── ant.config.js │ │ │ │ ├── base.config.js │ │ │ │ ├── build.js │ │ │ │ ├── init-quick-app.js │ │ │ │ ├── quick.config.js │ │ │ │ ├── swan.config.js │ │ │ │ ├── tt.config.js │ │ │ │ └── wx.config.js │ │ │ └── src │ │ │ │ ├── actions │ │ │ │ ├── index.js │ │ │ │ ├── todo.js │ │ │ │ └── type.js │ │ │ │ ├── app.js │ │ │ │ ├── app.styl │ │ │ │ ├── common │ │ │ │ ├── behavior │ │ │ │ │ ├── behaviorA.js │ │ │ │ │ ├── behaviorB.js │ │ │ │ │ ├── behaviorC.js │ │ │ │ │ ├── behaviorD.js │ │ │ │ │ └── util.js │ │ │ │ ├── css │ │ │ │ │ ├── base.styl │ │ │ │ │ ├── common.css │ │ │ │ │ ├── font.eot │ │ │ │ │ ├── font.less │ │ │ │ │ └── icon.styl │ │ │ │ ├── font │ │ │ │ │ ├── bdfont.eot │ │ │ │ │ ├── bdfont.svg │ │ │ │ │ ├── bdfont.ttf │ │ │ │ │ └── bdfont.woff │ │ │ │ ├── img │ │ │ │ │ ├── a.gif │ │ │ │ │ ├── close.png │ │ │ │ │ ├── component.png │ │ │ │ │ ├── data.png │ │ │ │ │ ├── goto.png │ │ │ │ │ ├── js.png │ │ │ │ │ ├── logo.png │ │ │ │ │ ├── more.png │ │ │ │ │ ├── okm.png │ │ │ │ │ ├── open.png │ │ │ │ │ ├── performance.png │ │ │ │ │ ├── template.png │ │ │ │ │ └── ui.png │ │ │ │ ├── js │ │ │ │ │ └── tstest.ts │ │ │ │ ├── tpl │ │ │ │ │ ├── footer.tpl │ │ │ │ │ └── include.tpl │ │ │ │ ├── ts │ │ │ │ │ ├── Employee.ts │ │ │ │ │ └── Person.ts │ │ │ │ └── util.js │ │ │ │ ├── components │ │ │ │ ├── BehaviorComponent.vue │ │ │ │ ├── BroadcastComponent.vue │ │ │ │ ├── Counter.vue │ │ │ │ ├── DataComponent.vue │ │ │ │ ├── Hello.vue │ │ │ │ ├── ModelComponent.vue │ │ │ │ ├── MyComponent.vue │ │ │ │ ├── OkamHello.vue │ │ │ │ ├── SimpleComponent.vue │ │ │ │ ├── SimpleComponent2.vue │ │ │ │ ├── SpModelComponent.vue │ │ │ │ └── quick │ │ │ │ │ └── Button.vue │ │ │ │ ├── packageA │ │ │ │ └── pages │ │ │ │ │ └── subPageA │ │ │ │ │ └── index.vue │ │ │ │ ├── packageB │ │ │ │ └── pages │ │ │ │ │ └── subPageB │ │ │ │ │ └── index.vue │ │ │ │ ├── pages │ │ │ │ ├── behavior │ │ │ │ │ └── index.vue │ │ │ │ ├── broadcast │ │ │ │ │ └── index.vue │ │ │ │ ├── component │ │ │ │ │ ├── canvas.vue │ │ │ │ │ └── componentPage.vue │ │ │ │ ├── data │ │ │ │ │ ├── array.vue │ │ │ │ │ ├── computed.vue │ │ │ │ │ ├── init.vue │ │ │ │ │ ├── model.vue │ │ │ │ │ ├── vhtml.vue │ │ │ │ │ └── watch.vue │ │ │ │ ├── filter │ │ │ │ │ ├── FilterComponent.vue │ │ │ │ │ └── index.vue │ │ │ │ ├── home │ │ │ │ │ └── index.vue │ │ │ │ ├── lifecycle │ │ │ │ │ └── index.vue │ │ │ │ ├── performance │ │ │ │ │ └── oninit.vue │ │ │ │ ├── sfc │ │ │ │ │ ├── index.vue │ │ │ │ │ ├── script.js │ │ │ │ │ ├── separate.vue │ │ │ │ │ ├── style.styl │ │ │ │ │ └── view.tpl │ │ │ │ ├── todos │ │ │ │ │ ├── counter.vue │ │ │ │ │ └── todoList.vue │ │ │ │ ├── tpl │ │ │ │ │ ├── ref.vue │ │ │ │ │ ├── tplNewline.vue │ │ │ │ │ ├── tplPug.vue │ │ │ │ │ ├── tplReuse.vue │ │ │ │ │ ├── tplSyntax.vue │ │ │ │ │ └── vueSyntax.vue │ │ │ │ └── typescript │ │ │ │ │ ├── dep.less │ │ │ │ │ └── ts.vue │ │ │ │ ├── reducers │ │ │ │ ├── counter.js │ │ │ │ ├── index.js │ │ │ │ ├── todos.js │ │ │ │ ├── userInfo.js │ │ │ │ └── utils.js │ │ │ │ ├── services │ │ │ │ └── todo.js │ │ │ │ └── store │ │ │ │ └── index.js │ │ ├── components │ │ │ ├── ant-native │ │ │ │ ├── README.md │ │ │ │ ├── package.json │ │ │ │ ├── project.json5 │ │ │ │ ├── scripts │ │ │ │ │ ├── ant.config.js │ │ │ │ │ └── build.js │ │ │ │ └── src │ │ │ │ │ ├── app.css │ │ │ │ │ ├── app.js │ │ │ │ │ ├── components │ │ │ │ │ ├── add-button │ │ │ │ │ │ ├── add-button.acss │ │ │ │ │ │ ├── add-button.axml │ │ │ │ │ │ ├── add-button.js │ │ │ │ │ │ └── add-button.json │ │ │ │ │ └── hello │ │ │ │ │ │ ├── hello.acss │ │ │ │ │ │ ├── hello.axml │ │ │ │ │ │ ├── hello.js │ │ │ │ │ │ └── hello.json │ │ │ │ │ ├── filters │ │ │ │ │ ├── string.sjs │ │ │ │ │ └── util.sjs │ │ │ │ │ └── pages │ │ │ │ │ ├── filter.vue │ │ │ │ │ └── index.vue │ │ │ ├── iview │ │ │ │ ├── .fecsignore │ │ │ │ ├── .gitignore │ │ │ │ ├── README.md │ │ │ │ ├── package.json │ │ │ │ ├── project.json5 │ │ │ │ ├── scripts │ │ │ │ │ ├── base.config.js │ │ │ │ │ ├── build.js │ │ │ │ │ ├── swan.config.js │ │ │ │ │ └── wx.config.js │ │ │ │ └── src │ │ │ │ │ ├── app.js │ │ │ │ │ ├── app.styl │ │ │ │ │ └── pages │ │ │ │ │ ├── button │ │ │ │ │ ├── index.js │ │ │ │ │ ├── index.json │ │ │ │ │ ├── index.wxml │ │ │ │ │ └── index.wxss │ │ │ │ │ └── index.vue │ │ │ ├── native │ │ │ │ ├── README.md │ │ │ │ ├── package.json │ │ │ │ ├── project.json5 │ │ │ │ ├── scripts │ │ │ │ │ ├── base.config.js │ │ │ │ │ ├── build.js │ │ │ │ │ ├── swan.config.js │ │ │ │ │ └── wx.config.js │ │ │ │ └── src │ │ │ │ │ ├── app.css │ │ │ │ │ ├── app.js │ │ │ │ │ ├── components │ │ │ │ │ ├── Hello.css │ │ │ │ │ ├── Hello.js │ │ │ │ │ ├── Hello.json │ │ │ │ │ ├── Hello.swan │ │ │ │ │ ├── Hi │ │ │ │ │ │ ├── index.js │ │ │ │ │ │ ├── index.json │ │ │ │ │ │ └── index.swan │ │ │ │ │ ├── Simple.css │ │ │ │ │ ├── Simple.js │ │ │ │ │ ├── Simple.json │ │ │ │ │ ├── Simple.swan │ │ │ │ │ ├── SimpleSfc.vue │ │ │ │ │ └── WxComp │ │ │ │ │ │ ├── index.js │ │ │ │ │ │ ├── index.json │ │ │ │ │ │ ├── index.wxml │ │ │ │ │ │ └── index.wxs │ │ │ │ │ ├── filter │ │ │ │ │ ├── string.filter.js │ │ │ │ │ └── util.filter.js │ │ │ │ │ └── pages │ │ │ │ │ ├── index.vue │ │ │ │ │ ├── swanFilter.vue │ │ │ │ │ ├── swanNative │ │ │ │ │ ├── index.css │ │ │ │ │ ├── index.js │ │ │ │ │ ├── index.json │ │ │ │ │ └── index.swan │ │ │ │ │ ├── wxNative │ │ │ │ │ ├── index.js │ │ │ │ │ ├── index.json │ │ │ │ │ ├── index.wxml │ │ │ │ │ └── index.wxss │ │ │ │ │ └── wxWxs.vue │ │ │ ├── wux │ │ │ │ ├── .gitignore │ │ │ │ ├── README.md │ │ │ │ ├── package.json │ │ │ │ ├── project.json5 │ │ │ │ ├── scripts │ │ │ │ │ ├── build.js │ │ │ │ │ ├── swan.config.js │ │ │ │ │ └── wx.config.js │ │ │ │ └── src │ │ │ │ │ ├── app.css │ │ │ │ │ ├── app.js │ │ │ │ │ └── pages │ │ │ │ │ └── index.vue │ │ │ ├── wx │ │ │ │ ├── README.md │ │ │ │ ├── package.json │ │ │ │ ├── project.json5 │ │ │ │ ├── scripts │ │ │ │ │ ├── build.js │ │ │ │ │ └── wx.config.js │ │ │ │ └── src │ │ │ │ │ ├── app.css │ │ │ │ │ ├── app.js │ │ │ │ │ ├── filter │ │ │ │ │ ├── string.wxs │ │ │ │ │ └── util.wxs │ │ │ │ │ └── pages │ │ │ │ │ └── wxFilter.vue │ │ │ └── youzan │ │ │ │ ├── .gitignore │ │ │ │ ├── README.md │ │ │ │ ├── package.json │ │ │ │ ├── project.json5 │ │ │ │ ├── scripts │ │ │ │ ├── base.config.js │ │ │ │ ├── build.js │ │ │ │ ├── swan.config.js │ │ │ │ └── wx.config.js │ │ │ │ └── src │ │ │ │ ├── app.js │ │ │ │ ├── app.styl │ │ │ │ ├── components │ │ │ │ └── DemoBlock.vue │ │ │ │ └── pages │ │ │ │ ├── button │ │ │ │ └── index.vue │ │ │ │ └── index.vue │ │ └── test │ │ │ ├── .editorconfig │ │ │ ├── .fecsignore │ │ │ ├── .fecsrc │ │ │ ├── .gitignore │ │ │ ├── .npmignore │ │ │ ├── .tinyimgcache │ │ │ ├── README.md │ │ │ ├── package.json │ │ │ ├── project.json5 │ │ │ ├── scripts │ │ │ ├── ant.config.js │ │ │ ├── base.config.js │ │ │ ├── build.js │ │ │ ├── init-quick-app.js │ │ │ ├── quick.config.js │ │ │ ├── swan.config.js │ │ │ ├── tt.config.js │ │ │ └── wx.config.js │ │ │ └── src │ │ │ ├── app.css │ │ │ ├── app.js │ │ │ ├── common │ │ │ ├── css │ │ │ │ ├── b.css │ │ │ │ └── common.css │ │ │ ├── img │ │ │ │ └── okm.png │ │ │ └── tpl │ │ │ │ └── footer.tpl │ │ │ ├── components │ │ │ └── Hello.vue │ │ │ ├── pages │ │ │ ├── home │ │ │ │ ├── index.vue │ │ │ │ ├── sfc.vue │ │ │ │ └── styl.vue │ │ │ ├── sfc │ │ │ │ ├── script.js │ │ │ │ ├── sfc.vue │ │ │ │ ├── style.styl │ │ │ │ └── view.tpl │ │ │ └── syntax │ │ │ │ └── index.vue │ │ │ └── sfc │ │ │ ├── script.js │ │ │ ├── style.styl │ │ │ └── tpl.tpl │ ├── index.js │ ├── lib │ │ ├── build │ │ │ ├── BuildManager.js │ │ │ ├── CacheManager.js │ │ │ ├── ModuleResolver.js │ │ │ ├── ant │ │ │ │ ├── index.js │ │ │ │ └── init-native-ant-processor.js │ │ │ ├── app-type.js │ │ │ ├── build-hook.js │ │ │ ├── clean-build.js │ │ │ ├── global-component.js │ │ │ ├── index.js │ │ │ ├── init-build-options.js │ │ │ ├── load-process-files.js │ │ │ ├── quick │ │ │ │ └── index.js │ │ │ ├── run-build.js │ │ │ ├── swan │ │ │ │ ├── build-info.js │ │ │ │ ├── index.js │ │ │ │ ├── init-native-swan-processor.js │ │ │ │ └── init-wx2swan-processor.js │ │ │ ├── tt │ │ │ │ └── index.js │ │ │ └── wx │ │ │ │ └── index.js │ │ ├── config │ │ │ ├── ant.js │ │ │ ├── base.js │ │ │ ├── quick.js │ │ │ ├── swan.js │ │ │ ├── tt.js │ │ │ └── wx.js │ │ ├── framework.js │ │ ├── generator │ │ │ └── FileOutput.js │ │ ├── polyfill │ │ │ ├── normalize.js │ │ │ └── prepare.js │ │ ├── processor │ │ │ ├── FileFactory.js │ │ │ ├── component │ │ │ │ ├── helper.js │ │ │ │ ├── sfc-parser.js │ │ │ │ ├── ux-generator.js │ │ │ │ └── ux-parser.js │ │ │ ├── css │ │ │ │ ├── add-css-dependencies.js │ │ │ │ ├── less.js │ │ │ │ ├── plugins │ │ │ │ │ ├── helper.js │ │ │ │ │ ├── match-media-params.js │ │ │ │ │ ├── postcss-plugin-env.js │ │ │ │ │ ├── postcss-plugin-px2rpx.js │ │ │ │ │ ├── postcss-plugin-quickcss.js │ │ │ │ │ ├── postcss-plugin-resource.js │ │ │ │ │ └── postcss-plugin-wx2swan.js │ │ │ │ ├── postcss.js │ │ │ │ ├── sass.js │ │ │ │ └── stylus.js │ │ │ ├── helper │ │ │ │ ├── builtin.js │ │ │ │ ├── component.js │ │ │ │ ├── config.js │ │ │ │ ├── init-babel.js │ │ │ │ ├── init-view.js │ │ │ │ ├── npm.js │ │ │ │ ├── processor.js │ │ │ │ ├── px2rpx.js │ │ │ │ ├── url.js │ │ │ │ └── wxs2filter.js │ │ │ ├── index.js │ │ │ ├── js │ │ │ │ ├── babel-parser-helper.js │ │ │ │ ├── babel-parser.js │ │ │ │ ├── babel7-parser.js │ │ │ │ ├── plugins │ │ │ │ │ ├── babel-native-ant-plugin.js │ │ │ │ │ ├── babel-native-swan-plugin.js │ │ │ │ │ ├── babel-polyfill-plugins.js │ │ │ │ │ ├── babel-program-plugins.js │ │ │ │ │ └── babel-wx2swan-plugin.js │ │ │ │ ├── polyfill │ │ │ │ │ ├── async.js │ │ │ │ │ ├── helper.js │ │ │ │ │ └── promise.js │ │ │ │ ├── transform │ │ │ │ │ ├── app.js │ │ │ │ │ ├── component.js │ │ │ │ │ ├── dep.js │ │ │ │ │ ├── filter.js │ │ │ │ │ ├── helper.js │ │ │ │ │ ├── native-component.js │ │ │ │ │ └── visitor.js │ │ │ │ └── typescript-parser.js │ │ │ ├── json │ │ │ │ ├── component-json.js │ │ │ │ ├── config-json.js │ │ │ │ ├── json5-parser.js │ │ │ │ └── quick-app-json.js │ │ │ ├── replacement.js │ │ │ ├── template │ │ │ │ ├── index.js │ │ │ │ ├── parser │ │ │ │ │ └── index.js │ │ │ │ ├── plugins │ │ │ │ │ ├── event │ │ │ │ │ │ ├── ant-event-plugin.js │ │ │ │ │ │ ├── event-helper.js │ │ │ │ │ │ ├── quick-event-plugin.js │ │ │ │ │ │ ├── swan-event-plugin.js │ │ │ │ │ │ ├── tt-event-plugin.js │ │ │ │ │ │ └── wx-event-plugin.js │ │ │ │ │ ├── filter │ │ │ │ │ │ ├── ant-filter-plugin.js │ │ │ │ │ │ ├── filter-helper.js │ │ │ │ │ │ ├── quick-filter-plugin.js │ │ │ │ │ │ ├── swan-filter-plugin.js │ │ │ │ │ │ └── wx-filter-plugin.js │ │ │ │ │ ├── helper.js │ │ │ │ │ ├── model │ │ │ │ │ │ ├── ant-model-plugin.js │ │ │ │ │ │ ├── model-helper.js │ │ │ │ │ │ ├── quick-model-plugin.js │ │ │ │ │ │ ├── swan-model-plugin.js │ │ │ │ │ │ ├── tt-model-plugin.js │ │ │ │ │ │ └── wx-model-plugin.js │ │ │ │ │ ├── ref-plugin.js │ │ │ │ │ ├── resource-plugin.js │ │ │ │ │ ├── syntax │ │ │ │ │ │ ├── ant-syntax-plugin.js │ │ │ │ │ │ ├── quick-syntax-plugin.js │ │ │ │ │ │ ├── swan-syntax-plugin.js │ │ │ │ │ │ ├── tt-syntax-plugin.js │ │ │ │ │ │ ├── wx-syntax-plugin.js │ │ │ │ │ │ └── wx2swan-syntax-plugin.js │ │ │ │ │ ├── tag-transform-plugin.js │ │ │ │ │ ├── v-html-plugin.js │ │ │ │ │ └── vue-prefix-plugin.js │ │ │ │ ├── pug.js │ │ │ │ ├── serializer │ │ │ │ │ ├── bool-attributes.js │ │ │ │ │ ├── index.js │ │ │ │ │ ├── selfclose-tags.js │ │ │ │ │ └── unencoded-tags.js │ │ │ │ └── transform │ │ │ │ │ ├── ant │ │ │ │ │ ├── canvas.js │ │ │ │ │ ├── class.js │ │ │ │ │ ├── condition.js │ │ │ │ │ ├── for.js │ │ │ │ │ ├── index.js │ │ │ │ │ ├── key.js │ │ │ │ │ └── tpl.js │ │ │ │ │ ├── base │ │ │ │ │ ├── attribute.js │ │ │ │ │ ├── class.js │ │ │ │ │ ├── condition.js │ │ │ │ │ ├── constant.js │ │ │ │ │ ├── data-bind.js │ │ │ │ │ ├── element.js │ │ │ │ │ ├── env.js │ │ │ │ │ ├── event.js │ │ │ │ │ ├── filter.js │ │ │ │ │ ├── for-if.js │ │ │ │ │ ├── for.js │ │ │ │ │ ├── helper.js │ │ │ │ │ ├── index.js │ │ │ │ │ ├── key.js │ │ │ │ │ ├── style.js │ │ │ │ │ └── tpl.js │ │ │ │ │ ├── helper │ │ │ │ │ └── style.js │ │ │ │ │ ├── quick │ │ │ │ │ ├── button.js │ │ │ │ │ ├── class.js │ │ │ │ │ ├── condition.js │ │ │ │ │ ├── for.js │ │ │ │ │ ├── include.js │ │ │ │ │ ├── index.js │ │ │ │ │ ├── key.js │ │ │ │ │ ├── text.js │ │ │ │ │ └── tpl.js │ │ │ │ │ ├── swan │ │ │ │ │ ├── condition.js │ │ │ │ │ ├── data-bind.js │ │ │ │ │ ├── for.js │ │ │ │ │ ├── index.js │ │ │ │ │ └── key.js │ │ │ │ │ ├── tt │ │ │ │ │ ├── class.js │ │ │ │ │ ├── condition.js │ │ │ │ │ ├── data-bind.js │ │ │ │ │ ├── for.js │ │ │ │ │ ├── index.js │ │ │ │ │ ├── key.js │ │ │ │ │ └── tpl.js │ │ │ │ │ ├── wx │ │ │ │ │ ├── condition.js │ │ │ │ │ ├── data-bind.js │ │ │ │ │ ├── for.js │ │ │ │ │ ├── index.js │ │ │ │ │ ├── key.js │ │ │ │ │ └── tpl.js │ │ │ │ │ └── wx2swan │ │ │ │ │ ├── attribute.js │ │ │ │ │ ├── constant.js │ │ │ │ │ ├── directives.js │ │ │ │ │ ├── element.js │ │ │ │ │ ├── forIf.js │ │ │ │ │ ├── index.js │ │ │ │ │ └── wxs.js │ │ │ └── type.js │ │ ├── server │ │ │ ├── ConnectServer.js │ │ │ ├── ExpressServer.js │ │ │ ├── KoaServer.js │ │ │ ├── ServerBase.js │ │ │ ├── index.js │ │ │ └── net.js │ │ ├── util │ │ │ ├── babel.js │ │ │ ├── index.js │ │ │ └── tag-tansform-helper.js │ │ └── watch │ │ │ ├── FileMonitor.js │ │ │ ├── index.js │ │ │ └── watch-handler.js │ ├── package-lock.json │ ├── package.json │ └── test │ │ ├── fixtures │ │ ├── condition │ │ │ ├── condition.expect.tpl │ │ │ ├── condition.tpl │ │ │ ├── v-condition.expect.tpl │ │ │ └── v-condition.tpl │ │ ├── filters │ │ │ ├── test.babel6.expect │ │ │ ├── test.babel7.expect │ │ │ └── test.js │ │ ├── for-and-if │ │ │ ├── for-and-if.expect.tpl │ │ │ ├── for-and-if.tpl │ │ │ ├── wx2swan.expect.swan │ │ │ └── wx2swan.wxml │ │ ├── for │ │ │ ├── v-for.expect.tpl │ │ │ └── v-for.tpl │ │ ├── model │ │ │ ├── model-conflict-ant.expect.tpl │ │ │ ├── model-conflict-swan.expect.tpl │ │ │ ├── model-conflict-wx.expect.tpl │ │ │ ├── model-conflict.tpl │ │ │ ├── model-nosupport-ant.expect.tpl │ │ │ ├── model-nosupport-swan.expect.tpl │ │ │ ├── model-nosupport-wx.expect.tpl │ │ │ ├── model-nosupport.tpl │ │ │ ├── model-support-ant.expect.tpl │ │ │ ├── model-support-swan.expect.tpl │ │ │ ├── model-support-wx.expect.tpl │ │ │ └── model-support.tpl │ │ ├── result.tpl │ │ ├── template │ │ │ ├── attribute.expect.swan │ │ │ ├── attribute.wxml │ │ │ ├── element.expect.swan │ │ │ └── element.wxml │ │ ├── templateSerialize │ │ │ ├── autoClose.expect.tpl │ │ │ ├── autoClose.tpl │ │ │ ├── boolAttribute.expect.tpl │ │ │ ├── boolAttribute.tpl │ │ │ ├── removeVoidEndTag.expect.tpl │ │ │ └── removeVoidEndTag.tpl │ │ └── vhtml │ │ │ ├── vhtml.expect.tpl │ │ │ └── vhtml.tpl │ │ └── tasks │ │ ├── helper.js │ │ ├── processor │ │ ├── css │ │ │ └── postcss │ │ │ │ └── match-media-params.spec.js │ │ ├── js │ │ │ └── transform │ │ │ │ └── filter.spec.js │ │ └── template │ │ │ ├── pug.spec.js │ │ │ ├── serializer │ │ │ └── templateSerialize.spec.js │ │ │ └── transform │ │ │ ├── ant │ │ │ └── model.spec.js │ │ │ ├── base │ │ │ ├── class.spec.js │ │ │ ├── constant.spec.js │ │ │ ├── data-binding.spec.js │ │ │ ├── event.spec.js │ │ │ ├── filter.spec.js │ │ │ ├── for-and-if.spec.js │ │ │ ├── style.spec.js │ │ │ ├── tag-transform.spec.js │ │ │ ├── tag.spec.js │ │ │ ├── template.spec.js │ │ │ ├── tpl.spec.js │ │ │ ├── v-html.spec.js │ │ │ └── v-prefix.spec.js │ │ │ ├── swan │ │ │ ├── condition.spec.js │ │ │ ├── for.spec.js │ │ │ └── model.spec.js │ │ │ ├── wx │ │ │ ├── for.spec.js │ │ │ └── model.spec.js │ │ │ └── wx2swan │ │ │ ├── attribute.spec.js │ │ │ ├── element.spec.js │ │ │ └── forIf.spec.js │ │ └── util │ │ └── index.spec.js ├── okam-cli │ ├── .babelrc.js │ ├── .fecsignore │ ├── .fecsrc │ ├── .gitignore │ ├── .npmignore │ ├── README.md │ ├── bin │ │ ├── okam │ │ ├── okam-init │ │ └── okam-upgrade │ ├── index.js │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── Project.js │ │ ├── download.js │ │ └── utils │ │ │ ├── etpl.js │ │ │ ├── index.js │ │ │ └── prompts.js │ └── templates │ │ ├── base │ │ ├── README.md │ │ ├── dotFilesAll │ │ │ ├── editorconfig │ │ │ ├── gitignore │ │ │ └── npmignore │ │ ├── dotFilesESlint │ │ │ └── eslintrc.json │ │ ├── dotFilesFecs │ │ │ ├── fecsignore │ │ │ └── fecsrc │ │ ├── packagejson │ │ ├── project.json5 │ │ ├── reduxSrc │ │ │ ├── actions │ │ │ │ ├── counter.js │ │ │ │ └── index.js │ │ │ ├── components │ │ │ │ └── Counter.okm │ │ │ ├── constants │ │ │ │ └── counter.js │ │ │ ├── pages │ │ │ │ └── counter │ │ │ │ │ └── index.okm │ │ │ ├── reducers │ │ │ │ ├── counter.js │ │ │ │ └── index.js │ │ │ └── store │ │ │ │ └── index.js │ │ ├── scripts │ │ │ ├── ant.config.js │ │ │ ├── base.config.js │ │ │ ├── build.js │ │ │ ├── init-quick-app.js │ │ │ ├── quick.config.js │ │ │ ├── swan.config.js │ │ │ ├── tt.config.js │ │ │ └── wx.config.js │ │ └── src │ │ │ ├── app.js │ │ │ ├── app.styl │ │ │ ├── common │ │ │ ├── css │ │ │ │ └── common.styl │ │ │ ├── img │ │ │ │ └── okm.png │ │ │ └── tpl │ │ │ │ └── footer.tpl │ │ │ ├── components │ │ │ ├── Hello.okm │ │ │ └── quick │ │ │ │ └── Button.okm │ │ │ └── pages │ │ │ └── home │ │ │ └── index.okm │ │ ├── index.js │ │ └── onlineTemplate.js ├── okam-component │ ├── .babelrc.js │ ├── .fecsignore │ ├── .fecsrc │ ├── .gitignore │ ├── .npmignore │ ├── README.md │ ├── example │ │ └── quick │ │ │ ├── .eslintrc.json │ │ │ ├── .gitignore │ │ │ ├── babel.config.js │ │ │ ├── package.json │ │ │ ├── sign │ │ │ └── debug │ │ │ │ ├── certificate.pem │ │ │ │ └── private.pem │ │ │ └── src │ │ │ ├── About │ │ │ └── index.ux │ │ │ ├── Button │ │ │ ├── index.ux │ │ │ ├── loading.png │ │ │ ├── loading2.png │ │ │ └── logo.png │ │ │ ├── CardDemo │ │ │ └── index.ux │ │ │ ├── Common │ │ │ └── logo.png │ │ │ ├── Demo │ │ │ └── index.ux │ │ │ ├── DemoDetail │ │ │ └── index.ux │ │ │ ├── app.ux │ │ │ ├── components │ │ │ ├── Hello.ux │ │ │ └── quick │ │ │ ├── manifest.json │ │ │ └── util.js │ ├── index.js │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── quick │ │ │ └── button │ │ │ ├── index.less │ │ │ ├── index.ux │ │ │ └── loading.png │ └── test │ │ └── tasks │ │ └── test.spec.js ├── okam-core │ ├── .babelrc.js │ ├── .fecsignore │ ├── .fecsrc │ ├── .gitignore │ ├── .npmignore │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── App.js │ │ ├── ant │ │ │ ├── App.js │ │ │ ├── Component.js │ │ │ ├── Page.js │ │ │ ├── adapter │ │ │ │ └── component.js │ │ │ ├── api.js │ │ │ ├── base │ │ │ │ └── component.js │ │ │ ├── env.js │ │ │ └── helper │ │ │ │ ├── component.js │ │ │ │ └── triggerEvent.js │ │ ├── base │ │ │ ├── application.js │ │ │ ├── base.js │ │ │ ├── component.js │ │ │ ├── init-api.js │ │ │ └── page.js │ │ ├── extend │ │ │ ├── behavior │ │ │ │ ├── Behavior.js │ │ │ │ ├── ant │ │ │ │ │ ├── Behavior.js │ │ │ │ │ └── index.js │ │ │ │ ├── helper.js │ │ │ │ ├── index.js │ │ │ │ ├── override.js │ │ │ │ ├── quick │ │ │ │ │ ├── Behavior.js │ │ │ │ │ └── index.js │ │ │ │ └── strategy.js │ │ │ ├── broadcast │ │ │ │ ├── index.js │ │ │ │ └── quick │ │ │ │ │ └── index.js │ │ │ ├── data │ │ │ │ ├── equal.js │ │ │ │ ├── model.js │ │ │ │ ├── observable │ │ │ │ │ ├── ComputedObserver.js │ │ │ │ │ ├── Observer.js │ │ │ │ │ ├── ant │ │ │ │ │ │ ├── array.js │ │ │ │ │ │ └── index.js │ │ │ │ │ ├── array.js │ │ │ │ │ ├── base.js │ │ │ │ │ ├── dataDiff.js │ │ │ │ │ ├── helper.js │ │ │ │ │ ├── index.js │ │ │ │ │ ├── initProps.js │ │ │ │ │ ├── nextTick.js │ │ │ │ │ ├── quick │ │ │ │ │ │ ├── index.js │ │ │ │ │ │ └── watch.js │ │ │ │ │ ├── setData.js │ │ │ │ │ ├── swan │ │ │ │ │ │ ├── array.js │ │ │ │ │ │ └── index.js │ │ │ │ │ ├── tt │ │ │ │ │ │ └── index.js │ │ │ │ │ └── wx │ │ │ │ │ │ └── index.js │ │ │ │ ├── redux │ │ │ │ │ ├── connect.js │ │ │ │ │ ├── index.js │ │ │ │ │ └── swan │ │ │ │ │ │ └── index.js │ │ │ │ ├── vuex │ │ │ │ │ ├── Vue.js │ │ │ │ │ ├── index.js │ │ │ │ │ └── swan │ │ │ │ │ │ └── index.js │ │ │ │ └── watch │ │ │ │ │ ├── index.js │ │ │ │ │ └── quick │ │ │ │ │ └── index.js │ │ │ ├── filter │ │ │ │ └── quick │ │ │ │ │ └── index.js │ │ │ └── ref │ │ │ │ ├── ant │ │ │ │ └── index.js │ │ │ │ ├── index.js │ │ │ │ └── quick │ │ │ │ └── index.js │ │ ├── helper │ │ │ ├── component.js │ │ │ ├── data.js │ │ │ ├── eventCenter.js │ │ │ ├── factory.js │ │ │ ├── methods.js │ │ │ ├── page.js │ │ │ └── props.js │ │ ├── index.js │ │ ├── na │ │ │ ├── api.js │ │ │ ├── index.js │ │ │ ├── platform.js │ │ │ ├── request.js │ │ │ └── semver.js │ │ ├── polyfill │ │ │ ├── async.js │ │ │ └── promise.js │ │ ├── quick │ │ │ ├── App.js │ │ │ ├── Component.js │ │ │ ├── Page.js │ │ │ ├── api │ │ │ │ ├── index.js │ │ │ │ ├── platform.js │ │ │ │ ├── prompt.js │ │ │ │ ├── request.js │ │ │ │ └── router.js │ │ │ ├── base │ │ │ │ ├── application.js │ │ │ │ ├── component.js │ │ │ │ └── page.js │ │ │ └── env.js │ │ ├── swan │ │ │ ├── App.js │ │ │ ├── Component.js │ │ │ ├── Page.js │ │ │ ├── adapter │ │ │ │ └── component.js │ │ │ ├── api.js │ │ │ ├── base │ │ │ │ ├── component.js │ │ │ │ └── page.js │ │ │ ├── env.js │ │ │ └── helper │ │ │ │ └── triggerEvent.js │ │ ├── tt │ │ │ ├── App.js │ │ │ ├── Component.js │ │ │ ├── Page.js │ │ │ ├── api.js │ │ │ └── env.js │ │ ├── util │ │ │ ├── EventListener.js │ │ │ ├── index.js │ │ │ └── url.js │ │ └── wx │ │ │ ├── App.js │ │ │ ├── Component.js │ │ │ ├── Page.js │ │ │ ├── api.js │ │ │ ├── env.js │ │ │ └── request.js │ └── test │ │ ├── fixtures │ │ └── quick │ │ │ ├── app.js │ │ │ ├── device.js │ │ │ ├── fetch.js │ │ │ ├── prompt.js │ │ │ └── router.js │ │ ├── helper.js │ │ ├── prepare.js │ │ └── tasks │ │ ├── App.spec.js │ │ ├── ant │ │ ├── adapter │ │ │ └── component.spec.js │ │ └── env.spec.js │ │ ├── extend │ │ ├── behavior │ │ │ └── index.spec.js │ │ ├── broadcast.spec.js │ │ ├── data │ │ │ ├── equal.spec.js │ │ │ ├── model.spec.js │ │ │ ├── observable │ │ │ │ ├── ant │ │ │ │ │ ├── array.spec.js │ │ │ │ │ └── index.spec.js │ │ │ │ ├── array.spec.js │ │ │ │ ├── helper.js │ │ │ │ ├── helper.spec.js │ │ │ │ ├── setData.spec.js │ │ │ │ ├── swan │ │ │ │ │ ├── array.spec.js │ │ │ │ │ └── index.spec.js │ │ │ │ └── wx │ │ │ │ │ └── index.spec.js │ │ │ ├── redux │ │ │ │ ├── index.spec.js │ │ │ │ ├── reducers │ │ │ │ │ ├── counter.js │ │ │ │ │ └── index.js │ │ │ │ └── store │ │ │ │ │ └── index.js │ │ │ ├── vuex │ │ │ │ ├── Vue.spec.js │ │ │ │ ├── index.spec.js │ │ │ │ └── store │ │ │ │ │ ├── simpleStore.js │ │ │ │ │ ├── store2.js │ │ │ │ │ ├── store3.js │ │ │ │ │ ├── store4.js │ │ │ │ │ ├── store5.js │ │ │ │ │ └── store6.js │ │ │ └── watch.spec.js │ │ └── ref │ │ │ ├── ant │ │ │ └── ref.spec.js │ │ │ └── ref.spec.js │ │ ├── helper │ │ └── methods.spec.js │ │ ├── na │ │ ├── api.spec.js │ │ ├── index.spec.js │ │ ├── platform.spec.js │ │ ├── request.spec.js │ │ └── semver.spec.js │ │ ├── quick │ │ └── env.spec.js │ │ ├── swan │ │ ├── App.spec.js │ │ ├── Component.spec.js │ │ ├── Page.spec.js │ │ ├── adapter │ │ │ └── component.spec.js │ │ ├── api.spec.js │ │ └── env.spec.js │ │ ├── tt │ │ └── env.spec.js │ │ ├── util │ │ ├── EventListener.spec.js │ │ ├── index.spec.js │ │ └── url.spec.js │ │ └── wx │ │ ├── App.spec.js │ │ ├── Component.spec.js │ │ ├── Page.spec.js │ │ ├── api.spec.js │ │ ├── env.spec.js │ │ └── request.spec.js └── okam-helper │ ├── .babelrc.js │ ├── .fecsignore │ ├── .fecsrc │ ├── .gitignore │ ├── .npmignore │ ├── README.md │ ├── index.js │ ├── lib │ ├── Timer.js │ ├── event.js │ ├── file.js │ ├── helper.js │ ├── logger.js │ ├── require.js │ └── string.js │ ├── package-lock.json │ ├── package.json │ └── test │ └── tasks │ ├── Timer.spec.js │ ├── event.spec.js │ ├── file.spec.js │ ├── helper.spec.js │ ├── logger.spec.js │ ├── require.spec.js │ └── string.spec.js └── scripts └── install.sh /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 4 6 | 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [{package.json,.travis.yml,ci.yml}] 13 | indent_style = space 14 | indent_size = 2 15 | 16 | [*.md] 17 | trim_trailing_whitespace = false 18 | -------------------------------------------------------------------------------- /.fecsignore: -------------------------------------------------------------------------------- 1 | node_modules/**/* 2 | dep/**/* 3 | test/**/* 4 | mock/**/* 5 | example/**/* 6 | output/**/* 7 | dist/**/* 8 | wx_dist/**/* 9 | ant_dist/**/* 10 | quick_dist/**/* 11 | tt_dist/**/* 12 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | registry https://registry.npmjs.org 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | node_js: 4 | - "10" 5 | 6 | cache: 7 | directories: 8 | - node_modules 9 | 10 | install: 11 | - npm install 12 | - npm run bootstrap 13 | 14 | script: 15 | - npm run lint 16 | - npm run test 17 | 18 | after_success: 19 | - npm run report-coverage 20 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Global project babel config 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | module.exports = { 9 | babelrcRoots: [ 10 | './packages/*' 11 | ] 12 | }; 13 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | dist/ 4 | *.bat 5 | .idea/ 6 | coverage/ 7 | yarn.lock 8 | package-lock.json 9 | -------------------------------------------------------------------------------- /docs/.nojekyll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecomfe/okam/ecc4640249cf2abf3a8c76feeffde7a1729ca4c3/docs/.nojekyll -------------------------------------------------------------------------------- /docs/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 变更日志 2 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # OKAM 小程序开发框架文档 2 | 3 | ## 快速开始 4 | 5 | * 安装 6 | 7 | ```shell 8 | npm i docsify-cli -g 9 | ``` 10 | 11 | * 开启本地文档服务 12 | 13 | ```shell 14 | docsify serve 15 | ``` 16 | 17 | ``` 18 | visit http://localhost:3000/ 19 | 20 | ``` 21 | 22 | * 文档编写 23 | 24 | docsify: https://docsify.js.org/#/ 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/_navbar.md: -------------------------------------------------------------------------------- 1 | * [CHANGELOG](https://github.com/ecomfe/okam/blob/master/CHANGELOG.md) 2 | 3 | -------------------------------------------------------------------------------- /docs/advance/http.md: -------------------------------------------------------------------------------- 1 | # HTTP 请求 2 | 3 | ## 原生请求接口 4 | 5 | * `swan.request`: 默认情况下,你可以在组件、页面或者 App 上下文使用 `this.$api.request()` 调用原生请求接口 6 | 7 | ## 请求 Promise 化 8 | 9 | * 默认组件、页面或者 App 上下文提供了一个封装好的请求对象: `$http` 10 | 11 | * 该请求对象请求接口默认返回的是 `Promise`,建议开发过程中直接使用该请求对象发起 HTTP 请求 12 | 13 | * 请求对象接口 14 | 15 | * `$http.get(url, options)`: 发起一个 `GET` 请求,请求选项可以参考原生请求接口[定义](https://smartprogram.baidu.com/docs/develop/api/net_request/) 16 | 17 | * `$http.post(url, options)`: 发起一个 `POST` 请求 18 | 19 | * `$http.fetch(url, options)`: 发起自定义 Method 请求 20 | 21 | ```javascript 22 | this.$http.fetch( 23 | 'http://xxx.com/xx', 24 | {method: 'PUT', data: {}} 25 | ).then( 26 | res => console.log(res), 27 | err => console.error(err) 28 | ); 29 | ``` 30 | 31 | !> 如果接口请求想在页面组件外部实现,可以参考 `okam-core` 提供的 [API](api/global)。 32 | -------------------------------------------------------------------------------- /docs/build/plugin.md: -------------------------------------------------------------------------------- 1 | # 自定义处理器 2 | 3 | ## 处理器定义 4 | 5 | * 一个简单的自定义处理器示例 6 | 7 | ```javascript 8 | function compile(file, options) { 9 | let json5 = require('json5'); 10 | 11 | let obj = json5.parse(file.content.toString()); 12 | let result = JSON.stringify(obj, null, 4); 13 | 14 | return { 15 | content: result 16 | }; 17 | } 18 | 19 | module.exports = exports = compile; 20 | ``` 21 | 22 | ## 处理器使用 23 | 24 | * 在构建配置里注册处理器 25 | 26 | ```javascript 27 | { 28 | processors: { 29 | myPlugin: { 30 | processor: './tools/myPlugin' // 如果发布到 NPM,可以直接指定包名,前提得先安装该处理器 NPM 包 31 | } 32 | }, 33 | 34 | rules: [ 35 | match: '*.js', 36 | processors: [ 37 | 'myPlugin' 38 | ] 39 | ] 40 | } 41 | ``` 42 | 43 | ## 第三方处理器 44 | 45 | 具体可以查看[处理器列表章节](plugins/imgCompress) 46 | -------------------------------------------------------------------------------- /docs/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecomfe/okam/ecc4640249cf2abf3a8c76feeffde7a1729ca4c3/docs/favicon.ico -------------------------------------------------------------------------------- /docs/img/my.showToast.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecomfe/okam/ecc4640249cf2abf3a8c76feeffde7a1729ca4c3/docs/img/my.showToast.png -------------------------------------------------------------------------------- /docs/img/qr/ems.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecomfe/okam/ecc4640249cf2abf3a8c76feeffde7a1729ca4c3/docs/img/qr/ems.png -------------------------------------------------------------------------------- /docs/img/qr/jiandanfanyi.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecomfe/okam/ecc4640249cf2abf3a8c76feeffde7a1729ca4c3/docs/img/qr/jiandanfanyi.jpg -------------------------------------------------------------------------------- /docs/img/qr/jianjianya.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecomfe/okam/ecc4640249cf2abf3a8c76feeffde7a1729ca4c3/docs/img/qr/jianjianya.png -------------------------------------------------------------------------------- /docs/img/template_demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecomfe/okam/ecc4640249cf2abf3a8c76feeffde7a1729ca4c3/docs/img/template_demo.png -------------------------------------------------------------------------------- /docs/img/wx.showToast.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecomfe/okam/ecc4640249cf2abf3a8c76feeffde7a1729ca4c3/docs/img/wx.showToast.png -------------------------------------------------------------------------------- /docs/img/wx_async_default_error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecomfe/okam/ecc4640249cf2abf3a8c76feeffde7a1729ca4c3/docs/img/wx_async_default_error.png -------------------------------------------------------------------------------- /docs/img/wx_multiple_pages_error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecomfe/okam/ecc4640249cf2abf3a8c76feeffde7a1729ca4c3/docs/img/wx_multiple_pages_error.png -------------------------------------------------------------------------------- /docs/img/wx_regnerator_runtime_error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecomfe/okam/ecc4640249cf2abf3a8c76feeffde7a1729ca4c3/docs/img/wx_regnerator_runtime_error.png -------------------------------------------------------------------------------- /docs/questions/index.md: -------------------------------------------------------------------------------- 1 | # 问题解决 2 | 3 | * 更新到最新版本,看是否能解决 4 | * `okam-cli` 升级: `okam upgrade self` 5 | * 项目升级: `cd 项目路径 && okam upgrade project` 6 | * 注意看一下 [CHANGELOG](https://github.com/ecomfe/okam/blob/master/CHANGELOG.md), 以免有不兼容升级 `breakchange` 7 | * 看一下 [教程文档](https://ecomfe.github.io/okam/#/),看是否能解决? 8 | * 搜一下已有 [ISSUE](https://github.com/ecomfe/okam/issues/new) 或者 [问题集锦](questions/problems),看是否有帮助? 9 | * 如果没有找到相应解决办法,可以加 QQ 群 `728460911` 反馈,入群备注:okam,如果确认是问题的话,麻烦到 `Github` 提 [ISSUE](https://github.com/ecomfe/okam/issues/new) 10 | -------------------------------------------------------------------------------- /docs/template/condition.md: -------------------------------------------------------------------------------- 1 | # 条件渲染 2 | 3 | ## if-elif-else 4 | * 使用 `if`、`elif`、`else` 来决定模板模块的展现。 5 | ```html 6 | A 7 | B 8 | C 9 | ``` 10 | 11 | * 支持用`else-if`替代`elif` 12 | ```html 13 | A 14 | B 15 | C 16 | ``` 17 | 18 | ## 在 block 上使用 if 19 | `block` 是虚拟标签,可以用 `if` 来渲染一组组件或者标签。 20 | ```html 21 | A B 22 | ``` 23 | 24 | !> 原生限制,没有 `show` 语法
25 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "lerna": "3.5.1", 3 | "packages": [ 4 | "packages/*" 5 | ], 6 | "command": { 7 | "publish": { 8 | "allowBranch": ["master", "0.3.x"], 9 | "message": "chore: publish" 10 | } 11 | }, 12 | "npmClient": "npm", 13 | "version": "independent" 14 | } 15 | -------------------------------------------------------------------------------- /packages/okam-build/.babelrc.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Babel config 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const path = require('path'); 9 | 10 | module.exports = { 11 | env: { 12 | development: { 13 | plugins: [ 14 | [ 15 | 'module-resolver', 16 | { 17 | alias: { 18 | okam: path.join(__dirname, 'lib'), 19 | test: path.join(__dirname, 'test/tasks') 20 | } 21 | } 22 | ] 23 | ] 24 | } 25 | } 26 | }; 27 | -------------------------------------------------------------------------------- /packages/okam-build/.fecsignore: -------------------------------------------------------------------------------- 1 | node_modules/**/* 2 | dep/**/* 3 | test/**/* 4 | mock/**/* 5 | example/**/* 6 | output/**/* 7 | dist/**/* 8 | -------------------------------------------------------------------------------- /packages/okam-build/.fecsrc: -------------------------------------------------------------------------------- 1 | { 2 | "eslint": { 3 | "env": { 4 | "node": true, 5 | "browser": false 6 | }, 7 | 8 | "rules": { 9 | "fecs-no-require": -1, 10 | "no-console": 0 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/okam-build/.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | example/**/package-lock.json 3 | test/**/package-lock.json 4 | test/example/ 5 | test/test.js 6 | wx_dist 7 | ant_dist 8 | tt_dist 9 | quick_dist 10 | node_modules 11 | -------------------------------------------------------------------------------- /packages/okam-build/.npmignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | coverage/ 3 | test/ 4 | demo/ 5 | example/ 6 | examples/ 7 | .idea/ 8 | npm-debug.log 9 | Thumbs.db 10 | .DS_Store 11 | .npmrc 12 | *.swp 13 | *.bat 14 | yarn.lock 15 | .fecsrc 16 | .fecsignore 17 | .nyc_output 18 | .babelrc.js 19 | -------------------------------------------------------------------------------- /packages/okam-build/README.md: -------------------------------------------------------------------------------- 1 | okam-build 2 | ====== 3 | [![NPM Version](https://img.shields.io/npm/v/okam-build.svg?style=flat)](https://npmjs.org/package/okam-build) 4 | 5 | > OKAM 开发框架构建工具 6 | 7 | ## Usage 8 | 9 | ``` 10 | npm i okam-build --save-dev 11 | ``` 12 | 13 | ## Development 14 | 15 | ### Run Demo 16 | 17 | * 初始化 18 | 19 | ```shell 20 | cd example/base 21 | npm run init 22 | ``` 23 | 24 | **提示:** 如果有依赖更新,需要重新执行下上面命令 25 | 26 | 27 | * 运行 28 | 29 | **注意:** 在 `okam-build` 根目录下执行,非 `example` 目录 30 | 31 | ```shell 32 | npm run demo 33 | npm run demo:debug # 调试模式 34 | ``` 35 | 36 | ### Test 37 | 38 | ```shell 39 | npm test 40 | ``` 41 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/.frameworkinfo: -------------------------------------------------------------------------------- 1 | {"toolName":"okam","toolFrameworkVersion":"0.4.26-alpha.0","toolCliVersion":"0.1.12","createTime":"1551240469040"} -------------------------------------------------------------------------------- /packages/okam-build/example/base/README.md: -------------------------------------------------------------------------------- 1 | Example 2 | --- 3 | 4 | ## Preparation 5 | 6 | ```shell 7 | npm run init 8 | ``` 9 | 10 | **提示:** 如果有依赖更新,需要重新执行下上面命令 11 | 12 | `example` 示例还自带其它几个命令: 13 | 14 | ## 构建 15 | 16 | ```shell 17 | npm run build # 清空之前构建产物,重新构建 18 | ``` 19 | 20 | ## 开发调试 21 | 22 | ```shell 23 | npm run dev # 重新构建,并进入watch mode 24 | npm run dev:debug 25 | npm run dev:clean # 删除构建产物,保留 project.swan.json 并进入 watch 构建模式 26 | ``` 27 | 28 | ## 使用 Babel7 29 | 30 | 如果要使用 babel7,需要在 `scripts/swan.config.js` 将对应的 `babel` 处理器名称改成 `babel7` 31 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/dep/a.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Swan IDE GUI 3 | * Copyright 2018 Baidu Inc. All rights reserved. 4 | * @file 5 | * @author wuhuiyao(wuhuiyao@baidu.com) 6 | */ 7 | 8 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/project.json5: -------------------------------------------------------------------------------- 1 | { 2 | description: '小程序项目置文件', // 项目说明 3 | _ttEnv: { 4 | appid: '体验appId', 5 | setting: { 6 | urlCheck: true, 7 | es6: true, 8 | postcss: true, 9 | minified: true, 10 | newFeature: true 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/scripts/build.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file build script 3 | * @author xxx 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const build = require('../../..'); 9 | build.run(); 10 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/scripts/tt.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Build toutitao mini program config 3 | * @author xxx 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const merge = require('../../../').merge; 9 | 10 | module.exports = merge({}, require('./base.config'), { 11 | output: { 12 | dir: 'tt_dist', 13 | depDir: 'src/common' 14 | }, 15 | localPolyfill: [ 16 | 'async', 17 | 'promise' 18 | ], 19 | dev: { 20 | processors: { 21 | postcss: { 22 | options: { 23 | plugins: { 24 | 'postcss-url': { 25 | url: 'inline' 26 | } 27 | } 28 | } 29 | } 30 | } 31 | } 32 | }); 33 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/actions/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file redux actions 3 | * @author xxx 4 | */ 5 | 6 | import * as todoActions from './todo'; 7 | 8 | export default Object.assign({}, todoActions) 9 | // export default todoActions; // 这种写法 支付宝小程序编译会出错 10 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/actions/type.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file action type constants 3 | * @author xxx 4 | */ 5 | 6 | export const EDIT_NAME = 'EDIT_NAME'; 7 | 8 | export const ADD_TODO = 'ADD_TODO'; 9 | export const EDIT_TODO = 'EDIT_TODO'; 10 | export const REMOVE_TODO = 'REMOVE_TODO'; 11 | export const TOGGLE_TODO = 'TOGGLE_TODO'; 12 | 13 | export const FETCH_TODOS = 'FETCH_TODO'; 14 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/common/behavior/behaviorC.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file BehaviorC 3 | * @author xxx 4 | */ 5 | 6 | export default { 7 | data: { 8 | b: { 9 | c: 56 10 | }, 11 | dc: 666 12 | }, 13 | created() { 14 | console.log('call behvaiorC created...this.$query', this.$query); 15 | }, 16 | 17 | beforeMount() { 18 | console.log('call behvaiorC mount...'); 19 | }, 20 | 21 | methods: { 22 | methodB() { 23 | console.log('call behvaiorC methodB...'); 24 | } 25 | } 26 | }; 27 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/common/behavior/behaviorD.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file BehaviorD 3 | * @author xxx 4 | */ 5 | 6 | export default { 7 | data: { 8 | b: { 9 | c: 96 10 | }, 11 | dd: 866 12 | }, 13 | 14 | created() { 15 | console.log('call behvaiorD created...'); 16 | }, 17 | 18 | beforeMount() { 19 | console.log('call behvaiorD mount...'); 20 | }, 21 | 22 | methods: { 23 | methodB() { 24 | console.log('call behvaiorD methodB...'); 25 | } 26 | } 27 | }; 28 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/common/behavior/util.js: -------------------------------------------------------------------------------- 1 | 2 | export function hi() { 3 | 4 | } 5 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/common/css/base.styl: -------------------------------------------------------------------------------- 1 | @require './icon.styl' 2 | 3 | html, 4 | body 5 | background-color: #211e2e 6 | font-family: -apple-system-font, Helvetica Neue, Helvetica, sans-serif 7 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/common/css/common.css: -------------------------------------------------------------------------------- 1 | /** 2 | * @file common style 3 | * @author xxx 4 | */ 5 | 6 | .hide { 7 | width: 200px; 8 | display: none; 9 | } 10 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/common/css/font.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecomfe/okam/ecc4640249cf2abf3a8c76feeffde7a1729ca4c3/packages/okam-build/example/base/src/common/css/font.eot -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/common/css/font.less: -------------------------------------------------------------------------------- 1 | 2 | 3 | @font-face { 4 | font-family: 'test'; 5 | src: url(font.eot); 6 | } 7 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/common/font/bdfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecomfe/okam/ecc4640249cf2abf3a8c76feeffde7a1729ca4c3/packages/okam-build/example/base/src/common/font/bdfont.eot -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/common/font/bdfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecomfe/okam/ecc4640249cf2abf3a8c76feeffde7a1729ca4c3/packages/okam-build/example/base/src/common/font/bdfont.ttf -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/common/font/bdfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecomfe/okam/ecc4640249cf2abf3a8c76feeffde7a1729ca4c3/packages/okam-build/example/base/src/common/font/bdfont.woff -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/common/img/a.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecomfe/okam/ecc4640249cf2abf3a8c76feeffde7a1729ca4c3/packages/okam-build/example/base/src/common/img/a.gif -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/common/img/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecomfe/okam/ecc4640249cf2abf3a8c76feeffde7a1729ca4c3/packages/okam-build/example/base/src/common/img/close.png -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/common/img/component.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecomfe/okam/ecc4640249cf2abf3a8c76feeffde7a1729ca4c3/packages/okam-build/example/base/src/common/img/component.png -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/common/img/data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecomfe/okam/ecc4640249cf2abf3a8c76feeffde7a1729ca4c3/packages/okam-build/example/base/src/common/img/data.png -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/common/img/goto.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecomfe/okam/ecc4640249cf2abf3a8c76feeffde7a1729ca4c3/packages/okam-build/example/base/src/common/img/goto.png -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/common/img/js.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecomfe/okam/ecc4640249cf2abf3a8c76feeffde7a1729ca4c3/packages/okam-build/example/base/src/common/img/js.png -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/common/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecomfe/okam/ecc4640249cf2abf3a8c76feeffde7a1729ca4c3/packages/okam-build/example/base/src/common/img/logo.png -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/common/img/more.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecomfe/okam/ecc4640249cf2abf3a8c76feeffde7a1729ca4c3/packages/okam-build/example/base/src/common/img/more.png -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/common/img/okm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecomfe/okam/ecc4640249cf2abf3a8c76feeffde7a1729ca4c3/packages/okam-build/example/base/src/common/img/okm.png -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/common/img/open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecomfe/okam/ecc4640249cf2abf3a8c76feeffde7a1729ca4c3/packages/okam-build/example/base/src/common/img/open.png -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/common/img/performance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecomfe/okam/ecc4640249cf2abf3a8c76feeffde7a1729ca4c3/packages/okam-build/example/base/src/common/img/performance.png -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/common/img/template.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecomfe/okam/ecc4640249cf2abf3a8c76feeffde7a1729ca4c3/packages/okam-build/example/base/src/common/img/template.png -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/common/img/ui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecomfe/okam/ecc4640249cf2abf3a8c76feeffde7a1729ca4c3/packages/okam-build/example/base/src/common/img/ui.png -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/common/js/tstest.ts: -------------------------------------------------------------------------------- 1 | interface Person { 2 | firstName: string; 3 | lastName: string; 4 | } 5 | 6 | function greeter(person: Person) { 7 | return "Typescripte 测试 , Hello, " + person.firstName + " " + person.lastName; 8 | } 9 | 10 | let user = { firstName: "Jane", lastName: "User" }; 11 | 12 | const x: number = 0; 13 | 14 | exports.greeter = greeter; 15 | 16 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/common/tpl/footer.tpl: -------------------------------------------------------------------------------- 1 | 2 | 7 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/common/tpl/include.tpl: -------------------------------------------------------------------------------- 1 | Hello: {{from}} 2 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/common/ts/Employee.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Employee 3 | * @author xxx 4 | */ 5 | 6 | import {IPerson, Person} from './Person'; 7 | 8 | export default class Employee extends Person { 9 | constructor(config: IPerson) { 10 | super(config); 11 | } 12 | 13 | work(hours: number) { 14 | console.log(this.getName(), 'need to work', hours + 'h'); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/common/ts/Person.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Person 3 | * @author xxx 4 | */ 5 | 6 | export interface IPerson { 7 | firstName: string; 8 | lastName: string; 9 | age: number; 10 | } 11 | 12 | export class Person { 13 | private firstName: string; 14 | private lastName: string; 15 | private age: number; 16 | 17 | constructor(config: IPerson){ 18 | this.firstName = config.firstName; 19 | this.lastName = config.lastName; 20 | this.age = config.age; 21 | } 22 | 23 | greet(person: Person) { 24 | console.log('hi', person.getName()); 25 | } 26 | 27 | getName() { 28 | return this.firstName + ' ' + this.lastName; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/common/util.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file util 3 | * @author xxx 4 | */ 5 | 6 | export function test() { 7 | if (process.env.NODE_DEV === 'dev') { 8 | console.log('dev', 'https://smartapp.baidu.com/test'); 9 | console.log('dv', 'https://my.baidu.com/test'); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/components/OkamHello.vue: -------------------------------------------------------------------------------- 1 | 6 | 28 | 39 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/components/SimpleComponent2.vue: -------------------------------------------------------------------------------- 1 | 6 | 22 | 29 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/packageA/pages/subPageA/index.vue: -------------------------------------------------------------------------------- 1 | 6 | 21 | 29 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/packageB/pages/subPageB/index.vue: -------------------------------------------------------------------------------- 1 | 6 | 15 | 23 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/pages/data/init.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 33 | 34 | 42 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/pages/filter/FilterComponent.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 17 | 18 | 24 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/pages/filter/index.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 34 | 35 | 42 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/pages/sfc/script.js: -------------------------------------------------------------------------------- 1 | import Hello from '../../components/OkamHello'; 2 | 3 | export default { 4 | config: { 5 | title: 'Home Page Title' 6 | }, 7 | 8 | components: { 9 | Hello 10 | }, 11 | 12 | data: { 13 | btnText: 'Hello', 14 | clicked: false, 15 | from: 'Okam home page' 16 | }, 17 | 18 | methods: { 19 | 20 | handleHello(e) { 21 | this.clicked = true; 22 | this.btnText = 'You clicked'; 23 | 24 | this.$api.showToast({ 25 | title: 'Received Hello', 26 | duration: 3000 27 | }); 28 | } 29 | } 30 | }; 31 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/pages/sfc/separate.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/pages/sfc/style.styl: -------------------------------------------------------------------------------- 1 | // 用于示例,建议写法保持一致性 2 | @import '../../common/css/common.css' 3 | 4 | .home-wrap 5 | box-sizing: border-box 6 | height: 100vh 7 | background: #f0f0f0 8 | 9 | .click-tip 10 | text-align: center 11 | color: red 12 | 13 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/pages/sfc/view.tpl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | You click me~ 6 | 7 | 8 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/pages/todos/counter.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 31 | 38 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/pages/typescript/dep.less: -------------------------------------------------------------------------------- 1 | .greeting { 2 | color: #fff; 3 | } 4 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/reducers/counter.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file counter reducers 3 | * @author xxx 4 | */ 5 | 6 | export default (state = 0, action) => { 7 | let {type, value} = action; 8 | switch (type) { 9 | case 'INCREMENT': 10 | return state + value; 11 | case 'DECREMENT': 12 | return state - value; 13 | default: 14 | return state; 15 | } 16 | }; 17 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/reducers/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file redux root reducer 3 | * @author xxx 4 | */ 5 | 6 | import {combineReducers} from 'redux'; 7 | import todos from './todos'; 8 | import counter from './counter'; 9 | import userInfo from './userInfo'; 10 | 11 | export default combineReducers({ 12 | todos, 13 | counter, 14 | userInfo 15 | }); 16 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/reducers/userInfo.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userInfo reducer 3 | * @author xxx 4 | */ 5 | 6 | import createReducer from './utils'; 7 | const initialState = {}; 8 | 9 | export default createReducer(initialState, { 10 | 'upUserInfo': (state, {name, age}) => { 11 | state = Object.assign({}, {name, age}) 12 | return state; 13 | } 14 | }); 15 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/reducers/utils.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file reducer utils 3 | * @author xxx 4 | */ 5 | 6 | export default function createReducer(initialState, handlers) { 7 | return (state = initialState, action) => { 8 | if (Object.prototype.hasOwnProperty.call(handlers, action.type)) { 9 | return handlers[action.type](state, action); 10 | } 11 | return state; 12 | }; 13 | } 14 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/services/todo.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file common services 3 | * @author xxx 4 | */ 5 | 6 | import {request as requester} from 'okam'; 7 | 8 | export function fetchTodoList(pageNo = 1, pageSize = 10) { 9 | return requester.get('http://localhost:9090/api/todoList', { 10 | data: { 11 | pageNo, 12 | pageSize 13 | } 14 | }); 15 | } 16 | -------------------------------------------------------------------------------- /packages/okam-build/example/base/src/store/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file redux store 3 | * @author xxx 4 | */ 5 | 6 | import {createStore, applyMiddleware} from 'redux'; 7 | import thunk from 'redux-thunk'; 8 | import reducer from '../reducers/index'; 9 | 10 | export default createStore(reducer, applyMiddleware(thunk)); 11 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/ant-native/README.md: -------------------------------------------------------------------------------- 1 | Ant Native components 2 | --- 3 | 4 | ## Preparation 5 | 6 | 用于展现支付宝原生组件支持示例。 7 | 8 | ```shell 9 | npm i 10 | npm run init 11 | ``` 12 | 13 | ## 开发调试 14 | 15 | ```shell 16 | npm run dev # 重新构建,并进入watch mode 17 | npm run dev:debug 18 | npm run dev:clean # 删除构建产物,保留 project.swan.json 并进入 watch 构建模式 19 | ``` 20 | 21 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/ant-native/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "custom-component", 3 | "version": "1.0.0", 4 | "description": "custom-component example test", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "init": "ln -s ../../../../../okam-core node_modules", 9 | "clean": "rm -rf dist/", 10 | "build": "npm run clean && cross-env NODE_ENV=dev node scripts/build.js", 11 | "dev:debug": "cross-env NODE_ENV=dev node --inspect-brk scripts/build.js --watch", 12 | "dev": "cross-env NODE_ENV=dev node scripts/build.js --watch", 13 | "dev:clean": "cross-env NODE_ENV=dev node scripts/build.js --watch --clean" 14 | }, 15 | "devDependencies": { 16 | "cross-env": "^5.2.0" 17 | }, 18 | "keywords": [], 19 | "author": "", 20 | "license": "ISC", 21 | "dependencies": { 22 | "@antv/my-f2": "^1.1.3", 23 | "mini-ddui": "0.0.5" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/ant-native/project.json5: -------------------------------------------------------------------------------- 1 | { 2 | description: '小程序项目置文件' // 项目说明 3 | } 4 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/ant-native/scripts/ant.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Build wx mini program config 3 | * @author xxx 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const path = require('path'); 9 | 10 | module.exports = { 11 | verbose: false, 12 | root: path.join(__dirname, '..'), 13 | output: { 14 | dir: 'ant_dist', 15 | depDir: 'src/common' 16 | }, 17 | component: { 18 | extname: 'vue' 19 | }, 20 | framework: [ 21 | 'data', 22 | 'watch' 23 | ], 24 | processors: { 25 | babel7: { 26 | extnames: 'js', 27 | options: { 28 | presets: ['@babel/preset-env'] 29 | } 30 | } 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/ant-native/scripts/build.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file build script 3 | * @author xxx 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const build = require('../../../../'); 9 | build.run('ant', require('./ant.config')); 10 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/ant-native/src/app.css: -------------------------------------------------------------------------------- 1 | /** 2 | * @file The app entry style 3 | * @author xxx 4 | */ 5 | 6 | page { 7 | font-family: -apple-system-font, Helvetica Neue, Helvetica, sans-serif; 8 | } 9 | 10 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/ant-native/src/app.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file The app entrance 3 | * @author xxx@baidu.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | export default { 9 | config: { 10 | pages: [ 11 | 'pages/index', 12 | 'pages/filter' 13 | ], 14 | window: { 15 | } 16 | } 17 | }; 18 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/ant-native/src/components/add-button/add-button.acss: -------------------------------------------------------------------------------- 1 | .add-button-wrap { 2 | background: #ccc; 3 | } 4 | 5 | .add-button { 6 | display: inline-block; 7 | background: none; 8 | color: #FFF; 9 | border: none; 10 | width: 300rpx; 11 | } 12 | 13 | .add-icon { 14 | font-size: 52rpx; 15 | color: #00FFD6; 16 | margin-right: 10rpx; 17 | } 18 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/ant-native/src/components/add-button/add-button.axml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/ant-native/src/components/add-button/add-button.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Add button component 3 | * @author xxx@baidu.com 4 | */ 5 | 6 | /* eslint-disable babel/new-cap */ 7 | /* global Component:false */ 8 | 9 | Component({ 10 | props: { 11 | onClickMe: () => { 12 | console.log('hello... click me.'); 13 | } 14 | }, 15 | 16 | data: { 17 | hi: 'Add btn' 18 | }, 19 | 20 | methods: { 21 | onClickMe() { 22 | this.props.onClick('haha'); 23 | } 24 | } 25 | }); 26 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/ant-native/src/components/add-button/add-button.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": { 4 | "hello": "../hello/hello" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/ant-native/src/components/hello/hello.acss: -------------------------------------------------------------------------------- 1 | .hi-wrap { 2 | padding: 20px; 3 | background: #ccc; 4 | } 5 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/ant-native/src/components/hello/hello.axml: -------------------------------------------------------------------------------- 1 | 2 | HI:{{hi}} 3 | 4 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/ant-native/src/components/hello/hello.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Hello component 3 | * @author xxx@baidu.com 4 | */ 5 | 6 | /* eslint-disable babel/new-cap */ 7 | /* global Component:false */ 8 | 9 | Component({ 10 | props: { 11 | hi: 'hi233' 12 | }, 13 | 14 | methods: { 15 | } 16 | }); 17 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/ant-native/src/components/hello/hello.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/ant-native/src/filters/string.sjs: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Ant filter 3 | * @author xxx 4 | */ 5 | 6 | export function toLowerCase(str) { 7 | return str.toLowerCase(); 8 | } 9 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/ant-native/src/filters/util.sjs: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Ant filter 3 | * @author xxx 4 | */ 5 | import {toLowerCase} from './string.sjs'; 6 | const INFO = 'hello'; 7 | 8 | export default { 9 | info: INFO, 10 | toUpperCase: function (str) { 11 | return str.toUpperCase(); 12 | }, 13 | toLowerCase 14 | }; 15 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/ant-native/src/pages/filter.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 27 | 28 | 35 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/iview/.fecsignore: -------------------------------------------------------------------------------- 1 | node_modules/**/* 2 | dep/**/* 3 | test/**/* 4 | mock/**/* 5 | example/**/* 6 | output/**/* 7 | dist/**/* 8 | wx_dist/**/* 9 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/iview/.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | package-lock.json 3 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/iview/project.json5: -------------------------------------------------------------------------------- 1 | { 2 | description: '小程序项目置文件' // 项目说明 3 | } 4 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/iview/scripts/base.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Build swan smart program config 3 | * @author xxx 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const path = require('path'); 9 | 10 | 11 | module.exports = { 12 | verbose: false, 13 | root: path.join(__dirname, '..'), 14 | output: { 15 | dir: 'dist', 16 | depDir: 'src/common' 17 | }, 18 | source: { 19 | // include: [/^src\/pages\/.*/] 20 | }, 21 | component: { 22 | extname: 'vue' 23 | }, 24 | framework: [ 25 | 'data', 26 | 'watch', 27 | 'broadcast', 28 | 'ref' 29 | ], 30 | polyfill: [] 31 | }; 32 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/iview/scripts/build.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file build script 3 | * @author xxx 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const build = require('../../../../'); 9 | build.run(); 10 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/iview/scripts/swan.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Build swan smart program config 3 | * @author xxx 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const merge = require('../../../../').merge; 9 | module.exports = merge({}, require('./base.config'), { 10 | wx2swan: true, 11 | 12 | processors: { 13 | babel7: { 14 | extnames: 'js' 15 | } 16 | } 17 | }); 18 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/iview/scripts/wx.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Build wx mini program config 3 | * @author xxx 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const merge = require('../../../../').merge; 9 | module.exports = merge({}, require('./base.config'), { 10 | output: { 11 | dir: 'wx_dist', 12 | depDir: 'src/common' 13 | }, 14 | processors: { 15 | babel7: { 16 | extnames: 'js' 17 | } 18 | } 19 | }); 20 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/iview/src/app.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file The app entrance 3 | * @author xxx@baidu.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | export default { 9 | config: { 10 | pages: [ 11 | 'pages/button/index', 12 | 'pages/index' 13 | ], 14 | // subPackages: [], 15 | window: { 16 | } 17 | } 18 | }; 19 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/iview/src/app.styl: -------------------------------------------------------------------------------- 1 | /** 2 | * @file The app entry style 3 | * @author xxx 4 | */ 5 | 6 | .okam-inline 7 | display: inline 8 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/iview/src/pages/button/index.js: -------------------------------------------------------------------------------- 1 | Page({ 2 | handleClick () { 3 | 4 | } 5 | }); 6 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/iview/src/pages/button/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "Button 按钮", 3 | "usingComponents": { 4 | "i-button": "iview-weapp/dist/button/index", 5 | "i-panel": "iview-weapp/dist/panel/index" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/iview/src/pages/button/index.wxss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecomfe/okam/ecc4640249cf2abf3a8c76feeffde7a1729ca4c3/packages/okam-build/example/components/iview/src/pages/button/index.wxss -------------------------------------------------------------------------------- /packages/okam-build/example/components/native/project.json5: -------------------------------------------------------------------------------- 1 | { 2 | description: '小程序项目置文件' // 项目说明 3 | } 4 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/native/scripts/base.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Build swan smart program config 3 | * @author xxx 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const path = require('path'); 9 | 10 | module.exports = { 11 | verbose: false, 12 | root: path.join(__dirname, '..'), 13 | output: { 14 | dir: 'dist', 15 | depDir: 'src/common' 16 | }, 17 | component: { 18 | extname: 'vue' 19 | }, 20 | framework: [ 21 | 'data', 22 | 'watch', 23 | 'broadcast', 24 | 'ref' 25 | ], 26 | polyfill: [] 27 | }; 28 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/native/scripts/build.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file build script 3 | * @author xxx 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const build = require('../../../../'); 9 | build.run(); 10 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/native/scripts/swan.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Build swan smart program config 3 | * @author xxx 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const merge = require('../../../../').merge; 9 | module.exports = merge({}, require('./base.config'), { 10 | wx2swan: true 11 | }); 12 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/native/scripts/wx.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Build wx mini program config 3 | * @author xxx 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const merge = require('../../../../').merge; 9 | module.exports = merge({}, require('./base.config'), { 10 | output: { 11 | dir: 'wx_dist', 12 | depDir: 'src/common' 13 | }, 14 | processors: { 15 | babel7: { 16 | extnames: 'js' 17 | } 18 | } 19 | }); 20 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/native/src/app.css: -------------------------------------------------------------------------------- 1 | /** 2 | * @file The app entry style 3 | * @author xxx 4 | */ 5 | 6 | page { 7 | font-family: -apple-system-font, Helvetica Neue, Helvetica, sans-serif; 8 | } 9 | 10 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/native/src/app.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file The app entrance 3 | * @author xxx@baidu.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | export default { 9 | config: { 10 | pages: [ 11 | // index 12 | 'pages/index', 13 | // 组件是微信原生组件 14 | 'pages/wxWxs', 15 | // swan native 16 | 'pages/swanNative/index', 17 | // wx native 18 | 'pages/wxNative/index', 19 | // filter 20 | 'pages/swanFilter' 21 | ], 22 | window: { 23 | } 24 | } 25 | }; 26 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/native/src/components/Hello.css: -------------------------------------------------------------------------------- 1 | .hello-wrap { 2 | padding: 20rpx; 3 | background: #fff; 4 | } 5 | 6 | .hello-wrap .hello-title { 7 | font-size: 32rpx; 8 | } 9 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/native/src/components/Hello.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file redux actions 3 | * @author xxx 4 | */ 5 | 6 | /* global Component:false */ 7 | /* eslint-disable babel/new-cap */ 8 | 9 | Component({ 10 | data: { 11 | title: 'Hello Native Component' 12 | }, 13 | 14 | methods: { 15 | handleTap() { 16 | console.log('click me...'); 17 | this.triggerEvent('hello', 'hi'); 18 | } 19 | } 20 | }); 21 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/native/src/components/Hello.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": { 4 | "simple": "./Simple" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/native/src/components/Hello.swan: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{title}} 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/native/src/pages/wxNative/index.js: -------------------------------------------------------------------------------- 1 | // index.js 2 | 3 | // 获取应用实例 4 | 5 | Page({ 6 | data: { 7 | motto: 'Hello World' 8 | } 9 | }); 10 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/native/src/pages/wxNative/index.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /packages/okam-build/example/components/native/src/pages/wxNative/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{motto}} 5 | 6 | 7 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/native/src/pages/wxNative/index.wxss: -------------------------------------------------------------------------------- 1 | /**index.wxss**/ 2 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/native/src/pages/wxWxs.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 29 | 30 | 39 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/wux/.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | package-lock.json 3 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/wux/README.md: -------------------------------------------------------------------------------- 1 | Example 2 | --- 3 | 4 | ## Preparation 5 | 6 | 仅用于测试 自定义组件 npm 依赖 7 | 8 | ```shell 9 | npm run init 10 | ``` 11 | 12 | ## 构建 13 | 14 | ```shell 15 | npm run build # 清空之前构建产物,重新构建 16 | ``` 17 | 18 | ## 开发调试 19 | 20 | ```shell 21 | npm run dev # 重新构建,并进入watch mode 22 | npm run dev:debug 23 | npm run dev:clean # 删除构建产物,保留 project.swan.json 并进入 watch 构建模式 24 | ``` 25 | 26 | ## ui 组件 27 | - [wux-weapp](https://wux-weapp.github.io/wux-weapp-docs/#/) 28 | 29 | ## 存在问题 30 | 31 | - 引入了 `node_modules` 路径得组件 会导致出错,更换 路径名是 ok 的 32 | 33 | 已解决: 将 `node_modules` 替换成 `npm` 34 | 35 | 36 | - 用到的 `getRelationNodes` 即:behaviors、组件间关系、抽象节点 百度自定义组件不支持 等 37 | 38 | - 自定义组件样式不生效 同名的组件 有的加前缀 有的不加前缀,导致组件样式渲染失败 39 | 40 | - 自定义组件 样式 伪类 设置 content: 'xxx', xxx 为字体的代码点 时 不显示 新版本 直接显示 代码值 41 | 比如:content: '\e6de':会直接渲染成出 `e6de` 42 | 43 | - `relations` 不支持 44 | 45 | - event detail 微信与小程序不一致 46 | 47 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/wux/project.json5: -------------------------------------------------------------------------------- 1 | { 2 | description: '小程序项目置文件' // 项目说明 3 | } 4 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/wux/scripts/build.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file build script 3 | * @author xxx 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const build = require('../../../../'); 9 | build.run(); 10 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/wux/scripts/swan.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Build swan smart program config 3 | * @author xxx 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const path = require('path'); 9 | 10 | module.exports = { 11 | verbose: false, 12 | root: path.join(__dirname, '..'), 13 | output: { 14 | dir: 'dist', 15 | depDir: 'src/common' 16 | }, 17 | wx2swan: true, 18 | component: { 19 | extname: 'vue' 20 | }, 21 | framework: [ 22 | 'data', 23 | 'watch', 24 | 'broadcast', 25 | 'ref' 26 | ], 27 | polyfill: [] 28 | }; 29 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/wux/scripts/wx.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Build wx mini program config 3 | * @author xxx 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const path = require('path'); 9 | 10 | module.exports = { 11 | verbose: false, 12 | root: path.join(__dirname, '..'), 13 | output: { 14 | dir: 'wx_dist', 15 | depDir: 'src/common' 16 | }, 17 | component: { 18 | extname: 'vue' 19 | }, 20 | framework: [ 21 | 'data', 22 | 'watch', 23 | 'broadcast', 24 | 'ref' 25 | ], 26 | }; 27 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/wux/src/app.css: -------------------------------------------------------------------------------- 1 | page { 2 | 3 | font-family: -apple-system-font, Helvetica Neue, Helvetica, sans-serif; 4 | } 5 | 6 | .okam-inline { 7 | display: inline; 8 | } 9 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/wux/src/app.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file The app entrance 3 | * @author xxx@baidu.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | export default { 9 | config: { 10 | pages: [ 11 | 'pages/index' 12 | ], 13 | window: { 14 | } 15 | } 16 | }; 17 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/wx/README.md: -------------------------------------------------------------------------------- 1 | Native components 2 | --- 3 | 4 | ## Preparation 5 | 6 | 用于展现微信原生组件支持示例。 7 | 8 | ```shell 9 | npm i 10 | npm run init 11 | ``` 12 | 13 | ## 开发调试 14 | 15 | ```shell 16 | npm run dev 17 | npm run dev:debug 18 | npm run dev:clean 19 | ``` 20 | 21 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/wx/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "custom-component", 3 | "version": "1.0.0", 4 | "description": "custom-component example test", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "init": "ln -s ../../../../../okam-core node_modules", 9 | "clean": "rm -rf dist/", 10 | "build": "npm run clean && cross-env NODE_ENV=dev node scripts/build.js", 11 | "dev": "cross-env NODE_ENV=dev node scripts/build.js --type wx --watch", 12 | "dev:debug": "cross-env NODE_ENV=dev node --inspect-brk scripts/build.js --type wx --watch", 13 | "dev:clean": "npm run dev -- --clean" 14 | }, 15 | "devDependencies": { 16 | "cross-env": "^5.2.0" 17 | }, 18 | "keywords": [], 19 | "author": "", 20 | "license": "ISC", 21 | "dependencies": {} 22 | } 23 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/wx/project.json5: -------------------------------------------------------------------------------- 1 | { 2 | description: '小程序项目置文件' // 项目说明 3 | } 4 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/wx/scripts/build.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file build script 3 | * @author xxx 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const build = require('../../../../'); 9 | build.run(); 10 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/wx/scripts/wx.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Build swan smart program config 3 | * @author xxx 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const path = require('path'); 9 | 10 | module.exports = { 11 | verbose: false, 12 | root: path.join(__dirname, '..'), 13 | output: { 14 | dir: 'dist', 15 | depDir: 'src/common' 16 | }, 17 | component: { 18 | extname: 'vue' 19 | }, 20 | framework: [ 21 | 'data', 22 | 'watch', 23 | 'broadcast', 24 | 'ref' 25 | ] 26 | }; 27 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/wx/src/app.css: -------------------------------------------------------------------------------- 1 | /** 2 | * @file The app entry style 3 | * @author xxx 4 | */ 5 | 6 | page { 7 | font-family: -apple-system-font, Helvetica Neue, Helvetica, sans-serif; 8 | } 9 | 10 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/wx/src/app.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file The app entrance 3 | * @author xxx@baidu.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | export default { 9 | config: { 10 | pages: [ 11 | 'pages/wxFilter' 12 | ], 13 | window: { 14 | } 15 | } 16 | }; 17 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/wx/src/filter/string.wxs: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Weixin filter 3 | * @author xxx 4 | */ 5 | 6 | // exports.xxx is not allowed, module.exports.xxx is ok 7 | 8 | module.exports.toLowerCase = function (str) { 9 | return str.toLowerCase(); 10 | }; 11 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/wx/src/filter/util.wxs: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Weixin filter 3 | * @author xxx 4 | */ 5 | // using ES6 syntax is not allowed? 6 | var strUtil = require('./string.wxs'); 7 | var INFO = 'hello'; 8 | // exports.xxx is not allowed, module.exports.xxx is ok 9 | 10 | module.exports = { 11 | info: INFO, 12 | toUpperCase: function (str) { 13 | return str.toUpperCase(); 14 | }, 15 | toLowerCase: strUtil.toLowerCase 16 | }; 17 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/youzan/.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | package-lock.json 3 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/youzan/project.json5: -------------------------------------------------------------------------------- 1 | { 2 | description: '小程序项目置文件' // 项目说明 3 | } 4 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/youzan/scripts/base.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Build mini program base config 3 | * @author xxx 4 | */ 5 | 6 | 'use strict'; 7 | 8 | /* eslint-disable fecs-properties-quote */ 9 | const path = require('path'); 10 | 11 | module.exports = { 12 | verbose: false, 13 | root: path.join(__dirname, '..'), 14 | output: { 15 | dir: 'dist', 16 | depDir: 'src/common' 17 | }, 18 | component: { 19 | extname: 'vue' 20 | }, 21 | framework: [ 22 | 'data', 23 | // 'watch', 24 | // 'model', 25 | // ['behavior', '{useNativeBehavior: true}'], 26 | // 'broadcast', 27 | // 'redux', 28 | 'ref' 29 | ], 30 | polyfill: [], 31 | processors: { 32 | babel7: { 33 | extnames: 'js' 34 | } 35 | } 36 | }; 37 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/youzan/scripts/build.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file build script 3 | * @author xxx 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const build = require('../../../../'); 9 | build.run(); 10 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/youzan/scripts/swan.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Build swan smart program config 3 | * @author xxx 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const merge = require('../../../../').merge; 9 | module.exports = merge({}, require('./base.config'), { 10 | wx2swan: true 11 | }); 12 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/youzan/scripts/wx.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Build wx mini program config 3 | * @author xxx 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const merge = require('../../../../').merge; 9 | module.exports = merge({}, require('./base.config'), { 10 | output: { 11 | dir: 'wx_dist', 12 | depDir: 'src/common' 13 | } 14 | }); 15 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/youzan/src/app.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file The app entrance 3 | * @author xxx@baidu.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | export default { 9 | config: { 10 | pages: [ 11 | 'pages/button/index', 12 | 'pages/index' 13 | ], 14 | window: { 15 | } 16 | } 17 | }; 18 | -------------------------------------------------------------------------------- /packages/okam-build/example/components/youzan/src/app.styl: -------------------------------------------------------------------------------- 1 | /** 2 | * @file The app entry style 3 | * @author xxx 4 | */ 5 | 6 | .okam-inline 7 | display: inline 8 | 9 | page 10 | color: #333 11 | font-size: 16px 12 | background: #f8f8f8 13 | min-height: 100vh 14 | box-sizing: border-box 15 | padding: 0 0 100rpx 16 | -webkit-font-smoothing: antialiased 17 | font-family: 'PingFang SC', Helvetica, 'STHeiti STXihei', 'Microsoft YaHei', Tohoma, Arial, sans-serif 18 | 19 | .demo-margin-left 20 | margin-left: 10px 21 | 22 | .demo-margin-right 23 | margin-right: 10px 24 | 25 | .demo-margin-bottom 26 | display: block 27 | margin-bottom: 15px 28 | 29 | -------------------------------------------------------------------------------- /packages/okam-build/example/test/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 4 6 | 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [{package.json,.travis.yml,ci.yml}] 13 | indent_style = space 14 | indent_size = 2 15 | 16 | [*.md] 17 | trim_trailing_whitespace = false 18 | -------------------------------------------------------------------------------- /packages/okam-build/example/test/.fecsignore: -------------------------------------------------------------------------------- 1 | node_modules/**/* 2 | dep/**/* 3 | test/**/* 4 | mock/**/* 5 | example/**/* 6 | output/**/* 7 | -------------------------------------------------------------------------------- /packages/okam-build/example/test/.fecsrc: -------------------------------------------------------------------------------- 1 | { 2 | "eslint": { 3 | "rules": { 4 | "fecs-esnext-ext": -1, 5 | "fecs-valid-jsdoc": -1 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/okam-build/example/test/.npmignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | coverage/ 3 | test/ 4 | dist/ 5 | .idea/ 6 | npm-debug.log 7 | Thumbs.db 8 | .DS_Store 9 | .npmrc 10 | *.swp 11 | *.bat 12 | yarn.lock 13 | -------------------------------------------------------------------------------- /packages/okam-build/example/test/.tinyimgcache: -------------------------------------------------------------------------------- 1 | |compressed:0407dfeb408e3bf7c50c5e90507db0ae|original:31b69b1dfba132c166dd7068a8403a93|path:src/common/img/okm.png| 2 | -------------------------------------------------------------------------------- /packages/okam-build/example/test/project.json5: -------------------------------------------------------------------------------- 1 | { 2 | appid: '0', 3 | description: 'A okam project', 4 | projectname: 'test', 5 | _ttEnv: { 6 | appid: '体验appId', 7 | setting: { 8 | urlCheck: true, 9 | es6: true, 10 | postcss: true, 11 | minified: true, 12 | newFeature: true 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/okam-build/example/test/scripts/ant.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Build ant mini program build config 3 | * @author xxx 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const merge = require('../../../').merge; 9 | 10 | module.exports = merge({}, require('./base.config'), { 11 | output: { 12 | dir: 'ant_dist', 13 | depDir: 'src/common' 14 | }, 15 | localPolyfill: [ 16 | 'async', 17 | 'promise' 18 | ], 19 | processors: { 20 | babel7: { 21 | options: { 22 | presets: ['@babel/preset-env'] 23 | } 24 | } 25 | } 26 | }); 27 | -------------------------------------------------------------------------------- /packages/okam-build/example/test/scripts/build.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Build script 3 | * @author xxx 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const build = require('../../..'); 9 | build.run(); 10 | -------------------------------------------------------------------------------- /packages/okam-build/example/test/scripts/swan.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Build swan smart program build config 3 | * @author xxx 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const merge = require('../../../').merge; 9 | 10 | module.exports = merge({}, require('./base.config'), { 11 | polyfill: ['async'], 12 | // wx2swan: true, 13 | rules: [] 14 | }); 15 | -------------------------------------------------------------------------------- /packages/okam-build/example/test/src/common/css/b.css: -------------------------------------------------------------------------------- 1 | a { 2 | width: 100px; 3 | display: none; 4 | } 5 | -------------------------------------------------------------------------------- /packages/okam-build/example/test/src/common/css/common.css: -------------------------------------------------------------------------------- 1 | /** 2 | * @file common style 3 | * @author xxx 4 | */ 5 | 6 | .hide { 7 | width: 200px; 8 | display: none; 9 | } 10 | -------------------------------------------------------------------------------- /packages/okam-build/example/test/src/common/img/okm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecomfe/okam/ecc4640249cf2abf3a8c76feeffde7a1729ca4c3/packages/okam-build/example/test/src/common/img/okm.png -------------------------------------------------------------------------------- /packages/okam-build/example/test/src/common/tpl/footer.tpl: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /packages/okam-build/example/test/src/components/Hello.vue: -------------------------------------------------------------------------------- 1 | 6 | 28 | 39 | -------------------------------------------------------------------------------- /packages/okam-build/example/test/src/pages/home/sfc.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /packages/okam-build/example/test/src/pages/sfc/script.js: -------------------------------------------------------------------------------- 1 | import Hello from '../../components/Hello'; 2 | 3 | export default { 4 | config: { 5 | title: 'Home Page Title' 6 | }, 7 | 8 | components: { 9 | Hello 10 | }, 11 | 12 | data: { 13 | btnText: 'Hello', 14 | clicked: false, 15 | from: 'Okam home page' 16 | }, 17 | 18 | methods: { 19 | 20 | handleHello(e) { 21 | this.clicked = true; 22 | this.btnText = 'You clicked'; 23 | 24 | this.$api.showToast({ 25 | title: 'Received Hello', 26 | duration: 3000 27 | }); 28 | } 29 | } 30 | }; 31 | -------------------------------------------------------------------------------- /packages/okam-build/example/test/src/pages/sfc/sfc.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /packages/okam-build/example/test/src/pages/sfc/style.styl: -------------------------------------------------------------------------------- 1 | @import '../../common/css/common.css' 2 | 3 | .home-wrap 4 | box-sizing: border-box 5 | height: 100vh 6 | background: #f0f0f0 7 | 8 | .click-tip 9 | text-align: center 10 | color: red 11 | 12 | -------------------------------------------------------------------------------- /packages/okam-build/example/test/src/pages/sfc/view.tpl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | You click me~ 6 | 7 | 8 | -------------------------------------------------------------------------------- /packages/okam-build/example/test/src/sfc/script.js: -------------------------------------------------------------------------------- 1 | import Hello from '../components/Hello'; 2 | 3 | export default { 4 | config: { 5 | title: 'Home Page Title' 6 | }, 7 | 8 | components: { 9 | Hello 10 | }, 11 | 12 | data: { 13 | btnText: 'Hello', 14 | clicked: false, 15 | from: 'Okam home page' 16 | }, 17 | 18 | methods: { 19 | 20 | handleHello(e) { 21 | this.clicked = true; 22 | this.btnText = 'You clicked'; 23 | 24 | this.$api.showToast({ 25 | title: 'Received Hello', 26 | duration: 3000 27 | }); 28 | } 29 | } 30 | }; 31 | -------------------------------------------------------------------------------- /packages/okam-build/example/test/src/sfc/style.styl: -------------------------------------------------------------------------------- 1 | @import '../common/css/common.css'; 2 | 3 | .home-wrap { 4 | box-sizing: border-box; 5 | height: 100vh; 6 | background: #f0f0f0; 7 | } 8 | 9 | .home-wrap .click-tip { 10 | text-align: center; 11 | color: red; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /packages/okam-build/example/test/src/sfc/tpl.tpl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | You click me~ 6 | 7 | 8 | -------------------------------------------------------------------------------- /packages/okam-build/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file OKAM build entrance 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | // 用于 `component.template.transformTags` 配置项 9 | exports.reverseTagMap = require('./lib/util/tag-tansform-helper'); 10 | exports.merge = require('./lib/util').merge; 11 | exports.run = require('./lib/build'); 12 | -------------------------------------------------------------------------------- /packages/okam-build/lib/build/app-type.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file All app types definition 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | module.exports = [ 9 | 'swan', 10 | 'wx', 11 | 'ant', 12 | 'tt', 13 | 'quick' 14 | ]; 15 | 16 | -------------------------------------------------------------------------------- /packages/okam-build/lib/build/tt/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Toutiao mini program build task manager 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const BuildManager = require('../BuildManager'); 9 | 10 | class BuildTTAppManager extends BuildManager { 11 | } 12 | 13 | module.exports = BuildTTAppManager; 14 | -------------------------------------------------------------------------------- /packages/okam-build/lib/polyfill/normalize.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Normalize polyfill options 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | /* eslint-disable fecs-min-vars-per-destructure */ 9 | const preparePolyfill = require('./prepare'); 10 | const {getPolyfillInfo} = require('../framework'); 11 | 12 | module.exports = exports = function (polyfills, rootDir, logger) { 13 | if (!polyfills) { 14 | return; 15 | } 16 | 17 | let result = polyfills.map(item => { 18 | if (typeof item === 'string') { 19 | item = getPolyfillInfo(item); 20 | } 21 | 22 | // init module id to import 23 | item.id || (item.id = item.path); 24 | 25 | return item; 26 | }); 27 | 28 | // polyfill deps check 29 | preparePolyfill(result, rootDir, logger); 30 | 31 | return result; 32 | }; 33 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/css/add-css-dependencies.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Add the style dependence 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const {relative, replaceExtname} = require('../../util').file; 9 | 10 | module.exports = function (file, options) { 11 | let {config, resolve} = options; 12 | let content = file.content.toString(); 13 | let {styleFiles, rext} = config; 14 | let dirName = file.dirname; 15 | 16 | // add css style dependencies 17 | styleFiles && styleFiles.forEach(item => { 18 | let relPath = relative(item, dirName); 19 | relPath = resolve(file, relPath); 20 | rext && (relPath = replaceExtname(relPath, rext)); 21 | content = `@import '${relPath}';\n` + content; 22 | }); 23 | 24 | return { 25 | content 26 | }; 27 | }; 28 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/css/plugins/postcss-plugin-px2rpx.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file postcss plugin px2rpx 3 | * @author xiaohong8023@outlook.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const postcss = require('postcss'); 9 | const Px2rpx = require('../../helper/px2rpx'); 10 | 11 | function shouldIgnore(path) { 12 | if (path.indexOf('node_modules') !== -1) { 13 | return true; 14 | } 15 | return false; 16 | } 17 | 18 | module.exports = postcss.plugin('postcss-plugin-px2rpx', function (opts = {}) { 19 | let {filePath, ignore} = opts; 20 | ignore || (ignore = shouldIgnore); 21 | 22 | return function (css, result) { 23 | if (ignore(filePath)) { 24 | return; 25 | } 26 | 27 | const px2rpxIns = new Px2rpx(opts); 28 | px2rpxIns.generateRpx(css); 29 | }; 30 | }); 31 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/css/plugins/postcss-plugin-wx2swan.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file postcss wxss to swan css plugin 3 | * @author xiaohong8023@outlook.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const postcss = require('postcss'); 9 | 10 | module.exports = postcss.plugin('postcss-plugin-wx2swan', function (opts = {}) { 11 | return function (css) { 12 | css.walkAtRules(rule => { 13 | if (rule.name === 'import') { 14 | rule.params = rule.params.replace(/\.wxss/, '.css'); 15 | } 16 | }); 17 | }; 18 | }); 19 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/helper/wxs2filter.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file wxs2filter.js 3 | * @author xiaohong8023@outlook.com 4 | * 5 | * // swan 不支持 6 | * module.exports.message = msg; 7 | * module.exports = fn; 8 | * 9 | * 当前仅处理了 10 | * module.exports = {} 11 | * 12 | * @see https://smartprogram.baidu.com/docs/develop/framework/view_filter/ 13 | * @see https://developers.weixin.qq.com/miniprogram/dev/framework/view/wxs/ 14 | */ 15 | 16 | function wxs2filter(content) { 17 | return content.replace(/module\.exports\s*=/, 'export default'); 18 | } 19 | 20 | module.exports = exports = wxs2filter; 21 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/js/babel-parser.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file The babel parser 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const parserHelper = require('./babel-parser-helper'); 9 | 10 | /** 11 | * Compile the file using babel 12 | * 13 | * @param {Object} file the file to process 14 | * @param {Object} options the compile options 15 | * @return {{content: string, sourceMap: string}} 16 | */ 17 | function compile(file, options) { 18 | return parserHelper.compile(file, options); 19 | } 20 | 21 | module.exports = exports = compile; 22 | 23 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/js/babel7-parser.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file The babel7 parser 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const parserHelper = require('./babel-parser-helper'); 9 | 10 | /** 11 | * Compile the file using babel 12 | * 13 | * @param {Object} file the file to process 14 | * @param {Object} options the compile options 15 | * @return {{content: string, sourceMap: string}} 16 | */ 17 | function compile(file, options) { 18 | return parserHelper.compile(file, options, 7); 19 | } 20 | 21 | module.exports = exports = compile; 22 | 23 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/js/plugins/babel-polyfill-plugins.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Local polyfill babel plugins 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | module.exports = { 9 | 10 | /** 11 | * Promise API polyfill babel plugin 12 | * 13 | * @type {Function} 14 | */ 15 | promise: require('../polyfill/promise'), 16 | 17 | 18 | /** 19 | * Regeneration runtime API polyfill babel plugin 20 | * 21 | * @type {Function} 22 | */ 23 | async: require('../polyfill/async') 24 | }; 25 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/js/typescript-parser.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file The typescript parser 3 | * @author luxiangqian@baidu.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const parserHelper = require('./babel-parser-helper'); 9 | 10 | /** 11 | * Compile the file using babel 12 | * 13 | * @param {Object} file the file to process 14 | * @param {Object} options the compile options 15 | * @return {{content: string, sourceMap: string}} 16 | */ 17 | function compile(file, options) { 18 | let config = options.config || {}; 19 | let presets = config.presets || []; 20 | 21 | let tsPreset = '@babel/preset-typescript'; 22 | if (!presets.includes(tsPreset)) { 23 | config.presets = [tsPreset].concat(presets); 24 | options.config = config; 25 | } 26 | 27 | return parserHelper.compile(file, options, 7); 28 | } 29 | 30 | module.exports = exports = compile; 31 | 32 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/json/json5-parser.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file The json5 parser 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const json5 = require('json5'); 9 | 10 | /** 11 | * Compile the file using json5 12 | * 13 | * @param {Object} file the file to process 14 | * @param {Object} options the compile options 15 | * @return {{content: string}} 16 | */ 17 | function compile(file, options) { 18 | let obj = json5.parse(file.content.toString()); 19 | let result = JSON.stringify(obj, null, 4); 20 | 21 | return { 22 | content: result 23 | }; 24 | } 25 | 26 | module.exports = exports = compile; 27 | 28 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/plugins/event/swan-event-plugin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Swan template event attribute transform plugin 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const {createSyntaxPlugin} = require('../helper'); 9 | const transformEvent = require('../../transform/base/event'); 10 | const {EVENT_REGEXP} = require('../../transform/base/constant'); 11 | const {parseWxSwanEventName} = require('./event-helper'); 12 | 13 | module.exports = createSyntaxPlugin({ 14 | attribute: { 15 | event: { 16 | match: EVENT_REGEXP, 17 | transform(attrs, name, tplOpts, opts, element) { 18 | transformEvent( 19 | attrs, 20 | name, 21 | tplOpts, 22 | name => parseWxSwanEventName(name, element, tplOpts, opts) 23 | ); 24 | } 25 | } 26 | } 27 | }); 28 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/plugins/event/wx-event-plugin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Weixin template event attribute transform plugin 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | module.exports = require('./swan-event-plugin'); 9 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/plugins/filter/ant-filter-plugin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Ant template filter transform plugin 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const {getFilterTransformer} = require('./filter-helper'); 9 | 10 | module.exports = getFilterTransformer({ 11 | tag: 'import-sjs', 12 | srcAttrName: 'from', 13 | moduleAttrName: 'name' 14 | }); 15 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/plugins/filter/swan-filter-plugin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Swan template filter transform plugin 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const {getFilterTransformer} = require('./filter-helper'); 9 | 10 | module.exports = getFilterTransformer({ 11 | tag: 'filter', 12 | srcAttrName: 'src', 13 | moduleAttrName: 'module' 14 | }); 15 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/plugins/filter/wx-filter-plugin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Weixin template filter transform plugin 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const {getFilterTransformer} = require('./filter-helper'); 9 | 10 | module.exports = getFilterTransformer({ 11 | tag: 'wxs', 12 | srcAttrName: 'src', 13 | moduleAttrName: 'module' 14 | }); 15 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/plugins/model/quick-model-plugin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file quick-model-plugin 3 | * @author xiaohong8023@outlook.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | // quick v-model not support, 9 | // have error log by itself 10 | module.exports = {}; 11 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/plugins/model/tt-model-plugin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tt-model-plugin 3 | * @author xiaohong8023@outlook.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | module.exports = require('./wx-model-plugin'); 9 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/plugins/syntax/ant-syntax-plugin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Mini program view template syntax transform plugin: okam syntax -> ant syntax 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const {createSyntaxPlugin} = require('../helper'); 9 | const transformers = require('../../transform/ant'); 10 | 11 | module.exports = createSyntaxPlugin(transformers); 12 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/plugins/syntax/quick-syntax-plugin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Mini program view template syntax transform plugin: okam syntax -> quick app syntax 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const {createSyntaxPlugin} = require('../helper'); 9 | const transformers = require('../../transform/quick'); 10 | 11 | module.exports = createSyntaxPlugin(transformers); 12 | 13 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/plugins/syntax/swan-syntax-plugin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Mini program view template syntax transform plugin: okam syntax -> swan syntax 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const {createSyntaxPlugin} = require('../helper'); 9 | const transformers = require('../../transform/swan'); 10 | 11 | module.exports = createSyntaxPlugin(transformers); 12 | 13 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/plugins/syntax/tt-syntax-plugin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Mini program view template syntax transform plugin: okam syntax -> toutiao syntax 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const {createSyntaxPlugin} = require('../helper'); 9 | const transformers = require('../../transform/tt'); 10 | 11 | module.exports = createSyntaxPlugin(transformers); 12 | 13 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/plugins/syntax/wx-syntax-plugin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Mini program view template syntax transform plugin: okam syntax -> wx syntax 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const {createSyntaxPlugin} = require('../helper'); 9 | const transformers = require('../../transform/wx'); 10 | 11 | module.exports = createSyntaxPlugin(transformers); 12 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/plugins/syntax/wx2swan-syntax-plugin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Mini program view template syntax transform plugin: wx syntax -> swan syntax 3 | * @author xiaohong8023@outlook.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const {createSyntaxPlugin} = require('../helper'); 9 | const transformers = require('../../transform/wx2swan'); 10 | 11 | module.exports = createSyntaxPlugin(transformers); 12 | 13 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/pug.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file pug template parser 3 | * @author asd123freedom@gmail.com 4 | */ 5 | 6 | const pug = require('pug'); 7 | 8 | /** 9 | * Compile pug template 10 | * 11 | * @param {Object} file the file to compile 12 | * @param {Object} options for compile pug template 13 | * @return {Object} 14 | */ 15 | function compilePug(file, options) { 16 | let content = file.content.toString(); 17 | // 取出用于pug模板的配置项,包括渲染所需的数据(data字段) 18 | let config = options.config || {}; 19 | // 考虑到给之后的处理器传递数据,所以这里强制 pretty 为true 20 | config.pretty = true; 21 | let data = config.data; 22 | delete config.data; 23 | 24 | let fn = pug.compile(content, config); 25 | content = fn(data); 26 | 27 | return { 28 | content 29 | }; 30 | } 31 | 32 | module.exports = compilePug; 33 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/serializer/bool-attributes.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Boolean tag attributes 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const boolAttributes = [ 9 | 'allowfullscreen', 10 | 'async', 11 | 'autofocus', 12 | 'autoplay', 13 | 'checked', 14 | 'controls', 15 | 'default', 16 | 'defer', 17 | 'disabled', 18 | 'hidden', 19 | 'ismap', 20 | 'loop', 21 | 'multiple', 22 | 'muted', 23 | 'open', 24 | 'readonly', 25 | 'required', 26 | 'reversed', 27 | 'scoped', 28 | 'seamless', 29 | 'selected', 30 | 'typemustmatch' 31 | ]; 32 | 33 | module.exports = boolAttributes; 34 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/serializer/selfclose-tags.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Self close tags 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const voidElements = [ 9 | 'area', 10 | 'base', 11 | 'br', 12 | 'col', 13 | 'command', 14 | 'embed', 15 | 'hr', 16 | 'img', 17 | 'input', 18 | 'keygen', 19 | 'link', 20 | 'meta', 21 | 'param', 22 | 'source', 23 | 'track', 24 | 'wbr' 25 | // deprecated tags 26 | // 'basefont', 27 | // 'frame', 28 | // 'isindex' 29 | ]; 30 | 31 | module.exports = voidElements; 32 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/serializer/unencoded-tags.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Unencoded element tags 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | module.exports = [ 9 | 'style', 10 | 'script', 11 | 'xmp', 12 | 'iframe', 13 | 'noembed', 14 | 'noframes', 15 | 'plaintext', 16 | 'noscript' 17 | ]; 18 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/transform/ant/canvas.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Transform ant canvas element 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | module.exports = function (element, tplOpts, opts) { 9 | let {logger} = tplOpts; 10 | let {attribs: attrs} = element; 11 | let canvasId = attrs && attrs['canvas-id']; 12 | if (canvasId) { 13 | let id = attrs.id; 14 | if (id && id !== canvasId) { 15 | logger.warn( 16 | 'canvas element `id` attribute value should be the same as the', 17 | '`canvas-id`, because in ant app using `id`, in weixin app', 18 | 'using `canvas-id`' 19 | ); 20 | } 21 | else if (!id) { 22 | attrs.id = canvasId; 23 | } 24 | 25 | delete attrs['canvas-id']; 26 | } 27 | }; 28 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/transform/ant/class.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Transform ant class attribute 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const transformClass = require('../base/class'); 9 | 10 | module.exports = function (attrs, name, tplOpts, opts, element) { 11 | transformClass(attrs, name, tplOpts, Object.assign({ 12 | arrToStr: true 13 | }, opts), element); 14 | }; 15 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/transform/ant/condition.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Transform ant condition syntax 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const transformCondition = require('../base/condition'); 9 | 10 | const CONDITION_MAP = { 11 | 'if': 'a:if', 12 | 'elif': 'a:elif', 13 | 'else-if': 'a:elif', 14 | 'else': 'a:else' 15 | }; 16 | 17 | module.exports = function (attrs, name, tplOpts, opts) { 18 | transformCondition(attrs, name, tplOpts, Object.assign({ 19 | syntaxMap: CONDITION_MAP, 20 | wrapCondition: true 21 | }, opts)); 22 | }; 23 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/transform/ant/for.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Transform ant for syntax 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const transformFor = require('../base/for'); 9 | 10 | module.exports = function (attrs, name, tplOpts, opts, element) { 11 | transformFor(attrs, name, tplOpts, Object.assign({ 12 | forDirectionName: 'a:for', 13 | forItemDirectiveName: 'a:for-item', 14 | forIndexDirectiveName: 'a:for-index' 15 | }, opts), element); 16 | }; 17 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/transform/ant/key.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Transform ant for key syntax 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const transformKey = require('../base/key'); 9 | 10 | module.exports = function (attrs, name, tplOpts, opts, element) { 11 | transformKey(attrs, name, tplOpts, Object.assign({ 12 | forKeyDirectiveName: 'a:key' 13 | }, opts), element); 14 | }; 15 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/transform/ant/tpl.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Transform ant tpl syntax 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const transformTpl = require('../base/tpl'); 9 | 10 | module.exports = function (element, tplOpts, opts) { 11 | transformTpl(element, tplOpts, Object.assign({ 12 | transformDataAttr: true 13 | }, opts)); 14 | }; 15 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/transform/base/constant.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file transform regexp constants 3 | * @author sharonzd 4 | */ 5 | 6 | 'use strict'; 7 | 8 | exports.DATA_BIND_REGEXP = /^:/; 9 | exports.CURLY_BRACE_HAS_REGEXP = /{[\s\S]*}/; 10 | exports.SQUARE_BRACKETS_REGEXP = /^\[[\s\S]*\]$/; 11 | exports.BRACKET_REGEXP = /\(|\)/g; 12 | exports.EVENT_REGEXP = /^@/; 13 | exports.EVENT_HANDLE_REGEXP = /^(\w+)\s*(?:\((.+)?\))?$/; 14 | exports.VARIABLE_EVENT = /([^'])\$event([^'])/g; 15 | exports.PLAIN_OBJECT_REGEXP = /^{[\s\S]*}$/; 16 | exports.FOR_ITEM_INDEX_REGEXP = /^(.+)\s+in\s+(.+)$/; 17 | 18 | exports.CONDITION_DIRECTIVES = ['if', 'elif', 'else-if', 'else']; 19 | 20 | exports.NOT_SUPPORT_MODIFIERS = ['prevent', 'once', 'passive']; 21 | 22 | exports.ENV_ELEMENT_REGEXP = /\-env$/; 23 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/transform/base/helper.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Template transformation helper 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | exports.removeEmptyTextNode = function (...nodes) { 9 | nodes.forEach(item => { 10 | if (item && item.type === 'text' && !item.data.trim().length) { 11 | item.removed = true; 12 | } 13 | }); 14 | }; 15 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/transform/base/key.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 解析 for 循环的 key 3 | * @author zhoudan03 4 | */ 5 | 6 | module.exports = function (attrs, name, tplOpts, opts, element) { 7 | let {logger, file} = tplOpts; 8 | let {forKeyDirectiveName} = opts; 9 | let itemName = element.forItemName || 'item'; 10 | let value = attrs[name]; 11 | 12 | let keyPrefix = itemName + '.'; 13 | if (value === itemName) { 14 | value = '*this'; 15 | } 16 | else if (value.startsWith(keyPrefix)) { 17 | value = value.substr(keyPrefix.length); 18 | } 19 | 20 | if (attrs.hasOwnProperty(forKeyDirectiveName)) { 21 | logger.warn( 22 | `${file.path} template attribute ${name} is conflicted with` 23 | + ` ${forKeyDirectiveName}` 24 | ); 25 | } 26 | 27 | attrs[forKeyDirectiveName] = value; 28 | delete attrs[name]; 29 | }; 30 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/transform/quick/class.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Transform quick app class attribute 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const transformClass = require('../base/class'); 9 | 10 | module.exports = function (attrs, name, tplOpts, opts, element) { 11 | transformClass(attrs, name, tplOpts, Object.assign({ 12 | arrToStr: true 13 | }, opts), element); 14 | }; 15 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/transform/quick/condition.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Transform quickApp condition syntax 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const transformCondition = require('../base/condition'); 9 | 10 | const CONDITION_MAP = { 11 | 'else-if': 'elif' 12 | }; 13 | 14 | module.exports = function (attrs, name, tplOpts, opts) { 15 | transformCondition(attrs, name, tplOpts, Object.assign({ 16 | syntaxMap: CONDITION_MAP, 17 | wrapCondition: true 18 | }, opts)); 19 | }; 20 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/transform/quick/key.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Transform quick app for key syntax 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | module.exports = function (attrs, name, tplOpts, opts, element) { 9 | let {logger, file} = tplOpts; 10 | let value = attrs[name]; 11 | let itemName = element.forItemName; 12 | 13 | let keyPrefix = itemName + '.'; 14 | if (value.startsWith(keyPrefix)) { 15 | value = value.substr(keyPrefix.length); 16 | } 17 | 18 | let newName = 'tid'; 19 | if (attrs.hasOwnProperty(newName)) { 20 | logger.warn(`${file.path} template attribute ${name} is conflicted with ${newName}`); 21 | } 22 | delete attrs[name]; 23 | 24 | attrs[newName] = value; 25 | }; 26 | 27 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/transform/swan/condition.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Transform swan condition syntax 3 | * if -> s-if 4 | * elif -> s-elif 5 | * else-if -> s-elif 6 | * else -> s-else 7 | * @author sparklewhy@gmail.com 8 | */ 9 | 10 | 'use strict'; 11 | 12 | const transformCondition = require('../base/condition'); 13 | 14 | const CONDITION_MAP = { 15 | 'if': 's-if', 16 | 'elif': 's-elif', 17 | 'else-if': 's-elif', 18 | 'else': 's-else' 19 | }; 20 | 21 | module.exports = function (attrs, name, tplOpts, opts) { 22 | transformCondition(attrs, name, tplOpts, Object.assign({ 23 | syntaxMap: CONDITION_MAP 24 | }, opts)); 25 | }; 26 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/transform/swan/data-bind.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Transform swan data binding 3 | * :attr="value" -> attr="{{value}}" 4 | * :attr="{a: 3, b: c}" -> attr="{{{a: 3, b: c}}}" 5 | * @author sparklewhy@gmail.com 6 | */ 7 | 8 | 'use strict'; 9 | 10 | const transformDataBind = require('../base/data-bind'); 11 | 12 | module.exports = function (attrs, name, tplOpts, opts, element) { 13 | transformDataBind(attrs, name, tplOpts, Object.assign({ 14 | tripleBrace: true 15 | }, opts), element); 16 | }; 17 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/transform/swan/for.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Transform swan for syntax 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const transformFor = require('../base/for'); 9 | 10 | module.exports = function (attrs, name, tplOpts, opts, element) { 11 | transformFor(attrs, name, tplOpts, Object.assign({ 12 | forDirectionName: 's-for', 13 | supportForAbbr: true, 14 | tripleBrace: true 15 | }, opts), element); 16 | }; 17 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/transform/swan/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Swan mini program syntax transformer 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | /* eslint-disable fecs-properties-quote */ 9 | /* eslint-disable fecs-min-vars-per-destructure */ 10 | 11 | const {merge} = require('../../../../util'); 12 | const {element, attribute, text} = require('../base'); 13 | 14 | module.exports = { 15 | element: merge({}, element), 16 | attribute: merge({}, attribute, { 17 | if: { 18 | transform: require('./condition') 19 | }, 20 | for: { 21 | transform: require('./for') 22 | }, 23 | key: { 24 | transform: require('./key') 25 | }, 26 | bind: { 27 | transform: require('./data-bind') 28 | } 29 | }), 30 | text 31 | }; 32 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/transform/swan/key.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 处理 swan 时的 key 3 | * @author zhoudan03 4 | */ 5 | 6 | module.exports = function (attrs, name, tplOpts) { 7 | // let {logger, file} = tplOpts; 8 | // logger.warn(`${file.path}, swan is not support with :key`); 9 | // delete attrs[name]; 10 | 11 | let newAttr = name.substr(1); 12 | let value = attrs[name]; 13 | attrs[newAttr] = `{{${value}}}`; 14 | delete attrs[name]; 15 | }; 16 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/transform/tt/class.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Transform toutiao class attribute 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const transformClass = require('../base/class'); 9 | 10 | module.exports = function (attrs, name, tplOpts, opts, element) { 11 | transformClass(attrs, name, tplOpts, Object.assign({ 12 | arrToStr: true 13 | }, opts), element); 14 | }; 15 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/transform/tt/condition.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Transform toutiao condition syntax 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const transformCondition = require('../base/condition'); 9 | 10 | const CONDITION_MAP = { 11 | 'if': 'tt:if', 12 | 'elif': 'tt:elif', 13 | 'else-if': 'tt:elif', 14 | 'else': 'tt:else' 15 | }; 16 | 17 | module.exports = function (attrs, name, tplOpts, opts) { 18 | transformCondition(attrs, name, tplOpts, Object.assign({ 19 | syntaxMap: CONDITION_MAP, 20 | wrapCondition: true 21 | }, opts)); 22 | }; 23 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/transform/tt/data-bind.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Transform toutiao data binding 3 | * :attr="value" -> attr="{{value}}" 4 | * :attr="{a: 3, b: c}" -> attr="{{ {a: 3, b: c} }}" 5 | * @author sparklewhy@gmail.com 6 | */ 7 | 8 | 'use strict'; 9 | 10 | const transformDataBind = require('../base/data-bind'); 11 | 12 | module.exports = function (attrs, name, tplOpts, opts, element) { 13 | transformDataBind(attrs, name, tplOpts, Object.assign({ 14 | tripleBrace: true 15 | }, opts), element); 16 | }; 17 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/transform/tt/for.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Transform toutiao for syntax 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const transformFor = require('../base/for'); 9 | 10 | module.exports = function (attrs, name, tplOpts, opts, element) { 11 | transformFor(attrs, name, tplOpts, Object.assign({ 12 | forDirectionName: 'tt:for', 13 | forItemDirectiveName: 'tt:for-item', 14 | forIndexDirectiveName: 'tt:for-index', 15 | tripleBrace: true 16 | }, opts), element); 17 | }; 18 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/transform/tt/key.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Transform toutiao for key syntax 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const transformKey = require('../base/key'); 9 | 10 | module.exports = function (attrs, name, tplOpts, opts, element) { 11 | transformKey(attrs, name, tplOpts, Object.assign({ 12 | forKeyDirectiveName: 'tt:key' 13 | }, opts), element); 14 | }; 15 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/transform/tt/tpl.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Transform toutiao tpl syntax 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const transformTpl = require('../base/tpl'); 9 | 10 | module.exports = function (element, tplOpts, opts) { 11 | transformTpl(element, tplOpts, Object.assign({ 12 | transformDataAttr: true 13 | }, opts)); 14 | }; 15 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/transform/wx/condition.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Transform wx condition syntax 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const transformCondition = require('../base/condition'); 9 | 10 | const CONDITION_MAP = { 11 | 'if': 'wx:if', 12 | 'elif': 'wx:elif', 13 | 'else-if': 'wx:elif', 14 | 'else': 'wx:else' 15 | }; 16 | 17 | module.exports = function (attrs, name, tplOpts, opts) { 18 | transformCondition(attrs, name, tplOpts, Object.assign({ 19 | syntaxMap: CONDITION_MAP, 20 | wrapCondition: true 21 | }, opts)); 22 | }; 23 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/transform/wx/data-bind.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Transform wx data binding 3 | * :attr="value" -> attr="{{value}}" 4 | * :attr="{a: 3, b: c}" -> attr="{{ {a: 3, b: c} }}" 5 | * @author sparklewhy@gmail.com 6 | */ 7 | 8 | 'use strict'; 9 | 10 | const transformDataBind = require('../base/data-bind'); 11 | 12 | module.exports = function (attrs, name, tplOpts, opts, element) { 13 | transformDataBind(attrs, name, tplOpts, Object.assign({ 14 | tripleBrace: true 15 | }, opts), element); 16 | }; 17 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/transform/wx/for.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Transform wx for syntax 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const transformFor = require('../base/for'); 9 | 10 | module.exports = function (attrs, name, tplOpts, opts, element) { 11 | transformFor(attrs, name, tplOpts, Object.assign({ 12 | forDirectionName: 'wx:for', 13 | forItemDirectiveName: 'wx:for-item', 14 | forIndexDirectiveName: 'wx:for-index', 15 | tripleBrace: true 16 | }, opts), element); 17 | }; 18 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/transform/wx/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Weixin mini program syntax transformer 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | /* eslint-disable fecs-properties-quote */ 9 | /* eslint-disable fecs-min-vars-per-destructure */ 10 | 11 | const {merge} = require('../../../../util'); 12 | const {element, attribute, text} = require('../base'); 13 | 14 | module.exports = { 15 | element: merge({}, element, { 16 | tpl: { 17 | transform: require('./tpl') 18 | } 19 | }), 20 | attribute: merge({}, attribute, { 21 | if: { 22 | transform: require('./condition') 23 | }, 24 | for: { 25 | transform: require('./for') 26 | }, 27 | key: { 28 | transform: require('./key') 29 | }, 30 | bind: { 31 | transform: require('./data-bind') 32 | } 33 | }), 34 | text 35 | }; 36 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/transform/wx/key.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Transform weixin for key syntax 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const transformKey = require('../base/key'); 9 | 10 | module.exports = function (attrs, name, tplOpts, opts, element) { 11 | transformKey(attrs, name, tplOpts, Object.assign({ 12 | forKeyDirectiveName: 'wx:key' 13 | }, opts), element); 14 | }; 15 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/transform/wx/tpl.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Transform weixin tpl syntax 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const transformTpl = require('../base/tpl'); 9 | 10 | module.exports = function (element, tplOpts, opts) { 11 | transformTpl(element, tplOpts, Object.assign({ 12 | transformDataAttr: true 13 | }, opts)); 14 | }; 15 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/transform/wx2swan/attribute.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Element attribute transformer 3 | * @author xiaohong8023@outlook.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const {WX_DIRECTIVES_REGEXP} = require('./constant'); 9 | const directivesTransform = require('./directives'); 10 | 11 | module.exports = { 12 | directives: { 13 | match: WX_DIRECTIVES_REGEXP, 14 | transform: directivesTransform 15 | } 16 | }; 17 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/transform/wx2swan/constant.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file transform regexp constants 3 | * @author xiaohong8023@outlook.com 4 | */ 5 | 6 | 7 | 'use strict'; 8 | 9 | exports.WX_DIRECTIVES_REGEXP = /^wx:/; 10 | exports.DOUBLE_BRACES_REGEXP = /^{{.*}}$/; 11 | // 'wx:if' 放第一个元素 作为 for if 并存处理时的判断 12 | exports.CONDITION_DIRECTIVES = ['wx:if', 'wx:elif', 'wx:else']; 13 | exports.FOR_DIRECTIVES = ['wx:for', 'wx:for-items', 'wx:for-item', 'wx:for-index', 'wx:key']; 14 | -------------------------------------------------------------------------------- /packages/okam-build/lib/processor/template/transform/wx2swan/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file weixin mini program syntax tranform to swan 3 | * @author xiaohong8023@outlook.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const elementTransformerMap = require('./element'); 9 | const attrTransformerMap = require('./attribute'); 10 | 11 | module.exports = { 12 | element: elementTransformerMap, 13 | attribute: attrTransformerMap 14 | }; 15 | -------------------------------------------------------------------------------- /packages/okam-build/lib/server/ConnectServer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Dev server based on connect 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const ServerBase = require('./ServerBase'); 9 | 10 | class ConnectServer extends ServerBase { 11 | constructor(options) { 12 | super(options); 13 | 14 | let connect = this.serverType; 15 | this.app = connect(); 16 | } 17 | } 18 | 19 | module.exports = exports = ConnectServer; 20 | -------------------------------------------------------------------------------- /packages/okam-build/lib/server/ExpressServer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Dev server based on express 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const ServerBase = require('./ServerBase'); 9 | 10 | class ExpressServer extends ServerBase { 11 | constructor(options) { 12 | super(options); 13 | 14 | let express = this.serverType; 15 | this.app = express(); 16 | } 17 | } 18 | 19 | module.exports = exports = ExpressServer; 20 | -------------------------------------------------------------------------------- /packages/okam-build/lib/server/KoaServer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Dev server based on koa2 3 | * @author sparklewhy@gmail.com 4 | */ 5 | 6 | 'use strict'; 7 | 8 | const ServerBase = require('./ServerBase'); 9 | 10 | class KoaServer extends ServerBase { 11 | constructor(options) { 12 | super(options); 13 | 14 | // let Koa = require('koa'); 15 | let Koa = this.serverType; 16 | this.app = new Koa(); 17 | } 18 | } 19 | 20 | module.exports = exports = KoaServer; 21 | -------------------------------------------------------------------------------- /packages/okam-build/test/fixtures/condition/condition.expect.tpl: -------------------------------------------------------------------------------- 1 | hello 2 | world 3 | world 4 | goodbye 5 | -------------------------------------------------------------------------------- /packages/okam-build/test/fixtures/condition/condition.tpl: -------------------------------------------------------------------------------- 1 | hello 2 | world 3 | world 4 | goodbye 5 | -------------------------------------------------------------------------------- /packages/okam-build/test/fixtures/condition/v-condition.expect.tpl: -------------------------------------------------------------------------------- 1 | hello 2 | world 3 | world 4 | goodbye 5 | hello 6 | world 7 | world 8 | goodbye 9 | hello 10 | -------------------------------------------------------------------------------- /packages/okam-build/test/fixtures/condition/v-condition.tpl: -------------------------------------------------------------------------------- 1 | hello 2 | world 3 | world 4 | goodbye 5 | hello 6 | world 7 | world 8 | goodbye 9 | hello 10 | -------------------------------------------------------------------------------- /packages/okam-build/test/fixtures/filters/test.babel6.expect: -------------------------------------------------------------------------------- 1 | /*Auto generated filter code by okam*/"use strict"; 2 | 3 | module.exports = { 4 | toUpperCase(str) { 5 | return str.toUpperCase(); 6 | } 7 | 8 | }; -------------------------------------------------------------------------------- /packages/okam-build/test/fixtures/filters/test.babel7.expect: -------------------------------------------------------------------------------- 1 | /*Auto generated filter code by okam*/ 2 | "use strict"; 3 | 4 | export default { 5 | toUpperCase(str) { 6 | return str.toUpperCase(); 7 | } 8 | 9 | }; -------------------------------------------------------------------------------- /packages/okam-build/test/fixtures/filters/test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file test filter 3 | * @author xxx 4 | */ 5 | 6 | export default { 7 | data: {}, 8 | 9 | filters: { 10 | toUpperCase(str) { 11 | return str.toUpperCase(); 12 | } 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /packages/okam-build/test/fixtures/for/v-for.expect.tpl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 遍历数字5: {{item}} 4 | 5 | 6 | for of 遍历数组{{item}} 7 | 8 | of遍历字面量对象: hello {{index}} {{item}} 9 | of遍历字面量对象2: hello {{index}} {{item}} 10 | of遍历字面量对象3: hello {{index}} {{item}} 11 | 12 | -------------------------------------------------------------------------------- /packages/okam-build/test/fixtures/for/v-for.tpl: -------------------------------------------------------------------------------- 1 |
2 |
3 | 遍历数字5: {{item}} 4 |
5 |
6 | for of 遍历数组{{item}} 7 |
8 | of遍历字面量对象: hello {{index}} {{item}} 9 | of遍历字面量对象2: hello {{index}} {{item}} 10 | of遍历字面量对象3: hello {{index}} {{item}} 11 |
12 | -------------------------------------------------------------------------------- /packages/okam-build/test/fixtures/model/model-conflict-ant.expect.tpl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /packages/okam-build/test/fixtures/model/model-conflict-swan.expect.tpl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /packages/okam-build/test/fixtures/model/model-conflict-wx.expect.tpl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /packages/okam-build/test/fixtures/model/model-conflict.tpl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /packages/okam-build/test/fixtures/model/model-nosupport-ant.expect.tpl: -------------------------------------------------------------------------------- 1 | 2 | 不支持 3 | 不支持 4 | 不支持 5 | 6 | -------------------------------------------------------------------------------- /packages/okam-build/test/fixtures/model/model-nosupport-swan.expect.tpl: -------------------------------------------------------------------------------- 1 | 2 | 不支持 3 | 不支持 4 | 不支持 5 | 6 | -------------------------------------------------------------------------------- /packages/okam-build/test/fixtures/model/model-nosupport-wx.expect.tpl: -------------------------------------------------------------------------------- 1 | 2 | 不支持 3 | 不支持 4 | 不支持 5 | 6 | -------------------------------------------------------------------------------- /packages/okam-build/test/fixtures/model/model-nosupport.tpl: -------------------------------------------------------------------------------- 1 | 2 | 不支持 3 | 不支持 4 | 不支持 5 | 6 | -------------------------------------------------------------------------------- /packages/okam-build/test/fixtures/result.tpl: -------------------------------------------------------------------------------- 1 | 2 | 3 | abc 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 |
25 | -------------------------------------------------------------------------------- /packages/okam-build/test/fixtures/template/element.expect.swan: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 12 | 13 | Click me! 14 | 15 | 16 | 17 | 20 | 21 | 22 |