You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by gr...@apache.org on 2019/11/01 03:19:38 UTC
[royale-asjs] branch develop updated (9de0b62 -> a4d34bb)
This is an automated email from the ASF dual-hosted git repository.
gregdove pushed a change to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git.
from 9de0b62 add data property to ComboBox. Fixes #542
new 49696fb Add appropriate licence/attribution to Swiz for the 2 'QuickStart' Crux examples. Some of these include slight variations compared to the originals as the examples were also used for testing of different features during royale development.
new 22e00f9 Merge branch 'develop' of https://github.com/apache/royale-asjs into develop
new e6bc568 SharedObject emulation for JS that is closer to swf (i.e. uses AMF), plus a lighter-weight version that uses JSON serialization only (does not support roundtripping of custom classes)
new 43bf108 proxy display object 'contains' emulation via native DOM node 'contains'
new a4d34bb remove warnings for instanceof operator, and also fixed illogical comparison to undefined for typeof.
The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../main/royale/crux/quickstart/config/Beans.mxml | 32 +--
.../crux/quickstart/controller/UserController.as | 33 ++-
.../main/royale/crux/quickstart/event/UserEvent.as | 33 ++-
.../src/main/royale/crux/quickstart/model/User.as | 33 ++-
.../royale/crux/quickstart/service/UserService.as | 33 ++-
.../main/royale/crux/quickstart/view/UserForm.mxml | 32 +--
.../crux/quickstart/config/ActionscriptBeans.as | 34 ++-
.../main/royale/crux/quickstart/config/Beans.mxml | 32 +--
.../crux/quickstart/controller/UserController.as | 34 ++-
.../main/royale/crux/quickstart/event/UserEvent.as | 34 ++-
.../src/main/royale/crux/quickstart/model/User.as | 34 ++-
.../royale/crux/quickstart/service/UserService.as | 34 ++-
.../main/royale/crux/quickstart/view/UserForm.mxml | 32 +--
frameworks/projects/MXRoyale/pom.xml | 13 +-
.../MXRoyale/src/main/royale/MXRoyaleClasses.as | 1 +
.../src/main/royale/mx/core/UIComponent.as | 11 +-
.../src/main/royale/mx/managers/SystemManager.as | 13 +-
.../src/main/royale/mx/net/SharedObject.as | 251 ++++++++++++---------
.../src/main/royale/mx/net/SharedObjectJSON.as | 183 +++++++++++++++
.../main/royale/flexUnitTests/MXRoyaleTester.as | 4 +-
.../flexUnitTests/mxroyale/SharedObjectTest.as | 130 +++++++++++
21 files changed, 680 insertions(+), 356 deletions(-)
create mode 100644 frameworks/projects/MXRoyale/src/main/royale/mx/net/SharedObjectJSON.as
create mode 100644 manualtests/UnitTests/src/main/royale/flexUnitTests/mxroyale/SharedObjectTest.as
[royale-asjs] 02/05: Merge branch 'develop' of
https://github.com/apache/royale-asjs into develop
Posted by gr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gregdove pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
commit 22e00f9e45aa598316ec40a8aeb992450625c4b1
Merge: 49696fb 9de0b62
Author: greg-dove <gr...@gmail.com>
AuthorDate: Fri Nov 1 07:03:10 2019 +1300
Merge branch 'develop' of https://github.com/apache/royale-asjs into develop
.../src/main/royale/mx/controls/ComboBox.as | 118 +++++++++++++++++++++
.../main/royale/mx/controls/RadioButtonGroup.as | 2 +-
.../mx/controls/listClasses/AdvancedListBase.as | 6 +-
.../src/main/royale/mx/core/UIComponent.as | 13 ++-
.../royale/spark/components/beads/TabBarView.as | 104 ++++++++++++------
.../beads/controllers/TabBarController.as | 13 +--
.../supportClasses/SparkTextButtonItemRenderer.as | 1 -
7 files changed, 202 insertions(+), 55 deletions(-)
[royale-asjs] 04/05: proxy display object 'contains' emulation via
native DOM node 'contains'
Posted by gr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gregdove pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
commit 43bf108bdbdc71d963f406588b0249e5f181948d
Author: greg-dove <gr...@gmail.com>
AuthorDate: Fri Nov 1 15:30:29 2019 +1300
proxy display object 'contains' emulation via native DOM node 'contains'
---
.../MXRoyale/src/main/royale/mx/core/UIComponent.as | 11 +----------
.../MXRoyale/src/main/royale/mx/managers/SystemManager.as | 13 ++-----------
2 files changed, 3 insertions(+), 21 deletions(-)
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as b/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
index 85ea26d..54d1482 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
@@ -3477,16 +3477,7 @@ COMPILE::JS
}
COMPILE::JS
{
- var children:NodeList = element.childNodes;
- var n:int = children.length;
- var e:Object = child.element;
-
- for (var i:int = 0; i < n; i++)
- {
- if (children[i] == e)
- return true;
- }
- return false;
+ return element.contains(child.element);
}
}
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/managers/SystemManager.as b/frameworks/projects/MXRoyale/src/main/royale/mx/managers/SystemManager.as
index b9d7665..7b56f6d 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/managers/SystemManager.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/managers/SystemManager.as
@@ -96,7 +96,7 @@ import org.apache.royale.core.IPopUpHost;
import org.apache.royale.core.IPopUpHostParent;
import org.apache.royale.core.IUIBase;
import org.apache.royale.events.IEventDispatcher;
-import org.apache.royale.geom.Rectangle;
+import org.apache.royale.geom.Rectangle;
//--------------------------------------
// Events
@@ -3722,16 +3722,7 @@ public class SystemManager extends SystemManagerBase implements ISystemManager,
}
COMPILE::JS
{
- var children:NodeList = element.childNodes;
- var n:int = children.length;
- var e:Object = child.element;
-
- for (var i:int = 0; i < n; i++)
- {
- if (children[i] == e)
- return true;
- }
- return false;
+ return element.contains(child.element);
}
}
[royale-asjs] 01/05: Add appropriate licence/attribution to Swiz
for the 2 'QuickStart' Crux examples. Some of these include slight
variations compared to the originals as the examples were also used for
testing of different features during royale development.
Posted by gr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gregdove pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
commit 49696fbe19d78b7fbb8d4ab5e5f1b7efc3169e64
Author: greg-dove <gr...@gmail.com>
AuthorDate: Thu Oct 31 09:15:02 2019 +1300
Add appropriate licence/attribution to Swiz for the 2 'QuickStart' Crux examples.
Some of these include slight variations compared to the originals as the examples were also used for testing of different features during royale development.
---
.../main/royale/crux/quickstart/config/Beans.mxml | 32 ++++++++++----------
.../crux/quickstart/controller/UserController.as | 33 ++++++++++-----------
.../main/royale/crux/quickstart/event/UserEvent.as | 33 ++++++++++-----------
.../src/main/royale/crux/quickstart/model/User.as | 33 ++++++++++-----------
.../royale/crux/quickstart/service/UserService.as | 33 ++++++++++-----------
.../main/royale/crux/quickstart/view/UserForm.mxml | 32 ++++++++++----------
.../crux/quickstart/config/ActionscriptBeans.as | 34 ++++++++++------------
.../main/royale/crux/quickstart/config/Beans.mxml | 32 ++++++++++----------
.../crux/quickstart/controller/UserController.as | 34 ++++++++++------------
.../main/royale/crux/quickstart/event/UserEvent.as | 34 ++++++++++------------
.../src/main/royale/crux/quickstart/model/User.as | 34 ++++++++++------------
.../royale/crux/quickstart/service/UserService.as | 34 ++++++++++------------
.../main/royale/crux/quickstart/view/UserForm.mxml | 32 ++++++++++----------
13 files changed, 204 insertions(+), 226 deletions(-)
diff --git a/examples/crux/CruxQuickStart/src/main/royale/crux/quickstart/config/Beans.mxml b/examples/crux/CruxQuickStart/src/main/royale/crux/quickstart/config/Beans.mxml
index 854c72e..f5f262e 100644
--- a/examples/crux/CruxQuickStart/src/main/royale/crux/quickstart/config/Beans.mxml
+++ b/examples/crux/CruxQuickStart/src/main/royale/crux/quickstart/config/Beans.mxml
@@ -1,20 +1,20 @@
<!--
-
- 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.
-
+/*
+ * Copyright 2010 Swiz Framework Contributors
+ *
+ * Licensed 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. 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.
+ */
+// Apache Royale Crux example based on https://github.com/swiz/swiz-examples/tree/master/SwizQuickStartExample-Flex4
-->
<crux:BeanProvider
xmlns:fx="http://ns.adobe.com/mxml/2009"
diff --git a/examples/crux/CruxQuickStart/src/main/royale/crux/quickstart/controller/UserController.as b/examples/crux/CruxQuickStart/src/main/royale/crux/quickstart/controller/UserController.as
index de5c5b9..4677731 100644
--- a/examples/crux/CruxQuickStart/src/main/royale/crux/quickstart/controller/UserController.as
+++ b/examples/crux/CruxQuickStart/src/main/royale/crux/quickstart/controller/UserController.as
@@ -1,21 +1,18 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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.
-//
-////////////////////////////////////////////////////////////////////////////////
+/*
+ * Copyright 2010 Swiz Framework Contributors
+ *
+ * Licensed 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. 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.
+ */
package crux.quickstart.controller
{
import crux.quickstart.model.User;
diff --git a/examples/crux/CruxQuickStart/src/main/royale/crux/quickstart/event/UserEvent.as b/examples/crux/CruxQuickStart/src/main/royale/crux/quickstart/event/UserEvent.as
index 301624a..52d3c13 100644
--- a/examples/crux/CruxQuickStart/src/main/royale/crux/quickstart/event/UserEvent.as
+++ b/examples/crux/CruxQuickStart/src/main/royale/crux/quickstart/event/UserEvent.as
@@ -1,21 +1,18 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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.
-//
-////////////////////////////////////////////////////////////////////////////////
+/*
+ * Copyright 2010 Swiz Framework Contributors
+ *
+ * Licensed 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. 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.
+ */
package crux.quickstart.event
{
import crux.quickstart.model.User;
diff --git a/examples/crux/CruxQuickStart/src/main/royale/crux/quickstart/model/User.as b/examples/crux/CruxQuickStart/src/main/royale/crux/quickstart/model/User.as
index 778eab2..9533870 100644
--- a/examples/crux/CruxQuickStart/src/main/royale/crux/quickstart/model/User.as
+++ b/examples/crux/CruxQuickStart/src/main/royale/crux/quickstart/model/User.as
@@ -1,21 +1,18 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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.
-//
-////////////////////////////////////////////////////////////////////////////////
+/*
+ * Copyright 2010 Swiz Framework Contributors
+ *
+ * Licensed 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. 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.
+ */
package crux.quickstart.model
{
diff --git a/examples/crux/CruxQuickStart/src/main/royale/crux/quickstart/service/UserService.as b/examples/crux/CruxQuickStart/src/main/royale/crux/quickstart/service/UserService.as
index e437963..259a00b 100644
--- a/examples/crux/CruxQuickStart/src/main/royale/crux/quickstart/service/UserService.as
+++ b/examples/crux/CruxQuickStart/src/main/royale/crux/quickstart/service/UserService.as
@@ -1,21 +1,18 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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.
-//
-////////////////////////////////////////////////////////////////////////////////
+/*
+ * Copyright 2010 Swiz Framework Contributors
+ *
+ * Licensed 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. 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.
+ */
package crux.quickstart.service
{
import crux.quickstart.model.User;
diff --git a/examples/crux/CruxQuickStart/src/main/royale/crux/quickstart/view/UserForm.mxml b/examples/crux/CruxQuickStart/src/main/royale/crux/quickstart/view/UserForm.mxml
index b322d21..0ac7de7 100644
--- a/examples/crux/CruxQuickStart/src/main/royale/crux/quickstart/view/UserForm.mxml
+++ b/examples/crux/CruxQuickStart/src/main/royale/crux/quickstart/view/UserForm.mxml
@@ -1,21 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
-
-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.
-
+/*
+ * Copyright 2010 Swiz Framework Contributors
+ *
+ * Licensed 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. 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.
+ */
+// Apache Royale Crux example based on https://github.com/swiz/swiz-examples/tree/master/SwizQuickStartExample-Flex4
-->
<j:GridCell xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:j="library://ns.apache.org/royale/jewel"
diff --git a/examples/crux/CruxQuickStartBasic/src/main/royale/crux/quickstart/config/ActionscriptBeans.as b/examples/crux/CruxQuickStartBasic/src/main/royale/crux/quickstart/config/ActionscriptBeans.as
index 76cff3e..fc367e6 100644
--- a/examples/crux/CruxQuickStartBasic/src/main/royale/crux/quickstart/config/ActionscriptBeans.as
+++ b/examples/crux/CruxQuickStartBasic/src/main/royale/crux/quickstart/config/ActionscriptBeans.as
@@ -1,21 +1,19 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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.
-//
-////////////////////////////////////////////////////////////////////////////////
+/*
+ * Copyright 2010 Swiz Framework Contributors
+ *
+ * Licensed 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. 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.
+ */
+// Apache Royale Crux example based on https://github.com/swiz/swiz-examples/tree/master/SwizQuickStartExample-Flex4
package crux.quickstart.config {
import crux.quickstart.service.*
import crux.quickstart.controller.*
diff --git a/examples/crux/CruxQuickStartBasic/src/main/royale/crux/quickstart/config/Beans.mxml b/examples/crux/CruxQuickStartBasic/src/main/royale/crux/quickstart/config/Beans.mxml
index 854c72e..f5f262e 100644
--- a/examples/crux/CruxQuickStartBasic/src/main/royale/crux/quickstart/config/Beans.mxml
+++ b/examples/crux/CruxQuickStartBasic/src/main/royale/crux/quickstart/config/Beans.mxml
@@ -1,20 +1,20 @@
<!--
-
- 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.
-
+/*
+ * Copyright 2010 Swiz Framework Contributors
+ *
+ * Licensed 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. 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.
+ */
+// Apache Royale Crux example based on https://github.com/swiz/swiz-examples/tree/master/SwizQuickStartExample-Flex4
-->
<crux:BeanProvider
xmlns:fx="http://ns.adobe.com/mxml/2009"
diff --git a/examples/crux/CruxQuickStartBasic/src/main/royale/crux/quickstart/controller/UserController.as b/examples/crux/CruxQuickStartBasic/src/main/royale/crux/quickstart/controller/UserController.as
index d867061..44a02ee 100644
--- a/examples/crux/CruxQuickStartBasic/src/main/royale/crux/quickstart/controller/UserController.as
+++ b/examples/crux/CruxQuickStartBasic/src/main/royale/crux/quickstart/controller/UserController.as
@@ -1,21 +1,19 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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.
-//
-////////////////////////////////////////////////////////////////////////////////
+/*
+ * Copyright 2010 Swiz Framework Contributors
+ *
+ * Licensed 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. 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.
+ */
+// Apache Royale Crux example based on https://github.com/swiz/swiz-examples/tree/master/SwizQuickStartExample-Flex4
package crux.quickstart.controller
{
import crux.quickstart.model.User;
diff --git a/examples/crux/CruxQuickStartBasic/src/main/royale/crux/quickstart/event/UserEvent.as b/examples/crux/CruxQuickStartBasic/src/main/royale/crux/quickstart/event/UserEvent.as
index 301624a..907a18d 100644
--- a/examples/crux/CruxQuickStartBasic/src/main/royale/crux/quickstart/event/UserEvent.as
+++ b/examples/crux/CruxQuickStartBasic/src/main/royale/crux/quickstart/event/UserEvent.as
@@ -1,21 +1,19 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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.
-//
-////////////////////////////////////////////////////////////////////////////////
+/*
+ * Copyright 2010 Swiz Framework Contributors
+ *
+ * Licensed 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. 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.
+ */
+// Apache Royale Crux example based on https://github.com/swiz/swiz-examples/tree/master/SwizQuickStartExample-Flex4
package crux.quickstart.event
{
import crux.quickstart.model.User;
diff --git a/examples/crux/CruxQuickStartBasic/src/main/royale/crux/quickstart/model/User.as b/examples/crux/CruxQuickStartBasic/src/main/royale/crux/quickstart/model/User.as
index 1c3383e..a373ea8 100644
--- a/examples/crux/CruxQuickStartBasic/src/main/royale/crux/quickstart/model/User.as
+++ b/examples/crux/CruxQuickStartBasic/src/main/royale/crux/quickstart/model/User.as
@@ -1,21 +1,19 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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.
-//
-////////////////////////////////////////////////////////////////////////////////
+/*
+ * Copyright 2010 Swiz Framework Contributors
+ *
+ * Licensed 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. 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.
+ */
+// Apache Royale Crux example based on https://github.com/swiz/swiz-examples/tree/master/SwizQuickStartExample-Flex4
package crux.quickstart.model
{
diff --git a/examples/crux/CruxQuickStartBasic/src/main/royale/crux/quickstart/service/UserService.as b/examples/crux/CruxQuickStartBasic/src/main/royale/crux/quickstart/service/UserService.as
index 7aa59c9..cec9c8a 100644
--- a/examples/crux/CruxQuickStartBasic/src/main/royale/crux/quickstart/service/UserService.as
+++ b/examples/crux/CruxQuickStartBasic/src/main/royale/crux/quickstart/service/UserService.as
@@ -1,21 +1,19 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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.
-//
-////////////////////////////////////////////////////////////////////////////////
+/*
+ * Copyright 2010 Swiz Framework Contributors
+ *
+ * Licensed 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. 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.
+ */
+// Apache Royale Crux example based on https://github.com/swiz/swiz-examples/tree/master/SwizQuickStartExample-Flex4
package crux.quickstart.service
{
import crux.quickstart.model.User;
diff --git a/examples/crux/CruxQuickStartBasic/src/main/royale/crux/quickstart/view/UserForm.mxml b/examples/crux/CruxQuickStartBasic/src/main/royale/crux/quickstart/view/UserForm.mxml
index 9795bd5..1fe536d 100644
--- a/examples/crux/CruxQuickStartBasic/src/main/royale/crux/quickstart/view/UserForm.mxml
+++ b/examples/crux/CruxQuickStartBasic/src/main/royale/crux/quickstart/view/UserForm.mxml
@@ -1,21 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
-
-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.
-
+/*
+ * Copyright 2010 Swiz Framework Contributors
+ *
+ * Licensed 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. 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.
+ */
+// Apache Royale Crux example based on https://github.com/swiz/swiz-examples/tree/master/SwizQuickStartExample-Flex4
-->
<js:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:js="library://ns.apache.org/royale/basic"
[royale-asjs] 05/05: remove warnings for instanceof operator,
and also fixed illogical comparison to undefined for typeof.
Posted by gr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gregdove pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
commit a4d34bbf4c28312e67d9673c63ba18fe59203bdd
Author: greg-dove <gr...@gmail.com>
AuthorDate: Fri Nov 1 16:19:10 2019 +1300
remove warnings for instanceof operator, and also fixed illogical comparison to undefined for typeof.
---
frameworks/projects/MXRoyale/pom.xml | 13 ++++++++++++-
.../MXRoyale/src/main/royale/mx/net/SharedObject.as | 2 +-
.../MXRoyale/src/main/royale/mx/net/SharedObjectJSON.as | 2 +-
3 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/frameworks/projects/MXRoyale/pom.xml b/frameworks/projects/MXRoyale/pom.xml
index c704e7f..011f565 100644
--- a/frameworks/projects/MXRoyale/pom.xml
+++ b/frameworks/projects/MXRoyale/pom.xml
@@ -73,7 +73,18 @@
</define>
</defines>
<allowSubclassOverrides>true</allowSubclassOverrides>
- <additionalCompilerOptions>${project.compiler.options};-js-compiler-define=COMPILE::JS,true;-js-compiler-define=COMPILE::SWF,false;-js-compiler-define=GOOG::DEBUG,goog.DEBUG;-js-compiler-define=ROYALE::DISPLAYOBJECT,IUIComponent;-js-compiler-define=ROYALE::PROXYVISIBILITY,public;-namespace+=http://ns.adobe.com/mxml/2009,${project.basedir}/../../mxml-2009-manifest.xml;-compiler.js-namespaces.namespace+=http://ns.adobe.com/mxml/2009,${project.basedir}/../../mxml-2009-manifest.xml [...]
+ <additionalCompilerOptions>
+ ${project.compiler.options};
+ -js-compiler-define=COMPILE::JS,true;
+ -js-compiler-define=COMPILE::SWF,false;
+ -js-compiler-define=GOOG::DEBUG,goog.DEBUG;
+ -js-compiler-define=ROYALE::DISPLAYOBJECT,IUIComponent;
+ -js-compiler-define=ROYALE::PROXYVISIBILITY,public;
+ -namespace+=http://ns.adobe.com/mxml/2009,${project.basedir}/../../mxml-2009-manifest.xml;
+ -compiler.js-namespaces.namespace+=http://ns.adobe.com/mxml/2009,${project.basedir}/../../mxml-2009-manifest.xml;
+ -compiler.js-namespaces.namespace+=library://ns.apache.org/royale/mx,${project.basedir}/src/main/resources/mx-royale-manifest.xml;
+ -compiler.warn-instance-of-changes=false;
+ </additionalCompilerOptions>
</configuration>
</plugin>
</plugins>
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/net/SharedObject.as b/frameworks/projects/MXRoyale/src/main/royale/mx/net/SharedObject.as
index 4630fe0..5bb4569 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/net/SharedObject.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/net/SharedObject.as
@@ -147,7 +147,7 @@ package mx.net
}
COMPILE::JS{
_ls = window.localStorage;
- if (!_ls && typeof Storage != undefined) {
+ if (!_ls && typeof Storage != "undefined") {
//this gets around an issue with local testing with file:// protocol in IE11
var p:String = window.location.pathname.replace(/(^..)(:)/, "$1$$");
window.location.href = window.location.protocol + "//127.0.0.1" + p;
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/net/SharedObjectJSON.as b/frameworks/projects/MXRoyale/src/main/royale/mx/net/SharedObjectJSON.as
index e1c9e68..474f68c 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/net/SharedObjectJSON.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/net/SharedObjectJSON.as
@@ -159,7 +159,7 @@ package mx.net
}
COMPILE::JS{
_ls = window.localStorage;
- if (!_ls && typeof Storage != undefined) {
+ if (!_ls && typeof Storage != "undefined") {
//this gets around an issue with local testing with file:// protocol in IE11
var p:String = window.location.pathname.replace(/(^..)(:)/, "$1$$");
window.location.href = window.location.protocol + "//127.0.0.1" + p;
[royale-asjs] 03/05: SharedObject emulation for JS that is closer
to swf (i.e. uses AMF),
plus a lighter-weight version that uses JSON serialization only (does not
support roundtripping of custom classes)
Posted by gr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gregdove pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
commit e6bc56822b6edafd79aabf8cdefde707de9ca74a
Author: greg-dove <gr...@gmail.com>
AuthorDate: Fri Nov 1 14:21:45 2019 +1300
SharedObject emulation for JS that is closer to swf (i.e. uses AMF), plus a lighter-weight version that uses JSON serialization only (does not support roundtripping of custom classes)
---
.../MXRoyale/src/main/royale/MXRoyaleClasses.as | 1 +
.../src/main/royale/mx/net/SharedObject.as | 251 ++++++++++++---------
.../src/main/royale/mx/net/SharedObjectJSON.as | 183 +++++++++++++++
.../main/royale/flexUnitTests/MXRoyaleTester.as | 4 +-
.../flexUnitTests/mxroyale/SharedObjectTest.as | 130 +++++++++++
5 files changed, 461 insertions(+), 108 deletions(-)
diff --git a/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as b/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as
index 625bb27..2dc9f9b 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as
@@ -174,6 +174,7 @@ internal class MXRoyaleClasses
import mx.formatters.CurrencyFormatter; CurrencyFormatter;
import mx.events.CalendarLayoutChangeEvent; CalendarLayoutChangeEvent;
import mx.net.SharedObject; SharedObject;
+ import mx.net.SharedObjectJSON; SharedObjectJSON;
import mx.modules.ModuleManager; ModuleManager;
import mx.events.DragEvent; DragEvent;
import mx.formatters.DateBase; DateBase;
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/net/SharedObject.as b/frameworks/projects/MXRoyale/src/main/royale/mx/net/SharedObject.as
index 14df1fd..4630fe0 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/net/SharedObject.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/net/SharedObject.as
@@ -19,59 +19,69 @@
package mx.net
{
-
-COMPILE::SWF
-{
- import flash.net.SharedObject;
-}
-
-import org.apache.royale.events.EventDispatcher;
-import org.apache.royale.utils.string.trim;
-
-
-
-public class SharedObject extends org.apache.royale.events.EventDispatcher
-{
- public static function getLocal(name:String, localPath:String = null, secure:Boolean = false):mx.net.SharedObject
- {
- var so:mx.net.SharedObject = new mx.net.SharedObject();
- so.setName(name);
- so.setLocalPath(localPath);
- COMPILE::SWF
- {
- so.createSO();
- }
- return so;
- }
COMPILE::SWF
- private var _so:flash.net.SharedObject;
-
- public function flush(minDiskSpace:int = 0):String
- {
- COMPILE::JS
+ {
+ import flash.net.SharedObject;
+ }
+
+ COMPILE::JS{
+ import org.apache.royale.net.remoting.amf.AMFBinaryData;
+ }
+
+ import org.apache.royale.events.EventDispatcher;
+
+ /**
+ * An emulation class to support the swf based Local SharedObject support.
+ * This implementation supports AMF encoded content (requires registerClassAlias before reading and writing to roundtrip instances of custom classes)
+ */
+ public class SharedObject extends org.apache.royale.events.EventDispatcher
+ {
+ private static const map:Object = {};
+ private static var unlocked:Boolean;
+
+ public static function getLocal(name:String, localPath:String = null, secure:Boolean = false):mx.net.SharedObject
+ {
+ var pathKey:String = localPath == null ? '$null$' : localPath;
+ COMPILE::JS {
+ localPath = pathKey;
+ }
+ var cached:mx.net.SharedObject = map[pathKey + '::' + name];
+ if (!cached)
+ {
+ unlocked = true;
+ cached = new mx.net.SharedObject();
+ unlocked = false;
+ map[pathKey + '::' + name] = cached;
+ cached.setName(name);
+ cached.setLocalPath(localPath);
+ cached.createSO(secure);
+ }
+ return cached;
+ }
+
+ public function SharedObject()
+ {
+ if (!unlocked) throw new Error('ArgumentError: Error #2012: SharedObject class cannot be instantiated.')
+ }
+
+ COMPILE::SWF
+ private var _so:flash.net.SharedObject;
+
+ COMPILE::JS
+ private var _ls:Storage;
+
+
+ public function flush(minDiskSpace:int = 0):String
+ {
+ COMPILE::JS
{
if (_data)
{
- var theseKeys:Object = {};
- for (var p:String in _data)
- {
- document.cookie = _name + p + '=' + _data[p];
- theseKeys[p] = 1;
- }
- var deleteKeys:Array = [];
- for (p in keys)
- {
- if (!theseKeys[p])
- {
- deleteKeys.push(p);
- }
- }
- for each (p in deleteKeys)
- {
- delete keys[p];
- document.cookie = _name + p + '=; expires=Thu, 01 Jan 1970 00:00:00 GMT';
- }
+ var amf:AMFBinaryData = new AMFBinaryData();
+ amf.writeObject(_data);
+ var base64:String = window['btoa'](String.fromCharCode.apply(null, amf.array));
+ _ls.setItem(_localPath + "::" + _name, base64);
}
return SharedObjectFlushStatus.FLUSHED;
}
@@ -79,62 +89,91 @@ public class SharedObject extends org.apache.royale.events.EventDispatcher
{
return _so.flush(minDiskSpace);
}
- }
-
- private var keys:Object = {};
-
- private var _data:Object;
-
- public function get data():Object
- {
- COMPILE::SWF
- {
- return _so.data;
- }
- COMPILE::JS
- {
- if (!_data)
- {
- _data = {};
- var allCookies:String = String(document.cookie);
- var arrCookies:Array = allCookies.split(';');
- for each (var s:String in arrCookies)
- {
- s = trim(s);
- var parts:Array = s.split('=');
- if (parts[0].indexOf(_name) == 0)
- {
- var key:String = parts[0].substring(_name.length);
- keys[key] = 1;
- _data[key] = parts[1];
- }
- }
- }
- return _data;
- }
- }
-
- private var _name:String;
-
- public function setName(name:String):void
- {
- _name = name;
- }
-
- private var _localPath:String;
-
- public function setLocalPath(localPath:String):void
- {
- _localPath = localPath;
- }
-
- COMPILE::SWF
- public function createSO():void
- {
- _so = flash.net.SharedObject.getLocal(_name, _localPath);
- }
- }
-
-
-
+ }
+
+ public function clear():void{
+ COMPILE::SWF{
+ _so.clear();
+ }
+ COMPILE::JS{
+ if (_data) {
+ if (_ls) {
+ _ls.removeItem(_localPath + "::" + _name);
+ }
+ _data = null;
+ }
+ }
+ }
+
+ COMPILE::JS
+ private var _data:Object;
+
+ public function get data():Object
+ {
+ COMPILE::SWF
+ {
+ return _so.data;
+ }
+ COMPILE::JS
+ {
+ if (!_data)
+ {
+ _data = {};
+ }
+ return _data;
+ }
+ }
+
+ private var _name:String;
+ private function setName(name:String):void
+ {
+ COMPILE::JS{
+ //apply same limits as swf
+ if (/[~%&\\;:"',<>?#\s]/.test(name)) throw new Error('Error #2134: Cannot create SharedObject.')
+ }
+ _name = name;
+ }
+
+ private var _localPath:String;
+ private function setLocalPath(localPath:String):void
+ {
+ _localPath = localPath;
+ }
+
+ private function createSO(secure:Boolean):void
+ {
+ COMPILE::SWF{
+ _so = flash.net.SharedObject.getLocal(_name, _localPath, secure);
+ }
+ COMPILE::JS{
+ _ls = window.localStorage;
+ if (!_ls && typeof Storage != undefined) {
+ //this gets around an issue with local testing with file:// protocol in IE11
+ var p:String = window.location.pathname.replace(/(^..)(:)/, "$1$$");
+ window.location.href = window.location.protocol + "//127.0.0.1" + p;
+ _ls = window.localStorage;
+ }
+ if (!_ls) {
+ throw new Error('local storage not supported');
+ }
+ var base64:String = _ls.getItem(_localPath + "::" + _name);
+ if (base64)
+ {
+ var binary_string:String = window['atob'](base64);
+ var arr:Uint8Array = new Uint8Array(
+ binary_string.split('')
+ .map(
+ function (charStr:String):uint
+ {
+ return charStr.charCodeAt(0);
+ }
+ )
+ );
+ var amf:AMFBinaryData = new AMFBinaryData(arr.buffer);
+ _data = amf.readObject();
+ }
+ }
+ }
+ }
+
}
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/net/SharedObjectJSON.as b/frameworks/projects/MXRoyale/src/main/royale/mx/net/SharedObjectJSON.as
new file mode 100644
index 0000000..e1c9e68
--- /dev/null
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/net/SharedObjectJSON.as
@@ -0,0 +1,183 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package mx.net
+{
+
+ COMPILE::SWF
+ {
+ import flash.net.SharedObject;
+ }
+
+ import org.apache.royale.events.EventDispatcher;
+
+ /**
+ * An lighter weight emulation class to support the swf based Local SharedObject support.
+ * This implementation does not support AMF encoded content. It is intended for javascript
+ * implementations that require persistence, but do not already have the AMF support dependency as part of the application
+ */
+ public class SharedObjectJSON extends org.apache.royale.events.EventDispatcher
+ {
+ private static const map:Object = {};
+ private static var unlocked:Boolean;
+
+ public static function getLocal(name:String, localPath:String = null, secure:Boolean = false):mx.net.SharedObjectJSON
+ {
+ var pathKey:String = localPath == null ? '$null$' : localPath;
+ COMPILE::JS {
+ localPath = pathKey;
+ }
+ var cached:mx.net.SharedObjectJSON = map[pathKey + '::' + name];
+ if (!cached)
+ {
+ unlocked = true;
+ cached = new mx.net.SharedObjectJSON();
+ unlocked = false;
+ map[pathKey + '::' + name] = cached;
+ cached.setName(name);
+ cached.setLocalPath(localPath);
+ cached.createSO(secure);
+ }
+ return cached;
+ }
+
+ public function SharedObjectJSON()
+ {
+ if (!unlocked) throw new Error('ArgumentError: Error #2012: SharedObjectJSON class cannot be instantiated.')
+ }
+
+ COMPILE::SWF
+ private var _so:flash.net.SharedObject;
+
+ COMPILE::JS
+ private var _ls:Storage;
+
+
+ public function flush(minDiskSpace:int = 0):String
+ {
+ COMPILE::JS
+ {
+ if (_data)
+ {
+ _ls.setItem(_localPath + "::" + _name, JSON.stringify(_data));
+ }
+ return SharedObjectFlushStatus.FLUSHED;
+ }
+ COMPILE::SWF
+ {
+ if (_data) {
+ _so.data['jsonContent'] = JSON.stringify(_data);
+ }
+ return _so.flush(minDiskSpace);
+ }
+ }
+
+ public function clear():void{
+ COMPILE::SWF{
+ _so.data['jsonContent'] = '{}';
+ _so.flush();
+ _data = {};
+ }
+ COMPILE::JS{
+ if (_data) {
+ if (_ls) {
+ _ls.removeItem(_localPath + "::" + _name);
+ }
+ _data = null;
+ }
+ }
+ }
+
+
+ private var _data:Object;
+
+ public function get data():Object
+ {
+ COMPILE::SWF
+ {
+ if (!_data) {
+ if (_so.data['jsonContent']) {
+ try{
+ _data = JSON.parse(_so.data['jsonContent']);
+ } catch(e:Error) {
+ throw new Error('Error #2134: Bad data. Cannot create SharedObjectJSON.')
+ }
+ } else _data = {};
+ }
+ return _data;
+ }
+ COMPILE::JS
+ {
+ if (!_data)
+ {
+ _data = {};
+ }
+ return _data;
+ }
+ }
+
+ private var _name:String;
+ private function setName(name:String):void
+ {
+ COMPILE::JS{
+ //apply same limits as swf
+ if (/[~%&\\;:"',<>?#\s]/.test(name)) throw new Error('Error #2134: Cannot create SharedObjectJSON.')
+ }
+ _name = name;
+ }
+
+ private var _localPath:String;
+ private function setLocalPath(localPath:String):void
+ {
+ COMPILE::JS{
+ localPath+='$jsonContent$';
+ }
+ _localPath = localPath;
+ }
+
+ private function createSO(secure:Boolean):void
+ {
+ COMPILE::SWF{
+ _so = flash.net.SharedObject.getLocal(_name, _localPath, secure);
+
+ }
+ COMPILE::JS{
+ _ls = window.localStorage;
+ if (!_ls && typeof Storage != undefined) {
+ //this gets around an issue with local testing with file:// protocol in IE11
+ var p:String = window.location.pathname.replace(/(^..)(:)/, "$1$$");
+ window.location.href = window.location.protocol + "//127.0.0.1" + p;
+ _ls = window.localStorage;
+ }
+ if (!_ls) {
+ throw new Error('local storage not supported');
+ }
+ var json:String = _ls.getItem(_localPath + "::" + _name);
+ if (json) {
+ try{
+ _data = JSON.parse(json);
+ } catch(e:Error) {
+ throw new Error('Error #2134: Bad data. Cannot create SharedObjectJSON.')
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/MXRoyaleTester.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/MXRoyaleTester.as
index 08edb08..f0c93c8 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/MXRoyaleTester.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/MXRoyaleTester.as
@@ -30,8 +30,8 @@ package flexUnitTests
public function MXRoyaleTester()
{
}
-
-
+
+ public var sharedObjectTest:SharedObjectTest;
public var objectUtilTest:ObjectUtilTest;
public var flexSDK_ObjectUtilTests:FlexSDK_ObjectUtil_Tests;
public var flexSDK_ObjectUtil_FLEX_34852_Tests:FlexSDK_ObjectUtil_FLEX_34852_Tests;
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/mxroyale/SharedObjectTest.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/mxroyale/SharedObjectTest.as
new file mode 100644
index 0000000..49232ae
--- /dev/null
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/mxroyale/SharedObjectTest.as
@@ -0,0 +1,130 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.
+//
+////////////////////////////////////////////////////////////////////////////////
+package flexUnitTests.mxroyale
+{
+
+
+ import mx.net.SharedObject;
+ import mx.net.SharedObjectJSON;
+ import org.apache.royale.reflection.registerClassAlias;
+ import org.apache.royale.test.asserts.*;
+ import flexUnitTests.mxroyale.support.*;
+ import testshim.RoyaleUnitTestRunner;
+
+
+
+ /**
+ * @royalesuppresspublicvarwarning
+ */
+ public class SharedObjectTest
+ {
+
+
+ public static var isJS:Boolean = COMPILE::JS;
+
+
+ [Before]
+ public function setUp():void
+ {
+ registerClassAlias('TestClass5', TestClass5);
+ }
+
+ [After]
+ public function tearDown():void
+ {
+
+ }
+
+ [BeforeClass]
+ public static function setUpBeforeClass():void
+ {
+ }
+
+ [AfterClass]
+ public static function tearDownAfterClass():void
+ {
+ }
+
+ public function getPlayerVersion():Number{
+ COMPILE::SWF{
+ import flash.system.Capabilities;
+ var parts:Array = Capabilities.version.split(' ')[1].split(',');
+ return Number( parts[0]+'.'+parts[1])
+ }
+ //something for js, indicating javascript 'playerversion' is consistent with more recent flash player versions:
+ return 30;
+ }
+
+
+ [Test]
+ public function testSharedObjectSimple():void{
+ var so:SharedObject = SharedObject.getLocal('myDynamicTest');
+ var content:Object = so.data;
+
+ var so2:SharedObject = SharedObject.getLocal('myDynamicTest');
+
+ var content2:Object = so2.data;
+
+ assertEquals(so,so2, 'unexpected non equivalency');
+ assertEquals(content,content2, 'unexpected non equivalency');
+
+ //content should either be empty or the last saved.
+ var validContents:Array = [ '{"test":{"name":"an Object"}}', '{}'];
+ assertTrue(validContents.indexOf(JSON.stringify(content)) != -1, 'contents not considered valid');
+ so.data['test'] = {'name':'an Object'};
+ so.flush();
+ }
+
+ [Test]
+ public function testSharedObjectAMF():void{
+ var so:SharedObject = SharedObject.getLocal('myTypedTest');
+
+ //this will work first when saving, and subsequently when retrieving
+ var object:Object = so.data['testClass'];
+ RoyaleUnitTestRunner.consoleOut('testSharedObjectAMF found TestClass5 instance? '+(object is TestClass5));
+ if (object == null) {
+ so.data['testClass'] = new TestClass5();
+ so.flush();
+ object = so.data['testClass']
+ }
+
+ assertTrue(object is TestClass5, 'contents not considered valid');
+ }
+
+
+ [Test]
+ public function testSharedObjectJSONSimple():void{
+ var so:SharedObjectJSON = SharedObjectJSON.getLocal('myJSONTest');
+ var content:Object = so.data;
+
+ var so2:SharedObjectJSON = SharedObjectJSON.getLocal('myJSONTest');
+
+ var content2:Object = so2.data;
+
+ assertEquals(so,so2, 'unexpected non equivalency');
+ assertEquals(content,content2, 'unexpected non equivalency');
+ RoyaleUnitTestRunner.consoleOut('testSharedObjectJSONSimple content is '+JSON.stringify(content));
+ //content should either be empty or the last saved.
+ var validContents:Array = [ '{"test":{"name":"an Object"}}', '{}'];
+ assertTrue(validContents.indexOf(JSON.stringify(content)) != -1, 'contents not considered valid');
+ so.data['test'] = {'name':'an Object'};
+ so.flush();
+ }
+ }
+}