Last active
February 18, 2016 11:03
-
-
Save ChrisRus/f260d02d07e53d0f704b to your computer and use it in GitHub Desktop.
Auto-generated HTML5 client app entry point generated by 'snapsite' tool I've been working on...
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
// ====================================================================== | |
/* | |
__client-entry.jsx | |
Copyright (C) 2016 Encapsule.io | |
Main client entry point for Encapsule.io snapsite route '95cdf211'. | |
This script will be called when the HTML5 document published at | |
URL 'https://encapsule.io/' loads in your browser. | |
Produced by Encapsule/snapsite v0.0.7 Thu Feb 18 2016 02:49:24 GMT-0800 (PST) | |
Site build instance: [1455792564291 oa4g-BU0TwqyiibOIhk3tw] | |
*/ | |
// ====================================================================== | |
// Load the snapsite runtime library. | |
const SNAPRT = require('../client-libs'); | |
// Alias submodules. | |
const ARCCORE = SNAPRT.arccore; | |
const React = SNAPRT.react; | |
const ReactDOM = SNAPRT.reactDOM; | |
// Load the React data context prepared by snapsite. | |
var reactContextData = require('json!./__page-context'); | |
// Convert the serialized pages digraph model into an in-memory graph DB. | |
var factoryResponse = ARCCORE.graph.directed.create(reactContextData.pagesGraph); | |
if (factoryResponse.error) { | |
throw new Error(factoryResponse.error); | |
} | |
// Replace the serialized digraph model with a runtime DirectedGraph container. | |
reactContextData.pagesGraph = factoryResponse.result; | |
// Load the developer-defined React component responsible for rendering | |
// page-specific content from (a) the React data context (b) user input | |
// (c) local storage (d) communication with remote servers. | |
var reactContentComponent = require('./root.jsx'); | |
// If there's no content.jsx module defined in the route directory, | |
// use <MissingContent> component from SNAPSITE.reactTheme. | |
// TO-DO | |
// Possibly require in client-side app plug-ins? | |
// I'm thinking a pre/post render callback would be useful. | |
// May additionally provide the option to override default | |
// behavior entirely skipping the auto-render? | |
// TO-DO | |
// Specialize the content rendering behavior of <SnapPage>. | |
reactContextData.renderContent = reactContentComponent; | |
ReactDOM.render( | |
React.createElement(SNAPRT.reactTheme.SnapPage, reactContextData), | |
document.getElementById('content') | |
); | |
// ====================================================================== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment