scratch-render-fonts 1.0.0 → 1.0.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/.editorconfig +11 -0
- package/.eslintignore +2 -0
- package/.eslintrc.js +3 -0
- package/.github/workflows/ci-cd.yml +48 -0
- package/.husky/.gitattributes +1 -0
- package/.husky/commit-msg +4 -0
- package/.nvmrc +1 -0
- package/CHANGELOG.md +19 -0
- package/README.md +20 -0
- package/commitlint.config.js +4 -0
- package/pack/scratch-render-fonts-1.0.1.tgz +0 -0
- package/package.json +28 -20
- package/release.config.js +13 -0
- package/renovate.json5 +7 -0
- package/src/.eslintrc.js +7 -0
- package/src/index.js +41 -41
- package/.circleci/config.yml +0 -81
package/.editorconfig
ADDED
package/.eslintignore
ADDED
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
name: CI/CD
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab
|
|
5
|
+
pull_request: # Runs whenever a pull request is created or updated
|
|
6
|
+
push: # Runs whenever a commit is pushed to the repository
|
|
7
|
+
branches: [master, hotfix/*] # ...on any of these branches
|
|
8
|
+
|
|
9
|
+
concurrency:
|
|
10
|
+
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
|
|
11
|
+
cancel-in-progress: true
|
|
12
|
+
|
|
13
|
+
permissions:
|
|
14
|
+
contents: write # publish a GitHub release
|
|
15
|
+
pages: write # deploy to GitHub Pages
|
|
16
|
+
issues: write # comment on released issues
|
|
17
|
+
pull-requests: write # comment on released pull requests
|
|
18
|
+
|
|
19
|
+
jobs:
|
|
20
|
+
ci-cd:
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
|
|
24
|
+
- uses: wagoid/commitlint-github-action@5ce82f5d814d4010519d15f0552aec4f17a1e1fe # v5
|
|
25
|
+
if: github.event_name == 'pull_request'
|
|
26
|
+
- uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3
|
|
27
|
+
with:
|
|
28
|
+
cache: 'npm'
|
|
29
|
+
node-version-file: '.nvmrc'
|
|
30
|
+
- name: Info
|
|
31
|
+
run: |
|
|
32
|
+
cat <<EOF
|
|
33
|
+
Node version: $(node --version)
|
|
34
|
+
NPM version: $(npm --version)
|
|
35
|
+
GitHub ref: ${{ github.ref }}
|
|
36
|
+
GitHub head ref: ${{ github.head_ref }}
|
|
37
|
+
EOF
|
|
38
|
+
- name: Setup
|
|
39
|
+
run: npm ci
|
|
40
|
+
- name: Lint
|
|
41
|
+
run: npm run lint
|
|
42
|
+
- name: Build
|
|
43
|
+
run: npm run build
|
|
44
|
+
- name: Release
|
|
45
|
+
env:
|
|
46
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
47
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
48
|
+
run: npx --no -- semantic-release
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
* text eol=lf
|
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
v16
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file. See
|
|
4
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## [1.0.1](https://github.com/scratchfoundation/scratch-render-fonts/compare/v1.0.0...v1.0.1) (2024-02-21)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* bump version to sync with npm registry ([104c050](https://github.com/scratchfoundation/scratch-render-fonts/commit/104c0506658d707081bd29a042f7bae903e9bba2))
|
|
12
|
+
|
|
13
|
+
# 1.0.0 (2024-02-21)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* **deps:** acknowledge semantic-release dev dependency ([0bd6614](https://github.com/scratchfoundation/scratch-render-fonts/commit/0bd6614018b67a655488b71ffd052e43e391a4ac))
|
|
19
|
+
* **deps:** update to semantic-release@^19 ([6bee7ca](https://github.com/scratchfoundation/scratch-render-fonts/commit/6bee7cae2355540d90b2bac2f48c69b96b023cf0))
|
package/README.md
CHANGED
|
@@ -1,2 +1,22 @@
|
|
|
1
1
|
# scratch-render-fonts
|
|
2
|
+
|
|
2
3
|
Fonts for Scratch SVG rendering
|
|
4
|
+
|
|
5
|
+
[](https://github.com/scratchfoundation/scratch-render-fonts/actions/workflows/ci-cd.yml)
|
|
6
|
+
|
|
7
|
+
## Committing
|
|
8
|
+
|
|
9
|
+
This project uses [semantic release](https://github.com/semantic-release/semantic-release) to ensure version bumps
|
|
10
|
+
follow semver so that projects depending on it don't break unexpectedly.
|
|
11
|
+
|
|
12
|
+
In order to automatically determine version updates, semantic release expects commit messages to follow the
|
|
13
|
+
[conventional-changelog](https://github.com/bcoe/conventional-changelog-standard/blob/master/convention.md)
|
|
14
|
+
specification.
|
|
15
|
+
|
|
16
|
+
Use the [commitizen CLI](https://github.com/commitizen/cz-cli) to make commits formatted in this way:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install -g commitizen
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Now you're ready to make commits using `git cz`.
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,37 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scratch-render-fonts",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"author": "Massachusetts Institute of Technology",
|
|
7
|
+
"homepage": "https://github.com/scratchfoundation/scratch-render-fonts#readme",
|
|
7
8
|
"repository": {
|
|
8
9
|
"type": "git",
|
|
9
|
-
"url": "
|
|
10
|
+
"url": "https://git@github.com/scratchfoundation/scratch-render-fonts.git"
|
|
10
11
|
},
|
|
11
12
|
"scripts": {
|
|
12
|
-
"build": "npm run clean && webpack --progress --
|
|
13
|
+
"build": "npm run clean && webpack --progress --bail",
|
|
13
14
|
"clean": "rimraf ./dist",
|
|
15
|
+
"lint": "eslint .",
|
|
14
16
|
"test": "npm run build",
|
|
15
|
-
"watch": "webpack --progress --
|
|
17
|
+
"watch": "webpack --progress --watch"
|
|
18
|
+
},
|
|
19
|
+
"config": {
|
|
20
|
+
"commitizen": {
|
|
21
|
+
"path": "cz-conventional-changelog"
|
|
22
|
+
}
|
|
16
23
|
},
|
|
17
|
-
"homepage": "https://github.com/LLK/scratch-render-fonts#readme",
|
|
18
24
|
"dependencies": {
|
|
19
|
-
"base64-loader": "1.0.0"
|
|
25
|
+
"base64-loader": "^1.0.0"
|
|
20
26
|
},
|
|
21
27
|
"devDependencies": {
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"babel-
|
|
25
|
-
"babel-
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"eslint
|
|
29
|
-
"eslint-
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"rimraf": "
|
|
34
|
-
"
|
|
35
|
-
"
|
|
28
|
+
"@commitlint/cli": "17.8.0",
|
|
29
|
+
"@commitlint/config-conventional": "17.8.0",
|
|
30
|
+
"babel-core": "6.26.3",
|
|
31
|
+
"babel-eslint": "10.1.0",
|
|
32
|
+
"babel-loader": "7.1.5",
|
|
33
|
+
"babel-preset-env": "1.7.0",
|
|
34
|
+
"eslint": "8.56.0",
|
|
35
|
+
"eslint-config-scratch": "9.0.3",
|
|
36
|
+
"husky": "8.0.3",
|
|
37
|
+
"json": "10.0.0",
|
|
38
|
+
"lodash.defaultsdeep": "4.6.1",
|
|
39
|
+
"rimraf": "2.7.1",
|
|
40
|
+
"scratch-semantic-release-config": "1.0.8",
|
|
41
|
+
"semantic-release": "19.0.5",
|
|
42
|
+
"webpack": "4.47.0",
|
|
43
|
+
"webpack-cli": "3.3.12"
|
|
36
44
|
}
|
|
37
45
|
}
|
package/renovate.json5
ADDED
package/src/.eslintrc.js
ADDED
package/src/index.js
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
// Synchronously load TTF fonts.
|
|
2
|
-
// First, have Webpack load their data as Base 64 strings.
|
|
3
|
-
let FONTS;
|
|
4
|
-
|
|
5
|
-
const getFonts = function () {
|
|
6
|
-
if (FONTS) return FONTS;
|
|
7
|
-
/* eslint-disable global-require */
|
|
8
|
-
FONTS = {
|
|
9
|
-
'Sans Serif': require('base64-loader!./NotoSans-Medium.ttf'),
|
|
10
|
-
'Serif': require('base64-loader!./SourceSerifPro-Regular.otf'),
|
|
11
|
-
'Handwriting': require('base64-loader!./handlee-regular.ttf'),
|
|
12
|
-
'Marker': require('base64-loader!./Knewave.ttf'),
|
|
13
|
-
'Curly': require('base64-loader!./Griffy-Regular.ttf'),
|
|
14
|
-
'Pixel': require('base64-loader!./Grand9K-Pixel.ttf'),
|
|
15
|
-
'Scratch': require('base64-loader!./Scratch.ttf')
|
|
16
|
-
};
|
|
17
|
-
/* eslint-enable global-require */
|
|
18
|
-
|
|
19
|
-
// For each Base 64 string,
|
|
20
|
-
// 1. Replace each with a usable @font-face tag that points to a Data URI.
|
|
21
|
-
// 2. Inject the font into a style on `document.body`, so measurements
|
|
22
|
-
// can be accurately taken in SvgRenderer._transformMeasurements.
|
|
23
|
-
for (const fontName in FONTS) {
|
|
24
|
-
const fontData = FONTS[fontName];
|
|
25
|
-
FONTS[fontName] = '@font-face {' +
|
|
26
|
-
`font-family: "${fontName}";src: url("data:application/x-font-ttf;charset=utf-8;base64,${fontData}");}`;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (!document.getElementById('scratch-font-styles')) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return FONTS;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
module.exports = getFonts;
|
|
1
|
+
// Synchronously load TTF fonts.
|
|
2
|
+
// First, have Webpack load their data as Base 64 strings.
|
|
3
|
+
let FONTS;
|
|
4
|
+
|
|
5
|
+
const getFonts = function () {
|
|
6
|
+
if (FONTS) return FONTS;
|
|
7
|
+
/* eslint-disable global-require */
|
|
8
|
+
FONTS = {
|
|
9
|
+
'Sans Serif': require('base64-loader!./NotoSans-Medium.ttf'),
|
|
10
|
+
'Serif': require('base64-loader!./SourceSerifPro-Regular.otf'),
|
|
11
|
+
'Handwriting': require('base64-loader!./handlee-regular.ttf'),
|
|
12
|
+
'Marker': require('base64-loader!./Knewave.ttf'),
|
|
13
|
+
'Curly': require('base64-loader!./Griffy-Regular.ttf'),
|
|
14
|
+
'Pixel': require('base64-loader!./Grand9K-Pixel.ttf'),
|
|
15
|
+
'Scratch': require('base64-loader!./Scratch.ttf')
|
|
16
|
+
};
|
|
17
|
+
/* eslint-enable global-require */
|
|
18
|
+
|
|
19
|
+
// For each Base 64 string,
|
|
20
|
+
// 1. Replace each with a usable @font-face tag that points to a Data URI.
|
|
21
|
+
// 2. Inject the font into a style on `document.body`, so measurements
|
|
22
|
+
// can be accurately taken in SvgRenderer._transformMeasurements.
|
|
23
|
+
for (const fontName in FONTS) {
|
|
24
|
+
const fontData = FONTS[fontName];
|
|
25
|
+
FONTS[fontName] = '@font-face {' +
|
|
26
|
+
`font-family: "${fontName}";src: url("data:application/x-font-ttf;charset=utf-8;base64,${fontData}");}`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (!document.getElementById('scratch-font-styles')) {
|
|
30
|
+
const documentStyleTag = document.createElement('style');
|
|
31
|
+
documentStyleTag.id = 'scratch-font-styles';
|
|
32
|
+
for (const fontName in FONTS) {
|
|
33
|
+
documentStyleTag.textContent += FONTS[fontName];
|
|
34
|
+
}
|
|
35
|
+
document.body.insertBefore(documentStyleTag, document.body.firstChild);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return FONTS;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
module.exports = getFonts;
|
package/.circleci/config.yml
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
version: 2.1
|
|
2
|
-
|
|
3
|
-
executors:
|
|
4
|
-
default-executor:
|
|
5
|
-
docker:
|
|
6
|
-
- image: "cimg/node:8.17.0"
|
|
7
|
-
resource_class: large
|
|
8
|
-
|
|
9
|
-
commands:
|
|
10
|
-
setup:
|
|
11
|
-
steps:
|
|
12
|
-
- run:
|
|
13
|
-
name: Setup
|
|
14
|
-
command: |
|
|
15
|
-
npm install
|
|
16
|
-
npm update
|
|
17
|
-
npm prune
|
|
18
|
-
test:
|
|
19
|
-
steps:
|
|
20
|
-
- run:
|
|
21
|
-
name: Test
|
|
22
|
-
command: |
|
|
23
|
-
npm run test
|
|
24
|
-
deploy:
|
|
25
|
-
steps:
|
|
26
|
-
- run:
|
|
27
|
-
name: Deploy
|
|
28
|
-
command: |
|
|
29
|
-
echo "export NPM_TAG=latest" >> $BASH_ENV
|
|
30
|
-
echo "export NODE_ENV=production" >> $BASH_ENV
|
|
31
|
-
echo "export RELEASE_TIMESTAMP=$(date +'%Y%m%d%H%M%S')" >> $BASH_ENV
|
|
32
|
-
npm run build
|
|
33
|
-
VPKG=$($(npm bin)/json -f package.json version)
|
|
34
|
-
echo "export VERSION=${VPKG}-prerelease.$(date +%Y%m%d%H%M%S)" >> $BASH_ENV
|
|
35
|
-
npm --no-git-tag-version version $VERSION
|
|
36
|
-
after_deploy:
|
|
37
|
-
steps:
|
|
38
|
-
- run:
|
|
39
|
-
name: After Deploy
|
|
40
|
-
command: |
|
|
41
|
-
npm set //registry.npmjs.org/:_authToken=$NPM_TOKEN
|
|
42
|
-
npm publish
|
|
43
|
-
|
|
44
|
-
jobs:
|
|
45
|
-
build-and-test:
|
|
46
|
-
executor: default-executor
|
|
47
|
-
steps:
|
|
48
|
-
- checkout
|
|
49
|
-
- setup
|
|
50
|
-
- test
|
|
51
|
-
deploy:
|
|
52
|
-
executor: default-executor
|
|
53
|
-
steps:
|
|
54
|
-
- checkout
|
|
55
|
-
- setup
|
|
56
|
-
- deploy
|
|
57
|
-
- after_deploy
|
|
58
|
-
|
|
59
|
-
workflows:
|
|
60
|
-
build-and-test-workflow:
|
|
61
|
-
when:
|
|
62
|
-
not:
|
|
63
|
-
and:
|
|
64
|
-
- equal: [tsm/circleci, <<pipeline.git.branch>>]
|
|
65
|
-
jobs:
|
|
66
|
-
- build-and-test
|
|
67
|
-
|
|
68
|
-
deploy-workflow:
|
|
69
|
-
when:
|
|
70
|
-
or:
|
|
71
|
-
- equal: [master, <<pipeline.git.branch>>]
|
|
72
|
-
- equal: [develop, <<pipeline.git.branch>>]
|
|
73
|
-
- equal: [hotfix/*, <<pipeline.git.branch>>]
|
|
74
|
-
- equal: [tsm/circleci, <<pipeline.git.branch>>]
|
|
75
|
-
jobs:
|
|
76
|
-
- build-and-test
|
|
77
|
-
- deploy:
|
|
78
|
-
context:
|
|
79
|
-
- scratch-npm-creds
|
|
80
|
-
requires:
|
|
81
|
-
- build-and-test
|