Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First shot at minimal APIs using Cocoa JavaScriptCore
- Loading branch information
Showing
35 changed files
with
2,135 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
# Mac desktop data | ||
.DS_Store | ||
|
||
# Compiled Object files | ||
*.slo | ||
*.lo | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
Electrino/Electrino.xcodeproj/project.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file added
BIN
+22.9 KB
...xcodeproj/project.xcworkspace/xcuserdata/pauli.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
5 changes: 5 additions & 0 deletions
5
...ino/Electrino.xcodeproj/xcuserdata/pauli.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Bucket | ||
type = "1" | ||
version = "2.0"> | ||
</Bucket> |
91 changes: 91 additions & 0 deletions
91
Electrino/Electrino.xcodeproj/xcuserdata/pauli.xcuserdatad/xcschemes/Electrino.xcscheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Scheme | ||
LastUpgradeVersion = "0820" | ||
version = "1.3"> | ||
<BuildAction | ||
parallelizeBuildables = "YES" | ||
buildImplicitDependencies = "YES"> | ||
<BuildActionEntries> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "YES" | ||
buildForArchiving = "YES" | ||
buildForAnalyzing = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "5AA9DBAD1EB9F58A00EF7CC9" | ||
BuildableName = "ElectrinoTest.app" | ||
BlueprintName = "ElectrinoTest" | ||
ReferencedContainer = "container:Electrino.xcodeproj"> | ||
</BuildableReference> | ||
</BuildActionEntry> | ||
</BuildActionEntries> | ||
</BuildAction> | ||
<TestAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
shouldUseLaunchSchemeArgsEnv = "YES"> | ||
<Testables> | ||
</Testables> | ||
<MacroExpansion> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "5AA9DBAD1EB9F58A00EF7CC9" | ||
BuildableName = "ElectrinoTest.app" | ||
BlueprintName = "ElectrinoTest" | ||
ReferencedContainer = "container:Electrino.xcodeproj"> | ||
</BuildableReference> | ||
</MacroExpansion> | ||
<AdditionalOptions> | ||
</AdditionalOptions> | ||
</TestAction> | ||
<LaunchAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
launchStyle = "0" | ||
useCustomWorkingDirectory = "NO" | ||
ignoresPersistentStateOnLaunch = "NO" | ||
debugDocumentVersioning = "YES" | ||
debugServiceExtension = "internal" | ||
allowLocationSimulation = "YES"> | ||
<BuildableProductRunnable | ||
runnableDebuggingMode = "0"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "5AA9DBAD1EB9F58A00EF7CC9" | ||
BuildableName = "ElectrinoTest.app" | ||
BlueprintName = "ElectrinoTest" | ||
ReferencedContainer = "container:Electrino.xcodeproj"> | ||
</BuildableReference> | ||
</BuildableProductRunnable> | ||
<AdditionalOptions> | ||
</AdditionalOptions> | ||
</LaunchAction> | ||
<ProfileAction | ||
buildConfiguration = "Release" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
savedToolIdentifier = "" | ||
useCustomWorkingDirectory = "NO" | ||
debugDocumentVersioning = "YES"> | ||
<BuildableProductRunnable | ||
runnableDebuggingMode = "0"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "5AA9DBAD1EB9F58A00EF7CC9" | ||
BuildableName = "ElectrinoTest.app" | ||
BlueprintName = "ElectrinoTest" | ||
ReferencedContainer = "container:Electrino.xcodeproj"> | ||
</BuildableReference> | ||
</BuildableProductRunnable> | ||
</ProfileAction> | ||
<AnalyzeAction | ||
buildConfiguration = "Debug"> | ||
</AnalyzeAction> | ||
<ArchiveAction | ||
buildConfiguration = "Release" | ||
revealArchiveInOrganizer = "YES"> | ||
</ArchiveAction> | ||
</Scheme> |
22 changes: 22 additions & 0 deletions
22
...trino/Electrino.xcodeproj/xcuserdata/pauli.xcuserdatad/xcschemes/xcschememanagement.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>SchemeUserState</key> | ||
<dict> | ||
<key>Electrino.xcscheme</key> | ||
<dict> | ||
<key>orderHint</key> | ||
<integer>0</integer> | ||
</dict> | ||
</dict> | ||
<key>SuppressBuildableAutocreation</key> | ||
<dict> | ||
<key>5AA9DBAD1EB9F58A00EF7CC9</key> | ||
<dict> | ||
<key>primary</key> | ||
<true/> | ||
</dict> | ||
</dict> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// AppDelegate.h | ||
// Electrino | ||
// | ||
// Created by Pauli Ojala on 03/05/17. | ||
// Copyright © 2017 Lacquer. All rights reserved. | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
|
||
@interface AppDelegate : NSObject <NSApplicationDelegate> | ||
|
||
|
||
@end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// | ||
// AppDelegate.m | ||
// Electrino | ||
// | ||
// Created by Pauli Ojala on 03/05/17. | ||
// Copyright © 2017 Lacquer. All rights reserved. | ||
// | ||
|
||
#import "AppDelegate.h" | ||
#import "ENOJavaScriptApp.h" | ||
|
||
|
||
@interface AppDelegate () | ||
|
||
@end | ||
|
||
|
||
|
||
|
||
@implementation AppDelegate | ||
|
||
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification | ||
{ | ||
NSString *appDir = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"js-app"]; | ||
NSString *mainJSPath = [appDir stringByAppendingPathComponent:@"main.js"]; | ||
|
||
if ( ![[NSFileManager defaultManager] fileExistsAtPath:mainJSPath]) { | ||
NSLog(@"** no main.js found in dir: %@", appDir); | ||
[NSApp terminate:nil]; // -- | ||
} | ||
|
||
NSString *mainJS = [NSString stringWithContentsOfFile:mainJSPath encoding:NSUTF8StringEncoding error:NULL]; | ||
ENOJavaScriptApp *jsApp = [ENOJavaScriptApp sharedApp]; | ||
NSError *error = nil; | ||
|
||
// setup | ||
jsApp.jsContext[@"__dirname"] = appDir; | ||
|
||
// load code | ||
if ( ![jsApp loadMainJS:mainJS error:&error]) { | ||
NSLog(@"** could not load main.js: %@, path: %@", error, mainJSPath); | ||
|
||
[self _presentJSError:error message:@"Main program execution failed."]; | ||
|
||
[NSApp terminate:nil]; // -- | ||
} | ||
|
||
// start | ||
if ( ![jsApp.jsAppGlobalObject emitReady:&error]) { | ||
NSLog(@"** app.on('ready'): %@", error); | ||
|
||
[self _presentJSError:error message:@"Exception in app.on('ready')"]; | ||
} | ||
} | ||
|
||
- (void)_presentJSError:(NSError *)error message:(NSString *)msg | ||
{ | ||
NSAlert *alert = [[NSAlert alloc] init]; | ||
alert.alertStyle = NSCriticalAlertStyle; | ||
alert.messageText = msg ?: @"JavaScript error"; | ||
alert.informativeText = [NSString stringWithFormat:@"\n%@\n\n(On line %@)", error.localizedDescription, error.userInfo[@"SourceLineNumber"]]; | ||
|
||
[alert runModal]; | ||
} | ||
|
||
- (void)applicationWillTerminate:(NSNotification *)aNotification | ||
{ | ||
|
||
} | ||
|
||
|
||
@end |
58 changes: 58 additions & 0 deletions
58
Electrino/Electrino/Assets.xcassets/AppIcon.appiconset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "mac", | ||
"size" : "16x16", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "16x16", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "32x32", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "32x32", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "128x128", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "128x128", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "256x256", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "256x256", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "512x512", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "512x512", | ||
"scale" : "2x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
Oops, something went wrong.