code:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Zip = void 0;
const yazl = require("yazl");
const fs_1 = require("fs");
const exfs = require("./fs");
const path = require("path");
const util = require("./util");
const cancelable_1 = require("./cancelable");
/**
 * Compress files or folders to a zip file.
 */
class Zip extends cancelable_1.Cancelable {
    /**
     *
     */
    constructor(options) {
        super();
        this.options = options;
        this.isPipe = false;
        this.zipFiles = [];
        this.zipFolders = [];
    }
    /**
     * Adds a file from the file system at realPath into the zipfile as metadataPath.
     * @param file
     * @param metadataPath Typically metadataPath would be calculated as path.relative(root, realPath).
     * A valid metadataPath must not start with "/" or /[A-Za-z]:\//, and must not contain "..".
     */
    addFile(file, metadataPath) {
        let mpath = metadataPath;
        if (!mpath) {
            mpath = path.basename(file);
        }
        this.zipFiles.push({
            path: file,
            metadataPath: mpath
        });
    }
    /**
     * Adds a folder from the file system at realPath into the zipfile as metadataPath.
     * @param folder
     * @param metadataPath Typically metadataPath would be calculated as path.relative(root, realPath).
     * A valid metadataPath must not start with "/" or /[A-Za-z]:\//, and must not contain "..".
     */
    addFolder(folder, metadataPath) {
        this.zipFolders.push({
            path: folder,
            metadataPath
        });
    }
    /**
     * Generate zip file.
     * @param zipFile the zip file path.
     */
    async archive(zipFile) {
        if (!zipFile) {
            return Promise.reject(new Error("zipPath must not be empty"));
        }
        const token = new cancelable_1.CancellationToken();
        this.token = token;
        this.isPipe = false;
        await exfs.ensureFolder(path.dirname(zipFile));
        // Re-instantiate yazl every time the archive method is called to ensure that files are not added repeatedly.
        // This will also make the Zip class reusable.
        this.yazlFile = new yazl.ZipFile();
        return new Promise(async (c, e) => {
            this.yazlFile.once("error", (err) => {
                e(this.wrapError(err, token.isCancelled));
            });
            const zip = this.yazlFile;
            if (!token.isCancelled) {
                this.zipStream = (0, fs_1.createWriteStream)(zipFile);
                this.zipStream.once("error", (err) => {
                    e(this.wrapError(err, token.isCancelled));
                });
                this.zipStream.once("close", () => {
                    if (token.isCancelled) {
                        e(this.canceledError());
                    }
                    else {
                        c(void 0);
                    }
                });
                zip.outputStream.once("error", (err) => {
                    e(this.wrapError(err, token.isCancelled));
                });
                zip.outputStream.pipe(this.zipStream);
                this.isPipe = true;
            }
            try {
                const files = this.zipFiles;
                for (const file of files) {
                    const entry = await exfs.getFileEntry(file.path);
                    await this.addEntry(zip, entry, file, token);
                }
                if (this.zipFolders.length > 0) {
                    await this.walkDir(this.zipFolders, token);
                }
            }
            catch (error) {
                e(this.wrapError(error, token.isCancelled));
                return;
            }
            zip.end();
        });
    }
    /**
     * Cancel compression.
     * If the cancel method is called after the archive is complete, nothing will happen.
     */
    cancel() {
        if (this.token) {
            this.token.cancel();
            this.token = null;
        }
        this.stopPipe(this.canceledError());
    }
    async addEntry(zip, entry, file, token) {
        if (entry.isSymbolicLink) {
            if (this.followSymlink()) {
                if (entry.type === "dir") {
                    const realPath = await util.realpath(file.path);
                    await this.walkDir([{ path: realPath, metadataPath: file.metadataPath }], token);
                }
                else {
                    zip.addFile(file.path, file.metadataPath);
                }
            }
            else {
                await this.addSymlink(zip, entry, file.metadataPath);
            }
        }
        else {
            if (entry.type === "dir") {
                zip.addEmptyDirectory(file.metadataPath, {
                    mtime: entry.mtime,
                    mode: entry.mode
                });
            }
            else {
                await this.addFileStream(zip, entry, file.metadataPath, token);
            }
        }
    }
    addFileStream(zip, file, metadataPath, token) {
        return new Promise((c, e) => {
            const fileStream = (0, fs_1.createReadStream)(file.path);
            fileStream.once("error", (err) => {
                const wrappedError = this.wrapError(err, token.isCancelled);
                this.stopPipe(wrappedError);
                e(wrappedError);
            });
            fileStream.once("close", () => {
                c();
            });
            // If the file attribute is known, add the entry using `addReadStream`,
            // this can reduce the number of calls to the `fs.stat` method.
            zip.addReadStream(fileStream, metadataPath, {
                mode: file.mode,
                mtime: file.mtime
            });
        });
    }
    async addSymlink(zip, file, metadataPath) {
        const linkTarget = await util.readlink(file.path);
        zip.addBuffer(Buffer.from(linkTarget), metadataPath, {
            mtime: file.mtime,
            mode: file.mode
        });
    }
    async walkDir(folders, token) {
        for (const folder of folders) {
            if (token.isCancelled) {
                return;
            }
            const entries = await exfs.readdirp(folder.path);
            if (entries.length > 0) {
                for (const entry of entries) {
                    if (token.isCancelled) {
                        return;
                    }
                    const relativePath = path.relative(folder.path, entry.path);
                    const metadataPath = folder.metadataPath ? path.join(folder.metadataPath, relativePath) : relativePath;
                    await this.addEntry(this.yazlFile, entry, { path: entry.path, metadataPath }, token);
                }
            }
            else {
                // If the folder is empty and the metadataPath has a value,
                // an empty folder should be created based on the metadataPath
                if (folder.metadataPath) {
                    this.yazlFile.addEmptyDirectory(folder.metadataPath);
                }
            }
        }
    }
    stopPipe(err) {
        if (this.isPipe) {
            this.yazlFile.outputStream.unpipe(this.zipStream);
            this.zipStream.destroy(err);
            this.isPipe = false;
        }
    }
    followSymlink() {
        let followSymlink = false;
        if (this.options &&
            this.options.followSymlinks === true) {
            followSymlink = true;
        }
        return followSymlink;
    }
}
exports.Zip = Zip;


zip-lib

description: zip and unzip library for node

compile: rimraf ./lib && tsc -p ./src/tsconfig.json

release: rimraf ./lib && tsc -p ./src/tsconfig.release.json

compile-test: rimraf ./test/out && tsc -p ./test/src/tsconfig.json

test: node ./test/src/before.js && mocha ./test/out --timeout 10000

pack: npm run release && npm pack

publish: npm run release && npm publish

type: git

keywords: zip folder unzip archive extract promise async

author: fpsqdb

license: MIT

license: mit


era-electron

type: opencollective


author: SLeader <erauma@tutanota.com>

description: Electron-based ERA game engine


code:
const registry = {};

export default {
  ready() {
    window['ipc'].listen((res) => {
      try {
        registry[res.action](res.data);
      } catch (e) {
        console.log(res);
        console.log(e.message);
      }
    });
    window['ipc'].load();
  },
  register(action, handler) {
    registry[action] = handler;
  },
  registerMenu(cb) {
    window['ipc'].registerMenu(cb);
  },
  restart() {
    window['ipc'].restart();
  },
  returnInput(key, val) {
    window['ipc'].returnInput(key, val);
  },
  saveConfig(_config) {
    window['ipc'].saveConfig(_config);
  },
};


code:
const lineType = {
    button: 1,
    divider: 2,
    dynamicText: 3,
    empty: 0,
    image: 4,
    'image.whole': 5,
    inColRows: 8,
    lineChart: 0,
    lineUp: 6,
    multiCol: 7,
    progress: 9,
    text: 10,
  };
  const engineCommand = {
    config: 6,
    copyright: 1,
    resize: 2,
    restart: 3,
    saveConfig: 7,
    start: 4,
    version: 5,
    downloadEnd: 8,
    downloadFailed: 9,
    downloadStart: 7,
    newVersion: 6
  };
