@ciderjs/gasnuki 0.3.6 → 0.3.7
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.ja.md +1 -1
- package/README.md +1 -1
- package/dist/cli.cjs +2 -2
- package/dist/cli.mjs +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +2 -2
- package/dist/shared/{gasnuki.rciF8k_d.cjs → gasnuki.CooUv3Bz.cjs} +57 -31
- package/dist/shared/{gasnuki.CfdOhkQS.mjs → gasnuki.Md02V2Fd.mjs} +57 -31
- package/dist/vite.cjs +1 -1
- package/dist/vite.mjs +1 -1
- package/package.json +1 -1
package/README.ja.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @ciderjs/gasnuki
|
|
2
2
|
|
|
3
3
|
[](./README.md)
|
|
4
|
-
[](https://github.com/luthpg/gasnuki)
|
|
5
5
|
[](LICENSE)
|
|
6
6
|
[](https://www.npmjs.com/package/@ciderjs/gasnuki)
|
|
7
7
|
[](https://github.com/luthpg/gasnuki/issues)
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @ciderjs/gasnuki
|
|
2
2
|
|
|
3
3
|
[](./README.ja.md)
|
|
4
|
-
[](https://github.com/luthpg/gasnuki)
|
|
5
5
|
[](LICENSE)
|
|
6
6
|
[](https://www.npmjs.com/package/@ciderjs/gasnuki)
|
|
7
7
|
[](https://github.com/luthpg/gasnuki/issues)
|
package/dist/cli.cjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
const path = require('node:path');
|
|
5
5
|
const commander = require('commander');
|
|
6
6
|
const index = require('./index.cjs');
|
|
7
|
-
const config = require('./shared/gasnuki.
|
|
7
|
+
const config = require('./shared/gasnuki.CooUv3Bz.cjs');
|
|
8
8
|
require('chokidar');
|
|
9
9
|
require('consola');
|
|
10
10
|
require('node:fs');
|
|
@@ -25,7 +25,7 @@ function _interopNamespaceCompat(e) {
|
|
|
25
25
|
|
|
26
26
|
const path__namespace = /*#__PURE__*/_interopNamespaceCompat(path);
|
|
27
27
|
|
|
28
|
-
const version = "0.3.
|
|
28
|
+
const version = "0.3.7";
|
|
29
29
|
|
|
30
30
|
const parseArgs = async (command) => {
|
|
31
31
|
const cliOpts = command.opts();
|
package/dist/cli.mjs
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
import * as path from 'node:path';
|
|
3
3
|
import { Command } from 'commander';
|
|
4
4
|
import { generateTypes } from './index.mjs';
|
|
5
|
-
import { l as loadConfig } from './shared/gasnuki.
|
|
5
|
+
import { l as loadConfig } from './shared/gasnuki.Md02V2Fd.mjs';
|
|
6
6
|
import 'chokidar';
|
|
7
7
|
import 'consola';
|
|
8
8
|
import 'node:fs';
|
|
9
9
|
import 'ts-morph';
|
|
10
10
|
import 'jiti';
|
|
11
11
|
|
|
12
|
-
const version = "0.3.
|
|
12
|
+
const version = "0.3.7";
|
|
13
13
|
|
|
14
14
|
const parseArgs = async (command) => {
|
|
15
15
|
const cliOpts = command.opts();
|
package/dist/index.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const path = require('node:path');
|
|
4
4
|
const chokidar = require('chokidar');
|
|
5
5
|
const consola = require('consola');
|
|
6
|
-
const config = require('./shared/gasnuki.
|
|
6
|
+
const config = require('./shared/gasnuki.CooUv3Bz.cjs');
|
|
7
7
|
require('node:fs');
|
|
8
8
|
require('ts-morph');
|
|
9
9
|
require('jiti');
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as path from 'node:path';
|
|
2
2
|
import * as chokidar from 'chokidar';
|
|
3
3
|
import { consola } from 'consola';
|
|
4
|
-
import { g as generateAppsScriptTypes } from './shared/gasnuki.
|
|
5
|
-
export { d as defineConfig } from './shared/gasnuki.
|
|
4
|
+
import { g as generateAppsScriptTypes } from './shared/gasnuki.Md02V2Fd.mjs';
|
|
5
|
+
export { d as defineConfig } from './shared/gasnuki.Md02V2Fd.mjs';
|
|
6
6
|
import 'node:fs';
|
|
7
7
|
import 'ts-morph';
|
|
8
8
|
import 'jiti';
|
|
@@ -58,7 +58,15 @@ const getInterfaceMethodDefinition_ = (name, node) => {
|
|
|
58
58
|
`;
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
|
|
61
|
+
const cleanType = (t) => t.replace(/import\(.*?\)\./g, "");
|
|
62
|
+
const cleanedReturnType = cleanType(returnType);
|
|
63
|
+
const cleanedParameters = parameters.replace(
|
|
64
|
+
/:\s*([^,;)]+)/g,
|
|
65
|
+
(_match, p1) => {
|
|
66
|
+
return `: ${cleanType(p1)}`;
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
return `${jsDocString}${name}${typeParamsString}(${cleanedParameters}): ${cleanedReturnType};`;
|
|
62
70
|
};
|
|
63
71
|
const SIMPLE_TRIGGER_FUNCTION_NAMES = [
|
|
64
72
|
"onOpen",
|
|
@@ -164,16 +172,15 @@ const generateAppsScriptTypes = async ({
|
|
|
164
172
|
const declarations = aliasSymbol.getDeclarations();
|
|
165
173
|
if (declarations.length > 0) {
|
|
166
174
|
const sourceFilePath = declarations[0].getSourceFile().getFilePath();
|
|
167
|
-
const
|
|
168
|
-
if (
|
|
175
|
+
const isExternal = sourceFilePath.includes("node_modules") || !sourceFilePath.replace(/\\/g, "/").startsWith(absoluteSrcDir.replace(/\\/g, "/")) && !sourceFilePath.replace(/\\/g, "/").startsWith(path__namespace.join(projectPath, srcDir).replace(/\\/g, "/"));
|
|
176
|
+
if (isExternal) {
|
|
169
177
|
foundSymbols.add(aliasSymbol);
|
|
178
|
+
for (const typeArg of type.getAliasTypeArguments()) {
|
|
179
|
+
collectSymbolsFromType(typeArg, foundSymbols);
|
|
180
|
+
}
|
|
170
181
|
return;
|
|
171
182
|
}
|
|
172
183
|
}
|
|
173
|
-
foundSymbols.add(aliasSymbol);
|
|
174
|
-
for (const typeArg of type.getAliasTypeArguments()) {
|
|
175
|
-
collectSymbolsFromType(typeArg, foundSymbols);
|
|
176
|
-
}
|
|
177
184
|
}
|
|
178
185
|
const symbol = type.getSymbol();
|
|
179
186
|
let shouldTraverseProperties = true;
|
|
@@ -185,7 +192,10 @@ const generateAppsScriptTypes = async ({
|
|
|
185
192
|
const declarations = symbol.getDeclarations();
|
|
186
193
|
if (declarations.length > 0) {
|
|
187
194
|
const sourceFilePath = declarations[0].getSourceFile().getFilePath();
|
|
188
|
-
|
|
195
|
+
const isExternal = sourceFilePath.includes("node_modules") || !sourceFilePath.replace(/\\/g, "/").startsWith(absoluteSrcDir.replace(/\\/g, "/")) && !sourceFilePath.replace(/\\/g, "/").startsWith(
|
|
196
|
+
path__namespace.join(projectPath, srcDir).replace(/\\/g, "/")
|
|
197
|
+
);
|
|
198
|
+
if (isExternal) {
|
|
189
199
|
shouldTraverseProperties = false;
|
|
190
200
|
}
|
|
191
201
|
}
|
|
@@ -261,16 +271,35 @@ const generateAppsScriptTypes = async ({
|
|
|
261
271
|
if (!declaration) {
|
|
262
272
|
continue;
|
|
263
273
|
}
|
|
264
|
-
|
|
265
|
-
|
|
274
|
+
const allowedKinds = [
|
|
275
|
+
tsMorph.SyntaxKind.InterfaceDeclaration,
|
|
276
|
+
tsMorph.SyntaxKind.TypeAliasDeclaration,
|
|
277
|
+
tsMorph.SyntaxKind.EnumDeclaration,
|
|
278
|
+
tsMorph.SyntaxKind.ClassDeclaration,
|
|
279
|
+
tsMorph.SyntaxKind.ModuleDeclaration
|
|
280
|
+
];
|
|
281
|
+
if (!allowedKinds.includes(declaration.getKind())) {
|
|
282
|
+
if (declaration.getKind() === tsMorph.SyntaxKind.VariableDeclaration) {
|
|
283
|
+
const typeNode = declaration.getTypeNode();
|
|
284
|
+
const isUniqueSymbol = typeNode?.getText().includes("unique symbol");
|
|
285
|
+
if (!isUniqueSymbol) {
|
|
286
|
+
continue;
|
|
287
|
+
}
|
|
288
|
+
} else {
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
266
291
|
}
|
|
267
292
|
const sourceFile = declaration.getSourceFile();
|
|
268
293
|
const sourceFilePath = sourceFile.getFilePath();
|
|
269
294
|
if (/[/\\]typescript[/\\]lib[/\\]/.test(sourceFilePath)) {
|
|
270
295
|
continue;
|
|
271
296
|
}
|
|
272
|
-
|
|
273
|
-
|
|
297
|
+
const isExternal = sourceFilePath.includes("node_modules") || !sourceFilePath.replace(/\\/g, "/").startsWith(absoluteSrcDir.replace(/\\/g, "/")) && !sourceFilePath.replace(/\\/g, "/").startsWith(path__namespace.join(projectPath, srcDir).replace(/\\/g, "/"));
|
|
298
|
+
if (isExternal) {
|
|
299
|
+
if (sourceFilePath.includes("node_modules")) {
|
|
300
|
+
if (!functionSignatureSymbols.has(symbol)) {
|
|
301
|
+
continue;
|
|
302
|
+
}
|
|
274
303
|
const packageName = getPackageNameFromNodeModulesPath_(sourceFilePath);
|
|
275
304
|
if (packageName) {
|
|
276
305
|
processedSymbols.add(symbolName);
|
|
@@ -279,29 +308,26 @@ const generateAppsScriptTypes = async ({
|
|
|
279
308
|
}
|
|
280
309
|
importsMap.get(packageName)?.add(symbolName);
|
|
281
310
|
}
|
|
311
|
+
} else {
|
|
312
|
+
let modulePath = path__namespace.relative(absoluteOutDir, sourceFilePath).replace(/\\/g, "/");
|
|
313
|
+
modulePath = modulePath.replace(/\.(d\.)?ts$/, "");
|
|
314
|
+
if (modulePath.endsWith("/index")) {
|
|
315
|
+
modulePath = modulePath.slice(0, -6);
|
|
316
|
+
}
|
|
317
|
+
if (modulePath === "index" || modulePath === "") {
|
|
318
|
+
modulePath = ".";
|
|
319
|
+
}
|
|
320
|
+
if (!modulePath.startsWith(".")) {
|
|
321
|
+
modulePath = `./${modulePath}`;
|
|
322
|
+
}
|
|
323
|
+
if (!importsMap.has(modulePath)) {
|
|
324
|
+
importsMap.set(modulePath, /* @__PURE__ */ new Set());
|
|
325
|
+
}
|
|
326
|
+
importsMap.get(modulePath)?.add(symbolName);
|
|
282
327
|
}
|
|
283
328
|
continue;
|
|
284
329
|
}
|
|
285
330
|
processedSymbols.add(symbolName);
|
|
286
|
-
const isExternal = !sourceFilePath.replace(/\\/g, "/").startsWith(absoluteSrcDir.replace(/\\/g, "/")) && !sourceFilePath.replace(/\\/g, "/").startsWith(path__namespace.join(projectPath, srcDir).replace(/\\/g, "/"));
|
|
287
|
-
if (isExternal) {
|
|
288
|
-
let modulePath = path__namespace.relative(absoluteOutDir, sourceFilePath).replace(/\\/g, "/");
|
|
289
|
-
modulePath = modulePath.replace(/\.(d\.)?ts$/, "");
|
|
290
|
-
if (modulePath.endsWith("/index")) {
|
|
291
|
-
modulePath = modulePath.slice(0, -6);
|
|
292
|
-
}
|
|
293
|
-
if (modulePath === "index" || modulePath === "") {
|
|
294
|
-
modulePath = ".";
|
|
295
|
-
}
|
|
296
|
-
if (!modulePath.startsWith(".")) {
|
|
297
|
-
modulePath = `./${modulePath}`;
|
|
298
|
-
}
|
|
299
|
-
if (!importsMap.has(modulePath)) {
|
|
300
|
-
importsMap.set(modulePath, /* @__PURE__ */ new Set());
|
|
301
|
-
}
|
|
302
|
-
importsMap.get(modulePath)?.add(symbolName);
|
|
303
|
-
continue;
|
|
304
|
-
}
|
|
305
331
|
let declText = declaration.getText();
|
|
306
332
|
if (declaration.getKind() === tsMorph.SyntaxKind.VariableDeclaration) {
|
|
307
333
|
const variableStatement = declaration.getParent()?.getParent();
|
|
@@ -41,7 +41,15 @@ const getInterfaceMethodDefinition_ = (name, node) => {
|
|
|
41
41
|
`;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
|
|
44
|
+
const cleanType = (t) => t.replace(/import\(.*?\)\./g, "");
|
|
45
|
+
const cleanedReturnType = cleanType(returnType);
|
|
46
|
+
const cleanedParameters = parameters.replace(
|
|
47
|
+
/:\s*([^,;)]+)/g,
|
|
48
|
+
(_match, p1) => {
|
|
49
|
+
return `: ${cleanType(p1)}`;
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
return `${jsDocString}${name}${typeParamsString}(${cleanedParameters}): ${cleanedReturnType};`;
|
|
45
53
|
};
|
|
46
54
|
const SIMPLE_TRIGGER_FUNCTION_NAMES = [
|
|
47
55
|
"onOpen",
|
|
@@ -147,16 +155,15 @@ const generateAppsScriptTypes = async ({
|
|
|
147
155
|
const declarations = aliasSymbol.getDeclarations();
|
|
148
156
|
if (declarations.length > 0) {
|
|
149
157
|
const sourceFilePath = declarations[0].getSourceFile().getFilePath();
|
|
150
|
-
const
|
|
151
|
-
if (
|
|
158
|
+
const isExternal = sourceFilePath.includes("node_modules") || !sourceFilePath.replace(/\\/g, "/").startsWith(absoluteSrcDir.replace(/\\/g, "/")) && !sourceFilePath.replace(/\\/g, "/").startsWith(path.join(projectPath, srcDir).replace(/\\/g, "/"));
|
|
159
|
+
if (isExternal) {
|
|
152
160
|
foundSymbols.add(aliasSymbol);
|
|
161
|
+
for (const typeArg of type.getAliasTypeArguments()) {
|
|
162
|
+
collectSymbolsFromType(typeArg, foundSymbols);
|
|
163
|
+
}
|
|
153
164
|
return;
|
|
154
165
|
}
|
|
155
166
|
}
|
|
156
|
-
foundSymbols.add(aliasSymbol);
|
|
157
|
-
for (const typeArg of type.getAliasTypeArguments()) {
|
|
158
|
-
collectSymbolsFromType(typeArg, foundSymbols);
|
|
159
|
-
}
|
|
160
167
|
}
|
|
161
168
|
const symbol = type.getSymbol();
|
|
162
169
|
let shouldTraverseProperties = true;
|
|
@@ -168,7 +175,10 @@ const generateAppsScriptTypes = async ({
|
|
|
168
175
|
const declarations = symbol.getDeclarations();
|
|
169
176
|
if (declarations.length > 0) {
|
|
170
177
|
const sourceFilePath = declarations[0].getSourceFile().getFilePath();
|
|
171
|
-
|
|
178
|
+
const isExternal = sourceFilePath.includes("node_modules") || !sourceFilePath.replace(/\\/g, "/").startsWith(absoluteSrcDir.replace(/\\/g, "/")) && !sourceFilePath.replace(/\\/g, "/").startsWith(
|
|
179
|
+
path.join(projectPath, srcDir).replace(/\\/g, "/")
|
|
180
|
+
);
|
|
181
|
+
if (isExternal) {
|
|
172
182
|
shouldTraverseProperties = false;
|
|
173
183
|
}
|
|
174
184
|
}
|
|
@@ -244,16 +254,35 @@ const generateAppsScriptTypes = async ({
|
|
|
244
254
|
if (!declaration) {
|
|
245
255
|
continue;
|
|
246
256
|
}
|
|
247
|
-
|
|
248
|
-
|
|
257
|
+
const allowedKinds = [
|
|
258
|
+
SyntaxKind.InterfaceDeclaration,
|
|
259
|
+
SyntaxKind.TypeAliasDeclaration,
|
|
260
|
+
SyntaxKind.EnumDeclaration,
|
|
261
|
+
SyntaxKind.ClassDeclaration,
|
|
262
|
+
SyntaxKind.ModuleDeclaration
|
|
263
|
+
];
|
|
264
|
+
if (!allowedKinds.includes(declaration.getKind())) {
|
|
265
|
+
if (declaration.getKind() === SyntaxKind.VariableDeclaration) {
|
|
266
|
+
const typeNode = declaration.getTypeNode();
|
|
267
|
+
const isUniqueSymbol = typeNode?.getText().includes("unique symbol");
|
|
268
|
+
if (!isUniqueSymbol) {
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
} else {
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
249
274
|
}
|
|
250
275
|
const sourceFile = declaration.getSourceFile();
|
|
251
276
|
const sourceFilePath = sourceFile.getFilePath();
|
|
252
277
|
if (/[/\\]typescript[/\\]lib[/\\]/.test(sourceFilePath)) {
|
|
253
278
|
continue;
|
|
254
279
|
}
|
|
255
|
-
|
|
256
|
-
|
|
280
|
+
const isExternal = sourceFilePath.includes("node_modules") || !sourceFilePath.replace(/\\/g, "/").startsWith(absoluteSrcDir.replace(/\\/g, "/")) && !sourceFilePath.replace(/\\/g, "/").startsWith(path.join(projectPath, srcDir).replace(/\\/g, "/"));
|
|
281
|
+
if (isExternal) {
|
|
282
|
+
if (sourceFilePath.includes("node_modules")) {
|
|
283
|
+
if (!functionSignatureSymbols.has(symbol)) {
|
|
284
|
+
continue;
|
|
285
|
+
}
|
|
257
286
|
const packageName = getPackageNameFromNodeModulesPath_(sourceFilePath);
|
|
258
287
|
if (packageName) {
|
|
259
288
|
processedSymbols.add(symbolName);
|
|
@@ -262,29 +291,26 @@ const generateAppsScriptTypes = async ({
|
|
|
262
291
|
}
|
|
263
292
|
importsMap.get(packageName)?.add(symbolName);
|
|
264
293
|
}
|
|
294
|
+
} else {
|
|
295
|
+
let modulePath = path.relative(absoluteOutDir, sourceFilePath).replace(/\\/g, "/");
|
|
296
|
+
modulePath = modulePath.replace(/\.(d\.)?ts$/, "");
|
|
297
|
+
if (modulePath.endsWith("/index")) {
|
|
298
|
+
modulePath = modulePath.slice(0, -6);
|
|
299
|
+
}
|
|
300
|
+
if (modulePath === "index" || modulePath === "") {
|
|
301
|
+
modulePath = ".";
|
|
302
|
+
}
|
|
303
|
+
if (!modulePath.startsWith(".")) {
|
|
304
|
+
modulePath = `./${modulePath}`;
|
|
305
|
+
}
|
|
306
|
+
if (!importsMap.has(modulePath)) {
|
|
307
|
+
importsMap.set(modulePath, /* @__PURE__ */ new Set());
|
|
308
|
+
}
|
|
309
|
+
importsMap.get(modulePath)?.add(symbolName);
|
|
265
310
|
}
|
|
266
311
|
continue;
|
|
267
312
|
}
|
|
268
313
|
processedSymbols.add(symbolName);
|
|
269
|
-
const isExternal = !sourceFilePath.replace(/\\/g, "/").startsWith(absoluteSrcDir.replace(/\\/g, "/")) && !sourceFilePath.replace(/\\/g, "/").startsWith(path.join(projectPath, srcDir).replace(/\\/g, "/"));
|
|
270
|
-
if (isExternal) {
|
|
271
|
-
let modulePath = path.relative(absoluteOutDir, sourceFilePath).replace(/\\/g, "/");
|
|
272
|
-
modulePath = modulePath.replace(/\.(d\.)?ts$/, "");
|
|
273
|
-
if (modulePath.endsWith("/index")) {
|
|
274
|
-
modulePath = modulePath.slice(0, -6);
|
|
275
|
-
}
|
|
276
|
-
if (modulePath === "index" || modulePath === "") {
|
|
277
|
-
modulePath = ".";
|
|
278
|
-
}
|
|
279
|
-
if (!modulePath.startsWith(".")) {
|
|
280
|
-
modulePath = `./${modulePath}`;
|
|
281
|
-
}
|
|
282
|
-
if (!importsMap.has(modulePath)) {
|
|
283
|
-
importsMap.set(modulePath, /* @__PURE__ */ new Set());
|
|
284
|
-
}
|
|
285
|
-
importsMap.get(modulePath)?.add(symbolName);
|
|
286
|
-
continue;
|
|
287
|
-
}
|
|
288
314
|
let declText = declaration.getText();
|
|
289
315
|
if (declaration.getKind() === SyntaxKind.VariableDeclaration) {
|
|
290
316
|
const variableStatement = declaration.getParent()?.getParent();
|
package/dist/vite.cjs
CHANGED
package/dist/vite.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as path from 'node:path';
|
|
2
2
|
import { consola } from 'consola';
|
|
3
|
-
import { l as loadConfig, g as generateAppsScriptTypes } from './shared/gasnuki.
|
|
3
|
+
import { l as loadConfig, g as generateAppsScriptTypes } from './shared/gasnuki.Md02V2Fd.mjs';
|
|
4
4
|
import 'node:fs';
|
|
5
5
|
import 'ts-morph';
|
|
6
6
|
import 'jiti';
|