Skip to content

Commit

Permalink
project reorg
Browse files Browse the repository at this point in the history
  • Loading branch information
martypdx committed Feb 25, 2024
1 parent 3d12bed commit f487fcf
Show file tree
Hide file tree
Showing 38 changed files with 1,112 additions and 182 deletions.
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"inlines",
"jsonic",
"martypdx",
"maya",
"nsbsp",
"onattribute",
"onclosetag",
Expand Down
2 changes: 1 addition & 1 deletion core/compiler/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Parser } from 'acorn';
import acornJsx from 'acorn-jsx';
import { generate as astring } from 'astring';
import { TemplateGenerator } from './TemplateGenerator.js';
import { TemplateGenerator } from './transform/TemplateGenerator.js';
import { SourceMapGenerator } from 'source-map';

// compile = parse + generate
Expand Down
8 changes: 4 additions & 4 deletions core/compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
"repository": {
"type": "git",
"url": "git+https://github.com/azoth-web/azoth.git",
"directory": "aetheria-core/thoth-compiler"
"directory": "core/compiler"
},
"type": "module",
"main": "./src/index.js",
"main": "./index.js",
"files": [
"src/!(*test*).js"
"!(*test*).js"
],
"exports": {
".": {
"import": {
"default": "./src/index.js"
"default": "./index.js"
}
}
},
Expand Down
96 changes: 54 additions & 42 deletions core/compiler/source-maps.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,107 +3,119 @@ import { compile as _compile } from './index.js';
import { test } from 'vitest';

const compile = input => {
return _compile(input, {
generate: { indent: ' ' }
});
return _compile(input);
};


