@neatico/visual-core 0.14.3 → 0.14.64

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 (68) hide show
  1. package/dist/candidateRanking.d.ts +31 -0
  2. package/dist/candidateRanking.js +55 -0
  3. package/dist/cjs/candidateRanking.js +61 -0
  4. package/dist/cjs/composition.js +62 -36
  5. package/dist/cjs/compositionNumbers.js +111 -0
  6. package/dist/cjs/compositionScenes.js +91 -38
  7. package/dist/cjs/compositionUseCases.js +145 -0
  8. package/dist/cjs/content.js +574 -120
  9. package/dist/cjs/contentBrief.js +82 -0
  10. package/dist/cjs/designBlueprint.js +94 -19
  11. package/dist/cjs/designSystem.js +536 -77
  12. package/dist/cjs/editorial.js +76 -20
  13. package/dist/cjs/fontCatalog.js +81 -23
  14. package/dist/cjs/formalCompositions.js +120 -0
  15. package/dist/cjs/index.js +13 -0
  16. package/dist/cjs/layoutContracts.js +57 -11
  17. package/dist/cjs/layouts.js +5 -92
  18. package/dist/cjs/nativeSocialParameters.js +145 -0
  19. package/dist/cjs/pagination.js +27 -7
  20. package/dist/cjs/parameterDefaults.js +20 -0
  21. package/dist/cjs/recipeParameters.js +304 -0
  22. package/dist/cjs/socialLayouts.js +127 -387
  23. package/dist/cjs/styleManifest.js +107 -0
  24. package/dist/cjs/text.js +12 -2
  25. package/dist/cjs/textPresentation.js +68 -0
  26. package/dist/composition.d.ts +4 -4
  27. package/dist/composition.js +62 -36
  28. package/dist/compositionNumbers.d.ts +4 -0
  29. package/dist/compositionNumbers.js +108 -0
  30. package/dist/compositionScenes.d.ts +2 -2
  31. package/dist/compositionScenes.js +91 -38
  32. package/dist/compositionUseCases.d.ts +1 -0
  33. package/dist/compositionUseCases.js +142 -0
  34. package/dist/content.d.ts +65 -20
  35. package/dist/content.js +575 -121
  36. package/dist/contentBrief.d.ts +16 -0
  37. package/dist/contentBrief.js +78 -0
  38. package/dist/designBlueprint.d.ts +4 -4
  39. package/dist/designBlueprint.js +95 -20
  40. package/dist/designSystem.d.ts +11 -7
  41. package/dist/designSystem.js +537 -79
  42. package/dist/editorial.d.ts +1 -1
  43. package/dist/editorial.js +77 -21
  44. package/dist/fontCatalog.d.ts +1 -1
  45. package/dist/fontCatalog.js +81 -23
  46. package/dist/formalCompositions.d.ts +26 -0
  47. package/dist/formalCompositions.js +116 -0
  48. package/dist/index.d.ts +10 -0
  49. package/dist/index.js +10 -0
  50. package/dist/layoutContracts.d.ts +3 -3
  51. package/dist/layoutContracts.js +58 -12
  52. package/dist/layouts.d.ts +2 -2
  53. package/dist/layouts.js +5 -92
  54. package/dist/nativeSocialParameters.d.ts +38 -0
  55. package/dist/nativeSocialParameters.js +139 -0
  56. package/dist/pagination.js +27 -7
  57. package/dist/parameterDefaults.d.ts +2 -0
  58. package/dist/parameterDefaults.js +17 -0
  59. package/dist/recipeParameters.d.ts +34 -0
  60. package/dist/recipeParameters.js +300 -0
  61. package/dist/socialLayouts.d.ts +40 -232
  62. package/dist/socialLayouts.js +127 -387
  63. package/dist/styleManifest.d.ts +20 -0
  64. package/dist/styleManifest.js +103 -0
  65. package/dist/text.js +12 -2
  66. package/dist/textPresentation.d.ts +29 -0
  67. package/dist/textPresentation.js +64 -0
  68. package/package.json +1 -1
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createContentBrief = createContentBrief;
4
+ exports.validateContentBrief = validateContentBrief;
5
+ function createContentBrief(source) {
6
+ if (!source ||
7
+ source.version !== 1 ||
8
+ typeof source.text !== "string" ||
9
+ !source.text.trim() ||
10
+ !Array.isArray(source.segments) ||
11
+ !source.segments.length)
12
+ throw new Error("CONTENT_BRIEF_INVALID");
13
+ const provenance = source.provenance;
14
+ if (provenance &&
15
+ (!["creative-draft", "user-revision"].includes(provenance.kind) ||
16
+ typeof provenance.original !== "string" ||
17
+ !provenance.original.trim() ||
18
+ typeof provenance.disclosure !== "string" ||
19
+ !provenance.disclosure.trim() ||
20
+ (provenance.originalMode !== undefined &&
21
+ (provenance.kind !== "user-revision" ||
22
+ !["source-backed", "creative"].includes(provenance.originalMode))) ||
23
+ (provenance.illustrative !== undefined &&
24
+ (provenance.kind !== "user-revision" || typeof provenance.illustrative !== "boolean")) ||
25
+ (provenance.simulationAllowed !== undefined &&
26
+ typeof provenance.simulationAllowed !== "boolean") ||
27
+ (provenance.language !== undefined &&
28
+ (typeof provenance.language !== "string" ||
29
+ !/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8}){0,3}$/.test(provenance.language)))))
30
+ throw new Error("CONTENT_BRIEF_INVALID");
31
+ const sourceIds = source.segments.map((segment) => segment.id);
32
+ if (sourceIds.some((id) => typeof id !== "string" || !id) ||
33
+ new Set(sourceIds).size !== sourceIds.length)
34
+ throw new Error("CONTENT_BRIEF_INVALID");
35
+ return validateContentBrief({
36
+ version: 1,
37
+ originalInput: provenance?.original || source.text,
38
+ ...(provenance?.kind === "user-revision" ? { revisedInput: source.text } : {}),
39
+ ...(provenance?.kind === "user-revision" && provenance.illustrative ? { revisedInputIllustrative: true } : {}),
40
+ mode: provenance?.kind === "user-revision" ? provenance.originalMode || "source-backed" : provenance ? "creative" : "source-backed",
41
+ ...(provenance?.language ? { language: provenance.language } : {}),
42
+ creativeAllowed: true,
43
+ simulationAllowed: true,
44
+ sourceIds,
45
+ });
46
+ }
47
+ function validateContentBrief(value) {
48
+ const brief = value;
49
+ if (!brief ||
50
+ brief.version !== 1 ||
51
+ typeof brief.originalInput !== "string" ||
52
+ !brief.originalInput.trim() ||
53
+ brief.originalInput.length > 20000 ||
54
+ (brief.revisedInput !== undefined &&
55
+ (typeof brief.revisedInput !== "string" || !brief.revisedInput.trim() || brief.revisedInput.length > 20000)) ||
56
+ (brief.revisedInputIllustrative !== undefined &&
57
+ (typeof brief.revisedInputIllustrative !== "boolean" || brief.revisedInput === undefined)) ||
58
+ !["source-backed", "creative"].includes(brief.mode) ||
59
+ typeof brief.creativeAllowed !== "boolean" ||
60
+ typeof brief.simulationAllowed !== "boolean" ||
61
+ (brief.simulationAllowed && !brief.creativeAllowed) ||
62
+ (brief.language !== undefined &&
63
+ (typeof brief.language !== "string" ||
64
+ !/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8}){0,3}$/.test(brief.language))) ||
65
+ !Array.isArray(brief.sourceIds) ||
66
+ !brief.sourceIds.length ||
67
+ brief.sourceIds.length > 1024 ||
68
+ new Set(brief.sourceIds).size !== brief.sourceIds.length ||
69
+ brief.sourceIds.some((id) => typeof id !== "string" || !id || id.length > 160))
70
+ throw new Error("CONTENT_BRIEF_INVALID");
71
+ return {
72
+ version: 1,
73
+ originalInput: brief.originalInput,
74
+ ...(brief.revisedInput !== undefined ? { revisedInput: brief.revisedInput } : {}),
75
+ ...(brief.revisedInputIllustrative !== undefined ? { revisedInputIllustrative: brief.revisedInputIllustrative } : {}),
76
+ mode: brief.mode,
77
+ ...(brief.language ? { language: brief.language } : {}),
78
+ creativeAllowed: brief.creativeAllowed,
79
+ simulationAllowed: brief.simulationAllowed,
80
+ sourceIds: [...brief.sourceIds],
81
+ };
82
+ }
@@ -4,31 +4,106 @@ exports.DESIGN_SAMPLE_LOCALES = void 0;
4
4
  exports.validateDesignBlueprint = validateDesignBlueprint;
