lyrics-structure 1.4.0 → 1.4.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.
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,6 @@
1
- import { getSlideParts } from './slide';
2
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const slide_1 = require("./slide");
3
4
  const comprehensiveInput = `
4
5
  [verse]
5
6
  First line of verse
@@ -42,6 +43,5 @@ Regular line
42
43
  [/verse 2]
43
44
 
44
45
  [chorus]`;
45
-
46
46
  console.log('Output from getSlideParts:');
47
- console.log(JSON.stringify(getSlideParts(comprehensiveInput), null, 2));
47
+ console.log(JSON.stringify((0, slide_1.getSlideParts)(comprehensiveInput), null, 2));
@@ -0,0 +1,2 @@
1
+ export * from './slide.js';
2
+ export * from './lyrics.js';
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./slide.js"), exports);
18
+ __exportStar(require("./lyrics.js"), exports);
@@ -0,0 +1,25 @@
1
+ export type LyricPart = {
2
+ name: string | undefined;
3
+ repetition: boolean;
4
+ indication: string | null;
5
+ content: string | undefined;
6
+ };
7
+ /**
8
+ * Splits lyrics into structured parts, handling named sections, repetitions, and indications.
9
+ * Works with lyrics formatted using square brackets for section names and optional parentheses for indications.
10
+ *
11
+ * Example input:
12
+ * ```
13
+ * [verse 1] (first time)
14
+ * Lyrics content here
15
+ * [/verse 1]
16
+ *
17
+ * [chorus]
18
+ * Chorus lyrics
19
+ * [/chorus]
20
+ * ```
21
+ *
22
+ * @param lyrics - The input lyrics text to be parsed into parts
23
+ * @returns Array of LyricPart objects containing structured lyrics data
24
+ */
25
+ export declare function getLyricsParts(lyrics: string): LyricPart[];
package/dist/lyrics.js ADDED
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLyricsParts = getLyricsParts;
4
+ /**
5
+ * Splits lyrics into structured parts, handling named sections, repetitions, and indications.
6
+ * Works with lyrics formatted using square brackets for section names and optional parentheses for indications.
7
+ *
8
+ * Example input:
9
+ * ```
10
+ * [verse 1] (first time)
11
+ * Lyrics content here
12
+ * [/verse 1]
13
+ *
14
+ * [chorus]
15
+ * Chorus lyrics
16
+ * [/chorus]
17
+ * ```
18
+ *
19
+ * @param lyrics - The input lyrics text to be parsed into parts
20
+ * @returns Array of LyricPart objects containing structured lyrics data
21
+ */
22
+ function getLyricsParts(lyrics) {
23
+ const parts = [];
24
+ const seenParts = new Map();
25
+ const partContentMap = new Map();
26
+ // First pass: extract all content with closing tags
27
+ const cleanedText = lyrics.replace(/\[([^\]]+)\](?:\s*\(([^)]+)\))?\s*([\s\S]*?)\[\/\1\]/g, (match, key, indication, content) => {
28
+ if (!partContentMap.has(key)) {
29
+ partContentMap.set(key, content.trim());
30
+ }
31
+ return `[${key}]${indication ? ` (${indication})` : ''}`;
32
+ });
33
+ // Split the lyrics into lines and process them
34
+ const lines = cleanedText.split('\n');
35
+ let currentPart = null;
36
+ let currentUnnamedContent = [];
37
+ for (let i = 0; i < lines.length; i++) {
38
+ const line = lines[i].trim();
39
+ // Check for part start
40
+ const partStartMatch = line.match(/^\[([^\]]+)\](?:\s*\(([^)]+)\))?$/);
41
+ if (partStartMatch) {
42
+ // If we have accumulated unnamed content, add it as a part
43
+ if (currentUnnamedContent.length > 0) {
44
+ parts.push({
45
+ name: undefined,
46
+ repetition: false,
47
+ indication: null,
48
+ content: currentUnnamedContent.join('\n'),
49
+ });
50
+ currentUnnamedContent = [];
51
+ }
52
+ const partName = partStartMatch[1];
53
+ const indication = partStartMatch[2] || null;
54
+ // Check if this part has been seen before
55
+ const partCount = (seenParts.get(partName) || 0) + 1;
56
+ seenParts.set(partName, partCount);
57
+ currentPart = {
58
+ name: partName,
59
+ repetition: partCount > 1,
60
+ indication,
61
+ content: partContentMap.get(partName),
62
+ };
63
+ parts.push(currentPart);
64
+ continue;
65
+ }
66
+ // Handle content without a part container
67
+ if (line && !line.startsWith('[') && !line.startsWith('[/')) {
68
+ currentUnnamedContent.push(line);
69
+ }
70
+ else if (currentUnnamedContent.length > 0) {
71
+ // If we hit a part marker or empty line, add the accumulated content
72
+ parts.push({
73
+ name: undefined,
74
+ repetition: false,
75
+ indication: null,
76
+ content: currentUnnamedContent.join('\n'),
77
+ });
78
+ currentUnnamedContent = [];
79
+ }
80
+ }
81
+ // Add any remaining unnamed content
82
+ if (currentUnnamedContent.length > 0) {
83
+ parts.push({
84
+ name: undefined,
85
+ repetition: false,
86
+ indication: null,
87
+ content: currentUnnamedContent.join('\n'),
88
+ });
89
+ }
90
+ return parts;
91
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const lyrics_1 = require("./lyrics");
4
+ const testLyrics = `[partname 1] (indication 1)
5
+
6
+ content 1
7
+
8
+ [/partname 1]
9
+
10
+ [partname 1] (indication 2)
11
+
12
+ [partname 2]
13
+
14
+ content 2
15
+
16
+ [/partname 2]
17
+
18
+ [interlude 1]
19
+
20
+ [partname 3]
21
+
22
+ content without partname container
23
+
24
+ content standalone 1
25
+ content standalone 2
26
+ `;
27
+ describe('getLyricsParts', () => {
28
+ it('should correctly parse lyrics into parts', () => {
29
+ const result = (0, lyrics_1.getLyricsParts)(testLyrics);
30
+ expect(result).toEqual([
31
+ {
32
+ name: 'partname 1',
33
+ repetition: false,
34
+ indication: 'indication 1',
35
+ content: 'content 1',
36
+ },
37
+ {
38
+ name: 'partname 1',
39
+ repetition: true,
40
+ indication: 'indication 2',
41
+ content: 'content 1',
42
+ },
43
+ {
44
+ name: 'partname 2',
45
+ repetition: false,
46
+ indication: null,
47
+ content: 'content 2',
48
+ },
49
+ {
50
+ name: 'interlude 1',
51
+ repetition: false,
52
+ indication: null,
53
+ content: undefined,
54
+ },
55
+ {
56
+ name: 'partname 3',
57
+ repetition: false,
58
+ indication: null,
59
+ content: undefined,
60
+ },
61
+ {
62
+ name: undefined,
63
+ repetition: false,
64
+ indication: null,
65
+ content: 'content without partname container',
66
+ },
67
+ {
68
+ name: undefined,
69
+ repetition: false,
70
+ indication: null,
71
+ content: 'content standalone 1\ncontent standalone 2',
72
+ },
73
+ ]);
74
+ });
75
+ });
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Splits text into natural sections based on text structure.
3
+ * Works with plain text without requiring markdown or special formatting.
4
+ * Empty lines are treated as natural separators between parts.
5
+ *
6
+ * @param text - The input text to be split into sections
7
+ * @param maxLines - Maximum number of lines to include in a single slide (default: 4)
8
+ * @returns An array of content sections
9
+ */
10
+ export declare const getSlideParts: (text?: string, maxLines?: number) => string[];
package/dist/slide.js ADDED
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ /**
3
+ * Splits text into natural sections based on text structure.
4
+ * Works with plain text without requiring markdown or special formatting.
5
+ * Empty lines are treated as natural separators between parts.
6
+ *
7
+ * @param text - The input text to be split into sections
8
+ * @param maxLines - Maximum number of lines to include in a single slide (default: 4)
9
+ * @returns An array of content sections
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getSlideParts = void 0;
13
+ const lyrics_1 = require("./lyrics");
14
+ const isLineTooLong = (line) => line.length > 60;
15
+ const processContent = (content, maxLines) => {
16
+ const slides = [];
17
+ let currentSlide = [];
18
+ content.split('\n').forEach((line) => {
19
+ const trimmedLine = line.trim();
20
+ if (!trimmedLine) {
21
+ if (currentSlide.length > 0) {
22
+ slides.push(currentSlide.join('\n'));
23
+ currentSlide = [];
24
+ }
25
+ return;
26
+ }
27
+ if (currentSlide.length >= maxLines ||
28
+ (currentSlide.length >= 2 && currentSlide.filter(isLineTooLong).length >= 2)) {
29
+ slides.push(currentSlide.join('\n'));
30
+ currentSlide = [];
31
+ }
32
+ currentSlide.push(trimmedLine);
33
+ });
34
+ if (currentSlide.length > 0) {
35
+ slides.push(currentSlide.join('\n'));
36
+ }
37
+ return slides;
38
+ };
39
+ const getSlideParts = (text, maxLines = 4) => {
40
+ if (!text)
41
+ return [];
42
+ const partsText = (0, lyrics_1.getLyricsParts)(text).map((part) => part.content);
43
+ const result = [];
44
+ partsText.forEach((part) => {
45
+ if (part) {
46
+ result.push(...processContent(part, maxLines));
47
+ }
48
+ });
49
+ return result;
50
+ };
51
+ exports.getSlideParts = getSlideParts;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,6 @@
1
- import { getSlideParts } from './slide.js';
2
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const slide_js_1 = require("./slide.js");
3
4
  describe('Comprehensive Tests', () => {
4
5
  test('handles all cases in one comprehensive input', () => {
5
6
  const comprehensiveInput = `
@@ -44,8 +45,7 @@ Regular line
44
45
  [/verse 2]
45
46
 
46
47
  [chorus]`;
47
-
48
- expect(getSlideParts(comprehensiveInput)).toEqual([
48
+ expect((0, slide_js_1.getSlideParts)(comprehensiveInput)).toEqual([
49
49
  'First line of verse\nSecond line of verse\nThird line of verse\nFourth line of verse',
50
50
  'Fifth line of verse',
51
51
  'First line of verse\nSecond line of verse\nThird line of verse\nFourth line of verse',
@@ -63,9 +63,7 @@ Regular line
63
63
  'First chorus line\nSecond chorus line'
64
64
  ]);
65
65
  });
66
-
67
66
  });
68
-
69
67
  describe('maxLines parameter', () => {
70
68
  const input = `
71
69
  [verse]
@@ -75,9 +73,8 @@ Line three
75
73
  Line four
76
74
  Line five
77
75
  [/verse]`;
78
-
79
76
  test('maxLines=1 outputs one line per slide', () => {
80
- expect(getSlideParts(input, 1)).toEqual([
77
+ expect((0, slide_js_1.getSlideParts)(input, 1)).toEqual([
81
78
  'Line one',
82
79
  'Line two',
83
80
  'Line three',
@@ -85,22 +82,19 @@ Line five
85
82
  'Line five',
86
83
  ]);
87
84
  });
88
-
89
85
  test('maxLines=2 outputs at most two lines per slide', () => {
90
- expect(getSlideParts(input, 2)).toEqual([
86
+ expect((0, slide_js_1.getSlideParts)(input, 2)).toEqual([
91
87
  'Line one\nLine two',
92
88
  'Line three\nLine four',
93
89
  'Line five',
94
90
  ]);
95
91
  });
96
-
97
92
  test('default maxLines (4) groups up to four lines', () => {
98
- expect(getSlideParts(input)).toEqual([
93
+ expect((0, slide_js_1.getSlideParts)(input)).toEqual([
99
94
  'Line one\nLine two\nLine three\nLine four',
100
95
  'Line five',
101
96
  ]);
102
97
  });
103
-
104
98
  test('maxLines=2 still splits on empty lines', () => {
105
99
  const inputWithGap = `
106
100
  [verse]
@@ -111,14 +105,12 @@ Line three
111
105
  Line four
112
106
  Line five
113
107
  [/verse]`;
114
-
115
- expect(getSlideParts(inputWithGap, 2)).toEqual([
108
+ expect((0, slide_js_1.getSlideParts)(inputWithGap, 2)).toEqual([
116
109
  'Line one\nLine two',
117
110
  'Line three\nLine four',
118
111
  'Line five',
119
112
  ]);
120
113
  });
121
-
122
114
  test('maxLines=2 with long lines still breaks at 2 long lines', () => {
123
115
  const inputWithLongLines = `
124
116
  [verse]
@@ -126,10 +118,9 @@ This is a very long line that should be considered too long for the slide
126
118
  This is another very long line that should also be considered too long
127
119
  Short line
128
120
  [/verse]`;
129
-
130
- expect(getSlideParts(inputWithLongLines, 2)).toEqual([
121
+ expect((0, slide_js_1.getSlideParts)(inputWithLongLines, 2)).toEqual([
131
122
  'This is a very long line that should be considered too long for the slide\nThis is another very long line that should also be considered too long',
132
123
  'Short line',
133
124
  ]);
134
125
  });
135
- });
126
+ });
package/package.json CHANGED
@@ -1,11 +1,15 @@
1
1
  {
2
2
  "name": "lyrics-structure",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "Parse lyrics with bracketed sections into structured parts, with slide generation for presentations",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
7
10
  "scripts": {
8
11
  "build": "tsc",
12
+ "prepublishOnly": "npm run build",
9
13
  "test": "jest",
10
14
  "test:watch": "jest --watch",
11
15
  "format": "prettier --write \"**/*.{ts,js,json,md}\""
