提交 b61c3ec1 编写于 作者: F fangyeqing

Merge branch 'master' of https://github.com.cnpmjs.org/didi/DoraemonKit into feature/20211027_view

......@@ -23,17 +23,23 @@ public class DMapLocationListenerProxy implements DIDILocationListener, DMapLoca
@Override
public void onLocationChanged(DIDILocation didiLocation) {
if (didiLocationListener != null) {
didiLocationListener.onLocationChanged(didiLocation);
}
}
@Override
public void onLocationError(int i, ErrInfo errInfo) {
if (didiLocationListener != null) {
didiLocationListener.onLocationError(i, errInfo);
}
}
@Override
public void onStatusUpdate(String s, int i, String s1) {
if (didiLocationListener != null) {
didiLocationListener.onStatusUpdate(s, i, s1);
}
}
@NonNull
......
......@@ -7,7 +7,7 @@
Pod::Spec.new do |s|
s.name = 'DoraemonKit'
s.version = '3.1.0'
s.version = '3.1.1'
s.summary = 'iOS各式各样的工具集合'
s.description = <<-DESC
iOS各式各样的工具集合 Desc
......
此差异已折叠。
55 error Error: Command failed with exit code 128: git push --follow-tags --no-verify --atomic origin master
55 error fatal: unable to access 'https://github.com/didi/DoraemonKit.git/': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443
55 error at makeError (/Users/didi/Desktop/DoKit/DoraemonKit/Web/node_modules/execa/lib/error.js:59:11)
55 error at handlePromise (/Users/didi/Desktop/DoKit/DoraemonKit/Web/node_modules/execa/index.js:114:26)
......@@ -3,7 +3,7 @@
"packages": [
"packages/*"
],
"version": "0.0.1-alpha.4",
"version": "0.0.1-alpha.6",
"npmClient": "npm",
"command": {
"bootstrap": {
......
{
"name": "@dokit/web-core",
"version": "0.0.1-alpha.4",
"version": "0.0.1-alpha.6",
"description": "Dokit",
"keywords": [
"Dokit"
......@@ -29,7 +29,7 @@
"url": "https://github.com/didi/DoraemonKit/issues"
},
"dependencies": {
"@dokit/web-utils": "^0.0.1-alpha.4"
"@dokit/web-utils": "^0.0.1-alpha.5"
},
"gitHead": "886ea7c19806526668e5da0179da335e7df9d012"
}
......@@ -23,7 +23,7 @@ export default {
return this.$route.component
},
title(){
return this.$route.title || 'DoKit'
return this.$route.meta && this.$route.meta.title || 'DoKit'
},
canBack(){
return this.$route.name !== 'home'
......
{
"name": "@dokit/web-utils",
"version": "0.0.1-alpha.4",
"version": "0.0.1-alpha.5",
"description": "Dokit",
"keywords": [
"Dokit"
......
{
"name": "@dokit/web",
"version": "0.0.1-alpha.4",
"version": "0.0.1-alpha.6",
"description": "Dokit Web Main Entry",
"keywords": [
"Dokit"
......@@ -32,6 +32,7 @@
"dependencies": {
"@dokit/web-core": "^0.0.1-alpha.4",
"@dokit/web-utils": "^0.0.1-alpha.4",
"web-vitals": "^2.1.2",
"mutation-observer": "^1.0.3"
},
"gitHead": "886ea7c19806526668e5da0179da335e7df9d012"
......
......@@ -10,12 +10,13 @@ import AlignRuler from './plugins/align-ruler/index'
import HelloWorld from './components/ToolHelloWorld'
import Resource from './plugins/resources/index'
import ApiMock from './plugins/api-mock/index'
import WebVitals from './plugins/web-vitals-time/index'
import {IndependPlugin, RouterPlugin} from '@dokit/web-core'
export const BasicFeatures = {
title: '常用工具',
list: [Console, AppInfo, Resource, Network, Storage, DemoPlugin, DemoIndependPlugin, H5DoorPlugin,Element]
list: [Console, AppInfo, Resource, Network, Storage, DemoPlugin, DemoIndependPlugin, H5DoorPlugin, WebVitals, Element]
// list: [Console, AppInfo, Resource, Network, Storage, H5DoorPlugin]
}
......@@ -27,7 +28,7 @@ export const DokitFeatures = {
export const UIFeatures = {
title: '视觉功能',
list: [AlignRuler]
// list: [AlignRuler,
// list: [AlignRuler,
// new RouterPlugin({
// nameZh: 'UI结构',
// name: 'view-selector',
......@@ -35,4 +36,4 @@ export const UIFeatures = {
// component: HelloWorld
// })]
}
export const Features = [BasicFeatures, DokitFeatures, UIFeatures]
\ No newline at end of file
export const Features = [BasicFeatures, DokitFeatures, UIFeatures]
import WebVitalsTime from './info-box.vue'
import {RouterPlugin} from '@dokit/web-core'
export default new RouterPlugin({
nameZh: '性能',
name: 'webVitalsTime',
icon: 'https://pt-starimg.didistatic.com/static/starimg/img/6WONqJCVks1621926657356.png',
component: WebVitalsTime
})
<template>
<div class="web-vitals-time">
<div class="title">性能指标(web vitals)</div>
<div class="desc">请在页面加载完成后再获取指标</div>
<div class="content">
<div><span class="item important">FCP:</span>{{FCP}}</div>
<div><span class="item important">LCP:</span>{{LCP}}</div>
<div><span class="item">CLS:</span>{{CLS}}</div>
<div><span class="item">FID:</span>{{FID}}</div>
<div><span class="item">TTFB:</span>{{TTFB}}</div>
</div>
</div>
</template>
<script>
import {getFCP, getLCP, getFID, getCLS, getTTFB} from 'web-vitals';
export default {
data() {
return {
FCP: '',
CLS: '',
FID: '',
LCP: '',
TTFB: ''
}
},
mounted() {
getFCP(this.handleData);
getLCP(this.handleData, true);
getCLS(this.handleData, true);
getFID(this.handleData);
getTTFB(this.handleData);
},
methods: {
handleData(detail) {
console.log(JSON.parse(JSON.stringify(detail)))
const { name, value } = detail
this[name] = Math.round(value) + ' ms'
}
}
}
</script>
<style lang="less" scoped>
.web-vitals-time {
padding: 10px;
text-align: center;
.title {
font-weight: bold;
font-size: 22px;
}
.desc {
font-size: 12px;
color: #999999;
}
.content {
text-align: left;
margin-top: 20px;
padding-left: 5%;
}
.item {
display: inline-block;
text-align: right;
width: 60px;
margin-top: 4px;
font-size: 16px;
}
.important {
color: red;
}
}
</style>
......@@ -8,7 +8,6 @@
/* Begin PBXBuildFile section */
18C7CAA526FB5F8D00A47F7C /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18C7CAA426FB5F8D00A47F7C /* AppDelegate.swift */; };
18C7CAA726FB5F8D00A47F7C /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18C7CAA626FB5F8D00A47F7C /* SceneDelegate.swift */; };
18C7CAA926FB5F8D00A47F7C /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18C7CAA826FB5F8D00A47F7C /* ViewController.swift */; };
18C7CAAC26FB5F8D00A47F7C /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 18C7CAAA26FB5F8D00A47F7C /* Main.storyboard */; };
18C7CAAE26FB5F8F00A47F7C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 18C7CAAD26FB5F8F00A47F7C /* Assets.xcassets */; };
......@@ -20,7 +19,6 @@
175B450197F10CD038689527 /* Pods-Demo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Demo.release.xcconfig"; path = "Target Support Files/Pods-Demo/Pods-Demo.release.xcconfig"; sourceTree = "<group>"; };
18C7CAA126FB5F8D00A47F7C /* Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Demo.app; sourceTree = BUILT_PRODUCTS_DIR; };
18C7CAA426FB5F8D00A47F7C /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
18C7CAA626FB5F8D00A47F7C /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
18C7CAA826FB5F8D00A47F7C /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
18C7CAAB26FB5F8D00A47F7C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
18C7CAAD26FB5F8F00A47F7C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
......@@ -64,7 +62,6 @@
isa = PBXGroup;
children = (
18C7CAA426FB5F8D00A47F7C /* AppDelegate.swift */,
18C7CAA626FB5F8D00A47F7C /* SceneDelegate.swift */,
18C7CAA826FB5F8D00A47F7C /* ViewController.swift */,
18C7CAAA26FB5F8D00A47F7C /* Main.storyboard */,
18C7CAAD26FB5F8F00A47F7C /* Assets.xcassets */,
......@@ -88,7 +85,6 @@
EC6833A07F0818E63D44A2B9 /* Pods-Demo.debug.xcconfig */,
175B450197F10CD038689527 /* Pods-Demo.release.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
......@@ -209,7 +205,6 @@
files = (
18C7CAA926FB5F8D00A47F7C /* ViewController.swift in Sources */,
18C7CAA526FB5F8D00A47F7C /* AppDelegate.swift in Sources */,
18C7CAA726FB5F8D00A47F7C /* SceneDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -366,6 +361,7 @@
INFOPLIST_KEY_UIMainStoryboardFile = Main;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
......@@ -394,6 +390,7 @@
INFOPLIST_KEY_UIMainStoryboardFile = Main;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
......
......@@ -6,31 +6,19 @@
//
import UIKit
import DoraemonKit
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
private class AppDelegate: UIResponder, UIApplicationDelegate {
fileprivate var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
fileprivate func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
DoraemonManager.shareInstance().install()
return true
}
// MARK: UISceneSession Lifecycle
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
}
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19162" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19144"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController">
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="Demo" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="139" y="80"/>
</scene>
</scenes>
<resources>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
......@@ -2,24 +2,10 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIApplicationSceneManifest</key>
<key>NSAppTransportSecurity</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
<key>UISceneStoryboardFile</key>
<string>Main</string>
</dict>
</array>
</dict>
<key>NSAllowsLocalNetworking</key>
<true/>
</dict>
</dict>
</plist>
//
// SceneDelegate.swift
// Demo
//
// Created by 唐佳诚 on 2021/9/22.
//
import UIKit
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
guard let _ = (scene as? UIWindowScene) else { return }
}
func sceneDidDisconnect(_ scene: UIScene) {
// Called as the scene is being released by the system.
// This occurs shortly after the scene enters the background, or when its session is discarded.
// Release any resources associated with this scene that can be re-created the next time the scene connects.
// The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead).
}
func sceneDidBecomeActive(_ scene: UIScene) {
// Called when the scene has moved from an inactive state to an active state.
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
}
func sceneWillResignActive(_ scene: UIScene) {
// Called when the scene will move from an active state to an inactive state.
// This may occur due to temporary interruptions (ex. an incoming phone call).
}
func sceneWillEnterForeground(_ scene: UIScene) {
// Called as the scene transitions from the background to the foreground.
// Use this method to undo the changes made on entering the background.
}
func sceneDidEnterBackground(_ scene: UIScene) {
// Called as the scene transitions from the foreground to the background.
// Use this method to save data, release shared resources, and store enough scene-specific state information
// to restore the scene back to its current state.
}
}
......@@ -14,6 +14,4 @@ class ViewController: UIViewController {
// Do any additional setup after loading the view.
}
}
......@@ -7,6 +7,7 @@
#include "doraemon_fishhook.h"
#include <assert.h>
#include <dlfcn.h>
#include <stdbool.h>
#include <stdlib.h>
......@@ -96,10 +97,35 @@ static void doraemon_perform_rebinding_with_section(struct doraemon_rebindings_e
const bool isDataConst = strcmp(section->segname, "__DATA_CONST") == 0;
uint32_t *indirect_symbol_indices = indirect_symtab + section->reserved1;
void **indirect_symbol_bindings = (void **)((uintptr_t)slide + section->addr);
vm_prot_t oldProtection = VM_PROT_READ;
vm_prot_t oldProtection = VM_PROT_NONE;
vm_address_t vmAddress = (vm_address_t)indirect_symbol_bindings;
// https://opensource.apple.com/source/xnu/xnu-7195.141.2/osfmk/vm/vm_user.c.auto.html
// OUT argument, but init with zero to eliminate `Variable 'vmSize' may be uninitialized when used here` warning
vm_size_t vmSize = 0;
if (isDataConst) {
oldProtection = doraemon_get_protection(rebindings);
mprotect(indirect_symbol_bindings, section->size, PROT_READ | PROT_WRITE);
memory_object_name_t object;
#ifdef __LP64__
mach_msg_type_number_t count = VM_REGION_BASIC_INFO_COUNT_64;
vm_region_basic_info_data_64_t vmRegionBasicInfoData;
kern_return_t kernelReturn = vm_region_64(mach_task_self(), &vmAddress, &vmSize, VM_REGION_BASIC_INFO_64, (vm_region_info_t)&vmRegionBasicInfoData, &count, &object);
#else
mach_msg_type_number_t count = VM_REGION_BASIC_INFO_COUNT;
vm_region_basic_info_data_t vmRegionBasicInfoData;
kern_return_t kernelReturn = vm_region(mach_task_self(), &vmAddress, &vmSize, VM_REGION_BASIC_INFO, (vm_region_info_t)&vmRegionBasicInfoData, &count, object);
#endif
if (__builtin_expect(kernelReturn == KERN_SUCCESS, true)) {
oldProtection = vmRegionBasicInfoData.protection;
} else {
assert(false && "vm_region() failure.");
return;
}
kernelReturn = vm_protect(mach_task_self(), vmAddress, vmSize, false, oldProtection | VM_PROT_WRITE);
if (__builtin_expect(kernelReturn != KERN_SUCCESS, false)) {
assert(false && "vm_protect() failure.");
return;
}
}
for (uint i = 0; i < section->size / sizeof(void *); i++) {
uint32_t symtab_index = indirect_symbol_indices[i];
......@@ -128,17 +154,8 @@ static void doraemon_perform_rebinding_with_section(struct doraemon_rebindings_e
symbol_loop:;
}
if (isDataConst) {
int protection = 0;
if (oldProtection & VM_PROT_READ) {
protection |= PROT_READ;
}
if (oldProtection & VM_PROT_WRITE) {
protection |= PROT_WRITE;
}
if (oldProtection & VM_PROT_EXECUTE) {
protection |= PROT_EXEC;
}
mprotect(indirect_symbol_bindings, section->size, protection);
kern_return_t kernelReturn = vm_protect(mach_task_self(), vmAddress, vmSize, false, oldProtection);
assert(kernelReturn == KERN_SUCCESS && "vm_protect() failure.");
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册