pbind 0.6.2 → 0.8.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.
@@ -0,0 +1,25 @@
1
+ //
2
+ // PBLLResource.h
3
+ // Pbind
4
+ //
5
+ // Created by galen on 17/7/30.
6
+ //
7
+
8
+ #import "PBLLOptions.h"
9
+ #include <targetconditionals.h>
10
+
11
+ #if (PBLIVE_ENABLED)
12
+
13
+ #import <Foundation/Foundation.h>
14
+ #import <UIKit/UIKit.h>
15
+
16
+ @interface PBLLResource : NSObject
17
+
18
+ @property (nonatomic, strong, class, readonly) UIImage *logoImage;
19
+ @property (nonatomic, strong, class, readonly) UIImage *copyImage;
20
+ @property (nonatomic, strong, class, readonly) NSString *pbindTitle;
21
+ @property (nonatomic, strong, class, readonly) UIColor *pbindColor;
22
+
23
+ @end
24
+
25
+ #endif
@@ -0,0 +1,208 @@
1
+ //
2
+ // PBLLResource.m
3
+ // Pbind
4
+ //
5
+ // Created by galen on 17/7/30.
6
+ //
7
+
8
+ #import "PBLLResource.h"
9
+
10
+ #if (PBLIVE_ENABLED)
11
+
12
+ #import <Pbind/Pbind.h>
13
+
14
+ @implementation PBLLResource
15
+
16
+ + (NSString *)pbindTitle {
17
+ return @"Pbind";
18
+ }
19
+
20
+ + (UIColor *)pbindColor {
21
+ return PBColorMake(@"5D74E9");
22
+ }
23
+
24
+ + (UIImage *)imageWithWidth:(CGFloat)width height:(CGFloat)height draw:(dispatch_block_t)drawBlock {
25
+ CGRect imageRect = CGRectMake(0.0, 0.0, width, height);
26
+ UIGraphicsBeginImageContextWithOptions(imageRect.size, NO, [UIScreen mainScreen].scale);
27
+
28
+ drawBlock();
29
+
30
+ UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
31
+ UIGraphicsEndImageContext();
32
+ return image;
33
+ }
34
+
35
+ + (UIImage *)logoImage {
36
+ static UIImage *image = nil;
37
+ static dispatch_once_t onceToken;
38
+ dispatch_once(&onceToken, ^{
39
+ image = [self imageWithWidth:32.f height:32.f draw:^{
40
+ //// Color Declarations
41
+ //// General Declarations
42
+ CGContextRef context = UIGraphicsGetCurrentContext();
43
+
44
+ //// Color Declarations
45
+ UIColor* fillColor4 = [UIColor whiteColor];;
46
+
47
+ //// Group
48
+ {
49
+ CGContextSaveGState(context);
50
+ CGContextBeginTransparencyLayer(context, NULL);
51
+
52
+ //// Clip Clip 2
53
+ UIBezierPath* clip2Path = [UIBezierPath bezierPath];
54
+ [clip2Path moveToPoint: CGPointMake(16, 32)];
55
+ [clip2Path addCurveToPoint: CGPointMake(32, 16) controlPoint1: CGPointMake(24.84, 32) controlPoint2: CGPointMake(32, 24.84)];
56
+ [clip2Path addCurveToPoint: CGPointMake(16, 0) controlPoint1: CGPointMake(32, 7.16) controlPoint2: CGPointMake(24.84, 0)];
57
+ [clip2Path addCurveToPoint: CGPointMake(0, 16) controlPoint1: CGPointMake(7.16, 0) controlPoint2: CGPointMake(0, 7.16)];
58
+ [clip2Path addCurveToPoint: CGPointMake(16, 32) controlPoint1: CGPointMake(0, 24.84) controlPoint2: CGPointMake(7.16, 32)];
59
+ [clip2Path closePath];
60
+ clip2Path.usesEvenOddFillRule = YES;
61
+
62
+ [clip2Path addClip];
63
+
64
+
65
+ //// Group 2
66
+ {
67
+ CGContextSaveGState(context);
68
+ CGContextBeginTransparencyLayer(context, NULL);
69
+
70
+ //// Clip Clip
71
+ UIBezierPath* clipPath = [UIBezierPath bezierPath];
72
+ [clipPath moveToPoint: CGPointMake(12.13, 20.25)];
73
+ [clipPath addCurveToPoint: CGPointMake(-19.8, 48) controlPoint1: CGPointMake(10.03, 35.91) controlPoint2: CGPointMake(-3.46, 48)];
74
+ [clipPath addCurveToPoint: CGPointMake(-52, 16) controlPoint1: CGPointMake(-37.58, 48) controlPoint2: CGPointMake(-52, 33.67)];
75
+ [clipPath addCurveToPoint: CGPointMake(-19.8, -16) controlPoint1: CGPointMake(-52, -1.67) controlPoint2: CGPointMake(-37.58, -16)];
76
+ [clipPath addCurveToPoint: CGPointMake(12.13, 11.75) controlPoint1: CGPointMake(-3.46, -16) controlPoint2: CGPointMake(10.03, -3.91)];
77
+ [clipPath addCurveToPoint: CGPointMake(18.95, 8) controlPoint1: CGPointMake(13.55, 9.5) controlPoint2: CGPointMake(16.07, 8)];
78
+ [clipPath addCurveToPoint: CGPointMake(27, 16) controlPoint1: CGPointMake(23.4, 8) controlPoint2: CGPointMake(27, 11.58)];
79
+ [clipPath addCurveToPoint: CGPointMake(18.95, 24) controlPoint1: CGPointMake(27, 20.42) controlPoint2: CGPointMake(23.4, 24)];
80
+ [clipPath addCurveToPoint: CGPointMake(12.13, 20.25) controlPoint1: CGPointMake(16.07, 24) controlPoint2: CGPointMake(13.55, 22.5)];
81
+ [clipPath closePath];
82
+ [clipPath moveToPoint: CGPointMake(18.95, 22.5)];
83
+ [clipPath addCurveToPoint: CGPointMake(25.49, 16) controlPoint1: CGPointMake(22.56, 22.5) controlPoint2: CGPointMake(25.49, 19.59)];
84
+ [clipPath addCurveToPoint: CGPointMake(18.95, 9.5) controlPoint1: CGPointMake(25.49, 12.41) controlPoint2: CGPointMake(22.56, 9.5)];
85
+ [clipPath addCurveToPoint: CGPointMake(12.41, 16) controlPoint1: CGPointMake(15.34, 9.5) controlPoint2: CGPointMake(12.41, 12.41)];
86
+ [clipPath addCurveToPoint: CGPointMake(18.95, 22.5) controlPoint1: CGPointMake(12.41, 19.59) controlPoint2: CGPointMake(15.34, 22.5)];
87
+ [clipPath closePath];
88
+ [clipPath moveToPoint: CGPointMake(-19.8, 46.5)];
89
+ [clipPath addCurveToPoint: CGPointMake(10.9, 16) controlPoint1: CGPointMake(-2.84, 46.5) controlPoint2: CGPointMake(10.9, 32.84)];
90
+ [clipPath addCurveToPoint: CGPointMake(-19.8, -14.5) controlPoint1: CGPointMake(10.9, -0.84) controlPoint2: CGPointMake(-2.84, -14.5)];
91
+ [clipPath addCurveToPoint: CGPointMake(-50.49, 16) controlPoint1: CGPointMake(-36.75, -14.5) controlPoint2: CGPointMake(-50.49, -0.84)];
92
+ [clipPath addCurveToPoint: CGPointMake(-19.8, 46.5) controlPoint1: CGPointMake(-50.49, 32.84) controlPoint2: CGPointMake(-36.75, 46.5)];
93
+ [clipPath closePath];
94
+ clipPath.usesEvenOddFillRule = YES;
95
+
96
+ [clipPath addClip];
97
+
98
+
99
+ //// Rectangle Drawing
100
+ UIBezierPath* rectanglePath = [UIBezierPath bezierPathWithRect: CGRectMake(1, 0, 31, 32)];
101
+ [fillColor4 setFill];
102
+ [rectanglePath fill];
103
+
104
+
105
+ CGContextEndTransparencyLayer(context);
106
+ CGContextRestoreGState(context);
107
+ }
108
+
109
+
110
+ CGContextEndTransparencyLayer(context);
111
+ CGContextRestoreGState(context);
112
+ }
113
+
114
+ }];
115
+ });
116
+ return image;
117
+ }
118
+
119
+ + (UIImage *)copyImage {
120
+ static UIImage *image = nil;
121
+ static dispatch_once_t onceToken;
122
+ dispatch_once(&onceToken, ^{
123
+ image = [self imageWithWidth:24.f height:24.f draw:^{
124
+ //// Color Declarations
125
+ UIColor* fillColor2 = [UIColor colorWithRed: 0 green: 0 blue: 0 alpha: 1];
126
+
127
+ //// Text-files
128
+ {
129
+ //// Bezier Drawing
130
+ UIBezierPath* bezierPath = [UIBezierPath bezierPath];
131
+ [bezierPath moveToPoint: CGPointMake(22.1, 3.43)];
132
+ [bezierPath addLineToPoint: CGPointMake(20.64, 3.43)];
133
+ [bezierPath addCurveToPoint: CGPointMake(20.55, 3.45) controlPoint1: CGPointMake(20.61, 3.43) controlPoint2: CGPointMake(20.58, 3.44)];
134
+ [bezierPath addLineToPoint: CGPointMake(20.55, 1.88)];
135
+ [bezierPath addCurveToPoint: CGPointMake(18.66, 0) controlPoint1: CGPointMake(20.55, 0.84) controlPoint2: CGPointMake(19.7, 0)];
136
+ [bezierPath addLineToPoint: CGPointMake(5.97, 0)];
137
+ [bezierPath addCurveToPoint: CGPointMake(4.08, 1.88) controlPoint1: CGPointMake(4.93, 0) controlPoint2: CGPointMake(4.08, 0.84)];
138
+ [bezierPath addLineToPoint: CGPointMake(4.08, 19.45)];
139
+ [bezierPath addCurveToPoint: CGPointMake(5.97, 21.33) controlPoint1: CGPointMake(4.08, 20.49) controlPoint2: CGPointMake(4.93, 21.33)];
140
+ [bezierPath addLineToPoint: CGPointMake(8.2, 21.33)];
141
+ [bezierPath addLineToPoint: CGPointMake(8.2, 22.18)];
142
+ [bezierPath addCurveToPoint: CGPointMake(10.02, 24) controlPoint1: CGPointMake(8.2, 23.19) controlPoint2: CGPointMake(9.01, 24)];
143
+ [bezierPath addLineToPoint: CGPointMake(22.1, 24)];
144
+ [bezierPath addCurveToPoint: CGPointMake(23.92, 22.18) controlPoint1: CGPointMake(23.1, 24) controlPoint2: CGPointMake(23.92, 23.19)];
145
+ [bezierPath addLineToPoint: CGPointMake(23.92, 5.24)];
146
+ [bezierPath addCurveToPoint: CGPointMake(22.1, 3.43) controlPoint1: CGPointMake(23.92, 4.24) controlPoint2: CGPointMake(23.1, 3.43)];
147
+ [bezierPath closePath];
148
+ [bezierPath moveToPoint: CGPointMake(4.83, 19.45)];
149
+ [bezierPath addLineToPoint: CGPointMake(4.83, 1.88)];
150
+ [bezierPath addCurveToPoint: CGPointMake(5.97, 0.76) controlPoint1: CGPointMake(4.83, 1.27) controlPoint2: CGPointMake(5.34, 0.76)];
151
+ [bezierPath addLineToPoint: CGPointMake(18.66, 0.76)];
152
+ [bezierPath addCurveToPoint: CGPointMake(19.8, 1.88) controlPoint1: CGPointMake(19.29, 0.76) controlPoint2: CGPointMake(19.8, 1.27)];
153
+ [bezierPath addLineToPoint: CGPointMake(19.8, 19.45)];
154
+ [bezierPath addCurveToPoint: CGPointMake(18.66, 20.57) controlPoint1: CGPointMake(19.8, 20.07) controlPoint2: CGPointMake(19.29, 20.57)];
155
+ [bezierPath addLineToPoint: CGPointMake(5.97, 20.57)];
156
+ [bezierPath addCurveToPoint: CGPointMake(4.83, 19.45) controlPoint1: CGPointMake(5.34, 20.57) controlPoint2: CGPointMake(4.83, 20.07)];
157
+ [bezierPath closePath];
158
+ [bezierPath moveToPoint: CGPointMake(23.17, 22.18)];
159
+ [bezierPath addCurveToPoint: CGPointMake(22.1, 23.24) controlPoint1: CGPointMake(23.17, 22.77) controlPoint2: CGPointMake(22.69, 23.24)];
160
+ [bezierPath addLineToPoint: CGPointMake(10.02, 23.24)];
161
+ [bezierPath addCurveToPoint: CGPointMake(8.95, 22.18) controlPoint1: CGPointMake(9.43, 23.24) controlPoint2: CGPointMake(8.95, 22.77)];
162
+ [bezierPath addLineToPoint: CGPointMake(8.95, 21.33)];
163
+ [bezierPath addLineToPoint: CGPointMake(18.66, 21.33)];
164
+ [bezierPath addCurveToPoint: CGPointMake(20.55, 19.45) controlPoint1: CGPointMake(19.7, 21.33) controlPoint2: CGPointMake(20.55, 20.49)];
165
+ [bezierPath addLineToPoint: CGPointMake(20.55, 4.17)];
166
+ [bezierPath addCurveToPoint: CGPointMake(20.64, 4.19) controlPoint1: CGPointMake(20.58, 4.18) controlPoint2: CGPointMake(20.61, 4.19)];
167
+ [bezierPath addLineToPoint: CGPointMake(22.1, 4.19)];
168
+ [bezierPath addCurveToPoint: CGPointMake(23.17, 5.24) controlPoint1: CGPointMake(22.69, 4.19) controlPoint2: CGPointMake(23.17, 4.66)];
169
+ [bezierPath addLineToPoint: CGPointMake(23.17, 22.18)];
170
+ [bezierPath closePath];
171
+ bezierPath.miterLimit = 4;
172
+
173
+ [fillColor2 setFill];
174
+ [bezierPath fill];
175
+
176
+
177
+ //// Rectangle Drawing
178
+ UIBezierPath* rectanglePath = [UIBezierPath bezierPathWithRoundedRect: CGRectMake(8.25, 4.17, 8.4, 1.05) cornerRadius: 0.53];
179
+ [fillColor2 setFill];
180
+ [rectanglePath fill];
181
+
182
+
183
+ //// Rectangle 2 Drawing
184
+ UIBezierPath* rectangle2Path = [UIBezierPath bezierPathWithRoundedRect: CGRectMake(8.25, 7.33, 8.4, 1.05) cornerRadius: 0.52];
185
+ [fillColor2 setFill];
186
+ [rectangle2Path fill];
187
+
188
+
189
+ //// Rectangle 3 Drawing
190
+ UIBezierPath* rectangle3Path = [UIBezierPath bezierPathWithRoundedRect: CGRectMake(8.25, 10.48, 8.4, 1.05) cornerRadius: 0.52];
191
+ [fillColor2 setFill];
192
+ [rectangle3Path fill];
193
+
194
+
195
+ //// Rectangle 4 Drawing
196
+ UIBezierPath* rectangle4Path = [UIBezierPath bezierPathWithRoundedRect: CGRectMake(8.25, 13.58, 5.2, 1.05) cornerRadius: 0.52];
197
+ [fillColor2 setFill];
198
+ [rectangle4Path fill];
199
+ }
200
+ }];
201
+ });
202
+
203
+ return image;
204
+ }
205
+
206
+ @end
207
+
208
+ #endif
@@ -102,9 +102,21 @@ static BOOL HasSuffix(NSString *src, NSString *tail)
102
102
  NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
