-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
893 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
#!/usr/bin/env deno run --allow-read --allow-write --unstable | ||
import type { AddonType } from "./lib/common.ts"; | ||
|
||
import { parseArgs } from "jsr:@std/[email protected]"; | ||
import { Colors } from "./deps.ts"; | ||
import { buildAddon } from "./cli/main.ts"; | ||
import type { AddonType } from "./lib/common.ts"; | ||
import { build } from "./cli/main.ts"; | ||
import { serveAddon } from './cli/serve-addon.ts'; | ||
|
||
const VERSION = '1.2.5' | ||
|
@@ -11,8 +12,8 @@ type LostCommand = 'none' | 'help' | 'version' | 'build' | 'create' | 'serve'; | |
|
||
async function main() { | ||
const { _, ...flags } = parseArgs(Deno.args, { | ||
boolean: ["plugin"], | ||
alias: {p: "plugin"}, | ||
boolean: ["plugin", "theme", "effect"], | ||
alias: {p: "plugin", t: "theme", e: "effect"}, | ||
"--": true, | ||
}); | ||
|
||
|
@@ -38,7 +39,7 @@ async function main() { | |
} | ||
break; | ||
case 'build': | ||
await buildAddon(); | ||
await build(); | ||
break; | ||
case 'serve': | ||
await serveAddon(65432); | ||
|
@@ -85,8 +86,9 @@ function printHelp() { | |
|
||
console.log(` ${Colors.yellow('create')}`); | ||
console.log(' ⚙️', Colors.gray(' --plugin, -p'), ' Creates a bare-bones for "plugin" addon type.'); | ||
console.log(' ⚙️', Colors.gray(' --theme, -t'), ' Creates a bare-bones for "theme" addon type.'); | ||
console.log(' ⚙️', Colors.gray(' --effect, -e'), ' Creates a bare-bones for "effect" addon type.'); | ||
|
||
console.log(` ${Colors.yellow('build')}`); | ||
console.log(' ⚙️', Colors.gray(' --local-base, -c'), ' Builds addon with local addon base.'); | ||
console.log(` ${Colors.yellow('serve')}`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import type { EffectParameter } from "../../lib/params.ts"; | ||
import type { AddonEffectFile } from './get-addon-effect-files.ts'; | ||
import type { LostConfig } from "../../lib/common.ts"; | ||
import type { AddonJSON } from "../../lib/json.ts"; | ||
import type { EffectParameterOptions } from '../../lib/params/EffectParameters.ts'; | ||
|
||
import { BUILD_PATH } from "../paths.ts"; | ||
|
||
interface CreateAddonJSONOptions { | ||
CONFIG: LostConfig<'effect'>; | ||
EFFECT_FILES: AddonEffectFile[]; | ||
PARAMETERS: EffectParameter<EffectParameterOptions>[]; | ||
} | ||
|
||
export async function createAddonEffectJSON({CONFIG, EFFECT_FILES, PARAMETERS}: CreateAddonJSONOptions) { | ||
const AddonJSON: AddonJSON.Effect = { | ||
"is-deprecated": CONFIG.Deprecated || false, | ||
"is-c3-addon": true, | ||
"type": CONFIG.Type, | ||
"name": CONFIG.AddonName, | ||
"id": CONFIG.AddonId, | ||
"version": CONFIG.Version, | ||
"author": CONFIG.Author, | ||
"website": CONFIG.WebsiteURL, | ||
"documentation": CONFIG.DocsURL, | ||
"description": CONFIG.AddonDescription, | ||
"file-list": [ | ||
"lang/en-US.json", | ||
"addon.json", | ||
], | ||
"category": CONFIG.Category, | ||
"supported-renderers": CONFIG.SupportedRenderers, | ||
"uses-depth": CONFIG.UsesDepth, | ||
"cross-sampling": CONFIG.CrossSampling, | ||
"preserves-opaqueness": CONFIG.PreservesOpaqueness, | ||
"animated": CONFIG.Animated, | ||
"must-predraw": CONFIG.MustPredraw || false, | ||
"supports-3d-direct-rendering": CONFIG.Supports3DDirectRendering || false, | ||
"extend-box": { | ||
"horizontal": CONFIG.ExtendBox[0], | ||
"vertical": CONFIG.ExtendBox[1], | ||
}, | ||
"blends-background": CONFIG.BlendsBackground, | ||
"parameters": [] | ||
}; | ||
|
||
PARAMETERS.forEach(parameter => { | ||
const {Id, Type, InitialValue, Uniform} = parameter.Options; | ||
AddonJSON['parameters'].push({ | ||
"id": Id, | ||
"type": Type, | ||
"initial-value": InitialValue, | ||
"uniform": Uniform | ||
}) | ||
}) | ||
|
||
EFFECT_FILES.forEach(effectFile => { | ||
AddonJSON['file-list'].push(`${effectFile.filename}`); | ||
}); | ||
|
||
await Deno.writeTextFile(`${BUILD_PATH}/addon.json`, JSON.stringify(AddonJSON, null, 4)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import type { LanguageJSON } from "../../lib/json.ts"; | ||
import type { LostConfig } from "../../lib/common.ts"; | ||
import type { EffectParameter } from '../../lib/params.ts'; | ||
import type { EffectParameterOptions } from '../../lib/params/EffectParameters.ts'; | ||
|
||
import { BUILD_PATH } from "../paths.ts"; | ||
|
||
interface CreateLanguageJSONOptions { | ||
CONFIG: LostConfig<'effect'>; | ||
PARAMETERS: EffectParameter<EffectParameterOptions>[]; | ||
} | ||
|
||
export async function createAddonEffectLanguageJSON({CONFIG, PARAMETERS}: CreateLanguageJSONOptions) { | ||
const LanguageJSON = { | ||
"languageTag": "en-US", | ||
"fileDescription": `Strings for ${CONFIG.AddonName} addon.`, | ||
"text": { | ||
[CONFIG.Type + 's']: { | ||
[CONFIG.AddonId.toLowerCase()]: { | ||
"name": CONFIG.AddonName, | ||
"description": CONFIG.AddonDescription, | ||
"parameters": {} | ||
} | ||
} | ||
} | ||
} as LanguageJSON.Effect; | ||
|
||
const DeepJSON = LanguageJSON['text'][CONFIG.Type + 's'][CONFIG.AddonId.toLowerCase()]; | ||
|
||
PARAMETERS.forEach(parameter => { | ||
const {Id, Name, Description} = parameter.Options; | ||
DeepJSON['parameters'][Id] = { | ||
"name": Name, | ||
"desc": Description || '' | ||
} | ||
}) | ||
|
||
await Deno.writeTextFile(`${BUILD_PATH}/lang/en-US.json`, JSON.stringify(LanguageJSON, null, 4)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { AddonEffectFile } from './get-addon-effect-files.ts'; | ||
|
||
import { BUILD_PATH } from "../paths.ts"; | ||
|
||
interface CreateAddonStructureOptions { | ||
EFFECT_FILES: AddonEffectFile[]; | ||
} | ||
|
||
export async function createAddonEffectStructure({EFFECT_FILES}: CreateAddonStructureOptions) { | ||
try { | ||
await Deno.remove(BUILD_PATH, { recursive: true }); | ||
} catch (e) { | ||
//return; | ||
} | ||
await Deno.mkdir(BUILD_PATH); | ||
await Deno.mkdir(`${BUILD_PATH}/lang`); | ||
|
||
if (EFFECT_FILES.length > 0) { | ||
EFFECT_FILES.forEach(effectFile => { | ||
Deno.copyFile(effectFile.path, `${BUILD_PATH}/${effectFile.filename}`); | ||
}) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { LOGGER } from '../misc.ts'; | ||
import { EFFECT_ADDON_FILES_FOLDER_PATH } from "../paths.ts"; | ||
|
||
export interface AddonEffectFile { | ||
filename: string; | ||
path: string; | ||
} | ||
|
||
export async function getAddonEffectFiles() { | ||
LOGGER.Searching('Searching for files'); | ||
|
||
const effectFiles: AddonEffectFile[] = []; | ||
|
||
const readFilesDirectory = async (path: string) => { | ||
for await (const entry of Deno.readDir(path)) { | ||
if (entry.isDirectory) { | ||
await readFilesDirectory(`${path}/${entry.name}`); | ||
} | ||
if (entry.isFile && (entry.name.endsWith('.fx') || entry.name.endsWith('.wgsl'))) { | ||
LOGGER.Info(`Founded effect file: ${entry.name}`); | ||
effectFiles.push({ | ||
filename: entry.name, | ||
path: `${path}/${entry.name}` | ||
}) | ||
} | ||
} | ||
} | ||
|
||
await readFilesDirectory(EFFECT_ADDON_FILES_FOLDER_PATH); | ||
|
||
return effectFiles; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { getModule } from "../misc.ts"; | ||
import type { EffectParameter } from "../../lib/params.ts"; | ||
import { EFFECT_PARAMETERS_FILE_PATH } from "../paths.ts"; | ||
|
||
interface EffectParametersModule { | ||
default: EffectParameter<any>[]; | ||
} | ||
|
||
export async function getAddonThemeEffectParameters() { | ||
const module = await getModule<EffectParametersModule>(EFFECT_PARAMETERS_FILE_PATH); | ||
return module.default; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.