11ty-plugin-giallo 0.1.0-alpha.0 → 0.1.0-alpha.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/.eleventy.js CHANGED
@@ -1,5 +1,8 @@
1
+ import { WASIShim } from "@bytecodealliance/preview2-shim/instantiation";
2
+ import { readFileSync } from "node:fs";
3
+
1
4
  import pkg from "./package.json" with { type: "json" };
2
- import { syntaxHighlighter } from "./dist/giallo_js.js";
5
+ import { instantiate as instantiateGiallo } from "./dist/giallo_js.js";
3
6
 
4
7
  function gialloMarkdownHighlighter(options = {}) {
5
8
  return function (str, language) {
@@ -121,6 +124,7 @@ export default function (eleventyConfig, options) {
121
124
  `WARN: Eleventy Plugin (${pkg.name}) Compatibility: ${e.message}`,
122
125
  );
123
126
  }
127
+
124
128
  options = Object.assign({
125
129
  lineSeparator: "\n",
126
130
  preAttributes: {},
@@ -128,6 +132,12 @@ export default function (eleventyConfig, options) {
128
132
  languages: [],
129
133
  }, options);
130
134
 
135
+ const { syntaxHighlighter } = instantiateGiallo((path) => {
136
+ WebAssembly.instantiate(
137
+ readFileSync(`${import.meta.dirname}/dist/${path}`),
138
+ );
139
+ }, new WASIShim().getImportObject());
140
+
131
141
  if (hasTemplateFormat(options.templateFormats, "md")) {
132
142
  // ```js/0,2-3
133
143
  eleventyConfig.addMarkdownHighlighter(gialloMarkdownHighlighter(options));
package/.helix/ignore ADDED
@@ -0,0 +1,4 @@
1
+ /node_modules
2
+ /build
3
+ /dist
4
+ /target
Binary file
Binary file
@@ -1,13 +1,56 @@
1
1
  // world root:component/root
2
- export type * as WasiCliEnvironment026 from './interfaces/wasi-cli-environment.js'; // import wasi:cli/environment@0.2.6
3
- export type * as WasiCliExit026 from './interfaces/wasi-cli-exit.js'; // import wasi:cli/exit@0.2.6
4
- export type * as WasiCliStderr026 from './interfaces/wasi-cli-stderr.js'; // import wasi:cli/stderr@0.2.6
5
- export type * as WasiCliStdin026 from './interfaces/wasi-cli-stdin.js'; // import wasi:cli/stdin@0.2.6
6
- export type * as WasiCliStdout026 from './interfaces/wasi-cli-stdout.js'; // import wasi:cli/stdout@0.2.6
7
- export type * as WasiClocksWallClock026 from './interfaces/wasi-clocks-wall-clock.js'; // import wasi:clocks/wall-clock@0.2.6
8
- export type * as WasiFilesystemPreopens026 from './interfaces/wasi-filesystem-preopens.js'; // import wasi:filesystem/preopens@0.2.6
9
- export type * as WasiFilesystemTypes026 from './interfaces/wasi-filesystem-types.js'; // import wasi:filesystem/types@0.2.6
10
- export type * as WasiIoError026 from './interfaces/wasi-io-error.js'; // import wasi:io/error@0.2.6
11
- export type * as WasiIoStreams026 from './interfaces/wasi-io-streams.js'; // import wasi:io/streams@0.2.6
12
- export type * as WasiRandomInsecureSeed026 from './interfaces/wasi-random-insecure-seed.js'; // import wasi:random/insecure-seed@0.2.6
13
- export * as syntaxHighlighter from './interfaces/docs-giallo-js-syntax-highlighter.js'; // export docs:giallo-js/syntax-highlighter@0.0.1
2
+ import type * as WasiCliEnvironment from './interfaces/wasi-cli-environment.js'; // wasi:cli/environment@0.2.6
3
+ import type * as WasiCliExit from './interfaces/wasi-cli-exit.js'; // wasi:cli/exit@0.2.6
4
+ import type * as WasiCliStderr from './interfaces/wasi-cli-stderr.js'; // wasi:cli/stderr@0.2.6
5
+ import type * as WasiCliStdin from './interfaces/wasi-cli-stdin.js'; // wasi:cli/stdin@0.2.6
6
+ import type * as WasiCliStdout from './interfaces/wasi-cli-stdout.js'; // wasi:cli/stdout@0.2.6
7
+ import type * as WasiClocksWallClock from './interfaces/wasi-clocks-wall-clock.js'; // wasi:clocks/wall-clock@0.2.6
8
+ import type * as WasiFilesystemPreopens from './interfaces/wasi-filesystem-preopens.js'; // wasi:filesystem/preopens@0.2.6
9
+ import type * as WasiFilesystemTypes from './interfaces/wasi-filesystem-types.js'; // wasi:filesystem/types@0.2.6
10
+ import type * as WasiIoError from './interfaces/wasi-io-error.js'; // wasi:io/error@0.2.6
11
+ import type * as WasiIoStreams from './interfaces/wasi-io-streams.js'; // wasi:io/streams@0.2.6
12
+ import type * as WasiRandomInsecureSeed from './interfaces/wasi-random-insecure-seed.js'; // wasi:random/insecure-seed@0.2.6
13
+ import type * as DocsGialloJsSyntaxHighlighter from './interfaces/docs-giallo-js-syntax-highlighter.js'; // docs:giallo-js/syntax-highlighter@0.0.1
14
+ export interface ImportObject {
15
+ 'wasi:cli/environment@0.2.6': typeof WasiCliEnvironment,
16
+ 'wasi:cli/exit@0.2.6': typeof WasiCliExit,
17
+ 'wasi:cli/stderr@0.2.6': typeof WasiCliStderr,
18
+ 'wasi:cli/stdin@0.2.6': typeof WasiCliStdin,
19
+ 'wasi:cli/stdout@0.2.6': typeof WasiCliStdout,
20
+ 'wasi:clocks/wall-clock@0.2.6': typeof WasiClocksWallClock,
21
+ 'wasi:filesystem/preopens@0.2.6': typeof WasiFilesystemPreopens,
22
+ 'wasi:filesystem/types@0.2.6': typeof WasiFilesystemTypes,
23
+ 'wasi:io/error@0.2.6': typeof WasiIoError,
24
+ 'wasi:io/streams@0.2.6': typeof WasiIoStreams,
25
+ 'wasi:random/insecure-seed@0.2.6': typeof WasiRandomInsecureSeed,
26
+ }
27
+ export interface Root {
28
+ 'docs:giallo-js/syntax-highlighter@0.0.1': typeof DocsGialloJsSyntaxHighlighter,
29
+ syntaxHighlighter: typeof DocsGialloJsSyntaxHighlighter,
30
+ }
31
+
32
+ /**
33
+ * Instantiates this component with the provided imports and
34
+ * returns a map of all the exports of the component.
35
+ *
36
+ * This function is intended to be similar to the
37
+ * `WebAssembly.Instantiate` constructor. The second `imports`
38
+ * argument is the "import object" for wasm, except here it
39
+ * uses component-model-layer types instead of core wasm
40
+ * integers/numbers/etc.
41
+ *
42
+ * The first argument to this function, `getCoreModule`, is
43
+ * used to compile core wasm modules within the component.
44
+ * Components are composed of core wasm modules and this callback
45
+ * will be invoked per core wasm module. The caller of this
46
+ * function is responsible for reading the core wasm module
47
+ * identified by `path` and returning its compiled
48
+ * `WebAssembly.Module` object. This would use the
49
+ * `WebAssembly.Module` constructor on the web, for example.
50
+ */
51
+ export function instantiate(
52
+ getCoreModule: (path: string) => WebAssembly.Module,
53
+ imports: ImportObject,
54
+ instantiateCore?: (module: WebAssembly.Module, imports: Record<string, any>) => WebAssembly.Instance
55
+ ): Root;
56
+