@jchat/addon-sdk 1.0.0-alpha.4 → 1.0.0-alpha.7

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @jchat/addon-sdk
2
2
 
3
+ ## 1.0.0-alpha.7
4
+
5
+ ### Minor Changes
6
+
7
+ - 7cef24c: - Enhance addon package diagnostics with semantic version compatibility validation for JChat host and Addon SDK
8
+ - Add support for local workspace development, sandbox test harnesses, and distribution packaging
9
+ - Improve runtime license verification and multi-environment path resolution
10
+ - Update addon generator templates with 20-language i18n support, standard scripts, and type definitions
11
+
12
+ ## 1.0.0-alpha.6
13
+
14
+ ## 1.0.0-alpha.5
15
+
16
+ ### Minor Changes
17
+
18
+ - 9755c28: Export curated UI components, types, and Tailwind styles from `@jchat/addon-sdk/ui` (`@jchat/addon-sdk/ui/tailwind.css`) for sandbox and third-party addon developers.
19
+
20
+ ### Patch Changes
21
+
22
+ - ad4b00c: Add `OWNER_SETTINGS` (`"owner-settings"`) and `ADDON_SETTINGS` (`"addon-settings"`) to `MOUNT_POINTS` constant and strictly type `MountPoint` union to official mount points. Remove legacy `ConfigSchemaField` and `configSchema` from `AddonManifest` in favor of mount-point-driven settings.
23
+ - ada430f: Formatted type declarations in the Addon SDK to align with project style guidelines.
24
+
3
25
  ## 1.0.0-alpha.4
4
26
 
5
27
  ### Patch Changes
package/LICENSE CHANGED
@@ -1,201 +1,23 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
1
+ CUSTOM COMMERCIAL END USER LICENSE AGREEMENT (EULA)
4
2
 
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
3
+ Copyright (c) 2026 JChat Project. All rights reserved.
6
4
 
