@aelionsdk/vite-plugin 0.1.0-beta.1 → 1.0.0-rc.1

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/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # `@aelionsdk/vite-plugin`
2
2
 
3
- Official Vite integration for AelionSDK's module Worker and AudioWorklet entry files.
3
+ Official Vite integration plus Webpack/Rspack and explicit CDN helpers for AelionSDK's module
4
+ Worker and AudioWorklet entry files.
4
5
 
5
6
  ## Install
6
7
 
@@ -33,6 +34,28 @@ aelion({ audioWorklets: true, exportWorker: true, rendererWorker: true });
33
34
 
34
35
  All flags default to `true`. A disabled asset group must not be used by application code.
35
36
 
37
+ ## Webpack and Rspack
38
+
39
+ ```ts
40
+ import { AelionWebpackPlugin, aelionRuntimeAssetUrls } from '@aelionsdk/vite-plugin';
41
+
42
+ // webpack.config.ts / rspack.config.ts
43
+ export default {
44
+ plugins: [new AelionWebpackPlugin()],
45
+ };
46
+
47
+ // Client-only application module
48
+ const runtimeAssets = aelionRuntimeAssetUrls('/');
49
+ ```
50
+
51
+ The adapter emits stable `aelion/{audio,renderer-worker,export}` paths and works against the
52
+ Webpack 5-compatible hooks exposed by Rspack. Pass `runtimeAssets` to `Aelion.createSession()`.
53
+
54
+ For a custom build or CDN copy step, use `loadAelionRuntimeAssets(outputDirectory)`. For an
55
+ already-deployed versioned CDN directory, use
56
+ `aelionRuntimeAssetUrls('https://cdn.example/sdk/0.1.0/')`; keep application modules and all four
57
+ runtime entries on the same SDK version.
58
+
36
59
  Production pages should use HTTPS. For the SharedArrayBuffer audio path, also return `Cross-Origin-Opener-Policy: same-origin` and `Cross-Origin-Embedder-Policy: require-corp`. CSP must allow same-origin `worker-src` and `script-src`.
37
60
 
38
- This package is part of [AelionSDK](https://github.com/FoyonaCZY/AelionSDK). The `0.1.0-beta.1` API may change before the first stable release.
61
+ This package is part of [AelionSDK](https://github.com/FoyonaCZY/AelionSDK). The `1.0.0-rc.1` API may change before the first stable release.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { Plugin } from 'vite';
2
+ export * from './runtime-assets.js';
2
3
  /** Options for the official Aelion Vite integration. */
3
4
  export interface AelionVitePluginOptions {
4
5
  /** Emit and serve both `@aelionsdk/audio` AudioWorklet entries. Defaults to true. */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAiBnC,wDAAwD;AACxD,MAAM,WAAW,uBAAuB;IACtC,qFAAqF;IACrF,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,uFAAuF;IACvF,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,2EAA2E;IAC3E,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AA6CD;;;GAGG;AACH,wBAAgB,MAAM,CAAC,OAAO,GAAE,uBAA4B,GAAG,MAAM,CAmGpE;AAED,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,cAAc,qBAAqB,CAAC;AAiBpC,wDAAwD;AACxD,MAAM,WAAW,uBAAuB;IACtC,qFAAqF;IACrF,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,uFAAuF;IACvF,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,2EAA2E;IAC3E,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AA6CD;;;GAGG;AACH,wBAAgB,MAAM,CAAC,OAAO,GAAE,uBAA4B,GAAG,MAAM,CAmGpE;AAED,eAAe,MAAM,CAAC"}
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { readFile } from 'node:fs/promises';
2
2
  import { dirname, resolve } from 'node:path';
3
3
  import { fileURLToPath } from 'node:url';
4
+ export * from './runtime-assets.js';
4
5
  const virtualPrefix = '\0@aelionsdk/vite-plugin:runtime-asset:';
5
6
  const publicPrefix = '/@aelionsdk/vite-plugin/runtime-assets';
6
7
  function normalizedModuleId(id) {
@@ -0,0 +1,58 @@
1
+ export interface AelionRuntimeAssetUrls {
2
+ readonly rendererWorker: string;
3
+ readonly exportWorker: string;
4
+ readonly sharedAudioWorklet: string;
5
+ readonly transferableAudioWorklet: string;
6
+ }
7
+ export interface AelionRuntimeAssetFile {
8
+ readonly key: keyof AelionRuntimeAssetUrls;
9
+ readonly outputPath: string;
10
+ readonly bytes: Uint8Array;
11
+ }
12
+ export interface AelionWebpackPluginOptions {
13
+ /** Emitted directory inside the bundler output. Defaults to `aelion`. */
14
+ readonly outputDirectory?: string;
15
+ }
16
+ interface CompilationLike {
17
+ readonly hooks: {
18
+ readonly processAssets: {
19
+ tapPromise(options: {
20
+ readonly name: string;
21
+ readonly stage: number;
22
+ }, callback: () => Promise<void>): void;
23
+ };
24
+ };
25
+ emitAsset(name: string, source: unknown): void;
26
+ }
27
+ interface CompilerLike {
28
+ readonly webpack: {
29
+ readonly Compilation: {
30
+ readonly PROCESS_ASSETS_STAGE_ADDITIONAL: number;
31
+ };
32
+ readonly sources: {
33
+ readonly RawSource: new (bytes: Uint8Array) => unknown;
34
+ };
35
+ };
36
+ readonly hooks: {
37
+ readonly thisCompilation: {
38
+ tap(name: string, callback: (compilation: CompilationLike) => void): void;
39
+ };
40
+ };
41
+ }
42
+ /** Explicit URLs for ESM/CDN/Next.js clients that serve the four runtime entries themselves. */
43
+ export declare function aelionRuntimeAssetUrls(publicBase?: string, outputDirectory?: string): AelionRuntimeAssetUrls;
44
+ /** Reads the built package entries for custom copy pipelines and non-Webpack bundlers. */
45
+ export declare function loadAelionRuntimeAssets(outputDirectory?: string): Promise<readonly AelionRuntimeAssetFile[]>;
46
+ /**
47
+ * Webpack 5/Rspack adapter. It emits the same stable asset layout used by
48
+ * `AelionSessionOptions.runtimeAssets`; applications pass `runtimeAssets()`
49
+ * from a client-only module.
50
+ */
51
+ export declare class AelionWebpackPlugin {
52
+ #private;
53
+ constructor(options?: AelionWebpackPluginOptions);
54
+ runtimeAssets(publicBase?: string): AelionRuntimeAssetUrls;
55
+ apply(compiler: CompilerLike): void;
56
+ }
57
+ export {};
58
+ //# sourceMappingURL=runtime-assets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-assets.d.ts","sourceRoot":"","sources":["../src/runtime-assets.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,wBAAwB,EAAE,MAAM,CAAC;CAC3C;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,GAAG,EAAE,MAAM,sBAAsB,CAAC;IAC3C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;CAC5B;AAED,MAAM,WAAW,0BAA0B;IACzC,yEAAyE;IACzE,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;CACnC;AAED,UAAU,eAAe;IACvB,QAAQ,CAAC,KAAK,EAAE;QACd,QAAQ,CAAC,aAAa,EAAE;YACtB,UAAU,CACR,OAAO,EAAE;gBAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;aAAE,EAC1D,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAC5B,IAAI,CAAC;SACT,CAAC;KACH,CAAC;IACF,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;CAChD;AAED,UAAU,YAAY;IACpB,QAAQ,CAAC,OAAO,EAAE;QAChB,QAAQ,CAAC,WAAW,EAAE;YAAE,QAAQ,CAAC,+BAA+B,EAAE,MAAM,CAAA;SAAE,CAAC;QAC3E,QAAQ,CAAC,OAAO,EAAE;YAChB,QAAQ,CAAC,SAAS,EAAE,KAAK,KAAK,EAAE,UAAU,KAAK,OAAO,CAAC;SACxD,CAAC;KACH,CAAC;IACF,QAAQ,CAAC,KAAK,EAAE;QACd,QAAQ,CAAC,eAAe,EAAE;YACxB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,WAAW,EAAE,eAAe,KAAK,IAAI,GAAG,IAAI,CAAC;SAC3E,CAAC;KACH,CAAC;CACH;AA+CD,gGAAgG;AAChG,wBAAgB,sBAAsB,CACpC,UAAU,SAAa,EACvB,eAAe,SAAW,GACzB,sBAAsB,CAOxB;AAED,0FAA0F;AAC1F,wBAAsB,uBAAuB,CAC3C,eAAe,SAAW,GACzB,OAAO,CAAC,SAAS,sBAAsB,EAAE,CAAC,CAa5C;AAED;;;;GAIG;AACH,qBAAa,mBAAmB;;gBAGX,OAAO,GAAE,0BAA+B;IAIpD,aAAa,CAAC,UAAU,SAAM,GAAG,sBAAsB;IAIvD,KAAK,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI;CAmB3C"}
@@ -0,0 +1,89 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { dirname, posix, resolve } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ function packageDistDirectory(packageName) {
5
+ return dirname(fileURLToPath(import.meta.resolve(packageName)));
6
+ }
7
+ function specifications(outputDirectory) {
8
+ return [
9
+ {
10
+ key: 'sharedAudioWorklet',
11
+ packageName: '@aelionsdk/audio',
12
+ fileName: 'pcm-player.worklet.js',
13
+ directory: posix.join(outputDirectory, 'audio'),
14
+ },
15
+ {
16
+ key: 'transferableAudioWorklet',
17
+ packageName: '@aelionsdk/audio',
18
+ fileName: 'pcm-message-player.worklet.js',
19
+ directory: posix.join(outputDirectory, 'audio'),
20
+ },
21
+ {
22
+ key: 'rendererWorker',
23
+ packageName: '@aelionsdk/renderer-worker',
24
+ fileName: 'webgl2-worker.js',
25
+ directory: posix.join(outputDirectory, 'renderer-worker'),
26
+ },
27
+ {
28
+ key: 'exportWorker',
29
+ packageName: '@aelionsdk/export',
30
+ fileName: 'mux-export-worker.js',
31
+ directory: posix.join(outputDirectory, 'export'),
32
+ },
33
+ ];
34
+ }
35
+ function normalizedDirectory(value) {
36
+ const result = value.replaceAll('\\', '/').replace(/^\/+|\/+$/gu, '');
37
+ if (result.length === 0 || result.split('/').some(part => part === '.' || part === '..')) {
38
+ throw new TypeError('outputDirectory must be a safe relative path');
39
+ }
40
+ return result;
41
+ }
42
+ function baseUrl(value) {
43
+ return `${value.replace(/\/+$/gu, '')}/`;
44
+ }
45
+ /** Explicit URLs for ESM/CDN/Next.js clients that serve the four runtime entries themselves. */
46
+ export function aelionRuntimeAssetUrls(publicBase = '/aelion/', outputDirectory = 'aelion') {
47
+ const prefix = baseUrl(publicBase);
48
+ const entries = specifications(normalizedDirectory(outputDirectory)).map(specification => [
49
+ specification.key,
50
+ `${prefix}${specification.directory}/${specification.fileName}`,
51
+ ]);
52
+ return Object.freeze(Object.fromEntries(entries));
53
+ }
54
+ /** Reads the built package entries for custom copy pipelines and non-Webpack bundlers. */
55
+ export async function loadAelionRuntimeAssets(outputDirectory = 'aelion') {
56
+ const files = await Promise.all(specifications(normalizedDirectory(outputDirectory)).map(async (specification) => ({
57
+ key: specification.key,
58
+ outputPath: posix.join(specification.directory, specification.fileName),
59
+ bytes: new Uint8Array(await readFile(resolve(packageDistDirectory(specification.packageName), specification.fileName))),
60
+ })));
61
+ return Object.freeze(files);
62
+ }
63
+ /**
64
+ * Webpack 5/Rspack adapter. It emits the same stable asset layout used by
65
+ * `AelionSessionOptions.runtimeAssets`; applications pass `runtimeAssets()`
66
+ * from a client-only module.
67
+ */
68
+ export class AelionWebpackPlugin {
69
+ #outputDirectory;
70
+ constructor(options = {}) {
71
+ this.#outputDirectory = normalizedDirectory(options.outputDirectory ?? 'aelion');
72
+ }
73
+ runtimeAssets(publicBase = '/') {
74
+ return aelionRuntimeAssetUrls(publicBase, this.#outputDirectory);
75
+ }
76
+ apply(compiler) {
77
+ const pluginName = '@aelionsdk/webpack-plugin';
78
+ compiler.hooks.thisCompilation.tap(pluginName, compilation => {
79
+ compilation.hooks.processAssets.tapPromise({
80
+ name: pluginName,
81
+ stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL,
82
+ }, async () => {
83
+ for (const asset of await loadAelionRuntimeAssets(this.#outputDirectory)) {
84
+ compilation.emitAsset(asset.outputPath, new compiler.webpack.sources.RawSource(asset.bytes));
85
+ }
86
+ });
87
+ });
88
+ }
89
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aelionsdk/vite-plugin",
3
- "version": "0.1.0-beta.1",
3
+ "version": "1.0.0-rc.1",
4
4
  "description": "Official Vite integration for AelionSDK Worker and AudioWorklet assets",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -39,12 +39,12 @@
39
39
  "provenance": true
40
40
  },
41
41
  "dependencies": {
42
- "@aelionsdk/audio": "0.1.0-beta.1",
43
- "@aelionsdk/export": "0.1.0-beta.1",
44
- "@aelionsdk/renderer-worker": "0.1.0-beta.1"
42
+ "@aelionsdk/audio": "1.0.0-rc.1",
43
+ "@aelionsdk/export": "1.0.0-rc.1",
44
+ "@aelionsdk/renderer-worker": "1.0.0-rc.1"
45
45
  },
46
46
  "peerDependencies": {
47
- "vite": "^7.0.0"
47
+ "vite": "^7.3.6"
48
48
  },
49
49
  "scripts": {
50
50
  "build": "tsc -b",