@ciderjs/gasnuki 0.5.2 → 0.5.4
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 +2 -2
- package/README.md +2 -2
- 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.Clw_jH65.cjs → gasnuki.D2FZdJSt.cjs} +23 -4
- package/dist/shared/{gasnuki.CYbD-wKI.mjs → gasnuki.Ee5cF3d4.mjs} +24 -5
- package/dist/vite.cjs +27 -17
- package/dist/vite.mjs +25 -15
- package/package.json +4 -4
package/README.ja.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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://www.npmjs.com/package/@ciderjs/gasnuki)
|
|
8
8
|
[](https://github.com/luthpg/gasnuki/issues)
|
|
9
9
|
|
|
10
10
|
Google Apps Script クライアントサイドAPIの型定義・ユーティリティ
|
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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://www.npmjs.com/package/@ciderjs/gasnuki)
|
|
8
8
|
[](https://github.com/luthpg/gasnuki/issues)
|
|
9
9
|
|
|
10
10
|
Type definitions and utilities for Google Apps Script client-side API
|
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.D2FZdJSt.cjs');
|
|
8
8
|
require('chokidar');
|
|
9
9
|
require('consola');
|
|
10
10
|
require('node:crypto');
|
|
@@ -26,7 +26,7 @@ function _interopNamespaceCompat(e) {
|
|
|
26
26
|
|
|
27
27
|
const path__namespace = /*#__PURE__*/_interopNamespaceCompat(path);
|
|
28
28
|
|
|
29
|
-
const version = "0.5.
|
|
29
|
+
const version = "0.5.4";
|
|
30
30
|
|
|
31
31
|
const parseArgs = async (command) => {
|
|
32
32
|
const cliOpts = command.opts();
|
package/dist/cli.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
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.Ee5cF3d4.mjs';
|
|
6
6
|
import 'chokidar';
|
|
7
7
|
import 'consola';
|
|
8
8
|
import 'node:crypto';
|
|
@@ -10,7 +10,7 @@ import 'node:fs';
|
|
|
10
10
|
import 'ts-morph';
|
|
11
11
|
import 'jiti';
|
|
12
12
|
|
|
13
|
-
const version = "0.5.
|
|
13
|
+
const version = "0.5.4";
|
|
14
14
|
|
|
15
15
|
const parseArgs = async (command) => {
|
|
16
16
|
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.D2FZdJSt.cjs');
|
|
7
7
|
require('node:crypto');
|
|
8
8
|
require('node:fs');
|
|
9
9
|
require('ts-morph');
|
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.Ee5cF3d4.mjs';
|
|
5
|
+
export { d as defineConfig } from './shared/gasnuki.Ee5cF3d4.mjs';
|
|
6
6
|
import 'node:crypto';
|
|
7
7
|
import 'node:fs';
|
|
8
8
|
import 'ts-morph';
|
|
@@ -123,15 +123,18 @@ const findPackageJson_ = (startDir) => {
|
|
|
123
123
|
return null;
|
|
124
124
|
};
|
|
125
125
|
const matchesExportValue_ = (node, targetPath) => {
|
|
126
|
+
const normalize = (p) => p.startsWith(".") ? p : `./${p}`;
|
|
127
|
+
const normalizedTarget = normalize(targetPath);
|
|
126
128
|
if (typeof node === "string") {
|
|
127
|
-
|
|
129
|
+
const normalizedNode = normalize(node);
|
|
130
|
+
return normalizedNode === normalizedTarget || normalizedNode === normalizedTarget.replace(/\.d\.ts$/, ".js");
|
|
128
131
|
}
|
|
129
132
|
if (typeof node === "object" && node !== null) {
|
|
130
|
-
if (node.types && node.types
|
|
133
|
+
if (node.types && matchesExportValue_(node.types, targetPath)) {
|
|
131
134
|
return true;
|
|
132
135
|
}
|
|
133
136
|
for (const key in node) {
|
|
134
|
-
if (matchesExportValue_(node[key], targetPath)) {
|
|
137
|
+
if (key !== "types" && matchesExportValue_(node[key], targetPath)) {
|
|
135
138
|
return true;
|
|
136
139
|
}
|
|
137
140
|
}
|
|
@@ -155,7 +158,13 @@ const resolveNodeModuleSpecifier_ = (filePath) => {
|
|
|
155
158
|
const exportValue = pkg.content.exports[key];
|
|
156
159
|
if (matchesExportValue_(exportValue, relativePath)) {
|
|
157
160
|
if (key === ".") return packageName;
|
|
158
|
-
|
|
161
|
+
const subPath = key.startsWith("./") ? key.slice(2) : key;
|
|
162
|
+
console.log(`[gasnuki] Matched key: ${key}, subPath: ${subPath}`);
|
|
163
|
+
return `${packageName}/${subPath}`;
|
|
164
|
+
} else {
|
|
165
|
+
console.log(
|
|
166
|
+
`[gasnuki] No match for ${key}: ${JSON.stringify(exportValue)} vs ${relativePath} (pkgRoot: ${packageRoot}, file: ${filePath})`
|
|
167
|
+
);
|
|
159
168
|
}
|
|
160
169
|
}
|
|
161
170
|
}
|
|
@@ -488,6 +497,16 @@ const generateAppsScriptTypes = async ({
|
|
|
488
497
|
if (!functionSignatureSymbols.has(symbol)) {
|
|
489
498
|
continue;
|
|
490
499
|
}
|
|
500
|
+
const hasExportModifier = sourceFile.getStatements().some((stmt) => {
|
|
501
|
+
if (tsMorph.Node.isExportable(stmt)) {
|
|
502
|
+
return stmt.isExported();
|
|
503
|
+
}
|
|
504
|
+
return false;
|
|
505
|
+
});
|
|
506
|
+
const isGlobal = sourceFile.getImportDeclarations().length === 0 && sourceFile.getExportDeclarations().length === 0 && sourceFile.getExportAssignments().length === 0 && !hasExportModifier;
|
|
507
|
+
if (isGlobal) {
|
|
508
|
+
continue;
|
|
509
|
+
}
|
|
491
510
|
const packageName = resolveNodeModuleSpecifier_(sourceFilePath);
|
|
492
511
|
if (packageName) {
|
|
493
512
|
processedSymbols.add(symbolName);
|
|
@@ -2,7 +2,7 @@ import * as crypto from 'node:crypto';
|
|
|
2
2
|
import * as fs from 'node:fs';
|
|
3
3
|
import * as path from 'node:path';
|
|
4
4
|
import { consola } from 'consola';
|
|
5
|
-
import { Project, SyntaxKind, SymbolFlags } from 'ts-morph';
|
|
5
|
+
import { Project, SyntaxKind, SymbolFlags, Node } from 'ts-morph';
|
|
6
6
|
import { createJiti } from 'jiti';
|
|
7
7
|
|
|
8
8
|
const text = "export type RemoveReturnType<T> = {\n [P in keyof T]: T[P] extends (...args: infer A) => any\n ? (...args: A) => void\n : T[P];\n};\n\ntype _AppsScriptRun = RemoveReturnType<ServerScripts> & {\n [key: string]: (...args: any[]) => any;\n withSuccessHandler: <T = string | number | boolean | undefined, U = any>(\n callback: (returnValues: T, userObject?: U) => void,\n ) => _AppsScriptRun;\n withFailureHandler: <U = any>(\n callback: (error: Error, userObject?: U) => void,\n ) => _AppsScriptRun;\n withUserObject: <U = any>(userObject: U) => _AppsScriptRun;\n};\n\ntype _AppsScriptHistoryFunction = (\n stateObject: object,\n params: object,\n hash: string,\n) => void;\n\ninterface _WebAppLocationType {\n hash: string;\n parameter: Record<string, string>;\n parameters: Record<string, string[]>;\n}\n\nexport declare interface GoogleClientSideApi {\n script: {\n run: _AppsScriptRun;\n url: {\n getLocation: (callback: (location: _WebAppLocationType) => void) => void;\n };\n history: {\n push: _AppsScriptHistoryFunction;\n replace: _AppsScriptHistoryFunction;\n setChangeHandler: (\n callback: (e: { state: object; location: _WebAppLocationType }) => void,\n ) => void;\n };\n };\n}\n\ndeclare global {\n const google: GoogleClientSideApi;\n}\n";
|
|
@@ -105,15 +105,18 @@ const findPackageJson_ = (startDir) => {
|
|
|
105
105
|
return null;
|
|
106
106
|
};
|
|
107
107
|
const matchesExportValue_ = (node, targetPath) => {
|
|
108
|
+
const normalize = (p) => p.startsWith(".") ? p : `./${p}`;
|
|
109
|
+
const normalizedTarget = normalize(targetPath);
|
|
108
110
|
if (typeof node === "string") {
|
|
109
|
-
|
|
111
|
+
const normalizedNode = normalize(node);
|
|
112
|
+
return normalizedNode === normalizedTarget || normalizedNode === normalizedTarget.replace(/\.d\.ts$/, ".js");
|
|
110
113
|
}
|
|
111
114
|
if (typeof node === "object" && node !== null) {
|
|
112
|
-
if (node.types && node.types
|
|
115
|
+
if (node.types && matchesExportValue_(node.types, targetPath)) {
|
|
113
116
|
return true;
|
|
114
117
|
}
|
|
115
118
|
for (const key in node) {
|
|
116
|
-
if (matchesExportValue_(node[key], targetPath)) {
|
|
119
|
+
if (key !== "types" && matchesExportValue_(node[key], targetPath)) {
|
|
117
120
|
return true;
|
|
118
121
|
}
|
|
119
122
|
}
|
|
@@ -137,7 +140,13 @@ const resolveNodeModuleSpecifier_ = (filePath) => {
|
|
|
137
140
|
const exportValue = pkg.content.exports[key];
|
|
138
141
|
if (matchesExportValue_(exportValue, relativePath)) {
|
|
139
142
|
if (key === ".") return packageName;
|
|
140
|
-
|
|
143
|
+
const subPath = key.startsWith("./") ? key.slice(2) : key;
|
|
144
|
+
console.log(`[gasnuki] Matched key: ${key}, subPath: ${subPath}`);
|
|
145
|
+
return `${packageName}/${subPath}`;
|
|
146
|
+
} else {
|
|
147
|
+
console.log(
|
|
148
|
+
`[gasnuki] No match for ${key}: ${JSON.stringify(exportValue)} vs ${relativePath} (pkgRoot: ${packageRoot}, file: ${filePath})`
|
|
149
|
+
);
|
|
141
150
|
}
|
|
142
151
|
}
|
|
143
152
|
}
|
|
@@ -470,6 +479,16 @@ const generateAppsScriptTypes = async ({
|
|
|
470
479
|
if (!functionSignatureSymbols.has(symbol)) {
|
|
471
480
|
continue;
|
|
472
481
|
}
|
|
482
|
+
const hasExportModifier = sourceFile.getStatements().some((stmt) => {
|
|
483
|
+
if (Node.isExportable(stmt)) {
|
|
484
|
+
return stmt.isExported();
|
|
485
|
+
}
|
|
486
|
+
return false;
|
|
487
|
+
});
|
|
488
|
+
const isGlobal = sourceFile.getImportDeclarations().length === 0 && sourceFile.getExportDeclarations().length === 0 && sourceFile.getExportAssignments().length === 0 && !hasExportModifier;
|
|
489
|
+
if (isGlobal) {
|
|
490
|
+
continue;
|
|
491
|
+
}
|
|
473
492
|
const packageName = resolveNodeModuleSpecifier_(sourceFilePath);
|
|
474
493
|
if (packageName) {
|
|
475
494
|
processedSymbols.add(symbolName);
|
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.
|
|
5
|
+
const config = require('./shared/gasnuki.D2FZdJSt.cjs');
|
|
6
6
|
require('node:crypto');
|
|
7
7
|
require('node:fs');
|
|
8
8
|
require('ts-morph');
|
|
@@ -54,31 +54,41 @@ function gasnuki(options) {
|
|
|
54
54
|
name: "vite-plugin-gasnuki",
|
|
55
55
|
apply: "serve",
|
|
56
56
|
// Apply only in serve mode
|
|
57
|
-
async configResolved(config
|
|
58
|
-
projectRoot = config
|
|
59
|
-
|
|
60
|
-
const defaultOptions = {
|
|
61
|
-
srcDir: "server",
|
|
62
|
-
outDir: "types",
|
|
63
|
-
outputFile: "appsscript.ts"
|
|
64
|
-
};
|
|
65
|
-
gasnukiOptions = {
|
|
66
|
-
...defaultOptions,
|
|
67
|
-
...fileConfig,
|
|
68
|
-
...options || {}
|
|
69
|
-
};
|
|
57
|
+
async configResolved(config) {
|
|
58
|
+
projectRoot = config.root;
|
|
59
|
+
await reloadOptions();
|
|
70
60
|
},
|
|
71
61
|
async configureServer(server) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
62
|
+
server.watcher.on("all", async (_event, filePath) => {
|
|
63
|
+
const fileName = path__namespace.basename(filePath);
|
|
64
|
+
if (fileName.startsWith("gasnuki.config.")) {
|
|
65
|
+
consola.consola.info("[gasnuki] Config file changed, reloading...");
|
|
66
|
+
await reloadOptions();
|
|
67
|
+
runGeneration("config change");
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const targetDir = path__namespace.resolve(projectRoot, gasnukiOptions.srcDir);
|
|
75
71
|
const relativePath = path__namespace.relative(targetDir, filePath);
|
|
76
72
|
if (!relativePath.startsWith("..") && relativePath !== "..") {
|
|
77
73
|
runGeneration(path__namespace.relative(projectRoot, filePath));
|
|
78
74
|
}
|
|
79
75
|
});
|
|
76
|
+
runGeneration("server startup");
|
|
80
77
|
}
|
|
81
78
|
};
|
|
79
|
+
async function reloadOptions() {
|
|
80
|
+
const fileConfig = await config.loadConfig(projectRoot);
|
|
81
|
+
const defaultOptions = {
|
|
82
|
+
srcDir: "server",
|
|
83
|
+
outDir: "types",
|
|
84
|
+
outputFile: "appsscript.ts"
|
|
85
|
+
};
|
|
86
|
+
gasnukiOptions = {
|
|
87
|
+
...defaultOptions,
|
|
88
|
+
...fileConfig,
|
|
89
|
+
...options || {}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
82
92
|
}
|
|
83
93
|
|
|
84
94
|
exports.gasnuki = gasnuki;
|
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.Ee5cF3d4.mjs';
|
|
4
4
|
import 'node:crypto';
|
|
5
5
|
import 'node:fs';
|
|
6
6
|
import 'ts-morph';
|
|
@@ -40,29 +40,39 @@ function gasnuki(options) {
|
|
|
40
40
|
// Apply only in serve mode
|
|
41
41
|
async configResolved(config) {
|
|
42
42
|
projectRoot = config.root;
|
|
43
|
-
|
|
44
|
-
const defaultOptions = {
|
|
45
|
-
srcDir: "server",
|
|
46
|
-
outDir: "types",
|
|
47
|
-
outputFile: "appsscript.ts"
|
|
48
|
-
};
|
|
49
|
-
gasnukiOptions = {
|
|
50
|
-
...defaultOptions,
|
|
51
|
-
...fileConfig,
|
|
52
|
-
...options || {}
|
|
53
|
-
};
|
|
43
|
+
await reloadOptions();
|
|
54
44
|
},
|
|
55
45
|
async configureServer(server) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
46
|
+
server.watcher.on("all", async (_event, filePath) => {
|
|
47
|
+
const fileName = path.basename(filePath);
|
|
48
|
+
if (fileName.startsWith("gasnuki.config.")) {
|
|
49
|
+
consola.info("[gasnuki] Config file changed, reloading...");
|
|
50
|
+
await reloadOptions();
|
|
51
|
+
runGeneration("config change");
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const targetDir = path.resolve(projectRoot, gasnukiOptions.srcDir);
|
|
59
55
|
const relativePath = path.relative(targetDir, filePath);
|
|
60
56
|
if (!relativePath.startsWith("..") && relativePath !== "..") {
|
|
61
57
|
runGeneration(path.relative(projectRoot, filePath));
|
|
62
58
|
}
|
|
63
59
|
});
|
|
60
|
+
runGeneration("server startup");
|
|
64
61
|
}
|
|
65
62
|
};
|
|
63
|
+
async function reloadOptions() {
|
|
64
|
+
const fileConfig = await loadConfig(projectRoot);
|
|
65
|
+
const defaultOptions = {
|
|
66
|
+
srcDir: "server",
|
|
67
|
+
outDir: "types",
|
|
68
|
+
outputFile: "appsscript.ts"
|
|
69
|
+
};
|
|
70
|
+
gasnukiOptions = {
|
|
71
|
+
...defaultOptions,
|
|
72
|
+
...fileConfig,
|
|
73
|
+
...options || {}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
66
76
|
}
|
|
67
77
|
|
|
68
78
|
export { gasnuki };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ciderjs/gasnuki",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
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",
|
|
@@ -68,12 +68,12 @@
|
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@biomejs/biome": "^2.3.11",
|
|
71
|
-
"@types/node": "^25.0.
|
|
72
|
-
"@vitest/coverage-v8": "4.0.
|
|
71
|
+
"@types/node": "^25.0.9",
|
|
72
|
+
"@vitest/coverage-v8": "4.0.17",
|
|
73
73
|
"typescript": "^5.9.3",
|
|
74
74
|
"unbuild": "^3.6.1",
|
|
75
75
|
"vite": "^7.3.1",
|
|
76
|
-
"vitest": "4.0.
|
|
76
|
+
"vitest": "4.0.17"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
79
|
"vite": "^7"
|