Skip to content

(#34) Rename top-level namespace to reactjuce:: #216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/guides/Integrating_Your_Project.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ our JUCE project.

## Native Code

Because we've already added the Blueprint module to our Projucer project, we can jump straight into the code on the native side. Part of the native Blueprint API is a particularly important class called `blueprint::ReactApplicationRoot`. This class is mostly just a `juce::Component`, and in that way you should think about using it the same way you might use a `juce::Slider` in your application.
Because we've already added the Blueprint module to our Projucer project, we can jump straight into the code on the native side. Part of the native Blueprint API is a particularly important class called `reactjuce::ReactApplicationRoot`. This class is mostly just a `juce::Component`, and in that way you should think about using it the same way you might use a `juce::Slider` in your application.

For example, let's suppose that we have our `MainComponent` or our `AudioProcessorPluginEditor` at the top of our project:

Expand All @@ -54,7 +54,7 @@ private:
};
```

Adding the `blueprint::ReactApplicationRoot` is easy, and should be familiar if you've worked with `juce::Component`s before:
Adding the `reactjuce::ReactApplicationRoot` is easy, and should be familiar if you've worked with `juce::Component`s before:

```cpp
class MainComponent : public Component
Expand All @@ -79,7 +79,7 @@ public:

private:
//==============================================================================
blueprint::ReactApplicationRoot appRoot;
reactjuce::ReactApplicationRoot appRoot;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainComponent)
};
Expand Down Expand Up @@ -121,7 +121,7 @@ public:

private:
//==============================================================================
blueprint::ReactApplicationRoot appRoot;
reactjuce::ReactApplicationRoot appRoot;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainComponent)
};
Expand Down
6 changes: 3 additions & 3 deletions docs/native/Interop.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ auto result = engine->invoke("myFun", (int) myValue);

## Custom Native View
Now the other option is to define a totally custom native view, and register it with React.
To do this, you can make your own C++ class that inherits `blueprint::View`, and override the necessary methods.
Basically, a `blueprint::View` is just a `juce::Component` with some extra goodies.
To do this, you can make your own C++ class that inherits `reactjuce::View`, and override the necessary methods.
Basically, a `reactjuce::View` is just a `juce::Component` with some extra goodies.

For greater detail, see [Custom Native Components](Custom_Native_Components.md), but for a brief example, see below.

### Example

```cpp
class MyCoolView : public blueprint::View {
class MyCoolView : public reactjuce::View {
void paint(juce::Graphics& g) override {
// Do your own paint routine like usual.
// You can also treat this whole class instance like your normal juce::Components. Add children, `addAndMakeVisible`,
Expand Down
2 changes: 1 addition & 1 deletion examples/GainPlugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ juce_generate_juce_header(GainPlugin)
# that will be built into the target. This is a standard CMake command.
target_sources(GainPlugin PRIVATE PluginProcessor.cpp)

# Add an explicit include path here so that Blueprint's EcmascriptEngine can find
# Add an explicit include path here so that React-juce's EcmascriptEngine can find
# the included Duktape source. You can optionally point this elsewhere if you'd like to
# include a custom Duktape build.
target_include_directories(GainPlugin PRIVATE react_juce/)
Expand Down
2 changes: 1 addition & 1 deletion examples/GainPlugin/PluginProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ AudioProcessorEditor* GainPluginAudioProcessor::createEditor()
File sourceDir = File(GAINPLUGIN_SOURCE_DIR);
File bundle = sourceDir.getChildFile("jsui/build/js/main.js");

auto* editor = new blueprint::GenericEditor(*this, bundle);
auto* editor = new reactjuce::GenericEditor(*this, bundle);

editor->setResizable(true, true);
editor->setResizeLimits(400, 240, 400 * 2, 240 * 2);
Expand Down
6 changes: 3 additions & 3 deletions examples/GainPlugin/jsui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/GainPlugin/jsui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"dependencies": {
"@babel/runtime-corejs3": "^7.11.2",
"react-juce": "^0.2.9",
"react-juce": "^0.2.10",
"file-loader": "6.1.0",
"react": "^16.13.1"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/GainPlugin/jsui/src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import Blueprint from 'react-juce';
import ReactJUCE from 'react-juce';
import App from './App';

Blueprint.render(<App />, Blueprint.getRootContainer());
ReactJUCE.render(<App />, ReactJUCE.getRootContainer());
2 changes: 1 addition & 1 deletion packages/react-juce/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/react-juce/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-juce",
"version": "0.2.9",
"version": "0.2.10",
"description": "Write cross-platform native apps with React.js and JUCE.",
"repository": {
"type": "git",
Expand Down
6 changes: 3 additions & 3 deletions packages/react-juce/scripts/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var targetDir = path.resolve(args[0]);
var packageDir = path.resolve(__dirname, '..');
var templateDir = path.resolve(packageDir, 'template');

console.log('Initializing a Blueprint template in:', chalk.green(targetDir));
console.log('Initializing a React-JUCE template in:', chalk.green(targetDir));
console.log('Directory tree will be created if it does not exist.');

fs.mkdirp(targetDir, function(err) {
Expand Down Expand Up @@ -45,14 +45,14 @@ fs.mkdirp(targetDir, function(err) {

console.log();
console.log(`
${chalk.blue('Success!')} Initialized a Blueprint template in ${chalk.green(targetDir)}
${chalk.blue('Success!')} Initialized a React-JUCE template in ${chalk.green(targetDir)}

