Skip to content

Commit fff1b2e

Browse files
authored
Merge pull request #1916 from polywrap/origin-0.12-dev
Origin 0.12.1 | /workflows/release-pr
2 parents fe8b36f + ecbfdfd commit fff1b2e

File tree

95 files changed

+4299
-296
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+4299
-296
lines changed

.github/CODEOWNERS

+1-62
Original file line numberDiff line numberDiff line change
@@ -1,62 +1 @@
1-
# Default
2-
* @dOrgJelli @namesty
3-
4-
# Wasm Runtime
5-
packages/wasm/as @dOrgJelli @krisbitney @namesty @Niraj-Kamdar
6-
packages/wasm/rs @namesty @dOrgJelli
7-
8-
# Wrapper Test-Cases
9-
packages/test-cases/cases/wrappers/wasm-as @cbrzn @namesty @nerfZael @krisbitney @Niraj-Kamdar
10-
packages/test-cases/cases/wrappers/wasm-rs @cbrzn @namesty @nerfZael @krisbitney @Niraj-Kamdar
11-
12-
# Schema
13-
packages/schema/parse @dOrgJelli @namesty @nerfZael @Niraj-Kamdar
14-
packages/schema/compose @dOrgJelli @namesty @nerfZael @Niraj-Kamdar
15-
packages/schema/bind @dOrgJelli @krisbitney @nerfZael @Niraj-Kamdar @cbrzn
16-
17-
# Schema Test-Cases
18-
packages/test-cases/cases/parse @dOrgJelli @namesty @nerfZael @Niraj-Kamdar
19-
packages/test-cases/cases/compose @dOrgJelli @namesty @nerfZael @Niraj-Kamdar
20-
packages/test-cases/cases/bind @dOrgJelli @krisbitney @nerfZael @Niraj-Kamdar @cbrzn
21-
22-
# Project Manifests
23-
packages/manifests/ @dOrgJelli @namesty @cbrzn @Niraj-Kamdar
24-
25-
# CLI
26-
packages/js/cli @dOrgJelli @krisbitney @namesty @nerfZael @Niraj-Kamdar
27-
28-
# CLI Test-Cases
29-
packages/test-cases/cases/cli @dOrgJelli @krisbitney @namesty @nerfZael @Niraj-Kamdar
30-
31-
# Interfaces
32-
packages/interfaces @dOrgJelli @krisbitney @cbrzn
33-
34-
# JS Client
35-
packages/js @dOrgJelli @nerfZael
36-
packages/js/asyncify @namesty @dOrgJelli
37-
packages/js/client @dOrgJelli @krisbitney @namesty @nerfZael
38-
packages/js/client-config-builder @pileks @nerfZael
39-
packages/js/core @dOrgJelli @krisbitney @namesty @nerfZael
40-
packages/js/manifests @dOrgJelli @namesty @nerfZael @pileks @Niraj-Kamdar
41-
packages/js/msgpack @dOrgJelli @Niraj-Kamdar
42-
packages/js/os @dOrgJelli
43-
packages/js/plugin @nerfZael @dOrgJelli
44-
packages/js/react @dOrgJelli @nerfZael
45-
packages/js/result @nerfZael
46-
packages/js/test-env @dOrgJelli @krisbitney @cbrzn @namesty
47-
packages/js/tracing @dOrgJelli @Niraj-Kamdar @fetsorn
48-
packages/js/uri-resolver-extensions @nerfZael
49-
packages/js/uri-resolvers @nerfZael
50-
packages/js/validation @nerfZael @cbrzn
51-
packages/js/wasm @nerfZael @dOrgJelli
52-
53-
# JS Plugins
54-
packages/js/plugins/ethereum @dOrgJelli @krisbitney @namesty
55-
packages/js/plugins/file-system @krisbitney @dOrgJelli @Niraj-Kamdar @cbrzn
56-
packages/js/plugins/http @dOrgJelli @ramilexe @cbrzn @namesty @krisbitney
57-
packages/js/plugins/ipfs @dOrgJelli @krisbitney @nerfZael
58-
packages/js/plugins/ws @dOrgJelli @nerfZael @fetsorn
59-
packages/js/plugins/uri-resolvers/ens-resolver @nerfZael @pileks @krisbitney @cbrzn @dOrgJelli
60-
packages/js/plugins/uri-resolvers/file-system-resolver @pileks @dOrgJelli @nerfZael @cbrzn @krisbitney
61-
packages/js/plugins/uri-resolvers/http-resolver @namesty @krisbitney @nerfZael
62-
packages/js/plugins/uri-resolvers/ipfs-resolver @pileks @nerfZael @dOrgJelli @cbrzn
1+
* @dOrgJelli @namesty @pileks

CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
# Polywrap Origin (0.12.1)
2+
## Features
3+
**`polywrap` CLI:**
4+
* [PR-1911](https://github.com/polywrap/cli/pull/1911) **Polywrap Manifest - Default Source Paths**
5+
* `polywrap.yaml` manifests can now omit the `source:` section and use the defaults defined by the CLI babsed on the manifest's `project.type` property.
6+
* [PR-1893](https://github.com/polywrap/cli/pull/1893) **Add `embed` option to `polywrap codegen`**
7+
* Adds the `--embed` option to `polywrap codegen` which embeds wrap modules into applications (requires wrap-abi-bindgen support).
8+
9+
## Bugs
10+
**`polywrap` CLI:**
11+
* [PR-1913](https://github.com/polywrap/cli/pull/1913) **Use Sys Bundle IPFS Providers in CLI**
12+
113
# Polywrap Origin (0.12.0)
214
## Breaking Changes
315
**`@polywrap/schema-bind`:**

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.12.0
1+
0.12.1

WRAP_TEST_HARNESS

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
kris/test-wrap-rust-2
1+
master

packages/cli/lang/en.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@
8282
"commands_codegen_description": "Generate Code For Polywrap Projects",
8383
"commands_codegen_error_domain": "domain",
8484
"commands_codegen_error_optionMissingArgument": "{option} option missing {argument} argument",
85+
"commands_codegen_error_embedAppOnly": "The --embed option is currently only available for app projects",
8586
"commands_codegen_options_codegen": "Output directory for the generated code (default: {default})",
86-
"commands_codegen_options_e": "ENS address to lookup external schemas (default: 0x0000...2e1e)",
87-
"commands_codegen_options_e_address": "address",
87+
"commands_codegen_options_e": "Locally embed Wasm wraps",
8888
"commands_codegen_options_h": "Show usage information",
8989
"commands_codegen_options_s": "Path to a custom generation script (JavaScript | TypeScript)",
9090
"commands_codegen_options_i": "IPFS node to load external schemas (default: ipfs.io & localhost)",
@@ -272,6 +272,8 @@
272272
"lib_project_app_uri_support": "The app command supports only filesystem URIs for plugins. Examples:",
273273
"lib_project_imported_plugin_manifest_not_found": "No manifest found for imported plugin namespace `{namespace}` at path `{path}`",
274274
"lib_project_invalid_uri": "Invalid URI Received:",
275+
"lib_project_no_default_schema": "Couldn't find schema in default paths. Please specify the schema location in the project manifest.",
276+
"lib_project_no_default_module": "Couldn't find module entry point in default paths. Please specify the module entry point in the project manifest.",
275277
"lib_typescript_notInstalled": "Your project uses typescript, but it's not installed",
276278
"lib_typescript_tsNodeNotInstalled": "Your project uses typescript, but ts-node is not installed",
277279
"lib_watcher_alreadyWatching": "Watcher session is already in progress. Directory: {dir}",

packages/cli/lang/es.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@
8282
"commands_codegen_description": "Generate Code For Polywrap Projects",
8383
"commands_codegen_error_domain": "domain",
8484
"commands_codegen_error_optionMissingArgument": "{option} option missing {argument} argument",
85+
"commands_codegen_error_embedAppOnly": "The --embed option is currently only available for app projects",
8586
"commands_codegen_options_codegen": "Output directory for the generated code (default: {default})",
86-
"commands_codegen_options_e": "ENS address to lookup external schemas (default: 0x0000...2e1e)",
87-
"commands_codegen_options_e_address": "address",
87+
"commands_codegen_options_e": "Locally embed Wasm wraps",
8888
"commands_codegen_options_h": "Show usage information",
8989
"commands_codegen_options_s": "Path to a custom generation script (JavaScript | TypeScript)",
9090
"commands_codegen_options_i": "IPFS node to load external schemas (default: ipfs.io & localhost)",
@@ -272,6 +272,8 @@
272272
"lib_project_app_uri_support": "The app command supports only filesystem URIs for plugins. Examples:",
273273
"lib_project_imported_plugin_manifest_not_found": "No manifest found for imported plugin namespace `{namespace}` at path `{path}`",
274274
"lib_project_invalid_uri": "Invalid URI Received:",
275+
"lib_project_no_default_schema": "Couldn't find schema in default paths. Please specify the schema location in the project manifest.",
276+
"lib_project_no_default_module": "Couldn't find module entry point in default paths. Please specify the module entry point in the project manifest.",
275277
"lib_typescript_notInstalled": "Your project uses typescript, but it's not installed",
276278
"lib_typescript_tsNodeNotInstalled": "Your project uses typescript, but ts-node is not installed",
277279
"lib_watcher_alreadyWatching": "Watcher session is already in progress. Directory: {dir}",

packages/cli/src/__tests__/e2e/p2/codegen.spec.ts

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Options:
1919
-b, --bindgen <URI> Uri for custom bindgen wrap (must
2020
implement wrap-abi-bindgen interface; see
2121
https://github.com/polywrap/wrap-abi-bindgen)
22+
-e, --embed Locally embed Wasm wraps
2223
-s, --script <path> Path to a custom generation script
2324
(JavaScript | TypeScript)
2425
-c, --client-config <config-path> Add custom configuration to the

packages/cli/src/commands/build.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,15 @@ export const build: Command = {
132132
async function validateManifestModules(polywrapManifest: PolywrapManifest) {
133133
if (
134134
polywrapManifest.project.type !== "interface" &&
135-
!polywrapManifest.source.module
135+
!polywrapManifest.source?.module
136136
) {
137137
const missingModuleMessage = intlMsg.lib_compiler_missingModule();
138138
throw Error(missingModuleMessage);
139139
}
140140

141141
if (
142142
polywrapManifest.project.type === "interface" &&
143-
polywrapManifest.source.module
143+
polywrapManifest.source?.module
144144
) {
145145
const noInterfaceModule = intlMsg.lib_compiler_noInterfaceModule();
146146
throw Error(noInterfaceModule);
@@ -242,11 +242,12 @@ async function run(options: Required<BuildCommandOptions>) {
242242
project,
243243
client,
244244
});
245+
const abi = await schemaComposer.getComposedAbis();
245246

246247
if (canRunCodegen && !noCodegen) {
247248
const codeGenerator = new CodeGenerator({
248249
project,
249-
schemaComposer,
250+
abi,
250251
codegenDirAbs: codegenDir || undefined,
251252
bindgenUri,
252253
});
@@ -261,7 +262,7 @@ async function run(options: Required<BuildCommandOptions>) {
261262
const compiler = new Compiler({
262263
project: project as PolywrapProject,
263264
outputDir,
264-
schemaComposer,
265+
abi,
265266
buildStrategy,
266267
});
267268

packages/cli/src/commands/codegen.ts

+21-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import {
1414
defaultPolywrapManifestFiles,
1515
parseLogFileOption,
1616
parseWrapperEnvsOption,
17+
WasmEmbed,
18+
getWasmEmbeds,
1719
} from "../lib";
1820
import { ScriptCodegenerator } from "../lib/codegen/ScriptCodeGenerator";
1921
import { DEFAULT_CODEGEN_DIR } from "../lib/defaults";
@@ -29,6 +31,7 @@ export interface CodegenCommandOptions extends BaseCommandOptions {
2931
manifestFile: string;
3032
codegenDir: string | false;
3133
bindgen: string | false;
34+
embed: boolean | false;
3235
script: string | false;
3336
clientConfig: string | false;
3437
wrapperEnvs: string | false;
@@ -54,6 +57,7 @@ export const codegen: Command = {
5457
})}`
5558
)
5659
.option(`-b, --bindgen <URI>`, `${intlMsg.commands_codegen_options_b()}`)
60+
.option(`-e, --embed`, `${intlMsg.commands_codegen_options_e()}`)
5761
.option(
5862
`-s, --script <${pathStr}>`,
5963
`${intlMsg.commands_codegen_options_s()}`
@@ -81,6 +85,7 @@ export const codegen: Command = {
8185
),
8286
codegenDir: parseDirOptionNoDefault(options.codegenDir),
8387
bindgen: options.bindgen || false,
88+
embed: options.embed || false,
8489
script: parseCodegenScriptOption(options.script),
8590
clientConfig: options.clientConfig || false,
8691
wrapperEnvs: options.wrapperEnvs || false,
@@ -100,6 +105,7 @@ async function run(options: Required<CodegenCommandOptions>) {
100105
wrapperEnvs,
101106
codegenDir,
102107
bindgen,
108+
embed,
103109
script,
104110
verbose,
105111
quiet,
@@ -133,21 +139,34 @@ async function run(options: Required<CodegenCommandOptions>) {
133139
project,
134140
client,
135141
});
142+
const abi = await schemaComposer.getComposedAbis();
143+
144+
const projectLang = await project.getManifestLanguage();
145+
if (embed && !projectLang.startsWith("app")) {
146+
logger.error(intlMsg.commands_codegen_error_embedAppOnly());
147+
process.exit(1);
148+
}
149+
150+
const embeds: WasmEmbed[] | undefined =
151+
embed && abi.importedModuleTypes
152+
? await getWasmEmbeds(abi.importedModuleTypes, client, logger)
153+
: undefined;
136154

137155
const codeGenerator = script
138156
? new ScriptCodegenerator({
139157
codegenDirAbs: codegenDir || undefined,
140158
script,
141-
schemaComposer,
159+
abi,
142160
project,
143161
omitHeader: false,
144162
mustacheView: undefined,
145163
})
146164
: new CodeGenerator({
147165
codegenDirAbs: codegenDir || undefined,
148-
schemaComposer,
166+
abi,
149167
project,
150168
bindgenUri,
169+
embeds,
151170
});
152171

153172
const execute = async (): Promise<boolean> => {

packages/cli/src/lib/Compiler.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
PolywrapProject,
99
PluginProject,
1010
resetDir,
11-
SchemaComposer,
1211
logActivity,
1312
loadDocsManifest,
1413
} from "./";
@@ -21,12 +20,13 @@ import fs from "fs";
2120
import fse from "fs-extra";
2221
import path from "path";
2322
import { DocsManifest } from "@polywrap/polywrap-manifest-types-js";
23+
import { Abi } from "@polywrap/schema-parse";
2424

2525
export interface CompilerConfig {
2626
outputDir: string;
2727
project: PolywrapProject | PluginProject;
2828
buildStrategy?: BuildStrategy;
29-
schemaComposer: SchemaComposer;
29+
abi: Abi;
3030
}
3131

3232
export class Compiler {
@@ -111,13 +111,12 @@ export class Compiler {
111111
}
112112

113113
private async _outputWrapManifest(): Promise<unknown> {
114-
const { outputDir, project, schemaComposer } = this._config;
114+
const { outputDir, project, abi } = this._config;
115115
const manifestPath = `${outputDir}/wrap.info`;
116116
const run = async () => {
117117
const manifest = await project.getManifest();
118118

119119
const type = manifest.project.type.split("/")[0];
120-
const abi = await schemaComposer.getComposedAbis();
121120
await generateWrapFile(
122121
abi,
123122
manifest.project.name,

packages/cli/src/lib/SchemaComposer.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export class SchemaComposer {
7373
private _abiResolver(
7474
schemaFile: SchemaFile,
7575
importFrom: string,
76-
import_abis?: PolywrapManifest["source"]["import_abis"]
76+
import_abis?: NonNullable<PolywrapManifest["source"]>["import_abis"]
7777
): Promise<WrapAbi | SchemaFile> {
7878
if (Uri.isValidUri(importFrom)) {
7979
return this._resolveUri(importFrom, import_abis);
@@ -97,7 +97,7 @@ export class SchemaComposer {
9797

9898
private async _resolveUri(
9999
uri: string,
100-
import_abis?: PolywrapManifest["source"]["import_abis"]
100+
import_abis?: NonNullable<PolywrapManifest["source"]>["import_abis"]
101101
): Promise<WrapAbi> {
102102
// Check to see if we have any import redirects that match
103103
if (import_abis) {
@@ -155,7 +155,7 @@ export class SchemaComposer {
155155

156156
private async _loadGraphqlAbi(
157157
path: string,
158-
import_abis: PolywrapManifest["source"]["import_abis"]
158+
import_abis: NonNullable<PolywrapManifest["source"]>["import_abis"]
159159
): Promise<WrapAbi> {
160160
const schema = fs.readFileSync(path, "utf-8");
161161

packages/cli/src/lib/codegen/CodeGenerator.ts

+13-5
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,21 @@ import {
1515
Project,
1616
} from "../project";
1717
import { resetDir } from "../system";
18-
import { SchemaComposer } from "../SchemaComposer";
1918
import { CodegenOverrides, tryGetCodegenOverrides } from "./CodegenOverrides";
19+
import { WasmEmbed } from "./WasmEmbed";
2020

2121
import path from "path";
2222
import { BindLanguage } from "@polywrap/schema-bind";
2323
import { writeDirectorySync } from "@polywrap/os-js";
2424
import { Uri } from "@polywrap/core-js";
25+
import { Abi } from "@polywrap/schema-parse";
2526

2627
export interface CodeGeneratorConfig {
2728
project: Project<AnyProjectManifest>;
28-
schemaComposer: SchemaComposer;
29+
abi: Abi;
2930
codegenDirAbs?: string;
3031
bindgenUri?: Uri;
32+
embeds?: WasmEmbed[];
3133
}
3234

3335
export class CodeGenerator {
@@ -88,13 +90,19 @@ export class CodeGenerator {
8890
)
8991
: undefined;
9092

91-
const bindConfig = overrides
93+
let bindConfig = overrides
9294
? await overrides.getSchemaBindConfig(this._config.project)
9395
: {};
9496

95-
const abi = await this._config.schemaComposer.getComposedAbis();
97+
if (this._config.embeds) {
98+
bindConfig = {
99+
...bindConfig,
100+
embeds: this._config.embeds,
101+
};
102+
}
103+
96104
const binding = await this._config.project.generateSchemaBindings(
97-
abi,
105+
this._config.abi,
98106
codegenDir,
99107
this._config.bindgenUri?.toString(),
100108
bindConfig

0 commit comments

Comments
 (0)