Object.keys(lineType).forEach((k, i) => (lineType[k] = i + 1));
Object.keys(engineCommand).forEach((k, i) => (engineCommand[k] = i + 1));

module.exports = {
  lineType,
  engineCommand,
};


code:
module.exports = {
  fuckOffUtf8Bom(content) {
    return content.replace(/^\uFEFF/, '');
  },
  getGameVersion(version) {
    let ver_str = version / 1000;
    if (ver_str % 1 === 0) {
      ver_str = ver_str.toFixed(1);
    }
    return ver_str;
  },
  getNumber(val) {
    const num = Number(val);
    if (isNaN(num)) {
      return val;
    }
    return num;
  },
  getValidValue(val, lowest, highest, defVal) {
    const num = Number(val);
    if (isNaN(num) || num < lowest || num > highest) {
      return defVal;
    }
    return num;
  },
  safeUndefinedCheck(_value, _default) {
    if (_value === undefined) {
      return _default;
    }
    return _value;
  },
  safelyGetConfigEntry(config, _entry) {
    const entries = _entry.split('.');
    let tmp = config;
    entries.forEach((e) => {
      if (tmp === undefined) {
        return undefined;
      }
      tmp = tmp[e];
    });
    return tmp;
  },
  toLowerCase(val) {
    if (typeof val === 'string') {
      return val.toLowerCase();
    }
    return val;
  },
};


code:
**/Jquery.js
**/mousetrap.js
**/sugarCubeConfig.js
**/format.js
**/displayVariables.js
**/dTree.min.js
**/optionsMacro.js
temp.**
**.temp
**/001-lib

repo_name: Banyanael/fc

path: .eslintignore