test('static one line', ({ expect }) => {
const input = `const t = <div>Hello World</div>`;
const { map, code } = compile(input);
const { code, _sourceMap } = compile(input);
expect(code).toMatchInlineSnapshot(`
"const t = tbc5b60ab9f()[0];
"
`);

expect(map).toMatchInlineSnapshot(`
{
"file": "module.jsx",
"mappings": "MAAMA,IAAI,aAAA",
"names": [
"t",
],
"sources": [
"module.jsx",
],
"version": 3,
}
expect(_sourceMap._mappings._array).toMatchInlineSnapshot(`
[
{
"generatedColumn": 6,
"generatedLine": 1,
"name": "t",
"originalColumn": 6,
"originalLine": 1,
"source": "module.jsx",
},
{
"generatedColumn": 10,
"generatedLine": 1,
"name": undefined,
"originalColumn": 10,
"originalLine": 1,
"source": "module.jsx",
},
{
"generatedColumn": 23,
"generatedLine": 1,
"name": undefined,
"originalColumn": 10,
"originalLine": 1,
"source": "module.jsx",
},
]
`);
});

test.skip('{...} one line', ({ expect }) => {
test('{...} one line', ({ expect }) => {
const input = `<div>Hello {place}</div>`;
const { _sourceMap, code } = compile(input);
expect(code).toMatchInlineSnapshot(`
"(() => {
const __root = ta94b210052()[0];
const __child0 = __root.childNodes[1];
__compose(__child0, place);
return __root;
const __root = ta94b210052()[0];
const __child0 = __root.childNodes[1];
__compose(__child0, place);
return __root;
})();
"
`);
expect(_sourceMap._mappings._array).toMatchInlineSnapshot(`
[
{
"generatedColumn": 19,
"generatedColumn": 17,
"generatedLine": 2,
"name": undefined,
"originalColumn": 0,
"originalLine": 1,
"source": "module.jsx",
},
{
"generatedColumn": 32,
"generatedColumn": 30,
"generatedLine": 2,
"name": undefined,
"originalColumn": 0,
"originalLine": 1,
"source": "module.jsx",
},
{
"generatedColumn": 21,
"generatedColumn": 19,
"generatedLine": 3,
"name": "div",
"originalColumn": 1,
"originalLine": 1,
"source": "module.jsx",
},
{
"generatedColumn": 38,
"generatedColumn": 36,
"generatedLine": 3,
"name": undefined,
"originalColumn": 11,
"originalLine": 1,
"source": "module.jsx",
},
{
"generatedColumn": 4,
"generatedColumn": 2,
"generatedLine": 4,
"name": undefined,
"originalColumn": 11,
"originalLine": 1,
"source": "module.jsx",
},
{
"generatedColumn": 14,
"generatedColumn": 12,
"generatedLine": 4,
"name": undefined,
"originalColumn": 11,
"originalLine": 1,
"source": "module.jsx",
},
{
"generatedColumn": 24,
"generatedColumn": 22,
"generatedLine": 4,
"name": "place",
"originalColumn": 12,
"originalLine": 1,
"source": "module.jsx",
},
{
"generatedColumn": 11,
"generatedColumn": 9,
"generatedLine": 5,
"name": undefined,
"originalColumn": 0,
Expand Down Expand Up @@ -160,10 +172,10 @@ test('{...} three line', ({ expect }) => {
const { _sourceMap, code } = compile(input);
expect(code).toMatchInlineSnapshot(`
"const t = (() => {
const __root = tf2d718c3f5()[0];
const __child0 = __root.childNodes[1];
__compose(__child0, place);
return __root;
const __root = tf2d718c3f5()[0];
const __child0 = __root.childNodes[1];
__compose(__child0, place);
return __root;
})();
"
`);
Expand All @@ -178,63 +190,63 @@ test('{...} three line', ({ expect }) => {
"source": "module.jsx",
},
{
"generatedColumn": 19,
"generatedColumn": 17,
"generatedLine": 2,
"name": undefined,
"originalColumn": 10,
"originalLine": 1,
"source": "module.jsx",
},
{
"generatedColumn": 32,
"generatedColumn": 30,
"generatedLine": 2,
"name": undefined,
"originalColumn": 10,
"originalLine": 1,
"source": "module.jsx",
},
{
"generatedColumn": 21,
"generatedColumn": 19,
"generatedLine": 3,
"name": "div",
"originalColumn": 11,
"originalLine": 1,
"source": "module.jsx",
},
{
"generatedColumn": 38,
"generatedColumn": 36,
"generatedLine": 3,
"name": undefined,
"originalColumn": 14,
"originalLine": 2,
"source": "module.jsx",
},
{
"generatedColumn": 4,
"generatedColumn": 2,
"generatedLine": 4,
"name": undefined,
"originalColumn": 14,
"originalLine": 2,
"source": "module.jsx",
},
{
"generatedColumn": 14,
"generatedColumn": 12,
"generatedLine": 4,
"name": undefined,
"originalColumn": 14,
"originalLine": 2,
"source": "module.jsx",
},
{
"generatedColumn": 24,
"generatedColumn": 22,
"generatedLine": 4,
"name": "place",
"originalColumn": 15,
"originalLine": 2,
"source": "module.jsx",
},
{
"generatedColumn": 11,
"generatedColumn": 9,
"generatedLine": 5,
"name": undefined,
"originalColumn": 10,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { GENERATOR } from 'astring';

// enable extending as es6 class
export function Generator() {

}
export function Generator() { }
Generator.prototype = GENERATOR;

export function writeNextLine(state) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions core/runtime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@

**Azoth Runtime**

The ancient Egyptian goddess Maat is the counterpart
to Thoth. She is the force which maintains the universe as the unification of matter and spirit.

The azoth runtime orchestrates the actualization of the compiled creations of thoth. Invisible and unseen, maya performs the rendering magic in the browser
2 changes: 1 addition & 1 deletion core/runtime/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ export {
export {
makeRenderer as __makeRenderer,
rendererById as __rendererById,
} from './dom/index.js';
} from './renderer/index.js';
4 changes: 2 additions & 2 deletions core/runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"repository": {
"type": "git",
"url": "git+https://github.com/azoth-web/azoth.git",
"directory": "aetheria-core/maya-runtime"
"directory": "core/runtime"
},
"type": "module",
"main": "./src/index.js",
Expand All @@ -38,7 +38,7 @@
"@testing-library/dom": "^9.3.4",
"@vitest/browser": "^1.3.1",
"@vitest/ui": "^1.3.1",
"happy-dom": "^13.5.3",
"happy-dom": "^13.6.0",
"jsdom": "^24.0.0",
"test-utils": "workspace:^",
"vitest": "^1.3.1"
Expand Down
18 changes: 9 additions & 9 deletions core/runtime/pnpm-lock.yaml

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

File renamed without changes.
File renamed without changes.
Loading

0 comments on commit f487fcf

Please sign in to comment.