@oazmi/superbuild 0.1.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.
Files changed (118) hide show
  1. package/esm/_dnt.shims.d.ts +2 -0
  2. package/esm/_dnt.shims.d.ts.map +1 -0
  3. package/esm/_dnt.shims.js +57 -0
  4. package/esm/deps/jsr.io/@oazmi/esbuild-types/0.28.0/src/mod.d.ts +598 -0
  5. package/esm/deps/jsr.io/@oazmi/esbuild-types/0.28.0/src/mod.d.ts.map +1 -0
  6. package/esm/deps/jsr.io/@oazmi/esbuild-types/0.28.0/src/mod.js +1 -0
  7. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/alias.d.ts +617 -0
  8. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/alias.d.ts.map +1 -0
  9. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/alias.js +671 -0
  10. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/array1d.d.ts +487 -0
  11. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/array1d.d.ts.map +1 -0
  12. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/array1d.js +536 -0
  13. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/array2d.d.ts +266 -0
  14. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/array2d.d.ts.map +1 -0
  15. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/array2d.js +318 -0
  16. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/binder.d.ts +368 -0
  17. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/binder.d.ts.map +1 -0
  18. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/binder.js +380 -0
  19. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/crossenv.d.ts +711 -0
  20. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/crossenv.d.ts.map +1 -0
  21. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/crossenv.js +1173 -0
  22. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/cryptoman.d.ts +171 -0
  23. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/cryptoman.d.ts.map +1 -0
  24. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/cryptoman.js +308 -0
  25. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/deps.d.ts +10 -0
  26. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/deps.d.ts.map +1 -0
  27. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/deps.js +10 -0
  28. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/eightpack.d.ts +168 -0
  29. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/eightpack.d.ts.map +1 -0
  30. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/eightpack.js +236 -0
  31. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/eightpack_varint.d.ts +90 -0
  32. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/eightpack_varint.d.ts.map +1 -0
  33. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/eightpack_varint.js +237 -0
  34. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/numericarray.d.ts +213 -0
  35. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/numericarray.d.ts.map +1 -0
  36. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/numericarray.js +363 -0
  37. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/numericmethods.d.ts +233 -0
  38. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/numericmethods.d.ts.map +1 -0
  39. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/numericmethods.js +256 -0
  40. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/pathman.d.ts +1436 -0
  41. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/pathman.d.ts.map +1 -0
  42. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/pathman.js +1730 -0
  43. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/promiseman.d.ts +647 -0
  44. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/promiseman.d.ts.map +1 -0
  45. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/promiseman.js +762 -0
  46. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/stringman.d.ts +538 -0
  47. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/stringman.d.ts.map +1 -0
  48. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/stringman.js +626 -0
  49. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/struct.d.ts +734 -0
  50. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/struct.d.ts.map +1 -0
  51. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/struct.js +764 -0
  52. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/typedbuffer.d.ts +137 -0
  53. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/typedbuffer.d.ts.map +1 -0
  54. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/typedbuffer.js +234 -0
  55. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/typedefs.d.ts +391 -0
  56. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/typedefs.d.ts.map +1 -0
  57. package/esm/deps/jsr.io/@oazmi/kitchensink/0.10.0/src/typedefs.js +8 -0
  58. package/esm/deps.d.ts +56 -0
  59. package/esm/deps.d.ts.map +1 -0
  60. package/esm/deps.js +37 -0
  61. package/esm/esbuild/metafile.d.ts +90 -0
  62. package/esm/esbuild/metafile.d.ts.map +1 -0
  63. package/esm/esbuild/metafile.js +275 -0
  64. package/esm/esbuild/native.d.ts +95 -0
  65. package/esm/esbuild/native.d.ts.map +1 -0
  66. package/esm/esbuild/native.js +127 -0
  67. package/esm/esbuild/outputfile.d.ts +86 -0
  68. package/esm/esbuild/outputfile.d.ts.map +1 -0
  69. package/esm/esbuild/outputfile.js +221 -0
  70. package/esm/esbuild/strongtypes.d.ts +90 -0
  71. package/esm/esbuild/strongtypes.d.ts.map +1 -0
  72. package/esm/esbuild/strongtypes.js +8 -0
  73. package/esm/esbuild/typedefs.d.ts +121 -0
  74. package/esm/esbuild/typedefs.d.ts.map +1 -0
  75. package/esm/esbuild/typedefs.js +55 -0
  76. package/esm/esbuild/weaktypes.d.ts +46 -0
  77. package/esm/esbuild/weaktypes.d.ts.map +1 -0
  78. package/esm/esbuild/weaktypes.js +8 -0
  79. package/esm/funcdefs.d.ts +89 -0
  80. package/esm/funcdefs.d.ts.map +1 -0
  81. package/esm/funcdefs.js +145 -0
  82. package/esm/mod.d.ts +4 -0
  83. package/esm/mod.d.ts.map +1 -0
  84. package/esm/mod.js +2 -0
  85. package/esm/package.json +3 -0
  86. package/esm/plugins/emissions_driver.d.ts +33 -0
  87. package/esm/plugins/emissions_driver.d.ts.map +1 -0
  88. package/esm/plugins/emissions_driver.js +260 -0
  89. package/esm/plugins/long_build.d.ts +138 -0
  90. package/esm/plugins/long_build.d.ts.map +1 -0
  91. package/esm/plugins/long_build.js +288 -0
  92. package/esm/plugins/native_replica.d.ts +48 -0
  93. package/esm/plugins/native_replica.d.ts.map +1 -0
  94. package/esm/plugins/native_replica.js +122 -0
  95. package/esm/super/build.d.ts +53 -0
  96. package/esm/super/build.d.ts.map +1 -0
  97. package/esm/super/build.js +39 -0
  98. package/esm/super/build_context.d.ts +83 -0
  99. package/esm/super/build_context.d.ts.map +1 -0
  100. package/esm/super/build_context.js +124 -0
  101. package/esm/super/mod.d.ts +12 -0
  102. package/esm/super/mod.d.ts.map +1 -0
  103. package/esm/super/mod.js +9 -0
  104. package/esm/super/plugin.d.ts +23 -0
  105. package/esm/super/plugin.d.ts.map +1 -0
  106. package/esm/super/plugin.js +31 -0
  107. package/esm/super/plugin_build.d.ts +38 -0
  108. package/esm/super/plugin_build.d.ts.map +1 -0
  109. package/esm/super/plugin_build.js +198 -0
  110. package/esm/super/typedefs.d.ts +323 -0
  111. package/esm/super/typedefs.d.ts.map +1 -0
  112. package/esm/super/typedefs.js +10 -0
  113. package/esm/typedefs.d.ts +21 -0
  114. package/esm/typedefs.d.ts.map +1 -0
  115. package/esm/typedefs.js +5 -0
  116. package/license.md +37 -0
  117. package/package.json +88 -0
  118. package/readme.md +181 -0