code:
{
	"root": true,
	"env": {
		"browser": true,
		"es6": true,
		"jquery": true
	},
	"extends": ["eslint:recommended"],
	"plugins": [
		"jsdoc",
		"sonarjs"
	],
	"globals": {
		"SugarCube": false,
		"Config": false,
		"State": false,
		"Story": false,
		"settings": false,
		"setup": false,
		"App": false,
		"prehistory": true,
		"predisplay": true,
		"prerender": true,
		"postrender": true,
		"postdisplay": true
	},
	"parserOptions": {
		"ecmaVersion": 2019,
		"sourceType": "script",
		"ecmaFeatures": {
			"impliedStrict": true
		}
	},
	"settings": {
		"jsdoc": {
			"mode": "typescript"
		}
	},
	"rules": {
		"no-prototype-builtins": "off",
		"semi": ["warn", "always"],
		"semi-spacing": "warn",
		"semi-style": "warn",
		"block-spacing": ["warn", "always"],
		"curly": ["warn", "all"],
		"eqeqeq": ["warn", "smart"],
		"space-before-function-paren": ["warn", {
			"anonymous": "never",
			"named": "never",
			"asyncArrow": "always"
		}],
		"template-curly-spacing": ["warn", "never"],
		"no-trailing-spaces": "warn",
		"no-mixed-spaces-and-tabs": ["warn", "smart-tabs"],
		"no-unneeded-ternary": "warn",
		"camelcase": "warn",
		"padded-blocks": ["warn", "never"],
		"comma-spacing": "warn",
		"comma-style": "warn",
		"object-curly-newline": ["warn",
			{
				"ObjectExpression":{
					"minProperties": 4,
					"consistent": true
				},
				"ImportDeclaration": {
					"minProperties": 4,
					"consistent": true
				},
				"ExportDeclaration": {
					"minProperties": 4,
					"consistent": true
				},
				"ObjectPattern": {
					"minProperties": 8,
					"consistent": true
				}
			}
		],
		"object-curly-spacing": "warn",
		"no-var": "warn",
		"spaced-comment": "warn",
		"no-undef": "off",
		"indent": ["error", "tab", { "SwitchCase": 1 }],
		"no-unused-vars": ["error", {"args": "none"}],
		"no-unused-expressions": "error",
		"block-scoped-var": "error",
		"dot-notation": "warn",
		"eol-last": "warn",
		"unicode-bom": [
			"error",
			"never"
		],
		"brace-style": [
			"warn",
			"1tbs",
			{
				"allowSingleLine": true
			}
		],
		"no-sequences": "warn",
		"no-unreachable-loop": "warn",
		"generator-star-spacing": [
			"warn",
			{
				"before": false,
				"after": true,
				"anonymous": "neither"
			}
		],
		"one-var": ["warn", "never"],
		"keyword-spacing": "warn",
		"no-template-curly-in-string": "error",
		"operator-linebreak": ["warn", "after", { "overrides": { "?": "before", ":": "before" }}],
		"jsdoc/check-alignment": 1,
		"jsdoc/check-examples": 0, // interferes with SugarCube examples
		"jsdoc/check-indentation": 0,
		"jsdoc/check-param-names": 1,
		"jsdoc/check-property-names": 1,
		"jsdoc/check-syntax": 1,
		"jsdoc/check-tag-names": 1,
		"jsdoc/check-types": 1,
		"jsdoc/implements-on-classes": 1,
		"jsdoc/match-description": 0, // rejects SugarCube syntax
		"jsdoc/newline-after-description": 0,
		"jsdoc/no-types": 0,
		"jsdoc/no-undefined-types": 0,
		"jsdoc/require-jsdoc": 0,
		"jsdoc/require-param": 0,
		"jsdoc/require-param-description": 0,
		"jsdoc/require-param-name": 1,
		"jsdoc/require-param-type": 1,
		"jsdoc/require-returns": 0,
		"jsdoc/require-returns-check": 1,
		"jsdoc/require-returns-description": 0,
		"jsdoc/require-returns-type": 1,
		"jsdoc/valid-types": 1,
		"sonarjs/no-all-duplicated-branches": "error",
		"sonarjs/no-element-overwrite": "error",
		"sonarjs/no-extra-arguments": "error",
		"sonarjs/no-identical-conditions": "error",
		"sonarjs/no-identical-expressions": "error",
		"sonarjs/no-one-iteration-loop": "error",
		"sonarjs/no-use-of-empty-return-value": "error",
		"sonarjs/no-collection-size-mischeck": "warn",
		"sonarjs/no-same-line-conditional": "warn",
		"sonarjs/no-unused-collection": "warn"
	}
}


code:
*.bat	text eol=crlf
*.js	text eol=lf
*.tw	text eol=lf
*.sh	text eol=lf
*.py	text eol=lf
*.txt	text eol=lf

path: .gitattributes


code:
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# Vim stuff
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]
Session.vim
Sessionx.vim
.netrwhist
*~
tags
[._]*.un~

# celery beat schedule file
celerybeat-schedule

# dotenv
.env

# virtualenv
venv/
ENV/

# Spyder project settings
.spyderproject

# Rope project settings
.ropeproject

# Start.tw
src/002-config/start.tw

# eslint
node_modules
package-lock.json
yarn.lock

# Visual Studio Code
.vscode/settings.json
.vscode/tasks.json
*.code-workspace

# WebStorm
.idea

# Gulp
build/

# backup
*.bak
*.gho
*.ori
*.orig
*.tmp

