Skip to content

Commit a9fa0f4

Browse files
committed
v1.2.3
Removed 'behavior' addon type for developing Added SDK v2 module system support Changed Instance.ts base file structure (you do not need to import Config) -- lost.d.ts Fixed zipping issue (when install addon)
1 parent 223841b commit a9fa0f4

File tree

14 files changed

+60
-67
lines changed

14 files changed

+60
-67
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
ts-defs/
12
mocks/
23
src/
34
deno.lock

addon_base/plugin/plugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const PLUGIN_CLASS = SDK.Plugins[ADDON_ID] = class LostPlugin extends SDK.IPlugi
4141
this._info.AddFileDependency({ filename: `scripts/${script.filename}`, type: script.dependencyType });
4242
});
4343
FILES.forEach(file => {
44-
this._info.AddFileDependency({ filename: `files/${file.filename}`, type: file.dependencyType });
44+
this._info.AddFileDependency({ filename: `files/${file.filename}`, type: file.dependencyType, fileType: file.fileType });
4545
});
4646
MODULES.forEach(module => {
4747
this._info.AddC3RuntimeScript(`c3runtime/Modules/${module.filename}`);

cli.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ type LostCommand = 'none' | 'help' | 'version' | 'build' | 'create' | 'serve' |
1111

1212
async function main() {
1313
const { _, ...flags } = parseArgs(Deno.args, {
14-
boolean: ["plugin", "behavior", "local-base"],
15-
alias: {p: "plugin", b: "plugin", l: "local-base"},
14+
boolean: ["plugin"],
15+
alias: {p: "plugin"},
1616
"--": true,
1717
});
1818

@@ -36,10 +36,6 @@ async function main() {
3636
await createBareBones('plugin');
3737
break;
3838
}
39-
if (flags.behavior) {
40-
await createBareBones('behavior');
41-
break;
42-
}
4339
break;
4440
case 'build':
4541
await buildAddon();

cli/cli-deps.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
export {
2+
BlobReader, BlobWriter, TextReader,
3+
TextWriter, ZipReader, ZipWriter,
4+
} from "jsr:@zip-js/[email protected]";
5+
16
export { Project } from 'jsr:@ts-morph/[email protected]';
27
export { walk } from 'jsr:@std/fs@1/walk';
3-
export * as zip from 'jsr:@quentinadam/zip@^0.1.1';
48
export { underscorePath } from "jsr:@hugoalh/[email protected]";

cli/create-addon-json.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export async function createAddonJSON(options: CreateAddonJSONOptions) {
5555

5656
SCRIPTS.forEach(script => AddonJSON['file-list'].push(`scripts/${script.filename}`));
5757
FILES.forEach(file => AddonJSON['file-list'].push(`files/${file.filename}`));
58-
MODULES.forEach(module => AddonJSON['file-list'].push(`modules/${module.filename}`));
58+
MODULES.forEach(module => AddonJSON['file-list'].push(`c3runtime/Modules/${module.filename}`));
5959

6060
await Deno.writeTextFile(`${BUILD_PATH}/addon.json`, JSON.stringify(AddonJSON, null, 4));
6161
}

cli/create-addon-structure.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import { LOGGER } from './misc.ts';
1313

1414
type AddonFiles = {
1515
readonly [K in AddonType]: [
16-
`c3runtime/${K}.js`,
17-
'c3runtime/type.js',
1816
'instance.js',
1917
'plugin.js',
2018
'type.js'
@@ -23,23 +21,14 @@ type AddonFiles = {
2321

2422
const ADDON_FILES: AddonFiles = {
2523
plugin: [
26-
'c3runtime/plugin.js',
27-
'c3runtime/type.js',
2824
'instance.js',
2925
'plugin.js',
3026
'type.js'
31-
],
32-
behavior: [
33-
'c3runtime/behavior.js',
34-
'c3runtime/type.js',
35-
'instance.js',
36-
'plugin.js',
37-
'type.js'
3827
]
3928
}
4029

4130
interface CreateAddonStructureOptions {
42-
CONFIG: LostConfig<'plugin' | 'behavior'>;
31+
CONFIG: LostConfig<AddonType>;
4332
PLUGIN_PROPERTIES: Property[];
4433
SCRIPTS: AddonScript[];
4534
FILES: AddonFile[];
@@ -80,9 +69,16 @@ export async function createAddonStructure(options: CreateAddonStructureOptions)
8069

8170
let instanceFileData = await transpileTsToJs(`${Deno.cwd()}/Addon/Instance.ts`) as string;
8271
instanceFileData = `const Config = {AddonId: ${JSON.stringify(CONFIG.AddonId)}};\n${instanceFileData}`
83-
// instanceFileData = instanceFileData.replace(/import\s+Config\s+from\s+["'](?:@config|\.\.\/lost\.config\.ts)["'];/, `const Config = ${JSON.stringify(CONFIG)};`);
8472
await Deno.writeTextFile(`${BUILD_PATH}/c3runtime/instance.js`, instanceFileData);
8573

74+
let pluginFileData = await transpileTsToJs(`${Deno.cwd()}/Addon/Plugin.ts`) as string;
75+
pluginFileData = `const Config = {AddonId: ${JSON.stringify(CONFIG.AddonId)}};\n${pluginFileData}`
76+
await Deno.writeTextFile(`${BUILD_PATH}/c3runtime/plugin.js`, pluginFileData);
77+
78+
let typeFileData = await transpileTsToJs(`${Deno.cwd()}/Addon/Type.ts`) as string;
79+
typeFileData = `const Config = {AddonId: ${JSON.stringify(CONFIG.AddonId)}};\n${typeFileData}`
80+
await Deno.writeTextFile(`${BUILD_PATH}/c3runtime/type.js`, typeFileData);
81+
8682
if (!localBase) {
8783
if (!ICON.isDefault) {
8884
await Deno.copyFile(ICON.path, `${BUILD_PATH}/${ICON.filename}`);

cli/create-language-json.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import type { LanguageJSON, LanguageAction, LanguageCondition, LanguageExpression, LanguagePluginProperty, LanguageParam } from "../lib/json.ts";
2-
import type { LostConfig } from "../lib/common.ts";
2+
import type { AddonType, LostConfig } from "../lib/common.ts";
33
import type { Property } from "../lib/plugin-props.ts";
44
import { BUILD_PATH } from "./paths.ts";
55
import type { CategoryClassType } from '../lib/entities.ts';
66

77
interface CreateLanguageJSONOptions {
8-
CONFIG: LostConfig<'plugin' | 'behavior'>;
8+
CONFIG: LostConfig<AddonType>;
99
PLUGIN_PROPERTIES: Property[];
1010
CATEGORIES: CategoryClassType[];
1111
}

cli/get-addon-files.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { LostConfig, FileDependencyType } from "../lib/common.ts";
1+
import type { LostConfig, FileDependencyType, AddonType } from "../lib/common.ts";
22
import { getMIMEFileType, LOGGER } from "./misc.ts";
33
import { ADDON_FILES_FOLDER_PATH } from "./paths.ts";
44

@@ -9,7 +9,7 @@ export interface AddonFile {
99
dependencyType: FileDependencyType;
1010
}
1111

12-
export async function getAddonFiles(config: LostConfig<'plugin' | 'behavior'>) {
12+
export async function getAddonFiles(config: LostConfig<AddonType>) {
1313
LOGGER.Searching('Searching for files');
1414

1515
const files: AddonFile[] = [];

cli/get-addon-scripts.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { LostConfig, ScriptDependencyType } from "../lib/common.ts";
1+
import type { AddonType, LostConfig, ScriptDependencyType } from "../lib/common.ts";
22
import { LOGGER } from "./misc.ts";
33
import { ADDON_SCRIPTS_FOLDER_PATH } from "./paths.ts";
44

@@ -9,7 +9,7 @@ export interface AddonScript {
99
dependencyType: ScriptDependencyType;
1010
}
1111

12-
export async function getAddonScripts(config: LostConfig<'plugin' | 'behavior'>) {
12+
export async function getAddonScripts(config: LostConfig<AddonType>) {
1313
LOGGER.Searching('Searching for scripts');
1414

1515
const scripts: AddonScript[] = [];

cli/get-config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { getModule } from "./misc.ts";
2-
import type { LostConfig } from "../lib/common.ts";
2+
import type { AddonType, LostConfig } from "../lib/common.ts";
33
import { CONFIG_FILE_PATH } from "./paths.ts";
44

55
interface ConfigModule {
6-
default: LostConfig<'plugin' | 'behavior'>;
6+
default: LostConfig<AddonType>;
77
}
88

99
export async function getConfig() {

0 commit comments

Comments
 (0)