Skip to content

Commit 0ec49c5

Browse files
authored
Upgrade to lit 2 (#3405)
* upgrade to lit 2 * add license to spread directive * remove lit 2 binding artifacts from snippets * Update comment to match current comment style
1 parent 4734ba3 commit 0ec49c5

109 files changed

Lines changed: 2290 additions & 1014 deletions

File tree

Some content is hidden

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

packages/model-viewer/package-lock.json

Lines changed: 63 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/model-viewer/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@
7070
],
7171
"dependencies": {
7272
"three": "^0.139.2",
73-
"lit-element": "^2.5.1",
74-
"lit-html": "^1.4.1"
73+
"lit": "^2.2.3"
7574
},
7675
"devDependencies": {
7776
"@open-wc/karma-esm": "^4.0.0",

packages/model-viewer/src/assets/close-material-svg.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* limitations under the License.
1414
*/
1515

16-
import {html} from 'lit-html';
16+
import {html} from 'lit';
1717

1818
export default html`
1919
<svg xmlns="http://www.w3.org/2000/svg" width="24px" height="24px" viewBox="0 0 24 24" fill="#000000">

packages/model-viewer/src/assets/controls-svg.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* limitations under the License.
1414
*/
1515

16-
import {html} from 'lit-html';
16+
import {html} from 'lit';
1717

1818
export default html`
1919
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="25" height="36">

packages/model-viewer/src/assets/view-in-ar-material-svg.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* limitations under the License.
1414
*/
1515

16-
import {html} from 'lit-html';
16+
import {html} from 'lit';
1717

1818
export default html`
1919
<svg version="1.1" id="view_x5F_in_x5F_AR_x5F_icon"

packages/model-viewer/src/decorators.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@
1313
* limitations under the License.
1414
*/
1515

16-
import {UpdatingElement} from 'lit-element/lib/updating-element';
16+
import {ReactiveElement} from 'lit';
1717
import {EvaluatedStyle, Intrinsics, StyleEvaluator} from './styles/evaluators';
1818
import {parseExpressions, Unit} from './styles/parsers';
1919
import {StyleEffector} from './styles/style-effector';
2020

2121
// An IntrinsicsFactory generates up-to-date intrinsics for a given ModelViewer
2222
// element instance when it is invoked.
2323
export type IntrinsicsFactory<T extends Intrinsics<Array<Unit>>,
24-
U extends UpdatingElement> =
24+
U extends ReactiveElement> =
2525
(element: U) => T;
2626

2727
// When applying the @style decorator, it needs to be configured with
2828
// corresponding Intrinsics and the property key of a method to receive updated
2929
// values. Optionally, it can also be configured to observe environment effects,
3030
// which causes a StyleEffector to be created for the property.
3131
export interface StyleDecoratorConfig<T extends Intrinsics<Array<Unit>>,
32-
U extends UpdatingElement> {
32+
U extends ReactiveElement> {
3333
intrinsics: T|IntrinsicsFactory<T, U>;
3434
updateHandler: symbol;
3535
observeEffects?: boolean;
@@ -66,14 +66,14 @@ export interface StyleDecoratorConfig<T extends Intrinsics<Array<Unit>>,
6666
* static).
6767
*/
6868
export const style =
69-
<T extends Intrinsics<Array<Unit>>, U extends UpdatingElement>(
69+
<T extends Intrinsics<Array<Unit>>, U extends ReactiveElement>(
7070
config: StyleDecoratorConfig<T, U>) => {
7171
const observeEffects: boolean = config.observeEffects || false;
7272
const getIntrinsics = config.intrinsics instanceof Function ?
7373
config.intrinsics :
7474
(() => config.intrinsics) as IntrinsicsFactory<T, U>;
7575

76-
return <U extends typeof UpdatingElement['prototype']>(
76+
return <U extends typeof ReactiveElement['prototype']>(
7777
proto: U, propertyName: string) => {
7878
const originalUpdated = (proto as any).updated;
7979
const originalConnectedCallback = proto.connectedCallback;
@@ -93,7 +93,7 @@ export const style =
9393
[$updateEvaluator]: {
9494
value: function() {
9595
const ast = parseExpressions(
96-
this[propertyName as keyof UpdatingElement] as string);
96+
this[propertyName as keyof ReactiveElement] as string);
9797
this[$styleEvaluator] =
9898
new StyleEvaluator(ast, getIntrinsics(this));
9999

packages/model-viewer/src/features/animation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* limitations under the License.
1414
*/
1515

16-
import {property} from 'lit-element';
16+
import {property} from 'lit/decorators.js';
1717
import {LoopOnce, LoopPingPong, LoopRepeat} from 'three';
1818

1919
import ModelViewerElementBase, {$hasTransitioned, $needsRender, $onModelLoad, $renderer, $scene, $tick, $updateSource} from '../model-viewer-base.js';

packages/model-viewer/src/features/ar.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* limitations under the License.
1414
*/
1515

16-
import {property} from 'lit-element';
16+
import {property} from 'lit/decorators.js';
1717
import {Event as ThreeEvent} from 'three';
1818
import {USDZExporter} from 'three/examples/jsm/exporters/USDZExporter.js';
1919

packages/model-viewer/src/features/controls.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* limitations under the License.
1414
*/
1515

16-
import {property} from 'lit-element';
16+
import {property} from 'lit/decorators.js';
1717
import {Event, PerspectiveCamera, Spherical, Vector3} from 'three';
1818

1919
import {style} from '../decorators.js';
@@ -563,7 +563,8 @@ export const ControlsMixin = <T extends Constructor<ModelViewerElementBase>>(
563563
this.requestUpdate('fieldOfView');
564564
this.requestUpdate('minCameraOrbit');
565565
this.requestUpdate('maxCameraOrbit');
566-
await this.requestUpdate('cameraOrbit');
566+
this.requestUpdate('cameraOrbit');
567+
await this.updateComplete;
567568
}
568569

569570
[$syncFieldOfView](style: EvaluatedStyle<Intrinsics<['rad']>>) {
@@ -729,7 +730,8 @@ export const ControlsMixin = <T extends Constructor<ModelViewerElementBase>>(
729730

730731
controls.updateAspect(this[$scene].aspect);
731732

732-
await this.requestUpdate('maxFieldOfView', this.maxFieldOfView);
733+
this.requestUpdate('maxFieldOfView', this.maxFieldOfView);
734+
await this.updateComplete;
733735
this[$controls].setFieldOfView(fov);
734736

735737
this.jumpCameraToGoal();

packages/model-viewer/src/features/environment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* limitations under the License.
1414
*/
1515

16-
import {property} from 'lit-element';
16+
import {property} from 'lit/decorators.js';
1717
import {Event as ThreeEvent, Texture} from 'three';
1818

1919
import ModelViewerElementBase, {$needsRender, $onModelLoad, $progressTracker, $renderer, $scene, $shouldAttemptPreload} from '../model-viewer-base.js';

0 commit comments

Comments
 (0)