You can now get started by typing:

${chalk.blue('cd')} ${args[0]}
${chalk.blue('npm start')}

Then adding the blueprint::ReactApplicationRoot component to your project.
Then adding the reactjuce::ReactApplicationRoot component to your project.
`);
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/react-juce/src/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Component } from 'react';

import { View } from './View'
import { SyntheticMouseEvent } from '../lib/SyntheticEvents'
import { ViewInstance } from "../lib/BlueprintBackend";
import { ViewInstance } from "../lib/Backend";

//TODO: Once ViewProps work is complete we can probably
// remove this in favour of ViewProps.
Expand Down
2 changes: 1 addition & 1 deletion packages/react-juce/src/components/ListView.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component, PropsWithChildren, ReactElement } from 'react';

import { ViewInstance } from "../lib/BlueprintBackend";
import { ViewInstance } from "../lib/Backend";
import { ScrollView, ScrollEvent } from './ScrollView';

import invariant from 'invariant';
Expand Down
10 changes: 5 additions & 5 deletions packages/react-juce/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import 'core-js/es6/set';
import 'core-js/es6/map';

import BlueprintBackend from './lib/BlueprintBackend';
import BlueprintRenderer, { BlueprintTracedRenderer } from './lib/BlueprintRenderer';
import Backend from './lib/Backend';
import Renderer, { TracedRenderer } from './lib/Renderer';

export { default as EventBridge } from './lib/EventBridge';

Expand All @@ -18,12 +18,12 @@ export * from './components/ListView';
export * from './lib/SyntheticEvents';

let __renderStarted = false;
let __preferredRenderer = BlueprintRenderer;
let __preferredRenderer = Renderer;

export default {

getRootContainer() {
return BlueprintBackend.getRootContainer();
return Backend.getRootContainer();
},

render(element: any, container: any, callback?: () => void | null | undefined) {
Expand All @@ -46,7 +46,7 @@ export default {
throw new Error('Cannot enable method trace after initial render.');
}

__preferredRenderer = BlueprintTracedRenderer;
__preferredRenderer = TracedRenderer;
},

};
2 changes: 1 addition & 1 deletion packages/react-juce/src/lib/NativeMethods.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
let Native = global['__BlueprintNative__'] || {};
let Native = global['__NativeBindings__'] || {};
let DefaultExport = Native;

declare var process : {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import MethodTracer from './MethodTracer';
import ReactReconciler from 'react-reconciler';
import BlueprintBackend, {ViewInstance, RawTextViewInstance} from './BlueprintBackend';
import Backend, {ViewInstance, RawTextViewInstance} from './Backend';

import invariant from 'invariant';

Expand Down Expand Up @@ -43,7 +43,7 @@ const HostConfig = {

prepareForCommit: (...args: any) => {},
resetAfterCommit: (...args: any) => {
BlueprintBackend.resetAfterCommit();
Backend.resetAfterCommit();
},

/** Called to determine whether or not a new text value can be set on an
Expand Down Expand Up @@ -73,7 +73,7 @@ const HostConfig = {
'Nesting elements inside of <Text> is currently not supported.'
);

return BlueprintBackend.createViewInstance(elementType, props, rootContainerInstance);
return Backend.createViewInstance(elementType, props, rootContainerInstance);
},

/** Create a new text node. */
Expand All @@ -86,7 +86,7 @@ const HostConfig = {
'Raw text strings must be rendered within a <Text> element.'
);

return BlueprintBackend.createTextViewInstance(text, rootContainerInstance);
return Backend.createTextViewInstance(text, rootContainerInstance);
},

/** Mount the child to its container. */
Expand Down Expand Up @@ -209,4 +209,4 @@ const HostConfig = {
//TODO: Applied ts-ignore here as TS complains about missing functions on HostConfig
//@ts-ignore
export default ReactReconciler(HostConfig);
export const BlueprintTracedRenderer = ReactReconciler(new Proxy(HostConfig, MethodTracer));
export const TracedRenderer = ReactReconciler(new Proxy(HostConfig, MethodTracer));
2 changes: 1 addition & 1 deletion packages/react-juce/src/lib/SyntheticEvents.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Instance } from "./BlueprintBackend";
import { Instance } from "./Backend";

export class SyntheticEvent {
public bubbles: boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-juce/template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"dependencies": {
"@babel/runtime-corejs3": "^7.10.3",
"react-juce": "^0.2.9",
"react-juce": "^0.2.10",
"react": "^16.6.3"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/react-juce/template/src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import Blueprint from 'react-juce';
import ReactJUCE from 'react-juce';
import App from './App';

Blueprint.render(<App />, Blueprint.getRootContainer());
ReactJUCE.render(<App />, ReactJUCE.getRootContainer());
2 changes: 1 addition & 1 deletion react_juce/core/AppHarness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "AppHarness.h"


namespace blueprint
namespace reactjuce
{

//==============================================================================
Expand Down
2 changes: 1 addition & 1 deletion react_juce/core/AppHarness.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "ReactApplicationRoot.h"


namespace blueprint
namespace reactjuce
{

/** The AppHarness is a simple class which composes over your ReactApplicationRoot
Expand Down
4 changes: 2 additions & 2 deletions react_juce/core/CanvasView.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "View.h"


namespace blueprint
namespace reactjuce
{
/** The CanvasContext class is a C++ implementation/binding for the
* HTML Canvas API's CanvasRenderingContext2D object.
Expand Down Expand Up @@ -84,7 +84,7 @@ namespace blueprint
~CanvasContext() = default;

/** Set the size of the CanvasContext. This is akin to setting the width and height attributes
* on a HTML <canvas> element. If you have a blueprint::View or a juce::Component that wished
* on a HTML <canvas> element. If you have a View or a juce::Component that wished
* to render a CanvasContext you should ensure CanvasContext::setSize() is called from the
* View/Component's resized function.
*/
Expand Down
4 changes: 2 additions & 2 deletions react_juce/core/EcmascriptEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
#include "EcmascriptEngine.h"


namespace blueprint
namespace reactjuce
{

namespace detail
Expand Down Expand Up @@ -689,7 +689,7 @@ namespace blueprint
struct CallbackHelper {
CallbackHelper(std::weak_ptr<duk_context> _weakContext)
: weakContext(_weakContext)
, funcId(juce::String("__blueprintCallback__") + juce::Uuid().toString()) {}
, funcId(juce::String("__NativeCallback__") + juce::Uuid().toString()) {}

~CallbackHelper() {
if (auto spt = weakContext.lock()) {
Expand Down
2 changes: 1 addition & 1 deletion react_juce/core/EcmascriptEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <unordered_map>


namespace blueprint
namespace reactjuce
{

//==============================================================================
Expand Down
2 changes: 1 addition & 1 deletion react_juce/core/FileWatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#pragma once


namespace blueprint
namespace reactjuce
{

//==============================================================================
Expand Down
2 changes: 1 addition & 1 deletion react_juce/core/GenericEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "GenericEditor.h"


namespace blueprint
namespace reactjuce
{

//==============================================================================
Expand Down
2 changes: 1 addition & 1 deletion react_juce/core/GenericEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "ReactApplicationRoot.h"


namespace blueprint
namespace reactjuce
{

//==============================================================================
Expand Down
2 changes: 1 addition & 1 deletion react_juce/core/ImageView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace

}

namespace blueprint
namespace reactjuce
{
//==============================================================================
void ImageView::setProperty(const juce::Identifier& name, const juce::var& value)
Expand Down
2 changes: 1 addition & 1 deletion react_juce/core/ImageView.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "View.h"


namespace blueprint
namespace reactjuce
{
//==============================================================================
/** The ImageView class is a core view for drawing images within Blueprint's
Expand Down
2 changes: 1 addition & 1 deletion react_juce/core/RawTextView.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "View.h"


namespace blueprint
namespace reactjuce
{

//==============================================================================
Expand Down
Loading