Compare commits

..

No commits in common. "master" and "0.3.3" have entirely different histories.

26 changed files with 4979 additions and 3967 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,

160
.gitlab-ci.yml Normal file
View file

@ -0,0 +1,160 @@
# 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
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

768
.yarn/releases/yarn-3.1.1.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.js";
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,20 +1,20 @@
#!/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.js";
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) {
// Setup the environment to be able to require eslint // Setup the environment to be able to require eslint/lib/api.js
require(absPnpApiPath).setup(); require(absPnpApiPath).setup();
} }
} }
// Defer to the real eslint your application uses // Defer to the real eslint/lib/api.js your application uses
module.exports = absRequire(`eslint`); module.exports = absRequire(`eslint/lib/api.js`);

View file

@ -1,6 +1,6 @@
{ {
"name": "eslint", "name": "eslint",
"version": "8.25.0-sdk", "version": "8.1.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.js";
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.4.1-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.1.1.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,7 +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 ### libWrapper

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.3",
"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.3/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.3",
"readme": "https://git2.f3l.de/saluu/darkness-dependent-vision/raw/tag/0.3.13/README.md", "readme": "./README.md",
"license": "https://git2.f3l.de/saluu/darkness-dependent-vision/raw/tag/0.3.13/LICENSE.md" "license": "./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.3",
"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.1.0",
"@commitlint/config-conventional": "19.5.0", "@commitlint/config-conventional": "16.0.0",
"@guanghechen/rollup-plugin-copy": "6.0.2", "@guanghechen/rollup-plugin-copy": "1.8.6",
"@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.8.0",
"eslint-config-prettier": "9.1.0", "eslint-config-prettier": "8.3.0",
"eslint-plugin-prettier": "4.2.1", "eslint-plugin-prettier": "4.0.0",
"fs-extra": "11.2.0", "fs-extra": "10.0.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.2",
"npm-run-all": "4.1.5", "npm-run-all": "4.1.5",
"prettier": "2.8.8", "prettier": "2.5.1",
"rimraf": "6.0.1", "rimraf": "3.0.2",
"rollup": "4.24.0", "rollup": "2.66.1",
"rollup-plugin-terser": "7.0.2", "rollup-plugin-terser": "7.0.2",
"semver": "7.6.3", "semver": "7.3.5",
"yargs": "17.7.2" "yargs": "17.3.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.1.1"
} }

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

@ -1,16 +1,11 @@
// SPDX-License-Identifier: MIT
// Copyright © 2021 fvtt-lib-wrapper Rui Pinheiro // Copyright © 2021 fvtt-lib-wrapper Rui Pinheiro
// 2021 Johannes Loher
'use strict'; //
// SPDX-License-Identifier: MIT
// A shim for the libWrapper library // A shim for the libWrapper library
export let libWrapper = undefined; 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', () => { Hooks.once('init', () => {
// Check if the real module is already loaded - if so, use it // Check if the real module is already loaded - if so, use it
if (globalThis.libWrapper && !(globalThis.libWrapper.is_fallback ?? true)) { if (globalThis.libWrapper && !(globalThis.libWrapper.is_fallback ?? true)) {
@ -24,31 +19,14 @@ Hooks.once('init', () => {
return true; return true;
} }
static get WRAPPER() { static register(package_id, target, fn, type = 'MIXED', { chain = undefined } = {}) {
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'); const is_setter = target.endsWith('#set');
target = !is_setter ? target : target.slice(0, -4); 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 split = target.split('.');
const fn_name = split.pop();
const root_nm = split.splice(0, 1)[0]; const root_nm = split.splice(0, 1)[0];
const _eval = eval; // The browser doesn't expose all global variables (e.g. 'Game') inside globalThis, but it does to an eval. We copy it to a variable to have it run in global scope.
let obj, fn_name; const obj = split.reduce((x, y) => x[y], globalThis[root_nm] ?? _eval(root_nm));
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 iObj = obj;
let descriptor = null; let descriptor = null;
@ -58,19 +36,18 @@ Hooks.once('init', () => {
iObj = Object.getPrototypeOf(iObj); iObj = Object.getPrototypeOf(iObj);
} }
if (!descriptor || descriptor?.configurable === false) if (!descriptor || descriptor?.configurable === false)
throw new Error( throw `libWrapper Shim: '${target}' does not exist, could not be found, or has a non-configurable descriptor.`;
`libWrapper Shim: '${target}' does not exist, could not be found, or has a non-configurable descriptor.`,
);
let original = null; let original = null;
const wrapper = const wrapper =
chain ?? (type.toUpperCase?.() != 'OVERRIDE' && type != 3) chain ?? type != 'OVERRIDE'
? function (...args) { ? function () {
return fn.call(this, original.bind(this), ...bind, ...args); return fn.call(this, original.bind(this), ...arguments);
} }
: function (...args) { : function () {
return fn.call(this, ...bind, ...args); return fn.apply(this, arguments);
}; };
if (!is_setter) { if (!is_setter) {
if (descriptor.value) { if (descriptor.value) {
original = descriptor.value; original = descriptor.value;
@ -80,7 +57,7 @@ Hooks.once('init', () => {
descriptor.get = wrapper; descriptor.get = wrapper;
} }
} else { } else {
if (!descriptor.set) throw new Error(`libWrapper Shim: '${target}' does not have a setter`); if (!descriptor.set) throw `libWrapper Shim: '${target}' does not have a setter`;
original = descriptor.set; original = descriptor.set;
descriptor.set = wrapper; descriptor.set = wrapper;
} }
@ -91,8 +68,11 @@ Hooks.once('init', () => {
}; };
//************** USER CUSTOMIZABLE: //************** USER CUSTOMIZABLE:
// Set up the ready hook that shows the "libWrapper not installed" warning dialog. Remove if undesired. // Whether to warn GM that the fallback is being used
{ const WARN_FALLBACK = true;
// Set up the ready hook that shows the "libWrapper not installed" warning dialog
if (WARN_FALLBACK) {
//************** USER CUSTOMIZABLE: //************** 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 // 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 [PACKAGE_ID, PACKAGE_TITLE] = (() => {

View file

@ -7,20 +7,11 @@ 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 getDownloadURL = (version) =>
const repositoryOwner = process.env.CI_REPO_OWNER; `https://git.f3l.de/ghost/darkness-dependent-vision/-/releases/${version}/downloads/darkness-dependent-vision.zip`;
const repositoryName = process.env.CI_REPO_NAME; const getChangelogURL = (version) => `https://git.f3l.de/ghost/darkness-dependent-vision/-/releases/${version}`;
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 manifestPath = 'module.json';
const getDownloadURL = (version) => `${repositoryURL}/releases/download/${version}/${repositoryName}.zip`;
const bugsURL = `${repositoryURL}/issues`;
const getChangelogURL = (version) => `${repositoryURL}/releases/tag/${version}`;
const getReadmeURL = (version) => `${repositoryURL}/raw/tag/${version}/README.md`;
const getLicenseURL = (version) => `${repositoryURL}/raw/tag/${version}/LICENSE.md`;
const manifestPath = `${packageType}.json`;
/** /**
* Get the contents of the manifest file as object. * Get the contents of the manifest file as object.
@ -71,16 +62,11 @@ 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.version = targetVersion;
manifest.url = repositoryURL;
manifest.manifest = manifestURL;
manifest.download = getDownloadURL(targetVersion); manifest.download = getDownloadURL(targetVersion);
manifest.bugs = bugsURL;
manifest.changelog = getChangelogURL(targetVersion); manifest.changelog = getChangelogURL(targetVersion);
manifest.readme = getReadmeURL(targetVersion); fs.writeJSONSync(manifestPath, manifest, { spaces: 4 });
manifest.license = getLicenseURL(targetVersion);
fs.writeJSONSync(manifestPath, manifest, { spaces: 2 });
} }
const argv = yargs(hideBin(process.argv)).usage('Usage: $0').option('release', { const argv = yargs(hideBin(process.argv)).usage('Usage: $0').option('release', {

6771
yarn.lock

File diff suppressed because it is too large Load diff