@react-arch/importers 0.1.0
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 +21 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 React Arch
|
|
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.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BuildingDocument } from "@react-arch/core";
|
|
2
|
+
import { Diagnostic } from "@react-arch/validation";
|
|
3
|
+
|
|
4
|
+
//#region src/index.d.ts
|
|
5
|
+
interface ImportResult {
|
|
6
|
+
document: BuildingDocument | null;
|
|
7
|
+
diagnostics: Diagnostic[];
|
|
8
|
+
}
|
|
9
|
+
interface ModelImporter<TInput> {
|
|
10
|
+
readonly format: string;
|
|
11
|
+
import(input: TInput): Promise<ImportResult>;
|
|
12
|
+
}
|
|
13
|
+
declare const jsonImporter: ModelImporter<string>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { ImportResult, ModelImporter, jsonImporter };
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;UAUiB,YAAA;EACf,QAAA,EAAU,gBAAA;EACV,WAAA,EAAa,UAAU;AAAA;AAAA,UAGR,aAAA;EAAA,SACN,MAAA;EACT,MAAA,CAAO,KAAA,EAAO,MAAA,GAAS,OAAA,CAAQ,YAAA;AAAA;AAAA,cAGpB,YAAA,EAAc,aAAa"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { deserialize } from "@react-arch/core";
|
|
2
|
+
import { validateDocument } from "@react-arch/validation";
|
|
3
|
+
//#region src/index.ts
|
|
4
|
+
/**
|
|
5
|
+
* @react-arch/importers
|
|
6
|
+
*
|
|
7
|
+
* Import external formats into the canonical model. MVP implements React Arch
|
|
8
|
+
* JSON; the ModelImporter interface is designed so DXF/IFC/SVG/image tracing
|
|
9
|
+
* can be added later without changing call sites.
|
|
10
|
+
*/
|
|
11
|
+
const jsonImporter = {
|
|
12
|
+
format: "react-arch-json",
|
|
13
|
+
async import(input) {
|
|
14
|
+
try {
|
|
15
|
+
const document = deserialize(input);
|
|
16
|
+
const diagnostics = validateDocument(document);
|
|
17
|
+
return {
|
|
18
|
+
document: diagnostics.some((d) => d.severity === "error") ? null : document,
|
|
19
|
+
diagnostics
|
|
20
|
+
};
|
|
21
|
+
} catch (err) {
|
|
22
|
+
return {
|
|
23
|
+
document: null,
|
|
24
|
+
diagnostics: [{
|
|
25
|
+
severity: "error",
|
|
26
|
+
code: "parse",
|
|
27
|
+
message: err instanceof Error ? err.message : "Invalid JSON"
|
|
28
|
+
}]
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
//#endregion
|
|
34
|
+
export { jsonImporter };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * @react-arch/importers\n *\n * Import external formats into the canonical model. MVP implements React Arch\n * JSON; the ModelImporter interface is designed so DXF/IFC/SVG/image tracing\n * can be added later without changing call sites.\n */\nimport { deserialize, type BuildingDocument } from \"@react-arch/core\";\nimport { validateDocument, type Diagnostic } from \"@react-arch/validation\";\n\nexport interface ImportResult {\n document: BuildingDocument | null;\n diagnostics: Diagnostic[];\n}\n\nexport interface ModelImporter<TInput> {\n readonly format: string;\n import(input: TInput): Promise<ImportResult>;\n}\n\nexport const jsonImporter: ModelImporter<string> = {\n format: \"react-arch-json\",\n async import(input: string): Promise<ImportResult> {\n try {\n const document = deserialize(input);\n const diagnostics = validateDocument(document);\n const fatal = diagnostics.some((d) => d.severity === \"error\");\n return { document: fatal ? null : document, diagnostics };\n } catch (err) {\n return {\n document: null,\n diagnostics: [\n { severity: \"error\", code: \"parse\", message: err instanceof Error ? err.message : \"Invalid JSON\" },\n ],\n };\n }\n },\n};\n"],"mappings":";;;;;;;;;;AAoBA,MAAa,eAAsC;CACjD,QAAQ;CACR,MAAM,OAAO,OAAsC;EACjD,IAAI;GACF,MAAM,WAAW,YAAY,KAAK;GAClC,MAAM,cAAc,iBAAiB,QAAQ;GAE7C,OAAO;IAAE,UADK,YAAY,MAAM,MAAM,EAAE,aAAa,OAC9B,IAAI,OAAO;IAAU;GAAY;EAC1D,SAAS,KAAK;GACZ,OAAO;IACL,UAAU;IACV,aAAa,CACX;KAAE,UAAU;KAAS,MAAM;KAAS,SAAS,eAAe,QAAQ,IAAI,UAAU;IAAe,CACnG;GACF;EACF;CACF;AACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@react-arch/importers",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@react-arch/core": "0.1.0",
|
|
16
|
+
"@react-arch/validation": "0.1.0"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"typescript": "^5.7.2",
|
|
20
|
+
"vitest": "^2.1.8"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/react-arch/react-arch.git",
|
|
31
|
+
"directory": "packages/importers"
|
|
32
|
+
},
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"scripts": {
|
|
35
|
+
"typecheck": "tsc --noEmit",
|
|
36
|
+
"test": "vitest run --passWithNoTests",
|
|
37
|
+
"lint": "oxlint src",
|
|
38
|
+
"build": "tsdown"
|
|
39
|
+
}
|
|
40
|
+
}
|