Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
* [jsfm] Adjust the file structure of js framework
Browse files Browse the repository at this point in the history
1. Rename `html5/` to `runtime/` and move api, bridge, vdom out:

  rename: html5/frameworks       -> runtime/frameworks
  rename: html5/runtime/api      -> runtime/api
  rename: html5/runtime/bridge   -> runtime/bridge
  rename: html5/runtime/vdom     -> runtime/vdom
  rename: html5/runtime/utils.js -> runtime/shared/utils.js
  rename: html5/services         -> runtime/services
  rename: html5/shared           -> runtime/shared

2. Delete `html5/render/`, move it to `entries`:

  delete: html5/render/
  rename: html5/runtime/index.js       -> runtime/entries/runtime.js
  rename: html5/render/native/index.js -> runtime/entries/index.js
  rename: html5/render/native/setup.js -> runtime/entries/setup.js

3. Move `html5/test` into `test/` folder:

  rename: html5/test -> test/js-framework
  • Loading branch information
Hanks10100 committed Dec 29, 2017
1 parent dc42844 commit 51dd277
Show file tree
Hide file tree
Showing 232 changed files with 135 additions and 100 deletions.
3 changes: 0 additions & 3 deletions html5/render/vue/README.md

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 3 additions & 18 deletions html5/runtime/index.js → runtime/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,12 @@
* under the License.
*/

/**
* @fileOverview
* Register framework(s) in JS runtime. Weex supply two layers for 3rd-party
* framework(s): one is the instance management layer, another is the
* virtual-DOM layer.
*/

import * as shared from '../shared'

import init from './api/init'
import config from './api/config'
import { register, unregister, has } from './api/service'
import init from './init'
import config from './config'
import { register, unregister, has } from './service'

/* istanbul ignore next */
function freezePrototype () {
shared.freezePrototype()

// Object.freeze(config.Element)
Object.freeze(config.Comment)
Object.freeze(config.Listener)
Expand All @@ -44,10 +33,6 @@ function freezePrototype () {
}

export default {
setNativeConsole: shared.setNativeConsole,
resetNativeConsole: shared.resetNativeConsole,
setNativeTimer: shared.setNativeTimer,
resetNativeTimer: shared.resetNativeTimer,
service: { register, unregister, has },
freezePrototype,
init,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import CallbackManager from './CallbackManager'
import Element from '../vdom/Element'
import { typof } from '../utils'
import { typof } from '../shared/utils'
import { normalizePrimitive } from './normalize'

let fallback = function () {}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { typof, bufferToBase64, base64ToBuffer } from '../utils'
import { typof, bufferToBase64, base64ToBuffer } from '../shared/utils'

/**
* Normalize a primitive value.
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion html5/render/native/index.js → runtime/entries/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/

import setup from './setup'
import frameworks from '../../frameworks/index'
import frameworks from '../frameworks'

setup(frameworks)
23 changes: 23 additions & 0 deletions runtime/entries/rax.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import setup from './setup'
import * as Rax from 'weex-rax-framework'

setup({ Rax })
10 changes: 6 additions & 4 deletions html5/render/native/setup.js → runtime/entries/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
* under the License.
*/

import { subversion } from '../../../package.json'
import runtime from '../../runtime'
import services from '../../services/index'
import { subversion } from '../../package.json'
import * as shared from '../shared'
import runtime from '../api'
import services from '../services'

/**
* Setup frameworks with runtime.
Expand All @@ -35,8 +36,9 @@ export default function (frameworks) {
runtime.service.register(serviceName, services[serviceName])
}

shared.freezePrototype()
shared.setNativeConsole()
runtime.freezePrototype()
runtime.setNativeConsole()

// register framework meta info
global.frameworkVersion = native
Expand Down
23 changes: 23 additions & 0 deletions runtime/entries/vue.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import setup from './setup'
import * as Vue from 'weex-vue-framework'

setup({ Vue })
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
15 changes: 8 additions & 7 deletions html5/shared/index.js → runtime/shared/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@
* specific language governing permissions and limitations
* under the License.
*/
import './arrayFrom'
import './objectAssign'
import './objectSetPrototypeOf'

import './polyfill/arrayFrom'
import './polyfill/objectAssign'
import './polyfill/objectSetPrototypeOf'

// import promise hack and polyfills
import './promise'
import './polyfill/promise'
import 'core-js/modules/es6.object.to-string'
import 'core-js/modules/es6.string.iterator'
import 'core-js/modules/web.dom.iterable'
import 'core-js/modules/es6.promise'

export * from './console'
export * from './setTimeout'
export * from './freeze'
export * from './env/console'
export * from './env/setTimeout'
export * from './env/freeze'
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion html5/runtime/vdom/Comment.js → runtime/vdom/Comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import Node from './Node'
import { uniqueId } from '../utils'
import { uniqueId } from '../shared/utils'

export default class Comment extends Node {
constructor (value) {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion html5/runtime/vdom/Element.js → runtime/vdom/Element.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
moveIndex,
removeIndex
} from './operation'
import { uniqueId, isEmpty } from '../utils'
import { uniqueId, isEmpty } from '../shared/utils'
import { getWeexElement, setElement } from './WeexElement'

const DEFAULT_TAG_NAME = 'div'
Expand Down
2 changes: 1 addition & 1 deletion html5/runtime/vdom/Node.js → runtime/vdom/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { uniqueId } from '../utils'
import { uniqueId } from '../shared/utils'
import { getDoc } from './operation'

export default class Node {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions html5/test/case/prepare.js → test/js-framework/case/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ import {
} from 'weex-vdom-tester'

// load env
import shared from '../../shared'
import { Document, Element, Comment } from '../../runtime/vdom'
import Listener from '../../runtime/bridge/Listener'
import { TaskCenter, init } from '../../runtime/bridge/TaskCenter'
import shared from '../../../runtime/shared'
import { Document, Element, Comment } from '../../../runtime/vdom'
import Listener from '../../../runtime/bridge/Listener'
import { TaskCenter, init } from '../../../runtime/bridge/TaskCenter'

// load framework
import * as defaultFramework from '../../frameworks/legacy'
import * as defaultFramework from '../../../runtime/frameworks/legacy'
import { subversion } from '../../../package.json'

shared.setNativeConsole()
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import sinonChai from 'sinon-chai'
const { expect } = chai
chai.use(sinonChai)

import '../../../../shared/console'
import * as modules from '../../../../frameworks/legacy/api/modules'
import * as methods from '../../../../frameworks/legacy/api/methods'
import Differ from '../../../../frameworks/legacy/app/differ'
import { initModules, requireModule, clearModules, initMethods } from '../../../../frameworks/legacy/app/register'
import '../../../../../runtime/shared/env/console'
import * as modules from '../../../../../runtime/frameworks/legacy/api/modules'
import * as methods from '../../../../../runtime/frameworks/legacy/api/methods'
import Differ from '../../../../../runtime/frameworks/legacy/app/differ'
import { initModules, requireModule, clearModules, initMethods } from '../../../../../runtime/frameworks/legacy/app/register'

function Vm () {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import chai from 'chai'
const { expect } = chai

import * as modules from '../../../../frameworks/legacy/api/modules'
import { initModules, requireModule, clearModules } from '../../../../frameworks/legacy/app/register'
import * as modules from '../../../../../runtime/frameworks/legacy/api/modules'
import { initModules, requireModule, clearModules } from '../../../../../runtime/frameworks/legacy/app/register'

describe('built-in modules', () => {
before(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import sinonChai from 'sinon-chai'
const { expect } = chai
chai.use(sinonChai)

import * as bundle from '../../../../frameworks/legacy/app/bundle'
import * as register from '../../../../frameworks/legacy/app/register'
import { removeWeexPrefix } from '../../../../frameworks/legacy/util'
import { Document } from '../../../../runtime/vdom'
import Listener from '../../../../runtime/bridge/Listener'
import * as bundle from '../../../../../runtime/frameworks/legacy/app/bundle'
import * as register from '../../../../../runtime/frameworks/legacy/app/register'
import { removeWeexPrefix } from '../../../../../runtime/frameworks/legacy/util'
import { Document } from '../../../../../runtime/vdom'
import Listener from '../../../../../runtime/bridge/Listener'

describe('parsing a bundle file', () => {
const componentTemplate = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import sinonChai from 'sinon-chai'
const { expect } = chai
chai.use(sinonChai)

import * as ctrl from '../../../../frameworks/legacy/app/ctrl'
import Differ from '../../../../frameworks/legacy/app/differ'
import { Document } from '../../../../runtime/vdom'
import * as ctrl from '../../../../../runtime/frameworks/legacy/app/ctrl'
import Differ from '../../../../../runtime/frameworks/legacy/app/differ'
import { Document } from '../../../../../runtime/vdom'

describe('the api of app', () => {
let app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import chai from 'chai'
const { expect } = chai

import * as Downgrade from '../../../../frameworks/legacy/app/downgrade'
import * as Downgrade from '../../../../../runtime/frameworks/legacy/app/downgrade'

describe('downgrade', () => {
describe('normalizeVersion', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import sinonChai from 'sinon-chai'
const { expect } = chai
chai.use(sinonChai)

import App from '../../../../frameworks/legacy/app'
import { Element, Document } from '../../../../runtime/vdom'
import App from '../../../../../runtime/frameworks/legacy/app'
import { Element, Document } from '../../../../../runtime/vdom'

describe('App Instance', () => {
const oriDocumentHandler = Document.handler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
requireModule,
requireCustomComponent,
registerCustomComponent
} from '../../../../frameworks/legacy/app/register'
} from '../../../../../runtime/frameworks/legacy/app/register'

function Ctx () {
this.customComponentMap = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import sinonChai from 'sinon-chai'
const { expect } = chai
chai.use(sinonChai)

import * as viewport from '../../../../frameworks/legacy/app/viewport'
import * as viewport from '../../../../../runtime/frameworks/legacy/app/viewport'

describe('viewport', function () {
const originalCallNative = global.callNative
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import chai from 'chai'
const { expect } = chai

import * as util from '../../../../frameworks/legacy/util'
import * as util from '../../../../../runtime/frameworks/legacy/util'

describe('Util', () => {
describe('isReserved', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
import { expect } from 'chai'

import * as utils from '../../../../frameworks/legacy/util/shared'
import * as utils from '../../../../../runtime/frameworks/legacy/util/shared'

describe('test util functions', () => {
it('extend', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import {
applyNaitveComponentOptions,
bindSubVm,
bindSubVmAfterInitialized
} from '../../../../frameworks/legacy/vm/directive'
} from '../../../../../runtime/frameworks/legacy/vm/directive'

import {
initState
} from '../../../../frameworks/legacy/core/state'
import config from '../../../../frameworks/legacy/config'
} from '../../../../../runtime/frameworks/legacy/core/state'
import config from '../../../../../runtime/frameworks/legacy/config'

const { nativeComponentMap } = config
const directive = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import {
attachTarget,
moveTarget,
removeTarget
} from '../../../../frameworks/legacy/vm/dom-helper'
import { Document } from '../../../../runtime/vdom'
import Listener from '../../../../runtime/bridge/Listener'
} from '../../../../../runtime/frameworks/legacy/vm/dom-helper'
import { Document } from '../../../../../runtime/vdom'
import Listener from '../../../../../runtime/bridge/Listener'

describe('help create body', () => {
let vm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import sinonChai from 'sinon-chai'
const { expect } = chai
chai.use(sinonChai)

import Vm from '../../../../frameworks/legacy/vm'
import { Document } from '../../../../runtime/vdom'
import Vm from '../../../../../runtime/frameworks/legacy/vm'
import { Document } from '../../../../../runtime/vdom'

describe('bind and fire events', () => {
let doc, customComponentMap, spy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import sinonChai from 'sinon-chai'
const { expect } = chai
chai.use(sinonChai)

import Vm from '../../../../frameworks/legacy/vm'
import { Document } from '../../../../runtime/vdom'
import { init as resetTaskHandler } from '../../../../runtime/bridge/TaskCenter'
import Differ from '../../../../frameworks/legacy/app/differ'
import Vm from '../../../../../runtime/frameworks/legacy/vm'
import { Document } from '../../../../../runtime/vdom'
import { init as resetTaskHandler } from '../../../../../runtime/bridge/TaskCenter'
import Differ from '../../../../../runtime/frameworks/legacy/app/differ'

const oriCallNative = global.callNative

Expand Down
Loading

0 comments on commit 51dd277

Please sign in to comment.