@stripe/extensibility-language-server 0.2.8
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/LICENSE.md +19 -0
- package/dist/extensibility-language-server-alpha.d.ts +46 -0
- package/dist/extensibility-language-server-beta.d.ts +46 -0
- package/dist/extensibility-language-server-internal.d.ts +46 -0
- package/dist/extensibility-language-server-plugin-alpha.d.ts +10 -0
- package/dist/extensibility-language-server-plugin-beta.d.ts +10 -0
- package/dist/extensibility-language-server-plugin-internal.d.ts +10 -0
- package/dist/extensibility-language-server-plugin-public.d.ts +10 -0
- package/dist/extensibility-language-server-public.d.ts +46 -0
- package/dist/extensibility-language-server-server-alpha.d.ts +25 -0
- package/dist/extensibility-language-server-server-beta.d.ts +25 -0
- package/dist/extensibility-language-server-server-internal.d.ts +25 -0
- package/dist/extensibility-language-server-server-public.d.ts +25 -0
- package/dist/index.cjs +123 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +97 -0
- package/dist/plugin/index.d.ts +8 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin.cjs +112 -0
- package/dist/plugin.js +87 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/server.d.ts +22 -0
- package/dist/server/server.d.ts.map +1 -0
- package/dist/server.cjs +36 -0
- package/dist/server.js +11 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +60 -0
- package/plugin.cjs +1 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (C) 2026 Stripe, Inc. (https://stripe.com)
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
|
11
|
+
all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extensibility Language Server
|
|
3
|
+
*
|
|
4
|
+
* Provides a tsserver plugin and standalone LSP language server for the
|
|
5
|
+
* Stripe extensibility SDK, built on formspec building blocks.
|
|
6
|
+
*
|
|
7
|
+
* Consumers should import from subpath exports:
|
|
8
|
+
* - `extensibility-language-server/plugin` — tsserver plugin
|
|
9
|
+
* - `extensibility-language-server/server` — LSP language server
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import type { Connection } from 'vscode-languageserver/node.js';
|
|
15
|
+
import { CreateServerOptions as CreateServerOptions_2 } from '@formspec/language-server';
|
|
16
|
+
import type * as tsServer from 'typescript/lib/tsserverlibrary.js';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Creates and configures the Extensibility language server connection.
|
|
20
|
+
*
|
|
21
|
+
* The current implementation delegates to FormSpec's packaged server and keeps
|
|
22
|
+
* a local wrapper so Extensibility-specific handlers can be interleaved later
|
|
23
|
+
* without changing this package's public API.
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export declare function createServer(options?: CreateServerOptions): Connection;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Public configuration for constructing the Extensibility language server.
|
|
31
|
+
*
|
|
32
|
+
* This currently matches FormSpec's server options, while preserving an SDK-owned
|
|
33
|
+
* wrapper seam where Extensibility-specific LSP behavior can be layered in.
|
|
34
|
+
*
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
export declare type CreateServerOptions = CreateServerOptions_2;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Initializes the Extensibility TypeScript language service plugin.
|
|
41
|
+
*
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
export declare function init(modules: { readonly typescript: typeof tsServer }): tsServer.server.PluginModule;
|
|
45
|
+
|
|
46
|
+
export { }
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extensibility Language Server
|
|
3
|
+
*
|
|
4
|
+
* Provides a tsserver plugin and standalone LSP language server for the
|
|
5
|
+
* Stripe extensibility SDK, built on formspec building blocks.
|
|
6
|
+
*
|
|
7
|
+
* Consumers should import from subpath exports:
|
|
8
|
+
* - `extensibility-language-server/plugin` — tsserver plugin
|
|
9
|
+
* - `extensibility-language-server/server` — LSP language server
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import type { Connection } from 'vscode-languageserver/node.js';
|
|
15
|
+
import { CreateServerOptions as CreateServerOptions_2 } from '@formspec/language-server';
|
|
16
|
+
import type * as tsServer from 'typescript/lib/tsserverlibrary.js';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Creates and configures the Extensibility language server connection.
|
|
20
|
+
*
|
|
21
|
+
* The current implementation delegates to FormSpec's packaged server and keeps
|
|
22
|
+
* a local wrapper so Extensibility-specific handlers can be interleaved later
|
|
23
|
+
* without changing this package's public API.
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export declare function createServer(options?: CreateServerOptions): Connection;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Public configuration for constructing the Extensibility language server.
|
|
31
|
+
*
|
|
32
|
+
* This currently matches FormSpec's server options, while preserving an SDK-owned
|
|
33
|
+
* wrapper seam where Extensibility-specific LSP behavior can be layered in.
|
|
34
|
+
*
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
export declare type CreateServerOptions = CreateServerOptions_2;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Initializes the Extensibility TypeScript language service plugin.
|
|
41
|
+
*
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
export declare function init(modules: { readonly typescript: typeof tsServer }): tsServer.server.PluginModule;
|
|
45
|
+
|
|
46
|
+
export { }
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extensibility Language Server
|
|
3
|
+
*
|
|
4
|
+
* Provides a tsserver plugin and standalone LSP language server for the
|
|
5
|
+
* Stripe extensibility SDK, built on formspec building blocks.
|
|
6
|
+
*
|
|
7
|
+
* Consumers should import from subpath exports:
|
|
8
|
+
* - `extensibility-language-server/plugin` — tsserver plugin
|
|
9
|
+
* - `extensibility-language-server/server` — LSP language server
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import type { Connection } from 'vscode-languageserver/node.js';
|
|
15
|
+
import { CreateServerOptions as CreateServerOptions_2 } from '@formspec/language-server';
|
|
16
|
+
import type * as tsServer from 'typescript/lib/tsserverlibrary.js';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Creates and configures the Extensibility language server connection.
|
|
20
|
+
*
|
|
21
|
+
* The current implementation delegates to FormSpec's packaged server and keeps
|
|
22
|
+
* a local wrapper so Extensibility-specific handlers can be interleaved later
|
|
23
|
+
* without changing this package's public API.
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export declare function createServer(options?: CreateServerOptions): Connection;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Public configuration for constructing the Extensibility language server.
|
|
31
|
+
*
|
|
32
|
+
* This currently matches FormSpec's server options, while preserving an SDK-owned
|
|
33
|
+
* wrapper seam where Extensibility-specific LSP behavior can be layered in.
|
|
34
|
+
*
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
export declare type CreateServerOptions = CreateServerOptions_2;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Initializes the Extensibility TypeScript language service plugin.
|
|
41
|
+
*
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
export declare function init(modules: { readonly typescript: typeof tsServer }): tsServer.server.PluginModule;
|
|
45
|
+
|
|
46
|
+
export { }
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type * as tsServer from 'typescript/lib/tsserverlibrary.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Initializes the Extensibility TypeScript language service plugin.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare function init(modules: { readonly typescript: typeof tsServer }): tsServer.server.PluginModule;
|
|
9
|
+
|
|
10
|
+
export { }
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type * as tsServer from 'typescript/lib/tsserverlibrary.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Initializes the Extensibility TypeScript language service plugin.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare function init(modules: { readonly typescript: typeof tsServer }): tsServer.server.PluginModule;
|
|
9
|
+
|
|
10
|
+
export { }
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type * as tsServer from 'typescript/lib/tsserverlibrary.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Initializes the Extensibility TypeScript language service plugin.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare function init(modules: { readonly typescript: typeof tsServer }): tsServer.server.PluginModule;
|
|
9
|
+
|
|
10
|
+
export { }
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type * as tsServer from 'typescript/lib/tsserverlibrary.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Initializes the Extensibility TypeScript language service plugin.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare function init(modules: { readonly typescript: typeof tsServer }): tsServer.server.PluginModule;
|
|
9
|
+
|
|
10
|
+
export { }
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extensibility Language Server
|
|
3
|
+
*
|
|
4
|
+
* Provides a tsserver plugin and standalone LSP language server for the
|
|
5
|
+
* Stripe extensibility SDK, built on formspec building blocks.
|
|
6
|
+
*
|
|
7
|
+
* Consumers should import from subpath exports:
|
|
8
|
+
* - `extensibility-language-server/plugin` — tsserver plugin
|
|
9
|
+
* - `extensibility-language-server/server` — LSP language server
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import type { Connection } from 'vscode-languageserver/node.js';
|
|
15
|
+
import { CreateServerOptions as CreateServerOptions_2 } from '@formspec/language-server';
|
|
16
|
+
import type * as tsServer from 'typescript/lib/tsserverlibrary.js';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Creates and configures the Extensibility language server connection.
|
|
20
|
+
*
|
|
21
|
+
* The current implementation delegates to FormSpec's packaged server and keeps
|
|
22
|
+
* a local wrapper so Extensibility-specific handlers can be interleaved later
|
|
23
|
+
* without changing this package's public API.
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export declare function createServer(options?: CreateServerOptions): Connection;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Public configuration for constructing the Extensibility language server.
|
|
31
|
+
*
|
|
32
|
+
* This currently matches FormSpec's server options, while preserving an SDK-owned
|
|
33
|
+
* wrapper seam where Extensibility-specific LSP behavior can be layered in.
|
|
34
|
+
*
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
export declare type CreateServerOptions = CreateServerOptions_2;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Initializes the Extensibility TypeScript language service plugin.
|
|
41
|
+
*
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
export declare function init(modules: { readonly typescript: typeof tsServer }): tsServer.server.PluginModule;
|
|
45
|
+
|
|
46
|
+
export { }
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Connection } from 'vscode-languageserver/node.js';
|
|
2
|
+
import { CreateServerOptions as CreateServerOptions_2 } from '@formspec/language-server';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Creates and configures the Extensibility language server connection.
|
|
6
|
+
*
|
|
7
|
+
* The current implementation delegates to FormSpec's packaged server and keeps
|
|
8
|
+
* a local wrapper so Extensibility-specific handlers can be interleaved later
|
|
9
|
+
* without changing this package's public API.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export declare function createServer(options?: CreateServerOptions): Connection;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Public configuration for constructing the Extensibility language server.
|
|
17
|
+
*
|
|
18
|
+
* This currently matches FormSpec's server options, while preserving an SDK-owned
|
|
19
|
+
* wrapper seam where Extensibility-specific LSP behavior can be layered in.
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export declare type CreateServerOptions = CreateServerOptions_2;
|
|
24
|
+
|
|
25
|
+
export { }
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Connection } from 'vscode-languageserver/node.js';
|
|
2
|
+
import { CreateServerOptions as CreateServerOptions_2 } from '@formspec/language-server';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Creates and configures the Extensibility language server connection.
|
|
6
|
+
*
|
|
7
|
+
* The current implementation delegates to FormSpec's packaged server and keeps
|
|
8
|
+
* a local wrapper so Extensibility-specific handlers can be interleaved later
|
|
9
|
+
* without changing this package's public API.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export declare function createServer(options?: CreateServerOptions): Connection;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Public configuration for constructing the Extensibility language server.
|
|
17
|
+
*
|
|
18
|
+
* This currently matches FormSpec's server options, while preserving an SDK-owned
|
|
19
|
+
* wrapper seam where Extensibility-specific LSP behavior can be layered in.
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export declare type CreateServerOptions = CreateServerOptions_2;
|
|
24
|
+
|
|
25
|
+
export { }
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Connection } from 'vscode-languageserver/node.js';
|
|
2
|
+
import { CreateServerOptions as CreateServerOptions_2 } from '@formspec/language-server';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Creates and configures the Extensibility language server connection.
|
|
6
|
+
*
|
|
7
|
+
* The current implementation delegates to FormSpec's packaged server and keeps
|
|
8
|
+
* a local wrapper so Extensibility-specific handlers can be interleaved later
|
|
9
|
+
* without changing this package's public API.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export declare function createServer(options?: CreateServerOptions): Connection;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Public configuration for constructing the Extensibility language server.
|
|
17
|
+
*
|
|
18
|
+
* This currently matches FormSpec's server options, while preserving an SDK-owned
|
|
19
|
+
* wrapper seam where Extensibility-specific LSP behavior can be layered in.
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export declare type CreateServerOptions = CreateServerOptions_2;
|
|
24
|
+
|
|
25
|
+
export { }
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Connection } from 'vscode-languageserver/node.js';
|
|
2
|
+
import { CreateServerOptions as CreateServerOptions_2 } from '@formspec/language-server';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Creates and configures the Extensibility language server connection.
|
|
6
|
+
*
|
|
7
|
+
* The current implementation delegates to FormSpec's packaged server and keeps
|
|
8
|
+
* a local wrapper so Extensibility-specific handlers can be interleaved later
|
|
9
|
+
* without changing this package's public API.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export declare function createServer(options?: CreateServerOptions): Connection;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Public configuration for constructing the Extensibility language server.
|
|
17
|
+
*
|
|
18
|
+
* This currently matches FormSpec's server options, while preserving an SDK-owned
|
|
19
|
+
* wrapper seam where Extensibility-specific LSP behavior can be layered in.
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export declare type CreateServerOptions = CreateServerOptions_2;
|
|
24
|
+
|
|
25
|
+
export { }
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
createServer: () => createServer,
|
|
24
|
+
init: () => init
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(src_exports);
|
|
27
|
+
|
|
28
|
+
// src/plugin/index.ts
|
|
29
|
+
var import_ts_plugin = require("@formspec/ts-plugin");
|
|
30
|
+
var services = /* @__PURE__ */ new Map();
|
|
31
|
+
var PERF_LOG_ENV_VAR = "EXTENSIBILITY_PLUGIN_PROFILE";
|
|
32
|
+
var PERF_LOG_THRESHOLD_ENV_VAR = "EXTENSIBILITY_PLUGIN_PROFILE_THRESHOLD_MS";
|
|
33
|
+
function formatPluginError(error) {
|
|
34
|
+
return error instanceof Error ? error.stack ?? error.message : String(error);
|
|
35
|
+
}
|
|
36
|
+
function readBooleanEnvFlag(name) {
|
|
37
|
+
const rawValue = process.env[name];
|
|
38
|
+
return rawValue === "1" || rawValue === "true";
|
|
39
|
+
}
|
|
40
|
+
function readNumberEnvFlag(name) {
|
|
41
|
+
const rawValue = process.env[name];
|
|
42
|
+
if (rawValue === void 0 || rawValue.trim() === "") {
|
|
43
|
+
return void 0;
|
|
44
|
+
}
|
|
45
|
+
const parsed = Number(rawValue);
|
|
46
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
47
|
+
}
|
|
48
|
+
function getOrCreateService(info, typescriptVersion) {
|
|
49
|
+
const workspaceRoot = info.project.getCurrentDirectory();
|
|
50
|
+
const existing = services.get(workspaceRoot);
|
|
51
|
+
if (existing !== void 0) {
|
|
52
|
+
existing.referenceCount += 1;
|
|
53
|
+
attachProjectCloseHandler(info, workspaceRoot, existing);
|
|
54
|
+
return existing.service;
|
|
55
|
+
}
|
|
56
|
+
const performanceLogThresholdMs = readNumberEnvFlag(PERF_LOG_THRESHOLD_ENV_VAR);
|
|
57
|
+
const service = new import_ts_plugin.FormSpecPluginService({
|
|
58
|
+
workspaceRoot,
|
|
59
|
+
typescriptVersion,
|
|
60
|
+
getProgram: () => info.languageService.getProgram(),
|
|
61
|
+
logger: info.project.projectService.logger,
|
|
62
|
+
enablePerformanceLogging: readBooleanEnvFlag(PERF_LOG_ENV_VAR),
|
|
63
|
+
...performanceLogThresholdMs === void 0 ? {} : { performanceLogThresholdMs }
|
|
64
|
+
});
|
|
65
|
+
const serviceEntry = {
|
|
66
|
+
service,
|
|
67
|
+
referenceCount: 1
|
|
68
|
+
};
|
|
69
|
+
attachProjectCloseHandler(info, workspaceRoot, serviceEntry);
|
|
70
|
+
service.start().catch((error) => {
|
|
71
|
+
info.project.projectService.logger.info(
|
|
72
|
+
`[Extensibility] Plugin service failed to start for ${workspaceRoot}: ${formatPluginError(error)}`
|
|
73
|
+
);
|
|
74
|
+
services.delete(workspaceRoot);
|
|
75
|
+
});
|
|
76
|
+
services.set(workspaceRoot, serviceEntry);
|
|
77
|
+
return service;
|
|
78
|
+
}
|
|
79
|
+
function attachProjectCloseHandler(info, workspaceRoot, serviceEntry) {
|
|
80
|
+
const originalClose = info.project.close.bind(info.project);
|
|
81
|
+
let closed = false;
|
|
82
|
+
info.project.close = () => {
|
|
83
|
+
if (closed) {
|
|
84
|
+
originalClose();
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
closed = true;
|
|
88
|
+
serviceEntry.referenceCount -= 1;
|
|
89
|
+
if (serviceEntry.referenceCount <= 0) {
|
|
90
|
+
services.delete(workspaceRoot);
|
|
91
|
+
void serviceEntry.service.stop().catch((error) => {
|
|
92
|
+
info.project.projectService.logger.info(
|
|
93
|
+
`[Extensibility] Failed to stop plugin service for ${workspaceRoot}: ${formatPluginError(error)}`
|
|
94
|
+
);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
originalClose();
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function init(modules) {
|
|
101
|
+
const typescriptVersion = modules.typescript.version;
|
|
102
|
+
return {
|
|
103
|
+
create(info) {
|
|
104
|
+
const service = getOrCreateService(info, typescriptVersion);
|
|
105
|
+
return (0, import_ts_plugin.createLanguageServiceProxy)(
|
|
106
|
+
info.languageService,
|
|
107
|
+
service.getSemanticService()
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// src/server/server.ts
|
|
114
|
+
var import_language_server = require("@formspec/language-server");
|
|
115
|
+
var import_extensibility_jsonschema_tools = require("@stripe/extensibility-jsonschema-tools");
|
|
116
|
+
function createServer(options = {}) {
|
|
117
|
+
return (0, import_language_server.createServer)({ config: import_extensibility_jsonschema_tools._stripeFormSpecConfig, ...options });
|
|
118
|
+
}
|
|
119
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
120
|
+
0 && (module.exports = {
|
|
121
|
+
createServer,
|
|
122
|
+
init
|
|
123
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extensibility Language Server
|
|
3
|
+
*
|
|
4
|
+
* Provides a tsserver plugin and standalone LSP language server for the
|
|
5
|
+
* Stripe extensibility SDK, built on formspec building blocks.
|
|
6
|
+
*
|
|
7
|
+
* Consumers should import from subpath exports:
|
|
8
|
+
* - `extensibility-language-server/plugin` — tsserver plugin
|
|
9
|
+
* - `extensibility-language-server/server` — LSP language server
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
export { init } from './plugin/index.js';
|
|
14
|
+
export { createServer } from './server/index.js';
|
|
15
|
+
export type { CreateServerOptions } from './server/index.js';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// src/plugin/index.ts
|
|
2
|
+
import { createLanguageServiceProxy, FormSpecPluginService } from "@formspec/ts-plugin";
|
|
3
|
+
var services = /* @__PURE__ */ new Map();
|
|
4
|
+
var PERF_LOG_ENV_VAR = "EXTENSIBILITY_PLUGIN_PROFILE";
|
|
5
|
+
var PERF_LOG_THRESHOLD_ENV_VAR = "EXTENSIBILITY_PLUGIN_PROFILE_THRESHOLD_MS";
|
|
6
|
+
function formatPluginError(error) {
|
|
7
|
+
return error instanceof Error ? error.stack ?? error.message : String(error);
|
|
8
|
+
}
|
|
9
|
+
function readBooleanEnvFlag(name) {
|
|
10
|
+
const rawValue = process.env[name];
|
|
11
|
+
return rawValue === "1" || rawValue === "true";
|
|
12
|
+
}
|
|
13
|
+
function readNumberEnvFlag(name) {
|
|
14
|
+
const rawValue = process.env[name];
|
|
15
|
+
if (rawValue === void 0 || rawValue.trim() === "") {
|
|
16
|
+
return void 0;
|
|
17
|
+
}
|
|
18
|
+
const parsed = Number(rawValue);
|
|
19
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
20
|
+
}
|
|
21
|
+
function getOrCreateService(info, typescriptVersion) {
|
|
22
|
+
const workspaceRoot = info.project.getCurrentDirectory();
|
|
23
|
+
const existing = services.get(workspaceRoot);
|
|
24
|
+
if (existing !== void 0) {
|
|
25
|
+
existing.referenceCount += 1;
|
|
26
|
+
attachProjectCloseHandler(info, workspaceRoot, existing);
|
|
27
|
+
return existing.service;
|
|
28
|
+
}
|
|
29
|
+
const performanceLogThresholdMs = readNumberEnvFlag(PERF_LOG_THRESHOLD_ENV_VAR);
|
|
30
|
+
const service = new FormSpecPluginService({
|
|
31
|
+
workspaceRoot,
|
|
32
|
+
typescriptVersion,
|
|
33
|
+
getProgram: () => info.languageService.getProgram(),
|
|
34
|
+
logger: info.project.projectService.logger,
|
|
35
|
+
enablePerformanceLogging: readBooleanEnvFlag(PERF_LOG_ENV_VAR),
|
|
36
|
+
...performanceLogThresholdMs === void 0 ? {} : { performanceLogThresholdMs }
|
|
37
|
+
});
|
|
38
|
+
const serviceEntry = {
|
|
39
|
+
service,
|
|
40
|
+
referenceCount: 1
|
|
41
|
+
};
|
|
42
|
+
attachProjectCloseHandler(info, workspaceRoot, serviceEntry);
|
|
43
|
+
service.start().catch((error) => {
|
|
44
|
+
info.project.projectService.logger.info(
|
|
45
|
+
`[Extensibility] Plugin service failed to start for ${workspaceRoot}: ${formatPluginError(error)}`
|
|
46
|
+
);
|
|
47
|
+
services.delete(workspaceRoot);
|
|
48
|
+
});
|
|
49
|
+
services.set(workspaceRoot, serviceEntry);
|
|
50
|
+
return service;
|
|
51
|
+
}
|
|
52
|
+
function attachProjectCloseHandler(info, workspaceRoot, serviceEntry) {
|
|
53
|
+
const originalClose = info.project.close.bind(info.project);
|
|
54
|
+
let closed = false;
|
|
55
|
+
info.project.close = () => {
|
|
56
|
+
if (closed) {
|
|
57
|
+
originalClose();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
closed = true;
|
|
61
|
+
serviceEntry.referenceCount -= 1;
|
|
62
|
+
if (serviceEntry.referenceCount <= 0) {
|
|
63
|
+
services.delete(workspaceRoot);
|
|
64
|
+
void serviceEntry.service.stop().catch((error) => {
|
|
65
|
+
info.project.projectService.logger.info(
|
|
66
|
+
`[Extensibility] Failed to stop plugin service for ${workspaceRoot}: ${formatPluginError(error)}`
|
|
67
|
+
);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
originalClose();
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function init(modules) {
|
|
74
|
+
const typescriptVersion = modules.typescript.version;
|
|
75
|
+
return {
|
|
76
|
+
create(info) {
|
|
77
|
+
const service = getOrCreateService(info, typescriptVersion);
|
|
78
|
+
return createLanguageServiceProxy(
|
|
79
|
+
info.languageService,
|
|
80
|
+
service.getSemanticService()
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// src/server/server.ts
|
|
87
|
+
import {
|
|
88
|
+
createServer as createFormSpecServer
|
|
89
|
+
} from "@formspec/language-server";
|
|
90
|
+
import { _stripeFormSpecConfig } from "@stripe/extensibility-jsonschema-tools";
|
|
91
|
+
function createServer(options = {}) {
|
|
92
|
+
return createFormSpecServer({ config: _stripeFormSpecConfig, ...options });
|
|
93
|
+
}
|
|
94
|
+
export {
|
|
95
|
+
createServer,
|
|
96
|
+
init
|
|
97
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type * as tsServer from 'typescript/lib/tsserverlibrary.js';
|
|
2
|
+
/**
|
|
3
|
+
* Initializes the Extensibility TypeScript language service plugin.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export declare function init(modules: { readonly typescript: typeof tsServer }): tsServer.server.PluginModule;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,QAAQ,MAAM,mCAAmC,CAAC;AAiGnE;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE;IAC5B,QAAQ,CAAC,UAAU,EAAE,OAAO,QAAQ,CAAC;CACtC,GAAG,QAAQ,CAAC,MAAM,CAAC,YAAY,CAW/B"}
|