@@ -0,0 +1,198 @@
1
+ /** the {@link SuperPluginBuild} class extends `esbuild.PluginBuild` to introduce additional functionality to esbuild's plugin api.
2
+ *
3
+ * TODO: I think I should begin adding new utility features to the superbuild plugin build, such as "resolvePath" and "resolveOutdirPath", etc...
4
+ *
5
+ * @module
6
+ */
7
+ import { array_isEmpty, isNull, isRecord, pathToPosixPath } from "../deps.js";
8
+ import { concatArrays } from "../funcdefs.js";
9
+ import { SuperBuild } from "./build.js";
10
+ import { INNER_PLUGIN_BUILD } from "./typedefs.js";
11
+ /** holds the original user/plugin-provided `OnResolveArgs.pluginData` when the {@link SuperPluginBuild.resolve} method is invoked by some plugin.
12
+ *
13
+ * its presence signifies if the caller of the `onResolve` methods is actually `build.resolve(...)`,
14
+ * in order to hint that the resolved path should neither be cached, nor should the file counter be incremented,
15
+ * as there is no direct "resource loading" that will occur as a consequence of this path resolution.
16
+ */
17
+ const ORIGINAL_PLUGINDATA = Symbol();
18
+ /** in the context of {@link ORIGINAL_PLUGINDATA}, this symbol indicates that a plugin data does not exist inside the `options` passed to {@link SuperPluginBuild.resolve}. */
19
+ const ORIGINAL_PLUGINDATA_DNE = Symbol();
20
+ const wrap_resolve_call_options = (options = {}) => {
21
+ const original_plugindata = ("pluginData" in options) ? options.pluginData : ORIGINAL_PLUGINDATA_DNE, wrapped_options = { ...options, pluginData: { [ORIGINAL_PLUGINDATA]: original_plugindata } };
22
+ return wrapped_options;
23
+ };
24
+ const unwrap_resolve_call_options = (args) => {
25
+ const original_plugindata = args.pluginData[ORIGINAL_PLUGINDATA], unwrapped_args = { ...args, pluginData: original_plugindata };
26
+ if (original_plugindata === ORIGINAL_PLUGINDATA_DNE) {
27
+ delete unwrapped_args["pluginData"];
28
+ }
29
+ return unwrapped_args;
30
+ };
31
+ const is_wrapped_resolve_call = (args) => { return isRecord(args.pluginData) ? (ORIGINAL_PLUGINDATA in args.pluginData) : false; };
32
+ /** this is the extension of `esbuild.PluginBuild` that introduces additional functionality to esbuild's plugin api. */
33
+ export class SuperPluginBuild {
34
+ ctx;
35
+ basePluginBuild;
36
+ pluginName;
37
+ initialOptions;
38
+ esbuild;
39
+ /** a reference to the original {@link EsbuildPluginBuild} that was used to construct this class.
40
+ *
41
+ * its presence can be used to check whether or not your plugin is running inside a super-build.
42
+ * gaining access to esbuild's original `PluginBuild` can be useful in certain situations where bypassing super-build is necessary,
43
+ * such as in the case of the {@link nativeReplicaPlugin}, and the underlying {@link EsbuildNativeResolver} that it uses.
44
+ */
45
+ [INNER_PLUGIN_BUILD];
46
+ constructor(ctx, base_plugin_build, plugin_name) {
47
+ this.ctx = ctx;
48
+ this.basePluginBuild = base_plugin_build;
49
+ this.pluginName = plugin_name;
50
+ this.initialOptions = base_plugin_build.initialOptions;
51
+ // the inner `PluginBuild["esbuild"]` gets replaced by a new `SuperBuild` wrapper.
52
+ // TODO: we might want to add a "parent" field to `SuperBuild`, so that it can communicate with the parent super-build,
53
+ // and also `resolve()` with respect to the parent's plugins and `pluginData` context.
54
+ this.esbuild = new SuperBuild(base_plugin_build.esbuild);
55
+ this[INNER_PLUGIN_BUILD] = base_plugin_build;
56
+ }
57
+ resolve(path, options = {}) {
58
+ // `SuperPluginBuild.resolve` calls should not influence the long-build plugin's `remainingFilesCounter` at all
59
+ // (nor should its result get cached by `LongBuildController.cacheResolvedResult(...)`).
60
+ // however, the `onResolve` hooks have no knowledge of where the path-resolution request comes from;
61
+ // it could either come directly from esbuild (after traversing the parent resource's imports),
62
+ // or it could come from a plugin utilizing `build.resolve(...)`.
63
+ // thus, in order to make `SuperPluginBuild.resolve` calls discoverable, we hijack the `options.pluginData` here,
64
+ // and keep a copy of the original `pluginData` by using the `wrap_resolve_call_options` function.
65
+ // then, the overloaded `onResolve` hook will first check to see if the special `options.pluginData[ORIGINAL_PLUGINDATA]` symbol is present:
66
+ // - if it is, then that will be an indication of `SuperPluginBuild.resolve` being used, in which case we skip caching altogether,
67
+ // and also decrement the file counter once to compensate for the default increment performed by the long-build plugin's `onResolve` hook.
68
+ // - if the symbol is not present, then it will indicate that it is a natural path-resolution request coming from esbuild (i.e. imports traversal).
69
+ // in such cases, we carry out our resolved-path cache registration like normal.
70
+ return this.basePluginBuild.resolve(path, wrap_resolve_call_options(options));
71
+ }
72
+ onStart(callback) {
73
+ return this.basePluginBuild.onStart(callback);
74
+ }
75
+ onEnd(callback) {
76
+ /** the {@link emissionsDriverPlugin | "emissions driver" plugin's} `onEnd` stage performs calling each of the registered callbacks. */
77
+ this.ctx.onEndHandlers.push({ pluginName: this.pluginName, callback });
78
+ }
79
+ onResolve(options, callback) {
80
+ // NOTE: esbuild's own native resolver never makes it to here because it gets resolved internally, bypassing the plugin api.
81
+ // hence, our cached resolved check is rendered useless because of it.
82
+ // however, this is where our `nativeReplicaPlugin` comes in; it mimics esbuild's native node-resolution through the api layer,
83
+ // and hence all path resolutions get intercepted here by super-build.
84
+ const long_build_controller = this.ctx.longBuildController;
85
+ const new_callback = async (args) => {
86
+ // see the long comment under `SuperPluginBuild.resolve` to understand why we try to detect if the caller of this `onResolve`
87
+ // hook comes naturally from esbuild, or if it is a plugin that is performing a `build.resolve` call.
88
+ const is_resolve_call = is_wrapped_resolve_call(args), result = await callback(is_resolve_call ? unwrap_resolve_call_options(args) : args), is_valid_result = !isNull(result?.path) || (result?.external === true);
89
+ if (is_valid_result) {
90
+ // if the caller was not esbuild (i.e. a `buildresolve(...)` was performed by a plugin),
91
+ // then we need only to decrement the file counter to compensate for the initial increment by the long-build plugin's `onResolve` hook.
92
+ // this is because the result of this path resolution will not directly result in the creation of a new file (i.e. an `onLoad` operation),
93
+ // nor will this resolved path contribute to any future path resolution in terms of path caching by esbuild.
94
+ if (is_resolve_call) {
95
+ long_build_controller.decrementFilesCounter(result.path);
96
+ }
97
+ // but if the caller was esbuild, then the resolved path will get cached and esbuild will entirely skip loading (i.e. `onLoad` operation)
98
+ // the same file again if the resolved `namespace:path` pair had been encountered before (i.e. resource caching).
99
+ // thus, the file counter must be decremented immediately if the resolved path had been previously cached (since no loading will occur for it anymore),
100
+ // or if the resolved path points towards a new file, then the file counter's decrement will occur later after it has passed through its `onLoad` or `onTransform` stage.
101
+ else {
102
+ long_build_controller.cacheResolvedResult(result);
103
+ }
104
+ }
105
+ return result;
106
+ };
107
+ return this.basePluginBuild.onResolve(options, new_callback);
108
+ }
109
+ onLoad(options, callback) {
110
+ const resolvedResourceRegistry = this.ctx.resolvedResourceRegistry, onTransformHandlers = this.ctx.onTransformHandlers, long_build_controller = this.ctx.longBuildController;
111
+ const transform_interceptor_callback = async (args) => {
112
+ const { namespace, path, suffix, with: with_attrs } = args, onload_result = await callback(args);
113
+ if (isNull(onload_result?.contents)) {
114
+ return;
115
+ }
116
+ // if any error occurs during the plugin's `onLoad` callback, we shall halt the build altogether by passing esbuild the error early.
117
+ // also, since generic `loader`s are not permitted by esbuild, so we'll use `as any` to bypass the type error, since the build has failed anyway.
118
+ if (!array_isEmpty(onload_result.errors ?? [])) {
119
+ return onload_result;
120
+ }
121
+ // TODO: inform the user that when `loader` is set to `undefined`, it will get set to an empty string before being transferred to their `onTransform` hook,
122
+ // instead of being converted into "js" (which is esbuild's default interpretation).
123
+ // this is to allow for more flexibility when a user explicitly decides to return a `"js"` loader content vs a more ambiguous empty `""` loader content.
124
+ const { contents, loader = "", resolveDir = "", pluginData } = onload_result;
125
+ for (const handler of onTransformHandlers) {
126
+ const { pluginName: transformerPluginName, filter, namespace: handler_ns, loader: handler_loader } = handler;
127
+ if (filter.test(path)
128
+ && (handler_ns ? (handler_ns === namespace) : true)
129
+ && (handler_loader ? handler_loader === loader : true)) {
130
+ const { imports = [], emitData, ...transform_result } = await handler.callback({
131
+ contents: contents,
132
+ loader, namespace, path, pluginData, resolveDir, suffix, with: with_attrs,
133
+ }) ?? {};
134
+ // if the transformation did not generate any result (i.e. void) or generated no `content`, then we shall move to testing the next transformation handler.
135
+ if (isNull(transform_result.contents)) {
136
+ continue;
137
+ }
138
+ // there is no possibility of an error from the `onLoad` hook to be introduced, since we've already ruled it out before the loop.
139
+ // transform_result.errors = concatArrays(transform_result.errors, onload_result.errors)
140
+ transform_result.warnings = concatArrays(transform_result.warnings, onload_result.warnings);
141
+ transform_result.watchDirs = concatArrays(transform_result.watchDirs, onload_result.watchDirs);
142
+ transform_result.watchFiles = concatArrays(transform_result.watchDirs, onload_result.watchFiles);
143
+ transform_result.pluginName ??= transformerPluginName;
144
+ // NOTE: the plugin writer must ensure that their import paths are pre-resolved (not relative, nor contextually dependent).
145
+ if (imports.length > 0) {
146
+ const importer_path = namespace === "file" ? pathToPosixPath(path) : path, importer_key = namespace + ":" + importer_path;
147
+ long_build_controller.steps.at(-1).pushImports(importer_key, imports);
148
+ }
149
+ return [
150
+ transform_result,
151
+ { loader, transformLoader: transform_result.loader ?? "", emitData },
152
+ ];
153
+ }
154
+ }
155
+ // at this point, we've already tried all available transformation handlers, but none produced a viable result,
156
+ // hence we shall return the original result directly to esbuild.
157
+ return [
158
+ onload_result,
159
+ { emitData: undefined, loader: loader, transformLoader: loader },
160
+ ];
161
+ };
162
+ const resource_registry_interceptor_callback = async (args) => {
163
+ const [result, additional_info] = await transform_interceptor_callback(args) ?? [];
164
+ if (!isNull(result)) {
165
+ const { path: _path, namespace: _namespace, suffix, with: with_attrs } = args, { emitData, loader, transformLoader } = additional_info, path = pathToPosixPath(_path), namespace = _namespace ? _namespace : "file", key = namespace + ":" + path, contributing_emit_file = { path, namespace, suffix, loader, transformLoader, emitData };
166
+ resolvedResourceRegistry.set(key, contributing_emit_file);
167
+ }
168
+ return result;
169
+ };
170
+ const long_build_interceptor_callback = async (args) => {
171
+ const result = await resource_registry_interceptor_callback(args);
172
+ // every loaded result indicates that a file has gone out of circulation,
173
+ // and hence we must decrement the `remainingFilesCounter` of the long-build plugin.
174
+ if (!isNull(result)) {
175
+ long_build_controller.decrementFilesCounter(args.path);
176
+ }
177
+ // TODO: our `nativeReplicaPlugin` is expected to load everything that is left uncaptured/unloaded.
178
+ // yet, if something comes its way (i.e. the final loader) but fails to get loaded with a valid `result`,
179
+ // then our plugin should throw a warning to indicate that either something is wrong with our
180
+ // `nativeReplicaPlugin` itself, or if the input resolved path may be incorrect.
181
+ return result;
182
+ };
183
+ return this.basePluginBuild.onLoad(options, long_build_interceptor_callback);
184
+ }
185
+ onDispose(callback) {
186
+ return this.basePluginBuild.onDispose(callback);
187
+ }
188
+ /** TODO: add documentation and usage examples. */
189
+ onTransform(options, callback) {
190
+ const { filter, namespace, loader } = options;
191
+ this.ctx.onTransformHandlers.push({ pluginName: this.pluginName, filter, namespace, loader, callback });
192
+ }
193
+ /** TODO: add documentation and usage examples. */
194
+ onEmit(options, callback) {
195
+ const { filter, inputs } = options;
196
+ this.ctx.onEmitHandlers.push({ pluginName: this.pluginName, filter, inputs, callback });
197
+ }
198
+ }
@@ -0,0 +1,323 @@
1
+ /** this module contains type definitions for super-build's extended plugin api.
2
+ *
3
+ * @module
4
+ */
5
+ import type { AutoSuggestOrString, MaybePromiseOrNull } from "../deps.js";
6
+ import type { EsbuildLoaderType, EsbuildOnEndResult, OnLoadArgs as EsbuildOnLoadArgs, OnLoadOptions as EsbuildOnLoadOptions, OnLoadResult as EsbuildOnLoadResult, EsbuildOutputsImportKind, EsbuildPartialMessage } from "../esbuild/strongtypes.js";
7
+ import type { AbsolutePath, Path, RelativePath, ResolvedPath } from "../typedefs.js";
8
+ /** this symbol gives you access to the **true** internal `PluginBuild` object that was used for constructing a {@link SuperPluginBuild}.
9
+ * it can be used as a means to check whether you're inside super-build or not,
10
+ * or if you have a situation where it is necessary for super-build to be bypassed,
11
+ * such as in the case of {@link EsbuildNativeResolver}, which is spawned by {@link nativeReplicaPluginSetup}.
12
+ */
13
+ export declare const INNER_PLUGIN_BUILD: unique symbol;
14
+ /** type alias for `esbuild.OnLoadOptions`. */
15
+ export type OnLoadOptions = EsbuildOnLoadOptions;
16
+ /** type alias for `esbuild.OnLoadArgs`, slightly tweaked for this library's internal use. */
17
+ export type OnLoadArgs = EsbuildOnLoadArgs;
18
+ /** type alias for `esbuild.OnLoadResult`, except that the `loader` can be set to anything arbitrary. */
19
+ export type OnLoadResult = Omit<EsbuildOnLoadResult, "loader"> & {
20
+ loader?: AutoSuggestOrString<EsbuildLoaderType>;
21
+ };
22
+ /** type alias for the callback function provided to the `OnLoad` function (aka `esbuild.PluginBuild["OnLoad"]`). */
23
+ export type OnLoadCallback = (args: OnLoadArgs) => MaybePromiseOrNull<OnLoadResult>;
24
+ export interface OnTransformOptions {
25
+ filter: RegExp;
26
+ namespace?: string;
27
+ loader?: AutoSuggestOrString<EsbuildLoaderType>;
28
+ }
29
+ export interface OnTransformArgs {
30
+ /** the resolved path of the {@link contents}. */
31
+ path: ResolvedPath;
32
+ /** the namespace inherited from the `onLoad` hook (which gets inherited from the `onResolve` hook). */
33
+ namespace: string;
34
+ /** the loader that is supposed to be used for this {@link contents} for the transformation. */
35
+ loader: AutoSuggestOrString<EsbuildLoaderType>;
36
+ /** any url-suffix string that is present in the {@link path}. */
37
+ suffix: string;
38
+ /** the loaded content that is to be transformed. */
39
+ contents: string | Uint8Array<ArrayBuffer>;
40
+ /** the plugin data returned by the `onLoad` hook.
41
+ *
42
+ * > [!important]
43
+ * > esbuild strips away any plugin-data when it resolves/loads natively.
44
+ * > hence, in order to preserve it during native loading,
45
+ * > we might have to instill a `"file"` namespace loader that will capture all native loading cases,
46
+ * > and then perform the loading ourselves, followed by preserving the plugin-data.
47
+ * >
48
+ * > TODO: actually, right now, I'm intentionally stripping away the `pluginData` in my "native loader".
49
+ * > I'll have to see how much of an inconvenience it becomes before I give in to preserving the plugin-data.
50
+ * > otherwise, if I can manage to write plugins without needing this feature, then there's no reason to add it.
51
+ */
52
+ pluginData: any;
53
+ /** the `resolveDir` (used for node-resolution) returned by the loader.
54
+ *
55
+ * > [!note]
56
+ * > when the `onLoad` hook function returns an empty/undefined `resolveDir`, this value turns into an empty string.
57
+ */
58
+ resolveDir: string;
59
+ /** the `with` attribute argument passed to the `onLoad` hook. */
60
+ with: Record<string, string>;
61
+ }
62
+ export interface OnTransformResult {
63
+ /** insert your plugin's name to override the current plugin name that will be used for error printing. */
64
+ pluginName?: string;
65
+ /** the transformed/transpiled contents that will be returned to esbuild. */
66
+ contents?: string | Uint8Array<ArrayBuffer>;
67
+ /** if the {@link contents} needs to be transformed/minified natively by esbuild again
68
+ * (in addition to discovering additional imports), use one of the native loaders provided by esbuild.
69
+ */
70
+ loader?: EsbuildLoaderType;
71
+ /** insert plugin-data to be passed onto the dependencies' `onResolve` hook's `arg.pluginData`.
72
+ *
73
+ * if you wish to pass on the incoming {@link OnTransformArgs.pluginData} from the prior `onLoad` hook,
74
+ * you will need to explicitly pass it over as a return argument, otherwise the plugin-data will get lost.
75
+ * so, keep this in mind when designing transformation hooks, because you wouldn't want to ruin any plugin-data that some plugin was anticipating.
76
+ */
77
+ pluginData?: any;
78
+ /** pass some arbitrary data from the transformation stage to the emit stage.
79
+ *
80
+ * this feature is handled by {@link SuperBuildContext.resolvedResourceRegistry}.
81
+ */
82
+ emitData?: any;
83
+ /** specify arbitrary resource imports that must be performed for this resource.
84
+ *
85
+ * while these resources will get bundled (via dynamic imports performed by {@link longBuildPluginSetup}, so long as they are not marked with `external: true`),
86
+ * they (i.e. their output paths) won't get automatically incorporated into your {@link contents};
87
+ * for that, you will have to use an {@link SuperPluginBuild.onEmit} hook to re-capture the output paths of the bundled imports specified here,
88
+ * and then re-incorporate those output paths into your {@link OnEmitArgs.contents},
89
+ * using the non-mutating {@link ImportEntity.key} trace which resource is being referenced by the {@link ImportedEntity.outputPath}.
90
+ *
91
+ * to skip an import from being bundled, you can either stay silent about it (i.e. not include it here),
92
+ * or mark that import with `external: true`, so that it still gets passed to {@link OnEmitArgs.imports},
93
+ * but will appear to esbuild as an external reference (and hence not resolved, nor bundled as an emitted output file).
94
+ */
95
+ imports?: ImportEntity[];
96
+ /** if any fatal error(s) occur during the transformation, pass it as a return value so that the build gets immediately halted. */
97
+ errors?: EsbuildPartialMessage[];
98
+ /** if any warning(s) occur during the transformation, pass it as a return value so that esbuild prints out a warning immediately. */
99
+ warnings?: EsbuildPartialMessage[];
100
+ /** add a list of local files to watch for mutation in order to trigger a reload of the original loader hook.
101
+ * (I think the paths need to be an absolute path.)
102
+ *
103
+ * any files added to this array will be combined with the {@link OnLoadResult.watchFiles} list of the prior `onLoad` hook function.
104
+ */
105
+ watchFiles?: string[];
106
+ /** add a list of directories to watch for mutation in order to trigger a reload.
107
+ * (I think the paths need to be an absolute path.)
108
+ *
109
+ * any directories added to this array will be combined with the {@link OnLoadResult.watchDirs} list of the prior `onLoad` hook function.
110
+ */
111
+ watchDirs?: string[];
112
+ }
113
+ /** this is your `onTransform` hook function that gets called,
114
+ * if the handler associated with it allows a certain result from an `onLoad` hook to pass through its filter ({@link OnTransformOptions}).
115
+ *
116
+ * if your return value is nullable (`null` or `undefined`), then the next matching `onTransform` hook function will try to transform the incoming loaded contents.
117
+ * if no transformation hook returns a non-nullable after all matches have been made,
118
+ * then the loaded contents from the `onLoad` hook will be passed to esbuild as is.
119
+ */
120
+ export type OnTransformCallback = (args: OnTransformArgs) => MaybePromiseOrNull<OnTransformResult>;
121
+ /** specify an entity/file that should be imported for a given loaded entity (during the transformation stage). */
122
+ export interface ImportEntity<K = any> {
123
+ /** include a unique key that you can use to trace back the imported entity,
124
+ * because the `path` of the import in the bundled output will differ, whereas this key will remain the same.
125
+ */
126
+ key: K;
127
+ /** the **absolute/resolved** path of the resource.
128
+ *
129
+ * do not insert unresolved or relative paths!
130
+ * this is a strict design choice because you should ideally run a sub-build to acquire the resolved paths of your dependencies.
131
+ * of course, nothing is stopping your `onTransform` hook from either:
132
+ * - using the `build.resolve` of the sub-build's parent `PluginBuild` (thereby not requiring re-instantiation of the plugins).
133
+ * - re-instantiating the plugins in the sub-build, so that the path-resolution logic remains similar. although, this can have drawbacks;
134
+ * for instance, my `esbuild-plugin-deno`'s `setup` method is _generated_ based on the user's initial config
135
+ * (containing contextual information, such as the location of `deno.json`), which may not be desired in the sub-build
136
+ * (if for instance, the thing being resolved for the sub-build is actually inside a different package/scope than the primary package).
137
+ *
138
+ * because there is a variablility in how you can potentially approach path resolution,
139
+ * we leave it up to the plugin designer to decide how they would want to resolve the paths in their `onTransform` hook's returned imports,
140
+ * rather than performing a default action ourselves.
141
+ */
142
+ path: AbsolutePath | ResolvedPath;
143
+ /** associate a `with` import attribute to the import. */
144
+ with?: Record<string, string>;
145
+ /** specify if this import should be marked as an external resource, so that it neither gets resolved, nor loaded/bundled as an output file.
146
+ *
147
+ * if you wish for your import's path to get resolved, but not loaded/bundled as a file, then you should either:
148
+ * 1. set `external: false` and then capture {@link path} during the `onResolve` stage,
149
+ * followed by setting `external` to `true` in the returned `OnResolveResult`.
150
+ * 2. set `external: true` and make sure that your {@link path} is pre-resolved within the transformation stage,
151
+ * by simply using {@link SuperPluginBuild.resolve | `build.resolve(...)`} to resolve its path in your plugin.
152
+ */
153
+ external?: boolean;
154
+ }
155
+ export type ImportedEntityKind = EsbuildOutputsImportKind | "user-import";
156
+ /** a description of an entity that is imported by an output file (post-build, during the emission stage).
157
+ *
158
+ * - for user-specified `imports` performed in the transformation stage ({@link OnTransformResult}), the {@link key} will be supplied by the user,
159
+ * and it will be up to the user to trace back the original linked resource that was being referenced.
160
+ * - for imports performed by esbuild (such as js and css imports), the {@link key} will be an array of namespaced resolved paths
161
+ * (of the form `${namespace}:${resolved_path}`) that contributed to the creation of the imported (and possibly bundled) resource.
162
+ *
163
+ * TODO: the currently include `with` import attribute is defunct. should it have any built-in purpose,
164
+ * or should it be just left up to the user to decide what to do with that information?
165
+ */
166
+ export interface ImportedEntity<K = any> extends Pick<NonNullable<ImportEntity<K>>, "key" | "with"> {
167
+ /** the **absolute** output path of the resource/entity that is being imported.
168
+ *
169
+ * to convert it to a relative path with respect to the entity that imports this resource,
170
+ * use the `relativePath` function from my `jsr:@oazmi/kitchensink/pathman` or `npm:@oazmi/kitchensink/pathman` libraries.
171
+ */
172
+ outputPath: AbsolutePath;
173
+ /** if the imported entity was renamed during the {@link SuperPluginBuild.onEmit, emission stage},
174
+ * then its original (absolute) {@link outputPath} will get saved here.
175
+ *
176
+ * this is to aid you with modifying/renaming import paths within your dependent entity's {@link OnEmitArgs.contents},
177
+ * when you cannot reliably use your {@link key} to identify the import statement corresponding to an imported entity.
178
+ *
179
+ * for instance, suppose your build emits a `./main.js` file that imports `./meow.worker.js`,
180
+ * and then during the emission stage, suppose you renamed the `./meow.worker.js` output file to `./workers/meow.js`.
181
+ * then, when `./main.js` enters the {@link SuperPluginBuild.onEmit | emission phase},
182
+ * the {@link OnEmitArgs.imports | import field} corresponding to the `./workers/meow.js` file (formerly `./meow.worker.js`)
183
+ * will have its {@link outputPath} set to `./workers/meow.js` (but as an absolute path),
184
+ * while its {@link initialPath} will get assigned `./meow.worker.js` (again, as an absolute path),
185
+ * so that you can scan the {@link OnEmitArgs.contents} of your `./main.js` file to find all references to `./meow.worker.js`,
186
+ * and then replace those statements with the updated `./workers/meow.js` path.
187
+ *
188
+ * > [!note]
189
+ * > this field is only assigned when the {@link OnEmitResult | emission stage result} of the dependency import changes the
190
+ * > {@link OnEmitResult.path} to something different from the original (case sensitive).
191
+ */
192
+ initialPath?: AbsolutePath;
193
+ /** indicates the kind of import that is being performed. all of these are inherited from esbuild metafile's
194
+ * {@link EsbuildMetafileImportProps.kind | `kind` field}, with the exception of `"user-import"`,
195
+ * which is assigned when the user specifies an import during the transformation stage ({@link OnTransformResult}).
196
+ */
197
+ kind: ImportedEntityKind;
198
+ /** indicates if this imported entity is an external resource (and hence not bundled). */
199
+ external: boolean;
200
+ /** this flag indicates if the imported file entity is being written at all into the filesystem (supposing that the `EsbuildBuildOptions.write` was not disabled).
201
+ *
202
+ * in general, this flag is set to `false` for entities with {@link external} set to `true`.
203
+ * but for non-external imported entities, when this flag is set to `false`,
204
+ * it can hint to the importer entity that they should probably remove the import statement associated with this import,
205
+ * in order not to get any runtime-import exceptions. or perhaps,
206
+ * it can hint that the imported entity should have its contents inlined into the importer, such as in the case of html's inline js and css.
207
+ * (TODO: currently, importers cannot read the `contents` of the imported entity, so this feature needs to be implemented).
208
+ */
209
+ write: boolean;
210
+ }
211
+ /** a single input file filteration rule used in {@link OnEmitOptions}. */
212
+ export interface OnEmitOptions_InputFilter {
213
+ /** a resolved path name filter of the input resource that is to be matched by at least one of the emitted file's {@link OnEmitArgs.inputs | inputs}. */
214
+ filter: RegExp;
215
+ /** specify an optional namespace in which the loaded input file must be part of. */
216
+ namespace?: string;
217
+ /** specify an optional loader which should have been used to load this input file by the {@link SuperPluginBuild.onLoad} hook. */
218
+ loader?: AutoSuggestOrString<EsbuildLoaderType>;
219
+ /** specify an optional transform-loader which should have been used to load this input file during the transformation hook ({@link SuperPluginBuild.onTransform}).
220
+ * if no {@link SuperPluginBuild.onTransform} hook captured this input resource,
221
+ * then the `loader` value from the prior {@link SuperPluginBuild.onLoad} stage will be used to match against this option.
222
+ */
223
+ transformLoader?: EsbuildLoaderType;
224
+ }
225
+ export interface OnEmitOptions {
226
+ /** a filter for the {@link OnEmitArgs.outputPath | output filename} of a file that is to be emitted. */
227
+ filter: RegExp;
228
+ /** a filter for specifying which input resources should be part of what constitutes this output file.
229
+ *
230
+ * for instance, if one were to bundle entrypoints `A` and `B`, and `A` depended on `X` and `Y`, while `B` depended on `Y` and `Z`,
231
+ * then the emitted bundled file corresponding to entrypoint `A` will have all three `A`, `X`, and `Y` show up in its `inputs` array.
232
+ * similarly, the emitted bundled file corresponding to entrypoint `B` will have all three `B`, `Y`, and `Z` show up in its `inputs` array.
233
+ *
234
+ * when multiple input filters are specified, they (the filters) will all need to be satisfied simultaneously (logical AND)
235
+ * by the list of available {@link OnEmitArgs.inputs} of the emitted resource. for instance, for the scenario mentioned prior:
236
+ * - if `inputs = [{ filter: /A/ }, { filter: /Y/ }]`,
237
+ * then the emitted file corresponding to entrypoint `A` will be matched, but not `B` (since it has no input with the name `A`).
238
+ * - if `inputs = [{ filter: /Y/ }]`,
239
+ * then the emitted files corresponding to both entrypoints `A` and `B` will be matched (since they both incorporate the dependency file `Y`).
240
+ * - if `inputs = [{ filter: /Y/ }, { filter: /Z/ }]`,
241
+ * then only the emitted file corresponding to entrypoint `B` will be matched, and not `A` (since `A` does not incorporate the dependency file `Z`).
242
+ */
243
+ inputs?: Array<OnEmitOptions_InputFilter>;
244
+ }
245
+ /** a description of an input file that was bundled into a physical output file ({@link OnEmitArgs}). */
246
+ export interface BundledInputFile {
247
+ /** the original (absolute) resolved path (return value of the `onResolve` hook) of this bundled resource. */
248
+ path: ResolvedPath;
249
+ /** the namespace inherited from the `onTransform` hook
250
+ * (which gets inherited from the `onLoad` hook, and the `onResolve` hook prior to it).
251
+ */
252
+ namespace: string;
253
+ /** the `onLoad` loader that was used for this resource. equivalent to {@link OnEmitOptions.loader}. */
254
+ loader: string;
255
+ /** the `onTransform` loader that was used for this resource during its transformation stage.
256
+ * if the resource did not go through a transformation stage, then this value will be the same as {@link loader}.
257
+ * moreover, this value is equivalent to the {@link OnEmitOptions.transformLoader} provided in the filteration options.
258
+ */
259
+ transformLoader: NonNullable<OnTransformResult["loader"]> | "";
260
+ /** any url-suffix string that might present in the {@link path | resolved path}. */
261
+ suffix: string;
262
+ /** arbitrary data passed from the {@link OnTransformResult.emitData | transformation stage} to the emit stage. */
263
+ emitData: NonNullable<OnTransformResult["emitData"]>;
264
+ }
265
+ export interface OnEmitArgs {
266
+ /** the output path of this bundled resource, relative to the `cwd` or `absWorkingDir`
267
+ * (not the `outdir` directory!), and always in posix format.
268
+ *
269
+ * TODO: I actually don't provide a relative path right now. but should I even?
270
+ */
271
+ outputPath: RelativePath;
272
+ /** a list of input resources that were bundled into this resource (by esbuild), or were chunked by esbuild for this resource. */
273
+ inputs: Array<BundledInputFile>;
274
+ /** a list of resource imports that were included in the build for this resource.
275
+ * these, however, are not currently _bundled_ into the contents of your resource;
276
+ * they're still external resources that your transformed file will need to reference (re-incorporate) in order to import during runtime.
277
+ */
278
+ imports: Array<ImportedEntity>;
279
+ /** the transformed and/or bundled content that may need to have the linked {@link imports} re-incorporated into it. */
280
+ contents: Uint8Array<ArrayBuffer>;
281
+ }
282
+ export interface OnEmitResult extends EsbuildOnEndResult {
283
+ /** provide an alternate path to place this resource.
284
+ *
285
+ * if a relative path is provided (which is what is recommended),
286
+ * then this file will be placed relative to the `cwd` or `absWorkingDir` specified in the initial build options,
287
+ * which is different from the `outdir`. for providing paths relative to `outdir`, use an absolute path.
288
+ *
289
+ * TODO: in the future, consider adding a `pathRelativeTo` option, with the symbols `OUTDIR`, `CWD`, and `ABS_WORKING_DIR`,
290
+ * for specifying what is the `path` relative to.
291
+ */
292
+ path?: Path;
293
+ /** the contents of the file after you've re-incorporated the imported/dependency links into it.
294
+ * if left `undefined`, then the original {@link OnEmitArgs.contents} will be used as its value.
295
+ */
296
+ contents?: string | Uint8Array<ArrayBuffer>;
297
+ /** specify if the file should be written (i.e. emitted) at all.
298
+ *
299
+ * > [!note]
300
+ * > note that it is totally possible to delete an entity, but still have some {@link contents} assigned to it.
301
+ * > this way, you should be able to read the contents of the "deleted" file later on inside on of the dependent entities.
302
+ * >
303
+ * > this can be useful when you would like to code a plugin that takes in inlined code (such as inlined js or css inside an html),
304
+ * > then includes it in the bundle (by faking it as virtual files during resolutions/loading),
305
+ * > and then deletes the emitted files corresponding to the inlined code blocks, while retaining the minified/bundled {@link contents},
306
+ * > so that the original dependent entity (html file in this case) can read the minified/bundled {@link contents} and then re-incorporate them as inlined code.
307
+ * >
308
+ * > (TODO: though, right now, I don't currently give a global readonly access to the output files registry inside the {@link OnEmitCallback} function.
309
+ * > I should probably add the registry as a second argument to the callback function.)
310
+ *
311
+ * @defaultValue `true` (i.e. it'll be written if `EsbuildBuildOption.write` is enabled, otherwise it won't be.)
312
+ */
313
+ write?: boolean;
314
+ }
315
+ /** this is your `onEmit` hook function that gets called,
316
+ * if the handler associated with it allows a certain result from an `onLoad` hook to pass through its filter ({@link OnEmitOptions}).
317
+ *
318
+ * if your return value is nullable (`null` or `undefined`), then the next matching `onEmit` hook function will try to mutate the finalized loaded/transformed contents.
319
+ * if no emit hook returns a non-nullable after all matches have been made,
320
+ * then the transformed contents from the `onTransform` hook will be passed to esbuild as is.
321
+ */
322
+ export type OnEmitCallback = (args: OnEmitArgs) => MaybePromiseOrNull<OnEmitResult>;
323
+ //# sourceMappingURL=typedefs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typedefs.d.ts","sourceRoot":"","sources":["../../src/super/typedefs.ts"],"names":[],"mappings":"AAAA;;;EAGE;AAEF,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AACzE,OAAO,KAAK,EACX,iBAAiB,EAEjB,kBAAkB,EAClB,UAAU,IAAI,iBAAiB,EAC/B,aAAa,IAAI,oBAAoB,EACrC,YAAY,IAAI,mBAAmB,EACnC,wBAAwB,EACxB,qBAAqB,EACrB,MAAM,2BAA2B,CAAA;AAGlC,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAKpF;;;;EAIE;AACF,eAAO,MAAM,kBAAkB,eAAW,CAAA;AAK1C,8CAA8C;AAC9C,MAAM,MAAM,aAAa,GAAG,oBAAoB,CAAA;AAEhD,6FAA6F;AAC7F,MAAM,MAAM,UAAU,GAAG,iBAAiB,CAA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GAAG,UAAU,CAAC,WAAW,CAAC,CAAA;IAE3C;;;;;;;;;;;;;;;MAeE;IACF,KAAK,CAAC,EAAE,OAAO,CAAA;CACf;AAED;;;;;;EAME;AACF,MAAM,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,UAAU,KAAK,kBAAkB,CAAC,YAAY,CAAC,CAAA"}
@@ -0,0 +1,10 @@
1
+ /** this module contains type definitions for super-build's extended plugin api.
2
+ *
3
+ * @module
4
+ */
5
+ /** this symbol gives you access to the **true** internal `PluginBuild` object that was used for constructing a {@link SuperPluginBuild}.
6
+ * it can be used as a means to check whether you're inside super-build or not,
7
+ * or if you have a situation where it is necessary for super-build to be bypassed,
8
+ * such as in the case of {@link EsbuildNativeResolver}, which is spawned by {@link nativeReplicaPluginSetup}.
9
+ */
10
+ export const INNER_PLUGIN_BUILD = Symbol();
@@ -0,0 +1,21 @@
1
+ /** this module contains base type definitions.
2
+ *
3
+ * @module
4
+ */
5
+ /** type annotation for a relative path. */
6
+ export type RelativePath = string;
7
+ /** type annotation for an absolute path. */
8
+ export type AbsolutePath = string;
9
+ /** type annotation for a resolved path (that originates from the path resolver stage).
10
+ * it could either be an absolute path or an external absolute path.
11
+ */
12
+ export type ResolvedPath = string;
13
+ /** type annotation for a namespaced resolved path of the form `${namespace}:${resolved_path}`, all in lowercasing.
14
+ * this is often used as a key for various `Map`s to identify resources and references to resources.
15
+ */
16
+ export type NamespacedPath = string;
17
+ /** type annotation for any kind path. */
18
+ export type Path = RelativePath | AbsolutePath;
19
+ /** a logging function that can be used as an alternative to the default `console.log` logger function. */
20
+ export type LoggerFunction = (...data: any[]) => void;
21
+ //# sourceMappingURL=typedefs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typedefs.d.ts","sourceRoot":"","sources":["../src/typedefs.ts"],"names":[],"mappings":"AAAA;;;EAGE;AAGF,2CAA2C;AAC3C,MAAM,MAAM,YAAY,GAAG,MAAM,CAAA;AAEjC,4CAA4C;AAC5C,MAAM,MAAM,YAAY,GAAG,MAAM,CAAA;AAEjC;;EAEE;AACF,MAAM,MAAM,YAAY,GAAG,MAAM,CAAA;AAEjC;;EAEE;AACF,MAAM,MAAM,cAAc,GAAG,MAAM,CAAA;AAEnC,yCAAyC;AACzC,MAAM,MAAM,IAAI,GAAG,YAAY,GAAG,YAAY,CAAA;AAE9C,0GAA0G;AAC1G,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA"}
@@ -0,0 +1,5 @@
1
+ /** this module contains base type definitions.
2
+ *
3
+ * @module
4
+ */
5
+ export {};
package/license.md ADDED
@@ -0,0 +1,37 @@
1
+ # Apache License, Version 2.0 (Modified)
2
+
3
+ Copyright [2026] [Omar Azmi]
4
+
5
+ This project is licensed under the Apache License, Version 2.0, with additional terms and restrictions.
6
+ You may not use or view any file under this project except in compliance with this license.
7
+ You may obtain a copy of the Apache License Version 2.0 at:
8
+
9
+ > http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ ## Additional Terms and Restrictions
12
+
13
+ Redistribution and use of this project, or any artifacts generated by it, in source or binary forms, with or without modification, are permitted provided that the following conditions are met:
14
+
15
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the disclaimer that follows.
16
+
17
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the disclaimer that follows, in its documentation and/or other materials provided with the distribution.
18
+
19
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
20
+
21
+ 4. The software may be used in open source and closed source projects.
22
+ If used in a closed source project, the project must provide attribution to this software.
23
+
24
+ 5. Distributions of this software or its specifications in any form must not be used in the development, training, or operation of an Artificial Intelligence system.
25
+
26
+ 6. The software or its derivatives must not be used in any form of crawling or caching that is not directly related to code archiving.
27
+
28
+ 7. No portion of this software or its specifications may be copied or used in another codebase without proper attribution to the original work.
29
+
30
+ 8. Derivative works that directly compete with the original software are not permitted.
31
+ Major enhancements or modifications should ideally be contributed back to the original software's development.
32
+ This is to prevent the intent of diverting existing or potential users away from the original work.
33
+
34
+ 9. Redistribution for the sole purpose of competing with the original software is not permitted.
35
+
36
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
37
+ IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.