@kurot/cli 3.2.1 → 3.3.1
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/CHANGELOG.md +59 -0
- package/README.md +38 -6
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/clean.d.ts.map +1 -1
- package/dist/commands/clean.js.map +1 -1
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js.map +1 -1
- package/dist/core/components/discover-components.d.ts.map +1 -1
- package/dist/core/components/discover-components.js +27 -0
- package/dist/core/components/discover-components.js.map +1 -1
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +6 -0
- package/dist/core/config.js.map +1 -1
- package/dist/core/dev-server.d.ts +2 -2
- package/dist/core/dev-server.d.ts.map +1 -1
- package/dist/core/dev-server.js +78 -45
- package/dist/core/dev-server.js.map +1 -1
- package/dist/core/diagnostics/collector.d.ts +9 -0
- package/dist/core/diagnostics/collector.d.ts.map +1 -1
- package/dist/core/diagnostics/collector.js +12 -0
- package/dist/core/diagnostics/collector.js.map +1 -1
- package/dist/core/diagnostics/output.d.ts +1 -1
- package/dist/core/diagnostics/output.d.ts.map +1 -1
- package/dist/core/errors.d.ts +6 -0
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +6 -0
- package/dist/core/errors.js.map +1 -1
- package/dist/core/kui/codegen.js +63 -0
- package/dist/core/kui/codegen.js.map +1 -1
- package/dist/core/kui/index.d.ts +6 -2
- package/dist/core/kui/index.d.ts.map +1 -1
- package/dist/core/kui/index.js +3 -3
- package/dist/core/kui/index.js.map +1 -1
- package/dist/core/kui/kui-diagnostics.d.ts.map +1 -1
- package/dist/core/kui/kui-diagnostics.js.map +1 -1
- package/dist/core/kui/kui-parser.d.ts +2 -2
- package/dist/core/kui/kui-parser.d.ts.map +1 -1
- package/dist/core/kui/kui-parser.js +42 -3
- package/dist/core/kui/kui-parser.js.map +1 -1
- package/dist/core/kui/registry.d.ts.map +1 -1
- package/dist/core/kui/registry.js +9 -0
- package/dist/core/kui/registry.js.map +1 -1
- package/dist/core/kui/skin-module-builder.js +20 -5
- package/dist/core/kui/skin-module-builder.js.map +1 -1
- package/dist/core/kui/skin-parts-declaration.d.ts.map +1 -1
- package/dist/core/kui/skin-parts-declaration.js +27 -0
- package/dist/core/kui/skin-parts-declaration.js.map +1 -1
- package/dist/core/kui/source-location.d.ts +3 -0
- package/dist/core/kui/source-location.d.ts.map +1 -1
- package/dist/core/kui/source-location.js +3 -0
- package/dist/core/kui/source-location.js.map +1 -1
- package/dist/core/namespace-external-plugin.d.ts.map +1 -1
- package/dist/core/namespace-external-plugin.js +3 -0
- package/dist/core/namespace-external-plugin.js.map +1 -1
- package/dist/core/plugins/clean-output.d.ts.map +1 -1
- package/dist/core/plugins/clean-output.js +3 -0
- package/dist/core/plugins/clean-output.js.map +1 -1
- package/dist/core/plugins/compile-custom-namespaces.d.ts.map +1 -1
- package/dist/core/plugins/compile-custom-namespaces.js +15 -0
- package/dist/core/plugins/compile-custom-namespaces.js.map +1 -1
- package/dist/core/plugins/compile-engine.d.ts.map +1 -1
- package/dist/core/plugins/compile-engine.js +3 -0
- package/dist/core/plugins/compile-engine.js.map +1 -1
- package/dist/core/plugins/compile-kui.d.ts.map +1 -1
- package/dist/core/plugins/compile-kui.js +27 -0
- package/dist/core/plugins/compile-kui.js.map +1 -1
- package/dist/core/plugins/compile-source.d.ts.map +1 -1
- package/dist/core/plugins/compile-source.js +6 -0
- package/dist/core/plugins/compile-source.js.map +1 -1
- package/dist/core/plugins/component-catalog.d.ts.map +1 -1
- package/dist/core/plugins/component-catalog.js +3 -0
- package/dist/core/plugins/component-catalog.js.map +1 -1
- package/dist/core/plugins/copy-assets.d.ts.map +1 -1
- package/dist/core/plugins/copy-assets.js +3 -0
- package/dist/core/plugins/copy-assets.js.map +1 -1
- package/dist/core/plugins/generate-html.d.ts.map +1 -1
- package/dist/core/plugins/generate-html.js +3 -0
- package/dist/core/plugins/generate-html.js.map +1 -1
- package/dist/core/plugins/manifest.d.ts.map +1 -1
- package/dist/core/plugins/manifest.js +3 -0
- package/dist/core/plugins/manifest.js.map +1 -1
- package/dist/core/project.d.ts.map +1 -1
- package/dist/core/project.js +6 -0
- package/dist/core/project.js.map +1 -1
- package/dist/core/resource-asset-sync.d.ts +8 -0
- package/dist/core/resource-asset-sync.d.ts.map +1 -0
- package/dist/core/resource-asset-sync.js +121 -0
- package/dist/core/resource-asset-sync.js.map +1 -0
- package/dist/core/resource-watcher.d.ts +6 -0
- package/dist/core/resource-watcher.d.ts.map +1 -0
- package/dist/core/resource-watcher.js +54 -0
- package/dist/core/resource-watcher.js.map +1 -0
- package/dist/core/template.d.ts.map +1 -1
- package/dist/core/template.js.map +1 -1
- package/dist/utils/fs.d.ts.map +1 -1
- package/dist/utils/fs.js.map +1 -1
- package/dist/utils/logger.d.ts +15 -0
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +18 -0
- package/dist/utils/logger.js.map +1 -1
- package/docs/ai-context.md +25 -4
- package/docs/architecture.md +15 -7
- package/docs/dev-resource-watching.md +88 -0
- package/docs/game-template.md +1 -1
- package/docs/label-text-layout.md +6 -1
- package/package.json +2 -2
- package/templates/game/resource/assets/fonts/OFL.txt +1 -1
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import * as fs from 'node:fs/promises';
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
import { KUI_THEME_OUTPUT_PATH } from './project.js';
|
|
5
|
+
/**
|
|
6
|
+
* Tracks source-owned assets only; generated themes and compiler outputs are never removed.
|
|
7
|
+
* All changed bytes are staged before publication. Individual renames are atomic,
|
|
8
|
+
* but a group of files is not an atomic transaction for concurrent HTTP readers.
|
|
9
|
+
*/
|
|
10
|
+
export async function createResourceAssetSync(project) {
|
|
11
|
+
const destination = path.join(project.outputDir, 'resource');
|
|
12
|
+
/**
|
|
13
|
+
* Excludes authored KUI and generated themes from runtime asset ownership.
|
|
14
|
+
*/
|
|
15
|
+
const accepts = (name) => !project.config.ui ||
|
|
16
|
+
(name !== path.basename(KUI_THEME_OUTPUT_PATH) && !name.endsWith('.kui.xml'));
|
|
17
|
+
let previous = new Map();
|
|
18
|
+
for (const file of await collectFiles(project.resourceDir, accepts)) {
|
|
19
|
+
previous.set(file, fingerprint(await fs.readFile(path.join(project.resourceDir, file))));
|
|
20
|
+
}
|
|
21
|
+
return async () => {
|
|
22
|
+
// Retry a bounded number of times when an editor renames files during a scan.
|
|
23
|
+
for (let attempt = 0;; attempt++) {
|
|
24
|
+
try {
|
|
25
|
+
await synchronize();
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
if (error.code !== 'ENOENT' || attempt >= 2)
|
|
30
|
+
throw error;
|
|
31
|
+
await new Promise(resolve => setTimeout(resolve, 50));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Stages changed assets and reconciles removed source-owned files.
|
|
37
|
+
*/
|
|
38
|
+
async function synchronize() {
|
|
39
|
+
const staging = await fs.mkdtemp(path.join(project.outputDir, '.kurot-assets-'));
|
|
40
|
+
const next = new Map();
|
|
41
|
+
const changed = [];
|
|
42
|
+
try {
|
|
43
|
+
for (const file of await collectFiles(project.resourceDir, accepts)) {
|
|
44
|
+
const bytes = await fs.readFile(path.join(project.resourceDir, file));
|
|
45
|
+
const hash = fingerprint(bytes);
|
|
46
|
+
next.set(file, hash);
|
|
47
|
+
if (previous.get(file) === hash)
|
|
48
|
+
continue;
|
|
49
|
+
const stagedFile = path.join(staging, file);
|
|
50
|
+
await fs.mkdir(path.dirname(stagedFile), { recursive: true });
|
|
51
|
+
await fs.writeFile(stagedFile, bytes);
|
|
52
|
+
changed.push(file);
|
|
53
|
+
}
|
|
54
|
+
const removed = [...previous.keys()].filter(file => !next.has(file));
|
|
55
|
+
// Remove source-owned obsolete files first to allow file/directory replacements.
|
|
56
|
+
for (const file of removed) {
|
|
57
|
+
await fs.rm(path.join(destination, file), { force: true });
|
|
58
|
+
await removeEmptyParents(path.dirname(path.join(destination, file)), destination);
|
|
59
|
+
}
|
|
60
|
+
for (const file of changed) {
|
|
61
|
+
const target = path.join(destination, file);
|
|
62
|
+
await fs.mkdir(path.dirname(target), { recursive: true });
|
|
63
|
+
await fs.rename(path.join(staging, file), target);
|
|
64
|
+
}
|
|
65
|
+
previous = next;
|
|
66
|
+
}
|
|
67
|
+
finally {
|
|
68
|
+
await fs.rm(staging, { recursive: true, force: true });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Collects accepted runtime files in stable relative-path order.
|
|
74
|
+
*/
|
|
75
|
+
async function collectFiles(directory, accepts, relative = '') {
|
|
76
|
+
let entries;
|
|
77
|
+
try {
|
|
78
|
+
entries = await fs.readdir(path.join(directory, relative), { withFileTypes: true });
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
if (error.code === 'ENOENT' && relative === '')
|
|
82
|
+
return [];
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
85
|
+
const files = [];
|
|
86
|
+
for (const entry of entries) {
|
|
87
|
+
const file = path.join(relative, entry.name);
|
|
88
|
+
if (entry.isDirectory()) {
|
|
89
|
+
files.push(...await collectFiles(directory, accepts, file));
|
|
90
|
+
}
|
|
91
|
+
else if (accepts(entry.name)) {
|
|
92
|
+
files.push(file);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return files.sort();
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Removes empty output parents without deleting the resource root.
|
|
99
|
+
*/
|
|
100
|
+
async function removeEmptyParents(directory, root) {
|
|
101
|
+
while (directory !== root) {
|
|
102
|
+
try {
|
|
103
|
+
await fs.rmdir(directory);
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
const code = error.code;
|
|
107
|
+
if (code === 'ENOTEMPTY' || code === 'EEXIST')
|
|
108
|
+
return;
|
|
109
|
+
if (code !== 'ENOENT')
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
directory = path.dirname(directory);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Hashes asset contents to avoid rewriting unchanged output files.
|
|
117
|
+
*/
|
|
118
|
+
function fingerprint(bytes) {
|
|
119
|
+
return createHash('sha256').update(bytes).digest('hex');
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=resource-asset-sync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-asset-sync.js","sourceRoot":"","sources":["../../src/core/resource-asset-sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAGrD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,OAAgB;IAC7D,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAE7D;;OAEG;IACH,MAAM,OAAO,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QAC5D,CAAC,IAAI,KAAK,IAAI,CAAC,QAAQ,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;IAE/E,IAAI,QAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEzC,KAAK,MAAM,IAAI,IAAI,MAAM,YAAY,CAAC,OAAO,CAAC,WAAW,E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AO,KAAK,CAAC,IAAI,EAAE,CAAC;AACrB,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,kBAAkB,CAAC,SAAiB,EAAE,IAAY;IAChE,OAAO,SAAS,KAAK,IAAI,EAAE,CAAC;QAC3B,IAAI,CAAC;YACJ,MAAM,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,GAAI,KAA+B,CAAC,IAAI,CAAC;YACnD,IAAI,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,QAAQ;gBAAE,OAAO;YACtD,IAAI,IAAI,KAAK,QAAQ;gBAAE,MAAM,KAAK,CAAC;QACpC,CAAC;QACD,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACrC,CAAC;AACF,CAAC;AAED;;GAEG;AACH,SAAS,WAAW,CAAC,KAAiB;IACrC,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACzD,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Watches only the resource subtree. A shallow parent watcher reconnects when
|
|
3
|
+
* the root is created or replaced without recursively watching node_modules.
|
|
4
|
+
*/
|
|
5
|
+
export declare function watchResourceDirectory(directory: string, onChange: (file: string | undefined) => void): () => void;
|
|
6
|
+
//# sourceMappingURL=resource-watcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-watcher.d.ts","sourceRoot":"","sources":["../../src/core/resource-watcher.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,GAAG,MAAM,IAAI,CAkDlH"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
/**
|
|
4
|
+
* Watches only the resource subtree. A shallow parent watcher reconnects when
|
|
5
|
+
* the root is created or replaced without recursively watching node_modules.
|
|
6
|
+
*/
|
|
7
|
+
export function watchResourceDirectory(directory, onChange) {
|
|
8
|
+
let watcher;
|
|
9
|
+
let identity;
|
|
10
|
+
/**
|
|
11
|
+
* Reattaches the recursive watcher when the resource root identity changes.
|
|
12
|
+
*/
|
|
13
|
+
const reconnect = () => {
|
|
14
|
+
let next;
|
|
15
|
+
try {
|
|
16
|
+
const stat = fs.statSync(directory);
|
|
17
|
+
if (stat.isDirectory()) {
|
|
18
|
+
next = `${stat.dev}:${stat.ino}`;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
if (error.code !== 'ENOENT')
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
if (next === identity)
|
|
26
|
+
return false;
|
|
27
|
+
watcher?.close();
|
|
28
|
+
watcher = undefined;
|
|
29
|
+
identity = next;
|
|
30
|
+
if (next !== undefined) {
|
|
31
|
+
watcher = fs.watch(directory, { recursive: true }, (_event, filename) => onChange(filename ?? undefined));
|
|
32
|
+
}
|
|
33
|
+
return true;
|
|
34
|
+
};
|
|
35
|
+
const parent = fs.watch(path.dirname(directory), (_event, filename) => {
|
|
36
|
+
if (filename && filename !== path.basename(directory))
|
|
37
|
+
return;
|
|
38
|
+
if (reconnect()) {
|
|
39
|
+
onChange(undefined);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
try {
|
|
43
|
+
reconnect();
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
parent.close();
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
return () => {
|
|
50
|
+
parent.close();
|
|
51
|
+
watcher?.close();
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=resource-watcher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C,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE;QACrE,IAAI,QAAQ,IAAI,QAAQ,KAAK,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;YAAE,OAAO;QAC9D,IAAI,SAAS,EAAE,EAAE,CAAC;YACjB,QAAQ,CAAC,SAAS,CAAC,CAAC;QACrB,CAAC;IACF,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC;QACJ,SAAS,EAAE,CAAC;IACb,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,CAAC,KAAK,EAAE,CAAC;QACf,MAAM,KAAK,CAAC;IACb,CAAC;IAED,OAAO,GAAS,EAAE;QACjB,MAAM,CAAC,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,KAAK,EAAE,CAAC;IAClB,CAAC,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../src/core/template.ts"],"names":[],"mappings":"AAgBA;;GAEG;AACH,eAAO,MAAM,SAAS,4BAA6B,CAAC;AAEpD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtD;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../src/core/template.ts"],"names":[],"mappings":"AAgBA;;GAEG;AACH,eAAO,MAAM,SAAS,4BAA6B,CAAC;AAEpD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtD;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,GAAG,OAAO,CAA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S,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE1D;AAED;;;;;GAKG;AACH,wBAAsB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../src/utils/fs.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE1D;AAED;;;;;GAKG;AACH,wBAAsB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAc1G;AAED;;GAEG;AACH,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGhF;AAED;;GAEG;AACH,wBAAsB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAK/D"}
|
package/dist/utils/fs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../../src/utils/fs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,GAAW;IAC1C,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAC1C,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,C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U,SAAS,CAAC,QAAgB,EAAE,OAAe;IAChE,MAAM,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxC,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAChD,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,QAAgB;IAC5C,OAAO,EAAE;SACP,MAAM,CAAC,QAAQ,CAAC;SAChB,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC;SAChB,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC"}
|
package/dist/utils/logger.d.ts
CHANGED
|
@@ -7,10 +7,25 @@ export declare function setLoggerEnabled(value: boolean): void;
|
|
|
7
7
|
* Human-readable CLI logger with a consistent Kurot prefix and severity color.
|
|
8
8
|
*/
|
|
9
9
|
export declare const logger: {
|
|
10
|
+
/**
|
|
11
|
+
* Writes an informational message.
|
|
12
|
+
*/
|
|
10
13
|
info: (msg: string) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Writes a successful-operation message.
|
|
16
|
+
*/
|
|
11
17
|
success: (msg: string) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Writes a warning message.
|
|
20
|
+
*/
|
|
12
21
|
warn: (msg: string) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Writes an error message.
|
|
24
|
+
*/
|
|
13
25
|
error: (msg: string) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Writes a build-stage message.
|
|
28
|
+
*/
|
|
14
29
|
step: (msg: string) => void;
|
|
15
30
|
};
|
|
16
31
|
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAmBA;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAErD;AAED;;GAEG;AACH,eAAO,MAAM,MAAM;IAClB;;OAEG;gBACS,MAAM,KAAG,IAAI;IAEzB;;OAEG;mBACY,MAAM,KAAG,IAAI;IAE5B;;OAEG;gBACS,MAAM,KAAG,IAAI;IAEzB;;OAEG;iBACU,MAAM,KAAG,IAAI;IAE1B;;OAEG;gBACS,MAAM,KAAG,IAAI;CACzB,CAAC"}
|
package/dist/utils/logger.js
CHANGED
|
@@ -6,6 +6,9 @@ const cyan = '\x1b[36m';
|
|
|
6
6
|
const dim = '\x1b[2m';
|
|
7
7
|
const tag = `${cyan}[kurot]${reset}`;
|
|
8
8
|
let enabled = true;
|
|
9
|
+
/**
|
|
10
|
+
* Writes human-readable logs only when logging is enabled.
|
|
11
|
+
*/
|
|
9
12
|
function write(method, message) {
|
|
10
13
|
if (!enabled)
|
|
11
14
|
return;
|
|
@@ -22,10 +25,25 @@ export function setLoggerEnabled(value) {
|
|
|
22
25
|
* Human-readable CLI logger with a consistent Kurot prefix and severity color.
|
|
23
26
|
*/
|
|
24
27
|
export const logger = {
|
|
28
|
+
/**
|
|
29
|
+
* Writes an informational message.
|
|
30
|
+
*/
|
|
25
31
|
info: (msg) => write('log', `${tag} ${msg}`),
|
|
32
|
+
/**
|
|
33
|
+
* Writes a successful-operation message.
|
|
34
|
+
*/
|
|
26
35
|
success: (msg) => write('log', `${tag} ${green}${msg}${reset}`),
|
|
36
|
+
/**
|
|
37
|
+
* Writes a warning message.
|
|
38
|
+
*/
|
|
27
39
|
warn: (msg) => write('warn', `${tag} ${yellow}${msg}${reset}`),
|
|
40
|
+
/**
|
|
41
|
+
* Writes an error message.
|
|
42
|
+
*/
|
|
28
43
|
error: (msg) => write('error', `${tag} ${red}${msg}${reset}`),
|
|
44
|
+
/**
|
|
45
|
+
* Writes a build-stage message.
|
|
46
|
+
*/
|
|
29
47
|
step: (msg) => write('log', `${tag} ${dim}›${reset} ${msg}`),
|
|
30
48
|
};
|
|
31
49
|
//# sourceMappingURL=logger.js.map
|
package/dist/utils/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,MAAM,KAAK,GAAG,SAAS,CAAC;AACxB,MAAM,KAAK,GAAG,UAAU,CAAC;AACzB,MAAM,MAAM,GAAG,UAAU,CAAC;AAC1B,MAAM,GAAG,GAAG,UAAU,CAAC;AACvB,MAAM,IAAI,GAAG,UAAU,CAAC;AACxB,MAAM,GAAG,GAAG,SAAS,CAAC;AAEtB,MAAM,GAAG,GAAG,GAAG,IAAI,UAAU,KAAK,EAAE,CAAC;AAErC,IAAI,OAAO,GAAG,IAAI,CAAC;AAEnB,SAAS,KAAK,CAAC,MAAgC,EAAE,OAAe;IAC/D,IAAI,CAAC,OAAO;QAAE,OAAO;IACrB,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC;AAC1B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC9C,OAAO,GAAG,KAAK,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG;IACrB,IAAI,EAAE,CAAC,GAAW,EAAQ,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,MAAM,KAAK,GAAG,SAAS,CAAC;AACxB,MAAM,KAAK,GAAG,UAAU,CAAC;AACzB,MAAM,MAAM,GAAG,UAAU,CAAC;AAC1B,MAAM,GAAG,GAAG,UAAU,CAAC;AACvB,MAAM,IAAI,GAAG,UAAU,CAAC;AACxB,MAAM,GAAG,GAAG,SAAS,CAAC;AAEtB,MAAM,GA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`](./architecture.md)
|
|
4
|
-
explains the plugin pipeline. The package is `@kurot/cli@3.
|
|
5
|
-
Node.js 20+, and is installed as a project dev dependency.
|
|
4
|
+
explains the plugin pipeline. The package is `@kurot/cli@3.3.1`, prepared for
|
|
5
|
+
publication, runs on Node.js 20+, and is installed as a project dev dependency.
|
|
6
6
|
|
|
7
7
|
## Directory map
|
|
8
8
|
|
|
@@ -16,6 +16,8 @@ src/
|
|
|
16
16
|
│ ├── project.ts resolved paths, dependencies, namespaces
|
|
17
17
|
│ ├── pipeline.ts BuildContext and ordered plugin runner
|
|
18
18
|
│ ├── dev-server.ts static server and watchers
|
|
19
|
+
│ ├── resource-watcher.ts recursive resource + shallow parent watch/reconnect
|
|
20
|
+
│ ├── resource-asset-sync.ts content comparison, staged writes and deletion reconciliation
|
|
19
21
|
│ ├── diagnostics/ stable codes and JSON/JSONL output
|
|
20
22
|
│ ├── components/ reusable component discovery
|
|
21
23
|
│ ├── kui/ UIDocument → SkinIR → ESM compiler
|
|
@@ -28,7 +30,11 @@ The 3.2.1 game template includes fixed style/locale configuration,
|
|
|
28
30
|
English properties and licensed regular/bold font files. StyleManager finishes
|
|
29
31
|
font loading before Main creates Player/Preloader; LocaleManager registers
|
|
30
32
|
preload texts before creating the scene. See [game-template.md](game-template.md).
|
|
31
|
-
Version 3.
|
|
33
|
+
Version 3.3.0 is published with Label preset compilation and
|
|
34
|
+
published ui-document 0.11.0. It has no local document-kernel override.
|
|
35
|
+
Version 3.3.1 adds whole-resource dev synchronization, deletion/reconnect handling
|
|
36
|
+
and no-store responses. Installed CLI 3.3.0 lacks these fixes; source versions
|
|
37
|
+
do not prove that 3.3.1 has been published or adopted by consumers.
|
|
32
38
|
|
|
33
39
|
## KUI compilation
|
|
34
40
|
|
|
@@ -44,7 +50,7 @@ and layout apply to the runtime Skin, and its direct visual children become
|
|
|
44
50
|
`property.state` attributes. Storage IDs and runtime mapping metadata are not
|
|
45
51
|
authored XML fields.
|
|
46
52
|
|
|
47
|
-
CLI 3.
|
|
53
|
+
CLI 3.3.1 requires `@kurot/ui-document@^0.11.0`. Schema-defined strings, including
|
|
48
54
|
numeric/boolean-looking text and state text, are literal attributes without
|
|
49
55
|
backslash type escaping. Old synthetic prefixes become literal characters;
|
|
50
56
|
do not migrate them silently. Numeric/boolean properties and schema-free
|
|
@@ -87,6 +93,11 @@ manual prefix cannot conflict with `ui.components.namespace`.
|
|
|
87
93
|
`--strict` or release policy.
|
|
88
94
|
- Machine diagnostic modes own stdout: build emits one JSON result; dev emits
|
|
89
95
|
JSONL lifecycle events.
|
|
96
|
+
- Since 3.3.1, dev watches all resource assets even without UI, emits
|
|
97
|
+
resource-change for copy-only batches, retains KUI requirements across mixed
|
|
98
|
+
batches, and reconciles deletions. Browser refresh remains manual; HTTP is
|
|
99
|
+
no-store. Per-file staging/rename is not an atomic atlas pair transaction.
|
|
100
|
+
Read [dev resource watching](dev-resource-watching.md) for the exact boundaries.
|
|
90
101
|
- `compileCustomNamespaces` must precede `compileSource`. Application-relative
|
|
91
102
|
imports and generated `#ns/<prefix>` imports must resolve to one bundled class
|
|
92
103
|
identity.
|
|
@@ -175,3 +186,13 @@ Base and state colors use @style:colors:<key>; reject the previous color prefix
|
|
|
175
186
|
without migrating files. Fonts are validated but not loaded; the application owns
|
|
176
187
|
font loading and rendering. Build/preview copies resolve references while authored
|
|
177
188
|
XML retains them. No live runtime palette switching is introduced.
|
|
189
|
+
|
|
190
|
+
## Label presets in 3.3.0
|
|
191
|
+
|
|
192
|
+
skin-module-builder.ts reads the entire stylesheet once per build and passes it
|
|
193
|
+
through parseToIR/parseKUISkin. Resolve resource defaults, then Label presets, then colors before
|
|
194
|
+
native emission; retain XML references and local/state precedence. compileKUI
|
|
195
|
+
accepts an optional styleSheet. style.json changes already trigger whole-Skin
|
|
196
|
+
rebuilds. Invalid presets retain the last successful bundle. The dependency and
|
|
197
|
+
lockfile use published ui-document 0.11.0 without a local override. textStyle is
|
|
198
|
+
Default-only; individual named-state fields can still override preset properties.
|
package/docs/architecture.md
CHANGED
|
@@ -39,17 +39,19 @@ factory variables, property assignments, semantic layout children, and state
|
|
|
39
39
|
property overrides. Document contracts, reusable instances, data bindings, and
|
|
40
40
|
actions remain `UIDocument` concepts.
|
|
41
41
|
|
|
42
|
-
CLI 3.
|
|
42
|
+
CLI 3.3.1 consumes ui-document 0.11.x, retaining Label text-fitting metadata. The
|
|
43
43
|
compiler emits `textFit`, `minFontSize`, base font sizes and state overrides;
|
|
44
44
|
native UI owns measurement and derives drawing sizes after layout validation.
|
|
45
45
|
See [Label compilation](label-text-layout.md). The application supplies UI
|
|
46
46
|
3.1.x and Core 2.1.x or later within their respective majors.
|
|
47
47
|
|
|
48
48
|
Each build also reads optional `resource/config/style.json` through the shared
|
|
49
|
-
parser. Resource nine-slice defaults and named color references
|
|
50
|
-
disposable document before SkinIR conversion;
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
parser. Resource nine-slice defaults, Label presets and named color references
|
|
50
|
+
resolve in that order into a disposable document before SkinIR conversion;
|
|
51
|
+
authored Skin XML is never rewritten. Default-only `@style:labels:<key>` expands
|
|
52
|
+
to native properties, with state fields taking priority over local and preset
|
|
53
|
+
fields. Invalid configurations and unknown preset/color references fail before
|
|
54
|
+
a new Skin bundle is installed.
|
|
53
55
|
|
|
54
56
|
The authored `Skin` root supplies its generated `class` and optional state
|
|
55
57
|
names. State values live on their target nodes as `property.state`. The compiler
|
|
@@ -76,8 +78,14 @@ convention-based reusable components. A component change can affect its source
|
|
|
76
78
|
namespace, paired skin, generated type declaration, and editor catalog, so that
|
|
77
79
|
path refreshes all four outputs as one operation. The server preserves the last
|
|
78
80
|
successful output after an invalid edit.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
Since 3.3.1, the resource watcher synchronizes all runtime assets even without UI,
|
|
82
|
+
and reconciles additions, deletions and directory replacement. Runtime-only
|
|
83
|
+
changes do not recompile skins. The fixed style.json and default.res.json paths
|
|
84
|
+
still trigger KUI compilation; font loading remains an application responsibility.
|
|
85
|
+
Changes are debounced and queued, with changed bytes staged before publication.
|
|
86
|
+
Browser refresh remains manual and HTTP responses use no-store. Individual
|
|
87
|
+
renames do not form an atomic multi-file transaction. See
|
|
88
|
+
[resource watching](dev-resource-watching.md).
|
|
81
89
|
|
|
82
90
|
## Diagnostics
|
|
83
91
|
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Development resource watching
|
|
2
|
+
|
|
3
|
+
Available in CLI 3.3.1, currently prepared for publication. No configuration or
|
|
4
|
+
dependency-range changes are required. Projects must install the new CLI to
|
|
5
|
+
receive these behaviors; installed CLI 3.3.0 does not include them.
|
|
6
|
+
|
|
7
|
+
## Inputs and rebuilds
|
|
8
|
+
|
|
9
|
+
`kurot dev` watches the entire `resource/` subtree regardless of whether `ui` is
|
|
10
|
+
enabled. Runtime files do not need an extension allowlist or a special atlas
|
|
11
|
+
directory. This includes JSON configurations, PNG/JPEG/WebP, fonts, audio,
|
|
12
|
+
translations and other project-owned files.
|
|
13
|
+
|
|
14
|
+
| Input change | Action |
|
|
15
|
+
| --- | --- |
|
|
16
|
+
| KUI source, default.res.json or config/style.json in a UI project | Compile KUI and synchronize runtime assets |
|
|
17
|
+
| Runtime JSON, including config/locale.json and sheet JSON | Synchronize assets |
|
|
18
|
+
| PNG, fonts, language properties and other runtime files | Synchronize assets |
|
|
19
|
+
| Resource directory creation, replacement or deletion | Reconnect watcher and reconcile output; compile KUI when enabled |
|
|
20
|
+
| Reusable component source or skin | Retain component discovery/namespace/catalog rebuild and synchronize assets |
|
|
21
|
+
|
|
22
|
+
Changes to `kurot.config.ts`, dependencies or build configuration still require
|
|
23
|
+
restarting dev. Locale configuration is consumed by project code; the CLI does
|
|
24
|
+
not introduce a locale parser or mutate authored skins. A style edit may change
|
|
25
|
+
compiled skin assignments while its XML remains untouched.
|
|
26
|
+
|
|
27
|
+
The resource watcher uses recursive `fs.watch` on the resource directory plus a
|
|
28
|
+
shallow parent watcher, so it can reconnect when a missing root is created or an
|
|
29
|
+
existing root is replaced. It does not recursively watch dependencies or build
|
|
30
|
+
output. Native recursive watch support is required; setup failures are logged.
|
|
31
|
+
|
|
32
|
+
## Batches and synchronization
|
|
33
|
+
|
|
34
|
+
Events are debounced for 100 ms. A batch retains its need for KUI compilation even
|
|
35
|
+
when a later event concerns only a runtime resource. Resource updates and
|
|
36
|
+
component rebuilds share a serialized queue. Failed KUI batches are retried on
|
|
37
|
+
subsequent resource edits before any resource synchronization can succeed.
|
|
38
|
+
|
|
39
|
+
Synchronization scans source assets, compares SHA-256 content hashes and writes
|
|
40
|
+
only changed files. It stages every changed file on the output filesystem before
|
|
41
|
+
publishing. Each changed file is renamed into place; source-owned deleted files
|
|
42
|
+
and empty parent directories are removed. Directory renames and file/directory
|
|
43
|
+
replacements are reconciled. Generated theme files, compiled bundles and catalogs
|
|
44
|
+
are not treated as source-owned assets. Identical contents are not rewritten.
|
|
45
|
+
|
|
46
|
+
Source renames during a scan are retried at most twice after an initial ENOENT
|
|
47
|
+
failure. Other errors are reported through a failed build-complete event; dev
|
|
48
|
+
stays running for the next edit. A failed scan leaves staged bytes unpublished.
|
|
49
|
+
Publication itself can fail after some files have been renamed: this is not a
|
|
50
|
+
rollback transaction.
|
|
51
|
+
|
|
52
|
+
A resource-only batch emits JSONL build-start with reason `resource-change`,
|
|
53
|
+
followed by build-complete after synchronization. Existing `kui-change` and
|
|
54
|
+
`source-change` reasons retain their meaning. Consumers should tolerate the
|
|
55
|
+
additional reason and refresh only after a successful build-complete event.
|
|
56
|
+
|
|
57
|
+
## Preview and atlas boundaries
|
|
58
|
+
|
|
59
|
+
Browser refresh remains manual. Successful HTTP responses use
|
|
60
|
+
`Cache-Control: no-store`, so a reloaded preview requests current output files.
|
|
61
|
+
The CLI does not invalidate resources inside a running game's Core cache.
|
|
62
|
+
Reskin's existing reload-preview button can load synchronized assets without
|
|
63
|
+
restarting the dev process.
|
|
64
|
+
|
|
65
|
+
Atlas PNG and JSON can be saved together and handled in the same debounce batch.
|
|
66
|
+
The CLI copies bytes; it does not parse or validate atlas geometry, discover
|
|
67
|
+
source images, pack atlases or require an atlas dependency. It does not infer
|
|
68
|
+
when an external packer has finished a job.
|
|
69
|
+
|
|
70
|
+
**Debouncing and per-file atomic renames are not an atomic PNG/JSON transaction.**
|
|
71
|
+
Files saved farther apart can produce separate successful batches, and a request
|
|
72
|
+
during publication can observe different generations. For now, save both files
|
|
73
|
+
before refreshing. A tool requiring strict cross-process group consistency needs
|
|
74
|
+
a separate commit notification/version protocol; that is outside this change.
|
|
75
|
+
|
|
76
|
+
Every resource batch currently scans and hashes the complete source asset tree,
|
|
77
|
+
reading one file at a time and staging changed files on disk. This avoids retaining
|
|
78
|
+
all decoded assets in memory and avoids rewriting unchanged output, but scan I/O
|
|
79
|
+
still grows with total resource size. Path-based scan caches can be evaluated
|
|
80
|
+
separately for large projects.
|
|
81
|
+
|
|
82
|
+
## Verification
|
|
83
|
+
|
|
84
|
+
`test/resource-watch.test.ts` starts actual CLI processes and verifies HTTP bytes,
|
|
85
|
+
cache headers, runtime-only updates without changed skin output, atlas atomic-save
|
|
86
|
+
events, locale/properties/fonts, rename/deletion, Core-only root creation/recreation,
|
|
87
|
+
mixed style/runtime changes, failure retention and recovery. Existing CLI KUI,
|
|
88
|
+
manifest, component and Label preset watch tests cover their respective rebuilds.
|
package/docs/game-template.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Project styles and languages in the game template
|
|
2
2
|
|
|
3
|
-
CLI 3.2.1
|
|
3
|
+
CLI 3.2.1 is published with this template update. It adds
|
|
4
4
|
project-owned initialization without changing Core/UI APIs or migrating existing
|
|
5
5
|
projects. The empty template stays minimal.
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Label text compilation
|
|
2
2
|
|
|
3
|
-
CLI 3.
|
|
3
|
+
CLI 3.3.1 consumes ui-document 0.11.x and compiles KUI text-fitting properties
|
|
4
4
|
through the existing UIDocument → SkinIR → ESM factory pipeline. The semantic
|
|
5
5
|
document format remains version 2.
|
|
6
6
|
|
|
@@ -27,6 +27,11 @@ The compiler does not measure fonts or change `size` based on text length,
|
|
|
27
27
|
currency, locale or display bounds. Source XML remains authored data; neither
|
|
28
28
|
derived sizes nor fitting diagnostics are persisted by compilation.
|
|
29
29
|
|
|
30
|
+
Label presets supply baseline appearance before local and state fields are
|
|
31
|
+
applied. They do not own wrapping or fitting policy, and preset expansion never
|
|
32
|
+
introduces build-time text measurement. See the
|
|
33
|
+
[shared style contract](../../ui-document/docs/project-styles.md).
|
|
34
|
+
|
|
30
35
|
## Runtime boundary
|
|
31
36
|
|
|
32
37
|
- The application must install UI `^3.1.0` and Core `^2.1.0` for shrinking.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kurot/cli",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.1",
|
|
4
4
|
"description": "Kurot CLI - build tool for Kurot Editor KUI XML workflows",
|
|
5
5
|
"author": "Kelvin <kyia.x52@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"kurot": "tsx src/index.ts"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@kurot/ui-document": "^0.
|
|
31
|
+
"@kurot/ui-document": "^0.11.0",
|
|
32
32
|
"commander": "^13.0.0",
|
|
33
33
|
"esbuild": "^0.25.0"
|
|
34
34
|
},
|
|
@@ -18,7 +18,7 @@ with others.
|
|
|
18
18
|
|
|
19
19
|
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
20
|
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
-
fonts, including any derivative works, can be bundled, embedded,
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
22
|
redistributed and/or sold with any software provided that any reserved
|
|
23
23
|
names are not used by derivative works. The fonts and derivatives,
|
|
24
24
|
however, cannot be released under any other type of license. The
|