@kubohiroya/turbowarp-aframe 0.6.0 → 0.8.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/README.ja.md +6 -1
- package/README.md +6 -1
- package/dist/turbowarp-aframe.js +8122 -61
- package/docs/architecture.ja.md +1 -1
- package/docs/architecture.md +1 -1
- package/docs/editor-schema-ci-fix-20261018.ja.md +25 -0
- package/docs/editor-schema-ci-fix-20261018.json +88 -0
- package/docs/editor-schema-publication.ja.md +13 -0
- package/docs/editor-schema-publication.json +100 -0
- package/docs/editor-schema-verification.json +50 -0
- package/docs/editor-schema.ja.md +23 -0
- package/docs/index.html +55 -1
- package/docs/source-editor.ja.md +13 -0
- package/docs/stage-2-publication.ja.md +34 -0
- package/docs/stage-2-publication.json +67 -0
- package/lib-editor/schemas/block-editor-template-compat.schema.json +48 -0
- package/lib-editor/src/editor-schema.d.ts +44 -0
- package/lib-editor/src/editor-schema.js +100 -0
- package/lib-editor/src/template-validation.d.ts +10 -0
- package/lib-editor/src/template-validation.js +69 -0
- package/package.json +20 -5
- package/schemas/block-editor-template-compat.schema.json +48 -0
- package/src/editor-schema.ts +111 -0
- package/src/extension.ts +18 -77
- package/src/runtime-capability.ts +17 -0
- package/src/source-editors.ts +30 -0
- package/src/template-validation.ts +79 -0
- package/schemas/extension-manifest.schema.json +0 -49
- package/src/extension-manifest.ts +0 -149
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"scope": "stage-2-stable-release",
|
|
3
|
+
"version": "0.8.0",
|
|
4
|
+
"previousVersion": "0.7.0",
|
|
5
|
+
"baseHead": "224775e7207e221d4c91b2ee4a7229d61c44c94f",
|
|
6
|
+
"issue": "https://github.com/kubohiroya/turbowarp-aframe/issues/21",
|
|
7
|
+
"issueWrites": "not performed in this release; Ref only, no automatic close",
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@kubohiroya/turbowarp-extension-data-editor": "git+https://github.com/kubohiroya/turbowarp-extension-data-editor.git#76fa1d50a3c188082ceef723ea018a9d8769ea6e"
|
|
10
|
+
},
|
|
11
|
+
"commonBuildInfo": {
|
|
12
|
+
"name": "@kubohiroya/turbowarp-extension-data-editor",
|
|
13
|
+
"version": "0.2.0",
|
|
14
|
+
"repository": "https://github.com/kubohiroya/turbowarp-extension-data-editor",
|
|
15
|
+
"revision": "76fa1d50a3c188082ceef723ea018a9d8769ea6e",
|
|
16
|
+
"sourceState": "archive",
|
|
17
|
+
"sourceSha256": "912efc0438710958698527aa5c26a33b0b1c2da280f91d36b048f6f2389a48f0",
|
|
18
|
+
"capabilities": {
|
|
19
|
+
"preparedSource": 1
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"commonMainTarballSha256": "f51d14a502442336d6803009e3f6780fb03f7c3c51203287fed83073551a9194",
|
|
23
|
+
"commonMainTarballBuildInfo": {
|
|
24
|
+
"name": "@kubohiroya/turbowarp-extension-data-editor",
|
|
25
|
+
"version": "0.2.0",
|
|
26
|
+
"repository": "https://github.com/kubohiroya/turbowarp-extension-data-editor",
|
|
27
|
+
"revision": "76fa1d50a3c188082ceef723ea018a9d8769ea6e",
|
|
28
|
+
"sourceState": "commit",
|
|
29
|
+
"sourceSha256": "912efc0438710958698527aa5c26a33b0b1c2da280f91d36b048f6f2389a48f0",
|
|
30
|
+
"capabilities": {
|
|
31
|
+
"preparedSource": 1
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"commonProvenance": "Git prepare archive and main pack commit identify the same revision/sourceSha256; provenance sourceState is intentionally distinguished",
|
|
35
|
+
"fastUri": "3.1.8 across direct/common-AJV and all lock nodes",
|
|
36
|
+
"reactDomTestPeer": "devDependency 18.3.1 exact; no production API/permission change",
|
|
37
|
+
"node": "22.23.3",
|
|
38
|
+
"packageManager": "pnpm@11.11.0",
|
|
39
|
+
"fullTests": 60,
|
|
40
|
+
"fullTestFiles": 6,
|
|
41
|
+
"generatedFiles": 7,
|
|
42
|
+
"generatedSha256": {
|
|
43
|
+
"dist/extension-manifest.json": "8eac539f8ac68b78207e43ebc928834d66b694996db8acde47d916b34652988a",
|
|
44
|
+
"dist/turbowarp-aframe.js": "34c3555fcb97134f5d5028c39c2174230181ea4f851276f124ae98317fe94f97",
|
|
45
|
+
"lib-editor/schemas/block-editor-template-compat.schema.json": "10d385bedffe4133c374059278ed7393023055af23d2a26d49099d5ffaac0e75",
|
|
46
|
+
"lib-editor/src/editor-schema.d.ts": "cbe86a73ec3f2673da0c4d6bc48ff4d9152faaebd0bb4b5807b48b8d6ad09bd7",
|
|
47
|
+
"lib-editor/src/template-validation.js": "9726e75a5f5d2f8d9e75627b2a131245a8bc9fc84da0d23b4b3035eca7a0e2b1",
|
|
48
|
+
"lib-editor/src/editor-schema.js": "c04b24e30465589b35b53ff4d3e682b40b429452885011e58b16ed828838c935",
|
|
49
|
+
"lib-editor/src/template-validation.d.ts": "dec81b820da071d823a9909dd65a0a6b36d08391ddce5a0bd7c50f7b686ee021"
|
|
50
|
+
},
|
|
51
|
+
"samePathTwoBuildsMatch": true,
|
|
52
|
+
"freshCrossPathBuildMatches": true,
|
|
53
|
+
"productionAudit": "0 vulnerabilities",
|
|
54
|
+
"historicalStage2Subset": {
|
|
55
|
+
"count": 659,
|
|
56
|
+
"note": "prior whole-cohort related cases; not added to current full suite",
|
|
57
|
+
"guiCases": 5,
|
|
58
|
+
"stepsPerCase": 8
|
|
59
|
+
},
|
|
60
|
+
"flags": {
|
|
61
|
+
"blockEditorSourceForms": false,
|
|
62
|
+
"blockEditorDialogsRequired": true
|
|
63
|
+
},
|
|
64
|
+
"postCommitChecks": "repository check-dist/docs Git guards run after commit; CI outcome recorded in PR and aggregate",
|
|
65
|
+
"publication": "user-authorized commit/push/PR/squash merge and npm release; npm publisher is coordinated separately",
|
|
66
|
+
"rollback": "flag OFF; reverse dependency revert package/lock/allowBuilds; retain published npm versions and publish fixes under new versions"
|
|
67
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://kubohiroya.github.io/turbowarp-aframe/schemas/block-editor-template-compat.schema.json",
|
|
4
|
+
"title": "A-Frame existing parser compatible template",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"properties": {
|
|
8
|
+
"type": {
|
|
9
|
+
"type": "string"
|
|
10
|
+
},
|
|
11
|
+
"id": {
|
|
12
|
+
"type": "string"
|
|
13
|
+
},
|
|
14
|
+
"class": {
|
|
15
|
+
"oneOf": [
|
|
16
|
+
{
|
|
17
|
+
"type": "string"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"type": "array",
|
|
21
|
+
"items": {
|
|
22
|
+
"type": "string"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
"classes": {
|
|
28
|
+
"type": "array",
|
|
29
|
+
"items": {
|
|
30
|
+
"type": "string"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"data": {
|
|
34
|
+
"type": "object",
|
|
35
|
+
"additionalProperties": true
|
|
36
|
+
},
|
|
37
|
+
"attributes": {
|
|
38
|
+
"type": "object",
|
|
39
|
+
"additionalProperties": true
|
|
40
|
+
},
|
|
41
|
+
"children": {
|
|
42
|
+
"type": "array",
|
|
43
|
+
"items": {
|
|
44
|
+
"$ref": "#"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { SchemaValidationContext } from '@kubohiroya/turbowarp-extension-data-editor/schema';
|
|
2
|
+
import type { SchemaBundle, SyncOwnerValidator } from '@kubohiroya/turbowarp-extension-data-editor/schema';
|
|
3
|
+
export { validateTemplateNode } from './template-validation.js';
|
|
4
|
+
/** Parser-compatible gate; the older strict public schema is reference material only. */
|
|
5
|
+
export declare const templateSchemaBundle: SchemaBundle;
|
|
6
|
+
export declare const validateTemplateInput: SyncOwnerValidator;
|
|
7
|
+
export declare function decodeTemplateSource(source: string): {
|
|
8
|
+
source: string;
|
|
9
|
+
format: "json";
|
|
10
|
+
variantId: "template-json";
|
|
11
|
+
data: unknown;
|
|
12
|
+
};
|
|
13
|
+
/** Safe source boundary: preserve raw input separately from diagnostics and normalized values. */
|
|
14
|
+
export declare function validateTemplateSource(source: string, context: SchemaValidationContext): {
|
|
15
|
+
source: string;
|
|
16
|
+
result: {
|
|
17
|
+
kind: "invalid";
|
|
18
|
+
diagnostics: readonly [import("@kubohiroya/turbowarp-extension-data-editor/schema").SchemaDiagnosticBase & {
|
|
19
|
+
readonly phase: "decode";
|
|
20
|
+
readonly code: "input-format-invalid" | "variant-unrecognized";
|
|
21
|
+
readonly dataPath: import("@kubohiroya/turbowarp-extension-data-editor/schema").JsonPointer;
|
|
22
|
+
} & {
|
|
23
|
+
phase: "decode";
|
|
24
|
+
}];
|
|
25
|
+
};
|
|
26
|
+
} | {
|
|
27
|
+
result: {
|
|
28
|
+
readonly kind: "schema-error";
|
|
29
|
+
readonly diagnostics: import("@kubohiroya/turbowarp-extension-data-editor/schema").NonEmpty<import("@kubohiroya/turbowarp-extension-data-editor/schema").CompileDiagnostic>;
|
|
30
|
+
} | {
|
|
31
|
+
readonly kind: "execution-error";
|
|
32
|
+
readonly diagnostics: import("@kubohiroya/turbowarp-extension-data-editor/schema").NonEmpty<import("@kubohiroya/turbowarp-extension-data-editor/schema").CompileExecutionDiagnostic>;
|
|
33
|
+
};
|
|
34
|
+
source: string;
|
|
35
|
+
format: "json";
|
|
36
|
+
variantId: "template-json";
|
|
37
|
+
data: unknown;
|
|
38
|
+
} | {
|
|
39
|
+
result: import("@kubohiroya/turbowarp-extension-data-editor/schema").SchemaInputValidationResult;
|
|
40
|
+
source: string;
|
|
41
|
+
format: "json";
|
|
42
|
+
variantId: "template-json";
|
|
43
|
+
data: unknown;
|
|
44
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { compileSchemaBundle, validateSchemaInput, } from '@kubohiroya/turbowarp-extension-data-editor/schema';
|
|
2
|
+
import document from '../schemas/block-editor-template-compat.schema.json' with { type: 'json' };
|
|
3
|
+
import { validateTemplateNode } from './template-validation.js';
|
|
4
|
+
export { validateTemplateNode } from './template-validation.js';
|
|
5
|
+
const source = {
|
|
6
|
+
repository: 'turbowarp-aframe',
|
|
7
|
+
path: 'schemas/block-editor-template-compat.schema.json',
|
|
8
|
+
};
|
|
9
|
+
/** Parser-compatible gate; the older strict public schema is reference material only. */
|
|
10
|
+
export const templateSchemaBundle = {
|
|
11
|
+
identity: {
|
|
12
|
+
ownerId: 'turbowarp-aframe',
|
|
13
|
+
contractId: 'aframe-template',
|
|
14
|
+
revision: 'parser-v0.7.0',
|
|
15
|
+
variantId: 'template-json',
|
|
16
|
+
},
|
|
17
|
+
dialect: '2020-12',
|
|
18
|
+
root: {
|
|
19
|
+
retrievalUri: document.$id,
|
|
20
|
+
document: document,
|
|
21
|
+
artifact: { role: 'canonical-schema', source },
|
|
22
|
+
},
|
|
23
|
+
resources: [],
|
|
24
|
+
provenance: {
|
|
25
|
+
canonicalSources: [
|
|
26
|
+
source,
|
|
27
|
+
{
|
|
28
|
+
repository: 'turbowarp-aframe',
|
|
29
|
+
path: 'src/template-validation.ts',
|
|
30
|
+
symbol: 'validateTemplateNode',
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
generatedFiles: [],
|
|
34
|
+
referenceSchemas: [
|
|
35
|
+
{ repository: 'turbowarp-aframe', path: 'schemas/aframe-template.schema.json' },
|
|
36
|
+
],
|
|
37
|
+
generationSources: [],
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
export const validateTemplateInput = (data) => {
|
|
41
|
+
try {
|
|
42
|
+
validateTemplateNode(data, 'template');
|
|
43
|
+
return { kind: 'valid', issues: [] };
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return { kind: 'invalid', issues: [{ dataPath: '', ruleId: 'existing-template-parser' }] };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
export function decodeTemplateSource(source) {
|
|
50
|
+
return {
|
|
51
|
+
source,
|
|
52
|
+
format: 'json',
|
|
53
|
+
variantId: 'template-json',
|
|
54
|
+
data: JSON.parse(source),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
const sourceCompilation = compileSchemaBundle(templateSchemaBundle);
|
|
58
|
+
/** Safe source boundary: preserve raw input separately from diagnostics and normalized values. */
|
|
59
|
+
export function validateTemplateSource(source, context) {
|
|
60
|
+
let consumerId;
|
|
61
|
+
try {
|
|
62
|
+
const descriptor = Object.getOwnPropertyDescriptor(context, 'consumerId');
|
|
63
|
+
if (descriptor && 'value' in descriptor && typeof descriptor.value === 'string')
|
|
64
|
+
consumerId = descriptor.value;
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
/* Leave the consumer unspecified when context cannot be inspected safely. */
|
|
68
|
+
}
|
|
69
|
+
let decoded;
|
|
70
|
+
try {
|
|
71
|
+
decoded = decodeTemplateSource(source);
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
const code = error instanceof TypeError && error.message === 'Unrecognized camera profile variant.'
|
|
75
|
+
? 'variant-unrecognized'
|
|
76
|
+
: 'input-format-invalid';
|
|
77
|
+
const diagnostics = [
|
|
78
|
+
{
|
|
79
|
+
scope: {
|
|
80
|
+
identity: templateSchemaBundle.identity,
|
|
81
|
+
...(consumerId === undefined ? {} : { consumerId }),
|
|
82
|
+
},
|
|
83
|
+
phase: 'decode',
|
|
84
|
+
code,
|
|
85
|
+
dataPath: '',
|
|
86
|
+
},
|
|
87
|
+
];
|
|
88
|
+
return { source, result: { kind: 'invalid', diagnostics } };
|
|
89
|
+
}
|
|
90
|
+
const compilation = sourceCompilation;
|
|
91
|
+
if (compilation.kind !== 'compiled')
|
|
92
|
+
return { ...decoded, result: compilation };
|
|
93
|
+
return {
|
|
94
|
+
...decoded,
|
|
95
|
+
result: validateSchemaInput(compilation.validator, decoded.data, {
|
|
96
|
+
context,
|
|
97
|
+
ownerValidate: validateTemplateInput,
|
|
98
|
+
}),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface TemplateNode {
|
|
2
|
+
type?: string;
|
|
3
|
+
id?: string;
|
|
4
|
+
class?: string | string[];
|
|
5
|
+
classes?: string[];
|
|
6
|
+
data?: Record<string, unknown>;
|
|
7
|
+
attributes?: Record<string, unknown>;
|
|
8
|
+
children?: TemplateNode[];
|
|
9
|
+
}
|
|
10
|
+
export declare function validateTemplateNode(value: unknown, path: string): asserts value is TemplateNode;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
const TEMPLATE_NODE_KEYS = new Set([
|
|
2
|
+
'attributes',
|
|
3
|
+
'children',
|
|
4
|
+
'class',
|
|
5
|
+
'classes',
|
|
6
|
+
'data',
|
|
7
|
+
'id',
|
|
8
|
+
'type'
|
|
9
|
+
]);
|
|
10
|
+
export function validateTemplateNode(value, path) {
|
|
11
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
12
|
+
throw new TypeError(`A-Frame ${path} must be an object.`);
|
|
13
|
+
}
|
|
14
|
+
const node = value;
|
|
15
|
+
for (const key of Object.keys(node)) {
|
|
16
|
+
if (!TEMPLATE_NODE_KEYS.has(key)) {
|
|
17
|
+
throw new TypeError(`A-Frame ${path}.${key} is not supported.`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
validateOptionalString(node['type'], `${path}.type`);
|
|
21
|
+
validateOptionalString(node['id'], `${path}.id`);
|
|
22
|
+
validateTemplateClass(node['class'], `${path}.class`);
|
|
23
|
+
validateOptionalStringArray(node['classes'], `${path}.classes`);
|
|
24
|
+
validateStringRecord(node['data'], `${path}.data`);
|
|
25
|
+
validateStringRecord(node['attributes'], `${path}.attributes`);
|
|
26
|
+
const children = node['children'];
|
|
27
|
+
if (children === undefined)
|
|
28
|
+
return;
|
|
29
|
+
if (!Array.isArray(children)) {
|
|
30
|
+
throw new TypeError(`A-Frame ${path}.children must be an array.`);
|
|
31
|
+
}
|
|
32
|
+
children.forEach((child, index) => {
|
|
33
|
+
validateTemplateNode(child, `${path}.children[${index}]`);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function validateTemplateClass(value, path) {
|
|
37
|
+
if (value === undefined || typeof value === 'string')
|
|
38
|
+
return;
|
|
39
|
+
if (Array.isArray(value) && value.every((item) => typeof item === 'string'))
|
|
40
|
+
return;
|
|
41
|
+
throw new TypeError(`A-Frame ${path} must be a string or string array.`);
|
|
42
|
+
}
|
|
43
|
+
function validateOptionalStringArray(value, path) {
|
|
44
|
+
if (value === undefined)
|
|
45
|
+
return;
|
|
46
|
+
if (Array.isArray(value) && value.every((item) => typeof item === 'string'))
|
|
47
|
+
return;
|
|
48
|
+
throw new TypeError(`A-Frame ${path} must be a string array.`);
|
|
49
|
+
}
|
|
50
|
+
function validateOptionalString(value, path) {
|
|
51
|
+
if (value === undefined || typeof value === 'string')
|
|
52
|
+
return;
|
|
53
|
+
throw new TypeError(`A-Frame ${path} must be a string.`);
|
|
54
|
+
}
|
|
55
|
+
function validateStringRecord(value, path) {
|
|
56
|
+
if (value === undefined)
|
|
57
|
+
return;
|
|
58
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
59
|
+
throw new TypeError(`A-Frame ${path} must be an object.`);
|
|
60
|
+
}
|
|
61
|
+
for (const [key, recordValue] of Object.entries(value)) {
|
|
62
|
+
if (key.trim().length === 0) {
|
|
63
|
+
throw new TypeError(`A-Frame ${path} keys must be non-empty strings.`);
|
|
64
|
+
}
|
|
65
|
+
if (recordValue === undefined) {
|
|
66
|
+
throw new TypeError(`A-Frame ${path}.${key} must not be undefined.`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubohiroya/turbowarp-aframe",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "A TurboWarp extension for declarative A-Frame scene graphs.",
|
|
5
5
|
"author": "Hiroya Kubo <hiroya@cuc.ac.jp>",
|
|
6
6
|
"license": "MPL-2.0",
|
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
"README.md",
|
|
33
33
|
"README.ja.md",
|
|
34
34
|
"LICENSE",
|
|
35
|
-
"THIRD_PARTY_NOTICES.md"
|
|
35
|
+
"THIRD_PARTY_NOTICES.md",
|
|
36
|
+
"lib-editor/"
|
|
36
37
|
],
|
|
37
38
|
"publishConfig": {
|
|
38
39
|
"access": "public",
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
"scripts": {
|
|
46
47
|
"dev": "vite build --watch",
|
|
47
48
|
"typecheck": "tsc --noEmit",
|
|
48
|
-
"build": "vite build",
|
|
49
|
+
"build": "vite build && npm run build:editor",
|
|
49
50
|
"lint": "eslint src tests vite.config.ts",
|
|
50
51
|
"format": "eslint src tests vite.config.ts --fix",
|
|
51
52
|
"test": "vitest run",
|
|
@@ -54,10 +55,13 @@
|
|
|
54
55
|
"repo:check": "node scripts/check-repo.ts",
|
|
55
56
|
"pack:check": "npm pack --dry-run --ignore-scripts",
|
|
56
57
|
"check": "pnpm run typecheck && pnpm run lint && pnpm run test && pnpm run docs:check && pnpm run check:dist && pnpm run repo:check && pnpm run pack:check",
|
|
57
|
-
"check:dist": "pnpm run build && node scripts/check-dist.ts"
|
|
58
|
+
"check:dist": "pnpm run build && node scripts/check-dist.ts",
|
|
59
|
+
"build:editor": "tsc -p tsconfig.editor.json",
|
|
60
|
+
"prepare": "npm run build"
|
|
58
61
|
},
|
|
59
62
|
"devDependencies": {
|
|
60
63
|
"@eslint/js": "^9.39.5",
|
|
64
|
+
"@kubohiroya/turbowarp-extension-manifest": "0.2.0",
|
|
61
65
|
"@kubohiroya/vite-plugin-turbowarp-extension": "0.4.0",
|
|
62
66
|
"@pixiv/three-vrm": "3.5.5",
|
|
63
67
|
"@types/node": "^24.13.3",
|
|
@@ -67,6 +71,17 @@
|
|
|
67
71
|
"typescript": "^5.9.3",
|
|
68
72
|
"typescript-eslint": "^8.66.0",
|
|
69
73
|
"vite": "^8.2.2",
|
|
70
|
-
"vitest": "^4.1.10"
|
|
74
|
+
"vitest": "^4.1.10",
|
|
75
|
+
"react-dom": "18.3.1"
|
|
76
|
+
},
|
|
77
|
+
"dependencies": {
|
|
78
|
+
"@kubohiroya/turbowarp-extension-data-editor": "git+https://github.com/kubohiroya/turbowarp-extension-data-editor.git#76fa1d50a3c188082ceef723ea018a9d8769ea6e"
|
|
79
|
+
},
|
|
80
|
+
"exports": {
|
|
81
|
+
"./*": "./*",
|
|
82
|
+
"./editor-schema": {
|
|
83
|
+
"types": "./lib-editor/src/editor-schema.d.ts",
|
|
84
|
+
"import": "./lib-editor/src/editor-schema.js"
|
|
85
|
+
}
|
|
71
86
|
}
|
|
72
87
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://kubohiroya.github.io/turbowarp-aframe/schemas/block-editor-template-compat.schema.json",
|
|
4
|
+
"title": "A-Frame existing parser compatible template",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"properties": {
|
|
8
|
+
"type": {
|
|
9
|
+
"type": "string"
|
|
10
|
+
},
|
|
11
|
+
"id": {
|
|
12
|
+
"type": "string"
|
|
13
|
+
},
|
|
14
|
+
"class": {
|
|
15
|
+
"oneOf": [
|
|
16
|
+
{
|
|
17
|
+
"type": "string"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"type": "array",
|
|
21
|
+
"items": {
|
|
22
|
+
"type": "string"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
"classes": {
|
|
28
|
+
"type": "array",
|
|
29
|
+
"items": {
|
|
30
|
+
"type": "string"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"data": {
|
|
34
|
+
"type": "object",
|
|
35
|
+
"additionalProperties": true
|
|
36
|
+
},
|
|
37
|
+
"attributes": {
|
|
38
|
+
"type": "object",
|
|
39
|
+
"additionalProperties": true
|
|
40
|
+
},
|
|
41
|
+
"children": {
|
|
42
|
+
"type": "array",
|
|
43
|
+
"items": {
|
|
44
|
+
"$ref": "#"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import {
|
|
2
|
+
compileSchemaBundle,
|
|
3
|
+
validateSchemaInput,
|
|
4
|
+
} from '@kubohiroya/turbowarp-extension-data-editor/schema';
|
|
5
|
+
import type {
|
|
6
|
+
SchemaValidationContext,
|
|
7
|
+
SchemaJsonValue,
|
|
8
|
+
InputDiagnostic,
|
|
9
|
+
} from '@kubohiroya/turbowarp-extension-data-editor/schema';
|
|
10
|
+
import document from '../schemas/block-editor-template-compat.schema.json' with { type: 'json' };
|
|
11
|
+
import type {
|
|
12
|
+
SchemaBundle,
|
|
13
|
+
SchemaDocument,
|
|
14
|
+
SyncOwnerValidator,
|
|
15
|
+
} from '@kubohiroya/turbowarp-extension-data-editor/schema';
|
|
16
|
+
import { validateTemplateNode } from './template-validation.js';
|
|
17
|
+
export { validateTemplateNode } from './template-validation.js';
|
|
18
|
+
const source = {
|
|
19
|
+
repository: 'turbowarp-aframe',
|
|
20
|
+
path: 'schemas/block-editor-template-compat.schema.json',
|
|
21
|
+
};
|
|
22
|
+
/** Parser-compatible gate; the older strict public schema is reference material only. */
|
|
23
|
+
export const templateSchemaBundle: SchemaBundle = {
|
|
24
|
+
identity: {
|
|
25
|
+
ownerId: 'turbowarp-aframe',
|
|
26
|
+
contractId: 'aframe-template',
|
|
27
|
+
revision: 'parser-v0.7.0',
|
|
28
|
+
variantId: 'template-json',
|
|
29
|
+
},
|
|
30
|
+
dialect: '2020-12',
|
|
31
|
+
root: {
|
|
32
|
+
retrievalUri: document.$id,
|
|
33
|
+
document: document as SchemaDocument,
|
|
34
|
+
artifact: { role: 'canonical-schema', source },
|
|
35
|
+
},
|
|
36
|
+
resources: [],
|
|
37
|
+
provenance: {
|
|
38
|
+
canonicalSources: [
|
|
39
|
+
source,
|
|
40
|
+
{
|
|
41
|
+
repository: 'turbowarp-aframe',
|
|
42
|
+
path: 'src/template-validation.ts',
|
|
43
|
+
symbol: 'validateTemplateNode',
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
generatedFiles: [],
|
|
47
|
+
referenceSchemas: [
|
|
48
|
+
{ repository: 'turbowarp-aframe', path: 'schemas/aframe-template.schema.json' },
|
|
49
|
+
],
|
|
50
|
+
generationSources: [],
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
export const validateTemplateInput: SyncOwnerValidator = (data) => {
|
|
54
|
+
try {
|
|
55
|
+
validateTemplateNode(data, 'template');
|
|
56
|
+
return { kind: 'valid', issues: [] };
|
|
57
|
+
} catch {
|
|
58
|
+
return { kind: 'invalid', issues: [{ dataPath: '', ruleId: 'existing-template-parser' }] };
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
export function decodeTemplateSource(source: string) {
|
|
62
|
+
return {
|
|
63
|
+
source,
|
|
64
|
+
format: 'json' as const,
|
|
65
|
+
variantId: 'template-json' as const,
|
|
66
|
+
data: JSON.parse(source) as unknown,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const sourceCompilation = compileSchemaBundle(templateSchemaBundle);
|
|
71
|
+
/** Safe source boundary: preserve raw input separately from diagnostics and normalized values. */
|
|
72
|
+
export function validateTemplateSource(source: string, context: SchemaValidationContext) {
|
|
73
|
+
let consumerId: string | undefined;
|
|
74
|
+
try {
|
|
75
|
+
const descriptor = Object.getOwnPropertyDescriptor(context, 'consumerId');
|
|
76
|
+
if (descriptor && 'value' in descriptor && typeof descriptor.value === 'string')
|
|
77
|
+
consumerId = descriptor.value;
|
|
78
|
+
} catch {
|
|
79
|
+
/* Leave the consumer unspecified when context cannot be inspected safely. */
|
|
80
|
+
}
|
|
81
|
+
let decoded: ReturnType<typeof decodeTemplateSource>;
|
|
82
|
+
try {
|
|
83
|
+
decoded = decodeTemplateSource(source);
|
|
84
|
+
} catch (error) {
|
|
85
|
+
const code =
|
|
86
|
+
error instanceof TypeError && error.message === 'Unrecognized camera profile variant.'
|
|
87
|
+
? ('variant-unrecognized' as const)
|
|
88
|
+
: ('input-format-invalid' as const);
|
|
89
|
+
const diagnostics: readonly [InputDiagnostic & { phase: 'decode' }] = [
|
|
90
|
+
{
|
|
91
|
+
scope: {
|
|
92
|
+
identity: templateSchemaBundle.identity,
|
|
93
|
+
...(consumerId === undefined ? {} : { consumerId }),
|
|
94
|
+
},
|
|
95
|
+
phase: 'decode',
|
|
96
|
+
code,
|
|
97
|
+
dataPath: '',
|
|
98
|
+
},
|
|
99
|
+
];
|
|
100
|
+
return { source, result: { kind: 'invalid' as const, diagnostics } };
|
|
101
|
+
}
|
|
102
|
+
const compilation = sourceCompilation;
|
|
103
|
+
if (compilation.kind !== 'compiled') return { ...decoded, result: compilation };
|
|
104
|
+
return {
|
|
105
|
+
...decoded,
|
|
106
|
+
result: validateSchemaInput(compilation.validator, decoded.data as SchemaJsonValue, {
|
|
107
|
+
context,
|
|
108
|
+
ownerValidate: validateTemplateInput,
|
|
109
|
+
}),
|
|
110
|
+
};
|
|
111
|
+
}
|