Skip to content
Snippets Groups Projects
Select Git revision
  • 2ca41b2b51bdc39240f193ee533aef0efe033fe7
  • master default protected
  • rednatco-v2
  • rednatco
  • test
  • ntc-tube-uniform-color
  • ntc-tube-missing-atoms
  • restore-vertex-array-per-program
  • watlas2
  • dnatco_new
  • cleanup-old-nodejs
  • webmmb
  • fix_auth_seq_id
  • update_deps
  • ext_dev
  • ntc_balls
  • nci-2
  • plugin
  • bugfix-0.4.5
  • nci
  • servers
  • v0.5.0-dev.1
  • v0.4.5
  • v0.4.4
  • v0.4.3
  • v0.4.2
  • v0.4.1
  • v0.4.0
  • v0.3.12
  • v0.3.11
  • v0.3.10
  • v0.3.9
  • v0.3.8
  • v0.3.7
  • v0.3.6
  • v0.3.5
  • v0.3.4
  • v0.3.3
  • v0.3.2
  • v0.3.1
  • v0.3.0
41 results

webpack.config.common.js

Blame
    • Alexander Rose's avatar
      4904bae5
      background pass improvements · 4904bae5
      Alexander Rose authored
      - add PluginConfig.Background.Styles
      - file support, asset management
      - opacity, saturation, lightness controls for skybox/image
      - coverage controls for image/gradient
      - add backgrounds extension with examples
      - image handling for build/watch (webpack, cpx)
      4904bae5
      History
      background pass improvements
      Alexander Rose authored
      - add PluginConfig.Background.Styles
      - file support, asset management
      - opacity, saturation, lightness controls for skybox/image
      - coverage controls for image/gradient
      - add backgrounds extension with examples
      - image handling for build/watch (webpack, cpx)
    helpers.ts 1.76 KiB
    /*
     * Copyright (c) 2018 Mol* contributors, licensed under MIT, See LICENSE file for more info.
     *
     * @author David Sehnal <david.sehnal@gmail.com>
     */
    
    import { Type } from './type';
    import { MSymbol, Arguments, isSymbol } from './symbol';
    
    export function symbol<A extends Arguments, T extends Type<S>, S>(args: A, type: T, description?: string) {
        return MSymbol('', args, type, description);
    }
    
    export function normalizeTable(table: any) {
        _normalizeTable('', '', table);
    }
    
    export function symbolList(table: any): MSymbol[] {
        const list: MSymbol[] = [];
        _symbolList(table, list);
        return list;
    }
    
    function formatKey(key: string) {
        const regex = /([a-z])([A-Z])([a-z]|$)/g;
        // do this twice because 'xXxX'
        return key.replace(regex, (s, a, b, c) => `${a}-${b.toLocaleLowerCase()}${c}`).replace(regex, (s, a, b, c) => `${a}-${b.toLocaleLowerCase()}${c}`);
    }
    
    function _normalizeTable(namespace: string, key: string, obj: any) {
        if (isSymbol(obj)) {
            obj.info.namespace = namespace;
            obj.info.name = obj.info.name || formatKey(key);
            obj.id = `${obj.info.namespace}.${obj.info.name}`;
            return;
        }
        const currentNs = `${obj['@namespace'] || formatKey(key)}`;
        const newNs = namespace ? `${namespace}.${currentNs}` : currentNs;
        for (const childKey of Object.keys(obj)) {
            if (typeof obj[childKey] !== 'object' && !isSymbol(obj[childKey])) continue;
            _normalizeTable(newNs, childKey, obj[childKey]);
        }
    }
    
    function _symbolList(obj: any, list: MSymbol[]) {
        if (isSymbol(obj)) {
            list.push(obj);
            return;
        }
        for (const childKey of Object.keys(obj)) {
            if (typeof obj[childKey] !== 'object' && !isSymbol(obj[childKey])) continue;
            _symbolList(obj[childKey], list);
        }
    }