Compare commits

..

1 commit

Author SHA1 Message Date
5b2b29ae4c refactor: replace libWrapper with mixins 2022-04-18 03:09:05 +02:00
30 changed files with 5162 additions and 4170 deletions

View file

@ -19,7 +19,6 @@ module.exports = {
plugins: [], plugins: [],
globals: { globals: {
DefaultTokenConfig: false,
PrototypeTokenDocument: false, PrototypeTokenDocument: false,
}, },
@ -29,7 +28,7 @@ module.exports = {
overrides: [ overrides: [
{ {
files: ['./*.js', './*.cjs', './*.mjs', './tools/**/*'], files: ['./*.js', './tools/**/*'],
env: { env: {
node: true, node: true,
browser: false, browser: false,

161
.gitlab-ci.yml Normal file
View file

@ -0,0 +1,161 @@
# SPDX-FileCopyrightText: 2021 Johannes Loher
# SPDX-FileCopyrightText: 2021 Oliver Rümpelein
#
# SPDX-License-Identifier: MIT
image: node:lts
stages:
- test
- build
- prepare-release
- release
- publish
cache: &global_cache
paths:
- .yarn/cache
lint:
stage: test
before_script:
- yarn install --immutable
script:
- yarn lint
cache:
<<: *global_cache
reuse:
stage: test
image:
name: fsfe/reuse:latest
entrypoint: ['']
script:
- reuse lint
build:
stage: build
before_script:
- yarn install --immutable
- if [[ ! -z ${CI_COMMIT_TAG+x} ]]; then export NODE_ENV=production; fi
script:
- yarn build
- mv dist darkness-dependent-vision
cache:
<<: *global_cache
artifacts:
paths:
- darkness-dependent-vision
expire_in: 1 week
publish-artifacts:
stage: prepare-release
image: alpine:latest
before_script:
- apk update
- apk add zip curl
script: |
zip -r darkness-dependent-vision.zip darkness-dependent-vision/*
curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file darkness-dependent-vision.zip "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/darkness-dependent-vision/$CI_COMMIT_TAG/darkness-dependent-vision.zip"
curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file darkness-dependent-vision/module.json "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/darkness-dependent-vision/$CI_COMMIT_TAG/module.json"
rules:
- if: '$CI_COMMIT_TAG =~ /^[0-9]+\.[0-9]+\.[0-9]+$/'
changelog:
stage: prepare-release
before_script:
- yarn install --immutable
script:
- yarn changelog
cache:
<<: *global_cache
artifacts:
paths:
- CHANGELOG.md
rules:
- if: '$CI_COMMIT_TAG =~ /^[0-9]+\.[0-9]+\.[0-9]+$/'
.release-template: &release-template
stage: release
before_script:
- yarn install --immutable
- apt update
- apt install --yes jq
- REPOSITORY_URL=$(echo "${CI_REPOSITORY_URL}" | sed -e "s|gitlab-ci-token:.*@|${RELEASE_TOKEN}:${RELEASE_TOKEN_SECRET}@|g")
- git remote set-url origin $REPOSITORY_URL
- git config user.name $GITLAB_USER_LOGIN
- git config user.email $GITLAB_USER_EMAIL
- git branch -D ci-processing || true
- git checkout -b ci-processing
cache:
<<: *global_cache
script: |
yarn bump-version --release=${RELEASE_TYPE}
RELEASE_VERSION=$(jq -r '.version' < package.json)
git add package.json module.json
git --no-pager diff
git commit -m "chore(release): ${RELEASE_VERSION}"
git tag -f ${RELEASE_VERSION}
git push origin ci-processing:${CI_BUILD_REF_NAME} -o ci.skip
git push origin ${RELEASE_VERSION}
only:
- master
when: manual
release-patch:
variables:
RELEASE_TYPE: patch
<<: *release-template
release-minor:
variables:
RELEASE_TYPE: minor
<<: *release-template
release-major:
variables:
RELEASE_TYPE: major
<<: *release-template
release:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
script:
- echo 'release job'
rules:
- if: '$CI_COMMIT_TAG =~ /^[0-9]+\.[0-9]+\.[0-9]+$/'
release:
tag_name: $CI_COMMIT_TAG
description: './CHANGELOG.md'
assets:
links:
- name: 'darkness-dependent-vision.zip'
url: '${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/darkness-dependent-vision/$CI_COMMIT_TAG/darkness-dependent-vision.zip'
filepath: /darkness-dependent-vision.zip
link_type: package
- name: 'module.json'
url: '${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/darkness-dependent-vision/$CI_COMMIT_TAG/module.json'
filepath: /module.json
link_type: other
publish-latest-manifest:
stage: publish
image: alpine:latest
before_script:
- apk update
- apk add zip curl
script: |
curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file darkness-dependent-vision/module.json "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/darkness-dependent-vision/latest/module.json"
rules:
- if: '$CI_COMMIT_TAG =~ /^[0-9]+\.[0-9]+\.[0-9]+$/'
publish-to-foundry-admin:
stage: publish
image: johannesloher/foundry-publish
variables:
FVTT_MANIFEST_PATH: darkness-dependent-vision/module.json
FVTT_MANIFEST_URL: ${CI_PROJECT_URL}/-/releases/${CI_COMMIT_TAG}/downloads/module.json
FVTT_DELETE_OBSOLETE_VERSIONS: 'true'
script: foundry-publish
rules:
- if: '$CI_COMMIT_TAG =~ /^[0-9]+\.[0-9]+\.[0-9]+$/'

View file

@ -1,7 +1,7 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: darkness-dependent-vision Upstream-Name: darkness-dependent-vision
Upstream-Contact: Johannes Loher <johannes.loher@fg4f.de> Upstream-Contact: Johannes Loher <johannes.loher@fg4f.de>
Source: https://git2.f3l.de/saluu/darkness-dependent-vision Source: https://git.f3l.de/ghost/darkness-dependent-vision
Files: .yarn/** Files: .yarn/**
Copyright: Copyright (c) 2016-present, Yarn Contributors. All rights reserved. Copyright: Copyright (c) 2016-present, Yarn Contributors. All rights reserved.

View file

@ -1,32 +0,0 @@
# SPDX-FileCopyrightText: 2023 Johannes Loher
#
# SPDX-License-Identifier: MIT
variables:
- &node_image node:lts
when:
- event: push
- event: tag
- event: manual
steps:
install:
image: *node_image
commands:
- yarn install --immutable
lint:
group: test
image: *node_image
commands:
- yarn lint
reuse:
group: test
image: fsfe/reuse:latest
commands:
- reuse lint
build:
group: build
image: *node_image
commands:
- yarn build

View file

@ -1,72 +0,0 @@
# SPDX-FileCopyrightText: 2023 Johannes Loher
#
# SPDX-License-Identifier: MIT
variables:
- &node_image node:lts
when:
event: tag
evaluate: CI_COMMIT_TAG matches "^[0-9]+\\\\.[0-9]+\\\\.[0-9]+$"
depends_on:
- checks
steps:
install:
image: *node_image
commands:
- yarn install --immutable
build:
image: *node_image
environment:
NODE_ENV: production
commands:
- yarn build
package:
group: prepare-release
image: alpine:latest
commands:
- apk update
- apk add zip curl
- mv dist ${CI_REPO_NAME}
- zip -r ${CI_REPO_NAME}.zip ${CI_REPO_NAME}/*
changelog:
group: prepare-release
image: *node_image
commands:
- yarn changelog
release:
image: woodpeckerci/plugin-gitea-release
settings:
base_url: ${CI_FORGE_URL}
title: ${CI_COMMIT_TAG}
note: CHANGELOG.md
files:
- ${CI_REPO_NAME}.zip
- ${CI_REPO_NAME}/module.json
api_key:
from_secret: forge_token
publish-latest-manifest:
group: publish
image: alpine:latest
commands:
- apk update
- apk add curl
- 'curl --header "Authorization: token $${FORGE_TOKEN}" -X "DELETE" "${CI_FORGE_URL}/api/packages/${CI_REPO_OWNER}/generic/${CI_REPO_NAME}/latest/module.json"'
- 'curl --fail --header "Authorization: token $${FORGE_TOKEN}" --upload-file ${CI_REPO_NAME}/module.json "${CI_FORGE_URL}/api/packages/${CI_REPO_OWNER}/generic/${CI_REPO_NAME}/latest/module.json"'
secrets:
- forge_token
publish-to-foundry-admin:
group: publish
image: johannesloher/foundry-publish
environment:
FVTT_DELETE_OBSOLETE_VERSIONS: 'true'
commands:
- export FVTT_MANIFEST_PATH=${CI_REPO_NAME}/module.json
- export FVTT_MANIFEST_URL=${CI_REPO_URL}/releases/download/${CI_COMMIT_TAG}/module.json
- foundry-publish
secrets:
- fvtt_package_id
- fvtt_username
- fvtt_password

View file

@ -1,39 +0,0 @@
# SPDX-FileCopyrightText: 2023 Johannes Loher
#
# SPDX-License-Identifier: MIT
variables:
- &node_image node:lts
when:
event: manual
branch: ${CI_REPO_DEFAULT_BRANCH}
depends_on:
- checks
steps:
install:
image: *node_image
commands:
- yarn install --immutable
release:
image: *node_image
commands:
- apt-get update
- apt-get install --yes jq
- export REPOSITORY_URL=$(echo "${CI_REPO_CLONE_URL}" | sed -e "s|://|://$${FORGE_TOKEN_NAME}:$${FORGE_TOKEN}@|g")
- git remote set-url origin $${REPOSITORY_URL}
- git config user.name woodpecker[bot]
- git config user.email woodpecker[bot]@${CI_SYSTEM_HOST}
- yarn bump-version --release=${RELEASE_TYPE}
- export RELEASE_VERSION=$(jq -r '.version' < package.json)
- git --no-pager diff
- git add package.json module.json
- 'git commit -m "chore(release): $${RELEASE_VERSION}"'
- git tag -f $${RELEASE_VERSION}
- git push origin ${CI_COMMIT_BRANCH}
- git push origin $${RELEASE_VERSION}
secrets:
- forge_token_name
- forge_token

785
.yarn/releases/yarn-3.2.0.cjs vendored Executable file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,13 +1,13 @@
#!/usr/bin/env node #!/usr/bin/env node
const {existsSync} = require(`fs`); const {existsSync} = require(`fs`);
const {createRequire} = require(`module`); const {createRequire, createRequireFromPath} = require(`module`);
const {resolve} = require(`path`); const {resolve} = require(`path`);
const relPnpApiPath = "../../../../.pnp.cjs"; const relPnpApiPath = "../../../../.pnp.cjs";
const absPnpApiPath = resolve(__dirname, relPnpApiPath); const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = createRequire(absPnpApiPath); const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
if (existsSync(absPnpApiPath)) { if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) { if (!process.versions.pnp) {

View file

@ -1,13 +1,13 @@
#!/usr/bin/env node #!/usr/bin/env node
const {existsSync} = require(`fs`); const {existsSync} = require(`fs`);
const {createRequire} = require(`module`); const {createRequire, createRequireFromPath} = require(`module`);
const {resolve} = require(`path`); const {resolve} = require(`path`);
const relPnpApiPath = "../../../../.pnp.cjs"; const relPnpApiPath = "../../../../.pnp.cjs";
const absPnpApiPath = resolve(__dirname, relPnpApiPath); const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = createRequire(absPnpApiPath); const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
if (existsSync(absPnpApiPath)) { if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) { if (!process.versions.pnp) {

View file

@ -1,6 +1,6 @@
{ {
"name": "eslint", "name": "eslint",
"version": "8.25.0-sdk", "version": "8.13.0-sdk",
"main": "./lib/api.js", "main": "./lib/api.js",
"type": "commonjs" "type": "commonjs"
} }

View file

@ -1,13 +1,13 @@
#!/usr/bin/env node #!/usr/bin/env node
const {existsSync} = require(`fs`); const {existsSync} = require(`fs`);
const {createRequire} = require(`module`); const {createRequire, createRequireFromPath} = require(`module`);
const {resolve} = require(`path`); const {resolve} = require(`path`);
const relPnpApiPath = "../../../.pnp.cjs"; const relPnpApiPath = "../../../.pnp.cjs";
const absPnpApiPath = resolve(__dirname, relPnpApiPath); const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = createRequire(absPnpApiPath); const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
if (existsSync(absPnpApiPath)) { if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) { if (!process.versions.pnp) {

View file

@ -1,6 +1,6 @@
{ {
"name": "prettier", "name": "prettier",
"version": "2.7.1-sdk", "version": "2.6.2-sdk",
"main": "./index.js", "main": "./index.js",
"type": "commonjs" "type": "commonjs"
} }

View file

@ -2,4 +2,4 @@ plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs - path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: '@yarnpkg/plugin-interactive-tools' spec: '@yarnpkg/plugin-interactive-tools'
yarnPath: .yarn/releases/yarn-3.8.6.cjs yarnPath: .yarn/releases/yarn-3.2.0.cjs

View file

@ -6,12 +6,6 @@ SPDX-License-Identifier: MIT
# Darkness Dependent Vision # Darkness Dependent Vision
[![status-badge](https://ci.f3l.de/api/badges/1/status.svg)](https://ci.f3l.de/repos/1)
[![REUSE status](https://api.reuse.software/badge/git2.f3l.de/saluu/darkness-dependent-vision)](https://api.reuse.software/info/git2.f3l.de/saluu/darkness-dependent-vision)
[![Forge installs](https://img.shields.io/badge/dynamic/json?label=Forge%20Installs&query=package.installs&suffix=%25&url=https%3A%2F%2Fforge-vtt.com%2Fapi%2Fbazaar%2Fpackage%2Fdarkness-dependent-vision&colorB=4aa94a)](https://forge-vtt.com/bazaar#package=darkness-dependent-vision)
[![Supported foundry versions](https://img.shields.io/endpoint?url=https://foundryshields.com/version?url=https%3A%2F%2Fgit2.f3l.de%2Fapi%2Fpackages%2Fsaluu%2Fgeneric%2Fdarkness-dependent-vision%2Flatest%2Fmodule.json)](https://git2.f3l.de/saluu/darkness-dependent-vision)
[![Ko-fi](https://img.shields.io/badge/Ko--fi-ghostfvtt-00B9FE?logo=kofi)](https://ko-fi.com/ghostfvtt)
A module for [Foundry Virtual Tabletop] that provides functionality to make the A module for [Foundry Virtual Tabletop] that provides functionality to make the
dim and bright vision of tokens depend on the scene's darkness level. dim and bright vision of tokens depend on the scene's darkness level.
@ -21,14 +15,7 @@ To install and use the Darkness Dependent Vision module for Foundry Virtual
Tabletop, simply paste the following URL into the **Install Module** dialog on Tabletop, simply paste the following URL into the **Install Module** dialog on
the Setup menu of the application. the Setup menu of the application.
https://git2.f3l.de/api/packages/saluu/generic/darkness-dependent-vision/latest/module.json https://git.f3l.de/ghost/darkness-dependent-vision/-/raw/latest/src/module.json?inline=false
### libWrapper
This module uses the [libWrapper] library for wrapping core methods. It is only
a soft dependency (a shim is provided) but it is highly recommended to install
libWrapper as a module for the best experience and compatibility with other
modules.
## Usage ## Usage
@ -122,7 +109,6 @@ specified either inside the source file or by an accompanying `.license` file,
but for some files, the licenses are specified in [.reuse/dep5]. but for some files, the licenses are specified in [.reuse/dep5].
[Foundry Virtual Tabletop]: http://foundryvtt.com [Foundry Virtual Tabletop]: http://foundryvtt.com
[libWrapper]: https://github.com/ruipin/fvtt-lib-wrapper
[LIMITED LICENSE AGREEMENT FOR MODULE DEVELOPMENT]: https://foundryvtt.com/article/license/ [LIMITED LICENSE AGREEMENT FOR MODULE DEVELOPMENT]: https://foundryvtt.com/article/license/
[REUSE]: https://reuse.software/ [REUSE]: https://reuse.software/
[.reuse/dep5]: .reuse/dep5 [.reuse/dep5]: .reuse/dep5

View file

@ -1,9 +1,8 @@
{ {
"name": "darkness-dependent-vision", "name": "darkness-dependent-vision",
"id": "darkness-dependent-vision",
"title": "Darkness Dependent Vision", "title": "Darkness Dependent Vision",
"description": "A module for Foundry Virtual Tabletop that provides functionality to make the dim and bright vision of tokens depend on the scene's darkness level.", "description": "A module for Foundry Virtual Tabletop that provides functionality to make the dim and bright vision of tokens depend on the scene's darkness level.",
"version": "0.3.13", "version": "0.3.6",
"author": "Johannes Loher", "author": "Johannes Loher",
"authors": [ "authors": [
{ {
@ -13,11 +12,6 @@
], ],
"minimumCoreVersion": "9.236", "minimumCoreVersion": "9.236",
"compatibleCoreVersion": "9", "compatibleCoreVersion": "9",
"compatibility": {
"minimum": "9.236",
"verified": "9",
"maximum": "9"
},
"esmodules": ["darkness-dependent-vision.js"], "esmodules": ["darkness-dependent-vision.js"],
"languages": [ "languages": [
{ {
@ -31,11 +25,11 @@
"path": "lang/en.json" "path": "lang/en.json"
} }
], ],
"url": "https://git2.f3l.de/saluu/darkness-dependent-vision", "url": "https://git.f3l.de/ghost/darkness-dependent-vision",
"manifest": "https://git2.f3l.de/api/packages/saluu/generic/darkness-dependent-vision/latest/module.json", "manifest": "https://git.f3l.de/api/v4/projects/ghost%2Fdarkness-dependent-vision/packages/generic/darkness-dependent-vision/latest/module.json",
"download": "https://git2.f3l.de/saluu/darkness-dependent-vision/releases/download/0.3.13/darkness-dependent-vision.zip", "download": "https://git.f3l.de/ghost/darkness-dependent-vision/-/releases/0.3.6/downloads/darkness-dependent-vision.zip",
"bugs": "https://git2.f3l.de/saluu/darkness-dependent-vision/issues", "bugs": "https://git.f3l.de/ghost/darkness-dependent-vision/-/issues",
"changelog": "https://git2.f3l.de/saluu/darkness-dependent-vision/releases/tag/0.3.13", "changelog": "https://git.f3l.de/ghost/darkness-dependent-vision/-/releases/0.3.6",
"readme": "https://git2.f3l.de/saluu/darkness-dependent-vision/raw/tag/0.3.13/README.md", "readme": "https://git.f3l.de/ghost/darkness-dependent-vision/-/raw/0.3.6/README.md",
"license": "https://git2.f3l.de/saluu/darkness-dependent-vision/raw/tag/0.3.13/LICENSE.md" "license": "https://git.f3l.de/ghost/darkness-dependent-vision/-/raw/0.3.6/LICENSE.md"
} }

View file

@ -1,16 +1,16 @@
{ {
"private": true, "private": true,
"name": "darkness-dependent-vision", "name": "darkness-dependent-vision",
"version": "0.3.13", "version": "0.3.6",
"description": "A module for Foundry Virtual Tabletop that provides functionality to make the dim and bright vision of tokens depend on the scene's darkness level.", "description": "A module for Foundry Virtual Tabletop that provides functionality to make the dim and bright vision of tokens depend on the scene's darkness level.",
"license": "https://git2.f3l.de/saluu/darkness-dependent-vision/src/branch/master/LICENSE.md", "license": "https://git.f3l.de/ghost/darkness-dependent-vision#licensing",
"homepage": "https://git2.f3l.de/saluu/darkness-dependent-vision", "homepage": "https://git.f3l.de/ghost/darkness-dependent-vision",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://git2.f3l.de/saluu/darkness-dependent-vision" "url": "https://git.f3l.de/ghost/darkness-dependent-vision"
}, },
"bugs": { "bugs": {
"url": "https://git2.f3l.de/saluu/darkness-dependent-vision/issues" "url": "https://git.f3l.de/ghost/darkness-dependent-vision/-/issues"
}, },
"contributors": [ "contributors": [
{ {
@ -18,7 +18,6 @@
"email": "johannes.loher@fg4f.de" "email": "johannes.loher@fg4f.de"
} }
], ],
"type": "module",
"scripts": { "scripts": {
"build": "run-s clean:files build:files", "build": "run-s clean:files build:files",
"build:files": "rollup -c", "build:files": "rollup -c",
@ -36,30 +35,30 @@
"changelog": "conventional-changelog -p conventionalcommits -o CHANGELOG.md -r 2" "changelog": "conventional-changelog -p conventionalcommits -o CHANGELOG.md -r 2"
}, },
"devDependencies": { "devDependencies": {
"@commitlint/cli": "19.5.0", "@commitlint/cli": "16.2.3",
"@commitlint/config-conventional": "19.5.0", "@commitlint/config-conventional": "16.2.1",
"@guanghechen/rollup-plugin-copy": "6.0.2", "@guanghechen/rollup-plugin-copy": "1.9.3",
"@typhonjs-fvtt/eslint-config-foundry.js": "0.8.0", "@typhonjs-fvtt/eslint-config-foundry.js": "0.8.0",
"conventional-changelog-cli": "5.0.0", "conventional-changelog-cli": "2.2.2",
"conventional-changelog-conventionalcommits": "8.0.0", "conventional-changelog-conventionalcommits": "4.6.3",
"eslint": "8.57.1", "eslint": "8.13.0",
"eslint-config-prettier": "9.1.0", "eslint-config-prettier": "8.5.0",
"eslint-plugin-prettier": "4.2.1", "eslint-plugin-prettier": "4.0.0",
"fs-extra": "11.2.0", "fs-extra": "10.1.0",
"gulp": "5.0.0", "gulp": "4.0.2",
"husky": "9.1.6", "husky": "7.0.4",
"lint-staged": "15.2.10", "lint-staged": "12.3.8",
"npm-run-all": "4.1.5", "npm-run-all": "4.1.5",
"prettier": "2.8.8", "prettier": "2.6.2",
"rimraf": "6.0.1", "rimraf": "3.0.2",
"rollup": "4.24.0", "rollup": "2.70.2",
"rollup-plugin-terser": "7.0.2", "rollup-plugin-terser": "7.0.2",
"semver": "7.6.3", "semver": "7.3.7",
"yargs": "17.7.2" "yargs": "17.4.1"
}, },
"lint-staged": { "lint-staged": {
"*.(js|mjs|cjs)": "eslint --fix", "*.(js|mjs|cjs)": "eslint --fix",
"*.(json|css|yml)": "prettier --write" "*.(json|css|yml)": "prettier --write"
}, },
"packageManager": "yarn@3.8.6" "packageManager": "yarn@3.2.0"
} }

View file

@ -1,7 +1,4 @@
{ {
"$schema": "https://docs.renovatebot.com/renovate-schema.json", "$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:base", ":automergeAll", ":automergeBranch", ":prHourlyLimitNone", ":prConcurrentLimitNone"], "extends": ["config:base", ":automergeAll", ":automergeBranch", ":prHourlyLimitNone", ":prConcurrentLimitNone"]
"lockFileMaintenance": {
"enabled": true
}
} }

View file

@ -2,7 +2,7 @@
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
import { copy } from '@guanghechen/rollup-plugin-copy'; import copy from '@guanghechen/rollup-plugin-copy';
import { terser } from 'rollup-plugin-terser'; import { terser } from 'rollup-plugin-terser';
import { distDirectory, name, sourceDirectory } from './tools/const.mjs'; import { distDirectory, name, sourceDirectory } from './tools/const.mjs';

View file

@ -52,10 +52,6 @@ export class DarknessDependentVisionConfig extends FormApplication {
return `${name}: ${game.i18n.localize('DarknessDependentVision.Title')}`; return `${name}: ${game.i18n.localize('DarknessDependentVision.Title')}`;
} }
get isDefault() {
return this.options.tokenConfig instanceof DefaultTokenConfig;
}
async getData() { async getData() {
const data = this.isPrototype ? this.actor.data.token : this.token.data; const data = this.isPrototype ? this.actor.data.token : this.token.data;
return { return {
@ -73,23 +69,9 @@ export class DarknessDependentVisionConfig extends FormApplication {
} }
async _updateObject(event, formData) { async _updateObject(event, formData) {
// Configure the Default Token Configuration
if (this.isDefault) {
const current = game.settings.get('core', DefaultTokenConfig.SETTING);
const update = foundry.utils.mergeObject(current, formData, { inplace: false });
const result = await game.settings.set('core', DefaultTokenConfig.SETTING, update);
const tokenConfig = this.options.tokenConfig;
tokenConfig.data = new foundry.data.TokenData(result);
tokenConfig.object = new TokenDocument(tokenConfig.data, { actor: null });
tokenConfig.token = tokenConfig.object;
tokenConfig.render();
return result;
}
// Configure the Prototype Token data of an Actor // Configure the Prototype Token data of an Actor
if (this.isPrototype) return this.actor.update({ token: formData }); if (this.isPrototype) return this.actor.update({ token: formData });
// Update an embedded Token document // Update an embedded Token document
return this.token.update(formData); else return this.token.update(formData);
} }
} }

View file

@ -22,7 +22,7 @@ function onGetTokenConfigHeaderButtons(tokenConfig, buttons) {
class: 'configure-darkness-dependent-vision', class: 'configure-darkness-dependent-vision',
icon: 'fas fa-eye', icon: 'fas fa-eye',
onclick: async () => { onclick: async () => {
return new DarknessDependentVisionConfig(tokenConfig.object, { tokenConfig }).render(true); return new DarknessDependentVisionConfig(tokenConfig.object).render(true);
}, },
}); });
} }

View file

@ -5,9 +5,8 @@
import { packageName } from '../config'; import { packageName } from '../config';
import registerHandlebarsPartials from '../handlebars-partials'; import registerHandlebarsPartials from '../handlebars-partials';
import logger from '../logger'; import logger from '../logger';
import { registerMixins } from '../mixins/index.js';
import registerSettings from '../setiings'; import registerSettings from '../setiings';
import { libWrapper } from '../shims/libWrapperShim';
import { getBrightRadius, getDimRadius, updateVisionSource } from '../wrappers/token';
export default function registerForInitHook() { export default function registerForInitHook() {
Hooks.on('init', onInit); Hooks.on('init', onInit);
@ -16,27 +15,7 @@ export default function registerForInitHook() {
async function onInit() { async function onInit() {
logger.info(`Initializing ${packageName}`); logger.info(`Initializing ${packageName}`);
const dimRadiusTarget = 'Token.prototype.dimRadius'; registerMixins();
try {
libWrapper.register(packageName, dimRadiusTarget, getDimRadius, 'OVERRIDE');
} catch (e) {
logger.warn(`Failed to override ${dimRadiusTarget}, some things might not work correctly:`, e);
}
const brightRadiusTarget = 'Token.prototype.brightRadius';
try {
libWrapper.register(packageName, brightRadiusTarget, getBrightRadius, 'OVERRIDE');
} catch (e) {
logger.warn(`Failed to override ${brightRadiusTarget}, some things might not work correctly:`, e);
}
const updateVisionSourceTarget = 'Token.prototype.updateVisionSource';
try {
libWrapper.register(packageName, updateVisionSourceTarget, updateVisionSource, 'OVERRIDE');
} catch (e) {
logger.warn(`Failed to override ${updateVisionSourceTarget}, some things might not work correctly:`, e);
}
registerSettings(); registerSettings();
await registerHandlebarsPartials(); await registerHandlebarsPartials();
} }

5
src/mixins/index.js Normal file
View file

@ -0,0 +1,5 @@
import { registerTokenMixin } from './token';
export function registerMixins() {
registerTokenMixin();
}

124
src/mixins/token.js Normal file
View file

@ -0,0 +1,124 @@
// SPDX-FileCopyrightText: 2021 Johannes Loher
//
// SPDX-License-Identifier: MIT
import { packageName } from '../config';
export function registerTokenMixin() {
CONFIG.Token.objectClass = TokenMixin(CONFIG.Token.objectClass);
}
function TokenMixin(BaseToken) {
return class extends BaseToken {
/**
* Translate the token's sight distance in units into a radius in pixels.
* @return {number} The sight radius in pixels
* @override
*/
get dimRadius() {
const dimSight = this._dimVision;
let r = Math.abs(this.data.dimLight) > Math.abs(dimSight) ? this.data.dimLight : dimSight;
return this.getLightRadius(r);
}
/**
* Does this {@link Token} have dim vision, considering the darkness level of
* its containing {@link Scene}?
* @private
*/
get _hasDimVision() {
const dimVisionDarknessMin = this.document.getFlag(packageName, 'dimVisionDarknessMin') ?? 0;
const dimVisionDarknessMax = this.document.getFlag(packageName, 'dimVisionDarknessMax') ?? 1;
const darkness = this.document.parent.data.darkness;
return dimVisionDarknessMin <= darkness && darkness <= dimVisionDarknessMax;
}
/**
* Get this {@link Token}'s dim vision distance of in grid units, considering
* the darkness level of its containing {@link Scene}.
*
* @returns {number} The the number of grid units that this {@link Token} has
* dim vision
* @private
*/
get _dimVision() {
return this._hasDimVision ? this.data.dimSight : 0;
}
/**
* Translate the token's bright light distance in units into a radius in pixels.
* @return {number} The bright radius in pixels
* @override
*/
get brightRadius() {
const brightSight = this._brightVision;
let r = Math.abs(this.data.brightLight) > Math.abs(brightSight) ? this.data.brightLight : brightSight;
return this.getLightRadius(r);
}
/**
* Does this {@link Token} have bright vision, considering the darkness level of
* its containing {@link Scene}?
* @override
*/
get _hasBrightVision() {
const brightVisionDarknessMin = this.document.getFlag(packageName, 'brightVisionDarknessMin') ?? 0;
const brightVisionDarknessMax = this.document.getFlag(packageName, 'brightVisionDarknessMax') ?? 1;
const darkness = this.document.parent.data.darkness;
return brightVisionDarknessMin <= darkness && darkness <= brightVisionDarknessMax;
}
/**
* Get this {@link Token}'s bright vision distance in grid units, considering
* the darkness level of its containing {@link Scene}.
*
* @returns {number} The the number of grid units that this {@link Token} has
* bright vision
* @private
*/
get _brightVision() {
return this._hasBrightVision ? this.data.brightSight : 0;
}
/**
* Update an Token vision source associated for this token.
* @param {boolean} [defer] Defer refreshing the LightingLayer to manually call that refresh later.
* @param {boolean} [deleted] Indicate that this vision source has been deleted.
* @param {boolean} [skipUpdateFog] Never update the Fog exploration progress for this update.
* @override
*/
updateVisionSource({ defer = false, deleted = false, skipUpdateFog = false } = {}) {
// Prepare data
const origin = this.getSightOrigin();
const sourceId = this.sourceId;
const d = canvas.dimensions;
const isVisionSource = this._isVisionSource();
// Initialize vision source
if (isVisionSource && !deleted) {
const dimSight = this._dimVision;
const brightSight = this._brightVision;
let dim = Math.min(this.getLightRadius(dimSight), d.maxR);
const bright = Math.min(this.getLightRadius(brightSight), d.maxR);
this.vision.initialize({
x: origin.x,
y: origin.y,
dim: dim,
bright: bright,
angle: this.data.sightAngle,
rotation: this.data.rotation,
});
canvas.sight.sources.set(sourceId, this.vision);
}
// Remove vision source
else canvas.sight.sources.delete(sourceId);
// Schedule a perception update
if (!defer && (isVisionSource || deleted))
canvas.perception.schedule({
sight: { refresh: true, skipUpdateFog },
});
}
};
}

View file

@ -1,156 +0,0 @@
// SPDX-License-Identifier: MIT
// Copyright © 2021 fvtt-lib-wrapper Rui Pinheiro
'use strict';
// A shim for the libWrapper library
export let libWrapper = undefined;
export const VERSIONS = [1, 12, 1];
export const TGT_SPLIT_RE = new RegExp('([^.[]+|\\[(\'([^\'\\\\]|\\\\.)+?\'|"([^"\\\\]|\\\\.)+?")\\])', 'g');
export const TGT_CLEANUP_RE = new RegExp('(^\\[\'|\'\\]$|^\\["|"\\]$)', 'g');
// Main shim code
Hooks.once('init', () => {
// Check if the real module is already loaded - if so, use it
if (globalThis.libWrapper && !(globalThis.libWrapper.is_fallback ?? true)) {
libWrapper = globalThis.libWrapper;
return;
}
// Fallback implementation
libWrapper = class {
static get is_fallback() {
return true;
}
static get WRAPPER() {
return 'WRAPPER';
}
static get MIXED() {
return 'MIXED';
}
static get OVERRIDE() {
return 'OVERRIDE';
}
static register(package_id, target, fn, type = 'MIXED', { chain = undefined, bind = [] } = {}) {
const is_setter = target.endsWith('#set');
target = !is_setter ? target : target.slice(0, -4);
const split = target.match(TGT_SPLIT_RE).map((x) => x.replace(/\\(.)/g, '$1').replace(TGT_CLEANUP_RE, ''));
const root_nm = split.splice(0, 1)[0];
let obj, fn_name;
if (split.length == 0) {
obj = globalThis;
fn_name = root_nm;
} else {
const _eval = eval;
fn_name = split.pop();
obj = split.reduce((x, y) => x[y], globalThis[root_nm] ?? _eval(root_nm));
}
let iObj = obj;
let descriptor = null;
while (iObj) {
descriptor = Object.getOwnPropertyDescriptor(iObj, fn_name);
if (descriptor) break;
iObj = Object.getPrototypeOf(iObj);
}
if (!descriptor || descriptor?.configurable === false)
throw new Error(
`libWrapper Shim: '${target}' does not exist, could not be found, or has a non-configurable descriptor.`,
);
let original = null;
const wrapper =
chain ?? (type.toUpperCase?.() != 'OVERRIDE' && type != 3)
? function (...args) {
return fn.call(this, original.bind(this), ...bind, ...args);
}
: function (...args) {
return fn.call(this, ...bind, ...args);
};
if (!is_setter) {
if (descriptor.value) {
original = descriptor.value;
descriptor.value = wrapper;
} else {
original = descriptor.get;
descriptor.get = wrapper;
}
} else {
if (!descriptor.set) throw new Error(`libWrapper Shim: '${target}' does not have a setter`);
original = descriptor.set;
descriptor.set = wrapper;
}
descriptor.configurable = true;
Object.defineProperty(obj, fn_name, descriptor);
}
};
//************** USER CUSTOMIZABLE:
// Set up the ready hook that shows the "libWrapper not installed" warning dialog. Remove if undesired.
{
//************** USER CUSTOMIZABLE:
// Package ID & Package Title - by default attempts to auto-detect, but you might want to hardcode your package ID and title here to avoid potential auto-detect issues
const [PACKAGE_ID, PACKAGE_TITLE] = (() => {
const match = (import.meta?.url ?? Error().stack)?.match(/\/(worlds|systems|modules)\/(.+)(?=\/)/i);
if (match?.length !== 3) return [null, null];
const dirs = match[2].split('/');
if (match[1] === 'worlds')
return dirs.find((n) => n && game.world.id === n) ? [game.world.id, game.world.title] : [null, null];
if (match[1] === 'systems')
return dirs.find((n) => n && game.system.id === n) ? [game.system.id, game.system.data.title] : [null, null];
const id = dirs.find((n) => n && game.modules.has(n));
return [id, game.modules.get(id)?.data?.title];
})();
if (!PACKAGE_ID || !PACKAGE_TITLE) {
console.error(
'libWrapper Shim: Could not auto-detect package ID and/or title. The libWrapper fallback warning dialog will be disabled.',
);
return;
}
Hooks.once('ready', () => {
//************** USER CUSTOMIZABLE:
// Title and message for the dialog shown when the real libWrapper is not installed.
const FALLBACK_MESSAGE_TITLE = PACKAGE_TITLE;
const FALLBACK_MESSAGE = `
<p><b>'${PACKAGE_TITLE}' depends on the 'libWrapper' module, which is not present.</b></p>
<p>A fallback implementation will be used, which increases the chance of compatibility issues with other modules.</p>
<small><p>'libWrapper' is a library which provides package developers with a simple way to modify core Foundry VTT code, while reducing the likelihood of conflict with other packages.</p>
<p>You can install it from the "Add-on Modules" tab in the <a href="javascript:game.shutDown()">Foundry VTT Setup</a>, from the <a href="https://foundryvtt.com/packages/lib-wrapper">Foundry VTT package repository</a>, or from <a href="https://github.com/ruipin/fvtt-lib-wrapper/">libWrapper's Github page</a>.</p></small>
`;
// Settings key used for the "Don't remind me again" setting
const DONT_REMIND_AGAIN_KEY = 'libwrapper-dont-remind-again';
// Dialog code
console.warn(`${PACKAGE_TITLE}: libWrapper not present, using fallback implementation.`);
game.settings.register(PACKAGE_ID, DONT_REMIND_AGAIN_KEY, {
name: '',
default: false,
type: Boolean,
scope: 'world',
config: false,
});
if (game.user.isGM && !game.settings.get(PACKAGE_ID, DONT_REMIND_AGAIN_KEY)) {
new Dialog({
title: FALLBACK_MESSAGE_TITLE,
content: FALLBACK_MESSAGE,
buttons: {
ok: { icon: '<i class="fas fa-check"></i>', label: 'Understood' },
dont_remind: {
icon: '<i class="fas fa-times"></i>',
label: "Don't remind me again",
callback: () => game.settings.set(PACKAGE_ID, DONT_REMIND_AGAIN_KEY, true),
},
},
}).render(true);
}
});
}
});

View file

@ -1,109 +0,0 @@
// SPDX-FileCopyrightText: 2021 Johannes Loher
//
// SPDX-License-Identifier: MIT
import { packageName } from '../config';
/**
* Translate the token's sight distance in units into a radius in pixels.
* @return {number} The sight radius in pixels
*/
export function getDimRadius() {
const dimSight = getDimVision.call(this);
let r = Math.abs(this.data.dimLight) > Math.abs(dimSight) ? this.data.dimLight : dimSight;
return this.getLightRadius(r);
}
/**
* Translate the token's bright light distance in units into a radius in pixels.
* @return {number} The bright radius in pixels
*/
export function getBrightRadius() {
const brightSight = getBrightVision.call(this);
let r = Math.abs(this.data.brightLight) > Math.abs(brightSight) ? this.data.brightLight : brightSight;
return this.getLightRadius(r);
}
/**
* Update an Token vision source associated for this token.
* @param {boolean} [defer] Defer refreshing the LightingLayer to manually call that refresh later.
* @param {boolean} [deleted] Indicate that this vision source has been deleted.
* @param {boolean} [skipUpdateFog] Never update the Fog exploration progress for this update.
*/
export function updateVisionSource({ defer = false, deleted = false, skipUpdateFog = false } = {}) {
// Prepare data
const origin = this.getSightOrigin();
const sourceId = this.sourceId;
const d = canvas.dimensions;
const isVisionSource = this._isVisionSource();
// Initialize vision source
if (isVisionSource && !deleted) {
const dimSight = getDimVision.call(this);
const brightSight = getBrightVision.call(this);
let dim = Math.min(this.getLightRadius(dimSight), d.maxR);
const bright = Math.min(this.getLightRadius(brightSight), d.maxR);
this.vision.initialize({
x: origin.x,
y: origin.y,
dim: dim,
bright: bright,
angle: this.data.sightAngle,
rotation: this.data.rotation,
});
canvas.sight.sources.set(sourceId, this.vision);
}
// Remove vision source
else canvas.sight.sources.delete(sourceId);
// Schedule a perception update
if (!defer && (isVisionSource || deleted))
canvas.perception.schedule({
sight: { refresh: true, skipUpdateFog },
});
}
/**
* Does this {@link Token} have dim vision, considering the darkness level of
* its containing {@link Scene}?
*/
function hasDimVision() {
const dimVisionDarknessMin = this.document.getFlag(packageName, 'dimVisionDarknessMin') ?? 0;
const dimVisionDarknessMax = this.document.getFlag(packageName, 'dimVisionDarknessMax') ?? 1;
const darkness = this.document.parent.data.darkness;
return dimVisionDarknessMin <= darkness && darkness <= dimVisionDarknessMax;
}
/**
* Does this {@link Token} have bright vision, considering the darkness level of
* its containing {@link Scene}?
*/
function hasBrightVision() {
const brightVisionDarknessMin = this.document.getFlag(packageName, 'brightVisionDarknessMin') ?? 0;
const brightVisionDarknessMax = this.document.getFlag(packageName, 'brightVisionDarknessMax') ?? 1;
const darkness = this.document.parent.data.darkness;
return brightVisionDarknessMin <= darkness && darkness <= brightVisionDarknessMax;
}
/**
* Get this {@link Token}'s dim vision distance of in grid units, considering
* the darkness level of its containing {@link Scene}.
*
* @returns {number} The the number of grid units that this {@link Token} has
* dim vision
*/
function getDimVision() {
return hasDimVision.call(this) ? this.data.dimSight : 0;
}
/**
* Get this {@link Token}'s bright vision distance in grid units, considering
* the darkness level of its containing {@link Scene}.
*
* @returns {number} The the number of grid units that this {@link Token} has
* bright vision
*/
function getBrightVision() {
return hasBrightVision.call(this) ? this.data.brightSight : 0;
}

View file

@ -7,20 +7,16 @@ import semver from 'semver';
import yargs from 'yargs'; import yargs from 'yargs';
import { hideBin } from 'yargs/helpers'; import { hideBin } from 'yargs/helpers';
const packageType = 'module'; const repository = 'ghost/darkness-dependent-vision';
const repositoryOwner = process.env.CI_REPO_OWNER; const gitlabURL = 'https://git.f3l.de';
const repositoryName = process.env.CI_REPO_NAME;
const repositoryURL = process.env.CI_REPO_LINK;
const forgeURL = process.env.CI_FORGE_URL;
const manifestURL = `${forgeURL}/api/packages/${repositoryOwner}/generic/${repositoryName}/latest/${packageType}.json`; const getLicenseURL = (version) => `${gitlabURL}/${repository}/-/raw/${version}/LICENSE.md`;
const getDownloadURL = (version) => `${repositoryURL}/releases/download/${version}/${repositoryName}.zip`; const getReadmeURL = (version) => `${gitlabURL}/${repository}/-/raw/${version}/README.md`;
const bugsURL = `${repositoryURL}/issues`; const getChangelogURL = (version) => `${gitlabURL}/${repository}/-/releases/${version}`;
const getChangelogURL = (version) => `${repositoryURL}/releases/tag/${version}`; const getDownloadURL = (version) =>
const getReadmeURL = (version) => `${repositoryURL}/raw/tag/${version}/README.md`; `${gitlabURL}/${repository}/-/releases/${version}/downloads/darkness-dependent-vision.zip`;
const getLicenseURL = (version) => `${repositoryURL}/raw/tag/${version}/LICENSE.md`;
const manifestPath = `${packageType}.json`; const manifestPath = 'module.json';
/** /**
* Get the contents of the manifest file as object. * Get the contents of the manifest file as object.
@ -71,16 +67,13 @@ function bumpVersion(release) {
console.log(`Bumping version number to '${targetVersion}'`); console.log(`Bumping version number to '${targetVersion}'`);
packageJson.version = targetVersion; packageJson.version = targetVersion;
fs.writeJSONSync('package.json', packageJson, { spaces: 2 }); fs.writeJSONSync('package.json', packageJson, { spaces: 4 });
manifest.version = targetVersion;
manifest.url = repositoryURL;
manifest.manifest = manifestURL;
manifest.download = getDownloadURL(targetVersion);
manifest.bugs = bugsURL;
manifest.changelog = getChangelogURL(targetVersion);
manifest.readme = getReadmeURL(targetVersion);
manifest.license = getLicenseURL(targetVersion); manifest.license = getLicenseURL(targetVersion);
fs.writeJSONSync(manifestPath, manifest, { spaces: 2 }); manifest.readme = getReadmeURL(targetVersion);
manifest.changelog = getChangelogURL(targetVersion);
manifest.version = targetVersion;
manifest.download = getDownloadURL(targetVersion);
fs.writeJSONSync(manifestPath, manifest, { spaces: 4 });
} }
const argv = yargs(hideBin(process.argv)).usage('Usage: $0').option('release', { const argv = yargs(hideBin(process.argv)).usage('Usage: $0').option('release', {

6777
yarn.lock

File diff suppressed because it is too large Load diff