@coze-editor/extension-json-ast 0.1.0-alpha.09ffeb

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 coze-dev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,36 @@
1
+ // src/index.ts
2
+ import { TextDocument } from "vscode-languageserver-textdocument";
3
+ import { singleton } from "@coze-editor/utils";
4
+ import {
5
+ parse,
6
+ findNodeAtOffset
7
+ } from "@coze-editor/parser-json";
8
+ import { StateField } from "@codemirror/state";
9
+ var field = StateField.define({
10
+ create(state) {
11
+ return getAST(state);
12
+ },
13
+ update(value, tr) {
14
+ if (tr.docChanged) {
15
+ return getAST(tr.state);
16
+ }
17
+ return value;
18
+ }
19
+ });
20
+ function getAST(state) {
21
+ const source = state.doc.toString();
22
+ const textDocument = TextDocument.create(
23
+ "file://untitled.json",
24
+ "json",
25
+ 1,
26
+ source
27
+ );
28
+ const { ast } = parse(textDocument, { collectComments: true });
29
+ return ast;
30
+ }
31
+ var index_default = singleton("cm-extension-json-ast", field);
32
+ export {
33
+ index_default as default,
34
+ findNodeAtOffset
35
+ };
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// Copyright (c) 2025 coze-dev\n// SPDX-License-Identifier: MIT\n\nimport { TextDocument } from 'vscode-languageserver-textdocument';\nimport { singleton } from '@coze-editor/utils';\nimport {\n type ASTNode,\n parse,\n findNodeAtOffset,\n} from '@coze-editor/parser-json';\nimport { type EditorState, StateField } from '@codemirror/state';\n\nconst field = StateField.define<ASTNode | undefined>({\n create(state) {\n return getAST(state);\n },\n update(value, tr) {\n if (tr.docChanged) {\n return getAST(tr.state);\n }\n\n return value;\n },\n});\n\nfunction getAST(state: EditorState) {\n const source = state.doc.toString();\n const textDocument = TextDocument.create(\n 'file://untitled.json',\n 'json',\n 1,\n source,\n );\n const { ast } = parse(textDocument, { collectComments: true });\n return ast;\n}\n\nexport default singleton('cm-extension-json-ast', field);\n\nexport { findNodeAtOffset };\n\nexport type {\n ASTNode,\n ObjectASTNode,\n PropertyASTNode,\n ArrayASTNode,\n StringASTNode,\n NumberASTNode,\n BooleanASTNode,\n NullASTNode,\n} from '@coze-editor/parser-json';\n"],"mappings":";AAGA,SAAS,oBAAoB;AAC7B,SAAS,iBAAiB;AAC1B;AAAA,EAEE;AAAA,EACA;AAAA,OACK;AACP,SAA2B,kBAAkB;AAE7C,IAAM,QAAQ,WAAW,OAA4B;AAAA,EACnD,OAAO,OAAO;AACZ,WAAO,OAAO,KAAK;AAAA,EACrB;AAAA,EACA,OAAO,OAAO,IAAI;AAChB,QAAI,GAAG,YAAY;AACjB,aAAO,OAAO,GAAG,KAAK;AAAA,IACxB;AAEA,WAAO;AAAA,EACT;AACF,CAAC;AAED,SAAS,OAAO,OAAoB;AAClC,QAAM,SAAS,MAAM,IAAI,SAAS;AAClC,QAAM,eAAe,aAAa;AAAA,IAChC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,QAAM,EAAE,IAAI,IAAI,MAAM,cAAc,EAAE,iBAAiB,KAAK,CAAC;AAC7D,SAAO;AACT;AAEA,IAAO,gBAAQ,UAAU,yBAAyB,KAAK;","names":[]}
@@ -0,0 +1,7 @@
1
+ import { ASTNode } from '@coze-editor/parser-json';
2
+ export { ASTNode, ArrayASTNode, BooleanASTNode, NullASTNode, NumberASTNode, ObjectASTNode, PropertyASTNode, StringASTNode, findNodeAtOffset } from '@coze-editor/parser-json';
3
+ import { StateField } from '@codemirror/state';
4
+
5
+ declare const _default: StateField<ASTNode>;
6
+
7
+ export { _default as default };
@@ -0,0 +1,7 @@
1
+ import { ASTNode } from '@coze-editor/parser-json';
2
+ export { ASTNode, ArrayASTNode, BooleanASTNode, NullASTNode, NumberASTNode, ObjectASTNode, PropertyASTNode, StringASTNode, findNodeAtOffset } from '@coze-editor/parser-json';
3
+ import { StateField } from '@codemirror/state';
4
+
5
+ declare const _default: StateField<ASTNode>;
6
+
7
+ export { _default as default };
package/dist/index.js ADDED
@@ -0,0 +1,57 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/index.ts
20
+ var index_exports = {};
21
+ __export(index_exports, {
22
+ default: () => index_default,
23
+ findNodeAtOffset: () => import_parser_json.findNodeAtOffset
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+ var import_vscode_languageserver_textdocument = require("vscode-languageserver-textdocument");
27
+ var import_utils = require("@coze-editor/utils");
28
+ var import_parser_json = require("@coze-editor/parser-json");
29
+ var import_state = require("@codemirror/state");
30
+ var field = import_state.StateField.define({
31
+ create(state) {
32
+ return getAST(state);
33
+ },
34
+ update(value, tr) {
35
+ if (tr.docChanged) {
36
+ return getAST(tr.state);
37
+ }
38
+ return value;
39
+ }
40
+ });
41
+ function getAST(state) {
42
+ const source = state.doc.toString();
43
+ const textDocument = import_vscode_languageserver_textdocument.TextDocument.create(
44
+ "file://untitled.json",
45
+ "json",
46
+ 1,
47
+ source
48
+ );
49
+ const { ast } = (0, import_parser_json.parse)(textDocument, { collectComments: true });
50
+ return ast;
51
+ }
52
+ var index_default = (0, import_utils.singleton)("cm-extension-json-ast", field);
53
+ // Annotate the CommonJS export names for ESM import in node:
54
+ 0 && (module.exports = {
55
+ findNodeAtOffset
56
+ });
57
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Copyright (c) 2025 coze-dev\n// SPDX-License-Identifier: MIT\n\nimport { TextDocument } from 'vscode-languageserver-textdocument';\nimport { singleton } from '@coze-editor/utils';\nimport {\n type ASTNode,\n parse,\n findNodeAtOffset,\n} from '@coze-editor/parser-json';\nimport { type EditorState, StateField } from '@codemirror/state';\n\nconst field = StateField.define<ASTNode | undefined>({\n create(state) {\n return getAST(state);\n },\n update(value, tr) {\n if (tr.docChanged) {\n return getAST(tr.state);\n }\n\n return value;\n },\n});\n\nfunction getAST(state: EditorState) {\n const source = state.doc.toString();\n const textDocument = TextDocument.create(\n 'file://untitled.json',\n 'json',\n 1,\n source,\n );\n const { ast } = parse(textDocument, { collectComments: true });\n return ast;\n}\n\nexport default singleton('cm-extension-json-ast', field);\n\nexport { findNodeAtOffset };\n\nexport type {\n ASTNode,\n ObjectASTNode,\n PropertyASTNode,\n ArrayASTNode,\n StringASTNode,\n NumberASTNode,\n BooleanASTNode,\n NullASTNode,\n} from '@coze-editor/parser-json';\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,gDAA6B;AAC7B,mBAA0B;AAC1B,yBAIO;AACP,mBAA6C;AAE7C,IAAM,QAAQ,wBAAW,OAA4B;AAAA,EACnD,OAAO,OAAO;AACZ,WAAO,OAAO,KAAK;AAAA,EACrB;AAAA,EACA,OAAO,OAAO,IAAI;AAChB,QAAI,GAAG,YAAY;AACjB,aAAO,OAAO,GAAG,KAAK;AAAA,IACxB;AAEA,WAAO;AAAA,EACT;AACF,CAAC;AAED,SAAS,OAAO,OAAoB;AAClC,QAAM,SAAS,MAAM,IAAI,SAAS;AAClC,QAAM,eAAe,uDAAa;AAAA,IAChC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,QAAM,EAAE,IAAI,QAAI,0BAAM,cAAc,EAAE,iBAAiB,KAAK,CAAC;AAC7D,SAAO;AACT;AAEA,IAAO,oBAAQ,wBAAU,yBAAyB,KAAK;","names":[]}
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@coze-editor/extension-json-ast",
3
+ "version": "0.1.0-alpha.09ffeb",
4
+ "description": "extension-json-ast",
5
+ "license": "MIT",
6
+ "author": "fengzilong",
7
+ "maintainers": [],
8
+ "sideEffects": [
9
+ "**/*.css",
10
+ "**/*.less",
11
+ "**/*.sass",
12
+ "**/*.scss"
13
+ ],
14
+ "main": "./dist/esm/index.js",
15
+ "module": "./dist/esm/index.js",
16
+ "types": "./dist/index.d.ts",
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "scripts": {
21
+ "build": "tsup",
22
+ "lint": "eslint && tsc --noEmit"
23
+ },
24
+ "dependencies": {
25
+ "@coze-editor/parser-json": "0.1.0-alpha.09ffeb",
26
+ "@coze-editor/utils": "0.1.0-alpha.09ffeb",
27
+ "vscode-languageserver-textdocument": "^1.0.12"
28
+ },
29
+ "devDependencies": {
30
+ "@codemirror/state": "^6.4.1",
31
+ "@codemirror/view": "^6.26.1",
32
+ "@coze-arch/ts-config": "workspace:*",
33
+ "@coze-editor/eslint-config": "workspace:*",
34
+ "@types/node": "^22",
35
+ "eslint": "9.14.0",
36
+ "tsup": "^8.0.1",
37
+ "typescript": "^5.8.2"
38
+ },
39
+ "peerDependencies": {
40
+ "@codemirror/state": "^6.4.1",
41
+ "@codemirror/view": "^6.26.1"
42
+ },
43
+ "publishConfig": {
44
+ "access": "public",
45
+ "registry": "https://registry.npmjs.org"
46
+ },
47
+ "test:main": "./src/index.ts"
48
+ }