@ciderjs/gasnuki 0.3.4 → 0.3.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  # @ciderjs/gasnuki
2
2
 
3
3
  [![README-en](https://img.shields.io/badge/English-blue?logo=ReadMe)](./README.md)
4
- [![Test Coverage](https://img.shields.io/badge/test%20coverage-94.32%25-brightgreen)](https://github.com/luthpg/gasnuki)
4
+ [![Test Coverage](https://img.shields.io/badge/test%20coverage-94.74%25-brightgreen)](https://github.com/luthpg/gasnuki)
5
5
  [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
6
6
  [![npm version](https://img.shields.io/npm/v/@ciderjs/gasnuki.svg)](https://www.npmjs.com/package/@ciderjs/gasnuki)
7
7
  [![GitHub issues](https://img.shields.io/github/issues/luthpg/gasnuki.svg)](https://github.com/luthpg/gasnuki/issues)
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # @ciderjs/gasnuki
2
2
 
3
3
  [![README-ja](https://img.shields.io/badge/日本語-blue?logo=ReadMe)](./README.ja.md)
4
- [![Test Coverage](https://img.shields.io/badge/test%20coverage-94.32%25-brightgreen)](https://github.com/luthpg/gasnuki)
4
+ [![Test Coverage](https://img.shields.io/badge/test%20coverage-94.74%25-brightgreen)](https://github.com/luthpg/gasnuki)
5
5
  [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
6
6
  [![npm version](https://img.shields.io/npm/v/@ciderjs/gasnuki.svg)](https://www.npmjs.com/package/@ciderjs/gasnuki)
7
7
  [![GitHub issues](https://img.shields.io/github/issues/luthpg/gasnuki.svg)](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.kBd1L15Q.cjs');
7
+ const config = require('./shared/gasnuki.rciF8k_d.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.4";
28
+ const version = "0.3.6";
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.C96Q3amR.mjs';
5
+ import { l as loadConfig } from './shared/gasnuki.CfdOhkQS.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.4";
12
+ const version = "0.3.6";
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.kBd1L15Q.cjs');
6
+ const config = require('./shared/gasnuki.rciF8k_d.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.C96Q3amR.mjs';
5
- export { d as defineConfig } from './shared/gasnuki.C96Q3amR.mjs';
4
+ import { g as generateAppsScriptTypes } from './shared/gasnuki.CfdOhkQS.mjs';
5
+ export { d as defineConfig } from './shared/gasnuki.CfdOhkQS.mjs';
6
6
  import 'node:fs';
7
7
  import 'ts-morph';
8
8
  import 'jiti';
@@ -144,21 +144,53 @@ const generateAppsScriptTypes = async ({
144
144
  if (foundSymbols.has(aliasSymbol)) {
145
145
  return;
146
146
  }
147
+ const declarations = aliasSymbol.getDeclarations();
148
+ if (declarations.length > 0) {
149
+ const sourceFilePath = declarations[0].getSourceFile().getFilePath();
150
+ const isNodeModules = sourceFilePath.includes("node_modules");
151
+ if (isNodeModules) {
152
+ foundSymbols.add(aliasSymbol);
153
+ return;
154
+ }
155
+ }
147
156
  foundSymbols.add(aliasSymbol);
148
157
  for (const typeArg of type.getAliasTypeArguments()) {
149
158
  collectSymbolsFromType(typeArg, foundSymbols);
150
159
  }
151
- return;
152
160
  }
153
161
  const symbol = type.getSymbol();
154
- if (symbol && !foundSymbols.has(symbol)) {
155
- foundSymbols.add(symbol);
156
- if (type.isObject()) {
157
- for (const prop of type.getProperties()) {
158
- const propDecl = prop.getDeclarations()[0];
159
- if (propDecl) {
160
- collectSymbolsFromType(propDecl.getType(), foundSymbols);
162
+ let shouldTraverseProperties = true;
163
+ if (symbol) {
164
+ if (foundSymbols.has(symbol)) {
165
+ shouldTraverseProperties = false;
166
+ } else {
167
+ foundSymbols.add(symbol);
168
+ const declarations = symbol.getDeclarations();
169
+ if (declarations.length > 0) {
170
+ const sourceFilePath = declarations[0].getSourceFile().getFilePath();
171
+ if (sourceFilePath.includes("node_modules")) {
172
+ shouldTraverseProperties = false;
173
+ }
174
+ }
175
+ }
176
+ }
177
+ if (shouldTraverseProperties && type.isObject()) {
178
+ for (const prop of type.getProperties()) {
179
+ const propDecl = prop.getDeclarations()[0];
180
+ if (propDecl) {
181
+ const compilerNode = propDecl.compilerNode;
182
+ if (
183
+ // @ts-expect-error - avoiding full type checks for perf, checking kind directly
184
+ compilerNode.name && // @ts-expect-error - avoiding full type checks for perf, checking kind directly
185
+ compilerNode.name.kind === SyntaxKind.ComputedPropertyName
186
+ ) {
187
+ const expression = propDecl.getNameNode().getExpression();
188
+ const symbol2 = expression.getSymbol();
189
+ if (symbol2 && !foundSymbols.has(symbol2)) {
190
+ foundSymbols.add(symbol2);
191
+ }
161
192
  }
193
+ collectSymbolsFromType(propDecl.getType(), foundSymbols);
162
194
  }
163
195
  }
164
196
  }
@@ -251,10 +283,16 @@ const generateAppsScriptTypes = async ({
251
283
  importsMap.set(modulePath, /* @__PURE__ */ new Set());
252
284
  }
253
285
  importsMap.get(modulePath)?.add(symbolName);
254
- } else {
255
- const declText = declaration.getText();
256
- inlineDefinitions.set(symbolName, declText);
286
+ continue;
287
+ }
288
+ let declText = declaration.getText();
289
+ if (declaration.getKind() === SyntaxKind.VariableDeclaration) {
290
+ const variableStatement = declaration.getParent()?.getParent();
291
+ if (variableStatement && variableStatement.getKind() === SyntaxKind.VariableStatement) {
292
+ declText = variableStatement.getText();
293
+ }
257
294
  }
295
+ inlineDefinitions.set(symbolName, declText);
258
296
  for (const descendant of declaration.getDescendantsOfKind(
259
297
  SyntaxKind.TypeReference
260
298
  )) {
@@ -161,21 +161,53 @@ const generateAppsScriptTypes = async ({
161
161
  if (foundSymbols.has(aliasSymbol)) {
162
162
  return;
163
163
  }
164
+ const declarations = aliasSymbol.getDeclarations();
165
+ if (declarations.length > 0) {
166
+ const sourceFilePath = declarations[0].getSourceFile().getFilePath();
167
+ const isNodeModules = sourceFilePath.includes("node_modules");
168
+ if (isNodeModules) {
169
+ foundSymbols.add(aliasSymbol);
170
+ return;
171
+ }
172
+ }
164
173
  foundSymbols.add(aliasSymbol);
165
174
  for (const typeArg of type.getAliasTypeArguments()) {
166
175
  collectSymbolsFromType(typeArg, foundSymbols);
167
176
  }
168
- return;
169
177
  }
170
178
  const symbol = type.getSymbol();
171
- if (symbol && !foundSymbols.has(symbol)) {
172
- foundSymbols.add(symbol);
173
- if (type.isObject()) {
174
- for (const prop of type.getProperties()) {
175
- const propDecl = prop.getDeclarations()[0];
176
- if (propDecl) {
177
- collectSymbolsFromType(propDecl.getType(), foundSymbols);
179
+ let shouldTraverseProperties = true;
180
+ if (symbol) {
181
+ if (foundSymbols.has(symbol)) {
182
+ shouldTraverseProperties = false;
183
+ } else {
184
+ foundSymbols.add(symbol);
185
+ const declarations = symbol.getDeclarations();
186
+ if (declarations.length > 0) {
187
+ const sourceFilePath = declarations[0].getSourceFile().getFilePath();
188
+ if (sourceFilePath.includes("node_modules")) {
189
+ shouldTraverseProperties = false;
190
+ }
191
+ }
192
+ }
193
+ }
194
+ if (shouldTraverseProperties && type.isObject()) {
195
+ for (const prop of type.getProperties()) {
196
+ const propDecl = prop.getDeclarations()[0];
197
+ if (propDecl) {
198
+ const compilerNode = propDecl.compilerNode;
199
+ if (
200
+ // @ts-expect-error - avoiding full type checks for perf, checking kind directly
201
+ compilerNode.name && // @ts-expect-error - avoiding full type checks for perf, checking kind directly
202
+ compilerNode.name.kind === tsMorph.SyntaxKind.ComputedPropertyName
203
+ ) {
204
+ const expression = propDecl.getNameNode().getExpression();
205
+ const symbol2 = expression.getSymbol();
206
+ if (symbol2 && !foundSymbols.has(symbol2)) {
207
+ foundSymbols.add(symbol2);
208
+ }
178
209
  }
210
+ collectSymbolsFromType(propDecl.getType(), foundSymbols);
179
211
  }
180
212
  }
181
213
  }
@@ -268,10 +300,16 @@ const generateAppsScriptTypes = async ({
268
300
  importsMap.set(modulePath, /* @__PURE__ */ new Set());
269
301
  }
270
302
  importsMap.get(modulePath)?.add(symbolName);
271
- } else {
272
- const declText = declaration.getText();
273
- inlineDefinitions.set(symbolName, declText);
303
+ continue;
304
+ }
305
+ let declText = declaration.getText();
306
+ if (declaration.getKind() === tsMorph.SyntaxKind.VariableDeclaration) {
307
+ const variableStatement = declaration.getParent()?.getParent();
308
+ if (variableStatement && variableStatement.getKind() === tsMorph.SyntaxKind.VariableStatement) {
309
+ declText = variableStatement.getText();
310
+ }
274
311
  }
312
+ inlineDefinitions.set(symbolName, declText);
275
313
  for (const descendant of declaration.getDescendantsOfKind(
276
314
  tsMorph.SyntaxKind.TypeReference
277
315
  )) {
package/dist/vite.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  const path = require('node:path');
4
4
  const consola = require('consola');
5
- const config = require('./shared/gasnuki.kBd1L15Q.cjs');
5
+ const config = require('./shared/gasnuki.rciF8k_d.cjs');
6
6
  require('node:fs');
7
7
  require('ts-morph');
8
8
  require('jiti');
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.C96Q3amR.mjs';
3
+ import { l as loadConfig, g as generateAppsScriptTypes } from './shared/gasnuki.CfdOhkQS.mjs';
4
4
  import 'node:fs';
5
5
  import 'ts-morph';
6
6
  import 'jiti';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ciderjs/gasnuki",
3
- "version": "0.3.4",
3
+ "version": "0.3.6",
4
4
  "description": "Type definitions and utilities for Google Apps Script client-side API",
5
5
  "main": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",