Prepare for Safari release

This commit is contained in:
Federico Brigante 2023-03-16 20:48:23 +08:00
parent 25c9c6de55
commit ecdf25c9ad
11 changed files with 132 additions and 21 deletions

View File

@ -0,0 +1,20 @@
env:
SCRIPT_NAME: build
# FILE GENERATED WITH: npx ghat fregante/ghatemplates/is-dist-up-to-date
# SOURCE: https://github.com/fregante/ghatemplates
name: Verify Built Files
on:
- pull_request
- push
jobs:
Verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: install
run: npm ci || npm install
- run: npm run ${{ env.SCRIPT_NAME }}
- name: verify that built files are up to date
run: git diff --exit-code

View File

@ -61,7 +61,7 @@ If the value an be set via DOM, like for a standard `contentEditable`, the secon
https://github.com/fregante/GhostText/blob/febe6a66146cd3e620ad4458e50954e213bbb629/source/ghost-text.js#L14-L30
In the more likely case where you have to access the websites own script data, you'd have to go through the `AdvancedTextWrapper`, which communicates with the [`unsafe-messenger` script](https://github.com/fregante/GhostText/blob/main/source/unsafe-messenger.js) to get and set the text:
In the more likely case where you have to access the websites own script data, you'd have to go through the `AdvancedTextWrapper`, which communicates with the [`advanced-editors-messenger` script](https://github.com/fregante/GhostText/blob/main/source/advanced-editors-messenger.js) to get and set the text:
https://github.com/fregante/GhostText/blob/febe6a66146cd3e620ad4458e50954e213bbb629/source/unsafe-messenger.js#L35-L51

48
package-lock.json generated
View File

@ -13,6 +13,7 @@
"devDependencies": {
"@codemirror/view": "^6.9.2",
"@parcel/config-webextension": "^2.8.3",
"dot-json": "^1.2.2",
"parcel": "^2.8.3",
"xo": "^0.53.1"
},
@ -2591,6 +2592,15 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/detect-indent": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-6.0.0.tgz",
"integrity": "sha512-oSyFlqaTHCItVRGK5RmrmjB+CmaMOW7IaNA/kdxqhoa6d17j/5ce9O9eWXmV/KEdRwqpQA+Vqe8a8Bsybu4YnA==",
"dev": true,
"engines": {
"node": ">=8"
}
},
"node_modules/detect-libc": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz",
@ -2615,6 +2625,15 @@
"node": ">=8"
}
},
"node_modules/docopt": {
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/docopt/-/docopt-0.6.2.tgz",
"integrity": "sha512-NqTbaYeE4gA/wU1hdKFdU+AFahpDOpgGLzHP42k6H6DKExJd0A55KEVWYhL9FEmHmgeLvEU2vuKXDuU+4yToOw==",
"dev": true,
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/doctrine": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz",
@ -2696,6 +2715,20 @@
"url": "https://github.com/fb55/domutils?sponsor=1"
}
},
"node_modules/dot-json": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/dot-json/-/dot-json-1.2.2.tgz",
"integrity": "sha512-AKL+GsO4wSEU4LU+fAk/PqN4nQ6PB1vT3HpMiZous9xCzK5S0kh4DzfUY0EfU67jsIXLlu0ty71659N9Nmg+Tw==",
"dev": true,
"dependencies": {
"detect-indent": "~6.0.0",
"docopt": "~0.6.2",
"underscore-keypath": "~0.0.22"
},
"bin": {
"dot-json": "bin/dot-json.js"
}
},
"node_modules/dotenv": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-7.0.0.tgz",
@ -7201,6 +7234,21 @@
"node": ">=0.10.0"
}
},
"node_modules/underscore": {
"version": "1.13.6",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.6.tgz",
"integrity": "sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A==",
"dev": true
},
"node_modules/underscore-keypath": {
"version": "0.0.22",
"resolved": "https://registry.npmjs.org/underscore-keypath/-/underscore-keypath-0.0.22.tgz",
"integrity": "sha512-fU7aYj1J2LQd+jqdQ67AlCOZKK3Pl+VErS8fGYcgZG75XB9/bY+RLM+F2xEcKHhHNtLvqqFyXAoZQlLYfec3Xg==",
"dev": true,
"dependencies": {
"underscore": "*"
}
},
"node_modules/update-browserslist-db": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.10.tgz",

View File