5
5
  exports.blueprintFitsContent = blueprintFitsContent;
6
6
  const content_js_1 = require("./content.js");
7
- exports.DESIGN_SAMPLE_LOCALES = ['en-US', 'zh-CH', 'ja-JP', 'de-DE', 'fr-FR', 'es-ES', 'pt-PT'];
7
+ exports.DESIGN_SAMPLE_LOCALES = [
8
+ "en-US",
9
+ "zh-CH",
10
+ "ja-JP",
11
+ "de-DE",
12
+ "fr-FR",
13
+ "es-ES",
14
+ "pt-PT",
15
+ ];
8
16
  function validateDesignBlueprint(raw) {
9
17
  const v = raw;
10
- if (!v || v.version !== 2 || typeof v.id !== 'string' || !/^[a-z][a-z0-9-]{0,79}$/.test(v.id))
11
- throw new Error('DESIGN_BLUEPRINT_ID');
12
- const kinds = ['paragraph', 'steps', 'features', 'comparison', 'code', 'parameters', 'quote', 'chart', 'image'];
13
- if (!Array.isArray(v.kinds) || !v.kinds.length || v.kinds.length > 9 || v.kinds.some(k => !kinds.includes(k)))
14
- throw new Error('DESIGN_BLUEPRINT_KINDS');
15
- if (!v.labels || typeof v.labels !== 'object' || Array.isArray(v.labels) || typeof v.labels.en !== 'string' || !v.labels.en.trim() || Object.entries(v.labels).some(([key, value]) => !/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/.test(key) || typeof value !== 'string' || !value.trim() || value.length > 120))
16
- throw new Error('DESIGN_BLUEPRINT_LABELS');
17
- if (!Array.isArray(v.ratios) || !v.ratios.length || v.ratios.length > 8 || v.ratios.some(n => !Number.isFinite(n) || n < .25 || n > 4))
18
- throw new Error('DESIGN_BLUEPRINT_RATIOS');
19
- const number = (n, min, max) => { if (typeof n !== 'number' || !Number.isFinite(n) || n < min || n > max)
20
- throw new Error('DESIGN_BLUEPRINT_RANGE'); return n; };
18
+ if (!v ||
19
+ v.version !== 2 ||
20
+ typeof v.id !== "string" ||
21
+ !/^[a-z][a-z0-9-]{0,79}$/.test(v.id))
22
+ throw new Error("DESIGN_BLUEPRINT_ID");
23
+ const kinds = [
24
+ "paragraph",
25
+ "steps",
26
+ "features",
27
+ "comparison",
28
+ "code",
29
+ "parameters",
30
+ "quote",
31
+ "chart",
32
+ "image",
33
+ ];
34
+ if (!Array.isArray(v.kinds) ||
35
+ !v.kinds.length ||
36
+ v.kinds.length > 9 ||
37
+ v.kinds.some((k) => !kinds.includes(k)))
38
+ throw new Error("DESIGN_BLUEPRINT_KINDS");
39
+ if (!v.labels ||
40
+ typeof v.labels !== "object" ||
41
+ Array.isArray(v.labels) ||
42
+ typeof v.labels.en !== "string" ||
43
+ !v.labels.en.trim() ||
44
+ Object.entries(v.labels).some(([key, value]) => !/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/.test(key) ||
45
+ typeof value !== "string" ||
46
+ !value.trim() ||
47
+ value.length > 120))
48
+ throw new Error("DESIGN_BLUEPRINT_LABELS");
49
+ if (!Array.isArray(v.ratios) ||
50
+ !v.ratios.length ||
51
+ v.ratios.length > 8 ||
52
+ v.ratios.some((n) => !Number.isFinite(n) || n < 0.25 || n > 4))
53
+ throw new Error("DESIGN_BLUEPRINT_RATIOS");
54
+ const number = (n, min, max) => {
55
+ if (typeof n !== "number" || !Number.isFinite(n) || n < min || n > max)
56
+ throw new Error("DESIGN_BLUEPRINT_RANGE");
57
+ return n;
58
+ };
21
59
  const c = v.capacity, l = v.layout;
22
60
  if (!c || !l)
23
- throw new Error('DESIGN_BLUEPRINT_MISSING');
24
- if (!['stack', 'split', 'editorial'].includes(l.mode) || !['none', 'panels', 'bands'].includes(l.surface) || !['none', 'rail', 'rule'].includes(l.accent))
25
- throw new Error('DESIGN_BLUEPRINT_LAYOUT');
61
+ throw new Error("DESIGN_BLUEPRINT_MISSING");
62
+ if (!["stack", "split", "editorial"].includes(l.mode) ||
63
+ !["none", "panels", "bands"].includes(l.surface) ||
64
+ !["none", "rail", "rule"].includes(l.accent))
65
+ throw new Error("DESIGN_BLUEPRINT_LAYOUT");
26
66
  const maxEntries = number(c.maxEntries, 1, 20), maxBlocks = number(c.maxBlocks, 1, 8), columns = number(l.columns, 1, 4);
27
67
  if (![maxEntries, maxBlocks, columns].every(Number.isInteger))
28
- throw new Error('DESIGN_BLUEPRINT_INTEGER');
29
- return { version: 2, id: v.id, labels: { ...v.labels }, kinds: [...new Set(v.kinds)], ratios: [...new Set(v.ratios)], capacity: { maxCharacters: number(c.maxCharacters, 40, 20000), maxEntries, maxBlocks }, layout: { mode: l.mode, margin: number(l.margin, 32, 80), gap: number(l.gap, 12, 40), titleScale: number(l.titleScale, .8, 1.15), bodyScale: number(l.bodyScale, .9, 1.15), columns, surface: l.surface, accent: l.accent } };
68
+ throw new Error("DESIGN_BLUEPRINT_INTEGER");
69
+ return {
70
+ version: 2,
71
+ id: v.id,
72
+ labels: { ...v.labels },
73
+ kinds: [...new Set(v.kinds)],
74
+ ratios: [...new Set(v.ratios)],
75
+ capacity: {
76
+ maxCharacters: number(c.maxCharacters, 40, 20000),
77
+ maxEntries,
78
+ maxBlocks,
79
+ },
80
+ layout: {
81
+ mode: l.mode,
82
+ margin: number(l.margin, 32, 80),
83
+ gap: number(l.gap, 12, 40),
84
+ titleScale: number(l.titleScale, 0.8, 1.15),
85
+ bodyScale: number(l.bodyScale, 0.9, 1.15),
86
+ columns,
87
+ surface: l.surface,
88
+ accent: l.accent,
89
+ },
90
+ };
30
91
  }
