@willwade/aac-processors 0.0.3

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.
Files changed (89) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +787 -0
  3. package/dist/cli/index.d.ts +2 -0
  4. package/dist/cli/index.js +189 -0
  5. package/dist/cli/prettyPrint.d.ts +2 -0
  6. package/dist/cli/prettyPrint.js +28 -0
  7. package/dist/core/analyze.d.ts +6 -0
  8. package/dist/core/analyze.js +49 -0
  9. package/dist/core/baseProcessor.d.ts +94 -0
  10. package/dist/core/baseProcessor.js +208 -0
  11. package/dist/core/fileProcessor.d.ts +7 -0
  12. package/dist/core/fileProcessor.js +51 -0
  13. package/dist/core/stringCasing.d.ts +37 -0
  14. package/dist/core/stringCasing.js +174 -0
  15. package/dist/core/treeStructure.d.ts +190 -0
  16. package/dist/core/treeStructure.js +223 -0
  17. package/dist/index.d.ts +23 -0
  18. package/dist/index.js +96 -0
  19. package/dist/optional/symbolTools.d.ts +28 -0
  20. package/dist/optional/symbolTools.js +126 -0
  21. package/dist/processors/applePanelsProcessor.d.ts +23 -0
  22. package/dist/processors/applePanelsProcessor.js +521 -0
  23. package/dist/processors/astericsGridProcessor.d.ts +49 -0
  24. package/dist/processors/astericsGridProcessor.js +1427 -0
  25. package/dist/processors/dotProcessor.d.ts +21 -0
  26. package/dist/processors/dotProcessor.js +191 -0
  27. package/dist/processors/excelProcessor.d.ts +145 -0
  28. package/dist/processors/excelProcessor.js +556 -0
  29. package/dist/processors/gridset/helpers.d.ts +4 -0
  30. package/dist/processors/gridset/helpers.js +48 -0
  31. package/dist/processors/gridset/resolver.d.ts +8 -0
  32. package/dist/processors/gridset/resolver.js +100 -0
  33. package/dist/processors/gridsetProcessor.d.ts +28 -0
  34. package/dist/processors/gridsetProcessor.js +1339 -0
  35. package/dist/processors/index.d.ts +14 -0
  36. package/dist/processors/index.js +42 -0
  37. package/dist/processors/obfProcessor.d.ts +21 -0
  38. package/dist/processors/obfProcessor.js +278 -0
  39. package/dist/processors/opmlProcessor.d.ts +21 -0
  40. package/dist/processors/opmlProcessor.js +235 -0
  41. package/dist/processors/snap/helpers.d.ts +4 -0
  42. package/dist/processors/snap/helpers.js +27 -0
  43. package/dist/processors/snapProcessor.d.ts +44 -0
  44. package/dist/processors/snapProcessor.js +586 -0
  45. package/dist/processors/touchchat/helpers.d.ts +4 -0
  46. package/dist/processors/touchchat/helpers.js +27 -0
  47. package/dist/processors/touchchatProcessor.d.ts +27 -0
  48. package/dist/processors/touchchatProcessor.js +768 -0
  49. package/dist/types/aac.d.ts +47 -0
  50. package/dist/types/aac.js +2 -0
  51. package/docs/.keep +1 -0
  52. package/docs/ApplePanels.md +309 -0
  53. package/docs/Grid3-XML-Format.md +1788 -0
  54. package/docs/TobiiDynavox-Snap-Details.md +394 -0
  55. package/docs/asterics-Grid-fileformat-details.md +443 -0
  56. package/docs/obf_.obz Open Board File Formats.md +432 -0
  57. package/docs/touchchat.md +520 -0
  58. package/examples/.coverage +0 -0
  59. package/examples/.keep +1 -0
  60. package/examples/README.md +31 -0
  61. package/examples/communikate.dot +2637 -0
  62. package/examples/demo.js +143 -0
  63. package/examples/example-images.gridset +0 -0
  64. package/examples/example.ce +0 -0
  65. package/examples/example.dot +14 -0
  66. package/examples/example.grd +1 -0
  67. package/examples/example.gridset +0 -0
  68. package/examples/example.obf +27 -0
  69. package/examples/example.obz +0 -0
  70. package/examples/example.opml +18 -0
  71. package/examples/example.spb +0 -0
  72. package/examples/example.sps +0 -0
  73. package/examples/example2.grd +1 -0
  74. package/examples/gemini_response.txt +845 -0
  75. package/examples/image-map.js +45 -0
  76. package/examples/package-lock.json +1326 -0
  77. package/examples/package.json +10 -0
  78. package/examples/styled-output/converted-snap-to-touchchat.ce +0 -0
  79. package/examples/styled-output/styled-example.ce +0 -0
  80. package/examples/styled-output/styled-example.gridset +0 -0
  81. package/examples/styled-output/styled-example.obf +37 -0
  82. package/examples/styled-output/styled-example.spb +0 -0
  83. package/examples/styling-example.ts +316 -0
  84. package/examples/translate.js +39 -0
  85. package/examples/translate_demo.js +254 -0
  86. package/examples/translation_cache.json +44894 -0
  87. package/examples/typescript-demo.ts +251 -0
  88. package/examples/unified-interface-demo.ts +183 -0
  89. package/package.json +106 -0
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveGrid3CellImage = resolveGrid3CellImage;
4
+ function normalizeZipPathLocal(p) {
5
+ const unified = p.replace(/\\/g, '/');
6
+ try {
7
+ return unified.normalize('NFC');
8
+ }
9
+ catch {
10
+ return unified;
11
+ }
12
+ }
13
+ function listZipEntries(zip) {
14
+ try {
15
+ const raw = typeof zip?.getEntries === 'function' ? zip.getEntries() : [];
16
+ let entries = [];
17
+ if (Array.isArray(raw))
18
+ entries = raw;
19
+ const arr = entries;
20
+ return arr.map((e) => normalizeZipPathLocal(String(e.entryName)));
21
+ }
22
+ catch {
23
+ return [];
24
+ }
25
+ }
26
+ function extFromName(name) {
27
+ if (!name)
28
+ return undefined;
29
+ const m = name.match(/\.([A-Za-z0-9]+)$/);
30
+ return m ? `.${m[1].toLowerCase()}` : undefined;
31
+ }
32
+ function joinBaseDir(baseDir, leaf) {
33
+ const base = normalizeZipPathLocal(baseDir).replace(/\/?$/, '/');
34
+ return normalizeZipPathLocal(base + leaf.replace(/^\//, ''));
35
+ }
36
+ function resolveGrid3CellImage(zip, args) {
37
+ const { baseDir, dynamicFiles } = args;
38
+ const imageName = args.imageName?.trim();
39
+ const x = args.x;
40
+ const y = args.y;
41
+ const entries = new Set(listZipEntries(zip));
42
+ const has = (p) => entries.has(normalizeZipPathLocal(p));
43
+ // Built-in resource like [grid3x]...
44
+ if (imageName && imageName.startsWith('[')) {
45
+ if (args.builtinHandler) {
46
+ const mapped = args.builtinHandler(imageName);
47
+ if (mapped)
48
+ return mapped;
49
+ }
50
+ return null;
51
+ }
52
+ // Direct declared file
53
+ if (imageName) {
54
+ const p1 = joinBaseDir(baseDir, imageName);
55
+ if (has(p1))
56
+ return p1;
57
+ const p2 = joinBaseDir(baseDir, `Images/${imageName}`);
58
+ if (has(p2))
59
+ return p2;
60
+ }
61
+ // FileMap.xml dynamic files
62
+ if (x != null && y != null && dynamicFiles && dynamicFiles.length > 0) {
63
+ const prefix = joinBaseDir(baseDir, `${x}-${y}-`);
64
+ const matches = dynamicFiles
65
+ .map((f) => normalizeZipPathLocal(f))
66
+ .filter((f) => f.startsWith(prefix));
67
+ if (matches.length > 0) {
68
+ const preferred = matches.find((m) => /text/i.test(m)) || matches[0];
69
+ if (has(preferred))
70
+ return preferred;
71
+ }
72
+ }
73
+ // Coordinate-based guesses
74
+ if (x != null && y != null) {
75
+ const ext = extFromName(imageName);
76
+ if (ext) {
77
+ const c1 = joinBaseDir(baseDir, `${x}-${y}-0-text-0${ext}`);
78
+ if (has(c1))
79
+ return c1;
80
+ const c2 = joinBaseDir(baseDir, `${x}-${y}${ext}`);
81
+ if (has(c2))
82
+ return c2;
83
+ }
84
+ else {
85
+ const candidates = [
86
+ `${x}-${y}-0-text-0.jpeg`,
87
+ `${x}-${y}-0-text-0.jpg`,
88
+ `${x}-${y}-0-text-0.png`,
89
+ `${x}-${y}.jpeg`,
90
+ `${x}-${y}.jpg`,
91
+ `${x}-${y}.png`,
92
+ ].map((n) => joinBaseDir(baseDir, n));
93
+ for (const c of candidates) {
94
+ if (has(c))
95
+ return c;
96
+ }
97
+ }
98
+ }
99
+ return null;
100
+ }
@@ -0,0 +1,28 @@
1
+ import { BaseProcessor, ProcessorOptions, ExtractStringsResult, TranslatedString, SourceString } from '../core/baseProcessor';
2
+ import { AACTree } from '../core/treeStructure';
3
+ declare class GridsetProcessor extends BaseProcessor {
4
+ constructor(options?: ProcessorOptions);
5
+ private ensureAlphaChannel;
6
+ private generateCommandsFromSemanticAction;
7
+ private convertGrid3StyleToAACStyle;
8
+ private getStyleById;
9
+ private textOf;
10
+ extractTexts(filePathOrBuffer: string | Buffer): string[];
11
+ loadIntoTree(filePathOrBuffer: Buffer): AACTree;
12
+ processTexts(filePathOrBuffer: string | Buffer, translations: Map<string, string>, outputPath: string): Buffer;
13
+ saveFromTree(tree: AACTree, outputPath: string): void;
14
+ private calculateColumnDefinitions;
15
+ private calculateRowDefinitions;
16
+ private findButtonPosition;
17
+ /**
18
+ * Extract strings with metadata for aac-tools-platform compatibility
19
+ * Uses the generic implementation from BaseProcessor
20
+ */
21
+ extractStringsWithMetadata(filePath: string): Promise<ExtractStringsResult>;
22
+ /**
23
+ * Generate translated download for aac-tools-platform compatibility
24
+ * Uses the generic implementation from BaseProcessor
25
+ */
26
+ generateTranslatedDownload(filePath: string, translatedStrings: TranslatedString[], sourceStrings: SourceString[]): Promise<string>;
27
+ }
28
+ export { GridsetProcessor };