Skip to content

[WIP] Drag and Drop Editing and Sample Editor #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 59 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
8fa423e
Save off progress
adierkens Oct 19, 2022
8ab70a3
Save state
adierkens Nov 8, 2022
14ddc32
Use XLR
KetanReddy Nov 21, 2022
15592ea
Restyle and edit dropped assets
KetanReddy Jan 5, 2023
46f5c66
WIP: scaffold for filling in required properties on assets
KetanReddy Jan 5, 2023
4a8c4fc
Add sample property panel
adierkens Jan 5, 2023
6677c55
Cleanup modal for required props
KetanReddy Jan 6, 2023
495cb80
Modal for showing generated view
KetanReddy Jan 6, 2023
c8769ac
Sidebar docs for assets
KetanReddy Jan 6, 2023
6452bb0
reorg so production build passes
KetanReddy Jan 12, 2023
5df2d9b
Undo removing workflows
KetanReddy Jan 17, 2023
c15841d
fix build - prevent webpack from default .mjs handling
sugarmanz Jan 17, 2023
aecfd37
fix failing tests
KetanReddy Jan 18, 2023
42ac533
Update to latest player version
adierkens Jan 20, 2023
d858b80
Use applyReact instead of applyWeb
adierkens Jan 21, 2023
364981f
Move Test Helpers out of `@player-tools/xlr-utils`
sandrews06 Jan 25, 2023
aa8508a
fix: Import existing content into drag and drop
Feb 1, 2023
263236b
fix: change addDndStateToAsset to return a new view
Feb 2, 2023
8656b6d
Bump player and react types version. Fix new type errors
KetanReddy Feb 1, 2023
432826c
forward parameters to synthetic node for arrow functions with parameters
hborawski Jan 18, 2023
038ffd6
rename test
hborawski Jan 18, 2023
76d4e20
run yarn before bazel test to link deps for flipper
hborawski Jan 18, 2023
f4f11cc
fix function aliasing exporting wrong name
hborawski Jan 19, 2023
ba30ca2
update snapshot name
hborawski Jan 20, 2023
6a59fd8
compare against XLR node instead of TS Type
hborawski Jan 20, 2023
1a9e098
fix import that was changed by vscode
hborawski Jan 20, 2023
9522752
Reorg xlr compile target, support player specific post processing (#29)
KetanReddy Jan 26, 2023
b8a4975
Try and fix release stage
KetanReddy Jan 26, 2023
780252d
Release main
intuit-svc Jan 27, 2023
cc06653
Update CHANGELOG.md [skip ci]
intuit-svc Jan 27, 2023
3c9fe64
Bump version to: v0.3.0 [skip ci]
intuit-svc Jan 27, 2023
545d24d
add forked pr workflow
KetanReddy Feb 1, 2023
449d4ec
Support for Arrays and Collections
KetanReddy Feb 2, 2023
46ac221
Update CODEOWNERS
KetanReddy Feb 2, 2023
dd662e2
support for arrays
Feb 6, 2023
b6972ff
Fix dropped imports
KetanReddy Feb 6, 2023
b68cb2b
Merge branch 'main' into feature/drag-and-drop
KetanReddy Feb 6, 2023
c544e2e
Transform `values` key out to prevent Player from parsing it
KetanReddy Feb 6, 2023
3ec921c
Merge branch 'feature/drag-and-drop' of github.com:player-ui/tools in…
KetanReddy Feb 6, 2023
15d296b
Merge branch 'main' into feature/drag-and-drop
sandrews2 Feb 7, 2023
1a61a36
test: added test-helpers for xlr/utils
sandrews2 Feb 7, 2023
d52ac66
Merge pull request #44 from sandrews06/feature/drag-and-drop
KetanReddy Feb 7, 2023
94ed219
Also take out any XLR info during the beforeResolve phase for drop-ta…
KetanReddy Feb 8, 2023
3dcda7b
pass a callback to handle Drag and Drop state changes
Feb 17, 2023
fda1541
fix: Populates placeholder targets when importing existing content
Feb 22, 2023
bbdf3fb
fix: moved removeDndStateFromView to a helper function
Feb 23, 2023
de99318
Merge pull request #46 from chengliwang/feat-pass-a-callback-function…
KetanReddy Feb 23, 2023
50b36f1
feat: added ability to add player plugins that don't have a manifest …
sandrews06 Feb 27, 2023
d87a1b9
Merge branch 'main' of github.com:player-ui/tools into feature/drag-a…
KetanReddy Feb 27, 2023
e2844eb
Merge branch 'feature/drag-and-drop' of github.com:player-ui/tools in…
KetanReddy Feb 27, 2023
e12d2c6
maintenance: move testing helpers into shared local package
KetanReddy Feb 27, 2023
9d63cb3
move xlr deserialization out of sdk and in to cli
KetanReddy Feb 27, 2023
642c295
Run standard player transforms on XLR import
KetanReddy Mar 3, 2023
4ee940e
Add APIs for more operations, expose subscribe function
KetanReddy Mar 9, 2023
8fd2493
defer adding XLR info to transform
KetanReddy May 16, 2023
aa7f9c7
Fix bug preventing changing the asset being edited after updating an …
KetanReddy May 16, 2023
2a33ba9
Place Assets from side bar (doesn't update sidebar though)
KetanReddy May 17, 2023
922c223
Fix sidebar updates
adierkens May 23, 2023
a4bda88
Fix asset selecting not working
KetanReddy May 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Fallback
* @adierkens
* @KetanReddy

# Language
language/ @KetanReddy @adierkens
cli/ @KetanReddy @adierkens

# XLR
xlr/ @KetanReddy
drag-and-drop/ @KetanReddy @adierkens

# DevTools
devtools/ @sugarmanz
12 changes: 5 additions & 7 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ workspace(
},
)

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

http_archive(
name = "rules_player",
strip_prefix = "rules_player-0.10.0",
urls = ["https://github.com/player-ui/rules_player/archive/refs/tags/v0.10.0.tar.gz"],
sha256 = "73597c76a5ceb6c1f84735e0e086792e4695759c62c22f45e13041862c6b0c33"
git_repository(
name = "rules_player",
remote = "https://github.com/player-ui/rules_player.git",
branch = "esm-native-builds"
)

load("@rules_player//:workspace.bzl", "deps")

deps()
Expand Down
85 changes: 82 additions & 3 deletions cli/src/commands/xlr/convert.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { Flags } from '@oclif/core';
import path from 'path';
import fs from 'fs';
import ts from 'typescript';
import chalk from 'chalk';
import type { ExportTypes } from '@player-tools/xlr-sdk';
import { XLRSDK } from '@player-tools/xlr-sdk';
import logSymbols from 'log-symbols';
import type { NamedType } from '@player-tools/xlr';
import type { TopLevelDeclaration } from '@player-tools/xlr-utils';
import { TSWriter } from '@player-tools/xlr-converters';
import { BaseCommand } from '../../utils/base-command';

const PlayerImportMap = new Map([
Expand Down Expand Up @@ -39,6 +43,8 @@ export default class XLRConvert extends BaseCommand {
}),
};

private tsWriter = new TSWriter();

private async getOptions() {
const { flags } = await this.parse(XLRConvert);

Expand All @@ -51,7 +57,7 @@ export default class XLRConvert extends BaseCommand {
const language = flags.lang as ExportTypes;

if (!language) {
throw new Error(`Need to specifiy lanauge to export to`);
throw new Error(`Need to specify language to export to`);
}

return {
Expand All @@ -61,6 +67,71 @@ export default class XLRConvert extends BaseCommand {
};
}

private exportToTypeScript(
typesToExport: NamedType[],
importMap: Map<string, string[]>
): string {
const referencedImports: Set<string> = new Set();
const exportedTypes: Map<string, TopLevelDeclaration> = new Map();
const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed });

let resultFile = ts.createSourceFile(
'output.d.ts',
'',
ts.ScriptTarget.ES2017,
false, // setParentNodes
ts.ScriptKind.TS
);

typesToExport.forEach((typeNode) => {
const { type, referencedTypes, additionalTypes } =
this.tsWriter.convertNamedType(typeNode);
exportedTypes.set(typeNode.name, type);
additionalTypes?.forEach((additionalType, name) =>
exportedTypes.set(name, additionalType)
);
referencedTypes?.forEach((referencedType) =>
referencedImports.add(referencedType)
);
});

const typesToPrint: Array<string> = [];

exportedTypes.forEach((type) =>
typesToPrint.push(
printer.printNode(ts.EmitHint.Unspecified, type, resultFile)
)
);

importMap.forEach((imports, packageName) => {
const applicableImports = imports.filter((i) => referencedImports.has(i));
resultFile = ts.factory.updateSourceFile(resultFile, [
ts.factory.createImportDeclaration(
/* modifiers */ undefined,
ts.factory.createImportClause(
false,
undefined,
ts.factory.createNamedImports(
applicableImports.map((i) =>
ts.factory.createImportSpecifier(
false,
undefined,
ts.factory.createIdentifier(i)
)
)
)
),
ts.factory.createStringLiteral(packageName)
),
...resultFile.statements,
]);
});

const headerText = printer.printFile(resultFile);
const nodeText = typesToPrint.join('\n');
return `${headerText}\n${nodeText}`;
}

async run(): Promise<{
/** the status code */
exitCode: number;
Expand All @@ -73,8 +144,16 @@ export default class XLRConvert extends BaseCommand {

const sdk = new XLRSDK();
sdk.loadDefinitionsFromDisk(inputPath);
const files = sdk.exportRegistry(language, PlayerImportMap);
files.forEach(([filename, fileContents]) => {
const types = sdk.exportRegistry();
let writtenFiles;
if (language === 'TypeScript') {
const outputString = this.exportToTypeScript(types, PlayerImportMap);
writtenFiles = [['out.d.ts', outputString]];
} else {
throw new Error(`Unknown export format ${language}`);
}

writtenFiles.forEach(([filename, fileContents]) => {
fs.writeFileSync(path.join(outputDir, filename), fileContents, {});
});
} catch (e: any) {
Expand Down
4 changes: 4 additions & 0 deletions drag-and-drop/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Drag and Drop

This is a collection of utility libraries and reference integrations for constructing a drag-and-drop editor for Player content.

52 changes: 52 additions & 0 deletions drag-and-drop/app/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
load("@npm//next:index.bzl", "next")
load("@rules_player//javascript/next:next_build.bzl", "next_export")

package(default_visibility = ["//visibility:public"])

srcs = glob([
"public/**/*",
"pages/**/*",
"styles/*",
"components/**/*",
"plugins/*",
"utils/*",
"config/*",
]) + [
"next.config.mjs",
"next-env.d.ts",
"tsconfig.json"
]

data = [
"//drag-and-drop/library:@player-tools/dnd-lib",
"@npm//@player-ui/types",
"@npm//typescript",
"@npm//@chakra-ui/react",
"@npm//@player-ui/reference-assets-plugin-react",
"@npm//@types/react",
"@npm//@types/node",
"@npm//timm",
"@npm//react-syntax-highlighter",
"@npm//react-docgen-typescript",
"@npm//react-files"
]

next_export(
name = "site",
data = data,
srcs = srcs,
env = {
"NODE_ENV": "production",
# Need this b/c next will pull from env directly
# This just maps to a value we can stamp w/ later on
"NEXT_PUBLIC_GA_MEASUREMENT_ID": "NEXT_PUBLIC_GA_MEASUREMENT_ID",
},
)

next(
name = "start",
args = [
"dev", './drag-and-drop/app'
],
data = data + srcs,
)
Loading