frosty 0.0.67 → 0.0.69
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/README.md +50 -0
- package/dist/_native.d.ts +3 -3
- package/dist/_native.mjs +2 -2
- package/dist/dom.d.ts +3 -3
- package/dist/dom.mjs +3 -3
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +3 -3
- package/dist/internals/{common-jmXMOod4.d.ts → common-B0Nya-9e.d.ts} +3 -3
- package/dist/internals/{common-jmXMOod4.d.ts.map → common-B0Nya-9e.d.ts.map} +1 -1
- package/dist/internals/{common-uTufm_t7.mjs → common-Ca5Ux3vo.mjs} +3 -3
- package/dist/internals/{common-uTufm_t7.mjs.map → common-Ca5Ux3vo.mjs.map} +1 -1
- package/dist/internals/{common-C5xm7xDw.d.ts → common-lfYTb1eV.d.ts} +3 -3
- package/dist/internals/{common-C5xm7xDw.d.ts.map → common-lfYTb1eV.d.ts.map} +1 -1
- package/dist/internals/{fragment-BQXp1_iv.d.ts → fragment-CApRh6Hp.d.ts} +2 -2
- package/dist/internals/{fragment-BQXp1_iv.d.ts.map → fragment-CApRh6Hp.d.ts.map} +1 -1
- package/dist/internals/{renderer-DgKjFDB-.mjs → renderer-CEj3F2CM.mjs} +2 -2
- package/dist/internals/{renderer-DgKjFDB-.mjs.map → renderer-CEj3F2CM.mjs.map} +1 -1
- package/dist/internals/{renderer-D4aiCZGU.d.ts → renderer-DBPR_8BN.d.ts} +2 -2
- package/dist/internals/{renderer-D4aiCZGU.d.ts.map → renderer-DBPR_8BN.d.ts.map} +1 -1
- package/dist/internals/{state-j1YggBhW.mjs → state-C4Wldkq7.mjs} +2 -2
- package/dist/internals/{state-j1YggBhW.mjs.map → state-C4Wldkq7.mjs.map} +1 -1
- package/dist/internals/{sync-D_pTd9lu.mjs → sync-Ciycjqeo.mjs} +3 -3
- package/dist/internals/{sync-D_pTd9lu.mjs.map → sync-Ciycjqeo.mjs.map} +1 -1
- package/dist/internals/{utils-B_4b5vas.d.ts → utils-CyrF9IfR.d.ts} +2 -2
- package/dist/internals/{utils-B_4b5vas.d.ts.map → utils-CyrF9IfR.d.ts.map} +1 -1
- package/dist/jsx-dev-runtime.d.ts +7 -0
- package/dist/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/jsx-dev-runtime.js +14 -0
- package/dist/jsx-dev-runtime.js.map +1 -0
- package/dist/jsx-dev-runtime.mjs +4 -0
- package/dist/jsx-dev-runtime.mjs.map +1 -0
- package/dist/jsx-runtime.d.ts +2 -2
- package/dist/jsx-runtime.d.ts.map +1 -1
- package/dist/jsx-runtime.js +1 -1
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/jsx-runtime.mjs +1 -1
- package/dist/jsx-runtime.mjs.map +1 -1
- package/dist/server-dom.d.ts +3 -3
- package/dist/server-dom.mjs +3 -3
- package/dist/web.d.ts +3 -3
- package/dist/web.mjs +5 -5
- package/package.json +3 -2
- package/packages/frosty-cli/package.json +5 -1
- package/packages/frosty-cli/scripts/bin/run.sh +81 -42
- package/packages/frosty-cli/src/server/env.js +26 -0
- package/packages/frosty-cli/src/server/index.js +7 -11
- package/packages/frosty-cli/src/server/render.js +9 -10
- package/packages/frosty-cli/src/server/route.ts +1 -7
- package/packages/frosty-cli/{webpack.js → webpack.mjs} +95 -51
package/dist/jsx-runtime.js
CHANGED
package/dist/jsx-runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-runtime.js","sources":["../../src/core/types/fragment.ts","../../src/jsx-runtime.ts"],"sourcesContent":["//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport { ComponentType, PropsWithChildren } from './common';\n\nexport const Fragment: ComponentType<PropsWithChildren<{}>> = ({ children }) => {\n return children;\n}\n","//\n//
|
|
1
|
+
{"version":3,"file":"jsx-runtime.js","sources":["../../src/core/types/fragment.ts","../../src/jsx-runtime.ts"],"sourcesContent":["//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport { ComponentType, PropsWithChildren } from './common';\n\nexport const Fragment: ComponentType<PropsWithChildren<{}>> = ({ children }) => {\n return children;\n}\n","//\n// jsx-runtime.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport { ComponentNode } from './core/types/component';\nimport { _createElement, _ElementType, _IntrinsicAttributes, _IntrinsicElements, PropsType } from './core/types/runtime';\n\nexport { Fragment } from './core/types/fragment';\n\nexport declare namespace JSX {\n type IntrinsicElements = _IntrinsicElements;\n type IntrinsicAttributes = _IntrinsicAttributes;\n type ElementType = _ElementType;\n type Element = ComponentNode;\n type ElementChildrenAttribute = { children: {}; };\n};\n\nexport const JSX = Object.freeze({\n Element: ComponentNode,\n});\n\nexport function jsx(\n type: _ElementType,\n props: PropsType,\n key?: string | number\n): ComponentNode {\n return _createElement(type, { ...props, key });\n}\n\nexport const jsxs = jsx;\n"],"names":["ComponentNode","_createElement"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MAIa,QAAQ,GAAyC,CAAC,EAAE,QAAQ,EAAE,KAAI;AAC7E,IAAA,OAAO,QAAQ;AACjB;;AC7BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAeO,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC;AAC/B,IAAA,OAAO,EAAEA,uBAAa;AACvB,CAAA;SAEe,GAAG,CACjB,IAAkB,EAClB,KAAgB,EAChB,GAAqB,EAAA;IAErB,OAAOC,sBAAc,CAAC,IAAI,EAAE,EAAE,GAAG,KAAK,EAAE,GAAG,EAAE,CAAC;AAChD;AAEO,MAAM,IAAI,GAAG;;;;;;;"}
|
package/dist/jsx-runtime.mjs
CHANGED
package/dist/jsx-runtime.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-runtime.mjs","sources":["../../src/core/types/fragment.ts","../../src/jsx-runtime.ts"],"sourcesContent":["//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport { ComponentType, PropsWithChildren } from './common';\n\nexport const Fragment: ComponentType<PropsWithChildren<{}>> = ({ children }) => {\n return children;\n}\n","//\n//
|
|
1
|
+
{"version":3,"file":"jsx-runtime.mjs","sources":["../../src/core/types/fragment.ts","../../src/jsx-runtime.ts"],"sourcesContent":["//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport { ComponentType, PropsWithChildren } from './common';\n\nexport const Fragment: ComponentType<PropsWithChildren<{}>> = ({ children }) => {\n return children;\n}\n","//\n// jsx-runtime.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport { ComponentNode } from './core/types/component';\nimport { _createElement, _ElementType, _IntrinsicAttributes, _IntrinsicElements, PropsType } from './core/types/runtime';\n\nexport { Fragment } from './core/types/fragment';\n\nexport declare namespace JSX {\n type IntrinsicElements = _IntrinsicElements;\n type IntrinsicAttributes = _IntrinsicAttributes;\n type ElementType = _ElementType;\n type Element = ComponentNode;\n type ElementChildrenAttribute = { children: {}; };\n};\n\nexport const JSX = Object.freeze({\n Element: ComponentNode,\n});\n\nexport function jsx(\n type: _ElementType,\n props: PropsType,\n key?: string | number\n): ComponentNode {\n return _createElement(type, { ...props, key });\n}\n\nexport const jsxs = jsx;\n"],"names":[],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MAIa,QAAQ,GAAyC,CAAC,EAAE,QAAQ,EAAE,KAAI;AAC7E,IAAA,OAAO,QAAQ;AACjB;;AC7BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAeO,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC;AAC/B,IAAA,OAAO,EAAE,aAAa;AACvB,CAAA;SAEe,GAAG,CACjB,IAAkB,EAClB,KAAgB,EAChB,GAAqB,EAAA;IAErB,OAAO,cAAc,CAAC,IAAI,EAAE,EAAE,GAAG,KAAK,EAAE,GAAG,EAAE,CAAC;AAChD;AAEO,MAAM,IAAI,GAAG;;;;"}
|
package/dist/server-dom.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { JSDOM } from 'jsdom';
|
|
2
2
|
export * from 'jsdom';
|
|
3
|
-
import { _ as _DOMRenderer } from './internals/common-
|
|
4
|
-
import './internals/common-
|
|
3
|
+
import { _ as _DOMRenderer } from './internals/common-B0Nya-9e.js';
|
|
4
|
+
import './internals/common-lfYTb1eV.js';
|
|
5
5
|
import '@o2ter/utils-js';
|
|
6
6
|
import 'lodash';
|
|
7
7
|
import 'csstype';
|
|
8
|
-
import './internals/renderer-
|
|
8
|
+
import './internals/renderer-DBPR_8BN.js';
|
|
9
9
|
|
|
10
10
|
declare class ServerDOMRenderer extends _DOMRenderer {
|
|
11
11
|
constructor(dom?: JSDOM);
|
package/dist/server-dom.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { JSDOM } from 'jsdom';
|
|
2
2
|
export * from 'jsdom';
|
|
3
|
-
import { _ as _DOMRenderer } from './internals/common-
|
|
3
|
+
import { _ as _DOMRenderer } from './internals/common-Ca5Ux3vo.mjs';
|
|
4
4
|
import 'lodash';
|
|
5
5
|
import 'myers.js';
|
|
6
6
|
import './internals/component-BzurKp_J.mjs';
|
|
7
|
-
import './internals/renderer-
|
|
8
|
-
import './internals/state-
|
|
7
|
+
import './internals/renderer-CEj3F2CM.mjs';
|
|
8
|
+
import './internals/state-C4Wldkq7.mjs';
|
|
9
9
|
import 'nextick';
|
|
10
10
|
import 'postcss';
|
|
11
11
|
import 'postcss-js';
|
package/dist/web.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { S as SetStateAction,
|
|
1
|
+
import { S as SetStateAction, c as RefObject } from './internals/common-lfYTb1eV.js';
|
|
2
2
|
import * as jsdom from 'jsdom';
|
|
3
|
-
export { D as DOMNativeNode, _ as _DOMRenderer } from './internals/common-
|
|
3
|
+
export { D as DOMNativeNode, _ as _DOMRenderer } from './internals/common-B0Nya-9e.js';
|
|
4
4
|
import '@o2ter/utils-js';
|
|
5
5
|
import 'lodash';
|
|
6
6
|
import 'csstype';
|
|
7
|
-
import './internals/renderer-
|
|
7
|
+
import './internals/renderer-DBPR_8BN.js';
|
|
8
8
|
|
|
9
9
|
declare const useDocument: () => Document;
|
|
10
10
|
|
package/dist/web.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { r as reconciler,
|
|
2
|
-
import { _ as _DOMRenderer } from './internals/common-
|
|
3
|
-
export { D as DOMNativeNode } from './internals/common-
|
|
1
|
+
import { r as reconciler, u as uniqueId, E as EventEmitter } from './internals/state-C4Wldkq7.mjs';
|
|
2
|
+
import { _ as _DOMRenderer } from './internals/common-Ca5Ux3vo.mjs';
|
|
3
|
+
export { D as DOMNativeNode } from './internals/common-Ca5Ux3vo.mjs';
|
|
4
4
|
import _ from 'lodash';
|
|
5
|
-
import {
|
|
5
|
+
import { u as useSyncExternalStore, a as useMemo, b as useCallback, c as useEffect } from './internals/sync-Ciycjqeo.mjs';
|
|
6
6
|
import './internals/component-BzurKp_J.mjs';
|
|
7
7
|
import 'myers.js';
|
|
8
|
-
import './internals/renderer-
|
|
8
|
+
import './internals/renderer-CEj3F2CM.mjs';
|
|
9
9
|
import 'nextick';
|
|
10
10
|
import 'postcss';
|
|
11
11
|
import 'postcss-js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "frosty",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.69",
|
|
4
4
|
"main": "dist/index",
|
|
5
5
|
"module": "dist/index",
|
|
6
6
|
"types": "dist/index",
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
"gen-data": "node ./scripts/gen-data.mjs",
|
|
38
38
|
"clean": "rm -rf ./dist/*",
|
|
39
39
|
"rollup": "yarn clean && rollup -c",
|
|
40
|
-
"test": "jest"
|
|
40
|
+
"test": "jest",
|
|
41
|
+
"start": "npx frosty run -d -w -s ./src tests/server/app.tsx"
|
|
41
42
|
},
|
|
42
43
|
"subPackages": [
|
|
43
44
|
"packages/frosty-cli"
|
|
@@ -15,9 +15,13 @@
|
|
|
15
15
|
"@o2ter/server-js": "^0.0.20",
|
|
16
16
|
"babel-jest": "^29.7.0",
|
|
17
17
|
"babel-loader": "^10.0.0",
|
|
18
|
-
"
|
|
18
|
+
"css-loader": "^7.1.2",
|
|
19
19
|
"dotenv-webpack": "^8.1.1",
|
|
20
|
+
"file-loader": "^6.2.0",
|
|
20
21
|
"mini-css-extract-plugin": "^2.9.3",
|
|
22
|
+
"postcss-loader": "^8.1.1",
|
|
23
|
+
"sass": "^1.90.0",
|
|
24
|
+
"sass-loader": "^16.0.5",
|
|
21
25
|
"terser-webpack-plugin": "^5.3.14",
|
|
22
26
|
"webpack": "^5.98.0",
|
|
23
27
|
"webpack-cli": "^6.0.1"
|
|
@@ -34,57 +34,96 @@ export PROJECT_ROOT="${PROJECT_ROOT:-$( realpath "$INIT_CWD" )}"
|
|
|
34
34
|
|
|
35
35
|
cd "$PROJECT_ROOT"
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
print_usage() {
|
|
38
|
+
echo "Usage: frosty run [options] [input-file]"
|
|
39
|
+
echo ""
|
|
40
|
+
echo "Options:"
|
|
41
|
+
echo " -w, --watch Enable watch mode (rebuild on file changes)"
|
|
42
|
+
echo " -d, --debug Enable debug mode (development build)"
|
|
43
|
+
echo " -b, --build-only Only build, do not run the server"
|
|
44
|
+
echo " -B, --no-build Skip build step"
|
|
45
|
+
echo " -p, --port <port> Specify port for the server (default: 8080)"
|
|
46
|
+
echo " -c, --configuration <file> Specify configuration file to use (default: server.config.js)"
|
|
47
|
+
echo " -s, --src <dir> Specify source root directory"
|
|
48
|
+
echo " -o, --output <dir> Specify output directory for build artifacts"
|
|
49
|
+
echo " -h, --help Show this help message and exit"
|
|
50
|
+
echo ""
|
|
51
|
+
echo "Arguments:"
|
|
52
|
+
echo " input-file Optional input file to process"
|
|
53
|
+
echo ""
|
|
54
|
+
echo "Examples:"
|
|
55
|
+
echo " frosty run app.js"
|
|
56
|
+
}
|
|
38
57
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
NO_BUILD=true
|
|
55
|
-
shift
|
|
56
|
-
;;
|
|
57
|
-
-p|--port)
|
|
58
|
-
PORT="$2"
|
|
59
|
-
shift 2
|
|
60
|
-
;;
|
|
61
|
-
-*)
|
|
62
|
-
echo "Unknown option $1"
|
|
63
|
-
print_usage
|
|
64
|
-
exit 1
|
|
65
|
-
;;
|
|
66
|
-
*)
|
|
67
|
-
POSITIONAL_ARGS+=("$1") # save positional arg
|
|
68
|
-
shift # past argument
|
|
69
|
-
;;
|
|
58
|
+
POSITIONAL_ARGS=()
|
|
59
|
+
while [ $# -gt 0 ]; do
|
|
60
|
+
case "$1" in
|
|
61
|
+
-w|--watch) WATCH_MODE=true; shift ;;
|
|
62
|
+
-d|--debug) DEBUG_MODE=true; shift ;;
|
|
63
|
+
-b|--build-only) BUILD_ONLY=true; shift ;;
|
|
64
|
+
-B|--no-build) NO_BUILD=true; shift ;;
|
|
65
|
+
-p|--port) PORT="$2"; shift 2 ;;
|
|
66
|
+
-c|--configuration) CONFIG_FILE="$2"; shift 2 ;;
|
|
67
|
+
-s|--src) SRCROOT="$2"; shift 2 ;;
|
|
68
|
+
-o|--output) OUTPUT_DIR="$2"; shift 2 ;;
|
|
69
|
+
-h|--help) print_usage; exit 0 ;;
|
|
70
|
+
--) shift; break ;;
|
|
71
|
+
-*) echo "Unknown option $1"; print_usage; exit 1 ;;
|
|
72
|
+
*) POSITIONAL_ARGS+=("$1"); shift ;;
|
|
70
73
|
esac
|
|
71
74
|
done
|
|
72
75
|
|
|
73
|
-
|
|
76
|
+
# Restore positional parameters
|
|
77
|
+
set -- "${POSITIONAL_ARGS[@]}"
|
|
78
|
+
|
|
79
|
+
if [ $# -gt 0 ]; then
|
|
80
|
+
INPUT_FILE="$1"
|
|
81
|
+
fi
|
|
82
|
+
|
|
83
|
+
CONFIG_FILE="${CONFIG_FILE:-"$PROJECT_ROOT/server.config.js"}"
|
|
84
|
+
|
|
85
|
+
# Get output dir from config if not set
|
|
86
|
+
if [ -f "$CONFIG_FILE" ] && [ -z "$OUTPUT_DIR" ]; then
|
|
87
|
+
OUTPUT_DIR="$(node -pe "(() => {
|
|
88
|
+
try {
|
|
89
|
+
const config = require('$CONFIG_FILE');
|
|
90
|
+
return typeof config === 'function' ? config().output : config.output;
|
|
91
|
+
} catch {
|
|
92
|
+
return '';
|
|
93
|
+
}
|
|
94
|
+
})()")"
|
|
95
|
+
fi
|
|
74
96
|
|
|
75
|
-
|
|
97
|
+
OUTPUT_DIR="${OUTPUT_DIR:-"$FROSTY_CLI_ROOT/dist"}"
|
|
98
|
+
|
|
99
|
+
if [ "$NO_BUILD" != "true" ]; then
|
|
100
|
+
rm -rf "$OUTPUT_DIR"
|
|
101
|
+
fi
|
|
102
|
+
|
|
103
|
+
if [ "$BUILD_ONLY" != "true" ] && [ "$WATCH_MODE" = "true" ]; then
|
|
104
|
+
until [ -f "$OUTPUT_DIR/server.js" ]; do sleep 1; done && npx nodemon --watch "$OUTPUT_DIR" "$OUTPUT_DIR/server.js" &
|
|
105
|
+
fi
|
|
106
|
+
|
|
107
|
+
if [ "$NO_BUILD" != "true" ]; then
|
|
76
108
|
yarn install --cwd "$FROSTY_CLI_ROOT"
|
|
77
|
-
|
|
78
|
-
if [ $DEBUG_MODE ]; then
|
|
79
|
-
|
|
109
|
+
BUILD_OPTS="-c "$FROSTY_CLI_ROOT/webpack.mjs" --env CONFIG_FILE="$CONFIG_FILE" --env OUTPUT_DIR="$OUTPUT_DIR""
|
|
110
|
+
if [ "$DEBUG_MODE" = "true" ]; then
|
|
111
|
+
BUILD_OPTS="$BUILD_OPTS --mode development"
|
|
80
112
|
else
|
|
81
|
-
|
|
113
|
+
BUILD_OPTS="$BUILD_OPTS --mode production"
|
|
82
114
|
fi
|
|
83
|
-
|
|
84
|
-
|
|
115
|
+
[ -n "$INPUT_FILE" ] && BUILD_OPTS="$BUILD_OPTS --env INPUT_FILE="$INPUT_FILE""
|
|
116
|
+
[ -n "$SRCROOT" ] && BUILD_OPTS="$BUILD_OPTS --env SRCROOT="$SRCROOT""
|
|
117
|
+
[ -n "$PORT" ] && BUILD_OPTS="$BUILD_OPTS --env PORT="$PORT""
|
|
118
|
+
if [ "$WATCH_MODE" = "true" ]; then
|
|
119
|
+
npx webpack $BUILD_OPTS --watch &
|
|
120
|
+
else
|
|
121
|
+
npx webpack $BUILD_OPTS
|
|
85
122
|
fi
|
|
86
|
-
exec $SCRIPT
|
|
87
123
|
fi
|
|
88
124
|
|
|
89
|
-
if [
|
|
125
|
+
if [ "$WATCH_MODE" = "true" ]; then
|
|
126
|
+
wait
|
|
127
|
+
elif [ ! $BUILD_ONLY ]; then
|
|
128
|
+
node "$OUTPUT_DIR/server.js"
|
|
90
129
|
fi
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//
|
|
2
|
+
// env.js
|
|
3
|
+
//
|
|
4
|
+
// The MIT License
|
|
5
|
+
// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
|
|
6
|
+
//
|
|
7
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
// in the Software without restriction, including without limitation the rights
|
|
10
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
// furnished to do so, subject to the following conditions:
|
|
13
|
+
//
|
|
14
|
+
// The above copyright notice and this permission notice shall be included in
|
|
15
|
+
// all copies or substantial portions of the Software.
|
|
16
|
+
//
|
|
17
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
+
// THE SOFTWARE.
|
|
24
|
+
//
|
|
25
|
+
|
|
26
|
+
export const PORT = !_.isEmpty(process.env.PORT) ? parseInt(process.env.PORT) : 8080;
|
|
@@ -24,10 +24,12 @@
|
|
|
24
24
|
//
|
|
25
25
|
|
|
26
26
|
import _ from 'lodash';
|
|
27
|
+
import fs from 'fs';
|
|
27
28
|
import path from 'path';
|
|
28
29
|
import { Server } from '@o2ter/server-js';
|
|
29
30
|
import { ReactRoute } from './route';
|
|
30
31
|
import * as __APPLICATIONS__ from '__APPLICATIONS__';
|
|
32
|
+
import { PORT } from './env';
|
|
31
33
|
|
|
32
34
|
let __SERVER__ = {};
|
|
33
35
|
try {
|
|
@@ -43,23 +45,19 @@ app.use(Server.static(path.join(__dirname, 'public'), { cacheControl: true }));
|
|
|
43
45
|
const server_env = {};
|
|
44
46
|
if ('default' in __SERVER__) await __SERVER__.default(app, server_env);
|
|
45
47
|
|
|
46
|
-
for (const [name, { path, basename
|
|
48
|
+
for (const [name, { path: pathname, basename }] of _.toPairs(__applications__)) {
|
|
47
49
|
const { default: App } = __APPLICATIONS__[name];
|
|
50
|
+
const cssExists = fs.existsSync(path.join(__dirname, `public/css/${name}_bundle.css`));
|
|
48
51
|
const route = ReactRoute(App, {
|
|
49
|
-
env: {
|
|
50
|
-
...server_env,
|
|
51
|
-
...env,
|
|
52
|
-
},
|
|
53
52
|
jsSrc: `/${name}_bundle.js`,
|
|
54
|
-
cssSrc: `/css/${name}_bundle.css
|
|
53
|
+
cssSrc: cssExists ? `/css/${name}_bundle.css` : undefined,
|
|
55
54
|
basename: basename ?? '/',
|
|
56
55
|
preferredLocale: 'preferredLocale' in __SERVER__ ? (req) => __SERVER__.preferredLocale(app, name, req) : undefined,
|
|
57
|
-
resources: 'resources' in __SERVER__ ? (req) => __SERVER__.resources(app, name, req) : undefined,
|
|
58
56
|
});
|
|
59
|
-
if (_.isEmpty(
|
|
57
|
+
if (_.isEmpty(pathname) || pathname === '/') {
|
|
60
58
|
app.use(route);
|
|
61
59
|
} else {
|
|
62
|
-
app.use(
|
|
60
|
+
app.use(pathname, route);
|
|
63
61
|
}
|
|
64
62
|
}
|
|
65
63
|
|
|
@@ -67,6 +65,4 @@ app.use((err, req, res, next) => {
|
|
|
67
65
|
res.status(500).json(err instanceof Error ? { message: err.message } : err);
|
|
68
66
|
});
|
|
69
67
|
|
|
70
|
-
const PORT = !_.isEmpty(process.env.PORT) ? parseInt(process.env.PORT) : 8080;
|
|
71
|
-
|
|
72
68
|
app.listen(PORT, () => console.info(`listening on port ${PORT}`));
|
|
@@ -25,31 +25,30 @@
|
|
|
25
25
|
|
|
26
26
|
import _ from 'lodash';
|
|
27
27
|
import { ServerDOMRenderer } from 'frosty/server-dom';
|
|
28
|
+
import { JSDOM } from 'frosty/server-dom';
|
|
28
29
|
|
|
29
30
|
export const renderToHTML = async (App, {
|
|
30
|
-
request,
|
|
31
|
-
response,
|
|
32
|
-
env,
|
|
31
|
+
request: req,
|
|
32
|
+
response: res,
|
|
33
33
|
jsSrc,
|
|
34
34
|
cssSrc,
|
|
35
35
|
basename,
|
|
36
36
|
preferredLocale,
|
|
37
|
-
resources: _resources,
|
|
38
37
|
}) => {
|
|
39
|
-
|
|
40
38
|
const component = (
|
|
41
39
|
<html>
|
|
42
40
|
<head>
|
|
43
41
|
<script src={jsSrc} defer />
|
|
44
|
-
<link rel='stylesheet' type='text/css' href={cssSrc} />
|
|
42
|
+
{cssSrc && <link rel='stylesheet' type='text/css' href={cssSrc} />}
|
|
45
43
|
</head>
|
|
46
44
|
<body>
|
|
47
45
|
<div id="root"><App /></div>
|
|
48
46
|
</body>
|
|
49
47
|
</html>
|
|
50
48
|
);
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
const url = `${req.protocol}://${req.get('host')}${req.originalUrl}`;
|
|
50
|
+
const dom = new JSDOM(undefined, { url });
|
|
51
|
+
const renderer = new ServerDOMRenderer(dom);
|
|
52
|
+
res.setHeader('Content-Type', 'text/html');
|
|
53
|
+
res.send(await renderer.renderToString(component));
|
|
55
54
|
}
|
|
@@ -30,12 +30,10 @@ import { renderToHTML } from './render';
|
|
|
30
30
|
import { Awaitable } from '@o2ter/utils-js';
|
|
31
31
|
|
|
32
32
|
type ReactRouteOptions = {
|
|
33
|
-
env: any;
|
|
34
33
|
jsSrc: string;
|
|
35
|
-
cssSrc: string;
|
|
34
|
+
cssSrc: string | undefined;
|
|
36
35
|
basename: string;
|
|
37
36
|
preferredLocale?: (req: Request) => Awaitable<string | undefined>;
|
|
38
|
-
resources?: (req: Request) => Awaitable<any>;
|
|
39
37
|
}
|
|
40
38
|
|
|
41
39
|
const defaultPreferredLocale = (req: Request) => {
|
|
@@ -51,12 +49,10 @@ const defaultPreferredLocale = (req: Request) => {
|
|
|
51
49
|
}
|
|
52
50
|
|
|
53
51
|
export const ReactRoute = (App: any, {
|
|
54
|
-
env = {},
|
|
55
52
|
jsSrc,
|
|
56
53
|
cssSrc,
|
|
57
54
|
basename,
|
|
58
55
|
preferredLocale = defaultPreferredLocale,
|
|
59
|
-
resources,
|
|
60
56
|
}: ReactRouteOptions) => {
|
|
61
57
|
|
|
62
58
|
const router = Server.Router();
|
|
@@ -68,12 +64,10 @@ export const ReactRoute = (App: any, {
|
|
|
68
64
|
await renderToHTML(App, {
|
|
69
65
|
request: req,
|
|
70
66
|
response: res,
|
|
71
|
-
env,
|
|
72
67
|
jsSrc,
|
|
73
68
|
cssSrc,
|
|
74
69
|
basename,
|
|
75
70
|
preferredLocale: _preferredLocale,
|
|
76
|
-
resources: await resources?.(req),
|
|
77
71
|
});
|
|
78
72
|
});
|
|
79
73
|
|