From 80a8767706e2aa0a9cbd40f9294bb918750bb71a Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Wed, 19 Jun 2019 13:23:30 -0700 Subject: [PATCH] Updated modulo tiles app to load in 500ms --- apps/chat/src/js/api.js | 2 +- apps/chat/src/js/components/lib/chat-input.js | 7 +- apps/chat/src/js/components/lib/message.js | 7 +- apps/chat/src/js/components/new.js | 1 + apps/chat/src/js/subscription.js | 11 ++ apps/chat/tile/tile.js | 21 ++++ apps/chat/urbit/app/chat.hoon | 23 +++- apps/chat/urbit/app/chat/js/index.js | 74 ++++++------ apps/chat/urbit/app/chat/js/tile.js | 27 ++++- apps/chat/urbit/lib/chat.hoon | 108 +++++++++--------- apps/chat/urbit/mar/chat/initial.hoon | 56 --------- apps/clock/urbit/app/clock.hoon | 4 +- apps/launch/src/js/components/home.js | 29 +---- apps/launch/src/js/components/tile.js | 2 +- apps/launch/urbit/app/launch.hoon | 48 +++++--- apps/launch/urbit/app/launch/index.hoon | 18 +++ apps/launch/urbit/app/launch/index.html | 16 --- apps/launch/urbit/app/launch/js/index.js | 39 +------ apps/timer/urbit/app/timer.hoon | 8 +- apps/weather/urbit/app/weather.hoon | 11 +- 20 files changed, 253 insertions(+), 259 deletions(-) delete mode 100644 apps/chat/urbit/mar/chat/initial.hoon create mode 100644 apps/launch/urbit/app/launch/index.hoon delete mode 100644 apps/launch/urbit/app/launch/index.html diff --git a/apps/chat/src/js/api.js b/apps/chat/src/js/api.js index 1d6ac99928..32bfffc391 100644 --- a/apps/chat/src/js/api.js +++ b/apps/chat/src/js/api.js @@ -13,7 +13,7 @@ class UrbitApi { bind(path, method, ship = this.authTokens.ship, appl = "hall", success, fail) { this.bindPaths = _.uniq([...this.bindPaths, path]); - window.urb.subscribe(ship, appl, path, + window.subscriptionId = window.urb.subscribe(ship, appl, path, (err) => { fail(err); }, diff --git a/apps/chat/src/js/components/lib/chat-input.js b/apps/chat/src/js/components/lib/chat-input.js index 193809a640..715f13cebe 100644 --- a/apps/chat/src/js/components/lib/chat-input.js +++ b/apps/chat/src/js/components/lib/chat-input.js @@ -48,10 +48,13 @@ export class ChatInput extends Component { }); } - setTimeout(closure, 1000); + //setTimeout(closure, 2000); + setTimeout(() => { + window.location.reload(false); + }, 1000); }; - //closure(); + //setTimeout(closure, 2000); this.state = { diff --git a/apps/chat/src/js/components/lib/message.js b/apps/chat/src/js/components/lib/message.js index 5a06cc70e4..3712b403a4 100644 --- a/apps/chat/src/js/components/lib/message.js +++ b/apps/chat/src/js/components/lib/message.js @@ -38,6 +38,11 @@ export class Message extends Component { render() { let pending = !!this.props.msg.pending ? ' o-80' : ''; + + let timestamp = moment.unix(this.props.msg.wen / 1000).format('hh:mm'); + window.timestamp = timestamp; + window.wen = this.props.msg.wen; + window.moment = moment; return (
@@ -47,7 +52,7 @@ export class Message extends Component {

~{this.props.msg.aut}

-

{moment.unix(this.props.msg.wen).format('hh:mm')}

+

{timestamp}

{this.renderContent(this.props.details.type)}
diff --git a/apps/chat/src/js/components/new.js b/apps/chat/src/js/components/new.js index 100ae2a12a..5785f46e1d 100644 --- a/apps/chat/src/js/components/new.js +++ b/apps/chat/src/js/components/new.js @@ -1,5 +1,6 @@ import React, { Component } from 'react'; import classnames from 'classnames'; +import { uuid } from '/lib/util'; export class NewScreen extends Component { diff --git a/apps/chat/src/js/subscription.js b/apps/chat/src/js/subscription.js index ece9100505..8f03a294a5 100644 --- a/apps/chat/src/js/subscription.js +++ b/apps/chat/src/js/subscription.js @@ -18,6 +18,17 @@ export class Subscription { api.bind('/primary', 'PUT', api.authTokens.ship, 'chat', this.handleEvent.bind(this), this.handleError.bind(this)); + + /*window.addEventListener('beforeunload', (event) => { + // Cancel the event as stated by the standard. + event.preventDefault(); + // Chrome requires returnValue to be set. + event.returnValue = ''; + + if (window.subscriptionId) { + window.urb.unsubscribe(window.subscriptionId); + } + });*/ } fetchMessages(circle, start, end) { diff --git a/apps/chat/tile/tile.js b/apps/chat/tile/tile.js index 5921b52dcd..f819aafb7f 100644 --- a/apps/chat/tile/tile.js +++ b/apps/chat/tile/tile.js @@ -4,7 +4,28 @@ import classnames from 'classnames'; export default class ChatTile extends Component { + constructor(props) { + super(props); + + this.state = { + configs: null, + messages: null, + message: null + }; + } + + componentDidUpdate(prevProps, prevState) { + const { props, state } = this; + if (prevProps !== props) { + + // TODO: reducer logic :( + + this.setState(props); + } + } + render() { + console.log(this.state); return (
{ fail(err); }, @@ -47896,8 +47892,6 @@ isBuffer: isBuffer }); - var require$$0 = getCjsExportFromNamespace(bufferEs6); - var bn = createCommonjsModule(function (module) { (function (module, exports) { @@ -47950,7 +47944,7 @@ var Buffer; try { - Buffer = require$$0.Buffer; + Buffer = bufferEs6.Buffer; } catch (e) { } @@ -51997,6 +51991,17 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\ api.bind('/primary', 'PUT', api.authTokens.ship, 'chat', this.handleEvent.bind(this), this.handleError.bind(this)); + + /*window.addEventListener('beforeunload', (event) => { + // Cancel the event as stated by the standard. + event.preventDefault(); + // Chrome requires returnValue to be set. + event.returnValue = ''; + + if (window.subscriptionId) { + window.urb.unsubscribe(window.subscriptionId); + } + });*/ } fetchMessages(circle, start, end) { @@ -56950,16 +56955,21 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\ render() { let pending = !!this.props.msg.pending ? ' o-80' : ''; + + let timestamp = moment.unix(this.props.msg.wen / 1000).format('hh:mm'); + window.timestamp = timestamp; + window.wen = this.props.msg.wen; + window.moment = moment; return ( - react.createElement('div', { className: "w-100 pl3 pr3 pt2 pb2 mb2 cf flex" + pending, __self: this, __source: {fileName: _jsxFileName$8, lineNumber: 43}} - , react.createElement('div', { className: "fl mr2" , __self: this, __source: {fileName: _jsxFileName$8, lineNumber: 44}} - , react.createElement(Sigil, { ship: this.props.msg.aut, size: 32, __self: this, __source: {fileName: _jsxFileName$8, lineNumber: 45}} ) + react.createElement('div', { className: "w-100 pl3 pr3 pt2 pb2 mb2 cf flex" + pending, __self: this, __source: {fileName: _jsxFileName$8, lineNumber: 48}} + , react.createElement('div', { className: "fl mr2" , __self: this, __source: {fileName: _jsxFileName$8, lineNumber: 49}} + , react.createElement(Sigil, { ship: this.props.msg.aut, size: 32, __self: this, __source: {fileName: _jsxFileName$8, lineNumber: 50}} ) ) - , react.createElement('div', { className: "fr", style: { flexGrow: 1, marginTop: -4 }, __self: this, __source: {fileName: _jsxFileName$8, lineNumber: 47}} - , react.createElement('div', {__self: this, __source: {fileName: _jsxFileName$8, lineNumber: 48}} - , react.createElement('p', { className: "v-top label-small-mono gray dib mr3" , __self: this, __source: {fileName: _jsxFileName$8, lineNumber: 49}}, "~", this.props.msg.aut) - , react.createElement('p', { className: "v-top label-small-mono gray dib" , __self: this, __source: {fileName: _jsxFileName$8, lineNumber: 50}}, moment.unix(this.props.msg.wen).format('hh:mm')) + , react.createElement('div', { className: "fr", style: { flexGrow: 1, marginTop: -4 }, __self: this, __source: {fileName: _jsxFileName$8, lineNumber: 52}} + , react.createElement('div', {__self: this, __source: {fileName: _jsxFileName$8, lineNumber: 53}} + , react.createElement('p', { className: "v-top label-small-mono gray dib mr3" , __self: this, __source: {fileName: _jsxFileName$8, lineNumber: 54}}, "~", this.props.msg.aut) + , react.createElement('p', { className: "v-top label-small-mono gray dib" , __self: this, __source: {fileName: _jsxFileName$8, lineNumber: 55}}, timestamp) ) , this.renderContent(this.props.details.type) ) @@ -57041,7 +57051,7 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\ constructor(props) { super(props); - //closure(); + //setTimeout(closure, 2000); this.state = { @@ -57149,19 +57159,19 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\ const { props, state } = this; return ( - react.createElement('div', { className: "mt2 pa3 cf flex black bt" , __self: this, __source: {fileName: _jsxFileName$b, lineNumber: 162}} - , react.createElement('div', { className: "fl", style: { flexBasis: 35, height: 40 }, __self: this, __source: {fileName: _jsxFileName$b, lineNumber: 163}} - , react.createElement(Sigil, { ship: window.ship, size: 32, __self: this, __source: {fileName: _jsxFileName$b, lineNumber: 164}} ) + react.createElement('div', { className: "mt2 pa3 cf flex black bt" , __self: this, __source: {fileName: _jsxFileName$b, lineNumber: 165}} + , react.createElement('div', { className: "fl", style: { flexBasis: 35, height: 40 }, __self: this, __source: {fileName: _jsxFileName$b, lineNumber: 166}} + , react.createElement(Sigil, { ship: window.ship, size: 32, __self: this, __source: {fileName: _jsxFileName$b, lineNumber: 167}} ) ) - , react.createElement('div', { className: "fr h-100 flex" , style: { flexGrow: 1, height: 40 }, __self: this, __source: {fileName: _jsxFileName$b, lineNumber: 166}} + , react.createElement('div', { className: "fr h-100 flex" , style: { flexGrow: 1, height: 40 }, __self: this, __source: {fileName: _jsxFileName$b, lineNumber: 169}} , react.createElement('input', { className: "ml2 bn" , style: { flexGrow: 1 }, ref: this.textareaRef, placeholder: props.placeholder, value: state.message, - onChange: this.messageChange, __self: this, __source: {fileName: _jsxFileName$b, lineNumber: 167}} ) - , react.createElement('div', { className: "pointer", onClick: this.messageSubmit, __self: this, __source: {fileName: _jsxFileName$b, lineNumber: 173}} - , react.createElement(IconSend, {__self: this, __source: {fileName: _jsxFileName$b, lineNumber: 174}} ) + onChange: this.messageChange, __self: this, __source: {fileName: _jsxFileName$b, lineNumber: 170}} ) + , react.createElement('div', { className: "pointer", onClick: this.messageSubmit, __self: this, __source: {fileName: _jsxFileName$b, lineNumber: 176}} + , react.createElement(IconSend, {__self: this, __source: {fileName: _jsxFileName$b, lineNumber: 177}} ) ) ) ) @@ -57681,23 +57691,23 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\ render() { return ( - react.createElement('div', { className: "h-100 w-100 pa3 pt2 overflow-x-hidden flex flex-column" , __self: this, __source: {fileName: _jsxFileName$g, lineNumber: 86}} - , react.createElement('h2', { className: "mb3", __self: this, __source: {fileName: _jsxFileName$g, lineNumber: 87}}, "Create a New Chat" ) - , react.createElement('div', {__self: this, __source: {fileName: _jsxFileName$g, lineNumber: 88}} - , react.createElement('p', { className: "label-regular fw-bold" , __self: this, __source: {fileName: _jsxFileName$g, lineNumber: 89}}, "Name") + react.createElement('div', { className: "h-100 w-100 pa3 pt2 overflow-x-hidden flex flex-column" , __self: this, __source: {fileName: _jsxFileName$g, lineNumber: 87}} + , react.createElement('h2', { className: "mb3", __self: this, __source: {fileName: _jsxFileName$g, lineNumber: 88}}, "Create a New Chat" ) + , react.createElement('div', {__self: this, __source: {fileName: _jsxFileName$g, lineNumber: 89}} + , react.createElement('p', { className: "label-regular fw-bold" , __self: this, __source: {fileName: _jsxFileName$g, lineNumber: 90}}, "Name") , react.createElement('input', { className: "body-large bn pa2 pl0 mb2 w-50" , placeholder: "secret-chat", - onChange: this.idChange, __self: this, __source: {fileName: _jsxFileName$g, lineNumber: 90}} ) - , react.createElement('p', { className: "label-regular fw-bold" , __self: this, __source: {fileName: _jsxFileName$g, lineNumber: 94}}, "Invites") + onChange: this.idChange, __self: this, __source: {fileName: _jsxFileName$g, lineNumber: 91}} ) + , react.createElement('p', { className: "label-regular fw-bold" , __self: this, __source: {fileName: _jsxFileName$g, lineNumber: 95}}, "Invites") , react.createElement('input', { className: "body-large bn pa2 pl0 mb2 w-50" , placeholder: "~zod, ~bus" , - onChange: this.invChange, __self: this, __source: {fileName: _jsxFileName$g, lineNumber: 95}} ) - , react.createElement('br', {__self: this, __source: {fileName: _jsxFileName$g, lineNumber: 99}} ) + onChange: this.invChange, __self: this, __source: {fileName: _jsxFileName$g, lineNumber: 96}} ) + , react.createElement('br', {__self: this, __source: {fileName: _jsxFileName$g, lineNumber: 100}} ) , react.createElement('button', { onClick: this.onClickCreate.bind(this), - className: "body-large pointer underline bn" , __self: this, __source: {fileName: _jsxFileName$g, lineNumber: 100}}, "-> Create" ) + className: "body-large pointer underline bn" , __self: this, __source: {fileName: _jsxFileName$g, lineNumber: 101}}, "-> Create" ) ) ) ); diff --git a/apps/chat/urbit/app/chat/js/tile.js b/apps/chat/urbit/app/chat/js/tile.js index 9a0bc6b617..19ff803c17 100644 --- a/apps/chat/urbit/app/chat/js/tile.js +++ b/apps/chat/urbit/app/chat/js/tile.js @@ -2206,17 +2206,38 @@ class ChatTile extends react_1 { + constructor(props) { + super(props); + + this.state = { + configs: null, + messages: null, + message: null + }; + } + + componentDidUpdate(prevProps, prevState) { + const { props, state } = this; + if (prevProps !== props) { + + // TODO: reducer logic :( + + this.setState(props); + } + } + render() { + console.log(this.state); return ( - react.createElement('div', { className: "bg-dark-gray w-100 h-100" , __self: this, __source: {fileName: _jsxFileName, lineNumber: 9}} + react.createElement('div', { className: "bg-dark-gray w-100 h-100" , __self: this, __source: {fileName: _jsxFileName, lineNumber: 30}} , react.createElement('a', { className: "w-100 h-100 db" , style: { paddingTop: 68, paddingBottom: 68, paddingLeft: 64, paddingRight: 64 }, - href: "/~chat", __self: this, __source: {fileName: _jsxFileName, lineNumber: 10}} - , react.createElement('img', { src: "/~chat/img/Tile.png", width: 106, height: 98, __self: this, __source: {fileName: _jsxFileName, lineNumber: 17}} ) + href: "/~chat", __self: this, __source: {fileName: _jsxFileName, lineNumber: 31}} + , react.createElement('img', { src: "/~chat/img/Tile.png", width: 106, height: 98, __self: this, __source: {fileName: _jsxFileName, lineNumber: 38}} ) ) ) ); diff --git a/apps/chat/urbit/lib/chat.hoon b/apps/chat/urbit/lib/chat.hoon index 77175e15a7..1528a98bd6 100644 --- a/apps/chat/urbit/lib/chat.hoon +++ b/apps/chat/urbit/lib/chat.hoon @@ -17,14 +17,14 @@ :: +$ diff $% [%hall-rumor rumor:hall] - [%chat-initial streams] [%chat-update update] [%chat-config streams] + [%json json] == :: +$ poke $% [%hall-action action:hall] - [%noun [@tas path]] + [%noun [@tas path @t]] == :: +$ state @@ -81,61 +81,59 @@ == == :: -++ parse-chat-command - =, dejs:format - =, dejs:hall-json - %- of +++ config-to-json + |= str=streams + =, enjs:format + ^- json + %+ frond %chat + %- pairs + :~ + :: + [%inbox (conf:enjs:hall-json inbox.str)] + :: + :- %configs + %- pairs + %+ turn ~(tap by configs.str) + |= [cir=circle:hall con=(unit config:hall)] + ^- [@t json] + :- (crip (circ:en-tape:hall-json cir)) + ?~(con ~ (conf:enjs:hall-json u.con)) + :: + :- %circles :- %a + %+ turn ~(tap in circles.str) + |= nom=name:hall + [%s nom] + :: + :- %peers + %- pairs + %+ turn ~(tap by peers.str) + |= [cir=circle:hall per=(set @p)] + ^- [@t json] + :- (crip (circ:en-tape:hall-json cir)) + [%a (turn ~(tap in per) ship)] + :: + == +:: +++ numbers-to-json + |= num=(list [circle:hall @ud]) + ^- json + =, enjs:format + %+ frond %chat + %- pairs :~ - [%messages (ot circle+circ start+ni end+ni ~)] + :: + :: %config + :- %numbers + :- %a + %+ turn num + |= [cir=circle:hall len=@ud] + ^- json + %- pairs + :~ + [%circle (circ:enjs:hall-json cir)] + [%length (numb len)] + == == :: -+$ indices-internal-state - $: - lis=(list [circle:hall @]) - item=[cir=circle:hall count=@ud] - index=@ - == -:: -++ generate-circle-indices - |= wir=wire - ^- (list [circle:hall @]) - =/ data - %^ spin (swag [0 (lent wir)] wir) *indices-internal-state - |= [a=@ta b=indices-internal-state] - ^- [* out=indices-internal-state] - =/ switch (dvr index.b 3) - ?: =(q.switch 0) :: remainder 0, should be a ship - ?: =(index.b 0) :: if item is null, don't add to list - :- 0 - %= b - hos.cir.item (slav %p a) - index +(index.b) - == - :: if item is not null, add to list - :- 0 - %= b - hos.cir.item (slav %p a) - nom.cir.item *name:hall - count.item 0 - lis (snoc lis.b item.b) - index +(index.b) - == - ?: =(q.switch 1) :: remainder 1, should be a circle name - :- 0 - %= b - nom.cir.item a - index +(index.b) - == - ?: =(q.switch 2) :: remainder 2, should be a number - :- 0 - %= b - count.item (need (rush a dem)) - index +(index.b) - == - !! :: impossible - ?: =(index.q.data 0) - ~ - (snoc lis.q.data item.q.data) -:: -- :: diff --git a/apps/chat/urbit/mar/chat/initial.hoon b/apps/chat/urbit/mar/chat/initial.hoon deleted file mode 100644 index 99c7f8dc55..0000000000 --- a/apps/chat/urbit/mar/chat/initial.hoon +++ /dev/null @@ -1,56 +0,0 @@ -:: -:: -/? 309 -:: -/- hall -/+ chat, hall-json -:: -|_ str=streams:chat -++ grow - |% - ++ json - =, enjs:format - ^- ^json - %+ frond %initial - %- pairs - :~ - :: - [%inbox (conf:enjs:hall-json inbox.str)] - :: - :- %configs - %- pairs - %+ turn ~(tap by configs.str) - |= [cir=circle:hall con=(unit config:hall)] - ^- [@t ^json] - :- (crip (circ:en-tape:hall-json cir)) - ?~(con ~ (conf:enjs:hall-json u.con)) - :: - :- %messages - %- pairs - %+ turn ~(tap by messages.str) - |= [cir=circle:hall lis=(list envelope:hall)] - ^- [@t ^json] - :- (crip (circ:en-tape:hall-json cir)) - [%a (turn lis enve:enjs:hall-json)] - :: - :- %circles :- %a - %+ turn ~(tap in circles.str) - |= nom=name:hall - [%s nom] - :: - :- %peers - %- pairs - %+ turn ~(tap by peers.str) - |= [cir=circle:hall per=(set @p)] - ^- [@t ^json] - :- (crip (circ:en-tape:hall-json cir)) - [%a (turn ~(tap in per) ship)] - :: - == - -- -:: -++ grab - |% - ++ noun streams:chat - -- --- diff --git a/apps/clock/urbit/app/clock.hoon b/apps/clock/urbit/app/clock.hoon index 15a52baaf5..df1dbf4154 100644 --- a/apps/clock/urbit/app/clock.hoon +++ b/apps/clock/urbit/app/clock.hoon @@ -15,7 +15,7 @@ :: +card: output effect payload :: +$ poke - $% [%noun [@tas path]] + $% [%noun [@tas path @t]] == :: +$ card @@ -41,7 +41,7 @@ ^- (quip move _this) =/ lismov/(list move) %+ weld `(list move)`[ost.bol %connect / [~ /'~clock'] %clock]~ - `(list move)`[ost.bol %poke /clock [our.bol %launch] [%noun [%clock /tile]]]~ + `(list move)`[ost.bol %poke /clock [our.bol %launch] [%noun [%clock /tile '/~clock/js/tile.js']]]~ :- lismov this :: diff --git a/apps/launch/src/js/components/home.js b/apps/launch/src/js/components/home.js index 2947e1d818..d8057b8e36 100644 --- a/apps/launch/src/js/components/home.js +++ b/apps/launch/src/js/components/home.js @@ -6,49 +6,22 @@ import classnames from 'classnames'; import Header from '/components/header'; import Tile from '/components/tile'; -const loadExternalScript = (ext, callback) => { - const script = document.createElement('script'); - script.src = '/~' + ext + '/tile.js'; - script.id = ext; - document.body.appendChild(script); - - script.onload = () => { - console.log('callback'); - if (callback) callback(); - }; -}; export default class Home extends Component { constructor(props) { super(props); - - this.loadedScripts = new Set(); subscription.subscribe("/main"); } - componentDidUpdate(prevProps, prevState) { - let difference = new Set( - [...this.props.keys] - .filter(x => !prevProps.keys.has(x)) - ); - - difference.forEach((external) => { - loadExternalScript(external, this.forceUpdate.bind(this)); - }); - } - render() { let keys = [...this.props.keys]; - console.log(keys); let tileElems = keys.map((tile) => { - console.log(tile); - console.log(this.props.data[tile]); return ( ); }); - + return (
diff --git a/apps/launch/src/js/components/tile.js b/apps/launch/src/js/components/tile.js index 80d8af0ec7..f9dc4f732a 100644 --- a/apps/launch/src/js/components/tile.js +++ b/apps/launch/src/js/components/tile.js @@ -11,7 +11,7 @@ export default class Tile extends Component { render() { let SpecificTile = window[this.props.type + 'Tile']; - console.log(this.props.type, this.props.data); + return (
diff --git a/apps/launch/urbit/app/launch.hoon b/apps/launch/urbit/app/launch.hoon index f45c72dc5b..fb04683f99 100644 --- a/apps/launch/urbit/app/launch.hoon +++ b/apps/launch/urbit/app/launch.hoon @@ -1,11 +1,8 @@ + /+ *server, collections /= index - /^ octs - /; as-octs:mimes:html - /: /===/app/launch/index - /| /html/ - /~ ~ - == + /^ $-(marl manx) + /: /===/app/launch/index /!noun/ /= script /^ octs /; as-octs:mimes:html @@ -35,7 +32,7 @@ [%diff %json json] == +$ tile [name=@tas subscribe=path] -+$ tile-data (map @tas json) ++$ tile-data (map @tas [jon=json url=@t]) +$ state $% [%0 tiles=(set tile) data=tile-data path-to-tile=(map path @tas)] == @@ -49,6 +46,7 @@ ++ prep |= old=(unit state) ^- (quip move _this) + ~& 'launch prep' ?~ old :_ this [ost.bol %connect / [~ /] %launch]~ @@ -60,33 +58,54 @@ [~ this] :: ++ poke-noun - |= [name=@tas subscribe=path] + |= [name=@tas subscribe=path url=@t] ^- (quip move _this) + =/ beforedata (~(get by data.sta) name) + =/ newdata + ?~ beforedata + (~(put by data.sta) name [*json url]) + (~(put by data.sta) name [jon.u.beforedata url]) :- [ost.bol %peer subscribe [our.bol name] subscribe]~ %= this tiles.sta (~(put in tiles.sta) [name subscribe]) - data.sta (~(put by data.sta) name *json) + data.sta newdata path-to-tile.sta (~(put by path-to-tile.sta) subscribe name) == :: ++ diff-json |= [pax=path jon=json] + ^- (quip move _this) =/ name/@tas (~(got by path-to-tile.sta) pax) + =/ data/(unit [json url=@t]) (~(get by data.sta) name) + ?~ data + [~ this] :- %+ turn (prey:pubsub:userlib /main bol) - |= [=bone *] - [bone %diff %json (frond:enjs:format name jon)] + |= [=bone *] + [bone %diff %json (frond:enjs:format name jon)] %= this - data.sta (~(put by data.sta) name jon) + data.sta (~(put by data.sta) name [jon url.u.data]) == :: ++ peer-main |= [pax=path] ^- (quip move _this) - =/ data/json %- pairs:enjs:format ~(tap by data.sta) + =/ data/json + %- pairs:enjs:format + %+ turn ~(tap by data.sta) + |= [key=@tas [jon=json url=@t]] + [key jon] :_ this [ost.bol %diff %json data]~ :: +++ generate-script-marl + |= data=tile-data + ^- marl + %+ turn ~(tap by data) + |= [key=@tas [jon=json url=@t]] + ^- manx + ;script@"{(trip url)}"; +:: ++ poke-handle-http-request %- (require-authorization:app ost.bol move this) |= =inbound-request:http-server @@ -100,8 +119,9 @@ i.back-path =/ site (flop site.request-line) ?~ site + =/ hym=manx (index (generate-script-marl data.sta)) :_ this - [ost.bol %http-response (html-response:app index)]~ + [ost.bol %http-response (manx-response:app hym)]~ ?+ site.request-line :_ this [ost.bol %http-response not-found:app]~ diff --git a/apps/launch/urbit/app/launch/index.hoon b/apps/launch/urbit/app/launch/index.hoon new file mode 100644 index 0000000000..765a1152e6 --- /dev/null +++ b/apps/launch/urbit/app/launch/index.hoon @@ -0,0 +1,18 @@ +|= scripts=marl +;html + ;head + ;title: Home + ;meta(charset "utf-8"); + ;meta + =name "viewport" + =content "width=device-width, initial-scale=1, shrink-to-fit=no"; + ;link(rel "stylesheet", href "/~launch/css/index.css"); + == + ;body + ;div#root; + ;script@"/~/channel/channel.js"; + ;script@"/~modulo/session.js"; + ;* scripts + ;script@"/~launch/js/index.js"; + == +== diff --git a/apps/launch/urbit/app/launch/index.html b/apps/launch/urbit/app/launch/index.html deleted file mode 100644 index fe14e5204c..0000000000 --- a/apps/launch/urbit/app/launch/index.html +++ /dev/null @@ -1,16 +0,0 @@ - - - - Home - - - - - -
- - - - - diff --git a/apps/launch/urbit/app/launch/js/index.js b/apps/launch/urbit/app/launch/js/index.js index efd2acd865..4bb3b67c1b 100644 --- a/apps/launch/urbit/app/launch/js/index.js +++ b/apps/launch/urbit/app/launch/js/index.js @@ -49126,7 +49126,7 @@ render() { let SpecificTile = window[this.props.type + 'Tile']; - console.log(this.props.type, this.props.data); + return ( react.createElement('div', { className: "fl ma2 bg-white overflow-hidden" , style: { height: '234px', width: '234px' }, __self: this, __source: {fileName: _jsxFileName$2, lineNumber: 16}} @@ -49141,53 +49141,26 @@ } const _jsxFileName$3 = "/Users/logan/Dev/interface/apps/launch/src/js/components/home.js"; - const loadExternalScript = (ext, callback) => { - const script = document.createElement('script'); - script.src = '/~' + ext + '/tile.js'; - script.id = ext; - document.body.appendChild(script); - - script.onload = () => { - console.log('callback'); - if (callback) callback(); - }; - }; class Home extends react_1 { constructor(props) { super(props); - - this.loadedScripts = new Set(); subscription.subscribe("/main"); } - componentDidUpdate(prevProps, prevState) { - let difference = new Set( - [...this.props.keys] - .filter(x => !prevProps.keys.has(x)) - ); - - difference.forEach((external) => { - loadExternalScript(external, this.forceUpdate.bind(this)); - }); - } - render() { let keys = [...this.props.keys]; - console.log(keys); let tileElems = keys.map((tile) => { - console.log(tile); - console.log(this.props.data[tile]); return ( - react.createElement(Tile, { key: tile, type: tile, data: this.props.data[tile], __self: this, __source: {fileName: _jsxFileName$3, lineNumber: 48}} ) + react.createElement(Tile, { key: tile, type: tile, data: this.props.data[tile], __self: this, __source: {fileName: _jsxFileName$3, lineNumber: 21}} ) ); }); - + return ( - react.createElement('div', { className: "fl w-100 vh-100 bg-black center" , __self: this, __source: {fileName: _jsxFileName$3, lineNumber: 53}} - , react.createElement(Header, {__self: this, __source: {fileName: _jsxFileName$3, lineNumber: 54}} ) - , react.createElement('div', { className: "v-mid pa2 dtc" , __self: this, __source: {fileName: _jsxFileName$3, lineNumber: 55}} + react.createElement('div', { className: "fl w-100 vh-100 bg-black center" , __self: this, __source: {fileName: _jsxFileName$3, lineNumber: 26}} + , react.createElement(Header, {__self: this, __source: {fileName: _jsxFileName$3, lineNumber: 27}} ) + , react.createElement('div', { className: "v-mid pa2 dtc" , __self: this, __source: {fileName: _jsxFileName$3, lineNumber: 28}} , tileElems ) ) diff --git a/apps/timer/urbit/app/timer.hoon b/apps/timer/urbit/app/timer.hoon index 56067b7336..55f2eee4e4 100644 --- a/apps/timer/urbit/app/timer.hoon +++ b/apps/timer/urbit/app/timer.hoon @@ -18,7 +18,7 @@ :: +card: output effect payload :: +$ poke - $% [%noun [@tas path]] + $% [%noun [@tas path @t]] == :: +$ card @@ -46,7 +46,7 @@ ^- (quip move _this) =/ lismov/(list move) %+ weld `(list move)`[ost.bol %connect / [~ /'~timer'] %timer]~ - `(list move)`[ost.bol %poke /timer [our.bol %launch] [%noun [%timer /tile]]]~ + `(list move)`[ost.bol %poke /timer [our.bol %launch] [%noun [%timer /tile '/~timer/js/tile.js']]]~ :- lismov ?~ old this @@ -71,7 +71,6 @@ ++ poke-json |= jon=json ^- (quip move _this) - ~& jon ?. ?=(%s -.jon) [~ this] =/ str/@t +.jon @@ -100,13 +99,12 @@ '' i.back-path :: - ~& site.request-line ?+ site.request-line [[ost.bol %http-response not-found:app]~ this] :: :: tile :: - [%'~timer' %tile ~] + [%'~timer' %js %tile ~] [[ost.bol %http-response (js-response:app tile-js)]~ this] :: :: images diff --git a/apps/weather/urbit/app/weather.hoon b/apps/weather/urbit/app/weather.hoon index a587a4f3d7..0a6072de87 100644 --- a/apps/weather/urbit/app/weather.hoon +++ b/apps/weather/urbit/app/weather.hoon @@ -26,7 +26,7 @@ [%wait wire @da] == +$ poke - $% [%noun [@tas path]] + $% [%noun [@tas path @t]] == +$ state $% [%0 data=json time=@da location=@t timer=(unit @da)] @@ -45,10 +45,11 @@ ++ prep |= old=(unit state) ^- (quip move _this) - =/ lismov/(list move) %+ weld - `(list move)`[ost.bol %connect / [~ /'~weather'] %weather]~ - `(list move)`[ost.bol %poke /weather [our.bol %launch] [%noun [%weather /weathertile]]]~ - :- lismov + :- + :~ + [ost.bol %connect / [~ /'~weather'] %weather] + [ost.bol %poke /weather [our.bol %launch] [%noun [%weather /weathertile '/~weather/js/tile.js']]] + == ?~ old this %= this