sammi-next 1.2.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { version } from "../package.mjs";
1
+ import { version } from "../sammi-next/package.mjs";
2
2
  import { BUILD_PREFIX, GLOBAL_NAME, GREEN_CHECK, RED_X, SAMMI_NEXT_PACKAGE_DIR } from "./constants.mjs";
3
3
  import { displayTime } from "./utils.mjs";
4
4
  import fs from "node:fs";
@@ -20,7 +20,7 @@ function readOptionalFile(path$1) {
20
20
  }
21
21
  const CommandRE = /\w+\(\w+,\s*{\s*default:/gm;
22
22
  function generateSEF(options) {
23
- const { config, mode } = options;
23
+ const { config, rootDir, mode } = options;
24
24
  const content = [];
25
25
  const required_files = [
26
26
  {
@@ -39,10 +39,10 @@ function generateSEF(options) {
39
39
  for (const field of required_files) content.push(`[${field.header}]`, field.content, "");
40
40
  const external = readOptionalFile(config.external);
41
41
  content.push("[insert_external]", external ? `<div id="${config.id}-external">${external}</div>` : "", "");
42
- const script = fs.readFileSync(config.entry, "utf-8");
43
- content.push("[insert_command]", CommandRE.test(script) ? `${GLOBAL_NAME}.${config.id}.default()` : "", "");
42
+ const js_script = fs.readFileSync(path.join(rootDir, config.out.dir, config.out.js), "utf-8");
43
+ content.push("[insert_command]", CommandRE.test(js_script) ? `${GLOBAL_NAME}.${config.id}.default()` : "", "");
44
44
  content.push("[insert_hook]", "", "");
45
- content.push("[insert_script]", script, "");
45
+ content.push("[insert_script]", js_script, "");
46
46
  let over = readOptionalFile(config.over);
47
47
  if (over && mode === BuildMode.PRODUCTION) over = JSON.stringify(JSON.parse(over));
48
48
  content.push("[insert_over]", over && over != "{}" ? over : "", "");
@@ -1 +1 @@
1
- {"version":3,"file":"build.mjs","names":["path","VERSION","res"],"sources":["../../src/node/build.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport colors from 'picocolors';\nimport chokidar from 'chokidar';\nimport { ResolvedExtensionConfig } from \"@shared/config-types\";\nimport { build, TsdownBundle } from \"tsdown\";\nimport { BUILD_PREFIX, GLOBAL_NAME, GREEN_CHECK, RED_X, SAMMI_NEXT_PACKAGE_DIR, VERSION } from \"./constants\";\nimport { displayTime } from './utils';\n\nexport enum BuildMode {\n DEV,\n PRODUCTION,\n}\n\nexport const BuildModes = Object.keys(BuildMode).filter(key => isNaN(Number(key)));\n\nexport interface BuildOptions {\n config: ResolvedExtensionConfig;\n rootDir: string;\n mode?: BuildMode;\n}\n\nexport type ResolvedBuildOptions = Required<BuildOptions>;\n\nfunction readOptionalFile(path: string): string | undefined {\n if (!fs.existsSync(path)) return;\n\n return fs.readFileSync(path, 'utf-8');\n}\n\nconst CommandRE = /\\w+\\(\\w+,\\s*{\\s*default:/gm;\n\nfunction generateSEF(options: ResolvedBuildOptions): string {\n const { config, mode } = options;\n const content = [];\n\n const required_files: {\n header: string,\n content: string,\n }[] = [\n {\n header: \"extension_name\",\n content: config.name,\n },\n {\n header: \"extension_info\",\n content: config.info,\n },\n {\n header: \"extension_version\",\n content: config.version,\n },\n ]\n\n for (const field of required_files) {\n content.push(`[${field.header}]`, field.content, \"\");\n }\n\n const external = readOptionalFile(config.external);\n content.push(\"[insert_external]\", external ? `<div id=\"${config.id}-external\">${external}</div>` : \"\", \"\");\n\n const script = fs.readFileSync(config.entry, \"utf-8\");\n content.push(\"[insert_command]\", CommandRE.test(script) ? `${GLOBAL_NAME}.${config.id}.default()` : \"\", \"\");\n content.push(\"[insert_hook]\", \"\", \"\") // TODO: maybe add hook retro-compatibility\n content.push(\"[insert_script]\", script, \"\");\n\n let over = readOptionalFile(config.over);\n if (over && mode === BuildMode.PRODUCTION) {\n over = JSON.stringify(JSON.parse(over));\n }\n content.push(\"[insert_over]\", over && over != \"{}\" ? over : \"\", \"\");\n return content.join(\"\\n\");\n}\n\nfunction generatePreview(options: ResolvedBuildOptions): string {\n const { config } = options;\n\n const external = readOptionalFile(config.external);\n const script = fs.readFileSync(config.entry, \"utf-8\");\n return fs\n .readFileSync(path.join(SAMMI_NEXT_PACKAGE_DIR, \".sammi\", \"preview.blueprint.html\"), \"utf-8\")\n .replace(/{{EXTERNAL}}/g, external ? `<div id=\"${config.id}-external\">${external}</div>` : \"\")\n .replace(/{{SCRIPT}}/g, script);\n}\n\nasync function buildOnce(options: ResolvedBuildOptions) {\n const { config, rootDir, mode } = options;\n\n const startTime = Date.now();\n const bundle = await build({\n entry: [config.entry],\n outDir: path.join(rootDir, config.out.dir),\n platform: 'browser',\n format: 'iife',\n target: ['es2022'],\n sourcemap: false,\n minify: mode === BuildMode.PRODUCTION,\n banner: {\n js: `/* ${config.name} v${config.version} - Built with SAMMI Next v${VERSION} */`,\n },\n noExternal: ['**'],\n outputOptions: {\n entryFileNames: config.out.js,\n extend: true,\n name: `${GLOBAL_NAME}.${config.id}`,\n exports: 'named',\n },\n });\n const tsdownTime = Date.now();\n console.info(GREEN_CHECK, BUILD_PREFIX, `built ${config.out.js} in ${displayTime(tsdownTime - startTime)}`);\n\n fs.writeFileSync(path.join(rootDir, config.out.dir, config.out.sef), generateSEF(options), 'utf-8');\n const sefTime = Date.now();\n console.info(GREEN_CHECK, BUILD_PREFIX, `built ${config.out.sef} in ${displayTime(sefTime - tsdownTime)}`);\n\n fs.writeFileSync(path.join(rootDir, config.out.dir, \"preview.html\"), generatePreview(options), 'utf-8');\n const previewTime = Date.now();\n console.info(GREEN_CHECK, BUILD_PREFIX, `built preview.html in ${displayTime(previewTime - sefTime)}`);\n return { bundle, startTime };\n}\n\nexport async function buildExtension(options: ResolvedBuildOptions) {\n const { config, mode } = options;\n\n console.info(\n colors.cyan(\n `SAMMI Next v${VERSION} ${colors.green(\n `building \"${config.name}\" extension in ${BuildMode[mode].toLowerCase()} mode...`\n )}`\n ),\n );\n\n let bundle: TsdownBundle[] | undefined;\n let startTime: number | undefined;\n\n try {\n const res = await buildOnce(options);\n bundle = res.bundle;\n startTime = res.startTime;\n\n if (options.mode !== BuildMode.DEV) return bundle;\n\n console.info(BUILD_PREFIX, colors.cyan(\"watching for file changes...\"));\n\n const watchPaths = [\n path.dirname(config.entry),\n config.external,\n config.over,\n ].filter(Boolean);\n\n const watcher = chokidar.watch(watchPaths, { ignoreInitial: true });\n let timer: NodeJS.Timeout | null = null;\n\n watcher.on('all', (event, p) => {\n console.info(colors.cyan(`${event}: ${p}`));\n if (timer)\n clearTimeout(timer);\n\n timer = setTimeout(() => {\n buildOnce(options).then(res => {\n bundle = res.bundle;\n startTime = res.startTime;\n }).catch(e => console.error(e));\n }, 100);\n });\n\n process.on('SIGINT', () => {\n console.info(\"\\nStopping watch mode...\");\n watcher\n .close()\n .then(() => process.exit(0))\n .catch(e => {\n console.error(e);\n process.exit(1);\n });\n });\n return watcher;\n } catch (error) {\n if (startTime) {\n console.error(RED_X, BUILD_PREFIX, `Build failed in ${displayTime(Date.now() - startTime)}`);\n startTime = undefined;\n }\n throw error;\n }\n}\n"],"mappings":";;;;;;;;;;AASA,IAAY,gDAAL;AACH;AACA;;;AAGJ,MAAa,aAAa,OAAO,KAAK,UAAU,CAAC,QAAO,QAAO,MAAM,OAAO,IAAI,CAAC,CAAC;AAUlF,SAAS,iBAAiB,QAAkC;AACxD,KAAI,CAAC,GAAG,WAAWA,OAAK,CAAE;AAE1B,QAAO,GAAG,aAAaA,QAAM,QAAQ;;AAGzC,MAAM,YAAY;AAElB,SAAS,YAAY,SAAuC;CACxD,MAAM,EAAE,QAAQ,SAAS;CACzB,MAAM,UAAU,EAAE;CAElB,MAAM,iBAGA;EACF;GACI,QAAQ;GACR,SAAS,OAAO;GACnB;EACD;GACI,QAAQ;GACR,SAAS,OAAO;GACnB;EACD;GACI,QAAQ;GACR,SAAS,OAAO;GACnB;EACJ;AAED,MAAK,MAAM,SAAS,eAChB,SAAQ,KAAK,IAAI,MAAM,OAAO,IAAI,MAAM,SAAS,GAAG;CAGxD,MAAM,WAAW,iBAAiB,OAAO,SAAS;AAClD,SAAQ,KAAK,qBAAqB,WA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I,QAA+B;AAEnC,UAAQ,GAAG,QAAQ,OAAO,MAAM;AAC5B,WAAQ,KAAK,OAAO,KAAK,GAAG,MAAM,IAAI,IAAI,CAAC;AAC3C,OAAI,MACA,cAAa,MAAM;AAEvB,WAAQ,iBAAiB;AACrB,cAAU,QAAQ,CAAC,MAAK,UAAO;AAC3B,cAASC,MAAI;AACb,iBAAYA,MAAI;MAClB,CAAC,OAAM,MAAK,QAAQ,MAAM,EAAE,CAAC;MAChC,IAAI;IACT;AAEF,UAAQ,GAAG,gBAAgB;AACvB,WAAQ,KAAK,2BAA2B;AACxC,WACK,OAAO,CACP,WAAW,QAAQ,KAAK,EAAE,CAAC,CAC3B,OAAM,MAAK;AACR,YAAQ,MAAM,EAAE;AAChB,YAAQ,KAAK,EAAE;KACjB;IACR;AACF,SAAO;UACF,OAAO;AACZ,MAAI,WAAW;AACX,WAAQ,MAAM,OAAO,cAAc,mBAAmB,YAAY,KAAK,KAAK,GAAG,UAAU,GAAG;AAC5F,eAAY;;AAEhB,QAAM"}
1
+ {"version":3,"file":"build.mjs","names":["path","VERSION","res"],"sources":["../../src/node/build.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport colors from 'picocolors';\nimport chokidar from 'chokidar';\nimport { ResolvedExtensionConfig } from \"@shared/config-types\";\nimport { build, TsdownBundle } from \"tsdown\";\nimport { BUILD_PREFIX, GLOBAL_NAME, GREEN_CHECK, RED_X, SAMMI_NEXT_PACKAGE_DIR, VERSION } from \"./constants\";\nimport { displayTime } from './utils';\n\nexport enum BuildMode {\n DEV,\n PRODUCTION,\n}\n\nexport const BuildModes = Object.keys(BuildMode).filter(key => isNaN(Number(key)));\n\nexport interface BuildOptions {\n config: ResolvedExtensionConfig;\n rootDir: string;\n mode?: BuildMode;\n}\n\nexport type ResolvedBuildOptions = Required<BuildOptions>;\n\nfunction readOptionalFile(path: string): string | undefined {\n if (!fs.existsSync(path)) return;\n\n return fs.readFileSync(path, 'utf-8');\n}\n\nconst CommandRE = /\\w+\\(\\w+,\\s*{\\s*default:/gm;\n\nfunction generateSEF(options: ResolvedBuildOptions): string {\n const { config, rootDir, mode } = options;\n const content = [];\n\n const required_files: {\n header: string,\n content: string,\n }[] = [\n {\n header: \"extension_name\",\n content: config.name,\n },\n {\n header: \"extension_info\",\n content: config.info,\n },\n {\n header: \"extension_version\",\n content: config.version,\n },\n ]\n\n for (const field of required_files) {\n content.push(`[${field.header}]`, field.content, \"\");\n }\n\n const external = readOptionalFile(config.external);\n content.push(\"[insert_external]\", external ? `<div id=\"${config.id}-external\">${external}</div>` : \"\", \"\");\n\n const js_script = fs.readFileSync(path.join(rootDir, config.out.dir, config.out.js), \"utf-8\");\n content.push(\"[insert_command]\", CommandRE.test(js_script) ? `${GLOBAL_NAME}.${config.id}.default()` : \"\", \"\");\n content.push(\"[insert_hook]\", \"\", \"\") // TODO: maybe add hook retro-compatibility\n content.push(\"[insert_script]\", js_script, \"\");\n\n let over = readOptionalFile(config.over);\n if (over && mode === BuildMode.PRODUCTION) {\n over = JSON.stringify(JSON.parse(over));\n }\n content.push(\"[insert_over]\", over && over != \"{}\" ? over : \"\", \"\");\n return content.join(\"\\n\");\n}\n\nfunction generatePreview(options: ResolvedBuildOptions): string {\n const { config } = options;\n\n const external = readOptionalFile(config.external);\n const script = fs.readFileSync(config.entry, \"utf-8\");\n return fs\n .readFileSync(path.join(SAMMI_NEXT_PACKAGE_DIR, \".sammi\", \"preview.blueprint.html\"), \"utf-8\")\n .replace(/{{EXTERNAL}}/g, external ? `<div id=\"${config.id}-external\">${external}</div>` : \"\")\n .replace(/{{SCRIPT}}/g, script);\n}\n\nasync function buildOnce(options: ResolvedBuildOptions) {\n const { config, rootDir, mode } = options;\n\n const startTime = Date.now();\n const bundle = await build({\n entry: [config.entry],\n outDir: path.join(rootDir, config.out.dir),\n platform: 'browser',\n format: 'iife',\n target: ['es2022'],\n sourcemap: false,\n minify: mode === BuildMode.PRODUCTION,\n banner: {\n js: `/* ${config.name} v${config.version} - Built with SAMMI Next v${VERSION} */`,\n },\n noExternal: ['**'],\n outputOptions: {\n entryFileNames: config.out.js,\n extend: true,\n name: `${GLOBAL_NAME}.${config.id}`,\n exports: 'named',\n },\n });\n const tsdownTime = Date.now();\n console.info(GREEN_CHECK, BUILD_PREFIX, `built ${config.out.js} in ${displayTime(tsdownTime - startTime)}`);\n\n fs.writeFileSync(path.join(rootDir, config.out.dir, config.out.sef), generateSEF(options), 'utf-8');\n const sefTime = Date.now();\n console.info(GREEN_CHECK, BUILD_PREFIX, `built ${config.out.sef} in ${displayTime(sefTime - tsdownTime)}`);\n\n fs.writeFileSync(path.join(rootDir, config.out.dir, \"preview.html\"), generatePreview(options), 'utf-8');\n const previewTime = Date.now();\n console.info(GREEN_CHECK, BUILD_PREFIX, `built preview.html in ${displayTime(previewTime - sefTime)}`);\n return { bundle, startTime };\n}\n\nexport async function buildExtension(options: ResolvedBuildOptions) {\n const { config, mode } = options;\n\n console.info(\n colors.cyan(\n `SAMMI Next v${VERSION} ${colors.green(\n `building \"${config.name}\" extension in ${BuildMode[mode].toLowerCase()} mode...`\n )}`\n ),\n );\n\n let bundle: TsdownBundle[] | undefined;\n let startTime: number | undefined;\n\n try {\n const res = await buildOnce(options);\n bundle = res.bundle;\n startTime = res.startTime;\n\n if (options.mode !== BuildMode.DEV) return bundle;\n\n console.info(BUILD_PREFIX, colors.cyan(\"watching for file changes...\"));\n\n const watchPaths = [\n path.dirname(config.entry),\n config.external,\n config.over,\n ].filter(Boolean);\n\n const watcher = chokidar.watch(watchPaths, { ignoreInitial: true });\n let timer: NodeJS.Timeout | null = null;\n\n watcher.on('all', (event, p) => {\n console.info(colors.cyan(`${event}: ${p}`));\n if (timer)\n clearTimeout(timer);\n\n timer = setTimeout(() => {\n buildOnce(options).then(res => {\n bundle = res.bundle;\n startTime = res.startTime;\n }).catch(e => console.error(e));\n }, 100);\n });\n\n process.on('SIGINT', () => {\n console.info(\"\\nStopping watch mode...\");\n watcher\n .close()\n .then(() => process.exit(0))\n .catch(e => {\n console.error(e);\n process.exit(1);\n });\n });\n return watcher;\n } catch (error) {\n if (startTime) {\n console.error(RED_X, BUILD_PREFIX, `Build failed in ${displayTime(Date.now() - startTime)}`);\n startTime = undefined;\n }\n throw error;\n }\n}\n"],"mappings":";;;;;;;;;;AASA,IAAY,gDAAL;AACH;AACA;;;AAGJ,MAAa,aAAa,OAAO,KAAK,UAAU,CAAC,QAAO,QAAO,MAAM,OAAO,IAAI,CAAC,CAAC;AAUlF,SAAS,iBAAiB,QAAkC;AACxD,KAAI,CAAC,GAAG,WAAWA,OAAK,CAAE;AAE1B,QAAO,GAAG,aAAaA,QAAM,QAAQ;;AAGzC,MAAM,YAAY;AAElB,SAAS,YAAY,SAAuC;CACxD,MAAM,EAAE,QAAQ,SAAS,SAAS;CAClC,MAAM,UAAU,EAAE;CAElB,MAAM,iBAGA;EACF;GACI,QAAQ;GACR,SAAS,OAAO;GACnB;EACD;GACI,QAAQ;GACR,SAAS,OAAO;GACnB;EACD;GACI,QAAQ;GACR,SAAS,OAAO;GACnB;EACJ;AAED,MAAK,MAAM,SAAS,eAChB,SAAQ,KAAK,IAAI,MAAM,OAAO,IAAI,MAAM,SAAS,GAAG;CAGxD,MAAM,WAAW,iBAAiB,OAAO,SAAS;AAClD,SAAQ,KAAK,qBAAqB,WAAW,YAAY,OAAO,GAAG,aAAa,SAAS,UAAU,IAAI,GAAG;CAE1G,MAAM,YAAY,GAAG,aAAa,KAAK,KAAK,SAAS,OAAO,IAAI,KAAK,OAAO,IAAI,GAAG,EAAE,QAAQ;AAC7F,SAAQ,KAAK,oBAAoB,UAAU,KAAK,UAAU,GAAG,GAAG,YAAY,GAAG,OAAO,GAAG,cAAc,IAAI,GAAG;AAC9G,SAAQ,KAAK,iBAAiB,IAAI,GAAG;AACrC,SAAQ,KAAK,mBAAmB,WAAW,GAAG;CAE9C,IAAI,OAAO,iBAAiB,OAAO,KAAK;AACxC,KAAI,QAAQ,SAAS,UAAU,WAC3B,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AACxC,WACK,OAAO,CACP,WAAW,QAAQ,KAAK,EAAE,CAAC,CAC3B,OAAM,MAAK;AACR,YAAQ,MAAM,EAAE;AAChB,YAAQ,KAAK,EAAE;KACjB;IACR;AACF,SAAO;UACF,OAAO;AACZ,MAAI,WAAW;AACX,WAAQ,MAAM,OAAO,cAAc,mBAAmB,YAAY,KAAK,KAAK,GAAG,UAAU,GAAG;AAC5F,eAAY;;AAEhB,QAAM"}
package/dist/node/cli.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { version } from "../package.mjs";
1
+ import { version } from "../sammi-next/package.mjs";
2
2
  import "./constants.mjs";
3
3
  import { BuildMode, buildExtension } from "./build.mjs";
4
4
  import { resolveBuildConfig } from "./config.mjs";
@@ -1,4 +1,4 @@
1
- import { version } from "../package.mjs";
1
+ import { version } from "../sammi-next/package.mjs";
2
2
  import path from "node:path";
3
3
  import colors from "picocolors";
4
4
  import { fileURLToPath } from "node:url";
@@ -1,7 +1,7 @@
1
+ import "../sammi-bridge-types/src/index.mjs";
1
2
  import { ExtensionConfig, SAMMINextExtension } from "./types.mjs";
2
3
  import "./global.mjs";
3
4
  import { ExtensionConfig as ExtensionConfig$1 } from "../shared/config-types.mjs";
4
- import "sammi-bridge-types";
5
5
 
6
6
  //#region src/runtime/index.d.ts
7
7
  interface initExtensionOptions {
@@ -1,5 +1,5 @@
1
+ import "../sammi-bridge-types/src/index.d.mts";
1
2
  import "./global.d.mts";
2
- import "sammi-bridge-types";
3
3
 
4
4
  //#region src/runtime/index.ts
5
5
  const PROXY_PREFIX = "[SAMMI-NEXT-PROXY]";
@@ -0,0 +1,218 @@
1
+ //#region ../sammi-bridge-types/src/SAMMICommands.d.ts
2
+ /** SAMMI Core Helper Functions
3
+ * You can call them with SAMMI.{helperfunction}
4
+ * Use promises if you want to get a reply back from SAMMI
5
+ * No promise example: SAMMI.setVariable(myVariable, 'some value', 'someButtonID')
6
+ * Promise example: SAMMI.getVariable(myVariable, 'someButtonID').then(reply=>console.log(reply))
7
+ */
8
+ declare class SAMMICommands {
9
+ /**
10
+ * Get a variable from SAMMI
11
+ * @param {string} name - name of the variable
12
+ * @param {string} buttonId - button ID for local variable, default = global variable
13
+ */
14
+ getVariable(name?: string, buttonId?: string): Promise<any>;
15
+ /**
16
+ * Set a variable in SAMMI
17
+ * @param {string} name - name of the variable
18
+ * @param {(string|number|object|array|null)} value - new value of the variable
19
+ * @param {string} buttonId - button ID for local variable, default = global variable
20
+ */
21
+ setVariable(name?: string, value?: (string | number | object | any[] | null), buttonId?: string, instanceId?: number): Promise<any>;
22
+ /**
23
+ * Send a popup message to SAMMI
24
+ * @param {string} msg - message to send
25
+ */
26
+ popUp(msg?: string): Promise<any>;
27
+ /**
28
+ * Send a yellow notification message to SAMMI
29
+ * @param {string} msg - message to send
30
+ */
31
+ alert(msg?: string): Promise<any>;
32
+ /**
33
+ * send extension command to SAMMI
34
+ * @param {string} name - name of the extension command
35
+ * @param {string} color - box color, accepts hex/dec colors (include # for hex), default 3355443
36
+ * @param {string} height - height of the box in pixels, 52 for regular or 80 for resizable box, default 52
37
+ * @param {Object} boxes
38
+ * - one object per box, key = boxVariable, value = array of box params
39
+ * - boxVariable = variable to save the box value under
40
+ * - boxName = name of the box shown in the user interface
41
+ * - boxType = type of the box, 0 = resizable, 2 = checkbox (true/false), 14 = regular box, 15 = variable box, 18 = select box, see extension guide for more
42
+ * - defaultValue = default value of the variable
43
+ * - (optional) sizeModifier = horizontal box size, 1 is normal
44
+ * - (optional) [] selectOptions = array of options for the user to select (when using Select box type)
45
+ * @param {[boxName: string, boxType: number, defaultValue: (string | number), sizeModifier: (number|undefined), selectOptions: Array|undefined]} boxes.boxVariable
46
+ * */
47
+ extCommand(name?: string, color?: string, height?: string, boxes?: {
48
+ boxVariable: [boxName: string, boxType: number, defaultValue: (string | number), sizeModifier: (number | undefined), selectOptions: any[] | undefined];
49
+ }, triggerButton?: boolean, hidden?: boolean): Promise<any>;
50
+ /**
51
+ * Close SAMMI Bridge connection to SAMMI Core.
52
+ */
53
+ close(): Promise<any>;
54
+ /**
55
+ * Get deck and button updates
56
+ * @param {boolean} enabled - enable or disable updates
57
+ */
58
+ stayInformed(enabled: boolean): Promise<any>;
59
+ /**
60
+ * Request an array of all decks
61
+ * - Replies with an array ["Deck1 Name","Unique ID",crc32,"Deck2 Name","Unique ID",crc32,...]
62
+ * - Use crc32 value to verify deck you saved localy is the same
63
+ */
64
+ getDeckList(): Promise<any>;
65
+ /**
66
+ * Request a deck params
67
+ * @param {string} id - Unique deck ID retrieved from getDeckList
68
+ * - Replies with an object containing a full deck
69
+ */
70
+ getDeck(id?: string): Promise<any>;
71
+ /**
72
+ * Get deck status
73
+ * - Replies with either 0 (deck is disabled) or 1 (deck is enabled)
74
+ * @param {string} id - Unique deck ID retrieved from getDeckList
75
+ */
76
+ getDeckStatus(deckID?: number): Promise<any>;
77
+ /**
78
+ * Change deck status
79
+ * @param {string} id - Unique deck ID retrieved from getDeckList
80
+ * @param {int} status - New deck status, 0 = disable, 1 = enable, 2 = toggle
81
+ */
82
+ changeDeckStatus(deckID?: number, status?: int): Promise<any>;
83
+ /**
84
+ * Retrieve an image in base64
85
+ * @param {string} fileName - image file name without the path (image.png)
86
+ * - Replies with an object containing the Base64 string of the image
87
+ */
88
+ getImage(fileName?: string): Promise<any>;
89
+ /**
90
+ * Retrieves CRC32 of a file
91
+ * @param {string} fileName - file name without the path (image.png)
92
+ */
93
+ getSum(fileName?: string): Promise<any>;
94
+ /**
95
+ * Retrieves all currently active buttons
96
+ * - Replies with an array of button param objects
97
+ */
98
+ getActiveButtons(): Promise<any>;
99
+ /**
100
+ * Retrieves params of all linked Twitch accounts
101
+ */
102
+ getTwitchList(): Promise<any>;
103
+ /**
104
+ * Sends a trigger
105
+ * @param {number} type - type of trigger
106
+ * - trigger types: 0 Twitch chat, 1 Twitch Sub, 2 Twitch Gift, 3 Twitch redeem
107
+ * 4 Twitch Raid, 5 Twitch Bits, 6 Twitch Follower, 7 Hotkey
108
+ * 8 Timer, 9 OBS Trigger, 10 SAMMI Bridge, 11 twitch moderation, 12 extension trigger
109
+ * @param {object} data - whatever data is required for the trigger, see manual
110
+ */
111
+ trigger(type?: number, data?: object): Promise<any>;
112
+ /**
113
+ * Sends a test trigger that will automatically include channel ID for from_channel_id pull value
114
+ * @param {number} type - type of trigger
115
+ * - trigger types: 0 Twitch chat, 1 Twitch Sub, 2 Twitch Gift, 3 Twitch redeem
116
+ * 4 Twitch Raid, 5 Twitch Bits, 6 Twitch Follower, 7 Hotkey
117
+ * 8 Timer, 9 OBS Trigger, 10 SAMMI Bridge, 11 twitch moderation, 12 extension trigger
118
+ * @param {object} data - whatever data is required for the trigger, see manual
119
+ */
120
+ testTrigger(type: number, data: object): Promise<any>;
121
+ /**
122
+ * Triggers a button
123
+ * @param {string} id - button ID to trigger
124
+ */
125
+ triggerButton(id?: string): Promise<any>;
126
+ /**
127
+ * Releases a button
128
+ * @param {string} id - button ID to release
129
+ */
130
+ releaseButton(id?: string): Promise<any>;
131
+ /**
132
+ * Modifies a button
133
+ * @param {string} id - button ID to modify
134
+ * @param {number|undefined} color - decimal button color (BGR)
135
+ * @param {string|undefined} text - button text
136
+ * @param {string|undefined} image - button image file name
137
+ * @param {number|undefined} border - border size, 0-7
138
+ * - leave parameters empty to reset button back to default values
139
+ */
140
+ modifyButton(id: string, color: number | undefined, text: string | undefined, image: string | undefined, border: number | undefined): Promise<any>;
141
+ /**
142
+ * Opens edit command screen in SAMMI for the selected button
143
+ * @param {string} deckId - deckId ID to edit
144
+ * @param {string} buttonId - button ID to edit
145
+ */
146
+ editButton(deckId?: string, buttonId?: string): Promise<any>;
147
+ /**
148
+ * Retrieves all currently modified buttons
149
+ * - object of button objects that are currently modified
150
+ */
151
+ getModifiedButtons(): Promise<any>;
152
+ /**
153
+ * Sends an extension trigger
154
+ * @param {string} trigger - name of the trigger
155
+ * @param {object} dats - object containing all trigger pull data
156
+ */
157
+ triggerExt(trigger?: string, data?: {}): Promise<any>;
158
+ /**
159
+ * Deletes a variable
160
+ * @param {string} name - name of the variable
161
+ * @param {string} buttonId - button ID for local variable, default = global variable
162
+ */
163
+ deleteVariable(name?: string, buttonId?: string): Promise<any>;
164
+ /**
165
+ * Inserts an array value
166
+ * @param {string} arrayName - name of the array
167
+ * @param {number} index - index to insert the new item at
168
+ * @param {string|number|object|array} value - item value
169
+ * @param {string} buttonId - button id, default is global
170
+ */
171
+ insertArray(arrayName?: string, index?: number, value?: string | number | object | any[], buttonId?: string): Promise<any>;
172
+ /**
173
+ * Deletes an array value at specified index
174
+ * @param {string} arrayName - name of the array
175
+ * @param {number} index - index of the item to delete
176
+ * @param {string} buttonId - button id, default is global
177
+ */
178
+ deleteArray(arrayName?: string, slot?: number, buttonId?: string): Promise<any>;
179
+ /**
180
+ * Saves a number/string into an ini file
181
+ * @param {string} fileName - name of the ini file
182
+ * @param {number} section - section name
183
+ * @param {string} key - key name
184
+ * @param {string|number} value - value to save
185
+ * @param {string} type - type of the value, text or number
186
+ */
187
+ saveIni(fileName?: string, section?: number, key?: string, value?: string | number, type?: string): Promise<any>;
188
+ /**
189
+ * Loads a number/string from an ini file
190
+ * @param {string} fileName - name of the ini file
191
+ * @param {number} section - section name
192
+ * @param {string} key - key name
193
+ * @param {string} type - type of the value, text or number
194
+ */
195
+ loadIni(fileName?: string, section?: number, key?: string, type?: string): Promise<any>;
196
+ /**
197
+ * Sends an HTTP request
198
+ * @param {string} url - url to send the request to
199
+ * @param {string} method - request method, GET, POST, PUT, DELETE
200
+ * @param {json} headers - stringified JSON object of headers (optional)
201
+ * @param {json} body - stringified request body (optional)
202
+ */
203
+ httpRequest(url?: string, method?: string, headers?: json, body?: json): Promise<any>;
204
+ /**
205
+ * Sends a notification (tray icon bubble) message to SAMMI
206
+ * @param {string} msg - message to show
207
+ */
208
+ notification(msg?: string): Promise<any>;
209
+ /**
210
+ * Opens a URL in the default browser from SAMMI
211
+ * @param {string} url - url to open
212
+ */
213
+ openURL(url?: string): Promise<any>;
214
+ generateMessage(): string;
215
+ }
216
+ //#endregion
217
+ export { SAMMICommands };
218
+ //# sourceMappingURL=SAMMICommands.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SAMMICommands.d.mts","names":["SAMMICommands","Promise","int","json","getVariable","name","buttonId","setVariable","value","instanceId","popUp","msg","alert","extCommand","color","height","boxVariable","boxName","boxType","defaultValue","sizeModifier","selectOptions","boxes","triggerButton","hidden","close","stayInformed","enabled","getDeckList","getDeck","id","getDeckStatus","deckID","changeDeckStatus","status","getImage","fileName","getSum","getActiveButtons","getTwitchList","trigger","type","data","testTrigger","releaseButton","modifyButton","text","image","border","editButton","deckId","getModifiedButtons","triggerExt","deleteVariable","insertArray","arrayName","index","deleteArray","slot","saveIni","section","key","loadIni","httpRequest","url","method","headers","body","notification","openURL","generateMessage"],"sources":["../../../../sammi-bridge-types/src/SAMMICommands.d.ts"],"mappings":";;AAMA;;;;;cAAaA,aAAAA;EAuBYC;;;;;EAjBrBG,WAAAA,CAAYC,IAAAA,WAAeC,QAAAA,YAAoBL,OAAAA;EA8DfA;;;;;;EAvDhCM,WAAAA,CAAYF,IAAAA,WAAeG,KAAAA,8CAAmDF,QAAAA,WAAmBG,UAAAA,YAAsBR,OAAAA;EA0FhFA;;;;EArFvCS,KAAAA,CAAMC,GAAAA,YAAeV,OAAAA;EAwH2BA;;;;EAnHhDW,KAAAA,CAAMD,GAAAA,YAAeV,OAAAA;EAmJ8CA;;;;;;;;;;;;;;;EAnInEY,UAAAA,CAAWR,IAAAA,WAAeS,KAAAA,WAAgBC,MAAAA,WAAiBO,KAAAA;IACvDN,WAAAA,GAAcC,OAAAA,UAAiBC,OAAAA,UAAiBC,YAAAA,qBAAiCC,YAAAA,wBAAoCC,aAAAA;EAAAA,GACtHE,aAAAA,YAAyBC,MAAAA,aAAmBvB,OAAAA;EA5BkDQ;;;EAgCjGgB,KAAAA,CAAAA,GAASxB,OAAAA;EA3BYA;;;;EAgCrByB,YAAAA,CAAaC,OAAAA,YAAm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AAYC,SAAAA,WAAoBC,KAAAA,WAAgBhD,KAAAA,qCAA0CF,QAAAA,YAAoBL,OAAAA;EA0CvFA;;;;;;EAnCvBwD,WAAAA,CAAYF,SAAAA,WAAoBG,IAAAA,WAAepD,QAAAA,YAAoBL,OAAAA;;;;;;;;;EASnE0D,OAAAA,CAAQvB,QAAAA,WAAmBwB,OAAAA,WAAkBC,GAAAA,WAAcrD,KAAAA,oBAAyBiC,IAAAA,YAAgBxC,OAAAA;;;;;;;;EAQpG6D,OAAAA,CAAQ1B,QAAAA,WAAmBwB,OAAAA,WAAkBC,GAAAA,WAAcpB,IAAAA,YAAgBxC,OAAAA;;;;;;;;EAQ3E8D,WAAAA,CAAYC,GAAAA,WAAcC,MAAAA,WAAiBC,OAAAA,GAAU/D,IAAAA,EAAMgE,IAAAA,GAAOhE,IAAAA,GAAOF,OAAAA;;;;;EAKzEmE,YAAAA,CAAazD,GAAAA,YAAeV,OAAAA;;;;;EAK5BoE,OAAAA,CAAQL,GAAAA,YAAe/D,OAAAA;EACvBqE,eAAAA,CAAAA;AAAAA"}
@@ -0,0 +1,53 @@
1
+ import { SAMMIWebSocket } from "../../sammi-websocket-types/dist/SAMMIWebSocket.mjs";
2
+ import { SAMMICommands as SAMMICommands$1 } from "./SAMMICommands.mjs";
3
+
4
+ //#region ../sammi-bridge-types/src/index.d.ts
5
+ declare class SAMMICommands extends SAMMICommands$1 {
6
+ /**
7
+ * send extension command to SAMMI
8
+ * @param name - name of the extension command
9
+ * @param color - box color, accepts hex/dec colors (include # for hex), default 3355443
10
+ * @param height - height of the box in pixels, 52 for regular or 80 for resizable box, default 52
11
+ * @param boxes
12
+ * - one object per box, key = boxVariable, value = array of box params
13
+ * - boxVariable = variable to save the box value under
14
+ * - boxName = name of the box shown in the user interface
15
+ * - boxType = type of the box, 0 = resizable, 2 = checkbox (true/false), 14 = regular box, 15 = variable box, 18 = select box, see extension guide for more
16
+ * - defaultValue = default value of the variable
17
+ * - (optional) sizeModifier = horizontal box size, 1 is normal
18
+ * - (optional) [] selectOptions = array of options for the user to select (when using Select box type)
19
+ * @param boxes.boxVariable
20
+ * */
21
+ extCommand(name?: string, color?: string | number, height?: string | number, boxes?: {
22
+ [boxVariable: string]: [boxName: string, boxType: number, defaultValue: (string | number), sizeModifier: (number | undefined), selectOptions: any[] | undefined];
23
+ }, triggerButton?: boolean, hidden?: boolean): Promise<any>;
24
+ }
25
+ declare global {
26
+ /**
27
+ * Bridge provides native helper functions to make your life easier, without the need to use SAMMI Websocket library directly.
28
+ *
29
+ * You can call all helper functions with SAMMI.method(arguments).
30
+ *
31
+ * To use promises, you can call them with SAMMI.method(arguments).then(response=>console.log(response)).
32
+ */
33
+ const SAMMI: SAMMICommands;
34
+ /**
35
+ * When a user triggers an extension command, SAMMI will send the data to Bridge (unless the `sendAsExtensionTrigger` parameter is set to `true`).
36
+ *
37
+ * You can listen to this data by using `sammiclient.on('extension name', (payload) => {})`.
38
+ *
39
+ * You can also use `sammiclient.addListener('extension name', functionToExecute)`.
40
+ *
41
+ * For example, let's say your extension command is called Lucky Wheel:
42
+ * @example
43
+ * sammiclient.on('Lucky Wheel', (payload) => {
44
+ * console.log(payload)
45
+ * // DO SOMETHING WITH THE EXTENSION PAYLOAD
46
+ * // FromButton - button ID the extension command was triggered in
47
+ * // instanceId - instance ID of a button the extension command was triggered in
48
+ * const { FromButton, instanceId } = payload.Data
49
+ * });
50
+ */
51
+ const sammiclient: SAMMIWebSocket;
52
+ }
53
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":["SAMMIWebSocket","SAMMICommands","Commands","Promise","extCommand","name","color","height","boxVariable","boxName","boxType","defaultValue","sizeModifier","selectOptions","boxes","triggerButton","hidden","_0","global","SAMMI","sammiclient","sideEffect"],"sources":["../../../../sammi-bridge-types/src/index.d.ts"],"mappings":";;;;cAGcC,aAAAA,SAAsBC,eAAAA;EAAtBD;;;;;;;;;;;;;;;EAgBVG,UAAAA,CAAWC,IAAAA,WAAeC,KAAAA,oBAAyBC,MAAAA,oBAA0BO,KAAAA;IAAAA,CACxEN,WAAAA,YAAuBC,OAAAA,UAAiBC,OAAAA,UAAiBC,YAAAA,qBAAiCC,YAAAA,wBAAoCC,aAAAA;EAAAA,GAChIE,aAAAA,YAAyBC,MAAAA,aAAmBb,OAAAA;AAAAA;AAAAA,QAG3Ce,MAAAA;EAHkDD;;;;;;;EAAAA,MAWhDE,KAAAA,EAAOlB,aAAAA;EAmBoB;;;;;;;;;;;;;;;;;EAAA,MAA3BmB,WAAAA,EAAapB,cAAAA;AAAAA"}
@@ -0,0 +1,6 @@
1
+ //#region package.json
2
+ var version = "1.2.2";
3
+
4
+ //#endregion
5
+ export { version };
6
+ //# sourceMappingURL=package.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.mjs","names":[],"sources":["../../package.json"],"sourcesContent":[""],"mappings":""}
@@ -0,0 +1,18 @@
1
+ import { Socket } from "./Socket.mjs";
2
+
3
+ //#region ../sammi-websocket-types/dist/SAMMIWebSocket.d.ts
4
+ declare class SAMMIWebSocket extends Socket {
5
+ /**
6
+ * Generic Socket request method. Returns a promise.
7
+ * Generates a messageId internally and will override any passed in the args.
8
+ * Note that the requestType here is pre-marshaling and currently must match exactly what the websocket plugin is expecting.
9
+ *
10
+ * @param {String} requestType sammi-websocket plugin expected request type.
11
+ * @param {Object} [arg={}] request arguments.
12
+ * @return {Promise} Promise, passes the plugin response object.
13
+ */
14
+ send(requestType: string, args?: {}): Promise<any>;
15
+ }
16
+ //#endregion
17
+ export { SAMMIWebSocket };
18
+ //# sourceMappingURL=SAMMIWebSocket.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SAMMIWebSocket.d.mts","names":["SAMMIWebSocket","default","Promise","Socket","send","requestType","args"],"sources":["../../../../sammi-websocket-types/dist/SAMMIWebSocket.d.ts"],"mappings":";;;cACcA,cAAAA,SAAuBG,MAAAA;;AADd;;;;;;;;EAWnBC,IAAAA,CAAKC,WAAAA,UAAqBC,IAAAA,QAAYJ,OAAAA;AAAAA"}
@@ -0,0 +1,38 @@
1
+ import EventEmitter from "node:events";
2
+
3
+ //#region ../sammi-websocket-types/dist/Socket.d.ts
4
+ declare class Socket extends EventEmitter<any> {
5
+ constructor();
6
+ _connected: boolean;
7
+ _socket: any;
8
+ connect(args: any): Promise<any>;
9
+ /**
10
+ * Opens a WebSocket connection to an sammi-websocket server, but does not attempt any authentication.
11
+ *
12
+ * @param {String} address url without ws:// or wss:// prefix.
13
+ * @param {Boolean} secure whether to us ws:// or wss://
14
+ * @returns {Promise}
15
+ * @private
16
+ * @return {Promise} on attempted creation of WebSocket connection.
17
+ */
18
+ private _connect;
19
+ /**
20
+ * Authenticates to an sammi-websocket server. Must already have an active connection before calling this method.
21
+ *
22
+ * @param {String} [name=''] name of the client.
23
+ * @param {String} [password=''] authentication string.
24
+ * @private
25
+ * @return {Promise} on resolution of authentication call.
26
+ */
27
+ private _authenticate;
28
+ /**
29
+ * Close and disconnect the WebSocket connection.
30
+ *
31
+ * @function
32
+ * @category request
33
+ */
34
+ disconnect(): void;
35
+ }
36
+ //#endregion
37
+ export { Socket };
38
+ //# sourceMappingURL=Socket.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Socket.d.mts","names":["Socket","default","Promise","EventEmitter","constructor","_connected","_socket","connect","args","_connect","_authenticate","disconnect"],"sources":["../../../../sammi-websocket-types/dist/Socket.d.ts"],"mappings":";;;cACcA,MAAAA,SAAeG,YAAAA;EACzBC,WAAAA,CAAAA;EACAC,UAAAA;EACAC,OAAAA;EACAC,OAAAA,CAAQC,IAAAA,QAAYN,OAAAA;EAJiB;;;;;;;;;EAAA,QAc7BO,QAAAA;EAgBRE;;;;;;;;EAAAA,QAPQD,aAAAA;;;;;;;EAORC,UAAAA,CAAAA;AAAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sammi-next",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "author": {
5
5
  "name": "Benjas333",
6
6
  "url": "https://github.com/Benjas333"
package/dist/package.mjs DELETED
@@ -1,6 +0,0 @@
1
- //#region package.json
2
- var version = "1.2.0";
3
-
4
- //#endregion
5
- export { version };
6
- //# sourceMappingURL=package.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"package.mjs","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}