Skip to content

Commit

Permalink
Moves scope functions to scope/
Browse files Browse the repository at this point in the history
  • Loading branch information
stephband committed Jul 27, 2024
1 parent aab80e9 commit 4a21095
Show file tree
Hide file tree
Showing 31 changed files with 55 additions and 55 deletions.
4 changes: 2 additions & 2 deletions deno/scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import parseMarkdown from './parse-markdown.js';

import { red, yellow } from './log.js';

export * from '../modules/scope/scope-fns.js';
export * from '../modules/scope/scope-fns-ext.js';
export * from '../scope/scope-fns.js';
export * from '../scope/scope-fns-ext.js';
export { px, em, rem } from './parse-length.js';
export const vw = () => { throw new Error('Literal scope function vw() not available in Deno') }
export const vh = () => { throw new Error('Literal scope function vh() not available in Deno') }
Expand Down
2 changes: 1 addition & 1 deletion literal-html/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import element, { getInternals as Internals } from '../../dom/modules/element.js
import assignDataset from '../modules/dom/assign-dataset.js';
import requestData from '../modules/request-data.js';
import DOMRenderer from '../modules/template.js';
import { printError } from '../modules/scope/print.js';
import { printError } from '../modules/print.js';

const assign = Object.assign;
const rpath = /^(\.+|https?:\/)?\//;
Expand Down
2 changes: 1 addition & 1 deletion module.css
Original file line number Diff line number Diff line change
@@ -1 +1 @@
@import './modules/scope/print.css';
@import './modules/print.css';
2 changes: 1 addition & 1 deletion modules/compile/compile-attribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import R from '../renderer/renderer.js';
import isLiteralString from './is-literal-string.js';
import truncate from './truncate.js';
import compile from './compile.js';
import { printError } from '../scope/print.js';
import { printError } from '../print.js';