7
- 1. Definitions.
5
+ 1. DEFINITIONS
6
+ "Software" refers to this npm package and its source code.
7
+ "Authorized Application" refers strictly to the application known as "JChat".
8
8
 
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
9
+ 2. LICENSE GRANT
10
+ Subject to the terms of this Agreement and payment of any applicable fees, the
11
+ Licensor grants you a non-exclusive, non-transferable, revocable license to
12
+ download, install, and use the Software.
11
13
 
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
+ 3. RESTRICTIONS ON USE
15
+ You are expressly prohibited from using this Software, in whole or in part,
16
+ in any application, product, or service other than the Authorized Application (JChat).
17
+ Any deployment, linking, execution, or inclusion of this Software into an
18
+ application that is not JChat constitutes a breach of this contract and
19
+ an infringement of copyright law.
14
20
 
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright 2026 Md. Jabarullah
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.
21
+ 4. NO REDISTRIBUTION
22
+ You may not sub-license, rent, lease, or publicly redistribute this Software
23
+ to any third party without explicit written consent from the Licensor.
package/dist/cli.d.mts ADDED
@@ -0,0 +1,36 @@
1
+ import { t as AddonManifest } from "./contracts.mjs";
2
+ import { InlineConfig } from "vite";
3
+ //#region src/cli.d.ts
4
+ /** Options for resolving addon build configuration. */
5
+ interface AddonCliOptions {
6
+ rootDir?: string;
7
+ command?: "build" | "dev" | "help";
8
+ mode?: "production" | "development";
9
+ watch?: boolean;
10
+ zip?: boolean;
11
+ signingPrivateKey?: string;
12
+ }
13
+ /**
14
+ * Automatically loads the addon manifest from `src/manifest.ts`, `src/manifest.js`, or
15
+ * `src/manifest.json`.
16
+ *
17
+ * @param rootDir - Root directory of the addon workspace.
18
+ * @returns Parsed {@link AddonManifest}.
19
+ */
20
+ declare function loadAddonManifest(rootDir: string): Promise<AddonManifest>;
21
+ /**
22
+ * Resolves the full Vite configuration for building a JChat addon, merging user custom configs if
23
+ * present.
24
+ *
25
+ * @param options - CLI build options.
26
+ * @returns Fully merged {@link InlineConfig} for Vite.
27
+ */
28
+ declare function resolveAddonBuildConfig(options?: AddonCliOptions): Promise<InlineConfig>;
29
+ /**
30
+ * Main CLI handler for `jchat-addon`.
31
+ *
32
+ * @param args - CLI arguments (defaults to `process.argv.slice(2)`).
33
+ */
34
+ declare function runAddonCli(args?: string[]): Promise<void>;
35
+ //#endregion
36
+ export { AddonCliOptions, loadAddonManifest, resolveAddonBuildConfig, runAddonCli };
package/dist/cli.mjs ADDED
@@ -0,0 +1,135 @@
1
+ import { jchatAddon } from "./vite.mjs";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import tailwindcss from "@tailwindcss/vite";
5
+ import { pathToFileURL } from "node:url";
6
+ import { build, loadConfigFromFile, mergeConfig } from "vite";
7
+ //#region src/cli.ts
8
+ function hasPlugin(plugins, name) {
9
+ if (!plugins) return false;
10
+ if (Array.isArray(plugins)) return plugins.some((p) => hasPlugin(p, name));
11
+ if (typeof plugins === "object" && plugins !== null && "name" in plugins && plugins.name === name) return true;
12
+ return false;
13
+ }
14
+ /**
15
+ * Automatically loads the addon manifest from `src/manifest.ts`, `src/manifest.js`, or
16
+ * `src/manifest.json`.
17
+ *
18
+ * @param rootDir - Root directory of the addon workspace.
19
+ * @returns Parsed {@link AddonManifest}.
20
+ */
21
+ async function loadAddonManifest(rootDir) {
22
+ const existingPath = [
23
+ path.resolve(rootDir, "src/manifest.ts"),
24
+ path.resolve(rootDir, "src/manifest.js"),
25
+ path.resolve(rootDir, "src/manifest.mjs"),
26
+ path.resolve(rootDir, "src/manifest.json")
27
+ ].find((filePath) => fs.existsSync(filePath));
28
+ if (existingPath) {
29
+ if (existingPath.endsWith(".json")) {
30
+ const text = fs.readFileSync(existingPath, "utf-8");
31
+ return JSON.parse(text);
32
+ }
33
+ const imported = await import(pathToFileURL(existingPath).href);
34
+ return imported.default || imported.manifest;
35
+ }
36
+ throw new Error(`Could not find addon manifest in ${rootDir}/src (expected manifest.ts or manifest.json)`);
37
+ }
38
+ /**
39
+ * Resolves the full Vite configuration for building a JChat addon, merging user custom configs if
40
+ * present.
41
+ *
42
+ * @param options - CLI build options.
43
+ * @returns Fully merged {@link InlineConfig} for Vite.
44
+ */
45
+ async function resolveAddonBuildConfig(options = {}) {
46
+ const rootDir = path.resolve(options.rootDir || process.cwd());
47
+ const isDev = options.command === "dev" || options.mode === "development";
48
+ const mode = options.mode || (isDev ? "development" : "production");
49
+ const watch = options.watch ?? options.command === "dev";
50
+ const manifest = await loadAddonManifest(rootDir);
51
+ const baseConfig = {
52
+ root: rootDir,
53
+ configFile: false,
54
+ mode,
55
+ plugins: [tailwindcss(), jchatAddon({
56
+ manifest,
57
+ development: isDev,
58
+ zip: options.zip,
59
+ signingPrivateKey: options.signingPrivateKey
60
+ })],
61
+ build: { watch: watch ? {} : null }
62
+ };
63
+ const customConfigPath = [
64
+ "vite.config.ts",
65
+ "vite.config.js",
66
+ "vite.config.mjs",
67
+ "vite.config.cjs"
68
+ ].map((file) => path.resolve(rootDir, file)).find((file) => fs.existsSync(file));
69
+ if (customConfigPath) {
70
+ const loaded = await loadConfigFromFile({
71
+ command: "build",
72
+ mode
73
+ }, customConfigPath, rootDir);
74
+ if (loaded?.config) {
75
+ if (hasPlugin(loaded.config.plugins, "jchat-addon")) return mergeConfig(loaded.config, {
76
+ root: rootDir,
77
+ mode,
78
+ build: { watch: watch ? {} : null }
79
+ });
80
+ return mergeConfig(baseConfig, loaded.config);
81
+ }
82
+ }
83
+ return baseConfig;
84
+ }
85
+ /**
86
+ * Main CLI handler for `jchat-addon`.
87
+ *
88
+ * @param args - CLI arguments (defaults to `process.argv.slice(2)`).
89
+ */
90
+ async function runAddonCli(args = process.argv.slice(2)) {
91
+ let command = "build";
92
+ let watch = false;
93
+ let mode;
94
+ let zip;
95
+ for (const arg of args) if (arg === "dev") {
96
+ command = "dev";
97
+ watch = true;
98
+ mode = "development";
99
+ } else if (arg === "build") command = "build";
100
+ else if (arg === "--watch" || arg === "-w") watch = true;
101
+ else if (arg === "--dev") mode = "development";
102
+ else if (arg === "--prod" || arg === "--production") mode = "production";
103
+ else if (arg === "--no-zip") zip = false;
104
+ else if (arg === "--zip") zip = true;
105
+ else if (arg === "--help" || arg === "-h") command = "help";
106
+ if (command === "help") {
107
+ console.log(`
108
+ JChat Addon CLI (jchat-addon)
109
+
110
+ Usage:
111
+ jchat-addon build Build the addon for production
112
+ jchat-addon dev Build and watch the addon in development mode
113
+
114
+ Options:
115
+ --watch, -w Watch files for changes
116
+ --dev Run in development mode
117
+ --prod Run in production mode
118
+ --no-zip Do not package the build into a .zip archive
119
+ --help, -h Show this help message
120
+ `);
121
+ return;
122
+ }
123
+ await build(await resolveAddonBuildConfig({
124
+ command,
125
+ mode,
126
+ watch,
127
+ zip
128
+ }));
129
+ }
130
+ if (import.meta.main) runAddonCli().catch((error) => {
131
+ console.error("❌ Addon build failed:", error);
132
+ process.exit(1);
133
+ });
134
+ //#endregion
135
+ export { loadAddonManifest, resolveAddonBuildConfig, runAddonCli };
@@ -1,23 +1,4 @@
1
1
  //#region src/contracts.d.ts