103
103
  NSString *documentPath = paths.firstObject;
104
104
  NSString *tempBundlePath = [documentPath stringByAppendingPathComponent:@".pb_liveload"];
105
- if (![[NSFileManager defaultManager] fileExistsAtPath:tempBundlePath]) {
106
- [[NSFileManager defaultManager] createDirectoryAtPath:tempBundlePath withIntermediateDirectories:NO attributes:nil error:nil];
105
+ NSError *error = nil;
106
+ if ([[NSFileManager defaultManager] fileExistsAtPath:tempBundlePath]) {
107
+ [[NSFileManager defaultManager] removeItemAtPath:tempBundlePath error:&error];
108
+ if (error != nil) {
109
+ NSLog(@"PBLiveLoader: Failed to clear cache.");
110
+ return;
111
+ }
112
+ }
113
+
114
+ [[NSFileManager defaultManager] createDirectoryAtPath:tempBundlePath withIntermediateDirectories:NO attributes:nil error:&error];
115
+ if (error != nil) {
116
+ NSLog(@"PBLiveLoader: Failed to initialize cache.");
117
+ return;
107
118
  }
119
+
108
120
  [self defaultLoader]->tempResourcesPath = tempBundlePath;
109
121
  [Pbind addResourcesBundle:[NSBundle bundleWithPath:tempBundlePath]];
110
122
  #endif
@@ -160,15 +172,28 @@ static BOOL HasSuffix(NSString *src, NSString *tail)
160
172
  if (method != nil && ![method isEqualToString:@"GET"]) {
161
173
  action = [action stringByAppendingFormat:@"@%@", [method lowercaseString]];
162
174
  }
163
- action = [action stringByReplacingOccurrencesOfString:@"/" withString:@"-"];
164
175
  if (kIgnoreAPIs != nil && [kIgnoreAPIs containsObject:action]) {
165
176
  complection(nil);
166
177
  return;
167
178
  }
168
179
 
169
- NSString *jsonName = [NSString stringWithFormat:@"%@/%@.json", [[client class] description], action];
180
+ action = [action stringByReplacingOccurrencesOfString:@"/" withString:@":"];
181
+ if (kIgnoreAPIs != nil && [kIgnoreAPIs containsObject:action]) {
182
+ complection(nil);
183
+ return;
184
+ }
185
+
186
+ NSString *clientName = [[client class] alias];
187
+ if (clientName == nil) {
188
+ clientName = [[client class] description];
189
+ }
190
+ NSString *jsonName = [NSString stringWithFormat:@"%@/%@", clientName, action];
191
+ if (kIgnoreAPIs != nil && [kIgnoreAPIs containsObject:jsonName]) {
192
+ complection(nil);
193
+ return;
194
+ }
170
195
  #if (TARGET_IPHONE_SIMULATOR)
171
- NSString *jsonPath = [serverPath stringByAppendingPathComponent:jsonName];
196
+ NSString *jsonPath = [[serverPath stringByAppendingPathComponent:jsonName] stringByAppendingPathExtension:@"json"];
172
197
  if (![[NSFileManager defaultManager] fileExistsAtPath:jsonPath]) {
173
198
  NSLog(@"PBLiveLoader: Missing '%@', ignores!", jsonName);
174
199
  complection(nil);
@@ -278,7 +303,6 @@ static BOOL HasSuffix(NSString *src, NSString *tail)
278
303
  - (void)requestAPI:(NSString *)api complection:(void (^)(PBResponse *))complection {
279
304
  static dispatch_once_t onceToken;
280
305
  dispatch_once(&onceToken, ^{
281
- [PBLLInspector addToWindow];
282
306
  [[PBLLRemoteWatcher globalWatcher] connectDefaultIP];
283
307
  });
284
308
 
@@ -299,14 +323,26 @@ static BOOL HasSuffix(NSString *src, NSString *tail)
299
323
 
300
324
  #pragma mark - PBLLRemoteWatcherDelegate
301
325
 
326
+ - (void)remoteWatcher:(PBLLRemoteWatcher *)watcher didChangeConnectState:(BOOL)connected {
327
+ [[PBLLInspector sharedInspector] updateConnectState:connected];
328
+ }
329
+
302
330
  - (void)remoteWatcher:(PBLLRemoteWatcher *)watcher didReceiveResponse:(NSData *)jsonData {
303
331
  [[self class] receiveJsonData:jsonData withFile:nil complection:apiComplection];
304
332
  }
305
333
 
306
334
  - (void)remoteWatcher:(PBLLRemoteWatcher *)watcher didUpdateFile:(NSString *)fileName withData:(NSData *)data {
307
335
  if (HasSuffix(fileName, @".plist")) {
308
- NSString *plist = [tempResourcesPath stringByAppendingPathComponent:fileName];
309
- [data writeToFile:plist atomically:NO];
336
+ NSError *error;
337
+ NSPropertyListFormat format;
338
+ NSDictionary *dict = [NSPropertyListSerialization propertyListWithData:data options:NSPropertyListImmutable format:&format error:&error];
339
+ if (!dict){
340
+ NSLog(@"PBLiveLoader: Got a invalid plist. (error: %@)", error);
341
+ return;
342
+ }
343
+
344
+ NSString *plistPath = [tempResourcesPath stringByAppendingPathComponent:fileName];
345
+ [data writeToFile:plistPath atomically:NO];
310
346
 
311
347
  [Pbind reloadViewsOnPlistUpdate:fileName];
312
348
  } else if (HasSuffix(fileName, @".json")) {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pbind
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Galen Lin
@@ -76,8 +76,10 @@ files:
76
76
  - lib/pbind/command.rb
77
77
  - lib/pbind/command/mock.rb
78
78
  - lib/pbind/command/serv.rb
79
+ - lib/pbind/command/view.rb
79
80
  - lib/pbind/command/watch.rb
80
81
  - lib/pbind/gem_version.rb
82
+ - lib/pbind/minify.rb
81
83
  - lib/pbind/user_interface.rb
82
84
  - source/PBLiveLoader/NSInputStream+Reader.h
83
85
  - source/PBLiveLoader/NSInputStream+Reader.m
@@ -87,9 +89,13 @@ files:
87
89
  - source/PBLiveLoader/PBLLInspector.m
88
90
  - source/PBLiveLoader/PBLLInspectorController.h
89
91
  - source/PBLiveLoader/PBLLInspectorController.m
92
+ - source/PBLiveLoader/PBLLInspectorTipsController.h
93
+ - source/PBLiveLoader/PBLLInspectorTipsController.m
90
94
  - source/PBLiveLoader/PBLLOptions.h
91
95
  - source/PBLiveLoader/PBLLRemoteWatcher.h
92
96
  - source/PBLiveLoader/PBLLRemoteWatcher.m
97
+ - source/PBLiveLoader/PBLLResource.h
98
+ - source/PBLiveLoader/PBLLResource.m
93
99
  - source/PBLiveLoader/PBLiveLoader.h
94
100
  - source/PBLiveLoader/PBLiveLoader.m
95
101
  - source/PBLiveLoader/PBSimulatorEnviroment.h
@@ -114,9 +120,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
120
  version: '0'
115
121
  requirements: []
116
122
  rubyforge_project:
117
- rubygems_version: 2.6.6
123
+ rubygems_version: 2.6.8
118
124
  signing_key:
119
125
  specification_version: 4
120
126
  summary: Pbind xcodeproj helper
121
127
  test_files: []
122
- has_rdoc: