@vue-skuilder/client 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Colin Kennedy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # This package is inactive and should probably be deleted.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,87 @@
1
+ import * as fs from 'fs';
2
+ import axios from 'axios';
3
+
4
+ makeSpellingNotes();
5
+ testAPI();
6
+ function testAPI() {
7
+ // works!
8
+ axios.get('https://eduquilt.com/express').then((res) => {
9
+ console.log(res);
10
+ });
11
+ }
12
+ function isCVCword(w) {
13
+ if (w.length != 3)
14
+ return false;
15
+ const vowels = ['a', 'e', 'i', 'o', 'u'];
16
+ const consonants = 'bcdfghjklmnpqrstvwxyz'.split('');
17
+ const first = w[0];
18
+ const second = w[1];
19
+ const third = w[2];
20
+ return (consonants.includes(first) &&
21
+ vowels.includes(second) &&
22
+ consonants.includes(third));
23
+ }
24
+ function isCVCeWord(w) {
25
+ if (w.length != 4)
26
+ return false;
27
+ const last = w[3];
28
+ if (last !== 'e')
29
+ return false;
30
+ return isCVCword(w.slice(0, 3));
31
+ }
32
+ function cardText(w) {
33
+ return `Spell the word:
34
+
35
+ {{ ${w} }}`;
36
+ }
37
+ function spellingCardTags(w) {
38
+ const ret = ['spelling'];
39
+ if (isCVCword(w)) {
40
+ ret.push('CVC');
41
+ const vowel = w[1];
42
+ ret.push(`CVC-${vowel}`);
43
+ ret.push(`short-${vowel}`);
44
+ }
45
+ if (isCVCeWord(w)) {
46
+ ret.push('CVCe');
47
+ const vowel = w[1];
48
+ ret.push(`CVCe-${vowel}`);
49
+ ret.push(`long-${vowel}}`);
50
+ }
51
+ return ret;
52
+ }
53
+ function makeSpellingNotes() {
54
+ const ret = [];
55
+ const recordingsDir = '/home/colin/dev/eqrecordings';
56
+ const recordings = fs.readdirSync(recordingsDir);
57
+ recordings.sort((a, b) => a.length - b.length);
58
+ recordings.forEach((recording) => {
59
+ const word = recording.split('.')[0];
60
+ const ext = recording.split('.')[1];
61
+ if (word.length > 1 && // omit letters
62
+ ext === 'mp3') {
63
+ // exec(`xdg-open ${recordingsDir + '/' + recording}`); // works
64
+ const card = cardText(word);
65
+ const tags = spellingCardTags(word);
66
+ if (isCVCword(word)) {
67
+ console.log(`CVC word: ${word}`);
68
+ console.log(card);
69
+ }
70
+ if (isCVCeWord(word)) {
71
+ console.log(`CVCe word: ${word}`);
72
+ }
73
+ const note = {
74
+ md: card,
75
+ audio: fs.readFileSync(recordingsDir + '/' + recording),
76
+ tags: tags,
77
+ };
78
+ // ret.push(note);
79
+ console.log(note);
80
+ console.log(card);
81
+ console.log(tags);
82
+ }
83
+ // fs.writeFileSync(`./src/spelling/${word}.md`, `# ${word}`);
84
+ });
85
+ return ret;
86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K,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAEnC,QAAA,IACE,IAAI,CAAC,MAAM,GAAG,CAAC;YACf,GAAG,KAAK,KAAK,EACb;;AAGA,YAAA,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;AAC3B,YAAA,MAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC;AAEnC,YAAA,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE;AACnB,gBAAA,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,CAAA,CAAE,CAAC;AAEhC,gBAAA,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;;AAEnB,YAAA,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE;AACpB,gBAAA,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,CAAA,CAAE,CAAC;;AAEnC,YAAA,MAAM,IAAI,GAAG;AACX,gBAAA,EAAE,EAAE,IAAI;gBACR,KAAK,EAAE,EAAE,CAAC,YAAY,CAAC,aAAa,GAAG,GAAG,GAAG,SAAS,CAAC;AACvD,gBAAA,IAAI,EAAE,IAAI;aACX;;AAGD,YAAA,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;AACjB,YAAA,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;AACjB,YAAA,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;;;AAIrB,KAAC,CAAC;AACF,IAAA,OAAO,GAAG;AACZ"}
package/dist/index.js ADDED
@@ -0,0 +1,108 @@
1
+ 'use strict';
2
+
3
+ var fs = require('fs');
4
+ var axios = require('axios');
5
+
6
+ function _interopNamespaceDefault(e) {
7
+ var n = Object.create(null);
8
+ if (e) {
9
+ Object.keys(e).forEach(function (k) {
10
+ if (k !== 'default') {
11
+ var d = Object.getOwnPropertyDescriptor(e, k);
12
+ Object.defineProperty(n, k, d.get ? d : {
13
+ enumerable: true,
14
+ get: function () { return e[k]; }
15
+ });
16
+ }
17
+ });
18
+ }
19
+ n.default = e;
20
+ return Object.freeze(n);
21
+ }
22
+
23
+ var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
24
+
25
+ makeSpellingNotes();
26
+ testAPI();
27
+ function testAPI() {
28
+ // works!
29
+ axios.get('https://eduquilt.com/express').then((res) => {
30
+ console.log(res);
31
+ });
32
+ }
33
+ function isCVCword(w) {
34
+ if (w.length != 3)
35
+ return false;
36
+ const vowels = ['a', 'e', 'i', 'o', 'u'];
37
+ const consonants = 'bcdfghjklmnpqrstvwxyz'.split('');
38
+ const first = w[0];
39
+ const second = w[1];
40
+ const third = w[2];
41
+ return (consonants.includes(first) &&
42
+ vowels.includes(second) &&
43
+ consonants.includes(third));
44
+ }
45
+ function isCVCeWord(w) {
46
+ if (w.length != 4)
47
+ return false;
48
+ const last = w[3];
49
+ if (last !== 'e')
50
+ return false;
51
+ return isCVCword(w.slice(0, 3));
52
+ }
53
+ function cardText(w) {
54
+ return `Spell the word:
55
+
56
+ {{ ${w} }}`;
57
+ }
58
+ function spellingCardTags(w) {
59
+ const ret = ['spelling'];
60
+ if (isCVCword(w)) {
61
+ ret.push('CVC');
62
+ const vowel = w[1];
63
+ ret.push(`CVC-${vowel}`);
64
+ ret.push(`short-${vowel}`);
65
+ }
66
+ if (isCVCeWord(w)) {
67
+ ret.push('CVCe');
68
+ const vowel = w[1];
69
+ ret.push(`CVCe-${vowel}`);
70
+ ret.push(`long-${vowel}}`);
71
+ }
72
+ return ret;
73
+ }
74
+ function makeSpellingNotes() {
75
+ const ret = [];
76
+ const recordingsDir = '/home/colin/dev/eqrecordings';
77
+ const recordings = fs__namespace.readdirSync(recordingsDir);
78
+ recordings.sort((a, b) => a.length - b.length);
79
+ recordings.forEach((recording) => {
80
+ const word = recording.split('.')[0];
81
+ const ext = recording.split('.')[1];
82
+ if (word.length > 1 && // omit letters
83
+ ext === 'mp3') {
84
+ // exec(`xdg-open ${recordingsDir + '/' + recording}`); // works
85
+ const card = cardText(word);
86
+ const tags = spellingCardTags(word);
87
+ if (isCVCword(word)) {
88
+ console.log(`CVC word: ${word}`);
89
+ console.log(card);
90
+ }
91
+ if (isCVCeWord(word)) {
92
+ console.log(`CVCe word: ${word}`);
93
+ }
94
+ const note = {
95
+ md: card,
96
+ audio: fs__namespace.readFileSync(recordingsDir + '/' + recording),
97
+ tags: tags,
98
+ };
99
+ // ret.push(note);
100
+ console.log(note);
101
+ console.log(card);
102
+ console.log(tags);
103
+ }
104
+ // fs.writeFileSync(`./src/spelling/${word}.md`, `# ${word}`);
105
+ });
106
+ return ret;
107
+ }
108
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":[null],"names":["fs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAUA,iBAAiB,EAAE;AAanB,OAAO,EAAE;AAET,SAAS,OAAO,GAAA;;IAEd,KAAK,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,KAAI;AACrD,QAAA,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;AAClB,KAAC,CAAC;AACJ;AAEA,SAAS,SAAS,CAAC,CAAS,EAAA;AAC1B,IAAA,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC;AAAE,QAAA,OAAO,KAAK;AAE/B,IAAA,MAAM,MAAM,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;IACxC,MAAM,UAAU,GAAG,uBAAuB,CAAC,KAAK,CAAC,EAAE,CAAC;AAEpD,IAAA,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC;AAClB,IAAA,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;AACnB,IAAA,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC;AAElB,IAAA,QACE,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC;AAC1B,QAAA,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;AACvB,QAAA,U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;;"}
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@vue-skuilder/client",
3
+ "publishConfig": {
4
+ "access": "public"
5
+ },
6
+ "version": "0.1.1",
7
+ "license": "MIT",
8
+ "main": "dist/index.js",
9
+ "module": "dist/index.esm.js",
10
+ "typings": "dist/index.d.ts",
11
+ "files": [
12
+ "dist",
13
+ "src"
14
+ ],
15
+ "engines": {
16
+ "node": ">=12"
17
+ },
18
+ "scripts": {
19
+ "build": "rimraf dist && tsc && rollup --bundleConfigAsCjs -c",
20
+ "dev": "rollup --bundleConfigAsCjs -c -w",
21
+ "lint": "eslint 'src/**/*.ts'"
22
+ },
23
+ "prettier": {
24
+ "printWidth": 80,
25
+ "semi": true,
26
+ "singleQuote": true,
27
+ "trailingComma": "es5"
28
+ },
29
+ "author": "Colin Kennedy",
30
+ "dependencies": {
31
+ "axios": "^1.7.4",
32
+ "command-line-args": "^5.2.1"
33
+ },
34
+ "devDependencies": {
35
+ "@rollup/plugin-commonjs": "^25.0.7",
36
+ "@rollup/plugin-node-resolve": "^15.2.3",
37
+ "@rollup/plugin-typescript": "^11.1.6",
38
+ "@types/jest": "^29.5.12",
39
+ "@types/node": "^20.2.5",
40
+ "@typescript-eslint/eslint-plugin": "^7.4.0",
41
+ "@typescript-eslint/parser": "^7.4.0",
42
+ "eslint": "^8.57.0",
43
+ "jest": "^29.7.0",
44
+ "rimraf": "^5.0.5",
45
+ "rollup": "^4.12.1",
46
+ "ts-jest": "^29.1.2",
47
+ "tslib": "^2.6.2",
48
+ "typescript": "~5.7.2"
49
+ }
50
+ }
package/src/index.ts ADDED
@@ -0,0 +1,163 @@
1
+ import * as fs from 'fs';
2
+ import axios from 'axios';
3
+
4
+ // import { addNote55 } from 'new-skuilder';
5
+
6
+ // const spellingCourseID = 'a9fae15687220aa6ce62018005087c95';
7
+ // testAPI();
8
+
9
+ type AudioData = Buffer;
10
+
11
+ makeSpellingNotes();
12
+ makeSelectionNotes();
13
+
14
+ // createCard();
15
+
16
+ function makeSelectionNotes() {
17
+ // todo
18
+ // 1. get all the words
19
+ // 2. batch groups w/ low hamming distance ... ?
20
+ // 3. create notes
21
+ // 4. tag according to hamming diff (eg, what is the target phoneme different than given alternatives)
22
+ }
23
+
24
+ testAPI();
25
+
26
+ function testAPI() {
27
+ // works!
28
+ axios.get('https://eduquilt.com/express').then((res) => {
29
+ console.log(res);
30
+ });
31
+ }
32
+
33
+ function isCVCword(w: string): boolean {
34
+ if (w.length != 3) return false;
35
+
36
+ const vowels = ['a', 'e', 'i', 'o', 'u'];
37
+ const consonants = 'bcdfghjklmnpqrstvwxyz'.split('');
38
+
39
+ const first = w[0];
40
+ const second = w[1];
41
+ const third = w[2];
42
+
43
+ return (
44
+ consonants.includes(first) &&
45
+ vowels.includes(second) &&
46
+ consonants.includes(third)
47
+ );
48
+ }
49
+
50
+ function isCVCeWord(w: string): boolean {
51
+ if (w.length != 4) return false;
52
+
53
+ const last = w[3];
54
+ if (last !== 'e') return false;
55
+
56
+ return isCVCword(w.slice(0, 3));
57
+ }
58
+
59
+ function cardText(w: string): string {
60
+ return `Spell the word:
61
+
62
+ {{ ${w} }}`;
63
+ }
64
+
65
+ function spellingCardTags(w: string): string[] {
66
+ const ret = ['spelling'];
67
+
68
+ if (isCVCword(w)) {
69
+ ret.push('CVC');
70
+ const vowel = w[1];
71
+ ret.push(`CVC-${vowel}`);
72
+ ret.push(`short-${vowel}`);
73
+ }
74
+
75
+ if (isCVCeWord(w)) {
76
+ ret.push('CVCe');
77
+ const vowel = w[1];
78
+ ret.push(`CVCe-${vowel}`);
79
+ ret.push(`long-${vowel}}`);
80
+ }
81
+
82
+ return ret;
83
+ }
84
+
85
+ // async function createCard() {
86
+ // // get request
87
+ // const req = http.request(
88
+ // {
89
+ // method: 'POST',
90
+ // host: 'eduquilt.com',
91
+ // port: 3000,
92
+ // path: '/express',
93
+ // headers: {
94
+ // 'Content-Type': 'application/json',
95
+ // },
96
+ // auth: 'colin:colin', // todo
97
+ // username: 'colin',
98
+ // password: 'colin',
99
+ // },
100
+ // (res) => {
101
+ // if (res.statusCode !== 200) {
102
+ // console.warn(`Request failed with status code ${res.statusCode}`);
103
+ // }
104
+ // console.error(res);
105
+ // }
106
+ // );
107
+ // const data = JSON.stringify({
108
+ // request: 'getCourse',
109
+ // courseID: spellingCourseID,
110
+ // });
111
+ // req.write(data);
112
+ // }
113
+
114
+ type spellingNote = {
115
+ md: string;
116
+ audio: AudioData;
117
+ tags: string[];
118
+ };
119
+
120
+ function makeSpellingNotes(): spellingNote[] {
121
+ const ret: spellingNote[] = [];
122
+
123
+ const recordingsDir = '/home/colin/dev/eqrecordings';
124
+ const recordings = fs.readdirSync(recordingsDir);
125
+ recordings.sort((a, b) => a.length - b.length);
126
+
127
+ recordings.forEach((recording) => {
128
+ const word = recording.split('.')[0];
129
+ const ext = recording.split('.')[1];
130
+
131
+ if (
132
+ word.length > 1 && // omit letters
133
+ ext === 'mp3'
134
+ ) {
135
+ // exec(`xdg-open ${recordingsDir + '/' + recording}`); // works
136
+
137
+ const card = cardText(word);
138
+ const tags = spellingCardTags(word);
139
+
140
+ if (isCVCword(word)) {
141
+ console.log(`CVC word: ${word}`);
142
+
143
+ console.log(card);
144
+ }
145
+ if (isCVCeWord(word)) {
146
+ console.log(`CVCe word: ${word}`);
147
+ }
148
+ const note = {
149
+ md: card,
150
+ audio: fs.readFileSync(recordingsDir + '/' + recording),
151
+ tags: tags,
152
+ };
153
+ // ret.push(note);
154
+
155
+ console.log(note);
156
+ console.log(card);
157
+ console.log(tags);
158
+ }
159
+
160
+ // fs.writeFileSync(`./src/spelling/${word}.md`, `# ${word}`);
161
+ });
162
+ return ret;
163
+ }