Skip to content
Snippets Groups Projects
Select Git revision
  • 6de0a8ec00cfab1a7664bc5a934a9d4e7207e77d
  • zig default
  • master
  • zig-threaded
  • openat
  • chdir
  • clear
  • compll
  • v1.18.1
  • v2.2.2
  • v1.18
  • v2.2.1
  • v2.2
  • v1.17
  • v2.1.2
  • v2.1.1
  • v2.1
  • v2.0.1
  • v2.0
  • v2.0-beta3
  • v2.0-beta2
  • v2.0-beta1
  • v1.16
  • v1.15.1
  • v1.15
  • v1.14.2
  • v1.14.1
  • v1.14
28 results

calc.c

Blame
    • Yorhel's avatar
      6de0a8ec
      Use correct hard link information after partial recalculation or deletion · 6de0a8ec
      Yorhel authored
      Hard link detection is now done in a separate pass on the in-memory tree,
      and duplicates can be 'removed' and 're-added' on the fly. When making any
      changes in the tree, all hard links are re-added before the operation and
      removed again afterwards.
      
      While this guarantees that all hard link information is correct, it does
      have a few drawbacks. I can currently think of two:
      
       1. It's not the most efficient way to do it, and may be quite slow on
          large trees. Will have to do some benchmarks later to see whether
          it is anything to be concerned about.
      
       2. The first encountered item is considered as 'counted' and all items
          encountered after that are considered as 'duplicate'. Because the
          order in which we traverse the tree doesn't always have to be the
          same, the items that will be considered as 'duplicate' can vary with
          each deletion or re-calculation. This might cause confusion for
          people who aren't aware of how hard links work.
      6de0a8ec
      History
      Use correct hard link information after partial recalculation or deletion
      Yorhel authored
      Hard link detection is now done in a separate pass on the in-memory tree,
      and duplicates can be 'removed' and 're-added' on the fly. When making any
      changes in the tree, all hard links are re-added before the operation and
      removed again afterwards.
      
      While this guarantees that all hard link information is correct, it does
      have a few drawbacks. I can currently think of two:
      
       1. It's not the most efficient way to do it, and may be quite slow on
          large trees. Will have to do some benchmarks later to see whether
          it is anything to be concerned about.
      
       2. The first encountered item is considered as 'counted' and all items
          encountered after that are considered as 'duplicate'. Because the
          order in which we traverse the tree doesn't always have to be the
          same, the items that will be considered as 'duplicate' can vary with
          each deletion or re-calculation. This might cause confusion for
          people who aren't aware of how hard links work.
    webpack.config.common.js 3.87 KiB
    const path = require('path');
    const fs = require('fs');
    const webpack = require('webpack');
    const ExtraWatchWebpackPlugin = require('extra-watch-webpack-plugin');
    const MiniCssExtractPlugin = require('mini-css-extract-plugin');
    const VERSION = require('./package.json').version;
    
    class VersionFilePlugin {
        apply() {
            fs.writeFileSync(
                path.resolve(__dirname, 'lib/mol-plugin/version.js'),
                `export var PLUGIN_VERSION = '${VERSION}';\nexport var PLUGIN_VERSION_DATE = new Date(typeof __MOLSTAR_DEBUG_TIMESTAMP__ !== 'undefined' ? __MOLSTAR_DEBUG_TIMESTAMP__ : ${new Date().valueOf()});`);
        }
    }
    
    const sharedConfig = {
        module: {
            rules: [
                {
                    test: /\.(html|ico)$/,
                    use: [{
                        loader: 'file-loader',
                        options: { name: '[name].[ext]' }
                    }]
                },
                {
                    test: /\.(s*)css$/,
                    use: [
                        MiniCssExtractPlugin.loader,
                        { loader: 'css-loader', options: { sourceMap: false } },
                        { loader: 'sass-loader', options: { sourceMap: false } },
                    ]
                },
                {
                    test: /\.(jpg)$/i,
                    type: 'asset/resource',
                },
            ]
        },
        plugins: [
            new ExtraWatchWebpackPlugin({
                files: [
                    './lib/**/*.scss',
                    './lib/**/*.html'
                ],
            }),
            new webpack.DefinePlugin({
                'process.env.DEBUG': JSON.stringify(process.env.DEBUG),
                '__MOLSTAR_DEBUG_TIMESTAMP__': webpack.DefinePlugin.runtimeValue(() => `${new Date().valueOf()}`, true)
            }),
            new MiniCssExtractPlugin({ filename: 'molstar.css' }),
            new VersionFilePlugin(),
        ],
        resolve: {
            modules: [
                'node_modules',
                path.resolve(__dirname, 'lib/')
            ],
            fallback: {
                fs: false,
                crypto: require.resolve('crypto-browserify'),
                path: require.resolve('path-browserify'),
                stream: require.resolve('stream-browserify'),
            }
        },
        watchOptions: {
            aggregateTimeout: 750
        }
    };
    
    function createEntry(src, outFolder, outFilename, isNode) {
        return {
            target: isNode ? 'node' : void 0,
            entry: path.resolve(__dirname, `lib/${src}.js`),
            output: { filename: `${outFilename}.js`, path: path.resolve(__dirname, `build/${outFolder}`) },
            ...sharedConfig
        };
    }
    
    function createEntryPoint(name, dir, out, library) {
        return {
            entry: path.resolve(__dirname, `lib/${dir}/${name}.js`),
            output: { filename: `${library || name}.js`, path: path.resolve(__dirname, `build/${out}`), library: library || out, libraryTarget: 'umd', assetModuleFilename: 'images/[hash][ext][query]', 'publicPath': '' },
            ...sharedConfig
        };
    }
    
    function createNodeEntryPoint(name, dir, out) {
        return {
            target: 'node',
            entry: path.resolve(__dirname, `lib/${dir}/${name}.js`),
            output: { filename: `${name}.js`, path: path.resolve(__dirname, `build/${out}`) },
            externals: {
                argparse: 'require("argparse")',
                'node-fetch': 'require("node-fetch")',
                'util.promisify': 'require("util.promisify")',
                xhr2: 'require("xhr2")',
            },
            ...sharedConfig
        };
    }
    
    function createApp(name, library) { return createEntryPoint('index', `apps/${name}`, name, library); }
    function createExample(name) { return createEntry(`examples/${name}/index`, `examples/${name}`, 'index'); }
    function createBrowserTest(name) { return createEntryPoint(name, 'tests/browser', 'tests'); }
    function createNodeApp(name) { return createNodeEntryPoint('index', `apps/${name}`, name); }
    
    module.exports = {
        createApp,
        createEntry,
        createExample,
        createBrowserTest,
        createNodeEntryPoint,
        createNodeApp
    };