# misc
fc-pregmod
bin/*
*.outline
*.todo
TODO.txt
temp.*
*.temp
src/002-config/fc-version.js.commitHash.js

# macOS devices
*.icloud

path: .gitignore


code:
workflow:
  rules:
    # only run when on the main repo
    - if: '$CI_PROJECT_ID == "3528"'
      when: always

.official-releases:
  rules:
    - if: $CI_COMMIT_TAG =~ /\A\d+\.\d+\.\d+/

stages:
  - build
  - upload
  - release

variables:
  FC_PREGMOD_ARCHIVE: "FC_pregmod_${CI_COMMIT_TAG}.zip"
  # precompiled / assets
  # the URLs are the same as inside the game, change both if updating
  WEBGL_NAME: "WebGL art assets"
  WEBGL_URL: "https://mega.nz/folder/m1JQ3JAQ#2GJsM7csBBvBu0DX8SB2kA"
  RENDER_NAME: "Rendered imagepack (outdated)"
  RENDER_URL: "https://mega.nz/file/upoAlBaZ#EbZ5wCixxZxBhMN_ireJTXt0SIPOywO2JW9XzTIPhe0"

build:
  stage: build
  image: debian:latest
  rules:
    # official release
    - if: $CI_COMMIT_TAG =~ /\A\d+\.\d+\.\d+/
    # latest
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
  script:
    - ./compile.sh --ci --minify
  artifacts:
    paths:
      - bin/FC_pregmod.html

upload:
  stage: upload
  image: gitgud.io:5050/pregmodfan/fc-pregmod:megacmd
  extends: .official-releases
  script:
    - mega-login $MEGA_MAIL $MEGA_PWD
    - zip bin/$FC_PREGMOD_ARCHIVE bin/FC_pregmod.html
    - mega-put bin/$FC_PREGMOD_ARCHIVE /
    - echo "MEGA_URL=$(mega-export -a /$FC_PREGMOD_ARCHIVE | grep -o https.*)" >> variables.env
  artifacts:
    # carry MEGA_URL over to the release job
    reports:
      dotenv: variables.env

release:
  stage: release
  image: registry.gitlab.com/gitlab-org/release-cli:latest
  extends: .official-releases
  script:
    # extract changes from changelog
    # get line of version header + 1
    - START=$(awk 'match($1,"##") && match($2,v){print NR+1; exit}' v="0.10.7.1-$CI_COMMIT_TAG" CHANGELOG.md)
    # drop everything above the release including the release header
    - tail -n +$START CHANGELOG.md > tmp
    # get line of next version header - 1
    - END=$(awk 'match($1,"##") && match($2,v){print NR-1; exit}' v="0.10.7.1" tmp)
    # drop everything after current release
    - DESCRIPTION=$(head -n $END tmp)
    # create release
    # assets are displayed in inverse order to how they are defined here
    - |
      release-cli create --name "$CI_COMMIT_TAG" --description "$DESCRIPTION" \
        --tag-name "$CI_COMMIT_TAG" \
        --assets-link "{\"name\":\"${RENDER_NAME}\",\"url\":\"${RENDER_URL}\"}" \
        --assets-link "{\"name\":\"${WEBGL_NAME}\",\"url\":\"${WEBGL_URL}\"}" \
        --assets-link "{\"name\":\"${FC_PREGMOD_ARCHIVE}\",\"url\":\"${MEGA_URL}\"}"


code:
/label ~Bug

## Expected Behavior
<!--- If you're describing a bug, tell us what should happen -->

## Current Behavior
<!-- If describing a bug, tell us what happens instead of the expected behavior. Provide a Screenshots if possible. -->

## Steps to Reproduce
<!-- Provide an unambiguous sequence of steps to reproduce the bug. -->
1.
2.
3.
4.

## Additional information
<!-- Release ID and commit can be found on the starting splash screen or the options page. -->
* Release ID:
* Commit: (if available)
* Save file


code:
/label ~Feature

### Is your proposal related to a problem?
<!--
  Provide a clear and concise description of what the problem is.
  For example, "I'm always frustrated when..."
-->

### Describe the solution you'd like
<!--
  Provide a clear and concise description of what you want to happen.
-->

### Describe alternatives you've considered
<!--
  Let us know about other solutions you've tried or researched.
-->

### Additional context
<!--
  Is there anything else you can add about the proposal?
  You might want to link to related issues here, if you haven't already.
-->


code:
/label ~Question

<!-- Make sure to read the ingame encyclopedia before asking your question -->


code:
[submodule "submodules/sugarcube-2"]
	path = submodules/sugarcube-2
	url = https://gitgud.io/Arkerthan/sugarcube-2.git
	branch = fc

path: .gitmodules


brace_style: collapse,preserve-inline

path: .jsbeautifyrc


code:
// Minified files
**/dTree.min.js
**/js/displayVariables.js

path: .jshintignore