tungsten 0.1.58 → 0.1.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AnyComponent.d.ts.map +1 -1
- package/dist/ComponentInstance.d.ts +1 -2
- package/dist/ComponentInstance.d.ts.map +1 -1
- package/dist/ComponentInstance.js +4 -1
- package/dist/ComponentRenderInfo.type.d.ts +6 -0
- package/dist/ComponentRenderInfo.type.d.ts.map +1 -0
- package/dist/ComponentRenderInfo.type.js +1 -0
- package/dist/Components.d.ts +4 -2
- package/dist/Components.d.ts.map +1 -1
- package/dist/Components.js +10 -4
- package/dist/ContentNode.d.ts +3 -1
- package/dist/ContentNode.d.ts.map +1 -1
- package/dist/ContentNode.js +1 -0
- package/dist/Framework.d.ts +1 -1
- package/dist/Framework.d.ts.map +1 -1
- package/dist/Framework.js +42 -25
- package/dist/FrameworkConfig.d.ts +20 -4
- package/dist/FrameworkConfig.d.ts.map +1 -1
- package/dist/FunctionComponent.d.ts +2 -0
- package/dist/FunctionComponent.d.ts.map +1 -1
- package/dist/FunctionComponentStandIn.d.ts +4 -4
- package/dist/FunctionComponentStandIn.d.ts.map +1 -1
- package/dist/FunctionComponentStandIn.js +4 -2
- package/dist/Instance/InstanceConfig.d.ts +2 -0
- package/dist/Instance/InstanceConfig.d.ts.map +1 -1
- package/dist/Key.d.ts.map +1 -1
- package/dist/RenderedContentNode.d.ts +1 -1
- package/dist/RenderedContentNode.d.ts.map +1 -1
- package/dist/RenderedContentNode.js +2 -2
- package/dist/RenderingNode.d.ts +23 -8
- package/dist/RenderingNode.d.ts.map +1 -1
- package/dist/RenderingNode.js +39 -8
- package/dist/Servers/DevServer.d.ts.map +1 -1
- package/dist/Servers/DevServer.js +74 -25
- package/dist/Servers/ProdServer.d.ts +5 -1
- package/dist/Servers/ProdServer.d.ts.map +1 -1
- package/dist/Servers/ProdServer.js +49 -33
- package/dist/TungstenElement.d.ts +3 -0
- package/dist/TungstenElement.d.ts.map +1 -0
- package/dist/TungstenElement.js +1 -0
- package/dist/TungstenError.d.ts +4 -0
- package/dist/TungstenError.d.ts.map +1 -1
- package/dist/TungstenError.js +6 -0
- package/dist/_client/client.d.ts +4 -1
- package/dist/_client/client.d.ts.map +1 -1
- package/dist/_client/client.js +16 -9
- package/dist/babelPlugins/BabelTransformCjsToEsm.d.ts +1 -1
- package/dist/babelPlugins/BabelTransformCjsToEsm.d.ts.map +1 -1
- package/dist/babelPlugins/BabelTransformCjsToFunction.d.ts +1 -1
- package/dist/babelPlugins/BabelTransformCjsToFunction.d.ts.map +1 -1
- package/dist/babelPlugins/BabelTransformCjsToFunction2.d.ts +1 -1
- package/dist/babelPlugins/BabelTransformCjsToFunction2.d.ts.map +1 -1
- package/dist/babelPlugins/{BabelTransformCssImport.d.ts → BabelTransformCssImports.d.ts} +3 -2
- package/dist/babelPlugins/BabelTransformCssImports.d.ts.map +1 -0
- package/dist/babelPlugins/{BabelTransformCssImport.js → BabelTransformCssImports.js} +27 -5
- package/dist/babelPlugins/BabelTransformPackageImports.d.ts.map +1 -1
- package/dist/babelPlugins/BabelTransformPackageImports.js +75 -37
- package/dist/babelPlugins/BabelTransformRemoveServerBlocks.d.ts.map +1 -1
- package/dist/babelPlugins/BabelTransformRemoveServerBlocks.js +5 -0
- package/dist/babelPlugins/BabelTransformRemoveServerCode.d.ts +2 -0
- package/dist/babelPlugins/BabelTransformRemoveServerCode.d.ts.map +1 -0
- package/dist/babelPlugins/BabelTransformRemoveServerCode.js +1 -0
- package/dist/babelPlugins/fixImportsInSassErrorMessage.d.ts.map +1 -1
- package/dist/babelPlugins/{BabelTransformDependencyImportsCjs.d.ts → transformPackageImports/BabelTransformDependencyImportsCjs.d.ts} +1 -1
- package/dist/babelPlugins/transformPackageImports/BabelTransformDependencyImportsCjs.d.ts.map +1 -0
- package/dist/babelPlugins/{BabelTransformDependencyImportsCjs.js → transformPackageImports/BabelTransformDependencyImportsCjs.js} +12 -3
- package/dist/babelPlugins/{BabelTransformDependencyImportsEsm.d.ts → transformPackageImports/BabelTransformDependencyImportsEsm.d.ts} +1 -1
- package/dist/babelPlugins/transformPackageImports/BabelTransformDependencyImportsEsm.d.ts.map +1 -0
- package/dist/babelPlugins/transformPackageImports/BabelTransformDependencyImportsEsm.js +112 -0
- package/dist/bin/commands/compileSimplePackage.d.ts +2 -0
- package/dist/bin/commands/compileSimplePackage.d.ts.map +1 -0
- package/dist/bin/commands/compileSimplePackage.js +51 -0
- package/dist/bin/commands/static.js +2 -2
- package/dist/bin/index.d.ts.map +1 -1
- package/dist/bin/index.js +5 -0
- package/dist/build/babel.user.common.config.js +9 -3
- package/dist/build/bundle.d.ts +1 -2
- package/dist/build/bundle.d.ts.map +1 -1
- package/dist/build/bundle.js +7 -4
- package/dist/build/compileJavascript.d.ts.map +1 -1
- package/dist/build/compileJavascript.js +22 -11
- package/dist/build/compilePackages.d.ts +0 -5
- package/dist/build/compilePackages.d.ts.map +1 -1
- package/dist/build/compilePackages.js +89 -82
- package/dist/build/compileUserApp.d.ts.map +1 -1
- package/dist/build/copyPackageModulesToPackagesFolder.d.ts.map +1 -1
- package/dist/build/copyPackageModulesToPackagesFolder.js +3 -1
- package/dist/build/createClientFiles.d.ts.map +1 -1
- package/dist/build/createClientFiles.js +43 -52
- package/dist/build/createInstanceConfigFile.d.ts +4 -0
- package/dist/build/createInstanceConfigFile.d.ts.map +1 -0
- package/dist/build/{createAppConfig.js → createInstanceConfigFile.js} +2 -2
- package/dist/build/makeBabelUserDevConfig.d.ts.map +1 -1
- package/dist/build/makeBabelUserDevConfig.js +3 -2
- package/dist/build/makeBabelUserProdConfig.js +3 -2
- package/dist/compat/context.d.ts +25 -0
- package/dist/compat/context.d.ts.map +1 -0
- package/dist/compat/context.js +36 -0
- package/dist/compat/types.d.ts +18 -0
- package/dist/compat/types.d.ts.map +1 -0
- package/dist/compat/types.js +1 -0
- package/dist/components/Stylesheet.d.ts +1 -0
- package/dist/components/Stylesheet.d.ts.map +1 -1
- package/dist/components/Stylesheet.js +24 -3
- package/dist/createRef.d.ts +4 -2
- package/dist/createRef.d.ts.map +1 -1
- package/dist/createRef.js +5 -2
- package/dist/defaultConfig.d.ts +1 -0
- package/dist/defaultConfig.d.ts.map +1 -1
- package/dist/defaultConfig.js +1 -0
- package/dist/findUserConfig.d.ts.map +1 -1
- package/dist/findUserConfig.js +1 -1
- package/dist/frameworkConfigSchema.d.ts +188 -0
- package/dist/frameworkConfigSchema.d.ts.map +1 -0
- package/dist/frameworkConfigSchema.js +65 -0
- package/dist/getConfig.d.ts +1 -15
- package/dist/getConfig.d.ts.map +1 -1
- package/dist/getConfig.js +12 -11
- package/dist/getRoutes.d.ts.map +1 -1
- package/dist/getRoutes.js +20 -15
- package/dist/getUserConfig.d.ts +3 -0
- package/dist/getUserConfig.d.ts.map +1 -0
- package/dist/getUserConfig.js +25 -0
- package/dist/hooks/getCurrentComponent.d.ts +4 -0
- package/dist/hooks/getCurrentComponent.d.ts.map +1 -1
- package/dist/hooks/getCurrentComponent.js +8 -2
- package/dist/hooks/globalType.d.ts +2 -0
- package/dist/hooks/globalType.d.ts.map +1 -0
- package/dist/hooks/globalType.js +1 -0
- package/dist/hooks/useRef.d.ts +3 -1
- package/dist/hooks/useRef.d.ts.map +1 -1
- package/dist/hooks/useRef.js +4 -2
- package/dist/hooks/useState.d.ts +1 -1
- package/dist/hooks/useState.d.ts.map +1 -1
- package/dist/hooks/useState.js +14 -3
- package/dist/hydrate/hydrate.d.ts +1 -10
- package/dist/hydrate/hydrate.d.ts.map +1 -1
- package/dist/hydrate/hydrate.js +192 -53
- package/dist/hydrate/hydrateGlobalData.d.ts +9 -0
- package/dist/hydrate/hydrateGlobalData.d.ts.map +1 -0
- package/dist/hydrate/hydrateGlobalData.js +2 -0
- package/dist/indexInner.d.ts +1 -0
- package/dist/indexInner.d.ts.map +1 -1
- package/dist/jsx-runtime.d.ts +2 -0
- package/dist/jsx-runtime.d.ts.map +1 -0
- package/dist/jsx-runtime.js +1 -0
- package/dist/jsxRuntime.d.ts.map +1 -1
- package/dist/jsxRuntime.js +5 -1
- package/dist/makeFinalConfig.d.ts.map +1 -1
- package/dist/makeInstanceConfigFromFrameworkConfig.d.ts +4 -0
- package/dist/makeInstanceConfigFromFrameworkConfig.d.ts.map +1 -0
- package/dist/makeInstanceConfigFromFrameworkConfig.js +12 -0
- package/dist/render/componentNodeToRenderingTree.d.ts +6 -0
- package/dist/render/componentNodeToRenderingTree.d.ts.map +1 -0
- package/dist/render/componentNodeToRenderingTree.js +41 -0
- package/dist/render/contentToHtml.d.ts +9 -0
- package/dist/render/contentToHtml.d.ts.map +1 -0
- package/dist/render/contentToHtml.js +44 -0
- package/dist/render/contentToHtmlDev.d.ts +9 -0
- package/dist/render/contentToHtmlDev.d.ts.map +1 -0
- package/dist/render/contentToHtmlDev.js +4 -0
- package/dist/render/contentTreeToRenderingTree.d.ts.map +1 -1
- package/dist/render/contentTreeToRenderingTree.js +8 -8
- package/dist/render/functionComponentNodeToRenderingTree.d.ts.map +1 -1
- package/dist/render/functionComponentNodeToRenderingTree.js +4 -2
- package/dist/render/instantiateClassComponent.d.ts +2 -2
- package/dist/render/instantiateClassComponent.d.ts.map +1 -1
- package/dist/render/instantiateClassComponent.js +1 -1
- package/dist/render/instantiateComponent.d.ts.map +1 -1
- package/dist/render/processProps.d.ts.map +1 -1
- package/dist/render/processProps.js +1 -1
- package/dist/render/renderingTreeToHtml.d.ts.map +1 -1
- package/dist/render/renderingTreeToHtml.js +42 -8
- package/dist/render/rootToHtml.d.ts +2 -1
- package/dist/render/rootToHtml.d.ts.map +1 -1
- package/dist/render/rootToHtml.js +12 -6
- package/dist/render/rootToHtmlDev.d.ts +4 -3
- package/dist/render/rootToHtmlDev.d.ts.map +1 -1
- package/dist/render/rootToHtmlDev.js +2 -2
- package/dist/routing/MatchedRoute.d.ts.map +1 -1
- package/dist/routing/MatchedRoute.js +0 -3
- package/dist/routing/runContentFunction.d.ts +2 -0
- package/dist/routing/runContentFunction.d.ts.map +1 -0
- package/dist/routing/runContentFunction.js +13 -0
- package/dist/staticGen/getAppRoutes.d.ts.map +1 -1
- package/dist/staticGen/getAppRoutes.js +7 -6
- package/dist/staticGen/staticGen.d.ts.map +1 -1
- package/dist/staticGen/staticGen.js +9 -1
- package/dist/update/integrateUpdateVdom.d.ts +13 -1
- package/dist/update/integrateUpdateVdom.d.ts.map +1 -1
- package/dist/update/integrateUpdateVdom.js +112 -49
- package/dist/validChildren.d.ts +4 -2
- package/dist/validChildren.d.ts.map +1 -1
- package/dist/validChildren.js +4 -0
- package/package.json +13 -10
- package/types/jsx/jsx.d.ts +10 -7
- package/dist/babelPlugins/BabelTransformCssImport.d.ts.map +0 -1
- package/dist/babelPlugins/BabelTransformDependencyImportsCjs.d.ts.map +0 -1
- package/dist/babelPlugins/BabelTransformDependencyImportsEsm.d.ts.map +0 -1
- package/dist/babelPlugins/BabelTransformDependencyImportsEsm.js +0 -85
- package/dist/build/compileEnv.d.ts +0 -2
- package/dist/build/compileEnv.d.ts.map +0 -1
- package/dist/build/compileEnv.js +0 -132
- package/dist/build/createAppConfig.d.ts +0 -4
- package/dist/build/createAppConfig.d.ts.map +0 -1
- package/dist/build/webpack.user.prod.config.d.ts +0 -2
- package/dist/build/webpack.user.prod.config.d.ts.map +0 -1
- package/dist/build/webpack.user.prod.config.js +0 -337
- package/dist/createInstanceConfigFromFrameworkConfig.d.ts +0 -4
- package/dist/createInstanceConfigFromFrameworkConfig.d.ts.map +0 -1
- package/dist/createInstanceConfigFromFrameworkConfig.js +0 -9
- package/dist/getAppConfig.d.ts +0 -3
- package/dist/getAppConfig.d.ts.map +0 -1
- package/dist/getAppConfig.js +0 -12
- package/dist/render/componentNodeToRenderingToTree.d.ts +0 -6
- package/dist/render/componentNodeToRenderingToTree.d.ts.map +0 -1
- package/dist/render/componentNodeToRenderingToTree.js +0 -15
- package/dist/render/componentNodeToTree.d.ts +0 -5
- package/dist/render/componentNodeToTree.d.ts.map +0 -1
- package/dist/render/componentNodeToTree.js +0 -16
|
@@ -52,10 +52,10 @@ export function WideRenderedContentNodeIsHtml(wrcn) {
|
|
|
52
52
|
return wrcn !== $contentNull && RenderedContentNodeIsHtml(wrcn);
|
|
53
53
|
}
|
|
54
54
|
export function RenderedContentNodeIsHead(rcn) {
|
|
55
|
-
return typeof rcn === 'object' && rcn !== null && !Array.isArray(rcn) && rcn[$type] ===
|
|
55
|
+
return typeof rcn === 'object' && rcn !== null && !Array.isArray(rcn) && rcn[$type] === 'head'; //$head
|
|
56
56
|
}
|
|
57
57
|
export function RenderedContentNodeSingleIsHead(rcns) {
|
|
58
|
-
return typeof rcns === 'object' && rcns[$type] === $head
|
|
58
|
+
return typeof rcns === 'object' && rcns[$type] === 'head'; // $head
|
|
59
59
|
}
|
|
60
60
|
export function RenderedContentNodeIsComponent(rcn) {
|
|
61
61
|
return typeof rcn === 'object' && rcn !== null && !Array.isArray(rcn) && typeof rcn[$type] === 'function';
|
package/dist/RenderingNode.d.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import type { TungstenBaseComponent, TungstenBaseComponentType } from './Components.jsx';
|
|
2
2
|
import type { FunctionComponentStandInAny } from './FunctionComponentStandIn.js';
|
|
3
|
-
import { type ContentNodeLiteral, type ContentNodeNonRendered, type NodeValue, ContentNodeClassComponent, ContentNodeFunctionComponent } from './ContentNode.js';
|
|
3
|
+
import { type ContentNodeLiteral, type ContentNodeNonRendered, type NodeValue, ContentNodeClassComponent, ContentNodeFunctionComponent, ContentNodeRendered } from './ContentNode.js';
|
|
4
4
|
import { $key, $props, $type } from './contentNodeSymbols.js';
|
|
5
5
|
import { KeyAttr } from './KeyAttr.js';
|
|
6
6
|
import { FunctionComponent } from './FunctionComponent.js';
|
|
7
7
|
export declare const $component: unique symbol;
|
|
8
|
-
export
|
|
8
|
+
export type $Component = typeof $component;
|
|
9
|
+
export declare const $element: unique symbol;
|
|
10
|
+
export type $Element = typeof $element;
|
|
9
11
|
export declare const $children: unique symbol;
|
|
10
|
-
export
|
|
12
|
+
export type $Children = typeof $children;
|
|
13
|
+
export declare const $placeholder: unique symbol;
|
|
14
|
+
export type $Placeholder = typeof $placeholder;
|
|
11
15
|
export type RenderingNodeProps = {
|
|
12
16
|
children?: RenderingNode;
|
|
13
17
|
value?: NodeValue;
|
|
@@ -15,6 +19,7 @@ export type RenderingNodeProps = {
|
|
|
15
19
|
};
|
|
16
20
|
export type RenderingNodeNonRendered = ContentNodeNonRendered;
|
|
17
21
|
export type RenderingNodeLiteral = ContentNodeLiteral;
|
|
22
|
+
export type RenderingNodeRendered = ContentNodeRendered;
|
|
18
23
|
export type RenderingNodeHtml = {
|
|
19
24
|
[$type]: string;
|
|
20
25
|
[$props]: RenderingNodeProps;
|
|
@@ -22,21 +27,31 @@ export type RenderingNodeHtml = {
|
|
|
22
27
|
};
|
|
23
28
|
export type RenderingNodeClassComponent = {
|
|
24
29
|
[$type]: TungstenBaseComponentType<any, any>;
|
|
25
|
-
[$component]: TungstenBaseComponent;
|
|
26
30
|
[$props]: RenderingNodeProps;
|
|
31
|
+
[$placeholder]?: boolean;
|
|
27
32
|
};
|
|
28
33
|
export type RenderingNodeFunctionComponent = {
|
|
29
34
|
[$type]: FunctionComponent<any, any>;
|
|
30
|
-
[$
|
|
35
|
+
[$props]: RenderingNodeProps;
|
|
36
|
+
[$placeholder]?: boolean;
|
|
37
|
+
};
|
|
38
|
+
export type RenderingNodePlaceholder = {
|
|
39
|
+
[$type]: $Placeholder;
|
|
40
|
+
[$component]: TungstenBaseComponentType<any, any>;
|
|
31
41
|
[$props]: RenderingNodeProps;
|
|
32
42
|
};
|
|
33
43
|
export type RenderingNodeComponent = RenderingNodeClassComponent | RenderingNodeFunctionComponent;
|
|
34
44
|
export type RenderingNodeElement = RenderingNodeHtml | RenderingNodeComponent;
|
|
35
45
|
export type RenderingNodeSingle = RenderingNodeElement | RenderingNodeLiteral | ContentNodeNonRendered;
|
|
36
46
|
export type RenderingNode = RenderingNodeSingle | RenderingNode[];
|
|
37
|
-
export declare function makeRenderingNodeClassComponentFromContentNodeClassComponent(contentNode: ContentNodeClassComponent,
|
|
38
|
-
export declare function makeRenderingNodeFunctionComponentFromContentNodeFunctionComponent(contentNode: ContentNodeFunctionComponent,
|
|
47
|
+
export declare function makeRenderingNodeClassComponentFromContentNodeClassComponent(contentNode: ContentNodeClassComponent, element: TungstenBaseComponent<any, any> | null, renderingChildren: RenderingNode, placeholder?: boolean): RenderingNodeClassComponent;
|
|
48
|
+
export declare function makeRenderingNodeFunctionComponentFromContentNodeFunctionComponent(contentNode: ContentNodeFunctionComponent, element: FunctionComponentStandInAny | null, renderingChildren: RenderingNode, placeholder?: boolean): RenderingNodeFunctionComponent;
|
|
49
|
+
export declare function makeRenderingNodePlaceholderFromContentNodeComponent(contentNode: ContentNodeClassComponent, element: TungstenBaseComponent<any, any> | FunctionComponentStandInAny | null, renderingChildren: RenderingNode): RenderingNodePlaceholder;
|
|
39
50
|
export declare function RenderingNodeIsElement(item: RenderingNode): item is RenderingNodeElement;
|
|
40
|
-
export declare function RenderingNodeIsHtml(item: RenderingNode): item is
|
|
51
|
+
export declare function RenderingNodeIsHtml(item: RenderingNode): item is RenderingNodeHtml;
|
|
41
52
|
export declare function RenderingNodeElementIsHtml(item: RenderingNodeElement): item is RenderingNodeHtml;
|
|
53
|
+
export declare function RenderingNodeElementIsComponent(item: RenderingNodeElement): item is RenderingNodeClassComponent | RenderingNodeFunctionComponent;
|
|
54
|
+
export declare function RenderingNodeIsLiteral(item: RenderingNode): item is RenderingNodeLiteral;
|
|
55
|
+
export declare function RenderingNodeIsNonRendered(item: RenderingNode): item is RenderingNodeNonRendered;
|
|
56
|
+
export declare function RenderingNodeIsRendered(item: RenderingNode): item is RenderingNodeRendered;
|
|
42
57
|
//# sourceMappingURL=RenderingNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenderingNode.d.ts","sourceRoot":"","sources":["../src/RenderingNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAA;AACxF,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"RenderingNode.d.ts","sourceRoot":"","sources":["../src/RenderingNode.ts"],"names":[],"mappings":"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"}
|
package/dist/RenderingNode.js
CHANGED
|
@@ -1,21 +1,36 @@
|
|
|
1
|
+
import { ContentNodeIsLiteral } from "./ContentNode.js";
|
|
1
2
|
import { $key, $props, $type } from "./contentNodeSymbols.js";
|
|
2
3
|
export const $component = Symbol('element');
|
|
3
|
-
export const $
|
|
4
|
+
export const $element = Symbol('element');
|
|
4
5
|
export const $children = Symbol('children');
|
|
5
|
-
export const $
|
|
6
|
-
export function makeRenderingNodeClassComponentFromContentNodeClassComponent(contentNode,
|
|
7
|
-
|
|
6
|
+
export const $placeholder = Symbol('placeholder');
|
|
7
|
+
export function makeRenderingNodeClassComponentFromContentNodeClassComponent(contentNode, element, renderingChildren, placeholder) {
|
|
8
|
+
const n = {
|
|
8
9
|
[$type]: contentNode[$type],
|
|
9
|
-
[$component]: component,
|
|
10
|
+
//[$component]: component,
|
|
10
11
|
[$props]: {
|
|
11
12
|
children: renderingChildren
|
|
12
13
|
}
|
|
13
14
|
};
|
|
15
|
+
if (placeholder) n[$placeholder] = placeholder;
|
|
16
|
+
return n;
|
|
14
17
|
}
|
|
15
|
-
export function makeRenderingNodeFunctionComponentFromContentNodeFunctionComponent(contentNode,
|
|
16
|
-
|
|
18
|
+
export function makeRenderingNodeFunctionComponentFromContentNodeFunctionComponent(contentNode, element, renderingChildren, placeholder) {
|
|
19
|
+
const n = {
|
|
17
20
|
[$type]: contentNode[$type],
|
|
18
|
-
[$component]: component,
|
|
21
|
+
//[$component]: component,
|
|
22
|
+
[$props]: {
|
|
23
|
+
children: renderingChildren
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
if (placeholder) n[$placeholder] = placeholder;
|
|
27
|
+
return n;
|
|
28
|
+
}
|
|
29
|
+
export function makeRenderingNodePlaceholderFromContentNodeComponent(contentNode, element, renderingChildren) {
|
|
30
|
+
return {
|
|
31
|
+
[$type]: $placeholder,
|
|
32
|
+
[$component]: contentNode[$type],
|
|
33
|
+
//[$component]: component,
|
|
19
34
|
[$props]: {
|
|
20
35
|
children: renderingChildren
|
|
21
36
|
}
|
|
@@ -29,4 +44,20 @@ export function RenderingNodeIsHtml(item) {
|
|
|
29
44
|
}
|
|
30
45
|
export function RenderingNodeElementIsHtml(item) {
|
|
31
46
|
return typeof item[$type] === 'string';
|
|
47
|
+
}
|
|
48
|
+
export function RenderingNodeElementIsComponent(item) {
|
|
49
|
+
//: item is ContentNodeComponentAny {
|
|
50
|
+
return typeof item[$type] === 'function';
|
|
51
|
+
}
|
|
52
|
+
// export function RenderingNodeElementIsPlaceholder(item: RenderingNodeElement): item is RenderingNodePlaceholder {
|
|
53
|
+
// return item[$type] === $placeholder
|
|
54
|
+
// }
|
|
55
|
+
export function RenderingNodeIsLiteral(item) {
|
|
56
|
+
return ContentNodeIsLiteral(item);
|
|
57
|
+
}
|
|
58
|
+
export function RenderingNodeIsNonRendered(item) {
|
|
59
|
+
return item === null || item === undefined || typeof item === 'boolean';
|
|
60
|
+
}
|
|
61
|
+
export function RenderingNodeIsRendered(item) {
|
|
62
|
+
return !RenderingNodeIsNonRendered(item);
|
|
32
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DevServer.d.ts","sourceRoot":"","sources":["../../src/Servers/DevServer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAClC,OAAO,OAA4D,MAAM,SAAS,CAAA;AAGlF,OAAO,KAAK,EAAE,uBAAuB,EAAwB,MAAM,uBAAuB,CAAA;AAC1F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"DevServer.d.ts","sourceRoot":"","sources":["../../src/Servers/DevServer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAClC,OAAO,OAA4D,MAAM,SAAS,CAAA;AAGlF,OAAO,KAAK,EAAE,uBAAuB,EAAwB,MAAM,uBAAuB,CAAA;AAC1F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAOpD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAiB3C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAgBrD,qBAAa,SAAU,SAAQ,cAAc;IACzC,SAAS,EAAE,SAAS,CAAA;IACpB,MAAM,EAAE,uBAAuB,CAAA;IAC/B,eAAe,EAAE,eAAe,CAAA;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAO;IAC9B,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACzC,GAAG,EAAE,OAAO,CAAC,WAAW,CAAA;IAExB,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,OAAO,CAAO;gBAEvB,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,uBAAuB,EAAE,eAAe,EAAE,eAAe,EACvF,iBAAiB,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM;IA0ElD,OAAO,CAAC,mBAAmB,CA8C1B;IAKD,OAAO,CAAC,gBAAgB,CAcvB;IACD,OAAO,CAAC,aAAa,CAoJpB;IAID,QAAQ,UAAW,OAAO,UAEzB;IACD,SAAS,UAAW,OAAO,YAY1B;IACD,KAAK,QAAO,OAAO,CAAC,MAAM,CAAC,CAQ1B;IACD,IAAI,aAEH;CAGJ"}
|
|
@@ -6,9 +6,10 @@ import { join } from 'path';
|
|
|
6
6
|
import { allObj as promiseAllObj } from 'sxy-lib/promises.js';
|
|
7
7
|
import { staticFolder, assetsFolder, publicFolder, packagesFolder, clientFolder, componentCssFolder } from "../settings.js";
|
|
8
8
|
import { rootToHtmlDev as renderRootToHtmlDev } from "../render/rootToHtmlDev.js";
|
|
9
|
+
import { contentToHtmlDev as renderContentToHtmlDev } from "../render/contentToHtmlDev.js";
|
|
9
10
|
import { Instance } from "../Instance/Instance.js";
|
|
10
11
|
import { TungstenError } from "../TungstenError.js";
|
|
11
|
-
import {
|
|
12
|
+
import { makeInstanceConfigFromFrameworkConfig } from "../makeInstanceConfigFromFrameworkConfig.js";
|
|
12
13
|
import { cliNews, cliOut, cliLog } from "../cliOutput.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
13
14
|
import { existsSync } from 'fs';
|
|
14
15
|
import { getApiRoutes } from "../api/getApiRoutes.js";
|
|
@@ -22,7 +23,7 @@ import { createLoad } from 'sxy-loader';
|
|
|
22
23
|
import { routing } from "./routing.js";
|
|
23
24
|
import { globalDataFunc } from "../routing/registerGlobalData.js";
|
|
24
25
|
import { TungstenServer } from "./TungstenServer.js";
|
|
25
|
-
import { RoutingRedirect } from "../
|
|
26
|
+
import { RoutingRedirect } from "../routing/RoutingRedirect.js";
|
|
26
27
|
import { portError } from "./portError.js";
|
|
27
28
|
import { loadEnvsDev } from "./loadEnvsDev.js";
|
|
28
29
|
import { initStores } from "./initStores.js";
|
|
@@ -63,13 +64,15 @@ export class DevServer extends TungstenServer {
|
|
|
63
64
|
const fullFilePath = 'file://' + join(this.compilationInfo.codeLocation, middlewareFile);
|
|
64
65
|
const middlewareModule = await load(fullFilePath);
|
|
65
66
|
if (!(middlewareExportName in middlewareModule)) {
|
|
66
|
-
throwError('DevServer', `export ${middlewareExportName} not found in ${middlewareFile} when trying to load server middleware`);
|
|
67
|
+
throwError('DevServer', `export ${middlewareExportName} not found in ${middlewareFile}` + ` when trying to load server middleware`);
|
|
67
68
|
}
|
|
68
69
|
const middlewares = middlewareModule[middlewareExportName]; // eslint-disable-line no-type-assertion/no-type-assertion
|
|
69
70
|
if (!Array.isArray(middlewares)) throwError('addServerMiddleware', `Expected middlewares to be an array`);
|
|
70
71
|
if (!(0 in middlewares)) throwError('addServerMiddleware', `No middleware entry at index 0`);
|
|
71
72
|
const firstMiddleware = middlewares[0];
|
|
72
|
-
if (!(typeof firstMiddleware === 'function'))
|
|
73
|
+
if (!(typeof firstMiddleware === 'function')) {
|
|
74
|
+
throwError('addServerMiddleware', `Expected middleware to be a function`);
|
|
75
|
+
}
|
|
73
76
|
let i = 0;
|
|
74
77
|
const next = () => {
|
|
75
78
|
i++;
|
|
@@ -123,7 +126,7 @@ export class DevServer extends TungstenServer {
|
|
|
123
126
|
//// perhaps, set some return data in the instance
|
|
124
127
|
//// then return html string + other data
|
|
125
128
|
const location = req.url;
|
|
126
|
-
const instanceConfig =
|
|
129
|
+
const instanceConfig = makeInstanceConfigFromFrameworkConfig(this.config, true);
|
|
127
130
|
if (this.framework.frameworkModules === undefined) {
|
|
128
131
|
throwError('DevServer.handleRequest()', 'framework.frameworkModules is undefined');
|
|
129
132
|
}
|
|
@@ -132,22 +135,6 @@ export class DevServer extends TungstenServer {
|
|
|
132
135
|
}
|
|
133
136
|
const load = await createLoad(import.meta.url, sxyLoaderConfig);
|
|
134
137
|
await loadEnvsDev(this.config, load, this.initialProcessEnv, false);
|
|
135
|
-
// load everything in parallel
|
|
136
|
-
//const envFile = join(this.compilationInfo.location, '.env.js')
|
|
137
|
-
//const privateEnvFile = join(this.compilationInfo.location, '.private.env.js')
|
|
138
|
-
//const publicEnvFile = join(this.compilationInfo.location, clientFolder, '.public.env.js')
|
|
139
|
-
const rootComponentFileFull = join(this.compilationInfo.location, this.config.rootComponent);
|
|
140
|
-
const {
|
|
141
|
-
appRoutes,
|
|
142
|
-
RootComponentClass
|
|
143
|
-
} = await promiseAllObj({
|
|
144
|
-
//envFile: existsSync(envFile) && load(envFile),
|
|
145
|
-
//privateEnv: existsSync(privateEnvFile) && load(privateEnvFile),
|
|
146
|
-
//publicEnv: existsSync(publicEnvFile) && load(publicEnvFile),
|
|
147
|
-
//AppClass: getAppClass(),
|
|
148
|
-
appRoutes: getRoutesDev(this.compilationInfo, this.config, load),
|
|
149
|
-
RootComponentClass: getComponentDev(rootComponentFileFull, this.config.rootComponent, load)
|
|
150
|
-
});
|
|
151
138
|
// we are delaying instance creation until after we load the app code, to lets things initialise?
|
|
152
139
|
const reqRes = {
|
|
153
140
|
req,
|
|
@@ -157,10 +144,51 @@ export class DevServer extends TungstenServer {
|
|
|
157
144
|
const serverDataLoading = {
|
|
158
145
|
value: false
|
|
159
146
|
};
|
|
147
|
+
const routingPromise = getRoutesDev(this.compilationInfo, this.config, load).then(async appRoutes => {
|
|
148
|
+
const routes = typeof appRoutes === 'function' ? appRoutes(reqRes) : appRoutes;
|
|
149
|
+
// load data, and do routing
|
|
150
|
+
return promiseAllObj({
|
|
151
|
+
appRoutes,
|
|
152
|
+
routes,
|
|
153
|
+
globalData: globalDataFunc !== undefined ? globalDataFunc(reqRes) : {},
|
|
154
|
+
matchedRouteInfo: routing(location, routes, serverDataLoading)
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
let appRoutes;
|
|
158
|
+
let routes;
|
|
159
|
+
let globalData;
|
|
160
|
+
let matchedRouteInfo;
|
|
161
|
+
let RootComponentClass = null;
|
|
162
|
+
if (this.config.useRootComponent) {
|
|
163
|
+
const rootComponentFileFull = join(this.compilationInfo.location, this.config.rootComponent);
|
|
164
|
+
({
|
|
165
|
+
routing: {
|
|
166
|
+
appRoutes,
|
|
167
|
+
routes,
|
|
168
|
+
globalData,
|
|
169
|
+
matchedRouteInfo
|
|
170
|
+
},
|
|
171
|
+
RootComponentClass
|
|
172
|
+
} = await promiseAllObj({
|
|
173
|
+
routing: routingPromise,
|
|
174
|
+
RootComponentClass: getComponentDev(rootComponentFileFull, this.config.rootComponent, load)
|
|
175
|
+
}));
|
|
176
|
+
} else {
|
|
177
|
+
({
|
|
178
|
+
appRoutes,
|
|
179
|
+
routes,
|
|
180
|
+
globalData,
|
|
181
|
+
matchedRouteInfo
|
|
182
|
+
} = await routingPromise);
|
|
183
|
+
//throwError('DevServer', 'useRootComponent = false not implemented yet')
|
|
184
|
+
}
|
|
160
185
|
// get routes (running the getRoutes function if needed)
|
|
161
|
-
const routes = typeof appRoutes === 'function' ? appRoutes(reqRes) : appRoutes
|
|
186
|
+
//const routes = (typeof appRoutes === 'function') ? appRoutes(reqRes) : appRoutes
|
|
162
187
|
// load data, and do routing
|
|
163
|
-
const [globalData, matchedRouteInfo] = await Promise.all([
|
|
188
|
+
// const [globalData, matchedRouteInfo] = await Promise.all([
|
|
189
|
+
// (globalDataFunc !== undefined) ? globalDataFunc(reqRes) : {},
|
|
190
|
+
// routing(location, routes, serverDataLoading)
|
|
191
|
+
// ])
|
|
164
192
|
// handle any redirect issued during routing
|
|
165
193
|
if (matchedRouteInfo.data instanceof RoutingRedirect) {
|
|
166
194
|
const redirect = matchedRouteInfo.data;
|
|
@@ -175,7 +203,26 @@ export class DevServer extends TungstenServer {
|
|
|
175
203
|
} = initStores(location, reqRes, globalData, matchedRouteInfo, serverDataLoading);
|
|
176
204
|
// create the instance
|
|
177
205
|
const instance = new Instance(location, instanceConfig, reqRes, appRoutes, routes, internalStore, stores, storeSubscriptions, globalData, matchedRouteInfo);
|
|
178
|
-
|
|
206
|
+
let html;
|
|
207
|
+
if (RootComponentClass) {
|
|
208
|
+
html = await renderRootToHtmlDev(this.compilationInfo, this.framework.clientImportAliases, RootComponentClass, instance, this.config, global.tungstenPublicEnv, '' // siteBasePathOverride
|
|
209
|
+
);
|
|
210
|
+
} else {
|
|
211
|
+
const {
|
|
212
|
+
params,
|
|
213
|
+
data
|
|
214
|
+
} = matchedRouteInfo;
|
|
215
|
+
let {
|
|
216
|
+
content
|
|
217
|
+
} = matchedRouteInfo;
|
|
218
|
+
if (typeof content === 'function') {
|
|
219
|
+
content = content(data, params, {} /* props */, globalData, location);
|
|
220
|
+
//throwError('DevServer', 'route content is a function')
|
|
221
|
+
}
|
|
222
|
+
//console.log('content to render', content)
|
|
223
|
+
html = await renderContentToHtmlDev(this.compilationInfo, this.framework.clientImportAliases, content, instance, this.config, global.tungstenPublicEnv, '' // siteBasePathOverride
|
|
224
|
+
);
|
|
225
|
+
}
|
|
179
226
|
//debug('html', html)
|
|
180
227
|
res.setHeader('Content-Type', 'text/html');
|
|
181
228
|
res.status(instance.matchedRouteInfo.key === '404' ? 404 : 200);
|
|
@@ -256,7 +303,9 @@ export class DevServer extends TungstenServer {
|
|
|
256
303
|
const publicLocation = join(this.compilationInfo.location, publicFolder);
|
|
257
304
|
if (existsSync(publicLocation)) this.app.use(express.static(publicLocation)); // files from public folder
|
|
258
305
|
//cliWarn(`assets dir:`, this.config.assetsDir)
|
|
259
|
-
if (this.config.assetsDir !== undefined)
|
|
306
|
+
if (this.config.assetsDir !== undefined) {
|
|
307
|
+
this.app.use(`/${this.config.assetsDir}`, express.static(join(this.compilationInfo.location, assetsFolder))); // files from assets folder
|
|
308
|
+
}
|
|
260
309
|
this.app.use(express.static(this.compilationInfo.location, {
|
|
261
310
|
dotfiles: 'allow'
|
|
262
311
|
})); // serving the app files themselves
|
|
@@ -4,19 +4,23 @@ import type { FrameworkConfigComplete } from '../FrameworkConfig.js';
|
|
|
4
4
|
import type { CompilationInfo } from '../build/CompilationInfo.js';
|
|
5
5
|
import type { ApiRoutes } from '../api/ApiRoutes.js';
|
|
6
6
|
import { Framework } from '../Framework.js';
|
|
7
|
+
import { AnyComponentType } from '../AnyComponentType.js';
|
|
8
|
+
import { AppRoutes } from '../routing/AppRoutes.js';
|
|
7
9
|
import { ServerMiddleware } from './ServerMiddleware.js';
|
|
8
10
|
import { TungstenServer } from './TungstenServer.jsx';
|
|
9
11
|
export declare class ProdServer extends TungstenServer {
|
|
10
12
|
framework: Framework;
|
|
11
13
|
config: FrameworkConfigComplete;
|
|
12
14
|
compilationInfo: CompilationInfo;
|
|
15
|
+
appRoutes: AppRoutes;
|
|
16
|
+
RootComponentOrNull: AnyComponentType | null;
|
|
13
17
|
port: number;
|
|
14
18
|
location: string | null;
|
|
15
19
|
app: express.Application;
|
|
16
20
|
apiRoutesPromise?: Promise<ApiRoutes>;
|
|
17
21
|
apiRoutes?: ApiRoutes;
|
|
18
22
|
server?: Server;
|
|
19
|
-
constructor(framework: Framework, config: FrameworkConfigComplete, compilationInfo: CompilationInfo, serverMiddleware: ServerMiddleware | null);
|
|
23
|
+
constructor(framework: Framework, config: FrameworkConfigComplete, compilationInfo: CompilationInfo, appRoutes: AppRoutes, RootComponentOrNull: AnyComponentType | null, serverMiddleware: ServerMiddleware | null);
|
|
20
24
|
private handleRequestApi;
|
|
21
25
|
handleRequest: (req: express.Request, res: express.Response) => Promise<void>;
|
|
22
26
|
errorPage: () => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProdServer.d.ts","sourceRoot":"","sources":["../../src/Servers/ProdServer.ts"],"names":[],"mappings":"AAEA,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAI7B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"ProdServer.d.ts","sourceRoot":"","sources":["../../src/Servers/ProdServer.ts"],"names":[],"mappings":"AAEA,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAI7B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAMpD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAM3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAUnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAYrD,qBAAa,UAAW,SAAQ,cAAc;IAC1C,SAAS,EAAE,SAAS,CAAA;IACpB,MAAM,EAAE,uBAAuB,CAAA;IAC/B,eAAe,EAAE,eAAe,CAAA;IAChC,SAAS,EAAE,SAAS,CAAA;IACpB,mBAAmB,EAAE,gBAAgB,GAAG,IAAI,CAAA;IAI5C,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAO;IAC9B,GAAG,EAAE,OAAO,CAAC,WAAW,CAAA;IACxB,gBAAgB,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;IACrC,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;gBAEX,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,uBAAuB,EAC/B,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,SAAS,EACpB,mBAAmB,EAAE,gBAAgB,GAAG,IAAI,EAC5C,gBAAgB,EAAE,gBAAgB,GAAG,IAAI;IA+E7C,OAAO,CAAC,gBAAgB,CAgBvB;IACD,aAAa,QAAe,OAAO,CAAC,OAAO,OAAO,OAAO,CAAC,QAAQ,KAAG,OAAO,CAAC,IAAI,CAAC,CAqFjF;IACD,SAAS,eASR;IAID,KAAK,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,UAAQ,GAAG,OAAO,CAAC,MAAM,CAAC;IAYlE,IAAI;CAKP"}
|
|
@@ -6,15 +6,14 @@ import { join } from 'path';
|
|
|
6
6
|
import { existsSync } from 'fs';
|
|
7
7
|
import { staticFolder, assetsFolder, packageNameCapitalized, publicFolder } from "../settings.js";
|
|
8
8
|
import { rootToHtml as renderRootToHtml } from "../render/rootToHtml.js";
|
|
9
|
+
import { contentToHtml as renderContentToHtml } from "../render/contentToHtml.js";
|
|
9
10
|
import { Instance } from "../Instance/Instance.js";
|
|
10
11
|
import { cliOut, cliLog, cliNews } from "../cliOutput.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
11
12
|
import { TungstenError } from "../TungstenError.js";
|
|
12
|
-
import {
|
|
13
|
+
import { makeInstanceConfigFromFrameworkConfig } from "../makeInstanceConfigFromFrameworkConfig.js";
|
|
13
14
|
//import { addRequireResolveHooks } from '../reRouting/addRequireResolveHooks.js'
|
|
14
15
|
import { standardizeWebPath } from "../standardizeWebPath.js";
|
|
15
16
|
import { throwError } from "../throwError.js";
|
|
16
|
-
import { getRoutes } from "../getRoutes.js";
|
|
17
|
-
import { getComponent } from "../getComponent.js";
|
|
18
17
|
import { routing } from "./routing.js";
|
|
19
18
|
import { globalDataFunc } from "../routing/registerGlobalData.js";
|
|
20
19
|
import { TungstenServer } from "./TungstenServer.js";
|
|
@@ -24,11 +23,13 @@ function debug(...texts) {
|
|
|
24
23
|
// console.log(...texts)
|
|
25
24
|
}
|
|
26
25
|
export class ProdServer extends TungstenServer {
|
|
27
|
-
constructor(framework,
|
|
26
|
+
constructor(framework, _config, compilationInfo, _appRoutes, _RootComponentOrNull, serverMiddleware) {
|
|
28
27
|
super();
|
|
29
28
|
_defineProperty(this, "framework", void 0);
|
|
30
29
|
_defineProperty(this, "config", void 0);
|
|
31
30
|
_defineProperty(this, "compilationInfo", void 0);
|
|
31
|
+
_defineProperty(this, "appRoutes", void 0);
|
|
32
|
+
_defineProperty(this, "RootComponentOrNull", void 0);
|
|
32
33
|
// projectDir: string
|
|
33
34
|
// prodBuildLocation: string
|
|
34
35
|
// bundleLocation: string
|
|
@@ -84,16 +85,27 @@ export class ProdServer extends TungstenServer {
|
|
|
84
85
|
}
|
|
85
86
|
try {
|
|
86
87
|
const location = req.url;
|
|
87
|
-
const instanceConfig =
|
|
88
|
+
const instanceConfig = makeInstanceConfigFromFrameworkConfig(this.config);
|
|
88
89
|
if (this.framework.frameworkModules === undefined) {
|
|
89
90
|
throwError('ProdServer.handleRequest()', 'framework.frameworkModules is undefined');
|
|
90
91
|
}
|
|
91
92
|
if (this.framework.clientImportAliases === undefined) {
|
|
92
93
|
throwError('ProdServer.handleRequest()', 'framework.clientImportAliases is undefined');
|
|
93
94
|
}
|
|
94
|
-
const appRoutes = await getRoutes(this.compilationInfo, this.config)
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
// const appRoutes: AppRoutes = await getRoutes(this.compilationInfo, this.config)
|
|
96
|
+
// let RootComponentClass: AnyComponentType
|
|
97
|
+
// if (this.config.useRootComponent) {
|
|
98
|
+
// const rootComponentFileFull = join(this.compilationInfo.location, this.config.rootComponent)
|
|
99
|
+
// RootComponentClass = await getComponent(rootComponentFileFull, this.config.rootComponent)
|
|
100
|
+
// } else {
|
|
101
|
+
// throwError('DevServer', 'useRootComponent = false not implemented yet')
|
|
102
|
+
// }
|
|
103
|
+
const {
|
|
104
|
+
compilationInfo,
|
|
105
|
+
config,
|
|
106
|
+
appRoutes,
|
|
107
|
+
RootComponentOrNull
|
|
108
|
+
} = this;
|
|
97
109
|
const reqRes = {
|
|
98
110
|
req,
|
|
99
111
|
res
|
|
@@ -111,7 +123,23 @@ export class ProdServer extends TungstenServer {
|
|
|
111
123
|
storeSubscriptions
|
|
112
124
|
} = initStores(location, reqRes, globalData, matchedRouteInfo, serverDataLoading);
|
|
113
125
|
const instance = new Instance(location, instanceConfig, reqRes, appRoutes, routes, internalStore, stores, storeSubscriptions, globalData, matchedRouteInfo);
|
|
114
|
-
|
|
126
|
+
let html;
|
|
127
|
+
if (RootComponentOrNull !== null) {
|
|
128
|
+
html = await renderRootToHtml(this.compilationInfo, this.framework.clientImportAliases, RootComponentOrNull, instance, config, this.config.siteBasePath);
|
|
129
|
+
} else {
|
|
130
|
+
const {
|
|
131
|
+
params,
|
|
132
|
+
data
|
|
133
|
+
} = matchedRouteInfo;
|
|
134
|
+
let {
|
|
135
|
+
content
|
|
136
|
+
} = matchedRouteInfo;
|
|
137
|
+
if (typeof content === 'function') {
|
|
138
|
+
content = content(data, params, {} /* props */, globalData, location);
|
|
139
|
+
//throwError('DevServer', 'route content is a function')
|
|
140
|
+
}
|
|
141
|
+
html = await renderContentToHtml(this.compilationInfo, this.framework.clientImportAliases, content, instance, config, this.config.siteBasePath);
|
|
142
|
+
}
|
|
115
143
|
//debug('html', html)
|
|
116
144
|
res.setHeader('Content-Type', 'text/html');
|
|
117
145
|
res.status(instance.matchedRouteInfo.key === '404' ? 404 : 200);
|
|
@@ -134,13 +162,17 @@ export class ProdServer extends TungstenServer {
|
|
|
134
162
|
</html>`;
|
|
135
163
|
});
|
|
136
164
|
this.framework = framework;
|
|
137
|
-
this.config =
|
|
165
|
+
this.config = _config;
|
|
138
166
|
this.compilationInfo = compilationInfo;
|
|
167
|
+
this.appRoutes = _appRoutes;
|
|
168
|
+
this.RootComponentOrNull = _RootComponentOrNull;
|
|
139
169
|
if (tungstenPrivateEnv.TUNGSTEN_SERVER_PORT === -999) {
|
|
140
170
|
throwError('ProdServer', 'TUNGSTEN_SERVER_PORT environment variable has not been set');
|
|
141
171
|
}
|
|
142
172
|
// !! I wrote this line while drunk. Please check this over. I think its wrong
|
|
143
173
|
const _port = Number(typeof tungstenPrivateEnv !== 'undefined' ? tungstenPrivateEnv.TUNGSTEN_SERVER_PORT : process.env.TUNGSTEN_SERVER_PORT);
|
|
174
|
+
// seems like all we need is:
|
|
175
|
+
//const _port = tungstenPrivateEnv.TUNGSTEN_SERVER_PORT
|
|
144
176
|
if (isNaN(_port) || _port === 0) throwError('ProdServer', portError(_port));
|
|
145
177
|
this.port = _port;
|
|
146
178
|
this.app = express();
|
|
@@ -152,43 +184,27 @@ export class ProdServer extends TungstenServer {
|
|
|
152
184
|
this.app.use(path, middlewares);
|
|
153
185
|
}
|
|
154
186
|
//this.app.set('etag', false)
|
|
155
|
-
if (this.compilationInfo.bundleLocation === undefined)
|
|
187
|
+
if (this.compilationInfo.bundleLocation === undefined) {
|
|
188
|
+
throwError('ProdServer', 'compilationInfo.bundleLocation is unset/undefined');
|
|
189
|
+
}
|
|
156
190
|
this.app.use('/bundle', express.static(this.compilationInfo.bundleLocation));
|
|
157
191
|
const publicLocation = join(this.compilationInfo.location, publicFolder);
|
|
158
192
|
//console.log('publicLocation', publicLocation, existsSync(publicLocation))
|
|
159
193
|
if (existsSync(publicLocation)) this.app.use(express.static(publicLocation)); // files from public folder
|
|
160
194
|
//console.log("serving static files with etag")
|
|
161
195
|
this.app.use(express.static(join(this.compilationInfo.location, staticFolder)));
|
|
162
|
-
if (this.config.assetsDir !== undefined)
|
|
196
|
+
if (this.config.assetsDir !== undefined) {
|
|
197
|
+
this.app.use('/assets', express.static(join(this.compilationInfo.location, assetsFolder)));
|
|
198
|
+
}
|
|
163
199
|
this.app.use(express.static(this.compilationInfo.location));
|
|
164
|
-
if (typeof
|
|
200
|
+
if (typeof _config.apiRoutes === 'string' && _config.apiRoutes !== '') {
|
|
165
201
|
const apiPath = standardizeWebPath(this.config.apiPath);
|
|
166
202
|
cliOut(`API listening at ${apiPath}`);
|
|
167
203
|
this.app.use(apiPath, express.json());
|
|
168
204
|
this.app.use(apiPath, this.handleRequestApi);
|
|
169
205
|
}
|
|
170
206
|
this.app.use(this.handleRequest);
|
|
171
|
-
/*
|
|
172
|
-
These are from dev server
|
|
173
|
-
we need to integrate these
|
|
174
|
-
|
|
175
|
-
this.app.use(`/.tungsten.config.js`, express.static(join(this.compilationInfo.location, '.tungsten.config.js'))) // compiled packages
|
|
176
|
-
this.app.use(`/${packagesFolder}/`, express.static(join(this.compilationInfo.location, packagesFolder))) // compiled packages
|
|
177
|
-
this.app.use(`/${clientFolder}/`, express.static(join(this.compilationInfo.location, clientFolder))) // compiled packages
|
|
178
|
-
this.app.use(`/${componentCssFolder}/`, express.static(join(this.compilationInfo.location, componentCssFolder))) // compiled packages
|
|
179
|
-
this.app.use(express.static(join(this.compilationInfo.location, staticFolder))) // compiled stylesheets?
|
|
180
|
-
const publicLocation = join(this.compilationInfo.location, publicFolder)
|
|
181
|
-
if (existsSync(publicLocation)) this.app.use(express.static(publicLocation)) // files from public folder
|
|
182
|
-
cliWarn(`assets dir:`, this.config.assetsDir)
|
|
183
|
-
if (this.config.assetsDir !== undefined) this.app.use(`/${this.config.assetsDir}`, express.static(join(this.compilationInfo.location, assetsFolder))) // files from assets folder
|
|
184
|
-
this.app.use(express.static(this.compilationInfo.location, { dotfiles:'allow' })) // serving the app files themselves
|
|
185
|
-
this.app.use(this.handleRequest)
|
|
186
|
-
*/
|
|
187
|
-
// start hooking into require to rewrite react requires to tungsten
|
|
188
|
-
//addRequireResolveHooks() // we need this for server side
|
|
189
|
-
// we will need a server side import loader too
|
|
190
207
|
}
|
|
191
|
-
|
|
192
208
|
// private async handlePost(req: express.Request, res: express.Response): Promise<void> {
|
|
193
209
|
// throw new TungstenError(`Err - Dev server received a post request. Not supported yet.`)
|
|
194
210
|
// }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TungstenElement.d.ts","sourceRoot":"","sources":["../src/TungstenElement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAGrD,MAAM,MAAM,eAAe,GAAG,YAAY,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/TungstenError.d.ts
CHANGED
|
@@ -2,4 +2,8 @@ export declare class TungstenError extends Error {
|
|
|
2
2
|
name: string;
|
|
3
3
|
constructor(message: string);
|
|
4
4
|
}
|
|
5
|
+
export declare class TungstenProductionError extends TungstenError {
|
|
6
|
+
name: string;
|
|
7
|
+
constructor(message?: string);
|
|
8
|
+
}
|
|
5
9
|
//# sourceMappingURL=TungstenError.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TungstenError.d.ts","sourceRoot":"","sources":["../src/TungstenError.ts"],"names":[],"mappings":"AACA,qBAAa,aAAc,SAAQ,KAAK;IACpC,IAAI,SAAkB;gBACV,OAAO,EAAE,MAAM;CAG9B"}
|
|
1
|
+
{"version":3,"file":"TungstenError.d.ts","sourceRoot":"","sources":["../src/TungstenError.ts"],"names":[],"mappings":"AACA,qBAAa,aAAc,SAAQ,KAAK;IACpC,IAAI,SAAkB;gBACV,OAAO,EAAE,MAAM;CAG9B;AAED,qBAAa,uBAAwB,SAAQ,aAAa;IACtD,IAAI,SAA4B;gBACpB,OAAO,CAAC,EAAE,MAAM;CAG/B"}
|
package/dist/TungstenError.js
CHANGED
|
@@ -6,4 +6,10 @@ export class TungstenError extends Error {
|
|
|
6
6
|
super(message);
|
|
7
7
|
_defineProperty(this, "name", 'TungstenError');
|
|
8
8
|
}
|
|
9
|
+
}
|
|
10
|
+
export class TungstenProductionError extends TungstenError {
|
|
11
|
+
constructor(message) {
|
|
12
|
+
super(message !== undefined ? message : 'A Tungsten Framework error occurred');
|
|
13
|
+
_defineProperty(this, "name", 'TungstenProductionError');
|
|
14
|
+
}
|
|
9
15
|
}
|
package/dist/_client/client.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { InstanceConfig } from 'tungsten/Instance/InstanceConfig.js';
|
|
2
|
+
declare module '../.tungsten.config.js' {
|
|
3
|
+
export default InstanceConfig;
|
|
4
|
+
}
|
|
1
5
|
declare global {
|
|
2
6
|
interface Window {
|
|
3
7
|
__tungsten_hydrate__: Promise<any>;
|
|
@@ -5,5 +9,4 @@ declare global {
|
|
|
5
9
|
foo: number;
|
|
6
10
|
}
|
|
7
11
|
}
|
|
8
|
-
export {};
|
|
9
12
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/_client/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/_client/client.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAA;AAKpE,OAAO,QAAQ,wBAAwB,CAAC;IACpC,eAAe,cAAc,CAAA;CAChC;AAMD,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,oBAAoB,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;QAClC,iBAAiB,EAAE,OAAO,CAAA;QAC1B,GAAG,EAAE,MAAM,CAAA;KACd;CACJ"}
|
package/dist/_client/client.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
//import { helpers } from './cjsHelpers.js'
|
|
2
2
|
import { hydrate } from 'tungsten';
|
|
3
|
-
// @ts-ignore
|
|
4
|
-
import
|
|
3
|
+
// @ts-ignore -- ignore module not found, will be generated later
|
|
4
|
+
import instanceConfig from "../.tungsten.config.js";
|
|
5
|
+
console.log('app config', instanceConfig);
|
|
5
6
|
// wrap the async code in an async IIFE to help rollup
|
|
6
7
|
const clientPromise = (async () => {
|
|
7
8
|
//const isProd = window.__tungsten_prod__ = appConfig.prod
|
|
@@ -10,12 +11,18 @@ const clientPromise = (async () => {
|
|
|
10
11
|
// dynamically import this here, so that we can set __tungsten_prod__ first
|
|
11
12
|
// is this causing a slowdown?
|
|
12
13
|
// need to change this to static imports via build steps
|
|
13
|
-
let routes
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
let routes;
|
|
15
|
+
const promises = [import("./routes.js").then(mod => routes = mod.routes)];
|
|
16
|
+
let RootComponent = null;
|
|
17
|
+
if (instanceConfig.useRootComponent) {
|
|
18
|
+
// rollup is failing to handle this when useRootComponent is false
|
|
19
|
+
promises.push(import("./RootComponent.js").then(({
|
|
20
|
+
module,
|
|
21
|
+
filename
|
|
22
|
+
}) => RootComponent = 'default' in module ? module.default : module[filename]) // could probably do with better error handling/reporting
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
await Promise.all(promises);
|
|
19
26
|
//const rootComponentRelFilePath = (await import('./rootComponentRelFilePath.js')).rootComponentRelFilePath
|
|
20
27
|
// let RootComponent: TungstenBaseComponentType
|
|
21
28
|
// if ('default' in rootModule) {
|
|
@@ -31,6 +38,6 @@ const clientPromise = (async () => {
|
|
|
31
38
|
// }
|
|
32
39
|
// }
|
|
33
40
|
// @ts-expect-error -- TS doesn't understand that RootComponent was assigned by the promise
|
|
34
|
-
await hydrate(routes, RootComponent,
|
|
41
|
+
await hydrate(routes, RootComponent, instanceConfig);
|
|
35
42
|
})();
|
|
36
43
|
window.__tungsten_hydrate__ = clientPromise;
|