31
92
  function blueprintFitsContent(blueprint, page, ratio) {
32
- const entries = page.blocks.reduce((sum, b) => sum + ('entries' in b ? b.entries.length : 'columns' in b ? b.columns.length : 'rows' in b ? b.rows.length : 'values' in b ? b.values.length : 0), 0);
33
- return blueprint.ratios.some(r => Math.abs(r - ratio) < .001) && page.blocks.length <= blueprint.capacity.maxBlocks && page.blocks.every(b => blueprint.kinds.includes(b.kind)) && page.blocks.flatMap(content_js_1.contentBlockText).join('').length <= blueprint.capacity.maxCharacters && entries <= blueprint.capacity.maxEntries;
93
+ const entries = page.blocks.reduce((sum, b) => sum +
94
+ ("entries" in b
95
+ ? b.entries.length
96
+ : "columns" in b
97
+ ? b.columns.length
98
+ : "rows" in b
99
+ ? b.rows.length
100
+ : "values" in b
101
+ ? b.values.length
102
+ : 0), 0);
103
+ return (blueprint.ratios.some((r) => Math.abs(r - ratio) < 0.001) &&
104
+ page.blocks.length <= blueprint.capacity.maxBlocks &&
105
+ page.blocks.every((b) => blueprint.kinds.includes(b.kind)) &&
106
+ page.blocks.flatMap(content_js_1.contentBlockText).join("").length <=
107
+ blueprint.capacity.maxCharacters &&
108
+ entries <= blueprint.capacity.maxEntries);
34
109
  }