@@ -1,30 +0,0 @@
1
- name: Publish to npm
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
-
8
- jobs:
9
- publish:
10
- runs-on: ubuntu-latest
11
- permissions:
12
- contents: read
13
- id-token: write
14
- steps:
15
- - uses: actions/checkout@v4
16
-
17
- - uses: actions/setup-node@v4
18
- with:
19
- node-version: 20
20
- registry-url: https://registry.npmjs.org
21
-
22
- - run: npm ci
23
-
24
- - run: npm run build
25
-
26
- - run: npm test
27
-
28
- - run: npm publish --provenance --access public
29
- env:
30
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/.prettierrc DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "semi": true,
3
- "trailingComma": "es5",
4
- "singleQuote": true,
5
- "printWidth": 100,
6
- "tabWidth": 2,
7
- "useTabs": false,
8
- "bracketSpacing": true,
9
- "arrowParens": "always"
10
- }
@@ -1,19 +0,0 @@
1
- {
2
- "editor.formatOnSave": true,
3
- "editor.defaultFormatter": "esbenp.prettier-vscode",
4
- "editor.codeActionsOnSave": {
5
- "source.fixAll": "explicit"
6
- },
7
- "[typescript]": {
8
- "editor.defaultFormatter": "esbenp.prettier-vscode"
9
- },
10
- "[javascript]": {
11
- "editor.defaultFormatter": "esbenp.prettier-vscode"
12
- },
13
- "[json]": {
14
- "editor.defaultFormatter": "esbenp.prettier-vscode"
15
- },
16
- "[markdown]": {
17
- "editor.defaultFormatter": "esbenp.prettier-vscode"
18
- }
19
- }
package/CHANGELOG.md DELETED
@@ -1,56 +0,0 @@
1
- # Changelog
2
-
3
- ## [1.2.2] - 2024-04-06
4
-
5
- ### Fixed
6
-
7
- - Fixed issue where consecutive lines without part containers were incorrectly split into separate parts
8
- - Improved handling of regular text lines to maintain proper grouping
9
-
10
- ## [1.2.0] - 2024-03-XX
11
-
12
- ### Changed
13
-
14
- - Simplified the lyrics format to use clear section markers
15
- - Updated documentation with clearer examples
16
- - Improved type definitions for better TypeScript support
17
-
18
- ### Added
19
-
20
- - Support for section indications in parentheses
21
- - Better handling of repeated sections
22
- - More intuitive content structure
23
-
24
- ### Removed
25
-
26
- - Slide-based content splitting
27
- - Special command tags
28
- - Complex formatting options
29
-
30
- ## [1.1.0] - 2024-03-XX
31
-
32
- ### Added
33
-
34
- - Initial release
35
- - `getParts` function for basic content extraction
36
- - `getSlideParts` function for slide-based content splitting
37
- - Support for special command tags
38
- - Comprehensive test suite
39
- - TypeScript types and documentation
40
-
41
- ### Features
42
-
43
- - Bracketed section parsing
44
- - Special command tag handling
45
- - Slide splitting based on content length
46
- - Empty line separation
47
- - Long line handling (>40 characters)
48
- - Whitespace preservation
49
- - Unicode support in tags
50
-
51
- ### Test Coverage
52
-
53
- - Basic functionality tests
54
- - Slide splitting tests
55
- - Special command tests
56
- - Edge case handling
package/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './slide.js';
2
- export * from './lyrics.js';
package/jest.config.js DELETED
@@ -1,17 +0,0 @@
1
- /** @type {import('ts-jest').JestConfigWithTsJest} */
2
- export default {
3
- preset: 'ts-jest',
4
- testEnvironment: 'node',
5
- extensionsToTreatAsEsm: ['.ts'],
6
- moduleNameMapper: {
7
- '^(\\.{1,2}/.*)\\.js$': '$1',
8
- },
9
- transform: {
10
- '^.+\\.tsx?$': [
11
- 'ts-jest',
12
- {
13
- useESM: true,
14
- },
15
- ],
16
- },
17
- };
package/lyrics.test.ts DELETED
@@ -1,76 +0,0 @@
1
- import { getLyricsParts } from './lyrics';
2
-
3
- const testLyrics = `[partname 1] (indication 1)
4
-
5
- content 1
6
-
7
- [/partname 1]
8
-
9
- [partname 1] (indication 2)
10
-
11
- [partname 2]
12
-
13
- content 2
14
-
15
- [/partname 2]
16
-
17
- [interlude 1]
18
-
19
- [partname 3]
20
-
21
- content without partname container
22
-
23
- content standalone 1
24
- content standalone 2
25
- `;
26
-
27
- describe('getLyricsParts', () => {
28
- it('should correctly parse lyrics into parts', () => {
29
- const result = getLyricsParts(testLyrics);
30
-
31
- expect(result).toEqual([
32
- {
33
- name: 'partname 1',
34
- repetition: false,
35
- indication: 'indication 1',
36
- content: 'content 1',
37
- },
38
- {
39
- name: 'partname 1',
40
- repetition: true,
41
- indication: 'indication 2',
42
- content: 'content 1',
43
- },
44
- {
45
- name: 'partname 2',
46
- repetition: false,
47
- indication: null,
48
- content: 'content 2',
49
- },
50
- {
51
- name: 'interlude 1',
52
- repetition: false,
53
- indication: null,
54
- content: undefined,
55
- },
56
- {
57
- name: 'partname 3',
58
- repetition: false,
59
- indication: null,
60
- content: undefined,
61
- },
62
- {
63
- name: undefined,
64
- repetition: false,
65
- indication: null,
66
- content: 'content without partname container',
67
- },
68
- {
69
- name: undefined,
70
- repetition: false,
71
- indication: null,
72
- content: 'content standalone 1\ncontent standalone 2',
73
- },
74
- ]);
75
- });
76
- });
package/lyrics.ts DELETED
@@ -1,107 +0,0 @@
1
- export type LyricPart = {
2
- name: string | undefined;
3
- repetition: boolean;
4
- indication: string | null;
5
- content: string | undefined;
6
- };
7
- /**
8
- * Splits lyrics into structured parts, handling named sections, repetitions, and indications.
9
- * Works with lyrics formatted using square brackets for section names and optional parentheses for indications.
10
- *
11
- * Example input:
12
- * ```
13
- * [verse 1] (first time)
14
- * Lyrics content here
15
- * [/verse 1]
16
- *
17
- * [chorus]
18
- * Chorus lyrics
19
- * [/chorus]
20
- * ```
21
- *
22
- * @param lyrics - The input lyrics text to be parsed into parts
23
- * @returns Array of LyricPart objects containing structured lyrics data
24
- */
25
-
26
- export function getLyricsParts(lyrics: string): LyricPart[] {
27
- const parts: LyricPart[] = [];
28
- const seenParts = new Map<string, number>();
29
- const partContentMap = new Map<string, string>();
30
-
31
- // First pass: extract all content with closing tags
32
- const cleanedText = lyrics.replace(
33
- /\[([^\]]+)\](?:\s*\(([^)]+)\))?\s*([\s\S]*?)\[\/\1\]/g,
34
- (match, key: string, indication: string | undefined, content: string) => {
35
- if (!partContentMap.has(key)) {
36
- partContentMap.set(key, content.trim());
37
- }
38
- return `[${key}]${indication ? ` (${indication})` : ''}`;
39
- }
40
- );
41
-
42
- // Split the lyrics into lines and process them
43
- const lines = cleanedText.split('\n');
44
- let currentPart: LyricPart | null = null;
45
- let currentUnnamedContent: string[] = [];
46
-
47
- for (let i = 0; i < lines.length; i++) {
48
- const line = lines[i].trim();
49
-
50
- // Check for part start
51
- const partStartMatch = line.match(/^\[([^\]]+)\](?:\s*\(([^)]+)\))?$/);
52
- if (partStartMatch) {
53
- // If we have accumulated unnamed content, add it as a part
54
- if (currentUnnamedContent.length > 0) {
55
- parts.push({
56
- name: undefined,
57
- repetition: false,
58
- indication: null,
59
- content: currentUnnamedContent.join('\n'),
60
- });
61
- currentUnnamedContent = [];
62
- }
63
-
64
- const partName = partStartMatch[1];
65
- const indication = partStartMatch[2] || null;
66
-
67
- // Check if this part has been seen before
68
- const partCount = (seenParts.get(partName) || 0) + 1;
69
- seenParts.set(partName, partCount);
70
-
71
- currentPart = {
72
- name: partName,
73
- repetition: partCount > 1,
74
- indication,
75
- content: partContentMap.get(partName),
76
- };
77
- parts.push(currentPart);
78
- continue;
79
- }
80
-
81
- // Handle content without a part container
82
- if (line && !line.startsWith('[') && !line.startsWith('[/')) {
83
- currentUnnamedContent.push(line);
84
- } else if (currentUnnamedContent.length > 0) {
85
- // If we hit a part marker or empty line, add the accumulated content
86
- parts.push({
87
- name: undefined,
88
- repetition: false,
89
- indication: null,
90
- content: currentUnnamedContent.join('\n'),
91
- });
92
- currentUnnamedContent = [];
93
- }
94
- }
95
-
96
- // Add any remaining unnamed content
97
- if (currentUnnamedContent.length > 0) {
98
- parts.push({
99
- name: undefined,
100
- repetition: false,
101
- indication: null,
102
- content: currentUnnamedContent.join('\n'),
103
- });
104
- }
105
-
106
- return parts;
107
- }
package/slide.ts DELETED
@@ -1,61 +0,0 @@
1
- /**
2
- * Splits text into natural sections based on text structure.
3
- * Works with plain text without requiring markdown or special formatting.
4
- * Empty lines are treated as natural separators between parts.
5
- *
6
- * @param text - The input text to be split into sections
7
- * @param maxLines - Maximum number of lines to include in a single slide (default: 4)
8
- * @returns An array of content sections
9
- */
10
-
11
- import { getLyricsParts } from './lyrics';
12
-
13
- const isLineTooLong = (line: string) => line.length > 60;
14
- const processContent = (content: string, maxLines: number): string[] => {
15
- const slides: string[] = [];
16
- let currentSlide: string[] = [];
17
-
18
- content.split('\n').forEach((line) => {
19
- const trimmedLine = line.trim();
20
-
21
- if (!trimmedLine) {
22
- if (currentSlide.length > 0) {
23
- slides.push(currentSlide.join('\n'));
24
- currentSlide = [];
25
- }
26
- return;
27
- }
28
-
29
- if (
30
- currentSlide.length >= maxLines ||
31
- (currentSlide.length >= 2 && currentSlide.filter(isLineTooLong).length >= 2)
32
- ) {
33
- slides.push(currentSlide.join('\n'));
34
- currentSlide = [];
35
- }
36
-
37
- currentSlide.push(trimmedLine);
38
- });
39
-
40
- if (currentSlide.length > 0) {
41
- slides.push(currentSlide.join('\n'));
42
- }
43
-
44
- return slides;
45
- };
46
-
47
- export const getSlideParts = (text?: string, maxLines: number = 4): string[] => {
48
- if (!text) return [];
49
-
50
- const partsText = getLyricsParts(text).map((part) => part.content);
51
-
52
- const result: string[] = [];
53
-
54
- partsText.forEach((part) => {
55
- if (part) {
56
- result.push(...processContent(part, maxLines));
57
- }
58
- });
59
-
60
- return result;
61
- };
package/tsconfig.json DELETED
@@ -1,113 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- /* Visit https://aka.ms/tsconfig to read more about this file */
4
-
5
- /* Projects */
6
- // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
7
- // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8
- // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
9
- // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
10
- // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11
- // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
-
13
- /* Language and Environment */
14
- "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
15
- // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16
- // "jsx": "preserve", /* Specify what JSX code is generated. */
17
- // "libReplacement": true, /* Enable lib replacement. */
18
- // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
19
- // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
20
- // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
21
- // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
22
- // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
23
- // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
24
- // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
25
- // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
26
- // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
27
-
28
- /* Modules */
29
- "module": "NodeNext", /* Specify what module code is generated. */
30
- "moduleResolution": "NodeNext", /* Specify how TypeScript looks up a file from a given module specifier. */
31
- // "rootDir": "./", /* Specify the root folder within your source files. */
32
- // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
33
- // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
34
- // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
35
- // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
36
- // "types": [], /* Specify type package names to be included without being referenced in a source file. */
37
- // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
38
- // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
39
- // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
40
- // "rewriteRelativeImportExtensions": true, /* Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files. */
41
- // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
42
- // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
43
- // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
44
- // "noUncheckedSideEffectImports": true, /* Check side effect imports. */
45
- // "resolveJsonModule": true, /* Enable importing .json files. */
46
- // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
47
- // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
48
-
49
- /* JavaScript Support */
50
- // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
51
- // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
52
- // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
53
-
54
- /* Emit */
55
- "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
56
- // "declarationMap": true, /* Create sourcemaps for d.ts files. */
57
- // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
58
- // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
59
- // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
60
- // "noEmit": true, /* Disable emitting files from a compilation. */
61
- // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
62
- "outDir": "./dist", /* Specify an output folder for all emitted files. */
63
- // "removeComments": true, /* Disable emitting comments. */
64
- // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
65
- // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
66
- // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
67
- // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
68
- // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
69
- // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
70
- // "newLine": "crlf", /* Set the newline character for emitting files. */
71
- // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
72
- // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
73
- // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
74
- // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
75
- // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
76
-
77
- /* Interop Constraints */
78
- // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
79
- // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
80
- // "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
81
- // "erasableSyntaxOnly": true, /* Do not allow runtime constructs that are not part of ECMAScript. */
82
- // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
83
- "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
84
- // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
85
- "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
86
-
87
- /* Type Checking */
88
- "strict": true, /* Enable all strict type-checking options. */
89
- // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
90
- // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
91
- // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
92
- // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
93
- // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
94
- // "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */
95
- // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
96
- // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
97
- // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
98
- // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
99
- // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
100
- // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
101
- // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
102
- // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
103
- // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
104
- // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
105
- // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
106
- // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
107
- // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
108
-
109
- /* Completeness */
110
- // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
111
- "skipLibCheck": true /* Skip type checking all .d.ts files. */
112
- }
113
- }