2
- type AddonPermission = string;
3
- /**
4
- * Defines a single configuration field for an addon's settings panel. These are shown to site
5
- * admins in the Jchat dashboard.
6
- */
7
- interface ConfigSchemaField {
8
- /** Unique key used to store and retrieve the value in `getConfig` */
9
- key: string;
10
- /** Data type for validation and UI rendering */
11
- type: "string" | "number" | "boolean";
12
- /** Human-readable label shown in the settings UI */
13
- label: string;
14
- /** If true, the admin must provide a value before saving */
15
- required?: boolean;
16
- /** Whether the value is sensitive (encrypted at rest and masked in the UI) */
17
- secret?: boolean;
18
- /** Default value pre-filled in the settings form for new installations */
19
- default?: string | number | boolean;
20
- }
21
2
  /** Definition of a custom permission introduced by an addon. */
22
3
  interface AddonPermissionDefinition {
23
4
  /** Permission identifier (recommended: `addon.<id>.<action>`) */
@@ -53,8 +34,14 @@ declare const MOUNT_POINTS: {
53
34
  readonly CHAT_PLUS_MENU: "chat-plus-menu";
54
35
  /** Custom tab in the emoji/gif selection panel */
55
36
  readonly EMOJI_PICKER_GIF_TAB: "emoji-picker-gif-tab";
37
+ /** Custom tab in the emoji/sticker selection panel */
38
+ readonly EMOJI_PICKER_STICKER_TAB: "emoji-picker-sticker-tab";
56
39
  /** Full-screen or modal dialog specifically for TubeScan */
57
40
  readonly TUBESCAN_DIALOG: "tubescan-dialog";
41
+ /** Dedicated settings panel rendered in the Owner Dashboard */
42
+ readonly OWNER_SETTINGS: "owner-settings";
43
+ /** Dedicated settings panel rendered in the Site Admin Dashboard */
44
+ readonly ADDON_SETTINGS: "addon-settings";
58
45
  };
59
46
  /** Union type of all valid addon mount points. */
60
47
  type MountPoint = (typeof MOUNT_POINTS)[keyof typeof MOUNT_POINTS];
@@ -77,6 +64,13 @@ interface AddonManifest {
77
64
  homepage?: string;
78
65
  /** SPDX license identifier (e.g. `MIT`) */
79
66
  license?: string;
67
+ /**
68
+ * Supported language codes (e.g. ["ar", "de", "en", "es", "fr", "hi", "kn", "ml", "ta", "te",
69
+ * "ur"])
70
+ */
71
+ locales?: string[];
72
+ /** Default fallback language code (e.g. "en") */
73
+ defaultLocale?: string;
80
74
  /** Host and SDK versions this directly executed plugin was built and tested against */
81
75
  compatibility: {
82
76
  /** Supported JChat versions as a semantic-version range, for example `^1.0.0` */
@@ -118,13 +112,11 @@ interface AddonManifest {
118
112
  * The minimum permission required to see or use this addon. If provided, the host gates
119
113
  * visibility in the UI and access to all server routes.
120
114
  */
121
- accessPermission?: AddonPermission;
115
+ accessPermission?: string;
122
116
  /** Full list of all permissions used by this addon for informational purposes */
123
- permissions?: AddonPermission[];
117
+ permissions?: string[];
124
118
  /** Custom permissions that should be registered with the host application on installation */
125
119
  permissionDefinitions?: AddonPermissionDefinition[];
126
- /** Settings form structure shown to site admins. Values are stored encrypted per site */
127
- configSchema?: ConfigSchemaField[];
128
120
  }
129
121
  //#endregion
130
- export { MOUNT_POINTS as a, ConfigSchemaField as i, AddonPermission as n, MountPoint as o, AddonPermissionDefinition as r, AddonManifest as t };
122
+ export { MountPoint as i, AddonPermissionDefinition as n, MOUNT_POINTS as r, AddonManifest as t };
@@ -37,7 +37,7 @@ interface AddonPackageDiagnosticOptions {
37
37
  * current major version.
38
38
  *
39
39
  * @example
40
- * ```ts
40
+ * ;```ts
41
41
  * createCompatibleMajorRange("1.4.2") // returns ">=1.4.2 <2.0.0"
42
42
  * ```
43
43
  *
@@ -6,7 +6,7 @@ import * as path$1 from "node:path";
6
6
  * current major version.
7
7
  *
8
8
  * @example
9
- * ```ts
9
+ * ;```ts
10
10
  * createCompatibleMajorRange("1.4.2") // returns ">=1.4.2 <2.0.0"
11
11
  * ```
12
12
  *