[REF] reorganize file structure

in order to separate compiler/ and runtime/ code
This commit is contained in:
Géry Debongnie
2022-05-26 23:45:40 +02:00
committed by Sam Degueldre
parent e4b810c027
commit 22a79cdedd
68 changed files with 100 additions and 91 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ switch (process.argv[4]) {
]
break;
case "runtime":
input = "src/index.runtime.ts";
input = "src/runtime/index.ts";
output = [
getConfigForFormat('esm', addSuffix(pkg.module, 'runtime'), outro),
getConfigForFormat('cjs', addSuffix(pkg.main, 'runtime'), outro),
+2 -2
View File
@@ -1,5 +1,5 @@
import type { TemplateSet } from "../app/template_set";
import type { BDom } from "../blockdom";
import type { TemplateSet } from "../runtime/template_set";
import type { BDom } from "../runtime/blockdom";
import { CodeGenerator, Config } from "./code_generator";
import { parse } from "./parser";
+2 -2
View File
@@ -1,7 +1,7 @@
import { TemplateSet } from "./app/template_set";
import { TemplateSet } from "./runtime/template_set";
import { compile } from "./compiler";
export * from "./index.runtime";
export * from "./runtime";
TemplateSet.prototype._compileTemplate = function _compileTemplate(
name: string,
+6 -6
View File
@@ -1,10 +1,10 @@
import { Component, ComponentConstructor } from "../component/component";
import { ComponentNode } from "../component/component_node";
import { MountOptions } from "../component/fibers";
import { Scheduler } from "../component/scheduler";
import { Component, ComponentConstructor } from "./component";
import { ComponentNode } from "./component_node";
import { MountOptions } from "./fibers";
import { Scheduler } from "./scheduler";
import { TemplateSet, TemplateSetConfig } from "./template_set";
import { nodeErrorHandlers } from "../component/error_handling";
import { validateTarget } from "../utils";
import { nodeErrorHandlers } from "./error_handling";
import { validateTarget } from "./utils";
import { validateProps } from "./template_helpers";
// reimplement dev mode stuff see last change in 0f7a8289a6fb8387c3c1af41c6664b2a8448758f
@@ -1,4 +1,4 @@
import { Schema } from "../validation";
import { Schema } from "./validation";
import type { ComponentNode } from "./component_node";
// -----------------------------------------------------------------------------
@@ -1,5 +1,5 @@
import type { App, Env } from "../app/app";
import { BDom, VNode } from "../blockdom";
import type { App, Env } from "./app";
import { BDom, VNode } from "./blockdom";
import {
clearReactivesForCallback,
getSubscriptions,
@@ -8,8 +8,8 @@ import {
reactive,
toRaw,
TARGET,
} from "../reactivity";
import { batched, Callback } from "../utils";
} from "./reactivity";
import { batched, Callback } from "./utils";
import { Component, ComponentConstructor } from "./component";
import { fibersInError, handleError } from "./error_handling";
import { Fiber, makeChildFiber, makeRootFiber, MountFiber, MountOptions } from "./fibers";
@@ -1,4 +1,4 @@
import { BDom, mount } from "../blockdom";
import { BDom, mount } from "./blockdom";
import type { ComponentNode } from "./component_node";
import { fibersInError, handleError } from "./error_handling";
import { STATUS } from "./status";
@@ -1,4 +1,4 @@
import { filterOutModifiersFromData } from "../blockdom/config";
import { filterOutModifiersFromData } from "./blockdom/config";
import { STATUS } from "./status";
export const mainEventHandler = (data: any, ev: Event, currentTarget?: EventTarget | null) => {
+3 -3
View File
@@ -1,6 +1,6 @@
import type { Env } from "./app/app";
import { getCurrent } from "./component/component_node";
import { onMounted, onPatched, onWillUnmount } from "./component/lifecycle_hooks";
import type { Env } from "./app";
import { getCurrent } from "./component_node";
import { onMounted, onPatched, onWillUnmount } from "./lifecycle_hooks";
// -----------------------------------------------------------------------------
// useRef
@@ -11,7 +11,7 @@ import {
toggler,
comment,
} from "./blockdom";
import { mainEventHandler } from "./component/handler";
import { mainEventHandler } from "./handler";
export type { Reactive } from "./reactivity";
config.shouldNormalizeDom = false;
@@ -33,11 +33,11 @@ export const blockDom = {
comment,
};
export { App, mount } from "./app/app";
export { xml } from "./app/template_set";
export { Component } from "./component/component";
export { useComponent, useState } from "./component/component_node";
export { status } from "./component/status";
export { App, mount } from "./app";
export { xml } from "./template_set";
export { Component } from "./component";
export { useComponent, useState } from "./component_node";
export { status } from "./status";
export { reactive, markRaw, toRaw } from "./reactivity";
export { useEffect, useEnv, useExternalListener, useRef, useChildSubEnv, useSubEnv } from "./hooks";
export { EventBus, whenReady, loadFile, markup } from "./utils";
@@ -52,7 +52,7 @@ export {
onRendered,
onWillDestroy,
onError,
} from "./component/lifecycle_hooks";
} from "./lifecycle_hooks";
export { validate } from "./validation";
export const __info__ = {};
+2 -2
View File
@@ -1,6 +1,6 @@
import { onWillUnmount } from "./component/lifecycle_hooks";
import { onWillUnmount } from "./lifecycle_hooks";
import { BDom, text, VNode } from "./blockdom";
import { Component } from "./component/component";
import { Component } from "./component";
const VText: any = text("").constructor;
@@ -1,9 +1,9 @@
import { BDom, multi, text, toggler, createCatcher } from "../blockdom";
import { Markup } from "../utils";
import { html } from "../blockdom/index";
import { isOptional, validateSchema } from "../validation";
import type { ComponentConstructor } from "../component/component";
import { markRaw } from "../reactivity";
import { BDom, multi, text, toggler, createCatcher } from "./blockdom";
import { Markup } from "./utils";
import { html } from "./blockdom/index";
import { isOptional, validateSchema } from "./validation";
import type { ComponentConstructor } from "./component";
import { markRaw } from "./reactivity";
/**
* This file contains utility functions that will be injected in each template,
@@ -1,7 +1,7 @@
import { createBlock, html, list, multi, text, toggler, comment } from "../blockdom";
import { createBlock, html, list, multi, text, toggler, comment } from "./blockdom";
import { compile, Template, TemplateFunction } from "../compiler";
import { Portal, portalTemplate } from "../portal";
import { component, getCurrent } from "../component/component_node";
import { Portal, portalTemplate } from "./portal";
import { component, getCurrent } from "./component_node";
import { helpers } from "./template_helpers";
const bdom = { text, createBlock, list, multi, html, toggler, component, comment };
+1 -1
View File
@@ -1,5 +1,5 @@
import { App, Component, mount, xml } from "../../src";
import { status } from "../../src/component/status";
import { status } from "../../src/runtime/status";
import { makeTestFixture, snapshotEverything, nextTick, elem } from "../helpers";
let fixture: HTMLElement;
+1 -1
View File
@@ -1,4 +1,4 @@
import { createBlock, mount, patch, remove, text } from "../../src/blockdom";
import { createBlock, mount, patch, remove, text } from "../../src/runtime/blockdom";
import { makeTestFixture } from "./helpers";
//------------------------------------------------------------------------------
+1 -1
View File
@@ -1,4 +1,4 @@
import { mount, patch, createBlock } from "../../src/blockdom";
import { mount, patch, createBlock } from "../../src/runtime/blockdom";
import { makeTestFixture } from "./helpers";
//------------------------------------------------------------------------------
+1 -1
View File
@@ -1,4 +1,4 @@
import { mount, createBlock, multi, config, patch } from "../../src/blockdom";
import { mount, createBlock, multi, config, patch } from "../../src/runtime/blockdom";
// import { defaultHandler, setupMainHandler } from "../../src/bdom/block";
import { makeTestFixture } from "./helpers";
+1 -1
View File
@@ -1,4 +1,4 @@
import { createBlock, mount, patch, remove } from "../../src/blockdom";
import { createBlock, mount, patch, remove } from "../../src/runtime/blockdom";
import { logStep } from "../helpers";
import { makeTestFixture } from "./helpers";
+1 -1
View File
@@ -1,4 +1,4 @@
import { comment, mount } from "../../src/blockdom";
import { comment, mount } from "../../src/runtime/blockdom";
import { makeTestFixture } from "./helpers";
//------------------------------------------------------------------------------
+2 -2
View File
@@ -1,6 +1,6 @@
import { config, createBlock, createCatcher, mount } from "../../src/blockdom";
import { config, createBlock, createCatcher, mount } from "../../src/runtime/blockdom";
import { makeTestFixture } from "./helpers";
import { mainEventHandler } from "../../src/component/handler";
import { mainEventHandler } from "../../src/runtime/handler";
//------------------------------------------------------------------------------
// Setup and helpers
+1 -1
View File
@@ -1,4 +1,4 @@
import { html, mount, patch, text } from "../../src/blockdom";
import { html, mount, patch, text } from "../../src/runtime/blockdom";
import { makeTestFixture } from "./helpers";
//------------------------------------------------------------------------------
+10 -1
View File
@@ -1,4 +1,13 @@
import { list, mount, multi, patch, text, createBlock, VNode, withKey } from "../../src/blockdom";
import {
list,
mount,
multi,
patch,
text,
createBlock,
VNode,
withKey,
} from "../../src/runtime/blockdom";
import { makeTestFixture } from "./helpers";
//------------------------------------------------------------------------------
+1 -1
View File
@@ -1,4 +1,4 @@
import { mount, multi, patch, text, createBlock } from "../../src/blockdom";
import { mount, multi, patch, text, createBlock } from "../../src/runtime/blockdom";
import { makeTestFixture } from "./helpers";
//------------------------------------------------------------------------------
+1 -1
View File
@@ -1,4 +1,4 @@
import { createBlock, mount } from "../../src/blockdom";
import { createBlock, mount } from "../../src/runtime/blockdom";
import { makeTestFixture } from "./helpers";
//------------------------------------------------------------------------------
+1 -1
View File
@@ -1,4 +1,4 @@
import { createBlock, mount, multi, patch } from "../../src/blockdom";
import { createBlock, mount, multi, patch } from "../../src/runtime/blockdom";
import { makeTestFixture } from "./helpers";
//------------------------------------------------------------------------------
+1 -1
View File
@@ -1,4 +1,4 @@
import { mount, patch, remove, text } from "../../src/blockdom";
import { mount, patch, remove, text } from "../../src/runtime/blockdom";
import { makeTestFixture } from "./helpers";
//------------------------------------------------------------------------------
+1 -1
View File
@@ -1,4 +1,4 @@
import { createBlock, mount, patch, text, toggler } from "../../src/blockdom";
import { createBlock, mount, patch, text, toggler } from "../../src/runtime/blockdom";
import { makeTestFixture } from "./helpers";
//------------------------------------------------------------------------------
+1 -1
View File
@@ -1,4 +1,4 @@
import { mount, patch } from "../../src/blockdom";
import { mount, patch } from "../../src/runtime/blockdom";
import { makeTestFixture, renderToBdom, renderToString, snapshotEverything } from "../helpers";
snapshotEverything();
+4 -4
View File
@@ -1,8 +1,8 @@
import { TemplateSet } from "../../src/app/template_set";
import { mount } from "../../src/blockdom";
import { TemplateSet } from "../../src/runtime/template_set";
import { mount } from "../../src/runtime/blockdom";
import { makeTestFixture, renderToBdom, renderToString, snapshotEverything } from "../helpers";
import { markup } from "../../src/utils";
import { STATUS } from "../../src/component/status";
import { markup } from "../../src/runtime/utils";
import { STATUS } from "../../src/runtime/status";
snapshotEverything();
// -----------------------------------------------------------------------------
+1 -1
View File
@@ -1,5 +1,5 @@
import { renderToString, renderToBdom, snapshotEverything, makeTestFixture } from "../helpers";
import { mount } from "../../src/blockdom";
import { mount } from "../../src/runtime/blockdom";
import { mount as mountComponent, Component, xml } from "../../src/index";
// NB: check the snapshots to see where the SVG namespaces are added
+1 -1
View File
@@ -1,4 +1,4 @@
import { mount } from "../../src/blockdom";
import { mount } from "../../src/runtime/blockdom";
import {
makeTestFixture,
renderToBdom,
+1 -1
View File
@@ -5,7 +5,7 @@ import {
TestContext,
makeTestFixture,
} from "../helpers";
import { mount, patch } from "../../src/blockdom";
import { mount, patch } from "../../src/runtime/blockdom";
snapshotEverything();
+1 -1
View File
@@ -1,5 +1,5 @@
// import { mountBlock } from "../../src/blockdom/block";
import { mount } from "../../src/blockdom";
import { mount } from "../../src/runtime/blockdom";
import { makeTestFixture, renderToBdom, renderToString, snapshotEverything } from "../helpers";
snapshotEverything();
+1 -1
View File
@@ -1,5 +1,5 @@
import { renderToString, renderToBdom, snapshotEverything, makeTestFixture } from "../helpers";
import { mount, patch } from "../../src/blockdom/index";
import { mount, patch } from "../../src/runtime/blockdom/index";
snapshotEverything();
+3 -3
View File
@@ -5,9 +5,9 @@ import {
TestContext,
makeTestFixture,
} from "../helpers";
import { mount, patch } from "../../src/blockdom";
import { createBlock } from "../../src/blockdom/index";
import { markup } from "../../src/utils";
import { mount, patch } from "../../src/runtime/blockdom";
import { createBlock } from "../../src/runtime/blockdom/index";
import { markup } from "../../src/runtime/utils";
snapshotEverything();
+2 -2
View File
@@ -1,5 +1,5 @@
import { TemplateSet } from "../../src/app/template_set";
import { mount } from "../../src/blockdom";
import { TemplateSet } from "../../src/runtime/template_set";
import { mount } from "../../src/runtime/blockdom";
import { renderToBdom, snapshotEverything } from "../helpers";
snapshotEverything();
+1 -1
View File
@@ -1,4 +1,4 @@
import { mount, patch } from "../../src/blockdom";
import { mount, patch } from "../../src/runtime/blockdom";
import { makeTestFixture, renderToBdom, renderToString, snapshotEverything } from "../helpers";
snapshotEverything();
+1 -1
View File
@@ -1,4 +1,4 @@
import { TemplateSet } from "../../src/app/template_set";
import { TemplateSet } from "../../src/runtime/template_set";
import { renderToString, snapshotTemplate, TestContext } from "../helpers";
// -----------------------------------------------------------------------------
+1 -1
View File
@@ -1,6 +1,6 @@
import { App, Component, mount, status, toRaw, useState, xml } from "../../src";
import { elem, makeTestFixture, nextTick, snapshotEverything, useLogLifecycle } from "../helpers";
import { markup } from "../../src/utils";
import { markup } from "../../src/runtime/utils";
let fixture: HTMLElement;
+3 -3
View File
@@ -11,9 +11,9 @@ import {
useState,
xml,
} from "../../src";
import { Fiber } from "../../src/component/fibers";
import { Scheduler } from "../../src/component/scheduler";
import { status } from "../../src/component/status";
import { Fiber } from "../../src/runtime/fibers";
import { Scheduler } from "../../src/runtime/scheduler";
import { status } from "../../src/runtime/status";
import {
makeDeferred,
makeTestFixture,
+2 -2
View File
@@ -7,8 +7,8 @@ import {
onWillRender,
onWillDestroy,
onRendered,
} from "../../src/component/lifecycle_hooks";
import { status } from "../../src/component/status";
} from "../../src/runtime/lifecycle_hooks";
import { status } from "../../src/runtime/status";
import {
elem,
logStep,
+3 -3
View File
@@ -1,8 +1,8 @@
import { makeTestFixture, nextTick, snapshotEverything } from "../helpers";
import { Component, onError, xml, mount } from "../../src";
import { DEV_MSG } from "../../src/app/app";
import { validateProps } from "../../src/app/template_helpers";
import { Schema } from "../../src/validation";
import { DEV_MSG } from "../../src/runtime/app";
import { validateProps } from "../../src/runtime/template_helpers";
import { Schema } from "../../src/runtime/validation";
let fixture: HTMLElement;
+1 -1
View File
@@ -1,4 +1,4 @@
import { text } from "../../src/blockdom";
import { text } from "../../src/runtime/blockdom";
import { Component, mount, xml } from "../../src/index";
import { makeTestFixture, snapshotEverything } from "../helpers";
+1 -1
View File
@@ -1,4 +1,4 @@
import { Component } from "../../src/component/component";
import { Component } from "../../src/runtime/component";
import { mount, useState, xml } from "../../src/index";
import { editInput, makeTestFixture, nextTick, snapshotEverything } from "../helpers";
+1 -1
View File
@@ -1,6 +1,6 @@
import { Component, mount, onMounted, useState, xml } from "../../src/index";
import { elem, makeTestFixture, nextTick, snapshotEverything } from "../helpers";
import { status } from "../../src/component/status";
import { status } from "../../src/runtime/status";
snapshotEverything();
+3 -3
View File
@@ -15,9 +15,9 @@ import {
useComponent,
xml,
} from "../src";
import { helpers } from "../src/app/template_helpers";
import { TemplateSet, globalTemplates } from "../src/app/template_set";
import { BDom } from "../src/blockdom";
import { helpers } from "../src/runtime/template_helpers";
import { TemplateSet, globalTemplates } from "../src/runtime/template_set";
import { BDom } from "../src/runtime/blockdom";
import { compile } from "../src/compiler";
const mount = blockDom.mount;
+1 -1
View File
@@ -10,7 +10,7 @@ import {
useState,
} from "../../src";
import { xml } from "../../src/";
import { DEV_MSG } from "../../src/app/app";
import { DEV_MSG } from "../../src/runtime/app";
import { elem, makeTestFixture, nextTick, snapshotEverything } from "../helpers";
let fixture: HTMLElement;
+2 -2
View File
@@ -9,8 +9,8 @@ import {
markRaw,
toRaw,
} from "../src";
import { reactive, Reactive } from "../src/reactivity";
import { batched } from "../src/utils";
import { reactive, Reactive } from "../src/runtime/reactivity";
import { batched } from "../src/runtime/utils";
import {
makeDeferred,
makeTestFixture,
+1 -1
View File
@@ -1,4 +1,4 @@
import { batched, EventBus } from "../src/utils";
import { batched, EventBus } from "../src/runtime/utils";
import { nextMicroTick } from "./helpers";
describe("event bus behaviour", () => {
+1 -1
View File
@@ -1,4 +1,4 @@
import { Schema, validateSchema } from "../src/validation";
import { Schema, validateSchema } from "../src/runtime/validation";
describe("validateSchema", () => {
test("simple use", () => {