reactivated 0.34.1 → 0.35.0-a1885
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 +0 -2
- package/dist/build.client.mjs.map +1 -1
- package/dist/build.renderer.mjs +0 -2
- package/dist/build.renderer.mjs.map +1 -1
- package/dist/eslintrc.js +0 -5
- package/dist/eslintrc.js.map +1 -1
- package/dist/generator/constants.mjs +6 -4
- package/dist/generator/constants.mjs.map +1 -1
- package/dist/generator.mjs +93 -97
- package/dist/generator.mjs.map +1 -1
- package/package.json +1 -10
- package/src/build.client.mts +0 -2
- package/src/build.renderer.mts +0 -2
- package/src/eslintrc.tsx +0 -5
- package/src/generator/constants.mts +7 -4
- package/src/generator.mts +113 -105
- package/dist/linaria.d.mts +0 -14
- package/dist/linaria.mjs +0 -122
- package/dist/linaria.mjs.map +0 -1
- package/src/linaria.mts +0 -168
package/dist/build.client.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import linaria from "./linaria.mjs";
|
|
3
2
|
import { vanillaExtractPlugin } from "@vanilla-extract/esbuild-plugin";
|
|
4
3
|
import * as esbuild from "esbuild";
|
|
5
4
|
import ImportGlobPlugin from "esbuild-plugin-import-glob";
|
|
@@ -54,7 +53,6 @@ esbuild
|
|
|
54
53
|
// Instead of set it manually instead of relying on minification
|
|
55
54
|
// settings.
|
|
56
55
|
vanillaExtractPlugin({ identifiers }),
|
|
57
|
-
linaria({ sourceMap: true, esbuildOptions: { sourcemap: "inline" } }),
|
|
58
56
|
],
|
|
59
57
|
})
|
|
60
58
|
.then(async (context) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.client.mjs","sourceRoot":"","sources":["../src/build.client.mts"],"names":[],"mappings":";AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"build.client.mjs","sourceRoot":"","sources":["../src/build.client.mts"],"names":[],"mappings":";AAEA,O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EAAC,GAAG,EAAC,CAAC;QAE9B,4BAA4B;QAC5B,MAAM,EAAE,IAAI;KACf;IACD,MAAM,EAAE;QACJ,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,MAAM;QACf,MAAM,EAAE,MAAM;QACd,MAAM,EAAE,MAAM;QACd,MAAM,EAAE,MAAM;QACd,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,MAAM;QACf,QAAQ,EAAE,MAAM;KACnB;IACD,OAAO,EAAE;QACL,+BAA+B;QAC9B,gBAA+D,CAAC,OAAO,EAAE;QAC1E,4DAA4D;QAC5D,gEAAgE;QAChE,UAAU;QACV,gEAAgE;QAChE,YAAY;QACZ,oBAAoB,CAAC,EAAC,WAAW,EAAC,CAAC;KACtC;CACJ,CAAC;KACD,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACpB,IAAI,UAAU,KAAK,KAAK,EAAE;QACtB,OAAO,CAAC,KAAK,EAAE,CAAC;KACnB;SAAM;QACH,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;QACxB,OAAO,CAAC,IAAI,EAAE,CAAC;KAClB;AACL,CAAC,CAAC,CAAC"}
|
package/dist/build.renderer.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import linaria from "./linaria.mjs";
|
|
3
2
|
import { vanillaExtractPlugin } from "@vanilla-extract/esbuild-plugin";
|
|
4
3
|
import * as esbuild from "esbuild";
|
|
5
4
|
import ImportGlobPlugin from "esbuild-plugin-import-glob";
|
|
@@ -48,7 +47,6 @@ esbuild
|
|
|
48
47
|
// Instead of set it manually instead of relying on minification
|
|
49
48
|
// settings.
|
|
50
49
|
vanillaExtractPlugin({ identifiers }),
|
|
51
|
-
linaria({ sourceMap: true }),
|
|
52
50
|
{
|
|
53
51
|
name: "restartServer",
|
|
54
52
|
setup: (build) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.renderer.mjs","sourceRoot":"","sources":["../src/build.renderer.mts"],"names":[],"mappings":";AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"build.renderer.mjs","sourceRoot":"","sources":["../src/build.renderer.mts"],"names":[],"mappings":";AAEA,OAAO,EAAC,oBAAoB,EAAC,MAAM,iCAAiC,CAAC;AACrE,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,gBAAgB,MAAM,4BAA4B,CAAC;AAG1D,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,aAAa,EAAC,MAAM,QAAQ,CAAC;AAErC,IAAI,MAAM,GAAuB,IAAI,CAAC;AAEtC,MAAM,SAAS,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,wCAAwC,CAAC;AAC3E,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC;AACzD,MAAM,WAAW,GAAG,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;AAEnD,MAAM,aAAa,GAAG,KAAK,IAAI,EAAE;IAC7B,IAAI,MAAM,IAAI,IAAI,EAAE;QAChB,MAAM,CAAC,KAAK,EAAE,CAAC;KAClB;IAED,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAE3C,yEAAyE;IACzE,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/C,OAAO,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAChC,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC;AACvC,CAAC,CAAC;AAEF,OAAO;KACF,OAAO,CAAC;IACL,KAAK,EAAE;QACH,QAAQ,EAAE;;aAET;QACD,UAAU,EAAE,OAAO,CAAC,GAAG,EAAE;QACzB,MAAM,EAAE,IAAI;KACf;IACD,MAAM,EAAE,UAAU;IAClB,MAAM,EAAE,IAAI;IACZ,QAAQ,EAAE,MAAM;IAChB,OAAO,EAAE,yCAAyC;IAClD,SAAS,EAAE,IAAI;IACf,MAAM,EAAE,QAAQ;IAChB,gBAAgB,EAAE,IAAI;IACtB,gEAAgE;IAChE,kEAAkE;IAClE,yBAAyB;IACzB,SAAS,EAAE,CAAC,GAAG,OAAO,CAAC,GAAG,EAAE,eAAe,CAAC;IAC5C,OAAO,EAAE;QACL,+BAA+B;QAC9B,gBAA+D,CAAC,OAAO,EAAE;QAC1E,4DAA4D;QAC5D,gEAAgE;QAChE,UAAU;QACV,gEAAgE;QAChE,YAAY;QACZ,oBAAoB,CAAC,EAAC,WAAW,EAAC,CAAC;QACnC;YACI,IAAI,EAAE,eAAe;YACrB,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;gBACb,IAAI,UAAU,KAAK,KAAK,EAAE;oBACtB,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE;wBACnB,aAAa,EAAE,CAAC;oBACpB,CAAC,CAAC,CAAC;iBACN;YACL,CAAC;SACJ;KACJ;CACJ,CAAC;KACD,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACpB,IAAI,UAAU,KAAK,KAAK,EAAE;QACtB,OAAO,CAAC,KAAK,EAAE,CAAC;KACnB;SAAM;QACH,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;QACxB,OAAO,CAAC,IAAI,EAAE,CAAC;KAClB;AACL,CAAC,CAAC,CAAC"}
|
package/dist/eslintrc.js
CHANGED
package/dist/eslintrc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eslintrc.js","sourceRoot":"","sources":["../src/eslintrc.tsx"],"names":[],"mappings":";AAAA,MAAM,CAAC,OAAO,GAAG;IACb,IAAI,EAAE,IAAI;IACV,MAAM,EAAE,2BAA2B;IACnC,aAAa,EAAE;QACX,OAAO,EAAE,CAAC,iBAAiB,CAAC;KAC/B;IACD,OAAO,EAAE,CAAC,oBAAoB,EAAE,gBAAgB,CAA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AClC,6CAA6C,EAAE,OAAO;QAEtD,oDAAoD;QACpD,sCAAsC,EAAE,CAAC,OAAO,EAAE,EAAC,KAAK,EAAE,CAAC,gBAAgB,CAAC,EAAC,CAAC;QAE9E,uBAAuB;QACvB,+CAA+C,EAAE,OAAO;QAExD,kGAAkG;QAClG,kDAAkD;QAClD,wCAAwC,EAAE;YACtC,OAAO;YACP;gBACI,gBAAgB,EAAE;oBACd,UAAU,EAAE,KAAK;iBACpB;aACJ;SACJ;QAED,yGAAyG;QACzG,yCAAyC,EAAE,CAAC,OAAO,CAAC;KACvD;IACD,OAAO,EAAE;QACL,oBAAoB;QACpB,0BAA0B;QAC1B,gCAAgC;QAChC,uCAAuC;QACvC,+DAA+D;QAC/D,UAAU;QACV,0BAA0B;QAC1B,sBAAsB;QACtB,wBAAwB;KAC3B;CACJ,CAAC"}
|
|
@@ -6,7 +6,7 @@ const stdinBuffer = fs.readFileSync(0);
|
|
|
6
6
|
import { Project, VariableDeclarationKind, Writers, } from "ts-morph";
|
|
7
7
|
const schema = JSON.parse(stdinBuffer.toString("utf8"));
|
|
8
8
|
const project = new Project();
|
|
9
|
-
const
|
|
9
|
+
const statemenets = [];
|
|
10
10
|
const { urls, templates, types, values } = schema;
|
|
11
11
|
for (const name of Object.keys(values)) {
|
|
12
12
|
// Top level constants are deprecated.
|
|
@@ -14,7 +14,7 @@ for (const name of Object.keys(values)) {
|
|
|
14
14
|
if (name.includes(".")) {
|
|
15
15
|
continue;
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
statemenets.push({
|
|
18
18
|
declarationKind: VariableDeclarationKind.Const,
|
|
19
19
|
isExported: true,
|
|
20
20
|
declarations: [
|
|
@@ -25,7 +25,7 @@ for (const name of Object.keys(values)) {
|
|
|
25
25
|
],
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
statemenets.push({
|
|
29
29
|
declarationKind: VariableDeclarationKind.Const,
|
|
30
30
|
isExported: true,
|
|
31
31
|
declarations: [
|
|
@@ -35,5 +35,7 @@ interfaces.addVariableStatement({
|
|
|
35
35
|
},
|
|
36
36
|
],
|
|
37
37
|
});
|
|
38
|
-
|
|
38
|
+
const constantsSource = project.createSourceFile("");
|
|
39
|
+
constantsSource.addVariableStatements(statemenets);
|
|
40
|
+
process.stdout.write(constantsSource.getText());
|
|
39
41
|
//# sourceMappingURL=constants.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../../src/generator/constants.mts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,wDAAwD;AACxD,qEAAqE;AACrE,MAAM,WAAW,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;AAEvC,OAAO,EACH,OAAO,EAIP,uBAAuB,EAEvB,OAAO,GACV,MAAM,UAAU,CAAC;AAElB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;AAExD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,MAAM,
|
|
1
|
+
{"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../../src/generator/constants.mts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,wDAAwD;AACxD,qEAAqE;AACrE,MAAM,WAAW,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;AAEvC,OAAO,EACH,OAAO,EAIP,uBAAuB,EAEvB,OAAO,GACV,MAAM,UAAU,CAAC;AAElB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;AAExD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,MAAM,WAAW,GAAG,EAAE,CAAC;AAEvB,MAAM,EAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAC,GAAG,MAAM,CAAC;AAEhD,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;IACpC,sCAAsC;IACtC,+DAA+D;IAC/D,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACpB,SAAS;KACZ;IAED,WAAW,CAAC,IAAI,CAAC;QACb,eAAe,EAAE,uBAAuB,CAAC,KAAK;QAC9C,UAAU,EAAE,IAAI;QAChB,YAAY,EAAE;YACV;gBACI,IAAI;gBACJ,WAAW,EAAE,OAAO,CAAC,SAAS,CAC1B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EACrC,OAAO,CACV;aACJ;SACJ;KACJ,CAAC,CAAC;CACN;AAED,WAAW,CAAC,IAAI,CAAC;IACb,eAAe,EAAE,uBAAuB,CAAC,KAAK;IAC9C,UAAU,EAAE,IAAI;IAChB,YAAY,EAAE;QACV;YACI,IAAI,EAAE,WAAW;YACjB,WAAW,EAAE,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC;SAC3E;KACJ;CACJ,CAAC,CAAC;AAEH,MAAM,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;AACrD,eAAe,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC;AAEnD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC,CAAC"}
|
package/dist/generator.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import fs from "fs";
|
|
|
4
4
|
// json-schema-to-typescript messes up the descriptor even if unused.
|
|
5
5
|
const stdinBuffer = fs.readFileSync(0);
|
|
6
6
|
const { compile } = await import("json-schema-to-typescript");
|
|
7
|
-
import { Project, Scope, VariableDeclarationKind, Writers, } from "ts-morph";
|
|
7
|
+
import { Project, Scope, StructureKind, VariableDeclarationKind, Writers, } from "ts-morph";
|
|
8
8
|
const schema = JSON.parse(stdinBuffer.toString("utf8"));
|
|
9
9
|
const { urls: possibleEmptyUrls, templates, interfaces, rpc: uncastedRpc, types, values, } = schema;
|
|
10
10
|
const rpc = uncastedRpc;
|
|
@@ -23,22 +23,53 @@ const urls = {
|
|
|
23
23
|
};
|
|
24
24
|
const project = new Project();
|
|
25
25
|
const sourceFile = project.createSourceFile("");
|
|
26
|
-
const
|
|
26
|
+
const rpcConstructorStructure = {
|
|
27
|
+
statements: [],
|
|
28
|
+
parameters: [
|
|
29
|
+
{
|
|
30
|
+
name: "requester",
|
|
31
|
+
type: "rpcUtils.Requester",
|
|
32
|
+
isReadonly: false,
|
|
33
|
+
scope: Scope.Public,
|
|
34
|
+
decorators: [],
|
|
35
|
+
hasQuestionToken: false,
|
|
36
|
+
hasOverrideKeyword: false,
|
|
37
|
+
kind: StructureKind.Parameter,
|
|
38
|
+
isRestParameter: false,
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
typeParameters: [],
|
|
42
|
+
docs: [],
|
|
43
|
+
kind: StructureKind.Constructor,
|
|
44
|
+
overloads: [],
|
|
45
|
+
};
|
|
46
|
+
const rpcStructure = {
|
|
47
|
+
decorators: [],
|
|
48
|
+
typeParameters: [],
|
|
49
|
+
docs: [],
|
|
50
|
+
isAbstract: false,
|
|
51
|
+
implements: [],
|
|
27
52
|
name: "RPC",
|
|
28
53
|
isExported: true,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
54
|
+
isDefaultExport: false,
|
|
55
|
+
hasDeclareKeyword: false,
|
|
56
|
+
kind: StructureKind.Class,
|
|
57
|
+
ctors: [rpcConstructorStructure],
|
|
58
|
+
properties: [],
|
|
59
|
+
methods: [],
|
|
60
|
+
};
|
|
34
61
|
for (const name of Object.keys(rpc)) {
|
|
35
62
|
const { url, input, output, type, params } = rpc[name];
|
|
36
|
-
const
|
|
63
|
+
const methodStructure = {
|
|
64
|
+
kind: StructureKind.Method,
|
|
37
65
|
name,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
66
|
+
isAsync: true,
|
|
67
|
+
parameters: [],
|
|
68
|
+
statements: [],
|
|
69
|
+
returnType: "",
|
|
70
|
+
};
|
|
71
|
+
rpcConstructorStructure.statements.push(`this.${name} = (this.${name} as any).bind(this);\n`);
|
|
72
|
+
methodStructure.parameters?.push({
|
|
42
73
|
name: "this",
|
|
43
74
|
type: "void",
|
|
44
75
|
});
|
|
@@ -48,17 +79,21 @@ for (const name of Object.keys(rpc)) {
|
|
|
48
79
|
name: (writer) => writer.quote(name),
|
|
49
80
|
};
|
|
50
81
|
if (params.length >= 1) {
|
|
51
|
-
const
|
|
52
|
-
name: "WILL_BE_STRIPPED",
|
|
53
|
-
});
|
|
82
|
+
const paramsProperties = [];
|
|
54
83
|
const iterator = [];
|
|
55
84
|
for (const [paramType, paramName] of params) {
|
|
56
|
-
|
|
85
|
+
paramsProperties.push({ name: paramName, type: "string | number" });
|
|
57
86
|
iterator.push(paramName);
|
|
58
87
|
}
|
|
59
|
-
|
|
88
|
+
methodStructure.parameters?.push({
|
|
60
89
|
name: "params",
|
|
61
|
-
type:
|
|
90
|
+
type: Writers.objectType({ properties: paramsProperties }),
|
|
91
|
+
isReadonly: false,
|
|
92
|
+
decorators: [],
|
|
93
|
+
hasQuestionToken: false,
|
|
94
|
+
hasOverrideKeyword: false,
|
|
95
|
+
kind: StructureKind.Parameter,
|
|
96
|
+
isRestParameter: false,
|
|
62
97
|
});
|
|
63
98
|
Object.assign(initializer, {
|
|
64
99
|
paramsAndIterator: Writers.object({
|
|
@@ -66,24 +101,21 @@ for (const name of Object.keys(rpc)) {
|
|
|
66
101
|
params: "params",
|
|
67
102
|
}),
|
|
68
103
|
});
|
|
69
|
-
// Otherwise our interface will be inserted.
|
|
70
|
-
functionDeclaration.setBodyText("");
|
|
71
104
|
}
|
|
72
105
|
else {
|
|
73
106
|
Object.assign(initializer, { paramsAndIterator: "null" });
|
|
74
107
|
}
|
|
75
108
|
if (input != null) {
|
|
76
|
-
|
|
77
|
-
// isStatic: true,
|
|
109
|
+
rpcStructure.properties?.push({
|
|
78
110
|
name: input,
|
|
79
111
|
type: `_Types["${input}"]`,
|
|
80
112
|
initializer: JSON.stringify(values[input]),
|
|
81
113
|
});
|
|
82
|
-
|
|
114
|
+
methodStructure.parameters?.push({
|
|
83
115
|
name: "input",
|
|
84
116
|
type: `forms.FormOrFormSetValues<_Types["${input}"]>`,
|
|
85
117
|
});
|
|
86
|
-
|
|
118
|
+
methodStructure.returnType = `Promise<rpcUtils.Result<_Types["${output}"], forms.FormOrFormSetErrors<_Types["${input}"]>, _Types["RPCPermission"]>>`;
|
|
87
119
|
Object.assign(initializer, {
|
|
88
120
|
input: Writers.object({
|
|
89
121
|
values: "input",
|
|
@@ -92,67 +124,23 @@ for (const name of Object.keys(rpc)) {
|
|
|
92
124
|
});
|
|
93
125
|
}
|
|
94
126
|
else {
|
|
95
|
-
|
|
127
|
+
methodStructure.returnType = `Promise<rpcUtils.Result<_Types["${output}"], null, _Types["RPCPermission"]>>`;
|
|
96
128
|
Object.assign(initializer, { input: "null" });
|
|
97
129
|
}
|
|
98
|
-
|
|
130
|
+
methodStructure.statements?.push({
|
|
131
|
+
kind: StructureKind.VariableStatement,
|
|
99
132
|
declarationKind: VariableDeclarationKind.Const,
|
|
100
133
|
declarations: [
|
|
101
134
|
{
|
|
102
135
|
name: "options",
|
|
103
136
|
initializer: Writers.object(initializer),
|
|
104
|
-
/*
|
|
105
|
-
x: 123,
|
|
106
|
-
y: (writer) => writer.quote("abc"),
|
|
107
|
-
z: Writers.object({
|
|
108
|
-
one: (writer) => writer.quote("1"),
|
|
109
|
-
}),
|
|
110
|
-
*/
|
|
111
137
|
},
|
|
112
138
|
],
|
|
113
139
|
});
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (input != null) {
|
|
118
|
-
functionDeclaration.addParameter({
|
|
119
|
-
name: "input",
|
|
120
|
-
type: `forms.FormOrFormSetValues<_Types["${input}"]>`,
|
|
121
|
-
});
|
|
122
|
-
bodyText = bodyText.concat(`
|
|
123
|
-
const input = ${JSON.stringify({
|
|
124
|
-
type: "form",
|
|
125
|
-
})};
|
|
126
|
-
}
|
|
127
|
-
`);
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
}
|
|
131
|
-
*/
|
|
132
|
-
/*
|
|
133
|
-
if (instance.length === 1) {
|
|
134
|
-
functionDeclaration.addParameter({name: "instance", type: `string | number`});
|
|
135
|
-
functionDeclaration.setBodyText(`return rpcUtils.rpcCall("${url}", input, "${type}", instance)`);
|
|
136
|
-
}
|
|
137
|
-
else if (instance.length >= 2) {
|
|
138
|
-
const instanceInterface = functionDeclaration.addInterface({name: "WILL_BE_STRIPPED"});
|
|
139
|
-
|
|
140
|
-
for (const instanceArg of instance) {
|
|
141
|
-
instanceInterface.addProperty({name: instanceArg, type: "string | number"});
|
|
142
|
-
}
|
|
143
|
-
functionDeclaration.addParameter({name: "instance", type: instanceInterface.getText().replace("interface WILL_BE_STRIPPED", "")});
|
|
144
|
-
functionDeclaration.setBodyText(`const iterator = ${JSON.stringify(instance)}; return rpcUtils.rpcCall("${url}", input, "${type}", {iterator, params: instance})`);
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
functionDeclaration.setBodyText(`return rpcUtils.rpcCall("${url}", input, "${type}")`);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
functionDeclaration.addParameter({name: "input", type: `forms.FormOrFormSetValues<_Types["${input}"]>`});
|
|
151
|
-
functionDeclaration.setReturnType(`Promise<rpcUtils.Result<_Types["${output}"], forms.FormOrFormSetErrors<_Types["${input}"]>>>`);
|
|
152
|
-
functionDeclaration.setIsAsync(true);
|
|
153
|
-
*/
|
|
140
|
+
methodStructure.statements?.push("return rpcUtils.rpcCall((this as any).requester, options)");
|
|
141
|
+
rpcStructure.methods?.push(methodStructure);
|
|
154
142
|
}
|
|
155
|
-
|
|
143
|
+
sourceFile.addClass(rpcStructure);
|
|
156
144
|
if (Object.keys(urls).length !== 0) {
|
|
157
145
|
sourceFile.addVariableStatement({
|
|
158
146
|
declarationKind: VariableDeclarationKind.Const,
|
|
@@ -163,33 +151,34 @@ if (Object.keys(urls).length !== 0) {
|
|
|
163
151
|
},
|
|
164
152
|
],
|
|
165
153
|
});
|
|
166
|
-
const urlMap =
|
|
154
|
+
const urlMap = {
|
|
167
155
|
name: "URLMap",
|
|
168
|
-
|
|
169
|
-
|
|
156
|
+
properties: [],
|
|
157
|
+
// isExported: true,
|
|
158
|
+
};
|
|
170
159
|
const withArguments = [""];
|
|
171
160
|
const withoutArguments = [""];
|
|
161
|
+
const interfaces = [urlMap];
|
|
172
162
|
for (const name of Object.keys(urls)) {
|
|
173
163
|
const properties = urls[name].args;
|
|
174
164
|
const normalizedName = name.replace(/[^\w]/g, "_");
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
name:
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
urlMap.addProperty({
|
|
165
|
+
interfaces.push(...[
|
|
166
|
+
{
|
|
167
|
+
name: normalizedName,
|
|
168
|
+
properties: [
|
|
169
|
+
{ name: "name", type: `'${name}'` },
|
|
170
|
+
{ name: "args", type: `${normalizedName}_args` },
|
|
171
|
+
],
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
name: `${normalizedName}_args`,
|
|
175
|
+
properties: Object.keys(properties).map((propertyName) => ({
|
|
176
|
+
name: propertyName,
|
|
177
|
+
type: properties[propertyName],
|
|
178
|
+
})),
|
|
179
|
+
},
|
|
180
|
+
]);
|
|
181
|
+
urlMap.properties.push({
|
|
193
182
|
name: normalizedName,
|
|
194
183
|
type: normalizedName,
|
|
195
184
|
});
|
|
@@ -200,6 +189,7 @@ if (Object.keys(urls).length !== 0) {
|
|
|
200
189
|
withArguments.push(normalizedName);
|
|
201
190
|
}
|
|
202
191
|
}
|
|
192
|
+
sourceFile.addInterfaces(interfaces);
|
|
203
193
|
sourceFile.addTypeAlias({ name: "WithArguments", type: withArguments.join("|") });
|
|
204
194
|
sourceFile.addTypeAlias({
|
|
205
195
|
name: "WithoutArguments",
|
|
@@ -232,6 +222,10 @@ import * as rpcUtils from "reactivated/dist/rpc";
|
|
|
232
222
|
import {constants} from "./constants";
|
|
233
223
|
export {constants};
|
|
234
224
|
|
|
225
|
+
export function classNames(...classes: (string | undefined | null)[]) {
|
|
226
|
+
return classes.filter(Boolean).join(" ");
|
|
227
|
+
}
|
|
228
|
+
|
|
235
229
|
// Note: this needs strict function types to behave correctly with excess properties etc.
|
|
236
230
|
export type Checker<P, U extends (React.FunctionComponent<P> | React.ComponentClass<P>)> = {};
|
|
237
231
|
|
|
@@ -264,10 +258,11 @@ export const {Form, FormSet, Widget, useForm, useFormSet, ManagementForm} = form
|
|
|
264
258
|
compile(types, "this is unused").then((ts) => {
|
|
265
259
|
process.stdout.write("/* eslint-disable */\n");
|
|
266
260
|
process.stdout.write(ts);
|
|
261
|
+
const statements = [];
|
|
267
262
|
if (!fs.existsSync("./reactivated-skip-template-check")) {
|
|
268
263
|
for (const name of Object.keys(templates)) {
|
|
269
264
|
const propsName = templates[name];
|
|
270
|
-
|
|
265
|
+
statements.push(`
|
|
271
266
|
|
|
272
267
|
import ${name}Implementation from "@client/templates/${name}"
|
|
273
268
|
export type ${name}Check = Checker<_Types["${propsName}"], typeof ${name}Implementation>;
|
|
@@ -282,7 +277,7 @@ export namespace templates {
|
|
|
282
277
|
}
|
|
283
278
|
for (const name of Object.keys(interfaces)) {
|
|
284
279
|
const propsName = interfaces[name];
|
|
285
|
-
|
|
280
|
+
statements.push(`
|
|
286
281
|
|
|
287
282
|
export namespace interfaces {
|
|
288
283
|
export type ${name} = _Types["${propsName}"];
|
|
@@ -291,6 +286,7 @@ export namespace interfaces {
|
|
|
291
286
|
|
|
292
287
|
`);
|
|
293
288
|
}
|
|
289
|
+
sourceFile.addStatements(statements);
|
|
294
290
|
process.stdout.write(sourceFile.getText());
|
|
295
291
|
});
|
|
296
292
|
//# sourceMappingURL=generator.mjs.map
|
package/dist/generator.mjs.map
CHANGED
|
@@ -1 +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,EAEH,OAAO,EACP,KAAK,
|
|
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,EAEH,OAAO,EACP,KAAK,EAEL,aAAa,EAEb,uBAAuB,EAEvB,OAAO,GAQV,MAAM,UAAU,CAAC;AAElB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;AACxD,MAAM,EACF,IAAI,EAAE,iBAAiB,EACvB,SAAS,EACT,UAAU,EACV,GAAG,EAAE,WAAW,EAChB,KAAK,EACL,MAAM,GACT,GAAG,MAAM,CAAC;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|
|
|
1
1
|
{
|
|
2
2
|
"name": "reactivated",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0-a1885",
|
|
4
4
|
"description": "",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
@@ -25,14 +25,6 @@
|
|
|
25
25
|
},
|
|
26
26
|
"license": "ISC",
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@babel/core": "^7.21.8",
|
|
29
|
-
"@babel/preset-react": "^7.18.6",
|
|
30
|
-
"@babel/preset-typescript": "^7.21.5",
|
|
31
|
-
"@linaria/babel-preset": "^4.4.5",
|
|
32
|
-
"@linaria/core": "^4.2.10",
|
|
33
|
-
"@linaria/esbuild": "^4.2.11",
|
|
34
|
-
"@linaria/react": "^4.3.8",
|
|
35
|
-
"@linaria/shaker": "^4.2.11",
|
|
36
28
|
"@types/react": "^18.0.12",
|
|
37
29
|
"@types/react-dom": "^18.0.5",
|
|
38
30
|
"@typescript-eslint/eslint-plugin": "^5.59.6",
|
|
@@ -43,7 +35,6 @@
|
|
|
43
35
|
"@vanilla-extract/esbuild-plugin": "^2.2.2",
|
|
44
36
|
"@vanilla-extract/recipes": "^0.4.0",
|
|
45
37
|
"@vanilla-extract/sprinkles": "^1.6.0",
|
|
46
|
-
"babel-plugin-module-resolver": "^5.0.0",
|
|
47
38
|
"esbuild": "^0.17.19",
|
|
48
39
|
"esbuild-plugin-import-glob": "^0.1.1",
|
|
49
40
|
"eslint": "^8.40.0",
|
package/src/build.client.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import linaria from "./linaria.mjs";
|
|
4
3
|
import {vanillaExtractPlugin} from "@vanilla-extract/esbuild-plugin";
|
|
5
4
|
import * as esbuild from "esbuild";
|
|
6
5
|
import ImportGlobPlugin from "esbuild-plugin-import-glob";
|
|
@@ -63,7 +62,6 @@ esbuild
|
|
|
63
62
|
// Instead of set it manually instead of relying on minification
|
|
64
63
|
// settings.
|
|
65
64
|
vanillaExtractPlugin({identifiers}),
|
|
66
|
-
linaria({sourceMap: true, esbuildOptions: {sourcemap: "inline"}}),
|
|
67
65
|
],
|
|
68
66
|
})
|
|
69
67
|
.then(async (context) => {
|
package/src/build.renderer.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import linaria from "./linaria.mjs";
|
|
4
3
|
import {vanillaExtractPlugin} from "@vanilla-extract/esbuild-plugin";
|
|
5
4
|
import * as esbuild from "esbuild";
|
|
6
5
|
import ImportGlobPlugin from "esbuild-plugin-import-glob";
|
|
@@ -57,7 +56,6 @@ esbuild
|
|
|
57
56
|
// Instead of set it manually instead of relying on minification
|
|
58
57
|
// settings.
|
|
59
58
|
vanillaExtractPlugin({identifiers}),
|
|
60
|
-
linaria({sourceMap: true}),
|
|
61
59
|
{
|
|
62
60
|
name: "restartServer",
|
|
63
61
|
setup: (build) => {
|
package/src/eslintrc.tsx
CHANGED
|
@@ -20,7 +20,7 @@ const schema = JSON.parse(stdinBuffer.toString("utf8"));
|
|
|
20
20
|
|
|
21
21
|
const project = new Project();
|
|
22
22
|
|
|
23
|
-
const
|
|
23
|
+
const statemenets = [];
|
|
24
24
|
|
|
25
25
|
const {urls, templates, types, values} = schema;
|
|
26
26
|
|
|
@@ -31,7 +31,7 @@ for (const name of Object.keys(values)) {
|
|
|
31
31
|
continue;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
statemenets.push({
|
|
35
35
|
declarationKind: VariableDeclarationKind.Const,
|
|
36
36
|
isExported: true,
|
|
37
37
|
declarations: [
|
|
@@ -46,7 +46,7 @@ for (const name of Object.keys(values)) {
|
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
statemenets.push({
|
|
50
50
|
declarationKind: VariableDeclarationKind.Const,
|
|
51
51
|
isExported: true,
|
|
52
52
|
declarations: [
|
|
@@ -57,4 +57,7 @@ interfaces.addVariableStatement({
|
|
|
57
57
|
],
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
const constantsSource = project.createSourceFile("");
|
|
61
|
+
constantsSource.addVariableStatements(statemenets);
|
|
62
|
+
|
|
63
|
+
process.stdout.write(constantsSource.getText());
|
package/src/generator.mts
CHANGED
|
@@ -19,6 +19,13 @@ import {
|
|
|
19
19
|
VariableDeclarationKind,
|
|
20
20
|
WriterFunction,
|
|
21
21
|
Writers,
|
|
22
|
+
InterfaceDeclarationStructure,
|
|
23
|
+
OptionalKind,
|
|
24
|
+
MethodDeclarationStructure,
|
|
25
|
+
PropertyDeclarationStructure,
|
|
26
|
+
ParameterDeclarationStructure,
|
|
27
|
+
StatementedNodeStructure,
|
|
28
|
+
StatementStructures,
|
|
22
29
|
} from "ts-morph";
|
|
23
30
|
|
|
24
31
|
const schema = JSON.parse(stdinBuffer.toString("utf8"));
|
|
@@ -51,27 +58,60 @@ const project = new Project();
|
|
|
51
58
|
|
|
52
59
|
const sourceFile = project.createSourceFile("");
|
|
53
60
|
|
|
54
|
-
const
|
|
61
|
+
const rpcConstructorStructure = {
|
|
62
|
+
statements: [] as string[],
|
|
63
|
+
parameters: [
|
|
64
|
+
{
|
|
65
|
+
name: "requester",
|
|
66
|
+
type: "rpcUtils.Requester",
|
|
67
|
+
isReadonly: false,
|
|
68
|
+
scope: Scope.Public,
|
|
69
|
+
decorators: [],
|
|
70
|
+
hasQuestionToken: false,
|
|
71
|
+
hasOverrideKeyword: false,
|
|
72
|
+
kind: StructureKind.Parameter as const,
|
|
73
|
+
isRestParameter: false,
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
typeParameters: [],
|
|
77
|
+
docs: [],
|
|
78
|
+
kind: StructureKind.Constructor as const,
|
|
79
|
+
overloads: [],
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const rpcStructure = {
|
|
83
|
+
decorators: [],
|
|
84
|
+
typeParameters: [],
|
|
85
|
+
docs: [],
|
|
86
|
+
isAbstract: false,
|
|
87
|
+
implements: [],
|
|
55
88
|
name: "RPC",
|
|
56
89
|
isExported: true,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
90
|
+
isDefaultExport: false,
|
|
91
|
+
hasDeclareKeyword: false,
|
|
92
|
+
kind: StructureKind.Class as const,
|
|
93
|
+
ctors: [rpcConstructorStructure],
|
|
94
|
+
properties: [] as OptionalKind<PropertyDeclarationStructure>[],
|
|
95
|
+
methods: [] as OptionalKind<MethodDeclarationStructure>[],
|
|
96
|
+
};
|
|
64
97
|
|
|
65
98
|
for (const name of Object.keys(rpc)) {
|
|
66
99
|
const {url, input, output, type, params} = rpc[name];
|
|
67
|
-
|
|
100
|
+
|
|
101
|
+
const methodStructure = {
|
|
102
|
+
kind: StructureKind.Method as const,
|
|
68
103
|
name,
|
|
69
|
-
|
|
104
|
+
isAsync: true,
|
|
105
|
+
parameters: [] as OptionalKind<ParameterDeclarationStructure>[],
|
|
106
|
+
statements: [] as (string | StatementStructures)[],
|
|
107
|
+
returnType: "",
|
|
108
|
+
};
|
|
70
109
|
|
|
71
|
-
|
|
72
|
-
|
|
110
|
+
rpcConstructorStructure.statements.push(
|
|
111
|
+
`this.${name} = (this.${name} as any).bind(this);\n`,
|
|
112
|
+
);
|
|
73
113
|
|
|
74
|
-
|
|
114
|
+
methodStructure.parameters?.push({
|
|
75
115
|
name: "this",
|
|
76
116
|
type: "void",
|
|
77
117
|
});
|
|
@@ -83,18 +123,22 @@ for (const name of Object.keys(rpc)) {
|
|
|
83
123
|
};
|
|
84
124
|
|
|
85
125
|
if (params.length >= 1) {
|
|
86
|
-
const
|
|
87
|
-
name: "WILL_BE_STRIPPED",
|
|
88
|
-
});
|
|
126
|
+
const paramsProperties = [];
|
|
89
127
|
|
|
90
128
|
const iterator = [];
|
|
91
129
|
for (const [paramType, paramName] of params) {
|
|
92
|
-
|
|
130
|
+
paramsProperties.push({name: paramName, type: "string | number"});
|
|
93
131
|
iterator.push(paramName);
|
|
94
132
|
}
|
|
95
|
-
|
|
133
|
+
methodStructure.parameters?.push({
|
|
96
134
|
name: "params",
|
|
97
|
-
type:
|
|
135
|
+
type: Writers.objectType({properties: paramsProperties}),
|
|
136
|
+
isReadonly: false,
|
|
137
|
+
decorators: [],
|
|
138
|
+
hasQuestionToken: false,
|
|
139
|
+
hasOverrideKeyword: false,
|
|
140
|
+
kind: StructureKind.Parameter as const,
|
|
141
|
+
isRestParameter: false,
|
|
98
142
|
});
|
|
99
143
|
|
|
100
144
|
Object.assign(initializer, {
|
|
@@ -103,26 +147,23 @@ for (const name of Object.keys(rpc)) {
|
|
|
103
147
|
params: "params",
|
|
104
148
|
}),
|
|
105
149
|
});
|
|
106
|
-
// Otherwise our interface will be inserted.
|
|
107
|
-
functionDeclaration.setBodyText("");
|
|
108
150
|
} else {
|
|
109
151
|
Object.assign(initializer, {paramsAndIterator: "null"});
|
|
110
152
|
}
|
|
111
153
|
|
|
112
154
|
if (input != null) {
|
|
113
|
-
|
|
114
|
-
// isStatic: true,
|
|
155
|
+
rpcStructure.properties?.push({
|
|
115
156
|
name: input,
|
|
116
157
|
type: `_Types["${input}"]`,
|
|
117
158
|
initializer: JSON.stringify(values[input]),
|
|
118
159
|
});
|
|
119
|
-
|
|
160
|
+
methodStructure.parameters?.push({
|
|
120
161
|
name: "input",
|
|
121
162
|
type: `forms.FormOrFormSetValues<_Types["${input}"]>`,
|
|
122
163
|
});
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
164
|
+
|
|
165
|
+
methodStructure.returnType = `Promise<rpcUtils.Result<_Types["${output}"], forms.FormOrFormSetErrors<_Types["${input}"]>, _Types["RPCPermission"]>>`;
|
|
166
|
+
|
|
126
167
|
Object.assign(initializer, {
|
|
127
168
|
input: Writers.object({
|
|
128
169
|
values: "input",
|
|
@@ -131,73 +172,27 @@ for (const name of Object.keys(rpc)) {
|
|
|
131
172
|
}),
|
|
132
173
|
});
|
|
133
174
|
} else {
|
|
134
|
-
|
|
135
|
-
`Promise<rpcUtils.Result<_Types["${output}"], null, _Types["RPCPermission"]>>`,
|
|
136
|
-
);
|
|
175
|
+
methodStructure.returnType = `Promise<rpcUtils.Result<_Types["${output}"], null, _Types["RPCPermission"]>>`;
|
|
137
176
|
Object.assign(initializer, {input: "null"});
|
|
138
177
|
}
|
|
139
178
|
|
|
140
|
-
|
|
179
|
+
methodStructure.statements?.push({
|
|
180
|
+
kind: StructureKind.VariableStatement,
|
|
141
181
|
declarationKind: VariableDeclarationKind.Const,
|
|
142
182
|
declarations: [
|
|
143
183
|
{
|
|
144
184
|
name: "options",
|
|
145
185
|
initializer: Writers.object(initializer),
|
|
146
|
-
/*
|
|
147
|
-
x: 123,
|
|
148
|
-
y: (writer) => writer.quote("abc"),
|
|
149
|
-
z: Writers.object({
|
|
150
|
-
one: (writer) => writer.quote("1"),
|
|
151
|
-
}),
|
|
152
|
-
*/
|
|
153
186
|
},
|
|
154
187
|
],
|
|
155
188
|
});
|
|
156
|
-
|
|
157
|
-
|
|
189
|
+
methodStructure.statements?.push(
|
|
190
|
+
"return rpcUtils.rpcCall((this as any).requester, options)",
|
|
158
191
|
);
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
if (input != null) {
|
|
162
|
-
functionDeclaration.addParameter({
|
|
163
|
-
name: "input",
|
|
164
|
-
type: `forms.FormOrFormSetValues<_Types["${input}"]>`,
|
|
165
|
-
});
|
|
166
|
-
bodyText = bodyText.concat(`
|
|
167
|
-
const input = ${JSON.stringify({
|
|
168
|
-
type: "form",
|
|
169
|
-
})};
|
|
170
|
-
}
|
|
171
|
-
`);
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
}
|
|
175
|
-
*/
|
|
176
|
-
|
|
177
|
-
/*
|
|
178
|
-
if (instance.length === 1) {
|
|
179
|
-
functionDeclaration.addParameter({name: "instance", type: `string | number`});
|
|
180
|
-
functionDeclaration.setBodyText(`return rpcUtils.rpcCall("${url}", input, "${type}", instance)`);
|
|
181
|
-
}
|
|
182
|
-
else if (instance.length >= 2) {
|
|
183
|
-
const instanceInterface = functionDeclaration.addInterface({name: "WILL_BE_STRIPPED"});
|
|
184
|
-
|
|
185
|
-
for (const instanceArg of instance) {
|
|
186
|
-
instanceInterface.addProperty({name: instanceArg, type: "string | number"});
|
|
187
|
-
}
|
|
188
|
-
functionDeclaration.addParameter({name: "instance", type: instanceInterface.getText().replace("interface WILL_BE_STRIPPED", "")});
|
|
189
|
-
functionDeclaration.setBodyText(`const iterator = ${JSON.stringify(instance)}; return rpcUtils.rpcCall("${url}", input, "${type}", {iterator, params: instance})`);
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
functionDeclaration.setBodyText(`return rpcUtils.rpcCall("${url}", input, "${type}")`);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
functionDeclaration.addParameter({name: "input", type: `forms.FormOrFormSetValues<_Types["${input}"]>`});
|
|
196
|
-
functionDeclaration.setReturnType(`Promise<rpcUtils.Result<_Types["${output}"], forms.FormOrFormSetErrors<_Types["${input}"]>>>`);
|
|
197
|
-
functionDeclaration.setIsAsync(true);
|
|
198
|
-
*/
|
|
192
|
+
rpcStructure.methods?.push(methodStructure);
|
|
199
193
|
}
|
|
200
|
-
|
|
194
|
+
|
|
195
|
+
sourceFile.addClass(rpcStructure);
|
|
201
196
|
|
|
202
197
|
if (Object.keys(urls).length !== 0) {
|
|
203
198
|
sourceFile.addVariableStatement({
|
|
@@ -210,38 +205,43 @@ if (Object.keys(urls).length !== 0) {
|
|
|
210
205
|
],
|
|
211
206
|
});
|
|
212
207
|
|
|
213
|
-
const urlMap =
|
|
208
|
+
const urlMap = {
|
|
214
209
|
name: "URLMap",
|
|
215
|
-
|
|
216
|
-
|
|
210
|
+
properties: [] as any,
|
|
211
|
+
// isExported: true,
|
|
212
|
+
};
|
|
217
213
|
|
|
218
214
|
const withArguments = [""];
|
|
215
|
+
|
|
219
216
|
const withoutArguments = [""];
|
|
220
217
|
|
|
218
|
+
const interfaces: OptionalKind<InterfaceDeclarationStructure>[] = [urlMap];
|
|
219
|
+
|
|
221
220
|
for (const name of Object.keys(urls)) {
|
|
222
221
|
const properties = urls[name as keyof typeof urls].args;
|
|
223
222
|
const normalizedName = name.replace(/[^\w]/g, "_");
|
|
224
223
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
224
|
+
interfaces.push(
|
|
225
|
+
...[
|
|
226
|
+
{
|
|
227
|
+
name: normalizedName,
|
|
228
|
+
properties: [
|
|
229
|
+
{name: "name", type: `'${name}'`},
|
|
230
|
+
{name: "args", type: `${normalizedName}_args`},
|
|
231
|
+
],
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
name: `${normalizedName}_args`,
|
|
235
|
+
|
|
236
|
+
properties: Object.keys(properties).map((propertyName) => ({
|
|
237
|
+
name: propertyName,
|
|
238
|
+
type: properties[propertyName as keyof typeof properties],
|
|
239
|
+
})),
|
|
240
|
+
},
|
|
241
|
+
],
|
|
242
|
+
);
|
|
243
243
|
|
|
244
|
-
urlMap.
|
|
244
|
+
urlMap.properties.push({
|
|
245
245
|
name: normalizedName,
|
|
246
246
|
type: normalizedName,
|
|
247
247
|
});
|
|
@@ -252,6 +252,7 @@ if (Object.keys(urls).length !== 0) {
|
|
|
252
252
|
withArguments.push(normalizedName);
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
|
+
sourceFile.addInterfaces(interfaces);
|
|
255
256
|
sourceFile.addTypeAlias({name: "WithArguments", type: withArguments.join("|")});
|
|
256
257
|
sourceFile.addTypeAlias({
|
|
257
258
|
name: "WithoutArguments",
|
|
@@ -288,6 +289,10 @@ import * as rpcUtils from "reactivated/dist/rpc";
|
|
|
288
289
|
import {constants} from "./constants";
|
|
289
290
|
export {constants};
|
|
290
291
|
|
|
292
|
+
export function classNames(...classes: (string | undefined | null)[]) {
|
|
293
|
+
return classes.filter(Boolean).join(" ");
|
|
294
|
+
}
|
|
295
|
+
|
|
291
296
|
// Note: this needs strict function types to behave correctly with excess properties etc.
|
|
292
297
|
export type Checker<P, U extends (React.FunctionComponent<P> | React.ComponentClass<P>)> = {};
|
|
293
298
|
|
|
@@ -321,12 +326,13 @@ export const {Form, FormSet, Widget, useForm, useFormSet, ManagementForm} = form
|
|
|
321
326
|
compile(types, "this is unused").then((ts) => {
|
|
322
327
|
process.stdout.write("/* eslint-disable */\n");
|
|
323
328
|
process.stdout.write(ts);
|
|
329
|
+
const statements = [];
|
|
324
330
|
|
|
325
331
|
if (!fs.existsSync("./reactivated-skip-template-check")) {
|
|
326
332
|
for (const name of Object.keys(templates)) {
|
|
327
333
|
const propsName = templates[name];
|
|
328
334
|
|
|
329
|
-
|
|
335
|
+
statements.push(`
|
|
330
336
|
|
|
331
337
|
import ${name}Implementation from "@client/templates/${name}"
|
|
332
338
|
export type ${name}Check = Checker<_Types["${propsName}"], typeof ${name}Implementation>;
|
|
@@ -342,7 +348,7 @@ export namespace templates {
|
|
|
342
348
|
|
|
343
349
|
for (const name of Object.keys(interfaces)) {
|
|
344
350
|
const propsName = interfaces[name];
|
|
345
|
-
|
|
351
|
+
statements.push(`
|
|
346
352
|
|
|
347
353
|
export namespace interfaces {
|
|
348
354
|
export type ${name} = _Types["${propsName}"];
|
|
@@ -352,5 +358,7 @@ export namespace interfaces {
|
|
|
352
358
|
`);
|
|
353
359
|
}
|
|
354
360
|
|
|
361
|
+
sourceFile.addStatements(statements);
|
|
362
|
+
|
|
355
363
|
process.stdout.write(sourceFile.getText());
|
|
356
364
|
});
|
package/dist/linaria.d.mts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file contains an esbuild loader for Linaria.
|
|
3
|
-
* It uses the transform.ts function to generate class names from source code,
|
|
4
|
-
* returns transformed code without template literals and attaches generated source maps
|
|
5
|
-
*/
|
|
6
|
-
import type { Plugin, TransformOptions } from "esbuild";
|
|
7
|
-
import type { PluginOptions, Preprocessor } from "@linaria/babel-preset";
|
|
8
|
-
type EsbuildPluginOptions = {
|
|
9
|
-
sourceMap?: boolean;
|
|
10
|
-
preprocessor?: Preprocessor;
|
|
11
|
-
esbuildOptions?: TransformOptions;
|
|
12
|
-
} & Partial<PluginOptions>;
|
|
13
|
-
export default function linaria({ sourceMap, preprocessor, esbuildOptions, ...rest }?: EsbuildPluginOptions): Plugin;
|
|
14
|
-
export {};
|
package/dist/linaria.mjs
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file contains an esbuild loader for Linaria.
|
|
3
|
-
* It uses the transform.ts function to generate class names from source code,
|
|
4
|
-
* returns transformed code without template literals and attaches generated source maps
|
|
5
|
-
*/
|
|
6
|
-
import fs from "fs";
|
|
7
|
-
import path from "path";
|
|
8
|
-
import { transformSync } from "esbuild";
|
|
9
|
-
import { slugify, transform } from "@linaria/babel-preset";
|
|
10
|
-
const nodeModulesRegex = /^(?:.*[\\/])?node_modules(?:[\\/].*)?$/;
|
|
11
|
-
export default function linaria({ sourceMap, preprocessor, esbuildOptions, ...rest } = {}) {
|
|
12
|
-
let options = esbuildOptions;
|
|
13
|
-
return {
|
|
14
|
-
name: "linaria",
|
|
15
|
-
setup(build) {
|
|
16
|
-
const cssLookup = new Map();
|
|
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, {
|
|
22
|
-
kind: "entry-point",
|
|
23
|
-
resolveDir: context,
|
|
24
|
-
});
|
|
25
|
-
if (result.errors.length > 0) {
|
|
26
|
-
throw new Error(`Cannot resolve ${token}`);
|
|
27
|
-
}
|
|
28
|
-
return result.path;
|
|
29
|
-
};
|
|
30
|
-
build.onResolve({ filter: /\.linaria\.css$/ }, (args) => {
|
|
31
|
-
return {
|
|
32
|
-
namespace: "linaria",
|
|
33
|
-
path: args.path,
|
|
34
|
-
};
|
|
35
|
-
});
|
|
36
|
-
build.onLoad({ filter: /.*/, namespace: "linaria" }, (args) => {
|
|
37
|
-
return {
|
|
38
|
-
contents: cssLookup.get(args.path),
|
|
39
|
-
loader: "css",
|
|
40
|
-
resolveDir: path.basename(args.path),
|
|
41
|
-
};
|
|
42
|
-
});
|
|
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);
|
|
46
|
-
const loader = ext.replace(/^\./, "");
|
|
47
|
-
if (nodeModulesRegex.test(args.path)) {
|
|
48
|
-
return {
|
|
49
|
-
loader,
|
|
50
|
-
contents: rawCode,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
if (!options) {
|
|
54
|
-
options = {};
|
|
55
|
-
if ("jsxFactory" in build.initialOptions) {
|
|
56
|
-
options.jsxFactory = build.initialOptions.jsxFactory;
|
|
57
|
-
}
|
|
58
|
-
if ("jsxFragment" in build.initialOptions) {
|
|
59
|
-
options.jsxFragment = build.initialOptions.jsxFragment;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
const transformed = transformSync(rawCode, {
|
|
63
|
-
...options,
|
|
64
|
-
sourcefile: args.path,
|
|
65
|
-
sourcemap: sourceMap,
|
|
66
|
-
loader,
|
|
67
|
-
});
|
|
68
|
-
let { code } = transformed;
|
|
69
|
-
if (sourceMap) {
|
|
70
|
-
const esbuildMap = Buffer.from(transformed.map).toString("base64");
|
|
71
|
-
code += `/*# sourceMappingURL=data:application/json;base64,${esbuildMap}*/`;
|
|
72
|
-
}
|
|
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, {
|
|
91
|
-
filename: args.path,
|
|
92
|
-
preprocessor,
|
|
93
|
-
pluginOptions: { ...rest, babelOptions },
|
|
94
|
-
}, asyncResolve);
|
|
95
|
-
if (!result.cssText) {
|
|
96
|
-
return {
|
|
97
|
-
contents: code,
|
|
98
|
-
loader,
|
|
99
|
-
resolveDir: path.dirname(args.path),
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
let { cssText } = result;
|
|
103
|
-
const slug = slugify(cssText);
|
|
104
|
-
const cssFilename = `${filename}_${slug}.linaria.css`;
|
|
105
|
-
let contents = `import ${JSON.stringify(cssFilename)}; ${result.code}`;
|
|
106
|
-
if (sourceMap && result.cssSourceMapText) {
|
|
107
|
-
const map = Buffer.from(result.cssSourceMapText).toString("base64");
|
|
108
|
-
cssText += `/*# sourceMappingURL=data:application/json;base64,${map}*/`;
|
|
109
|
-
const linariaMap = Buffer.from(JSON.stringify(result.sourceMap)).toString("base64");
|
|
110
|
-
contents += `/*# sourceMappingURL=data:application/json;base64,${linariaMap}*/`;
|
|
111
|
-
}
|
|
112
|
-
cssLookup.set(cssFilename, cssText);
|
|
113
|
-
return {
|
|
114
|
-
contents,
|
|
115
|
-
loader,
|
|
116
|
-
resolveDir: path.dirname(args.path),
|
|
117
|
-
};
|
|
118
|
-
});
|
|
119
|
-
},
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
//# sourceMappingURL=linaria.mjs.map
|
package/dist/linaria.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"linaria.mjs","sourceRoot":"","sources":["../src/linaria.mts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAC,aAAa,EAAC,MAAM,SAAS,CAAC;AAGtC,OAAO,EAAC,OAAO,EAAE,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAQzD,MAAM,gBAAgB,GAAG,wCAAwC,CAAC;AAElE,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EAC5B,SAAS,EACT,YAAY,EACZ,cAAc,EACd,GAAG,IAAI,KACe,EAAE;IACxB,IAAI,OAAO,GAAG,cAAc,CAAC;IAC7B,OAAO;QACH,IAAI,EAAE,SAAS;QACf,KAAK,CAAC,KAAK;YACP,MAAM,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;YAE5C,MAAM,YAAY,GAAG,KAAK,EACtB,KAAa,EACb,QAAgB,EACD,EAAE;gBACjB,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;oBACrC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;oBACxB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAEvD,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE;oBACtC,IAAI,EAAE,aAAa;oBACnB,UAAU,EAAE,OAAO;iBACtB,CAAC,CAAC;gBAEH,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;oBAC1B,MAAM,IAAI,KAAK,CAAC,kBAAkB,KAAK,EAAE,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QAAQ,EAAE,IAAI;wBACd,MAAM;wBACN,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;qBACtC,CAAC;iBACL;gBAED,IAAI,EAAC,OAAO,EAAC,GAAG,MAAM,CAAC;gBAEvB,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;gBAC9B,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/src/linaria.mts
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file contains an esbuild loader for Linaria.
|
|
3
|
-
* It uses the transform.ts function to generate class names from source code,
|
|
4
|
-
* returns transformed code without template literals and attaches generated source maps
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import fs from "fs";
|
|
8
|
-
import path from "path";
|
|
9
|
-
|
|
10
|
-
import type {Plugin, TransformOptions, Loader} from "esbuild";
|
|
11
|
-
import {transformSync} from "esbuild";
|
|
12
|
-
|
|
13
|
-
import type {PluginOptions, Preprocessor} from "@linaria/babel-preset";
|
|
14
|
-
import {slugify, transform} from "@linaria/babel-preset";
|
|
15
|
-
|
|
16
|
-
type EsbuildPluginOptions = {
|
|
17
|
-
sourceMap?: boolean;
|
|
18
|
-
preprocessor?: Preprocessor;
|
|
19
|
-
esbuildOptions?: TransformOptions;
|
|
20
|
-
} & Partial<PluginOptions>;
|
|
21
|
-
|
|
22
|
-
const nodeModulesRegex = /^(?:.*[\\/])?node_modules(?:[\\/].*)?$/;
|
|
23
|
-
|
|
24
|
-
export default function linaria({
|
|
25
|
-
sourceMap,
|
|
26
|
-
preprocessor,
|
|
27
|
-
esbuildOptions,
|
|
28
|
-
...rest
|
|
29
|
-
}: EsbuildPluginOptions = {}): Plugin {
|
|
30
|
-
let options = esbuildOptions;
|
|
31
|
-
return {
|
|
32
|
-
name: "linaria",
|
|
33
|
-
setup(build) {
|
|
34
|
-
const cssLookup = new Map<string, string>();
|
|
35
|
-
|
|
36
|
-
const asyncResolve = async (
|
|
37
|
-
token: string,
|
|
38
|
-
importer: string,
|
|
39
|
-
): Promise<string> => {
|
|
40
|
-
const context = path.isAbsolute(importer)
|
|
41
|
-
? path.dirname(importer)
|
|
42
|
-
: path.join(process.cwd(), path.dirname(importer));
|
|
43
|
-
|
|
44
|
-
const result = await build.resolve(token, {
|
|
45
|
-
kind: "entry-point",
|
|
46
|
-
resolveDir: context,
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
if (result.errors.length > 0) {
|
|
50
|
-
throw new Error(`Cannot resolve ${token}`);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return result.path;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
build.onResolve({filter: /\.linaria\.css$/}, (args) => {
|
|
57
|
-
return {
|
|
58
|
-
namespace: "linaria",
|
|
59
|
-
path: args.path,
|
|
60
|
-
};
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
build.onLoad({filter: /.*/, namespace: "linaria"}, (args) => {
|
|
64
|
-
return {
|
|
65
|
-
contents: cssLookup.get(args.path),
|
|
66
|
-
loader: "css",
|
|
67
|
-
resolveDir: path.basename(args.path),
|
|
68
|
-
};
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
build.onLoad({filter: /\.(js|jsx|ts|tsx)$/}, async (args) => {
|
|
72
|
-
const rawCode = fs.readFileSync(args.path, "utf8");
|
|
73
|
-
const {ext, name: filename} = path.parse(args.path);
|
|
74
|
-
const loader = ext.replace(/^\./, "") as Loader;
|
|
75
|
-
|
|
76
|
-
if (nodeModulesRegex.test(args.path)) {
|
|
77
|
-
return {
|
|
78
|
-
loader,
|
|
79
|
-
contents: rawCode,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (!options) {
|
|
84
|
-
options = {};
|
|
85
|
-
if ("jsxFactory" in build.initialOptions) {
|
|
86
|
-
options.jsxFactory = build.initialOptions.jsxFactory;
|
|
87
|
-
}
|
|
88
|
-
if ("jsxFragment" in build.initialOptions) {
|
|
89
|
-
options.jsxFragment = build.initialOptions.jsxFragment;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const transformed = transformSync(rawCode, {
|
|
94
|
-
...options,
|
|
95
|
-
sourcefile: args.path,
|
|
96
|
-
sourcemap: sourceMap,
|
|
97
|
-
loader,
|
|
98
|
-
});
|
|
99
|
-
let {code} = transformed;
|
|
100
|
-
|
|
101
|
-
if (sourceMap) {
|
|
102
|
-
const esbuildMap = Buffer.from(transformed.map).toString("base64");
|
|
103
|
-
code += `/*# sourceMappingURL=data:application/json;base64,${esbuildMap}*/`;
|
|
104
|
-
}
|
|
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
|
-
|
|
124
|
-
const result = await transform(
|
|
125
|
-
code,
|
|
126
|
-
{
|
|
127
|
-
filename: args.path,
|
|
128
|
-
preprocessor,
|
|
129
|
-
pluginOptions: {...rest, babelOptions},
|
|
130
|
-
},
|
|
131
|
-
asyncResolve,
|
|
132
|
-
);
|
|
133
|
-
|
|
134
|
-
if (!result.cssText) {
|
|
135
|
-
return {
|
|
136
|
-
contents: code,
|
|
137
|
-
loader,
|
|
138
|
-
resolveDir: path.dirname(args.path),
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
let {cssText} = result;
|
|
143
|
-
|
|
144
|
-
const slug = slugify(cssText);
|
|
145
|
-
const cssFilename = `${filename}_${slug}.linaria.css`;
|
|
146
|
-
|
|
147
|
-
let contents = `import ${JSON.stringify(cssFilename)}; ${result.code}`;
|
|
148
|
-
|
|
149
|
-
if (sourceMap && result.cssSourceMapText) {
|
|
150
|
-
const map = Buffer.from(result.cssSourceMapText).toString("base64");
|
|
151
|
-
cssText += `/*# sourceMappingURL=data:application/json;base64,${map}*/`;
|
|
152
|
-
const linariaMap = Buffer.from(
|
|
153
|
-
JSON.stringify(result.sourceMap),
|
|
154
|
-
).toString("base64");
|
|
155
|
-
contents += `/*# sourceMappingURL=data:application/json;base64,${linariaMap}*/`;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
cssLookup.set(cssFilename, cssText);
|
|
159
|
-
|
|
160
|
-
return {
|
|
161
|
-
contents,
|
|
162
|
-
loader,
|
|
163
|
-
resolveDir: path.dirname(args.path),
|
|
164
|
-
};
|
|
165
|
-
});
|
|
166
|
-
},
|
|
167
|
-
};
|
|
168
|
-
}
|