1.1.6 • Published 9 months ago

soil-ts v1.1.6

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

soil-ts

一个基于 lodash 构建的 Ae 脚本开发工具库

- dist
- node_modules
  - ...
  - soil-ts
  - ...
- src
  - index.tsx
package.json
rollup.config.mjs
tsconfig.json

package.json

{
  "scripts": {
    "build": "rollup -c"
  },
  "devDependencies": {
    "soil-ts": "^1.0.0",
    "types-for-adobe": "^7.0.12",
    "@rollup/plugin-terser": "^0.4.0",
    "@rollup/plugin-typescript": "^11.0.0",
    "rollup": "^3.18.0",
    "tslib": "^2.5.0"
  }
}
npm install

index.tsx

import * as _ from "soil-ts";

let activeItem = _.getActiveComp();

if (activeItem) {
    alert(activeItem.name);
}

tsconfig.json

{
    "extends": "./node_modules/soil-ts/tsconfig.json",
    "compilerOptions": {
        "paths": {
            "soil-ts": ["./node_modules/soil-ts/soil.tsx"]
        }
    },
    "include": ["node_modules/soil-ts/**/*.tsx", "./src/index.tsx"]
}

rollup.config.mjs

import typescript from "@rollup/plugin-typescript";
import terser from "@rollup/plugin-terser";

export default {
    input: "src/index.tsx",
    output: [
        {
            file: "dist/script.jsx", // Configure your script name here.
            intro: "(function () {",
            outro: "}).call(this);",
            plugins: [
                terser({
                    compress: false,
                    mangle: false,
                    format: {
                        beautify: true,
                        braces: true,
                        comments: false,
                        keep_quoted_props: true,
                        keep_numbers: true,
                        preamble: `// ${new Date().toLocaleString()}`,
                        wrap_func_args: false,
                    },
                }),
            ],
        },
        {
            file: "dist/script.min.jsx", 
            intro: "(function () {",
            outro: "}).call(this);",
            plugins: [
                terser({
                    compress: {
                        arrows: false,
                        arguments: true,
                        booleans: false,
                        conditionals: false,
                        evaluate: false,
                        join_vars: false,
                        keep_infinity: true,
                        sequences: false,
                        toplevel: true,
                    },
                    format: {
                        braces: true,
                    },
                }),
            ],
        },
    ],
    treeshake: {
        propertyReadSideEffects: false,
        unknownGlobalSideEffects: false,
    },
    plugins: [typescript()],
    context: "this",
};

build

npm run build

output

- dist
  - script.jsx // The packaged script can be run directly in After Effects.
  - script.min.jsx // compressed version.
- node_modules
  - ...
  - soil-ts
  - ...
- src
  - index.tsx
package.json
rollup.config.mjs
tsconfig.json

script.jsx

(function() {
    function createIsNativeType(nativeObject) {
        return function(value) {
            return value != null && value instanceof nativeObject;
        };
    }
    var isCompItem = createIsNativeType(CompItem);
    function getActiveItem() {
        return app.project.activeItem;
    }
    function getActiveComp() {
        var item = getActiveItem();
        return isCompItem(item) ? item : undefined;
    }
    var activeItem = getActiveComp();
    if (activeItem) {
        alert(activeItem.name);
    }
}).call(this);
1.1.6

9 months ago

1.1.5

9 months ago

1.1.4

9 months ago

1.1.3

10 months ago

1.1.2

10 months ago

1.1.1

10 months ago

1.1.0

10 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago