@parcel/rust 2.14.5-canary.3437 → 2.14.5-canary.3442

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/index.d.ts CHANGED
@@ -13,6 +13,13 @@ export declare function findNodeModule(module: string, from: string): string | n
13
13
  export declare function hashString(s: string): string
14
14
  export declare function hashBuffer(buf: Buffer): string
15
15
  export declare function optimizeImage(kind: string, buf: Buffer): Buffer
16
+ export declare function transformHtml(opts: object): unknown
17
+ export declare function packageHtml(opts: object): unknown
18
+ export declare function optimizeHtml(opts: object): unknown
19
+ export declare function transformSvg(opts: object): unknown
20
+ export declare function packageSvg(opts: object): unknown
21
+ export declare function optimizeSvg(opts: object): unknown
22
+ export declare function svgReact(opts: object): unknown
16
23
  export interface JsFileSystemOptions {
17
24
  read: (...args: any[]) => any
18
25
  readLink: (...args: any[]) => any
package/index.js CHANGED
@@ -310,7 +310,7 @@ if (!nativeBinding) {
310
310
  throw new Error(`Failed to load native binding`)
311
311
  }
312
312
 
313
- const { findAncestorFile, findFirstFile, findNodeModule, hashString, hashBuffer, Hash, optimizeImage, Resolver, transform, transformAsync } = nativeBinding
313
+ const { findAncestorFile, findFirstFile, findNodeModule, hashString, hashBuffer, Hash, optimizeImage, transformHtml, packageHtml, optimizeHtml, transformSvg, packageSvg, optimizeSvg, svgReact, Resolver, transform, transformAsync } = nativeBinding
314
314
 
315
315
  module.exports.findAncestorFile = findAncestorFile
316
316
  module.exports.findFirstFile = findFirstFile
@@ -319,6 +319,13 @@ module.exports.hashString = hashString
319
319
  module.exports.hashBuffer = hashBuffer
320
320
  module.exports.Hash = Hash
321
321
  module.exports.optimizeImage = optimizeImage
322
+ module.exports.transformHtml = transformHtml
323
+ module.exports.packageHtml = packageHtml
324
+ module.exports.optimizeHtml = optimizeHtml
325
+ module.exports.transformSvg = transformSvg
326
+ module.exports.packageSvg = packageSvg
327
+ module.exports.optimizeSvg = optimizeSvg
328
+ module.exports.svgReact = svgReact
322
329
  module.exports.Resolver = Resolver
323
330
  module.exports.transform = transform
324
331
  module.exports.transformAsync = transformAsync
package/index.js.flow CHANGED
@@ -1,5 +1,6 @@
1
1
  // @flow
2
- import type {FileCreateInvalidation} from '@parcel/types';
2
+ import type {FileCreateInvalidation, SpecifierType, DependencyPriority, EnvironmentContext, JSONObject, SourceLocation, OutputFormat, SourceType} from '@parcel/types';
3
+ import type {Diagnostic} from '@parcel/diagnostic';
3
4
 
4
5
  declare export var init: void | (() => void);
5
6
 
@@ -16,6 +17,13 @@ declare export function findNodeModule(
16
17
  declare export function hashString(s: string): string;
17
18
  declare export function hashBuffer(buf: Buffer): string;
18
19
  declare export function optimizeImage(kind: string, buf: Buffer): Buffer;
20
+ declare export function transformHtml(opts: TransformHtmlOpts): TransformHtmlResult;
21
+ declare export function packageHtml(opts: PackageHtmlOpts): PackageHtmlResult;
22
+ declare export function optimizeHtml(opts: OptimizeHtmlOpts): PackageHtmlResult;
23
+ declare export function transformSvg(opts: TransformHtmlOpts): TransformHtmlResult;
24
+ declare export function packageSvg(opts: PackageHtmlOpts): PackageHtmlResult;
25
+ declare export function optimizeSvg(opts: OptimizeHtmlOpts): PackageHtmlResult;
26
+ declare export function svgReact(opts: OptimizeHtmlOpts): PackageHtmlResult;
19
27
  export interface JsFileSystemOptions {
20
28
  readLink: string => string;
21
29
  read: string => Buffer;
@@ -81,3 +89,76 @@ declare export class Resolver {
81
89
  resolveAsync(options: ResolveOptions): Promise<ResolveResult>;
82
90
  getInvalidations(path: string): JsInvalidations;
83
91
  }
92
+
93
+ export interface TransformHtmlOpts {
94
+ code: Buffer,
95
+ filePath: string,
96
+ env: RustEnvironment,
97
+ hmr: boolean
98
+ }
99
+
100
+ export interface TransformHtmlResult {
101
+ code: Buffer,
102
+ dependencies: RustDependency[],
103
+ assets: RustAsset[],
104
+ errors: Diagnostic[]
105
+ }
106
+
107
+ export interface RustEnvironment {
108
+ context: EnvironmentContext,
109
+ outputFormat: OutputFormat,
110
+ sourceType: SourceType,
111
+ flags: number,
112
+ sourceMap: ?any,
113
+ loc: ?SourceLocation,
114
+ includeNodeModules: any,
115
+ engines: any
116
+ }
117
+
118
+ export interface RustDependency {
119
+ specifier: string,
120
+ specifierType: SpecifierType,
121
+ flags: number,
122
+ priority: DependencyPriority,
123
+ bundleBehavior: 'none' | 'isolated' | 'inline',
124
+ env: RustEnvironment,
125
+ loc: ?SourceLocation,
126
+ placeholder: ?string,
127
+ resolveFrom: ?string,
128
+ range: ?string
129
+ }
130
+
131
+ export interface RustAsset {
132
+ loc: ?SourceLocation,
133
+ type: string,
134
+ content: Buffer,
135
+ env: RustEnvironment,
136
+ uniqueKey: string,
137
+ flags: number,
138
+ bundleBehavior: 'none' | 'isolated' | 'inline'
139
+ }
140
+
141
+ export interface PackageHtmlOpts {
142
+ code: Buffer,
143
+ bundles: HtmlBundleReference[],
144
+ inlineBundles: {[string]: HtmlInlineBundle},
145
+ importMap: JSONObject
146
+ }
147
+
148
+ export type HtmlBundleReference =
149
+ | {|type: 'StyleSheet', value: {|href: string|}|}
150
+ | {|type: 'Script', value: {|src: string, module: boolean, nomodule: boolean|}|};
151
+
152
+ export interface HtmlInlineBundle {
153
+ contents: string,
154
+ module: boolean
155
+ }
156
+
157
+ export interface PackageHtmlResult {
158
+ code: Buffer
159
+ }
160
+
161
+ export interface OptimizeHtmlOpts {
162
+ code: Buffer,
163
+ config: any,
164
+ }
package/lib/index.js ADDED
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _index = require("../index");
7
+ Object.keys(_index).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _index[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _index[key];
14
+ }
15
+ });
16
+ });
17
+ var _utils = require("./utils");
18
+ Object.keys(_utils).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _utils[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _utils[key];
25
+ }
26
+ });
27
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcel/rust",
3
- "version": "2.14.5-canary.3437+40ebdcd87",
3
+ "version": "2.14.5-canary.3442+914335c16",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -13,8 +13,9 @@
13
13
  "type": "git",
14
14
  "url": "https://github.com/parcel-bundler/parcel.git"
15
15
  },
16
- "main": "index.js",
17
- "browser": "browser.js",
16
+ "source": "src/index.js",
17
+ "main": "lib/index.js",
18
+ "browser": "src/browser.js",
18
19
  "napi": {
19
20
  "name": "parcel-node-bindings"
20
21
  },
@@ -48,5 +49,5 @@
48
49
  "wasm:build": "cargo build -p parcel-node-bindings --target wasm32-unknown-unknown && cp ../../../target/wasm32-unknown-unknown/debug/parcel_node_bindings.wasm .",
49
50
  "wasm:build-release": "CARGO_PROFILE_RELEASE_LTO=true cargo build -p parcel-node-bindings --target wasm32-unknown-unknown --release && wasm-opt --strip-debug -O ../../../target/wasm32-unknown-unknown/release/parcel_node_bindings.wasm -o parcel_node_bindings.wasm"
50
51
  },
51
- "gitHead": "40ebdcd87a4bb51df3b060a05aad005595de8558"
52
+ "gitHead": "914335c16417ca54c31cda5875000fd5ea7c26a6"
52
53
  }
@@ -1,4 +1,5 @@
1
1
  const {Environment, napi} = require('napi-wasm');
2
+ const utils = require('./utils');
2
3
 
3
4
  let env;
4
5
  module.exports.init = async function init(input) {
@@ -50,5 +51,6 @@ module.exports.init = async function init(input) {
50
51
  };
51
52
  };
52
53
 
54
+ Object.assign(module.exports, utils);
53
55
  env.exports.initPanicHook();
54
56
  };