const assign = Object.assign;
Expand Down
2 changes: 1 addition & 1 deletion modules/compile/compile-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import toType from '../../../dom/modules/to-type.js';
import decode from '../../../dom/modules/decode.js';
import indexOf from '../dom/index-of.js';
import TextRenderer from '../renderer/renderer-text.js';
import { printError } from '../scope/print.js';
import { printError } from '../print.js';
import scope from '../scope.js';
import compile from './compile.js';
import { pathSeparator } from './constants.js';
Expand Down
10 changes: 5 additions & 5 deletions modules/scope/include.js → modules/include.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ ${ data.array.map(include('#list-item')) }
```
**/

import Data from '../../../fn/modules/data.js';
import getById from '../dom/get-by-id.js';
import Literal from '../template.js';
import requestTemplate from '../request-template.js';
import requestData from '../request-data.js';
import Data from '../../fn/modules/data.js';
import getById from './dom/get-by-id.js';
import Literal from './template.js';
import requestTemplate from './request-template.js';
import requestData from './request-data.js';

function pipe(template, data, element, consts) {
const renderer = Literal.fromTemplate(template, element, consts, data);
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions modules/scope/print.js → modules/print.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ Renders as:
Messages should be styled with the print stylesheet:
```css
@import "http://stephen.band/literal/modules/scope/print.css";
@import "http://stephen.band/literal/modules/print.css";
```-->
**/

import noop from '../../../fn/modules/noop.js';
import Data from '../../../fn/modules/data.js';
import create from '../../../dom/modules/create.js';
import { log } from '../log.js';
import noop from '../../fn/modules/noop.js';
import Data from '../../fn/modules/data.js';
import create from '../../dom/modules/create.js';
import { log } from './log.js';

const linkHTML = '<a class="literal-link" href="https://stephen.band/literal/literal-html/">literal</literal>';

Expand Down
2 changes: 1 addition & 1 deletion modules/renderer/renderer-attribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import Signal from '../../../fn/modules/signal.js';
import names from './property-names.js';
import Renderer, { stats } from './renderer.js';
import { printError } from '../scope/print.js';
import { printError } from '../print.js';
import toText from './to-text.js';


Expand Down
2 changes: 1 addition & 1 deletion modules/renderer/renderer-checked.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import isDefined from '../../../fn/modules/is-defined.js';
import Signal from '../../../fn/modules/signal.js';
import trigger from '../../../dom/modules/trigger.js';
import config from '../config.js';
import bindChecked from '../scope/bind-checked.js';
import bindChecked from '../../scope/bind-checked.js';
import AttributeRenderer from './renderer-attribute.js';
import { toAttributeBoolean } from './renderer-boolean.js';
import { getValue } from './renderer-value.js';
Expand Down
10 changes: 5 additions & 5 deletions modules/renderer/renderer-text.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ that DOM after the text node.
import Signal from '../../../fn/modules/signal.js';
import Data from '../../../fn/modules/data.js';
import { isCommentNode, isElementNode, isFragmentNode, isTextNode } from '../../../dom/modules/node.js';
import include from '../scope/include.js';
import include from '../include.js';
import deleteRange from '../dom/delete-range.js';
import DOMRenderer from '../template.js';
import print, { printError } from '../scope/print.js';
import Literal from '../template.js';
import print, { printError } from '../print.js';
import toText from './to-text.js';
import Renderer, { stats } from './renderer.js';

Expand Down Expand Up @@ -55,7 +55,7 @@ function objectToContents(state, object, i) {

// If object is not a node or renderer, append to string. Array.isArray()
// does return true for a proxy of an array.
if (!(object instanceof DOMRenderer) && !(object instanceof Node) && !Array.isArray(object)) {
if (!(object instanceof Literal) && !(object instanceof Node) && !Array.isArray(object)) {
state.string += toText(object);
return i;
}
Expand Down Expand Up @@ -92,7 +92,7 @@ function objectToContents(state, object, i) {
}

// Object is a freshly rendered Literal Template
if (object instanceof DOMRenderer) {
if (object instanceof Literal) {
contents[++i].before(toContent(object));
if (window.DEBUG) ++stats.add;
contents.splice(i, 0, object);
Expand Down
2 changes: 1 addition & 1 deletion modules/renderer/renderer-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import overload from '../../../fn/modules/overload.js';
import Signal from '../../../fn/modules/signal.js';
import trigger from '../../../dom/modules/trigger.js';
import config from '../config.js';
import bindValue from '../scope/bind-value.js';
import bindValue from '../../scope/bind-value.js';
import AttributeRenderer, { toAttributeString } from './renderer-attribute.js';
import { stats } from './renderer.js';
import toText from './to-text.js';
Expand Down
4 changes: 2 additions & 2 deletions modules/scope.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

// Import base set of scope functions

import * as scope1 from './scope/scope-fns.js';
import * as scope2 from './scope/scope-dom.js';
import * as scope1 from '../scope/scope-fns.js';
import * as scope2 from '../scope/scope-dom.js';

export default Object.assign({}, scope1, scope2);
10 changes: 5 additions & 5 deletions modules/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function removeRange(first, last, fragment) {
fragment.appendChild(dom);
}

export default class LiteralDOM {
export default class Literal {
static compile(fragment, options, src) {
if (window.DEBUG) {
groupCollapsed('compile', src, 'yellow');
Expand All @@ -105,11 +105,11 @@ export default class LiteralDOM {

static fromFragment(fragment, identifier, element, consts = {}, data, options) {
const compiled = cache[identifier] || (
cache[identifier] = LiteralDOM.compile(fragment, options, identifier)
cache[identifier] = Literal.compile(fragment, options, identifier)
);

// fragment, targets, element, consts, data, options
return new LiteralDOM(fragment.cloneNode(true), compiled, element, consts, data, options);
return new Literal(fragment.cloneNode(true), compiled, element, consts, data, options);
}

static fromTemplate(template, element, consts = {}, data) {
Expand All @@ -120,7 +120,7 @@ export default class LiteralDOM {
nostrict: template.hasAttribute && template.hasAttribute('nostrict')
};

return LiteralDOM.fromFragment(fragment, '#' + id, element, consts, data, options);
return Literal.fromFragment(fragment, '#' + id, element, consts, data, options);
}

#first;
Expand Down Expand Up @@ -279,7 +279,7 @@ export default class LiteralDOM {
}
}

assign(LiteralDOM.prototype, {
assign(Literal.prototype, {
/**
.stop()
Stops renderer.
Expand Down
4 changes: 2 additions & 2 deletions scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Extend scope with library of pure and DOM functions

import Literal from './module.js';
import * as scopeFn from './modules/scope/scope-fns-ext.js';
import * as scopeDom from './modules/scope/scope-dom-ext.js';
import * as scopeFn from './scope/scope-fns-ext.js';
import * as scopeDom from './scope/scope-dom-ext.js';

Object.assign(Literal.scope, scopeFn, scopeDom);
File renamed without changes.
6 changes: 3 additions & 3 deletions modules/scope/bind-checked.js → scope/bind-checked.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import id from '../../../fn/modules/id.js';
import isDefined from '../../../fn/modules/is-defined.js';
import set from '../../../fn/modules/set.js';
import id from '../../fn/modules/id.js';
import isDefined from '../../fn/modules/is-defined.js';
import set from '../../fn/modules/set.js';
//import events from '../../../dom/modules/events.js';
//import { observe } from '../data.js';

Expand Down
6 changes: 3 additions & 3 deletions modules/scope/bind-value.js → scope/bind-value.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

import id from '../../../fn/modules/id.js';
import set from '../../../fn/modules/set-path.js';
import id from '../../fn/modules/id.js';
import set from '../../fn/modules/set-path.js';
//import events from '../../../dom/modules/events.js';
import { getValue, setValue } from '../renderer/renderer-value.js';
import { getValue, setValue } from '../modules/renderer/renderer-value.js';
//import { observe } from '../data.js';

let warned;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
26 changes: 13 additions & 13 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ <h1 class="text-01">Literal <span class="text-06">0.8.3</span></h1>
</header>

<section class="x1 4x @2-x2 x-stretch" id="template-scope">


<h2 class="text-02" id="template-scope">Template scope</h2>
<p>Literal templates are compiled in a <strong>scope</strong> that contains a number of
Expand Down Expand Up @@ -83,7 +83,7 @@ <h2 class="text-02" id="template-scope">Template scope</h2>
<div class="x1 4x @1-3x @1-y3 @2-x2 x-stretch y-start">
<h3>Objects</h3>



<details-toggle class="selector-details-toggle" id="selector-data">
<h4 class="selector-text text-05" slot="summary">
Expand Down Expand Up @@ -172,7 +172,7 @@ <h4 class="selector-text text-05" slot="summary">

<h3>Streams</h3>



<details-toggle class="function-details-toggle" id="function-clock-1">
<h4 class="function-text text-05" slot="summary">
Expand Down Expand Up @@ -362,7 +362,7 @@ <h4 class="constructor-text text-05" slot="summary">

<h3>Functions</h3>



<details-toggle class="function-details-toggle" id="function-assign-2">
<h4 class="function-text text-05" slot="summary">
Expand Down Expand Up @@ -450,7 +450,7 @@ <h4 class="function-text text-05" slot="summary">
<code class=" language-js">denormalise(<span class="param">min</span>, <span class="param">max</span>, <span class="param">value</span>)</code>
</h4>


</details-toggle>


Expand Down Expand Up @@ -639,7 +639,7 @@ <h4 class="function-text text-05" slot="summary">
<code class=" language-js">normalise(<span class="param">min</span>, <span class="param">max</span>, <span class="param">value</span>)</code>
</h4>


</details-toggle>


Expand Down Expand Up @@ -698,7 +698,7 @@ <h4 class="function-text text-05" slot="summary">
Messages should be styled with the print stylesheet:
```css
@import "http://stephen.band/literal/modules/scope/print.css";
@import "http://stephen.band/literal/modules/print.css";
```-->


Expand Down Expand Up @@ -838,7 +838,7 @@ <h4 class="function-text text-05" slot="summary">





<details-toggle class="function-details-toggle" id="function-px">
<h4 class="function-text text-05" slot="summary">
Expand Down Expand Up @@ -925,7 +925,7 @@ <h3 id="extending-the-template-scope">Extending the template scope</h3>
</section>

<section class="x1 4x @2-x2 x-stretch" id="template-expressions">


<h2 class="text-02" id="template-expressions">Template expressions</h2>
<p>Expressions may evaluate to a <strong>string</strong> or other <strong>primitive</strong>, a <strong>DOM node</strong>
Expand Down Expand Up @@ -1066,7 +1066,7 @@ <h2 class="text-02" id="template-expressions">Template expressions</h2>

</section>


<nav>
<details-toggle class="nav-details-toggle">
<button slot="summary" class="nav-thumb thumb">
Expand Down Expand Up @@ -1237,7 +1237,7 @@ <h2 class="text-02" id="template-expressions">Template expressions</h2>
</details-toggle>
</nav>


<hr class="x1 4x @2-x2 x-stretch" style="margin-top: 4.2em;" />

<div class="x1 4x @2-x2 x-stretch y-start">
Expand All @@ -1254,7 +1254,7 @@ <h2 class="text-02" id="template-expressions">Template expressions</h2>
</p>
</div>


<footer class="x1 4x @1-6x @2-7x @3-9x 4x-grid @1-6x-grid @2-7x-grid @3-9x-grid grid grid footer">
<div class="x1 4x @1-2x @2-x2 x-stretch y-start">
<h3>Elements</h3>
Expand Down Expand Up @@ -1284,4 +1284,4 @@ <h3>Tools</h3>
import '../literal-html/module.js';
</script>
</body>
</html>
</html>
6 changes: 3 additions & 3 deletions templates/index.html.literal
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@
'../../dom/modules/trigger.js',
'../modules/scope.js',
'../modules/scope-dom.js',
'../modules/scope/include.js',
'../modules/scope/paramify.js',
'../modules/scope/print.js'
'../modules/include.js',
'../scope/paramify.js',
'../modules/print.js'
))
.filter((doc) => (doc.type === 'function' || doc.type === 'constructor'))
.filter((entry) => !['Stream.of', 'Stream.from', 'Stream.combine', 'Stream.merge', 'clock', 'events', 'observe'].includes(entry.name))
Expand Down

0 comments on commit 4a21095

Please sign in to comment.