reactivated 0.30.0 → 0.30.1
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/build.client.mjs +69 -0
- package/dist/build.client.mjs.map +1 -0
- package/dist/build.renderer.mjs +73 -0
- package/dist/build.renderer.mjs.map +1 -0
- package/dist/client.js +4 -11
- package/dist/client.js.map +1 -1
- package/dist/components/Form.js +5 -12
- package/dist/components/Form.js.map +1 -1
- package/dist/components/Widget.js +3 -9
- package/dist/components/Widget.js.map +1 -1
- package/dist/context.js +5 -10
- package/dist/context.js.map +1 -1
- package/dist/forms/index.js +117 -159
- package/dist/forms/index.js.map +1 -1
- package/dist/forms/widgets.js +11 -24
- package/dist/forms/widgets.js.map +1 -1
- package/dist/generated.js +1 -2
- package/dist/generated.js.map +1 -1
- package/dist/generator/constants.mjs +24 -0
- package/dist/generator/constants.mjs.map +1 -0
- package/dist/{generator.js → generator.mjs} +15 -16
- package/dist/generator.mjs.map +1 -0
- package/dist/index.js +2 -18
- package/dist/index.js.map +1 -1
- package/dist/{linaria.js → linaria.mjs} +45 -50
- package/dist/linaria.mjs.map +1 -0
- package/dist/models.js +1 -2
- package/dist/renderer.d.ts +3 -3
- package/dist/renderer.js +27 -40
- package/dist/renderer.js.map +1 -1
- package/dist/types.js +1 -2
- package/package.json +12 -6
- package/src/{build.client.tsx → build.client.mts} +3 -2
- package/src/{build.renderer.tsx → build.renderer.mts} +12 -5
- package/src/{generator.tsx → generator.mts} +2 -1
- package/src/{linaria.tsx → linaria.mts} +19 -1
- package/src/renderer.tsx +11 -8
- package/tsconfig.json +3 -2
- package/dist/babel.config.d.ts +0 -12
- package/dist/babel.config.js +0 -17
- package/dist/babel.config.js.map +0 -1
- package/dist/build.client.js +0 -105
- package/dist/build.client.js.map +0 -1
- package/dist/build.renderer.js +0 -104
- package/dist/build.renderer.js.map +0 -1
- package/dist/generator/constants.js +0 -29
- package/dist/generator/constants.js.map +0 -1
- package/dist/generator.js.map +0 -1
- package/dist/linaria.js.map +0 -1
- package/src/babel.config.tsx +0 -14
- /package/dist/{build.client.d.ts → build.client.d.mts} +0 -0
- /package/dist/{build.renderer.d.ts → build.renderer.d.mts} +0 -0
- /package/dist/generator/{constants.d.ts → constants.d.mts} +0 -0
- /package/dist/{generator.d.ts → generator.d.mts} +0 -0
- /package/dist/{linaria.d.ts → linaria.d.mts} +0 -0
- /package/src/generator/{constants.tsx → constants.mts} +0 -0
|
@@ -1,31 +1,30 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
2
|
+
import fs from "fs";
|
|
8
3
|
// Must be above the compile import as get-stdin used by
|
|
9
4
|
// json-schema-to-typescript messes up the descriptor even if unused.
|
|
10
|
-
const stdinBuffer =
|
|
11
|
-
const
|
|
12
|
-
|
|
5
|
+
const stdinBuffer = fs.readFileSync(0);
|
|
6
|
+
const { compile } = await import("json-schema-to-typescript");
|
|
7
|
+
import { Project, VariableDeclarationKind, } from "ts-morph";
|
|
13
8
|
const schema = JSON.parse(stdinBuffer.toString("utf8"));
|
|
14
9
|
const { urls: possibleEmptyUrls, templates, interfaces, types, values } = schema;
|
|
15
|
-
const urls =
|
|
10
|
+
const urls = {
|
|
11
|
+
...possibleEmptyUrls,
|
|
12
|
+
__reactivated_do_not_use: {
|
|
16
13
|
route: "__reactivated_do_not_use",
|
|
17
14
|
args: {},
|
|
18
|
-
},
|
|
15
|
+
},
|
|
16
|
+
__reactivated_do_not_use_args: {
|
|
19
17
|
route: "__reactivated_do_not_use_args",
|
|
20
18
|
args: {
|
|
21
19
|
_: "string",
|
|
22
20
|
},
|
|
23
|
-
}
|
|
24
|
-
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
const project = new Project();
|
|
25
24
|
const sourceFile = project.createSourceFile("");
|
|
26
25
|
if (Object.keys(urls).length !== 0) {
|
|
27
26
|
sourceFile.addVariableStatement({
|
|
28
|
-
declarationKind:
|
|
27
|
+
declarationKind: VariableDeclarationKind.Const,
|
|
29
28
|
declarations: [
|
|
30
29
|
{
|
|
31
30
|
name: "urls",
|
|
@@ -123,7 +122,7 @@ export type models = _Types["globals"]["models"];
|
|
|
123
122
|
export const {Form, FormSet, Widget, useForm, useFormSet, ManagementForm} = forms;
|
|
124
123
|
`);
|
|
125
124
|
// tslint:disable-next-line
|
|
126
|
-
|
|
125
|
+
compile(types, "this is unused").then((ts) => {
|
|
127
126
|
process.stdout.write("/* eslint-disable */\n");
|
|
128
127
|
process.stdout.write(ts);
|
|
129
128
|
for (const name of Object.keys(templates)) {
|
|
@@ -153,4 +152,4 @@ export namespace interfaces {
|
|
|
153
152
|
}
|
|
154
153
|
process.stdout.write(sourceFile.getText());
|
|
155
154
|
});
|
|
156
|
-
//# sourceMappingURL=generator.
|
|
155
|
+
//# sourceMappingURL=generator.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.mjs","sourceRoot":"","sources":["../src/generator.mts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,IAAI,CAAC;AAGpB,wDAAwD;AACxD,qEAAqE;AACrE,MAAM,WAAW,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;AAEvC,MAAM,EAAC,OAAO,EAAC,GAAG,MAAM,MAAM,CAAC,2BAA2B,CAAC,CAAC;AAE5D,OAAO,EACH,OAAO,EAIP,uBAAuB,GAG1B,MAAM,UAAU,CAAC;AAElB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;AACxD,MAAM,EAAC,IAAI,EAAE,iBAAiB,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,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KAAK,EAAE,gBAAgB,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE;IACzC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC/C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAEzB,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;QACvC,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;QAClC,UAAU,CAAC,aAAa,CAAC;;SAExB,IAAI,0CAA0C,IAAI;cAC7C,IAAI,2BAA2B,SAAS,cAAc,IAAI;;;kBAGtD,IAAI,cAAc,SAAS;;;;SAIpC,CAAC,CAAC;KACN;IAED,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE;QACxC,MAAM,SAAS,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;QACnC,UAAU,CAAC,aAAa,CAAC;;;kBAGf,IAAI,cAAc,SAAS;;;;SAIpC,CAAC,CAAC;KACN;IAED,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;AAC/C,CAAC,CAAC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./components/Form"), exports);
|
|
18
|
-
__exportStar(require("./components/Widget"), exports);
|
|
1
|
+
export * from "./components/Form";
|
|
2
|
+
export * from "./components/Widget";
|
|
19
3
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAEA,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC"}
|
|
@@ -1,50 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* This file contains an esbuild loader for Linaria.
|
|
4
3
|
* It uses the transform.ts function to generate class names from source code,
|
|
5
4
|
* returns transformed code without template literals and attaches generated source maps
|
|
6
5
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
12
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
13
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
17
|
-
var t = {};
|
|
18
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
19
|
-
t[p] = s[p];
|
|
20
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
21
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
22
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
23
|
-
t[p[i]] = s[p[i]];
|
|
24
|
-
}
|
|
25
|
-
return t;
|
|
26
|
-
};
|
|
27
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
28
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
29
|
-
};
|
|
30
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
const fs_1 = __importDefault(require("fs"));
|
|
32
|
-
const path_1 = __importDefault(require("path"));
|
|
33
|
-
const esbuild_1 = require("esbuild");
|
|
34
|
-
const babel_preset_1 = require("@linaria/babel-preset");
|
|
6
|
+
import fs from "fs";
|
|
7
|
+
import path from "path";
|
|
8
|
+
import { transformSync } from "esbuild";
|
|
9
|
+
import { slugify, transform } from "@linaria/babel-preset";
|
|
35
10
|
const nodeModulesRegex = /^(?:.*[\\/])?node_modules(?:[\\/].*)?$/;
|
|
36
|
-
function linaria(
|
|
37
|
-
var { sourceMap, preprocessor, esbuildOptions } = _a, rest = __rest(_a, ["sourceMap", "preprocessor", "esbuildOptions"]);
|
|
11
|
+
export default function linaria({ sourceMap, preprocessor, esbuildOptions, ...rest } = {}) {
|
|
38
12
|
let options = esbuildOptions;
|
|
39
13
|
return {
|
|
40
14
|
name: "linaria",
|
|
41
15
|
setup(build) {
|
|
42
16
|
const cssLookup = new Map();
|
|
43
|
-
const asyncResolve = (token, importer) =>
|
|
44
|
-
const context =
|
|
45
|
-
?
|
|
46
|
-
:
|
|
47
|
-
const result =
|
|
17
|
+
const asyncResolve = async (token, importer) => {
|
|
18
|
+
const context = path.isAbsolute(importer)
|
|
19
|
+
? path.dirname(importer)
|
|
20
|
+
: path.join(process.cwd(), path.dirname(importer));
|
|
21
|
+
const result = await build.resolve(token, {
|
|
48
22
|
kind: "entry-point",
|
|
49
23
|
resolveDir: context,
|
|
50
24
|
});
|
|
@@ -52,7 +26,7 @@ function linaria(_a = {}) {
|
|
|
52
26
|
throw new Error(`Cannot resolve ${token}`);
|
|
53
27
|
}
|
|
54
28
|
return result.path;
|
|
55
|
-
}
|
|
29
|
+
};
|
|
56
30
|
build.onResolve({ filter: /\.linaria\.css$/ }, (args) => {
|
|
57
31
|
return {
|
|
58
32
|
namespace: "linaria",
|
|
@@ -63,12 +37,12 @@ function linaria(_a = {}) {
|
|
|
63
37
|
return {
|
|
64
38
|
contents: cssLookup.get(args.path),
|
|
65
39
|
loader: "css",
|
|
66
|
-
resolveDir:
|
|
40
|
+
resolveDir: path.basename(args.path),
|
|
67
41
|
};
|
|
68
42
|
});
|
|
69
|
-
build.onLoad({ filter: /\.(js|jsx|ts|tsx)$/ }, (args) =>
|
|
70
|
-
const rawCode =
|
|
71
|
-
const { ext, name: filename } =
|
|
43
|
+
build.onLoad({ filter: /\.(js|jsx|ts|tsx)$/ }, async (args) => {
|
|
44
|
+
const rawCode = fs.readFileSync(args.path, "utf8");
|
|
45
|
+
const { ext, name: filename } = path.parse(args.path);
|
|
72
46
|
const loader = ext.replace(/^\./, "");
|
|
73
47
|
if (nodeModulesRegex.test(args.path)) {
|
|
74
48
|
return {
|
|
@@ -85,26 +59,48 @@ function linaria(_a = {}) {
|
|
|
85
59
|
options.jsxFragment = build.initialOptions.jsxFragment;
|
|
86
60
|
}
|
|
87
61
|
}
|
|
88
|
-
const transformed =
|
|
62
|
+
const transformed = transformSync(rawCode, {
|
|
63
|
+
...options,
|
|
64
|
+
sourcefile: args.path,
|
|
65
|
+
sourcemap: sourceMap,
|
|
66
|
+
loader,
|
|
67
|
+
});
|
|
89
68
|
let { code } = transformed;
|
|
90
69
|
if (sourceMap) {
|
|
91
70
|
const esbuildMap = Buffer.from(transformed.map).toString("base64");
|
|
92
71
|
code += `/*# sourceMappingURL=data:application/json;base64,${esbuildMap}*/`;
|
|
93
72
|
}
|
|
94
|
-
const
|
|
73
|
+
const babelOptions = {
|
|
74
|
+
presets: [
|
|
75
|
+
["@babel/preset-env", { targets: { node: "v12.13.0" } }],
|
|
76
|
+
["@babel/preset-typescript", { allowNamespaces: true }],
|
|
77
|
+
],
|
|
78
|
+
plugins: [
|
|
79
|
+
[
|
|
80
|
+
"module-resolver",
|
|
81
|
+
{
|
|
82
|
+
root: ["./"],
|
|
83
|
+
alias: {
|
|
84
|
+
"@client": "./client",
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
],
|
|
89
|
+
};
|
|
90
|
+
const result = await transform(code, {
|
|
95
91
|
filename: args.path,
|
|
96
92
|
preprocessor,
|
|
97
|
-
pluginOptions: rest,
|
|
93
|
+
pluginOptions: { ...rest, babelOptions },
|
|
98
94
|
}, asyncResolve);
|
|
99
95
|
if (!result.cssText) {
|
|
100
96
|
return {
|
|
101
97
|
contents: code,
|
|
102
98
|
loader,
|
|
103
|
-
resolveDir:
|
|
99
|
+
resolveDir: path.dirname(args.path),
|
|
104
100
|
};
|
|
105
101
|
}
|
|
106
102
|
let { cssText } = result;
|
|
107
|
-
const slug =
|
|
103
|
+
const slug = slugify(cssText);
|
|
108
104
|
const cssFilename = `${filename}_${slug}.linaria.css`;
|
|
109
105
|
let contents = `import ${JSON.stringify(cssFilename)}; ${result.code}`;
|
|
110
106
|
if (sourceMap && result.cssSourceMapText) {
|
|
@@ -117,11 +113,10 @@ function linaria(_a = {}) {
|
|
|
117
113
|
return {
|
|
118
114
|
contents,
|
|
119
115
|
loader,
|
|
120
|
-
resolveDir:
|
|
116
|
+
resolveDir: path.dirname(args.path),
|
|
121
117
|
};
|
|
122
|
-
})
|
|
118
|
+
});
|
|
123
119
|
},
|
|
124
120
|
};
|
|
125
121
|
}
|
|
126
|
-
|
|
127
|
-
//# sourceMappingURL=linaria.js.map
|
|
122
|
+
//# sourceMappingURL=linaria.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linaria.mjs","sourceRoot":"","sources":["../src/linaria.mts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,IAA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BAC9B,MAAM,WAAW,GAAG,GAAG,QAAQ,IAAI,IAAI,cAAc,CAAC;gBAEtD,IAAI,QAAQ,GAAG,UAAU,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK,MAAM,CAAC,IAAI,EAAE,CAAC;gBAEvE,IAAI,SAAS,IAAI,MAAM,CAAC,gBAAgB,EAAE;oBACtC,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;oBACpE,OAAO,IAAI,qDAAqD,GAAG,IAAI,CAAC;oBACxE,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAC1B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CACnC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;oBACrB,QAAQ,IAAI,qDAAqD,UAAU,IAAI,CAAC;iBACnF;gBAED,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;gBAEpC,OAAO;oBACH,QAAQ;oBACR,MAAM;oBACN,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;iBACtC,CAAC;YACN,CAAC,CAAC,CAAC;QACP,CAAC;KACJ,CAAC;AACN,CAAC"}
|
package/dist/models.js
CHANGED
package/dist/renderer.d.ts
CHANGED
|
@@ -16,12 +16,12 @@ type Result = {
|
|
|
16
16
|
status: "error";
|
|
17
17
|
error: any;
|
|
18
18
|
};
|
|
19
|
-
export declare const render: ({ context, props }: {
|
|
19
|
+
export declare const render: ({ context, props, }: {
|
|
20
20
|
context: any;
|
|
21
21
|
props: any;
|
|
22
|
-
}) => Result
|
|
22
|
+
}) => Promise<Result>;
|
|
23
23
|
export declare const simpleRender: () => void;
|
|
24
|
-
export declare const serverRender: (body: Buffer) => Result
|
|
24
|
+
export declare const serverRender: (body: Buffer) => Promise<Result>;
|
|
25
25
|
export declare const SOCKET_PATH: string;
|
|
26
26
|
export declare const server: http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
27
27
|
export {};
|
package/dist/renderer.js
CHANGED
|
@@ -1,21 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.server = exports.SOCKET_PATH = exports.serverRender = exports.simpleRender = exports.render = exports.renderPage = exports.BODY_SIZE_LIMIT = void 0;
|
|
8
|
-
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
const http_1 = __importDefault(require("http"));
|
|
10
|
-
const react_1 = __importDefault(require("react"));
|
|
11
|
-
const server_1 = __importDefault(require("react-dom/server"));
|
|
12
|
-
const react_helmet_async_1 = require("react-helmet-async");
|
|
13
|
-
// Useful when running e2e tests or the like, where the output is not
|
|
14
|
-
// co-located with the running process.
|
|
15
|
-
const REACTIVATED_CLIENT_ROOT = (_a = process.env.REACTIVATED_CLIENT_ROOT) !== null && _a !== void 0 ? _a : `../client`;
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import http from "http";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import ReactDOMServer from "react-dom/server";
|
|
5
|
+
import { HelmetProvider, } from "react-helmet-async";
|
|
16
6
|
// TODO: WHAT DOES THIS NEED TO BE? Even 100k was super fragile and a 10 choice field broke it.
|
|
17
|
-
|
|
18
|
-
const renderPage = ({ html, helmet, context, props, }) => {
|
|
7
|
+
export const BODY_SIZE_LIMIT = "100000000k";
|
|
8
|
+
export const renderPage = ({ html, helmet, context, props, }) => {
|
|
19
9
|
const scriptNonce = context.request.csp_nonce
|
|
20
10
|
? `nonce="${context.request.csp_nonce}"`
|
|
21
11
|
: "";
|
|
@@ -44,20 +34,20 @@ const renderPage = ({ html, helmet, context, props, }) => {
|
|
|
44
34
|
</body>
|
|
45
35
|
</html>`;
|
|
46
36
|
};
|
|
47
|
-
exports.renderPage = renderPage;
|
|
48
37
|
const PATHS = ["/", "/form/"];
|
|
49
|
-
const render = ({ context, props }) => {
|
|
50
|
-
|
|
38
|
+
export const render = async ({ context, props, }) => {
|
|
39
|
+
// @ts-ignore
|
|
40
|
+
const { Provider, getTemplate } = await import("_reactivated/index.tsx");
|
|
51
41
|
try {
|
|
52
42
|
const Template = getTemplate(context);
|
|
53
43
|
const helmetContext = {};
|
|
54
|
-
const rendered =
|
|
55
|
-
|
|
56
|
-
|
|
44
|
+
const rendered = ReactDOMServer.renderToString(React.createElement(HelmetProvider, { context: helmetContext },
|
|
45
|
+
React.createElement(Provider, { value: context },
|
|
46
|
+
React.createElement(Template, { ...props }))));
|
|
57
47
|
const { helmet } = helmetContext;
|
|
58
48
|
return {
|
|
59
49
|
status: "success",
|
|
60
|
-
rendered:
|
|
50
|
+
rendered: renderPage({
|
|
61
51
|
html: rendered,
|
|
62
52
|
helmet,
|
|
63
53
|
props,
|
|
@@ -69,30 +59,27 @@ const render = ({ context, props }) => {
|
|
|
69
59
|
return { status: "error", error };
|
|
70
60
|
}
|
|
71
61
|
};
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
const input = fs_1.default.readFileSync(0);
|
|
62
|
+
export const simpleRender = () => {
|
|
63
|
+
const input = fs.readFileSync(0);
|
|
75
64
|
const { context, props } = JSON.parse(input.toString("utf8"));
|
|
76
|
-
process.stdout.write(JSON.stringify(
|
|
65
|
+
process.stdout.write(JSON.stringify(render({ context, props })));
|
|
77
66
|
};
|
|
78
|
-
|
|
79
|
-
const serverRender = (body) => {
|
|
67
|
+
export const serverRender = (body) => {
|
|
80
68
|
const { context, props } = JSON.parse(body.toString("utf8"));
|
|
81
|
-
return
|
|
69
|
+
return render({ context, props });
|
|
82
70
|
};
|
|
83
|
-
exports.serverRender = serverRender;
|
|
84
71
|
const OK_RESPONSE = 200;
|
|
85
72
|
const ERROR_REPONSE = 500;
|
|
86
73
|
// Relative path to keep it under 100 characters.
|
|
87
74
|
// See: https://unix.stackexchange.com/questions/367008/why-is-socket-path-length-limited-to-a-hundred-chars
|
|
88
|
-
|
|
89
|
-
|
|
75
|
+
export const SOCKET_PATH = process.env.REACTIVATED_SOCKET ?? `node_modules/_reactivated/reactivated.sock`;
|
|
76
|
+
export const server = http.createServer((req, res) => {
|
|
90
77
|
let body = Buffer.from("");
|
|
91
78
|
req.on("data", (chunk) => {
|
|
92
79
|
body = Buffer.concat([body, chunk]);
|
|
93
80
|
});
|
|
94
|
-
req.on("end", () => {
|
|
95
|
-
const result =
|
|
81
|
+
req.on("end", async () => {
|
|
82
|
+
const result = await serverRender(body);
|
|
96
83
|
if (result.status === "success") {
|
|
97
84
|
res.writeHead(OK_RESPONSE, { "Content-Type": "text/html; charset=utf-8" });
|
|
98
85
|
res.end(result.rendered);
|
|
@@ -103,11 +90,11 @@ exports.server = http_1.default.createServer((req, res) => {
|
|
|
103
90
|
}
|
|
104
91
|
});
|
|
105
92
|
});
|
|
106
|
-
if (
|
|
107
|
-
|
|
93
|
+
if (fs.existsSync(SOCKET_PATH)) {
|
|
94
|
+
fs.unlinkSync(SOCKET_PATH);
|
|
108
95
|
}
|
|
109
|
-
|
|
110
|
-
const address =
|
|
96
|
+
server.listen(SOCKET_PATH, () => {
|
|
97
|
+
const address = server.address();
|
|
111
98
|
if (address == null) {
|
|
112
99
|
throw new Error();
|
|
113
100
|
}
|
package/dist/renderer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.js","sourceRoot":"","sources":["../src/renderer.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"renderer.js","sourceRoot":"","sources":["../src/renderer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAGH,cAAc,GAEjB,MAAM,oBAAoB,CAAC;AAI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CAAC,WAAW,CAAC,CAAC;CAC9B;AAED,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,EAAE;IAC5B,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;IAEjC,IAAI,OAAO,IAAI,IAAI,EAAE;QACjB,MAAM,IAAI,KAAK,EAAE,CAAC;KACrB;SAAM,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;QACpC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,OAAO,YAAY,CAAC,CAAC;KACzD;SAAM;QACH,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;KACzE;AACL,CAAC,CAAC,CAAC"}
|
package/dist/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reactivated",
|
|
3
|
-
"version": "0.30.
|
|
3
|
+
"version": "0.30.1",
|
|
4
4
|
"description": "",
|
|
5
|
-
"
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./dist/index.js",
|
|
7
|
+
"./dist/renderer": "./dist/renderer.js",
|
|
8
|
+
"./dist/forms": "./dist/forms/index.js",
|
|
9
|
+
"./dist/context": "./dist/context.js",
|
|
10
|
+
"./dist/babel.config.js": "./dist/babel.config.js"
|
|
11
|
+
},
|
|
6
12
|
"typings": "dist/index.d.ts",
|
|
7
13
|
"scripts": {
|
|
8
14
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
@@ -11,10 +17,10 @@
|
|
|
11
17
|
"author": "",
|
|
12
18
|
"bin": {
|
|
13
19
|
"setup_environment.sh": "./scripts/setup_environment.sh",
|
|
14
|
-
"generate_client_assets": "./dist/generator.
|
|
15
|
-
"generate_client_constants": "./dist/generator/constants.
|
|
16
|
-
"build.client
|
|
17
|
-
"build.renderer
|
|
20
|
+
"generate_client_assets": "./dist/generator.mjs",
|
|
21
|
+
"generate_client_constants": "./dist/generator/constants.mjs",
|
|
22
|
+
"build.client": "./dist/build.client.mjs",
|
|
23
|
+
"build.renderer": "./dist/build.renderer.mjs"
|
|
18
24
|
},
|
|
19
25
|
"license": "ISC",
|
|
20
26
|
"peerDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import linaria from "./linaria";
|
|
3
|
+
import linaria from "./linaria.mjs";
|
|
4
4
|
import {vanillaExtractPlugin} from "@vanilla-extract/esbuild-plugin";
|
|
5
5
|
import * as esbuild from "esbuild";
|
|
6
6
|
import ImportGlobPlugin from "esbuild-plugin-import-glob";
|
|
@@ -55,7 +55,8 @@ esbuild
|
|
|
55
55
|
".woff2": "file",
|
|
56
56
|
},
|
|
57
57
|
plugins: [
|
|
58
|
-
|
|
58
|
+
// ESM imports make this weird.
|
|
59
|
+
(ImportGlobPlugin as unknown as {default: () => esbuild.Plugin}).default(),
|
|
59
60
|
// We manually pass in identifiers because the client is not
|
|
60
61
|
// minified by esbuild but the renderer is, so class names could
|
|
61
62
|
// differ.
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import linaria from "./linaria";
|
|
3
|
+
import linaria from "./linaria.mjs";
|
|
4
4
|
import {vanillaExtractPlugin} from "@vanilla-extract/esbuild-plugin";
|
|
5
5
|
import * as esbuild from "esbuild";
|
|
6
6
|
import ImportGlobPlugin from "esbuild-plugin-import-glob";
|
|
7
7
|
import http from "http";
|
|
8
|
-
import fs
|
|
8
|
+
import fs from "fs";
|
|
9
|
+
import path from "path";
|
|
10
|
+
import {createRequire} from "module";
|
|
9
11
|
|
|
10
12
|
let server: http.Server | null = null;
|
|
11
13
|
|
|
@@ -13,11 +15,15 @@ const CACHE_KEY = `${process.cwd()}/node_modules/_reactivated/renderer.js`;
|
|
|
13
15
|
const production = process.env.NODE_ENV === "production";
|
|
14
16
|
const identifiers = production ? "short" : "debug";
|
|
15
17
|
|
|
16
|
-
const restartServer = () => {
|
|
18
|
+
const restartServer = async () => {
|
|
17
19
|
if (server != null) {
|
|
18
20
|
server.close();
|
|
19
21
|
}
|
|
20
22
|
|
|
23
|
+
const modulePath = path.resolve(CACHE_KEY);
|
|
24
|
+
|
|
25
|
+
// https://ar.al/2021/02/22/cache-busting-in-node.js-dynamic-esm-imports/
|
|
26
|
+
const require = createRequire(import.meta.url);
|
|
21
27
|
delete require.cache[CACHE_KEY];
|
|
22
28
|
server = require(CACHE_KEY).server;
|
|
23
29
|
};
|
|
@@ -26,7 +32,7 @@ esbuild
|
|
|
26
32
|
.context({
|
|
27
33
|
stdin: {
|
|
28
34
|
contents: `
|
|
29
|
-
export {server} from "reactivated/dist/renderer";
|
|
35
|
+
export {server, currentTime} from "reactivated/dist/renderer";
|
|
30
36
|
`,
|
|
31
37
|
resolveDir: process.cwd(),
|
|
32
38
|
loader: "ts",
|
|
@@ -43,7 +49,8 @@ esbuild
|
|
|
43
49
|
// above as in monorepos.
|
|
44
50
|
nodePaths: [`${process.cwd()}/node_modules`],
|
|
45
51
|
plugins: [
|
|
46
|
-
|
|
52
|
+
// ESM imports make this weird.
|
|
53
|
+
(ImportGlobPlugin as unknown as {default: () => esbuild.Plugin}).default(),
|
|
47
54
|
// We manually pass in identifiers because the client is not
|
|
48
55
|
// minified by esbuild but the renderer is, so class names could
|
|
49
56
|
// differ.
|
|
@@ -7,7 +7,8 @@ import * as generated from "./generated";
|
|
|
7
7
|
// json-schema-to-typescript messes up the descriptor even if unused.
|
|
8
8
|
const stdinBuffer = fs.readFileSync(0);
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
const {compile} = await import("json-schema-to-typescript");
|
|
11
|
+
|
|
11
12
|
import {
|
|
12
13
|
Project,
|
|
13
14
|
SourceFile,
|
|
@@ -103,12 +103,30 @@ export default function linaria({
|
|
|
103
103
|
code += `/*# sourceMappingURL=data:application/json;base64,${esbuildMap}*/`;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
const babelOptions = {
|
|
107
|
+
presets: [
|
|
108
|
+
["@babel/preset-env", {targets: {node: "v12.13.0"}}],
|
|
109
|
+
["@babel/preset-typescript", {allowNamespaces: true}],
|
|
110
|
+
],
|
|
111
|
+
plugins: [
|
|
112
|
+
[
|
|
113
|
+
"module-resolver",
|
|
114
|
+
{
|
|
115
|
+
root: ["./"],
|
|
116
|
+
alias: {
|
|
117
|
+
"@client": "./client",
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
],
|
|
122
|
+
};
|
|
123
|
+
|
|
106
124
|
const result = await transform(
|
|
107
125
|
code,
|
|
108
126
|
{
|
|
109
127
|
filename: args.path,
|
|
110
128
|
preprocessor,
|
|
111
|
-
pluginOptions: rest,
|
|
129
|
+
pluginOptions: {...rest, babelOptions},
|
|
112
130
|
},
|
|
113
131
|
asyncResolve,
|
|
114
132
|
);
|
package/src/renderer.tsx
CHANGED
|
@@ -11,10 +11,6 @@ import {
|
|
|
11
11
|
HelmetServerState,
|
|
12
12
|
} from "react-helmet-async";
|
|
13
13
|
|
|
14
|
-
// Useful when running e2e tests or the like, where the output is not
|
|
15
|
-
// co-located with the running process.
|
|
16
|
-
const REACTIVATED_CLIENT_ROOT = process.env.REACTIVATED_CLIENT_ROOT ?? `../client`;
|
|
17
|
-
|
|
18
14
|
import {Settings} from "./models";
|
|
19
15
|
|
|
20
16
|
// TODO: WHAT DOES THIS NEED TO BE? Even 100k was super fragile and a 10 choice field broke it.
|
|
@@ -78,8 +74,15 @@ type Result =
|
|
|
78
74
|
error: any;
|
|
79
75
|
};
|
|
80
76
|
|
|
81
|
-
export const render = ({
|
|
82
|
-
|
|
77
|
+
export const render = async ({
|
|
78
|
+
context,
|
|
79
|
+
props,
|
|
80
|
+
}: {
|
|
81
|
+
context: any;
|
|
82
|
+
props: any;
|
|
83
|
+
}): Promise<Result> => {
|
|
84
|
+
// @ts-ignore
|
|
85
|
+
const {Provider, getTemplate} = await import("_reactivated/index.tsx");
|
|
83
86
|
|
|
84
87
|
try {
|
|
85
88
|
const Template = getTemplate(context);
|
|
@@ -136,8 +139,8 @@ export const server = http.createServer((req, res) => {
|
|
|
136
139
|
req.on("data", (chunk) => {
|
|
137
140
|
body = Buffer.concat([body, chunk as Buffer]);
|
|
138
141
|
});
|
|
139
|
-
req.on("end", () => {
|
|
140
|
-
const result = serverRender(body);
|
|
142
|
+
req.on("end", async () => {
|
|
143
|
+
const result = await serverRender(body);
|
|
141
144
|
|
|
142
145
|
if (result.status === "success") {
|
|
143
146
|
res.writeHead(OK_RESPONSE, {"Content-Type": "text/html; charset=utf-8"});
|
package/tsconfig.json
CHANGED