@ -1,17 +1,19 @@
{
"private": true,
"scripts": {
"build": "parcel build source/manifest.json --dist-dir distribution --no-cache",
"pre:build": "rm -rf distribution && node pre-build.mjs",
"build": "parcel build source/manifest.json --dist-dir distribution --no-cache --no-source-maps",
"lint": "xo",
"pack:safari": "xcodebuild -project 'safari/GhostText.xcodeproj'",
"prepare:safari": "bash safari/prepare-release.sh",
"start:safari": "open 'safari/build/Release/GhostText.app'",
"test": "xo && npm run build",
"pre:watch": "npm run pre:build",
"watch": "parcel watch source/manifest.json --dist-dir distribution --no-cache --no-hmr"
},
"browserslist": [
"Chrome >= 86",
"Firefox >= 83",
"Chrome >= 100",
"Firefox >= 100",
"Safari >= 14"
],
"xo": {
@ -35,6 +37,7 @@
"devDependencies": {
"@codemirror/view": "^6.9.2",
"@parcel/config-webextension": "^2.8.3",
"dot-json": "^1.2.2",
"parcel": "^2.8.3",
"xo": "^0.53.1"
},
@ -49,9 +52,5 @@
"https://ghosttext.fregante.com/test/"
]
}
},
"@parcel/bundler-default-bug": "https://github.com/parcel-bundler/parcel/issues/8071",
"@parcel/bundler-default": {
"minBundles": 10000000
}
}

29
pre-build.mjs Normal file
View File

@ -0,0 +1,29 @@
// Parcel changes names unless they're in web_accessible_resources
// `npm run build` creates additional files with hashed names
// Xcode can't handle dynamically-created filenames, so we need to keep this list here
import {readdir} from 'node:fs/promises';
import DotJson from 'dot-json';
const list = await readdir('./source', {withFileTypes: true});
const excludes = new Set([
'options.css', // Inlined, but only if excluded
'advanced-editors-messenger.js', // Inlined
'manifest.json', // Not necessary
]);
const resources = [];
for (const item of list) {
if (excludes.has(item.name)) {
continue;
}
if (item.isDirectory()) {
resources.push(item.name + '/*');
} else {
resources.push(item.name);
}
}
const manifest = new DotJson('source/manifest.json');
manifest.set('web_accessible_resources', resources);
manifest.save();

View File

@ -8,9 +8,12 @@ CONFIG_FILE=./safari/LocalOverrides.xcconfig
TAG=$(git describe --tags --abbrev=0)
if [[ $(git describe --tags) != "$TAG" ]]; then
echo Youre ahead of the latest tag. Run:
echo git checkout "$TAG"
exit 1
if [[ -z "$SKIP_TAG_CHECK" ]]; then
echo Youre ahead of the latest tag. Run:
echo git checkout "$TAG"
exit 1
fi
echo Youre ahead of the latest tag. Watch out!
fi
PROJECT_VERSION=$(sed -n 's/^CURRENT_PROJECT_VERSION = \(.*\)/\1/p' < $CONFIG_FILE)
@ -18,8 +21,8 @@ NEXT_PROJECT_VERSION=$((PROJECT_VERSION + 1))
echo "Will bump the project version" "$PROJECT_VERSION"
trash distribution
npm run build
echo "Run \`npm run watch\` in another shell, close it, then press any key."
read -r
npx dot-json distribution/manifest.json version "$TAG"
sed -i '' '/MARKETING_VERSION/d' $CONFIG_FILE

View File

@ -1,5 +1,5 @@
import GThumane from './humane-ghosttext.js';
import unsafeMessenger from './unsafe-messenger.js';
import advancedEditors from './advanced-editors-messenger.js';
import optionsStorage from './options-storage.js';
const knownElements = new Map();
@ -334,7 +334,7 @@ function stopGT() {
function init() {
const script = document.createElement('script');
script.textContent = '(' + unsafeMessenger.toString() + ')()';
script.textContent = '(' + advancedEditors.toString() + ')()';
document.head.append(script);
}

View File

@ -72,7 +72,14 @@
]
},
"web_accessible_resources": [
"background.js",
"ghost-text.css",
"ghost-text.js",
"ghost-text.css"
"humane-ghosttext.css",
"humane-ghosttext.js",
"icons/*",
"options-storage.js",
"options.html",
"options.js"
]
}

View File

@ -1,3 +1,10 @@
/* Keep this here to avoid creating a new bundle that breaks Safari */
@import "npm:webext-base-css";
:root {
max-width: 30em;
}
.field {
display: flex;
align-items: baseline;

View File

@ -1,10 +1,8 @@
<!DOCTYPE html>
<meta charset="UTF-8" />
<title>GhostText options</title>
<style>
@import 'npm:webext-base-css';
@import './options.css';
</style>
<!-- Don't upset Parcel nor Safari -->
<style>@import './options.css';</style>
<form id="options-form">
<p class="field">
<label for="serverPort">
@ -42,7 +40,7 @@
/>
<label for="focusOnDisconnect">
Bring the focus back to the browser when disconnected. <br>
some OS bring the browser to the foreground, others 'flash' the browser icon in the taskbar.
Some operating systems maybe just 'flash' the browser icon in the taskbar instead.
</label>
</p>
</form>