pixuireactcomponents 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -6
- package/package.json +9 -66
- package/tsconfig.json +27 -13
- package/{src/pixUIReactComponents/ui → ui}/components/slapface/Slapface.tsx +17 -17
- package/ui/sample/Slapface/SlapfaceDemo.tsx +30 -0
- package/.eslintignore +0 -7
- package/.eslintrc.js +0 -48
- package/.pixiderc/apps.json +0 -12
- package/.pixiderc/devel-config.meta.json +0 -23
- package/.pixiderc/postinstall.js +0 -17
- package/.pixiderc/util.js +0 -136
- package/.pixiderc/webpack.js +0 -180
- package/faas/helloworld.js +0 -8
- package/gen/pbo/pandora_pb.d.ts +0 -1179
- package/gen/pbo/pandora_pb.js +0 -10475
- package/gen/pbo/pandora_pb_service.d.ts +0 -1317
- package/gen/pbo/pandora_pb_service.js +0 -2307
- package/gen/pbo/test_pb.d.ts +0 -99
- package/gen/pbo/test_pb.js +0 -889
- package/gen/pbo/test_pb_service.d.ts +0 -82
- package/gen/pbo/test_pb_service.js +0 -117
- package/lib/assets/border.png +0 -0
- package/lib/assets/check.html +0 -54
- package/lib/assets/pixui.png +0 -0
- package/lib/assets/preact.png +0 -0
- package/lib/check/main.less +0 -63
- package/lib/check/main.tsx +0 -42
- package/lib/check/tool.js +0 -3
- package/lib/check/util.tsx +0 -107
- package/lib/dom.ts +0 -16
- package/lib/ext.d.ts +0 -95
- package/lib/grpc-web/dist/ChunkParser.js +0 -115
- package/lib/grpc-web/dist/ChunkParser.js.map +0 -1
- package/lib/grpc-web/dist/Code.js +0 -58
- package/lib/grpc-web/dist/Code.js.map +0 -1
- package/lib/grpc-web/dist/client.js +0 -299
- package/lib/grpc-web/dist/client.js.map +0 -1
- package/lib/grpc-web/dist/debug.js +0 -16
- package/lib/grpc-web/dist/debug.js.map +0 -1
- package/lib/grpc-web/dist/detach.js +0 -7
- package/lib/grpc-web/dist/detach.js.map +0 -1
- package/lib/grpc-web/dist/index.js +0 -29
- package/lib/grpc-web/dist/index.js.map +0 -1
- package/lib/grpc-web/dist/invoke.js +0 -32
- package/lib/grpc-web/dist/invoke.js.map +0 -1
- package/lib/grpc-web/dist/message.js +0 -3
- package/lib/grpc-web/dist/message.js.map +0 -1
- package/lib/grpc-web/dist/metadata.js +0 -5
- package/lib/grpc-web/dist/metadata.js.map +0 -1
- package/lib/grpc-web/dist/service.js +0 -3
- package/lib/grpc-web/dist/service.js.map +0 -1
- package/lib/grpc-web/dist/transports/Transport.js +0 -13
- package/lib/grpc-web/dist/transports/Transport.js.map +0 -1
- package/lib/grpc-web/dist/transports/http/fetch.js +0 -112
- package/lib/grpc-web/dist/transports/http/fetch.js.map +0 -1
- package/lib/grpc-web/dist/transports/http/http.js +0 -15
- package/lib/grpc-web/dist/transports/http/http.js.map +0 -1
- package/lib/grpc-web/dist/transports/http/xhr.js +0 -127
- package/lib/grpc-web/dist/transports/http/xhr.js.map +0 -1
- package/lib/grpc-web/dist/transports/http/xhrUtil.js +0 -37
- package/lib/grpc-web/dist/transports/http/xhrUtil.js.map +0 -1
- package/lib/grpc-web/dist/transports/websocket/websocket.js +0 -95
- package/lib/grpc-web/dist/transports/websocket/websocket.js.map +0 -1
- package/lib/grpc-web/dist/typings/ChunkParser.d.ts +0 -17
- package/lib/grpc-web/dist/typings/Code.d.ts +0 -20
- package/lib/grpc-web/dist/typings/client.d.ts +0 -22
- package/lib/grpc-web/dist/typings/debug.d.ts +0 -1
- package/lib/grpc-web/dist/typings/detach.d.ts +0 -1
- package/lib/grpc-web/dist/typings/index.d.ts +0 -60
- package/lib/grpc-web/dist/typings/invoke.d.ts +0 -17
- package/lib/grpc-web/dist/typings/message.d.ts +0 -8
- package/lib/grpc-web/dist/typings/metadata.d.ts +0 -2
- package/lib/grpc-web/dist/typings/service.d.ts +0 -16
- package/lib/grpc-web/dist/typings/transports/Transport.d.ts +0 -22
- package/lib/grpc-web/dist/typings/transports/http/fetch.d.ts +0 -6
- package/lib/grpc-web/dist/typings/transports/http/http.d.ts +0 -5
- package/lib/grpc-web/dist/typings/transports/http/xhr.d.ts +0 -27
- package/lib/grpc-web/dist/typings/transports/http/xhrUtil.d.ts +0 -3
- package/lib/grpc-web/dist/typings/transports/websocket/websocket.d.ts +0 -2
- package/lib/grpc-web/dist/typings/unary.d.ts +0 -20
- package/lib/grpc-web/dist/typings/util.d.ts +0 -2
- package/lib/grpc-web/dist/unary.js +0 -44
- package/lib/grpc-web/dist/unary.js.map +0 -1
- package/lib/grpc-web/dist/util.js +0 -11
- package/lib/grpc-web/dist/util.js.map +0 -1
- package/lib/grpcTransport/PixHttp2Transport.ts +0 -104
- package/lib/grpcTransport/PixLuaTransport.ts +0 -80
- package/lib/pi_component/tinyList/tinyList.js +0 -573
- package/lib/pi_component/tinyList/tinyList.tsx +0 -586
- package/lib/preact/compat/src/Children.js +0 -26
- package/lib/preact/compat/src/PureComponent.js +0 -19
- package/lib/preact/compat/src/events.js +0 -36
- package/lib/preact/compat/src/forwardRef.js +0 -29
- package/lib/preact/compat/src/index.d.ts +0 -121
- package/lib/preact/compat/src/index.js +0 -159
- package/lib/preact/compat/src/internal.d.ts +0 -45
- package/lib/preact/compat/src/memo.js +0 -34
- package/lib/preact/compat/src/portals.js +0 -85
- package/lib/preact/compat/src/render.js +0 -166
- package/lib/preact/compat/src/suspense-list.d.ts +0 -14
- package/lib/preact/compat/src/suspense-list.js +0 -127
- package/lib/preact/compat/src/suspense.d.ts +0 -15
- package/lib/preact/compat/src/suspense.js +0 -165
- package/lib/preact/compat/src/util.js +0 -23
- package/lib/preact/hooks/src/index.d.ts +0 -133
- package/lib/preact/hooks/src/index.js +0 -339
- package/lib/preact/hooks/src/internal.d.ts +0 -55
- package/lib/preact/src/clone-element.js +0 -27
- package/lib/preact/src/compat.ts +0 -0
- package/lib/preact/src/component.js +0 -219
- package/lib/preact/src/constants.js +0 -3
- package/lib/preact/src/create-context.js +0 -55
- package/lib/preact/src/create-element.js +0 -102
- package/lib/preact/src/css.d.ts +0 -30341
- package/lib/preact/src/diff/catch-error.js +0 -41
- package/lib/preact/src/diff/children.js +0 -259
- package/lib/preact/src/diff/index.js +0 -445
- package/lib/preact/src/diff/props.js +0 -163
- package/lib/preact/src/index.d.ts +0 -275
- package/lib/preact/src/index.js +0 -14
- package/lib/preact/src/internal.d.ts +0 -94
- package/lib/preact/src/jsx.d.ts +0 -884
- package/lib/preact/src/options.js +0 -16
- package/lib/preact/src/render.js +0 -98
- package/lib/preact/src/util.js +0 -25
- package/lib/preact-router/.travis.yml +0 -3
- package/lib/preact-router/LICENSE +0 -21
- package/lib/preact-router/README.md +0 -254
- package/lib/preact-router/index.d.ts +0 -71
- package/lib/preact-router/match/index.d.ts +0 -16
- package/lib/preact-router/match/package.json +0 -13
- package/lib/preact-router/match/src/cjs.js +0 -4
- package/lib/preact-router/match/src/index.js +0 -36
- package/lib/preact-router/package-lock.json +0 -12330
- package/lib/preact-router/package.json +0 -78
- package/lib/preact-router/src/cjs.js +0 -11
- package/lib/preact-router/src/index.js +0 -270
- package/lib/preact-router/src/util.js +0 -87
- package/lib/react-window/src/FixedSizeGrid.js +0 -244
- package/lib/react-window/src/FixedSizeList.js +0 -130
- package/lib/react-window/src/VariableSizeGrid.js +0 -507
- package/lib/react-window/src/VariableSizeList.js +0 -316
- package/lib/react-window/src/__tests__/FixedSizeGrid.js +0 -1336
- package/lib/react-window/src/__tests__/FixedSizeList.js +0 -966
- package/lib/react-window/src/__tests__/VariableSizeGrid.js +0 -779
- package/lib/react-window/src/__tests__/VariableSizeList.js +0 -442
- package/lib/react-window/src/__tests__/__snapshots__/FixedSizeGrid.js.snap +0 -912
- package/lib/react-window/src/__tests__/__snapshots__/FixedSizeList.js.snap +0 -568
- package/lib/react-window/src/__tests__/__snapshots__/VariableSizeGrid.js.snap +0 -542
- package/lib/react-window/src/__tests__/__snapshots__/VariableSizeList.js.snap +0 -331
- package/lib/react-window/src/__tests__/areEqual.js +0 -32
- package/lib/react-window/src/__tests__/shouldComponentUpdate.js +0 -36
- package/lib/react-window/src/areEqual.js +0 -18
- package/lib/react-window/src/createGridComponent.js +0 -919
- package/lib/react-window/src/createListComponent.js +0 -729
- package/lib/react-window/src/domHelpers.js +0 -72
- package/lib/react-window/src/index.js +0 -9
- package/lib/react-window/src/shallowDiffers.js +0 -17
- package/lib/react-window/src/shouldComponentUpdate.js +0 -16
- package/lib/react-window/src/test.js.flow +0 -382
- package/lib/react-window/src/timer.js +0 -36
- package/src/app/demopage.tsx +0 -77
- package/src/app/index.html +0 -48
- package/src/app/main.tsx +0 -30
- package/src/asset/Textures/Alert/bg_tips.png +0 -0
- package/src/asset/Textures/Alert/btn_zhedie_a.png +0 -0
- package/src/asset/Textures/Alert/com_home_bg_left.png +0 -0
- package/src/asset/Textures/Alert/com_home_bg_rightbar.png +0 -0
- package/src/asset/Textures/Commons/com_home_bg_a.png +0 -0
- package/src/asset/Textures/Commons/com_home_bg_back_top.png +0 -0
- package/src/asset/Textures/Commons/com_home_bg_bottombar_sheet.png +0 -0
- package/src/asset/Textures/Commons/com_home_bg_list_xiala.png +0 -0
- package/src/asset/Textures/Commons/com_home_bg_rightbar_line.png +0 -0
- package/src/asset/Textures/Commons/com_home_bg_rightbar_selected.png +0 -0
- package/src/asset/Textures/Commons/com_home_bg_touxiang_140.png +0 -0
- package/src/asset/Textures/Commons/com_home_bg_touxiang_60.png +0 -0
- package/src/asset/Textures/Commons/com_home_bg_touxiang_80.png +0 -0
- package/src/asset/Textures/Commons/com_home_btn_back.png +0 -0
- package/src/asset/Textures/Commons/com_home_btn_bottombar.png +0 -0
- package/src/asset/Textures/Commons/com_home_btn_bottombar_fadongtai.png +0 -0
- package/src/asset/Textures/Commons/com_home_btn_close.png +0 -0
- package/src/asset/Textures/Commons/com_home_btn_guanzhu_126.png +0 -0
- package/src/asset/Textures/Commons/com_home_btn_guanzhu_86.png +0 -0
- package/src/asset/Textures/Commons/com_home_btn_left_bianji.png +0 -0
- package/src/asset/Textures/Commons/com_home_btn_left_dongtai.png +0 -0
- package/src/asset/Textures/Commons/com_home_btn_left_touxiang.png +0 -0
- package/src/asset/Textures/Commons/com_home_btn_selet.png +0 -0
- package/src/asset/Textures/Commons/com_home_btn_yiguanzhu_126.png +0 -0
- package/src/asset/Textures/Commons/com_home_btn_yiguanzhu_86.png +0 -0
- package/src/asset/Textures/Commons/com_home_icon_bottombar_fadongtai.png +0 -0
- package/src/asset/Textures/Commons/com_home_icon_bottombar_red.png +0 -0
- package/src/asset/Textures/Commons/com_home_icon_loading.png +0 -0
- package/src/asset/Textures/Commons/com_home_pic_touxiang_moren.png +0 -0
- package/src/asset/Textures/Commons/com_home_tab_left_a.png +0 -0
- package/src/asset/Textures/Commons/com_home_tab_left_b.png +0 -0
- package/src/asset/Textures/Commons/com_home_tab_left_c.png +0 -0
- package/src/asset/Textures/Commons/feedItems/gc1_huati_icon_middle_v.png +0 -0
- package/src/asset/Textures/Commons/feedItems/gc1_huati_icon_middle_yonghurenzheng.png +0 -0
- package/src/asset/Textures/Commons/feedItems/pinglun_bg.png +0 -0
- package/src/asset/Textures/Commons/feedItems/pinglun_bg_line.png +0 -0
- package/src/asset/Textures/Commons/feedItems/pinglun_bg_middle_chakan.png +0 -0
- package/src/asset/Textures/Commons/feedItems/pinglun_bg_middle_input.png +0 -0
- package/src/asset/Textures/Commons/feedItems/pinglun_bg_zan.png +0 -0
- package/src/asset/Textures/Commons/feedItems/pinglun_btn_middle_input.png +0 -0
- package/src/asset/Textures/Commons/feedItems/pinglun_btn_more.png +0 -0
- package/src/asset/Textures/Commons/feedItems/pinglun_btn_normal.png +0 -0
- package/src/asset/Textures/Commons/feedItems/pinglun_btn_photo_more.png +0 -0
- package/src/asset/Textures/Commons/feedItems/pinglun_btn_zhedie_a.png +0 -0
- package/src/asset/Textures/Commons/feedItems/pinglun_btn_zhedie_a_shadow.png +0 -0
- package/src/asset/Textures/Commons/feedItems/pinglun_btn_zhedie_b_normal.png +0 -0
- package/src/asset/Textures/Commons/feedItems/pinglun_btn_zhedie_b_pressed.png +0 -0
- package/src/asset/Textures/Commons/feedItems/pinglun_icon_a_normal.png +0 -0
- package/src/asset/Textures/Commons/feedItems/pinglun_icon_a_pressed.png +0 -0
- package/src/asset/Textures/Commons/feedItems/pinglun_icon_b_normal.png +0 -0
- package/src/asset/Textures/Commons/feedItems/pinglun_icon_c_normal.png +0 -0
- package/src/asset/Textures/Commons/feedItems/pinglun_icon_d.png +0 -0
- package/src/asset/Textures/Commons/feedItems/pinglun_icon_e.png +0 -0
- package/src/asset/Textures/Commons/feedItems/pinglun_icon_f_share.png +0 -0
- package/src/asset/Textures/Commons/feedItems/pinglun_icon_middle_input_back.png +0 -0
- package/src/asset/Textures/Commons/gc1_huati_bg_middle_topbtn.png +0 -0
- package/src/asset/Textures/Commons/gc1_huati_bg_middle_topbtn_pressd.png +0 -0
- package/src/asset/Textures/Commons/karaoke/rukou_bg_music.png +0 -0
- package/src/asset/Textures/Commons/karaoke/rukou_btn_a.png +0 -0
- package/src/asset/Textures/Commons/karaoke/rukou_btn_b.png +0 -0
- package/src/asset/Textures/Commons/karaoke/rukou_icon_b.png +0 -0
- package/src/asset/Textures/Commons/karaoke/rukou_icon_d.png +0 -0
- package/src/asset/Textures/Commons/karaoke/rukou_icon_e.png +0 -0
- package/src/asset/Textures/Commons/rukou_bg_bottombar_line.png +0 -0
- package/src/asset/Textures/Commons/rukou_icon_a.png +0 -0
- package/src/asset/Textures/Commons/tc_bianji_tab_a.png +0 -0
- package/src/asset/Textures/Commons/tc_zanshang_bg_line.png +0 -0
- package/src/asset/Textures/Commons/touxiang_bg_tishikuang.png +0 -0
- package/src/asset/Textures/Commons/video/rukou_icon_shipin.png +0 -0
- package/src/asset/Textures/Commons/video/xiangce_btn_bofang.png +0 -0
- package/src/asset/Textures/Commons/voice/rukou_icon_yuyin.png +0 -0
- package/src/asset/Textures/Commons/voice/tc_yuyin_bg.png +0 -0
- package/src/asset/Textures/Commons/voice/tc_yuyin_bg_load.png +0 -0
- package/src/asset/Textures/Commons/voice/tc_yuyin_bg_xinhao_a.png +0 -0
- package/src/asset/Textures/Commons/voice/tc_yuyin_bg_xinhao_b.png +0 -0
- package/src/asset/Textures/Commons/xiangce_icon_bottombar_gulita.png +0 -0
- package/src/asset/Textures/SocialSecond/com_tc_bg.png +0 -0
- package/src/asset/Textures/SocialSecond/com_tc_bg_bottom.png +0 -0
- package/src/asset/Textures/SocialSecond/com_tc_bg_input.png +0 -0
- package/src/asset/Textures/SocialSecond/com_tc_bg_tips.png +0 -0
- package/src/asset/Textures/SocialSecond/com_tc_bg_topbar_a.png +0 -0
- package/src/asset/Textures/SocialSecond/com_tc_bg_topbar_line.png +0 -0
- package/src/asset/Textures/SocialSecond/com_tc_bg_upload_photo.png +0 -0
- package/src/asset/Textures/SocialSecond/com_tc_bg_upload_photo_line.png +0 -0
- package/src/asset/Textures/SocialSecond/com_tc_bg_zhaopian_line.png +0 -0
- package/src/asset/Textures/SocialSecond/com_tc_btn.png +0 -0
- package/src/asset/Textures/SocialSecond/com_tc_btn_close.png +0 -0
- package/src/asset/Textures/SocialSecond/com_tc_btn_upload_photo.png +0 -0
- package/src/asset/Textures/SocialSecond/com_tc_radio_normal.png +0 -0
- package/src/asset/Textures/SocialSecond/com_tc_radio_normal_@slice_0.png +0 -0
- package/src/asset/Textures/SocialSecond/com_tc_radio_selected.png +0 -0
- package/src/asset/Textures/SocialSecond/com_tc_tab_a.png +0 -0
- package/src/asset/Textures/SocialSecond/gc1_huati_bg_middle_topbar.png +0 -0
- package/src/asset/Textures/SocialSecond/gc1_huati_bg_middle_topbar_pre.png +0 -0
- package/src/asset/Textures/SocialSecond/newmessage_bg_left_line.png +0 -0
- package/src/asset/Textures/SocialSecond/newmessage_bg_left_normal.png +0 -0
- package/src/asset/Textures/SocialSecond/newmessage_bg_left_selected.png +0 -0
- package/src/asset/Textures/SocialSecond/newmessage_bg_middle_new.png +0 -0
- package/src/asset/Textures/SocialSecond/paihang_bg_list.png +0 -0
- package/src/asset/Textures/SocialSecond/paihang_bg_list_line.png +0 -0
- package/src/asset/Textures/SocialSecond/paihang_bg_list_my.png +0 -0
- package/src/asset/Textures/SocialSecond/paihang_bg_list_top.png +0 -0
- package/src/asset/Textures/SocialSecond/paihang_bg_topbar_a.png +0 -0
- package/src/asset/Textures/SocialSecond/paihang_icon_topbar_selected.png +0 -0
- package/src/asset/Textures/SocialSecond/paihang_pic_1.png +0 -0
- package/src/asset/Textures/SocialSecond/paihang_pic_2.png +0 -0
- package/src/asset/Textures/SocialSecond/tc_fadongtai_btn_close.png +0 -0
- package/src/asset/Textures/SocialSecond/tc_guanzhu_bg_topbar.png +0 -0
- package/src/asset/Textures/SocialSecond/tc_guanzhu_bg_topbar_selected.png +0 -0
- package/src/asset/Textures/SocialSecond/tc_liwu_bg.png +0 -0
- package/src/asset/Textures/SocialSecond/tc_liwu_bg_daoju.png +0 -0
- package/src/asset/Textures/SocialSecond/tc_liwu_btn_a.png +0 -0
- package/src/asset/Textures/SocialSecond/tc_liwu_btn_b.png +0 -0
- package/src/asset/Textures/SocialSecond/tc_liwu_btn_c.png +0 -0
- package/src/asset/Textures/SocialSecond/tc_liwu_pic_daoju1.png +0 -0
- package/src/asset/Textures/SocialSecond/tc_liwu_pic_daoju2.png +0 -0
- package/src/asset/Textures/SocialSecond/tc_liwu_pic_daoju3.png +0 -0
- package/src/asset/Textures/SocialSecond/tc_pinglun_bg.png +0 -0
- package/src/asset/Textures/SocialSecond/tc_shipin_tianjiashipin.png +0 -0
- package/src/asset/Textures/SocialSecond/tc_yuyin_bg.png +0 -0
- package/src/asset/Textures/SocialSecond/tc_yuyin_bg_delete.png +0 -0
- package/src/asset/Textures/SocialSecond/tc_yuyin_bg_xinhao_a.png +0 -0
- package/src/asset/Textures/SocialSecond/tc_yuyin_bg_xinhao_b.png +0 -0
- package/src/asset/Textures/SocialSecond/tc_yuyin_star.png +0 -0
- package/src/asset/Textures/SocialSecond/tc_yuyin_stop.png +0 -0
- package/src/asset/Textures/SocialSecond/tc_zanshang_bg_line.png +0 -0
- package/src/asset/Textures/SocialSecond/touxiang_bg_tishikuang.png +0 -0
- package/src/asset/Textures/SocialSecond/xiangce_huadong.png +0 -0
- package/src/asset/Textures/SocialSecond/xiangce_huadong_xuanzhong.png +0 -0
- package/src/asset/Textures/SocialSecond/xiangce_icon_xiazai.png +0 -0
- package/src/asset/Textures/SocialVideo/com_home_btn_close.png +0 -0
- package/src/asset/Textures/SocialVideo/tc_shipin_bg_guodu.png +0 -0
- package/src/asset/Textures/SocialVideo/tc_shipin_jinduanjian.png +0 -0
- package/src/asset/Textures/SocialVideo/tc_shipin_jindutiao.png +0 -0
- package/src/asset/Textures/SocialVideo/tc_shipin_jindutiao_hui.png +0 -0
- package/src/asset/Textures/SocialVideo/tc_shipin_play.png +0 -0
- package/src/asset/Textures/SocialVideo/tc_shipin_play_big.png +0 -0
- package/src/asset/Textures/SocialVideo/tc_shipin_stop.png +0 -0
- package/src/asset/laugh.gif +0 -0
- package/src/asset/npms.png +0 -0
- package/src/asset/pixui.png +0 -0
- package/src/asset/preact.png +0 -0
- package/src/asset/template.html +0 -47
- package/src/common/frame/appsettings.js +0 -111
- package/src/common/frame/common.js +0 -17
- package/src/common/frame/platform-api-callback.js +0 -341
- package/src/common/frame/platform-api.d.ts +0 -156
- package/src/common/frame/platform-api.js +0 -479
- package/src/common/main.less +0 -119
- package/src/pixUIReactComponents/README.md +0 -8
- package/src/pixUIReactComponents/package.json +0 -11
- package/src/pixUIReactComponents/tsconfig.json +0 -45
- package/src/pixUIReactComponents/ui/sample/Slapface/SlapfaceDemo.tsx +0 -30
- package/src/pixUIReactUtils/GenerateConstructorAndGeterSeter.js +0 -227
- package/src/pixUIReactUtils/MakeImage.js +0 -207
- package/src/pixUIReactUtils/README.md +0 -124
- package/src/pixUIReactUtils/Version.js +0 -3
- package/src/pixUIReactUtils/img/makeImage.png +0 -0
- package/src/pixUIReactUtils/index.js +0 -1
- package/src/pixUIReactUtils/package.json +0 -16
- package/src/preprocess/index.html +0 -48
- package/src/preprocess/main.tsx +0 -17
- package/src/preprocess/preprocesspage.tsx +0 -41
- /package/{src/pixUIReactComponents/cmdAfterTsBuild.js → cmdAfterTsBuild.js} +0 -0
- /package/{src/pixUIReactComponents/index.js → index.js} +0 -0
- /package/{src/pixUIReactComponents/tools → tools}/EventDispatcherJs.tsx +0 -0
- /package/{src/pixUIReactComponents/tools → tools}/Logger.tsx +0 -0
- /package/{src/pixUIReactComponents/tools → tools}/img/logger.png +0 -0
- /package/{src/pixUIReactComponents/tools → tools}/tools.md +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/components/bulletscreen/BulletItemAnimation.tsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/components/bulletscreen/BulletScreenAnimation.tsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/components/bulletscreen/bullet.less +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/components/button/Button.tsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/components/carousel/Carousel.tsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/components/checkBox/CheckBox.tsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/components/dropdown/Dropdown.tsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/components/dropdown/DropdownOptionUI.tsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/components/dropdown/DropdownSpreadMainUI.tsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/components/dropdown/DropdownUnspreadMainUI.tsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/components/gradient/GradientText.tsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/components/outlinetext/OutlineText.tsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/components/progress/Progress.tsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/components/slapface/less/Slapface.less +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/components/slider/Slider.tsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/components/tab/Tab.tsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/components/tab/Tabs.tsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/components/togglegroup/ToggleGroup.tsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/components/videoplayer/VideoPlayer.tsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/components/waterfallcomponent/WaterfallComponent.jsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/components/waterfallcomponent/less/WaterfallComponent.less +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/Images.tsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/OutlineText/OutlineDemo.tsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/asset/btn_close.png +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/asset/changtai_button.jpg +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/asset/checkbox0.png +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/asset/checkbox1.png +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/asset/data_arrow_down.png +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/asset/data_arrow_up.png +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/asset/dot.png +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/asset/inner.png +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/asset/item_reddot.png +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/asset/loading.png +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/asset/money_dropdown.png +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/asset/money_dropdownall.png +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/asset/outer.png +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/asset/slapface_samplepic1.png +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/asset/slapface_samplepic2.png +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/asset/slapface_samplepic3.png +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/asset/slapface_samplepic4.png +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/asset/slapface_samplepic5.png +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/asset/slapface_samplepic6.png +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/asset/tab_choosed.png +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/asset/tabs_bg.png +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/asset/video_pause.png +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/asset/video_play.png +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/asset/video_reload.png +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/asset/xuanfu_button.jpg +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/asset/yaxia_button.jpg +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/bulletscreen/BulletDemo.tsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/button/ButtonDemo.tsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/carousel/carouselDemo.tsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/checkBox/checkBoxDemo.tsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/dropdown/DropdownDemo.tsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/dropdown/MoneyDropdownOption.tsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/dropdown/MoneyDropdownSpreadMain.tsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/dropdown/MoneyDropdownUnspreadMain.tsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/gradient/GradientDemo.tsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/less/video.less +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/progress/ProgressDemo.tsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/slider/SliderDemo.tsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/tab/TabDemo.tsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/tab/TopTab.tsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/togglegroup/ToggleGroupDemo.tsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/videoplayer/VideoPlayerDemo.tsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/sample/waterfallcomponent/WaterfallComponentDemo.jsx +0 -0
- /package/{src/pixUIReactComponents/ui → ui}/ui.md +0 -0
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { _catchError } from './diff/catch-error';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The `option` object can potentially contain callback functions
|
|
5
|
-
* that are called during various stages of our renderer. This is the
|
|
6
|
-
* foundation on which all our addons like `preact/debug`, `preact/compat`,
|
|
7
|
-
* and `preact/hooks` are based on. See the `Options` type in `internal.d.ts`
|
|
8
|
-
* for a full list of available option hooks (most editors/IDEs allow you to
|
|
9
|
-
* ctrl+click or cmd+click on mac the type definition below).
|
|
10
|
-
* @type {import('./internal').Options}
|
|
11
|
-
*/
|
|
12
|
-
const options = {
|
|
13
|
-
_catchError
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export default options;
|
package/lib/preact/src/render.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { EMPTY_OBJ, EMPTY_ARR } from './constants';
|
|
2
|
-
import { commitRoot, diff } from './diff/index';
|
|
3
|
-
import { createElement, Fragment } from './create-element';
|
|
4
|
-
import options from './options';
|
|
5
|
-
|
|
6
|
-
const IS_HYDRATE = EMPTY_OBJ;
|
|
7
|
-
|
|
8
|
-
let stringify = function (obj) {
|
|
9
|
-
let seen = [];
|
|
10
|
-
|
|
11
|
-
return JSON.stringify(
|
|
12
|
-
obj,
|
|
13
|
-
function (key, val) {
|
|
14
|
-
if (val != null && typeof val == 'object') {
|
|
15
|
-
if (seen.indexOf(val) >= 0) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
seen.push(val);
|
|
19
|
-
}
|
|
20
|
-
return val;
|
|
21
|
-
},
|
|
22
|
-
2
|
|
23
|
-
);
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Render a Preact virtual node into a DOM element
|
|
27
|
-
* @param {import('./index').ComponentChild} vnode The virtual node to render
|
|
28
|
-
* @param {import('./internal').PreactElement} parentDom The DOM element to
|
|
29
|
-
* render into
|
|
30
|
-
* @param {Element | Text} [replaceNode] Optional: Attempt to re-use an
|
|
31
|
-
* existing DOM tree rooted at `replaceNode`
|
|
32
|
-
*/
|
|
33
|
-
export function render(vnode, parentDom, replaceNode) {
|
|
34
|
-
if (options._root) options._root(vnode, parentDom);
|
|
35
|
-
|
|
36
|
-
// We abuse the `replaceNode` parameter in `hydrate()` to signal if we
|
|
37
|
-
// are in hydration mode or not by passing `IS_HYDRATE` instead of a
|
|
38
|
-
// DOM element.
|
|
39
|
-
let isHydrating = replaceNode === IS_HYDRATE;
|
|
40
|
-
|
|
41
|
-
// To be able to support calling `render()` multiple times on the same
|
|
42
|
-
// DOM node, we need to obtain a reference to the previous tree. We do
|
|
43
|
-
// this by assigning a new `_children` property to DOM nodes which points
|
|
44
|
-
// to the last rendered tree. By default this property is not present, which
|
|
45
|
-
// means that we are mounting a new tree for the first time.
|
|
46
|
-
let oldVNode = isHydrating ? null : (replaceNode && replaceNode._children) || parentDom._children;
|
|
47
|
-
// console.log('in vnode:', vnode);
|
|
48
|
-
vnode = createElement(Fragment, null, [vnode]);
|
|
49
|
-
// console.log('out vnode:', vnode);
|
|
50
|
-
|
|
51
|
-
window.opList = [];
|
|
52
|
-
window.clearOP = () => {
|
|
53
|
-
window.opList = [];
|
|
54
|
-
};
|
|
55
|
-
window.addOP = (op) => {
|
|
56
|
-
if(window.debugVDomDiff)
|
|
57
|
-
window.opList.push(op);
|
|
58
|
-
};
|
|
59
|
-
window.dumpOP = (from) => {
|
|
60
|
-
if(window.debugVDomDiff)
|
|
61
|
-
console.log(`** opList(${from}) **\n` + window.opList.join('\n'), '\n');
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
// List of effects that need to be called after diffing.
|
|
65
|
-
let commitQueue = [];
|
|
66
|
-
diff(
|
|
67
|
-
parentDom,
|
|
68
|
-
// Determine the new vnode tree and store it on the DOM element on
|
|
69
|
-
// our custom `_children` property.
|
|
70
|
-
((isHydrating ? parentDom : replaceNode || parentDom)._children = vnode),
|
|
71
|
-
oldVNode || EMPTY_OBJ,
|
|
72
|
-
EMPTY_OBJ,
|
|
73
|
-
parentDom.ownerSVGElement !== undefined,
|
|
74
|
-
replaceNode && !isHydrating
|
|
75
|
-
? [replaceNode]
|
|
76
|
-
: oldVNode
|
|
77
|
-
? null
|
|
78
|
-
: EMPTY_ARR.slice.call(parentDom.childNodes),
|
|
79
|
-
commitQueue,
|
|
80
|
-
replaceNode || EMPTY_OBJ,
|
|
81
|
-
isHydrating
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
window.dumpOP('render');
|
|
85
|
-
|
|
86
|
-
// Flush all queued effects
|
|
87
|
-
commitRoot(commitQueue, vnode);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Update an existing DOM element with data from a Preact virtual node
|
|
92
|
-
* @param {import('./index').ComponentChild} vnode The virtual node to render
|
|
93
|
-
* @param {import('./internal').PreactElement} parentDom The DOM element to
|
|
94
|
-
* update
|
|
95
|
-
*/
|
|
96
|
-
export function hydrate(vnode, parentDom) {
|
|
97
|
-
render(vnode, parentDom, IS_HYDRATE);
|
|
98
|
-
}
|
package/lib/preact/src/util.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Assign properties from `props` to `obj`
|
|
3
|
-
* @template O, P The obj and props types
|
|
4
|
-
* @param {O} obj The object to copy properties to
|
|
5
|
-
* @param {P} props The object to copy properties from
|
|
6
|
-
* @returns {O & P}
|
|
7
|
-
*/
|
|
8
|
-
export function assign(obj, props) {
|
|
9
|
-
for (let i in props) obj[i] = props[i];
|
|
10
|
-
return /** @type {O & P} */ (obj);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Remove a child node from its parent if attached. This is a workaround for
|
|
15
|
-
* IE11 which doesn't support `Element.prototype.remove()`. Using this function
|
|
16
|
-
* is smaller than including a dedicated polyfill.
|
|
17
|
-
* @param {Node} node The node to remove
|
|
18
|
-
*/
|
|
19
|
-
export function removeNode(node) {
|
|
20
|
-
let parentNode = node.parentNode;
|
|
21
|
-
addOP(
|
|
22
|
-
`removeChild ${node.tagName || node.nodeName} of ${parentNode.tagName || parentNode.nodeName}`
|
|
23
|
-
);
|
|
24
|
-
if (parentNode) parentNode.removeChild(node);
|
|
25
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2015 Jason Miller
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
# preact-router
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/preact-router)
|
|
4
|
-
[](https://travis-ci.org/developit/preact-router)
|
|
5
|
-
|
|
6
|
-
Connect your [Preact] components up to that address bar.
|
|
7
|
-
|
|
8
|
-
`preact-router` provides a `<Router />` component that conditionally renders its children when the URL matches their `path`. It also automatically wires up `<a />` elements to the router.
|
|
9
|
-
|
|
10
|
-
> 💁 **Note:** This is not a preact-compatible version of React Router. `preact-router` is a simple URL wiring and does no orchestration for you.
|
|
11
|
-
>
|
|
12
|
-
> If you're looking for more complex solutions like nested routes and view composition, [react-router](https://github.com/ReactTraining/react-router) works great with preact as long as you alias in [preact-compat](https://github.com/developit/preact-compat). React Router 4 even [works directly with Preact](https://codepen.io/developit/pen/BWxepY?editors=0010), no compatibility layer needed!
|
|
13
|
-
|
|
14
|
-
#### [See a Real-world Example :arrow_right:](https://jsfiddle.net/developit/qc73v9va/)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
---
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
### Usage Example
|
|
21
|
-
|
|
22
|
-
```js
|
|
23
|
-
import Router from 'preact-router';
|
|
24
|
-
import { h, render } from 'preact';
|
|
25
|
-
/** @jsx h */
|
|
26
|
-
|
|
27
|
-
const Main = () => (
|
|
28
|
-
<Router>
|
|
29
|
-
<Home path="/" />
|
|
30
|
-
<About path="/about" />
|
|
31
|
-
// Advanced is an optional query
|
|
32
|
-
<Search path="/search/:query/:advanced?" />
|
|
33
|
-
</Router>
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
render(<Main />, document.body);
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
If there is an error rendering the destination route, a 404 will be displayed.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
### Handling URLS
|
|
43
|
-
|
|
44
|
-
:information_desk_person: Pages are just regular components that get mounted when you navigate to a certain URL.
|
|
45
|
-
Any URL parameters get passed to the component as `props`.
|
|
46
|
-
|
|
47
|
-
Defining what component(s) to load for a given URL is easy and declarative.
|
|
48
|
-
You can even mix-and-match URL parameters and normal `props`.
|
|
49
|
-
You can also make params optional by adding a `?` to it.
|
|
50
|
-
|
|
51
|
-
```js
|
|
52
|
-
<Router>
|
|
53
|
-
<A path="/" />
|
|
54
|
-
<B path="/b" id="42" />
|
|
55
|
-
<C path="/c/:id" />
|
|
56
|
-
<C path="/d/:optional?/:params?" />
|
|
57
|
-
<D default />
|
|
58
|
-
</Router>
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
### Lazy Loading
|
|
63
|
-
|
|
64
|
-
Lazy loading (code splitting) with `preact-router` can be implemented easily using the [AsyncRoute](https://www.npmjs.com/package/preact-async-route) module:
|
|
65
|
-
|
|
66
|
-
```js
|
|
67
|
-
import AsyncRoute from 'preact-async-route';
|
|
68
|
-
<Router>
|
|
69
|
-
<Home path="/" />
|
|
70
|
-
<AsyncRoute
|
|
71
|
-
path="/friends"
|
|
72
|
-
getComponent={ () => import('./friends').then(module => module.default) }
|
|
73
|
-
/>
|
|
74
|
-
<AsyncRoute
|
|
75
|
-
path="/friends/:id"
|
|
76
|
-
getComponent={ () => import('./friend').then(module => module.default) }
|
|
77
|
-
loading={ () => <div>loading...</div> }
|
|
78
|
-
/>
|
|
79
|
-
</Router>
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
### Active Matching & Links
|
|
84
|
-
|
|
85
|
-
`preact-router` includes an add-on module called `match` that lets you wire your components up to Router changes.
|
|
86
|
-
|
|
87
|
-
Here's a demo of `<Match>`, which invokes the function you pass it (as its only child) in response to any routing:
|
|
88
|
-
|
|
89
|
-
```js
|
|
90
|
-
import Router from 'preact-router';
|
|
91
|
-
import Match from 'preact-router/match';
|
|
92
|
-
|
|
93
|
-
render(
|
|
94
|
-
<div>
|
|
95
|
-
<Match path="/">
|
|
96
|
-
{ ({ matches, path, url }) => (
|
|
97
|
-
<pre>{url}</pre>
|
|
98
|
-
) }
|
|
99
|
-
</Match>
|
|
100
|
-
<Router>
|
|
101
|
-
<div default>demo fallback route</div>
|
|
102
|
-
</Router>
|
|
103
|
-
</div>
|
|
104
|
-
)
|
|
105
|
-
|
|
106
|
-
// another example: render only if at a given URL:
|
|
107
|
-
|
|
108
|
-
render(
|
|
109
|
-
<div>
|
|
110
|
-
<Match path="/">
|
|
111
|
-
{ ({ matches }) => matches && (
|
|
112
|
-
<h1>You are Home!</h1>
|
|
113
|
-
) }
|
|
114
|
-
</Match>
|
|
115
|
-
<Router />
|
|
116
|
-
</div>
|
|
117
|
-
)
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
`<Link>` is just a normal link, but it automatically adds and removes an "active" classname to itself based on whether it matches the current URL.
|
|
121
|
-
|
|
122
|
-
```js
|
|
123
|
-
import { Router } from 'preact-router';
|
|
124
|
-
import { Link } from 'preact-router/match';
|
|
125
|
-
|
|
126
|
-
render(
|
|
127
|
-
<div>
|
|
128
|
-
<nav>
|
|
129
|
-
<Link activeClassName="active" href="/">Home</Link>
|
|
130
|
-
<Link activeClassName="active" href="/foo">Foo</Link>
|
|
131
|
-
<Link activeClassName="active" href="/bar">Bar</Link>
|
|
132
|
-
</nav>
|
|
133
|
-
<Router>
|
|
134
|
-
<div default>
|
|
135
|
-
this is a demo route that always matches
|
|
136
|
-
</div>
|
|
137
|
-
</Router>
|
|
138
|
-
</div>
|
|
139
|
-
)
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
### Default Link Behavior
|
|
144
|
-
|
|
145
|
-
Sometimes it's necessary to bypass preact-router's link handling and let the browser perform routing on its own.
|
|
146
|
-
|
|
147
|
-
This can be accomplished by adding a `native` boolean attribute to any link:
|
|
148
|
-
|
|
149
|
-
```html
|
|
150
|
-
<a href="/foo" native>Foo</a>
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
### Detecting Route Changes
|
|
154
|
-
|
|
155
|
-
The `Router` notifies you when a change event occurs for a route with the `onChange` callback:
|
|
156
|
-
|
|
157
|
-
```js
|
|
158
|
-
import { render, Component } from 'preact';
|
|
159
|
-
import { Router, route } from 'preact-router';
|
|
160
|
-
|
|
161
|
-
class App extends Component {
|
|
162
|
-
|
|
163
|
-
// some method that returns a promise
|
|
164
|
-
isAuthenticated() { }
|
|
165
|
-
|
|
166
|
-
handleRoute = async e => {
|
|
167
|
-
switch (e.url) {
|
|
168
|
-
case '/profile':
|
|
169
|
-
const isAuthed = await this.isAuthenticated();
|
|
170
|
-
if (!isAuthed) route('/', true);
|
|
171
|
-
break;
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
render() {
|
|
176
|
-
return (
|
|
177
|
-
<Router onChange={this.handleRoute}>
|
|
178
|
-
<Home path="/" />
|
|
179
|
-
<Profile path="/profile" />
|
|
180
|
-
</Router>
|
|
181
|
-
);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
### Redirects
|
|
188
|
-
|
|
189
|
-
Can easily be implemented with a custom `Redirect` component;
|
|
190
|
-
|
|
191
|
-
```js
|
|
192
|
-
import { Component } from 'preact';
|
|
193
|
-
import { route } from 'preact-router';
|
|
194
|
-
|
|
195
|
-
export default class Redirect extends Component {
|
|
196
|
-
componentWillMount() {
|
|
197
|
-
route(this.props.to, true);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
render() {
|
|
201
|
-
return null;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
Now to create a redirect within your application, you can add this `Redirect` component to your router;
|
|
207
|
-
|
|
208
|
-
```js
|
|
209
|
-
<Router>
|
|
210
|
-
<Bar path="/bar" />
|
|
211
|
-
<Redirect path="/foo" to="/bar" />
|
|
212
|
-
</Router>
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
### Custom History
|
|
217
|
-
|
|
218
|
-
It's possible to use alternative history bindings, like `/#!/hash-history`:
|
|
219
|
-
|
|
220
|
-
```js
|
|
221
|
-
import { h } from 'preact';
|
|
222
|
-
import Router from 'preact-router';
|
|
223
|
-
import { createHashHistory } from 'history';
|
|
224
|
-
|
|
225
|
-
const Main = () => (
|
|
226
|
-
<Router history={createHashHistory()}>
|
|
227
|
-
<Home path="/" />
|
|
228
|
-
<About path="/about" />
|
|
229
|
-
<Search path="/search/:query" />
|
|
230
|
-
</Router>
|
|
231
|
-
);
|
|
232
|
-
|
|
233
|
-
render(<Main />, document.body);
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
### Programmatically Triggering Route
|
|
237
|
-
|
|
238
|
-
Its possible to programmatically trigger a route to a page (like `window.location = '/page-2'`)
|
|
239
|
-
|
|
240
|
-
```js
|
|
241
|
-
import { route } from 'preact-router';
|
|
242
|
-
|
|
243
|
-
route('/page-2') // appends a history entry
|
|
244
|
-
|
|
245
|
-
route('/page-3', true) // replaces the current history entry
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
### License
|
|
249
|
-
|
|
250
|
-
[MIT]
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
[Preact]: https://github.com/developit/preact
|
|
254
|
-
[MIT]: https://choosealicense.com/licenses/mit/
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import * as preact from 'preact';
|
|
2
|
-
|
|
3
|
-
export function route(url: string, replace?: boolean): boolean;
|
|
4
|
-
export function route(options: { url: string; replace?: boolean }): boolean;
|
|
5
|
-
|
|
6
|
-
export function getCurrentUrl(): string;
|
|
7
|
-
|
|
8
|
-
export interface Location {
|
|
9
|
-
pathname: string;
|
|
10
|
-
search: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface CustomHistory {
|
|
14
|
-
listen(callback: (location: Location) => void): () => void;
|
|
15
|
-
location: Location;
|
|
16
|
-
push(path: string): void;
|
|
17
|
-
replace(path: string): void;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface RoutableProps {
|
|
21
|
-
path?: string;
|
|
22
|
-
default?: boolean;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface RouterOnChangeArgs {
|
|
26
|
-
router: Router;
|
|
27
|
-
url: string;
|
|
28
|
-
previous?: string;
|
|
29
|
-
active: preact.VNode[];
|
|
30
|
-
current: preact.VNode;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface RouterProps extends RoutableProps {
|
|
34
|
-
history?: CustomHistory;
|
|
35
|
-
static?: boolean;
|
|
36
|
-
url?: string;
|
|
37
|
-
onChange?: (args: RouterOnChangeArgs) => void;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export class Router extends preact.Component<RouterProps, {}> {
|
|
41
|
-
canRoute(url: string): boolean;
|
|
42
|
-
getMatchingChildren(
|
|
43
|
-
children: preact.VNode[],
|
|
44
|
-
url: string,
|
|
45
|
-
invoke: boolean
|
|
46
|
-
): preact.VNode[];
|
|
47
|
-
routeTo(url: string): boolean;
|
|
48
|
-
render(props: RouterProps, {}): preact.VNode;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export const subscribers: Array<(url: string) => void>
|
|
52
|
-
|
|
53
|
-
type AnyComponent<Props> =
|
|
54
|
-
| preact.FunctionalComponent<Props>
|
|
55
|
-
| preact.ComponentConstructor<Props, any>;
|
|
56
|
-
|
|
57
|
-
export interface RouteProps<Props> extends RoutableProps {
|
|
58
|
-
component: AnyComponent<Props>;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function Route<Props>(
|
|
62
|
-
props: RouteProps<Props> & Partial<Props>
|
|
63
|
-
): preact.VNode;
|
|
64
|
-
|
|
65
|
-
export function Link(props: {activeClassName?: string} & preact.JSX.HTMLAttributes): preact.VNode;
|
|
66
|
-
|
|
67
|
-
declare module 'preact' {
|
|
68
|
-
export interface Attributes extends RoutableProps {}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export default Router;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as preact from 'preact';
|
|
2
|
-
|
|
3
|
-
import { Link as StaticLink, RoutableProps } from '..';
|
|
4
|
-
|
|
5
|
-
export class Match extends preact.Component<RoutableProps, {}> {
|
|
6
|
-
render(): preact.VNode;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface LinkProps extends preact.JSX.HTMLAttributes {
|
|
10
|
-
activeClassName?: string;
|
|
11
|
-
children?: preact.ComponentChildren;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function Link(props: LinkProps): preact.VNode;
|
|
15
|
-
|
|
16
|
-
export default Match;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "index",
|
|
3
|
-
"module": "./index.es.js",
|
|
4
|
-
"main": "./index.js",
|
|
5
|
-
"types": "./index.d.ts",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"build": "microbundle src/index.js -f es -o . --no-sourcemap && microbundle src/cjs.js -f cjs -o . --no-sourcemap"
|
|
8
|
-
},
|
|
9
|
-
"peerDependencies": {
|
|
10
|
-
"preact": "*",
|
|
11
|
-
"preact-router": "*"
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { h, Component } from 'preact';
|
|
2
|
-
import { subscribers, getCurrentUrl, Link as StaticLink, exec } from 'preact-router';
|
|
3
|
-
|
|
4
|
-
export class Match extends Component {
|
|
5
|
-
componentDidMount() {
|
|
6
|
-
this.update = url => {
|
|
7
|
-
this.nextUrl = url;
|
|
8
|
-
this.setState({});
|
|
9
|
-
};
|
|
10
|
-
subscribers.push(this.update);
|
|
11
|
-
}
|
|
12
|
-
componentWillUnmount() {
|
|
13
|
-
subscribers.splice(subscribers.indexOf(this.update)>>>0, 1);
|
|
14
|
-
}
|
|
15
|
-
render(props) {
|
|
16
|
-
let url = this.nextUrl || getCurrentUrl(),
|
|
17
|
-
path = url.replace(/\?.+$/,'');
|
|
18
|
-
this.nextUrl = null;
|
|
19
|
-
return props.children({
|
|
20
|
-
url,
|
|
21
|
-
path,
|
|
22
|
-
matches: exec(path, props.path, {}) !== false
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const Link = ({ activeClassName, path, ...props }) => (
|
|
28
|
-
<Match path={path || props.href}>
|
|
29
|
-
{ ({ matches }) => {
|
|
30
|
-
let cls=[props.class || props.className, matches && activeClassName].filter(Boolean).join(' ');
|
|
31
|
-
return <StaticLink {...props} className={cls} />;
|
|
32
|
-
} }
|
|
33
|
-
</Match>
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
export default Match;
|